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 =
class based it might be necessary to parse some more USB descriptors because
the device properties can differ in a wide range.
*/
static void *auerswald_probe (struct usb_device *usbdev, unsigned int ifnum,
const struct usb_device_id *id)
static int auerswald_probe (struct usb_interface *intf,
const struct usb_device_id *id)
{
struct usb_device *usbdev = interface_to_usbdev(intf);
pauerswald_t cp = NULL;
DECLARE_WAIT_QUEUE_HEAD (wqh);
unsigned int dtindex;
......@@ -1920,14 +1921,16 @@ static void *auerswald_probe (struct usb_device *usbdev, unsigned int ifnum,
char *pbuf;
int ret;
dbg ("probe: vendor id 0x%x, device id 0x%x ifnum:%d",
usbdev->descriptor.idVendor, usbdev->descriptor.idProduct, ifnum);
dbg ("probe: vendor id 0x%x, device id 0x%x",
usbdev->descriptor.idVendor, usbdev->descriptor.idProduct);
/* 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 */
if (ifnum != 0) return NULL;
if (intf->altsetting->bInterfaceNumber != 0)
return -ENODEV;
/* prevent module unloading while sleeping */
MOD_INC_USE_COUNT;
......@@ -2044,12 +2047,13 @@ static void *auerswald_probe (struct usb_device *usbdev, unsigned int ifnum,
}
/* all OK */
return cp;
dev_set_drvdata (&intf->dev, cp);
return 0;
/* Error exit: clean up the memory */
pfail: auerswald_delete (cp);
MOD_DEC_USE_COUNT;
return NULL;
return -EIO;
}
......@@ -2065,11 +2069,15 @@ pfail: auerswald_delete (cp);
this device. So especially the usb_device structure must not be used
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;
dev_set_drvdata (&intf->dev, NULL);
if (!cp)
return;
down (&cp->mutex);
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");
#endif
/* Prototypes */
static void *brlvger_probe (struct usb_device *dev, unsigned ifnum,
const struct usb_device_id *id);
static void brlvger_disconnect(struct usb_device *dev, void *ptr);
static int brlvger_probe (struct usb_interface *intf,
const struct usb_device_id *id);
static void brlvger_disconnect(struct usb_interface *intf);
static int brlvger_open(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,
......@@ -281,10 +281,11 @@ module_exit (brlvger_cleanup);
/* Probe and disconnect functions */
static void *
brlvger_probe (struct usb_device *dev, unsigned ifnum,
static int
brlvger_probe (struct usb_interface *intf,
const struct usb_device_id *id)
{
struct usb_device *dev = interface_to_usbdev(intf);
struct brlvger_priv *priv = NULL;
int i;
int retval;
......@@ -301,14 +302,14 @@ brlvger_probe (struct usb_device *dev, unsigned ifnum,
|| dev->config->bNumInterfaces != 1
|| actifsettings->bNumEndpoints != 1 ) {
err ("Bogus braille display config info");
return NULL;
return -ENODEV;
}
endpoint = actifsettings->endpoint;
if (!(endpoint->bEndpointAddress & 0x80) ||
((endpoint->bmAttributes & 3) != 0x03)) {
err ("Bogus braille display config info, wrong endpoints");
return NULL;
return -ENODEV;
}
down(&reserve_sem);
......@@ -404,15 +405,20 @@ brlvger_probe (struct usb_device *dev, unsigned ifnum,
out:
up(&reserve_sem);
return priv;
if (priv) {
dev_set_drvdata (&intf->dev, priv);
return 0;
}
return -EIO;
}
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;
dev_set_drvdata (&intf->dev, NULL);
if(priv){
info("Display %d disconnecting", priv->subminor);
......
......@@ -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_set_reset(struct usb_device *dev, unsigned char reset_bit);
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 void emi26_disconnect(struct usb_device *dev, void *drv_context);
static int emi26_probe(struct usb_interface *intf, const struct usb_device_id *id);
static void emi26_disconnect(struct usb_interface *intf);
static int __init emi26_init (void);
static void __exit emi26_exit (void);
......@@ -195,8 +195,10 @@ static __devinitdata struct usb_device_id 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__);
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
}
/* 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 = {
.release = close_rio,
};
static void *probe_rio(struct usb_device *dev, unsigned int ifnum,
const struct usb_device_id *id)
static int probe_rio(struct usb_interface *intf,
const struct usb_device_id *id)
{
struct usb_device *dev = interface_to_usbdev(intf);
struct rio_usb_data *rio = &rio_instance;
int retval;
......@@ -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);
if (retval) {
err("Not able to get a minor for this device.");
return NULL;
return -ENOMEM;
}
rio->present = 1;
......@@ -469,14 +470,14 @@ static void *probe_rio(struct usb_device *dev, unsigned int ifnum,
if (!(rio->obuf = (char *) kmalloc(OBUF_SIZE, GFP_KERNEL))) {
err("probe_rio: Not enough memory for the output buffer");
return NULL;
return -ENOMEM;
}
dbg("probe_rio: obuf address:%p", rio->obuf);
if (!(rio->ibuf = (char *) kmalloc(IBUF_SIZE, GFP_KERNEL))) {
err("probe_rio: Not enough memory for the input buffer");
kfree(rio->obuf);
return NULL;
return -ENOMEM;
}
dbg("probe_rio: ibuf address:%p", rio->ibuf);
......@@ -490,31 +491,35 @@ static void *probe_rio(struct usb_device *dev, unsigned int ifnum,
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);
usb_deregister_dev(1, rio->minor);
info("USB Rio disconnected.");
down(&(rio->lock));
if (rio->isopen) {
rio->isopen = 0;
/* better let it finish - the release will do whats needed */
rio->rio_dev = NULL;
rio->present = 0;
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 [] = {
......
......@@ -177,20 +177,20 @@ struct udsl_atm_dev_data {
/*
* usb driver prototypes and structures
*/
static void *udsl_usb_probe (struct usb_device *dev, unsigned int ifnum,
const struct usb_device_id *id);
static void udsl_usb_disconnect (struct usb_device *dev, void *ptr);
static int udsl_usb_probe (struct usb_interface *intf,
const struct usb_device_id *id);
static void udsl_usb_disconnect (struct usb_interface *intf);
int udsl_usb_send_data (struct udsl_instance_data *instance, struct atm_vcc *vcc,
struct sk_buff *skb);
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 struct usb_driver udsl_usb_driver = {
name:udsl_driver_name,
probe:udsl_usb_probe,
disconnect:udsl_usb_disconnect,
ioctl:udsl_usb_ioctl,
id_table:udsl_usb_ids,
.name = udsl_driver_name,
.probe = udsl_usb_probe,
.disconnect = udsl_usb_disconnect,
.ioctl = udsl_usb_ioctl,
.id_table = udsl_usb_ids,
};
/************
......@@ -828,7 +828,7 @@ int udsl_usb_data_init (struct udsl_instance_data *instance)
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;
......@@ -913,8 +913,10 @@ static int udsl_usb_ioctl (struct usb_device *dev, unsigned int code, void *user
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;
unsigned char mac[6];
unsigned char mac_str[13];
......@@ -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) ||
(dev->descriptor.idVendor != SPEEDTOUCH_VENDORID) ||
(dev->descriptor.idProduct != SPEEDTOUCH_PRODUCTID) || (ifnum != 1))
return NULL;
return -ENODEV;
MOD_INC_USE_COUNT;
......@@ -936,7 +938,7 @@ void *udsl_usb_probe (struct usb_device *dev, unsigned int ifnum, const struct u
if (i >= MAX_UDSL) {
printk (KERN_INFO "No minor table space available for SpeedTouch USB\n");
return NULL;
return -ENOMEM;
};
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
instance = kmalloc (sizeof (struct udsl_instance_data), GFP_KERNEL);
if (!instance) {
PDEBUG ("No memory for Instance data!\n");
return NULL;
return -ENOMEM;
}
/* initialize structure */
......@@ -969,32 +971,37 @@ void *udsl_usb_probe (struct usb_device *dev, unsigned int ifnum, const struct u
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;
int i = instance->minor;
struct udsl_instance_data *instance = dev_get_drvdata (&intf->dev);
int i;
/* unlinking receive buffers */
udsl_usb_data_exit (instance);
dev_set_drvdata (&intf->dev, NULL);
if (instance) {
i = instance->minor;
/* unlinking receive buffers */
udsl_usb_data_exit (instance);
/* removing atm device */
if (instance->atm_dev)
udsl_atm_stopdevice (instance);
/* removing atm device */
if (instance->atm_dev)
udsl_atm_stopdevice (instance);
PDEBUG ("disconnecting minor %d\n", i);
PDEBUG ("disconnecting minor %d\n", i);
while (MOD_IN_USE > 1) {
current->state = TASK_INTERRUPTIBLE;
schedule_timeout (1);
}
while (MOD_IN_USE > 1) {
current->state = TASK_INTERRUPTIBLE;
schedule_timeout (1);
}
kfree (instance);
minor_data[i] = NULL;
kfree (instance);
minor_data[i] = NULL;
MOD_DEC_USE_COUNT;
MOD_DEC_USE_COUNT;
}
}
/***************************************************************************
......
......@@ -326,17 +326,18 @@ static struct file_operations tiglusb_fops = {
/* --- initialisation code ------------------------------------- */
static void *
tiglusb_probe (struct usb_device *dev, unsigned int ifnum,
static int
tiglusb_probe (struct usb_interface *intf,
const struct usb_device_id *id)
{
struct usb_device *dev = interface_to_usbdev(intf);
int minor = -1;
int i;
ptiglusb_t s;
char name[8];
dbg ("probing vendor id 0x%x, device id 0x%x ifnum:%d",
dev->descriptor.idVendor, dev->descriptor.idProduct, ifnum);
dbg ("probing vendor id 0x%x, device id 0x%x",
dev->descriptor.idVendor, dev->descriptor.idProduct);
/*
* We don't handle multiple configurations. As of version 0x0103 of
......@@ -344,15 +345,15 @@ tiglusb_probe (struct usb_device *dev, unsigned int ifnum,
*/
if (dev->descriptor.bNumConfigurations != 1)
return NULL;
return -ENODEV;
if ((dev->descriptor.idProduct != 0xe001)
&& (dev->descriptor.idVendor != 0x451))
return NULL;
return -ENODEV;
if (usb_set_configuration (dev, dev->config[0].bConfigurationValue) < 0) {
err ("tiglusb_probe: set_configuration failed");
return NULL;
return -ENODEV;
}
/*
......@@ -367,7 +368,7 @@ tiglusb_probe (struct usb_device *dev, unsigned int ifnum,
}
if (minor == -1)
return NULL;
return -ENODEV;
s = &tiglusb[minor];
......@@ -375,7 +376,7 @@ tiglusb_probe (struct usb_device *dev, unsigned int ifnum,
s->remove_pending = 0;
s->dev = dev;
up (&s->mutex);
dbg ("bound to interface: %d", ifnum);
dbg ("bound to interface");
sprintf (name, "%d", s->minor);
dbg ("registering to devfs : major = %d, minor = %d, node = %s",
......@@ -390,16 +391,20 @@ tiglusb_probe (struct usb_device *dev, unsigned int ifnum,
dev->descriptor.bcdDevice >> 8,
dev->descriptor.bcdDevice & 0xff);
return s;
dev_set_drvdata (&intf->dev, s);
return 0;
}
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");
return;
}
s->remove_pending = 1;
wake_up (&s->wait);
......
......@@ -245,20 +245,21 @@ file_operations usb_lcd_fops = {
.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;
int i;
int retval;
if (dev->descriptor.idProduct != 0x0001 ) {
warn(KERN_INFO "USBLCD model not supported.");
return NULL;
return -ENODEV;
}
if (lcd->present == 1) {
warn(KERN_INFO "Multiple USBLCDs are not supported!");
return NULL;
return -ENODEV;
}
i = dev->descriptor.bcdDevice;
......@@ -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);
if (retval) {
err("Not able to get a minor for this device.");
return NULL;
return -ENOMEM;
}
lcd->present = 1;
......@@ -278,38 +279,42 @@ static void *probe_lcd(struct usb_device *dev, unsigned int ifnum)
if (!(lcd->obuf = (char *) kmalloc(OBUF_SIZE, GFP_KERNEL))) {
err("probe_lcd: Not enough memory for the output buffer");
return NULL;
return -ENOMEM;
}
dbg("probe_lcd: obuf address:%p", lcd->obuf);
if (!(lcd->ibuf = (char *) kmalloc(IBUF_SIZE, GFP_KERNEL))) {
err("probe_lcd: Not enough memory for the input buffer");
kfree(lcd->obuf);
return NULL;
return -ENOMEM;
}
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) {
lcd->isopen = 0;
/* better let it finish - the release will do whats needed */
lcd->lcd_dev = NULL;
return;
}
kfree(lcd->ibuf);
kfree(lcd->obuf);
if (lcd->isopen) {
lcd->isopen = 0;
/* better let it finish - the release will do whats needed */
lcd->lcd_dev = NULL;
return;
}
kfree(lcd->ibuf);
kfree(lcd->obuf);
info("USBLCD disconnected.");
info("USBLCD disconnected.");
lcd->present = 0;
lcd->present = 0;
}
}
static struct usb_device_id id_table [] = {
......
......@@ -545,9 +545,10 @@ static struct parport_operations parport_uss720_ops =
/* --------------------------------------------------------------------- */
static void * uss720_probe(struct usb_device *usbdev, unsigned int ifnum,
const struct usb_device_id *id)
static int uss720_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
struct usb_device *usbdev = interface_to_usbdev(intf);
struct usb_interface_descriptor *interface;
struct usb_endpoint_descriptor *endpoint;
struct parport_uss720_private *priv;
......@@ -558,13 +559,13 @@ static void * uss720_probe(struct usb_device *usbdev, unsigned int ifnum,
usbdev->descriptor.idVendor, usbdev->descriptor.idProduct);
/* our known interfaces have 3 alternate settings */
if (usbdev->actconfig->interface[ifnum].num_altsetting != 3)
return NULL;
if (intf->num_altsetting != 3)
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);
interface = &usbdev->actconfig->interface[ifnum].altsetting[2];
interface = &intf->altsetting[2];
/*
* Allocate parport interface
......@@ -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");
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))) {
printk(KERN_WARNING "usb-uss720: could not register parport\n");
goto probe_abort;
......@@ -607,7 +608,8 @@ static void * uss720_probe(struct usb_device *usbdev, unsigned int ifnum,
parport_announce_port(pp);
MOD_INC_USE_COUNT;
return pp;
dev_set_drvdata (&intf->dev, pp);
return 0;
#if 0
probe_abort_port:
......@@ -615,22 +617,26 @@ static void * uss720_probe(struct usb_device *usbdev, unsigned int ifnum,
#endif
probe_abort:
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_uss720_private *priv = pp->private_data;
struct parport *pp = dev_get_drvdata (&intf->dev);
struct parport_uss720_private *priv;
dev_set_drvdata (&intf->dev, NULL);
if (pp) {
priv = pp->private_data;
#if 0
usb_release_irq(usbdev, priv->irqhandle, priv->irqpipe);
usb_release_irq(usbdev, priv->irqhandle, priv->irqpipe);
#endif
priv->usbdev = NULL;
parport_proc_unregister(pp);
parport_unregister_port(pp);
kfree(priv);
MOD_DEC_USE_COUNT;
priv->usbdev = NULL;
parport_proc_unregister(pp);
parport_unregister_port(pp);
kfree(priv);
MOD_DEC_USE_COUNT;
}
}
/* 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