All of lore.kernel.org
 help / color / mirror / Atom feed
From: zyw@rock-chips.com (Chris Zhong)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/4] pinctrl: rockchip: Don't call pinctrl_gpio_direction_output() in pin_config_set()
Date: Mon, 20 Oct 2014 17:18:45 -0700	[thread overview]
Message-ID: <5445A665.9010905@rock-chips.com> (raw)
In-Reply-To: <1413847670-12245-2-git-send-email-dianders@chromium.org>


On 10/20/2014 04:27 PM, Doug Anderson wrote:
> The Rockchip pinctrl driver was calling
> rockchip_gpio_direction_output() in the pin_config_set() callback.
> This was just a shortcut for:
> * rockchip_gpio_set()
> * pinctrl_gpio_direction_output()
>
> Unfortunately it's not so good to call pinctrl_gpio_direction_output()
> from pin_config_set().  Specifically when initting hogs you'll get an
> error.
>
> Let's refactor a little so we can call
> _rockchip_pmx_gpio_set_direction() directly.
>
> Signed-off-by: Doug Anderson <dianders@chromium.org>
> ---
>   drivers/pinctrl/pinctrl-rockchip.c | 42 +++++++++++++++++++++++---------------
>   1 file changed, 26 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
> index 230d8f3..65efb88 100644
> --- a/drivers/pinctrl/pinctrl-rockchip.c
> +++ b/drivers/pinctrl/pinctrl-rockchip.c
> @@ -856,22 +856,16 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector,
>    * leads to this function call (via the pinctrl_gpio_direction_{input|output}()
>    * function called from the gpiolib interface).
>    */
> -static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
> -					      struct pinctrl_gpio_range *range,
> -					      unsigned offset, bool input)
> +static int _rockchip_pmx_gpio_set_direction(struct gpio_chip *gc,
> +					    unsigned offset, bool input)
>   {
> -	struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
>   	struct rockchip_pin_bank *bank;
> -	struct gpio_chip *chip;
>   	int pin, ret;
> +	unsigned long flags;
>   	u32 data;
>   
> -	chip = range->gc;
> -	bank = gc_to_pin_bank(chip);
> -	pin = offset - chip->base;
> -
> -	dev_dbg(info->dev, "gpio_direction for pin %u as %s-%d to %s\n",
> -		 offset, range->name, pin, input ? "input" : "output");
> +	bank = gc_to_pin_bank(gc);
> +	pin = offset - gc->base;
>   
>   	ret = rockchip_set_mux(bank, pin, RK_FUNC_GPIO);
>   	if (ret < 0)
> @@ -888,6 +882,22 @@ static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
>   	return 0;
>   }
>   
> +static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
> +					      struct pinctrl_gpio_range *range,
> +					      unsigned offset, bool input)
> +{
> +	struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
> +	struct gpio_chip *chip;
> +	int pin;
> +
> +	chip = range->gc;
> +	pin = offset - chip->base;
> +	dev_dbg(info->dev, "gpio_direction for pin %u as %s-%d to %s\n",
> +		 offset, range->name, pin, input ? "input" : "output");
> +
> +	return _rockchip_pmx_gpio_set_direction(range->gc, offset, input);
> +}
> +
>   static const struct pinmux_ops rockchip_pmx_ops = {
>   	.get_functions_count	= rockchip_pmx_get_funcs_count,
>   	.get_function_name	= rockchip_pmx_get_func_name,
> @@ -917,8 +927,7 @@ static bool rockchip_pinconf_pull_valid(struct rockchip_pin_ctrl *ctrl,
>   	return false;
>   }
>   
> -static int rockchip_gpio_direction_output(struct gpio_chip *gc,
> -					  unsigned offset, int value);
> +static void rockchip_gpio_set(struct gpio_chip *gc, unsigned offset, int value);
>   static int rockchip_gpio_get(struct gpio_chip *gc, unsigned offset);
>   
>   /* set the pin config settings for a specified pin */
> @@ -959,9 +968,10 @@ static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
>   				return rc;
>   			break;
>   		case PIN_CONFIG_OUTPUT:
> -			rc = rockchip_gpio_direction_output(&bank->gpio_chip,
> -							    pin - bank->pin_base,
> -							    arg);
> +			rockchip_gpio_set(&bank->gpio_chip,
> +					  pin - bank->pin_base, arg);
> +			rc = _rockchip_pmx_gpio_set_direction(&bank->gpio_chip,
> +					  pin - bank->pin_base, false);
>   			if (rc)
>   				return rc;
>   			break;
Tested-by: Chris Zhong <zyw@rock-chips.com>

WARNING: multiple messages have this Message-ID (diff)
From: Chris Zhong <zyw@rock-chips.com>
To: Doug Anderson <dianders@chromium.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Heiko Stuebner <heiko@sntech.de>
Cc: Sonny Rao <sonnyrao@chromium.org>,
	linux-rockchip@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] pinctrl: rockchip: Don't call pinctrl_gpio_direction_output() in pin_config_set()
Date: Mon, 20 Oct 2014 17:18:45 -0700	[thread overview]
Message-ID: <5445A665.9010905@rock-chips.com> (raw)
In-Reply-To: <1413847670-12245-2-git-send-email-dianders@chromium.org>


