From: Greg KH To: torvalds@transmeta.com Cc: linux-usb-devel@lists.sourceforge.net Subject: [PATCH 7 of 7] USB devrequest changes Hi, Here's a patch against 2.5.2-pre9 that renames the "generic" devrequest typedef, and replaces it with the "struct usb_ctrlrequest". It also renames the fields of the structure to match the USB protocol field names and adds some documentation for the structure. The patch was done by Johannes, with some small changes by me. thanks, greg k-h diff -Nru a/arch/cris/drivers/usb-host.c b/arch/cris/drivers/usb-host.c --- a/arch/cris/drivers/usb-host.c Sun Jan 6 12:18:36 2002 +++ b/arch/cris/drivers/usb-host.c Sun Jan 6 12:18:36 2002 @@ -1981,7 +1981,7 @@ struct usb_device *usb_dev = urb->dev; etrax_hc_t *hc = usb_dev->bus->hcpriv; unsigned int pipe = urb->pipe; - devrequest *cmd = (devrequest *) urb->setup_packet; + struct usb_ctrlrequest *cmd = (struct usb_ctrlrequest *) urb->setup_packet; void *data = urb->transfer_buffer; int leni = urb->transfer_buffer_length; int len = 0; @@ -2009,10 +2009,10 @@ return 0; } - bmRType_bReq = cmd->requesttype | cmd->request << 8; - wValue = le16_to_cpu(cmd->value); - wIndex = le16_to_cpu(cmd->index); - wLength = le16_to_cpu(cmd->length); + bmRType_bReq = cmd->bRequestType | cmd->bRequest << 8; + wValue = le16_to_cpu(cmd->wValue); + wIndex = le16_to_cpu(cmd->wIndex); + wLength = le16_to_cpu(cmd->wLength); dbg_rh("bmRType_bReq : 0x%04X (%d)", bmRType_bReq, bmRType_bReq); dbg_rh("wValue : 0x%04X (%d)", wValue, wValue); diff -Nru a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c --- a/drivers/bluetooth/hci_usb.c Sun Jan 6 12:18:36 2002 +++ b/drivers/bluetooth/hci_usb.c Sun Jan 6 12:18:36 2002 @@ -437,18 +437,18 @@ static int hci_usb_ctrl_msg(struct hci_usb *husb, struct sk_buff *skb) { struct urb *urb = husb->ctrl_urb; - devrequest *dr = &husb->dev_req; + struct usb_ctrlrequest *dr = &husb->dev_req; int pipe, status; DBG("%s len %d", husb->hdev.name, skb->len); pipe = usb_sndctrlpipe(husb->udev, 0); - dr->requesttype = HCI_CTRL_REQ; - dr->request = 0; - dr->index = 0; - dr->value = 0; - dr->length = cpu_to_le16(skb->len); + dr->bRequestType = HCI_CTRL_REQ; + dr->bRequest = 0; + dr->wIndex = 0; + dr->wValue = 0; + dr->wLength = cpu_to_le16(skb->len); FILL_CONTROL_URB(urb, husb->udev, pipe, (void*)dr, skb->data, skb->len, hci_usb_ctrl, skb); diff -Nru a/drivers/char/joystick/iforce.c b/drivers/char/joystick/iforce.c --- a/drivers/char/joystick/iforce.c Sun Jan 6 12:18:37 2002 +++ b/drivers/char/joystick/iforce.c Sun Jan 6 12:18:37 2002 @@ -134,7 +134,7 @@ #ifdef IFORCE_USB struct usb_device *usbdev; /* USB transfer */ struct urb irq, out, ctrl; - devrequest dr; + struct usb_ctrlrequest dr; #endif /* Force Feedback */ wait_queue_head_t wait; @@ -283,7 +283,7 @@ #ifdef IFORCE_USB case IFORCE_USB: - iforce->dr.request = packet[0]; + iforce->dr.bRequest = packet[0]; iforce->ctrl.dev = iforce->usbdev; set_current_state(TASK_INTERRUPTIBLE); @@ -1027,9 +1027,9 @@ iforce->bus = IFORCE_USB; iforce->usbdev = dev; - iforce->dr.requesttype = USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_INTERFACE; - iforce->dr.index = 0; - iforce->dr.length = 16; + iforce->dr.bRequestType = USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_INTERFACE; + iforce->dr.wIndex = 0; + iforce->dr.wLength = 16; FILL_INT_URB(&iforce->irq, dev, usb_rcvintpipe(dev, epirq->bEndpointAddress), iforce->data, 16, iforce_usb_irq, iforce, epirq->bInterval); diff -Nru a/drivers/isdn/hisax/st5481.h b/drivers/isdn/hisax/st5481.h --- a/drivers/isdn/hisax/st5481.h Sun Jan 6 12:18:37 2002 +++ b/drivers/isdn/hisax/st5481.h Sun Jan 6 12:18:37 2002 @@ -309,7 +309,7 @@ typedef void (*ctrl_complete_t)(void *); typedef struct ctrl_msg { - devrequest dr; + struct usb_ctrlrequest dr; ctrl_complete_t complete; void *context; } ctrl_msg; diff -Nru a/drivers/isdn/hisax/st5481_usb.c b/drivers/isdn/hisax/st5481_usb.c --- a/drivers/isdn/hisax/st5481_usb.c Sun Jan 6 12:18:36 2002 +++ b/drivers/isdn/hisax/st5481_usb.c Sun Jan 6 12:18:36 2002 @@ -41,9 +41,9 @@ (unsigned char *)&ctrl->msg_fifo.data[r_index]; DBG(1,"request=0x%02x,value=0x%04x,index=%x", - ((struct ctrl_msg *)urb->setup_packet)->dr.request, - ((struct ctrl_msg *)urb->setup_packet)->dr.value, - ((struct ctrl_msg *)urb->setup_packet)->dr.index); + ((struct ctrl_msg *)urb->setup_packet)->dr.bRequest, + ((struct ctrl_msg *)urb->setup_packet)->dr.wValue, + ((struct ctrl_msg *)urb->setup_packet)->dr.wIndex); // Prepare the URB urb->dev = adapter->usb_dev; @@ -69,11 +69,11 @@ } ctrl_msg = &ctrl->msg_fifo.data[w_index]; - ctrl_msg->dr.requesttype = requesttype; - ctrl_msg->dr.request = request; - ctrl_msg->dr.value = cpu_to_le16p(&value); - ctrl_msg->dr.index = cpu_to_le16p(&index); - ctrl_msg->dr.length = 0; + ctrl_msg->dr.bRequestType = requesttype; + ctrl_msg->dr.bRequest = request; + ctrl_msg->dr.wValue = cpu_to_le16p(&value); + ctrl_msg->dr.wIndex = cpu_to_le16p(&index); + ctrl_msg->dr.wLength = 0; ctrl_msg->complete = complete; ctrl_msg->context = context; @@ -140,17 +140,17 @@ ctrl_msg = (struct ctrl_msg *)urb->setup_packet; - if (ctrl_msg->dr.request == USB_REQ_CLEAR_FEATURE) { + if (ctrl_msg->dr.bRequest == USB_REQ_CLEAR_FEATURE) { /* Special case handling for pipe reset */ - le16_to_cpus(&ctrl_msg->dr.index); + le16_to_cpus(&ctrl_msg->dr.wIndex); usb_endpoint_running(adapter->usb_dev, - ctrl_msg->dr.index & ~USB_DIR_IN, - (ctrl_msg->dr.index & USB_DIR_IN) == 0); + ctrl_msg->dr.wIndex & ~USB_DIR_IN, + (ctrl_msg->dr.wIndex & USB_DIR_IN) == 0); /* toggle is reset on clear */ usb_settoggle(adapter->usb_dev, - ctrl_msg->dr.index & ~USB_DIR_IN, - (ctrl_msg->dr.index & USB_DIR_IN) == 0, + ctrl_msg->dr.wIndex & ~USB_DIR_IN, + (ctrl_msg->dr.wIndex & USB_DIR_IN) == 0, 0); @@ -560,7 +560,7 @@ */ int st5481_isoc_flatten(struct urb *urb) { - piso_packet_descriptor_t pipd,pend; + iso_packet_descriptor_t *pipd, *pend; unsigned char *src,*dst; unsigned int len; diff -Nru a/drivers/usb/acm.c b/drivers/usb/acm.c --- a/drivers/usb/acm.c Sun Jan 6 12:18:37 2002 +++ b/drivers/usb/acm.c Sun Jan 6 12:18:37 2002 @@ -184,7 +184,7 @@ static void acm_ctrl_irq(struct urb *urb) { struct acm *acm = urb->context; - devrequest *dr = urb->transfer_buffer; + struct usb_ctrlrequest *dr = urb->transfer_buffer; unsigned char *data = (unsigned char *)(dr + 1); int newctrl; @@ -195,7 +195,7 @@ return; } - switch (dr->request) { + switch (dr->bRequest) { case ACM_IRQ_NETWORK: @@ -223,7 +223,7 @@ default: dbg("unknown control event received: request %d index %d len %d data0 %d data1 %d", - dr->request, dr->index, dr->length, data[0], data[1]); + dr->bRequest, dr->wIndex, dr->wLength, data[0], data[1]); return; } } diff -Nru a/drivers/usb/bluetooth.c b/drivers/usb/bluetooth.c --- a/drivers/usb/bluetooth.c Sun Jan 6 12:18:37 2002 +++ b/drivers/usb/bluetooth.c Sun Jan 6 12:18:37 2002 @@ -179,7 +179,7 @@ __u8 control_out_bInterfaceNum; struct urb * control_urb_pool[NUM_CONTROL_URBS]; - devrequest dr[NUM_CONTROL_URBS]; + struct usb_ctrlrequest dr[NUM_CONTROL_URBS]; unsigned char * interrupt_in_buffer; struct urb * interrupt_in_urb; @@ -288,7 +288,7 @@ static int bluetooth_ctrl_msg (struct usb_bluetooth *bluetooth, int request, int value, const unsigned char *buf, int len) { struct urb *urb = NULL; - devrequest *dr = NULL; + struct usb_ctrlrequest *dr = NULL; int i; int status; @@ -325,11 +325,11 @@ } memcpy (urb->transfer_buffer, buf, len); - dr->requesttype = BLUETOOTH_CONTROL_REQUEST_TYPE; - dr->request = request; - dr->value = cpu_to_le16((u16) value); - dr->index = cpu_to_le16((u16) bluetooth->control_out_bInterfaceNum); - dr->length = cpu_to_le16((u16) len); + dr->bRequestType= BLUETOOTH_CONTROL_REQUEST_TYPE; + dr->bRequest = request; + dr->wValue = cpu_to_le16((u16) value); + dr->wIndex = cpu_to_le16((u16) bluetooth->control_out_bInterfaceNum); + dr->wLength = cpu_to_le16((u16) len); FILL_CONTROL_URB (urb, bluetooth->dev, usb_sndctrlpipe(bluetooth->dev, 0), (unsigned char*)dr, urb->transfer_buffer, len, bluetooth_ctrl_callback, bluetooth); diff -Nru a/drivers/usb/catc.c b/drivers/usb/catc.c --- a/drivers/usb/catc.c Sun Jan 6 12:18:37 2002 +++ b/drivers/usb/catc.c Sun Jan 6 12:18:37 2002 @@ -159,7 +159,7 @@ u8 rx_buf[RX_MAX_BURST * (PKT_SZ + 2)]; u8 irq_buf[2]; u8 ctrl_buf[64]; - devrequest ctrl_dr; + struct usb_ctrlrequest ctrl_dr; struct timer_list timer; u8 stats_buf[8]; @@ -383,14 +383,14 @@ struct ctrl_queue *q = catc->ctrl_queue + catc->ctrl_tail; struct usb_device *usbdev = catc->usbdev; struct urb *urb = &catc->ctrl_urb; - devrequest *dr = &catc->ctrl_dr; + struct usb_ctrlrequest *dr = &catc->ctrl_dr; int status; - dr->request = q->request; - dr->requesttype = 0x40 | q->dir; - dr->value = cpu_to_le16(q->value); - dr->index = cpu_to_le16(q->index); - dr->length = cpu_to_le16(q->len); + dr->bRequest = q->request; + dr->bRequestType = 0x40 | q->dir; + dr->wValue = cpu_to_le16(q->value); + dr->wIndex = cpu_to_le16(q->index); + dr->wLength = cpu_to_le16(q->len); urb->pipe = q->dir ? usb_rcvctrlpipe(usbdev, 0) : usb_sndctrlpipe(usbdev, 0); urb->transfer_buffer_length = q->len; diff -Nru a/drivers/usb/devio.c b/drivers/usb/devio.c --- a/drivers/usb/devio.c Sun Jan 6 12:18:35 2002 +++ b/drivers/usb/devio.c Sun Jan 6 12:18:35 2002 @@ -527,40 +527,40 @@ if (copy_from_user(&ctrl, (void *)arg, sizeof(ctrl))) return -EFAULT; - if ((ret = check_ctrlrecip(ps, ctrl.requesttype, ctrl.index))) + if ((ret = check_ctrlrecip(ps, ctrl.bRequestType, ctrl.wIndex))) return ret; - if (ctrl.length > PAGE_SIZE) + if (ctrl.wLength > PAGE_SIZE) return -EINVAL; if (!(tbuf = (unsigned char *)__get_free_page(GFP_KERNEL))) return -ENOMEM; tmo = (ctrl.timeout * HZ + 999) / 1000; - if (ctrl.requesttype & 0x80) { - if (ctrl.length && !access_ok(VERIFY_WRITE, ctrl.data, ctrl.length)) { + if (ctrl.bRequestType & 0x80) { + if (ctrl.wLength && !access_ok(VERIFY_WRITE, ctrl.data, ctrl.wLength)) { free_page((unsigned long)tbuf); return -EINVAL; } - i = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), ctrl.request, ctrl.requesttype, - ctrl.value, ctrl.index, tbuf, ctrl.length, tmo); - if ((i > 0) && ctrl.length) { - if (copy_to_user(ctrl.data, tbuf, ctrl.length)) { + i = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), ctrl.bRequest, ctrl.bRequestType, + ctrl.wValue, ctrl.wIndex, tbuf, ctrl.wLength, tmo); + if ((i > 0) && ctrl.wLength) { + if (copy_to_user(ctrl.data, tbuf, ctrl.wLength)) { free_page((unsigned long)tbuf); return -EFAULT; } } } else { - if (ctrl.length) { - if (copy_from_user(tbuf, ctrl.data, ctrl.length)) { + if (ctrl.wLength) { + if (copy_from_user(tbuf, ctrl.data, ctrl.wLength)) { free_page((unsigned long)tbuf); return -EFAULT; } } - i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), ctrl.request, ctrl.requesttype, - ctrl.value, ctrl.index, tbuf, ctrl.length, tmo); + i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), ctrl.bRequest, ctrl.bRequestType, + ctrl.wValue, ctrl.wIndex, tbuf, ctrl.wLength, tmo); } free_page((unsigned long)tbuf); if (i<0) { printk(KERN_DEBUG "usbdevfs: USBDEVFS_CONTROL failed dev %d rqt %u rq %u len %u ret %d\n", - dev->devnum, ctrl.requesttype, ctrl.request, ctrl.length, i); + dev->devnum, ctrl.bRequestType, ctrl.bRequest, ctrl.wLength, i); } return i; } @@ -757,7 +757,7 @@ struct usbdevfs_iso_packet_desc *isopkt = NULL; struct usb_endpoint_descriptor *ep_desc; struct async *as; - devrequest *dr = NULL; + struct usb_ctrlrequest *dr = NULL; unsigned int u, totlen, isofrmlen; int ret; @@ -787,23 +787,23 @@ /* min 8 byte setup packet, max arbitrary */ if (uurb.buffer_length < 8 || uurb.buffer_length > PAGE_SIZE) return -EINVAL; - if (!(dr = kmalloc(sizeof(devrequest), GFP_KERNEL))) + if (!(dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL))) return -ENOMEM; if (copy_from_user(dr, (unsigned char*)uurb.buffer, 8)) { kfree(dr); return -EFAULT; } - if (uurb.buffer_length < (le16_to_cpup(&dr->length) + 8)) { + if (uurb.buffer_length < (le16_to_cpup(&dr->wLength) + 8)) { kfree(dr); return -EINVAL; } - if ((ret = check_ctrlrecip(ps, dr->requesttype, le16_to_cpup(&dr->index)))) { + if ((ret = check_ctrlrecip(ps, dr->bRequestType, le16_to_cpup(&dr->wIndex)))) { kfree(dr); return ret; } - uurb.endpoint = (uurb.endpoint & ~USB_ENDPOINT_DIR_MASK) | (dr->requesttype & USB_ENDPOINT_DIR_MASK); + uurb.endpoint = (uurb.endpoint & ~USB_ENDPOINT_DIR_MASK) | (dr->bRequestType & USB_ENDPOINT_DIR_MASK); uurb.number_of_packets = 0; - uurb.buffer_length = le16_to_cpup(&dr->length); + uurb.buffer_length = le16_to_cpup(&dr->wLength); uurb.buffer += 8; if (!access_ok((uurb.endpoint & USB_DIR_IN) ? VERIFY_WRITE : VERIFY_READ, uurb.buffer, uurb.buffer_length)) { kfree(dr); diff -Nru a/drivers/usb/hcd/ehci-q.c b/drivers/usb/hcd/ehci-q.c --- a/drivers/usb/hcd/ehci-q.c Sun Jan 6 12:18:37 2002 +++ b/drivers/usb/hcd/ehci-q.c Sun Jan 6 12:18:37 2002 @@ -362,7 +362,7 @@ /* SETUP for control urb? */ if (unlikely (QTD_PID (token) == 2)) pci_unmap_single (ehci->hcd.pdev, - qtd->buf_dma, sizeof (devrequest), + qtd->buf_dma, sizeof (struct usb_ctrlrequest), PCI_DMA_TODEVICE); /* another queued urb? */ @@ -443,13 +443,13 @@ qtd->buf_dma = pci_map_single ( ehci->hcd.pdev, urb->setup_packet, - sizeof (devrequest), + sizeof (struct usb_ctrlrequest), PCI_DMA_TODEVICE); if (unlikely (!qtd->buf_dma)) goto cleanup; /* SETUP pid */ - qtd_fill (qtd, qtd->buf_dma, sizeof (devrequest), + qtd_fill (qtd, qtd->buf_dma, sizeof (struct usb_ctrlrequest), token | (2 /* "setup" */ << 8)); /* ... and always at least one more pid */ diff -Nru a/drivers/usb/hcd.c b/drivers/usb/hcd.c --- a/drivers/usb/hcd.c Sun Jan 6 12:18:37 2002 +++ b/drivers/usb/hcd.c Sun Jan 6 12:18:37 2002 @@ -268,16 +268,16 @@ /* Root hub control transfers execute synchronously */ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb) { - devrequest *cmd = (devrequest *) urb->setup_packet; + struct usb_ctrlrequest *cmd = (struct usb_ctrlrequest *) urb->setup_packet; u16 typeReq, wValue, wIndex, wLength; const u8 *bufp = 0; u8 *ubuf = urb->transfer_buffer; int len = 0; - typeReq = (cmd->requesttype << 8) | cmd->request; - wValue = le16_to_cpu (cmd->value); - wIndex = le16_to_cpu (cmd->index); - wLength = le16_to_cpu (cmd->length); + typeReq = (cmd->bRequestType << 8) | cmd->bRequest; + wValue = le16_to_cpu (cmd->wValue); + wIndex = le16_to_cpu (cmd->wIndex); + wLength = le16_to_cpu (cmd->wLength); if (wLength > urb->transfer_buffer_length) goto error; diff -Nru a/drivers/usb/hid-core.c b/drivers/usb/hid-core.c --- a/drivers/usb/hid-core.c Sun Jan 6 12:18:36 2002 +++ b/drivers/usb/hid-core.c Sun Jan 6 12:18:36 2002 @@ -987,7 +987,7 @@ static int hid_submit_out(struct hid_device *hid) { - hid->urbout.transfer_buffer_length = le16_to_cpup(&hid->out[hid->outtail].dr.length); + hid->urbout.transfer_buffer_length = le16_to_cpup(&hid->out[hid->outtail].dr.wLength); hid->urbout.transfer_buffer = hid->out[hid->outtail].buffer; hid->urbout.setup_packet = (void *) &(hid->out[hid->outtail].dr); hid->urbout.dev = hid->dev; @@ -1017,8 +1017,8 @@ { hid_output_report(report, hid->out[hid->outhead].buffer); - hid->out[hid->outhead].dr.value = cpu_to_le16(0x200 | report->id); - hid->out[hid->outhead].dr.length = cpu_to_le16((report->size + 7) >> 3); + hid->out[hid->outhead].dr.wValue = cpu_to_le16(0x200 | report->id); + hid->out[hid->outhead].dr.wLength = cpu_to_le16((report->size + 7) >> 3); hid->outhead = (hid->outhead + 1) & (HID_CONTROL_FIFO_SIZE - 1); @@ -1179,9 +1179,9 @@ hid->ifnum = interface->bInterfaceNumber; for (n = 0; n < HID_CONTROL_FIFO_SIZE; n++) { - hid->out[n].dr.requesttype = USB_TYPE_CLASS | USB_RECIP_INTERFACE; - hid->out[n].dr.request = HID_REQ_SET_REPORT; - hid->out[n].dr.index = cpu_to_le16(hid->ifnum); + hid->out[n].dr.bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE; + hid->out[n].dr.bRequest = HID_REQ_SET_REPORT; + hid->out[n].dr.wIndex = cpu_to_le16(hid->ifnum); } hid->name[0] = 0; diff -Nru a/drivers/usb/hid.h b/drivers/usb/hid.h --- a/drivers/usb/hid.h Sun Jan 6 12:18:36 2002 +++ b/drivers/usb/hid.h Sun Jan 6 12:18:36 2002 @@ -367,7 +367,7 @@ #define HID_CONTROL_FIFO_SIZE 8 struct hid_control_fifo { - devrequest dr; + struct usb_ctrlrequest dr; char buffer[HID_BUFFER_SIZE]; }; diff -Nru a/drivers/usb/kaweth.c b/drivers/usb/kaweth.c --- a/drivers/usb/kaweth.c Sun Jan 6 12:18:36 2002 +++ b/drivers/usb/kaweth.c Sun Jan 6 12:18:36 2002 @@ -110,8 +110,8 @@ ); static void kaweth_disconnect(struct usb_device *dev, void *ptr); int kaweth_internal_control_msg(struct usb_device *usb_dev, unsigned int pipe, - devrequest *cmd, void *data, int len, - int timeout); + struct usb_ctrlrequest *cmd, void *data, + int len, int timeout); /**************************************************************** * usb_device_id @@ -229,7 +229,7 @@ __u16 size, int timeout) { - devrequest *dr; + struct usb_ctrlrequest *dr; kaweth_dbg("kaweth_control()"); @@ -238,20 +238,19 @@ return -EBUSY; } - dr = kmalloc(sizeof(devrequest), + dr = kmalloc(sizeof(struct usb_ctrlrequest), in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); - if(!dr) - { + if (!dr) { kaweth_dbg("kmalloc() failed"); return -ENOMEM; } - dr->requesttype = requesttype; - dr->request = request; - dr->value = cpu_to_le16p(&value); - dr->index = cpu_to_le16p(&index); - dr->length = cpu_to_le16p(&size); + dr->bRequestType= requesttype; + dr->bRequest = request; + dr->wValue = cpu_to_le16p(&value); + dr->wIndex = cpu_to_le16p(&index); + dr->wLength = cpu_to_le16p(&size); return kaweth_internal_control_msg(kaweth->dev, pipe, @@ -1015,7 +1014,8 @@ /*-------------------------------------------------------------------*/ // returns status (negative) or length (positive) int kaweth_internal_control_msg(struct usb_device *usb_dev, unsigned int pipe, - devrequest *cmd, void *data, int len, int timeout) + struct usb_ctrlrequest *cmd, void *data, int len, + int timeout) { urb_t *urb; int retv; diff -Nru a/drivers/usb/pegasus.c b/drivers/usb/pegasus.c --- a/drivers/usb/pegasus.c Sun Jan 6 12:18:36 2002 +++ b/drivers/usb/pegasus.c Sun Jan 6 12:18:36 2002 @@ -142,11 +142,11 @@ remove_wait_queue(&pegasus->ctrl_wait, &wait); set_current_state(TASK_RUNNING); - pegasus->dr.requesttype = PEGASUS_REQT_READ; - pegasus->dr.request = PEGASUS_REQ_GET_REGS; - pegasus->dr.value = cpu_to_le16 (0); - pegasus->dr.index = cpu_to_le16p(&indx); - pegasus->dr.length = cpu_to_le16p(&size); + pegasus->dr.bRequestType = PEGASUS_REQT_READ; + pegasus->dr.bRequest = PEGASUS_REQ_GET_REGS; + pegasus->dr.wValue = cpu_to_le16 (0); + pegasus->dr.wIndex = cpu_to_le16p(&indx); + pegasus->dr.wLength = cpu_to_le16p(&size); pegasus->ctrl_urb.transfer_buffer_length = size; FILL_CONTROL_URB( &pegasus->ctrl_urb, pegasus->usb, @@ -192,11 +192,11 @@ remove_wait_queue(&pegasus->ctrl_wait, &wait); set_current_state(TASK_RUNNING); - pegasus->dr.requesttype = PEGASUS_REQT_WRITE; - pegasus->dr.request = PEGASUS_REQ_SET_REGS; - pegasus->dr.value = cpu_to_le16 (0); - pegasus->dr.index = cpu_to_le16p( &indx ); - pegasus->dr.length = cpu_to_le16p( &size ); + pegasus->dr.bRequestType = PEGASUS_REQT_WRITE; + pegasus->dr.bRequest = PEGASUS_REQ_SET_REGS; + pegasus->dr.wValue = cpu_to_le16 (0); + pegasus->dr.wIndex = cpu_to_le16p( &indx ); + pegasus->dr.wLength = cpu_to_le16p( &size ); pegasus->ctrl_urb.transfer_buffer_length = size; FILL_CONTROL_URB( &pegasus->ctrl_urb, pegasus->usb, @@ -242,11 +242,11 @@ remove_wait_queue(&pegasus->ctrl_wait, &wait); set_current_state(TASK_RUNNING); - pegasus->dr.requesttype = PEGASUS_REQT_WRITE; - pegasus->dr.request = PEGASUS_REQ_SET_REG; - pegasus->dr.value = cpu_to_le16p( &dat); - pegasus->dr.index = cpu_to_le16p( &indx ); - pegasus->dr.length = cpu_to_le16( 1 ); + pegasus->dr.bRequestType = PEGASUS_REQT_WRITE; + pegasus->dr.bRequest = PEGASUS_REQ_SET_REG; + pegasus->dr.wValue = cpu_to_le16p( &dat); + pegasus->dr.wIndex = cpu_to_le16p( &indx ); + pegasus->dr.wLength = cpu_to_le16( 1 ); pegasus->ctrl_urb.transfer_buffer_length = 1; FILL_CONTROL_URB( &pegasus->ctrl_urb, pegasus->usb, @@ -275,11 +275,11 @@ { int ret; - pegasus->dr.requesttype = PEGASUS_REQT_WRITE; - pegasus->dr.request = PEGASUS_REQ_SET_REGS; - pegasus->dr.value = 0; - pegasus->dr.index = cpu_to_le16(EthCtrl0); - pegasus->dr.length = cpu_to_le16(3); + pegasus->dr.bRequestType = PEGASUS_REQT_WRITE; + pegasus->dr.bRequest = PEGASUS_REQ_SET_REGS; + pegasus->dr.wValue = 0; + pegasus->dr.wIndex = cpu_to_le16(EthCtrl0); + pegasus->dr.wLength = cpu_to_le16(3); pegasus->ctrl_urb.transfer_buffer_length = 3; FILL_CONTROL_URB( &pegasus->ctrl_urb, pegasus->usb, diff -Nru a/drivers/usb/pegasus.h b/drivers/usb/pegasus.h --- a/drivers/usb/pegasus.h Sun Jan 6 12:18:36 2002 +++ b/drivers/usb/pegasus.h Sun Jan 6 12:18:36 2002 @@ -108,7 +108,7 @@ int dev_index; int intr_interval; struct urb ctrl_urb, rx_urb, tx_urb, intr_urb; - devrequest dr; + struct usb_ctrlrequest dr; wait_queue_head_t ctrl_wait; struct semaphore ctrl_sem; unsigned char ALIGN(rx_buff[PEGASUS_MAX_MTU]); diff -Nru a/drivers/usb/scanner.c b/drivers/usb/scanner.c --- a/drivers/usb/scanner.c Sun Jan 6 12:18:37 2002 +++ b/drivers/usb/scanner.c Sun Jan 6 12:18:37 2002 @@ -281,7 +281,7 @@ * 0.4.7 11/28/2001 * - Fixed typo in Documentation/scanner.txt. Thanks to * Karel for pointing it out. - * - Added ID's for a Memorex 6136u. Thanks to =C1lvaro Gaspar de + * - Added ID's for a Memorex 6136u. Thanks to Álvaro Gaspar de * Valenzuela" . * - Added ID's for Agfa e25. Thanks to Heinrich * Rust . Also reported to work with @@ -746,8 +746,8 @@ case SCANNER_IOCTL_CTRLMSG: { struct ctrlmsg_ioctl { - devrequest req; - void *data; + struct usb_ctrlrequest req; + void *data; } cmsg; int pipe, nb, ret; unsigned char buf[64]; @@ -755,12 +755,12 @@ if (copy_from_user(&cmsg, (void *)arg, sizeof(cmsg))) return -EFAULT; - nb = le16_to_cpup(&cmsg.req.length); + nb = le16_to_cpup(&cmsg.req.wLength); if (nb > sizeof(buf)) return -EINVAL; - if ((cmsg.req.requesttype & 0x80) == 0) { + if ((cmsg.req.bRequestType & 0x80) == 0) { pipe = usb_sndctrlpipe(dev, 0); if (nb > 0 && copy_from_user(buf, cmsg.data, nb)) return -EFAULT; @@ -768,10 +768,10 @@ pipe = usb_rcvctrlpipe(dev, 0); } - ret = usb_control_msg(dev, pipe, cmsg.req.request, - cmsg.req.requesttype, - le16_to_cpup(&cmsg.req.value), - le16_to_cpup(&cmsg.req.index), + ret = usb_control_msg(dev, pipe, cmsg.req.bRequest, + cmsg.req.bRequestType, + le16_to_cpup(&cmsg.req.wValue), + le16_to_cpup(&cmsg.req.wIndex), buf, nb, HZ); if (ret < 0) { @@ -779,7 +779,7 @@ return -EIO; } - if (nb > 0 && (cmsg.req.requesttype & 0x80) && copy_to_user(cmsg.data, buf, nb)) + if (nb > 0 && (cmsg.req.bRequestType & 0x80) && copy_to_user(cmsg.data, buf, nb)) return -EFAULT; return 0; diff -Nru a/drivers/usb/scanner.h b/drivers/usb/scanner.h --- a/drivers/usb/scanner.h Sun Jan 6 12:18:36 2002 +++ b/drivers/usb/scanner.h Sun Jan 6 12:18:36 2002 @@ -230,7 +230,7 @@ #define SCANNER_IOCTL_VENDOR _IOR('U', 0x20, int) #define SCANNER_IOCTL_PRODUCT _IOR('U', 0x21, int) /* send/recv a control message to the scanner */ -#define SCANNER_IOCTL_CTRLMSG _IOWR('U', 0x22, devrequest ) +#define SCANNER_IOCTL_CTRLMSG _IOWR('U', 0x22, struct usb_ctrlrequest) #define SCN_MAX_MNR 16 /* We're allocated 16 minors */ diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c --- a/drivers/usb/storage/transport.c Sun Jan 6 12:18:36 2002 +++ b/drivers/usb/storage/transport.c Sun Jan 6 12:18:36 2002 @@ -385,19 +385,19 @@ { struct completion urb_done; int status; - devrequest *dr; + struct usb_ctrlrequest *dr; /* allocate the device request structure */ - dr = kmalloc(sizeof(devrequest), GFP_NOIO); + dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO); if (!dr) return -ENOMEM; /* fill in the structure */ - dr->requesttype = requesttype; - dr->request = request; - dr->value = cpu_to_le16(value); - dr->index = cpu_to_le16(index); - dr->length = cpu_to_le16(size); + dr->bRequestType = requesttype; + dr->bRequest = request; + dr->wValue = cpu_to_le16(value); + dr->wIndex = cpu_to_le16(index); + dr->wLength = cpu_to_le16(size); /* set up data structures for the wakeup system */ init_completion(&urb_done); diff -Nru a/drivers/usb/uhci.c b/drivers/usb/uhci.c --- a/drivers/usb/uhci.c Sun Jan 6 12:18:36 2002 +++ b/drivers/usb/uhci.c Sun Jan 6 12:18:36 2002 @@ -646,7 +646,7 @@ if (usb_pipetype(urb->pipe) == PIPE_CONTROL && urb->setup_packet) { urbp->setup_packet_dma_handle = pci_map_single(uhci->dev, - urb->setup_packet, sizeof(devrequest), + urb->setup_packet, sizeof(struct usb_ctrlrequest), PCI_DMA_TODEVICE); if (!urbp->setup_packet_dma_handle) return NULL; @@ -715,7 +715,7 @@ if (urbp->setup_packet_dma_handle) pci_unmap_single(uhci->dev, urbp->setup_packet_dma_handle, - sizeof(devrequest), PCI_DMA_TODEVICE); + sizeof(struct usb_ctrlrequest), PCI_DMA_TODEVICE); if (urbp->transfer_buffer_dma_handle) pci_unmap_single(uhci->dev, urbp->transfer_buffer_dma_handle, @@ -2013,7 +2013,7 @@ { struct uhci *uhci = (struct uhci *)urb->dev->bus->hcpriv; unsigned int pipe = urb->pipe; - devrequest *cmd = (devrequest *)urb->setup_packet; + struct usb_ctrlrequest *cmd = (struct usb_ctrlrequest *)urb->setup_packet; void *data = urb->transfer_buffer; int leni = urb->transfer_buffer_length; int len = 0; @@ -2036,10 +2036,10 @@ return -EINPROGRESS; } - bmRType_bReq = cmd->requesttype | cmd->request << 8; - wValue = le16_to_cpu(cmd->value); - wIndex = le16_to_cpu(cmd->index); - wLength = le16_to_cpu(cmd->length); + bmRType_bReq = cmd->bRequestType | cmd->bRequest << 8; + wValue = le16_to_cpu(cmd->wValue); + wIndex = le16_to_cpu(cmd->wIndex); + wLength = le16_to_cpu(cmd->wLength); for (i = 0; i < 8; i++) uhci->rh.c_p_r[i] = 0; @@ -2276,7 +2276,7 @@ if (urbp->setup_packet_dma_handle) pci_dma_sync_single(uhci->dev, urbp->setup_packet_dma_handle, - sizeof(devrequest), PCI_DMA_TODEVICE); + sizeof(struct usb_ctrlrequest), PCI_DMA_TODEVICE); urb->dev = NULL; if (urb->complete) diff -Nru a/drivers/usb/usb-ohci.c b/drivers/usb/usb-ohci.c --- a/drivers/usb/usb-ohci.c Sun Jan 6 12:18:36 2002 +++ b/drivers/usb/usb-ohci.c Sun Jan 6 12:18:36 2002 @@ -1905,7 +1905,7 @@ struct usb_device * usb_dev = urb->dev; ohci_t * ohci = usb_dev->bus->hcpriv; unsigned int pipe = urb->pipe; - devrequest * cmd = (devrequest *) urb->setup_packet; + struct usb_ctrlrequest * cmd = (struct usb_ctrlrequest *) urb->setup_packet; void * data = urb->transfer_buffer; int leni = urb->transfer_buffer_length; int len = 0; @@ -1929,10 +1929,10 @@ return 0; } - bmRType_bReq = cmd->requesttype | (cmd->request << 8); - wValue = le16_to_cpu (cmd->value); - wIndex = le16_to_cpu (cmd->index); - wLength = le16_to_cpu (cmd->length); + bmRType_bReq = cmd->bRequestType | (cmd->bRequest << 8); + wValue = le16_to_cpu (cmd->wValue); + wIndex = le16_to_cpu (cmd->wIndex); + wLength = le16_to_cpu (cmd->wLength); switch (bmRType_bReq) { /* Request Destination: diff -Nru a/drivers/usb/usb-uhci.c b/drivers/usb/usb-uhci.c --- a/drivers/usb/usb-uhci.c Sun Jan 6 12:18:36 2002 +++ b/drivers/usb/usb-uhci.c Sun Jan 6 12:18:36 2002 @@ -1085,7 +1085,7 @@ { if (urb_priv->setup_packet_dma) pci_dma_sync_single(s->uhci_pci, urb_priv->setup_packet_dma, - sizeof(devrequest), PCI_DMA_TODEVICE); + sizeof(struct usb_ctrlrequest), PCI_DMA_TODEVICE); if (urb_priv->transfer_buffer_dma) pci_dma_sync_single(s->uhci_pci, urb_priv->transfer_buffer_dma, @@ -1099,7 +1099,7 @@ { if (urb_priv->setup_packet_dma) { pci_unmap_single(s->uhci_pci, urb_priv->setup_packet_dma, - sizeof(devrequest), PCI_DMA_TODEVICE); + sizeof(struct usb_ctrlrequest), PCI_DMA_TODEVICE); urb_priv->setup_packet_dma = 0; } if (urb_priv->transfer_buffer_dma) { @@ -1678,7 +1678,7 @@ if (type == PIPE_CONTROL) urb_priv->setup_packet_dma = pci_map_single(s->uhci_pci, urb->setup_packet, - sizeof(devrequest), PCI_DMA_TODEVICE); + sizeof(struct usb_ctrlrequest), PCI_DMA_TODEVICE); if (urb->transfer_buffer_length) urb_priv->transfer_buffer_dma = pci_map_single(s->uhci_pci, @@ -1963,7 +1963,7 @@ struct usb_device *usb_dev = urb->dev; uhci_t *uhci = usb_dev->bus->hcpriv; unsigned int pipe = urb->pipe; - devrequest *cmd = (devrequest *) urb->setup_packet; + struct usb_ctrlrequest *cmd = (struct usb_ctrlrequest *) urb->setup_packet; void *data = urb->transfer_buffer; int leni = urb->transfer_buffer_length; int len = 0; @@ -1989,10 +1989,10 @@ } - bmRType_bReq = cmd->requesttype | cmd->request << 8; - wValue = le16_to_cpu (cmd->value); - wIndex = le16_to_cpu (cmd->index); - wLength = le16_to_cpu (cmd->length); + bmRType_bReq = cmd->bRequestType | cmd->bRequest << 8; + wValue = le16_to_cpu (cmd->wValue); + wIndex = le16_to_cpu (cmd->wIndex); + wLength = le16_to_cpu (cmd->wLength); for (i = 0; i < 8; i++) uhci->rh.c_p_r[i] = 0; diff -Nru a/drivers/usb/usb.c b/drivers/usb/usb.c --- a/drivers/usb/usb.c Sun Jan 6 12:18:37 2002 +++ b/drivers/usb/usb.c Sun Jan 6 12:18:37 2002 @@ -1287,7 +1287,7 @@ /*-------------------------------------------------------------------*/ // returns status (negative) or length (positive) int usb_internal_control_msg(struct usb_device *usb_dev, unsigned int pipe, - devrequest *cmd, void *data, int len, int timeout) + struct usb_ctrlrequest *cmd, void *data, int len, int timeout) { urb_t *urb; int retv; @@ -1331,17 +1331,17 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size, int timeout) { - devrequest *dr = kmalloc(sizeof(devrequest), GFP_KERNEL); + struct usb_ctrlrequest *dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); int ret; if (!dr) return -ENOMEM; - dr->requesttype = requesttype; - dr->request = request; - dr->value = cpu_to_le16p(&value); - dr->index = cpu_to_le16p(&index); - dr->length = cpu_to_le16p(&size); + dr->bRequestType= requesttype; + dr->bRequest = request; + dr->wValue = cpu_to_le16p(&value); + dr->wIndex = cpu_to_le16p(&index); + dr->wLength = cpu_to_le16p(&size); //dbg("usb_control_msg"); @@ -1535,6 +1535,9 @@ } ifp = interface->altsetting + interface->num_altsetting; + ifp->endpoint = NULL; + ifp->extra = NULL; + ifp->extralen = 0; interface->num_altsetting++; memcpy(ifp, buffer, USB_DT_INTERFACE_SIZE); @@ -1576,10 +1579,7 @@ /* Copy any unknown descriptors into a storage area for */ /* drivers to later parse */ len = (int)(buffer - begin); - if (!len) { - ifp->extra = NULL; - ifp->extralen = 0; - } else { + if (len) { ifp->extra = kmalloc(len, GFP_KERNEL); if (!ifp->extra) { diff -Nru a/drivers/usb/usbkbd.c b/drivers/usb/usbkbd.c --- a/drivers/usb/usbkbd.c Sun Jan 6 12:18:36 2002 +++ b/drivers/usb/usbkbd.c Sun Jan 6 12:18:36 2002 @@ -74,7 +74,7 @@ unsigned char new[8]; unsigned char old[8]; struct urb irq, led; - devrequest dr; + struct usb_ctrlrequest dr; unsigned char leds, newleds; char name[128]; int open; @@ -218,11 +218,11 @@ FILL_INT_URB(&kbd->irq, dev, pipe, kbd->new, maxp > 8 ? 8 : maxp, usb_kbd_irq, kbd, endpoint->bInterval); - kbd->dr.requesttype = USB_TYPE_CLASS | USB_RECIP_INTERFACE; - kbd->dr.request = HID_REQ_SET_REPORT; - kbd->dr.value = 0x200; - kbd->dr.index = interface->bInterfaceNumber; - kbd->dr.length = 1; + kbd->dr.bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE; + kbd->dr.bRequest = HID_REQ_SET_REPORT; + kbd->dr.wValue = 0x200; + kbd->dr.wIndex = interface->bInterfaceNumber; + kbd->dr.wLength = 1; kbd->dev.name = kbd->name; kbd->dev.idbus = BUS_USB; diff -Nru a/include/linux/usb.h b/include/linux/usb.h --- a/include/linux/usb.h Sun Jan 6 12:18:36 2002 +++ b/include/linux/usb.h Sun Jan 6 12:18:36 2002 @@ -117,13 +117,26 @@ mdelay(ms); } -typedef struct { - __u8 requesttype; - __u8 request; - __u16 value; - __u16 index; - __u16 length; -} devrequest __attribute__ ((packed)); +/** + * struct usb_ctrlrequest - structure used to make USB device control requests easier to create and decode + * @bRequestType: matches the USB bmRequestType field + * @bRequest: matches the USB bRequest field + * @wValue: matches the USB wValue field + * @wIndex: matches the USB wIndex field + * @wLength: matches the USB wLength field + * + * This structure is used to send control requests to a USB device. It matches + * the different fields of the USB 2.0 Spec section 9.3, table 9-2. See the + * USB spec for a fuller description of the different fields, and what they are + * used for. + */ +struct usb_ctrlrequest { + __u8 bRequestType; + __u8 bRequest; + __u16 wValue; + __u16 wIndex; + __u16 wLength; +} __attribute__ ((packed)); /* * USB device number allocation bitmap. There's one bitmap diff -Nru a/include/linux/usbdevice_fs.h b/include/linux/usbdevice_fs.h --- a/include/linux/usbdevice_fs.h Sun Jan 6 12:18:36 2002 +++ b/include/linux/usbdevice_fs.h Sun Jan 6 12:18:36 2002 @@ -40,11 +40,11 @@ /* usbdevfs ioctl codes */ struct usbdevfs_ctrltransfer { - __u8 requesttype; - __u8 request; - __u16 value; - __u16 index; - __u16 length; + __u8 bRequestType; + __u8 bRequest; + __u16 wValue; + __u16 wIndex; + __u16 wLength; __u32 timeout; /* in milliseconds */ void *data; }; diff -Nru a/include/net/bluetooth/hci_usb.h b/include/net/bluetooth/hci_usb.h --- a/include/net/bluetooth/hci_usb.h Sun Jan 6 12:18:36 2002 +++ b/include/net/bluetooth/hci_usb.h Sun Jan 6 12:18:36 2002 @@ -38,7 +38,7 @@ struct hci_usb { struct usb_device *udev; - devrequest dev_req; + struct usb_ctrlrequest dev_req; struct urb *ctrl_urb; struct urb *intr_urb; struct urb *read_urb;