Skip to content

Commit 0054ae9

Browse files
author
Josuah Demangeon
committed
usb: host: rename "struct usbh_contex" to "usbh_context"
Make the struct name match the device naming for ease of use, although slightly longer name. Propagate the change to the subsystem, includes, tests and samples. Signed-off-by: Josuah Demangeon <[email protected]>
1 parent 83f1bd7 commit 0054ae9

File tree

8 files changed

+43
-43
lines changed

8 files changed

+43
-43
lines changed

include/zephyr/usb/usbh.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extern "C" {
3636
/**
3737
* USB host support runtime context
3838
*/
39-
struct usbh_contex {
39+
struct usbh_context {
4040
/** Name of the USB device */
4141
const char *name;
4242
/** Access mutex */
@@ -53,7 +53,7 @@ struct usbh_contex {
5353

5454
#define USBH_CONTROLLER_DEFINE(device_name, uhc_dev) \
5555
SYS_BITARRAY_DEFINE_STATIC(ba_##device_name, 128); \
56-
static STRUCT_SECTION_ITERABLE(usbh_contex, device_name) = { \
56+
static STRUCT_SECTION_ITERABLE(usbh_context, device_name) = { \
5757
.name = STRINGIFY(device_name), \
5858
.mutex = Z_MUTEX_INITIALIZER(device_name.mutex), \
5959
.dev = uhc_dev, \
@@ -80,20 +80,20 @@ struct usbh_class_data {
8080
struct usbh_code_triple code;
8181

8282
/** Initialization of the class implementation */
83-
/* int (*init)(struct usbh_contex *const uhs_ctx); */
83+
/* int (*init)(struct usbh_context *const uhs_ctx); */
8484
/** Request completion event handler */
85-
int (*request)(struct usbh_contex *const uhs_ctx,
85+
int (*request)(struct usbh_context *const uhs_ctx,
8686
struct uhc_transfer *const xfer, int err);
8787
/** Device connected handler */
88-
int (*connected)(struct usbh_contex *const uhs_ctx);
88+
int (*connected)(struct usbh_context *const uhs_ctx);
8989
/** Device removed handler */
90-
int (*removed)(struct usbh_contex *const uhs_ctx);
90+
int (*removed)(struct usbh_context *const uhs_ctx);
9191
/** Bus remote wakeup handler */
92-
int (*rwup)(struct usbh_contex *const uhs_ctx);
92+
int (*rwup)(struct usbh_context *const uhs_ctx);
9393
/** Bus suspended handler */
94-
int (*suspended)(struct usbh_contex *const uhs_ctx);
94+
int (*suspended)(struct usbh_context *const uhs_ctx);
9595
/** Bus resumed handler */
96-
int (*resumed)(struct usbh_contex *const uhs_ctx);
96+
int (*resumed)(struct usbh_context *const uhs_ctx);
9797
};
9898

9999
/**
@@ -109,7 +109,7 @@ struct usbh_class_data {
109109
*
110110
* @return 0 on success, other values on fail.
111111
*/
112-
int usbh_init(struct usbh_contex *uhs_ctx);
112+
int usbh_init(struct usbh_context *uhs_ctx);
113113

114114
/**
115115
* @brief Enable the USB host support and class instances
@@ -120,7 +120,7 @@ int usbh_init(struct usbh_contex *uhs_ctx);
120120
*
121121
* @return 0 on success, other values on fail.
122122
*/
123-
int usbh_enable(struct usbh_contex *uhs_ctx);
123+
int usbh_enable(struct usbh_context *uhs_ctx);
124124

125125
/**
126126
* @brief Disable the USB host support
@@ -131,7 +131,7 @@ int usbh_enable(struct usbh_contex *uhs_ctx);
131131
*
132132
* @return 0 on success, other values on fail.
133133
*/
134-
int usbh_disable(struct usbh_contex *uhs_ctx);
134+
int usbh_disable(struct usbh_context *uhs_ctx);
135135

136136
/**
137137
* @brief Shutdown the USB host support
@@ -142,7 +142,7 @@ int usbh_disable(struct usbh_contex *uhs_ctx);
142142
*
143143
* @return 0 on success, other values on fail.
144144
*/
145-
int usbh_shutdown(struct usbh_contex *const uhs_ctx);
145+
int usbh_shutdown(struct usbh_context *const uhs_ctx);
146146

147147
/**
148148
* @}

subsys/usb/host/usbh_api.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <zephyr/logging/log.h>
1212
LOG_MODULE_REGISTER(uhs_api, CONFIG_USBH_LOG_LEVEL);
1313

14-
int usbh_init(struct usbh_contex *uhs_ctx)
14+
int usbh_init(struct usbh_context *uhs_ctx)
1515
{
1616
int ret;
1717

@@ -36,7 +36,7 @@ int usbh_init(struct usbh_contex *uhs_ctx)
3636
return ret;
3737
}
3838

39-
int usbh_enable(struct usbh_contex *uhs_ctx)
39+
int usbh_enable(struct usbh_context *uhs_ctx)
4040
{
4141
int ret;
4242

@@ -65,7 +65,7 @@ int usbh_enable(struct usbh_contex *uhs_ctx)
6565
return ret;
6666
}
6767

68-
int usbh_disable(struct usbh_contex *uhs_ctx)
68+
int usbh_disable(struct usbh_context *uhs_ctx)
6969
{
7070
int ret;
7171

@@ -86,7 +86,7 @@ int usbh_disable(struct usbh_contex *uhs_ctx)
8686
return 0;
8787
}
8888

89-
int usbh_shutdown(struct usbh_contex *const uhs_ctx)
89+
int usbh_shutdown(struct usbh_context *const uhs_ctx)
9090
{
9191
int ret;
9292

subsys/usb/host/usbh_core.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static int usbh_event_carrier(const struct device *dev,
4343
return err;
4444
}
4545

46-
static void dev_connected_handler(struct usbh_contex *const ctx,
46+
static void dev_connected_handler(struct usbh_context *const ctx,
4747
const struct uhc_event *const event)
4848
{
4949

@@ -73,7 +73,7 @@ static void dev_connected_handler(struct usbh_contex *const ctx,
7373
}
7474
}
7575

76-
static void dev_removed_handler(struct usbh_contex *const ctx)
76+
static void dev_removed_handler(struct usbh_context *const ctx)
7777
{
7878
if (ctx->root != NULL) {
7979
usbh_device_free(ctx->root);
@@ -84,7 +84,7 @@ static void dev_removed_handler(struct usbh_contex *const ctx)
8484
}
8585
}
8686

87-
static int discard_ep_request(struct usbh_contex *const ctx,
87+
static int discard_ep_request(struct usbh_context *const ctx,
8888
struct uhc_transfer *const xfer)
8989
{
9090
const struct device *dev = ctx->dev;
@@ -97,7 +97,7 @@ static int discard_ep_request(struct usbh_contex *const ctx,
9797
return uhc_xfer_free(dev, xfer);
9898
}
9999

100-
static ALWAYS_INLINE int usbh_event_handler(struct usbh_contex *const ctx,
100+
static ALWAYS_INLINE int usbh_event_handler(struct usbh_context *const ctx,
101101
struct uhc_event *const event)
102102
{
103103
int ret = 0;
@@ -141,7 +141,7 @@ static void usbh_bus_thread(void *p1, void *p2, void *p3)
141141
ARG_UNUSED(p2);
142142
ARG_UNUSED(p3);
143143

144-
struct usbh_contex *uhs_ctx;
144+
struct usbh_context *uhs_ctx;
145145
struct uhc_event event;
146146

147147
while (true) {
@@ -158,7 +158,7 @@ static void usbh_thread(void *p1, void *p2, void *p3)
158158
ARG_UNUSED(p2);
159159
ARG_UNUSED(p3);
160160

161-
struct usbh_contex *uhs_ctx;
161+
struct usbh_context *uhs_ctx;
162162
struct uhc_event event;
163163
usbh_udev_cb_t cb;
164164
int ret;
@@ -182,7 +182,7 @@ static void usbh_thread(void *p1, void *p2, void *p3)
182182
}
183183
}
184184

185-
int usbh_init_device_intl(struct usbh_contex *const uhs_ctx)
185+
int usbh_init_device_intl(struct usbh_context *const uhs_ctx)
186186
{
187187
int ret;
188188

subsys/usb/host/usbh_data.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#include <zephyr/linker/iterable_sections.h>
22

3-
ITERABLE_SECTION_RAM(usbh_contex, Z_LINK_ITERABLE_SUBALIGN)
3+
ITERABLE_SECTION_RAM(usbh_context, Z_LINK_ITERABLE_SUBALIGN)
44
ITERABLE_SECTION_RAM(usbh_class_data, Z_LINK_ITERABLE_SUBALIGN)

subsys/usb/host/usbh_device.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ K_MEM_SLAB_DEFINE_STATIC(usb_device_slab, sizeof(struct usb_device),
1818

1919
K_HEAP_DEFINE(usb_device_heap, CONFIG_USBH_USB_DEVICE_HEAP);
2020

21-
struct usb_device *usbh_device_alloc(struct usbh_contex *const uhs_ctx)
21+
struct usb_device *usbh_device_alloc(struct usbh_context *const uhs_ctx)
2222
{
2323
struct usb_device *udev;
2424

@@ -37,7 +37,7 @@ struct usb_device *usbh_device_alloc(struct usbh_contex *const uhs_ctx)
3737

3838
void usbh_device_free(struct usb_device *const udev)
3939
{
40-
struct usbh_contex *const uhs_ctx = udev->ctx;
40+
struct usbh_context *const uhs_ctx = udev->ctx;
4141

4242
sys_bitarray_clear_bit(uhs_ctx->addr_ba, udev->addr);
4343
sys_dlist_remove(&udev->node);
@@ -48,7 +48,7 @@ void usbh_device_free(struct usb_device *const udev)
4848
k_mem_slab_free(&usb_device_slab, (void *)udev);
4949
}
5050

51-
struct usb_device *usbh_device_get_any(struct usbh_contex *const uhs_ctx)
51+
struct usb_device *usbh_device_get_any(struct usbh_context *const uhs_ctx)
5252
{
5353
sys_dnode_t *const node = sys_dlist_peek_head(&uhs_ctx->udevs);
5454
struct usb_device *udev;
@@ -58,7 +58,7 @@ struct usb_device *usbh_device_get_any(struct usbh_contex *const uhs_ctx)
5858
return udev;
5959
}
6060

61-
struct usb_device *usbh_device_get(struct usbh_contex *const uhs_ctx, const uint8_t addr)
61+
struct usb_device *usbh_device_get(struct usbh_context *const uhs_ctx, const uint8_t addr)
6262
{
6363
struct usb_device *udev;
6464

@@ -99,7 +99,7 @@ static int validate_device_mps0(const struct usb_device *const udev)
9999

100100
static int alloc_device_address(struct usb_device *const udev, uint8_t *const addr)
101101
{
102-
struct usbh_contex *const uhs_ctx = udev->ctx;
102+
struct usbh_context *const uhs_ctx = udev->ctx;
103103
int val;
104104
int err;
105105

@@ -449,7 +449,7 @@ int usbh_device_set_configuration(struct usb_device *const udev, const uint8_t n
449449

450450
int usbh_device_init(struct usb_device *const udev)
451451
{
452-
struct usbh_contex *const uhs_ctx = udev->ctx;
452+
struct usbh_context *const uhs_ctx = udev->ctx;
453453
uint8_t new_addr;
454454
int err;
455455

subsys/usb/host/usbh_device.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ typedef int (*usbh_udev_cb_t)(struct usb_device *const udev,
2020
* connection without hub support, this is the device connected directly to the
2121
* host controller.
2222
*/
23-
struct usb_device *usbh_device_get_any(struct usbh_contex *const ctx);
23+
struct usb_device *usbh_device_get_any(struct usbh_context *const ctx);
2424

25-
struct usb_device *usbh_device_get(struct usbh_contex *const uhs_ctx, const uint8_t addr);
25+
struct usb_device *usbh_device_get(struct usbh_context *const uhs_ctx, const uint8_t addr);
2626

2727
/* Allocate/free USB device */
28-
struct usb_device *usbh_device_alloc(struct usbh_contex *const uhs_ctx);
28+
struct usb_device *usbh_device_alloc(struct usbh_context *const uhs_ctx);
2929
void usbh_device_free(struct usb_device *const udev);
3030

3131
/* Reset and configure new USB device */
@@ -42,7 +42,7 @@ static inline struct uhc_transfer *usbh_xfer_alloc(struct usb_device *udev,
4242
usbh_udev_cb_t cb,
4343
void *const cb_priv)
4444
{
45-
struct usbh_contex *const ctx = udev->ctx;
45+
struct usbh_context *const ctx = udev->ctx;
4646

4747
return uhc_xfer_alloc(ctx->dev, ep, udev, cb, cb_priv);
4848
}
@@ -51,47 +51,47 @@ static inline int usbh_xfer_buf_add(const struct usb_device *udev,
5151
struct uhc_transfer *const xfer,
5252
struct net_buf *buf)
5353
{
54-
struct usbh_contex *const ctx = udev->ctx;
54+
struct usbh_context *const ctx = udev->ctx;
5555

5656
return uhc_xfer_buf_add(ctx->dev, xfer, buf);
5757
}
5858

5959
static inline struct net_buf *usbh_xfer_buf_alloc(struct usb_device *udev,
6060
const size_t size)
6161
{
62-
struct usbh_contex *const ctx = udev->ctx;
62+
struct usbh_context *const ctx = udev->ctx;
6363

6464
return uhc_xfer_buf_alloc(ctx->dev, size);
6565
}
6666

6767
static inline int usbh_xfer_free(const struct usb_device *udev,
6868
struct uhc_transfer *const xfer)
6969
{
70-
struct usbh_contex *const ctx = udev->ctx;
70+
struct usbh_context *const ctx = udev->ctx;
7171

7272
return uhc_xfer_free(ctx->dev, xfer);
7373
}
7474

7575
static inline void usbh_xfer_buf_free(const struct usb_device *udev,
7676
struct net_buf *const buf)
7777
{
78-
struct usbh_contex *const ctx = udev->ctx;
78+
struct usbh_context *const ctx = udev->ctx;
7979

8080
uhc_xfer_buf_free(ctx->dev, buf);
8181
}
8282

8383
static inline int usbh_xfer_enqueue(const struct usb_device *udev,
8484
struct uhc_transfer *const xfer)
8585
{
86-
struct usbh_contex *const ctx = udev->ctx;
86+
struct usbh_context *const ctx = udev->ctx;
8787

8888
return uhc_ep_enqueue(ctx->dev, xfer);
8989
}
9090

9191
static inline int usbh_xfer_dequeue(const struct usb_device *udev,
9292
struct uhc_transfer *const xfer)
9393
{
94-
struct usbh_contex *const ctx = udev->ctx;
94+
struct usbh_context *const ctx = udev->ctx;
9595

9696
return uhc_ep_dequeue(ctx->dev, xfer);
9797
}

subsys/usb/host/usbh_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
#include <stdint.h>
1111
#include <zephyr/usb/usbh.h>
1212

13-
int usbh_init_device_intl(struct usbh_contex *const uhs_ctx);
13+
int usbh_init_device_intl(struct usbh_context *const uhs_ctx);
1414

1515
#endif /* ZEPHYR_INCLUDE_USBH_INTERNAL_H */

subsys/usb/host/usbip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct usbip_dev_ctx {
4848

4949
/* Context of the exported bus (not really used yet) */
5050
struct usbip_bus_ctx {
51-
struct usbh_contex *uhs_ctx;
51+
struct usbh_context *uhs_ctx;
5252
struct usbip_dev_ctx devs[CONFIG_USBIP_DEVICES_COUNT];
5353
uint8_t busnum;
5454
};

0 commit comments

Comments
 (0)