ChangeSet 1.1608.84.8, 2004/03/09 09:47:03-08:00, [EMAIL PROTECTED]

[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.


 drivers/isdn/hisax/hfc_usb.c |   29 ++++++++++++++++-------------
 1 files changed, 16 insertions(+), 13 deletions(-)


diff -Nru a/drivers/isdn/hisax/hfc_usb.c b/drivers/isdn/hisax/hfc_usb.c
--- a/drivers/isdn/hisax/hfc_usb.c      Tue Mar 16 15:03:29 2004
+++ b/drivers/isdn/hisax/hfc_usb.c      Tue Mar 16 15:03:29 2004
@@ -1349,9 +1349,11 @@
 {
        struct usb_device *dev= interface_to_usbdev(intf);
        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;
-       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;
 
 //        usb_show_device(dev);
@@ -1366,7 +1368,7 @@
 
 #ifdef VERBOSE_USB_DEBUG       
        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
 
        if (vend_idx != 0xffff) {
@@ -1374,14 +1376,15 @@
                printk(KERN_INFO "HFC-USB: found vendor idx:%d  
name:%s\n",vend_idx,vdata[vend_idx].vend_name);
 #endif
                /* if vendor and product ID is OK, start probing a matching alternate 
setting ... */
-               probe_alt_setting = 0;
+               alt_idx = 0;
                small_match=0xffff;
                // default settings
                iso_packet_size=16;
                packet_size=64;
 
-               while(probe_alt_setting < intf->num_altsetting) {
-                       iface = intf->altsetting + probe_alt_setting;
+               while (alt_idx < intf->num_altsetting) {
+                       iface = intf->altsetting + alt_idx;
+                       probe_alt_setting = iface->desc.bAlternateSetting;
                        cfg_used=0;
 
 #ifdef VERBOSE_USB_DEBUG
@@ -1395,7 +1398,7 @@
 
 #ifdef VERBOSE_USB_DEBUG
                                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
                                // copy table
                                memcpy(cmptbl,vcf,16*sizeof(int));
@@ -1448,6 +1451,7 @@
                                        if (cfg_used < small_match) {
                                                small_match = cfg_used;
                                                alt_used = probe_alt_setting;
+                                               iface_used = iface;
                                        }
 #ifdef VERBOSE_USB_DEBUG
                                        printk(KERN_INFO "HFC-USB: small_match=%x 
%x\n", small_match, alt_used);
@@ -1457,15 +1461,14 @@
                                cfg_used++;
                        }
 
-                       probe_alt_setting++;
-               }               /* (probe_alt_setting < intf->num_altsetting) */
+                       alt_idx++;
+               }               /* (alt_idx < intf->num_altsetting) */
 #ifdef VERBOSE_USB_DEBUG
                printk(KERN_INFO "HFC-USB: final small_match=%x 
alt_used=%x\n",small_match, alt_used);
 #endif
                // yiipiee, we found a valid config
                if (small_match != 0xffff) {
-                       intf->act_altsetting = alt_used;
-                       iface = intf->altsetting + intf->act_altsetting;
+                       iface = iface_used;
 
                        if (!(context = kmalloc(sizeof(hfcusb_data), GFP_KERNEL)))
                                return(-ENOMEM);  /* got no mem */
@@ -1542,8 +1545,8 @@
 
                        // now share our luck
                        context->dev = dev;                                            
 /* save device */
-                       context->if_used = intf->altsetting->desc.bInterfaceNumber;    
 /* save used interface */
-                       context->alt_used = intf->act_altsetting;                      
 /* and alternate config */
+                       context->if_used = ifnum;                                      
 /* save used interface */
+                       context->alt_used = alt_used;                                  
 /* and alternate config */
                        context->ctrl_paksize = dev->descriptor.bMaxPacketSize0;       
 /* control size */
                        context->cfg_used=vcf[16];                                     
 // store used config
                        context->vend_idx=vend_idx;                                    
 // store found vendor



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to