Skip to content

Commit f74360f

Browse files
author
Josuah Demangeon
committed
remove the braces in case: {}
now that the variables are defined at top scope, no more need for double-scope in switch case statements
1 parent a3ade9f commit f74360f

File tree

1 file changed

+22
-36
lines changed

1 file changed

+22
-36
lines changed

drivers/usb/uhc/uhc_dwc2.c

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ void dwc2_hal_flush_rx_fifo(struct usb_dwc2_reg *const dwc2)
318318
{
319319
sys_write32(USB_DWC2_GRSTCTL_RXFFLSH, (mem_addr_t)&dwc2->grstctl);
320320
while (sys_read32((mem_addr_t)&dwc2->grstctl) & USB_DWC2_GRSTCTL_RXFFLSH) {
321+
continue;
321322
}
322323
}
323324

@@ -329,6 +330,7 @@ void dwc2_hal_flush_tx_fifo(struct usb_dwc2_reg *const dwc2, const uint8_t fnum)
329330

330331
sys_write32(grstctl, (mem_addr_t)&dwc2->grstctl);
331332
while (sys_read32((mem_addr_t)&dwc2->grstctl) & USB_DWC2_GRSTCTL_TXFFLSH) {
333+
continue;
332334
}
333335
}
334336

@@ -688,24 +690,21 @@ static enum uhc_port_event uhc_dwc2_decode_hprt(const struct device *dev,
688690
enum uhc_port_event port_event = UHC_PORT_EVENT_NONE;
689691

690692
switch (core_event) {
691-
case UHC_DWC2_CORE_EVENT_CONN: {
693+
case UHC_DWC2_CORE_EVENT_CONN:
692694
port_event = UHC_PORT_EVENT_CONNECTION;
693695
break;
694-
}
695-
case UHC_DWC2_CORE_EVENT_DISCONN: {
696+
case UHC_DWC2_CORE_EVENT_DISCONN:
696697
/* TODO: priv->port_state = UHC_PORT_STATE_RECOVERY */
697698
port_event = UHC_PORT_EVENT_DISCONNECTION;
698699
priv->conn_dev_ena = 0;
699700
break;
700-
}
701-
case UHC_DWC2_CORE_EVENT_ENABLED: {
701+
case UHC_DWC2_CORE_EVENT_ENABLED:
702702
/* Initialize remaining host port registers */
703703
dwc2_port_enable(dev);
704704
port_event = UHC_PORT_EVENT_ENABLED;
705705
priv->conn_dev_ena = 1;
706706
break;
707-
}
708-
case UHC_DWC2_CORE_EVENT_DISABLED: {
707+
case UHC_DWC2_CORE_EVENT_DISABLED:
709708
priv->conn_dev_ena = 0;
710709
/* Could be due to a disable request or reset request, or due to a port error */
711710
/* Ignore the disable event if it's due to a reset request */
@@ -727,9 +726,8 @@ static enum uhc_port_event uhc_dwc2_decode_hprt(const struct device *dev,
727726
}
728727
}
729728
break;
730-
}
731729
case UHC_DWC2_CORE_EVENT_OVRCUR:
732-
case UHC_DWC2_CORE_EVENT_OVRCUR_CLR: {
730+
case UHC_DWC2_CORE_EVENT_OVRCUR_CLR:
733731
/* TODO: Handle overcurrent event */
734732

735733
/* If port state powered, we need to power it off to protect it
@@ -740,12 +738,10 @@ static enum uhc_port_event uhc_dwc2_decode_hprt(const struct device *dev,
740738

741739
LOG_ERR("Overcurrent detected on port, not implemented yet");
742740
break;
743-
}
744-
default: {
741+
default:
745742
__ASSERT(false, "Unexpected core event %d", core_event);
746743
break;
747744
}
748-
}
749745
return port_event;
750746
}
751747

@@ -957,15 +953,13 @@ static void IRAM_ATTR _buffer_fill(struct uhc_dwc2_chan *chan)
957953
/* TODO: Double buffering scheme? */
958954

959955
switch (chan->type) {
960-
case UHC_DWC2_XFER_TYPE_CTRL: {
956+
case UHC_DWC2_XFER_TYPE_CTRL:
961957
_buffer_fill_ctrl(chan, xfer);
962958
break;
963-
}
964-
default: {
959+
default:
965960
LOG_ERR("Unsupported transfer type %d", chan->type);
966961
break;
967962
}
968-
}
969963
/* TODO: sync CACHE */
970964
}
971965

@@ -1099,11 +1093,10 @@ static enum uhc_dwc2_chan_event uhc_dwc2_decode_chan(const struct device *dev,
10991093
LOG_DBG("Channel event: %d", chan_event);
11001094

11011095
switch (chan_event) {
1102-
case DWC2_CHAN_EVENT_NONE: {
1096+
case DWC2_CHAN_EVENT_NONE:
11031097
/* No event, nothing to do */
11041098
break;
1105-
}
1106-
case DWC2_CHAN_EVENT_CPLT: {
1099+
case DWC2_CHAN_EVENT_CPLT:
11071100
if (!_buffer_is_done(chan)) {
11081101
_buffer_exec_proceed(dev, chan);
11091102
break;
@@ -1112,13 +1105,11 @@ static enum uhc_dwc2_chan_event uhc_dwc2_decode_chan(const struct device *dev,
11121105
ret = chan->last_event;
11131106
_buffer_done(dev, chan, chan->last_event, false);
11141107
break;
1115-
}
1116-
case DWC2_CHAN_EVENT_ERROR: {
1108+
case DWC2_CHAN_EVENT_ERROR:
11171109
LOG_ERR("Channel error handling not implemented yet");
11181110
/* TODO: get channel error, halt the chan */
11191111
break;
1120-
}
1121-
case DWC2_CHAN_EVENT_HALT_REQ: {
1112+
case DWC2_CHAN_EVENT_HALT_REQ:
11221113
LOG_ERR("Channel halt request handling not implemented yet");
11231114

11241115
__ASSERT(chan->waiting_halt, "Pipe is not watiting to be halted");
@@ -1136,7 +1127,6 @@ static enum uhc_dwc2_chan_event uhc_dwc2_decode_chan(const struct device *dev,
11361127
* _internal_chan_event_notify(chan, true);
11371128
*/
11381129
break;
1139-
}
11401130
default:
11411131
/* Should never happen */
11421132
LOG_WRN("Unknown channel event %d", chan_event);
@@ -1278,7 +1268,7 @@ static inline enum uhc_port_event uhc_dwc2_get_port_event(const struct device *d
12781268
port_event = priv->last_event;
12791269

12801270
switch (port_event) {
1281-
case UHC_PORT_EVENT_CONNECTION: {
1271+
case UHC_PORT_EVENT_CONNECTION:
12821272
/* Don't update state immediately, we still need to debounce. */
12831273
if (uhc_dwc2_port_debounce(dev)) {
12841274
port_event = UHC_PORT_EVENT_CONNECTION;
@@ -1288,16 +1278,13 @@ static inline enum uhc_port_event uhc_dwc2_get_port_event(const struct device *d
12881278
LOG_WRN("Port debounce error handling is not implemented yet");
12891279
}
12901280
break;
1291-
}
12921281
case UHC_PORT_EVENT_DISCONNECTION:
12931282
case UHC_PORT_EVENT_ERROR:
1294-
case UHC_PORT_EVENT_OVERCURRENT: {
1283+
case UHC_PORT_EVENT_OVERCURRENT:
12951284
break;
1296-
}
1297-
default: {
1285+
default:
12981286
break;
12991287
}
1300-
}
13011288
} else {
13021289
port_event = UHC_PORT_EVENT_NONE;
13031290
}
@@ -1613,12 +1600,12 @@ static inline void uhc_dwc2_handle_port_events(const struct device *dev)
16131600
case UHC_PORT_EVENT_NONE:
16141601
/* No event, nothing to do */
16151602
break;
1616-
case UHC_PORT_EVENT_CONNECTION: {
1603+
1604+
case UHC_PORT_EVENT_CONNECTION:
16171605
uhc_dwc2_port_reset(dev);
16181606
break;
1619-
}
16201607

1621-
case UHC_PORT_EVENT_ENABLED: {
1608+
case UHC_PORT_EVENT_ENABLED:
16221609
/* TODO: enter critical section */
16231610
priv->port_state = UHC_PORT_STATE_ENABLED;
16241611
/* TODO: exit critical section */
@@ -1639,10 +1626,10 @@ static inline void uhc_dwc2_handle_port_events(const struct device *dev)
16391626
/* Notify the higher logic about the new device */
16401627
uhc_dwc2_submit_new_device(dev, port_speed);
16411628
break;
1642-
}
1629+
16431630
case UHC_PORT_EVENT_DISCONNECTION:
16441631
case UHC_PORT_EVENT_ERROR:
1645-
case UHC_PORT_EVENT_OVERCURRENT: {
1632+
case UHC_PORT_EVENT_OVERCURRENT:
16461633
port_has_device = false;
16471634

16481635
/* TODO: enter critical section */
@@ -1667,7 +1654,6 @@ static inline void uhc_dwc2_handle_port_events(const struct device *dev)
16671654
/* Recover the port */
16681655
uhc_dwc2_port_recovery(dev);
16691656
break;
1670-
}
16711657
default:
16721658
break;
16731659
}

0 commit comments

Comments
 (0)