@@ -120,7 +120,7 @@ struct uhc_dwc2_chan {
120120 uint32_t offset ;
121121 /* Type of endpoint */
122122 enum uhc_dwc2_xfer_type type ;
123- enum uhc_dwc2_chan_event event ;
123+ atomic_t event ;
124124 /* The index of the channel */
125125 uint8_t chan_idx ;
126126 /* Maximum Packet Size */
@@ -917,7 +917,7 @@ static void uhc_dwc2_isr_handler(const struct device *dev)
917917 if (chan_event == DWC2_CHAN_EVENT_CPLT && !uhc_dwc2_buffer_is_done (chan )) {
918918 uhc_dwc2_buffer_exec_proceed (dev , chan );
919919 } else {
920- chan -> event = chan_event ;
920+ atomic_set_bit ( & chan -> event , chan_event ) ;
921921 k_event_set (& priv -> event , BIT (UHC_DWC2_EVENT_CHAN0 + i - 1 ));
922922 }
923923 }
@@ -1311,10 +1311,11 @@ static inline void uhc_dwc2_handle_chan_events(const struct device *dev, struct
13111311 const struct uhc_dwc2_config * const config = dev -> config ;
13121312 struct usb_dwc2_reg * const dwc2 = config -> base ;
13131313 const struct usb_dwc2_host_chan * chan_regs = UHC_DWC2_CHAN_REG (dwc2 , chan -> chan_idx );
1314+ uint32_t events = atomic_clear (& chan -> event );
13141315
1315- LOG_DBG ("Channel event: 0x%08x" , chan -> event );
1316+ LOG_DBG ("Channel event: 0x%08x" , events );
13161317
1317- if (chan -> event == DWC2_CHAN_EVENT_CPLT ) {
1318+ if (events & BIT ( DWC2_CHAN_EVENT_CPLT ) ) {
13181319 /* XFER transfer is done, process the transfer and release the chan buffer */
13191320 struct uhc_transfer * const xfer = (struct uhc_transfer * )chan -> xfer ;
13201321
@@ -1336,12 +1337,12 @@ static inline void uhc_dwc2_handle_chan_events(const struct device *dev, struct
13361337 uhc_xfer_return (dev , xfer , 0 );
13371338 }
13381339
1339- if (chan -> event == DWC2_CHAN_EVENT_ERROR ) {
1340+ if (events & BIT ( DWC2_CHAN_EVENT_ERROR ) ) {
13401341 LOG_ERR ("Channel error handling not implemented yet" );
13411342 /* TODO: get channel error, halt the chan */
13421343 }
13431344
1344- if (chan -> event == DWC2_CHAN_EVENT_HALT_REQ ) {
1345+ if (events & BIT ( DWC2_CHAN_EVENT_HALT_REQ ) ) {
13451346 LOG_ERR ("Channel halt request handling not implemented yet" );
13461347
13471348 /* TODO: Implement halting the ongoing transfer */
0 commit comments