Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 267009
b: refs/heads/master
c: c08604b
h: refs/heads/master
i:
  267007: 0a25e4a
v: v3
  • Loading branch information
Dimitris Papastamos authored and Mark Brown committed Oct 3, 2011
1 parent eab1459 commit 74fca98
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ac77a765cb6e3b5aa41c186ad9f37db7fdad7dbe
refs/heads/master: c08604b8ae72b4fa1843a76fc7b403ddec49f8f4
29 changes: 24 additions & 5 deletions trunk/drivers/base/regmap/regcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <linux/slab.h>
#include <trace/events/regmap.h>
#include <linux/sort.h>

#include "internal.h"

Expand Down Expand Up @@ -356,14 +357,30 @@ unsigned int regcache_get_val(const void *base, unsigned int idx,

int regcache_lookup_reg(struct regmap *map, unsigned int reg)
{
unsigned int i;

for (i = 0; i < map->num_reg_defaults; i++)
if (map->reg_defaults[i].reg == reg)
return i;
unsigned int min, max, index;

min = 0;
max = map->num_reg_defaults - 1;
do {
index = (min + max) / 2;
if (map->reg_defaults[index].reg == reg)
return index;
if (map->reg_defaults[index].reg < reg)
min = index + 1;
else
max = index;
} while (min <= max);
return -1;
}

static int regcache_insert_cmp(const void *a, const void *b)
{
const struct reg_default *_a = a;
const struct reg_default *_b = b;

return _a->reg - _b->reg;
}

int regcache_insert_reg(struct regmap *map, unsigned int reg,
unsigned int val)
{
Expand All @@ -378,5 +395,7 @@ int regcache_insert_reg(struct regmap *map, unsigned int reg,
map->num_reg_defaults++;
map->reg_defaults[map->num_reg_defaults - 1].reg = reg;
map->reg_defaults[map->num_reg_defaults - 1].def = val;
sort(map->reg_defaults, map->num_reg_defaults,
sizeof(struct reg_default), regcache_insert_cmp, NULL);
return 0;
}

0 comments on commit 74fca98

Please sign in to comment.