summaryrefslogtreecommitdiffstats
path: root/drivers/input/mouse/inport.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@insightbb.com>2006-11-05 22:40:19 -0500
committerDmitry Torokhov <dtor@insightbb.com>2006-11-05 22:40:19 -0500
commit721556150e397f606a3f029736d77a27503f94e2 (patch)
tree1bdce32c4d1421f0dfbd9871986fcb7eaa6aba56 /drivers/input/mouse/inport.c
parent127278ce2254c61f1346500374d61e33f74a8729 (diff)
downloadblackbird-op-linux-721556150e397f606a3f029736d77a27503f94e2.tar.gz
blackbird-op-linux-721556150e397f606a3f029736d77a27503f94e2.zip
Input: mice - handle errors when registering input devices
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/mouse/inport.c')
-rw-r--r--drivers/input/mouse/inport.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/drivers/input/mouse/inport.c b/drivers/input/mouse/inport.c
index e1252fa9a107..13dd96785e39 100644
--- a/drivers/input/mouse/inport.c
+++ b/drivers/input/mouse/inport.c
@@ -135,6 +135,7 @@ static void inport_close(struct input_dev *dev)
static int __init inport_init(void)
{
unsigned char a, b, c;
+ int err;
if (!request_region(INPORT_BASE, INPORT_EXTENT, "inport")) {
printk(KERN_ERR "inport.c: Can't allocate ports at %#x\n", INPORT_BASE);
@@ -145,15 +146,16 @@ static int __init inport_init(void)
b = inb(INPORT_SIGNATURE_PORT);
c = inb(INPORT_SIGNATURE_PORT);
if (a == b || a != c) {
- release_region(INPORT_BASE, INPORT_EXTENT);
printk(KERN_ERR "inport.c: Didn't find InPort mouse at %#x\n", INPORT_BASE);
- return -ENODEV;
+ err = -ENODEV;
+ goto err_release_region;
}
- if (!(inport_dev = input_allocate_device())) {
+ inport_dev = input_allocate_device();
+ if (!inport_dev) {
printk(KERN_ERR "inport.c: Not enough memory for input device\n");
- release_region(INPORT_BASE, INPORT_EXTENT);
- return -ENOMEM;
+ err = -ENOMEM;
+ goto err_release_region;
}
inport_dev->name = INPORT_NAME;
@@ -174,9 +176,18 @@ static int __init inport_init(void)
outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
outb(INPORT_MODE_BASE, INPORT_DATA_PORT);
- input_register_device(inport_dev);
+ err = input_register_device(inport_dev);
+ if (err)
+ goto err_free_dev;
return 0;
+
+ err_free_dev:
+ input_free_device(inport_dev);
+ err_release_region:
+ release_region(INPORT_BASE, INPORT_EXTENT);
+
+ return err;
}
static void __exit inport_exit(void)
OpenPOWER on IntegriCloud