Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

[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>

authored by

Paulo Marques and committed by
Greg KH
77ddecc3 58cfe911

+13 -15
+13 -15
drivers/usb/core/sysfs.c
··· 290 290 { 291 291 struct usb_interface *intf; 292 292 struct usb_device *udev; 293 + int len; 293 294 294 295 intf = to_usb_interface(dev); 295 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", 300 - le16_to_cpu(udev->descriptor.idVendor), 301 - le16_to_cpu(udev->descriptor.idProduct), 302 - le16_to_cpu(udev->descriptor.bcdDevice), 303 - udev->descriptor.bDeviceClass, 304 - udev->descriptor.bDeviceSubClass, 305 - udev->descriptor.bDeviceProtocol, 306 - alt->desc.bInterfaceClass, 307 - alt->desc.bInterfaceSubClass, 308 - alt->desc.bInterfaceProtocol); 309 - } else { 310 - return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*\n", 298 + len = sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic", 311 299 le16_to_cpu(udev->descriptor.idVendor), 312 300 le16_to_cpu(udev->descriptor.idProduct), 313 301 le16_to_cpu(udev->descriptor.bcdDevice), 314 302 udev->descriptor.bDeviceClass, 315 303 udev->descriptor.bDeviceSubClass, 316 304 udev->descriptor.bDeviceProtocol); 317 - } 305 + buf += len; 318 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", 311 + alt->desc.bInterfaceClass, 312 + alt->desc.bInterfaceSubClass, 313 + alt->desc.bInterfaceProtocol); 314 + } else { 315 + return len + sprintf(buf, "*isc*ip*\n"); 316 + } 319 317 } 320 318 static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); 321 319