* [PATCH] regmap: debugfs: Factor out debugfs_tot_len calc into a function
@ 2013-02-11 10:50 Dimitris Papastamos
2013-02-11 11:27 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Dimitris Papastamos @ 2013-02-11 10:50 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-kernel, patches
In preparation to support the regmap debugfs ranges functionality
factor this code out to a separate function. We'll need to ensure
that the value has been correctly calculated from two separate places
in the code.
Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
---
drivers/base/regmap/regmap-debugfs.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index 246f459..78d5f20 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -155,6 +155,19 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map,
return ret;
}
+static inline void regmap_calc_tot_len(struct regmap *map,
+ void *buf, size_t count)
+{
+ /* Calculate the length of a fixed format */
+ if (!map->debugfs_tot_len) {
+ map->debugfs_reg_len = regmap_calc_reg_len(map->max_register,
+ buf, count);
+ map->debugfs_val_len = 2 * map->format.val_bytes;
+ map->debugfs_tot_len = map->debugfs_reg_len +
+ map->debugfs_val_len + 3; /* : \n */
+ }
+}
+
static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
unsigned int to, char __user *user_buf,
size_t count, loff_t *ppos)
@@ -173,14 +186,7 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
if (!buf)
return -ENOMEM;
- /* Calculate the length of a fixed format */
- if (!map->debugfs_tot_len) {
- map->debugfs_reg_len = regmap_calc_reg_len(map->max_register,
- buf, count);
- map->debugfs_val_len = 2 * map->format.val_bytes;
- map->debugfs_tot_len = map->debugfs_reg_len +
- map->debugfs_val_len + 3; /* : \n */
- }
+ regmap_calc_tot_len(map, buf, count);
/* Work out which register we're starting at */
start_reg = regmap_debugfs_get_dump_start(map, from, *ppos, &p);
--
1.8.1.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] regmap: debugfs: Factor out debugfs_tot_len calc into a function
2013-02-11 10:50 [PATCH] regmap: debugfs: Factor out debugfs_tot_len calc into a function Dimitris Papastamos
@ 2013-02-11 11:27 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2013-02-11 11:27 UTC (permalink / raw)
To: Dimitris Papastamos; +Cc: linux-kernel, patches
[-- Attachment #1: Type: text/plain, Size: 311 bytes --]
On Mon, Feb 11, 2013 at 10:50:59AM +0000, Dimitris Papastamos wrote:
> In preparation to support the regmap debugfs ranges functionality
> factor this code out to a separate function. We'll need to ensure
> that the value has been correctly calculated from two separate places
> in the code.
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-02-11 11:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-11 10:50 [PATCH] regmap: debugfs: Factor out debugfs_tot_len calc into a function Dimitris Papastamos
2013-02-11 11:27 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).