Commit 26375db9 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

[PATCH] USB: Interface/altsetting update for ISDN hisax driver

On Mon, 8 Mar 2004, Greg KH wrote:

> Oh, could you look at drivers/isdn/hisax/hfc_usb.c if you get a chance?
> I tried to figure out the mess there with regards to act_altsetting, but
> gave up :(

You're right, it is a mess.  Beats me why they didn't use a plain old
"for" statement to do that altsetting loop.  Probably the most confusing
part is where the code needlessly resets intf->act_altsetting.

Anyway, this patch sets things right.  I haven't tried to compile it, but
any errors ought to be pretty small, obvious, and easy to fix.

My intention was to go through the files under driver/usb (in alphabetical
order!) and then do the ones outside that subtree -- I've got a little
list.  But it's no problem to take care of this one first.
parent 593f48d6
...@@ -1349,9 +1349,11 @@ static int __devinit hfc_usb_probe(struct usb_interface *intf, const struct usb_ ...@@ -1349,9 +1349,11 @@ static int __devinit hfc_usb_probe(struct usb_interface *intf, const struct usb_
{ {
struct usb_device *dev= interface_to_usbdev(intf); struct usb_device *dev= interface_to_usbdev(intf);
hfcusb_data *context; hfcusb_data *context;
struct usb_host_interface *iface = intf->altsetting + intf->act_altsetting; struct usb_host_interface *iface = intf->cur_altsetting;
struct usb_host_interface *iface_used;
struct usb_host_endpoint *ep; struct usb_host_endpoint *ep;
int i, idx, probe_alt_setting,vend_idx, cfg_used, *vcf, attr, cfg_found, cidx, ep_addr; int ifnum = iface->desc.bInterfaceNumber;
int i, idx, alt_idx, probe_alt_setting, vend_idx, cfg_used, *vcf, attr, cfg_found, cidx, ep_addr;
int cmptbl[16],small_match,iso_packet_size,packet_size,alt_used=0; int cmptbl[16],small_match,iso_packet_size,packet_size,alt_used=0;
// usb_show_device(dev); // usb_show_device(dev);
...@@ -1366,7 +1368,7 @@ static int __devinit hfc_usb_probe(struct usb_interface *intf, const struct usb_ ...@@ -1366,7 +1368,7 @@ static int __devinit hfc_usb_probe(struct usb_interface *intf, const struct usb_
#ifdef VERBOSE_USB_DEBUG #ifdef VERBOSE_USB_DEBUG
printk(KERN_INFO "HFC-USB: probing interface(%d) actalt(%d) minor(%d)\n", printk(KERN_INFO "HFC-USB: probing interface(%d) actalt(%d) minor(%d)\n",
intf->altsetting->desc.bInterfaceNumber, intf->act_altsetting, intf->minor); ifnum, iface->desc.bAlternateSetting, intf->minor);
#endif #endif
if (vend_idx != 0xffff) { if (vend_idx != 0xffff) {
...@@ -1374,14 +1376,15 @@ static int __devinit hfc_usb_probe(struct usb_interface *intf, const struct usb_ ...@@ -1374,14 +1376,15 @@ static int __devinit hfc_usb_probe(struct usb_interface *intf, const struct usb_
printk(KERN_INFO "HFC-USB: found vendor idx:%d name:%s\n",vend_idx,vdata[vend_idx].vend_name); printk(KERN_INFO "HFC-USB: found vendor idx:%d name:%s\n",vend_idx,vdata[vend_idx].vend_name);
#endif #endif
/* if vendor and product ID is OK, start probing a matching alternate setting ... */ /* if vendor and product ID is OK, start probing a matching alternate setting ... */
probe_alt_setting = 0; alt_idx = 0;
small_match=0xffff; small_match=0xffff;
// default settings // default settings
iso_packet_size=16; iso_packet_size=16;
packet_size=64; packet_size=64;
while(probe_alt_setting < intf->num_altsetting) { while (alt_idx < intf->num_altsetting) {
iface = intf->altsetting + probe_alt_setting; iface = intf->altsetting + alt_idx;
probe_alt_setting = iface->desc.bAlternateSetting;
cfg_used=0; cfg_used=0;
#ifdef VERBOSE_USB_DEBUG #ifdef VERBOSE_USB_DEBUG
...@@ -1395,7 +1398,7 @@ static int __devinit hfc_usb_probe(struct usb_interface *intf, const struct usb_ ...@@ -1395,7 +1398,7 @@ static int __devinit hfc_usb_probe(struct usb_interface *intf, const struct usb_
#ifdef VERBOSE_USB_DEBUG #ifdef VERBOSE_USB_DEBUG
printk(KERN_INFO "HFC-USB: (if=%d alt=%d cfg_used=%d)\n", printk(KERN_INFO "HFC-USB: (if=%d alt=%d cfg_used=%d)\n",
probe_alt_setting, intf->act_altsetting,cfg_used); ifnum, probe_alt_setting, cfg_used);
#endif #endif
// copy table // copy table
memcpy(cmptbl,vcf,16*sizeof(int)); memcpy(cmptbl,vcf,16*sizeof(int));
...@@ -1448,6 +1451,7 @@ static int __devinit hfc_usb_probe(struct usb_interface *intf, const struct usb_ ...@@ -1448,6 +1451,7 @@ static int __devinit hfc_usb_probe(struct usb_interface *intf, const struct usb_
if (cfg_used < small_match) { if (cfg_used < small_match) {
small_match = cfg_used; small_match = cfg_used;
alt_used = probe_alt_setting; alt_used = probe_alt_setting;
iface_used = iface;
} }
#ifdef VERBOSE_USB_DEBUG #ifdef VERBOSE_USB_DEBUG
printk(KERN_INFO "HFC-USB: small_match=%x %x\n", small_match, alt_used); printk(KERN_INFO "HFC-USB: small_match=%x %x\n", small_match, alt_used);
...@@ -1457,15 +1461,14 @@ static int __devinit hfc_usb_probe(struct usb_interface *intf, const struct usb_ ...@@ -1457,15 +1461,14 @@ static int __devinit hfc_usb_probe(struct usb_interface *intf, const struct usb_
cfg_used++; cfg_used++;
} }
probe_alt_setting++; alt_idx++;
} /* (probe_alt_setting < intf->num_altsetting) */ } /* (alt_idx < intf->num_altsetting) */
#ifdef VERBOSE_USB_DEBUG #ifdef VERBOSE_USB_DEBUG
printk(KERN_INFO "HFC-USB: final small_match=%x alt_used=%x\n",small_match, alt_used); printk(KERN_INFO "HFC-USB: final small_match=%x alt_used=%x\n",small_match, alt_used);
#endif #endif
// yiipiee, we found a valid config // yiipiee, we found a valid config
if (small_match != 0xffff) { if (small_match != 0xffff) {
intf->act_altsetting = alt_used; iface = iface_used;
iface = intf->altsetting + intf->act_altsetting;
if (!(context = kmalloc(sizeof(hfcusb_data), GFP_KERNEL))) if (!(context = kmalloc(sizeof(hfcusb_data), GFP_KERNEL)))
return(-ENOMEM); /* got no mem */ return(-ENOMEM); /* got no mem */
...@@ -1542,8 +1545,8 @@ static int __devinit hfc_usb_probe(struct usb_interface *intf, const struct usb_ ...@@ -1542,8 +1545,8 @@ static int __devinit hfc_usb_probe(struct usb_interface *intf, const struct usb_
// now share our luck // now share our luck
context->dev = dev; /* save device */ context->dev = dev; /* save device */
context->if_used = intf->altsetting->desc.bInterfaceNumber; /* save used interface */ context->if_used = ifnum; /* save used interface */
context->alt_used = intf->act_altsetting; /* and alternate config */ context->alt_used = alt_used; /* and alternate config */
context->ctrl_paksize = dev->descriptor.bMaxPacketSize0; /* control size */ context->ctrl_paksize = dev->descriptor.bMaxPacketSize0; /* control size */
context->cfg_used=vcf[16]; // store used config context->cfg_used=vcf[16]; // store used config
context->vend_idx=vend_idx; // store found vendor context->vend_idx=vend_idx; // store found vendor
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment