linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: davinci: Use unique labels for each gpio chip
@ 2016-11-03 11:34 Axel Haslam
  2016-11-08 13:31 ` Linus Walleij
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Axel Haslam @ 2016-11-03 11:34 UTC (permalink / raw)
  To: linus.walleij, gnurou, nsekhar, khilman, david,
	grygorii.strashko, keerthy
  Cc: linux-gpio, linux-kernel, Axel Haslam

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

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

* Re: [PATCH] gpio: davinci: Use unique labels for each gpio chip
  2016-11-03 11:34 [PATCH] gpio: davinci: Use unique labels for each gpio chip Axel Haslam
@ 2016-11-08 13:31 ` Linus Walleij
  2016-11-08 14:46   ` Sekhar Nori
  2016-11-08 18:16 ` Kevin Hilman
  2016-11-09  8:14 ` Linus Walleij
  2 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2016-11-08 13:31 UTC (permalink / raw)
  To: Axel Haslam, Nori, Sekhar, Kevin Hilman
  Cc: Alexandre Courbot, David Lechner, Grygorii Strashko, keerthy,
	linux-gpio, linux-kernel

On Thu, Nov 3, 2016 at 12:34 PM, Axel Haslam <ahaslam@baylibre.com> wrote:

> 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>

Sekhar/Kevin: can either of you review this patch?

Yours,
Linus Walleij

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

* Re: [PATCH] gpio: davinci: Use unique labels for each gpio chip
  2016-11-08 13:31 ` Linus Walleij
@ 2016-11-08 14:46   ` Sekhar Nori
  0 siblings, 0 replies; 5+ messages in thread
From: Sekhar Nori @ 2016-11-08 14:46 UTC (permalink / raw)
  To: Linus Walleij, Axel Haslam, Kevin Hilman
  Cc: Alexandre Courbot, David Lechner, Grygorii Strashko, J, KEERTHY,
	linux-gpio, linux-kernel

On Tuesday 08 November 2016 07:01 PM, Linus Walleij wrote:
> On Thu, Nov 3, 2016 at 12:34 PM, Axel Haslam <ahaslam@baylibre.com> wrote:
> 
>> 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>
> 
> Sekhar/Kevin: can either of you review this patch?

The patch looks good to me.

Reviewed-by: Sekhar Nori <nsekhar@ti.com>

I am traveling and did not really test the patch.

Thanks,
Sekhar

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

* Re: [PATCH] gpio: davinci: Use unique labels for each gpio chip
  2016-11-03 11:34 [PATCH] gpio: davinci: Use unique labels for each gpio chip Axel Haslam
  2016-11-08 13:31 ` Linus Walleij
@ 2016-11-08 18:16 ` Kevin Hilman
  2016-11-09  8:14 ` Linus Walleij
  2 siblings, 0 replies; 5+ messages in thread
From: Kevin Hilman @ 2016-11-08 18:16 UTC (permalink / raw)
  To: Axel Haslam
  Cc: linus.walleij, gnurou, nsekhar, david, grygorii.strashko,
	keerthy, linux-gpio, linux-kernel

Axel Haslam <ahaslam@baylibre.com> writes:

> 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>

Acked-by: Kevin Hilman <khilman@baylibre.com>

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

* Re: [PATCH] gpio: davinci: Use unique labels for each gpio chip
  2016-11-03 11:34 [PATCH] gpio: davinci: Use unique labels for each gpio chip Axel Haslam
  2016-11-08 13:31 ` Linus Walleij
  2016-11-08 18:16 ` Kevin Hilman
@ 2016-11-09  8:14 ` Linus Walleij
  2 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2016-11-09  8:14 UTC (permalink / raw)
  To: Axel Haslam
  Cc: Alexandre Courbot, Nori, Sekhar, Kevin Hilman, David Lechner,
	Grygorii Strashko, keerthy, linux-gpio, linux-kernel

On Thu, Nov 3, 2016 at 12:34 PM, Axel Haslam <ahaslam@baylibre.com> wrote:

> 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>

Patch applied with the ACKs.

Yours,
Linus Walleij

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

end of thread, other threads:[~2016-11-09  8:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-03 11:34 [PATCH] gpio: davinci: Use unique labels for each gpio chip Axel Haslam
2016-11-08 13:31 ` Linus Walleij
2016-11-08 14:46   ` Sekhar Nori
2016-11-08 18:16 ` Kevin Hilman
2016-11-09  8:14 ` Linus Walleij

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).