Skip to content

Commit

Permalink
Merge tag 'regmap-3.4-fixes' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/git/broonie/regmap

Pull two more small regmap fixes from Mark Brown:
 - Now we have users for it that aren't running Android it turns out
   that regcache_sync_region() is much more useful to drivers if it's
   exported for use by modules.  Who knew?
 - Make sure we don't divide by zero when doing debugfs dumps of
   rbtrees, not visible up until now because everything was providing at
   least some cache on startup.

* tag 'regmap-3.4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap:
  regmap: prevent division by zero in rbtree_show
  regmap: Export regcache_sync_region()
  • Loading branch information
torvalds committed Apr 7, 2012
2 parents a3fac08 + c04c1b9 commit f4e52e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/base/regmap/regcache-rbtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ static int rbtree_show(struct seq_file *s, void *ignored)
unsigned int base, top;
int nodes = 0;
int registers = 0;
int average;

mutex_lock(&map->lock);

Expand All @@ -152,8 +153,13 @@ static int rbtree_show(struct seq_file *s, void *ignored)
registers += top - base + 1;
}

if (nodes)
average = registers / nodes;
else
average = 0;

seq_printf(s, "%d nodes, %d registers, average %d registers\n",
nodes, registers, registers / nodes);
nodes, registers, average);

mutex_unlock(&map->lock);

Expand Down
1 change: 1 addition & 0 deletions drivers/base/regmap/regcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ int regcache_sync_region(struct regmap *map, unsigned int min,

return ret;
}
EXPORT_SYMBOL_GPL(regcache_sync_region);

/**
* regcache_cache_only: Put a register map into cache only mode
Expand Down

0 comments on commit f4e52e7

Please sign in to comment.