Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 267011
b: refs/heads/master
c: f094fea
h: refs/heads/master
i:
  267009: 74fca98
  267007: 0a25e4a
v: v3
  • Loading branch information
Mark Brown committed Oct 9, 2011
1 parent b4c1a29 commit 792c5b2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 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: 0eef6b0415f58ed16aff95af8c92514ce5c01258
refs/heads/master: f094fea68f0575286c55c06141cc89ffd0049024
40 changes: 20 additions & 20 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/bsearch.h>
#include <linux/sort.h>

#include "internal.h"
Expand Down Expand Up @@ -355,32 +356,31 @@ unsigned int regcache_get_val(const void *base, unsigned int idx,
return -1;
}

int regcache_lookup_reg(struct regmap *map, unsigned int reg)
{
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)
static int regcache_default_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_lookup_reg(struct regmap *map, unsigned int reg)
{
struct reg_default key;
struct reg_default *r;

key.reg = reg;
key.def = 0;

r = bsearch(&key, map->reg_defaults, map->num_reg_defaults,
sizeof(struct reg_default), regcache_default_cmp);

if (r)
return r - map->reg_defaults;
else
return -1;
}

int regcache_insert_reg(struct regmap *map, unsigned int reg,
unsigned int val)
{
Expand All @@ -396,6 +396,6 @@ int regcache_insert_reg(struct regmap *map, unsigned int reg,
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);
sizeof(struct reg_default), regcache_default_cmp, NULL);
return 0;
}

0 comments on commit 792c5b2

Please sign in to comment.