Commit 20c741ec authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

USB: convert the drivers/usb/misc files to the new USB driver model.

parent ab1ebbdf
...@@ -1910,9 +1910,10 @@ static struct file_operations auerswald_fops = ...@@ -1910,9 +1910,10 @@ static struct file_operations auerswald_fops =
class based it might be necessary to parse some more USB descriptors because class based it might be necessary to parse some more USB descriptors because
the device properties can differ in a wide range. the device properties can differ in a wide range.
*/ */
static void *auerswald_probe (struct usb_device *usbdev, unsigned int ifnum, static int auerswald_probe (struct usb_interface *intf,
const struct usb_device_id *id) const struct usb_device_id *id)
{ {
struct usb_device *usbdev = interface_to_usbdev(intf);
pauerswald_t cp = NULL; pauerswald_t cp = NULL;
DECLARE_WAIT_QUEUE_HEAD (wqh); DECLARE_WAIT_QUEUE_HEAD (wqh);
unsigned int dtindex; unsigned int dtindex;
...@@ -1920,14 +1921,16 @@ static void *auerswald_probe (struct usb_device *usbdev, unsigned int ifnum, ...@@ -1920,14 +1921,16 @@ static void *auerswald_probe (struct usb_device *usbdev, unsigned int ifnum,
char *pbuf; char *pbuf;
int ret; int ret;
dbg ("probe: vendor id 0x%x, device id 0x%x ifnum:%d", dbg ("probe: vendor id 0x%x, device id 0x%x",
usbdev->descriptor.idVendor, usbdev->descriptor.idProduct, ifnum); usbdev->descriptor.idVendor, usbdev->descriptor.idProduct);
/* See if the device offered us matches that we can accept */ /* See if the device offered us matches that we can accept */
if (usbdev->descriptor.idVendor != ID_AUERSWALD) return NULL; if (usbdev->descriptor.idVendor != ID_AUERSWALD)
return -ENODEV;
/* we use only the first -and only- interface */ /* we use only the first -and only- interface */
if (ifnum != 0) return NULL; if (intf->altsetting->bInterfaceNumber != 0)
return -ENODEV;
/* prevent module unloading while sleeping */ /* prevent module unloading while sleeping */
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
...@@ -2044,12 +2047,13 @@ static void *auerswald_probe (struct usb_device *usbdev, unsigned int ifnum, ...@@ -2044,12 +2047,13 @@ static void *auerswald_probe (struct usb_device *usbdev, unsigned int ifnum,
} }
/* all OK */ /* all OK */
return cp; dev_set_drvdata (&intf->dev, cp);
return 0;
/* Error exit: clean up the memory */ /* Error exit: clean up the memory */
pfail: auerswald_delete (cp); pfail: auerswald_delete (cp);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return NULL; return -EIO;
} }
...@@ -2065,11 +2069,15 @@ pfail: auerswald_delete (cp); ...@@ -2065,11 +2069,15 @@ pfail: auerswald_delete (cp);
this device. So especially the usb_device structure must not be used this device. So especially the usb_device structure must not be used
any longer by the usb driver. any longer by the usb driver.
*/ */
static void auerswald_disconnect (struct usb_device *usbdev, void *driver_context) static void auerswald_disconnect (struct usb_interface *intf)
{ {
pauerswald_t cp = (pauerswald_t) driver_context; pauerswald_t cp = dev_get_drvdata (&intf->dev);
unsigned int u; unsigned int u;
dev_set_drvdata (&intf->dev, NULL);
if (!cp)
return;
down (&cp->mutex); down (&cp->mutex);
info ("device /dev/usb/%s now disconnecting", cp->name); info ("device /dev/usb/%s now disconnecting", cp->name);
......
...@@ -105,9 +105,9 @@ MODULE_PARM_DESC(raw_voltage, "Parameter for the call to SET_DISPLAY_VOLTAGE"); ...@@ -105,9 +105,9 @@ MODULE_PARM_DESC(raw_voltage, "Parameter for the call to SET_DISPLAY_VOLTAGE");
#endif #endif
/* Prototypes */ /* Prototypes */
static void *brlvger_probe (struct usb_device *dev, unsigned ifnum, static int brlvger_probe (struct usb_interface *intf,
const struct usb_device_id *id); const struct usb_device_id *id);
static void brlvger_disconnect(struct usb_device *dev, void *ptr); static void brlvger_disconnect(struct usb_interface *intf);
static int brlvger_open(struct inode *inode, struct file *file); static int brlvger_open(struct inode *inode, struct file *file);
static int brlvger_release(struct inode *inode, struct file *file); static int brlvger_release(struct inode *inode, struct file *file);
static ssize_t brlvger_write(struct file *file, const char *buffer, static ssize_t brlvger_write(struct file *file, const char *buffer,
...@@ -281,10 +281,11 @@ module_exit (brlvger_cleanup); ...@@ -281,10 +281,11 @@ module_exit (brlvger_cleanup);
/* Probe and disconnect functions */ /* Probe and disconnect functions */
static void * static int
brlvger_probe (struct usb_device *dev, unsigned ifnum, brlvger_probe (struct usb_interface *intf,
const struct usb_device_id *id) const struct usb_device_id *id)
{ {
struct usb_device *dev = interface_to_usbdev(intf);
struct brlvger_priv *priv = NULL; struct brlvger_priv *priv = NULL;
int i; int i;
int retval; int retval;
...@@ -301,14 +302,14 @@ brlvger_probe (struct usb_device *dev, unsigned ifnum, ...@@ -301,14 +302,14 @@ brlvger_probe (struct usb_device *dev, unsigned ifnum,
|| dev->config->bNumInterfaces != 1 || dev->config->bNumInterfaces != 1
|| actifsettings->bNumEndpoints != 1 ) { || actifsettings->bNumEndpoints != 1 ) {
err ("Bogus braille display config info"); err ("Bogus braille display config info");
return NULL; return -ENODEV;
} }
endpoint = actifsettings->endpoint; endpoint = actifsettings->endpoint;
if (!(endpoint->bEndpointAddress & 0x80) || if (!(endpoint->bEndpointAddress & 0x80) ||
((endpoint->bmAttributes & 3) != 0x03)) { ((endpoint->bmAttributes & 3) != 0x03)) {
err ("Bogus braille display config info, wrong endpoints"); err ("Bogus braille display config info, wrong endpoints");
return NULL; return -ENODEV;
} }
down(&reserve_sem); down(&reserve_sem);
...@@ -404,15 +405,20 @@ brlvger_probe (struct usb_device *dev, unsigned ifnum, ...@@ -404,15 +405,20 @@ brlvger_probe (struct usb_device *dev, unsigned ifnum,
out: out:
up(&reserve_sem); up(&reserve_sem);
return priv; if (priv) {
dev_set_drvdata (&intf->dev, priv);
return 0;
}
return -EIO;
} }
static void static void
brlvger_disconnect(struct usb_device *dev, void *ptr) brlvger_disconnect(struct usb_interface *intf)
{ {
struct brlvger_priv *priv = (struct brlvger_priv *)ptr; struct brlvger_priv *priv = dev_get_drvdata (&intf->dev);
int r; int r;
dev_set_drvdata (&intf->dev, NULL);
if(priv){ if(priv){
info("Display %d disconnecting", priv->subminor); info("Display %d disconnecting", priv->subminor);
......
...@@ -41,8 +41,8 @@ typedef struct _INTEL_HEX_RECORD ...@@ -41,8 +41,8 @@ typedef struct _INTEL_HEX_RECORD
static int emi26_writememory( struct usb_device *dev, int address, unsigned char *data, int length, __u8 bRequest); static int emi26_writememory( struct usb_device *dev, int address, unsigned char *data, int length, __u8 bRequest);
static int emi26_set_reset(struct usb_device *dev, unsigned char reset_bit); static int emi26_set_reset(struct usb_device *dev, unsigned char reset_bit);
static int emi26_load_firmware (struct usb_device *dev); static int emi26_load_firmware (struct usb_device *dev);
static void *emi26_probe(struct usb_device *dev, unsigned int if_num, const struct usb_device_id *id); static int emi26_probe(struct usb_interface *intf, const struct usb_device_id *id);
static void emi26_disconnect(struct usb_device *dev, void *drv_context); static void emi26_disconnect(struct usb_interface *intf);
static int __init emi26_init (void); static int __init emi26_init (void);
static void __exit emi26_exit (void); static void __exit emi26_exit (void);
...@@ -195,8 +195,10 @@ static __devinitdata struct usb_device_id id_table [] = { ...@@ -195,8 +195,10 @@ static __devinitdata struct usb_device_id id_table [] = {
MODULE_DEVICE_TABLE (usb, id_table); MODULE_DEVICE_TABLE (usb, id_table);
static void * emi26_probe(struct usb_device *dev, unsigned int if_num, const struct usb_device_id *id) static int emi26_probe(struct usb_interface *intf, const struct usb_device_id *id)
{ {
struct usb_device *dev = interface_to_usbdev(intf);
info("%s start", __FUNCTION__); info("%s start", __FUNCTION__);
if((dev->descriptor.idVendor == EMI26_VENDOR_ID) && (dev->descriptor.idProduct == EMI26_PRODUCT_ID)) { if((dev->descriptor.idVendor == EMI26_VENDOR_ID) && (dev->descriptor.idProduct == EMI26_PRODUCT_ID)) {
...@@ -204,10 +206,10 @@ static void * emi26_probe(struct usb_device *dev, unsigned int if_num, const str ...@@ -204,10 +206,10 @@ static void * emi26_probe(struct usb_device *dev, unsigned int if_num, const str
} }
/* do not return the driver context, let real audio driver do that */ /* do not return the driver context, let real audio driver do that */
return 0; return -EIO;
} }
static void emi26_disconnect(struct usb_device *dev, void *drv_context) static void emi26_disconnect(struct usb_interface *intf)
{ {
} }
......
...@@ -450,9 +450,10 @@ file_operations usb_rio_fops = { ...@@ -450,9 +450,10 @@ file_operations usb_rio_fops = {
.release = close_rio, .release = close_rio,
}; };
static void *probe_rio(struct usb_device *dev, unsigned int ifnum, static int probe_rio(struct usb_interface *intf,
const struct usb_device_id *id) const struct usb_device_id *id)
{ {
struct usb_device *dev = interface_to_usbdev(intf);
struct rio_usb_data *rio = &rio_instance; struct rio_usb_data *rio = &rio_instance;
int retval; int retval;
...@@ -461,7 +462,7 @@ static void *probe_rio(struct usb_device *dev, unsigned int ifnum, ...@@ -461,7 +462,7 @@ static void *probe_rio(struct usb_device *dev, unsigned int ifnum,
retval = usb_register_dev(&usb_rio_fops, RIO_MINOR, 1, &rio->minor); retval = usb_register_dev(&usb_rio_fops, RIO_MINOR, 1, &rio->minor);
if (retval) { if (retval) {
err("Not able to get a minor for this device."); err("Not able to get a minor for this device.");
return NULL; return -ENOMEM;
} }
rio->present = 1; rio->present = 1;
...@@ -469,14 +470,14 @@ static void *probe_rio(struct usb_device *dev, unsigned int ifnum, ...@@ -469,14 +470,14 @@ static void *probe_rio(struct usb_device *dev, unsigned int ifnum,
if (!(rio->obuf = (char *) kmalloc(OBUF_SIZE, GFP_KERNEL))) { if (!(rio->obuf = (char *) kmalloc(OBUF_SIZE, GFP_KERNEL))) {
err("probe_rio: Not enough memory for the output buffer"); err("probe_rio: Not enough memory for the output buffer");
return NULL; return -ENOMEM;
} }
dbg("probe_rio: obuf address:%p", rio->obuf); dbg("probe_rio: obuf address:%p", rio->obuf);
if (!(rio->ibuf = (char *) kmalloc(IBUF_SIZE, GFP_KERNEL))) { if (!(rio->ibuf = (char *) kmalloc(IBUF_SIZE, GFP_KERNEL))) {
err("probe_rio: Not enough memory for the input buffer"); err("probe_rio: Not enough memory for the input buffer");
kfree(rio->obuf); kfree(rio->obuf);
return NULL; return -ENOMEM;
} }
dbg("probe_rio: ibuf address:%p", rio->ibuf); dbg("probe_rio: ibuf address:%p", rio->ibuf);
...@@ -490,31 +491,35 @@ static void *probe_rio(struct usb_device *dev, unsigned int ifnum, ...@@ -490,31 +491,35 @@ static void *probe_rio(struct usb_device *dev, unsigned int ifnum,
init_MUTEX(&(rio->lock)); init_MUTEX(&(rio->lock));
return rio; dev_set_drvdata (&intf->dev, rio);
return 0;
} }
static void disconnect_rio(struct usb_device *dev, void *ptr) static void disconnect_rio(struct usb_interface *intf)
{ {
struct rio_usb_data *rio = (struct rio_usb_data *) ptr; struct rio_usb_data *rio = dev_get_drvdata (&intf->dev);
dev_set_drvdata (&intf->dev, NULL);
if (rio) {
devfs_unregister(rio->devfs);
usb_deregister_dev(1, rio->minor);
down(&(rio->lock));
if (rio->isopen) {
rio->isopen = 0;
/* better let it finish - the release will do whats needed */
rio->rio_dev = NULL;
up(&(rio->lock));
return;
}
kfree(rio->ibuf);
kfree(rio->obuf);
devfs_unregister(rio->devfs); info("USB Rio disconnected.");
usb_deregister_dev(1, rio->minor);
down(&(rio->lock)); rio->present = 0;
if (rio->isopen) {
rio->isopen = 0;
/* better let it finish - the release will do whats needed */
rio->rio_dev = NULL;
up(&(rio->lock)); up(&(rio->lock));
return;
} }
kfree(rio->ibuf);
kfree(rio->obuf);
info("USB Rio disconnected.");
rio->present = 0;
up(&(rio->lock));
} }
static struct usb_device_id rio_table [] = { static struct usb_device_id rio_table [] = {
......
...@@ -177,20 +177,20 @@ struct udsl_atm_dev_data { ...@@ -177,20 +177,20 @@ struct udsl_atm_dev_data {
/* /*
* usb driver prototypes and structures * usb driver prototypes and structures
*/ */
static void *udsl_usb_probe (struct usb_device *dev, unsigned int ifnum, static int udsl_usb_probe (struct usb_interface *intf,
const struct usb_device_id *id); const struct usb_device_id *id);
static void udsl_usb_disconnect (struct usb_device *dev, void *ptr); static void udsl_usb_disconnect (struct usb_interface *intf);
int udsl_usb_send_data (struct udsl_instance_data *instance, struct atm_vcc *vcc, int udsl_usb_send_data (struct udsl_instance_data *instance, struct atm_vcc *vcc,
struct sk_buff *skb); struct sk_buff *skb);
static int udsl_usb_ioctl (struct usb_device *hub, unsigned int code, void *user_data); static int udsl_usb_ioctl (struct usb_device *hub, unsigned int code, void *user_data);
static int udsl_usb_cancelsends (struct udsl_instance_data *instance, struct atm_vcc *vcc); static int udsl_usb_cancelsends (struct udsl_instance_data *instance, struct atm_vcc *vcc);
static struct usb_driver udsl_usb_driver = { static struct usb_driver udsl_usb_driver = {
name:udsl_driver_name, .name = udsl_driver_name,
probe:udsl_usb_probe, .probe = udsl_usb_probe,
disconnect:udsl_usb_disconnect, .disconnect = udsl_usb_disconnect,
ioctl:udsl_usb_ioctl, .ioctl = udsl_usb_ioctl,
id_table:udsl_usb_ids, .id_table = udsl_usb_ids,
}; };
/************ /************
...@@ -828,7 +828,7 @@ int udsl_usb_data_init (struct udsl_instance_data *instance) ...@@ -828,7 +828,7 @@ int udsl_usb_data_init (struct udsl_instance_data *instance)
return 0; return 0;
} }
int udsl_usb_data_exit (struct udsl_instance_data *instance) static int udsl_usb_data_exit (struct udsl_instance_data *instance)
{ {
int i; int i;
...@@ -913,8 +913,10 @@ static int udsl_usb_ioctl (struct usb_device *dev, unsigned int code, void *user ...@@ -913,8 +913,10 @@ static int udsl_usb_ioctl (struct usb_device *dev, unsigned int code, void *user
return -EINVAL; return -EINVAL;
} }
void *udsl_usb_probe (struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *id) static int udsl_usb_probe (struct usb_interface *intf, const struct usb_device_id *id)
{ {
struct usb_device *dev = interface_to_usbdev(intf);
int ifnum = intf->altsetting->bInterfaceNumber;
int i; int i;
unsigned char mac[6]; unsigned char mac[6];
unsigned char mac_str[13]; unsigned char mac_str[13];
...@@ -926,7 +928,7 @@ void *udsl_usb_probe (struct usb_device *dev, unsigned int ifnum, const struct u ...@@ -926,7 +928,7 @@ void *udsl_usb_probe (struct usb_device *dev, unsigned int ifnum, const struct u
if ((dev->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) || if ((dev->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) ||
(dev->descriptor.idVendor != SPEEDTOUCH_VENDORID) || (dev->descriptor.idVendor != SPEEDTOUCH_VENDORID) ||
(dev->descriptor.idProduct != SPEEDTOUCH_PRODUCTID) || (ifnum != 1)) (dev->descriptor.idProduct != SPEEDTOUCH_PRODUCTID) || (ifnum != 1))
return NULL; return -ENODEV;
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
...@@ -936,7 +938,7 @@ void *udsl_usb_probe (struct usb_device *dev, unsigned int ifnum, const struct u ...@@ -936,7 +938,7 @@ void *udsl_usb_probe (struct usb_device *dev, unsigned int ifnum, const struct u
if (i >= MAX_UDSL) { if (i >= MAX_UDSL) {
printk (KERN_INFO "No minor table space available for SpeedTouch USB\n"); printk (KERN_INFO "No minor table space available for SpeedTouch USB\n");
return NULL; return -ENOMEM;
}; };
PDEBUG ("Device Accepted, assigning minor %d\n", i); PDEBUG ("Device Accepted, assigning minor %d\n", i);
...@@ -945,7 +947,7 @@ void *udsl_usb_probe (struct usb_device *dev, unsigned int ifnum, const struct u ...@@ -945,7 +947,7 @@ void *udsl_usb_probe (struct usb_device *dev, unsigned int ifnum, const struct u
instance = kmalloc (sizeof (struct udsl_instance_data), GFP_KERNEL); instance = kmalloc (sizeof (struct udsl_instance_data), GFP_KERNEL);
if (!instance) { if (!instance) {
PDEBUG ("No memory for Instance data!\n"); PDEBUG ("No memory for Instance data!\n");
return NULL; return -ENOMEM;
} }
/* initialize structure */ /* initialize structure */
...@@ -969,32 +971,37 @@ void *udsl_usb_probe (struct usb_device *dev, unsigned int ifnum, const struct u ...@@ -969,32 +971,37 @@ void *udsl_usb_probe (struct usb_device *dev, unsigned int ifnum, const struct u
minor_data[instance->minor] = instance; minor_data[instance->minor] = instance;
return instance; dev_set_drvdata (&intf->dev, instance);
return 0;
} }
void udsl_usb_disconnect (struct usb_device *dev, void *ptr) static void udsl_usb_disconnect (struct usb_interface *intf)
{ {
struct udsl_instance_data *instance = (struct udsl_instance_data *) ptr; struct udsl_instance_data *instance = dev_get_drvdata (&intf->dev);
int i = instance->minor; int i;
/* unlinking receive buffers */ dev_set_drvdata (&intf->dev, NULL);
udsl_usb_data_exit (instance); if (instance) {
i = instance->minor;
/* unlinking receive buffers */
udsl_usb_data_exit (instance);
/* removing atm device */ /* removing atm device */
if (instance->atm_dev) if (instance->atm_dev)
udsl_atm_stopdevice (instance); udsl_atm_stopdevice (instance);
PDEBUG ("disconnecting minor %d\n", i); PDEBUG ("disconnecting minor %d\n", i);
while (MOD_IN_USE > 1) { while (MOD_IN_USE > 1) {
current->state = TASK_INTERRUPTIBLE; current->state = TASK_INTERRUPTIBLE;
schedule_timeout (1); schedule_timeout (1);
} }
kfree (instance); kfree (instance);
minor_data[i] = NULL; minor_data[i] = NULL;
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
}
} }
/*************************************************************************** /***************************************************************************
......
...@@ -326,17 +326,18 @@ static struct file_operations tiglusb_fops = { ...@@ -326,17 +326,18 @@ static struct file_operations tiglusb_fops = {
/* --- initialisation code ------------------------------------- */ /* --- initialisation code ------------------------------------- */
static void * static int
tiglusb_probe (struct usb_device *dev, unsigned int ifnum, tiglusb_probe (struct usb_interface *intf,
const struct usb_device_id *id) const struct usb_device_id *id)
{ {
struct usb_device *dev = interface_to_usbdev(intf);
int minor = -1; int minor = -1;
int i; int i;
ptiglusb_t s; ptiglusb_t s;
char name[8]; char name[8];
dbg ("probing vendor id 0x%x, device id 0x%x ifnum:%d", dbg ("probing vendor id 0x%x, device id 0x%x",
dev->descriptor.idVendor, dev->descriptor.idProduct, ifnum); dev->descriptor.idVendor, dev->descriptor.idProduct);
/* /*
* We don't handle multiple configurations. As of version 0x0103 of * We don't handle multiple configurations. As of version 0x0103 of
...@@ -344,15 +345,15 @@ tiglusb_probe (struct usb_device *dev, unsigned int ifnum, ...@@ -344,15 +345,15 @@ tiglusb_probe (struct usb_device *dev, unsigned int ifnum,
*/ */
if (dev->descriptor.bNumConfigurations != 1) if (dev->descriptor.bNumConfigurations != 1)
return NULL; return -ENODEV;
if ((dev->descriptor.idProduct != 0xe001) if ((dev->descriptor.idProduct != 0xe001)
&& (dev->descriptor.idVendor != 0x451)) && (dev->descriptor.idVendor != 0x451))
return NULL; return -ENODEV;
if (usb_set_configuration (dev, dev->config[0].bConfigurationValue) < 0) { if (usb_set_configuration (dev, dev->config[0].bConfigurationValue) < 0) {
err ("tiglusb_probe: set_configuration failed"); err ("tiglusb_probe: set_configuration failed");
return NULL; return -ENODEV;
} }
/* /*
...@@ -367,7 +368,7 @@ tiglusb_probe (struct usb_device *dev, unsigned int ifnum, ...@@ -367,7 +368,7 @@ tiglusb_probe (struct usb_device *dev, unsigned int ifnum,
} }
if (minor == -1) if (minor == -1)
return NULL; return -ENODEV;
s = &tiglusb[minor]; s = &tiglusb[minor];
...@@ -375,7 +376,7 @@ tiglusb_probe (struct usb_device *dev, unsigned int ifnum, ...@@ -375,7 +376,7 @@ tiglusb_probe (struct usb_device *dev, unsigned int ifnum,
s->remove_pending = 0; s->remove_pending = 0;
s->dev = dev; s->dev = dev;
up (&s->mutex); up (&s->mutex);
dbg ("bound to interface: %d", ifnum); dbg ("bound to interface");
sprintf (name, "%d", s->minor); sprintf (name, "%d", s->minor);
dbg ("registering to devfs : major = %d, minor = %d, node = %s", dbg ("registering to devfs : major = %d, minor = %d, node = %s",
...@@ -390,16 +391,20 @@ tiglusb_probe (struct usb_device *dev, unsigned int ifnum, ...@@ -390,16 +391,20 @@ tiglusb_probe (struct usb_device *dev, unsigned int ifnum,
dev->descriptor.bcdDevice >> 8, dev->descriptor.bcdDevice >> 8,
dev->descriptor.bcdDevice & 0xff); dev->descriptor.bcdDevice & 0xff);
return s; dev_set_drvdata (&intf->dev, s);
return 0;
} }
static void static void
tiglusb_disconnect (struct usb_device *dev, void *drv_context) tiglusb_disconnect (struct usb_interface *intf)
{ {
ptiglusb_t s = (ptiglusb_t) drv_context; ptiglusb_t s = dev_get_drvdata (&intf->dev);
if (!s || !s->dev) dev_set_drvdata (&intf->dev, NULL);
if (!s || !s->dev) {
info ("bogus disconnect"); info ("bogus disconnect");
return;
}
s->remove_pending = 1; s->remove_pending = 1;
wake_up (&s->wait); wake_up (&s->wait);
......
...@@ -245,20 +245,21 @@ file_operations usb_lcd_fops = { ...@@ -245,20 +245,21 @@ file_operations usb_lcd_fops = {
.release = close_lcd, .release = close_lcd,
}; };
static void *probe_lcd(struct usb_device *dev, unsigned int ifnum) static int probe_lcd(struct usb_interface *intf, const struct usb_device_id *id)
{ {
struct usb_device *dev = interface_to_usbdev(intf);
struct lcd_usb_data *lcd = &lcd_instance; struct lcd_usb_data *lcd = &lcd_instance;
int i; int i;
int retval; int retval;
if (dev->descriptor.idProduct != 0x0001 ) { if (dev->descriptor.idProduct != 0x0001 ) {
warn(KERN_INFO "USBLCD model not supported."); warn(KERN_INFO "USBLCD model not supported.");
return NULL; return -ENODEV;
} }
if (lcd->present == 1) { if (lcd->present == 1) {
warn(KERN_INFO "Multiple USBLCDs are not supported!"); warn(KERN_INFO "Multiple USBLCDs are not supported!");
return NULL; return -ENODEV;
} }
i = dev->descriptor.bcdDevice; i = dev->descriptor.bcdDevice;
...@@ -270,7 +271,7 @@ static void *probe_lcd(struct usb_device *dev, unsigned int ifnum) ...@@ -270,7 +271,7 @@ static void *probe_lcd(struct usb_device *dev, unsigned int ifnum)
retval = usb_register_dev(&usb_lcd_fops, USBLCD_MINOR, 1, &lcd->minor); retval = usb_register_dev(&usb_lcd_fops, USBLCD_MINOR, 1, &lcd->minor);
if (retval) { if (retval) {
err("Not able to get a minor for this device."); err("Not able to get a minor for this device.");
return NULL; return -ENOMEM;
} }
lcd->present = 1; lcd->present = 1;
...@@ -278,38 +279,42 @@ static void *probe_lcd(struct usb_device *dev, unsigned int ifnum) ...@@ -278,38 +279,42 @@ static void *probe_lcd(struct usb_device *dev, unsigned int ifnum)
if (!(lcd->obuf = (char *) kmalloc(OBUF_SIZE, GFP_KERNEL))) { if (!(lcd->obuf = (char *) kmalloc(OBUF_SIZE, GFP_KERNEL))) {
err("probe_lcd: Not enough memory for the output buffer"); err("probe_lcd: Not enough memory for the output buffer");
return NULL; return -ENOMEM;
} }
dbg("probe_lcd: obuf address:%p", lcd->obuf); dbg("probe_lcd: obuf address:%p", lcd->obuf);
if (!(lcd->ibuf = (char *) kmalloc(IBUF_SIZE, GFP_KERNEL))) { if (!(lcd->ibuf = (char *) kmalloc(IBUF_SIZE, GFP_KERNEL))) {
err("probe_lcd: Not enough memory for the input buffer"); err("probe_lcd: Not enough memory for the input buffer");
kfree(lcd->obuf); kfree(lcd->obuf);
return NULL; return -ENOMEM;
} }
dbg("probe_lcd: ibuf address:%p", lcd->ibuf); dbg("probe_lcd: ibuf address:%p", lcd->ibuf);
return lcd; dev_set_drvdata (&intf->dev, lcd);
return 0;
} }
static void disconnect_lcd(struct usb_device *dev, void *ptr) static void disconnect_lcd(struct usb_interface *intf)
{ {
struct lcd_usb_data *lcd = (struct lcd_usb_data *) ptr; struct lcd_usb_data *lcd = dev_get_drvdata (&intf->dev);
usb_deregister_dev(1, lcd->minor); dev_set_drvdata (&intf->dev, NULL);
if (lcd) {
usb_deregister_dev(1, lcd->minor);
if (lcd->isopen) { if (lcd->isopen) {
lcd->isopen = 0; lcd->isopen = 0;
/* better let it finish - the release will do whats needed */ /* better let it finish - the release will do whats needed */
lcd->lcd_dev = NULL; lcd->lcd_dev = NULL;
return; return;
} }
kfree(lcd->ibuf); kfree(lcd->ibuf);
kfree(lcd->obuf); kfree(lcd->obuf);
info("USBLCD disconnected."); info("USBLCD disconnected.");
lcd->present = 0; lcd->present = 0;
}
} }
static struct usb_device_id id_table [] = { static struct usb_device_id id_table [] = {
......
...@@ -545,9 +545,10 @@ static struct parport_operations parport_uss720_ops = ...@@ -545,9 +545,10 @@ static struct parport_operations parport_uss720_ops =
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
static void * uss720_probe(struct usb_device *usbdev, unsigned int ifnum, static int uss720_probe(struct usb_interface *intf,
const struct usb_device_id *id) const struct usb_device_id *id)
{ {
struct usb_device *usbdev = interface_to_usbdev(intf);
struct usb_interface_descriptor *interface; struct usb_interface_descriptor *interface;
struct usb_endpoint_descriptor *endpoint; struct usb_endpoint_descriptor *endpoint;
struct parport_uss720_private *priv; struct parport_uss720_private *priv;
...@@ -558,13 +559,13 @@ static void * uss720_probe(struct usb_device *usbdev, unsigned int ifnum, ...@@ -558,13 +559,13 @@ static void * uss720_probe(struct usb_device *usbdev, unsigned int ifnum,
usbdev->descriptor.idVendor, usbdev->descriptor.idProduct); usbdev->descriptor.idVendor, usbdev->descriptor.idProduct);
/* our known interfaces have 3 alternate settings */ /* our known interfaces have 3 alternate settings */
if (usbdev->actconfig->interface[ifnum].num_altsetting != 3) if (intf->num_altsetting != 3)
return NULL; return -ENODEV;
i = usb_set_interface(usbdev, ifnum, 2); i = usb_set_interface(usbdev, intf->altsetting->bInterfaceNumber, 2);
printk(KERN_DEBUG "uss720: set inteface result %d\n", i); printk(KERN_DEBUG "uss720: set inteface result %d\n", i);
interface = &usbdev->actconfig->interface[ifnum].altsetting[2]; interface = &intf->altsetting[2];
/* /*
* Allocate parport interface * Allocate parport interface
...@@ -572,7 +573,7 @@ static void * uss720_probe(struct usb_device *usbdev, unsigned int ifnum, ...@@ -572,7 +573,7 @@ static void * uss720_probe(struct usb_device *usbdev, unsigned int ifnum,
printk(KERN_INFO "uss720: (C) 1999 by Thomas Sailer, <sailer@ife.ee.ethz.ch>\n"); printk(KERN_INFO "uss720: (C) 1999 by Thomas Sailer, <sailer@ife.ee.ethz.ch>\n");
if (!(priv = kmalloc(sizeof(struct parport_uss720_private), GFP_KERNEL))) if (!(priv = kmalloc(sizeof(struct parport_uss720_private), GFP_KERNEL)))
return NULL; return -ENOMEM;
if (!(pp = parport_register_port(0, PARPORT_IRQ_NONE, PARPORT_DMA_NONE, &parport_uss720_ops))) { if (!(pp = parport_register_port(0, PARPORT_IRQ_NONE, PARPORT_DMA_NONE, &parport_uss720_ops))) {
printk(KERN_WARNING "usb-uss720: could not register parport\n"); printk(KERN_WARNING "usb-uss720: could not register parport\n");
goto probe_abort; goto probe_abort;
...@@ -607,7 +608,8 @@ static void * uss720_probe(struct usb_device *usbdev, unsigned int ifnum, ...@@ -607,7 +608,8 @@ static void * uss720_probe(struct usb_device *usbdev, unsigned int ifnum,
parport_announce_port(pp); parport_announce_port(pp);
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
return pp; dev_set_drvdata (&intf->dev, pp);
return 0;
#if 0 #if 0
probe_abort_port: probe_abort_port:
...@@ -615,22 +617,26 @@ static void * uss720_probe(struct usb_device *usbdev, unsigned int ifnum, ...@@ -615,22 +617,26 @@ static void * uss720_probe(struct usb_device *usbdev, unsigned int ifnum,
#endif #endif
probe_abort: probe_abort:
kfree(priv); kfree(priv);
return NULL; return -ENODEV;
} }
static void uss720_disconnect(struct usb_device *usbdev, void *ptr) static void uss720_disconnect(struct usb_interface *intf)
{ {
struct parport *pp = (struct parport *)ptr; struct parport *pp = dev_get_drvdata (&intf->dev);
struct parport_uss720_private *priv = pp->private_data; struct parport_uss720_private *priv;
dev_set_drvdata (&intf->dev, NULL);
if (pp) {
priv = pp->private_data;
#if 0 #if 0
usb_release_irq(usbdev, priv->irqhandle, priv->irqpipe); usb_release_irq(usbdev, priv->irqhandle, priv->irqpipe);
#endif #endif
priv->usbdev = NULL; priv->usbdev = NULL;
parport_proc_unregister(pp); parport_proc_unregister(pp);
parport_unregister_port(pp); parport_unregister_port(pp);
kfree(priv); kfree(priv);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
}
} }
/* table of cables that work through this driver */ /* table of cables that work through this driver */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment