Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1456452 > unrolled thread

[PATCH 2/2] regmap: debugfs: Add support for dumping write only device registers

Started byCristian Birsan <cristian.birsan@microchip.com>
First post2016-08-04 17:00 +0200
Last post2016-08-05 10:30 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/2] regmap: debugfs: Add support for dumping write only device registers Cristian Birsan <cristian.birsan@microchip.com> - 2016-08-04 17:00 +0200
    Re: [PATCH 2/2] regmap: debugfs: Add support for dumping write only  device registers Mark Brown <broonie@kernel.org> - 2016-08-04 22:30 +0200
      Re: [PATCH 2/2] regmap: debugfs: Add support for dumping write only  device registers Nicolas Ferre <nicolas.ferre@atmel.com> - 2016-08-05 10:30 +0200

#1456452 — [PATCH 2/2] regmap: debugfs: Add support for dumping write only device registers

FromCristian Birsan <cristian.birsan@microchip.com>
Date2016-08-04 17:00 +0200
Subject[PATCH 2/2] regmap: debugfs: Add support for dumping write only device registers
Message-ID<s2shP-28W-1@gated-at.bofh.it>
Add support for dumping write only device registers in debugfs. This is
useful for audio codecs that have write only registers (like WM8731).
The logic that decides if a value can be printed is moved to
regmap_printable() function to allow for easier future updates.

Signed-off-by: Cristian Birsan <cristian.birsan@microchip.com>
---
 drivers/base/regmap/regmap-debugfs.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index 3f0a7e2..8db10e9 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -77,6 +77,17 @@ static void regmap_debugfs_free_dump_cache(struct regmap *map)
 	}
 }
 
+static bool regmap_printable(struct regmap *map, unsigned int reg)
+{
+	if (regmap_precious(map, reg))
+		return false;
+
+	if (!regmap_readable(map, reg) && !regmap_cached(map, reg))
+		return false;
+
+	return true;
+}
+
 /*
  * Work out where the start offset maps into register numbers, bearing
  * in mind that we suppress hidden registers.
@@ -105,8 +116,7 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map,
 	if (list_empty(&map->debugfs_off_cache)) {
 		for (; i <= map->max_register; i += map->reg_stride) {
 			/* Skip unprinted registers, closing off cache entry */
-			if (!regmap_readable(map, i) ||
-			    regmap_precious(map, i)) {
+			if (!regmap_printable(map, i)) {
 				if (c) {
 					c->max = p - 1;
 					c->max_reg = i - map->reg_stride;
@@ -204,7 +214,7 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
 	start_reg = regmap_debugfs_get_dump_start(map, from, *ppos, &p);
 
 	for (i = start_reg; i <= to; i += map->reg_stride) {
-		if (!regmap_readable(map, i))
+		if (!regmap_readable(map, i) && !regmap_cached(map, i))
 			continue;
 
 		if (regmap_precious(map, i))
@@ -222,7 +232,11 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
 			buf_pos += map->debugfs_reg_len + 2;
 
 			/* Format the value, write all X if we can't read */
-			ret = regmap_read(map, i, &val);
+			if (regmap_readable(map, i))
+				ret = regmap_read(map, i, &val);
+			else
+				ret = regcache_read(map, i, &val);
+
 			if (ret == 0)
 				snprintf(buf + buf_pos, count - buf_pos,
 					 "%.*x", map->debugfs_val_len, val);
-- 
1.9.1

[toc] | [next] | [standalone]


#1456714 — Re: [PATCH 2/2] regmap: debugfs: Add support for dumping write only device registers

FromMark Brown <broonie@kernel.org>
Date2016-08-04 22:30 +0200
SubjectRe: [PATCH 2/2] regmap: debugfs: Add support for dumping write only device registers
Message-ID<s2xrb-62U-1@gated-at.bofh.it>
In reply to#1456452

[Multipart message — attachments visible in raw view] — view raw

On Thu, Aug 04, 2016 at 05:55:58PM +0300, Cristian Birsan wrote:
> Add support for dumping write only device registers in debugfs. This is
> useful for audio codecs that have write only registers (like WM8731).
> The logic that decides if a value can be printed is moved to
> regmap_printable() function to allow for easier future updates.

Please check your CC list when sending things upstream - try to ensure
that people you're sending patches to are relevant to the patch.
Maintainers often get lots of mail and having to sort out mail that's
not really relevant to them can make it easier for relevant mail to get
missed.

> +static bool regmap_printable(struct regmap *map, unsigned int reg)
> +{
> +	if (regmap_precious(map, reg))
> +		return false;
> +
> +	if (!regmap_readable(map, reg) && !regmap_cached(map, reg))
> +		return false;
> +
> +	return true;
> +}

This only has one user...

>  	for (i = start_reg; i <= to; i += map->reg_stride) {
> -		if (!regmap_readable(map, i))
> +		if (!regmap_readable(map, i) && !regmap_cached(map, i))
>  			continue;
>  

...though it could have more.

> -			ret = regmap_read(map, i, &val);
> +			if (regmap_readable(map, i))
> +				ret = regmap_read(map, i, &val);
> +			else
> +				ret = regcache_read(map, i, &val);
> +

I don't understand this change, a read will go to cache anyway.

[toc] | [prev] | [next] | [standalone]


#1456945 — Re: [PATCH 2/2] regmap: debugfs: Add support for dumping write only device registers

FromNicolas Ferre <nicolas.ferre@atmel.com>
Date2016-08-05 10:30 +0200
SubjectRe: [PATCH 2/2] regmap: debugfs: Add support for dumping write only device registers
Message-ID<s2IFX-52N-19@gated-at.bofh.it>
In reply to#1456714

[Multipart message — attachments visible in raw view] — view raw

Le 04/08/2016 à 22:26, Mark Brown a écrit :
> On Thu, Aug 04, 2016 at 05:55:58PM +0300, Cristian Birsan wrote:
>> Add support for dumping write only device registers in debugfs. This is
>> useful for audio codecs that have write only registers (like WM8731).
>> The logic that decides if a value can be printed is moved to
>> regmap_printable() function to allow for easier future updates.
> 
> Please check your CC list when sending things upstream - try to ensure
> that people you're sending patches to are relevant to the patch.
> Maintainers often get lots of mail and having to sort out mail that's
> not really relevant to them can make it easier for relevant mail to get
> missed.

Mark,

Just FYI, I gave Cristian the CC list he could use: In fact the Atmel /
Microchip / Free-Electons people are in the list because we are all
working together on the AT91 platforms now. And these platforms use the
audio codec Cristian is working on.


>> +static bool regmap_printable(struct regmap *map, unsigned int reg)
>> +{
>> +	if (regmap_precious(map, reg))
>> +		return false;
>> +
>> +	if (!regmap_readable(map, reg) && !regmap_cached(map, reg))
>> +		return false;
>> +
>> +	return true;
>> +}
> 
> This only has one user...
> 
>>  	for (i = start_reg; i <= to; i += map->reg_stride) {
>> -		if (!regmap_readable(map, i))
>> +		if (!regmap_readable(map, i) && !regmap_cached(map, i))
>>  			continue;
>>  
> 
> ...though it could have more.
> 
>> -			ret = regmap_read(map, i, &val);
>> +			if (regmap_readable(map, i))
>> +				ret = regmap_read(map, i, &val);
>> +			else
>> +				ret = regcache_read(map, i, &val);
>> +
> 
> I don't understand this change, a read will go to cache anyway.
> 


-- 
Nicolas Ferre

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web