* [U-Boot] [PATCH] gpio: mxs: add name_to_gpio() function
@ 2015-12-15 22:27 Mans Rullgard
2016-01-03 15:05 ` Stefano Babic
0 siblings, 1 reply; 2+ messages in thread
From: Mans Rullgard @ 2015-12-15 22:27 UTC (permalink / raw)
To: u-boot
Override the default name_to_gpio() function with one that
accepts strings of the form bank:pin. If a colon is present
in the provided name, it behaves like the default version.
This lets the "gpio" command work with sane names rather than
requiring the user to enter the bank/pin composite in decimal.
Signed-off-by: Mans Rullgard <mans@mansr.com>
---
drivers/gpio/mxs_gpio.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/gpio/mxs_gpio.c b/drivers/gpio/mxs_gpio.c
index da0199b..b54a10b 100644
--- a/drivers/gpio/mxs_gpio.c
+++ b/drivers/gpio/mxs_gpio.c
@@ -114,3 +114,18 @@ int gpio_free(unsigned gpio)
{
return 0;
}
+
+int name_to_gpio(const char *name)
+{
+ unsigned bank, pin;
+ char *end;
+
+ bank = simple_strtoul(name, &end, 10);
+
+ if (!*end || *end != ':')
+ return bank;
+
+ pin = simple_strtoul(end + 1, NULL, 10);
+
+ return (bank << MXS_PAD_BANK_SHIFT) | (pin << MXS_PAD_PIN_SHIFT);
+}
--
2.6.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] [PATCH] gpio: mxs: add name_to_gpio() function
2015-12-15 22:27 [U-Boot] [PATCH] gpio: mxs: add name_to_gpio() function Mans Rullgard
@ 2016-01-03 15:05 ` Stefano Babic
0 siblings, 0 replies; 2+ messages in thread
From: Stefano Babic @ 2016-01-03 15:05 UTC (permalink / raw)
To: u-boot
On 15/12/2015 23:27, Mans Rullgard wrote:
> Override the default name_to_gpio() function with one that
> accepts strings of the form bank:pin. If a colon is present
> in the provided name, it behaves like the default version.
>
> This lets the "gpio" command work with sane names rather than
> requiring the user to enter the bank/pin composite in decimal.
>
> Signed-off-by: Mans Rullgard <mans@mansr.com>
> ---
> drivers/gpio/mxs_gpio.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/drivers/gpio/mxs_gpio.c b/drivers/gpio/mxs_gpio.c
> index da0199b..b54a10b 100644
> --- a/drivers/gpio/mxs_gpio.c
> +++ b/drivers/gpio/mxs_gpio.c
> @@ -114,3 +114,18 @@ int gpio_free(unsigned gpio)
> {
> return 0;
> }
> +
> +int name_to_gpio(const char *name)
> +{
> + unsigned bank, pin;
> + char *end;
> +
> + bank = simple_strtoul(name, &end, 10);
> +
> + if (!*end || *end != ':')
> + return bank;
> +
> + pin = simple_strtoul(end + 1, NULL, 10);
> +
> + return (bank << MXS_PAD_BANK_SHIFT) | (pin << MXS_PAD_PIN_SHIFT);
> +}
>
Reviewed-by: Stefano Babic <sbabic@denx.de>
Best regards,
Stefano Babic
--
=====================================================================
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-01-03 15:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-15 22:27 [U-Boot] [PATCH] gpio: mxs: add name_to_gpio() function Mans Rullgard
2016-01-03 15:05 ` Stefano Babic
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).