All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] gpio: pca953x: Introduce a long awaited ->get_direction()
@ 2017-03-22 14:11 Andy Shevchenko
  2017-03-22 14:11 ` [PATCH v2 2/3] gpio: pca953x: Sort headers alphabetically Andy Shevchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Andy Shevchenko @ 2017-03-22 14:11 UTC (permalink / raw)
  To: Linus Walleij, linux-gpio, Phil Reid, Bartosz Golaszewski; +Cc: Andy Shevchenko

Introduce ->get_direction() callback for the driver.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 v2: fix direction (0 for out, 1 for in)
 drivers/gpio/gpio-pca953x.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index d44232aadb6c..c149054ef976 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -363,6 +363,21 @@ static void pca953x_gpio_set_value(struct gpio_chip *gc, unsigned off, int val)
 	mutex_unlock(&chip->i2c_lock);
 }
 
+static int pca953x_gpio_get_direction(struct gpio_chip *gc, unsigned off)
+{
+	struct pca953x_chip *chip = gpiochip_get_data(gc);
+	u32 reg_val;
+	int ret;
+
+	mutex_lock(&chip->i2c_lock);
+	ret = pca953x_read_single(chip, chip->regs->direction, &reg_val, off);
+	mutex_unlock(&chip->i2c_lock);
+	if (ret < 0)
+		return ret;
+
+	return (reg_val & (1u << (off % BANK_SZ))) ? GPIOF_DIR_IN : GPIOF_DIR_OUT;
+}
+
 static void pca953x_gpio_set_multiple(struct gpio_chip *gc,
 				      unsigned long *mask, unsigned long *bits)
 {
@@ -408,6 +423,7 @@ static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios)
 	gc->direction_output = pca953x_gpio_direction_output;
 	gc->get = pca953x_gpio_get_value;
 	gc->set = pca953x_gpio_set_value;
+	gc->get_direction = pca953x_gpio_get_direction;
 	gc->set_multiple = pca953x_gpio_set_multiple;
 	gc->can_sleep = true;
 
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/3] gpio: pca953x: Sort headers alphabetically
  2017-03-22 14:11 [PATCH v2 1/3] gpio: pca953x: Introduce a long awaited ->get_direction() Andy Shevchenko
@ 2017-03-22 14:11 ` Andy Shevchenko
  2017-03-23  9:42   ` Linus Walleij
  2017-03-22 14:11 ` [PATCH v2 3/3] gpio: pca953x: Expand comment for "reset" GPIO in ACPI case Andy Shevchenko
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2017-03-22 14:11 UTC (permalink / raw)
  To: Linus Walleij, linux-gpio, Phil Reid, Bartosz Golaszewski; +Cc: Andy Shevchenko

For sake of better maintenance sort the headers by alphabetical order.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-pca953x.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index c149054ef976..cfee792182ab 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -11,18 +11,19 @@
  *  the Free Software Foundation; version 2 of the License.
  */
 
-#include <linux/module.h>
-#include <linux/init.h>
+#include <linux/acpi.h>
 #include <linux/gpio.h>
 #include <linux/gpio/consumer.h>
-#include <linux/interrupt.h>
 #include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
 #include <linux/platform_data/pca953x.h>
+#include <linux/regulator/consumer.h>
 #include <linux/slab.h>
+
 #include <asm/unaligned.h>
