linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: stx104: Add support for GPIO names
@ 2017-01-30 17:16 William Breathitt Gray
  2017-01-30 20:24 ` Jonathan Cameron
  2017-01-31  9:41 ` Linus Walleij
  0 siblings, 2 replies; 4+ messages in thread
From: William Breathitt Gray @ 2017-01-30 17:16 UTC (permalink / raw)
  To: jic23, knaack.h, lars, pmeerw
  Cc: linux-iio, linux-kernel, William Breathitt Gray

This patch sets the gpio_chip names option with an array of GPIO line
names that match the manual documentation for the Apex Embedded Systems
STX104. This should make it easier for users to identify which GPIO line
corresponds to a respective GPIO pin on the device.

Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
---
 drivers/iio/adc/stx104.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/stx104.c b/drivers/iio/adc/stx104.c
index c56ff286695d..04b94fcd5acf 100644
--- a/drivers/iio/adc/stx104.c
+++ b/drivers/iio/adc/stx104.c
@@ -266,6 +266,11 @@ static void stx104_gpio_set(struct gpio_chip *chip, unsigned int offset,
 	spin_unlock_irqrestore(&stx104gpio->lock, flags);
 }
 
+#define STX104_NGPIO 8
+static const char *stx104_names[STX104_NGPIO] = {
+	"DIN0", "DIN1", "DIN2", "DIN3", "DOUT0", "DOUT1", "DOUT2", "DOUT3"
+};
+
 static int stx104_probe(struct device *dev, unsigned int id)
 {
 	struct iio_dev *indio_dev;
@@ -324,7 +329,8 @@ static int stx104_probe(struct device *dev, unsigned int id)
 	stx104gpio->chip.parent = dev;
 	stx104gpio->chip.owner = THIS_MODULE;
 	stx104gpio->chip.base = -1;
-	stx104gpio->chip.ngpio = 8;
+	stx104gpio->chip.ngpio = STX104_NGPIO;
+	stx104gpio->chip.names = stx104_names;
 	stx104gpio->chip.get_direction = stx104_gpio_get_direction;
 	stx104gpio->chip.direction_input = stx104_gpio_direction_input;
 	stx104gpio->chip.direction_output = stx104_gpio_direction_output;
-- 
2.11.0

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

* Re: [PATCH] iio: stx104: Add support for GPIO names
  2017-01-30 17:16 [PATCH] iio: stx104: Add support for GPIO names William Breathitt Gray
@ 2017-01-30 20:24 ` Jonathan Cameron
  2017-01-31  9:41 ` Linus Walleij
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2017-01-30 20:24 UTC (permalink / raw)
  To: William Breathitt Gray, knaack.h, lars, pmeerw
  Cc: linux-iio, linux-kernel, linux-gpio, Linus Walleij

On 30/01/17 17:16, William Breathitt Gray wrote:
> This patch sets the gpio_chip names option with an array of GPIO line
> names that match the manual documentation for the Apex Embedded Systems
> STX104. This should make it easier for users to identify which GPIO line
> corresponds to a respective GPIO pin on the device.
> 
> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Cc'ing Linus Waleij and gpio list just in case there are any conventions on this
I don't know about!

Jonathan
> ---
>  drivers/iio/adc/stx104.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/stx104.c b/drivers/iio/adc/stx104.c
> index c56ff286695d..04b94fcd5acf 100644
> --- a/drivers/iio/adc/stx104.c
> +++ b/drivers/iio/adc/stx104.c
> @@ -266,6 +266,11 @@ static void stx104_gpio_set(struct gpio_chip *chip, unsigned int offset,
>  	spin_unlock_irqrestore(&stx104gpio->lock, flags);
>  }
>  
> +#define STX104_NGPIO 8
> +static const char *stx104_names[STX104_NGPIO] = {
> +	"DIN0", "DIN1", "DIN2", "DIN3", "DOUT0", "DOUT1", "DOUT2", "DOUT3"
> +};
> +
>  static int stx104_probe(struct device *dev, unsigned int id)
>  {
>  	struct iio_dev *indio_dev;
> @@ -324,7 +329,8 @@ static int stx104_probe(struct device *dev, unsigned int id)
>  	stx104gpio->chip.parent = dev;
>  	stx104gpio->chip.owner = THIS_MODULE;
>  	stx104gpio->chip.base = -1;
> -	stx104gpio->chip.ngpio = 8;
> +	stx104gpio->chip.ngpio = STX104_NGPIO;
> +	stx104gpio->chip.names = stx104_names;
>  	stx104gpio->chip.get_direction = stx104_gpio_get_direction;
>  	stx104gpio->chip.direction_input = stx104_gpio_direction_input;
>  	stx104gpio->chip.direction_output = stx104_gpio_direction_output;
> 

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

* Re: [PATCH] iio: stx104: Add support for GPIO names
  2017-01-30 17:16 [PATCH] iio: stx104: Add support for GPIO names William Breathitt Gray
  2017-01-30 20:24 ` Jonathan Cameron
@ 2017-01-31  9:41 ` Linus Walleij
  2017-01-31 18:55   ` Jonathan Cameron
  1 sibling, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2017-01-31  9:41 UTC (permalink / raw)
  To: William Breathitt Gray
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, linux-kernel

On Mon, Jan 30, 2017 at 6:16 PM, William Breathitt Gray
<vilhelm.gray@gmail.com> wrote:

> This patch sets the gpio_chip names option with an array of GPIO line
> names that match the manual documentation for the Apex Embedded Systems
> STX104. This should make it easier for users to identify which GPIO line
> corresponds to a respective GPIO pin on the device.
>
> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
(...)
> +#define STX104_NGPIO 8
> +static const char *stx104_names[STX104_NGPIO] = {
> +       "DIN0", "DIN1", "DIN2", "DIN3", "DOUT0", "DOUT1", "DOUT2", "DOUT3"
> +};
(...)
> +       stx104gpio->chip.ngpio = STX104_NGPIO;
> +       stx104gpio->chip.names = stx104_names;

If the device has a gpio-controller tagged node in a device tree, it is better
to use gpio-line-names = "foo" ...; for this. For ACPI there is something
similar.

If it is spawn from this device without any GPIO child node or hardware
description outside of the kernel driver, such as
ISA/PCI or whatever, this is a good way.

This is an isa_driver and falls in the latter category, so:
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH] iio: stx104: Add support for GPIO names
  2017-01-31  9:41 ` Linus Walleij
@ 2017-01-31 18:55   ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2017-01-31 18:55 UTC (permalink / raw)
  To: Linus Walleij, William Breathitt Gray
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald, linux-iio,
	linux-kernel

On 31/01/17 09:41, Linus Walleij wrote:
> On Mon, Jan 30, 2017 at 6:16 PM, William Breathitt Gray
> <vilhelm.gray@gmail.com> wrote:
> 
>> This patch sets the gpio_chip names option with an array of GPIO line
>> names that match the manual documentation for the Apex Embedded Systems
>> STX104. This should make it easier for users to identify which GPIO line
>> corresponds to a respective GPIO pin on the device.
>>
>> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
> (...)
>> +#define STX104_NGPIO 8
>> +static const char *stx104_names[STX104_NGPIO] = {
>> +       "DIN0", "DIN1", "DIN2", "DIN3", "DOUT0", "DOUT1", "DOUT2", "DOUT3"
>> +};
> (...)
>> +       stx104gpio->chip.ngpio = STX104_NGPIO;
>> +       stx104gpio->chip.names = stx104_names;
> 
> If the device has a gpio-controller tagged node in a device tree, it is better
> to use gpio-line-names = "foo" ...; for this. For ACPI there is something
> similar.
> 
> If it is spawn from this device without any GPIO child node or hardware
> description outside of the kernel driver, such as
> ISA/PCI or whatever, this is a good way.
> 
> This is an isa_driver and falls in the latter category, so:
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cool.. thanks for the info as well.

Applied to the togreg branch of iio.git. Will push out as testing in a few minutes
to let the autobuilders play with it.

Thanks,

Jonathan
> 
> Yours,
> Linus Walleij
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

end of thread, other threads:[~2017-01-31 18:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-30 17:16 [PATCH] iio: stx104: Add support for GPIO names William Breathitt Gray
2017-01-30 20:24 ` Jonathan Cameron
2017-01-31  9:41 ` Linus Walleij
2017-01-31 18:55   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).