Commit 7521803dcc0137668bb30483383092a647671d8b

Authored by Greg Kroah-Hartman
1 parent 17a882fc0c

[PATCH] USB: always export interface information for modalias

This fixes a problem with some cdc acm devices that were not getting
automatically loaded as the module alias was not being reported
properly.

This check was for back in the days when we only reported hotplug events
for the main usb device, not the interfaces.  We should always give the
interface information for MODALIAS/modalias as it can be needed.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Showing 2 changed files with 37 additions and 61 deletions Side-by-side Diff

drivers/usb/core/sysfs.c
... ... @@ -462,30 +462,23 @@
462 462 {
463 463 struct usb_interface *intf;
464 464 struct usb_device *udev;
465   - int len;
  465 + struct usb_host_interface *alt;
466 466  
467 467 intf = to_usb_interface(dev);
468 468 udev = interface_to_usbdev(intf);
  469 + alt = intf->cur_altsetting;
469 470  
470   - len = sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic",
471   - le16_to_cpu(udev->descriptor.idVendor),
472   - le16_to_cpu(udev->descriptor.idProduct),
473   - le16_to_cpu(udev->descriptor.bcdDevice),
474   - udev->descriptor.bDeviceClass,
475   - udev->descriptor.bDeviceSubClass,
476   - udev->descriptor.bDeviceProtocol);
477   - buf += len;
478   -
479   - if (udev->descriptor.bDeviceClass == 0) {
480   - struct usb_host_interface *alt = intf->cur_altsetting;
481   -
482   - return len + sprintf(buf, "%02Xisc%02Xip%02X\n",
483   - alt->desc.bInterfaceClass,
484   - alt->desc.bInterfaceSubClass,
485   - alt->desc.bInterfaceProtocol);
486   - } else {
487   - return len + sprintf(buf, "*isc*ip*\n");
488   - }
  471 + return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02X"
  472 + "ic%02Xisc%02Xip%02X\n",
  473 + le16_to_cpu(udev->descriptor.idVendor),
  474 + le16_to_cpu(udev->descriptor.idProduct),
  475 + le16_to_cpu(udev->descriptor.bcdDevice),
  476 + udev->descriptor.bDeviceClass,
  477 + udev->descriptor.bDeviceSubClass,
  478 + udev->descriptor.bDeviceProtocol,
  479 + alt->desc.bInterfaceClass,
  480 + alt->desc.bInterfaceSubClass,
  481 + alt->desc.bInterfaceProtocol);
489 482 }
490 483 static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL);
491 484  
drivers/usb/core/usb.c
... ... @@ -569,6 +569,7 @@
569 569 {
570 570 struct usb_interface *intf;
571 571 struct usb_device *usb_dev;
  572 + struct usb_host_interface *alt;
572 573 int i = 0;
573 574 int length = 0;
574 575  
... ... @@ -585,7 +586,8 @@
585 586  
586 587 intf = to_usb_interface(dev);
587 588 usb_dev = interface_to_usbdev (intf);
588   -
  589 + alt = intf->cur_altsetting;
  590 +
589 591 if (usb_dev->devnum < 0) {
590 592 pr_debug ("usb %s: already deleted?\n", dev->bus_id);
591 593 return -ENODEV;
592 594  
... ... @@ -627,46 +629,27 @@
627 629 usb_dev->descriptor.bDeviceProtocol))
628 630 return -ENOMEM;
629 631  
630   - if (usb_dev->descriptor.bDeviceClass == 0) {
631   - struct usb_host_interface *alt = intf->cur_altsetting;
  632 + if (add_hotplug_env_var(envp, num_envp, &i,
  633 + buffer, buffer_size, &length,
  634 + "INTERFACE=%d/%d/%d",
  635 + alt->desc.bInterfaceClass,
  636 + alt->desc.bInterfaceSubClass,
  637 + alt->desc.bInterfaceProtocol))
  638 + return -ENOMEM;
632 639  
633   - /* 2.4 only exposed interface zero. in 2.5, hotplug
634   - * agents are called for all interfaces, and can use
635   - * $DEVPATH/bInterfaceNumber if necessary.
636   - */
637   - if (add_hotplug_env_var(envp, num_envp, &i,
638   - buffer, buffer_size, &length,
639   - "INTERFACE=%d/%d/%d",
640   - alt->desc.bInterfaceClass,
641   - alt->desc.bInterfaceSubClass,
642   - alt->desc.bInterfaceProtocol))
643   - return -ENOMEM;
644   -
645   - if (add_hotplug_env_var(envp, num_envp, &i,
646   - buffer, buffer_size, &length,
647   - "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X",
648   - le16_to_cpu(usb_dev->descriptor.idVendor),
649   - le16_to_cpu(usb_dev->descriptor.idProduct),
650   - le16_to_cpu(usb_dev->descriptor.bcdDevice),
651   - usb_dev->descriptor.bDeviceClass,
652   - usb_dev->descriptor.bDeviceSubClass,
653   - usb_dev->descriptor.bDeviceProtocol,
654   - alt->desc.bInterfaceClass,
655   - alt->desc.bInterfaceSubClass,
656   - alt->desc.bInterfaceProtocol))
657   - return -ENOMEM;
658   - } else {
659   - if (add_hotplug_env_var(envp, num_envp, &i,
660   - buffer, buffer_size, &length,
661   - "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*",
662   - le16_to_cpu(usb_dev->descriptor.idVendor),
663   - le16_to_cpu(usb_dev->descriptor.idProduct),
664   - le16_to_cpu(usb_dev->descriptor.bcdDevice),
665   - usb_dev->descriptor.bDeviceClass,
666   - usb_dev->descriptor.bDeviceSubClass,
667   - usb_dev->descriptor.bDeviceProtocol))
668   - return -ENOMEM;
669   - }
  640 + if (add_hotplug_env_var(envp, num_envp, &i,
  641 + buffer, buffer_size, &length,
  642 + "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X",
  643 + le16_to_cpu(usb_dev->descriptor.idVendor),
  644 + le16_to_cpu(usb_dev->descriptor.idProduct),
  645 + le16_to_cpu(usb_dev->descriptor.bcdDevice),
  646 + usb_dev->descriptor.bDeviceClass,
  647 + usb_dev->descriptor.bDeviceSubClass,
  648 + usb_dev->descriptor.bDeviceProtocol,
  649 + alt->desc.bInterfaceClass,
  650 + alt->desc.bInterfaceSubClass,
  651 + alt->desc.bInterfaceProtocol))
  652 + return -ENOMEM;
670 653  
671 654 envp[i] = NULL;
672 655