USB: add support for dev_groups to struct usb_device_driver
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 6 Aug 2019 14:44:52 +0000 (16:44 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 7 Aug 2019 12:05:04 +0000 (14:05 +0200)
Now that the driver core supports dev_groups for individual drivers,
expose that pointer to struct usb_device_driver to make it easier for USB
drivers to also use it.

Yes, users of usb_device_driver are much rare, but there are instances
already that use custom sysfs files, so adding this support will make
things easier for those drivers.  usbip is one example, hubs might be
another one.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20190806144502.17792-3-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/driver.c
include/linux/usb.h

index 687fc5df4c17aea07cc56ce92129aa06db0eb227..2b27d232d7a75f29af95867ab710fcbb5b8160a9 100644 (file)
@@ -892,6 +892,7 @@ int usb_register_device_driver(struct usb_device_driver *new_udriver,
        new_udriver->drvwrap.driver.probe = usb_probe_device;
        new_udriver->drvwrap.driver.remove = usb_unbind_device;
        new_udriver->drvwrap.driver.owner = owner;
+       new_udriver->drvwrap.driver.dev_groups = new_udriver->dev_groups;
 
        retval = driver_register(&new_udriver->drvwrap.driver);
 
index af4eb6419ae82c1de6684d8271a20c8dca52a6f5..57f667cad3eced801a46e39b1051b78f15f62d59 100644 (file)
@@ -1224,6 +1224,8 @@ struct usb_driver {
  *     module is being unloaded.
  * @suspend: Called when the device is going to be suspended by the system.
  * @resume: Called when the device is being resumed by the system.
+ * @dev_groups: Attributes attached to the device that will be created once it
+ *     is bound to the driver.
  * @drvwrap: Driver-model core structure wrapper.
  * @supports_autosuspend: if set to 0, the USB core will not allow autosuspend
  *     for devices bound to this driver.
@@ -1238,6 +1240,7 @@ struct usb_device_driver {
 
        int (*suspend) (struct usb_device *udev, pm_message_t message);
        int (*resume) (struct usb_device *udev, pm_message_t message);
+       const struct attribute_group **dev_groups;
        struct usbdrv_wrap drvwrap;
        unsigned int supports_autosuspend:1;
 };