All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regmap: debugfs: Fix continued read from registers file
@ 2013-08-28 15:55 Lars-Peter Clausen
  2013-08-28 17:27 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Lars-Peter Clausen @ 2013-08-28 15:55 UTC (permalink / raw)
  To: Mark Brown; +Cc: Bard Liao, linux-kernel, Lars-Peter Clausen

The regmap_debugfs_get_dump_start() function maps from a file offset to the
register that can be found at that position in the file. This is done using a
look-up table. Commit d6814a7d ("regmap: debugfs: Suppress cache for partial
register files") added a check to bypass the look-up table for partial register
files, since the offsets in that table are only correct for the full register
file. The check incorrectly uses the file offset instead of the register base
address and returns it. This will cause the file offset to be interpreted as a
register address which will result in a incorrect output from the registers file
for all reads except at position 0.

The issue can easily be reproduced by doing small reads the registers file, e.g.
`dd if=registers bs=10 count=5`.

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

diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index 5349575..6c2652a 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -85,8 +85,8 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map,
 	unsigned int reg_offset;
 
 	/* Suppress the cache if we're using a subrange */
-	if (from)
-		return from;
+	if (base)
+		return base;
 
 	/*
 	 * If we don't have a cache build one so we don't have to do a
-- 
1.8.0


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

* Re: [PATCH] regmap: debugfs: Fix continued read from registers file
  2013-08-28 15:55 [PATCH] regmap: debugfs: Fix continued read from registers file Lars-Peter Clausen
@ 2013-08-28 17:27 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2013-08-28 17:27 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Bard Liao, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 405 bytes --]

On Wed, Aug 28, 2013 at 05:55:07PM +0200, Lars-Peter Clausen wrote:
> The regmap_debugfs_get_dump_start() function maps from a file offset to the
> register that can be found at that position in the file. This is done using a
> look-up table. Commit d6814a7d ("regmap: debugfs: Suppress cache for partial
> register files") added a check to bypass the look-up table for partial register

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2013-08-28 17:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-28 15:55 [PATCH] regmap: debugfs: Fix continued read from registers file Lars-Peter Clausen
2013-08-28 17:27 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.