[PATCH] USB: allow usb drivers to disable dynamic ids
authorGreg Kroah-Hartman <gregkh@suse.de>
Wed, 16 Nov 2005 21:41:28 +0000 (13:41 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 4 Jan 2006 21:48:32 +0000 (13:48 -0800)
This lets drivers, like the usb-serial ones, disable the ability to add
ids from sysfs.

The usb-serial drivers are "odd" in that they are really usb-serial bus
drivers, not usb bus drivers, so the dynamic id logic will have to go
into the usb-serial bus core for those drivers to get that ability.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
32 files changed:
drivers/usb/core/driver.c
drivers/usb/serial/airprime.c
drivers/usb/serial/anydata.c
drivers/usb/serial/belkin_sa.c
drivers/usb/serial/cp2101.c
drivers/usb/serial/cyberjack.c
drivers/usb/serial/cypress_m8.c
drivers/usb/serial/digi_acceleport.c
drivers/usb/serial/empeg.c
drivers/usb/serial/ftdi_sio.c
drivers/usb/serial/garmin_gps.c
drivers/usb/serial/generic.c
drivers/usb/serial/hp4x.c
drivers/usb/serial/io_edgeport.c
drivers/usb/serial/io_ti.c
drivers/usb/serial/ipaq.c
drivers/usb/serial/ipw.c
drivers/usb/serial/ir-usb.c
drivers/usb/serial/keyspan.h
drivers/usb/serial/keyspan_pda.c
drivers/usb/serial/kl5kusb105.c
drivers/usb/serial/kobil_sct.c
drivers/usb/serial/mct_u232.c
drivers/usb/serial/omninet.c
drivers/usb/serial/option.c
drivers/usb/serial/pl2303.c
drivers/usb/serial/safe_serial.c
drivers/usb/serial/ti_usb_3410_5052.c
drivers/usb/serial/usb-serial.c
drivers/usb/serial/visor.c
drivers/usb/serial/whiteheat.c
include/linux/usb.h

index 1c06110..5e65bc2 100644 (file)
@@ -112,12 +112,26 @@ static int usb_create_newid_file(struct usb_driver *usb_drv)
 {
        int error = 0;
 
+       if (usb_drv->no_dynamic_id)
+               goto exit;
+
        if (usb_drv->probe != NULL)
                error = sysfs_create_file(&usb_drv->driver.kobj,
                                          &driver_attr_new_id.attr);
+exit:
        return error;
 }
 
+static void usb_remove_newid_file(struct usb_driver *usb_drv)
+{
+       if (usb_drv->no_dynamic_id)
+               return;
+
+       if (usb_drv->probe != NULL)
+               sysfs_remove_file(&usb_drv->driver.kobj,
+                                 &driver_attr_new_id.attr);
+}
+
 static void usb_free_dynids(struct usb_driver *usb_drv)
 {
        struct usb_dynid *dynid, *n;
@@ -135,6 +149,10 @@ static inline int usb_create_newid_file(struct usb_driver *usb_drv)
        return 0;
 }
 
+static void usb_remove_newid_file(struct usb_driver *usb_drv)
+{
+}
+
 static inline void usb_free_dynids(struct usb_driver *usb_drv)
 {
 }
@@ -447,6 +465,7 @@ void usb_deregister(struct usb_driver *driver)
        pr_info("%s: deregistering driver %s\n", usbcore_name, driver->name);
 
        usb_lock_all_devices();
+       usb_remove_newid_file(driver);
        usb_free_dynids(driver);
        driver_unregister(&driver->driver);
        usb_unlock_all_devices();
index 1f29d88..2ef9945 100644 (file)
@@ -28,6 +28,7 @@ static struct usb_driver airprime_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
+       .no_dynamic_id =        1,
 };
 
 static struct usb_serial_driver airprime_device = {
index 18022a7..7a171e0 100644 (file)
@@ -32,6 +32,7 @@ static struct usb_driver anydata_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
+       .no_dynamic_id =        1,
 };
 
 static int anydata_open(struct usb_serial_port *port, struct file *filp)
