Skip to content

Commit aced8f5

Browse files
jfischer-nojhedberg
authored andcommitted
usb: host: cleanup UHC event processing
Remove ugly hack to call class driver ops. This is preparation for later changes where we will change parts to work on structure that represents USB device and not on glue UHC functions. Signed-off-by: Johann Fischer <[email protected]>
1 parent 9cb777b commit aced8f5

File tree

1 file changed

+11
-36
lines changed

1 file changed

+11
-36
lines changed

subsys/usb/host/usbh_core.c

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ LOG_MODULE_REGISTER(uhs, CONFIG_USBH_LOG_LEVEL);
1717
static K_KERNEL_STACK_DEFINE(usbh_stack, CONFIG_USBH_STACK_SIZE);
1818
static struct k_thread usbh_thread_data;
1919

20-
/* TODO */
21-
static struct usbh_class_data *class_data;
22-
2320
K_MSGQ_DEFINE(usbh_msgq, sizeof(struct uhc_event),
2421
CONFIG_USBH_MAX_UHC_MSG, sizeof(uint32_t));
2522

@@ -29,16 +26,11 @@ static int usbh_event_carrier(const struct device *dev,
2926
return k_msgq_put(&usbh_msgq, event, K_NO_WAIT);
3027
}
3128

32-
static int event_ep_request(struct usbh_contex *const ctx,
33-
struct uhc_event *const event)
29+
static int discard_ep_request(struct usbh_contex *const ctx,
30+
struct uhc_transfer *const xfer)
3431
{
35-
struct uhc_transfer *xfer = event->xfer;
3632
const struct device *dev = ctx->dev;
3733

38-
if (class_data && class_data->request) {
39-
return class_data->request(ctx, event->xfer, event->status);
40-
}
41-
4234
if (xfer->buf) {
4335
LOG_HEXDUMP_INF(xfer->buf->data, xfer->buf->len, "buf");
4436
uhc_xfer_buf_free(dev, xfer->buf);
@@ -52,51 +44,33 @@ static ALWAYS_INLINE int usbh_event_handler(struct usbh_contex *const ctx,
5244
{
5345
int ret = 0;
5446

47+
if (event->type == UHC_EVT_EP_REQUEST) {
48+
return discard_ep_request(ctx, event->xfer);
49+
}
50+
5551
switch (event->type) {
5652
case UHC_EVT_DEV_CONNECTED_LS:
5753
case UHC_EVT_DEV_CONNECTED_FS:
5854
case UHC_EVT_DEV_CONNECTED_HS:
5955
LOG_DBG("Device connected event");
60-
if (class_data && class_data->connected) {
61-
ret = class_data->connected(ctx);
62-
}
6356
break;
6457
case UHC_EVT_DEV_REMOVED:
6558
LOG_DBG("Device removed event");
66-
if (class_data && class_data->removed) {
67-
ret = class_data->removed(ctx);
68-
}
6959
break;
7060
case UHC_EVT_RESETED:
7161
LOG_DBG("Bus reset");
72-
/* TODO */
73-
if (class_data && class_data->removed) {
74-
ret = class_data->removed(ctx);
75-
}
7662
break;
7763
case UHC_EVT_SUSPENDED:
7864
LOG_DBG("Bus suspended");
79-
if (class_data && class_data->suspended) {
80-
ret = class_data->suspended(ctx);
81-
}
8265
break;
8366
case UHC_EVT_RESUMED:
8467
LOG_DBG("Bus resumed");
85-
if (class_data && class_data->resumed) {
86-
ret = class_data->resumed(ctx);
87-
}
8868
break;
8969
case UHC_EVT_RWUP:
9070
LOG_DBG("RWUP event");
91-
if (class_data && class_data->rwup) {
92-
ret = class_data->rwup(ctx);
93-
}
94-
break;
95-
case UHC_EVT_EP_REQUEST:
96-
event_ep_request(ctx, event);
9771
break;
9872
case UHC_EVT_ERROR:
99-
LOG_DBG("Error event");
73+
LOG_DBG("Error event %d", event->status);
10074
break;
10175
default:
10276
break;
@@ -131,9 +105,10 @@ int usbh_init_device_intl(struct usbh_contex *const uhs_ctx)
131105
}
132106

133107
STRUCT_SECTION_FOREACH(usbh_class_data, cdata) {
134-
LOG_DBG("class data %p", cdata);
135-
/* TODO */
136-
class_data = cdata;
108+
/*
109+
* For now, we have not implemented any class drivers,
110+
* so just keep it as placeholder.
111+
*/
137112
break;
138113
}
139114

0 commit comments

Comments
 (0)