Skip to content

Commit a7c8a8d

Browse files
jfischer-nokartben
authored andcommitted
drivers: uhc: remove UHC transfer parameter addr and attrib
Address parameter/argument is no longer needed because we have a pointer to the USB device. The Attrib parameter has never been used and will be replaced by the interval and start-frame parameters in the future. Signed-off-by: Johann Fischer <[email protected]>
1 parent 60884cc commit a7c8a8d

File tree

7 files changed

+10
-30
lines changed

7 files changed

+10
-30
lines changed

drivers/usb/uhc/uhc_common.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ void uhc_xfer_buf_free(const struct device *dev, struct net_buf *const buf)
9292
}
9393

9494
struct uhc_transfer *uhc_xfer_alloc(const struct device *dev,
95-
const uint8_t addr,
9695
const uint8_t ep,
97-
const uint8_t attrib,
9896
const uint16_t mps,
9997
void *const udev,
10098
void *const cb)
@@ -108,18 +106,15 @@ struct uhc_transfer *uhc_xfer_alloc(const struct device *dev,
108106
goto xfer_alloc_error;
109107
}
110108

111-
LOG_DBG("Allocate xfer, ep 0x%02x attrib 0x%02x cb %p",
112-
ep, attrib, cb);
109+
LOG_DBG("Allocate xfer, ep 0x%02x cb %p", ep, cb);
113110

114111
if (k_mem_slab_alloc(&uhc_xfer_pool, (void **)&xfer, K_NO_WAIT)) {
115112
LOG_ERR("Failed to allocate transfer");
116113
goto xfer_alloc_error;
117114
}
118115

119116
memset(xfer, 0, sizeof(struct uhc_transfer));
120-
xfer->addr = addr;
121117
xfer->ep = ep;
122-
xfer->attrib = attrib;
123118
xfer->mps = mps;
124119
xfer->udev = udev;
125120
xfer->cb = cb;
@@ -131,9 +126,7 @@ struct uhc_transfer *uhc_xfer_alloc(const struct device *dev,
131126
}
132127

