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.0 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,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 2B5F0C433E0 for ; Thu, 30 Jul 2020 06:21:32 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E59352075F for ; Thu, 30 Jul 2020 06:21:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="EvbxV3F6"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gxENsRRj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E59352075F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zxkMRQtlMMPpb7gQp+h5+PXtnLDZr6rHfmLMc0XqXSE=; b=EvbxV3F6SuV3sCjekD879DLNe 9M4noZw1aoJ2iGN/fyu7L3JuFZQaKJxyZ4NNlHz5bAhdIkDVVDaxQ8exhMnHJScmrTuDKGcAwJfnU ebyHpPobv9HMiZ91J0FLeS1ElUidC4ClrBY+iZww2bldSyGh5f3NbdGVE7b3+202WgyQlms4ePsM+ g/lWimPO5VnPuTi6O+k/mOxV0eWC+1KiL+eXItzPpbayvOfk5nLExFWc17ZGQgtXWGgGe3BusiXyV vIv5k0IaHYR7aXcEh2o6llP6p/iCccti/PxN+K9oDWPykllLnX4K0erH9tJ4nds0V0nI+wOHDMHMj 74I1/FDrQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k11uw-0001J1-RM; Thu, 30 Jul 2020 06:19:50 +0000 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k11uu-0001IJ-Fp for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2020 06:19:49 +0000 Received: by mail-pj1-x1043.google.com with SMTP id c6so3345554pje.1 for ; Wed, 29 Jul 2020 23:19:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=7sLH0f+gva54AANCFXOi4hfUciaEwWDTPWFMS6fyuNQ=; b=gxENsRRjmRt4hYykIkMYfhy7oEjiNxJMHjQJ2hpjtanoK/gTdGAYgVMW9/pfAGsXIm 7ywfiC4aIQA9HS6p+4y1zst7Gcp6rC7bufK0aNja47Gbk2yO9iSxn0WdaumvbDJYeeKW m764Hmz3bwEdrXUXk7ZmbWH2CcoF4zlCeAWvt+mk0DEnz67AXBHAFkEojdvOriBnXzZH oB93FEKJ2dzP+9WTPHnl6H/mrvH2KgSjLWAvFFaJaKAzk1e/y1BEsgeDiOb7UkbV1OBD U1YRCKP1byhPkOruzCTBSo7EK75Mfa0atDXjOiJ5LAt652wOGgGZAUp+lg0ux2DCCNMH Rz8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=7sLH0f+gva54AANCFXOi4hfUciaEwWDTPWFMS6fyuNQ=; b=sE9z40LDZldH7BMjwXWTpSSBS7CSFnCFLLFTjRboMgZNMWm429Bx8TRHeELf6ZjJ5f BLYNRipZPAtOR3RoPFfmRwGy34mwwAQv5HfV7ihvqh8uH4Ms6my/BLK+vyfU1efTQu53 e9fg5NZWVYgLDz0DQEbs1u0boeLi9PylucrrFCZCgxmkpygUxGrxGC+av9T3e1ccEpid Ec7F4HNwgEDh72oppP2UVZGh1gUBbTNXnjQzkzCFnKpDwEtJb+gDyYFryiQind+2ka1C ViCoBi20PKGAvYaVgWRawq6Fr4ZJyiQQVrKYz+nFeH4+4VdCYXGclEZ454MwdYzs80P0 120A== X-Gm-Message-State: AOAM530hiu9v7gPolf1hTMVdozR91Aof5uGS3gy8KdapAtLaIruXNu2k dVaP2YbePzZt4NItDozXJEU= X-Google-Smtp-Source: ABdhPJwGcoK2hmjgbxI7ge21+8vA+2hytsqnAprehXpM2qsg8Hsp+TRZ7lIZ9ggp8fv0ddu5Fv2XWg== X-Received: by 2002:a17:90a:bc45:: with SMTP id t5mr4706364pjv.139.1596089983001; Wed, 29 Jul 2020 23:19:43 -0700 (PDT) Received: from dtor-ws ([2620:15c:202:201:a6ae:11ff:fe11:fcc3]) by smtp.gmail.com with ESMTPSA id q6sm4540275pfg.76.2020.07.29.23.19.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jul 2020 23:19:42 -0700 (PDT) Date: Wed, 29 Jul 2020 23:19:39 -0700 From: Dmitry Torokhov To: Ondrej Jirman Subject: Re: [PATCH v4 2/4] input: gpio-vibra: Allow to use vcc-supply alone to control the vibrator Message-ID: <20200730061939.GF1665100@dtor-ws> References: <20200714102303.3007896-1-megous@megous.com> <20200714102303.3007896-3-megous@megous.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200714102303.3007896-3-megous@megous.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200730_021948_547891_F14F95D6 X-CRM114-Status: GOOD ( 23.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Chen-Yu Tsai , Maxime Ripard , linux-kernel@vger.kernel.org, Luca Weiss , linux-sunxi@googlegroups.com, Rob Herring , Tomas Novotny , linux-input@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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). > 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel