All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime.ripard@bootlin.com>
To: Chen-Yu Tsai <wens@csie.org>,
	Maxime Ripard <maxime.ripard@bootlin.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: linux-gpio@vger.kernel.org,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/6] gpio: Set proper argument value to set_config
Date: Thu, 14 Mar 2019 20:32:50 +0100	[thread overview]
Message-ID: <b9ed544722175ea00b1f6ecb29ca5c3e1322239f.1552591798.git-series.maxime.ripard@bootlin.com> (raw)
In-Reply-To: <cover.66d6a9a379de8ebf176e4c25a8542152dc09f366.1552591798.git-series.maxime.ripard@bootlin.com>

The gpio_set_config function creates a pinconf configuration for a given
pinc_config_param.

However, it always uses an arg of 0, which might not be a valid argument
for a given param. A good example of that would be the bias parameters,
where 0 means that the pull up or down resistor is null, and the pin is
directly connected to VCC/GND.

The framework uses in some other places the value 1 as a default argument
to enable the pull resistor, so let's use the same one here.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 drivers/gpio/gpiolib.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 144af0733581..27cb5783ef52 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2565,8 +2565,20 @@ EXPORT_SYMBOL_GPL(gpiochip_free_own_desc);
 static int gpio_set_config(struct gpio_chip *gc, unsigned offset,
 			   enum pin_config_param mode)
 {
-	unsigned long config = { PIN_CONF_PACKED(mode, 0) };
+	unsigned long config;
+	unsigned arg;
 
+	switch (mode) {
+	case PIN_CONFIG_BIAS_PULL_DOWN:
+	case PIN_CONFIG_BIAS_PULL_UP:
+		arg = 1;
+		break;
+
+	default:
+		arg = 0;
+	}
+
+	config = PIN_CONF_PACKED(mode, arg);
 	return gc->set_config ? gc->set_config(gc, offset, config) : -ENOTSUPP;
 }
 
-- 
git-series 0.9.1

WARNING: multiple messages have this Message-ID (diff)
From: Maxime Ripard <maxime.ripard@bootlin.com>
To: Chen-Yu Tsai <wens@csie.org>,
	Maxime Ripard <maxime.ripard@bootlin.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: linux-gpio@vger.kernel.org,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/6] gpio: Set proper argument value to set_config
Date: Thu, 14 Mar 2019 20:32:50 +0100	[thread overview]
Message-ID: <b9ed544722175ea00b1f6ecb29ca5c3e1322239f.1552591798.git-series.maxime.ripard@bootlin.com> (raw)
In-Reply-To: <cover.66d6a9a379de8ebf176e4c25a8542152dc09f366.1552591798.git-series.maxime.ripard@bootlin.com>

The gpio_set_config function creates a pinconf configuration for a given
pinc_config_param.

However, it always uses an arg of 0, which might not be a valid argument
for a given param. A good example of that would be the bias parameters,
where 0 means that the pull up or down resistor is null, and the pin is
directly connected to VCC/GND.

The framework uses in some other places the value 1 as a default argument
to enable the pull resistor, so let's use the same one here.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 drivers/gpio/gpiolib.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 144af0733581..27cb5783ef52 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2565,8 +2565,20 @@ EXPORT_SYMBOL_GPL(gpiochip_free_own_desc);
 static int gpio_set_config(struct gpio_chip *gc, unsigned offset,
 			   enum pin_config_param mode)
 {
-	unsigned long config = { PIN_CONF_PACKED(mode, 0) };
+	unsigned long config;
+	unsigned arg;
 
+	switch (mode) {
+	case PIN_CONFIG_BIAS_PULL_DOWN:
+	case PIN_CONFIG_BIAS_PULL_UP:
+		arg = 1;
+		break;
+
+	default:
+		arg = 0;
+	}
+
+	config = PIN_CONF_PACKED(mode, arg);
 	return gc->set_config ? gc->set_config(gc, offset, config) : -ENOTSUPP;
 }
 
-- 
git-series 0.9.1

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-03-14 19:32 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-14 19:32 [PATCH 0/6] pinctrl: sunxi: Allow to configure pull-up / pull-down from GPIO flags Maxime Ripard
2019-03-14 19:32 ` Maxime Ripard
2019-03-14 19:32 ` Maxime Ripard [this message]
2019-03-14 19:32   ` [PATCH 1/6] gpio: Set proper argument value to set_config Maxime Ripard
2019-04-03 16:41   ` Linus Walleij
2019-04-03 16:41     ` Linus Walleij
2019-04-03 18:36     ` Maxime Ripard
2019-04-04  4:56       ` Linus Walleij
2019-04-04  4:56         ` Linus Walleij
2019-03-14 19:32 ` [PATCH 2/6] pinctrl: sunxi: implement pin_config_set Maxime Ripard
2019-03-14 19:32   ` Maxime Ripard
2019-04-04  1:56   ` Linus Walleij
2019-04-04  1:56     ` Linus Walleij
2019-03-14 19:32 ` [PATCH 3/6] pinctrl: sunxi: Fix variable assignment syntax Maxime Ripard
2019-03-14 19:32   ` Maxime Ripard
2019-04-04  1:57   ` Linus Walleij
2019-04-04  1:57     ` Linus Walleij
2019-03-14 19:32 ` [PATCH 4/6] pinctrl: sunxi: Declare set_config on the GPIO chip Maxime Ripard
2019-03-14 19:32   ` Maxime Ripard
2019-04-04  3:27   ` Linus Walleij
2019-04-04  3:27     ` Linus Walleij
2019-03-14 19:32 ` [PATCH 5/6] ARM: dts: sunxi: Remove pinctrl groups setting bias Maxime Ripard
2019-03-14 19:32   ` Maxime Ripard
2019-04-04  3:29   ` Linus Walleij
2019-04-04  3:29     ` Linus Walleij
2019-03-14 19:32 ` [PATCH 6/6] ARM: dts: sunxi: Remove useless pinctrl nodes Maxime Ripard
2019-03-14 19:32   ` Maxime Ripard
2019-04-04  3:30   ` Linus Walleij
2019-04-04  3:30     ` Linus Walleij
2019-03-15  2:57 ` [PATCH 0/6] pinctrl: sunxi: Allow to configure pull-up / pull-down from GPIO flags Chen-Yu Tsai
2019-03-15  2:57   ` Chen-Yu Tsai
2019-04-02 13:22 ` Maxime Ripard
2019-04-04  7:26 ` Maxime Ripard

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=b9ed544722175ea00b1f6ecb29ca5c3e1322239f.1552591798.git-series.maxime.ripard@bootlin.com \
    --to=maxime.ripard@bootlin.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=wens@csie.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.