-#include <linux/of_platform.h>
-#include <linux/acpi.h>
-#include <linux/regulator/consumer.h>
 
 #define PCA953X_INPUT		0
 #define PCA953X_OUTPUT		1
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 3/3] gpio: pca953x: Expand comment for "reset" GPIO in ACPI case
  2017-03-22 14:11 [PATCH v2 1/3] gpio: pca953x: Introduce a long awaited ->get_direction() Andy Shevchenko
  2017-03-22 14:11 ` [PATCH v2 2/3] gpio: pca953x: Sort headers alphabetically Andy Shevchenko
@ 2017-03-22 14:11 ` Andy Shevchenko
  2017-03-23  9:43   ` Linus Walleij
  2017-03-23  9:37 ` [PATCH v2 1/3] gpio: pca953x: Introduce a long awaited ->get_direction() Linus Walleij
  2017-03-23  9:38 ` Linus Walleij
  3 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2017-03-22 14:11 UTC (permalink / raw)
  To: Linus Walleij, linux-gpio, Phil Reid, Bartosz Golaszewski; +Cc: Andy Shevchenko

GPIO ACPI library is going to be stricter about resources, thus, expand
comment regarding "reset" GPIO resource in this driver to clarify its
usage in ACPI case.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-pca953x.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index cfee792182ab..d8eddc9b7af0 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -777,7 +777,13 @@ static int pca953x_probe(struct i2c_client *client,
 		chip->gpio_start = -1;
 		irq_base = 0;
 
-		/* See if we need to de-assert a reset pin */
+		/*
+		 * See if we need to de-assert a reset pin.
+		 *
+		 * There is no known ACPI-enabled platforms that are
+		 * using "reset" GPIO. Otherwise any of those platform
+		 * must use _DSD method with corresponding property.
+		 */
 		reset_gpio = devm_gpiod_get_optional(&client->dev, "reset",
 						     GPIOD_OUT_LOW);
 		if (IS_ERR(reset_gpio))
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/3] gpio: pca953x: Introduce a long awaited ->get_direction()
  2017-03-22 14:11 [PATCH v2 1/3] gpio: pca953x: Introduce a long awaited ->get_direction() Andy Shevchenko
  2017-03-22 14:11 ` [PATCH v2 2/3] gpio: pca953x: Sort headers alphabetically Andy Shevchenko
  2017-03-22 14:11 ` [PATCH v2 3/3] gpio: pca953x: Expand comment for "reset" GPIO in ACPI case Andy Shevchenko
@ 2017-03-23  9:37 ` Linus Walleij
  2017-03-23  9:38 ` Linus Walleij
  3 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2017-03-23  9:37 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-gpio, Phil Reid, Bartosz Golaszewski

On Wed, Mar 22, 2017 at 3:11 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> Introduce ->get_direction() callback for the driver.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  v2: fix direction (0 for out, 1 for in)

This v2 patch applied.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/3] gpio: pca953x: Introduce a long awaited ->get_direction()
  2017-03-22 14:11 [PATCH v2 1/3] gpio: pca953x: Introduce a long awaited ->get_direction() Andy Shevchenko
                   ` (2 preceding siblings ...)
  2017-03-23  9:37 ` [PATCH v2 1/3] gpio: pca953x: Introduce a long awaited ->get_direction() Linus Walleij
@ 2017-03-23  9:38 ` Linus Walleij
  3 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2017-03-23  9:38 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-gpio, Phil Reid, Bartosz Golaszewski

On Wed, Mar 22, 2017 at 3:11 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> +       return (reg_val & (1u << (off % BANK_SZ))) ? GPIOF_DIR_IN : GPIOF_DIR_OUT;

The GPIOF_DIR_IN/GPIOF_DIR_OUT are part of the consumer API and should
not be used inside drivers.

I've fixed it up to 1/0 when applying.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/3] gpio: pca953x: Sort headers alphabetically
  2017-03-22 14:11 ` [PATCH v2 2/3] gpio: pca953x: Sort headers alphabetically Andy Shevchenko
@ 2017-03-23  9:42   ` Linus Walleij
  2017-03-23 13:10     ` Andy Shevchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Linus Walleij @ 2017-03-23  9:42 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-gpio, Phil Reid, Bartosz Golaszewski

On Wed, Mar 22, 2017 at 3:11 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> For sake of better maintenance sort the headers by alphabetical order.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Patch applied.

Unrelated:

>  #include <linux/gpio.h>
>  #include <linux/gpio/consumer.h>

#include <linux/gpio/driver.h> should normally be all that is needed.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/3] gpio: pca953x: Expand comment for "reset" GPIO in ACPI case
  2017-03-22 14:11 ` [PATCH v2 3/3] gpio: pca953x: Expand comment for "reset" GPIO in ACPI case Andy Shevchenko
@ 2017-03-23  9:43   ` Linus Walleij
  0 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2017-03-23  9:43 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-gpio, Phil Reid, Bartosz Golaszewski

On Wed, Mar 22, 2017 at 3:11 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> GPIO ACPI library is going to be stricter about resources, thus, expand
> comment regarding "reset" GPIO resource in this driver to clarify its
> usage in ACPI case.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Patch applied.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/3] gpio: pca953x: Sort headers alphabetically
  2017-03-23  9:42   ` Linus Walleij
@ 2017-03-23 13:10     ` Andy Shevchenko
  0 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2017-03-23 13:10 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-gpio, Phil Reid, Bartosz Golaszewski

On Thu, 2017-03-23 at 10:42 +0100, Linus Walleij wrote:
> On Wed, Mar 22, 2017 at 3:11 PM, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> 
> > For sake of better maintenance sort the headers by alphabetical
> > order.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> Patch applied.
> 
> Unrelated:
> 
> >  #include <linux/gpio.h>
> >  #include <linux/gpio/consumer.h>
> 
> #include <linux/gpio/driver.h> should normally be all that is needed.

Noted for the future, thanks!

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-03-23 13:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-22 14:11 [PATCH v2 1/3] gpio: pca953x: Introduce a long awaited ->get_direction() Andy Shevchenko
2017-03-22 14:11 ` [PATCH v2 2/3] gpio: pca953x: Sort headers alphabetically Andy Shevchenko
2017-03-23  9:42   ` Linus Walleij
2017-03-23 13:10     ` Andy Shevchenko
2017-03-22 14:11 ` [PATCH v2 3/3] gpio: pca953x: Expand comment for "reset" GPIO in ACPI case Andy Shevchenko
2017-03-23  9:43   ` Linus Walleij
2017-03-23  9:37 ` [PATCH v2 1/3] gpio: pca953x: Introduce a long awaited ->get_direction() Linus Walleij
2017-03-23  9:38 ` Linus Walleij

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.