[PATCH] USB: make MODALIAS code a bit smaller devices
This patch makes the code to provide modalias in sysfs for usb devices 56 bytes smaller in i386, while making it clear that the first part of the modalias string is the same no matter what the device class is. Signed-Off-By: Paulo Marques <pmarques@grupopie.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
58cfe9113e
commit
77ddecc3c0
1 changed files with 13 additions and 15 deletions
|
@ -290,32 +290,30 @@ static ssize_t show_modalias(struct device *dev, char *buf)
|
||||||
{
|
{
|
||||||
struct usb_interface *intf;
|
struct usb_interface *intf;
|
||||||
struct usb_device *udev;
|
struct usb_device *udev;
|
||||||
|
int len;
|
||||||
|
|
||||||
intf = to_usb_interface(dev);
|
intf = to_usb_interface(dev);
|
||||||
udev = interface_to_usbdev(intf);
|
udev = interface_to_usbdev(intf);
|
||||||
if (udev->descriptor.bDeviceClass == 0) {
|
|
||||||
struct usb_host_interface *alt = intf->cur_altsetting;
|
|
||||||
|
|
||||||
return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X\n",
|
len = sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic",
|
||||||
le16_to_cpu(udev->descriptor.idVendor),
|
|
||||||
le16_to_cpu(udev->descriptor.idProduct),
|
|
||||||
le16_to_cpu(udev->descriptor.bcdDevice),
|
|
||||||
udev->descriptor.bDeviceClass,
|
|
||||||
udev->descriptor.bDeviceSubClass,
|
|
||||||
udev->descriptor.bDeviceProtocol,
|
|
||||||
alt->desc.bInterfaceClass,
|
|
||||||
alt->desc.bInterfaceSubClass,
|
|
||||||
alt->desc.bInterfaceProtocol);
|
|
||||||
} else {
|
|
||||||
return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*\n",
|
|
||||||
le16_to_cpu(udev->descriptor.idVendor),
|
le16_to_cpu(udev->descriptor.idVendor),
|
||||||
le16_to_cpu(udev->descriptor.idProduct),
|
le16_to_cpu(udev->descriptor.idProduct),
|
||||||
le16_to_cpu(udev->descriptor.bcdDevice),
|
le16_to_cpu(udev->descriptor.bcdDevice),
|
||||||
udev->descriptor.bDeviceClass,
|
udev->descriptor.bDeviceClass,
|
||||||
udev->descriptor.bDeviceSubClass,
|
udev->descriptor.bDeviceSubClass,
|
||||||
udev->descriptor.bDeviceProtocol);
|
udev->descriptor.bDeviceProtocol);
|
||||||
}
|
buf += len;
|
||||||
|
|
||||||
|
if (udev->descriptor.bDeviceClass == 0) {
|
||||||
|
struct usb_host_interface *alt = intf->cur_altsetting;
|
||||||
|
|
||||||
|
return len + sprintf(buf, "%02Xisc%02Xip%02X\n",
|
||||||
|
alt->desc.bInterfaceClass,
|
||||||
|
alt->desc.bInterfaceSubClass,
|
||||||
|
alt->desc.bInterfaceProtocol);
|
||||||
|
} else {
|
||||||
|
return len + sprintf(buf, "*isc*ip*\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL);
|
static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue