mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
spi: Replace all spi->chip_select and spi->cs_gpiod references with function call
Supporting multi-cs in spi drivers would require the chip_select & cs_gpiod members of struct spi_device to be an array. But changing the type of these members to array would break the spi driver functionality. To make the transition smoother introduced four new APIs to get/set the spi->chip_select & spi->cs_gpiod and replaced all spi->chip_select and spi->cs_gpiod references with get or set API calls. While adding multi-cs support in further patches the chip_select & cs_gpiod members of the spi_device structure would be converted to arrays & the "idx" parameter of the APIs would be used as array index i.e., spi->chip_select[idx] & spi->cs_gpiod[idx] respectively. Signed-off-by: Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com> Acked-by: Heiko Stuebner <heiko@sntech.de> # Rockchip drivers Reviewed-by: Michal Simek <michal.simek@amd.com> Reviewed-by: Cédric Le Goater <clg@kaod.org> # Aspeed driver Reviewed-by: Dhruva Gole <d-gole@ti.com> # SPI Cadence QSPI Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com> # spi-stm32-qspi Acked-by: William Zhang <william.zhang@broadcom.com> # bcm63xx-hsspi driver Reviewed-by: Serge Semin <fancer.lancer@gmail.com> # DW SSI part Link: https://lore.kernel.org/r/167847070432.26.15076794204368669839@mailman-core.alsa-project.org Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
21d19e601f
commit
9e264f3f85
@@ -902,19 +902,19 @@ static irqreturn_t dspi_interrupt(int irq, void *dev_id)
|
||||
|
||||
static void dspi_assert_cs(struct spi_device *spi, bool *cs)
|
||||
{
|
||||
if (!spi->cs_gpiod || *cs)
|
||||
if (!spi_get_csgpiod(spi, 0) || *cs)
|
||||
return;
|
||||
|
||||
gpiod_set_value_cansleep(spi->cs_gpiod, true);
|
||||
gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), true);
|
||||
*cs = true;
|
||||
}
|
||||
|
||||
static void dspi_deassert_cs(struct spi_device *spi, bool *cs)
|
||||
{
|
||||
if (!spi->cs_gpiod || !*cs)
|
||||
if (!spi_get_csgpiod(spi, 0) || !*cs)
|
||||
return;
|
||||
|
||||
gpiod_set_value_cansleep(spi->cs_gpiod, false);
|
||||
gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), false);
|
||||
*cs = false;
|
||||
}
|
||||
|
||||
@@ -938,8 +938,8 @@ static int dspi_transfer_one_message(struct spi_controller *ctlr,
|
||||
|
||||
/* Prepare command word for CMD FIFO */
|
||||
dspi->tx_cmd = SPI_PUSHR_CMD_CTAS(0);
|
||||
if (!spi->cs_gpiod)
|
||||
dspi->tx_cmd |= SPI_PUSHR_CMD_PCS(spi->chip_select);
|
||||
if (!spi_get_csgpiod(spi, 0))
|
||||
dspi->tx_cmd |= SPI_PUSHR_CMD_PCS(spi_get_chipselect(spi, 0));
|
||||
|
||||
if (list_is_last(&dspi->cur_transfer->transfer_list,
|
||||
&dspi->cur_msg->transfers)) {
|
||||
@@ -1058,7 +1058,7 @@ static int dspi_setup(struct spi_device *spi)
|
||||
chip->ctar_val |= SPI_CTAR_LSBFE;
|
||||
}
|
||||
|
||||
gpiod_direction_output(spi->cs_gpiod, false);
|
||||
gpiod_direction_output(spi_get_csgpiod(spi, 0), false);
|
||||
dspi_deassert_cs(spi, &cs);
|
||||
|
||||
spi_set_ctldata(spi, chip);
|
||||
@@ -1071,7 +1071,7 @@ static void dspi_cleanup(struct spi_device *spi)
|
||||
struct chip_data *chip = spi_get_ctldata((struct spi_device *)spi);
|
||||
|
||||
dev_dbg(&spi->dev, "spi_device %u.%u cleanup\n",
|
||||
spi->controller->bus_num, spi->chip_select);
|
||||
spi->controller->bus_num, spi_get_chipselect(spi, 0));
|
||||
|
||||
kfree(chip);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user