diff options
| author | Måns Rullgård <[email protected]> | 2015-12-15 22:27:57 +0000 |
|---|---|---|
| committer | Stefano Babic <[email protected]> | 2016-01-07 17:54:16 +0100 |
| commit | 88f91d1375aaf4d21d77a2f2daa351dea9132a58 (patch) | |
| tree | 773d349d3cbd8d2abea662bda72a4d026281bed7 /drivers | |
| parent | fcbe8c56743a1f8ec397a71d5a932faee920bc8a (diff) | |
gpio: mxs: add name_to_gpio() function
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 <[email protected]>
Reviewed-by: Stefano Babic <[email protected]>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/gpio/mxs_gpio.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/gpio/mxs_gpio.c b/drivers/gpio/mxs_gpio.c index da0199b168a..b54a10b4933 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); +} |
