Skip to content

Commit 2cea6e0

Browse files
jfischer-nojhedberg
authored andcommitted
usb: host: remove unused USBH_DEFINE_CLASS(bazfoo) from the shell
With the latest change, there is no need for this structure to be used as a completion handler. Signed-off-by: Johann Fischer <[email protected]>
1 parent c1065e0 commit 2cea6e0

File tree

1 file changed

+1
-117
lines changed

1 file changed

+1
-117
lines changed

subsys/usb/host/usbh_shell.c

Lines changed: 1 addition & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ LOG_MODULE_REGISTER(usbh_shell, CONFIG_USBH_LOG_LEVEL);
2424
USBH_CONTROLLER_DEFINE(uhs_ctx, DEVICE_DT_GET(DT_NODELABEL(zephyr_uhc0)));
2525
static struct usb_device *udev;
2626
const static struct shell *ctx_shell;
27+
static uint8_t vreq_test_buf[1024];
2728

2829
static void print_dev_desc(const struct shell *sh,
2930
const struct usb_device_descriptor *const desc)
@@ -57,123 +58,6 @@ static void print_cfg_desc(const struct shell *sh,
5758
shell_print(sh, "bMaxPower\t\t%u mA", desc->bMaxPower * 2);
5859
}
5960

60-
static void print_desc(const struct shell *sh, const struct net_buf *const buf)
61-
{
62-
struct usb_desc_header *head = (void *)buf->data;
63-
64-
if (buf->len < sizeof(struct usb_desc_header)) {
65-
return;
66-
}
67-
68-
switch (head->bDescriptorType) {
69-
case USB_DESC_DEVICE: {
70-
struct usb_device_descriptor *desc = (void *)buf->data;
71-
72-
if (buf->len < sizeof(struct usb_device_descriptor)) {
73-
shell_hexdump(ctx_shell, buf->data, buf->len);
74-
break;
75-
}
76-
77-
desc->bcdUSB = sys_le16_to_cpu(desc->bcdUSB);
78-
desc->idVendor = sys_le16_to_cpu(desc->idVendor);
79-
desc->idProduct = sys_le16_to_cpu(desc->idProduct);
80-
desc->bcdDevice = sys_le16_to_cpu(desc->bcdDevice);
81-
print_dev_desc(sh, desc);
82-
break;
83-
}
84-
case USB_DESC_CONFIGURATION: {
85-
struct usb_cfg_descriptor *desc = (void *)buf->data;
86-
87-
if (buf->len < sizeof(struct usb_cfg_descriptor)) {
88-
shell_hexdump(ctx_shell, buf->data, buf->len);
89-
break;
90-
}
91-
92-
desc->wTotalLength = sys_le16_to_cpu(desc->wTotalLength);
93-
print_cfg_desc(sh, desc);
94-
break;
95-
}
96-
default:
97-
shell_hexdump(ctx_shell, buf->data, buf->len);
98-
break;
99-
}
100-
}
101-
102-
static int bazfoo_request(struct usbh_contex *const ctx,
103-
struct uhc_transfer *const xfer,
104-
int err)
105-
{
106-
const struct device *dev = ctx->dev;
107-
108-
shell_info(ctx_shell, "host: transfer finished %p, err %d", xfer, err);
109-
110-
if (xfer->buf) {
111-
/*
112-
* FIXME: We don not distinguish the context
113-
* of the request and always try to print it
114-
* as descriptor first. If it is not a known descriptor,
115-
* we show a hexdump in any case.
116-
* This is just simple enough for first steps and will
117-
* be revised with coming peripheral device management.
118-
*/
119-
if (xfer->ep == USB_CONTROL_EP_IN) {
120-
print_desc(ctx_shell, xfer->buf);
121-
} else {
122-
shell_hexdump(ctx_shell, xfer->buf->data, xfer->buf->len);
123-
}
124-
125-
uhc_xfer_buf_free(dev, xfer->buf);
126-
}
127-
128-
return uhc_xfer_free(dev, xfer);
129-
}
130-
131-
static int bazfoo_connected(struct usbh_contex *const ctx)
132-
{
133-
shell_info(ctx_shell, "host: USB device connected");
134-
135-
return 0;
136-
}
137-
138-
static int bazfoo_removed(struct usbh_contex *const ctx)
139-
{
140-
shell_info(ctx_shell, "host: USB device removed");
141-
142-
return 0;
143-
}
144-
145-
static int bazfoo_rwup(struct usbh_contex *const ctx)
146-
{
147-
shell_info(ctx_shell, "host: Bus remote wakeup event");
148-
149-
return 0;
150-
}
151-
152-
static int bazfoo_suspended(struct usbh_contex *const ctx)
153-
{
154-
shell_info(ctx_shell, "host: Bus suspended");
155-
156-
return 0;
157-
}
158-
159-
static int bazfoo_resumed(struct usbh_contex *const ctx)
160-
{
161-
shell_info(ctx_shell, "host: Bus resumed");
162-
163-
return 0;
164-
}
165-
166-
USBH_DEFINE_CLASS(bazfoo) = {
167-
.request = bazfoo_request,
168-
.connected = bazfoo_connected,
169-
.removed = bazfoo_removed,
170-
.rwup = bazfoo_rwup,
171-
.suspended = bazfoo_suspended,
172-
.resumed = bazfoo_resumed,
173-
};
174-
175-
static uint8_t vreq_test_buf[1024];
176-
17761
static int cmd_bulk(const struct shell *sh, size_t argc, char **argv)
17862
{
17963
struct uhc_transfer *xfer;

0 commit comments

Comments
 (0)