Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1514467

[PATCH] gpio: davinci: Use unique labels for each gpio chip

From Axel Haslam <ahaslam@baylibre.com>
Newsgroups linux.kernel
Subject [PATCH] gpio: davinci: Use unique labels for each gpio chip
Date 2016-11-03 12:40 +0100
Message-ID <szoxb-3eu-7@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


The gpiod framework uses the chip label to match a specific chip.
The davinci gpio driver, creates several chips using always the same
label, which is not compatible with gpiod.

To allow platform data to declare gpio lookup tables, and for drivers
to use the gpiod framework, allocate unique label per registered chip.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
---
 drivers/gpio/gpio-davinci.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index dd262f0..9191056 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -40,6 +40,7 @@ struct davinci_gpio_regs {
 typedef struct irq_chip *(*gpio_get_irq_chip_cb_t)(unsigned int irq);
 
 #define BINTEN	0x8 /* GPIO Interrupt Per-Bank Enable Register */
+#define MAX_LABEL_SIZE 20
 
 static void __iomem *gpio_base;
 
@@ -201,6 +202,7 @@ static int davinci_gpio_probe(struct platform_device *pdev)
 	struct davinci_gpio_regs __iomem *regs;
 	struct device *dev = &pdev->dev;
 	struct resource *res;
+	char label[MAX_LABEL_SIZE];
 
 	pdata = davinci_gpio_get_pdata(pdev);
 	if (!pdata) {
@@ -237,7 +239,10 @@ static int davinci_gpio_probe(struct platform_device *pdev)
 		return PTR_ERR(gpio_base);
 
 	for (i = 0, base = 0; base < ngpio; i++, base += 32) {
-		chips[i].chip.label = "DaVinci";
+		snprintf(label, MAX_LABEL_SIZE, "davinci_gpio.%d", i);
+		chips[i].chip.label = devm_kstrdup(dev, label, GFP_KERNEL);
+		if (!chips[i].chip.label)
+			return -ENOMEM;
 
 		chips[i].chip.direction_input = davinci_direction_in;
 		chips[i].chip.get = davinci_gpio_get;
-- 
2.10.1

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] gpio: davinci: Use unique labels for each gpio chip Axel Haslam <ahaslam@baylibre.com> - 2016-11-03 12:40 +0100
  Re: [PATCH] gpio: davinci: Use unique labels for each gpio chip Linus Walleij <linus.walleij@linaro.org> - 2016-11-08 14:40 +0100
    Re: [PATCH] gpio: davinci: Use unique labels for each gpio chip Sekhar Nori <nsekhar@ti.com> - 2016-11-08 15:50 +0100
  Re: [PATCH] gpio: davinci: Use unique labels for each gpio chip Kevin Hilman <khilman@baylibre.com> - 2016-11-08 19:20 +0100
  Re: [PATCH] gpio: davinci: Use unique labels for each gpio chip Linus Walleij <linus.walleij@linaro.org> - 2016-11-09 09:20 +0100

csiph-web