diff options
Diffstat (limited to 'drivers/input/serio')
-rw-r--r-- | drivers/input/serio/ps2mult.c | 13 | ||||
-rw-r--r-- | drivers/input/serio/serio_raw.c | 56 | ||||
-rw-r--r-- | drivers/input/serio/xilinx_ps2.c | 35 |
3 files changed, 45 insertions, 59 deletions
diff --git a/drivers/input/serio/ps2mult.c b/drivers/input/serio/ps2mult.c index 15aa81c..a76fb64 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 4494233..3e24362 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 = 0; - if (serio_raw->dead) - return -ENODEV; + do { + 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++)) { + error = -EFAULT; + goto out; + } + read++; + } - while (read < count && serio_raw_fetch_byte(serio_raw, &c)) { - if (put_user(c, buffer++)) { - retval = -EFAULT; + if (read) break; - } - read++; - } - return read ?: retval; + if (!(file->f_flags & O_NONBLOCK)) + error = wait_event_interruptible(serio_raw->wait, + serio_raw->head != serio_raw->tail || + serio_raw->dead); + } while (!error); + +out: + return read ?: error; } static ssize_t serio_raw_write(struct file *file, const char __user *buffer, @@ -432,15 +439,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 d96d4c2..1e983be 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; } |