Skip to contentSkip to conversation

gpio: davinci: Use unique labels for each gpio chip

PATCH In review Axel Haslam 4 participants 5 messages Nov 3, 2016 – Nov 9, 2016

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

PATCH 1/1 gpio: davinci: Use unique labels for each gpio chip

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.

---
 drivers/gpio/gpio-davinci.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpio/gpio-davinci.c +6 -1
index dd262f0..9191056 100644
@@ -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;
Signature · 1 line
2.10.1
#1 lore raw
Quoted 8 lines · 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.

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

Yours,
Linus Walleij

Reviewed-by
#2 lore raw
Quoted 6 lines · Linus Walleij
Quoted 4 lines · 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.

Quoted 6 lines
Quoted 4 lines

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

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

The patch looks good to me.

I am traveling and did not really test the patch.

Thanks,
Sekhar

Acked-by on v1 1/1
#3 lore raw
In reply to Axel Haslam
Quoted 8 lines · 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.

#4 lore raw
In reply to Axel Haslam
Quoted 8 lines · 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.

Patch applied with the ACKs.

Yours,
Linus Walleij