index 84bc0ee..69039bd 100644 (file)
@@ -118,6 +118,7 @@ static struct usb_driver belkin_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table_combined,
+       .no_dynamic_id =        1,
 };
 
 /* All of the device info needed for the serial converters */
index c978700..813bab3 100644 (file)
@@ -72,6 +72,7 @@ static struct usb_driver cp2101_driver = {
        .probe          = usb_serial_probe,
        .disconnect     = usb_serial_disconnect,
        .id_table       = id_table,
+       .no_dynamic_id  =       1,
 };
 
 static struct usb_serial_driver cp2101_device = {
index e581e4a..8c10e40 100644 (file)
@@ -81,6 +81,7 @@ static struct usb_driver cyberjack_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
+       .no_dynamic_id =        1,
 };
 
 static struct usb_serial_driver cyberjack_device = {
index af9290e..af18355 100644 (file)
@@ -112,6 +112,7 @@ static struct usb_driver cypress_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table_combined,
+       .no_dynamic_id =        1,
 };
 
 struct cypress_private {
index dc74644..c50cec9 100644 (file)
@@ -498,6 +498,7 @@ static struct usb_driver digi_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table_combined,
+       .no_dynamic_id =        1,
 };
 
 
index 0b0546d..e5e4006 100644 (file)
@@ -110,6 +110,7 @@ static struct usb_driver empeg_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
+       .no_dynamic_id =        1,
 };
 
 static struct usb_serial_driver empeg_device = {
index 06e04b4..857fe79 100644 (file)
@@ -488,6 +488,7 @@ static struct usb_driver ftdi_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table_combined,
+       .no_dynamic_id =        1,
 };
 
 static char *ftdi_chip_name[] = {
index 35820bd..198a322 100644 (file)
@@ -227,6 +227,7 @@ static struct usb_driver garmin_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
+       .no_dynamic_id =        1,
 };
 
 
index 53a47c3..c00a440 100644 (file)
@@ -73,6 +73,7 @@ static struct usb_driver generic_driver = {
        .probe =        generic_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     generic_serial_ids,
+       .no_dynamic_id =        1,
 };
 #endif
 
index 8eadfb7..e588c3f 100644 (file)
@@ -42,6 +42,7 @@ static struct usb_driver hp49gp_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
+       .no_dynamic_id =        1,
 };
 
 static struct usb_serial_driver hp49gp_device = {
index dc4c498..276bd42 100644 (file)
@@ -247,6 +247,7 @@ static struct usb_driver io_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table_combined,
+       .no_dynamic_id =        1,
 };
 
 /* function prototypes for all of our local functions */
index 832b6d6..8b2e4c7 100644 (file)
@@ -221,6 +221,7 @@ static struct usb_driver io_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table_combined,
+       .no_dynamic_id =        1,
 };
 
 
index d5d0664..efb568b 100644 (file)
@@ -547,6 +547,7 @@ static struct usb_driver ipaq_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     ipaq_id_table,
+       .no_dynamic_id =        1,
 };
 
 
index 7744b81..64e2cda 100644 (file)
@@ -157,6 +157,7 @@ static struct usb_driver usb_ipw_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     usb_ipw_ids,
+       .no_dynamic_id =        1,
 };
 
 static int debug;
index 19f329e..647431c 100644 (file)
@@ -130,6 +130,7 @@ static struct usb_driver ir_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
+       .no_dynamic_id =        1,
 };
 
 
index 5cfc13b..4e6f626 100644 (file)
@@ -525,6 +525,7 @@ static struct usb_driver keyspan_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     keyspan_ids_combined,
+       .no_dynamic_id =        1,
 };
 
 /* usb_device_id table for the pre-firmware download keyspan devices */
