From: Jarkko Nikula <jarkko.nikula@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: linux-kernel@vger.kernel.org, Mark Brown <broonie@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Jarkko Nikula <jarkko.nikula@linux.intel.com>
Subject: [PATCH 1/2] regmap: cache: Fix regcache_sync_block for non-autoincrementing devices
Date: Tue, 26 Aug 2014 17:03:12 +0300 [thread overview]
Message-ID: <1409061793-10495-2-git-send-email-jarkko.nikula@linux.intel.com> (raw)
In-Reply-To: <1409061793-10495-1-git-send-email-jarkko.nikula@linux.intel.com>
Commit 75a5f89f635c ("regmap: cache: Write consecutive registers in a single
block write") expected that autoincrementing writes are supported if
hardware has a register format which can support raw writes.
This is not necessarily true and thus for instance rbtree sync can fail when
there is need to sync multiple consecutive registers but block write to
device fails due not supported autoincrementing writes.
Fix this by spliting raw block sync to series of single register writes for
devices that don't support autoincrementing writes.
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
I noticed this with Realtek RT5642 audio codec which didn't resume properly
since first block write having more data than for single register failed to
not acknowledged I2C write during regcache_sync(). Chip acknowledges device
address, register address and two data bytes for its word size registers but
next data byte is not which then causes aborted I2C transfer and aborted
register sync.
---
drivers/base/regmap/regcache.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 29b4128da0b0..54707e586ac8 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -629,6 +629,7 @@ static int regcache_sync_block_raw_flush(struct regmap *map, const void **data,
{
size_t val_bytes = map->format.val_bytes;
int ret, count;
+ unsigned int i;
if (*data == NULL)
return 0;
@@ -640,7 +641,18 @@ static int regcache_sync_block_raw_flush(struct regmap *map, const void **data,
map->cache_bypass = 1;
- ret = _regmap_raw_write(map, base, *data, count * val_bytes);
+ if (!map->use_single_rw) {
+ ret = _regmap_raw_write(map, base, *data, count * val_bytes);
+ } else {
+ for (i = 0; i < count; i++) {
+ ret = _regmap_raw_write(map,
+ base + (i * map->reg_stride),
+ *data + (i * val_bytes),
+ val_bytes);
+ if (ret != 0)
+ break;
+ }
+ }
map->cache_bypass = 0;
--
2.1.0
next prev parent reply other threads:[~2014-08-26 14:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-26 14:03 [PATCH 0/2] ASoC/regmap: rt5640: Fix resume Jarkko Nikula
2014-08-26 14:03 ` Jarkko Nikula [this message]
2014-08-26 14:21 ` [alsa-devel] [PATCH 1/2] regmap: cache: Fix regcache_sync_block for non-autoincrementing devices Takashi Iwai
2014-08-27 5:52 ` Jarkko Nikula
2014-08-27 8:18 ` Mark Brown
2014-08-27 11:58 ` Mark Brown
2014-08-26 14:03 ` [PATCH 2/2] ASoC: rt5640: Do not allow regmap to use bulk read-write operations Jarkko Nikula
2014-08-27 12:00 ` 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=1409061793-10495-2-git-send-email-jarkko.nikula@linux.intel.com \
--to=jarkko.nikula@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.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