Skip to contentSkip to conversation

iio: stx104: Add support for GPIO names

PATCH In review William Breathitt Gray 3 participants 4 messages Jan 30, 2017 – Jan 31, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: stx104: Add support for GPIO names

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.

---
 drivers/iio/adc/stx104.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/iio/adc/stx104.c +7 -1
index c56ff286695d..04b94fcd5acf 100644
@@ -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;
Signature · 1 line
2.11.0
maintainer
#1 lore raw
Quoted 6 lines · 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.

Cc'ing Linus Waleij and gpio list just in case there are any conventions on this I don't know about!

Jonathan

Quoted 31 lines
---
 drivers/iio/adc/stx104.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/iio/adc/stx104.c +7 -1
index c56ff286695d..04b94fcd5acf 100644
@@ -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;
Reviewed-by on v1 1/1
#2 lore raw
In reply to William Breathitt Gray
Quoted 6 lines · 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.

(...)

Quoted 4 lines
drivers/iio/adc/stx104.c +4 -0
+#define STX104_NGPIO 8
+static const char *stx104_names[STX104_NGPIO] = {
+       "DIN0", "DIN1", "DIN2", "DIN3", "DOUT0", "DOUT1", "DOUT2", "DOUT3"
+};

(...)

drivers/iio/adc/stx104.c static int stx104_probe(struct device *dev, unsigned int id) · line 333

Quoted 2 lines
drivers/iio/adc/stx104.c +2 -0
+       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:

Yours,
Linus Walleij

maintainer
#3 lore raw
Quoted 22 lines · Linus Walleij
Quoted 6 lines · 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.

(...)

Quoted 4 lines
drivers/iio/adc/stx104.c +4 -0
+#define STX104_NGPIO 8
+static const char *stx104_names[STX104_NGPIO] = {
+       "DIN0", "DIN1", "DIN2", "DIN3", "DOUT0", "DOUT1", "DOUT2", "DOUT3"
+};

(...)

drivers/iio/adc/stx104.c static int stx104_probe(struct device *dev, unsigned int id) · line 333

Quoted 2 lines
drivers/iio/adc/stx104.c +2 -0
+       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.

Quoted 6 lines

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:

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

Quoted 8 lines

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