Skip to content

Commit d402d03

Browse files
finikorgnashif
authored andcommitted
usb: msc: Fix redeclaration of enumerators
Add prefixes to MSC enumerators, otherwise they are (ERROR) are conflicting with other enumerators. ... subsys/usb/class/mass_storage.c:149:2: error: redeclaration of enumerator ‘ERROR’ ERROR, /* error */ ^~~~~ ... ext/hal/st/stm32cube/stm32f4xx/soc/stm32f4xx.h:216:3: note: previous definition of ‘ERROR’ was here ERROR = 0U, ^~~~~ ... Signed-off-by: Andrei Emeltchenko <[email protected]>
1 parent 873ae0b commit d402d03

File tree

1 file changed

+38
-36
lines changed

1 file changed

+38
-36
lines changed

subsys/usb/class/mass_storage.c

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ enum Status {
145145

146146
/* MSC Bulk-only Stage */
147147
enum Stage {
148-
READ_CBW, /* wait a CBW */
149-
ERROR, /* error */
150-
PROCESS_CBW, /* process a CBW request */
151-
SEND_CSW, /* send a CSW */
152-
WAIT_CSW /* wait that a CSW has been effectively sent */
148+
MSC_READ_CBW, /* wait a CBW */
149+
MSC_ERROR, /* error */
150+
MSC_PROCESS_CBW, /* process a CBW request */
151+
MSC_SEND_CSW, /* send a CSW */
152+
MSC_WAIT_CSW /* wait that a CSW has been effectively sent */
153153
};
154154

155155
/* state of the bulk-only state machine */
@@ -174,7 +174,7 @@ static bool memOK;
174174

175175
static void msd_state_machine_reset(void)
176176
{
177-
stage = READ_CBW;
177+
stage = MSC_READ_CBW;
178178
}
179179

180180
static void msd_init(void)
@@ -193,7 +193,7 @@ static void sendCSW(void)
193193
sizeof(struct CSW), NULL) != 0) {
194194
LOG_ERR("usb write failure");
195195
}
196-
stage = WAIT_CSW;
196+
stage = MSC_WAIT_CSW;
197197
}
198198

199199
static bool write(u8_t *buf, u16_t size)
@@ -205,7 +205,7 @@ static bool write(u8_t *buf, u16_t size)
205205
/* updating the State Machine , so that we send CSW when this
206206
* transfer is complete, ie when we get a bulk in callback
207207
*/
208-
stage = SEND_CSW;
208+
stage = MSC_SEND_CSW;
209209

