Re: [PATCH] input: Fix USB autosuspend on bcm5974
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: 2011-10-06 22:38:41
Hi Matthew, On Thu, Oct 06, 2011 at 05:36:37PM -0400, Matthew Garrett wrote:
The bcm5974 code takes a USB autosuspend reference on device open but only releases it if there's an error. Repeated opens will bump the count,
No, there won't be repeated opens as input core will not issue another open unless everyone closes the device first (and then bcm5974_close will drop the reference that is being held).
which is clearly wrong. It's also unnecessary - the only part of the driver operation that is incompatible with autosuspend is the initial setup, and after that the device generates appropriate remote wakeups. Making the unreference unconditional fixes this.
... and makes counter unbalanced on close. If we change bcm5974_open() as you are suggesting we need to adjust bcm5974_close() accordingly.
quoted hunk ↗ jump to hunk
Signed-off-by: Matthew Garrett <redacted> --- drivers/input/mouse/bcm5974.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c index 5ec617e..38d0286 100644 --- a/drivers/input/mouse/bcm5974.c +++ b/drivers/input/mouse/bcm5974.c@@ -764,8 +764,7 @@ static int bcm5974_open(struct input_dev *input) mutex_unlock(&dev->pm_mutex); - if (error) - usb_autopm_put_interface(dev->intf); + usb_autopm_put_interface(dev->intf); return error; }
Thanks. -- Dmitry