ChangeSet 1.1608.24.37, 2004/03/03 12:52:40-08:00, stern@rowland.harvard.edu [PATCH] USB: Small improvements for devio.c devio.c doesn't need to be changed to support the new altsetting mechanism, but while looking through it I noticed a couple of places that could be improved slightly. Here they are, just removal of some redundant tests (all altsettings for the same interface are guaranteed to have the same bInterfaceNumber) and function calls. drivers/usb/core/devio.c | 21 ++++++--------------- 1 files changed, 6 insertions(+), 15 deletions(-) diff -Nru a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c --- a/drivers/usb/core/devio.c Tue Mar 16 15:04:32 2004 +++ b/drivers/usb/core/devio.c Tue Mar 16 15:04:32 2004 @@ -430,19 +430,14 @@ static int findintfif(struct usb_device *dev, unsigned int ifn) { - unsigned int i, j; - struct usb_interface *iface; - struct usb_host_interface *alts; + unsigned int i; if (ifn & ~0xff) return -EINVAL; for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { - iface = dev->actconfig->interface[i]; - for (j = 0; j < iface->num_altsetting; j++) { - alts = &iface->altsetting[j]; - if (alts->desc.bInterfaceNumber == ifn) - return i; - } + if (dev->actconfig->interface[i]-> + altsetting[0].desc.bInterfaceNumber == ifn) + return i; } return -ENOENT; } @@ -688,9 +683,7 @@ return -EFAULT; if ((ret = findintfif(ps->dev, gd.interface)) < 0) return ret; - interface = usb_ifnum_to_if(ps->dev, gd.interface); - if (!interface) - return -EINVAL; + interface = ps->dev->actconfig->interface[ret]; if (!interface->driver) return -ENODATA; strcpy(gd.driver, interface->driver->name); @@ -744,9 +737,7 @@ return -EFAULT; if ((ret = findintfif(ps->dev, setintf.interface)) < 0) return ret; - interface = usb_ifnum_to_if(ps->dev, setintf.interface); - if (!interface) - return -EINVAL; + interface = ps->dev->actconfig->interface[ret]; if (interface->driver) { if ((ret = checkintf(ps, ret))) return ret;