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/inport.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/inport.c')
-rw-r--r-- | drivers/input/mouse/inport.c | 23 |
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) | |||
135 | static int __init inport_init(void) | 135 | static int __init inport_init(void) |
136 | { | 136 | { |
137 | unsigned char a, b, c; | 137 | unsigned char a, b, c; |
138 | int err; | ||
138 | 139 | ||
139 | if (!request_region(INPORT_BASE, INPORT_EXTENT, "inport")) { | 140 | if (!request_region(INPORT_BASE, INPORT_EXTENT, "inport")) { |
140 | printk(KERN_ERR "inport.c: Can't allocate ports at %#x\n", INPORT_BASE); | 141 | printk(KERN_ERR "inport.c: Can't allocate ports at %#x\n", INPORT_BASE); |
@@ -145,15 +146,16 @@ static int __init inport_init(void) | |||
145 | b = inb(INPORT_SIGNATURE_PORT); | 146 | b = inb(INPORT_SIGNATURE_PORT); |
146 | c = inb(INPORT_SIGNATURE_PORT); | 147 | c = inb(INPORT_SIGNATURE_PORT); |
147 | if (a == b || a != c) { | 148 | if (a == b || a != c) { |
148 | release_region(INPORT_BASE, INPORT_EXTENT); | ||
149 | printk(KERN_ERR "inport.c: Didn't find InPort mouse at %#x\n", INPORT_BASE); | 149 | printk(KERN_ERR "inport.c: Didn't find InPort mouse at %#x\n", INPORT_BASE); |
150 | return -ENODEV; | 150 | err = -ENODEV; |
151 | goto err_release_region; | ||
151 | } | 152 | } |
152 | 153 | ||
153 | if (!(inport_dev = input_allocate_device())) { | 154 | inport_dev = input_allocate_device(); |
155 | if (!inport_dev) { | ||
154 | printk(KERN_ERR "inport.c: Not enough memory for input device\n"); | 156 | printk(KERN_ERR "inport.c: Not enough memory for input device\n"); |
155 | release_region(INPORT_BASE, INPORT_EXTENT); | 157 | err = -ENOMEM; |
156 | return -ENOMEM; | 158 | goto err_release_region; |
157 | } | 159 | } |
158 | 160 | ||
159 | inport_dev->name = INPORT_NAME; | 161 | inport_dev->name = INPORT_NAME; |
@@ -174,9 +176,18 @@ static int __init inport_init(void) | |||
174 | outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); | 176 | outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); |
175 | outb(INPORT_MODE_BASE, INPORT_DATA_PORT); | 177 | outb(INPORT_MODE_BASE, INPORT_DATA_PORT); |
176 | 178 | ||
177 | input_register_device(inport_dev); | 179 | err = input_register_device(inport_dev); |
180 | if (err) | ||
181 | goto err_free_dev; | ||
178 | 182 | ||
179 | return 0; | 183 | return 0; |
184 | |||
185 | err_free_dev: | ||
186 | input_free_device(inport_dev); | ||
187 | err_release_region: | ||
188 | release_region(INPORT_BASE, INPORT_EXTENT); | ||
189 | |||
190 | return err; | ||
180 | } | 191 | } |
181 | 192 | ||
182 | static void __exit inport_exit(void) | 193 | static void __exit inport_exit(void) |