Skip to content

Commit 60884cc

Browse files
jfischer-nokartben
authored andcommitted
usb: host: move representation of a USB device to UHC header
This will allow the controller driver to access information about the device in the future. Signed-off-by: Johann Fischer <[email protected]>
1 parent 7f53eca commit 60884cc

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

include/zephyr/drivers/usb/uhc.h

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,34 @@
2323
* @defgroup uhc_api USB host controller driver API
2424
* @ingroup io_interfaces
2525
* @since 3.3
26-
* @version 0.1.0
26+
* @version 0.1.1
2727
* @{
2828
*/
2929

30+
/** USB device state */
31+
enum usb_device_state {
32+
USB_STATE_NOTCONNECTED,
33+
USB_STATE_DEFAULT,
34+
USB_STATE_ADDRESSED,
35+
USB_STATE_CONFIGURED,
36+
};
37+
38+
/**
39+
* Host representation of a USB device
40+
*/
41+
struct usb_device {
42+
/** An opaque pointer to the host context to which this device belongs */
43+
void *ctx;
44+
/** USB device descriptor */
45+
struct usb_device_descriptor dev_desc;
46+
/** Device state */
47+
enum usb_device_state state;
48+
/** Actual active device configuration */
49+
uint8_t actual_cfg;
50+
/** Device address */
51+
uint8_t addr;
52+
};
53+
3054
/**
3155
* @brief USB control transfer stage
3256
*/
@@ -65,8 +89,8 @@ struct uhc_transfer {
6589
unsigned int queued : 1;
6690
/** Control stage status, up to the driver to use it or not */
6791
unsigned int stage : 2;
68-
/** Pointer to USB device (opaque for the UHC) */
69-
void *udev;
92+
/** Pointer to USB device */
93+
struct usb_device *udev;
7094
/** Pointer to transfer completion callback (opaque for the UHC) */
7195
void *cb;
7296
/** Transfer result, 0 on success, other values on error */

subsys/usb/host/usbh_device.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,6 @@
1111
#include <zephyr/usb/usbh.h>
1212
#include <zephyr/drivers/usb/uhc.h>
1313

14-
/* USB device state */
15-
enum usb_device_state {
16-
USB_STATE_NOTCONNECTED,
17-
USB_STATE_DEFAULT,
18-
USB_STATE_ADDRESSED,
19-
USB_STATE_CONFIGURED,
20-
};
21-
22-
/* Host support view of a USB device */
23-
struct usb_device {
24-
struct usbh_contex *ctx;
25-
struct usb_device_descriptor dev_desc;
26-
enum usb_device_state state;
27-
uint8_t actual_cfg;
28-
uint8_t addr;
29-
};
30-
3114
/* Callback type to be used for e.g. synchronous requests */
3215
typedef int (*usbh_udev_cb_t)(struct usb_device *const udev,
3316
struct uhc_transfer *const xfer);

0 commit comments

Comments
 (0)