summaryrefslogtreecommitdiffstats
path: root/drivers/input/mouse/logibm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/mouse/logibm.c')
-rw-r--r--drivers/input/mouse/logibm.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/drivers/input/mouse/logibm.c b/drivers/input/mouse/logibm.c
index 8e9c2f3d69a8..db205995bffd 100644
--- a/drivers/input/mouse/logibm.c
+++ b/drivers/input/mouse/logibm.c
@@ -124,6 +124,8 @@ static void logibm_close(struct input_dev *dev)
static int __init logibm_init(void)
{
+ int err;
+
if (!request_region(LOGIBM_BASE, LOGIBM_EXTENT, "logibm")) {
printk(KERN_ERR "logibm.c: Can't allocate ports at %#x\n", LOGIBM_BASE);
return -EBUSY;
@@ -134,18 +136,19 @@ static int __init logibm_init(void)
udelay(100);
if (inb(LOGIBM_SIGNATURE_PORT) != LOGIBM_SIGNATURE_BYTE) {
- release_region(LOGIBM_BASE, LOGIBM_EXTENT);
printk(KERN_ERR "logibm.c: Didn't find Logitech busmouse at %#x\n", LOGIBM_BASE);
- return -ENODEV;
+ err = -ENODEV;
+ goto err_release_region;
}
outb(LOGIBM_DEFAULT_MODE, LOGIBM_CONFIG_PORT);
outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT);
- if (!(logibm_dev = input_allocate_device())) {
+ logibm_dev = input_allocate_device();
+ if (!logibm_dev) {
printk(KERN_ERR "logibm.c: Not enough memory for input device\n");
- release_region(LOGIBM_BASE, LOGIBM_EXTENT);
- return -ENOMEM;
+ err = -ENOMEM;
+ goto err_release_region;
}
logibm_dev->name = "Logitech bus mouse";
@@ -162,9 +165,18 @@ static int __init logibm_init(void)
logibm_dev->open = logibm_open;
logibm_dev->close = logibm_close;
- input_register_device(logibm_dev);
+ err = input_register_device(logibm_dev);
+ if (err)
+ goto err_free_dev;
return 0;
+
+ err_free_dev:
+ input_free_device(logibm_dev);
+ err_release_region:
+ release_region(LOGIBM_BASE, LOGIBM_EXTENT);
+
+ return err;
}
static void __exit logibm_exit(void)