From 11ff12feb40dc663cad0f2da86729f1af9d1356e Mon Sep 17 00:00:00 2001 From: Tomas Winkler Date: Wed, 6 Apr 2011 17:37:33 +0300 Subject: [PATCH] staging/easycap: easycap_probe : rename usb variables to common names 1. rename usb variables to more common names struct usb_device *pusb_device -> usbdev struct usb_host_interface *pusb_host_interface -> alt struct usb_endpoint_descriptor *pepd -> struct usb_interface_descriptor *pusb_interface_descriptor -> interface; 2. use usb_altnum_to_altsetting to access alternative settings Cc: Mike Thomas Signed-off-by: Tomas Winkler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/easycap/easycap_main.c | 143 ++++++++++++------------- 1 file changed, 68 insertions(+), 75 deletions(-) diff --git a/drivers/staging/easycap/easycap_main.c b/drivers/staging/easycap/easycap_main.c index 06df88b6cd5..68b1f4fd1cd 100644 --- a/drivers/staging/easycap/easycap_main.c +++ b/drivers/staging/easycap/easycap_main.c @@ -2975,13 +2975,13 @@ static const struct v4l2_file_operations v4l2_fops = { * TIMES, ONCE FOR EACH OF THE THREE INTERFACES. BEWARE. */ /*---------------------------------------------------------------------------*/ -static int easycap_usb_probe(struct usb_interface *pusb_interface, - const struct usb_device_id *pusb_device_id) +static int easycap_usb_probe(struct usb_interface *intf, + const struct usb_device_id *id) { - struct usb_device *pusb_device; - struct usb_host_interface *pusb_host_interface; - struct usb_endpoint_descriptor *pepd; - struct usb_interface_descriptor *pusb_interface_descriptor; + struct usb_device *usbdev; + struct usb_host_interface *alt; + struct usb_endpoint_descriptor *ep; + struct usb_interface_descriptor *interface; struct urb *purb; struct easycap *peasycap; int ndong; @@ -3010,23 +3010,17 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, struct inputset *inputset; struct v4l2_device *pv4l2_device; -/*---------------------------------------------------------------------------*/ -/* - * GET POINTER TO STRUCTURE usb_device - */ -/*---------------------------------------------------------------------------*/ - pusb_device = interface_to_usbdev(pusb_interface); + usbdev = interface_to_usbdev(intf); - JOT(4, "bNumConfigurations=%i\n", pusb_device->descriptor.bNumConfigurations); /*---------------------------------------------------------------------------*/ - pusb_host_interface = pusb_interface->cur_altsetting; - if (!pusb_host_interface) { - SAY("ERROR: pusb_host_interface is NULL\n"); + alt = usb_altnum_to_altsetting(intf, 0); + if (!alt) { + SAY("ERROR: usb_host_interface not found\n"); return -EFAULT; } - pusb_interface_descriptor = &(pusb_host_interface->desc); - if (!pusb_interface_descriptor) { - SAY("ERROR: pusb_interface_descriptor is NULL\n"); + interface = &alt->desc; + if (!interface) { + SAY("ERROR: intf_descriptor is NULL\n"); return -EFAULT; } /*---------------------------------------------------------------------------*/ @@ -3034,16 +3028,15 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, * GET PROPERTIES OF PROBED INTERFACE */ /*---------------------------------------------------------------------------*/ - bInterfaceNumber = pusb_interface_descriptor->bInterfaceNumber; - bInterfaceClass = pusb_interface_descriptor->bInterfaceClass; - bInterfaceSubClass = pusb_interface_descriptor->bInterfaceSubClass; + bInterfaceNumber = interface->bInterfaceNumber; + bInterfaceClass = interface->bInterfaceClass; + bInterfaceSubClass = interface->bInterfaceSubClass; JOT(4, "intf[%i]: num_altsetting=%i\n", - bInterfaceNumber, pusb_interface->num_altsetting); + bInterfaceNumber, intf->num_altsetting); JOT(4, "intf[%i]: cur_altsetting - altsetting=%li\n", bInterfaceNumber, - (long int)(pusb_interface->cur_altsetting - - pusb_interface->altsetting)); + (long int)(intf->cur_altsetting - intf->altsetting)); JOT(4, "intf[%i]: bInterfaceClass=0x%02X bInterfaceSubClass=0x%02X\n", bInterfaceNumber, bInterfaceClass, bInterfaceSubClass); /*---------------------------------------------------------------------------*/ @@ -3129,8 +3122,8 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, * ... AND FURTHER INITIALIZE THE STRUCTURE */ /*---------------------------------------------------------------------------*/ - peasycap->pusb_device = pusb_device; - peasycap->pusb_interface = pusb_interface; + peasycap->pusb_device = usbdev; + peasycap->pusb_interface = intf; peasycap->ilk = 0; peasycap->microphone = false; @@ -3264,7 +3257,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, */ /*---------------------------------------------------------------------------*/ for (ndong = 0; ndong < DONGLE_MANY; ndong++) { - if (pusb_device == easycapdc60_dongle[ndong].peasycap-> + if (usbdev == easycapdc60_dongle[ndong].peasycap-> pusb_device) { peasycap = easycapdc60_dongle[ndong].peasycap; JOT(8, "intf[%i]: dongle[%i].peasycap\n", @@ -3291,7 +3284,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, */ /*---------------------------------------------------------------------------*/ if (memcmp(&peasycap->telltale[0], TELLTALE, strlen(TELLTALE))) { - pv4l2_device = usb_get_intfdata(pusb_interface); + pv4l2_device = usb_get_intfdata(intf); if (!pv4l2_device) { SAY("ERROR: pv4l2_device is NULL\n"); return -ENODEV; @@ -3340,34 +3333,34 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, /*---------------------------------------------------------------------------*/ isokalt = 0; - for (i = 0; i < pusb_interface->num_altsetting; i++) { - pusb_host_interface = &(pusb_interface->altsetting[i]); - if (!pusb_host_interface) { - SAM("ERROR: pusb_host_interface is NULL\n"); + for (i = 0; i < intf->num_altsetting; i++) { + alt = usb_altnum_to_altsetting(intf, i); + if (!alt) { + SAM("ERROR: alt is NULL\n"); return -EFAULT; } - pusb_interface_descriptor = &(pusb_host_interface->desc); - if (!pusb_interface_descriptor) { - SAM("ERROR: pusb_interface_descriptor is NULL\n"); + interface = &alt->desc; + if (!interface) { + SAM("ERROR: intf_descriptor is NULL\n"); return -EFAULT; } JOM(4, "intf[%i]alt[%i]: desc.bDescriptorType=0x%02X\n", - bInterfaceNumber, i, pusb_interface_descriptor->bDescriptorType); + bInterfaceNumber, i, interface->bDescriptorType); JOM(4, "intf[%i]alt[%i]: desc.bInterfaceNumber=0x%02X\n", - bInterfaceNumber, i, pusb_interface_descriptor->bInterfaceNumber); + bInterfaceNumber, i, interface->bInterfaceNumber); JOM(4, "intf[%i]alt[%i]: desc.bAlternateSetting=0x%02X\n", - bInterfaceNumber, i, pusb_interface_descriptor->bAlternateSetting); + bInterfaceNumber, i, interface->bAlternateSetting); JOM(4, "intf[%i]alt[%i]: desc.bNumEndpoints=0x%02X\n", - bInterfaceNumber, i, pusb_interface_descriptor->bNumEndpoints); + bInterfaceNumber, i, interface->bNumEndpoints); JOM(4, "intf[%i]alt[%i]: desc.bInterfaceClass=0x%02X\n", - bInterfaceNumber, i, pusb_interface_descriptor->bInterfaceClass); + bInterfaceNumber, i, interface->bInterfaceClass); JOM(4, "intf[%i]alt[%i]: desc.bInterfaceSubClass=0x%02X\n", - bInterfaceNumber, i, pusb_interface_descriptor->bInterfaceSubClass); + bInterfaceNumber, i, interface->bInterfaceSubClass); JOM(4, "intf[%i]alt[%i]: desc.bInterfaceProtocol=0x%02X\n", - bInterfaceNumber, i, pusb_interface_descriptor->bInterfaceProtocol); + bInterfaceNumber, i, interface->bInterfaceProtocol); JOM(4, "intf[%i]alt[%i]: desc.iInterface=0x%02X\n", - bInterfaceNumber, i, pusb_interface_descriptor->iInterface); + bInterfaceNumber, i, interface->iInterface); ISOCwMaxPacketSize = -1; BULKwMaxPacketSize = -1; @@ -3376,34 +3369,34 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, ISOCbEndpointAddress = 0; INTbEndpointAddress = 0; - if (0 == pusb_interface_descriptor->bNumEndpoints) + if (0 == interface->bNumEndpoints) JOM(4, "intf[%i]alt[%i] has no endpoints\n", bInterfaceNumber, i); /*---------------------------------------------------------------------------*/ - for (j = 0; j < pusb_interface_descriptor->bNumEndpoints; j++) { - pepd = &(pusb_host_interface->endpoint[j].desc); - if (!pepd) { - SAM("ERROR: pepd is NULL.\n"); + for (j = 0; j < interface->bNumEndpoints; j++) { + ep = &alt->endpoint[j].desc; + if (!ep) { + SAM("ERROR: ep is NULL.\n"); SAM("...... skipping\n"); continue; } - wMaxPacketSize = le16_to_cpu(pepd->wMaxPacketSize); - bEndpointAddress = pepd->bEndpointAddress; + wMaxPacketSize = le16_to_cpu(ep->wMaxPacketSize); + bEndpointAddress = ep->bEndpointAddress; JOM(4, "intf[%i]alt[%i]end[%i]: bEndpointAddress=0x%X\n", bInterfaceNumber, i, j, - pepd->bEndpointAddress); + ep->bEndpointAddress); JOM(4, "intf[%i]alt[%i]end[%i]: bmAttributes=0x%X\n", bInterfaceNumber, i, j, - pepd->bmAttributes); + ep->bmAttributes); JOM(4, "intf[%i]alt[%i]end[%i]: wMaxPacketSize=%i\n", bInterfaceNumber, i, j, - pepd->wMaxPacketSize); + ep->wMaxPacketSize); JOM(4, "intf[%i]alt[%i]end[%i]: bInterval=%i\n", bInterfaceNumber, i, j, - pepd->bInterval); + ep->bInterval); - if (pepd->bEndpointAddress & USB_DIR_IN) { + if (ep->bEndpointAddress & USB_DIR_IN) { JOM(4, "intf[%i]alt[%i]end[%i] is an IN endpoint\n", bInterfaceNumber, i, j); isin = 1; @@ -3414,7 +3407,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, SAM("...... continuing\n"); isin = 0; } - if ((pepd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == + if ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_ISOC) { JOM(4, "intf[%i]alt[%i]end[%i] is an ISOC endpoint\n", bInterfaceNumber, i, j); @@ -3427,7 +3420,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, "peasycap is NULL\n"); return -EFAULT; } - if (pepd->wMaxPacketSize) { + if (ep->wMaxPacketSize) { if (8 > isokalt) { okalt[isokalt] = i; JOM(4, @@ -3435,7 +3428,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, okalt[isokalt], isokalt); okepn[isokalt] = - pepd-> + ep-> bEndpointAddress & 0x0F; JOM(4, @@ -3443,7 +3436,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, okepn[isokalt], isokalt); okmps[isokalt] = - le16_to_cpu(pepd-> + le16_to_cpu(ep-> wMaxPacketSize); JOM(4, "%i=okmps[%i]\n", @@ -3485,7 +3478,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, "peasycap is NULL\n"); return -EFAULT; } - if (pepd->wMaxPacketSize) { + if (ep->wMaxPacketSize) { if (8 > isokalt) { okalt[isokalt] = i ; JOM(4, @@ -3493,7 +3486,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, okalt[isokalt], isokalt); okepn[isokalt] = - pepd-> + ep-> bEndpointAddress & 0x0F; JOM(4, @@ -3501,7 +3494,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, okepn[isokalt], isokalt); okmps[isokalt] = - le16_to_cpu(pepd-> + le16_to_cpu(ep-> wMaxPacketSize); JOM(4, "%i=okmps[%i]\n", @@ -3539,12 +3532,12 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, break; } } - } else if ((pepd->bmAttributes & + } else if ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK) { JOM(4, "intf[%i]alt[%i]end[%i] is a BULK endpoint\n", bInterfaceNumber, i, j); - } else if ((pepd->bmAttributes & + } else if ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) { JOM(4, "intf[%i]alt[%i]end[%i] is an INT endpoint\n", @@ -3553,7 +3546,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, JOM(4, "intf[%i]alt[%i]end[%i] is a CTRL endpoint\n", bInterfaceNumber, i, j); } - if (0 == pepd->wMaxPacketSize) { + if (0 == ep->wMaxPacketSize) { JOM(4, "intf[%i]alt[%i]end[%i] " "has zero packet size\n", bInterfaceNumber, i, j); @@ -3566,7 +3559,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, */ /*---------------------------------------------------------------------------*/ JOM(4, "initialization begins for interface %i\n", - pusb_interface_descriptor->bInterfaceNumber); + interface->bInterfaceNumber); switch (bInterfaceNumber) { /*---------------------------------------------------------------------------*/ /* @@ -3833,7 +3826,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, * SAVE POINTER peasycap IN THIS INTERFACE. */ /*--------------------------------------------------------------------------*/ - usb_set_intfdata(pusb_interface, peasycap); + usb_set_intfdata(intf, peasycap); /*---------------------------------------------------------------------------*/ /* * IT IS ESSENTIAL TO INITIALIZE THE HARDWARE BEFORE, RATHER THAN AFTER, @@ -3855,7 +3848,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, * THE VIDEO DEVICE CAN BE REGISTERED NOW, AS IT IS READY. */ /*--------------------------------------------------------------------------*/ - if (0 != (v4l2_device_register(&(pusb_interface->dev), + if (0 != (v4l2_device_register(&(intf->dev), &(peasycap->v4l2_device)))) { SAM("v4l2_device_register() failed\n"); return -ENODEV; @@ -3913,9 +3906,9 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, * SAVE POINTER peasycap IN INTERFACE 1 */ /*--------------------------------------------------------------------------*/ - usb_set_intfdata(pusb_interface, peasycap); + usb_set_intfdata(intf, peasycap); JOM(4, "no initialization required for interface %i\n", - pusb_interface_descriptor->bInterfaceNumber); + interface->bInterfaceNumber); break; } /*--------------------------------------------------------------------------*/ @@ -4177,7 +4170,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, * SAVE POINTER peasycap IN THIS INTERFACE. */ /*---------------------------------------------------------------------------*/ - usb_set_intfdata(pusb_interface, peasycap); + usb_set_intfdata(intf, peasycap); /*---------------------------------------------------------------------------*/ /* * THE AUDIO DEVICE CAN BE REGISTERED NOW, AS IT IS READY. @@ -4198,10 +4191,10 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, } #else /* CONFIG_EASYCAP_OSS */ - rc = usb_register_dev(pusb_interface, &easyoss_class); + rc = usb_register_dev(intf, &easyoss_class); if (rc) { SAY("ERROR: usb_register_dev() failed\n"); - usb_set_intfdata(pusb_interface, NULL); + usb_set_intfdata(intf, NULL); return -ENODEV; } else { JOM(8, "kref_get() with %i=kref.refcount.counter\n", @@ -4209,7 +4202,7 @@ static int easycap_usb_probe(struct usb_interface *pusb_interface, kref_get(&peasycap->kref); peasycap->registered_audio++; } - SAM("easyoss attached to minor #%d\n", pusb_interface->minor); + SAM("easyoss attached to minor #%d\n", intf->minor); #endif /* CONFIG_EASYCAP_OSS */ break; -- 2.39.5