diff mbox series

[v4,07/12] gpio: dw: Add a trailing underscore to generated name

Message ID 20200624102947.359794-8-seanga2@gmail.com
State Superseded
Delegated to: Andes
Headers show
Series riscv: Add FPIOA and GPIO support for Kendryte K210 | expand

Commit Message

Sean Anderson June 24, 2020, 10:29 a.m. UTC
Previously, if there was no bank-name property, it was easy to have
confusing gpio names like "gpio1@08", instead of "gpio1@0_8". This patch
follows the example of the sifive gpio driver.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
---
This patch was previously submitted as part of
https://patchwork.ozlabs.org/project/uboot/list/?series=161576

(no changes since v1)

 drivers/gpio/dwapb_gpio.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Simon Glass July 3, 2020, 12:46 a.m. UTC | #1
On Wed, 24 Jun 2020 at 04:30, Sean Anderson <seanga2@gmail.com> wrote:
>
> Previously, if there was no bank-name property, it was easy to have
> confusing gpio names like "gpio1@08", instead of "gpio1@0_8". This patch
> follows the example of the sifive gpio driver.
>
> Signed-off-by: Sean Anderson <seanga2@gmail.com>
> ---
> This patch was previously submitted as part of
> https://patchwork.ozlabs.org/project/uboot/list/?series=161576
>
> (no changes since v1)
>
>  drivers/gpio/dwapb_gpio.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
index bf324f5239..a52c9e18e3 100644
--- a/drivers/gpio/dwapb_gpio.c
+++ b/drivers/gpio/dwapb_gpio.c
@@ -186,7 +186,15 @@  static int gpio_dwapb_bind(struct udevice *dev)
 			 * Fall back to node name. This means accessing pins
 			 * via bank name won't work.
 			 */
-			plat->name = ofnode_get_name(node);
+			char name[32];
+
+			snprintf(name, sizeof(name), "%s_",
+				 ofnode_get_name(node));
+			plat->name = strdup(name);
+			if (!plat->name) {
+				kfree(plat);
+				return -ENOMEM;
+			}
 		}
 
 		ret = device_bind_ofnode(dev, dev->driver, plat->name,