diff options
| author | David S. Miller <davem@davemloft.net> | 2013-01-29 15:32:13 -0500 | 
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2013-01-29 15:32:13 -0500 | 
| commit | f1e7b73acc26e8908af783bcd3a9900fd80688f5 (patch) | |
| tree | 9a9382fb7f12f1889020efb4bffa3f4a88589fc5 /drivers/base/regmap/regmap-debugfs.c | |
| parent | 218774dc341f219bfcf940304a081b121a0e8099 (diff) | |
| parent | fc16e884a2320198b8cb7bc2fdcf6b4485e79709 (diff) | |
| download | olio-linux-3.10-f1e7b73acc26e8908af783bcd3a9900fd80688f5.tar.xz olio-linux-3.10-f1e7b73acc26e8908af783bcd3a9900fd80688f5.zip  | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Bring in the 'net' tree so that we can get some ipv4/ipv6 bug
fixes that some net-next work will build upon.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/base/regmap/regmap-debugfs.c')
| -rw-r--r-- | drivers/base/regmap/regmap-debugfs.c | 51 | 
1 files changed, 38 insertions, 13 deletions
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c index 07aad786f81..d9a6c94ce42 100644 --- a/drivers/base/regmap/regmap-debugfs.c +++ b/drivers/base/regmap/regmap-debugfs.c @@ -56,6 +56,19 @@ static const struct file_operations regmap_name_fops = {  	.llseek = default_llseek,  }; +static void regmap_debugfs_free_dump_cache(struct regmap *map) +{ +	struct regmap_debugfs_off_cache *c; + +	while (!list_empty(&map->debugfs_off_cache)) { +		c = list_first_entry(&map->debugfs_off_cache, +				     struct regmap_debugfs_off_cache, +				     list); +		list_del(&c->list); +		kfree(c); +	} +} +  /*   * Work out where the start offset maps into register numbers, bearing   * in mind that we suppress hidden registers. @@ -91,8 +104,10 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map,  			/* No cache entry?  Start a new one */  			if (!c) {  				c = kzalloc(sizeof(*c), GFP_KERNEL); -				if (!c) -					break; +				if (!c) { +					regmap_debugfs_free_dump_cache(map); +					return base; +				}  				c->min = p;  				c->base_reg = i;  			} @@ -101,14 +116,32 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map,  		}  	} +	/* Close the last entry off if we didn't scan beyond it */ +	if (c) { +		c->max = p - 1; +		list_add_tail(&c->list, +			      &map->debugfs_off_cache); +	} + +	/* +	 * This should never happen; we return above if we fail to +	 * allocate and we should never be in this code if there are +	 * no registers at all. +	 */ +	if (list_empty(&map->debugfs_off_cache)) { +		WARN_ON(list_empty(&map->debugfs_off_cache)); +		return base; +	} +  	/* Find the relevant block */  	list_for_each_entry(c, &map->debugfs_off_cache, list) { -		if (*pos >= c->min && *pos <= c->max) { +		if (from >= c->min && from <= c->max) {  			*pos = c->min;  			return c->base_reg;  		} -		ret = c->max; +		*pos = c->min; +		ret = c->base_reg;  	}  	return ret; @@ -387,16 +420,8 @@ void regmap_debugfs_init(struct regmap *map, const char *name)  void regmap_debugfs_exit(struct regmap *map)  { -	struct regmap_debugfs_off_cache *c; -  	debugfs_remove_recursive(map->debugfs); -	while (!list_empty(&map->debugfs_off_cache)) { -		c = list_first_entry(&map->debugfs_off_cache, -				     struct regmap_debugfs_off_cache, -				     list); -		list_del(&c->list); -		kfree(c); -	} +	regmap_debugfs_free_dump_cache(map);  	kfree(map->debugfs_name);  }  |