On 10/20/2014 04:27 PM, Doug Anderson wrote:
> The Rockchip pinctrl driver was calling
> rockchip_gpio_direction_output() in the pin_config_set() callback.
> This was just a shortcut for:
> * rockchip_gpio_set()
> * pinctrl_gpio_direction_output()
>
> Unfortunately it's not so good to call pinctrl_gpio_direction_output()
> from pin_config_set().  Specifically when initting hogs you'll get an
> error.
>
> Let's refactor a little so we can call
> _rockchip_pmx_gpio_set_direction() directly.
>
> Signed-off-by: Doug Anderson <dianders@chromium.org>
> ---
>   drivers/pinctrl/pinctrl-rockchip.c | 42 +++++++++++++++++++++++---------------
>   1 file changed, 26 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
> index 230d8f3..65efb88 100644
> --- a/drivers/pinctrl/pinctrl-rockchip.c
> +++ b/drivers/pinctrl/pinctrl-rockchip.c
> @@ -856,22 +856,16 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector,
>    * leads to this function call (via the pinctrl_gpio_direction_{input|output}()
>    * function called from the gpiolib interface).
>    */
> -static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
> -					      struct pinctrl_gpio_range *range,
> -					      unsigned offset, bool input)
> +static int _rockchip_pmx_gpio_set_direction(struct gpio_chip *gc,
> +					    unsigned offset, bool input)
>   {
> -	struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
>   	struct rockchip_pin_bank *bank;
> -	struct gpio_chip *chip;
>   	int pin, ret;
> +	unsigned long flags;
>   	u32 data;
>   
> -	chip = range->gc;
> -	bank = gc_to_pin_bank(chip);
> -	pin = offset - chip->base;
> -
> -	dev_dbg(info->dev, "gpio_direction for pin %u as %s-%d to %s\n",
> -		 offset, range->name, pin, input ? "input" : "output");
> +	bank = gc_to_pin_bank(gc);
> +	pin = offset - gc->base;
>   
>   	ret = rockchip_set_mux(bank, pin, RK_FUNC_GPIO);
>   	if (ret < 0)
> @@ -888,6 +882,22 @@ static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
>   	return 0;
>   }
>   
> +static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
> +					      struct pinctrl_gpio_range *range,
> +					      unsigned offset, bool input)
> +{
> +	struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
> +	struct gpio_chip *chip;
> +	int pin;
> +
> +	chip = range->gc;
> +	pin = offset - chip->base;
> +	dev_dbg(info->dev, "gpio_direction for pin %u as %s-%d to %s\n",
> +		 offset, range->name, pin, input ? "input" : "output");
> +
> +	return _rockchip_pmx_gpio_set_direction(range->gc, offset, input);
> +}
> +
>   static const struct pinmux_ops rockchip_pmx_ops = {
>   	.get_functions_count	= rockchip_pmx_get_funcs_count,
>   	.get_function_name	= rockchip_pmx_get_func_name,
> @@ -917,8 +927,7 @@ static bool rockchip_pinconf_pull_valid(struct rockchip_pin_ctrl *ctrl,
>   	return false;
>   }
>   
> -static int rockchip_gpio_direction_output(struct gpio_chip *gc,
> -					  unsigned offset, int value);
> +static void rockchip_gpio_set(struct gpio_chip *gc, unsigned offset, int value);
>   static int rockchip_gpio_get(struct gpio_chip *gc, unsigned offset);
>   
>   /* set the pin config settings for a specified pin */
> @@ -959,9 +968,10 @@ static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
>   				return rc;
>   			break;
>   		case PIN_CONFIG_OUTPUT:
> -			rc = rockchip_gpio_direction_output(&bank->gpio_chip,
> -							    pin - bank->pin_base,
> -							    arg);
> +			rockchip_gpio_set(&bank->gpio_chip,
> +					  pin - bank->pin_base, arg);
> +			rc = _rockchip_pmx_gpio_set_direction(&bank->gpio_chip,
> +					  pin - bank->pin_base, false);
>   			if (rc)
>   				return rc;
>   			break;
Tested-by: Chris Zhong <zyw@rock-chips.com>

  reply	other threads:[~2014-10-21  0:18 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-20 23:27 [PATCH 1/4] pinctrl: rockchip: Set wake_enabled Doug Anderson
2014-10-20 23:27 ` Doug Anderson
2014-10-20 23:27 ` [PATCH 2/4] pinctrl: rockchip: Don't call pinctrl_gpio_direction_output() in pin_config_set() Doug Anderson
2014-10-20 23:27   ` Doug Anderson
2014-10-21  0:18   ` Chris Zhong [this message]
2014-10-21  0:18     ` Chris Zhong
2014-10-21 16:32   ` Doug Anderson
2014-10-21 16:32     ` Doug Anderson
2014-10-20 23:27 ` [PATCH 3/4] pinctrl: rockchip: Parse pin groups before calling pinctrl_register() Doug Anderson
2014-10-20 23:27   ` Doug Anderson
2014-10-21  0:19   ` Chris Zhong
2014-10-21  0:19     ` Chris Zhong
2014-10-20 23:27 ` [PATCH 4/4] pinctrl: rockchip: Protect read-modify-write with the spinlock Doug Anderson
2014-10-20 23:27   ` Doug Anderson
2014-10-20 23:57   ` Doug Anderson
2014-10-20 23:57     ` Doug Anderson
2014-10-21  0:15 ` [PATCH 1/4] pinctrl: rockchip: Set wake_enabled Chris Zhong
2014-10-21  0:15   ` Chris Zhong
2014-10-28 15:51 ` Linus Walleij
2014-10-28 15:51   ` Linus Walleij
2014-10-28 16:06   ` Doug Anderson
2014-10-28 16:06     ` Doug Anderson

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=5445A665.9010905@rock-chips.com \
    --to=zyw@rock-chips.com \
    --cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.