Commit 0f04b761 authored by Michael Welling's avatar Michael Welling
Browse files

ARRAY_SIZE no workie on pointers.


Signed-off-by: default avatarMichael Welling <mwelling@emacinc.com>
parent 342a8c08
......@@ -49,7 +49,7 @@ static gpio_data gpio_data_read(struct gpio_s *gpio)
int i;
value = 0;
for(i = 0; i < ARRAY_SIZE(gpio->gpio_set); i++)
for(i = 0; i < gpio->gpio_cnt; i++)
value |= (gpio_get_value(gpio->gpio_set[i]) << i);
return value;
......@@ -59,7 +59,7 @@ static int gpio_data_write(struct gpio_s *gpio, gpio_data data)
{
int i;
for(i = 0; i < ARRAY_SIZE(gpio->gpio_set); i++)
for(i = 0; i < gpio->gpio_cnt; i++)
gpio_set_value(gpio->gpio_set[i], (data >> i) & 1);
return 0;
......@@ -76,7 +76,7 @@ static int gpio_ddr_write(struct gpio_s *gpio, gpio_data data)
gpio->ddr_shadow = data;
for(i = 0; i < ARRAY_SIZE(gpio->gpio_set); i++)
for(i = 0; i < gpio->gpio_cnt; i++)
{
if (data & (1 << i))
gpio_direction_output(gpio->gpio_set[i], 0);
......@@ -86,8 +86,8 @@ static int gpio_ddr_write(struct gpio_s *gpio, gpio_data data)
return 0;
}
struct device * gpio_class_create(char * name, int * gpio_array, int direction,
int value)
struct device * gpio_class_create(char * name, int * gpio_array, int gpio_count,
int direction, int value)
{
gpio_t *gpio = kzalloc(sizeof(gpio_t), GFP_KERNEL);
......@@ -100,6 +100,7 @@ struct device * gpio_class_create(char * name, int * gpio_array, int direction,
gpio->ddr_write = gpio_ddr_write;
gpio->ddr_read = gpio_ddr_read;
gpio->gpio_set = gpio_array;
gpio->gpio_cnt = gpio_count;
gpio_ddr_write(gpio, direction);
gpio_data_write(gpio, value);
......@@ -150,8 +151,8 @@ int boardspec_generic_init_of(struct device_node * np)
if (tprop)
value = of_read_ulong(tprop, 1);
if (gpio_class_create(prop->name, curr_gpio, direction,
value) == NULL)
if (gpio_class_create(prop->name, curr_gpio, curr_count,
direction, value) == NULL)
return -ENOMEM;
}
......
......@@ -62,6 +62,7 @@ typedef struct gpio_s {
struct mutex lock;
struct gpio_irq_data irq_data;
int *gpio_set;
int gpio_cnt;
#ifdef CONFIG_GPIOCLASS_CHAR
struct cdev *cdev;
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment