diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-12-17 01:38:45 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2013-01-21 20:31:58 -0500 |
commit | ea05ae071ed0f360c6002d7b5107e0dad724d511 (patch) | |
tree | 0554f52c212011e863e885e217ced0e6fd45e874 | |
parent | e0dba55eae4557461aba53ec38ad82372fff86d6 (diff) |
Input: walkera0701 - use proper error codes
We have been using -EBUSY where we should have used -EIO or -ENOMEM,
so let's fix that and also add some diagnostic messages.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r-- | drivers/input/joystick/walkera0701.c | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/drivers/input/joystick/walkera0701.c b/drivers/input/joystick/walkera0701.c index da657e63a223..b86134c0b299 100644 --- a/drivers/input/joystick/walkera0701.c +++ b/drivers/input/joystick/walkera0701.c | |||
@@ -197,37 +197,51 @@ static void walkera0701_close(struct input_dev *dev) | |||
197 | 197 | ||
198 | static int walkera0701_connect(struct walkera_dev *w, int parport) | 198 | static int walkera0701_connect(struct walkera_dev *w, int parport) |
199 | { | 199 | { |
200 | int err = -ENODEV; | 200 | int error; |
201 | 201 | ||
202 | w->parport = parport_find_number(parport); | 202 | w->parport = parport_find_number(parport); |
203 | if (w->parport == NULL) | 203 | if (!w->parport) { |
204 | pr_err("parport %d does not exist\n", parport); | ||
204 | return -ENODEV; | 205 | return -ENODEV; |
206 | } | ||
205 | 207 | ||
206 | if (w->parport->irq == -1) { | 208 | if (w->parport->irq == -1) { |
207 | pr_err("parport %d does not have interrupt assigned\n", | 209 | pr_err("parport %d does not have interrupt assigned\n", |
208 | parport); | 210 | parport); |
209 | goto init_err; | 211 | error = -EINVAL; |
212 | goto err_put_parport; | ||
210 | } | 213 | } |
211 | 214 | ||
212 | err = -EBUSY; | ||
213 | w->pardevice = parport_register_device(w->parport, "walkera0701", | 215 | w->pardevice = parport_register_device(w->parport, "walkera0701", |
214 | NULL, NULL, walkera0701_irq_handler, | 216 | NULL, NULL, walkera0701_irq_handler, |
215 | PARPORT_DEV_EXCL, w); | 217 | PARPORT_DEV_EXCL, w); |
216 | if (!w->pardevice) | 218 | if (!w->pardevice) { |
217 | goto init_err; | 219 | pr_err("failed to register parport device\n"); |
220 | error = -EIO; | ||
221 | goto err_put_parport; | ||
222 | } | ||
218 | 223 | ||
219 | if (parport_negotiate(w->pardevice->port, IEEE1284_MODE_COMPAT)) | 224 | if (parport_negotiate(w->pardevice->port, IEEE1284_MODE_COMPAT)) { |
220 | goto init_err1; | 225 | pr_err("failed to negotiate parport mode\n"); |
226 | error = -EIO; | ||
227 | goto err_unregister_device; | ||
228 | } | ||
221 | 229 | ||
222 | if (parport_claim(w->pardevice)) | 230 | if (parport_claim(w->pardevice)) { |
223 | goto init_err1; | 231 | pr_err("failed to claim parport\n"); |
232 | error = -EBUSY; | ||
233 | goto err_unregister_device; | ||
234 | } | ||
224 | 235 | ||
225 | hrtimer_init(&w->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); | 236 | hrtimer_init(&w->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); |
226 | w->timer.function = timer_handler; | 237 | w->timer.function = timer_handler; |
227 | 238 | ||
228 | w->input_dev = input_allocate_device(); | 239 | w->input_dev = input_allocate_device(); |
229 | if (!w->input_dev) | 240 | if (!w->input_dev) { |
230 | goto init_err2; | 241 | pr_err("failed to allocate input device\n"); |
242 | error = -ENOMEM; | ||
243 | goto err_release_parport; | ||
244 | } | ||
231 | 245 | ||
232 | input_set_drvdata(w->input_dev, w); | 246 | input_set_drvdata(w->input_dev, w); |
233 | w->input_dev->name = "Walkera WK-0701 TX"; | 247 | w->input_dev->name = "Walkera WK-0701 TX"; |
@@ -252,21 +266,23 @@ static int walkera0701_connect(struct walkera_dev *w, int parport) | |||
252 | input_set_abs_params(w->input_dev, ABS_RUDDER, -512, 512, 0, 0); | 266 | input_set_abs_params(w->input_dev, ABS_RUDDER, -512, 512, 0, 0); |
253 | input_set_abs_params(w->input_dev, ABS_MISC, -512, 512, 0, 0); | 267 | input_set_abs_params(w->input_dev, ABS_MISC, -512, 512, 0, 0); |
254 | 268 | ||
255 | err = input_register_device(w->input_dev); | 269 | error = input_register_device(w->input_dev); |
256 | if (err) | 270 | if (error) { |
257 | goto init_err3; | 271 | pr_err("failed to register input device\n"); |
272 | goto err_free_input_dev; | ||
273 | } | ||
258 | 274 | ||
259 | return 0; | 275 | return 0; |
260 | 276 | ||
261 | init_err3: | 277 | err_free_input_dev: |
262 | input_free_device(w->input_dev); | 278 | input_free_device(w->input_dev); |
263 | init_err2: | 279 | err_release_parport: |
264 | parport_release(w->pardevice); | 280 | parport_release(w->pardevice); |
265 | init_err1: | 281 | err_unregister_device: |
266 | parport_unregister_device(w->pardevice); | 282 | parport_unregister_device(w->pardevice); |
267 | init_err: | 283 | err_put_parport: |
268 | parport_put_port(w->parport); | 284 | parport_put_port(w->parport); |
269 | return err; | 285 | return error; |
270 | } | 286 | } |
271 | 287 | ||
272 | static void walkera0701_disconnect(struct walkera_dev *w) | 288 | static void walkera0701_disconnect(struct walkera_dev *w) |