summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/usb_request.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/usb/usb_request.c')
-rw-r--r--sys/dev/usb/usb_request.c304
1 files changed, 152 insertions, 152 deletions
diff --git a/sys/dev/usb/usb_request.c b/sys/dev/usb/usb_request.c
index da694c5..da93b7b 100644
--- a/sys/dev/usb/usb_request.c
+++ b/sys/dev/usb/usb_request.c
@@ -32,7 +32,7 @@
#include <dev/usb/usb_ioctl.h>
#include <dev/usb/usbhid.h>
-#define USB_DEBUG_VAR usb2_debug
+#define USB_DEBUG_VAR usb_debug
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_busdma.h>
@@ -49,26 +49,26 @@
#include <sys/ctype.h>
#if USB_DEBUG
-static int usb2_pr_poll_delay = USB_PORT_RESET_DELAY;
-static int usb2_pr_recovery_delay = USB_PORT_RESET_RECOVERY;
-static int usb2_ss_delay = 0;
+static int usb_pr_poll_delay = USB_PORT_RESET_DELAY;
+static int usb_pr_recovery_delay = USB_PORT_RESET_RECOVERY;
+static int usb_ss_delay = 0;
SYSCTL_INT(_hw_usb, OID_AUTO, pr_poll_delay, CTLFLAG_RW,
- &usb2_pr_poll_delay, 0, "USB port reset poll delay in ms");
+ &usb_pr_poll_delay, 0, "USB port reset poll delay in ms");
SYSCTL_INT(_hw_usb, OID_AUTO, pr_recovery_delay, CTLFLAG_RW,
- &usb2_pr_recovery_delay, 0, "USB port reset recovery delay in ms");
+ &usb_pr_recovery_delay, 0, "USB port reset recovery delay in ms");
SYSCTL_INT(_hw_usb, OID_AUTO, ss_delay, CTLFLAG_RW,
- &usb2_ss_delay, 0, "USB status stage delay in ms");
+ &usb_ss_delay, 0, "USB status stage delay in ms");
#endif
/*------------------------------------------------------------------------*
- * usb2_do_request_callback
+ * usbd_do_request_callback
*
* This function is the USB callback for generic USB Host control
* transfers.
*------------------------------------------------------------------------*/
void
-usb2_do_request_callback(struct usb_xfer *xfer)
+usbd_do_request_callback(struct usb_xfer *xfer)
{
; /* workaround for a bug in "indent" */
@@ -76,7 +76,7 @@ usb2_do_request_callback(struct usb_xfer *xfer)
switch (USB_GET_STATE(xfer)) {
case USB_ST_SETUP:
- usb2_start_hardware(xfer);
+ usbd_transfer_submit(xfer);
break;
default:
cv_signal(xfer->xroot->udev->default_cv);
@@ -85,12 +85,12 @@ usb2_do_request_callback(struct usb_xfer *xfer)
}
/*------------------------------------------------------------------------*
- * usb2_do_clear_stall_callback
+ * usb_do_clear_stall_callback
*
* This function is the USB callback for generic clear stall requests.
*------------------------------------------------------------------------*/
void
-usb2_do_clear_stall_callback(struct usb_xfer *xfer)
+usb_do_clear_stall_callback(struct usb_xfer *xfer)
{
struct usb_device_request req;
struct usb_device *udev;
@@ -119,7 +119,7 @@ usb2_do_clear_stall_callback(struct usb_xfer *xfer)
ep->toggle_next = 0;
ep->is_stalled = 0;
/* start up the current or next transfer, if any */
- usb2_command_wrapper(&ep->endpoint_q,
+ usb_command_wrapper(&ep->endpoint_q,
ep->endpoint_q.curr);
}
ep++;
@@ -144,14 +144,14 @@ tr_setup:
/* copy in the transfer */
- usb2_copy_in(xfer->frbuffers, 0, &req, sizeof(req));
+ usbd_copy_in(xfer->frbuffers, 0, &req, sizeof(req));
/* set length */
xfer->frlengths[0] = sizeof(req);
xfer->nframes = 1;
USB_BUS_UNLOCK(udev->bus);
- usb2_start_hardware(xfer);
+ usbd_transfer_submit(xfer);
USB_BUS_LOCK(udev->bus);
break;
@@ -173,11 +173,11 @@ tr_setup:
}
static usb_handle_req_t *
-usb2_get_hr_func(struct usb_device *udev)
+usbd_get_hr_func(struct usb_device *udev)
{
/* figure out if there is a Handle Request function */
if (udev->flags.usb_mode == USB_MODE_DEVICE)
- return (usb2_temp_get_desc_p);
+ return (usb_temp_get_desc_p);
else if (udev->parent_hub == NULL)
return (udev->bus->methods->roothub_exec);
else
@@ -185,7 +185,7 @@ usb2_get_hr_func(struct usb_device *udev)
}
/*------------------------------------------------------------------------*
- * usb2_do_request_flags and usb2_do_request
+ * usbd_do_request_flags and usbd_do_request
*
* Description of arguments passed to these functions:
*
@@ -232,7 +232,7 @@ usb2_get_hr_func(struct usb_device *udev)
* does not allow control requests without a timeout.
*
* NOTE: This function is thread safe. All calls to
- * "usb2_do_request_flags" will be serialised by the use of an
+ * "usbd_do_request_flags" will be serialised by the use of an
* internal "sx_lock".
*
* Returns:
@@ -240,7 +240,7 @@ usb2_get_hr_func(struct usb_device *udev)
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_do_request_flags(struct usb_device *udev, struct mtx *mtx,
+usbd_do_request_flags(struct usb_device *udev, struct mtx *mtx,
struct usb_device_request *req, void *data, uint16_t flags,
uint16_t *actlen, usb_timeout_t timeout)
{
@@ -301,7 +301,7 @@ usb2_do_request_flags(struct usb_device *udev, struct mtx *mtx,
sx_xlock(udev->default_sx);
- hr_func = usb2_get_hr_func(udev);
+ hr_func = usbd_get_hr_func(udev);
if (hr_func != NULL) {
DPRINTF("Handle Request function is set\n");
@@ -354,7 +354,7 @@ usb2_do_request_flags(struct usb_device *udev, struct mtx *mtx,
/*
* Setup a new USB transfer or use the existing one, if any:
*/
- usb2_default_transfer_setup(udev);
+ usbd_default_transfer_setup(udev);
xfer = udev->default_xfer[0];
if (xfer == NULL) {
@@ -380,7 +380,7 @@ usb2_do_request_flags(struct usb_device *udev, struct mtx *mtx,
max_ticks = USB_MS_TO_TICKS(timeout);
- usb2_copy_in(xfer->frbuffers, 0, req, sizeof(*req));
+ usbd_copy_in(xfer->frbuffers, 0, req, sizeof(*req));
xfer->frlengths[0] = sizeof(*req);
xfer->nframes = 2;
@@ -397,7 +397,7 @@ usb2_do_request_flags(struct usb_device *udev, struct mtx *mtx,
#if USB_HAVE_USER_IO
if (flags & USB_USER_DATA_PTR) {
USB_XFER_UNLOCK(xfer);
- err = usb2_copy_in_user(xfer->frbuffers + 1,
+ err = usbd_copy_in_user(xfer->frbuffers + 1,
0, data, temp);
USB_XFER_LOCK(xfer);
if (err) {
@@ -406,7 +406,7 @@ usb2_do_request_flags(struct usb_device *udev, struct mtx *mtx,
}
} else
#endif
- usb2_copy_in(xfer->frbuffers + 1,
+ usbd_copy_in(xfer->frbuffers + 1,
0, data, temp);
}
xfer->nframes = 2;
@@ -416,12 +416,12 @@ usb2_do_request_flags(struct usb_device *udev, struct mtx *mtx,
#if USB_DEBUG
int temp;
- temp = usb2_ss_delay;
+ temp = usb_ss_delay;
if (temp > 5000) {
temp = 5000;
}
if (temp > 0) {
- usb2_pause_mtx(
+ usb_pause_mtx(
xfer->xroot->xfer_mtx,
USB_MS_TO_TICKS(temp));
}
@@ -434,9 +434,9 @@ usb2_do_request_flags(struct usb_device *udev, struct mtx *mtx,
xfer->nframes = 1;
}
- usb2_transfer_start(xfer);
+ usbd_transfer_start(xfer);
- while (usb2_transfer_pending(xfer)) {
+ while (usbd_transfer_pending(xfer)) {
cv_wait(udev->default_cv,
xfer->xroot->xfer_mtx);
}
@@ -465,7 +465,7 @@ usb2_do_request_flags(struct usb_device *udev, struct mtx *mtx,
#if USB_HAVE_USER_IO
if (flags & USB_USER_DATA_PTR) {
USB_XFER_UNLOCK(xfer);
- err = usb2_copy_out_user(xfer->frbuffers + 1,
+ err = usbd_copy_out_user(xfer->frbuffers + 1,
0, data, temp);
USB_XFER_LOCK(xfer);
if (err) {
@@ -474,7 +474,7 @@ usb2_do_request_flags(struct usb_device *udev, struct mtx *mtx,
}
} else
#endif
- usb2_copy_out(xfer->frbuffers + 1,
+ usbd_copy_out(xfer->frbuffers + 1,
0, data, temp);
}
}
@@ -509,7 +509,7 @@ usb2_do_request_flags(struct usb_device *udev, struct mtx *mtx,
* Make sure that the control endpoint is no longer
* blocked in case of a non-transfer related error:
*/
- usb2_transfer_stop(xfer);
+ usbd_transfer_stop(xfer);
}
USB_XFER_UNLOCK(xfer);
@@ -523,17 +523,17 @@ done:
}
/*------------------------------------------------------------------------*
- * usb2_do_request_proc - factored out code
+ * usbd_do_request_proc - factored out code
*
* This function is factored out code. It does basically the same like
- * usb2_do_request_flags, except it will check the status of the
+ * usbd_do_request_flags, except it will check the status of the
* passed process argument before doing the USB request. If the
* process is draining the USB_ERR_IOERROR code will be returned. It
* is assumed that the mutex associated with the process is locked
* when calling this function.
*------------------------------------------------------------------------*/
usb_error_t
-usb2_do_request_proc(struct usb_device *udev, struct usb_process *pproc,
+usbd_do_request_proc(struct usb_device *udev, struct usb_process *pproc,
struct usb_device_request *req, void *data, uint16_t flags,
uint16_t *actlen, usb_timeout_t timeout)
{
@@ -544,13 +544,13 @@ usb2_do_request_proc(struct usb_device *udev, struct usb_process *pproc,
len = UGETW(req->wLength);
/* check if the device is being detached */
- if (usb2_proc_is_gone(pproc)) {
+ if (usb_proc_is_gone(pproc)) {
err = USB_ERR_IOERROR;
goto done;
}
/* forward the USB request */
- err = usb2_do_request_flags(udev, pproc->up_mtx,
+ err = usbd_do_request_flags(udev, pproc->up_mtx,
req, data, flags, actlen, timeout);
done:
@@ -566,7 +566,7 @@ done:
}
/*------------------------------------------------------------------------*
- * usb2_req_reset_port
+ * usbd_req_reset_port
*
* This function will instruct an USB HUB to perform a reset sequence
* on the specified port number.
@@ -577,7 +577,7 @@ done:
* disabled.
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_reset_port(struct usb_device *udev, struct mtx *mtx, uint8_t port)
+usbd_req_reset_port(struct usb_device *udev, struct mtx *mtx, uint8_t port)
{
struct usb_port_status ps;
usb_error_t err;
@@ -588,19 +588,19 @@ usb2_req_reset_port(struct usb_device *udev, struct mtx *mtx, uint8_t port)
uint16_t pr_recovery_delay;
#endif
- err = usb2_req_set_port_feature(udev, mtx, port, UHF_PORT_RESET);
+ err = usbd_req_set_port_feature(udev, mtx, port, UHF_PORT_RESET);
if (err) {
goto done;
}
#if USB_DEBUG
/* range check input parameters */
- pr_poll_delay = usb2_pr_poll_delay;
+ pr_poll_delay = usb_pr_poll_delay;
if (pr_poll_delay < 1) {
pr_poll_delay = 1;
} else if (pr_poll_delay > 1000) {
pr_poll_delay = 1000;
}
- pr_recovery_delay = usb2_pr_recovery_delay;
+ pr_recovery_delay = usb_pr_recovery_delay;
if (pr_recovery_delay > 1000) {
pr_recovery_delay = 1000;
}
@@ -609,14 +609,14 @@ usb2_req_reset_port(struct usb_device *udev, struct mtx *mtx, uint8_t port)
while (1) {
#if USB_DEBUG
/* wait for the device to recover from reset */
- usb2_pause_mtx(mtx, USB_MS_TO_TICKS(pr_poll_delay));
+ usb_pause_mtx(mtx, USB_MS_TO_TICKS(pr_poll_delay));
n += pr_poll_delay;
#else
/* wait for the device to recover from reset */
- usb2_pause_mtx(mtx, USB_MS_TO_TICKS(USB_PORT_RESET_DELAY));
+ usb_pause_mtx(mtx, USB_MS_TO_TICKS(USB_PORT_RESET_DELAY));
n += USB_PORT_RESET_DELAY;
#endif
- err = usb2_req_get_port_status(udev, mtx, &ps, port);
+ err = usbd_req_get_port_status(udev, mtx, &ps, port);
if (err) {
goto done;
}
@@ -636,7 +636,7 @@ usb2_req_reset_port(struct usb_device *udev, struct mtx *mtx, uint8_t port)
}
/* clear port reset first */
- err = usb2_req_clear_port_feature(
+ err = usbd_req_clear_port_feature(
udev, mtx, port, UHF_C_PORT_RESET);
if (err) {
goto done;
@@ -648,20 +648,20 @@ usb2_req_reset_port(struct usb_device *udev, struct mtx *mtx, uint8_t port)
}
#if USB_DEBUG
/* wait for the device to recover from reset */
- usb2_pause_mtx(mtx, USB_MS_TO_TICKS(pr_recovery_delay));
+ usb_pause_mtx(mtx, USB_MS_TO_TICKS(pr_recovery_delay));
#else
/* wait for the device to recover from reset */
- usb2_pause_mtx(mtx, USB_MS_TO_TICKS(USB_PORT_RESET_RECOVERY));
+ usb_pause_mtx(mtx, USB_MS_TO_TICKS(USB_PORT_RESET_RECOVERY));
#endif
done:
DPRINTFN(2, "port %d reset returning error=%s\n",
- port, usb2_errstr(err));
+ port, usbd_errstr(err));
return (err);
}
/*------------------------------------------------------------------------*
- * usb2_req_get_desc
+ * usbd_req_get_desc
*
* This function can be used to retrieve USB descriptors. It contains
* some additional logic like zeroing of missing descriptor bytes and
@@ -685,7 +685,7 @@ done:
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_get_desc(struct usb_device *udev,
+usbd_req_get_desc(struct usb_device *udev,
struct mtx *mtx, uint16_t *actlen, void *desc,
uint16_t min_len, uint16_t max_len,
uint16_t id, uint8_t type, uint8_t index,
@@ -711,7 +711,7 @@ usb2_req_get_desc(struct usb_device *udev,
}
USETW(req.wLength, min_len);
- err = usb2_do_request_flags(udev, mtx, &req,
+ err = usbd_do_request_flags(udev, mtx, &req,
desc, 0, NULL, 1000);
if (err) {
@@ -720,7 +720,7 @@ usb2_req_get_desc(struct usb_device *udev,
}
retries--;
- usb2_pause_mtx(mtx, hz / 5);
+ usb_pause_mtx(mtx, hz / 5);
continue;
}
@@ -764,7 +764,7 @@ done:
}
/*------------------------------------------------------------------------*
- * usb2_req_get_string_any
+ * usbd_req_get_string_any
*
* This function will return the string given by "string_index"
* using the first language ID. The maximum length "len" includes
@@ -776,7 +776,7 @@ done:
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_get_string_any(struct usb_device *udev, struct mtx *mtx, char *buf,
+usbd_req_get_string_any(struct usb_device *udev, struct mtx *mtx, char *buf,
uint16_t len, uint8_t string_index)
{
char *s;
@@ -800,7 +800,7 @@ usb2_req_get_string_any(struct usb_device *udev, struct mtx *mtx, char *buf,
buf[0] = 0;
return (USB_ERR_STALLED);
}
- err = usb2_req_get_string_desc
+ err = usbd_req_get_string_desc
(udev, mtx, buf, len, udev->langid, string_index);
if (err) {
buf[0] = 0;
@@ -861,26 +861,26 @@ usb2_req_get_string_any(struct usb_device *udev, struct mtx *mtx, char *buf,
}
/*------------------------------------------------------------------------*
- * usb2_req_get_string_desc
+ * usbd_req_get_string_desc
*
* If you don't know the language ID, consider using
- * "usb2_req_get_string_any()".
+ * "usbd_req_get_string_any()".
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_get_string_desc(struct usb_device *udev, struct mtx *mtx, void *sdesc,
+usbd_req_get_string_desc(struct usb_device *udev, struct mtx *mtx, void *sdesc,
uint16_t max_len, uint16_t lang_id,
uint8_t string_index)
{
- return (usb2_req_get_desc(udev, mtx, NULL, sdesc, 2, max_len, lang_id,
+ return (usbd_req_get_desc(udev, mtx, NULL, sdesc, 2, max_len, lang_id,
UDESC_STRING, string_index, 0));
}
/*------------------------------------------------------------------------*
- * usb2_req_get_config_desc_ptr
+ * usbd_req_get_config_desc_ptr
*
* This function is used in device side mode to retrieve the pointer
* to the generated config descriptor. This saves allocating space for
@@ -891,7 +891,7 @@ usb2_req_get_string_desc(struct usb_device *udev, struct mtx *mtx, void *sdesc,
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_get_descriptor_ptr(struct usb_device *udev,
+usbd_req_get_descriptor_ptr(struct usb_device *udev,
struct usb_config_descriptor **ppcd, uint16_t wValue)
{
struct usb_device_request req;
@@ -909,7 +909,7 @@ usb2_req_get_descriptor_ptr(struct usb_device *udev,
ptr = NULL;
len = 0;
- hr_func = usb2_get_hr_func(udev);
+ hr_func = usbd_get_hr_func(udev);
if (hr_func == NULL)
err = USB_ERR_INVAL;
@@ -930,21 +930,21 @@ usb2_req_get_descriptor_ptr(struct usb_device *udev,
}
/*------------------------------------------------------------------------*
- * usb2_req_get_config_desc
+ * usbd_req_get_config_desc
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_get_config_desc(struct usb_device *udev, struct mtx *mtx,
+usbd_req_get_config_desc(struct usb_device *udev, struct mtx *mtx,
struct usb_config_descriptor *d, uint8_t conf_index)
{
usb_error_t err;
DPRINTFN(4, "confidx=%d\n", conf_index);
- err = usb2_req_get_desc(udev, mtx, NULL, d, sizeof(*d),
+ err = usbd_req_get_desc(udev, mtx, NULL, d, sizeof(*d),
sizeof(*d), 0, UDESC_CONFIG, conf_index, 0);
if (err) {
goto done;
@@ -958,7 +958,7 @@ done:
}
/*------------------------------------------------------------------------*
- * usb2_req_get_config_desc_full
+ * usbd_req_get_config_desc_full
*
* This function gets the complete USB configuration descriptor and
* ensures that "wTotalLength" is correct.
@@ -968,7 +968,7 @@ done:
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_get_config_desc_full(struct usb_device *udev, struct mtx *mtx,
+usbd_req_get_config_desc_full(struct usb_device *udev, struct mtx *mtx,
struct usb_config_descriptor **ppcd, struct malloc_type *mtype,
uint8_t index)
{
@@ -981,7 +981,7 @@ usb2_req_get_config_desc_full(struct usb_device *udev, struct mtx *mtx,
*ppcd = NULL;
- err = usb2_req_get_config_desc(udev, mtx, &cd, index);
+ err = usbd_req_get_config_desc(udev, mtx, &cd, index);
if (err) {
return (err);
}
@@ -995,7 +995,7 @@ usb2_req_get_config_desc_full(struct usb_device *udev, struct mtx *mtx,
if (cdesc == NULL) {
return (USB_ERR_NOMEM);
}
- err = usb2_req_get_desc(udev, mtx, NULL, cdesc, len, len, 0,
+ err = usbd_req_get_desc(udev, mtx, NULL, cdesc, len, len, 0,
UDESC_CONFIG, index, 3);
if (err) {
free(cdesc, mtype);
@@ -1010,33 +1010,33 @@ usb2_req_get_config_desc_full(struct usb_device *udev, struct mtx *mtx,
}
/*------------------------------------------------------------------------*
- * usb2_req_get_device_desc
+ * usbd_req_get_device_desc
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_get_device_desc(struct usb_device *udev, struct mtx *mtx,
+usbd_req_get_device_desc(struct usb_device *udev, struct mtx *mtx,
struct usb_device_descriptor *d)
{
DPRINTFN(4, "\n");
- return (usb2_req_get_desc(udev, mtx, NULL, d, sizeof(*d),
+ return (usbd_req_get_desc(udev, mtx, NULL, d, sizeof(*d),
sizeof(*d), 0, UDESC_DEVICE, 0, 3));
}
/*------------------------------------------------------------------------*
- * usb2_req_get_alt_interface_no
+ * usbd_req_get_alt_interface_no
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_get_alt_interface_no(struct usb_device *udev, struct mtx *mtx,
+usbd_req_get_alt_interface_no(struct usb_device *udev, struct mtx *mtx,
uint8_t *alt_iface_no, uint8_t iface_index)
{
- struct usb_interface *iface = usb2_get_iface(udev, iface_index);
+ struct usb_interface *iface = usbd_get_iface(udev, iface_index);
struct usb_device_request req;
if ((iface == NULL) || (iface->idesc == NULL)) {
@@ -1048,21 +1048,21 @@ usb2_req_get_alt_interface_no(struct usb_device *udev, struct mtx *mtx,
req.wIndex[0] = iface->idesc->bInterfaceNumber;
req.wIndex[1] = 0;
USETW(req.wLength, 1);
- return (usb2_do_request(udev, mtx, &req, alt_iface_no));
+ return (usbd_do_request(udev, mtx, &req, alt_iface_no));
}
/*------------------------------------------------------------------------*
- * usb2_req_set_alt_interface_no
+ * usbd_req_set_alt_interface_no
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_set_alt_interface_no(struct usb_device *udev, struct mtx *mtx,
+usbd_req_set_alt_interface_no(struct usb_device *udev, struct mtx *mtx,
uint8_t iface_index, uint8_t alt_no)
{
- struct usb_interface *iface = usb2_get_iface(udev, iface_index);
+ struct usb_interface *iface = usbd_get_iface(udev, iface_index);
struct usb_device_request req;
if ((iface == NULL) || (iface->idesc == NULL)) {
@@ -1075,18 +1075,18 @@ usb2_req_set_alt_interface_no(struct usb_device *udev, struct mtx *mtx,
req.wIndex[0] = iface->idesc->bInterfaceNumber;
req.wIndex[1] = 0;
USETW(req.wLength, 0);
- return (usb2_do_request(udev, mtx, &req, 0));
+ return (usbd_do_request(udev, mtx, &req, 0));
}
/*------------------------------------------------------------------------*
- * usb2_req_get_device_status
+ * usbd_req_get_device_status
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_get_device_status(struct usb_device *udev, struct mtx *mtx,
+usbd_req_get_device_status(struct usb_device *udev, struct mtx *mtx,
struct usb_status *st)
{
struct usb_device_request req;
@@ -1096,18 +1096,18 @@ usb2_req_get_device_status(struct usb_device *udev, struct mtx *mtx,
USETW(req.wValue, 0);
USETW(req.wIndex, 0);
USETW(req.wLength, sizeof(*st));
- return (usb2_do_request(udev, mtx, &req, st));
+ return (usbd_do_request(udev, mtx, &req, st));
}
/*------------------------------------------------------------------------*
- * usb2_req_get_hub_descriptor
+ * usbd_req_get_hub_descriptor
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_get_hub_descriptor(struct usb_device *udev, struct mtx *mtx,
+usbd_req_get_hub_descriptor(struct usb_device *udev, struct mtx *mtx,
struct usb_hub_descriptor *hd, uint8_t nports)
{
struct usb_device_request req;
@@ -1118,18 +1118,18 @@ usb2_req_get_hub_descriptor(struct usb_device *udev, struct mtx *mtx,
USETW2(req.wValue, UDESC_HUB, 0);
USETW(req.wIndex, 0);
USETW(req.wLength, len);
- return (usb2_do_request(udev, mtx, &req, hd));
+ return (usbd_do_request(udev, mtx, &req, hd));
}
/*------------------------------------------------------------------------*
- * usb2_req_get_hub_status
+ * usbd_req_get_hub_status
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_get_hub_status(struct usb_device *udev, struct mtx *mtx,
+usbd_req_get_hub_status(struct usb_device *udev, struct mtx *mtx,
struct usb_hub_status *st)
{
struct usb_device_request req;
@@ -1139,11 +1139,11 @@ usb2_req_get_hub_status(struct usb_device *udev, struct mtx *mtx,
USETW(req.wValue, 0);
USETW(req.wIndex, 0);
USETW(req.wLength, sizeof(struct usb_hub_status));
- return (usb2_do_request(udev, mtx, &req, st));
+ return (usbd_do_request(udev, mtx, &req, st));
}
/*------------------------------------------------------------------------*
- * usb2_req_set_address
+ * usbd_req_set_address
*
* This function is used to set the address for an USB device. After
* port reset the USB device will respond at address zero.
@@ -1153,7 +1153,7 @@ usb2_req_get_hub_status(struct usb_device *udev, struct mtx *mtx,
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_set_address(struct usb_device *udev, struct mtx *mtx, uint16_t addr)
+usbd_req_set_address(struct usb_device *udev, struct mtx *mtx, uint16_t addr)
{
struct usb_device_request req;
@@ -1166,19 +1166,19 @@ usb2_req_set_address(struct usb_device *udev, struct mtx *mtx, uint16_t addr)
USETW(req.wLength, 0);
/* Setting the address should not take more than 1 second ! */
- return (usb2_do_request_flags(udev, mtx, &req, NULL,
+ return (usbd_do_request_flags(udev, mtx, &req, NULL,
USB_DELAY_STATUS_STAGE, NULL, 1000));
}
/*------------------------------------------------------------------------*
- * usb2_req_get_port_status
+ * usbd_req_get_port_status
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_get_port_status(struct usb_device *udev, struct mtx *mtx,
+usbd_req_get_port_status(struct usb_device *udev, struct mtx *mtx,
struct usb_port_status *ps, uint8_t port)
{
struct usb_device_request req;
@@ -1189,18 +1189,18 @@ usb2_req_get_port_status(struct usb_device *udev, struct mtx *mtx,
req.wIndex[0] = port;
req.wIndex[1] = 0;
USETW(req.wLength, sizeof *ps);
- return (usb2_do_request(udev, mtx, &req, ps));
+ return (usbd_do_request(udev, mtx, &req, ps));
}
/*------------------------------------------------------------------------*
- * usb2_req_clear_hub_feature
+ * usbd_req_clear_hub_feature
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_clear_hub_feature(struct usb_device *udev, struct mtx *mtx,
+usbd_req_clear_hub_feature(struct usb_device *udev, struct mtx *mtx,
uint16_t sel)
{
struct usb_device_request req;
@@ -1210,18 +1210,18 @@ usb2_req_clear_hub_feature(struct usb_device *udev, struct mtx *mtx,
USETW(req.wValue, sel);
USETW(req.wIndex, 0);
USETW(req.wLength, 0);
- return (usb2_do_request(udev, mtx, &req, 0));
+ return (usbd_do_request(udev, mtx, &req, 0));
}
/*------------------------------------------------------------------------*
- * usb2_req_set_hub_feature
+ * usbd_req_set_hub_feature
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_set_hub_feature(struct usb_device *udev, struct mtx *mtx,
+usbd_req_set_hub_feature(struct usb_device *udev, struct mtx *mtx,
uint16_t sel)
{
struct usb_device_request req;
@@ -1231,18 +1231,18 @@ usb2_req_set_hub_feature(struct usb_device *udev, struct mtx *mtx,
USETW(req.wValue, sel);
USETW(req.wIndex, 0);
USETW(req.wLength, 0);
- return (usb2_do_request(udev, mtx, &req, 0));
+ return (usbd_do_request(udev, mtx, &req, 0));
}
/*------------------------------------------------------------------------*
- * usb2_req_clear_port_feature
+ * usbd_req_clear_port_feature
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_clear_port_feature(struct usb_device *udev, struct mtx *mtx,
+usbd_req_clear_port_feature(struct usb_device *udev, struct mtx *mtx,
uint8_t port, uint16_t sel)
{
struct usb_device_request req;
@@ -1253,18 +1253,18 @@ usb2_req_clear_port_feature(struct usb_device *udev, struct mtx *mtx,
req.wIndex[0] = port;
req.wIndex[1] = 0;
USETW(req.wLength, 0);
- return (usb2_do_request(udev, mtx, &req, 0));
+ return (usbd_do_request(udev, mtx, &req, 0));
}
/*------------------------------------------------------------------------*
- * usb2_req_set_port_feature
+ * usbd_req_set_port_feature
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_set_port_feature(struct usb_device *udev, struct mtx *mtx,
+usbd_req_set_port_feature(struct usb_device *udev, struct mtx *mtx,
uint8_t port, uint16_t sel)
{
struct usb_device_request req;
@@ -1275,21 +1275,21 @@ usb2_req_set_port_feature(struct usb_device *udev, struct mtx *mtx,
req.wIndex[0] = port;
req.wIndex[1] = 0;
USETW(req.wLength, 0);
- return (usb2_do_request(udev, mtx, &req, 0));
+ return (usbd_do_request(udev, mtx, &req, 0));
}
/*------------------------------------------------------------------------*
- * usb2_req_set_protocol
+ * usbd_req_set_protocol
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_set_protocol(struct usb_device *udev, struct mtx *mtx,
+usbd_req_set_protocol(struct usb_device *udev, struct mtx *mtx,
uint8_t iface_index, uint16_t report)
{
- struct usb_interface *iface = usb2_get_iface(udev, iface_index);
+ struct usb_interface *iface = usbd_get_iface(udev, iface_index);
struct usb_device_request req;
if ((iface == NULL) || (iface->idesc == NULL)) {
@@ -1304,21 +1304,21 @@ usb2_req_set_protocol(struct usb_device *udev, struct mtx *mtx,
req.wIndex[0] = iface->idesc->bInterfaceNumber;
req.wIndex[1] = 0;
USETW(req.wLength, 0);
- return (usb2_do_request(udev, mtx, &req, 0));
+ return (usbd_do_request(udev, mtx, &req, 0));
}
/*------------------------------------------------------------------------*
- * usb2_req_set_report
+ * usbd_req_set_report
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_set_report(struct usb_device *udev, struct mtx *mtx, void *data, uint16_t len,
+usbd_req_set_report(struct usb_device *udev, struct mtx *mtx, void *data, uint16_t len,
uint8_t iface_index, uint8_t type, uint8_t id)
{
- struct usb_interface *iface = usb2_get_iface(udev, iface_index);
+ struct usb_interface *iface = usbd_get_iface(udev, iface_index);
struct usb_device_request req;
if ((iface == NULL) || (iface->idesc == NULL)) {
@@ -1332,21 +1332,21 @@ usb2_req_set_report(struct usb_device *udev, struct mtx *mtx, void *data, uint16
req.wIndex[0] = iface->idesc->bInterfaceNumber;
req.wIndex[1] = 0;
USETW(req.wLength, len);
- return (usb2_do_request(udev, mtx, &req, data));
+ return (usbd_do_request(udev, mtx, &req, data));
}
/*------------------------------------------------------------------------*
- * usb2_req_get_report
+ * usbd_req_get_report
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_get_report(struct usb_device *udev, struct mtx *mtx, void *data,
+usbd_req_get_report(struct usb_device *udev, struct mtx *mtx, void *data,
uint16_t len, uint8_t iface_index, uint8_t type, uint8_t id)
{
- struct usb_interface *iface = usb2_get_iface(udev, iface_index);
+ struct usb_interface *iface = usbd_get_iface(udev, iface_index);
struct usb_device_request req;
if ((iface == NULL) || (iface->idesc == NULL) || (id == 0)) {
@@ -1360,21 +1360,21 @@ usb2_req_get_report(struct usb_device *udev, struct mtx *mtx, void *data,
req.wIndex[0] = iface->idesc->bInterfaceNumber;
req.wIndex[1] = 0;
USETW(req.wLength, len);
- return (usb2_do_request(udev, mtx, &req, data));
+ return (usbd_do_request(udev, mtx, &req, data));
}
/*------------------------------------------------------------------------*
- * usb2_req_set_idle
+ * usbd_req_set_idle
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_set_idle(struct usb_device *udev, struct mtx *mtx,
+usbd_req_set_idle(struct usb_device *udev, struct mtx *mtx,
uint8_t iface_index, uint8_t duration, uint8_t id)
{
- struct usb_interface *iface = usb2_get_iface(udev, iface_index);
+ struct usb_interface *iface = usbd_get_iface(udev, iface_index);
struct usb_device_request req;
if ((iface == NULL) || (iface->idesc == NULL)) {
@@ -1388,21 +1388,21 @@ usb2_req_set_idle(struct usb_device *udev, struct mtx *mtx,
req.wIndex[0] = iface->idesc->bInterfaceNumber;
req.wIndex[1] = 0;
USETW(req.wLength, 0);
- return (usb2_do_request(udev, mtx, &req, 0));
+ return (usbd_do_request(udev, mtx, &req, 0));
}
/*------------------------------------------------------------------------*
- * usb2_req_get_report_descriptor
+ * usbd_req_get_report_descriptor
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_get_report_descriptor(struct usb_device *udev, struct mtx *mtx,
+usbd_req_get_report_descriptor(struct usb_device *udev, struct mtx *mtx,
void *d, uint16_t size, uint8_t iface_index)
{
- struct usb_interface *iface = usb2_get_iface(udev, iface_index);
+ struct usb_interface *iface = usbd_get_iface(udev, iface_index);
struct usb_device_request req;
if ((iface == NULL) || (iface->idesc == NULL)) {
@@ -1414,11 +1414,11 @@ usb2_req_get_report_descriptor(struct usb_device *udev, struct mtx *mtx,
req.wIndex[0] = iface->idesc->bInterfaceNumber;
req.wIndex[1] = 0;
USETW(req.wLength, size);
- return (usb2_do_request(udev, mtx, &req, d));
+ return (usbd_do_request(udev, mtx, &req, d));
}
/*------------------------------------------------------------------------*
- * usb2_req_set_config
+ * usbd_req_set_config
*
* This function is used to select the current configuration number in
* both USB device side mode and USB host side mode. When setting the
@@ -1429,7 +1429,7 @@ usb2_req_get_report_descriptor(struct usb_device *udev, struct mtx *mtx,
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_set_config(struct usb_device *udev, struct mtx *mtx, uint8_t conf)
+usbd_req_set_config(struct usb_device *udev, struct mtx *mtx, uint8_t conf)
{
struct usb_device_request req;
@@ -1443,18 +1443,18 @@ usb2_req_set_config(struct usb_device *udev, struct mtx *mtx, uint8_t conf)
req.wValue[1] = 0;
USETW(req.wIndex, 0);
USETW(req.wLength, 0);
- return (usb2_do_request(udev, mtx, &req, 0));
+ return (usbd_do_request(udev, mtx, &req, 0));
}
/*------------------------------------------------------------------------*
- * usb2_req_get_config
+ * usbd_req_get_config
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_get_config(struct usb_device *udev, struct mtx *mtx, uint8_t *pconf)
+usbd_req_get_config(struct usb_device *udev, struct mtx *mtx, uint8_t *pconf)
{
struct usb_device_request req;
@@ -1463,11 +1463,11 @@ usb2_req_get_config(struct usb_device *udev, struct mtx *mtx, uint8_t *pconf)
USETW(req.wValue, 0);
USETW(req.wIndex, 0);
USETW(req.wLength, 1);
- return (usb2_do_request(udev, mtx, &req, pconf));
+ return (usbd_do_request(udev, mtx, &req, pconf));
}
/*------------------------------------------------------------------------*
- * usb2_req_re_enumerate
+ * usbd_req_re_enumerate
*
* NOTE: After this function returns the hardware is in the
* unconfigured state! The application is responsible for setting a
@@ -1478,7 +1478,7 @@ usb2_req_get_config(struct usb_device *udev, struct mtx *mtx, uint8_t *pconf)
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_re_enumerate(struct usb_device *udev, struct mtx *mtx)
+usbd_req_re_enumerate(struct usb_device *udev, struct mtx *mtx)
{
struct usb_device *parent_hub;
usb_error_t err;
@@ -1494,10 +1494,10 @@ usb2_req_re_enumerate(struct usb_device *udev, struct mtx *mtx)
return (USB_ERR_INVAL);
}
retry:
- err = usb2_req_reset_port(parent_hub, mtx, udev->port_no);
+ err = usbd_req_reset_port(parent_hub, mtx, udev->port_no);
if (err) {
DPRINTFN(0, "addr=%d, port reset failed, %s\n",
- old_addr, usb2_errstr(err));
+ old_addr, usbd_errstr(err));
goto done;
}
/*
@@ -1512,39 +1512,39 @@ retry:
/*
* Restore device address:
*/
- err = usb2_req_set_address(udev, mtx, old_addr);
+ err = usbd_req_set_address(udev, mtx, old_addr);
if (err) {
/* XXX ignore any errors! */
DPRINTFN(0, "addr=%d, set address failed! (%s, ignored)\n",
- old_addr, usb2_errstr(err));
+ old_addr, usbd_errstr(err));
}
/* restore device address */
udev->address = old_addr;
/* allow device time to set new address */
- usb2_pause_mtx(mtx, USB_MS_TO_TICKS(USB_SET_ADDRESS_SETTLE));
+ usb_pause_mtx(mtx, USB_MS_TO_TICKS(USB_SET_ADDRESS_SETTLE));
/* get the device descriptor */
- err = usb2_req_get_desc(udev, mtx, NULL, &udev->ddesc,
+ err = usbd_req_get_desc(udev, mtx, NULL, &udev->ddesc,
USB_MAX_IPACKET, USB_MAX_IPACKET, 0, UDESC_DEVICE, 0, 0);
if (err) {
DPRINTFN(0, "getting device descriptor "
"at addr %d failed, %s!\n", udev->address,
- usb2_errstr(err));
+ usbd_errstr(err));
goto done;
}
/* get the full device descriptor */
- err = usb2_req_get_device_desc(udev, mtx, &udev->ddesc);
+ err = usbd_req_get_device_desc(udev, mtx, &udev->ddesc);
if (err) {
DPRINTFN(0, "addr=%d, getting device "
"descriptor failed, %s!\n", old_addr,
- usb2_errstr(err));
+ usbd_errstr(err));
goto done;
}
done:
if (err && do_retry) {
/* give the USB firmware some time to load */
- usb2_pause_mtx(mtx, hz / 2);
+ usb_pause_mtx(mtx, hz / 2);
/* no more retries after this retry */
do_retry = 0;
/* try again */
@@ -1556,14 +1556,14 @@ done:
}
/*------------------------------------------------------------------------*
- * usb2_req_clear_device_feature
+ * usbd_req_clear_device_feature
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_clear_device_feature(struct usb_device *udev, struct mtx *mtx,
+usbd_req_clear_device_feature(struct usb_device *udev, struct mtx *mtx,
uint16_t sel)
{
struct usb_device_request req;
@@ -1573,18 +1573,18 @@ usb2_req_clear_device_feature(struct usb_device *udev, struct mtx *mtx,
USETW(req.wValue, sel);
USETW(req.wIndex, 0);
USETW(req.wLength, 0);
- return (usb2_do_request(udev, mtx, &req, 0));
+ return (usbd_do_request(udev, mtx, &req, 0));
}
/*------------------------------------------------------------------------*
- * usb2_req_set_device_feature
+ * usbd_req_set_device_feature
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
usb_error_t
-usb2_req_set_device_feature(struct usb_device *udev, struct mtx *mtx,
+usbd_req_set_device_feature(struct usb_device *udev, struct mtx *mtx,
uint16_t sel)
{
struct usb_device_request req;
@@ -1594,5 +1594,5 @@ usb2_req_set_device_feature(struct usb_device *udev, struct mtx *mtx,
USETW(req.wValue, sel);
USETW(req.wIndex, 0);
USETW(req.wLength, 0);
- return (usb2_do_request(udev, mtx, &req, 0));
+ return (usbd_do_request(udev, mtx, &req, 0));
}
OpenPOWER on IntegriCloud