ChangeSet 1.1587.3.19, 2004/04/30 22:15:51-07:00, stern@rowland.harvard.edu [PATCH] USB: USB altsetting updates for IDSN Hisax driver The USB core is changing the way interfaces and altsettings are stored. They are no longer required to be in numerical order, and as a result, simply indexing the interface and altsetting arrays won't work as expected. This patch for the st5481 takes these changes into account. A simpler approach would be to store a pointer to the struct usb_host_interface rather than look it up repeatedly, but I'm not very familiar with this driver and didn't want to attempt such an alteration. drivers/isdn/hisax/st5481_b.c | 9 +++++++-- drivers/isdn/hisax/st5481_d.c | 9 +++++++-- drivers/isdn/hisax/st5481_usb.c | 10 +++++++--- 3 files changed, 21 insertions(+), 7 deletions(-) diff -Nru a/drivers/isdn/hisax/st5481_b.c b/drivers/isdn/hisax/st5481_b.c --- a/drivers/isdn/hisax/st5481_b.c Fri May 14 15:31:13 2004 +++ b/drivers/isdn/hisax/st5481_b.c Fri May 14 15:31:13 2004 @@ -257,13 +257,18 @@ static int st5481_setup_b_out(struct st5481_bcs *bcs) { struct usb_device *dev = bcs->adapter->usb_dev; - struct usb_host_interface *altsetting; + struct usb_interface *intf; + struct usb_host_interface *altsetting = NULL; struct usb_host_endpoint *endpoint; struct st5481_b_out *b_out = &bcs->b_out; DBG(4,""); - altsetting = &(dev->config->interface[0]->altsetting[3]); + intf = usb_ifnum_to_if(dev, 0); + if (intf) + altsetting = usb_altnum_to_altsetting(intf, 3); + if (!altsetting) + return -ENXIO; // Allocate URBs and buffers for the B channel out endpoint = &altsetting->endpoint[EP_B1_OUT - 1 + bcs->channel * 2]; diff -Nru a/drivers/isdn/hisax/st5481_d.c b/drivers/isdn/hisax/st5481_d.c --- a/drivers/isdn/hisax/st5481_d.c Fri May 14 15:31:13 2004 +++ b/drivers/isdn/hisax/st5481_d.c Fri May 14 15:31:13 2004 @@ -652,13 +652,18 @@ static int st5481_setup_d_out(struct st5481_adapter *adapter) { struct usb_device *dev = adapter->usb_dev; - struct usb_host_interface *altsetting; + struct usb_interface *intf; + struct usb_host_interface *altsetting = NULL; struct usb_host_endpoint *endpoint; struct st5481_d_out *d_out = &adapter->d_out; DBG(2,""); - altsetting = &(dev->config->interface[0]->altsetting[3]); + intf = usb_ifnum_to_if(dev, 0); + if (intf) + altsetting = usb_altnum_to_altsetting(intf, 3); + if (!altsetting) + return -ENXIO; // Allocate URBs and buffers for the D channel out endpoint = &altsetting->endpoint[EP_D_OUT-1]; diff -Nru a/drivers/isdn/hisax/st5481_usb.c b/drivers/isdn/hisax/st5481_usb.c --- a/drivers/isdn/hisax/st5481_usb.c Fri May 14 15:31:13 2004 +++ b/drivers/isdn/hisax/st5481_usb.c Fri May 14 15:31:13 2004 @@ -244,7 +244,8 @@ struct usb_device *dev = adapter->usb_dev; struct st5481_ctrl *ctrl = &adapter->ctrl; struct st5481_intr *intr = &adapter->intr; - struct usb_host_interface *altsetting; + struct usb_interface *intf; + struct usb_host_interface *altsetting = NULL; struct usb_host_endpoint *endpoint; int status; struct urb *urb; @@ -257,8 +258,11 @@ return status; } - - altsetting = &(dev->config->interface[0]->altsetting[3]); + intf = usb_ifnum_to_if(dev, 0); + if (intf) + altsetting = usb_altnum_to_altsetting(intf, 3); + if (!altsetting) + return -ENXIO; // Check if the config is sane if ( altsetting->desc.bNumEndpoints != 7 ) {