From: Marek Vasut <marek.vasut@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] M28: Added pin name support in GPIO driver
Date: Tue, 22 Nov 2011 19:28:10 +0100 [thread overview]
Message-ID: <201111221928.11095.marek.vasut@gmail.com> (raw)
In-Reply-To: <B0658F55E67EDE4A914644632835B2CAF7F1E5@DEUTERIUM.delien.local>
> This patch adds adds pin name support in the GPIO driver. With this patch
> applied, the gpio command supports pins to be addressed with friendly
> names.
>
> The user's manual refers to pins by the bank number they're in and their
> number within that bank. With this patch the friendly naming convention to
> address pin number 5 in bank 3 is b3p5. But names like B00000003p005 are
> interpreted correctly too.
>
> Signed-off-by: Robert Deli?n <robert@delien.nl>
> diff --git a/arch/arm/include/asm/arch-mx28/gpio.h
> b/arch/arm/include/asm/arch-mx28/gpio.h index be1c944..5ae66e6 100644
> --- a/arch/arm/include/asm/arch-mx28/gpio.h
> +++ b/arch/arm/include/asm/arch-mx28/gpio.h
No, move this to mxs_gpio.c and simply make the function not static.
> @@ -23,8 +23,44 @@
> #ifndef __MX28_GPIO_H__
> #define __MX28_GPIO_H__
>
> +#include <linux/ctype.h>
> +#include <asm/errno.h>
> +#include <asm/arch/iomux.h>
> +
> #ifdef CONFIG_MXS_GPIO
> void mxs_gpio_init(void);
> +
> +static inline int name_to_gpio(const char *name)
> +{
> + int pin_nr;
> +
> + if (name[0] >= '0' && name[0] <= '9') {
So if I pass name == NULL, we're done for here ;-)
> + pin_nr = simple_strtoul(name, (char **)&name, 10);
> + if (name[0])
> + return -EINVAL;
> + else
> + return pin_nr;
> + }
> +
> + if (tolower(name[0]) == 'b') {
> + name++;
> + pin_nr = (simple_strtoul(name, (char **)&name, 10) <<
> MXS_PAD_BANK_SHIFT) & MXS_PAD_BANK_MASK; + } else
> + return -EINVAL;
Braces missing around this return statement. Also, why not do something like:
if (tolower(name[0]) != 'b')
return -EINVAL;
name++;
pinnr = ...
if (tolower(name[0]) != 'p')
return -EINVAL;
name++;
...
It seems more explicit to me that way.
> +
> + if (tolower(name[0]) == 'p') {
> + name++;
> + pin_nr |= (simple_strtoul(name, (char **)&name, 10) <<
> MXS_PAD_PIN_SHIFT) & MXS_PAD_PIN_MASK; + } else
> + return -EINVAL;
> +
> + if (name[0])
> + return -EINVAL;
> +
> + return pin_nr;
> +}
> +#define name_to_gpio(n) name_to_gpio(n)
What's this define for ?
> +
> #else
> inline void mxs_gpio_init(void) {}
> #endif
Do you even need this if CONFIG_CMD_GPIO is undefined? Move the function to
mxs_gpio.c and make it not static should work for you.
M
next prev parent reply other threads:[~2011-11-22 18:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-22 15:40 [U-Boot] [PATCH] M28: Added pin name support in GPIO driver Robert Deliën
2011-11-22 18:28 ` Marek Vasut [this message]
2011-11-22 19:13 ` Robert Deliën
2011-11-22 19:32 ` Marek Vasut
2011-11-22 20:49 ` Robert Deliën
2011-11-22 22:18 ` Mike Frysinger
2011-11-22 22:37 ` Marek Vasut
2011-11-23 10:08 ` Robert Deliën
2011-11-23 22:18 ` Mike Frysinger
2011-11-22 21:10 ` Mike Frysinger
2011-11-22 21:11 ` Mike Frysinger
2011-11-23 9:07 ` Stefano Babic
2011-11-23 9:51 ` Robert Deliën
2011-11-23 22:11 ` Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201111221928.11095.marek.vasut@gmail.com \
--to=marek.vasut@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox