Received: by 10.223.185.116 with SMTP id b49csp5039495wrg; Wed, 7 Mar 2018 05:30:47 -0800 (PST) X-Google-Smtp-Source: AG47ELsVJ43y3bpexb91zbvXX2HoF5p0/UZRsC+jNY/pnKN9lK/Mrq0MyqLwkh0ggi3Q3gG6CLXE X-Received: by 2002:a17:902:8a89:: with SMTP id p9-v6mr20286748plo.379.1520429447073; Wed, 07 Mar 2018 05:30:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520429447; cv=none; d=google.com; s=arc-20160816; b=movH1ucrcqevKbYoFeJwQrG9P8is1qI4a7M3gdka1pjQ35EZT7fK3Ytx2VwmnX9VJ9 2siuJCE4jf3SKVE3o6uHy1ufyjr6P1v1+gEthWOo1SsfNXX2TjLZr7IJeS46P9W0lKi1 wQ+QMXpwxFD88DBvjD61LnPAnUWP+Y7fNxkKfrCjJmcg7C5Spa0yauLfv9RTpLMZgXcW NhoYHy8e49qVh39aJBX5QhfAXZq5BUTYx9tYPyt2eNHwywa4Hl5yxGbeUX/ymOFPcMDG ZbdJAL/5bVjP9kGZwk/GcNz/47/HNHfc5HOMtanUjph4EdJmPOA6LJSE8zNLcXON9DXE qAAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=Alk6ZFUMoqfzLHXSEAkE07hpBDB1M8nbIzUxRyMWTHY=; b=DILFqKuvImIAHtydaOJk3aDfo1xhzmibTNLPM+sVLcB3m0nCajvTJZhr518qcoBYFy Q648pDKZpKLRmbHoK2hshfGGluCv3nq2BWDFC9YtJc2oHpgPkBq8V8vIWpN3llp0+PjP IaU//ALZPIGA9P5/vUybExN1gKO8SY4vZuv+nalxV1U9FyimeCG+c3k9laAwUHET73dh zv8bn+11o8QVMyTNROpI1uybDv37q+S2J8jaFHcgxIRh46NQid86nS+afo3u/a6M+xyO /F9xq7inOjc0GW5+euL1dLiyXulgjcMStnZhwE0U44T95eu71x4YbnKUGeeDRHKkAQ/x G/kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bfANIAKb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5si11335494pgg.286.2018.03.07.05.30.31; Wed, 07 Mar 2018 05:30:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bfANIAKb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933310AbeCGN2V (ORCPT + 99 others); Wed, 7 Mar 2018 08:28:21 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36118 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753168AbeCGN2Q (ORCPT ); Wed, 7 Mar 2018 08:28:16 -0500 Received: by mail-wm0-f68.google.com with SMTP id 188so4709607wme.1 for ; Wed, 07 Mar 2018 05:28:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=Alk6ZFUMoqfzLHXSEAkE07hpBDB1M8nbIzUxRyMWTHY=; b=bfANIAKbgdkk/VrtcwafWavqhFhzPkemIVTi7oIIg1l3NZ8y+RQBT7eZWk73lYvn4D 3/MrB1c91b3sykJIZbf7ugPte+9lx0AMYw2vNdwqdne+W4iTw7Yfps+ZvGb8pr15uXOd UP28Q/5zUeR5tqEntO9VjVv2Tu0+9taZteDH8= 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:content-transfer-encoding :in-reply-to:user-agent; bh=Alk6ZFUMoqfzLHXSEAkE07hpBDB1M8nbIzUxRyMWTHY=; b=o2I+Xa9Y3WaFRNWnryzcsRgpvZqff9mg4gj09+aV0sgSE2JAO79Zllw3Xma4QTrTe/ 3ZiIs8WdLWIpPb1dExjNZJjgTzS+DoUccjZjFEziXsgcBhv5sncLszd+cmKvoJFqpRlX VxHeqseJDdENHxw4z0y72NaF5b8bPba93NlPrHdYO3fNxzMAv1NeTvuEqlRVfkZhiHOi udz3p/re072g9Jo4pxqpcbThxVQw/KU3CDgSK6jOS/6EEjloPNqsVYWsjQOeZhM6eEZZ XIQql48l6kgCuFvTo6jD6a9SzS9aAbntSF/T7RKZEkWQGa1tQiIMj4r2y5qHBynyLi9g fqWg== X-Gm-Message-State: AElRT7FMHTyrYwNC5v/5O3enCsaXHmpjBtmrd5qQ8Mi87avqNtuWTCRb yeds/mcQPfk8BDbFmO+hHTTBbQ== X-Received: by 10.28.234.8 with SMTP id i8mr15380048wmh.44.1520429294974; Wed, 07 Mar 2018 05:28:14 -0800 (PST) Received: from dell ([2.27.35.218]) by smtp.gmail.com with ESMTPSA id j6sm2674774wmg.14.2018.03.07.05.28.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 07 Mar 2018 05:28:14 -0800 (PST) Date: Wed, 7 Mar 2018 13:28:12 +0000 From: Lee Jones To: Charles Keepax Cc: robh+dt@kernel.org, mark.rutland@arm.com, linus.walleij@linaro.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, patches@opensource.cirrus.com Subject: Re: [PATCH v3 1/2] mfd: arizona: Update reset pin to use GPIOD Message-ID: <20180307132812.r5epcs26clpnh72t@dell> References: <20180220163540.6704-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180220163540.6704-1-ckeepax@opensource.cirrus.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 20 Feb 2018, Charles Keepax wrote: > Now GPIOD has support for both pdata systems and for non-standard DT > bindings the Arizona reset GPIO can be converted to use it. > > Signed-off-by: Charles Keepax > --- > > Changes since v2: > - Kept null check in arizona_enable_reset, although > gpiod_set_value_cansleep does its own null check it will also issue > a fat WARN we don't want if gpiolib is not built in. > - Added a check for ENOSYS in arizona_of_get_core_pdata, just to > silence the extra error that would be printed here if gpiolib is not > built in. > > Thanks, > Charles > > drivers/mfd/arizona-core.c | 50 ++++++++++++++++++++++++++------------- > include/linux/mfd/arizona/pdata.h | 3 ++- > 2 files changed, 36 insertions(+), 17 deletions(-) > > diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c > index 77875250abe5..9558c4d9c8ca 100644 > --- a/drivers/mfd/arizona-core.c > +++ b/drivers/mfd/arizona-core.c > @@ -279,7 +279,7 @@ static int arizona_wait_for_boot(struct arizona *arizona) > static inline void arizona_enable_reset(struct arizona *arizona) > { > if (arizona->pdata.reset) > - gpio_set_value_cansleep(arizona->pdata.reset, 0); > + gpiod_set_value_cansleep(arizona->pdata.reset, 0); > } > > static void arizona_disable_reset(struct arizona *arizona) > @@ -295,7 +295,7 @@ static void arizona_disable_reset(struct arizona *arizona) > break; > } > > - gpio_set_value_cansleep(arizona->pdata.reset, 1); > + gpiod_set_value_cansleep(arizona->pdata.reset, 1); > usleep_range(1000, 5000); > } > } > @@ -799,14 +799,26 @@ static int arizona_of_get_core_pdata(struct arizona *arizona) > struct arizona_pdata *pdata = &arizona->pdata; > int ret, i; > > - pdata->reset = of_get_named_gpio(arizona->dev->of_node, "wlf,reset", 0); > - if (pdata->reset == -EPROBE_DEFER) { > - return pdata->reset; > - } else if (pdata->reset < 0) { > - dev_err(arizona->dev, "Reset GPIO missing/malformed: %d\n", > - pdata->reset); > + pdata->reset = devm_gpiod_get_from_of_node(arizona->dev, > + arizona->dev->of_node, > + "wlf,reset", 0, > + GPIOD_OUT_LOW, > + "arizona /RESET"); > + if (IS_ERR(pdata->reset)) { > + ret = PTR_ERR(pdata->reset); > + switch (ret) { > + case -ENOENT: > + case -ENOSYS: > + break; > + case -EPROBE_DEFER: > + return ret; > + default: > + dev_err(arizona->dev, "Reset GPIO malformed: %d\n", > + ret); > + break; > + } I haven't seen a switch statement used in the error handling path before. There is probably good reason for that. What is the 'default' case? -EINVAL? > - pdata->reset = 0; > + pdata->reset = NULL; > } > > ret = of_property_read_u32_array(arizona->dev->of_node, > @@ -1050,14 +1062,20 @@ int arizona_dev_init(struct arizona *arizona) > goto err_early; > } > > - if (arizona->pdata.reset) { > + if (!arizona->pdata.reset) { > /* Start out with /RESET low to put the chip into reset */ > - ret = devm_gpio_request_one(arizona->dev, arizona->pdata.reset, > - GPIOF_DIR_OUT | GPIOF_INIT_LOW, > - "arizona /RESET"); > - if (ret != 0) { > - dev_err(dev, "Failed to request /RESET: %d\n", ret); > - goto err_dcvdd; > + arizona->pdata.reset = devm_gpiod_get(arizona->dev, "reset", > + GPIOD_OUT_LOW); > + if (IS_ERR(arizona->pdata.reset)) { > + ret = PTR_ERR(arizona->pdata.reset); > + if (ret == -EPROBE_DEFER) > + goto err_dcvdd; > + else > + dev_err(arizona->dev, > + "Reset GPIO missing/malformed: %d\n", > + ret); You don't need the else. arizona->pdata.reset = devm_gpiod_get(arizona->dev, "reset", GPIOD_OUT_LOW); ret = PTR_ERR(arizona->pdata.reset); if (ret == -EPROBE_DEFER) goto err_dcvdd; if (ret) { dev_err(arizona->dev, "Reset GPIO missing/malformed: %d\n", ret); arizona->pdata.reset = NULL; } > + arizona->pdata.reset = NULL; > } > } > > diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h > index f72dc53848d7..0013075d4cda 100644 > --- a/include/linux/mfd/arizona/pdata.h > +++ b/include/linux/mfd/arizona/pdata.h > @@ -56,6 +56,7 @@ > #define ARIZONA_MAX_PDM_SPK 2 > > struct regulator_init_data; > +struct gpio_desc; > > struct arizona_micbias { > int mV; /** Regulated voltage */ > @@ -77,7 +78,7 @@ struct arizona_micd_range { > }; > > struct arizona_pdata { > - int reset; /** GPIO controlling /RESET, if any */ > + struct gpio_desc *reset; /** GPIO controlling /RESET, if any */ > > /** Regulator configuration for MICVDD */ > struct arizona_micsupp_pdata micvdd; I know it doesn't have much to do with this patch, but it's probably better to use a Kerneldoc header for this struct. -- Lee Jones Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog