From: Mark Brown <broonie@kernel.org>
To: Arnd Bergmann <arnd@arndb.de>, Petr Tesarik <ptesarik@suse.com>,
linux-kernel@vger.kernel.org
Cc: Mark Brown <broonie@kernel.org>
Subject: [PATCH] regmap: spi: Don't use spi_write_then_read()
Date: Thu, 20 Mar 2025 23:00:34 +0000 [thread overview]
Message-ID: <20250320-regmap-spi-write-read-v1-1-31666bc6ebe8@kernel.org> (raw)
Currently SPI reads are implemented using spi_write_then_read(). This is a
convenience API which as well as constructing a SPI message from parameters
basically the same as for a bytestream read operation also bounces things
into a memory buffer to allow callers to use stack or other non-DMAable
memory. Since regmap should already be ensuring that everything can be
DMAed further up the stack this copy is redundant so switch to using the
underlying spi_sync() API with the buffers provided by the core directly.
Signed-off-by: Mark Brown <broonie@kernel.org>
---
drivers/base/regmap/regmap-spi.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/base/regmap/regmap-spi.c b/drivers/base/regmap/regmap-spi.c
index 14b1d88997cbe406c8900f5032d768fc7484e99f..6a3dbc217e890d25a392fd3157f9ed89188afdaa 100644
--- a/drivers/base/regmap/regmap-spi.c
+++ b/drivers/base/regmap/regmap-spi.c
@@ -94,8 +94,15 @@ static int regmap_spi_read(void *context,
{
struct device *dev = context;
struct spi_device *spi = to_spi_device(dev);
+ struct spi_message m;
+ struct spi_transfer t[2] = { { .tx_buf = reg, .len = reg_size, },
+ { .rx_buf = val, .len = val_size, }, };
+
+ spi_message_init(&m);
+ spi_message_add_tail(&t[0], &m);
+ spi_message_add_tail(&t[1], &m);
- return spi_write_then_read(spi, reg, reg_size, val, val_size);
+ return spi_sync(spi, &m);
}
static const struct regmap_bus regmap_spi = {
---
base-commit: 4701f33a10702d5fc577c32434eb62adde0a1ae1
change-id: 20250320-regmap-spi-write-read-8b2c2aecd027
Best regards,
--
Mark Brown <broonie@kernel.org>
next reply other threads:[~2025-03-20 23:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-20 23:00 Mark Brown [this message]
2025-03-20 23:08 ` Mark Brown
2025-03-21 11:27 ` Arnd Bergmann
2025-03-21 13:34 ` 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=20250320-regmap-spi-write-read-v1-1-31666bc6ebe8@kernel.org \
--to=broonie@kernel.org \
--cc=arnd@arndb.de \
--cc=linux-kernel@vger.kernel.org \
--cc=ptesarik@suse.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
all inboxes | Powered by JetHome®