public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] regmap: Add helper function for checking if a register range is volatile
@ 2011-11-08 17:37 Lars-Peter Clausen
  2011-11-08 17:37 ` [PATCH 2/2] regmap: Support some more block operations on cached devices Lars-Peter Clausen
  2011-11-09  0:57 ` [PATCH 1/2] regmap: Add helper function for checking if a register range is volatile Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Lars-Peter Clausen @ 2011-11-08 17:37 UTC (permalink / raw)
  To: Mark Brown; +Cc: Dimitris Papastamos, linux-kernel, Lars-Peter Clausen

We already have the same code for checking whether a register range is volatile
in two different places. Instead of duplicating it once more  add a small helper
function for checking whether a register range is voltaile.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/base/regmap/regmap.c |   29 ++++++++++++++++-------------
 1 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index bf441db..4016b00 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -64,6 +64,18 @@ bool regmap_precious(struct regmap *map, unsigned int reg)
 	return false;
 }
 
+static bool regmap_volatile_range(struct regmap *map, unsigned int reg,
+	unsigned int num)
+{
+	unsigned int i;
+
+	for (i = 0; i < num; i++)
+		if (!regmap_volatile(map, reg + i))
+			return false;
+
+	return true;
+}
+
 static void regmap_format_4_12_write(struct regmap *map,
 				     unsigned int reg, unsigned int val)
 {
@@ -481,15 +493,11 @@ EXPORT_SYMBOL_GPL(regmap_read);
 int regmap_raw_read(struct regmap *map, unsigned int reg, void *val,
 		    size_t val_len)
 {
+	size_t val_count = val_len / map->format.val_bytes;
 	int ret;
-	int i;
-	bool vol = true;
-
-	for (i = 0; i < val_len / map->format.val_bytes; i++)
-		if (!regmap_volatile(map, reg + i))
-			vol = false;
 
-	WARN_ON(!vol && map->cache_type != REGCACHE_NONE);
+	WARN_ON(!regmap_volatile_range(map, reg, val_count) &&
+		map->cache_type != REGCACHE_NONE);
 
 	mutex_lock(&map->lock);
 
@@ -517,16 +525,11 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
 {
 	int ret, i;
 	size_t val_bytes = map->format.val_bytes;
-	bool vol = true;
+	bool vol = regmap_volatile_range(map, reg, val_count);
 
 	if (!map->format.parse_val)
 		return -EINVAL;
 
-	/* Is this a block of volatile registers? */
-	for (i = 0; i < val_count; i++)
-		if (!regmap_volatile(map, reg + i))
-			vol = false;
-
 	if (vol || map->cache_type == REGCACHE_NONE) {
 		ret = regmap_raw_read(map, reg, val, val_bytes * val_count);
 		if (ret != 0)
-- 
1.7.7



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] regmap: Support some more block operations on cached devices
  2011-11-08 17:37 [PATCH 1/2] regmap: Add helper function for checking if a register range is volatile Lars-Peter Clausen
@ 2011-11-08 17:37 ` Lars-Peter Clausen
  2011-11-09 12:14   ` Dimitris Papastamos
  2011-11-09  0:57 ` [PATCH 1/2] regmap: Add helper function for checking if a register range is volatile Mark Brown
  1 sibling, 1 reply; 4+ messages in thread
From: Lars-Peter Clausen @ 2011-11-08 17:37 UTC (permalink / raw)
  To: Mark Brown; +Cc: Dimitris Papastamos, linux-kernel, Lars-Peter Clausen

Commit 10a08d9f ("regmap: Support some block operations on cached devices")
allowed raw read operations without throwing a warning when using caches if
all registers are volatile. This patch does the same for raw write operations.

This is for example useful when loading a firmware in a predefined volatile
region on a chip where we otherwise want registers to be cached.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/base/regmap/regmap.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 4016b00..a471083 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -387,9 +387,11 @@ EXPORT_SYMBOL_GPL(regmap_write);
 int regmap_raw_write(struct regmap *map, unsigned int reg,
 		     const void *val, size_t val_len)
 {
+	size_t val_count = val_len / map->format.val_bytes;
 	int ret;
 
-	WARN_ON(map->cache_type != REGCACHE_NONE);
+	WARN_ON(!regmap_volatile_range(map, reg, val_count) &&
+		map->cache_type != REGCACHE_NONE);
 
 	mutex_lock(&map->lock);
 
-- 
1.7.7



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] regmap: Add helper function for checking if a register range is volatile
  2011-11-08 17:37 [PATCH 1/2] regmap: Add helper function for checking if a register range is volatile Lars-Peter Clausen
  2011-11-08 17:37 ` [PATCH 2/2] regmap: Support some more block operations on cached devices Lars-Peter Clausen
@ 2011-11-09  0:57 ` Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2011-11-09  0:57 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Dimitris Papastamos, linux-kernel

On Tue, Nov 08, 2011 at 06:37:25PM +0100, Lars-Peter Clausen wrote:
> We already have the same code for checking whether a register range is volatile
> in two different places. Instead of duplicating it once more  add a small helper
> function for checking whether a register range is voltaile.

Applied both, thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] regmap: Support some more block operations on cached devices
  2011-11-08 17:37 ` [PATCH 2/2] regmap: Support some more block operations on cached devices Lars-Peter Clausen
@ 2011-11-09 12:14   ` Dimitris Papastamos
  0 siblings, 0 replies; 4+ messages in thread
From: Dimitris Papastamos @ 2011-11-09 12:14 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Mark Brown, linux-kernel

On Tue, Nov 08, 2011 at 06:37:26PM +0100, Lars-Peter Clausen wrote:
> Commit 10a08d9f ("regmap: Support some block operations on cached devices")
> allowed raw read operations without throwing a warning when using caches if
> all registers are volatile. This patch does the same for raw write operations.
> 
> This is for example useful when loading a firmware in a predefined volatile
> region on a chip where we otherwise want registers to be cached.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> ---
>  drivers/base/regmap/regmap.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
> index 4016b00..a471083 100644
> --- a/drivers/base/regmap/regmap.c
> +++ b/drivers/base/regmap/regmap.c
> @@ -387,9 +387,11 @@ EXPORT_SYMBOL_GPL(regmap_write);
>  int regmap_raw_write(struct regmap *map, unsigned int reg,
>  		     const void *val, size_t val_len)
>  {
> +	size_t val_count = val_len / map->format.val_bytes;
>  	int ret;
>  
> -	WARN_ON(map->cache_type != REGCACHE_NONE);
> +	WARN_ON(!regmap_volatile_range(map, reg, val_count) &&
> +		map->cache_type != REGCACHE_NONE);
>  
>  	mutex_lock(&map->lock);
>  
> -- 
> 1.7.7

Acked-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-09 12:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-08 17:37 [PATCH 1/2] regmap: Add helper function for checking if a register range is volatile Lars-Peter Clausen
2011-11-08 17:37 ` [PATCH 2/2] regmap: Support some more block operations on cached devices Lars-Peter Clausen
2011-11-09 12:14   ` Dimitris Papastamos
2011-11-09  0:57 ` [PATCH 1/2] regmap: Add helper function for checking if a register range is volatile Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox