diff options
author | Dmitry Torokhov <dtor@insightbb.com> | 2006-11-05 22:40:19 -0500 |
---|---|---|
committer | Dmitry Torokhov <dtor@insightbb.com> | 2006-11-05 22:40:19 -0500 |
commit | 721556150e397f606a3f029736d77a27503f94e2 (patch) | |
tree | 1bdce32c4d1421f0dfbd9871986fcb7eaa6aba56 /drivers/input/mouse/logibm.c | |
parent | 127278ce2254c61f1346500374d61e33f74a8729 (diff) |
Input: mice - handle errors when registering input devices
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/mouse/logibm.c')
-rw-r--r-- | drivers/input/mouse/logibm.c | 24 |
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) | |||
124 | 124 | ||
125 | static int __init logibm_init(void) | 125 | static int __init logibm_init(void) |
126 | { | 126 | { |
127 | int err; | ||
128 | |||
127 | if (!request_region(LOGIBM_BASE, LOGIBM_EXTENT, "logibm")) { | 129 | if (!request_region(LOGIBM_BASE, LOGIBM_EXTENT, "logibm")) { |
128 | printk(KERN_ERR "logibm.c: Can't allocate ports at %#x\n", LOGIBM_BASE); | 130 | printk(KERN_ERR "logibm.c: Can't allocate ports at %#x\n", LOGIBM_BASE); |
129 | return -EBUSY; | 131 | return -EBUSY; |
@@ -134,18 +136,19 @@ static int __init logibm_init(void) | |||
134 | udelay(100); | 136 | udelay(100); |
135 | 137 | ||
136 | if (inb(LOGIBM_SIGNATURE_PORT) != LOGIBM_SIGNATURE_BYTE) { | 138 | if (inb(LOGIBM_SIGNATURE_PORT) != LOGIBM_SIGNATURE_BYTE) { |
137 | release_region(LOGIBM_BASE, LOGIBM_EXTENT); | ||
138 | printk(KERN_ERR "logibm.c: Didn't find Logitech busmouse at %#x\n", LOGIBM_BASE); | 139 | printk(KERN_ERR "logibm.c: Didn't find Logitech busmouse at %#x\n", LOGIBM_BASE); |
139 | return -ENODEV; | 140 | err = -ENODEV; |
141 | goto err_release_region; | ||
140 | } | 142 | } |
141 | 143 | ||
142 | outb(LOGIBM_DEFAULT_MODE, LOGIBM_CONFIG_PORT); | 144 | outb(LOGIBM_DEFAULT_MODE, LOGIBM_CONFIG_PORT); |
143 | outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT); | 145 | outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT); |
144 | 146 | ||
145 | if (!(logibm_dev = input_allocate_device())) { | 147 | logibm_dev = input_allocate_device(); |
148 | if (!logibm_dev) { | ||
146 | printk(KERN_ERR "logibm.c: Not enough memory for input device\n"); | 149 | printk(KERN_ERR "logibm.c: Not enough memory for input device\n"); |
147 | release_region(LOGIBM_BASE, LOGIBM_EXTENT); | 150 | err = -ENOMEM; |
148 | return -ENOMEM; | 151 | goto err_release_region; |
149 | } | 152 | } |
150 | 153 | ||
151 | logibm_dev->name = "Logitech bus mouse"; | 154 | logibm_dev->name = "Logitech bus mouse"; |
@@ -162,9 +165,18 @@ static int __init logibm_init(void) | |||
162 | logibm_dev->open = logibm_open; | 165 | logibm_dev->open = logibm_open; |
163 | logibm_dev->close = logibm_close; | 166 | logibm_dev->close = logibm_close; |
164 | 167 | ||
165 | input_register_device(logibm_dev); | 168 | err = input_register_device(logibm_dev); |
169 | if (err) | ||
170 | goto err_free_dev; | ||
166 | 171 | ||
167 | return 0; | 172 | return 0; |
173 | |||
174 | err_free_dev: | ||
175 | input_free_device(logibm_dev); | ||
176 | err_release_region: | ||
177 | release_region(LOGIBM_BASE, LOGIBM_EXTENT); | ||
178 | |||
179 | return err; | ||
168 | } | 180 | } |
169 | 181 | ||
170 | static void __exit logibm_exit(void) | 182 | static void __exit logibm_exit(void) |