From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: linux-kernel@vger.kernel.org
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: [PATCH 3/3] regmap: Split raw writes that cross window boundaries
Date: Thu, 4 Oct 2012 18:36:16 +0100 [thread overview]
Message-ID: <1349372177-18931-3-git-send-email-broonie@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1349372177-18931-1-git-send-email-broonie@opensource.wolfsonmicro.com>
If a block write covers a paged memory region and crosses a window
boundary then rather than failing the write split the transfer up
into multiple writes, making the whole process more transparent for
drivers.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/base/regmap/regmap.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index baf9586..07ea564 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -852,8 +852,25 @@ static int _regmap_raw_write(struct regmap *map, unsigned int reg,
range = _regmap_range_lookup(map, reg);
if (range) {
- ret = _regmap_select_page(map, ®, range,
- val_len / map->format.val_bytes);
+ int val_num = val_len / map->format.val_bytes;
+ int win_offset = (reg - range->range_min) % range->window_len;
+ int win_residue = range->window_len - win_offset;
+
+ /* If the write goes beyond the end of the window split it */
+ while (val_num > win_residue) {
+ dev_dbg(map->dev, "Writing window %d/%d\n",
+ win_residue, val_len);
+ ret = _regmap_raw_write(map, reg, val, win_residue);
+ if (ret != 0)
+ return ret;
+
+ val += win_residue;
+ val_len -= win_residue;
+ val_num = val_len / map->format.val_bytes;
+ win_residue = range->window_len - win_offset;
+ }
+
+ ret = _regmap_select_page(map, ®, range, val_num);
if (ret != 0)
return ret;
}
--
1.7.10.4
prev parent reply other threads:[~2012-10-04 17:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-04 17:36 [PATCH 1/3] regmap: Factor range lookup out of page selection Mark Brown
2012-10-04 17:36 ` [PATCH 2/3] regmap: Make return code checks consistent Mark Brown
2012-10-04 17:36 ` Mark Brown [this message]
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=1349372177-18931-3-git-send-email-broonie@opensource.wolfsonmicro.com \
--to=broonie@opensource.wolfsonmicro.com \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).