[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 1c061104537943ac667797d6bbc16ad74bcb781c..5e65bc258e1b8a5d7966efd93583f48709aa90f1 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 1f29d883732720602336e341fd3cb2490f084cfe..2ef9945a6c077318b9f3674d22cbb8731c1e9263 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 18022a74a3dc72f4606f0c2af472520187e4b333..7a171e034b59633416232aeff6eb0508ef7c7b5c 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 84bc0ee4f0616c890a687259fea73939413589ff..69039bd9fc5eea09141ec0135ff29ec7567246d0 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 c9787001cf2a1e97ced97d799fe902d83256b469..813bab37e076febd58ba325f0338fc49d6e1af56 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 e581e4ae84830d82ac65f973c4fb1c781665fa21..8c10e40049054bdcf96758df86f1de3a6fea974c 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 af9290ed257bc17b3a5f1762ee1bd0411acb8745..af18355e94cc3fcc3e98bc684a18f191a712f24c 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 dc74644a603d6b72b051cd8387abe588515e43ae..c50cec95f49bc861e993eb3fae69052bb712c561 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 0b0546dcc7b9346a72c5ba0388dfefd064f61908..e5e40064caf22e0d3391776a675ee062f338b1c2 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 06e04b442ff1e9fa9f16fe63df3915a81e874a92..857fe791d702a4ea83f372fba2902b32ff068408 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 35820bda7ae19bfe56b1d33528558f653cafde82..198a322286f999cb230c3f7ae22d398723f78a93 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 53a47c31cd0ea32f6e2985e85fcb0304d0a49820..c00a440dc421a781aa0f44227c0ab385d5449b26 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 8eadfb70560132a5224567be0804fdacd4d03385..e588c3fe632d6b1c752379b6bc5751255f5cf7aa 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 dc4c498bd1eded80f10e15bf7dbdf7753787bfe8..276bd425a474903a4c0be043adf70f48aa7f4ae9 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 832b6d6734c0f6c1886f2e8ad365234e32dab31c..8b2e4c78abcd55eca44e160df649c6e97202d5b5 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 d5d066488100202b88afe7f7e441a4db0adb50ff..efb568be7015276cab68dd0c0d39020df51bc6ce 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 7744b8148bc5618fb626b2ddb93c59082bed7c75..64e2cda2a84a9c3d0afc03b77f97132c7808ffd0 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 19f329e9bdcf5afb161dc17e8512a433945b09d3..647431c1ccb1b13f520eff21f665e693045eec46 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 5cfc13b5e56f59aecdc14191577aef116a572b70..4e6f626f6062aed253a3501dc9b19b6af08fb04c 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 cd4f48bd83b614552372d2c5669aa275ba55ccd0..0d1f15268549c3a7785c2ba5ff1859458b8b2916 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 a8951c0fd0209bdffc6d585715d3f58771a554f7..bd68638b7c351e4d604d7c6c8601b1818edb1da9 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 9456dd9dd13672047beb7d63cbec7ebdd37cfee5..4c853afea3858e651edb98efe249c7193aa45d58 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 ca5dbadb9b7e821c73b4d0fa62ba7435439cf96c..b0415e7542c4a10278f56e3525160e8114110b0c 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 3caf97072ac014947cd036380f1a82ec8e824497..b595befb24cf783b410ae851be792ba2332b6f6f 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 7716000045b73dd632d41f1104c9696b8d715077..4ee657eaaa0ba8289b01a199167112d4cafa9353 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 41a45a5025b21275c818819ef77895468eba91fd..e302a320444cbe693b015ebbf84adf4ba86542b9 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 c22bdc0c4dfde9b02cdc13b490a0d7d6b3b1a446..f8241c152043dd7fff07fdd488f868b3cb152670 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 205dbf7201daa27f0fb366195d22798ff7d31fb5..17a1f09483bdde2afc9f85f1e409395a60bb1b5f 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 0c4881d18cd59b0c30f63b4a3401da3eb3813623..2ac37b52485aa760f11a154818b716d03efba164 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 a473c1c345593453b6a1775a960f0e477c013197..2973f5564c06e8ae5feb922ca7bf729640c14f04 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 18c3183be769d3bea41cafce1e7b226bb29325b9..19c6386bb6926234590d5c92ac7ca7ced093414b 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 0dd96ef78c13dfeadf907ad27883a1e71ee9a7d4..8d5829936bc4ec1d6af094081d6108b3eb63498e 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)