summaryrefslogtreecommitdiffstats
path: root/arch/blackfin/mach-bf548
diff options
context:
space:
mode:
authorMichael Hennerich <michael.hennerich@analog.com>2007-08-03 17:48:09 +0800
committerBryan Wu <bryan.wu@analog.com>2007-08-03 17:48:09 +0800
commit8c61362377970cd35cc37960b5cbed03cecd57e7 (patch)
tree10eae56e854776831c5de318b2c30f3e3a62c057 /arch/blackfin/mach-bf548
parent1708268f7ee5177c35826f047b91d7324f099ab0 (diff)
downloadblackbird-op-linux-8c61362377970cd35cc37960b5cbed03cecd57e7.tar.gz
blackbird-op-linux-8c61362377970cd35cc37960b5cbed03cecd57e7.zip
Blackfin arch: Some cosmetics based on LKML feedback from Joe Perches
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Cc: Joe Perches <joe@perches.com> Signed-off-by: Bryan Wu <bryan.wu@analog.com>
Diffstat (limited to 'arch/blackfin/mach-bf548')
-rw-r--r--arch/blackfin/mach-bf548/gpio.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/arch/blackfin/mach-bf548/gpio.c b/arch/blackfin/mach-bf548/gpio.c
index f3b9deacd332..390dd8c12430 100644
--- a/arch/blackfin/mach-bf548/gpio.c
+++ b/arch/blackfin/mach-bf548/gpio.c
@@ -49,9 +49,13 @@ static struct gpio_port_t *gpio_array[gpio_bank(MAX_BLACKFIN_GPIOS)] = {
static unsigned short reserved_gpio_map[gpio_bank(MAX_BLACKFIN_GPIOS)];
static unsigned short reserved_peri_map[gpio_bank(MAX_BLACKFIN_GPIOS)];
-char *str_ident = NULL;
-#define RESOURCE_LABEL_SIZE 16
+#define MAX_RESOURCES 256
+#define RESOURCE_LABEL_SIZE 16
+
+struct str_ident {
+ char name[RESOURCE_LABEL_SIZE];
+} *str_ident;
inline int check_gpio(unsigned short gpio)
{
@@ -96,10 +100,13 @@ static void port_setup(unsigned short gpio, unsigned short usage)
static int __init bfin_gpio_init(void)
{
- str_ident = kzalloc(RESOURCE_LABEL_SIZE * 256, GFP_KERNEL);
- if (!str_ident)
+ str_ident = kcalloc(MAX_RESOURCES,
+ sizeof(struct str_ident), GFP_KERNEL);
+ if (str_ident == NULL)
return -ENOMEM;
+ memset(str_ident, 0, MAX_RESOURCES * sizeof(struct str_ident));
+
printk(KERN_INFO "Blackfin GPIO Controller\n");
return 0;
@@ -111,10 +118,9 @@ static void set_label(unsigned short ident, const char *label)
{
if (label && str_ident) {
- strncpy(str_ident + ident * RESOURCE_LABEL_SIZE, label,
+ strncpy(str_ident[ident].name, label,
RESOURCE_LABEL_SIZE);
- str_ident[ident * RESOURCE_LABEL_SIZE +
- RESOURCE_LABEL_SIZE - 1] = 0;
+ str_ident[ident].name[RESOURCE_LABEL_SIZE - 1] = 0;
}
}
@@ -123,14 +129,13 @@ static char *get_label(unsigned short ident)
if (!str_ident)
return "UNKNOWN";
- return (str_ident[ident * RESOURCE_LABEL_SIZE] ?
- (str_ident + ident * RESOURCE_LABEL_SIZE) : "UNKNOWN");
+ return (*str_ident[ident].name ? str_ident[ident].name : "UNKNOWN");
}
static int cmp_label(unsigned short ident, const char *label)
{
if (label && str_ident)
- return strncmp(str_ident + ident * RESOURCE_LABEL_SIZE,
+ return strncmp(str_ident[ident].name,
label, strlen(label));
else
return -EINVAL;
OpenPOWER on IntegriCloud