From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752388AbdATRrJ (ORCPT ); Fri, 20 Jan 2017 12:47:09 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33531 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752138AbdATRrH (ORCPT ); Fri, 20 Jan 2017 12:47:07 -0500 Date: Fri, 20 Jan 2017 09:47:03 -0800 From: Dmitry Torokhov To: Thierry Reding Cc: linux-input@vger.kernel.org, David Lechner , linux-kernel@vger.kernel.org, Frieder Schrempf Subject: Re: [PATCH v2 6/7] Input: pwm-beeper - add optional amplifier regulator Message-ID: <20170120174703.GC4044@dtor-ws> References: <20170119224057.9995-1-dmitry.torokhov@gmail.com> <20170119224057.9995-6-dmitry.torokhov@gmail.com> <20170120101916.GF3824@ulmo.ba.sec> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170120101916.GF3824@ulmo.ba.sec> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 20, 2017 at 11:19:16AM +0100, Thierry Reding wrote: > On Thu, Jan 19, 2017 at 02:40:56PM -0800, Dmitry Torokhov wrote: > [...] > > diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c > > index 9964c46468d3..7b213e0ab06c 100644 > > --- a/drivers/input/misc/pwm-beeper.c > > +++ b/drivers/input/misc/pwm-beeper.c > > @@ -14,6 +14,7 @@ > > */ > > > > #include > > +#include > > #include > > #include > > #include > > @@ -25,30 +26,59 @@ > > struct pwm_beeper { > > struct input_dev *input; > > struct pwm_device *pwm; > > + struct regulator *amplifier; > > struct work_struct work; > > unsigned long period; > > bool suspended; > > + bool amplifier_on; > > Why do you need to track this? I thought regulator_enable() and > regulator_disable() were already reference counted? That us exactly the issue: without the flag userspace application sending: EV_SND/SND_TONE/100 EV_SND/SND_TONE/200 EV_SND/SND_TONE/300 EV_SND/SND_TONE/200 EV_SND/SND_TONE/100 EV_SND/SND_TONE/0 will result in enable count of 4 (and not 0) and regulator will stay on forever. Thanks. -- Dmitry