210210
if (usb_write(mass_ep_data[MSD_IN_EP_IDX].ep_addr, buf, size, NULL)) {
211211
LOG_ERR("USB write failed");
@@ -372,7 +372,7 @@ static void thread_memory_read_done(void)
372372
n = (length > MAX_PACKET) ? MAX_PACKET : length;
373373
if ((addr + n) > memory_size) {
374374
n = memory_size - addr;
375-
stage = ERROR;
375+
stage = MSC_ERROR;
376376
}
377377

378378
if (usb_write(mass_ep_data[MSD_IN_EP_IDX].ep_addr,
@@ -385,9 +385,10 @@ static void thread_memory_read_done(void)
385385

386386
csw.DataResidue -= n;
387387

388-
if (!length || (stage != PROCESS_CBW)) {
389-
csw.Status = (stage == PROCESS_CBW) ? CSW_PASSED : CSW_FAILED;
390-
stage = (stage == PROCESS_CBW) ? SEND_CSW : stage;
388+
if (!length || (stage != MSC_PROCESS_CBW)) {
389+
csw.Status = (stage == MSC_PROCESS_CBW) ?
390+
CSW_PASSED : CSW_FAILED;
391+
stage = (stage == MSC_PROCESS_CBW) ? MSC_SEND_CSW : stage;
391392
}
392393
}
393394

@@ -399,7 +400,7 @@ static void memoryRead(void)
399400
n = (length > MAX_PACKET) ? MAX_PACKET : length;
400401
if ((addr + n) > memory_size) {
401402
n = memory_size - addr;
402-
stage = ERROR;
403+
stage = MSC_ERROR;
403404
}
404405

405406
/* we read an entire block */
@@ -416,9 +417,10 @@ static void memoryRead(void)
416417

417418
csw.DataResidue -= n;
418419

419-
if (!length || (stage != PROCESS_CBW)) {
420-
csw.Status = (stage == PROCESS_CBW) ? CSW_PASSED : CSW_FAILED;
421-
stage = (stage == PROCESS_CBW) ? SEND_CSW : stage;
420+
if (!length || (stage != MSC_PROCESS_CBW)) {
421+
csw.Status = (stage == MSC_PROCESS_CBW) ?
422+
CSW_PASSED : CSW_FAILED;
423+
stage = (stage == MSC_PROCESS_CBW) ? MSC_SEND_CSW : stage;
422424
}
423425
}
424426

@@ -531,7 +533,7 @@ static void CBWDecode(u8_t *buf, u16_t size)
531533
LOG_DBG(">> READ");
532534
if (infoTransfer()) {
533535
if ((cbw.Flags & 0x80)) {
534-
stage = PROCESS_CBW;
536+
stage = MSC_PROCESS_CBW;
535537
memoryRead();
536538
} else {
537539
usb_ep_set_stall(
@@ -547,7 +549,7 @@ static void CBWDecode(u8_t *buf, u16_t size)
547549
LOG_DBG(">> WRITE");
548550
if (infoTransfer()) {
549551
if (!(cbw.Flags & 0x80)) {
550-
stage = PROCESS_CBW;
552+
stage = MSC_PROCESS_CBW;
551553
} else {
552554
usb_ep_set_stall(
553555
mass_ep_data[MSD_IN_EP_IDX].ep_addr);
@@ -566,7 +568,7 @@ static void CBWDecode(u8_t *buf, u16_t size)
566568
}
567569
if (infoTransfer()) {
568570
if (!(cbw.Flags & 0x80)) {
569-
stage = PROCESS_CBW;
571+
stage = MSC_PROCESS_CBW;
570572
memOK = true;
571573
} else {
572574
usb_ep_set_stall(
@@ -597,7 +599,7 @@ static void memoryVerify(u8_t *buf, u16_t size)
597599

598600
if ((addr + size) > memory_size) {
599601
size = memory_size - addr;
600-
stage = ERROR;
602+
stage = MSC_ERROR;
601603
usb_ep_set_stall(mass_ep_data[MSD_OUT_EP_IDX].ep_addr);
602604
LOG_WRN("Stall OUT endpoint");
603605
}
@@ -624,8 +626,8 @@ static void memoryVerify(u8_t *buf, u16_t size)
624626
length -= size;
625627
csw.DataResidue -= size;
626628

627-
if (!length || (stage != PROCESS_CBW)) {
628-
csw.Status = (memOK && (stage == PROCESS_CBW)) ?
629+
if (!length || (stage != MSC_PROCESS_CBW)) {
630+
csw.Status = (memOK && (stage == MSC_PROCESS_CBW)) ?
629631
CSW_PASSED : CSW_FAILED;
630632
sendCSW();
631633
}
@@ -635,7 +637,7 @@ static void memoryWrite(u8_t *buf, u16_t size)
635637
{
636638
if ((addr + size) > memory_size) {
637639
size = memory_size - addr;
638-
stage = ERROR;
640+
stage = MSC_ERROR;
639641
usb_ep_set_stall(mass_ep_data[MSD_OUT_EP_IDX].ep_addr);
640642
LOG_WRN("Stall OUT endpoint");
641643
}
@@ -661,8 +663,8 @@ static void memoryWrite(u8_t *buf, u16_t size)
661663
length -= size;
662664
csw.DataResidue -= size;
663665

664-
if ((!length) || (stage != PROCESS_CBW)) {
665-
csw.Status = (stage == ERROR) ? CSW_FAILED : CSW_PASSED;
666+
if ((!length) || (stage != MSC_PROCESS_CBW)) {
667+
csw.Status = (stage == MSC_ERROR) ? CSW_FAILED : CSW_PASSED;
666668
sendCSW();
667669
}
668670
}
@@ -681,13 +683,13 @@ static void mass_storage_bulk_out(u8_t ep,
681683

682684
switch (stage) {
683685
/*the device has to decode the CBW received*/
684-
case READ_CBW:
685-
LOG_DBG("> BO - READ_CBW");
686+
case MSC_READ_CBW:
687+
LOG_DBG("> BO - MSC_READ_CBW");
686688
CBWDecode(bo_buf, bytes_read);
687689
break;
688690

689691
/*the device has to receive data from the host*/
690-
case PROCESS_CBW:
692+
case MSC_PROCESS_CBW:
691693
switch (cbw.CB[0]) {
692694
case WRITE10:
693695
case WRITE12:
@@ -730,8 +732,8 @@ static void thread_memory_write_done(void)
730732
csw.DataResidue -= size;
731733

732734

733-
if ((!length) || (stage != PROCESS_CBW)) {
734-
csw.Status = (stage == ERROR) ? CSW_FAILED : CSW_PASSED;
735+
if ((!length) || (stage != MSC_PROCESS_CBW)) {
736+
csw.Status = (stage == MSC_ERROR) ? CSW_FAILED : CSW_PASSED;
735737
sendCSW();
736738
}
737739

@@ -756,7 +758,7 @@ static void mass_storage_bulk_in(u8_t ep,
756758

757759
switch (stage) {
758760
/*the device has to send data to the host*/
759-
case PROCESS_CBW:
761+
case MSC_PROCESS_CBW:
760762
switch (cbw.CB[0]) {
761763
case READ10:
762764
case READ12:
@@ -770,15 +772,15 @@ static void mass_storage_bulk_in(u8_t ep,
770772
break;
771773

772774
/*the device has to send a CSW*/
773-
case SEND_CSW:
774-
LOG_DBG("< BI - SEND_CSW");
775+
case MSC_SEND_CSW:
776+
LOG_DBG("< BI - MSC_SEND_CSW");
775777
sendCSW();
776778
break;
777779

778780
/*the host has received the CSW -> we wait a CBW*/
779-
case WAIT_CSW:
780-
LOG_DBG("< BI - WAIT_CSW");
781-
stage = READ_CBW;
781+
case MSC_WAIT_CSW:
782+
LOG_DBG("< BI - MSC_WAIT_CSW");
783+
stage = MSC_READ_CBW;
782784
break;
783785

784786
/*an error has occurred*/

0 commit comments

Comments
 (0)