From: Marcelo Schmitt <marcelo.schmitt@analog.com>
To: <linux-iio@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux@analog.com>
Cc: <jic23@kernel.org>, <nuno.sa@analog.com>, <dlechner@baylibre.com>,
<andy@kernel.org>, <Michael.Hennerich@analog.com>,
<robh@kernel.org>, <krzk+dt@kernel.org>, <conor+dt@kernel.org>,
<corbet@lwn.net>, <skhan@linuxfoundation.org>,
<marcelo.schmitt1@gmail.com>
Subject: [PATCH v6 07/16] iio: adc: ad4134: Run shorter transfers when CRC is disabled
Date: Fri, 23 Oct 2026 19:35:09 -0300 [thread overview]
Message-ID: <af78e90546e780aa9323c70753bbd062acb6cb49.1792792325.git.marcelo.schmitt@analog.com> (raw)
In-Reply-To: <cover.1792792325.git.marcelo.schmitt@analog.com>
When AD4134 has its SPI CRC feature enabled, one extra byte (the CRC code)
is sent through SPI for both ends to verify the integrity of data
transfers. Though, when CRC is not enabled, SPI transfers can be shorter.
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
---
No change in v6.
drivers/iio/adc/ad4134.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/adc/ad4134.c b/drivers/iio/adc/ad4134.c
index 71f626bbe9be..bbfa0b168ce5 100644
--- a/drivers/iio/adc/ad4134.c
+++ b/drivers/iio/adc/ad4134.c
@@ -106,6 +106,7 @@ struct ad4134_state {
*/
struct mutex sync_lock;
int refin_mv;
+ bool crc_en;
/*
* DMA (thus cache coherency maintenance) requires the transfer buffers
* to live in their own cache lines.
@@ -159,7 +160,7 @@ static int ad4134_reg_write(void *context, unsigned int reg, unsigned int val)
struct spi_transfer xfer = {
.tx_buf = st->tx_buf,
.rx_buf = st->rx_buf,
- .len = AD4134_SPI_MAX_XFER_LEN,
+ .len = st->crc_en ? AD4134_SPI_MAX_XFER_LEN : 2,
};
int ret;
@@ -169,7 +170,7 @@ static int ad4134_reg_write(void *context, unsigned int reg, unsigned int val)
if (ret)
return ret;
- if (st->rx_buf[2] != st->tx_buf[2])
+ if (st->crc_en && st->rx_buf[2] != st->tx_buf[2])
dev_dbg(&st->spi->dev, "reg write CRC check failed\n");
return 0;
@@ -217,7 +218,7 @@ static int ad4134_register_read(struct ad4134_state *st, unsigned int reg,
struct spi_transfer xfer = {
.tx_buf = st->tx_buf,
.rx_buf = st->rx_buf,
- .len = AD4134_SPI_MAX_XFER_LEN,
+ .len = st->crc_en ? AD4134_SPI_MAX_XFER_LEN : 2,
};
unsigned int inst;
int ret;
@@ -232,7 +233,7 @@ static int ad4134_register_read(struct ad4134_state *st, unsigned int reg,
*val = st->rx_buf[1];
/* Check CRC */
- if (st->rx_buf[2] != st->tx_buf[2])
+ if (st->crc_en && st->rx_buf[2] != st->tx_buf[2])
dev_dbg(&st->spi->dev, "reg read CRC check failed\n");
return 0;
@@ -319,6 +320,7 @@ static int ad4134_min_io_mode_setup(struct ad4134_state *st)
struct device *dev = &st->spi->dev;
int ret;
+ st->crc_en = true; /* In minimum I/O mode CRC cannot be disabled */
st->odr_gpio = devm_gpiod_get(dev, "odr", GPIOD_OUT_LOW);
if (IS_ERR(st->odr_gpio))
return dev_err_probe(dev, PTR_ERR(st->odr_gpio),
--
2.53.0
next prev parent reply other threads:[~2026-10-23 22:35 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 22:32 [PATCH v6 00/16] iio: adc: ad4134: Enable greater sample rate data capture Marcelo Schmitt
2026-10-23 22:33 ` [PATCH v6 01/16] iio: adc: ad4134: Adjust register map range Marcelo Schmitt
2026-10-23 22:33 ` [PATCH v6 02/16] iio: adc: ad4134: Sign extend sample data Marcelo Schmitt
2026-10-23 22:33 ` [PATCH v6 03/16] iio: adc: ad4134: Apply reset recovery wait time Marcelo Schmitt
2026-10-23 22:34 ` [PATCH v6 04/16] iio: adc: ad4134: Update include list to comply with IWYU principles Marcelo Schmitt
2026-10-23 22:34 ` [PATCH v6 05/16] iio: adc: ad4134: Serialize single-read operations Marcelo Schmitt
2026-10-23 22:34 ` [PATCH v6 06/16] iio: adc: ad4134: Protect conventional device access from debug accesses Marcelo Schmitt
2026-10-24 1:46 ` Jonathan Cameron
2026-10-23 22:35 ` Marcelo Schmitt [this message]
2026-10-23 22:35 ` [PATCH v6 08/16] iio: ABI: Add sinc6 filter_type Marcelo Schmitt
2026-10-23 22:35 ` [PATCH v6 09/16] iio: adc: ad4134: Add support for digital filter type selection Marcelo Schmitt
2026-10-23 22:36 ` [PATCH v6 10/16] iio: adc: ad4134: Support buffered data read Marcelo Schmitt
2026-10-23 22:36 ` [PATCH v6 11/16] dt-bindings: iio: adc: adi,ad4134: Document SPI connection mode Marcelo Schmitt
2026-10-23 22:36 ` [PATCH v6 12/16] dt-bindings: iio: adc: adi,ad4134: Document external multiplexer usage Marcelo Schmitt
2026-10-23 22:36 ` [PATCH v6 13/16] iio: adc: ad4134: Support SPI 4-wire mode Marcelo Schmitt
2026-10-23 22:37 ` [PATCH v6 14/16] dt-bindings: iio: adc: adi,ad4134: Document PWM usage Marcelo Schmitt
2026-10-23 22:37 ` [PATCH v6 15/16] iio: adc: ad4134: Support high-speed data capture Marcelo Schmitt
2026-10-23 22:37 ` [PATCH v6 16/16] Docs: iio: Add AD4134 Marcelo Schmitt
2026-10-24 1:54 ` [PATCH v6 00/16] iio: adc: ad4134: Enable greater sample rate data capture Jonathan Cameron
2026-11-02 0:27 ` Jonathan Cameron
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=af78e90546e780aa9323c70753bbd062acb6cb49.1792792325.git.marcelo.schmitt@analog.com \
--to=marcelo.schmitt@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@analog.com \
--cc=marcelo.schmitt1@gmail.com \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
--cc=skhan@linuxfoundation.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®