Skip to contentSkip to conversation

gpio/mxc: remove redundant shadow variables initialization

PATCH New Shawn Guo 4 participants 12 messages Aug 5, 2012 – Aug 7, 2012

Subsystems (3)
lore
Share & tools
lore

Shawn Guo

author
#0 lore raw

PATCH 1/4 gpio/mxc: remove redundant shadow variables initialization

With commit 3e11f7b (gpio/generic: initialize basic_mmio_gpio shadow variables properly) in place, the shadow variables initialization is being done in generic driver bgpio_init call.

Remove the redundant shadow variables initialization from gpio-mxc driver.

---
 drivers/gpio/gpio-mxc.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/gpio/gpio-mxc.c +0 -2
index 4db460b..76e8cda 100644
@@ -466,8 +466,6 @@ static int __devinit mxc_gpio_probe(struct platform_device *pdev)
 
 	port->bgc.gc.to_irq = mxc_gpio_to_irq;
 	port->bgc.gc.base = pdev->id * 32;
-	port->bgc.dir = port->bgc.read_reg(port->bgc.reg_dir);
-	port->bgc.data = port->bgc.read_reg(port->bgc.reg_set);
 
 	err = gpiochip_add(&port->bgc.gc);
 	if (err)
Signature · 1 line
1.7.5.4
author
#1 lore raw

PATCH 2/4 gpio/mxc: specify gpio base for device tree probe

Currently, unlike the non-DT probe where the gpio base is specified with pdev->id, the DT probe uses the base dynamically allocated by gpio core, which uses a completely different numbering scheme. This causes two issues to user space applications which access sysfs entry /sys/class/gpio/gpioN.

* It breaks the compatibility with user space applications between non-DT and DT kernels.

* It's not intuitive and sometimes hard for users to map the Linux gpio number to the actual hardware pin.

Use alias to identify the gpio port/bank, and then the gpio base can be specified with port id to solve above issues. If alias is not defined in device tree, the base number dynamically allocated by gpio core will be used.

---
 drivers/gpio/gpio-mxc.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/gpio/gpio-mxc.c +2 -1
index 76e8cda..80f44bb 100644
@@ -465,7 +465,8 @@ static int __devinit mxc_gpio_probe(struct platform_device *pdev)
 		goto out_iounmap;
 
 	port->bgc.gc.to_irq = mxc_gpio_to_irq;
-	port->bgc.gc.base = pdev->id * 32;
+	port->bgc.gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 :
+					     pdev->id * 32;
 
 	err = gpiochip_add(&port->bgc.gc);
 	if (err)
Signature · 1 line
1.7.5.4
#2 lore raw

PATCH 2/4 gpio/mxc: specify gpio base for device tree probe

Quoted 5 lines · Shawn Guo

Currently, unlike the non-DT probe where the gpio base is specified with pdev->id, the DT probe uses the base dynamically allocated by gpio core, which uses a completely different numbering scheme. This causes two issues to user space applications which access sysfs entry /sys/class/gpio/gpioN.

Applied.

Thanks,
Linus Walleij

#3 lore raw

PATCH 2/4 gpio/mxc: specify gpio base for device tree probe

In reply to Shawn Guo
Quoted 12 lines · Shawn Guo

Currently, unlike the non-DT probe where the gpio base is specified with pdev->id, the DT probe uses the base dynamically allocated by gpio core, which uses a completely different numbering scheme. This causes two issues to user space applications which access sysfs entry /sys/class/gpio/gpioN.

* It breaks the compatibility with user space applications between non-DT and DT kernels.

* It's not intuitive and sometimes hard for users to map the Linux gpio number to the actual hardware pin.

Quoted 6 lines

Use alias to identify the gpio port/bank, and then the gpio base can be specified with port id to solve above issues. If alias is not defined in device tree, the base number dynamically allocated by gpio core will be used.

I applied patches 1, 2 and 4 to my imx35 dt tree and they work like a charm.

for these three.

Thanks
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
author
#4 lore raw

