Skip to content

Commit b5596f1

Browse files
committed
Merge tag 'spi-v6.2-rc8-abi' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
Pull spi fix from Mark Brown: "One more last minute patch for v6.2 updating the parsing of the newly added spi-cs-setup-delay-ns. It's been pointed out that due to the way DT parsing works the change in property size is ABI visible so let's not let a release go out without it being fixed. The change got split from some earlier ABI related fixes to the property since the first version sent had a build error" * tag 'spi-v6.2-rc8-abi' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: spi: Use a 32-bit DT property for spi-cs-setup-delay-ns
2 parents 1890205 + f276aac commit b5596f1

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

drivers/spi/spi.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2220,11 +2220,26 @@ void spi_flush_queue(struct spi_controller *ctlr)
22202220
/*-------------------------------------------------------------------------*/
22212221

22222222
#if defined(CONFIG_OF)
2223+
static void of_spi_parse_dt_cs_delay(struct device_node *nc,
2224+
struct spi_delay *delay, const char *prop)
2225+
{
2226+
u32 value;
2227+
2228+
if (!of_property_read_u32(nc, prop, &value)) {
2229+
if (value > U16_MAX) {
2230+
delay->value = DIV_ROUND_UP(value, 1000);
2231+
delay->unit = SPI_DELAY_UNIT_USECS;
2232+
} else {
2233+
delay->value = value;
2234+
delay->unit = SPI_DELAY_UNIT_NSECS;
2235+
}
2236+
}
2237+
}
2238+
22232239
static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
22242240
struct device_node *nc)
22252241
{
22262242
u32 value;
2227-
u16 cs_setup;
22282243
int rc;
22292244

22302245
/* Mode (clock phase/polarity/etc.) */
@@ -2310,10 +2325,8 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
23102325
if (!of_property_read_u32(nc, "spi-max-frequency", &value))
23112326
spi->max_speed_hz = value;
23122327

2313-
if (!of_property_read_u16(nc, "spi-cs-setup-delay-ns", &cs_setup)) {
2314-
spi->cs_setup.value = cs_setup;
2315-
spi->cs_setup.unit = SPI_DELAY_UNIT_NSECS;
2316-
}
2328+
/* Device CS delays */
2329+
of_spi_parse_dt_cs_delay(nc, &spi->cs_setup, "spi-cs-setup-delay-ns");
23172330

23182331
return 0;
23192332
}

0 commit comments

Comments
 (0)