index cd4f48b..0d1f152 100644 (file)
@@ -155,6 +155,7 @@ static struct usb_driver keyspan_pda_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table_combined,
+       .no_dynamic_id =        1,
 };
 
 static struct usb_device_id id_table_std [] = {
index a8951c0..bd68638 100644 (file)
@@ -121,6 +121,7 @@ static struct usb_driver kl5kusb105d_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
+       .no_dynamic_id =        1,
 };
 
 static struct usb_serial_driver kl5kusb105d_device = {
index 9456dd9..4c853af 100644 (file)
@@ -102,6 +102,7 @@ static struct usb_driver kobil_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
+       .no_dynamic_id =        1,
 };
 
 
index ca5dbad..b0415e7 100644 (file)
@@ -130,6 +130,7 @@ static struct usb_driver mct_u232_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table_combined,
+       .no_dynamic_id =        1,
 };
 
 static struct usb_serial_driver mct_u232_device = {
index 3caf970..b595bef 100644 (file)
@@ -85,6 +85,7 @@ static struct usb_driver omninet_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
+       .no_dynamic_id =        1,
 };
 
 
index 7716000..4ee657e 100644 (file)
@@ -100,6 +100,7 @@ static struct usb_driver option_driver = {
        .probe      = usb_serial_probe,
        .disconnect = usb_serial_disconnect,
        .id_table   = option_ids,
+       .no_dynamic_id =        1,
 };
 
 /* The card has three separate interfaces, wich the serial driver
index 41a45a5..e302a32 100644 (file)
@@ -87,6 +87,7 @@ static struct usb_driver pl2303_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
+       .no_dynamic_id =        1,
 };
 
 #define SET_LINE_REQUEST_TYPE          0x21
index c22bdc0..f8241c1 100644 (file)
@@ -165,6 +165,7 @@ static struct usb_driver safe_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
+       .no_dynamic_id =        1,
 };
 
 static __u16 crc10_table[256] = {
index 205dbf7..17a1f09 100644 (file)
@@ -253,6 +253,7 @@ static struct usb_driver ti_usb_driver = {
        .probe                  = usb_serial_probe,
        .disconnect             = usb_serial_disconnect,
        .id_table               = ti_id_table_combined,
+       .no_dynamic_id =        1,
 };
 
 static struct usb_serial_driver ti_1port_device = {
index 0c4881d..2ac37b5 100644 (file)
@@ -46,6 +46,7 @@ static struct usb_driver usb_serial_driver = {
        .name =         "usbserial",
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
+       .no_dynamic_id =        1,
 };
 
 /* There is no MODULE_DEVICE_TABLE for usbserial.c.  Instead
index a473c1c..2973f55 100644 (file)
@@ -178,6 +178,7 @@ static struct usb_driver visor_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table_combined,
+       .no_dynamic_id =        1,
 };
 
 /* All of the device info needed for the Handspring Visor, and Palm 4.0 devices */
index 18c3183..19c6386 100644 (file)
@@ -132,6 +132,7 @@ static struct usb_driver whiteheat_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table_combined,
+       .no_dynamic_id =        1,
 };
 
 /* function prototypes for the Connect Tech WhiteHEAT prerenumeration device */
index 0dd96ef..8d58299 100644 (file)
@@ -561,6 +561,8 @@ struct usb_dynids {
  * @dynids: used internally to hold the list of dynamically added device
  *     ids for this driver.
  * @driver: the driver model core driver structure.
+ * @no_dynamic_id: if set to 1, the USB core will not allow dynamic ids to be
+ *     added to this driver by preventing the sysfs file from being created.
  *
  * USB drivers must provide a name, probe() and disconnect() methods,
  * and an id_table.  Other driver fields are optional.
@@ -597,6 +599,7 @@ struct usb_driver {
 
        struct usb_dynids dynids;
        struct device_driver driver;
+       unsigned int no_dynamic_id:1;
 };
 #define        to_usb_driver(d) container_of(d, struct usb_driver, driver)