diff options
author | Martin Kepplinger <martink@posteo.de> | 2016-07-19 14:25:00 -0700 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2016-07-19 14:33:05 -0700 |
commit | 9d3bef0be57d06fea442f17c95011f3530ff3ff8 (patch) | |
tree | c380c19cdc8a9b24f8b35bc77181db48480e87d1 /drivers/input | |
parent | 168c1398e0660eafd70597a06cdd68c179e8f30b (diff) | |
download | linux-9d3bef0be57d06fea442f17c95011f3530ff3ff8.tar.bz2 |
Input: pegasus_notetaker - fix usb_autopm calls to be balanced
We should only "put" the interface if submitting URB or setting tablet mode
in pegasus_open() fails, otherwise leave it to pegasus_close().
Signed-off-by: Martin Kepplinger <martink@posteo.de>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/tablet/pegasus_notetaker.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/drivers/input/tablet/pegasus_notetaker.c b/drivers/input/tablet/pegasus_notetaker.c index 78dbf39a6fc0..ef5fd31abaef 100644 --- a/drivers/input/tablet/pegasus_notetaker.c +++ b/drivers/input/tablet/pegasus_notetaker.c @@ -209,34 +209,39 @@ static void pegasus_init(struct work_struct *work) static int pegasus_open(struct input_dev *dev) { struct pegasus *pegasus = input_get_drvdata(dev); - int retval; + int error; - retval = usb_autopm_get_interface(pegasus->intf); - if (retval) - return retval; + error = usb_autopm_get_interface(pegasus->intf); + if (error) + return error; pegasus->irq->dev = pegasus->usbdev; - if (usb_submit_urb(pegasus->irq, GFP_KERNEL)) - retval = -EIO; + if (usb_submit_urb(pegasus->irq, GFP_KERNEL)) { + error = -EIO; + goto err_autopm_put; + } + + error = pegasus_set_mode(pegasus, PEN_MODE_XY, NOTETAKER_LED_MOUSE); + if (error) + goto err_kill_urb; - retval = pegasus_set_mode(pegasus, PEN_MODE_XY, NOTETAKER_LED_MOUSE); + return 0; +err_kill_urb: + usb_kill_urb(pegasus->irq); + cancel_work_sync(&pegasus->init); +err_autopm_put: usb_autopm_put_interface(pegasus->intf); - - return retval; + return error; } static void pegasus_close(struct input_dev *dev) { struct pegasus *pegasus = input_get_drvdata(dev); - int autopm_error; - autopm_error = usb_autopm_get_interface(pegasus->intf); usb_kill_urb(pegasus->irq); cancel_work_sync(&pegasus->init); - - if (!autopm_error) - usb_autopm_put_interface(pegasus->intf); + usb_autopm_put_interface(pegasus->intf); } static int pegasus_probe(struct usb_interface *intf, |