[PATCH] USB: add dynamic id functionality to USB core
Echo the usb vendor and product id to the "new_id" file in the driver's sysfs directory, and then that driver will be able to bind to a device with those ids if it is present. Example: echo 0557 2008 > /sys/bus/usb/drivers/foo_driver/new_id adds the hex values 0557 and 2008 to the device id table for the foo_driver. Note, usb-serial drivers do not currently work with this capability yet. usb-storage also might have some oddities. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
@@ -529,6 +529,11 @@ static inline int usb_make_path (struct usb_device *dev, char *buf,
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
struct usb_dynids {
|
||||
spinlock_t lock;
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct usb_driver - identifies USB driver to usbcore
|
||||
* @owner: Pointer to the module owner of this driver; initialize
|
||||
@@ -553,6 +558,8 @@ static inline int usb_make_path (struct usb_device *dev, char *buf,
|
||||
* @id_table: USB drivers use ID table to support hotplugging.
|
||||
* Export this with MODULE_DEVICE_TABLE(usb,...). This must be set
|
||||
* or your driver's probe function will never get called.
|
||||
* @dynids: used internally to hold the list of dynamically added device
|
||||
* ids for this driver.
|
||||
* @driver: the driver model core driver structure.
|
||||
*
|
||||
* USB drivers must provide a name, probe() and disconnect() methods,
|
||||
@@ -588,6 +595,7 @@ struct usb_driver {
|
||||
|
||||
const struct usb_device_id *id_table;
|
||||
|
||||
struct usb_dynids dynids;
|
||||
struct device_driver driver;
|
||||
};
|
||||
#define to_usb_driver(d) container_of(d, struct usb_driver, driver)
|
||||
|
Reference in New Issue
Block a user