From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59012C433E0 for ; Thu, 30 Jul 2020 09:18:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3741820672 for ; Thu, 30 Jul 2020 09:18:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=megous.com header.i=@megous.com header.b="AL5BskQR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728825AbgG3JSQ (ORCPT ); Thu, 30 Jul 2020 05:18:16 -0400 Received: from vps.xff.cz ([195.181.215.36]:51866 "EHLO vps.xff.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726819AbgG3JSQ (ORCPT ); Thu, 30 Jul 2020 05:18:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megous.com; s=mail; t=1596100692; bh=HOOQYK09295xgAy28jQQY6G9ActTahF44D4teInPcZc=; h=Date:From:To:Cc:Subject:References:X-My-GPG-KeyId:From; b=AL5BskQRTKQ2jtUjuXN5AlYRTEEoD9Yu79BpEqCpouulQKMRA9mLiMf2M11wyBQHx VO2AnkKvpaCVGtLMT5+sLy0cxbcQPLXiMwuT00skkrIJ8UGZ9Ig02gK+stqpF4/ZYK fxWKL7fR7MlXKcjEwTLEFa155Ph5W4PSBUtOQQDE= Date: Thu, 30 Jul 2020 11:18:12 +0200 From: =?utf-8?Q?Ond=C5=99ej?= Jirman To: Dmitry Torokhov Cc: linux-sunxi@googlegroups.com, Rob Herring , Mark Rutland , Maxime Ripard , Chen-Yu Tsai , Luca Weiss , Tomas Novotny , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v4 2/4] input: gpio-vibra: Allow to use vcc-supply alone to control the vibrator Message-ID: <20200730091812.7sia7w3waz2jj62a@core.my.home> Mail-Followup-To: =?utf-8?Q?Ond=C5=99ej?= Jirman , Dmitry Torokhov , linux-sunxi@googlegroups.com, Rob Herring , Mark Rutland , Maxime Ripard , Chen-Yu Tsai , Luca Weiss , Tomas Novotny , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20200714102303.3007896-1-megous@megous.com> <20200714102303.3007896-3-megous@megous.com> <20200730061939.GF1665100@dtor-ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200730061939.GF1665100@dtor-ws> X-My-GPG-KeyId: EBFBDDE11FB918D44D1F56C1F9F0A873BE9777ED Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Hello Dmitry, thanks for looking into the patch. :) On Wed, Jul 29, 2020 at 11:19:39PM -0700, Dmitry Torokhov wrote: > Hi Ondrej, > > On Tue, Jul 14, 2020 at 12:23:01PM +0200, Ondrej Jirman wrote: > > Make enable-gpio optional to allow using this driver with boards that > > have vibrator connected to a power supply without intermediate gpio > > based enable circuitry. > > > > Also avoid a case where neither regulator nor enable gpio is specified, > > and bail out in probe in such a case. > > > > Signed-off-by: Ondrej Jirman > > --- > > drivers/input/misc/gpio-vibra.c | 14 ++++++++++---- > > 1 file changed, 10 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/input/misc/gpio-vibra.c b/drivers/input/misc/gpio-vibra.c > > index f79f75595dd7..b3bb7e61ed1d 100644 > > --- a/drivers/input/misc/gpio-vibra.c > > +++ b/drivers/input/misc/gpio-vibra.c > > @@ -39,7 +39,7 @@ static int gpio_vibrator_start(struct gpio_vibrator *vibrator) > > struct device *pdev = vibrator->input->dev.parent; > > int err; > > > > - if (!vibrator->vcc_on) { > > + if (vibrator->vcc && !vibrator->vcc_on) { > > err = regulator_enable(vibrator->vcc); > > if (err) { > > dev_err(pdev, "failed to enable regulator: %d\n", err); > > @@ -57,7 +57,7 @@ static void gpio_vibrator_stop(struct gpio_vibrator *vibrator) > > { > > gpiod_set_value_cansleep(vibrator->gpio, 0); > > > > - if (vibrator->vcc_on) { > > + if (vibrator->vcc && vibrator->vcc_on) { > > regulator_disable(vibrator->vcc); > > vibrator->vcc_on = false; > > } > > @@ -112,7 +112,7 @@ static int gpio_vibrator_probe(struct platform_device *pdev) > > if (!vibrator->input) > > return -ENOMEM; > > > > - vibrator->vcc = devm_regulator_get(&pdev->dev, "vcc"); > > + vibrator->vcc = devm_regulator_get_optional(&pdev->dev, "vcc"); > > I know it is very surprising, but regulator_get_optional does not return > NULL when regulator is not present, but rather ERR_PTR(-ENODEV). You > need to replace it with NULL in the branch below, or change conditions > to !IS_ERR(virbrator->vcc) (and still handle -ENODEV in the branch > below). Oops, I'll fix that in the next revision. regards, o. > > err = PTR_ERR_OR_ZERO(vibrator->vcc); > > if (err) { > > if (err != -EPROBE_DEFER) > > @@ -121,7 +121,8 @@ static int gpio_vibrator_probe(struct platform_device *pdev) > > return err; > > } > > > > - vibrator->gpio = devm_gpiod_get(&pdev->dev, "enable", GPIOD_OUT_LOW); > > + vibrator->gpio = devm_gpiod_get_optional(&pdev->dev, "enable", > > + GPIOD_OUT_LOW); > > err = PTR_ERR_OR_ZERO(vibrator->gpio); > > if (err) { > > if (err != -EPROBE_DEFER) > > @@ -130,6 +131,11 @@ static int gpio_vibrator_probe(struct platform_device *pdev) > > return err; > > } > > > > + if (!vibrator->vcc && !vibrator->gpio) { > > + dev_err(&pdev->dev, "Neither gpio nor regulator provided\n"); > > + return -EINVAL; > > + } > > + > > INIT_WORK(&vibrator->play_work, gpio_vibrator_play_work); > > > > vibrator->input->name = "gpio-vibrator"; > > -- > > 2.27.0 > > > > Thanks. > > -- > Dmitry