USB driver conversion to "struct device_driver" for 2.5.31
Subsystems (10)
RFC 1/1 USB driver conversion to "struct device_driver" for 2.5.31
Hi all,
Here's another patch against 2.5.31 + all of the previous USB patches, that is the next snapshot for converting the USB code to using the core "struct device_driver" logic. The patch also includes lots of drivers/base patches from Pat Mochel that are already in Linus's latest BK tree, which are necessary for this patch.
Improvements over the last patch is:
- usb-serial core is converted, now all usb-serial drivers register with the USB core and the usb-serial core.
- usb-storage driver is converted. This was easier than I expected, once I added a helper function to the usb core for drivers that care about the interface number they are dealing with. Note, this is a BIG improvement over the current ifnum code in probe() as now you can get the _correct_ ifnum of an interface (previously the core just incremented the number, which could be incorrect, as some recent audio devices have proven.)
- other USB core cleanups, removing lots of unused code, and fixing the device tree representation, along with a number of oopses.
Comments are appreciated.
thanks,
greg k-h
Documentation/filesystems/driverfs.txt +4 -4
@@ -165,9 +165,9 @@ order to relieve pain in declaring attributes, the subsystem should also define a macro, like: -#define DEVICE_ATTR(_name,_str,_mode,_show,_store) \ +#define DEVICE_ATTR(_name,_mode,_show,_store) \ struct device_attribute dev_attr_##_name = { \ - .attr = {.name = _str, .mode = _mode }, \ + .attr = {.name = __stringify(_name) , .mode = _mode }, \ .show = _show, \ .store = _store, \ };
@@ -252,7 +252,7 @@ Declaring: -BUS_ATTR(_name,_str,_mode,_show,_store) +BUS_ATTR(_name,_mode,_show,_store) Creation/Removal:
@@ -273,7 +273,7 @@ Declaring: -DRIVER_ATTR(_name,_str,_mode,_show,_store) +DRIVER_ATTR(_name,_mode,_show,_store) Creation/Removal:
drivers/base/base.h +2 -0
@@ -9,6 +9,8 @@extern struct device device_root;extern spinlock_t device_lock; +extern struct device *get_device_locked (struct device *); +extern int bus_add_device (struct device * dev);extern void bus_remove_device (struct device * dev);
drivers/base/bus.c +46 -51
146 lines not on this page · raw message
drivers/base/core.c +56 -56
190 lines not on this page · raw message
drivers/base/driver.c +23 -30
90 lines not on this page · raw message
drivers/base/interface.c +2 -2
@@ -14,7 +14,7 @@return off ?0 :sprintf (buf,"%s\n" ,dev->name); } -static DEVICE_ATTR(name,"name",S_IRUGO,device_read_name,NULL); +static DEVICE_ATTR(name,S_IRUGO,device_read_name,NULL);static ssize_t device_read_power (struct device * dev,char * page,size_t count,loff_t off)
@@ -85,7 +85,7 @@return error <0 ? error : count; } -static DEVICE_ATTR(power,"power",S_IWUSR | S_IRUGO, +static DEVICE_ATTR(power,S_IWUSR | S_IRUGO, device_read_power,device_write_power);struct device_attribute * device_default_files[] = {
drivers/base/power.c +41 -51
133 lines not on this page · raw message
drivers/pci/proc.c +2 -2
@@ -378,7 +378,7 @@return off ?0 :sprintf (buf,"%u\n" ,pci_dev->irq); } -static DEVICE_ATTR(irq,"irq",S_IRUGO,pci_show_irq,NULL); +static DEVICE_ATTR(irq,S_IRUGO,pci_show_irq,NULL);static ssize_t pci_show_resources (struct device * dev,char * buf,size_t count,loff_t off) {
@@ -402,7 +402,7 @@return (str - buf); } -static DEVICE_ATTR(resource,"resource",S_IRUGO,pci_show_resources,NULL); +static DEVICE_ATTR(resource,S_IRUGO,pci_show_resources,NULL);int pci_proc_attach_device (struct pci_dev *dev) {
drivers/scsi/scsi_scan.c +1 -1
@@ -305,7 +305,7 @@return 0 ; } -static DEVICE_ATTR(type,"type",S_IRUGO,scsi_device_type_read,NULL); +static DEVICE_ATTR(type,S_IRUGO,scsi_device_type_read,NULL);/* end content handlers */
drivers/scsi/sg.c +2 -2
@@ -1401,14 +1401,14 @@Sg_device * sdp=list_entry (driverfs_dev, Sg_device, sg_driverfs_dev);return off ?0 :sprintf (page,"%x\n" ,sdp->i_rdev.value); } -static DEVICE_ATTR(kdev,"kdev",S_IRUGO,sg_device_kdev_read,NULL); +static DEVICE_ATTR(kdev,S_IRUGO,sg_device_kdev_read,NULL);static ssize_t sg_device_type_read (struct device *driverfs_dev,char *page,size_t count,loff_t off) {return off ?0 :sprintf (page,"CHR\n" ); } -static DEVICE_ATTR(type,"type",S_IRUGO,sg_device_type_read,NULL); +static DEVICE_ATTR(type,S_IRUGO,sg_device_type_read,NULL);static int sg_attach (Scsi_Device * scsidp) {
drivers/scsi/sr.c +2 -2
@@ -737,14 +737,14 @@ kdev.value=(int )driverfs_dev->driver_data;return off ?0 :sprintf (page,"%x\n" ,kdev.value); } -static DEVICE_ATTR(kdev,"kdev",S_IRUGO,sr_device_kdev_read,NULL); +static DEVICE_ATTR(kdev,S_IRUGO,sr_device_kdev_read,NULL);static ssize_t sr_device_type_read (struct device *driverfs_dev,char *page,size_t count,loff_t off) {return off ?0 :sprintf (page,"CHR\n" ); } -static DEVICE_ATTR(type,"type",S_IRUGO,sr_device_type_read,NULL); +static DEVICE_ATTR(type,S_IRUGO,sr_device_type_read,NULL);void sr_finish ()
drivers/scsi/st.c +2 -2
@@ -3533,14 +3533,14 @@ kdev.value=(int )driverfs_dev->driver_data;return off ?0 :sprintf (page,"%x\n" ,kdev.value); } -static DEVICE_ATTR(kdev,"kdev",S_IRUGO,st_device_kdev_read,NULL); +static DEVICE_ATTR(kdev,S_IRUGO,st_device_kdev_read,NULL);static ssize_t st_device_type_read (struct device *driverfs_dev,char *page,size_t count,loff_t off) {return off ?0 :sprintf (page,"CHR\n" ); } -static DEVICE_ATTR(type,"type",S_IRUGO,st_device_type_read,NULL); +static DEVICE_ATTR(type,S_IRUGO,st_device_type_read,NULL); static struct file_operations st_fops =
drivers/usb/class/audio.c +0 -1
@@ -2756,7 +2756,6 @@ .name = "audio", .probe = usb_audio_probe, .disconnect = usb_audio_disconnect, - .driver_list = LIST_HEAD_INIT(usb_audio_driver.driver_list), .id_table = usb_audio_ids, };
drivers/usb/class/usb-midi.c +0 -1
@@ -2099,7 +2099,6 @@ .probe = usb_midi_probe, .disconnect = usb_midi_disconnect, .id_table = NULL, /* check all devices */ - .driver_list = LIST_HEAD_INIT(usb_midi_driver.driver_list) };/* ------------------------------------------------------------------------- */
drivers/usb/core/devices.c +0 -1
@@ -111,7 +111,6 @@/* * Need access to the driver and USB bus lists. -* extern struct list_head usb_driver_list; * extern struct list_head usb_bus_list; * However, these will come from functions that return ptrs to each of them. */
drivers/usb/core/devio.c +3 -25
@@ -427,30 +427,6 @@return -ENOENT ; } -extern struct list_head usb_driver_list; - -#if 0 -static int finddriver (struct usb_driver **driver,char *name) -{ -struct list_head *tmp; - - tmp = usb_driver_list.next; -while (tmp != &usb_driver_list) { - struct usb_driver *d = list_entry(tmp, struct usb_driver, - driver_list); - -if (!strcmp (d->name, name)) { - *driver = d; -return 0 ; - } - - tmp = tmp->next; - } - -return -EINVAL ; -} -#endif -static int check_ctrlrecip (struct dev_state *ps,unsigned int requesttype,unsigned int index) {int ret;
@@ -1105,7 +1081,9 @@/* let kernel drivers try to (re)bind to the interface */ case USBDEVFS_CONNECT : -usb_find_interface_driver (ps->dev, ifp); +//usb_find_interface_driver (ps->dev, ifp); +err ("USBDEVFS_CONNECT is no longer supported." ); + retval = -EINVAL ;break ;/* talk directly to the interface's driver */
drivers/usb/core/hcd.c +7 -5
@@ -722,13 +722,15 @@ {int retval; - usb_dev->dev.parent = parent_dev; -strcpy (&usb_dev->dev.name[0 ],"usb_name" ); -strcpy (&usb_dev->dev.bus_id[0 ],"usb_bus" ); - retval =usb_new_device (usb_dev); +// usb_dev->dev.parent = parent_dev; +// strcpy (&usb_dev->dev.name[0], "usb_name"); +// strcpy (&usb_dev->dev.bus_id[0], "usb_bus"); + retval =usb_new_device (usb_dev, parent_dev);if (retval) -put_device (&usb_dev->dev); +err ("%s - usb_new_device failed with value %d" , __FUNCTION__, retval); +// put_device (&usb_dev->dev); return retval; +// return usb_new_device (usb_dev, parent_dev); }EXPORT_SYMBOL (usb_register_root_hub);
drivers/usb/core/hcd.h +1 -3
@@ -255,7 +255,7 @@/* -------------------------------------------------------------------------- */ /* Enumeration is only for the hub driver, or HCD virtual root hubs */ -extern int usb_new_device (struct usb_device *dev); +extern int usb_new_device (struct usb_device *dev,struct device *parent);extern void usb_connect (struct usb_device *dev);extern void usb_disconnect (struct usb_device **);
@@ -384,8 +384,6 @@/* for probe/disconnect with correct module usage counting */ void *usb_bind_driver (struct usb_driver *driver,struct usb_interface *intf);void usb_unbind_driver (struct usb_device *device,struct usb_interface *intf); - -extern struct list_head usb_driver_list;/* * USB device fs stuff
drivers/usb/core/hub.c +82 -68
277 lines not on this page · raw message
drivers/usb/core/hub.h +2 -1
@@ -170,7 +170,8 @@extern void usb_hub_tt_clear_buffer (struct usb_device *dev,int pipe);struct usb_hub { -struct usb_device *dev;/* the "real" device */ +// struct usb_device *dev; /* the "real" device */ +struct usb_interface *intf;/* the "real" device */ struct urb *urb;/* for interrupt polling pipe */ /* buffer for urb ... 1 bit each for hub and children, rounded up */
drivers/usb/core/usb.c +161 -275
571 lines not on this page · raw message
drivers/usb/host/ehci-dbg.c +2 -2
@@ -252,7 +252,7 @@return count - size; } -static DEVICE_ATTR (async, "sched-async", S_IRUSR, show_async, NULL); +static DEVICE_ATTR (async, S_IRUSR, show_async, NULL);#define DBG_SCHED_LIMIT 64
@@ -360,7 +360,7 @@return count - size; } -static DEVICE_ATTR (periodic, "sched-periodic", S_IRUSR, show_periodic, NULL); +static DEVICE_ATTR (periodic, S_IRUSR, show_periodic, NULL);#undef DBG_SCHED_LIMIT
drivers/usb/input/hid-core.c +19 -16
@@ -1338,9 +1338,10 @@ { 0, 0 } }; -static struct hid_device *usb_hid_configure (struct usb_device *dev,int ifnum) +static struct hid_device *usb_hid_configure (struct usb_interface *intf) { -struct usb_interface_descriptor *interface = dev->actconfig->interface[ifnum].altsetting +0 ; +struct usb_interface_descriptor *interface = intf->altsetting + intf->act_altsetting; +struct usb_device *dev =interface_to_usbdev (intf);struct hid_descriptor *hdesc;struct hid_device *hid;unsigned quirks =0 , rsize =0 ;
@@ -1450,7 +1451,7 @@snprintf (hid->name,128 ,"%04x:%04x" , dev->descriptor.idVendor, dev->descriptor.idProduct);usb_make_path (dev, buf,64 ); -snprintf (hid->phys,64 ,"%s/input%d" , buf, ifnum); +snprintf (hid->phys,64 ,"%s/input%d" , buf, intf->altsetting[0 ].bInterfaceNumber);if (usb_string (dev, dev->descriptor.iSerialNumber, hid->uniq,64 ) <=0 ) hid->uniq[0 ] =0 ;
@@ -1472,9 +1473,9 @@return NULL ; } -static void hid_disconnect (struct usb_device *dev,void *ptr) +static void hid_disconnect (struct usb_interface *intf) { -struct hid_device *hid = ptr; +struct hid_device *hid = intf->dev.driver_data;usb_unlink_urb (hid->urbin);usb_unlink_urb (hid->urbout);
@@ -1491,20 +1492,20 @@usb_free_urb (hid->urbout);hid_free_device (hid); + intf->dev.driver_data =NULL ; } -static void *hid_probe (struct usb_device *dev,unsigned int ifnum, -const struct usb_device_id *id) +static int hid_probe (struct usb_interface *intf,const struct usb_device_id *id) {struct hid_device *hid;char path[64 ];int i;char *c; -dbg ("HID probe called for ifnum %d" , ifnum); +dbg ("HID probe called for ifnum %d" , intf->ifnum); -if (!(hid =usb_hid_configure (dev, ifnum))) -return NULL ; +if (!(hid =usb_hid_configure (intf))) +return -EIO ;hid_init_reports (hid);hid_dump_device (hid);
@@ -1516,9 +1517,11 @@if (!hiddev_connect (hid)) hid->claimed |=HID_CLAIMED_HIDDEV ; + intf->dev.driver_data = hid; +if (!hid->claimed) { -hid_disconnect (dev, hid); -return NULL ; +hid_disconnect (intf); +return -EIO ; }printk (KERN_INFO );
@@ -1540,12 +1543,12 @@ } } -usb_make_path (dev, path,63 ); +usb_make_path (interface_to_usbdev (intf), path,63 );printk (": USB HID v%x.%02x %s [%s] on %s\n" , hid->version >>8 , hid->version &0xff , c, hid->name, path); -return hid; +return 0 ; }static struct usb_device_id hid_usb_ids [] = {
@@ -1558,8 +1561,8 @@static struct usb_driver hid_driver = { .name ="hid" , - .probe = hid_probe, - .disconnect = hid_disconnect, + .new_probe = hid_probe, + .new_disco = hid_disconnect, .id_table = hid_usb_ids, };
drivers/usb/serial/belkin_sa.c +9 -0
@@ -114,6 +114,13 @@MODULE_DEVICE_TABLE (usb, id_table_combined); +static struct usb_driver belkin_driver = { + .name ="belkin" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table_combined, +}; +/* All of the device info needed for the serial converters */ static struct usb_serial_device_type belkin_device = { .owner =THIS_MODULE ,
@@ -526,6 +533,7 @@static int __init belkin_sa_init (void ) {usb_serial_register (&belkin_device); +usb_register (&belkin_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ; }
@@ -533,6 +541,7 @@ static void __exit belkin_sa_exit (void) { +usb_deregister (&belkin_driver);usb_serial_deregister (&belkin_device); }
drivers/usb/serial/cyberjack.c +9 -0
@@ -73,6 +73,13 @@MODULE_DEVICE_TABLE (usb, id_table); +static struct usb_driver cyberjack_driver = { + .name ="cyberjack" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table, +}; +static struct usb_serial_device_type cyberjack_device = { .owner =THIS_MODULE , .name ="Reiner SCT Cyberjack USB card reader" ,
@@ -461,6 +468,7 @@static int __init cyberjack_init (void ) {usb_serial_register (&cyberjack_device); +usb_register (&cyberjack_driver);info (DRIVER_VERSION " " DRIVER_AUTHOR );info (DRIVER_DESC );
@@ -470,6 +478,7 @@ static void __exit cyberjack_exit (void) { +usb_deregister (&cyberjack_driver);usb_serial_deregister (&cyberjack_device); }
drivers/usb/serial/digi_acceleport.c +11 -1
@@ -477,7 +477,7 @@/* Statics */ -static __devinitdata struct usb_device_id id_table_combined [] = { +static struct usb_device_id id_table_combined [] = { {USB_DEVICE (DIGI_VENDOR_ID ,DIGI_2_ID ) }, {USB_DEVICE (DIGI_VENDOR_ID ,DIGI_4_ID ) }, { }/* Terminating entry */
@@ -495,6 +495,14 @@MODULE_DEVICE_TABLE (usb, id_table_combined); +static struct usb_driver digi_driver = { + .name ="digi_acceleport" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table_combined, +}; + +/* device info needed for the Digi serial converter */ static struct usb_serial_device_type digi_acceleport_2_device = {
@@ -2026,6 +2034,7 @@ {usb_serial_register (&digi_acceleport_2_device);usb_serial_register (&digi_acceleport_4_device); +usb_register (&digi_driver);info (DRIVER_VERSION ":" DRIVER_DESC );return 0 ; }
@@ -2033,6 +2042,7 @@ static void __exit digi_exit (void) { +usb_deregister (&digi_driver);usb_serial_deregister (&digi_acceleport_2_device);usb_serial_deregister (&digi_acceleport_4_device); }
drivers/usb/serial/empeg.c +11 -4
@@ -110,6 +110,13 @@MODULE_DEVICE_TABLE (usb, id_table); +static struct usb_driver empeg_driver = { + .name ="empeg" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table, +}; +static struct usb_serial_device_type empeg_device = { .owner =THIS_MODULE , .name ="Empeg" ,
@@ -550,8 +557,6 @@struct urb *urb;int i; -usb_serial_register (&empeg_device); -/* create our write urb pool and transfer buffers */ spin_lock_init (&write_urb_pool_lock);for (i =0 ; i <NUM_URBS ; ++i) {
@@ -570,10 +575,12 @@ } } +usb_serial_register (&empeg_device); +usb_register (&empeg_driver); +info (DRIVER_VERSION ":" DRIVER_DESC );return 0 ; - }
@@ -582,6 +589,7 @@int i;unsigned long flags; +usb_register (&empeg_driver);usb_serial_deregister (&empeg_device);spin_lock_irqsave (&write_urb_pool_lock, flags);
@@ -599,7 +607,6 @@ }spin_unlock_irqrestore (&write_urb_pool_lock, flags); - }
drivers/usb/serial/ftdi_sio.c +10 -1
@@ -140,7 +140,7 @@ }; -static __devinitdata struct usb_device_id id_table_combined [] = { +static struct usb_device_id id_table_combined [] = { {USB_DEVICE (FTDI_VID ,FTDI_SIO_PID ) }, {USB_DEVICE (FTDI_VID ,FTDI_8U232AM_PID ) }, {USB_DEVICE (FTDI_NF_RIC_VID ,FTDI_NF_RIC_PID ) },
@@ -149,6 +149,13 @@MODULE_DEVICE_TABLE (usb, id_table_combined); +static struct usb_driver ftdi_driver = { + .name ="ftdi_sio" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table_combined, +}; +struct ftdi_private {enum ftdi_type ftdi_type;
@@ -944,6 +951,7 @@dbg (__FUNCTION__);usb_serial_register (&ftdi_sio_device);usb_serial_register (&ftdi_8U232AM_device); +usb_register (&ftdi_driver);info (DRIVER_VERSION ":" DRIVER_DESC );return 0 ; }
@@ -952,6 +960,7 @@ static void __exit ftdi_sio_exit (void) {dbg (__FUNCTION__); +usb_deregister (&ftdi_driver);usb_serial_deregister (&ftdi_sio_device);usb_serial_deregister (&ftdi_8U232AM_device); }
drivers/usb/serial/io_edgeport.c +8 -0
@@ -457,6 +457,12 @@#include "io_tables.h" /* all of the devices that this driver supports */ +static struct usb_driver io_driver = { + .name ="io_edgeport" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table_combined, +};/* function prototypes for all of our local functions */ static int process_rcvd_data (struct edgeport_serial *edge_serial,unsigned char *buffer,__u16 bufferLength);
@@ -3049,6 +3055,7 @@usb_serial_register (&edgeport_2port_device);usb_serial_register (&edgeport_4port_device);usb_serial_register (&edgeport_8port_device); +usb_register (&io_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ; }
@@ -3061,6 +3068,7 @@****************************************************************************/ void __exit edgeport_exit (void) { +usb_deregister (&io_driver);usb_serial_deregister (&edgeport_1port_device);usb_serial_deregister (&edgeport_2port_device);usb_serial_deregister (&edgeport_4port_device);
drivers/usb/serial/io_tables.h +1 -1
@@ -61,7 +61,7 @@ };/* Devices that this driver supports */ -static __devinitdata struct usb_device_id id_table_combined [] = { +static struct usb_device_id id_table_combined [] = { {USB_DEVICE (USB_VENDOR_ID_ION ,ION_DEVICE_ID_EDGEPORT_4 ) }, {USB_DEVICE (USB_VENDOR_ID_ION ,ION_DEVICE_ID_RAPIDPORT_4 ) }, {USB_DEVICE (USB_VENDOR_ID_ION ,ION_DEVICE_ID_EDGEPORT_4T ) },
drivers/usb/serial/io_ti.c +10 -1
@@ -142,7 +142,7 @@ };/* Devices that this driver supports */ -static __devinitdata struct usb_device_id id_table_combined [] = { +static struct usb_device_id id_table_combined [] = { {USB_DEVICE (USB_VENDOR_ID_ION ,ION_DEVICE_ID_TI_EDGEPORT_1 ) }, {USB_DEVICE (USB_VENDOR_ID_ION ,ION_DEVICE_ID_TI_EDGEPORT_2 ) }, {USB_DEVICE (USB_VENDOR_ID_ION ,ION_DEVICE_ID_TI_EDGEPORT_2I ) },
@@ -161,6 +161,13 @@MODULE_DEVICE_TABLE (usb, id_table_combined); +static struct usb_driver io_driver = { + .name ="io_ti" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table_combined, +}; +static struct EDGE_FIRMWARE_VERSION_INFO OperationalCodeImageVersion;
@@ -2658,12 +2665,14 @@ {usb_serial_register (&edgeport_1port_device);usb_serial_register (&edgeport_2port_device); +usb_register (&io_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ; } static void __exit edgeport_exit (void) { +usb_deregister (&io_driver);usb_serial_deregister (&edgeport_1port_device);usb_serial_deregister (&edgeport_2port_device); }
drivers/usb/serial/ipaq.c +10 -0
@@ -94,6 +94,14 @@MODULE_DEVICE_TABLE (usb, ipaq_id_table); +static struct usb_driver ipaq_driver = { + .name ="ipaq" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = ipaq_id_table, +}; + +/* All of the device info needed for the Compaq iPAQ */ struct usb_serial_device_type ipaq_device = { .owner =THIS_MODULE ,
@@ -516,6 +524,7 @@static int __init ipaq_init (void ) {usb_serial_register (&ipaq_device); +usb_register (&ipaq_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ;
@@ -524,6 +533,7 @@ static void __exit ipaq_exit(void) { +usb_deregister (&ipaq_driver);usb_serial_deregister (&ipaq_device); }
drivers/usb/serial/ir-usb.c +9 -0
@@ -129,6 +129,13 @@MODULE_DEVICE_TABLE (usb, id_table); +static struct usb_driver ir_driver = { + .name ="ir-usb" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table, +}; +struct usb_serial_device_type ir_device = { .owner =THIS_MODULE ,
@@ -606,6 +613,7 @@static int __init ir_init (void ) {usb_serial_register (&ir_device); +usb_register (&ir_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ; }
@@ -613,6 +621,7 @@ static void __exit ir_exit (void) { +usb_deregister (&ir_driver);usb_serial_deregister (&ir_device); }
drivers/usb/serial/keyspan.c +2 -0
@@ -183,6 +183,7 @@usb_serial_register (&keyspan_1port_device);usb_serial_register (&keyspan_2port_device);usb_serial_register (&keyspan_4port_device); +usb_register (&keyspan_driver);info (DRIVER_VERSION ":" DRIVER_DESC );
@@ -191,6 +192,7 @@ static void __exit keyspan_exit (void) { +usb_deregister (&keyspan_driver);usb_serial_deregister (&keyspan_pre_device);usb_serial_deregister (&keyspan_1port_device);usb_serial_deregister (&keyspan_2port_device);
drivers/usb/serial/keyspan.h +8 -1
@@ -408,7 +408,7 @@ NULL, }; -static __devinitdata struct usb_device_id keyspan_ids_combined[] = { +static struct usb_device_id keyspan_ids_combined[] = { {USB_DEVICE (KEYSPAN_VENDOR_ID , keyspan_usa18x_pre_product_id) }, {USB_DEVICE (KEYSPAN_VENDOR_ID , keyspan_usa19_pre_product_id) }, {USB_DEVICE (KEYSPAN_VENDOR_ID , keyspan_usa19w_pre_product_id) },
@@ -433,6 +433,13 @@ };MODULE_DEVICE_TABLE (usb, keyspan_ids_combined); + +static struct usb_driver keyspan_driver = { + .name ="keyspan" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = keyspan_ids_combined, +};/* usb_device_id table for the pre-firmware download keyspan devices */ static struct usb_device_id keyspan_pre_ids[] = {
drivers/usb/serial/keyspan_pda.c +10 -1
@@ -140,7 +140,7 @@#define ENTREGRA_VENDOR_ID 0x1645#define ENTREGRA_FAKE_ID 0x8093 -static __devinitdata struct usb_device_id id_table_combined [] = { +static struct usb_device_id id_table_combined [] = {#ifdef KEYSPAN { USB_DEVICE(KEYSPAN_VENDOR_ID, KEYSPAN_PDA_FAKE_ID) }, #endif
@@ -154,6 +154,13 @@MODULE_DEVICE_TABLE (usb, id_table_combined); +static struct usb_driver keyspan_pda_driver = { + .name ="keyspan_pda" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table_combined, +}; +static struct usb_device_id id_table_std [] = { {USB_DEVICE (KEYSPAN_VENDOR_ID ,KEYSPAN_PDA_ID ) }, { }/* Terminating entry */
@@ -862,6 +869,7 @@#ifdef XIRCOM usb_serial_register (&xircom_pgs_fake_device);#endif +usb_register (&keyspan_pda_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ; }
@@ -869,6 +877,7 @@ static void __exit keyspan_pda_exit (void) { +usb_deregister (&keyspan_pda_driver);usb_serial_deregister (&keyspan_pda_device);#ifdef KEYSPAN usb_serial_deregister (&keyspan_pda_fake_device);
drivers/usb/serial/kl5kusb105.c +8 -0
@@ -117,6 +117,12 @@MODULE_DEVICE_TABLE (usb, id_table); +static struct usb_driver kl5kusb105d_driver = { + .name ="kl5kusb105d" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table, +};static struct usb_serial_device_type kl5kusb105d_device = { .owner =THIS_MODULE ,
@@ -1013,6 +1019,7 @@static int __init klsi_105_init (void ) {usb_serial_register (&kl5kusb105d_device); +usb_register (&kl5kusb105d_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ;
@@ -1021,6 +1028,7 @@ static void __exit klsi_105_exit (void) { +usb_deregister (&kl5kusb105d_driver);usb_serial_deregister (&kl5kusb105d_device); }
drivers/usb/serial/mct_u232.c +8 -0
@@ -139,6 +139,12 @@MODULE_DEVICE_TABLE (usb, id_table_combined); +static struct usb_driver mct_u232_driver = { + .name ="mct_u232" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table_combined, +};static struct usb_serial_device_type mct_u232_device = { .owner =THIS_MODULE ,
@@ -783,6 +789,7 @@static int __init mct_u232_init (void ) {usb_serial_register (&mct_u232_device); +usb_register (&mct_u232_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ; }
@@ -790,6 +797,7 @@ static void __exit mct_u232_exit (void) { +usb_deregister (&mct_u232_driver);usb_serial_deregister (&mct_u232_device); }
drivers/usb/serial/omninet.c +9 -0
@@ -83,6 +83,13 @@MODULE_DEVICE_TABLE (usb, id_table); +static struct usb_driver omninet_driver = { + .name ="omninet" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table, +}; +static struct usb_serial_device_type zyxel_omninet_device = { .owner =THIS_MODULE ,
@@ -370,6 +377,7 @@static int __init omninet_init (void ) {usb_serial_register (&zyxel_omninet_device); +usb_register (&omninet_driver);info (DRIVER_VERSION ":" DRIVER_DESC );return 0 ; }
@@ -377,6 +385,7 @@ static void __exit omninet_exit (void) { +usb_deregister (&omninet_driver);usb_serial_deregister (&zyxel_omninet_device); }
drivers/usb/serial/pl2303.c +8 -0
@@ -77,6 +77,12 @@MODULE_DEVICE_TABLE (usb, id_table); +static struct usb_driver pl2303_driver = { + .name ="pl2303" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table, +};#define SET_LINE_REQUEST_TYPE 0x21#define SET_LINE_REQUEST 0x20
@@ -708,6 +714,7 @@static int __init pl2303_init (void ) {usb_serial_register (&pl2303_device); +usb_register (&pl2303_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ; }
@@ -715,6 +722,7 @@ static void __exit pl2303_exit (void) { +usb_deregister (&pl2303_driver);usb_serial_deregister (&pl2303_device); }
drivers/usb/serial/safe_serial.c +9 -0
@@ -161,6 +161,13 @@MODULE_DEVICE_TABLE (usb, id_table); +static struct usb_driver safe_driver = { + .name ="safe_serial" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table, +}; +static __u16 crc10_table[256 ] = {0x000 ,0x233 ,0x255 ,0x066 ,0x299 ,0x0aa ,0x0cc ,0x2ff ,0x301 ,0x132 ,0x154 ,0x367 ,0x198 ,0x3ab ,0x3cd ,0x1fe ,0x031 ,0x202 ,0x264 ,0x057 ,0x2a8 ,0x09b ,0x0fd ,0x2ce ,0x330 ,0x103 ,0x165 ,0x356 ,0x1a9 ,0x39a ,0x3fc ,0x1cf ,
@@ -434,12 +441,14 @@ }usb_serial_register (&safe_device); +usb_register (&safe_driver);return 0 ; } static void __exit safe_exit (void) { +usb_deregister (&safe_driver);usb_serial_deregister (&safe_device); }
drivers/usb/serial/usb-serial.h +3 -0
@@ -233,6 +233,9 @@extern int usb_serial_register (struct usb_serial_device_type *new_device);extern void usb_serial_deregister (struct usb_serial_device_type *device); +extern int usb_serial_probe (struct usb_interface *iface,const struct usb_device_id *id); +extern void usb_serial_disconnect (struct usb_interface *iface); +/* determine if we should include the EzUSB loader functions */ #undef USES_EZUSB_FUNCTIONS#if defined(CONFIG_USB_SERIAL_KEYSPAN_PDA ) || defined(CONFIG_USB_SERIAL_KEYSPAN_PDA_MODULE )
drivers/usb/serial/usbserial.c +33 -37
182 lines not on this page · raw message
drivers/usb/serial/visor.c +9 -2
@@ -197,7 +197,7 @@ { }/* Terminating entry */ }; -static __devinitdata struct usb_device_id id_table_combined [] = { +static struct usb_device_id id_table_combined [] = { {USB_DEVICE (HANDSPRING_VENDOR_ID ,HANDSPRING_VISOR_ID ) }, {USB_DEVICE (PALM_VENDOR_ID ,PALM_M500_ID ) }, {USB_DEVICE (PALM_VENDOR_ID ,PALM_M505_ID ) },
@@ -214,7 +214,12 @@MODULE_DEVICE_TABLE (usb, id_table_combined); - +static struct usb_driver visor_driver = { + .name ="visor" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table_combined, +};/* All of the device info needed for the Handspring Visor, and Palm 4.0 devices */ static struct usb_serial_device_type handspring_device = {
@@ -761,6 +766,7 @@ {usb_serial_register (&handspring_device);usb_serial_register (&clie_3_5_device); +usb_register (&visor_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ;
@@ -769,6 +775,7 @@ static void __exit visor_exit (void) { +usb_deregister (&visor_driver);usb_serial_deregister (&handspring_device);usb_serial_deregister (&clie_3_5_device); }
drivers/usb/serial/whiteheat.c +10 -1
@@ -110,7 +110,7 @@ { }/* Terminating entry */ }; -static __devinitdata struct usb_device_id id_table_combined [] = { +static struct usb_device_id id_table_combined [] = { {USB_DEVICE (CONNECT_TECH_VENDOR_ID ,CONNECT_TECH_WHITE_HEAT_ID ) }, {USB_DEVICE (CONNECT_TECH_VENDOR_ID ,CONNECT_TECH_FAKE_WHITE_HEAT_ID ) }, { }/* Terminating entry */
@@ -118,6 +118,13 @@MODULE_DEVICE_TABLE (usb, id_table_combined); +static struct usb_driver whiteheat_driver = { + .name ="whiteheat" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table_combined, +}; +/* function prototypes for the Connect Tech WhiteHEAT serial converter */ static int whiteheat_open (struct usb_serial_port *port,struct file *filp);static void whiteheat_close (struct usb_serial_port *port,struct file *filp);
@@ -676,6 +683,7 @@ {usb_serial_register (&whiteheat_fake_device);usb_serial_register (&whiteheat_device); +usb_register (&whiteheat_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ; }
@@ -683,6 +691,7 @@ static void __exit whiteheat_exit (void) { +usb_deregister (&whiteheat_driver);usb_serial_deregister (&whiteheat_fake_device);usb_serial_deregister (&whiteheat_device); }
drivers/usb/storage/usb.c +19 -17
@@ -103,10 +103,10 @@struct us_data *us_list;struct semaphore us_list_semaphore; -static void *storage_probe (struct usb_device *dev,unsigned int ifnum, -const struct usb_device_id *id); +static int storage_probe (struct usb_interface *iface, +const struct usb_device_id *id); -static void storage_disconnect (struct usb_device *dev,void *ptr); +static void storage_disconnect (struct usb_interface *iface);/* The entries in this table, except for final ones here * (USB_MASS_STORAGE_CLASS and the empty entry), correspond,
@@ -229,8 +229,8 @@struct usb_driver usb_storage_driver = { .name ="usb-storage" , - .probe = storage_probe, - .disconnect = storage_disconnect, + .new_probe = storage_probe, + .new_disco = storage_disconnect, .id_table = storage_usb_ids, };
@@ -618,9 +618,11 @@ }/* Probe to see if a new device is actually a SCSI device */ -static void *storage_probe (struct usb_device *dev,unsigned int ifnum, -const struct usb_device_id *id) +static int storage_probe (struct usb_interface *intf, +const struct usb_device_id *id) { +struct usb_device *dev =interface_to_usbdev (intf); +int ifnum =usb_if_to_ifnum (intf);int i;const int id_index = id - storage_usb_ids;char mf[USB_STOR_STRING_LEN ];/* manufacturer */
@@ -645,7 +647,6 @@/* the altsetting on the interface we're probing that matched our * usb_match_id table */ -struct usb_interface *intf = dev->actconfig->interface;struct usb_interface_descriptor *altsetting = intf[ifnum].altsetting + intf[ifnum].act_altsetting;US_DEBUGP ("act_altsetting is %d\n" , intf[ifnum].act_altsetting);
@@ -675,7 +676,7 @@US_DEBUGP ("Product: %s\n" , unusual_dev->productName); }else /* no, we can't support it */ -return NULL ; +return -EIO ;/* At this point, we know we've got a live one */ US_DEBUGP ("USB Mass Storage device detected\n" );
@@ -724,7 +725,7 @@ } else if (result != 0) {/* it's not a stall, but another error -- time to bail */ US_DEBUGP ("-- Unknown error. Rejecting device\n" ); -return NULL ; +return -EIO ; } }#endif
@@ -732,7 +733,7 @@/* Do some basic sanity checks, and bail if we find a problem */ if (!ep_in || !ep_out || (protocol ==US_PR_CBI && !ep_int)) {US_DEBUGP ("Endpoint sanity check failed! Rejecting dev.\n" ); -return NULL ; +return -EIO ; }/* At this point, we've decided to try to use the device */
@@ -811,7 +812,7 @@ GFP_KERNEL)) == NULL) { printk(KERN_WARNING USB_STORAGE "Out of memory\n");usb_put_dev (dev); -return NULL ; +return -ENOMEM ; }memset (ss,0 ,sizeof (struct us_data )); new_device =1 ;
@@ -1088,8 +1089,9 @@printk (KERN_DEBUG "USB Mass Storage device found at %d\n" , dev->devnum); -/* return a pointer for the disconnect function */ -return ss; +/* save a pointer to our structure */ + intf->dev.driver_data = ss; +return 0 ;/* we come here if there are any problems */ /* ss->dev_semaphore must be locked */
@@ -1099,13 +1101,13 @@up (&ss->dev_semaphore);if (new_device)kfree (ss); -return NULL ; +return -EIO ; }/* Handle a disconnect event from the USB core */ -static void storage_disconnect (struct usb_device *dev,void *ptr) +static void storage_disconnect (struct usb_interface *intf) { -struct us_data *ss = ptr; +struct us_data *ss = intf->dev.driver_data;US_DEBUGP ("storage_disconnect() called\n" );
fs/partitions/check.c +2 -2
@@ -175,14 +175,14 @@ kdev.value=(int )(long )driverfs_dev->driver_data;return off ?0 :sprintf (page,"%x\n" ,kdev.value); } -static DEVICE_ATTR(kdev,"kdev",S_IRUGO,partition_device_kdev_read,NULL); +static DEVICE_ATTR(kdev,S_IRUGO,partition_device_kdev_read,NULL);static ssize_t partition_device_type_read (struct device *driverfs_dev,char *page,size_t count,loff_t off) {return off ?0 :sprintf (page,"BLK\n" ); } -static DEVICE_ATTR(type,"type",S_IRUGO,partition_device_type_read,NULL); +static DEVICE_ATTR(type,S_IRUGO,partition_device_type_read,NULL);void driverfs_create_partitions (struct gendisk *hd,int minor) {
include/linux/device.h +8 -12
@@ -93,9 +93,9 @@ssize_t (*store)(struct bus_type *,const char * buf,size_t count,loff_t off); }; -#define BUS_ATTR (_name,_str,_mode,_show,_store) \ +#define BUS_ATTR (_name,_mode,_show,_store) \ struct bus_attribute bus_attr_##_name = { \ - .attr = {.name = _str, .mode = _mode }, \ + .attr = {.name = __stringify(_name), .mode = _mode }, \ .show = _show, \ .store = _store, \ };
@@ -150,9 +150,9 @@ssize_t (*store)(struct device_driver *,const char * buf,size_t count,loff_t off); }; -#define DRIVER_ATTR (_name,_str,_mode,_show,_store) \ +#define DRIVER_ATTR (_name,_mode,_show,_store) \ struct driver_attribute driver_attr_##_name = { \ - .attr = {.name = _str, .mode = _mode }, \ + .attr = {.name = __stringify(_name), .mode = _mode }, \ .show = _show, \ .store = _store, \ };
@@ -222,13 +222,14 @@ssize_t (*store)(struct device * dev,const char * buf,size_t count,loff_t off); }; -#define DEVICE_ATTR (_name,_str,_mode,_show,_store) \ +#define DEVICE_ATTR (_name,_mode,_show,_store) \ struct device_attribute dev_attr_##_name = { \ - .attr = {.name = _str, .mode = _mode }, \ + .attr = {.name = __stringify(_name), .mode = _mode }, \ .show = _show, \ .store = _store, \ }; +extern int device_create_file (struct device *device,struct device_attribute * entry);extern void device_remove_file (struct device * dev,struct device_attribute * attr);
@@ -260,12 +261,7 @@* get_device - atomically increment the reference count for the device. * */ -static inline void get_device (struct device * dev) -{ -BUG_ON (!atomic_read (&dev->refcount)); -atomic_inc (&dev->refcount); -} - +extern struct device *get_device (struct device * dev);extern void put_device (struct device * dev);/* drivers/base/sys.c */
include/linux/usb.h +9 -5
@@ -227,7 +227,7 @@int act_altsetting;/* active alternate setting */ int num_altsetting;/* number of alternate settings */ int max_altsetting;/* total memory allocated */ - +struct usb_driver *driver;/* driver */ struct device dev;/* interface specific device info */ void *private_data;
@@ -291,6 +291,8 @@__usb_get_extra_descriptor ((ifpoint)->extra,(ifpoint)->extralen,\ type,(void**)ptr) +extern int usb_if_to_ifnum (struct usb_interface *iface); +/* -------------------------------------------------------------------------- */ /* Host Controller Driver (HCD) support */
@@ -399,9 +401,6 @@extern void usb_free_dev (struct usb_device *);#define usb_put_dev usb_free_dev -/* for when layers above USB add new non-USB drivers */ -extern void usb_scan_devices (void ); -/* mostly for devices emulating SCSI over USB */ extern int usb_reset_device (struct usb_device *dev);
@@ -645,6 +644,11 @@struct module *owner;const char *name; +int (*new_probe) (struct usb_interface *intf,const struct usb_device_id *id); +void (*new_disco) (struct usb_interface *intf); + +struct device_driver driver; + void *(*probe)( struct usb_device *dev, /* the device */ unsigned intf, /* what interface */
@@ -655,7 +659,6 @@void *handle/* as returned by probe() */ ); -struct list_head driver_list;struct semaphore serialize;/* ioctl -- userspace apps can talk to drivers through usbfs */
@@ -669,6 +672,7 @@/* void (*suspend)(struct usb_device *dev); */ /* void (*resume)(struct usb_device *dev); */ }; +#define to_usb_driver (d) container_of(d, struct usb_driver, driver)extern struct bus_type usb_bus_type;
As I got some complaints that the patch was difficult to apply, here it is again, against 2.5.31-bk6.
Changes from the version yesterday include:
- conversion of usbmouse.c driver by Pat Mochel
- tried to fix up module locking issues in the new_probe() and new_disco() calls.
I'm pretty sure I've messed up the disconnect and connect ability of usbfs (the ioctl calls). If anyone can test this out, I would appreciate it.
thanks,
greg k-h
drivers/usb/class/audio.c +0 -1
@@ -2756,7 +2756,6 @@ .name = "audio", .probe = usb_audio_probe, .disconnect = usb_audio_disconnect, - .driver_list = LIST_HEAD_INIT(usb_audio_driver.driver_list), .id_table = usb_audio_ids, };
drivers/usb/class/usb-midi.c +0 -1
@@ -2099,7 +2099,6 @@ .probe = usb_midi_probe, .disconnect = usb_midi_disconnect, .id_table = NULL, /* check all devices */ - .driver_list = LIST_HEAD_INIT(usb_midi_driver.driver_list) };/* ------------------------------------------------------------------------- */
drivers/usb/core/devices.c +0 -1
@@ -111,7 +111,6 @@/* * Need access to the driver and USB bus lists. -* extern struct list_head usb_driver_list; * extern struct list_head usb_bus_list; * However, these will come from functions that return ptrs to each of them. */
drivers/usb/core/devio.c +11 -39
74 lines not on this page · raw message
drivers/usb/core/hcd.c +7 -5
@@ -724,13 +724,15 @@ {int retval; - usb_dev->dev.parent = parent_dev; -strcpy (&usb_dev->dev.name[0 ],"usb_name" ); -strcpy (&usb_dev->dev.bus_id[0 ],"usb_bus" ); - retval =usb_new_device (usb_dev); +// usb_dev->dev.parent = parent_dev; +// strcpy (&usb_dev->dev.name[0], "usb_name"); +// strcpy (&usb_dev->dev.bus_id[0], "usb_bus"); + retval =usb_new_device (usb_dev, parent_dev);if (retval) -put_device (&usb_dev->dev); +err ("%s - usb_new_device failed with value %d" , __FUNCTION__, retval); +// put_device (&usb_dev->dev); return retval; +// return usb_new_device (usb_dev, parent_dev); }EXPORT_SYMBOL (usb_register_root_hub);
drivers/usb/core/hcd.h +1 -5
@@ -230,7 +230,7 @@/* -------------------------------------------------------------------------- */ /* Enumeration is only for the hub driver, or HCD virtual root hubs */ -extern int usb_new_device (struct usb_device *dev); +extern int usb_new_device (struct usb_device *dev,struct device *parent);extern void usb_connect (struct usb_device *dev);extern void usb_disconnect (struct usb_device **);
@@ -354,10 +354,6 @@extern int usb_find_interface_driver (struct usb_device *dev,struct usb_interface *interface); -/* for probe/disconnect with correct module usage counting */ -void *usb_bind_driver (struct usb_driver *driver,struct usb_interface *intf); -void usb_unbind_driver (struct usb_device *device,struct usb_interface *intf); -/*-------------------------------------------------------------------------*/ /* hub.h ... DeviceRemovable in 2.4.2-ac11, gone in 2.4.10 */
drivers/usb/core/hub.c +85 -68
280 lines not on this page · raw message
drivers/usb/core/hub.h +2 -1
@@ -170,7 +170,8 @@extern void usb_hub_tt_clear_buffer (struct usb_device *dev,int pipe);struct usb_hub { -struct usb_device *dev;/* the "real" device */ +// struct usb_device *dev; /* the "real" device */ +struct usb_interface *intf;/* the "real" device */ struct urb *urb;/* for interrupt polling pipe */ /* buffer for urb ... 1 bit each for hub and children, rounded up */
drivers/usb/core/usb.c +205 -287
629 lines not on this page · raw message
drivers/usb/input/hid-core.c +22 -16
@@ -1338,9 +1338,10 @@ { 0, 0 } }; -static struct hid_device *usb_hid_configure (struct usb_device *dev,int ifnum) +static struct hid_device *usb_hid_configure (struct usb_interface *intf) { -struct usb_interface_descriptor *interface = dev->actconfig->interface[ifnum].altsetting +0 ; +struct usb_interface_descriptor *interface = intf->altsetting + intf->act_altsetting; +struct usb_device *dev =interface_to_usbdev (intf);struct hid_descriptor *hdesc;struct hid_device *hid;unsigned quirks =0 , rsize =0 ;
@@ -1450,7 +1451,7 @@snprintf (hid->name,128 ,"%04x:%04x" , dev->descriptor.idVendor, dev->descriptor.idProduct);usb_make_path (dev, buf,64 ); -snprintf (hid->phys,64 ,"%s/input%d" , buf, ifnum); +snprintf (hid->phys,64 ,"%s/input%d" , buf, intf->altsetting[0 ].bInterfaceNumber);if (usb_string (dev, dev->descriptor.iSerialNumber, hid->uniq,64 ) <=0 ) hid->uniq[0 ] =0 ;
@@ -1472,9 +1473,12 @@return NULL ; } -static void hid_disconnect (struct usb_device *dev,void *ptr) +static void hid_disconnect (struct usb_interface *intf) { -struct hid_device *hid = ptr; +struct hid_device *hid = intf->dev.driver_data; + +if (!hid) +return ;usb_unlink_urb (hid->urbin);usb_unlink_urb (hid->urbout);
@@ -1491,20 +1495,20 @@usb_free_urb (hid->urbout);hid_free_device (hid); + intf->dev.driver_data =NULL ; } -static void *hid_probe (struct usb_device *dev,unsigned int ifnum, -const struct usb_device_id *id) +static int hid_probe (struct usb_interface *intf,const struct usb_device_id *id) {struct hid_device *hid;char path[64 ];int i;char *c; -dbg ("HID probe called for ifnum %d" , ifnum); +dbg ("HID probe called for ifnum %d" , intf->ifnum); -if (!(hid =usb_hid_configure (dev, ifnum))) -return NULL ; +if (!(hid =usb_hid_configure (intf))) +return -EIO ;hid_init_reports (hid);hid_dump_device (hid);
@@ -1516,9 +1520,11 @@if (!hiddev_connect (hid)) hid->claimed |=HID_CLAIMED_HIDDEV ; + intf->dev.driver_data = hid; +if (!hid->claimed) { -hid_disconnect (dev, hid); -return NULL ; +hid_disconnect (intf); +return -EIO ; }printk (KERN_INFO );
@@ -1540,12 +1546,12 @@ } } -usb_make_path (dev, path,63 ); +usb_make_path (interface_to_usbdev (intf), path,63 );printk (": USB HID v%x.%02x %s [%s] on %s\n" , hid->version >>8 , hid->version &0xff , c, hid->name, path); -return hid; +return 0 ; }static struct usb_device_id hid_usb_ids [] = {
@@ -1558,8 +1564,8 @@static struct usb_driver hid_driver = { .name ="hid" , - .probe = hid_probe, - .disconnect = hid_disconnect, + .new_probe = hid_probe, + .new_disco = hid_disconnect, .id_table = hid_usb_ids, };
drivers/usb/input/usbmouse.c +29 -23
100 lines not on this page · raw message
drivers/usb/serial/belkin_sa.c +9 -0
@@ -114,6 +114,13 @@MODULE_DEVICE_TABLE (usb, id_table_combined); +static struct usb_driver belkin_driver = { + .name ="belkin" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table_combined, +}; +/* All of the device info needed for the serial converters */ static struct usb_serial_device_type belkin_device = { .owner =THIS_MODULE ,
@@ -526,6 +533,7 @@static int __init belkin_sa_init (void ) {usb_serial_register (&belkin_device); +usb_register (&belkin_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ; }
@@ -533,6 +541,7 @@ static void __exit belkin_sa_exit (void) { +usb_deregister (&belkin_driver);usb_serial_deregister (&belkin_device); }
drivers/usb/serial/cyberjack.c +9 -0
@@ -73,6 +73,13 @@MODULE_DEVICE_TABLE (usb, id_table); +static struct usb_driver cyberjack_driver = { + .name ="cyberjack" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table, +}; +static struct usb_serial_device_type cyberjack_device = { .owner =THIS_MODULE , .name ="Reiner SCT Cyberjack USB card reader" ,
@@ -461,6 +468,7 @@static int __init cyberjack_init (void ) {usb_serial_register (&cyberjack_device); +usb_register (&cyberjack_driver);info (DRIVER_VERSION " " DRIVER_AUTHOR );info (DRIVER_DESC );
@@ -470,6 +478,7 @@ static void __exit cyberjack_exit (void) { +usb_deregister (&cyberjack_driver);usb_serial_deregister (&cyberjack_device); }
drivers/usb/serial/digi_acceleport.c +11 -1
@@ -477,7 +477,7 @@/* Statics */ -static __devinitdata struct usb_device_id id_table_combined [] = { +static struct usb_device_id id_table_combined [] = { {USB_DEVICE (DIGI_VENDOR_ID ,DIGI_2_ID ) }, {USB_DEVICE (DIGI_VENDOR_ID ,DIGI_4_ID ) }, { }/* Terminating entry */
@@ -495,6 +495,14 @@MODULE_DEVICE_TABLE (usb, id_table_combined); +static struct usb_driver digi_driver = { + .name ="digi_acceleport" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table_combined, +}; + +/* device info needed for the Digi serial converter */ static struct usb_serial_device_type digi_acceleport_2_device = {
@@ -2026,6 +2034,7 @@ {usb_serial_register (&digi_acceleport_2_device);usb_serial_register (&digi_acceleport_4_device); +usb_register (&digi_driver);info (DRIVER_VERSION ":" DRIVER_DESC );return 0 ; }
@@ -2033,6 +2042,7 @@ static void __exit digi_exit (void) { +usb_deregister (&digi_driver);usb_serial_deregister (&digi_acceleport_2_device);usb_serial_deregister (&digi_acceleport_4_device); }
drivers/usb/serial/empeg.c +11 -4
@@ -110,6 +110,13 @@MODULE_DEVICE_TABLE (usb, id_table); +static struct usb_driver empeg_driver = { + .name ="empeg" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table, +}; +static struct usb_serial_device_type empeg_device = { .owner =THIS_MODULE , .name ="Empeg" ,
@@ -550,8 +557,6 @@struct urb *urb;int i; -usb_serial_register (&empeg_device); -/* create our write urb pool and transfer buffers */ spin_lock_init (&write_urb_pool_lock);for (i =0 ; i <NUM_URBS ; ++i) {
@@ -570,10 +575,12 @@ } } +usb_serial_register (&empeg_device); +usb_register (&empeg_driver); +info (DRIVER_VERSION ":" DRIVER_DESC );return 0 ; - }
@@ -582,6 +589,7 @@int i;unsigned long flags; +usb_register (&empeg_driver);usb_serial_deregister (&empeg_device);spin_lock_irqsave (&write_urb_pool_lock, flags);
@@ -599,7 +607,6 @@ }spin_unlock_irqrestore (&write_urb_pool_lock, flags); - }
drivers/usb/serial/ftdi_sio.c +10 -1
@@ -140,7 +140,7 @@ }; -static __devinitdata struct usb_device_id id_table_combined [] = { +static struct usb_device_id id_table_combined [] = { {USB_DEVICE (FTDI_VID ,FTDI_SIO_PID ) }, {USB_DEVICE (FTDI_VID ,FTDI_8U232AM_PID ) }, {USB_DEVICE (FTDI_NF_RIC_VID ,FTDI_NF_RIC_PID ) },
@@ -149,6 +149,13 @@MODULE_DEVICE_TABLE (usb, id_table_combined); +static struct usb_driver ftdi_driver = { + .name ="ftdi_sio" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table_combined, +}; +struct ftdi_private {enum ftdi_type ftdi_type;
@@ -944,6 +951,7 @@dbg (__FUNCTION__);usb_serial_register (&ftdi_sio_device);usb_serial_register (&ftdi_8U232AM_device); +usb_register (&ftdi_driver);info (DRIVER_VERSION ":" DRIVER_DESC );return 0 ; }
@@ -952,6 +960,7 @@ static void __exit ftdi_sio_exit (void) {dbg (__FUNCTION__); +usb_deregister (&ftdi_driver);usb_serial_deregister (&ftdi_sio_device);usb_serial_deregister (&ftdi_8U232AM_device); }
drivers/usb/serial/io_edgeport.c +8 -0
@@ -457,6 +457,12 @@#include "io_tables.h" /* all of the devices that this driver supports */ +static struct usb_driver io_driver = { + .name ="io_edgeport" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table_combined, +};/* function prototypes for all of our local functions */ static int process_rcvd_data (struct edgeport_serial *edge_serial,unsigned char *buffer,__u16 bufferLength);
@@ -3049,6 +3055,7 @@usb_serial_register (&edgeport_2port_device);usb_serial_register (&edgeport_4port_device);usb_serial_register (&edgeport_8port_device); +usb_register (&io_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ; }
@@ -3061,6 +3068,7 @@****************************************************************************/ void __exit edgeport_exit (void) { +usb_deregister (&io_driver);usb_serial_deregister (&edgeport_1port_device);usb_serial_deregister (&edgeport_2port_device);usb_serial_deregister (&edgeport_4port_device);
drivers/usb/serial/io_tables.h +1 -1
@@ -61,7 +61,7 @@ };/* Devices that this driver supports */ -static __devinitdata struct usb_device_id id_table_combined [] = { +static struct usb_device_id id_table_combined [] = { {USB_DEVICE (USB_VENDOR_ID_ION ,ION_DEVICE_ID_EDGEPORT_4 ) }, {USB_DEVICE (USB_VENDOR_ID_ION ,ION_DEVICE_ID_RAPIDPORT_4 ) }, {USB_DEVICE (USB_VENDOR_ID_ION ,ION_DEVICE_ID_EDGEPORT_4T ) },
drivers/usb/serial/io_ti.c +10 -1
@@ -142,7 +142,7 @@ };/* Devices that this driver supports */ -static __devinitdata struct usb_device_id id_table_combined [] = { +static struct usb_device_id id_table_combined [] = { {USB_DEVICE (USB_VENDOR_ID_ION ,ION_DEVICE_ID_TI_EDGEPORT_1 ) }, {USB_DEVICE (USB_VENDOR_ID_ION ,ION_DEVICE_ID_TI_EDGEPORT_2 ) }, {USB_DEVICE (USB_VENDOR_ID_ION ,ION_DEVICE_ID_TI_EDGEPORT_2I ) },
@@ -161,6 +161,13 @@MODULE_DEVICE_TABLE (usb, id_table_combined); +static struct usb_driver io_driver = { + .name ="io_ti" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table_combined, +}; +static struct EDGE_FIRMWARE_VERSION_INFO OperationalCodeImageVersion;
@@ -2658,12 +2665,14 @@ {usb_serial_register (&edgeport_1port_device);usb_serial_register (&edgeport_2port_device); +usb_register (&io_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ; } static void __exit edgeport_exit (void) { +usb_deregister (&io_driver);usb_serial_deregister (&edgeport_1port_device);usb_serial_deregister (&edgeport_2port_device); }
drivers/usb/serial/ipaq.c +10 -0
@@ -94,6 +94,14 @@MODULE_DEVICE_TABLE (usb, ipaq_id_table); +static struct usb_driver ipaq_driver = { + .name ="ipaq" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = ipaq_id_table, +}; + +/* All of the device info needed for the Compaq iPAQ */ struct usb_serial_device_type ipaq_device = { .owner =THIS_MODULE ,
@@ -516,6 +524,7 @@static int __init ipaq_init (void ) {usb_serial_register (&ipaq_device); +usb_register (&ipaq_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ;
@@ -524,6 +533,7 @@ static void __exit ipaq_exit(void) { +usb_deregister (&ipaq_driver);usb_serial_deregister (&ipaq_device); }
drivers/usb/serial/ir-usb.c +9 -0
@@ -129,6 +129,13 @@MODULE_DEVICE_TABLE (usb, id_table); +static struct usb_driver ir_driver = { + .name ="ir-usb" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table, +}; +struct usb_serial_device_type ir_device = { .owner =THIS_MODULE ,
@@ -606,6 +613,7 @@static int __init ir_init (void ) {usb_serial_register (&ir_device); +usb_register (&ir_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ; }
@@ -613,6 +621,7 @@ static void __exit ir_exit (void) { +usb_deregister (&ir_driver);usb_serial_deregister (&ir_device); }
drivers/usb/serial/keyspan.c +2 -0
@@ -183,6 +183,7 @@usb_serial_register (&keyspan_1port_device);usb_serial_register (&keyspan_2port_device);usb_serial_register (&keyspan_4port_device); +usb_register (&keyspan_driver);info (DRIVER_VERSION ":" DRIVER_DESC );
@@ -191,6 +192,7 @@ static void __exit keyspan_exit (void) { +usb_deregister (&keyspan_driver);usb_serial_deregister (&keyspan_pre_device);usb_serial_deregister (&keyspan_1port_device);usb_serial_deregister (&keyspan_2port_device);
drivers/usb/serial/keyspan.h +8 -1
@@ -408,7 +408,7 @@ NULL, }; -static __devinitdata struct usb_device_id keyspan_ids_combined[] = { +static struct usb_device_id keyspan_ids_combined[] = { {USB_DEVICE (KEYSPAN_VENDOR_ID , keyspan_usa18x_pre_product_id) }, {USB_DEVICE (KEYSPAN_VENDOR_ID , keyspan_usa19_pre_product_id) }, {USB_DEVICE (KEYSPAN_VENDOR_ID , keyspan_usa19w_pre_product_id) },
@@ -434,6 +434,13 @@MODULE_DEVICE_TABLE (usb, keyspan_ids_combined); +static struct usb_driver keyspan_driver = { + .name ="keyspan" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = keyspan_ids_combined, +}; +/* usb_device_id table for the pre-firmware download keyspan devices */ static struct usb_device_id keyspan_pre_ids[] = { {USB_DEVICE (KEYSPAN_VENDOR_ID , keyspan_usa18x_pre_product_id) },
drivers/usb/serial/keyspan_pda.c +10 -1
@@ -140,7 +140,7 @@#define ENTREGRA_VENDOR_ID 0x1645#define ENTREGRA_FAKE_ID 0x8093 -static __devinitdata struct usb_device_id id_table_combined [] = { +static struct usb_device_id id_table_combined [] = {#ifdef KEYSPAN { USB_DEVICE(KEYSPAN_VENDOR_ID, KEYSPAN_PDA_FAKE_ID) }, #endif
@@ -154,6 +154,13 @@MODULE_DEVICE_TABLE (usb, id_table_combined); +static struct usb_driver keyspan_pda_driver = { + .name ="keyspan_pda" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table_combined, +}; +static struct usb_device_id id_table_std [] = { {USB_DEVICE (KEYSPAN_VENDOR_ID ,KEYSPAN_PDA_ID ) }, { }/* Terminating entry */
@@ -862,6 +869,7 @@#ifdef XIRCOM usb_serial_register (&xircom_pgs_fake_device);#endif +usb_register (&keyspan_pda_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ; }
@@ -869,6 +877,7 @@ static void __exit keyspan_pda_exit (void) { +usb_deregister (&keyspan_pda_driver);usb_serial_deregister (&keyspan_pda_device);#ifdef KEYSPAN usb_serial_deregister (&keyspan_pda_fake_device);
drivers/usb/serial/kl5kusb105.c +8 -0
@@ -117,6 +117,12 @@MODULE_DEVICE_TABLE (usb, id_table); +static struct usb_driver kl5kusb105d_driver = { + .name ="kl5kusb105d" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table, +};static struct usb_serial_device_type kl5kusb105d_device = { .owner =THIS_MODULE ,
@@ -1013,6 +1019,7 @@static int __init klsi_105_init (void ) {usb_serial_register (&kl5kusb105d_device); +usb_register (&kl5kusb105d_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ;
@@ -1021,6 +1028,7 @@ static void __exit klsi_105_exit (void) { +usb_deregister (&kl5kusb105d_driver);usb_serial_deregister (&kl5kusb105d_device); }
drivers/usb/serial/mct_u232.c +8 -0
@@ -139,6 +139,12 @@MODULE_DEVICE_TABLE (usb, id_table_combined); +static struct usb_driver mct_u232_driver = { + .name ="mct_u232" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table_combined, +};static struct usb_serial_device_type mct_u232_device = { .owner =THIS_MODULE ,
@@ -783,6 +789,7 @@static int __init mct_u232_init (void ) {usb_serial_register (&mct_u232_device); +usb_register (&mct_u232_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ; }
@@ -790,6 +797,7 @@ static void __exit mct_u232_exit (void) { +usb_deregister (&mct_u232_driver);usb_serial_deregister (&mct_u232_device); }
drivers/usb/serial/omninet.c +9 -0
@@ -83,6 +83,13 @@MODULE_DEVICE_TABLE (usb, id_table); +static struct usb_driver omninet_driver = { + .name ="omninet" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table, +}; +static struct usb_serial_device_type zyxel_omninet_device = { .owner =THIS_MODULE ,
@@ -370,6 +377,7 @@static int __init omninet_init (void ) {usb_serial_register (&zyxel_omninet_device); +usb_register (&omninet_driver);info (DRIVER_VERSION ":" DRIVER_DESC );return 0 ; }
@@ -377,6 +385,7 @@ static void __exit omninet_exit (void) { +usb_deregister (&omninet_driver);usb_serial_deregister (&zyxel_omninet_device); }
drivers/usb/serial/pl2303.c +8 -0
@@ -77,6 +77,12 @@MODULE_DEVICE_TABLE (usb, id_table); +static struct usb_driver pl2303_driver = { + .name ="pl2303" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table, +};#define SET_LINE_REQUEST_TYPE 0x21#define SET_LINE_REQUEST 0x20
@@ -708,6 +714,7 @@static int __init pl2303_init (void ) {usb_serial_register (&pl2303_device); +usb_register (&pl2303_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ; }
@@ -715,6 +722,7 @@ static void __exit pl2303_exit (void) { +usb_deregister (&pl2303_driver);usb_serial_deregister (&pl2303_device); }
drivers/usb/serial/safe_serial.c +9 -0
@@ -161,6 +161,13 @@MODULE_DEVICE_TABLE (usb, id_table); +static struct usb_driver safe_driver = { + .name ="safe_serial" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table, +}; +static __u16 crc10_table[256 ] = {0x000 ,0x233 ,0x255 ,0x066 ,0x299 ,0x0aa ,0x0cc ,0x2ff ,0x301 ,0x132 ,0x154 ,0x367 ,0x198 ,0x3ab ,0x3cd ,0x1fe ,0x031 ,0x202 ,0x264 ,0x057 ,0x2a8 ,0x09b ,0x0fd ,0x2ce ,0x330 ,0x103 ,0x165 ,0x356 ,0x1a9 ,0x39a ,0x3fc ,0x1cf ,
@@ -434,12 +441,14 @@ }usb_serial_register (&safe_device); +usb_register (&safe_driver);return 0 ; } static void __exit safe_exit (void) { +usb_deregister (&safe_driver);usb_serial_deregister (&safe_device); }
drivers/usb/serial/usb-serial.h +3 -0
@@ -233,6 +233,9 @@extern int usb_serial_register (struct usb_serial_device_type *new_device);extern void usb_serial_deregister (struct usb_serial_device_type *device); +extern int usb_serial_probe (struct usb_interface *iface,const struct usb_device_id *id); +extern void usb_serial_disconnect (struct usb_interface *iface); +/* determine if we should include the EzUSB loader functions */ #undef USES_EZUSB_FUNCTIONS#if defined(CONFIG_USB_SERIAL_KEYSPAN_PDA ) || defined(CONFIG_USB_SERIAL_KEYSPAN_PDA_MODULE )
drivers/usb/serial/usbserial.c +36 -40
199 lines not on this page · raw message
drivers/usb/serial/visor.c +9 -2
@@ -197,7 +197,7 @@ { }/* Terminating entry */ }; -static __devinitdata struct usb_device_id id_table_combined [] = { +static struct usb_device_id id_table_combined [] = { {USB_DEVICE (HANDSPRING_VENDOR_ID ,HANDSPRING_VISOR_ID ) }, {USB_DEVICE (PALM_VENDOR_ID ,PALM_M500_ID ) }, {USB_DEVICE (PALM_VENDOR_ID ,PALM_M505_ID ) },
@@ -214,7 +214,12 @@MODULE_DEVICE_TABLE (usb, id_table_combined); - +static struct usb_driver visor_driver = { + .name ="visor" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table_combined, +};/* All of the device info needed for the Handspring Visor, and Palm 4.0 devices */ static struct usb_serial_device_type handspring_device = {
@@ -761,6 +766,7 @@ {usb_serial_register (&handspring_device);usb_serial_register (&clie_3_5_device); +usb_register (&visor_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ;
@@ -769,6 +775,7 @@ static void __exit visor_exit (void) { +usb_deregister (&visor_driver);usb_serial_deregister (&handspring_device);usb_serial_deregister (&clie_3_5_device); }
drivers/usb/serial/whiteheat.c +10 -1
@@ -110,7 +110,7 @@ { }/* Terminating entry */ }; -static __devinitdata struct usb_device_id id_table_combined [] = { +static struct usb_device_id id_table_combined [] = { {USB_DEVICE (CONNECT_TECH_VENDOR_ID ,CONNECT_TECH_WHITE_HEAT_ID ) }, {USB_DEVICE (CONNECT_TECH_VENDOR_ID ,CONNECT_TECH_FAKE_WHITE_HEAT_ID ) }, { }/* Terminating entry */
@@ -118,6 +118,13 @@MODULE_DEVICE_TABLE (usb, id_table_combined); +static struct usb_driver whiteheat_driver = { + .name ="whiteheat" , + .new_probe = usb_serial_probe, + .new_disco = usb_serial_disconnect, + .id_table = id_table_combined, +}; +/* function prototypes for the Connect Tech WhiteHEAT serial converter */ static int whiteheat_open (struct usb_serial_port *port,struct file *filp);static void whiteheat_close (struct usb_serial_port *port,struct file *filp);
@@ -676,6 +683,7 @@ {usb_serial_register (&whiteheat_fake_device);usb_serial_register (&whiteheat_device); +usb_register (&whiteheat_driver);info (DRIVER_DESC " " DRIVER_VERSION );return 0 ; }
@@ -683,6 +691,7 @@ static void __exit whiteheat_exit (void) { +usb_deregister (&whiteheat_driver);usb_serial_deregister (&whiteheat_fake_device);usb_serial_deregister (&whiteheat_device); }
drivers/usb/storage/scsiglue.c +2 -6
@@ -252,7 +252,6 @@for (i =0 ; i < pusb_dev_save->actconfig->bNumInterfaces; i++) {struct usb_interface *intf = &pusb_dev_save->actconfig->interface[i]; -const struct usb_device_id *id;/* if this is an unclaimed interface, skip it */ if (!intf->driver) {
@@ -263,11 +262,8 @@/* simulate a disconnect and reconnect for all interfaces */ US_DEBUGPX ("simulating disconnect/reconnect.\n" ); -down (&intf->driver->serialize); - intf->driver->disconnect (pusb_dev_save, intf->private_data); - id =usb_match_id (intf, intf->driver->id_table); - intf->driver->probe (pusb_dev_save, i, id); -up (&intf->driver->serialize); +usb_device_remove (&intf->dev); +usb_device_probe (&intf->dev); }US_DEBUGP ("bus_reset() complete\n" );scsi_lock (srb->host);
drivers/usb/storage/usb.c +21 -17
@@ -103,10 +103,10 @@struct us_data *us_list;struct semaphore us_list_semaphore; -static void *storage_probe (struct usb_device *dev,unsigned int ifnum, -const struct usb_device_id *id); +static int storage_probe (struct usb_interface *iface, +const struct usb_device_id *id); -static void storage_disconnect (struct usb_device *dev,void *ptr); +static void storage_disconnect (struct usb_interface *iface);/* The entries in this table, except for final ones here * (USB_MASS_STORAGE_CLASS and the empty entry), correspond,
@@ -229,8 +229,8 @@struct usb_driver usb_storage_driver = { .name ="usb-storage" , - .probe = storage_probe, - .disconnect = storage_disconnect, + .new_probe = storage_probe, + .new_disco = storage_disconnect, .id_table = storage_usb_ids, };
@@ -583,9 +583,11 @@ }/* Probe to see if a new device is actually a SCSI device */ -static void *storage_probe (struct usb_device *dev,unsigned int ifnum, -const struct usb_device_id *id) +static int storage_probe (struct usb_interface *intf, +const struct usb_device_id *id) { +struct usb_device *dev =interface_to_usbdev (intf); +int ifnum =usb_if_to_ifnum (intf);int i;const int id_index = id - storage_usb_ids;char mf[USB_STOR_STRING_LEN ];/* manufacturer */
@@ -610,7 +612,6 @@/* the altsetting on the interface we're probing that matched our * usb_match_id table */ -struct usb_interface *intf = dev->actconfig->interface;struct usb_interface_descriptor *altsetting = intf[ifnum].altsetting + intf[ifnum].act_altsetting;US_DEBUGP ("act_altsetting is %d\n" , intf[ifnum].act_altsetting);
@@ -640,7 +641,7 @@US_DEBUGP ("Product: %s\n" , unusual_dev->productName); }else /* no, we can't support it */ -return NULL ; +return -EIO ;/* At this point, we know we've got a live one */ US_DEBUGP ("USB Mass Storage device detected\n" );
@@ -689,7 +690,7 @@ } else if (result != 0) {/* it's not a stall, but another error -- time to bail */ US_DEBUGP ("-- Unknown error. Rejecting device\n" ); -return NULL ; +return -EIO ; } }#endif
@@ -697,7 +698,7 @@/* Do some basic sanity checks, and bail if we find a problem */ if (!ep_in || !ep_out || (protocol ==US_PR_CBI && !ep_int)) {US_DEBUGP ("Endpoint sanity check failed! Rejecting dev.\n" ); -return NULL ; +return -EIO ; }/* At this point, we've decided to try to use the device */
@@ -776,7 +777,7 @@ GFP_KERNEL)) == NULL) { printk(KERN_WARNING USB_STORAGE "Out of memory\n");usb_put_dev (dev); -return NULL ; +return -ENOMEM ; }memset (ss,0 ,sizeof (struct us_data )); new_device =1 ;
@@ -1053,8 +1054,9 @@printk (KERN_DEBUG "USB Mass Storage device found at %d\n" , dev->devnum); -/* return a pointer for the disconnect function */ -return ss; +/* save a pointer to our structure */ + intf->dev.driver_data = ss; +return 0 ;/* we come here if there are any problems */ /* ss->dev_semaphore must be locked */
@@ -1064,16 +1066,18 @@up (&ss->dev_semaphore);if (new_device)kfree (ss); -return NULL ; +return -EIO ; }/* Handle a disconnect event from the USB core */ -static void storage_disconnect (struct usb_device *dev,void *ptr) +static void storage_disconnect (struct usb_interface *intf) { -struct us_data *ss = ptr; +struct us_data *ss = intf->dev.driver_data;US_DEBUGP ("storage_disconnect() called\n" ); + intf->dev.driver_data =NULL ; +/* this is the odd case -- we disconnected but weren't using it */ if (!ss) {US_DEBUGP ("-- device was not in use\n" );
include/linux/usb.h +12 -5
@@ -248,7 +248,7 @@int act_altsetting;/* active alternate setting */ int num_altsetting;/* number of alternate settings */ int max_altsetting;/* total memory allocated */ - +struct usb_driver *driver;/* driver */ struct device dev;/* interface specific device info */ void *private_data;
@@ -312,6 +312,8 @@__usb_get_extra_descriptor ((ifpoint)->extra,(ifpoint)->extralen,\ type,(void**)ptr) +extern int usb_if_to_ifnum (struct usb_interface *iface); +/* -------------------------------------------------------------------------- */ /* Host Controller Driver (HCD) support */
@@ -428,9 +430,6 @@extern void usb_free_dev (struct usb_device *);#define usb_put_dev usb_free_dev -/* for when layers above USB add new non-USB drivers */ -extern void usb_scan_devices (void ); -/* mostly for devices emulating SCSI over USB */ extern int usb_reset_device (struct usb_device *dev);
@@ -674,6 +673,11 @@struct module *owner;const char *name; +int (*new_probe) (struct usb_interface *intf,const struct usb_device_id *id); +void (*new_disco) (struct usb_interface *intf); + +struct device_driver driver; + void *(*probe)( struct usb_device *dev, /* the device */ unsigned intf, /* what interface */
@@ -684,7 +688,6 @@void *handle/* as returned by probe() */ ); -struct list_head driver_list;struct semaphore serialize;/* ioctl -- userspace apps can talk to drivers through usbfs */
@@ -698,6 +701,7 @@/* void (*suspend)(struct usb_device *dev); */ /* void (*resume)(struct usb_device *dev); */ }; +#define to_usb_driver (d) container_of(d, struct usb_driver, driver)extern struct bus_type usb_bus_type;
@@ -711,6 +715,9 @@extern int usb_register_dev (struct file_operations *fops,int minor,int num_minors,int *start_minor);extern void usb_deregister_dev (int num_minors,int start_minor); +extern int usb_device_probe (struct device *dev); +extern int usb_device_remove (struct device *dev); +/* -------------------------------------------------------------------------- */ /*
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [linux-usb-devel] [RFC] USB driver conversion to "struct device_driver" for 2.5.32
So to be sure I've got this right ... those modified driver entry points change things as follows:
Review
Quoted 2 lines
(quoted diff) +2
-0+ int (*probe) (struct usb_interface *intf, + const struct usb_device_id *id);
(a) the device (for urbs etc) is now implicit:
struct usb_device *dev = interface_to_usbdev (int):
(b) the interface index should no longer matter
(c) returns 0 (not void *) or -Errno (not null)
(d) that void * handle is explicitly intf->dev.driver_data
Review
Quoted 1 line
(quoted diff) +1
-0+ void (*disconnect) (struct usb_interface *intf);
(a) and (d) above: same change
Makes me wonder about intf->private_data, which was the original version of intf->dev.driver_data. Shouldn't that be removed too? It's only used in the interface claiming calls (shouldn't they fit in with the driver model?) and usbfs just now. Is that the usbfs work you mentioned?
- Dave
Re: [linux-usb-devel] [RFC] USB driver conversion to "struct device_driver" for 2.5.32
For the lkml readers, my original post (with patch) didn't seem to go through to that list, it can be found at:
http://marc.theaimsgroup.com/?l=linux-usb-devel&m=103065990107372
Quoted 8 lines · David Brownell
So to be sure I've got this right ... those modified driver entry points change things as follows:
Review
Quoted 2 lines
(quoted diff) +2
-0+ int (*probe) (struct usb_interface *intf, + const struct usb_device_id *id);(a) the device (for urbs etc) is now implicit:
structusb_device*dev =interface_to_usbdev(int):
Yes.
Quoted 1 line
(b) the interface index should no longer matter
Yes. But for those drivers that do care, they can get it with the new usb_if_to_ifnum() function. This will provide the _correct_ interface number, the old interface only provided the index, which people seemed to use as the ifnum.
Quoted 1 line
(c) returns 0 (not void *) or -Errno (not null)
Yes.
Quoted 1 line
(d) that void * handle is explicitly
intf->dev.driver_data
Yes. dev.driver_data should be wrapped by a function, like pci_set_drvdata() and pci_get_drvdata() are for.
Quoted 3 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ void (*disconnect) (struct usb_interface *intf);(a) and (d) above: same change
exactly.
Quoted 3 lines
Makes me wonder about
intf->private_data, which was the original version ofintf->dev.driver_data. Shouldn't that be removed too?
Yes it should.
Quoted 3 lines
It's only used in the interface claiming calls (shouldn't they fit in with the driver model?) and usbfs just now. Is that the usbfs work you mentioned?
Yes, that's the part that I am pretty sure is not working properly right now, and is next on my list of things to clean up.
thanks,
greg k-h