PATCH 3/4 gpio/mxs: specify gpio base for device tree probe

In reply to Shawn Guo

Currently, unlike the non-DT probe where the gpio base is specified with pdev->id, the DT probe uses the base dynamically allocated by gpio core, which uses a completely different numbering scheme. This causes two issues to user space applications which access sysfs entry /sys/class/gpio/gpioN.

* It breaks the compatibility with user space applications between non-DT and DT kernels.

* It's not intuitive and sometimes hard for users to map the Linux gpio number to the actual hardware pin.

Use alias to identify the gpio port/bank, and then the gpio base can be specified with port id to solve above issues. If alias is not defined in device tree, the base number dynamically allocated by gpio core will be used.

---
 drivers/gpio/gpio-mxs.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/gpio/gpio-mxs.c +2 -1
index 39e4956..09687ce 100644
@@ -290,7 +290,8 @@ static int __devinit mxs_gpio_probe(struct platform_device *pdev)
 		return err;
 
 	port->bgc.gc.to_irq = mxs_gpio_to_irq;
-	port->bgc.gc.base = port->id * 32;
+	port->bgc.gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 :
+					     pdev->id * 32;
 
 	err = gpiochip_add(&port->bgc.gc);
 	if (err) {
Signature · 1 line
1.7.5.4
#5 lore raw

PATCH 3/4 gpio/mxs: specify gpio base for device tree probe

Quoted 5 lines · Shawn Guo

Currently, unlike the non-DT probe where the gpio base is specified with pdev->id, the DT probe uses the base dynamically allocated by gpio core, which uses a completely different numbering scheme. This causes two issues to user space applications which access sysfs entry /sys/class/gpio/gpioN.

Applied.

Thanks,
Linus Walleij

author
#6 lore raw

PATCH 3/4 gpio/mxs: specify gpio base for device tree probe

Quoted 10 lines · Linus Walleij
Quoted 5 lines · Shawn Guo

Currently, unlike the non-DT probe where the gpio base is specified with pdev->id, the DT probe uses the base dynamically allocated by gpio core, which uses a completely different numbering scheme. This causes two issues to user space applications which access sysfs entry /sys/class/gpio/gpioN.

Applied.

Sorry, Linus. I just recall gpio-mxs driver already reads alias to assign port->id for DT boot at the beginning of probe function, and this patch is completely a noise therefore. So can you please drop the patch from you branch? Sorry again.

Signature · 2 lines
Regards,
Shawn
#7 lore raw

PATCH 3/4 gpio/mxs: specify gpio base for device tree probe

Quoted 9 lines · Shawn Guo
Quoted 8 lines · Linus Walleij
Quoted 5 lines · Shawn Guo

Currently, unlike the non-DT probe where the gpio base is specified with pdev->id, the DT probe uses the base dynamically allocated by gpio core, which uses a completely different numbering scheme. This causes two issues to user space applications which access sysfs entry /sys/class/gpio/gpioN.

Quoted 6 lines
Quoted 2 lines

Applied.

Sorry, Linus. I just recall gpio-mxs driver already reads alias to assign port->id for DT boot at the beginning of probe function, and this patch is completely a noise therefore. So can you please drop the patch from you branch? Sorry again.

OK dropped this patch...

Yours,
Linus Walleij

author
#8 lore raw

PATCH 4/4 ARM: dts: imx: add alias for gpio

In reply to Shawn Guo

Add alias for gpio nodes, so that gpio driver can identify the port number and then specify a sensible gpio base rather than using the one dynamically allocated by gpio core.

---
 arch/arm/boot/dts/imx27.dtsi |    6 ++++++
 arch/arm/boot/dts/imx51.dtsi |    4 ++++
 arch/arm/boot/dts/imx53.dtsi |    7 +++++++
 arch/arm/boot/dts/imx6q.dtsi |    7 +++++++
 4 files changed, 24 insertions(+), 0 deletions(-)
arch/arm/boot/dts/imx27.dtsi +6 -0
index 00bae3a..5303ab6 100644
@@ -19,6 +19,12 @@
 		serial3 = &uart4;
 		serial4 = &uart5;
 		serial5 = &uart6;
+		gpio0 = &gpio1;
+		gpio1 = &gpio2;
+		gpio2 = &gpio3;
+		gpio3 = &gpio4;
+		gpio4 = &gpio5;
+		gpio5 = &gpio6;
 	};
 
 	avic: avic-interrupt-controller at e0000000 {
arch/arm/boot/dts/imx51.dtsi +4 -0
index 53cbaa3..aba28dc 100644
@@ -17,6 +17,10 @@
 		serial0 = &uart1;
 		serial1 = &uart2;
 		serial2 = &uart3;
+		gpio0 = &gpio1;
+		gpio1 = &gpio2;
+		gpio2 = &gpio3;
+		gpio3 = &gpio4;
 	};
 
 	tzic: tz-interrupt-controller at e0000000 {
arch/arm/boot/dts/imx53.dtsi +7 -0
index fc79cdc..cd37165 100644
@@ -19,6 +19,13 @@
 		serial2 = &uart3;
 		serial3 = &uart4;
 		serial4 = &uart5;
+		gpio0 = &gpio1;
+		gpio1 = &gpio2;
+		gpio2 = &gpio3;
+		gpio3 = &gpio4;
+		gpio4 = &gpio5;
+		gpio5 = &gpio6;
+		gpio6 = &gpio7;
 	};
 
 	tzic: tz-interrupt-controller at 0fffc000 {
arch/arm/boot/dts/imx6q.dtsi +7 -0
index 3d3c64b..fd57079 100644
@@ -19,6 +19,13 @@
 		serial2 = &uart3;
 		serial3 = &uart4;
 		serial4 = &uart5;
+		gpio0 = &gpio1;
+		gpio1 = &gpio2;
+		gpio2 = &gpio3;
+		gpio3 = &gpio4;
+		gpio4 = &gpio5;
+		gpio5 = &gpio6;
+		gpio6 = &gpio7;
 	};
 
 	cpus {
Signature · 1 line
1.7.5.4
#9 lore raw

PATCH 4/4 ARM: dts: imx: add alias for gpio

Quoted 5 lines · Shawn Guo

Add alias for gpio nodes, so that gpio driver can identify the port number and then specify a sensible gpio base rather than using the one dynamically allocated by gpio core.

Applied.

Thanks,
Linus Walleij

#10 lore raw

PATCH 1/4 gpio/mxc: remove redundant shadow variables initialization

In reply to Shawn Guo
Quoted 8 lines · Shawn Guo

With commit 3e11f7b (gpio/generic: initialize basic_mmio_gpio shadow variables properly) in place, the shadow variables initialization is being done in generic driver bgpio_init call.

Remove the redundant shadow variables initialization from gpio-mxc driver.

Applied.

Thanks,
Linus Walleij

#11 lore raw

PATCH 1/4 gpio/mxc: remove redundant shadow variables initialization

In reply to Shawn Guo
Quoted 8 lines · Shawn Guo

With commit 3e11f7b (gpio/generic: initialize basic_mmio_gpio shadow variables properly) in place, the shadow variables initialization is being done in generic driver bgpio_init call.

Remove the redundant shadow variables initialization from gpio-mxc driver.

Whole series:

Looks good :)

Many thanks

Dirk

Quoted 17 lines
---
 drivers/gpio/gpio-mxc.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/gpio/gpio-mxc.c +0 -2
index 4db460b..76e8cda 100644
@@ -466,8 +466,6 @@ static int __devinit mxc_gpio_probe(struct platform_device *pdev)
 
 	port->bgc.gc.to_irq = mxc_gpio_to_irq;
 	port->bgc.gc.base = pdev->id * 32;
-	port->bgc.dir = port->bgc.read_reg(port->bgc.reg_dir);
-	port->bgc.data = port->bgc.read_reg(port->bgc.reg_set);
 
 	err = gpiochip_add(&port->bgc.gc);
 	if (err)