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

[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.
parent 3f48fc79
...@@ -430,20 +430,15 @@ static int findintfep(struct usb_device *dev, unsigned int ep) ...@@ -430,20 +430,15 @@ static int findintfep(struct usb_device *dev, unsigned int ep)
static int findintfif(struct usb_device *dev, unsigned int ifn) static int findintfif(struct usb_device *dev, unsigned int ifn)
{ {
unsigned int i, j; unsigned int i;
struct usb_interface *iface;
struct usb_host_interface *alts;
if (ifn & ~0xff) if (ifn & ~0xff)
return -EINVAL; return -EINVAL;
for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) {
iface = dev->actconfig->interface[i]; if (dev->actconfig->interface[i]->
for (j = 0; j < iface->num_altsetting; j++) { altsetting[0].desc.bInterfaceNumber == ifn)
alts = &iface->altsetting[j];
if (alts->desc.bInterfaceNumber == ifn)
return i; return i;
} }
}
return -ENOENT; return -ENOENT;
} }
...@@ -688,9 +683,7 @@ static int proc_getdriver(struct dev_state *ps, void __user *arg) ...@@ -688,9 +683,7 @@ static int proc_getdriver(struct dev_state *ps, void __user *arg)
return -EFAULT; return -EFAULT;
if ((ret = findintfif(ps->dev, gd.interface)) < 0) if ((ret = findintfif(ps->dev, gd.interface)) < 0)
return ret; return ret;
interface = usb_ifnum_to_if(ps->dev, gd.interface); interface = ps->dev->actconfig->interface[ret];
if (!interface)
return -EINVAL;
if (!interface->driver) if (!interface->driver)
return -ENODATA; return -ENODATA;
strcpy(gd.driver, interface->driver->name); strcpy(gd.driver, interface->driver->name);
...@@ -744,9 +737,7 @@ static int proc_setintf(struct dev_state *ps, void __user *arg) ...@@ -744,9 +737,7 @@ static int proc_setintf(struct dev_state *ps, void __user *arg)
return -EFAULT; return -EFAULT;
if ((ret = findintfif(ps->dev, setintf.interface)) < 0) if ((ret = findintfif(ps->dev, setintf.interface)) < 0)
return ret; return ret;
interface = usb_ifnum_to_if(ps->dev, setintf.interface); interface = ps->dev->actconfig->interface[ret];
if (!interface)
return -EINVAL;
if (interface->driver) { if (interface->driver) {
if ((ret = checkintf(ps, ret))) if ((ret = checkintf(ps, ret)))
return ret; return ret;
......
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