diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-12-17 01:59:12 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2013-01-21 20:32:01 -0500 |
commit | cb696e7cf261e2af323d49db8839dd1cc34709dd (patch) | |
tree | 5e063f8bb28d04f54685e49bf6f1a093b4fa0d47 /drivers/input/joystick | |
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>
Diffstat (limited to 'drivers/input/joystick')
-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) | |||
183 | { | 183 | { |
184 | struct walkera_dev *w = input_get_drvdata(dev); | 184 | struct walkera_dev *w = input_get_drvdata(dev); |
185 | 185 | ||
186 | if (parport_claim(w->pardevice)) | ||
187 | return -EBUSY; | ||
188 | |||
186 | parport_enable_irq(w->parport); | 189 | parport_enable_irq(w->parport); |
187 | return 0; | 190 | return 0; |
188 | } | 191 | } |
@@ -193,6 +196,8 @@ static void walkera0701_close(struct input_dev *dev) | |||
193 | 196 | ||
194 | parport_disable_irq(w->parport); | 197 | parport_disable_irq(w->parport); |
195 | hrtimer_cancel(&w->timer); | 198 | hrtimer_cancel(&w->timer); |
199 | |||
200 | parport_release(w->pardevice); | ||
196 | } | 201 | } |
197 | 202 | ||
198 | static int walkera0701_connect(struct walkera_dev *w, int parport) | 203 | static int walkera0701_connect(struct walkera_dev *w, int parport) |
@@ -227,12 +232,6 @@ static int walkera0701_connect(struct walkera_dev *w, int parport) | |||
227 | goto err_unregister_device; | 232 | goto err_unregister_device; |
228 | } | 233 | } |
229 | 234 | ||
230 | if (parport_claim(w->pardevice)) { | ||
231 | pr_err("failed to claim parport\n"); | ||
232 | error = -EBUSY; | ||
233 | goto err_unregister_device; | ||
234 | } | ||
235 | |||
236 | hrtimer_init(&w->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); | 235 | hrtimer_init(&w->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); |
237 | w->timer.function = timer_handler; | 236 | w->timer.function = timer_handler; |
238 | 237 | ||
@@ -240,7 +239,7 @@ static int walkera0701_connect(struct walkera_dev *w, int parport) | |||
240 | if (!w->input_dev) { | 239 | if (!w->input_dev) { |
241 | pr_err("failed to allocate input device\n"); | 240 | pr_err("failed to allocate input device\n"); |
242 | error = -ENOMEM; | 241 | error = -ENOMEM; |
243 | goto err_release_parport; | 242 | goto err_unregister_device; |
244 | } | 243 | } |
245 | 244 | ||
246 | input_set_drvdata(w->input_dev, w); | 245 | input_set_drvdata(w->input_dev, w); |
@@ -276,8 +275,6 @@ static int walkera0701_connect(struct walkera_dev *w, int parport) | |||
276 | 275 | ||
277 | err_free_input_dev: | 276 | err_free_input_dev: |
278 | input_free_device(w->input_dev); | 277 | input_free_device(w->input_dev); |
279 | err_release_parport: | ||
280 | parport_release(w->pardevice); | ||
281 | err_unregister_device: | 278 | err_unregister_device: |
282 | parport_unregister_device(w->pardevice); | 279 | parport_unregister_device(w->pardevice); |
283 | err_put_parport: | 280 | err_put_parport: |
@@ -288,7 +285,6 @@ err_put_parport: | |||
288 | static void walkera0701_disconnect(struct walkera_dev *w) | 285 | static void walkera0701_disconnect(struct walkera_dev *w) |
289 | { | 286 | { |
290 | input_unregister_device(w->input_dev); | 287 | input_unregister_device(w->input_dev); |
291 | parport_release(w->pardevice); | ||
292 | parport_unregister_device(w->pardevice); | 288 | parport_unregister_device(w->pardevice); |
293 | parport_put_port(w->parport); | 289 | parport_put_port(w->parport); |
294 | } | 290 | } |