[PATCH v2 3/3] spi: dw: Use the rx-sample-delay-ns value parsed by the core

From: Frieder Schrempf

Date: Mon Sep 21 2026 - 06:18:42 EST


From: Frieder Schrempf <frieder.schrempf@xxxxxxxxxx>

The core now parses the "rx-sample-delay-ns" peripheral property into
spi_device.rx_sample_delay_ns, so drop the private copy of that parsing.

The controller-wide default is deliberately left alone. It is read from
the *controller* node into dws->def_rx_sample_dly_ns, which is a
different node and none of the core's business when it parses properties
of a peripheral.

One corner case changes: the peripheral value is now treated as unset
when it is zero, whereas before an absent property could be told apart
from an explicit "rx-sample-delay-ns = <0>", the latter overriding a
non-zero controller default with no delay at all. There are no in-tree
users affected by this and it is very unlikely for out-of-tree users
to set rx-sample-delay-ns on the controller level and then revert it
to 0 at the chip level. We should abandon this configuration that was
probably never meant to work like this and doesn't make sense.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Frieder Schrempf <frieder.schrempf@xxxxxxxxxx>
---
drivers/spi/spi-dw-core.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c
index 206d3f9dd83d..b86b607cc817 100644
--- a/drivers/spi/spi-dw-core.c
+++ b/drivers/spi/spi-dw-core.c
@@ -1104,12 +1104,13 @@ static int dw_spi_setup(struct spi_device *spi)
if (!chip)
return -ENOMEM;
spi_set_ctldata(spi, chip);
- /* Get specific / default rx-sample-delay */
- if (device_property_read_u32(&spi->dev,
- "rx-sample-delay-ns",
- &rx_sample_dly_ns) != 0)
- /* Use default controller value */
- rx_sample_dly_ns = dws->def_rx_sample_dly_ns;
+ /*
+ * Use the per-device value the core parsed from the peripheral
+ * node, and fall back to the controller-wide default when the
+ * device does not ask for a delay of its own.
+ */
+ rx_sample_dly_ns = spi->rx_sample_delay_ns ?:
+ dws->def_rx_sample_dly_ns;
chip->rx_sample_dly = DIV_ROUND_CLOSEST(rx_sample_dly_ns,
NSEC_PER_SEC /
dws->max_freq);

--
2.55.0