Skip to content

Commit

Permalink
regcache: flat: Un-inline index lookup from cache access
Browse files Browse the repository at this point in the history
This makes the code slightly more readable and allows for cleaner
addition of functionality in later patches.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Andrew F. Davis authored and Mark Brown committed Jan 8, 2018
1 parent 4fbd8d1 commit 46318b9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions drivers/base/regmap/regcache-flat.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ static int regcache_flat_init(struct regmap *map)

cache = map->cache;

for (i = 0; i < map->num_reg_defaults; i++)
cache[regcache_flat_get_index(map, map->reg_defaults[i].reg)] =
map->reg_defaults[i].def;
for (i = 0; i < map->num_reg_defaults; i++) {
unsigned int reg = map->reg_defaults[i].reg;
unsigned int index = regcache_flat_get_index(map, reg);

cache[index] = map->reg_defaults[i].def;
}

return 0;
}
Expand All @@ -56,8 +59,9 @@ static int regcache_flat_read(struct regmap *map,
unsigned int reg, unsigned int *value)
{
unsigned int *cache = map->cache;
unsigned int index = regcache_flat_get_index(map, reg);

*value = cache[regcache_flat_get_index(map, reg)];
*value = cache[index];

return 0;
}
Expand All @@ -66,8 +70,9 @@ static int regcache_flat_write(struct regmap *map, unsigned int reg,
unsigned int value)
{
unsigned int *cache = map->cache;
unsigned int index = regcache_flat_get_index(map, reg);

cache[regcache_flat_get_index(map, reg)] = value;
cache[index] = value;

return 0;
}
Expand Down

0 comments on commit 46318b9

Please sign in to comment.