diff options
Diffstat (limited to 'drivers/input/serio')
-rw-r--r-- | drivers/input/serio/pcips2.c | 15 | ||||
-rw-r--r-- | drivers/input/serio/ps2mult.c | 13 | ||||
-rw-r--r-- | drivers/input/serio/serio_raw.c | 65 | ||||
-rw-r--r-- | drivers/input/serio/xilinx_ps2.c | 35 |
4 files changed, 53 insertions, 75 deletions
diff --git a/drivers/input/serio/pcips2.c b/drivers/input/serio/pcips2.c index 43494742541..0c42497aaaf 100644 --- a/drivers/input/serio/pcips2.c +++ b/drivers/input/serio/pcips2.c @@ -206,6 +206,7 @@ static const struct pci_device_id pcips2_ids[] = { }, { 0, } }; +MODULE_DEVICE_TABLE(pci, pcips2_ids); static struct pci_driver pcips2_driver = { .name = "pcips2", @@ -214,20 +215,8 @@ static struct pci_driver pcips2_driver = { .remove = __devexit_p(pcips2_remove), }; -static int __init pcips2_init(void) -{ - return pci_register_driver(&pcips2_driver); -} - -static void __exit pcips2_exit(void) -{ - pci_unregister_driver(&pcips2_driver); -} - -module_init(pcips2_init); -module_exit(pcips2_exit); +module_pci_driver(pcips2_driver); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>"); MODULE_DESCRIPTION("PCI PS/2 keyboard/mouse driver"); -MODULE_DEVICE_TABLE(pci, pcips2_ids); diff --git a/drivers/input/serio/ps2mult.c b/drivers/input/serio/ps2mult.c index 15aa81c9f1f..a76fb64f03d 100644 --- a/drivers/input/serio/ps2mult.c +++ b/drivers/input/serio/ps2mult.c @@ -304,15 +304,4 @@ static struct serio_driver ps2mult_drv = { .reconnect = ps2mult_reconnect, }; -static int __init ps2mult_init(void) -{ - return serio_register_driver(&ps2mult_drv); -} - -static void __exit ps2mult_exit(void) -{ - serio_unregister_driver(&ps2mult_drv); -} - -module_init(ps2mult_init); -module_exit(ps2mult_exit); +module_serio_driver(ps2mult_drv); diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c index 4494233d331..59df2e7317a 100644 --- a/drivers/input/serio/serio_raw.c +++ b/drivers/input/serio/serio_raw.c @@ -165,31 +165,38 @@ static ssize_t serio_raw_read(struct file *file, char __user *buffer, struct serio_raw *serio_raw = client->serio_raw; char uninitialized_var(c); ssize_t read = 0; - int retval; + int error; - if (serio_raw->dead) - return -ENODEV; + for (;;) { + if (serio_raw->dead) + return -ENODEV; - if (serio_raw->head == serio_raw->tail && (file->f_flags & O_NONBLOCK)) - return -EAGAIN; + if (serio_raw->head == serio_raw->tail && + (file->f_flags & O_NONBLOCK)) + return -EAGAIN; - retval = wait_event_interruptible(serio_raw->wait, - serio_raw->head != serio_raw->tail || serio_raw->dead); - if (retval) - return retval; + if (count == 0) + break; - if (serio_raw->dead) - return -ENODEV; + while (read < count && serio_raw_fetch_byte(serio_raw, &c)) { + if (put_user(c, buffer++)) + return -EFAULT; + read++; + } - while (read < count && serio_raw_fetch_byte(serio_raw, &c)) { - if (put_user(c, buffer++)) { - retval = -EFAULT; + if (read) break; + + if (!(file->f_flags & O_NONBLOCK)) { + error = wait_event_interruptible(serio_raw->wait, + serio_raw->head != serio_raw->tail || + serio_raw->dead); + if (error) + return error; } - read++; } - return read ?: retval; + return read; } static ssize_t serio_raw_write(struct file *file, const char __user *buffer, @@ -197,8 +204,7 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer, { struct serio_raw_client *client = file->private_data; struct serio_raw *serio_raw = client->serio_raw; - ssize_t written = 0; - int retval; + int retval = 0; unsigned char c; retval = mutex_lock_interruptible(&serio_raw_mutex); @@ -218,16 +224,20 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer, retval = -EFAULT; goto out; } + if (serio_write(serio_raw->serio, c)) { - retval = -EIO; + /* Either signal error or partial write */ + if (retval == 0) + retval = -EIO; goto out; } - written++; + + retval++; } out: mutex_unlock(&serio_raw_mutex); - return written ?: retval; + return retval; } static unsigned int serio_raw_poll(struct file *file, poll_table *wait) @@ -432,15 +442,4 @@ static struct serio_driver serio_raw_drv = { .manual_bind = true, }; -static int __init serio_raw_init(void) -{ - return serio_register_driver(&serio_raw_drv); -} - -static void __exit serio_raw_exit(void) -{ - serio_unregister_driver(&serio_raw_drv); -} - -module_init(serio_raw_init); -module_exit(serio_raw_exit); +module_serio_driver(serio_raw_drv); diff --git a/drivers/input/serio/xilinx_ps2.c b/drivers/input/serio/xilinx_ps2.c index d96d4c2a76a..1e983bec7d8 100644 --- a/drivers/input/serio/xilinx_ps2.c +++ b/drivers/input/serio/xilinx_ps2.c @@ -73,7 +73,8 @@ struct xps2data { spinlock_t lock; void __iomem *base_address; /* virt. address of control registers */ unsigned int flags; - struct serio serio; /* serio */ + struct serio *serio; /* serio */ + struct device *dev; }; /************************************/ @@ -119,7 +120,7 @@ static irqreturn_t xps2_interrupt(int irq, void *dev_id) /* Check which interrupt is active */ if (intr_sr & XPS2_IPIXR_RX_OVF) - dev_warn(drvdata->serio.dev.parent, "receive overrun error\n"); + dev_warn(drvdata->dev, "receive overrun error\n"); if (intr_sr & XPS2_IPIXR_RX_ERR) drvdata->flags |= SERIO_PARITY; @@ -132,10 +133,10 @@ static irqreturn_t xps2_interrupt(int irq, void *dev_id) /* Error, if a byte is not received */ if (status) { - dev_err(drvdata->serio.dev.parent, + dev_err(drvdata->dev, "wrong rcvd byte count (%d)\n", status); } else { - serio_interrupt(&drvdata->serio, c, drvdata->flags); + serio_interrupt(drvdata->serio, c, drvdata->flags); drvdata->flags = 0; } } @@ -193,7 +194,7 @@ static int sxps2_open(struct serio *pserio) error = request_irq(drvdata->irq, &xps2_interrupt, 0, DRIVER_NAME, drvdata); if (error) { - dev_err(drvdata->serio.dev.parent, + dev_err(drvdata->dev, "Couldn't allocate interrupt %d\n", drvdata->irq); return error; } @@ -259,15 +260,16 @@ static int __devinit xps2_of_probe(struct platform_device *ofdev) } drvdata = kzalloc(sizeof(struct xps2data), GFP_KERNEL); - if (!drvdata) { - dev_err(dev, "Couldn't allocate device private record\n"); - return -ENOMEM; + serio = kzalloc(sizeof(struct serio), GFP_KERNEL); + if (!drvdata || !serio) { + error = -ENOMEM; + goto failed1; } - dev_set_drvdata(dev, drvdata); - spin_lock_init(&drvdata->lock); drvdata->irq = r_irq.start; + drvdata->serio = serio; + drvdata->dev = dev; phys_addr = r_mem.start; remap_size = resource_size(&r_mem); @@ -298,7 +300,6 @@ static int __devinit xps2_of_probe(struct platform_device *ofdev) (unsigned long long)phys_addr, drvdata->base_address, drvdata->irq); - serio = &drvdata->serio; serio->id.type = SERIO_8042; serio->write = sxps2_write; serio->open = sxps2_open; @@ -312,13 +313,14 @@ static int __devinit xps2_of_probe(struct platform_device *ofdev) serio_register_port(serio); + platform_set_drvdata(ofdev, drvdata); return 0; /* success */ failed2: release_mem_region(phys_addr, remap_size); failed1: + kfree(serio); kfree(drvdata); - dev_set_drvdata(dev, NULL); return error; } @@ -333,22 +335,21 @@ failed1: */ static int __devexit xps2_of_remove(struct platform_device *of_dev) { - struct device *dev = &of_dev->dev; - struct xps2data *drvdata = dev_get_drvdata(dev); + struct xps2data *drvdata = platform_get_drvdata(of_dev); struct resource r_mem; /* IO mem resources */ - serio_unregister_port(&drvdata->serio); + serio_unregister_port(drvdata->serio); iounmap(drvdata->base_address); /* Get iospace of the device */ if (of_address_to_resource(of_dev->dev.of_node, 0, &r_mem)) - dev_err(dev, "invalid address\n"); + dev_err(drvdata->dev, "invalid address\n"); else release_mem_region(r_mem.start, resource_size(&r_mem)); kfree(drvdata); - dev_set_drvdata(dev, NULL); + platform_set_drvdata(of_dev, NULL); return 0; } |