diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-12-16 22:59:12 -0800 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2013-01-21 17:32:01 -0800 |
commit | cb696e7cf261e2af323d49db8839dd1cc34709dd (patch) | |
tree | 5e063f8bb28d04f54685e49bf6f1a093b4fa0d47 | |
parent | ea05ae071ed0f360c6002d7b5107e0dad724d511 (diff) |
Input: walkera0701 - claim parport when opening the device
Postpone claiming the port until the device is opened, instead of doing
that when the driver is loaded.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r-- | drivers/input/joystick/walkera0701.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/drivers/input/joystick/walkera0701.c b/drivers/input/joystick/walkera0701.c index b86134c0b299..b76ac580703c 100644 --- a/drivers/input/joystick/walkera0701.c +++ b/drivers/input/joystick/walkera0701.c @@ -183,6 +183,9 @@ static int walkera0701_open(struct input_dev *dev) { struct walkera_dev *w = input_get_drvdata(dev); + if (parport_claim(w->pardevice)) + return -EBUSY; + parport_enable_irq(w->parport); return 0; } @@ -193,6 +196,8 @@ static void walkera0701_close(struct input_dev *dev) parport_disable_irq(w->parport); hrtimer_cancel(&w->timer); + + parport_release(w->pardevice); } static int walkera0701_connect(struct walkera_dev *w, int parport) @@ -227,12 +232,6 @@ static int walkera0701_connect(struct walkera_dev *w, int parport) goto err_unregister_device; } - if (parport_claim(w->pardevice)) { - pr_err("failed to claim parport\n"); - error = -EBUSY; - goto err_unregister_device; - } - hrtimer_init(&w->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); w->timer.function = timer_handler; @@ -240,7 +239,7 @@ static int walkera0701_connect(struct walkera_dev *w, int parport) if (!w->input_dev) { pr_err("failed to allocate input device\n"); error = -ENOMEM; - goto err_release_parport; + goto err_unregister_device; } input_set_drvdata(w->input_dev, w); @@ -276,8 +275,6 @@ static int walkera0701_connect(struct walkera_dev *w, int parport) err_free_input_dev: input_free_device(w->input_dev); -err_release_parport: - parport_release(w->pardevice); err_unregister_device: parport_unregister_device(w->pardevice); err_put_parport: @@ -288,7 +285,6 @@ err_put_parport: static void walkera0701_disconnect(struct walkera_dev *w) { input_unregister_device(w->input_dev); - parport_release(w->pardevice); parport_unregister_device(w->pardevice); parport_put_port(w->parport); } |