All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] regmap: debugfs: Optimize seeking within blocks of registers
@ 2013-02-07 11:40 Dimitris Papastamos
  2013-02-08 11:35 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Dimitris Papastamos @ 2013-02-07 11:40 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel, patches

Optimize this so that we can better guess where to start scanning
from.  We know the length of the register field format, therefore
given the file pointer position align to the nearest register
field and scan from there onwards.  We round down in this calculation
and we let the rest of the code figure out where to start scanning
from.

Change-Id: I2515e0981ef6b17f784dd0e389d0d4a13d47123c
Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
---
 drivers/base/regmap/regmap-debugfs.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index c2c51f7..1525f39 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -81,6 +81,8 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map,
 	struct regmap_debugfs_off_cache *c = NULL;
 	loff_t p = 0;
 	unsigned int i, ret;
+	unsigned int fpos_offset;
+	unsigned int reg_offset;
 
 	/*
 	 * If we don't have a cache build one so we don't have to do a
@@ -139,15 +141,17 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map,
 		return base;
 	}
 
-	/* Find the relevant block */
+	/* Find the relevant block:offset */
 	list_for_each_entry(c, &map->debugfs_off_cache, list) {
 		if (from >= c->min && from <= c->max) {
-			*pos = c->min;
-			return c->base_reg;
+			fpos_offset = from - c->min;
+			reg_offset = fpos_offset / map->debugfs_tot_len;
+			*pos = c->min + (reg_offset * map->debugfs_tot_len);
+			return c->base_reg + reg_offset;
 		}
 
-		*pos = c->min;
-		ret = c->base_reg;
+		*pos = c->max;
+		ret = c->max_reg;
 	}
 
 	return ret;
-- 
1.8.1.2


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

* Re: [PATCH 2/2] regmap: debugfs: Optimize seeking within blocks of registers
  2013-02-07 11:40 [PATCH 2/2] regmap: debugfs: Optimize seeking within blocks of registers Dimitris Papastamos
@ 2013-02-08 11:35 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2013-02-08 11:35 UTC (permalink / raw)
  To: Dimitris Papastamos; +Cc: linux-kernel, patches

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

On Thu, Feb 07, 2013 at 11:40:32AM +0000, Dimitris Papastamos wrote:
> Optimize this so that we can better guess where to start scanning
> from.  We know the length of the register field format, therefore
> given the file pointer position align to the nearest register
> field and scan from there onwards.  We round down in this calculation
> and we let the rest of the code figure out where to start scanning
> from.

This doesn't apply against -next.

[-- 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-02-08 11:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-07 11:40 [PATCH 2/2] regmap: debugfs: Optimize seeking within blocks of registers Dimitris Papastamos
2013-02-08 11:35 ` 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.