Skip to content

Commit 960e758

Browse files
jfischer-nojhedberg
authored andcommitted
drivers: uhc: move transfer status to transfer structure
Aling with the changes in UDC done in the commit ad81b3b ("drivers: udc: move transfer status to buffer info structure") This allows us to get the result of synchronous transfer and simplify uhc_submit_event(). Signed-off-by: Johann Fischer <[email protected]>
1 parent bb3193a commit 960e758

File tree

5 files changed

+27
-22
lines changed

5 files changed

+27
-22
lines changed

drivers/usb/uhc/uhc_common.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@ NET_BUF_POOL_VAR_DEFINE(uhc_ep_pool,
2121

2222
int uhc_submit_event(const struct device *dev,
2323
const enum uhc_event_type type,
24-
const int status,
25-
struct uhc_transfer *const xfer)
24+
const int status)
2625
{
2726
struct uhc_data *data = dev->data;
2827
struct uhc_event drv_evt = {
2928
.type = type,
30-
.xfer = xfer,
3129
.status = status,
3230
.dev = dev,
3331
};
@@ -43,10 +41,19 @@ void uhc_xfer_return(const struct device *dev,
4341
struct uhc_transfer *const xfer,
4442
const int err)
4543
{
44+
struct uhc_data *data = dev->data;
45+
struct uhc_event drv_evt = {
46+
.type = UHC_EVT_EP_REQUEST,
47+
.xfer = xfer,
48+
.dev = dev,
49+
};
50+
4651
sys_dlist_remove(&xfer->node);
4752
xfer->queued = 0;
4853
xfer->claimed = 0;
49-
uhc_submit_event(dev, UHC_EVT_EP_REQUEST, err, xfer);
54+
xfer->err = err;
55+
56+
data->event_cb(dev, &drv_evt);
5057
}
5158

5259
struct uhc_transfer *uhc_xfer_get_next(const struct device *dev)

drivers/usb/uhc/uhc_common.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,12 @@ int uhc_xfer_append(const struct device *dev,
173173
* @param[in] dev Pointer to device struct of the driver instance
174174
* @param[in] type Event type
175175
* @param[in] status Event status
176-
* @param[in] xfer Pointer to UHC transfer
177176
*
178177
* @return 0 on success, all other values should be treated as error.
179178
* @retval -EPERM controller is not initialized
180179
*/
181180
int uhc_submit_event(const struct device *dev,
182181
const enum uhc_event_type type,
183-
const int status,
184-
struct uhc_transfer *const xfer);
182+
const int status);
185183

186184
#endif /* ZEPHYR_INCLUDE_UHC_COMMON_H */

drivers/usb/uhc/uhc_max3421e.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ static void max3421e_handle_condet(const struct device *dev)
607607
type = UHC_EVT_DEV_CONNECTED_LS;
608608
}
609609

610-
uhc_submit_event(dev, type, 0, NULL);
610+
uhc_submit_event(dev, type, 0);
611611
}
612612

613613
static void max3421e_bus_event(const struct device *dev)
@@ -617,13 +617,13 @@ static void max3421e_bus_event(const struct device *dev)
617617
if (atomic_test_and_clear_bit(&priv->state,
618618
MAX3421E_STATE_BUS_RESUME)) {
619619
/* Resume operation done event */
620-
uhc_submit_event(dev, UHC_EVT_RESUMED, 0, NULL);
620+
uhc_submit_event(dev, UHC_EVT_RESUMED, 0);
621621
}
622622

623623
if (atomic_test_and_clear_bit(&priv->state,
624624
MAX3421E_STATE_BUS_RESET)) {
625625
/* Reset operation done event */
626-
uhc_submit_event(dev, UHC_EVT_RESETED, 0, NULL);
626+
uhc_submit_event(dev, UHC_EVT_RESETED, 0);
627627
}
628628
}
629629