133128
struct uhc_transfer *uhc_xfer_alloc_with_buf(const struct device *dev,
134-
const uint8_t addr,
135129
const uint8_t ep,
136-
const uint8_t attrib,
137130
const uint16_t mps,
138131
void *const udev,
139132
void *const cb,
@@ -147,7 +140,7 @@ struct uhc_transfer *uhc_xfer_alloc_with_buf(const struct device *dev,
147140
return NULL;
148141
}
149142

150-
xfer = uhc_xfer_alloc(dev, addr, ep, attrib, mps, udev, cb);
143+
xfer = uhc_xfer_alloc(dev, ep, mps, udev, cb);
151144
if (xfer == NULL) {
152145
net_buf_unref(buf);
153146
return NULL;

drivers/usb/uhc/uhc_max3421e.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ static int max3421e_schedule_xfer(const struct device *dev)
392392
}
393393

394394
LOG_DBG("Next transfer %p", priv->last_xfer);
395-
ret = max3421e_peraddr(dev, priv->last_xfer->addr);
395+
ret = max3421e_peraddr(dev, priv->last_xfer->udev->addr);
396396
if (ret) {
397397
return ret;
398398
}

drivers/usb/uhc/uhc_virtual.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static int vrt_xfer_control(const struct device *dev,
9898
if (xfer->stage == UHC_CONTROL_STAGE_SETUP) {
9999
LOG_DBG("Handle SETUP stage");
100100
uvb_pkt = uvb_alloc_pkt(UVB_REQUEST_SETUP,
101-
xfer->addr, USB_CONTROL_EP_OUT,
101+
xfer->udev->addr, USB_CONTROL_EP_OUT,
102102
xfer->setup_pkt, sizeof(xfer->setup_pkt));
103103
if (uvb_pkt == NULL) {
104104
LOG_ERR("Failed to allocate UVB packet");
@@ -121,7 +121,7 @@ static int vrt_xfer_control(const struct device *dev,
121121

122122
LOG_DBG("Handle DATA stage");
123123
uvb_pkt = uvb_alloc_pkt(UVB_REQUEST_DATA,
124-
xfer->addr, xfer->ep,
124+
xfer->udev->addr, xfer->ep,
125125
data, length);
126126
if (uvb_pkt == NULL) {
127127
LOG_ERR("Failed to allocate UVB packet");
@@ -144,7 +144,7 @@ static int vrt_xfer_control(const struct device *dev,
144144
}
145145

146146
uvb_pkt = uvb_alloc_pkt(UVB_REQUEST_DATA,
147-
xfer->addr, ep,
147+
xfer->udev->addr, ep,
148148
NULL, 0);
149149
if (uvb_pkt == NULL) {
150150
LOG_ERR("Failed to allocate UVB packet");
@@ -176,7 +176,7 @@ static int vrt_xfer_bulk(const struct device *dev,
176176
data = buf->data;
177177
}
178178

179-
uvb_pkt = uvb_alloc_pkt(UVB_REQUEST_DATA, xfer->addr, xfer->ep,
179+
uvb_pkt = uvb_alloc_pkt(UVB_REQUEST_DATA, xfer->udev->addr, xfer->ep,
180180
data, length);
181181
if (uvb_pkt == NULL) {
182182
LOG_ERR("Failed to allocate UVB packet");

include/zephyr/drivers/usb/uhc.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,8 @@ struct uhc_transfer {
7777
uint8_t setup_pkt[8];
7878
/** Transfer data buffer */
7979
struct net_buf *buf;
80-
/** Device (peripheral) address */
81-
uint8_t addr;
8280
/** Endpoint to which request is associated */
8381
uint8_t ep;
84-
/** Endpoint attributes (TBD) */
85-
uint8_t attrib;
8682
/** Maximum packet size */
8783
uint16_t mps;
8884
/** Flag marks request buffer is queued */
@@ -358,19 +354,15 @@ static inline int uhc_bus_resume(const struct device *dev)
358354
* and added from different pools.
359355
*
360356
* @param[in] dev Pointer to device struct of the driver instance
361-
* @param[in] addr Device (peripheral) address
362357
* @param[in] ep Endpoint address
363-
* @param[in] attrib Endpoint attributes
364358
* @param[in] mps Maximum packet size of the endpoint
365359
* @param[in] udev Opaque pointer to USB device
366360
* @param[in] cb Transfer completion callback
367361
*
368362
* @return pointer to allocated transfer or NULL on error.
369363
*/
370364
struct uhc_transfer *uhc_xfer_alloc(const struct device *dev,
371-
const uint8_t addr,
372365
const uint8_t ep,
373-
const uint8_t attrib,
374366
const uint16_t mps,
375367
void *const udev,
376368
void *const cb);
@@ -381,9 +373,7 @@ struct uhc_transfer *uhc_xfer_alloc(const struct device *dev,
381373
* Allocate a new transfer from common transfer pool with buffer.
382374
*
383375
* @param[in] dev Pointer to device struct of the driver instance
384-
* @param[in] addr Device (peripheral) address
385376
* @param[in] ep Endpoint address
386-
* @param[in] attrib Endpoint attributes
387377
* @param[in] mps Maximum packet size of the endpoint
388378
* @param[in] udev Opaque pointer to USB device
389379
* @param[in] cb Transfer completion callback
@@ -392,9 +382,7 @@ struct uhc_transfer *uhc_xfer_alloc(const struct device *dev,
392382
* @return pointer to allocated transfer or NULL on error.
393383
*/
394384
struct uhc_transfer *uhc_xfer_alloc_with_buf(const struct device *dev,
395-
const uint8_t addr,
396385
const uint8_t ep,
397-
const uint8_t attrib,
398386
const uint16_t mps,
399387
void *const udev,
400388
void *const cb,

subsys/usb/host/usbh_ch9.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int usbh_req_setup(struct usb_device *const udev,
6060
uint8_t ep = usb_reqtype_is_to_device(&req) ? 0x00 : 0x80;
6161
int ret;
6262

63-
xfer = usbh_xfer_alloc(udev, ep, 0, 64, ch9_req_cb);
63+
xfer = usbh_xfer_alloc(udev, ep, 64, ch9_req_cb);
6464
if (!xfer) {
6565
return -ENOMEM;
6666
}

subsys/usb/host/usbh_device.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ struct usb_device *usbh_device_get_any(struct usbh_contex *const ctx);
2424
/* Wrappers around to avoid glue UHC calls. */
2525
static inline struct uhc_transfer *usbh_xfer_alloc(struct usb_device *udev,
2626
const uint8_t ep,
27-
const uint8_t attrib,
2827
const uint16_t mps,
2928
usbh_udev_cb_t cb)
3029
{
3130
struct usbh_contex *const ctx = udev->ctx;
3231

33-
return uhc_xfer_alloc(ctx->dev, udev->addr, ep, attrib, mps, udev, cb);
32+
return uhc_xfer_alloc(ctx->dev, ep, mps, udev, cb);
3433
}
3534

3635
static inline int usbh_xfer_buf_add(const struct usb_device *udev,

subsys/usb/host/usbh_shell.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static int cmd_bulk(const struct shell *sh, size_t argc, char **argv)
8787
ep = strtol(argv[1], NULL, 16);
8888
len = MIN(sizeof(vreq_test_buf), strtol(argv[2], NULL, 10));
8989

90-
xfer = usbh_xfer_alloc(udev, ep, 0, 512, bulk_req_cb);
90+
xfer = usbh_xfer_alloc(udev, ep, 512, bulk_req_cb);
9191
if (!xfer) {
9292
shell_error(sh, "host: Failed to allocate transfer");
9393
return -ENOMEM;

0 commit comments

Comments
 (0)