Title: [5949] trunk/drivers/mtd/maps/gpio-addr-flash.c: cache the last gpio state since accesses are much more often in the same subbank rather than crossing boundaries ...
- Revision
- 5949
- Author
- vapier
- Date
- 2009-01-06 08:19:54 -0600 (Tue, 06 Jan 2009)
Log Message
cache the last gpio state since accesses are much more often in the same subbank rather than crossing boundaries ... no point in calling the gpio layer (which might be quite a bit of overhead) just to set the gpio state to the state it is already at
Modified Paths
Diff
Modified: trunk/drivers/mtd/maps/gpio-addr-flash.c (5948 => 5949)
--- trunk/drivers/mtd/maps/gpio-addr-flash.c 2009-01-06 14:18:11 UTC (rev 5948)
+++ trunk/drivers/mtd/maps/gpio-addr-flash.c 2009-01-06 14:19:54 UTC (rev 5949)
@@ -35,14 +35,21 @@
struct map_info map;
size_t gpio_count;
unsigned *gpio_addrs;
+ int *gpio_values;
unsigned long win_size;
};
static void gf_set_gpios(struct async_state *state, unsigned long ofs)
{
size_t i;
- for (i = 0; i < state->gpio_count; ++i)
- gpio_set_value(state->gpio_addrs[i], !!((ofs / state->win_size) & (1 << i)));
+ int value;
+ for (i = 0; i < state->gpio_count; ++i) {
+ value = !!((ofs / state->win_size) & (1 << i));
+ if (state->gpio_values[i] != value) {
+ gpio_set_value(state->gpio_addrs[i], value);
+ state->gpio_values[i] = value;
+ }
+ }
}
static map_word gf_read(struct map_info *map, unsigned long ofs)
@@ -108,14 +115,17 @@
struct resource *gpios = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
struct async_state *state;
- state = kzalloc(sizeof(*state) + sizeof(unsigned) * gpios->end, GFP_KERNEL);
+ state = kzalloc(sizeof(*state) + (sizeof(int) * gpios->end * 2), GFP_KERNEL);
if (!state)
return -ENOMEM;
state->gpio_count = gpios->end;
state->gpio_addrs = (void *)(state + 1);
+ state->gpio_values = state->gpio_addrs + state->gpio_count;
state->win_size = memory->end - memory->start + 1;
memcpy(state->gpio_addrs, (void *)gpios->start, sizeof(unsigned) * state->gpio_count);
+ for (i = 0; i < state->gpio_count; ++i)
+ state->gpio_values[i] = -1;
state->map.name = DRIVER_NAME;
state->map.read = gf_read;
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
http://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits