From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: linux-kernel@vger.kernel.org
Cc: patches@opensource.wolfsonmicro.com,
Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: [PATCH 2/3] regmap: Share some of the debugfs infrastructure ready for more files
Date: Sun, 14 Aug 2011 19:50:24 +0900 [thread overview]
Message-ID: <1313319025-5514-2-git-send-email-broonie@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1313319025-5514-1-git-send-email-broonie@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/base/regmap/regmap-debugfs.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index fff8e83..e541d7f4 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -20,7 +20,14 @@
static struct dentry *regmap_debugfs_root;
-static int regmap_map_open_file(struct inode *inode, struct file *file)
+/* Calculate the length of a fixed format */
+static size_t regmap_calc_reg_len(int max_val, char *buf, size_t buf_size)
+{
+ snprintf(buf, buf_size, "%x", max_val);
+ return strlen(buf);
+}
+
+static int regmap_open_file(struct inode *inode, struct file *file)
{
file->private_data = inode->i_private;
return 0;
@@ -46,8 +53,7 @@ static ssize_t regmap_map_read_file(struct file *file, char __user *user_buf,
return -ENOMEM;
/* Calculate the length of a fixed format */
- snprintf(buf, count, "%x", map->max_register);
- reg_len = strlen(buf);
+ reg_len = regmap_calc_reg_len(map->max_register, buf, count);
val_len = 2 * map->format.val_bytes;
tot_len = reg_len + val_len + 3; /* : \n */
@@ -98,7 +104,7 @@ out:
}
static const struct file_operations regmap_map_fops = {
- .open = regmap_map_open_file,
+ .open = regmap_open_file,
.read = regmap_map_read_file,
.llseek = default_llseek,
};
--
1.7.5.4
next prev parent reply other threads:[~2011-08-14 10:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-14 10:50 [PATCH 1/3] regmap: Add functions to check for access on registers Mark Brown
2011-08-14 10:50 ` Mark Brown [this message]
2011-08-14 10:50 ` [PATCH 3/3] regmap: Provide access information via debugfs Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1313319025-5514-2-git-send-email-broonie@opensource.wolfsonmicro.com \
--to=broonie@opensource.wolfsonmicro.com \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@opensource.wolfsonmicro.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox