From 93bacefc4cc0b53e1cb6a336d43847154fdf6886 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 17 Dec 2006 21:50:23 +0100 Subject: USB serial: add dynamic id support to usb-serial core MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks to Johannes Hölzl for fixing a few things and getting it all working properly. This adds support for dynamic usb ids to the usb serial core. The file "new_id" will show up under the usb serial driver, not the usb driver associated with the usb-serial driver (yeah, it can be a bit confusing at first glance...) This patch also modifies the USB core to allow the usb-serial core to reuse much of the dynamic id logic. Signed-off-by: Greg Kroah-Hartman Signed-off-by: Johannes Hölzl --- include/linux/usb.h | 12 ++++++++++++ include/linux/usb/serial.h | 5 +++++ 2 files changed, 17 insertions(+) (limited to 'include') diff --git a/include/linux/usb.h b/include/linux/usb.h index f3b21636c9d..3cb9285df2d 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -476,6 +476,8 @@ extern void usb_driver_release_interface(struct usb_driver *driver, struct usb_interface *iface); const struct usb_device_id *usb_match_id(struct usb_interface *interface, const struct usb_device_id *id); +extern int usb_match_one_id(struct usb_interface *interface, + const struct usb_device_id *id); extern struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor); @@ -724,11 +726,21 @@ static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor /* ----------------------------------------------------------------------- */ +/* Stuff for dynamic usb ids */ struct usb_dynids { spinlock_t lock; struct list_head list; }; +struct usb_dynid { + struct list_head node; + struct usb_device_id id; +}; + +extern ssize_t usb_store_new_id(struct usb_dynids *dynids, + struct device_driver *driver, + const char *buf, size_t count); + /** * struct usbdrv_wrap - wrapper for driver-model structure * @driver: The driver-model core driver structure. diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index 10f99e5f1a9..33dcd857669 100644 --- a/include/linux/usb/serial.h +++ b/include/linux/usb/serial.h @@ -179,6 +179,9 @@ static inline void usb_set_serial_data (struct usb_serial *serial, void *data) * memory structure allocation at this point in time. * @shutdown: pointer to the driver's shutdown function. This will be * called when the device is removed from the system. + * @usb_driver: pointer to the struct usb_driver that controls this + * device. This is necessary to allow dynamic ids to be added to + * the driver from sysfs. * * This structure is defines a USB Serial driver. It provides all of * the information that the USB serial core code needs. If the function @@ -202,6 +205,8 @@ struct usb_serial_driver { struct list_head driver_list; struct device_driver driver; + struct usb_driver *usb_driver; + struct usb_dynids dynids; int (*probe) (struct usb_serial *serial, const struct usb_device_id *id); int (*attach) (struct usb_serial *serial); -- cgit v1.2.3