Skip to content

Commit 73bb30e

Browse files
author
Josuah Demangeon
committed
remove has_xfer
since channel allocation is not dynamic (k_malloc) anymore, no more need to check for pending transfers so no need to keep track of them and has_xfer can be removed. Signed-off-by: Josuah Demangeon <[email protected]>
1 parent 78c2cb8 commit 73bb30e

File tree

1 file changed

+1
-34
lines changed

1 file changed

+1
-34
lines changed

drivers/usb/uhc/uhc_dwc2.c

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@ struct uhc_dwc2_chan {
174174
uint8_t ls_via_fs_hub: 1;
175175
uint8_t waiting_halt: 1;
176176
uint8_t chan_cmd_processing: 1;
177-
/* XFER: pending, in-flight or done */
178-
uint8_t has_xfer: 1;
179177
/* Is channel enabled */
180178
uint8_t active: 1;
181179
/* Halt has been requested */
@@ -1510,31 +1508,12 @@ static inline int uhc_dwc2_chan_config(const struct device *dev, uint8_t chan_id
15101508
/*
15111509
* Free the chan and its resources.
15121510
*/
1513-
static inline int uhc_dwc2_chan_deinit(const struct device *dev, struct uhc_dwc2_chan *chan)
1511+
static void uhc_dwc2_chan_deinit(const struct device *dev, struct uhc_dwc2_chan *chan)
15141512
{
15151513
const struct uhc_dwc2_config *const config = dev->config;
15161514
struct usb_dwc2_reg *const dwc2 = config->base;
1517-
struct uhc_dwc2_data *priv = uhc_get_private(dev);
1518-
1519-
if (chan->num_xfer_pending && chan->has_xfer) {
1520-
LOG_ERR("Unable to free chan with pending XFERs");
1521-
return -EBUSY;
1522-
}
1523-
1524-
if (chan->type == UHC_DWC2_XFER_TYPE_INTR || chan->type == UHC_DWC2_XFER_TYPE_ISOCHRONOUS) {
1525-
/* TODO: Unschedule this channel */
1526-
LOG_WRN("Cannot free interrupt or isochronous channels yet");
1527-
}
1528-
1529-
__ASSERT(!chan->active, "Cannot free channel %d, it is still active", chan->chan_idx);
15301515

15311516
sys_clear_bits((mem_addr_t)&dwc2->haintmsk, (1 << chan->chan_idx));
1532-
1533-
LOG_DBG("Freeing channel %d", chan->chan_idx);
1534-
1535-
/* TODO: Remove the chan from the list of idle chans in the port object */
1536-
1537-
return 0;
15381517
}
15391518

15401519
static inline void uhc_dwc2_handle_port_events(const struct device *dev)
@@ -1612,7 +1591,6 @@ static inline void uhc_dwc2_handle_port_events(const struct device *dev)
16121591

16131592
static inline void uhc_dwc2_handle_chan_events(const struct device *dev, struct uhc_dwc2_chan *chan)
16141593
{
1615-
struct uhc_dwc2_data *priv = uhc_get_private(dev);
16161594
const struct uhc_dwc2_config *const config = dev->config;
16171595
struct usb_dwc2_reg *const dwc2 = config->base;
16181596
const struct usb_dwc2_host_chan *chan_regs = UHC_DWC2_CHAN_REG(dwc2, chan->chan_idx);
@@ -1638,9 +1616,6 @@ static inline void uhc_dwc2_handle_chan_events(const struct device *dev, struct
16381616
k_msleep(SET_ADDR_DELAY_MS);
16391617
}
16401618

1641-
/* TODO: Refactor chan resources release */
1642-
chan->has_xfer = 0;
1643-
16441619
uhc_xfer_return(dev, xfer, 0);
16451620

16461621
} else {
@@ -1680,7 +1655,6 @@ static inline void uhc_dwc2_thread_handler(void *const arg)
16801655
static inline int uhc_dwc2_submit_ctrl_xfer(const struct device *dev, struct uhc_dwc2_chan *chan,
16811656
struct uhc_transfer *const xfer)
16821657
{
1683-
struct uhc_dwc2_data *priv = uhc_get_private(dev);
16841658
unsigned int key;
16851659

16861660
LOG_HEXDUMP_INF(xfer->setup_pkt, 8, "setup");
@@ -1714,13 +1688,6 @@ static inline int uhc_dwc2_submit_ctrl_xfer(const struct device *dev, struct uhc
17141688
_buffer_exec(dev, chan);
17151689
}
17161690

1717-
if (!chan->has_xfer) {
1718-
/* This is the first XFER to be enqueued into the chan. */
1719-
/* TODO: remove chan from idle chans list */
1720-
/* TODO: add chan to active chans list */
1721-
chan->has_xfer = 1;
1722-
}
1723-
17241691
irq_unlock(key);
17251692

17261693
return 0;

0 commit comments

Comments
 (0)