Devicetree
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Charles Keepax <ckeepax@opensource.cirrus.com>
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
Date: Wed, 7 Mar 2018 13:28:12 +0000	[thread overview]
Message-ID: <20180307132812.r5epcs26clpnh72t@dell> (raw)
In-Reply-To: <20180220163540.6704-1-ckeepax@opensource.cirrus.com>

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 <ckeepax@opensource.cirrus.com>
> ---
> 
> 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

  parent reply	other threads:[~2018-03-07 13:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-20 16:35 [PATCH v3 1/2] mfd: arizona: Update reset pin to use GPIOD Charles Keepax
2018-02-20 16:35 ` [PATCH v3 2/2] mfd: arizona: Update DT doc to support more standard reset binding Charles Keepax
2018-03-07 15:03   ` Lee Jones
2018-02-21  1:43 ` [PATCH v3 1/2] mfd: arizona: Update reset pin to use GPIOD kbuild test robot
2018-03-07 13:28 ` Lee Jones [this message]
2018-03-07 14:15   ` Charles Keepax
2018-03-07 16:25     ` Lee Jones
2018-03-07 17:53       ` Charles Keepax
2018-03-07 14:24 ` Fabio Estevam
2018-03-07 14:55   ` Charles Keepax
2018-03-07 15:53     ` Fabio Estevam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180307132812.r5epcs26clpnh72t@dell \
    --to=lee.jones@linaro.org \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=patches@opensource.cirrus.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox