From: Fabio Baltieri <fabio.baltieri@linaro.org>
To: patrice.chotard.st@gmail.com
Cc: linux-kernel@vger.kernel.org,
Linus Walleij <linus.walleij@linaro.org>,
Olivier Clergeaud <olivier.clergeaud@st.com>,
Lee Jones <lee.jones@linaro.org>,
Patrice Chotard <patrice.chotard@st.com>
Subject: Re: [PATCH 2/2] pinctrl: abx500: fix abx500_pin_config_set()
Date: Thu, 20 Jun 2013 10:18:50 +0200 [thread overview]
Message-ID: <20130620081850.GB20594@balto.lan> (raw)
In-Reply-To: <1371713002-18974-3-git-send-email-patrice.chotard.st@gmail.com>
On Thu, Jun 20, 2013 at 09:23:22AM +0200, patrice.chotard.st@gmail.com wrote:
> From: Patrice Chotard <patrice.chotard@st.com>
>
> _ Update abx500_pin_config_set() in order to take in
> account PIN_CONFIG_BIAS_DISABLE state to disable
> pull up or pull down.
>
> _ Rework error path.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> ---
> drivers/pinctrl/pinctrl-abx500.c | 31 +++++++++++++++++++++++++------
> 1 file changed, 25 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-abx500.c b/drivers/pinctrl/pinctrl-abx500.c
> index b5b5460..14dc078 100644
> --- a/drivers/pinctrl/pinctrl-abx500.c
> +++ b/drivers/pinctrl/pinctrl-abx500.c
> @@ -33,6 +33,7 @@
> #include <linux/pinctrl/machine.h>
>
> #include "pinctrl-abx500.h"
> +#include "core.h"
> #include "pinconf.h"
>
> /*
> @@ -963,7 +964,7 @@ static int abx500_pin_config_set(struct pinctrl_dev *pctldev,
> struct pullud *pullud = pct->soc->pullud;
> struct gpio_chip *chip = &pct->chip;
> unsigned offset;
> - int ret = 0;
> + int ret = -EINVAL;
> enum pin_config_param param = pinconf_to_config_param(config);
> enum pin_config_param argument = pinconf_to_config_argument(config);
>
> @@ -976,13 +977,32 @@ static int abx500_pin_config_set(struct pinctrl_dev *pctldev,
> offset = pin - 1;
>
> switch (param) {
> - case PIN_CONFIG_BIAS_PULL_DOWN:
> + case PIN_CONFIG_BIAS_DISABLE:
> + ret = abx500_gpio_direction_input(chip, offset);
> /*
> - * if argument = 1 set the pull down
> - * else clear the pull down
> + * Some chips only support pull down, while some actually
> + * support both pull up and pull down. Such chips have
> + * a "pullud" range specified for the pins that support
> + * both features. If the pin is not within that range, we
> + * fall back to the old bit set that only support pull down.
> */
> + if (pullud &&
> + pin >= pullud->first_pin &&
> + pin <= pullud->last_pin)
This multi-line check is replicated in all conditions, would it make
sense to move it on a dedicated function to improve readability?
> + ret = abx500_set_pull_updown(pct,
> + pin,
> + ABX500_GPIO_PULL_NONE);
> + else
> + /* Chip only supports pull down */
> + ret = abx500_gpio_set_bits(chip, AB8500_GPIO_PUD1_REG,
> + offset, ABX500_GPIO_PULL_NONE);
> + break;
> +
> + case PIN_CONFIG_BIAS_PULL_DOWN:
> ret = abx500_gpio_direction_input(chip, offset);
> /*
> + * if argument = 1 set the pull down
> + * else clear the pull down
> * Some chips only support pull down, while some actually
> * support both pull up and pull down. Such chips have
> * a "pullud" range specified for the pins that support
> @@ -1002,6 +1022,7 @@ static int abx500_pin_config_set(struct pinctrl_dev *pctldev,
> break;
>
> case PIN_CONFIG_BIAS_PULL_UP:
> + ret = abx500_gpio_direction_input(chip, offset);
Here the return value of abx500_gpio_direction_input is set but never
checked, and will be always overwritten by the next abx500_gpio_ call...
Would it make sense to add a pr_err for it? On the other side, if it
never fails, you can just drop the return field altogether.
That's also done in other conditions in the same 'switch', it may make
sense to have a patch just for that.
Thanks,
Fabio
> /*
> * if argument = 1 set the pull up
> * else clear the pull up
> @@ -1030,8 +1051,6 @@ static int abx500_pin_config_set(struct pinctrl_dev *pctldev,
>
> default:
> dev_err(chip->dev, "illegal configuration requested\n");
> -
> - return -EINVAL;
> }
>
> return ret;
> --
> 1.7.10
>
--
Fabio Baltieri
next prev parent reply other threads:[~2013-06-20 8:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-20 7:23 [PATCH 0/2] pinctrl: ABX500: Add device tree support patrice.chotard.st
2013-06-20 7:23 ` [PATCH 1/2] pinctrl: abx500: " patrice.chotard.st
2013-06-20 8:03 ` Fabio Baltieri
2013-06-20 11:29 ` Patrice Chotard
2013-06-20 7:23 ` [PATCH 2/2] pinctrl: abx500: fix abx500_pin_config_set() patrice.chotard.st
2013-06-20 8:18 ` Fabio Baltieri [this message]
2013-06-20 11:32 ` Patrice Chotard
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=20130620081850.GB20594@balto.lan \
--to=fabio.baltieri@linaro.org \
--cc=lee.jones@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olivier.clergeaud@st.com \
--cc=patrice.chotard.st@gmail.com \
--cc=patrice.chotard@st.com \
/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
all inboxes | Powered by JetHome®