diff options
Diffstat (limited to 'arch/blackfin/mach-bf548/gpio.c')
-rw-r--r-- | arch/blackfin/mach-bf548/gpio.c | 25 |
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)] = { | |||
49 | 49 | ||
50 | static unsigned short reserved_gpio_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; | 50 | static unsigned short reserved_gpio_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; |
51 | static unsigned short reserved_peri_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; | 51 | static unsigned short reserved_peri_map[gpio_bank(MAX_BLACKFIN_GPIOS)]; |
52 | char *str_ident = NULL; | ||
53 | 52 | ||
54 | #define RESOURCE_LABEL_SIZE 16 | 53 | #define MAX_RESOURCES 256 |
54 | #define RESOURCE_LABEL_SIZE 16 | ||
55 | |||
56 | struct str_ident { | ||
57 | char name[RESOURCE_LABEL_SIZE]; | ||
58 | } *str_ident; | ||
55 | 59 | ||
56 | inline int check_gpio(unsigned short gpio) | 60 | inline int check_gpio(unsigned short gpio) |
57 | { | 61 | { |
@@ -96,10 +100,13 @@ static void port_setup(unsigned short gpio, unsigned short usage) | |||
96 | static int __init bfin_gpio_init(void) | 100 | static int __init bfin_gpio_init(void) |
97 | { | 101 | { |
98 | 102 | ||
99 | str_ident = kzalloc(RESOURCE_LABEL_SIZE * 256, GFP_KERNEL); | 103 | str_ident = kcalloc(MAX_RESOURCES, |
100 | if (!str_ident) | 104 | sizeof(struct str_ident), GFP_KERNEL); |
105 | if (str_ident == NULL) | ||
101 | return -ENOMEM; | 106 | return -ENOMEM; |
102 | 107 | ||
108 | memset(str_ident, 0, MAX_RESOURCES * sizeof(struct str_ident)); | ||
109 | |||
103 | printk(KERN_INFO "Blackfin GPIO Controller\n"); | 110 | printk(KERN_INFO "Blackfin GPIO Controller\n"); |
104 | 111 | ||
105 | return 0; | 112 | return 0; |
@@ -111,10 +118,9 @@ static void set_label(unsigned short ident, const char *label) | |||
111 | { | 118 | { |
112 | 119 | ||
113 | if (label && str_ident) { | 120 | if (label && str_ident) { |
114 | strncpy(str_ident + ident * RESOURCE_LABEL_SIZE, label, | 121 | strncpy(str_ident[ident].name, label, |
115 | RESOURCE_LABEL_SIZE); | 122 | RESOURCE_LABEL_SIZE); |
116 | str_ident[ident * RESOURCE_LABEL_SIZE + | 123 | str_ident[ident].name[RESOURCE_LABEL_SIZE - 1] = 0; |
117 | RESOURCE_LABEL_SIZE - 1] = 0; | ||
118 | } | 124 | } |
119 | } | 125 | } |
120 | 126 | ||
@@ -123,14 +129,13 @@ static char *get_label(unsigned short ident) | |||
123 | if (!str_ident) | 129 | if (!str_ident) |
124 | return "UNKNOWN"; | 130 | return "UNKNOWN"; |
125 | 131 | ||
126 | return (str_ident[ident * RESOURCE_LABEL_SIZE] ? | 132 | return (*str_ident[ident].name ? str_ident[ident].name : "UNKNOWN"); |
127 | (str_ident + ident * RESOURCE_LABEL_SIZE) : "UNKNOWN"); | ||
128 | } | 133 | } |
129 | 134 | ||
130 | static int cmp_label(unsigned short ident, const char *label) | 135 | static int cmp_label(unsigned short ident, const char *label) |
131 | { | 136 | { |
132 | if (label && str_ident) | 137 | if (label && str_ident) |
133 | return strncmp(str_ident + ident * RESOURCE_LABEL_SIZE, | 138 | return strncmp(str_ident[ident].name, |
134 | label, strlen(label)); | 139 | label, strlen(label)); |
135 | else | 140 | else |
136 | return -EINVAL; | 141 | return -EINVAL; |