From: Jim Wylder <jwylder@google.com>
To: Mark Brown <broonie@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
linux-kernel@vger.kernel.org, Jim Wylder <jwylder@google.com>
Subject: [PATCH] regmap: Account for register length when chunking
Date: Tue, 16 May 2023 10:52:23 -0500 [thread overview]
Message-ID: <20230516155223.2070731-1-jwylder@google.com> (raw)
In-Reply-To: <ZGJI2zU/bxDPxLAh@finisterre.sirena.org.uk>
Currently, when regmap_raw_write() splits the data, it uses the
max_raw_write value defined for the bus. For any bus that includes
the target register address in the max_raw_write value, the chunked
transmission will always exceed the maximum transmission length.
To avoid this problem, subtract the length of the register from the
maximum transmission.
Signed-off-by: Jim Wylder <jwylder@google.com>
---
drivers/base/regmap/regmap.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index db7851f0e3b8c..1d1496c253ca6 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -2083,14 +2083,15 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg,
size_t chunk_count, chunk_bytes;
size_t chunk_regs = val_count;
int ret, i;
+ size_t max_data = map->max_raw_write - map->format.reg_bytes;
if (!val_count)
return -EINVAL;
if (map->use_single_write)
chunk_regs = 1;
- else if (map->max_raw_write && val_len > map->max_raw_write)
- chunk_regs = map->max_raw_write / val_bytes;
+ else if (map->max_raw_write && val_len > max_data)
+ chunk_regs = max_data / val_bytes;
chunk_count = val_count / chunk_regs;
chunk_bytes = chunk_regs * val_bytes;
base-commit: ad2fd53a7870a395b8564697bef6c329d017c6c9
--
2.40.1.606.ga4b1b128d6-goog
next prev parent reply other threads:[~2023-05-16 15:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-15 14:39 Jim Wylder
2023-05-15 14:59 ` Mark Brown
2023-05-16 15:52 ` Jim Wylder [this message]
2023-05-17 1:15 ` Mark Brown
2023-05-17 15:20 ` Jim Wylder
2023-05-17 15:20 ` [PATCH] " Jim Wylder
2023-05-18 17:31 ` 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=20230516155223.2070731-1-jwylder@google.com \
--to=jwylder@google.com \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@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
all inboxes | Powered by JetHome®