Skip to content

Commit 8c33ebf

Browse files
Mason Zhangbroonie
authored andcommitted
spi: move cs spi_delay to spi_device
As we know, spi core layer has removed spi_set_cs_timing() API. So this patch moved spi_delay for cs_timing from spi_controller to spi_device, because cs timing should be set by spi_device but not controller. Signed-off-by: Mason Zhang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 726e6f3 commit 8c33ebf

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

drivers/spi/spi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -842,9 +842,9 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force)
842842
if (spi->cs_gpiod || gpio_is_valid(spi->cs_gpio) ||
843843
!spi->controller->set_cs_timing) {
844844
if (activate)
845-
spi_delay_exec(&spi->controller->cs_setup, NULL);
845+
spi_delay_exec(&spi->cs_setup, NULL);
846846
else
847-
spi_delay_exec(&spi->controller->cs_hold, NULL);
847+
spi_delay_exec(&spi->cs_hold, NULL);
848848
}
849849

850850
if (spi->mode & SPI_CS_HIGH)
@@ -887,7 +887,7 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force)
887887
if (spi->cs_gpiod || gpio_is_valid(spi->cs_gpio) ||
888888
!spi->controller->set_cs_timing) {
889889
if (!activate)
890-
spi_delay_exec(&spi->controller->cs_inactive, NULL);
890+
spi_delay_exec(&spi->cs_inactive, NULL);
891891
}
892892
}
893893

include/linux/spi/spi.h

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@ extern int spi_delay_exec(struct spi_delay *_delay, struct spi_transfer *xfer);
147147
* not using a GPIO line)
148148
* @word_delay: delay to be inserted between consecutive
149149
* words of a transfer
150-
*
150+
* @cs_setup: delay to be introduced by the controller after CS is asserted
151+
* @cs_hold: delay to be introduced by the controller before CS is deasserted
152+
* @cs_inactive: delay to be introduced by the controller after CS is
153+
* deasserted. If @cs_change_delay is used from @spi_transfer, then the
154+
* two delays will be added up.
151155
* @statistics: statistics for the spi_device
152156
*
153157
* A @spi_device is used to interchange data between an SPI slave
@@ -188,6 +192,10 @@ struct spi_device {
188192
int cs_gpio; /* LEGACY: chip select gpio */
189193
struct gpio_desc *cs_gpiod; /* chip select gpio desc */
190194
struct spi_delay word_delay; /* inter-word delay */
195+
/* CS delays */
196+
struct spi_delay cs_setup;
197+
struct spi_delay cs_hold;
198+
struct spi_delay cs_inactive;
191199

192200
/* the statistics */
193201
struct spi_statistics statistics;
@@ -413,11 +421,6 @@ extern struct spi_device *spi_new_ancillary_device(struct spi_device *spi, u8 ch
413421
* controller has native support for memory like operations.
414422
* @unprepare_message: undo any work done by prepare_message().
415423
* @slave_abort: abort the ongoing transfer request on an SPI slave controller
416-
* @cs_setup: delay to be introduced by the controller after CS is asserted
417-
* @cs_hold: delay to be introduced by the controller before CS is deasserted
418-
* @cs_inactive: delay to be introduced by the controller after CS is
419-
* deasserted. If @cs_change_delay is used from @spi_transfer, then the
420-
* two delays will be added up.
421424
* @cs_gpios: LEGACY: array of GPIO descs to use as chip select lines; one per
422425
* CS number. Any individual value may be -ENOENT for CS lines that
423426
* are not GPIOs (driven by the SPI controller itself). Use the cs_gpiods
@@ -639,11 +642,6 @@ struct spi_controller {
639642
/* Optimized handlers for SPI memory-like operations. */
640643
const struct spi_controller_mem_ops *mem_ops;
641644

642-
/* CS delays */
643-
struct spi_delay cs_setup;
644-
struct spi_delay cs_hold;
645-
struct spi_delay cs_inactive;
646-
647645
/* gpio chip select */
648646
int *cs_gpios;
649647
struct gpio_desc **cs_gpiods;

0 commit comments

Comments
 (0)