Skip to content

Commit

Permalink
Input: walkera0701 - claim parport when opening the device
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dmitry Torokhov committed Jan 22, 2013
1 parent ea05ae0 commit cb696e7
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions drivers/input/joystick/walkera0701.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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)
Expand Down Expand Up @@ -227,20 +232,14 @@ 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;

w->input_dev = input_allocate_device();
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);
Expand Down Expand Up @@ -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:
Expand All @@ -288,7 +285,6 @@ static int walkera0701_connect(struct walkera_dev *w, int 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);
}
Expand Down

0 comments on commit cb696e7

Please sign in to comment.