aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorPaulo Marques <pmarques@grupopie.com>2005-05-18 08:12:49 -0400
committerGreg KH <gregkh@suse.de>2005-06-03 03:04:29 -0400
commit77ddecc3c047e4e9bd7332d3173def93ea2de1ad (patch)
tree9ea913e583e6ccccd97232da3e184e668fa79576 /drivers
parent58cfe9113e485f7e04bd0eac4fc4251b330af501 (diff)
[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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/core/sysfs.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 4ab50009291d..4d0c9e65cd03 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -290,32 +290,30 @@ static ssize_t show_modalias(struct device *dev, char *buf)
290{ 290{
291 struct usb_interface *intf; 291 struct usb_interface *intf;
292 struct usb_device *udev; 292 struct usb_device *udev;
293 int len;
293 294
294 intf = to_usb_interface(dev); 295 intf = to_usb_interface(dev);
295 udev = interface_to_usbdev(intf); 296 udev = interface_to_usbdev(intf);
296 if (udev->descriptor.bDeviceClass == 0) {
297 struct usb_host_interface *alt = intf->cur_altsetting;
298 297
299 return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X\n", 298 len = sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic",
300 le16_to_cpu(udev->descriptor.idVendor), 299 le16_to_cpu(udev->descriptor.idVendor),
301 le16_to_cpu(udev->descriptor.idProduct), 300 le16_to_cpu(udev->descriptor.idProduct),
302 le16_to_cpu(udev->descriptor.bcdDevice), 301 le16_to_cpu(udev->descriptor.bcdDevice),
303 udev->descriptor.bDeviceClass, 302 udev->descriptor.bDeviceClass,
304 udev->descriptor.bDeviceSubClass, 303 udev->descriptor.bDeviceSubClass,
305 udev->descriptor.bDeviceProtocol, 304 udev->descriptor.bDeviceProtocol);
305 buf += len;
306
307 if (udev->descriptor.bDeviceClass == 0) {
308 struct usb_host_interface *alt = intf->cur_altsetting;
309
310 return len + sprintf(buf, "%02Xisc%02Xip%02X\n",
306 alt->desc.bInterfaceClass, 311 alt->desc.bInterfaceClass,
307 alt->desc.bInterfaceSubClass, 312 alt->desc.bInterfaceSubClass,
308 alt->desc.bInterfaceProtocol); 313 alt->desc.bInterfaceProtocol);
309 } else { 314 } else {
310 return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*\n", 315 return len + sprintf(buf, "*isc*ip*\n");
311 le16_to_cpu(udev->descriptor.idVendor),
312 le16_to_cpu(udev->descriptor.idProduct),
313 le16_to_cpu(udev->descriptor.bcdDevice),
314 udev->descriptor.bDeviceClass,
315 udev->descriptor.bDeviceSubClass,
316 udev->descriptor.bDeviceProtocol);
317 } 316 }
318
319} 317}
320static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); 318static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL);
321 319