diff options
author | Dmitry Torokhov <dtor@insightbb.com> | 2006-11-05 22:39:56 -0500 |
---|---|---|
committer | Dmitry Torokhov <dtor@insightbb.com> | 2006-11-05 22:39:56 -0500 |
commit | 2b03b60e6b8635fffdd15d5d24943950f2bbf96e (patch) | |
tree | 17f0354b7edb08920a89e663ef724c84518c49fa /drivers/input/keyboard/locomokbd.c | |
parent | 41ad5fbabda0c3930136bb40cfc7a0c23013365f (diff) |
Input: keyboards - handle errors when registering input devices
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/keyboard/locomokbd.c')
-rw-r--r-- | drivers/input/keyboard/locomokbd.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c index 5788dbc317bb..2ade5186cc41 100644 --- a/drivers/input/keyboard/locomokbd.c +++ b/drivers/input/keyboard/locomokbd.c | |||
@@ -193,22 +193,22 @@ static int locomokbd_probe(struct locomo_dev *dev) | |||
193 | { | 193 | { |
194 | struct locomokbd *locomokbd; | 194 | struct locomokbd *locomokbd; |
195 | struct input_dev *input_dev; | 195 | struct input_dev *input_dev; |
196 | int i, ret; | 196 | int i, err; |
197 | 197 | ||
198 | locomokbd = kzalloc(sizeof(struct locomokbd), GFP_KERNEL); | 198 | locomokbd = kzalloc(sizeof(struct locomokbd), GFP_KERNEL); |
199 | input_dev = input_allocate_device(); | 199 | input_dev = input_allocate_device(); |
200 | if (!locomokbd || !input_dev) { | 200 | if (!locomokbd || !input_dev) { |
201 | ret = -ENOMEM; | 201 | err = -ENOMEM; |
202 | goto free; | 202 | goto err_free_mem; |
203 | } | 203 | } |
204 | 204 | ||
205 | /* try and claim memory region */ | 205 | /* try and claim memory region */ |
206 | if (!request_mem_region((unsigned long) dev->mapbase, | 206 | if (!request_mem_region((unsigned long) dev->mapbase, |
207 | dev->length, | 207 | dev->length, |
208 | LOCOMO_DRIVER_NAME(dev))) { | 208 | LOCOMO_DRIVER_NAME(dev))) { |
209 | ret = -EBUSY; | 209 | err = -EBUSY; |
210 | printk(KERN_ERR "locomokbd: Can't acquire access to io memory for keyboard\n"); | 210 | printk(KERN_ERR "locomokbd: Can't acquire access to io memory for keyboard\n"); |
211 | goto free; | 211 | goto err_free_mem; |
212 | } | 212 | } |
213 | 213 | ||
214 | locomokbd->ldev = dev; | 214 | locomokbd->ldev = dev; |
@@ -244,24 +244,28 @@ static int locomokbd_probe(struct locomo_dev *dev) | |||
244 | clear_bit(0, input_dev->keybit); | 244 | clear_bit(0, input_dev->keybit); |
245 | 245 | ||
246 | /* attempt to get the interrupt */ | 246 | /* attempt to get the interrupt */ |
247 | ret = request_irq(dev->irq[0], locomokbd_interrupt, 0, "locomokbd", locomokbd); | 247 | err = request_irq(dev->irq[0], locomokbd_interrupt, 0, "locomokbd", locomokbd); |
248 | if (ret) { | 248 | if (err) { |
249 | printk(KERN_ERR "locomokbd: Can't get irq for keyboard\n"); | 249 | printk(KERN_ERR "locomokbd: Can't get irq for keyboard\n"); |
250 | goto out; | 250 | goto err_release_region; |
251 | } | 251 | } |
252 | 252 | ||
253 | input_register_device(locomokbd->input); | 253 | err = input_register_device(locomokbd->input); |
254 | if (err) | ||
255 | goto err_free_irq; | ||
254 | 256 | ||
255 | return 0; | 257 | return 0; |
256 | 258 | ||
257 | out: | 259 | err_free_irq: |
260 | free_irq(dev->irq[0], locomokbd); | ||
261 | err_release_region: | ||
258 | release_mem_region((unsigned long) dev->mapbase, dev->length); | 262 | release_mem_region((unsigned long) dev->mapbase, dev->length); |
259 | locomo_set_drvdata(dev, NULL); | 263 | locomo_set_drvdata(dev, NULL); |
260 | free: | 264 | err_free_mem: |
261 | input_free_device(input_dev); | 265 | input_free_device(input_dev); |
262 | kfree(locomokbd); | 266 | kfree(locomokbd); |
263 | 267 | ||
264 | return ret; | 268 | return err; |
265 | } | 269 | } |
266 | 270 | ||
267 | static int locomokbd_remove(struct locomo_dev *dev) | 271 | static int locomokbd_remove(struct locomo_dev *dev) |