@@ -654,7 +654,7 @@ static int max3421e_handle_bus_irq(const struct device *dev)
654654
/* Suspend operation Done Interrupt (bus suspended) */
655655
if (hirq & MAX3421E_SUSDN) {
656656
ret = max3421e_hien_disable(dev, MAX3421E_SUSDN);
657-
uhc_submit_event(dev, UHC_EVT_SUSPENDED, 0, NULL);
657+
uhc_submit_event(dev, UHC_EVT_SUSPENDED, 0);
658658
}
659659

660660
/* Peripheral Connect/Disconnect Interrupt */
@@ -664,7 +664,7 @@ static int max3421e_handle_bus_irq(const struct device *dev)
664664

665665
/* Remote Wakeup Interrupt */
666666
if (hirq & MAX3421E_RWU) {
667-
uhc_submit_event(dev, UHC_EVT_RWUP, 0, NULL);
667+
uhc_submit_event(dev, UHC_EVT_RWUP, 0);
668668
}
669669

670670
/* Bus Reset or Bus Resume event */
@@ -695,7 +695,7 @@ static void uhc_max3421e_thread(const struct device *dev)
695695
*/
696696
err = max3421e_update_hrsl_hirq(dev);
697697
if (unlikely(err)) {
698-
uhc_submit_event(dev, UHC_EVT_ERROR, err, NULL);
698+
uhc_submit_event(dev, UHC_EVT_ERROR, err);
699699
}
700700

701701
/* Host Transfer Done Interrupt */
@@ -713,20 +713,20 @@ static void uhc_max3421e_thread(const struct device *dev)
713713
if (priv->hirq & ~(MAX3421E_FRAME | MAX3421E_HXFRDN)) {
714714
err = max3421e_handle_bus_irq(dev);
715715
if (unlikely(err)) {
716-
uhc_submit_event(dev, UHC_EVT_ERROR, err, NULL);
716+
uhc_submit_event(dev, UHC_EVT_ERROR, err);
717717
}
718718
}
719719

720720
/* Clear interrupts and schedule new bus transfer */
721721
err = max3421e_clear_hirq(dev, priv->hirq);
722722
if (unlikely(err)) {
723-
uhc_submit_event(dev, UHC_EVT_ERROR, err, NULL);
723+
uhc_submit_event(dev, UHC_EVT_ERROR, err);
724724
}
725725

726726
if (schedule) {
727727
err = max3421e_schedule_xfer(dev);
728728
if (unlikely(err)) {
729-
uhc_submit_event(dev, UHC_EVT_ERROR, err, NULL);
729+
uhc_submit_event(dev, UHC_EVT_ERROR, err);
730730
}
731731
}
732732

drivers/usb/uhc/uhc_virtual.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ static void xfer_work_handler(struct k_work *work)
374374
if (schedule && !priv->busy) {
375375
err = vrt_schedule_xfer(dev);
376376
if (unlikely(err)) {
377-
uhc_submit_event(dev, UHC_EVT_ERROR, err, NULL);
377+
uhc_submit_event(dev, UHC_EVT_ERROR, err);
378378
}
379379
}
380380

@@ -411,7 +411,7 @@ static void vrt_device_act(const struct device *dev,
411411
type = UHC_EVT_ERROR;
412412
}
413413

414-
uhc_submit_event(dev, type, 0, NULL);
414+
uhc_submit_event(dev, type, 0);
415415
}
416416

417417
static void uhc_vrt_uvb_cb(const void *const vrt_priv,

include/zephyr/drivers/usb/uhc.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ struct uhc_transfer {
6060
unsigned int setup : 1;
6161
/** Transfer owner */
6262
void *owner;
63+
/** Transfer result, 0 on success, other values on error */
64+
int err;
6365
};
6466

6567
/**
@@ -105,13 +107,11 @@ struct uhc_event {
105107
/** Event type */
106108
enum uhc_event_type type;
107109
union {
108-
/** Event value */
109-
uint32_t value;
110+
/** Event status value, if any */
111+
int status;
110112
/** Pointer to request used only for UHC_EVT_EP_REQUEST */
111113
struct uhc_transfer *xfer;
112114
};
113-
/** Event status, 0 on success, other (transfer) values on error */
114-
int status;
115115
/** Pointer to controller's device struct */
116116
const struct device *dev;
117117
};

0 commit comments

Comments
 (0)