mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
USB: core: add 'shutdown' callback to usb_driver
Currently there is no standardized method for USB drivers to handle shutdown events. This patch simplifies running code on shutdown for USB devices by adding a shutdown callback to usb_driver. Signed-off-by: Kerem Karabay <kekrby@gmail.com> Signed-off-by: Aditya Garg <gargaditya08@live.com> Link: https://lore.kernel.org/r/7AAC1BF4-8B60-448D-A3C1-B7E80330BE42@live.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
41ea26a06a
commit
a5f81642a7
@ -517,6 +517,19 @@ static int usb_unbind_interface(struct device *dev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void usb_shutdown_interface(struct device *dev)
|
||||||
|
{
|
||||||
|
struct usb_interface *intf = to_usb_interface(dev);
|
||||||
|
struct usb_driver *driver;
|
||||||
|
|
||||||
|
if (!dev->driver)
|
||||||
|
return;
|
||||||
|
|
||||||
|
driver = to_usb_driver(dev->driver);
|
||||||
|
if (driver->shutdown)
|
||||||
|
driver->shutdown(intf);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* usb_driver_claim_interface - bind a driver to an interface
|
* usb_driver_claim_interface - bind a driver to an interface
|
||||||
* @driver: the driver to be bound
|
* @driver: the driver to be bound
|
||||||
@ -1059,6 +1072,7 @@ int usb_register_driver(struct usb_driver *new_driver, struct module *owner,
|
|||||||
new_driver->driver.bus = &usb_bus_type;
|
new_driver->driver.bus = &usb_bus_type;
|
||||||
new_driver->driver.probe = usb_probe_interface;
|
new_driver->driver.probe = usb_probe_interface;
|
||||||
new_driver->driver.remove = usb_unbind_interface;
|
new_driver->driver.remove = usb_unbind_interface;
|
||||||
|
new_driver->driver.shutdown = usb_shutdown_interface;
|
||||||
new_driver->driver.owner = owner;
|
new_driver->driver.owner = owner;
|
||||||
new_driver->driver.mod_name = mod_name;
|
new_driver->driver.mod_name = mod_name;
|
||||||
new_driver->driver.dev_groups = new_driver->dev_groups;
|
new_driver->driver.dev_groups = new_driver->dev_groups;
|
||||||
|
@ -1171,6 +1171,7 @@ extern ssize_t usb_show_dynids(struct usb_dynids *dynids, char *buf);
|
|||||||
* post_reset method is called.
|
* post_reset method is called.
|
||||||
* @post_reset: Called by usb_reset_device() after the device
|
* @post_reset: Called by usb_reset_device() after the device
|
||||||
* has been reset
|
* has been reset
|
||||||
|
* @shutdown: Called at shut-down time to quiesce the device.
|
||||||
* @id_table: USB drivers use ID table to support hotplugging.
|
* @id_table: USB drivers use ID table to support hotplugging.
|
||||||
* Export this with MODULE_DEVICE_TABLE(usb,...). This must be set
|
* Export this with MODULE_DEVICE_TABLE(usb,...). This must be set
|
||||||
* or your driver's probe function will never get called.
|
* or your driver's probe function will never get called.
|
||||||
@ -1222,6 +1223,8 @@ struct usb_driver {
|
|||||||
int (*pre_reset)(struct usb_interface *intf);
|
int (*pre_reset)(struct usb_interface *intf);
|
||||||
int (*post_reset)(struct usb_interface *intf);
|
int (*post_reset)(struct usb_interface *intf);
|
||||||
|
|
||||||
|
void (*shutdown)(struct usb_interface *intf);
|
||||||
|
|
||||||
const struct usb_device_id *id_table;
|
const struct usb_device_id *id_table;
|
||||||
const struct attribute_group **dev_groups;
|
const struct attribute_group **dev_groups;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user