spi: Replace all spi->chip_select and spi->cs_gpiod references with function call
authorAmit Kumar Mahapatra via Alsa-devel <alsa-devel@alsa-project.org>
Fri, 10 Mar 2023 17:32:03 +0000 (23:02 +0530)
committerMark Brown <broonie@kernel.org>
Sat, 11 Mar 2023 12:34:01 +0000 (12:34 +0000)
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>
92 files changed:
drivers/spi/spi-altera-core.c
drivers/spi/spi-amd.c
drivers/spi/spi-ar934x.c
drivers/spi/spi-armada-3700.c
drivers/spi/spi-aspeed-smc.c
drivers/spi/spi-at91-usart.c
drivers/spi/spi-ath79.c
drivers/spi/spi-atmel.c
drivers/spi/spi-au1550.c
drivers/spi/spi-axi-spi-engine.c
drivers/spi/spi-bcm-qspi.c
drivers/spi/spi-bcm2835.c
drivers/spi/spi-bcm2835aux.c
drivers/spi/spi-bcm63xx-hsspi.c
drivers/spi/spi-bcm63xx.c
drivers/spi/spi-bcmbca-hsspi.c
drivers/spi/spi-cadence-quadspi.c
drivers/spi/spi-cadence-xspi.c
drivers/spi/spi-cadence.c
drivers/spi/spi-cavium.c
drivers/spi/spi-coldfire-qspi.c
drivers/spi/spi-davinci.c
drivers/spi/spi-dln2.c
drivers/spi/spi-dw-core.c
drivers/spi/spi-dw-mmio.c
drivers/spi/spi-falcon.c
drivers/spi/spi-fsi.c
drivers/spi/spi-fsl-dspi.c
drivers/spi/spi-fsl-espi.c
drivers/spi/spi-fsl-lpspi.c
drivers/spi/spi-fsl-qspi.c
drivers/spi/spi-fsl-spi.c
drivers/spi/spi-geni-qcom.c
drivers/spi/spi-gpio.c
drivers/spi/spi-gxp.c
drivers/spi/spi-hisi-sfc-v3xx.c
drivers/spi/spi-img-spfi.c
drivers/spi/spi-imx.c
drivers/spi/spi-ingenic.c
drivers/spi/spi-intel.c
drivers/spi/spi-jcore.c
drivers/spi/spi-lantiq-ssc.c
drivers/spi/spi-mem.c
drivers/spi/spi-meson-spicc.c
drivers/spi/spi-microchip-core.c
drivers/spi/spi-mpc512x-psc.c
drivers/spi/spi-mpc52xx.c
drivers/spi/spi-mt65xx.c
drivers/spi/spi-mt7621.c
drivers/spi/spi-mux.c
drivers/spi/spi-mxic.c
drivers/spi/spi-mxs.c
drivers/spi/spi-npcm-fiu.c
drivers/spi/spi-nxp-fspi.c
drivers/spi/spi-omap-uwire.c
drivers/spi/spi-omap2-mcspi.c
drivers/spi/spi-orion.c
drivers/spi/spi-pci1xxxx.c
drivers/spi/spi-pic32-sqi.c
drivers/spi/spi-pic32.c
drivers/spi/spi-pl022.c
drivers/spi/spi-pxa2xx.c
drivers/spi/spi-qcom-qspi.c
drivers/spi/spi-rb4xx.c
drivers/spi/spi-rockchip-sfc.c
drivers/spi/spi-rockchip.c
drivers/spi/spi-rspi.c
drivers/spi/spi-s3c64xx.c
drivers/spi/spi-sc18is602.c
drivers/spi/spi-sh-msiof.c
drivers/spi/spi-sh-sci.c
drivers/spi/spi-sifive.c
drivers/spi/spi-sn-f-ospi.c
drivers/spi/spi-st-ssc4.c
drivers/spi/spi-stm32-qspi.c
drivers/spi/spi-sun4i.c
drivers/spi/spi-sun6i.c
drivers/spi/spi-synquacer.c
drivers/spi/spi-tegra114.c
drivers/spi/spi-tegra20-sflash.c
drivers/spi/spi-tegra20-slink.c
drivers/spi/spi-tegra210-quad.c
drivers/spi/spi-ti-qspi.c
drivers/spi/spi-topcliff-pch.c
drivers/spi/spi-wpcm-fiu.c
drivers/spi/spi-xcomm.c
drivers/spi/spi-xilinx.c
drivers/spi/spi-xlp.c
drivers/spi/spi-zynq-qspi.c
drivers/spi/spi-zynqmp-gqspi.c
drivers/spi/spidev.c
include/trace/events/spi.h

index 94fe6bf1b9a6a54843d92c3e0690d787e4a31b8e..87e37f48f196ef173da49f1f35bfb378d28c934c 100644 (file)
@@ -80,7 +80,7 @@ static void altera_spi_set_cs(struct spi_device *spi, bool is_high)
                altr_spi_writel(hw, ALTERA_SPI_TARGET_SEL, 0);
        } else {
                altr_spi_writel(hw, ALTERA_SPI_TARGET_SEL,
-                               BIT(spi->chip_select));
+                               BIT(spi_get_chipselect(spi, 0)));
                hw->imr |= ALTERA_SPI_CONTROL_SSO_MSK;
                altr_spi_writel(hw, ALTERA_SPI_CONTROL, hw->imr);
        }
index bfc3ab5f39eaaa567a332f107c44d690b9151897..fecead757a3cd66c211102545fea5950de6c7573 100644 (file)
@@ -347,7 +347,7 @@ fin_msg:
        case AMD_SPI_V1:
                break;
        case AMD_SPI_V2:
-               amd_spi_clear_chip(amd_spi, message->spi->chip_select);
+               amd_spi_clear_chip(amd_spi, spi_get_chipselect(message->spi, 0));
                break;
        default:
                return -ENODEV;
@@ -364,7 +364,7 @@ static int amd_spi_master_transfer(struct spi_master *master,
        struct amd_spi *amd_spi = spi_master_get_devdata(master);
        struct spi_device *spi = msg->spi;
 
-       amd_spi_select_chip(amd_spi, spi->chip_select);
+       amd_spi_select_chip(amd_spi, spi_get_chipselect(spi, 0));
 
        /*
         * Extract spi_transfers from the spi message and
index c71c8348eeaa696012ed48d43def33b70e1e073b..9dcada8c4cb987bcd45e5e66a51aef03987f4065 100644 (file)
@@ -125,7 +125,7 @@ static int ar934x_spi_transfer_one_message(struct spi_controller *ctlr,
                                iowrite32(reg, sp->base + AR934X_SPI_DATAOUT);
                        }
 
-                       reg = AR934X_SPI_SHIFT_VAL(spi->chip_select, term,
+                       reg = AR934X_SPI_SHIFT_VAL(spi_get_chipselect(spi, 0), term,
                                                   trx_cur * 8);
                        iowrite32(reg, sp->base + AR934X_SPI_REG_SHIFT_CTRL);
                        stat = readl_poll_timeout(
index 6a7e605f73bf0add5ed0b6e163b7cee517113819..a7fb7c94e70ecb7fbde8055eed14a4e4b438f9e7 100644 (file)
@@ -437,9 +437,9 @@ static void a3700_spi_set_cs(struct spi_device *spi, bool enable)
        struct a3700_spi *a3700_spi = spi_controller_get_devdata(spi->controller);
 
        if (!enable)
-               a3700_spi_activate_cs(a3700_spi, spi->chip_select);
+               a3700_spi_activate_cs(a3700_spi, spi_get_chipselect(spi, 0));
        else
-               a3700_spi_deactivate_cs(a3700_spi, spi->chip_select);
+               a3700_spi_deactivate_cs(a3700_spi, spi_get_chipselect(spi, 0));
 }
 
 static void a3700_spi_header_set(struct a3700_spi *a3700_spi)
index 3f25488603176f34bdef0cd960a8aef45b2cc5a8..e75b0d51f06ab82f9069fd4a7cfce779bf9b3643 100644 (file)
@@ -296,7 +296,7 @@ static const struct aspeed_spi_data ast2400_spi_data;
 static int do_aspeed_spi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
 {
        struct aspeed_spi *aspi = spi_controller_get_devdata(mem->spi->master);
-       struct aspeed_spi_chip *chip = &aspi->chips[mem->spi->chip_select];
+       struct aspeed_spi_chip *chip = &aspi->chips[spi_get_chipselect(mem->spi, 0)];
        u32 addr_mode, addr_mode_backup;
        u32 ctl_val;
        int ret = 0;
@@ -377,7 +377,8 @@ static const char *aspeed_spi_get_name(struct spi_mem *mem)
        struct aspeed_spi *aspi = spi_controller_get_devdata(mem->spi->master);
        struct device *dev = aspi->dev;
 
-       return devm_kasprintf(dev, GFP_KERNEL, "%s.%d", dev_name(dev), mem->spi->chip_select);
+       return devm_kasprintf(dev, GFP_KERNEL, "%s.%d", dev_name(dev),
+                             spi_get_chipselect(mem->spi, 0));
 }
 
 struct aspeed_spi_window {
@@ -553,7 +554,7 @@ static int aspeed_spi_do_calibration(struct aspeed_spi_chip *chip);
 static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
 {
        struct aspeed_spi *aspi = spi_controller_get_devdata(desc->mem->spi->master);
-       struct aspeed_spi_chip *chip = &aspi->chips[desc->mem->spi->chip_select];
+       struct aspeed_spi_chip *chip = &aspi->chips[spi_get_chipselect(desc->mem->spi, 0)];
        struct spi_mem_op *op = &desc->info.op_tmpl;
        u32 ctl_val;
        int ret = 0;
@@ -620,7 +621,7 @@ static ssize_t aspeed_spi_dirmap_read(struct spi_mem_dirmap_desc *desc,
                                      u64 offset, size_t len, void *buf)
 {
        struct aspeed_spi *aspi = spi_controller_get_devdata(desc->mem->spi->master);
-       struct aspeed_spi_chip *chip = &aspi->chips[desc->mem->spi->chip_select];
+       struct aspeed_spi_chip *chip = &aspi->chips[spi_get_chipselect(desc->mem->spi, 0)];
 
        /* Switch to USER command mode if mapping window is too small */
        if (chip->ahb_window_size < offset + len) {
@@ -670,7 +671,7 @@ static int aspeed_spi_setup(struct spi_device *spi)
 {
        struct aspeed_spi *aspi = spi_controller_get_devdata(spi->master);
        const struct aspeed_spi_data *data = aspi->data;
-       unsigned int cs = spi->chip_select;
+       unsigned int cs = spi_get_chipselect(spi, 0);
        struct aspeed_spi_chip *chip = &aspi->chips[cs];
 
        chip->aspi = aspi;
@@ -697,7 +698,7 @@ static int aspeed_spi_setup(struct spi_device *spi)
 static void aspeed_spi_cleanup(struct spi_device *spi)
 {
        struct aspeed_spi *aspi = spi_controller_get_devdata(spi->master);
-       unsigned int cs = spi->chip_select;
+       unsigned int cs = spi_get_chipselect(spi, 0);
 
        aspeed_spi_chip_enable(aspi, cs, false);
 
index 4fb3653b5941f2a75b8b77a22639603c5f437b2e..7854d9790fe945c60a35f7f64b7bdd08a3482c6c 100644 (file)
@@ -390,7 +390,7 @@ static int at91_usart_spi_setup(struct spi_device *spi)
 
        dev_dbg(&spi->dev,
                "setup: bpw %u mode 0x%x -> mr %d %08x\n",
-               spi->bits_per_word, spi->mode, spi->chip_select, mr);
+               spi->bits_per_word, spi->mode, spi_get_chipselect(spi, 0), mr);
 
        return 0;
 }
index b4d25b3bee1965990bd69f3bd6cfed46792ed7a3..d3dd21386f12567fb5a2c8c74d4f5ef1c015be97 100644 (file)
@@ -71,7 +71,7 @@ static void ath79_spi_chipselect(struct spi_device *spi, int is_active)
 {
        struct ath79_spi *sp = ath79_spidev_to_sp(spi);
        int cs_high = (spi->mode & SPI_CS_HIGH) ? is_active : !is_active;
-       u32 cs_bit = AR71XX_SPI_IOC_CS(spi->chip_select);
+       u32 cs_bit = AR71XX_SPI_IOC_CS(spi_get_chipselect(spi, 0));
 
        if (cs_high)
                sp->ioc_base |= cs_bit;
@@ -140,7 +140,7 @@ static int ath79_exec_mem_op(struct spi_mem *mem,
        struct ath79_spi *sp = ath79_spidev_to_sp(mem->spi);
 
        /* Ensures that reading is performed on device connected to hardware cs0 */
-       if (mem->spi->chip_select || mem->spi->cs_gpiod)
+       if (spi_get_chipselect(mem->spi, 0) || spi_get_csgpiod(mem->spi, 0))
                return -ENOTSUPP;
 
        /* Only use for fast-read op. */
index 73f80c8ac2ffd819cfbb1a1ccd1a31b4eba4e528..7f06305e16cbc60fc3fa1d83316d818770c29f49 100644 (file)
@@ -327,10 +327,10 @@ static void cs_activate(struct atmel_spi *as, struct spi_device *spi)
        int chip_select;
        u32 mr;
 
-       if (spi->cs_gpiod)
+       if (spi_get_csgpiod(spi, 0))
                chip_select = as->native_cs_for_gpio;
        else
-               chip_select = spi->chip_select;
+               chip_select = spi_get_chipselect(spi, 0);
 
        if (atmel_spi_is_v2(as)) {
                spi_writel(as, CSR0 + 4 * chip_select, asd->csr);
@@ -378,10 +378,10 @@ static void cs_deactivate(struct atmel_spi *as, struct spi_device *spi)
        int chip_select;
        u32 mr;
 
-       if (spi->cs_gpiod)
+       if (spi_get_csgpiod(spi, 0))
                chip_select = as->native_cs_for_gpio;
        else
-               chip_select = spi->chip_select;
+               chip_select = spi_get_chipselect(spi, 0);
 
        /* only deactivate *this* device; sometimes transfers to
         * another device may be active when this routine is called.
@@ -394,7 +394,7 @@ static void cs_deactivate(struct atmel_spi *as, struct spi_device *spi)
 
        dev_dbg(&spi->dev, "DEactivate NPCS, mr %08x\n", mr);
 
-       if (!spi->cs_gpiod)
+       if (!spi_get_csgpiod(spi, 0))
                spi_writel(as, CR, SPI_BIT(LASTXFER));
 }
 
@@ -800,10 +800,10 @@ static int atmel_spi_set_xfer_speed(struct atmel_spi *as,
        unsigned long           bus_hz;
        int chip_select;
 
-       if (spi->cs_gpiod)
+       if (spi_get_csgpiod(spi, 0))
                chip_select = as->native_cs_for_gpio;
        else
-               chip_select = spi->chip_select;
+               chip_select = spi_get_chipselect(spi, 0);
 
        /* v1 chips start out at half the peripheral bus speed. */
        bus_hz = as->spi_clk;
@@ -1189,7 +1189,7 @@ static int atmel_spi_setup(struct spi_device *spi)
        as = spi_controller_get_devdata(spi->controller);
 
        /* see notes above re chipselect */
-       if (!spi->cs_gpiod && (spi->mode & SPI_CS_HIGH)) {
+       if (!spi_get_csgpiod(spi, 0) && (spi->mode & SPI_CS_HIGH)) {
                dev_warn(&spi->dev, "setup: non GPIO CS can't be active-high\n");
                return -EINVAL;
        }
@@ -1201,16 +1201,16 @@ static int atmel_spi_setup(struct spi_device *spi)
         */
        initialize_native_cs_for_gpio(as);
 
-       if (spi->cs_gpiod && as->native_cs_free) {
+       if (spi_get_csgpiod(spi, 0) && as->native_cs_free) {
                dev_err(&spi->dev,
                        "No native CS available to support this GPIO CS\n");
                return -EBUSY;
        }
 
-       if (spi->cs_gpiod)
+       if (spi_get_csgpiod(spi, 0))
                chip_select = as->native_cs_for_gpio;
        else
-               chip_select = spi->chip_select;
+               chip_select = spi_get_chipselect(spi, 0);
 
        csr = SPI_BF(BITS, bits - 8);
        if (spi->mode & SPI_CPOL)
@@ -1218,7 +1218,7 @@ static int atmel_spi_setup(struct spi_device *spi)
        if (!(spi->mode & SPI_CPHA))
                csr |= SPI_BIT(NCPHA);
 
-       if (!spi->cs_gpiod)
+       if (!spi_get_csgpiod(spi, 0))
                csr |= SPI_BIT(CSAAT);
        csr |= SPI_BF(DLYBS, 0);
 
@@ -1244,7 +1244,7 @@ static int atmel_spi_setup(struct spi_device *spi)
 
        dev_dbg(&spi->dev,
                "setup: bpw %u mode 0x%x -> csr%d %08x\n",
-               bits, spi->mode, spi->chip_select, csr);
+               bits, spi->mode, spi_get_chipselect(spi, 0), csr);
 
        if (!atmel_spi_is_v2(as))
                spi_writel(as, CSR0 + 4 * chip_select, csr);
index 8151bed8a117b5f837220630ae6568466217fc7f..0b57e6afce0f61ecf53729fe9bca5a4f27230cc7 100644 (file)
@@ -166,7 +166,7 @@ static void au1550_spi_chipsel(struct spi_device *spi, int value)
        switch (value) {
        case BITBANG_CS_INACTIVE:
                if (hw->pdata->deactivate_cs)
-                       hw->pdata->deactivate_cs(hw->pdata, spi->chip_select,
+                       hw->pdata->deactivate_cs(hw->pdata, spi_get_chipselect(spi, 0),
                                        cspol);
                break;
 
@@ -211,7 +211,7 @@ static void au1550_spi_chipsel(struct spi_device *spi, int value)
                } while ((stat & PSC_SPISTAT_DR) == 0);
 
                if (hw->pdata->activate_cs)
-                       hw->pdata->activate_cs(hw->pdata, spi->chip_select,
+                       hw->pdata->activate_cs(hw->pdata, spi_get_chipselect(spi, 0),
                                        cspol);
                break;
        }
index c5a3a318916420a130b6ea68dd19e6d0e3d0cb9a..89661f3b0d44c69f8fe5b862501c3a2ed44d6bf5 100644 (file)
@@ -193,7 +193,7 @@ static void spi_engine_gen_cs(struct spi_engine_program *p, bool dry,
        unsigned int mask = 0xff;
 
        if (assert)
-               mask ^= BIT(spi->chip_select);
+               mask ^= BIT(spi_get_chipselect(spi, 0));
 
        spi_engine_program_add_cmd(p, dry, SPI_ENGINE_CMD_ASSERT(1, mask));
 }
index 0eee574d3e1f20635ad9ed9726c6339dc1616e8f..7c2f1d1fb3f703f3b9e1a0d357e1e45cfe8bfe9e 100644 (file)
@@ -986,7 +986,7 @@ static int write_to_hw(struct bcm_qspi *qspi, struct spi_device *spi)
                if (has_bspi(qspi))
                        mspi_cdram &= ~1;
                else
-                       mspi_cdram |= (~(1 << spi->chip_select) &
+                       mspi_cdram |= (~(1 << spi_get_chipselect(spi, 0)) &
                                       MSPI_CDRAM_PCS);
 
                write_cdram_slot(qspi, slot, mspi_cdram);
@@ -1046,8 +1046,8 @@ static int bcm_qspi_bspi_exec_mem_op(struct spi_device *spi,
                        return -EIO;
 
        from = op->addr.val;
-       if (!spi->cs_gpiod)
-               bcm_qspi_chip_select(qspi, spi->chip_select);
+       if (!spi_get_csgpiod(spi, 0))
+               bcm_qspi_chip_select(qspi, spi_get_chipselect(spi, 0));
        bcm_qspi_write(qspi, MSPI, MSPI_WRITE_LOCK, 0);
 
        /*
@@ -1126,8 +1126,8 @@ static int bcm_qspi_transfer_one(struct spi_master *master,
        int slots;
        unsigned long timeo = msecs_to_jiffies(100);
 
-       if (!spi->cs_gpiod)
-               bcm_qspi_chip_select(qspi, spi->chip_select);
+       if (!spi_get_csgpiod(spi, 0))
+               bcm_qspi_chip_select(qspi, spi_get_chipselect(spi, 0));
        qspi->trans_pos.trans = trans;
        qspi->trans_pos.byte = 0;
 
index 747e03228c487237998802313bd0c8d3491b9bef..6b7a3fa93fdf6a2bfb8a23f5228ea2829a57fe8e 100644 (file)
@@ -1274,9 +1274,9 @@ static int bcm2835_spi_setup(struct spi_device *spi)
         * The SPI core has successfully requested the CS GPIO line from the
         * device tree, so we are done.
         */
-       if (spi->cs_gpiod)
+       if (spi_get_csgpiod(spi, 0))
                return 0;
-       if (spi->chip_select > 1) {
+       if (spi_get_chipselect(spi, 0) > 1) {
                /* error in the case of native CS requested with CS > 1
                 * officially there is a CS2, but it is not documented
                 * which GPIO is connected with that...
@@ -1301,18 +1301,19 @@ static int bcm2835_spi_setup(struct spi_device *spi)
        if (!chip)
                return 0;
 
-       spi->cs_gpiod = gpiochip_request_own_desc(chip, 8 - spi->chip_select,
-                                                 DRV_NAME,
-                                                 GPIO_LOOKUP_FLAGS_DEFAULT,
-                                                 GPIOD_OUT_LOW);
-       if (IS_ERR(spi->cs_gpiod)) {
-               ret = PTR_ERR(spi->cs_gpiod);
+       spi_set_csgpiod(spi, 0, gpiochip_request_own_desc(chip,
+                                                         8 - (spi_get_chipselect(spi, 0)),
+                                                         DRV_NAME,
+                                                         GPIO_LOOKUP_FLAGS_DEFAULT,
+                                                         GPIOD_OUT_LOW));
+       if (IS_ERR(spi_get_csgpiod(spi, 0))) {
+               ret = PTR_ERR(spi_get_csgpiod(spi, 0));
                goto err_cleanup;
        }
 
        /* and set up the "mode" and level */
        dev_info(&spi->dev, "setting up native-CS%i to use GPIO\n",
-                spi->chip_select);
+                spi_get_chipselect(spi, 0));
 
        return 0;
 
index 7f2546fd900ad12cad000b6f36d6d83b2454f421..288f7b994b36c37b97d22873d7641590641f77ff 100644 (file)
@@ -448,7 +448,7 @@ static int bcm2835aux_spi_setup(struct spi_device *spi)
        if (spi->mode & SPI_NO_CS)
                return 0;
 
-       if (spi->cs_gpiod)
+       if (spi_get_csgpiod(spi, 0))
                return 0;
 
        /* for dt-backwards compatibility: only support native on CS0
@@ -465,7 +465,7 @@ static int bcm2835aux_spi_setup(struct spi_device *spi)
        dev_warn(&spi->dev,
                 "Native CS is not supported - please configure cs-gpio in device-tree\n");
 
-       if (spi->chip_select == 0)
+       if (spi_get_chipselect(spi, 0) == 0)
                return 0;
 
        dev_warn(&spi->dev, "Native CS is not working for cs > 0\n");
index f2708caa2f334bb9705abb87b6153afb30238e7b..ee2528dad02df03b5c72814ad0b3009676072c6a 100644 (file)
@@ -349,7 +349,7 @@ static int bcm63xx_hsspi_do_prepend_txrx(struct spi_device *spi,
                                         struct spi_transfer *t)
 {
        struct bcm63xx_hsspi *bs = spi_master_get_devdata(spi->master);
-       unsigned int chip_select = spi->chip_select;
+       unsigned int chip_select = spi_get_chipselect(spi, 0);
        u16 opcode = 0, val;
        const u8 *tx = t->tx_buf;
        u8 *rx = t->rx_buf;
@@ -441,7 +441,7 @@ static void bcm63xx_hsspi_set_cs(struct bcm63xx_hsspi *bs, unsigned int cs,
 static void bcm63xx_hsspi_set_clk(struct bcm63xx_hsspi *bs,
                                  struct spi_device *spi, int hz)
 {
-       unsigned int profile = spi->chip_select;
+       unsigned int profile = spi_get_chipselect(spi, 0);
        u32 reg;
 
        reg = DIV_ROUND_UP(2048, DIV_ROUND_UP(bs->speed_hz, hz));
@@ -468,7 +468,7 @@ static void bcm63xx_hsspi_set_clk(struct bcm63xx_hsspi *bs,
 static int bcm63xx_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t)
 {
        struct bcm63xx_hsspi *bs = spi_master_get_devdata(spi->master);
-       unsigned int chip_select = spi->chip_select;
+       unsigned int chip_select = spi_get_chipselect(spi, 0);
        u16 opcode = 0, val;
        int pending = t->len;
        int step_size = HSSPI_BUFFER_LEN;
@@ -478,7 +478,7 @@ static int bcm63xx_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t)
 
        bcm63xx_hsspi_set_clk(bs, spi, t->speed_hz);
        if (!t->cs_off)
-               bcm63xx_hsspi_set_cs(bs, spi->chip_select, true);
+               bcm63xx_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), true);
 
        if (tx && rx)
                opcode = HSSPI_OP_READ_WRITE;
@@ -545,14 +545,14 @@ static int bcm63xx_hsspi_setup(struct spi_device *spi)
        u32 reg;
 
        reg = __raw_readl(bs->regs +
-                         HSSPI_PROFILE_SIGNAL_CTRL_REG(spi->chip_select));
+                         HSSPI_PROFILE_SIGNAL_CTRL_REG(spi_get_chipselect(spi, 0)));
        reg &= ~(SIGNAL_CTRL_LAUNCH_RISING | SIGNAL_CTRL_LATCH_RISING);
        if (spi->mode & SPI_CPHA)
                reg |= SIGNAL_CTRL_LAUNCH_RISING;
        else
                reg |= SIGNAL_CTRL_LATCH_RISING;
        __raw_writel(reg, bs->regs +
-                    HSSPI_PROFILE_SIGNAL_CTRL_REG(spi->chip_select));
+                    HSSPI_PROFILE_SIGNAL_CTRL_REG(spi_get_chipselect(spi, 0)));
 
        mutex_lock(&bs->bus_mutex);
        reg = __raw_readl(bs->regs + HSSPI_GLOBAL_CTRL_REG);
@@ -560,16 +560,16 @@ static int bcm63xx_hsspi_setup(struct spi_device *spi)
        /* only change actual polarities if there is no transfer */
        if ((reg & GLOBAL_CTRL_CS_POLARITY_MASK) == bs->cs_polarity) {
                if (spi->mode & SPI_CS_HIGH)
-                       reg |= BIT(spi->chip_select);
+                       reg |= BIT(spi_get_chipselect(spi, 0));
                else
-                       reg &= ~BIT(spi->chip_select);
+                       reg &= ~BIT(spi_get_chipselect(spi, 0));
                __raw_writel(reg, bs->regs + HSSPI_GLOBAL_CTRL_REG);
        }
 
        if (spi->mode & SPI_CS_HIGH)
-               bs->cs_polarity |= BIT(spi->chip_select);
+               bs->cs_polarity |= BIT(spi_get_chipselect(spi, 0));
        else
-               bs->cs_polarity &= ~BIT(spi->chip_select);
+               bs->cs_polarity &= ~BIT(spi_get_chipselect(spi, 0));
 
        mutex_unlock(&bs->bus_mutex);
 
@@ -600,7 +600,7 @@ static int bcm63xx_hsspi_do_dummy_cs_txrx(struct spi_device *spi,
         * e. At the end restore the polarities again to their default values.
         */
 
-       dummy_cs = !spi->chip_select;
+       dummy_cs = !spi_get_chipselect(spi, 0);
        bcm63xx_hsspi_set_cs(bs, dummy_cs, true);
 
        list_for_each_entry(t, &msg->transfers, transfer_list) {
@@ -633,22 +633,22 @@ static int bcm63xx_hsspi_do_dummy_cs_txrx(struct spi_device *spi,
                                keep_cs = true;
                        } else {
                                if (!t->cs_off)
-                                       bcm63xx_hsspi_set_cs(bs, spi->chip_select, false);
+                                       bcm63xx_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), false);
 
                                spi_transfer_cs_change_delay_exec(msg, t);
 
                                if (!list_next_entry(t, transfer_list)->cs_off)
-                                       bcm63xx_hsspi_set_cs(bs, spi->chip_select, true);
+                                       bcm63xx_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), true);
                        }
                } else if (!list_is_last(&t->transfer_list, &msg->transfers) &&
                           t->cs_off != list_next_entry(t, transfer_list)->cs_off) {
-                       bcm63xx_hsspi_set_cs(bs, spi->chip_select, t->cs_off);
+                       bcm63xx_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), t->cs_off);
                }
        }
 
        bcm63xx_hsspi_set_cs(bs, dummy_cs, false);
        if (status || !keep_cs)
-               bcm63xx_hsspi_set_cs(bs, spi->chip_select, false);
+               bcm63xx_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), false);
 
        return status;
 }
index 77b8328c8a6d66eb4f01952cf0ca7ce3a5fb5130..96633a0051b10ccc254236304bac59c2f39082ad 100644 (file)
@@ -282,7 +282,7 @@ static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *first,
        /* Issue the transfer */
        cmd = SPI_CMD_START_IMMEDIATE;
        cmd |= (prepend_len << SPI_CMD_PREPEND_BYTE_CNT_SHIFT);
-       cmd |= (spi->chip_select << SPI_CMD_DEVICE_ID_SHIFT);
+       cmd |= (spi_get_chipselect(spi, 0) << SPI_CMD_DEVICE_ID_SHIFT);
        bcm_spi_writew(bs, cmd, SPI_CMD);
 
        /* Enable the CMD_DONE interrupt */
index c7a44832bc9c553d999ee7a32f0814fc65cffd2f..8cbd0161978915d64cbfbc4836719d0710fbc7b4 100644 (file)
@@ -193,7 +193,7 @@ static void bcmbca_hsspi_set_cs(struct bcmbca_hsspi *bs, unsigned int cs,
 static void bcmbca_hsspi_set_clk(struct bcmbca_hsspi *bs,
                                  struct spi_device *spi, int hz)
 {
-       unsigned int profile = spi->chip_select;
+       unsigned int profile = spi_get_chipselect(spi, 0);
        u32 reg;
 
        reg = DIV_ROUND_UP(2048, DIV_ROUND_UP(bs->speed_hz, hz));
@@ -251,7 +251,7 @@ static int bcmbca_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t,
                                                                struct spi_message *msg)
 {
        struct bcmbca_hsspi *bs = spi_master_get_devdata(spi->master);
-       unsigned int chip_select = spi->chip_select;
+       unsigned int chip_select = spi_get_chipselect(spi, 0);
        u16 opcode = 0, val;
        int pending = t->len;
        int step_size = HSSPI_BUFFER_LEN;
@@ -312,7 +312,7 @@ static int bcmbca_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t,
                            PINGPONG_COMMAND_START_NOW;
                __raw_writel(reg, bs->regs + HSSPI_PINGPONG_COMMAND_REG(0));
 
-               if (bcmbca_hsspi_wait_cmd(bs, spi->chip_select))
+               if (bcmbca_hsspi_wait_cmd(bs, spi_get_chipselect(spi, 0)))
                        return -ETIMEDOUT;
 
                pending -= curr_step;
@@ -332,33 +332,33 @@ static int bcmbca_hsspi_setup(struct spi_device *spi)
        u32 reg;
 
        reg = __raw_readl(bs->regs +
-                         HSSPI_PROFILE_SIGNAL_CTRL_REG(spi->chip_select));
+                         HSSPI_PROFILE_SIGNAL_CTRL_REG(spi_get_chipselect(spi, 0)));
        reg &= ~(SIGNAL_CTRL_LAUNCH_RISING | SIGNAL_CTRL_LATCH_RISING);
        if (spi->mode & SPI_CPHA)
                reg |= SIGNAL_CTRL_LAUNCH_RISING;
        else
                reg |= SIGNAL_CTRL_LATCH_RISING;
        __raw_writel(reg, bs->regs +
-                    HSSPI_PROFILE_SIGNAL_CTRL_REG(spi->chip_select));
+                    HSSPI_PROFILE_SIGNAL_CTRL_REG(spi_get_chipselect(spi, 0)));
 
        mutex_lock(&bs->bus_mutex);
        reg = __raw_readl(bs->regs + HSSPI_GLOBAL_CTRL_REG);
 
        if (spi->mode & SPI_CS_HIGH)
-               reg |= BIT(spi->chip_select);
+               reg |= BIT(spi_get_chipselect(spi, 0));
        else
-               reg &= ~BIT(spi->chip_select);
+               reg &= ~BIT(spi_get_chipselect(spi, 0));
        __raw_writel(reg, bs->regs + HSSPI_GLOBAL_CTRL_REG);
 
        if (spi->mode & SPI_CS_HIGH)
-               bs->cs_polarity |= BIT(spi->chip_select);
+               bs->cs_polarity |= BIT(spi_get_chipselect(spi, 0));
        else
-               bs->cs_polarity &= ~BIT(spi->chip_select);
+               bs->cs_polarity &= ~BIT(spi_get_chipselect(spi, 0));
 
        reg = __raw_readl(bs->spim_ctrl);
-       reg &= ~BIT(spi->chip_select + SPIM_CTRL_CS_OVERRIDE_VAL_SHIFT);
+       reg &= ~BIT(spi_get_chipselect(spi, 0) + SPIM_CTRL_CS_OVERRIDE_VAL_SHIFT);
        if (spi->mode & SPI_CS_HIGH)
-               reg |= BIT(spi->chip_select + SPIM_CTRL_CS_OVERRIDE_VAL_SHIFT);
+               reg |= BIT(spi_get_chipselect(spi, 0) + SPIM_CTRL_CS_OVERRIDE_VAL_SHIFT);
        __raw_writel(reg, bs->spim_ctrl);
 
        mutex_unlock(&bs->bus_mutex);
@@ -388,16 +388,16 @@ static int bcmbca_hsspi_transfer_one(struct spi_master *master,
                                keep_cs = true;
                        } else {
                                if (!t->cs_off)
-                                       bcmbca_hsspi_set_cs(bs, spi->chip_select, false);
+                                       bcmbca_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), false);
 
                                spi_transfer_cs_change_delay_exec(msg, t);
 
                                if (!list_next_entry(t, transfer_list)->cs_off)
-                                       bcmbca_hsspi_set_cs(bs, spi->chip_select, true);
+                                       bcmbca_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), true);
                        }
                } else if (!list_is_last(&t->transfer_list, &msg->transfers) &&
                           t->cs_off != list_next_entry(t, transfer_list)->cs_off) {
-                       bcmbca_hsspi_set_cs(bs, spi->chip_select, t->cs_off);
+                       bcmbca_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), t->cs_off);
                }
 
                msg->actual_length += t->len;
@@ -406,7 +406,7 @@ static int bcmbca_hsspi_transfer_one(struct spi_master *master,
        mutex_unlock(&bs->msg_mutex);
 
        if (status || !keep_cs)
-               bcmbca_hsspi_set_cs(bs, spi->chip_select, false);
+               bcmbca_hsspi_set_cs(bs, spi_get_chipselect(spi, 0), false);
 
        msg->status = status;
        spi_finalize_current_message(master);
index 463fd49f4f804e9d8ebfbdc8ac3ba46faee790aa..79ab7e3096447289447a6dc577a2737520df25c1 100644 (file)
@@ -1355,7 +1355,7 @@ static int cqspi_mem_process(struct spi_mem *mem, const struct spi_mem_op *op)
        struct cqspi_st *cqspi = spi_master_get_devdata(mem->spi->master);
        struct cqspi_flash_pdata *f_pdata;
 
-       f_pdata = &cqspi->f_pdata[mem->spi->chip_select];
+       f_pdata = &cqspi->f_pdata[spi_get_chipselect(mem->spi, 0)];
        cqspi_configure(f_pdata, mem->spi->max_speed_hz);
 
        if (op->data.dir == SPI_MEM_DATA_IN && op->data.buf.in) {
@@ -1561,7 +1561,8 @@ static const char *cqspi_get_name(struct spi_mem *mem)
        struct cqspi_st *cqspi = spi_master_get_devdata(mem->spi->master);
        struct device *dev = &cqspi->pdev->dev;
 
-       return devm_kasprintf(dev, GFP_KERNEL, "%s.%d", dev_name(dev), mem->spi->chip_select);
+       return devm_kasprintf(dev, GFP_KERNEL, "%s.%d", dev_name(dev),
+                             spi_get_chipselect(mem->spi, 0));
 }
 
 static const struct spi_controller_mem_ops cqspi_mem_ops = {
index 91db3c973167b0e319274cad3024c85cb50840bb..ce4a3145f065b2729b01985039c1386441b0140b 100644 (file)
@@ -409,8 +409,8 @@ static int cdns_xspi_mem_op(struct cdns_xspi_dev *cdns_xspi,
 {
        enum spi_mem_data_dir dir = op->data.dir;
 
-       if (cdns_xspi->cur_cs != mem->spi->chip_select)
-               cdns_xspi->cur_cs = mem->spi->chip_select;
+       if (cdns_xspi->cur_cs != spi_get_chipselect(mem->spi, 0))
+               cdns_xspi->cur_cs = spi_get_chipselect(mem->spi, 0);
 
        return cdns_xspi_send_stig_command(cdns_xspi, op,
                                           (dir != SPI_MEM_NO_DATA));
index 1ad86e5d2b2f18c28d5cead7b3b80f17558cfc08..49936237e583d97bd2b8e7e7d4869249ff026f19 100644 (file)
@@ -185,11 +185,11 @@ static void cdns_spi_chipselect(struct spi_device *spi, bool is_high)
                /* Select the slave */
                ctrl_reg &= ~CDNS_SPI_CR_SSCTRL;
                if (!(xspi->is_decoded_cs))
-                       ctrl_reg |= ((~(CDNS_SPI_SS0 << spi->chip_select)) <<
+                       ctrl_reg |= ((~(CDNS_SPI_SS0 << spi_get_chipselect(spi, 0))) <<
                                     CDNS_SPI_SS_SHIFT) &
                                     CDNS_SPI_CR_SSCTRL;
                else
-                       ctrl_reg |= (spi->chip_select << CDNS_SPI_SS_SHIFT) &
+                       ctrl_reg |= (spi_get_chipselect(spi, 0) << CDNS_SPI_SS_SHIFT) &
                                     CDNS_SPI_CR_SSCTRL;
        }
 
index 6854c3ce423b35b730469d180d90e30442c4ef96..dfe224defd6eda55aefed6b6775790d8847acdae 100644 (file)
@@ -57,8 +57,8 @@ static int octeon_spi_do_transfer(struct octeon_spi *p,
        mpi_cfg.s.cslate = cpha ? 1 : 0;
        mpi_cfg.s.enable = 1;
 
-       if (spi->chip_select < 4)
-               p->cs_enax |= 1ull << (12 + spi->chip_select);
+       if (spi_get_chipselect(spi, 0) < 4)
+               p->cs_enax |= 1ull << (12 + spi_get_chipselect(spi, 0));
        mpi_cfg.u64 |= p->cs_enax;
 
        if (mpi_cfg.u64 != p->last_cfg) {
@@ -78,7 +78,7 @@ static int octeon_spi_do_transfer(struct octeon_spi *p,
                        writeq(d, p->register_base + OCTEON_SPI_DAT0(p) + (8 * i));
                }
                mpi_tx.u64 = 0;
-               mpi_tx.s.csid = spi->chip_select;
+               mpi_tx.s.csid = spi_get_chipselect(spi, 0);
                mpi_tx.s.leavecs = 1;
                mpi_tx.s.txnum = tx_buf ? OCTEON_SPI_MAX_BYTES : 0;
                mpi_tx.s.totnum = OCTEON_SPI_MAX_BYTES;
@@ -103,7 +103,7 @@ static int octeon_spi_do_transfer(struct octeon_spi *p,
        }
 
        mpi_tx.u64 = 0;
-       mpi_tx.s.csid = spi->chip_select;
+       mpi_tx.s.csid = spi_get_chipselect(spi, 0);
        if (last_xfer)
                mpi_tx.s.leavecs = xfer->cs_change;
        else
index d98e74c6e4b2404cb3165982c73cc3e999d844b4..b1bd8a6b5bf910aa2e4c1a206d236350eafae3ee 100644 (file)
@@ -290,9 +290,9 @@ static void mcfqspi_set_cs(struct spi_device *spi, bool enable)
        bool cs_high = spi->mode & SPI_CS_HIGH;
 
        if (enable)
-               mcfqspi_cs_select(mcfqspi, spi->chip_select, cs_high);
+               mcfqspi_cs_select(mcfqspi, spi_get_chipselect(spi, 0), cs_high);
        else
-               mcfqspi_cs_deselect(mcfqspi, spi->chip_select, cs_high);
+               mcfqspi_cs_deselect(mcfqspi, spi_get_chipselect(spi, 0), cs_high);
 }
 
 static int mcfqspi_transfer_one(struct spi_master *master,
@@ -324,11 +324,11 @@ static int mcfqspi_transfer_one(struct spi_master *master,
 static int mcfqspi_setup(struct spi_device *spi)
 {
        mcfqspi_cs_deselect(spi_master_get_devdata(spi->master),
-                           spi->chip_select, spi->mode & SPI_CS_HIGH);
+                           spi_get_chipselect(spi, 0), spi->mode & SPI_CS_HIGH);
 
        dev_dbg(&spi->dev,
                        "bits per word %d, chip select %d, speed %d KHz\n",
-                       spi->bits_per_word, spi->chip_select,
+                       spi->bits_per_word, spi_get_chipselect(spi, 0),
                        (MCFQSPI_BUSCLK / mcfqspi_qmr_baud(spi->max_speed_hz))
                        / 1000);
 
index add1e198a43964153f7a6d1ed7f8ab35cc6c33cc..b04811c911e2ca7138186a685db34037c7cf5916 100644 (file)
@@ -199,7 +199,7 @@ static void davinci_spi_chipselect(struct spi_device *spi, int value)
 {
        struct davinci_spi *dspi;
        struct davinci_spi_config *spicfg = spi->controller_data;
-       u8 chip_sel = spi->chip_select;
+       u8 chip_sel = spi_get_chipselect(spi, 0);
        u16 spidat1 = CS_DEFAULT;
 
        dspi = spi_master_get_devdata(spi->master);
@@ -212,11 +212,11 @@ static void davinci_spi_chipselect(struct spi_device *spi, int value)
         * Board specific chip select logic decides the polarity and cs
         * line for the controller
         */
-       if (spi->cs_gpiod) {
+       if (spi_get_csgpiod(spi, 0)) {
                if (value == BITBANG_CS_ACTIVE)
-                       gpiod_set_value(spi->cs_gpiod, 1);
+                       gpiod_set_value(spi_get_csgpiod(spi, 0), 1);
                else
-                       gpiod_set_value(spi->cs_gpiod, 0);
+                       gpiod_set_value(spi_get_csgpiod(spi, 0), 0);
        } else {
                if (value == BITBANG_CS_ACTIVE) {
                        if (!(spi->mode & SPI_CS_WORD))
@@ -293,11 +293,11 @@ static int davinci_spi_setup_transfer(struct spi_device *spi,
        if (bits_per_word <= 8) {
                dspi->get_rx = davinci_spi_rx_buf_u8;
                dspi->get_tx = davinci_spi_tx_buf_u8;
-               dspi->bytes_per_word[spi->chip_select] = 1;
+               dspi->bytes_per_word[spi_get_chipselect(spi, 0)] = 1;
        } else {
                dspi->get_rx = davinci_spi_rx_buf_u16;
                dspi->get_tx = davinci_spi_tx_buf_u16;
-               dspi->bytes_per_word[spi->chip_select] = 2;
+               dspi->bytes_per_word[spi_get_chipselect(spi, 0)] = 2;
        }
 
        if (!hz)
@@ -415,11 +415,11 @@ static int davinci_spi_setup(struct spi_device *spi)
        dspi = spi_master_get_devdata(spi->master);
 
        if (!(spi->mode & SPI_NO_CS)) {
-               if (np && spi->cs_gpiod)
+               if (np && spi_get_csgpiod(spi, 0))
                        internal_cs = false;
 
                if (internal_cs)
-                       set_io_bits(dspi->base + SPIPC0, 1 << spi->chip_select);
+                       set_io_bits(dspi->base + SPIPC0, 1 << spi_get_chipselect(spi, 0));
        }
 
        if (spi->mode & SPI_READY)
@@ -579,7 +579,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
                spicfg = &davinci_spi_default_cfg;
 
        /* convert len to words based on bits_per_word */
-       data_type = dspi->bytes_per_word[spi->chip_select];
+       data_type = dspi->bytes_per_word[spi_get_chipselect(spi, 0)];
 
        dspi->tx = t->tx_buf;
        dspi->rx = t->rx_buf;
index 821bfc6b0dd6fe3c263c4f9710ecc286031e8dc7..6bd93c47853c2d8762c9dd86e80b858bdca230d6 100644 (file)
@@ -596,12 +596,12 @@ static int dln2_spi_prepare_message(struct spi_master *master,
        struct dln2_spi *dln2 = spi_master_get_devdata(master);
        struct spi_device *spi = message->spi;
 
-       if (dln2->cs != spi->chip_select) {
-               ret = dln2_spi_cs_set_one(dln2, spi->chip_select);
+       if (dln2->cs != spi_get_chipselect(spi, 0)) {
+               ret = dln2_spi_cs_set_one(dln2, spi_get_chipselect(spi, 0));
                if (ret < 0)
                        return ret;
 
-               dln2->cs = spi->chip_select;
+               dln2->cs = spi_get_chipselect(spi, 0);
        }
 
        return 0;
index c3bfb6c84cab2fb97ed1ef98f2491d791c550c86..ae3108c70f508b26d9aeb3a48dd37a8551597ba6 100644 (file)
@@ -103,7 +103,7 @@ void dw_spi_set_cs(struct spi_device *spi, bool enable)
         * support active-high or active-low CS level.
         */
        if (cs_high == enable)
-               dw_writel(dws, DW_SPI_SER, BIT(spi->chip_select));
+               dw_writel(dws, DW_SPI_SER, BIT(spi_get_chipselect(spi, 0)));
        else
                dw_writel(dws, DW_SPI_SER, 0);
 }
index 6ae124c30969662023dad0361f444503a33901e9..328541b5fb5222aed5191fe07841404035e8a94a 100644 (file)
@@ -65,7 +65,7 @@ static void dw_spi_mscc_set_cs(struct spi_device *spi, bool enable)
        struct dw_spi *dws = spi_master_get_devdata(spi->master);
        struct dw_spi_mmio *dwsmmio = container_of(dws, struct dw_spi_mmio, dws);
        struct dw_spi_mscc *dwsmscc = dwsmmio->priv;
-       u32 cs = spi->chip_select;
+       u32 cs = spi_get_chipselect(spi, 0);
 
        if (cs < 4) {
                u32 sw_mode = MSCC_SPI_MST_SW_MODE_SW_PIN_CTRL_MODE;
@@ -138,7 +138,7 @@ static void dw_spi_sparx5_set_cs(struct spi_device *spi, bool enable)
        struct dw_spi *dws = spi_master_get_devdata(spi->master);
        struct dw_spi_mmio *dwsmmio = container_of(dws, struct dw_spi_mmio, dws);
        struct dw_spi_mscc *dwsmscc = dwsmmio->priv;
-       u8 cs = spi->chip_select;
+       u8 cs = spi_get_chipselect(spi, 0);
 
        if (!enable) {
                /* CS override drive enable */
index a7d4dffac66b25a90fbdc85dc102c1f61a35b082..4c103dff0d4453d1b2e855f4f2c5dc5f622d0092 100644 (file)
@@ -131,7 +131,7 @@ int falcon_sflash_xfer(struct spi_device *spi, struct spi_transfer *t,
                                 * especially alen and dumlen.
                                 */
 
-                               priv->sfcmd = ((spi->chip_select
+                               priv->sfcmd = ((spi_get_chipselect(spi, 0)
                                                << SFCMD_CS_OFFSET)
                                               & SFCMD_CS_MASK);
                                priv->sfcmd |= SFCMD_KEEP_CS_KEEP_SELECTED;
index cf1e4f9ebd7276ec615cbf0d5ee87957fa79617b..ba3b17d7c9ec2dc40191c7e611aa03b60e9f1107 100644 (file)
@@ -425,7 +425,7 @@ static int fsi_spi_transfer_one_message(struct spi_controller *ctlr,
                                        struct spi_message *mesg)
 {
        int rc;
-       u8 seq_slave = SPI_FSI_SEQUENCE_SEL_SLAVE(mesg->spi->chip_select + 1);
+       u8 seq_slave = SPI_FSI_SEQUENCE_SEL_SLAVE(spi_get_chipselect(mesg->spi, 0) + 1);
        unsigned int len;
        struct spi_transfer *transfer;
        struct fsi_spi *ctx = spi_controller_get_devdata(ctlr);
index 49df00f52ea46aa89c4a00b6580da8caf430721a..ee42285b5c5243a5ddc416ad23386b55e94f3bcc 100644 (file)
@@ -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);
 }
index 42a3ed79e7dc50082aa28b40dd795d1bd438cf0a..b3d2d3db5850f22713cfbce94ba605eb99295644 100644 (file)
@@ -345,7 +345,7 @@ static void fsl_espi_setup_transfer(struct spi_device *spi,
 
        /* don't write the mode register if the mode doesn't change */
        if (cs->hw_mode != hw_mode_old)
-               fsl_espi_write_reg(espi, ESPI_SPMODEx(spi->chip_select),
+               fsl_espi_write_reg(espi, ESPI_SPMODEx(spi_get_chipselect(spi, 0)),
                                   cs->hw_mode);
 }
 
@@ -359,7 +359,7 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)
        reinit_completion(&espi->done);
 
        /* Set SPCOM[CS] and SPCOM[TRANLEN] field */
-       spcom = SPCOM_CS(spi->chip_select);
+       spcom = SPCOM_CS(spi_get_chipselect(spi, 0));
        spcom |= SPCOM_TRANLEN(t->len - 1);
 
        /* configure RXSKIP mode */
@@ -492,7 +492,7 @@ static int fsl_espi_setup(struct spi_device *spi)
 
        pm_runtime_get_sync(espi->dev);
 
-       cs->hw_mode = fsl_espi_read_reg(espi, ESPI_SPMODEx(spi->chip_select));
+       cs->hw_mode = fsl_espi_read_reg(espi, ESPI_SPMODEx(spi_get_chipselect(spi, 0)));
        /* mask out bits we are going to set */
        cs->hw_mode &= ~(CSMODE_CP_BEGIN_EDGECLK | CSMODE_CI_INACTIVEHIGH
                         | CSMODE_REV);
index b9e8b7b241a48c751185da08688a1a4b3a5aa6fd..f2341ab99556649fa308931afc7ede4e8bc7cd52 100644 (file)
@@ -425,7 +425,7 @@ static int fsl_lpspi_setup_transfer(struct spi_controller *controller,
        if (fsl_lpspi->is_only_cs1)
                fsl_lpspi->config.chip_select = 1;
        else
-               fsl_lpspi->config.chip_select = spi->chip_select;
+               fsl_lpspi->config.chip_select = spi_get_chipselect(spi, 0);
 
        if (!fsl_lpspi->config.speed_hz)
                fsl_lpspi->config.speed_hz = spi->max_speed_hz;
index bacc54836959c3c98e4b0b5c879dd693db824c1c..8ade61e5ebc0900c46da5378fa61aad85d6afb80 100644 (file)
@@ -528,7 +528,7 @@ static void fsl_qspi_select_mem(struct fsl_qspi *q, struct spi_device *spi)
        unsigned long rate = spi->max_speed_hz;
        int ret;
 
-       if (q->selected == spi->chip_select)
+       if (q->selected == spi_get_chipselect(spi, 0))
                return;
 
        if (needs_4x_clock(q))
@@ -544,7 +544,7 @@ static void fsl_qspi_select_mem(struct fsl_qspi *q, struct spi_device *spi)
        if (ret)
                return;
 
-       q->selected = spi->chip_select;
+       q->selected = spi_get_chipselect(spi, 0);
 
        fsl_qspi_invalidate(q);
 }
@@ -823,7 +823,7 @@ static const char *fsl_qspi_get_name(struct spi_mem *mem)
 
        name = devm_kasprintf(dev, GFP_KERNEL,
                              "%s-%d", dev_name(q->dev),
-                             mem->spi->chip_select);
+                             spi_get_chipselect(mem->spi, 0));
 
        if (!name) {
                dev_err(dev, "failed to get memory for custom flash name\n");
index 725d043488a1254038bcaad2a84aa2ae7e78da0d..702756c25aa75193de788bcf427354384542ca2d 100644 (file)
@@ -503,7 +503,7 @@ static void fsl_spi_grlib_cs_control(struct spi_device *spi, bool on)
        struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master);
        struct fsl_spi_reg __iomem *reg_base = mpc8xxx_spi->reg_base;
        u32 slvsel;
-       u16 cs = spi->chip_select;
+       u16 cs = spi_get_chipselect(spi, 0);
 
        if (cs < mpc8xxx_spi->native_chipselects) {
                slvsel = mpc8xxx_spi_read_reg(&reg_base->slvsel);
index f80635532b4d285840750dcd74449f76ad9a6990..ba7be505ec4ef5594ea9e9d4ee6e24c247f10140 100644 (file)
@@ -391,9 +391,9 @@ static int setup_fifo_params(struct spi_device *spi_slv,
                        cpha = CPHA;
 
                if (spi_slv->mode & SPI_CS_HIGH)
-                       demux_output_inv = BIT(spi_slv->chip_select);
+                       demux_output_inv = BIT(spi_get_chipselect(spi_slv, 0));
 
-               demux_sel = spi_slv->chip_select;
+               demux_sel = spi_get_chipselect(spi_slv, 0);
                mas->cur_bits_per_word = spi_slv->bits_per_word;
 
                spi_setup_word_len(mas, spi_slv->mode, spi_slv->bits_per_word);
@@ -469,7 +469,7 @@ static int setup_gsi_xfer(struct spi_transfer *xfer, struct spi_geni_master *mas
        peripheral.loopback_en = !!(spi_slv->mode & SPI_LOOP);
        peripheral.clock_pol_high = !!(spi_slv->mode & SPI_CPOL);
        peripheral.data_pol_high = !!(spi_slv->mode & SPI_CPHA);
-       peripheral.cs = spi_slv->chip_select;
+       peripheral.cs = spi_get_chipselect(spi_slv, 0);
        peripheral.pack_en = true;
        peripheral.word_len = xfer->bits_per_word - MIN_WORD_LEN;
 
index 9c8c7948044ed784017100aae497c0b5be35b0c7..092afc7679d4071edced902bbde9c32545820d4a 100644 (file)
@@ -230,7 +230,7 @@ static void spi_gpio_chipselect(struct spi_device *spi, int is_active)
 
        /* Drive chip select line, if we have one */
        if (spi_gpio->cs_gpios) {
-               struct gpio_desc *cs = spi_gpio->cs_gpios[spi->chip_select];
+               struct gpio_desc *cs = spi_gpio->cs_gpios[spi_get_chipselect(spi, 0)];
 
                /* SPI chip selects are normally active-low */
                gpiod_set_value_cansleep(cs, (spi->mode & SPI_CS_HIGH) ? is_active : !is_active);
@@ -248,7 +248,7 @@ static int spi_gpio_setup(struct spi_device *spi)
         * initialized from the descriptor lookup.
         */
        if (spi_gpio->cs_gpios) {
-               cs = spi_gpio->cs_gpios[spi->chip_select];
+               cs = spi_gpio->cs_gpios[spi_get_chipselect(spi, 0)];
                if (!spi->controller_state && cs)
                        status = gpiod_direction_output(cs,
                                                  !(spi->mode & SPI_CS_HIGH));
index c900c2f39b578f1d114249cb78d6831cc605e488..684d63f402f34d75d1151e1772944e2048733fae 100644 (file)
@@ -201,7 +201,7 @@ static ssize_t gxp_spi_write(struct gxp_spi_chip *chip, const struct spi_mem_op
 static int do_gxp_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op)
 {
        struct gxp_spi *spifi = spi_controller_get_devdata(mem->spi->master);
-       struct gxp_spi_chip *chip = &spifi->chips[mem->spi->chip_select];
+       struct gxp_spi_chip *chip = &spifi->chips[spi_get_chipselect(mem->spi, 0)];
        int ret;
 
        if (op->data.dir == SPI_MEM_DATA_IN) {
@@ -237,7 +237,7 @@ static const struct spi_controller_mem_ops gxp_spi_mem_ops = {
 static int gxp_spi_setup(struct spi_device *spi)
 {
        struct gxp_spi *spifi = spi_controller_get_devdata(spi->master);
-       unsigned int cs = spi->chip_select;
+       unsigned int cs = spi_get_chipselect(spi, 0);
        struct gxp_spi_chip *chip = &spifi->chips[cs];
 
        chip->spifi = spifi;
index f07d1045a30a227c8db4e28bad7e998d6997c410..7cbcb065bb44c10923621fcd1a5aca70cd4cdb8b 100644 (file)
@@ -361,7 +361,7 @@ static int hisi_sfc_v3xx_exec_op(struct spi_mem *mem,
 {
        struct hisi_sfc_v3xx_host *host;
        struct spi_device *spi = mem->spi;
-       u8 chip_select = spi->chip_select;
+       u8 chip_select = spi_get_chipselect(spi, 0);
 
        host = spi_controller_get_devdata(spi->master);
 
index c64e4fd3fdf003a39bd8004896a05959566a52eb..d775f87770e333b1f4503634d78512c7aefc2b35 100644 (file)
@@ -413,15 +413,15 @@ static int img_spfi_prepare(struct spi_master *master, struct spi_message *msg)
        val = spfi_readl(spfi, SPFI_PORT_STATE);
        val &= ~(SPFI_PORT_STATE_DEV_SEL_MASK <<
                 SPFI_PORT_STATE_DEV_SEL_SHIFT);
-       val |= msg->spi->chip_select << SPFI_PORT_STATE_DEV_SEL_SHIFT;
+       val |= spi_get_chipselect(msg->spi, 0) << SPFI_PORT_STATE_DEV_SEL_SHIFT;
        if (msg->spi->mode & SPI_CPHA)
-               val |= SPFI_PORT_STATE_CK_PHASE(msg->spi->chip_select);
+               val |= SPFI_PORT_STATE_CK_PHASE(spi_get_chipselect(msg->spi, 0));
        else
-               val &= ~SPFI_PORT_STATE_CK_PHASE(msg->spi->chip_select);
+               val &= ~SPFI_PORT_STATE_CK_PHASE(spi_get_chipselect(msg->spi, 0));
        if (msg->spi->mode & SPI_CPOL)
-               val |= SPFI_PORT_STATE_CK_POL(msg->spi->chip_select);
+               val |= SPFI_PORT_STATE_CK_POL(spi_get_chipselect(msg->spi, 0));
        else
-               val &= ~SPFI_PORT_STATE_CK_POL(msg->spi->chip_select);
+               val &= ~SPFI_PORT_STATE_CK_POL(spi_get_chipselect(msg->spi, 0));
        spfi_writel(spfi, val, SPFI_PORT_STATE);
 
        return 0;
@@ -450,11 +450,11 @@ static void img_spfi_config(struct spi_master *master, struct spi_device *spi,
        div = DIV_ROUND_UP(clk_get_rate(spfi->spfi_clk), xfer->speed_hz);
        div = clamp(512 / (1 << get_count_order(div)), 1, 128);
 
-       val = spfi_readl(spfi, SPFI_DEVICE_PARAMETER(spi->chip_select));
+       val = spfi_readl(spfi, SPFI_DEVICE_PARAMETER(spi_get_chipselect(spi, 0)));
        val &= ~(SPFI_DEVICE_PARAMETER_BITCLK_MASK <<
                 SPFI_DEVICE_PARAMETER_BITCLK_SHIFT);
        val |= div << SPFI_DEVICE_PARAMETER_BITCLK_SHIFT;
-       spfi_writel(spfi, val, SPFI_DEVICE_PARAMETER(spi->chip_select));
+       spfi_writel(spfi, val, SPFI_DEVICE_PARAMETER(spi_get_chipselect(spi, 0)));
 
        spfi_writel(spfi, xfer->len << SPFI_TRANSACTION_TSIZE_SHIFT,
                    SPFI_TRANSACTION);
index e4ccd0c329d063041fd3d365aa9a135c925b3a9f..620bce96b1f9a568fd38e968afa777ae55df531c 100644 (file)
@@ -528,7 +528,7 @@ static int mx51_ecspi_prepare_message(struct spi_imx_data *spi_imx,
                ctrl |= MX51_ECSPI_CTRL_DRCTL(spi_imx->spi_drctl);
 
        /* set chip select to use */
-       ctrl |= MX51_ECSPI_CTRL_CS(spi->chip_select);
+       ctrl |= MX51_ECSPI_CTRL_CS(spi_get_chipselect(spi, 0));
 
        /*
         * The ctrl register must be written first, with the EN bit set other
@@ -549,22 +549,22 @@ static int mx51_ecspi_prepare_message(struct spi_imx_data *spi_imx,
         * BURST_LENGTH + 1 bits are received
         */
        if (spi_imx->slave_mode && is_imx53_ecspi(spi_imx))
-               cfg &= ~MX51_ECSPI_CONFIG_SBBCTRL(spi->chip_select);
+               cfg &= ~MX51_ECSPI_CONFIG_SBBCTRL(spi_get_chipselect(spi, 0));
        else
-               cfg |= MX51_ECSPI_CONFIG_SBBCTRL(spi->chip_select);
+               cfg |= MX51_ECSPI_CONFIG_SBBCTRL(spi_get_chipselect(spi, 0));
 
        if (spi->mode & SPI_CPOL) {
-               cfg |= MX51_ECSPI_CONFIG_SCLKPOL(spi->chip_select);
-               cfg |= MX51_ECSPI_CONFIG_SCLKCTL(spi->chip_select);
+               cfg |= MX51_ECSPI_CONFIG_SCLKPOL(spi_get_chipselect(spi, 0));
+               cfg |= MX51_ECSPI_CONFIG_SCLKCTL(spi_get_chipselect(spi, 0));
        } else {
-               cfg &= ~MX51_ECSPI_CONFIG_SCLKPOL(spi->chip_select);
-               cfg &= ~MX51_ECSPI_CONFIG_SCLKCTL(spi->chip_select);
+               cfg &= ~MX51_ECSPI_CONFIG_SCLKPOL(spi_get_chipselect(spi, 0));
+               cfg &= ~MX51_ECSPI_CONFIG_SCLKCTL(spi_get_chipselect(spi, 0));
        }
 
        if (spi->mode & SPI_CS_HIGH)
-               cfg |= MX51_ECSPI_CONFIG_SSBPOL(spi->chip_select);
+               cfg |= MX51_ECSPI_CONFIG_SSBPOL(spi_get_chipselect(spi, 0));
        else
-               cfg &= ~MX51_ECSPI_CONFIG_SSBPOL(spi->chip_select);
+               cfg &= ~MX51_ECSPI_CONFIG_SSBPOL(spi_get_chipselect(spi, 0));
 
        if (cfg == current_cfg)
                return 0;
@@ -614,9 +614,9 @@ static void mx51_configure_cpha(struct spi_imx_data *spi_imx,
        cpha ^= flip_cpha;
 
        if (cpha)
-               cfg |= MX51_ECSPI_CONFIG_SCLKPHA(spi->chip_select);
+               cfg |= MX51_ECSPI_CONFIG_SCLKPHA(spi_get_chipselect(spi, 0));
        else
-               cfg &= ~MX51_ECSPI_CONFIG_SCLKPHA(spi->chip_select);
+               cfg &= ~MX51_ECSPI_CONFIG_SCLKPHA(spi_get_chipselect(spi, 0));
 
        writel(cfg, spi_imx->base + MX51_ECSPI_CONFIG);
 }
@@ -768,8 +768,8 @@ static int mx31_prepare_transfer(struct spi_imx_data *spi_imx,
                reg |= MX31_CSPICTRL_POL;
        if (spi->mode & SPI_CS_HIGH)
                reg |= MX31_CSPICTRL_SSPOL;
-       if (!spi->cs_gpiod)
-               reg |= (spi->chip_select) <<
+       if (!spi_get_csgpiod(spi, 0))
+               reg |= (spi_get_chipselect(spi, 0)) <<
                        (is_imx35_cspi(spi_imx) ? MX35_CSPICTRL_CS_SHIFT :
                                                  MX31_CSPICTRL_CS_SHIFT);
 
@@ -868,8 +868,8 @@ static int mx21_prepare_transfer(struct spi_imx_data *spi_imx,
                reg |= MX21_CSPICTRL_POL;
        if (spi->mode & SPI_CS_HIGH)
                reg |= MX21_CSPICTRL_SSPOL;
-       if (!spi->cs_gpiod)
-               reg |= spi->chip_select << MX21_CSPICTRL_CS_SHIFT;
+       if (!spi_get_csgpiod(spi, 0))
+               reg |= spi_get_chipselect(spi, 0) << MX21_CSPICTRL_CS_SHIFT;
 
        writel(reg, spi_imx->base + MXC_CSPICTRL);
 
index 713a238bee63a5b2c007874acf77748a64b594ca..7d4b515a160d91a4c836be75a94c575a689a5f47 100644 (file)
@@ -263,7 +263,7 @@ static int spi_ingenic_prepare_message(struct spi_controller *ctlr,
 {
        struct ingenic_spi *priv = spi_controller_get_devdata(ctlr);
        struct spi_device *spi = message->spi;
-       unsigned int cs = REG_SSICR1_FRMHL << spi->chip_select;
+       unsigned int cs = REG_SSICR1_FRMHL << spi_get_chipselect(spi, 0);
        unsigned int ssicr0_mask = REG_SSICR0_LOOP | REG_SSICR0_FSEL;
        unsigned int ssicr1_mask = REG_SSICR1_PHA | REG_SSICR1_POL | cs;
        unsigned int ssicr0 = 0, ssicr1 = 0;
@@ -282,7 +282,7 @@ static int spi_ingenic_prepare_message(struct spi_controller *ctlr,
 
        if (spi->mode & SPI_LOOP)
                ssicr0 |= REG_SSICR0_LOOP;
-       if (spi->chip_select)
+       if (spi_get_chipselect(spi, 0))
                ssicr0 |= REG_SSICR0_FSEL;
 
        if (spi->mode & SPI_CPHA)
index f4679868c49f1bdb09a974b5479f4a53e9dab60c..bc6d22149e7e1bdcb5fbcad99cc4a26348da7d18 100644 (file)
@@ -451,7 +451,7 @@ static u32 intel_spi_chip_addr(const struct intel_spi *ispi,
        /* Pick up the correct start address */
        if (!mem)
                return 0;
-       return mem->spi->chip_select == 1 ? ispi->chip0_size : 0;
+       return (spi_get_chipselect(mem->spi, 0) == 1) ? ispi->chip0_size : 0;
 }
 
 static int intel_spi_read_reg(struct intel_spi *ispi, const struct spi_mem *mem,
index 74c8319c29f1706aef9e4b2bea9b7956d4c937f6..c42a3358e8c9aac72cbaff2a7f87e0f347996c4e 100644 (file)
@@ -68,9 +68,9 @@ static void jcore_spi_program(struct jcore_spi *hw)
 static void jcore_spi_chipsel(struct spi_device *spi, bool value)
 {
        struct jcore_spi *hw = spi_master_get_devdata(spi->master);
-       u32 csbit = 1U << (2 * spi->chip_select);
+       u32 csbit = 1U << (2 * spi_get_chipselect(spi, 0));
 
-       dev_dbg(hw->master->dev.parent, "chipselect %d\n", spi->chip_select);
+       dev_dbg(hw->master->dev.parent, "chipselect %d\n", spi_get_chipselect(spi, 0));
 
        if (value)
                hw->cs_reg |= csbit;
index 76cf2a66f87497d39509663502946f68ef427666..8d6ecc5d6f70c2b4eea2d7661b90c19ca7b547a7 100644 (file)
@@ -388,11 +388,11 @@ static int lantiq_ssc_setup(struct spi_device *spidev)
 {
        struct spi_master *master = spidev->master;
        struct lantiq_ssc_spi *spi = spi_master_get_devdata(master);
-       unsigned int cs = spidev->chip_select;
+       unsigned int cs = spi_get_chipselect(spidev, 0);
        u32 gpocon;
 
        /* GPIOs are used for CS */
-       if (spidev->cs_gpiod)
+       if (spi_get_csgpiod(spidev, 0))
                return 0;
 
        dev_dbg(spi->dev, "using internal chipselect %u\n", cs);
@@ -796,7 +796,7 @@ static void lantiq_ssc_handle_err(struct spi_master *master,
 static void lantiq_ssc_set_cs(struct spi_device *spidev, bool enable)
 {
        struct lantiq_ssc_spi *spi = spi_master_get_devdata(spidev->master);
-       unsigned int cs = spidev->chip_select;
+       unsigned int cs = spi_get_chipselect(spidev, 0);
        u32 fgpo;
 
        if (!!(spidev->mode & SPI_CS_HIGH) == enable)
index 701838b6f0c40dd1ba0a07f08adbb387b5806424..edd7430d4c052bf31c122bfac684e8edfdad4de4 100644 (file)
@@ -325,7 +325,7 @@ int spi_mem_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
        if (!spi_mem_internal_supports_op(mem, op))
                return -ENOTSUPP;
 
-       if (ctlr->mem_ops && ctlr->mem_ops->exec_op && !mem->spi->cs_gpiod) {
+       if (ctlr->mem_ops && ctlr->mem_ops->exec_op && !spi_get_csgpiod(mem->spi, 0)) {
                ret = spi_mem_access_start(mem);
                if (ret)
                        return ret;
@@ -808,7 +808,7 @@ int spi_mem_poll_status(struct spi_mem *mem,
            op->data.dir != SPI_MEM_DATA_IN)
                return -EINVAL;
 
-       if (ctlr->mem_ops && ctlr->mem_ops->poll_status && !mem->spi->cs_gpiod) {
+       if (ctlr->mem_ops && ctlr->mem_ops->poll_status && !spi_get_csgpiod(mem->spi, 0)) {
                ret = spi_mem_access_start(mem);
                if (ret)
                        return ret;
index b9f812837cd62eac5431e4af236d5fe2bc1c68df..141562c882f1132effab24975fb612e72b29e909 100644 (file)
@@ -505,7 +505,7 @@ static int meson_spicc_prepare_message(struct spi_master *master,
                conf |= FIELD_PREP(SPICC_DRCTL_MASK, SPICC_DRCTL_IGNORE);
 
        /* Select CS */
-       conf |= FIELD_PREP(SPICC_CS_MASK, spi->chip_select);
+       conf |= FIELD_PREP(SPICC_CS_MASK, spi_get_chipselect(spi, 0));
 
        /* Default 8bit word */
        conf |= FIELD_PREP(SPICC_BITLENGTH_MASK, 8 - 1);
index e6cf6ff080610b9db876a2de59ec79b298fb2bec..b59e8a0c5b974a5f80f2c2f58aba78b308bbacc7 100644 (file)
@@ -247,8 +247,8 @@ static void mchp_corespi_set_cs(struct spi_device *spi, bool disable)
        struct mchp_corespi *corespi = spi_master_get_devdata(spi->master);
 
        reg = mchp_corespi_read(corespi, REG_SLAVE_SELECT);
-       reg &= ~BIT(spi->chip_select);
-       reg |= !disable << spi->chip_select;
+       reg &= ~BIT(spi_get_chipselect(spi, 0));
+       reg |= !disable << spi_get_chipselect(spi, 0);
 
        mchp_corespi_write(corespi, REG_SLAVE_SELECT, reg);
 }
@@ -265,7 +265,7 @@ static int mchp_corespi_setup(struct spi_device *spi)
         */
        if (spi->mode & SPI_CS_HIGH) {
                reg = mchp_corespi_read(corespi, REG_SLAVE_SELECT);
-               reg |= BIT(spi->chip_select);
+               reg |= BIT(spi_get_chipselect(spi, 0));
                mchp_corespi_write(corespi, REG_SLAVE_SELECT, reg);
        }
        return 0;
index 0b86f1804682e1473b3f2d350d2c62aeb192ae4b..99aeef28a4774b9707be5c2825086397fe32d8b9 100644 (file)
@@ -121,17 +121,17 @@ static void mpc512x_psc_spi_activate_cs(struct spi_device *spi)
        out_be32(psc_addr(mps, ccr), ccr);
        mps->bits_per_word = cs->bits_per_word;
 
-       if (spi->cs_gpiod) {
+       if (spi_get_csgpiod(spi, 0)) {
                /* gpiolib will deal with the inversion */
-               gpiod_set_value(spi->cs_gpiod, 1);
+               gpiod_set_value(spi_get_csgpiod(spi, 0), 1);
        }
 }
 
 static void mpc512x_psc_spi_deactivate_cs(struct spi_device *spi)
 {
-       if (spi->cs_gpiod) {
+       if (spi_get_csgpiod(spi, 0)) {
                /* gpiolib will deal with the inversion */
-               gpiod_set_value(spi->cs_gpiod, 0);
+               gpiod_set_value(spi_get_csgpiod(spi, 0), 0);
        }
 }
 
index b652fb196622f8b34af55bd790283c9d449b3717..ab7df5f64342a8b05f9814dde01fec70fc152eea 100644 (file)
@@ -101,7 +101,7 @@ static void mpc52xx_spi_chipsel(struct mpc52xx_spi *ms, int value)
        int cs;
 
        if (ms->gpio_cs_count > 0) {
-               cs = ms->message->spi->chip_select;
+               cs = spi_get_chipselect(ms->message->spi, 0);
                gpiod_set_value(ms->gpio_cs[cs], value);
        } else {
                out_8(ms->regs + SPI_PORTDATA, value ? 0 : 0x08);
index 9eab6c20dbc561ca499ef5c7becc3982164121cc..21c321f437667495c5a3ed94b3d73bf483672ffa 100644 (file)
@@ -421,7 +421,7 @@ static int mtk_spi_hw_init(struct spi_master *master,
 
        /* pad select */
        if (mdata->dev_comp->need_pad_sel)
-               writel(mdata->pad_sel[spi->chip_select],
+               writel(mdata->pad_sel[spi_get_chipselect(spi, 0)],
                       mdata->base + SPI_PAD_SEL_REG);
 
        /* tick delay */
@@ -735,9 +735,9 @@ static int mtk_spi_setup(struct spi_device *spi)
        if (!spi->controller_data)
                spi->controller_data = (void *)&mtk_default_chip_info;
 
-       if (mdata->dev_comp->need_pad_sel && spi->cs_gpiod)
+       if (mdata->dev_comp->need_pad_sel && spi_get_csgpiod(spi, 0))
                /* CS de-asserted, gpiolib will handle inversion */
-               gpiod_direction_output(spi->cs_gpiod, 0);
+               gpiod_direction_output(spi_get_csgpiod(spi, 0), 0);
 
        return 0;
 }
index c4cc8e2f85e2f85ce36674410b89500f7fd4accc..3e9d396b33bd3c5107ffb0cf2466377c8a831f24 100644 (file)
@@ -76,7 +76,7 @@ static inline void mt7621_spi_write(struct mt7621_spi *rs, u32 reg, u32 val)
 static void mt7621_spi_set_cs(struct spi_device *spi, int enable)
 {
        struct mt7621_spi *rs = spidev_to_mt7621_spi(spi);
-       int cs = spi->chip_select;
+       int cs = spi_get_chipselect(spi, 0);
        u32 polar = 0;
        u32 master;
 
index 0709e987bd5ab28ce521e13e550cca6e1dd293ec..fa8c1f740c702d3141b52aec1e112695919af449 100644 (file)
@@ -51,22 +51,22 @@ static int spi_mux_select(struct spi_device *spi)
        struct spi_mux_priv *priv = spi_controller_get_devdata(spi->controller);
        int ret;
 
-       ret = mux_control_select(priv->mux, spi->chip_select);
+       ret = mux_control_select(priv->mux, spi_get_chipselect(spi, 0));
        if (ret)
                return ret;
 
-       if (priv->current_cs == spi->chip_select)
+       if (priv->current_cs == spi_get_chipselect(spi, 0))
                return 0;
 
        dev_dbg(&priv->spi->dev, "setting up the mux for cs %d\n",
-               spi->chip_select);
+               spi_get_chipselect(spi, 0));
 
        /* copy the child device's settings except for the cs */
        priv->spi->max_speed_hz = spi->max_speed_hz;
        priv->spi->mode = spi->mode;
        priv->spi->bits_per_word = spi->bits_per_word;
 
-       priv->current_cs = spi->chip_select;
+       priv->current_cs = spi_get_chipselect(spi, 0);
 
        return 0;
 }
index 10727ea5304344d55d1747cbdbfcbf22ef219fb3..00617fd4b2c3a584a55eb6687748536c77c69a67 100644 (file)
@@ -306,8 +306,8 @@ static u32 mxic_spi_prep_hc_cfg(struct spi_device *spi, u32 flags)
                nio = 2;
 
        return flags | HC_CFG_NIO(nio) |
-              HC_CFG_TYPE(spi->chip_select, HC_CFG_TYPE_SPI_NOR) |
-              HC_CFG_SLV_ACT(spi->chip_select) | HC_CFG_IDLE_SIO_LVL(1);
+              HC_CFG_TYPE(spi_get_chipselect(spi, 0), HC_CFG_TYPE_SPI_NOR) |
+              HC_CFG_SLV_ACT(spi_get_chipselect(spi, 0)) | HC_CFG_IDLE_SIO_LVL(1);
 }
 
 static u32 mxic_spi_mem_prep_op_cfg(const struct spi_mem_op *op,
@@ -405,7 +405,7 @@ static ssize_t mxic_spi_mem_dirmap_read(struct spi_mem_dirmap_desc *desc,
        len = min_t(size_t, len, mxic->linear.size);
        writel(len, mxic->regs + LRD_RANGE);
        writel(LMODE_CMD0(desc->info.op_tmpl.cmd.opcode) |
-              LMODE_SLV_ACT(desc->mem->spi->chip_select) |
+              LMODE_SLV_ACT(spi_get_chipselect(desc->mem->spi, 0)) |
               LMODE_EN,
               mxic->regs + LRD_CTRL);
 
@@ -449,7 +449,7 @@ static ssize_t mxic_spi_mem_dirmap_write(struct spi_mem_dirmap_desc *desc,
        len = min_t(size_t, len, mxic->linear.size);
        writel(len, mxic->regs + LWR_RANGE);
        writel(LMODE_CMD0(desc->info.op_tmpl.cmd.opcode) |
-              LMODE_SLV_ACT(desc->mem->spi->chip_select) |
+              LMODE_SLV_ACT(spi_get_chipselect(desc->mem->spi, 0)) |
               LMODE_EN,
               mxic->regs + LWR_CTRL);
 
@@ -524,7 +524,7 @@ static int mxic_spi_mem_exec_op(struct spi_mem *mem,
        writel(HC_EN_BIT, mxic->regs + HC_EN);
 
        writel(mxic_spi_mem_prep_op_cfg(op, op->data.nbytes),
-              mxic->regs + SS_CTRL(mem->spi->chip_select));
+              mxic->regs + SS_CTRL(spi_get_chipselect(mem->spi, 0)));
 
        writel(readl(mxic->regs + HC_CFG) | HC_CFG_MAN_CS_ASSERT,
               mxic->regs + HC_CFG);
index 10fb31a5e4097d81c16bd7de0721583396cd2590..963a53dd680ba15077a701f28cf1a36f20d2b0d4 100644 (file)
@@ -369,7 +369,7 @@ static int mxs_spi_transfer_one(struct spi_master *master,
        /* Program CS register bits here, it will be used for all transfers. */
        writel(BM_SSP_CTRL0_WAIT_FOR_CMD | BM_SSP_CTRL0_WAIT_FOR_IRQ,
               ssp->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_CLR);
-       writel(mxs_spi_cs_to_reg(m->spi->chip_select),
+       writel(mxs_spi_cs_to_reg(spi_get_chipselect(m->spi, 0)),
               ssp->base + HW_SSP_CTRL0 + STMP_OFFSET_REG_SET);
 
        list_for_each_entry(t, &m->transfers, transfer_list) {
index 8d7698d167ef9c33b04608c9d998a7b8fcc57651..eb353561509a8a1e39079d46bbf2206b11e352ee 100644 (file)
@@ -288,7 +288,7 @@ static ssize_t npcm_fiu_direct_read(struct spi_mem_dirmap_desc *desc,
 {
        struct npcm_fiu_spi *fiu =
                spi_controller_get_devdata(desc->mem->spi->master);
-       struct npcm_fiu_chip *chip = &fiu->chip[desc->mem->spi->chip_select];
+       struct npcm_fiu_chip *chip = &fiu->chip[spi_get_chipselect(desc->mem->spi, 0)];
        void __iomem *src = (void __iomem *)(chip->flash_region_mapped_ptr +
                                             offs);
        u8 *buf_rx = buf;
@@ -315,7 +315,7 @@ static ssize_t npcm_fiu_direct_write(struct spi_mem_dirmap_desc *desc,
 {
        struct npcm_fiu_spi *fiu =
                spi_controller_get_devdata(desc->mem->spi->master);
-       struct npcm_fiu_chip *chip = &fiu->chip[desc->mem->spi->chip_select];
+       struct npcm_fiu_chip *chip = &fiu->chip[spi_get_chipselect(desc->mem->spi, 0)];
        void __iomem *dst = (void __iomem *)(chip->flash_region_mapped_ptr +
                                             offs);
        const u8 *buf_tx = buf;
@@ -344,7 +344,7 @@ static int npcm_fiu_uma_read(struct spi_mem *mem,
 
        regmap_update_bits(fiu->regmap, NPCM_FIU_UMA_CTS,
                           NPCM_FIU_UMA_CTS_DEV_NUM,
-                          (mem->spi->chip_select <<
+                          (spi_get_chipselect(mem->spi, 0) <<
                            NPCM_FIU_UMA_CTS_DEV_NUM_SHIFT));
        regmap_update_bits(fiu->regmap, NPCM_FIU_UMA_CMD,
                           NPCM_FIU_UMA_CMD_CMD, op->cmd.opcode);
@@ -398,7 +398,7 @@ static int npcm_fiu_uma_write(struct spi_mem *mem,
 
        regmap_update_bits(fiu->regmap, NPCM_FIU_UMA_CTS,
                           NPCM_FIU_UMA_CTS_DEV_NUM,
-                          (mem->spi->chip_select <<
+                          (spi_get_chipselect(mem->spi, 0) <<
                            NPCM_FIU_UMA_CTS_DEV_NUM_SHIFT));
 
        regmap_update_bits(fiu->regmap, NPCM_FIU_UMA_CMD,
@@ -451,7 +451,7 @@ static int npcm_fiu_manualwrite(struct spi_mem *mem,
 
        regmap_update_bits(fiu->regmap, NPCM_FIU_UMA_CTS,
                           NPCM_FIU_UMA_CTS_DEV_NUM,
-                          (mem->spi->chip_select <<
+                          (spi_get_chipselect(mem->spi, 0) <<
                            NPCM_FIU_UMA_CTS_DEV_NUM_SHIFT));
        regmap_update_bits(fiu->regmap, NPCM_FIU_UMA_CTS,
                           NPCM_FIU_UMA_CTS_SW_CS, 0);
@@ -545,7 +545,7 @@ static int npcm_fiu_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
 {
        struct npcm_fiu_spi *fiu =
                spi_controller_get_devdata(mem->spi->master);
-       struct npcm_fiu_chip *chip = &fiu->chip[mem->spi->chip_select];
+       struct npcm_fiu_chip *chip = &fiu->chip[spi_get_chipselect(mem->spi, 0)];
        int ret = 0;
        u8 *buf;
 
@@ -605,7 +605,7 @@ static int npcm_fiu_dirmap_create(struct spi_mem_dirmap_desc *desc)
 {
        struct npcm_fiu_spi *fiu =
                spi_controller_get_devdata(desc->mem->spi->master);
-       struct npcm_fiu_chip *chip = &fiu->chip[desc->mem->spi->chip_select];
+       struct npcm_fiu_chip *chip = &fiu->chip[spi_get_chipselect(desc->mem->spi, 0)];
        struct regmap *gcr_regmap;
 
        if (!fiu->res_mem) {
@@ -624,7 +624,7 @@ static int npcm_fiu_dirmap_create(struct spi_mem_dirmap_desc *desc)
                chip->flash_region_mapped_ptr =
                        devm_ioremap(fiu->dev, (fiu->res_mem->start +
                                                        (fiu->info->max_map_size *
-                                                   desc->mem->spi->chip_select)),
+                                                   spi_get_chipselect(desc->mem->spi, 0))),
                                             (u32)desc->info.length);
                if (!chip->flash_region_mapped_ptr) {
                        dev_warn(fiu->dev, "Error mapping memory region, direct read disabled\n");
@@ -669,9 +669,9 @@ static int npcm_fiu_setup(struct spi_device *spi)
        struct npcm_fiu_spi *fiu = spi_controller_get_devdata(ctrl);
        struct npcm_fiu_chip *chip;
 
-       chip = &fiu->chip[spi->chip_select];
+       chip = &fiu->chip[spi_get_chipselect(spi, 0)];
        chip->fiu = fiu;
-       chip->chipselect = spi->chip_select;
+       chip->chipselect = spi_get_chipselect(spi, 0);
        chip->clkrate = spi->max_speed_hz;
 
        fiu->clkrate = clk_get_rate(fiu->clk);
index 71be1ec3fbde38ef7e3e4206df1b3300cdcf86bf..76168cc1e00db307e9930c8db568cb1308a37e49 100644 (file)
@@ -663,7 +663,7 @@ static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi)
         * Return, if previously selected slave device is same as current
         * requested slave device.
         */
-       if (f->selected == spi->chip_select)
+       if (f->selected == spi_get_chipselect(spi, 0))
                return;
 
        /* Reset FLSHxxCR0 registers */
@@ -676,9 +676,9 @@ static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi)
        size_kb = FSPI_FLSHXCR0_SZ(f->memmap_phy_size);
 
        fspi_writel(f, size_kb, f->iobase + FSPI_FLSHA1CR0 +
-                   4 * spi->chip_select);
+                   4 * spi_get_chipselect(spi, 0));
 
-       dev_dbg(f->dev, "Slave device [CS:%x] selected\n", spi->chip_select);
+       dev_dbg(f->dev, "Slave device [CS:%x] selected\n", spi_get_chipselect(spi, 0));
 
        nxp_fspi_clk_disable_unprep(f);
 
@@ -690,7 +690,7 @@ static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi)
        if (ret)
                return;
 
-       f->selected = spi->chip_select;
+       f->selected = spi_get_chipselect(spi, 0);
 }
 
 static int nxp_fspi_read_ahb(struct nxp_fspi *f, const struct spi_mem_op *op)
@@ -1055,7 +1055,7 @@ static const char *nxp_fspi_get_name(struct spi_mem *mem)
 
        name = devm_kasprintf(dev, GFP_KERNEL,
                              "%s-%d", dev_name(f->dev),
-                             mem->spi->chip_select);
+                             spi_get_chipselect(mem->spi, 0));
 
        if (!name) {
                dev_err(dev, "failed to get memory for custom flash name\n");
index 6da77de19e2b194467815f6cb088db9117c2d912..902d2e0c1f2fc57a1a1cdb3c4d3cb6fca02e187d 100644 (file)
@@ -179,7 +179,7 @@ static void uwire_chipselect(struct spi_device *spi, int value)
 
        w = uwire_read_reg(UWIRE_CSR);
        old_cs = (w >> 10) & 0x03;
-       if (value == BITBANG_CS_INACTIVE || old_cs != spi->chip_select) {
+       if (value == BITBANG_CS_INACTIVE || old_cs != spi_get_chipselect(spi, 0)) {
                /* Deselect this CS, or the previous CS */
                w &= ~CS_CMD;
                uwire_write_reg(UWIRE_CSR, w);
@@ -193,7 +193,7 @@ static void uwire_chipselect(struct spi_device *spi, int value)
                else
                        uwire_write_reg(UWIRE_SR4, 0);
 
-               w = spi->chip_select << 10;
+               w = spi_get_chipselect(spi, 0) << 10;
                w |= CS_CMD;
                uwire_write_reg(UWIRE_CSR, w);
        }
@@ -210,7 +210,7 @@ static int uwire_txrx(struct spi_device *spi, struct spi_transfer *t)
        if (!t->tx_buf && !t->rx_buf)
                return 0;
 
-       w = spi->chip_select << 10;
+       w = spi_get_chipselect(spi, 0) << 10;
        w |= CS_CMD;
 
        if (t->tx_buf) {
@@ -408,7 +408,7 @@ static int uwire_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
                rate /= 8;
                break;
        }
-       omap_uwire_configure_mode(spi->chip_select, flags);
+       omap_uwire_configure_mode(spi_get_chipselect(spi, 0), flags);
        pr_debug("%s: uwire flags %02x, armxor %lu KHz, SCK %lu KHz\n",
                        __func__, flags,
                        clk_get_rate(uwire->ck) / 1000,
index ce3cdd5404208c1dc4592eaf801b49c63a1ef2ea..1a967930f4e55e362c8f686df5729ab769c1bea8 100644 (file)
@@ -379,7 +379,7 @@ static void omap2_mcspi_rx_callback(void *data)
 {
        struct spi_device *spi = data;
        struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master);
-       struct omap2_mcspi_dma *mcspi_dma = &mcspi->dma_channels[spi->chip_select];
+       struct omap2_mcspi_dma *mcspi_dma = &mcspi->dma_channels[spi_get_chipselect(spi, 0)];
 
        /* We must disable the DMA RX request */
        omap2_mcspi_set_dma_req(spi, 1, 0);
@@ -391,7 +391,7 @@ static void omap2_mcspi_tx_callback(void *data)
 {
        struct spi_device *spi = data;
        struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master);
-       struct omap2_mcspi_dma *mcspi_dma = &mcspi->dma_channels[spi->chip_select];
+       struct omap2_mcspi_dma *mcspi_dma = &mcspi->dma_channels[spi_get_chipselect(spi, 0)];
 
        /* We must disable the DMA TX request */
        omap2_mcspi_set_dma_req(spi, 0, 0);
@@ -408,7 +408,7 @@ static void omap2_mcspi_tx_dma(struct spi_device *spi,
        struct dma_async_tx_descriptor *tx;
 
        mcspi = spi_master_get_devdata(spi->master);
-       mcspi_dma = &mcspi->dma_channels[spi->chip_select];
+       mcspi_dma = &mcspi->dma_channels[spi_get_chipselect(spi, 0)];
 
        dmaengine_slave_config(mcspi_dma->dma_tx, &cfg);
 
@@ -446,7 +446,7 @@ omap2_mcspi_rx_dma(struct spi_device *spi, struct spi_transfer *xfer,
        struct dma_async_tx_descriptor *tx;
 
        mcspi = spi_master_get_devdata(spi->master);
-       mcspi_dma = &mcspi->dma_channels[spi->chip_select];
+       mcspi_dma = &mcspi->dma_channels[spi_get_chipselect(spi, 0)];
        count = xfer->len;
 
        /*
@@ -591,7 +591,7 @@ omap2_mcspi_txrx_dma(struct spi_device *spi, struct spi_transfer *xfer)
        int                     wait_res;
 
        mcspi = spi_master_get_devdata(spi->master);
-       mcspi_dma = &mcspi->dma_channels[spi->chip_select];
+       mcspi_dma = &mcspi->dma_channels[spi_get_chipselect(spi, 0)];
 
        if (cs->word_len <= 8) {
                width = DMA_SLAVE_BUSWIDTH_1_BYTE;
@@ -1062,8 +1062,8 @@ static int omap2_mcspi_setup(struct spi_device *spi)
                cs = kzalloc(sizeof(*cs), GFP_KERNEL);
                if (!cs)
                        return -ENOMEM;
-               cs->base = mcspi->base + spi->chip_select * 0x14;
-               cs->phys = mcspi->phys + spi->chip_select * 0x14;
+               cs->base = mcspi->base + spi_get_chipselect(spi, 0) * 0x14;
+               cs->phys = mcspi->phys + spi_get_chipselect(spi, 0) * 0x14;
                cs->mode = 0;
                cs->chconf0 = 0;
                cs->chctrl0 = 0;
@@ -1142,7 +1142,7 @@ static int omap2_mcspi_transfer_one(struct spi_master *master,
        u32                             chconf;
 
        mcspi = spi_master_get_devdata(master);
-       mcspi_dma = mcspi->dma_channels + spi->chip_select;
+       mcspi_dma = mcspi->dma_channels + spi_get_chipselect(spi, 0);
        cs = spi->controller_state;
        cd = spi->controller_data;
 
@@ -1158,7 +1158,7 @@ static int omap2_mcspi_transfer_one(struct spi_master *master,
 
        omap2_mcspi_set_enable(spi, 0);
 
-       if (spi->cs_gpiod)
+       if (spi_get_csgpiod(spi, 0))
                omap2_mcspi_set_cs(spi, spi->mode & SPI_CS_HIGH);
 
        if (par_override ||
@@ -1247,7 +1247,7 @@ out:
 
        omap2_mcspi_set_enable(spi, 0);
 
-       if (spi->cs_gpiod)
+       if (spi_get_csgpiod(spi, 0))
                omap2_mcspi_set_cs(spi, !(spi->mode & SPI_CS_HIGH));
 
        if (mcspi->fifo_depth > 0 && t)
@@ -1289,7 +1289,7 @@ static bool omap2_mcspi_can_dma(struct spi_master *master,
 {
        struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master);
        struct omap2_mcspi_dma *mcspi_dma =
-               &mcspi->dma_channels[spi->chip_select];
+               &mcspi->dma_channels[spi_get_chipselect(spi, 0)];
 
        if (!mcspi_dma->dma_rx || !mcspi_dma->dma_tx)
                return false;
@@ -1307,7 +1307,7 @@ static size_t omap2_mcspi_max_xfer_size(struct spi_device *spi)
 {
        struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master);
        struct omap2_mcspi_dma *mcspi_dma =
-               &mcspi->dma_channels[spi->chip_select];
+               &mcspi->dma_channels[spi_get_chipselect(spi, 0)];
 
        if (mcspi->max_xfer_len && mcspi_dma->dma_rx)
                return mcspi->max_xfer_len;
index e79d1fe0bca4be7b4698a69bc4a7c1e2ec00310f..bb244b5961430bc06967b143a642609776e7ee35 100644 (file)
@@ -346,7 +346,7 @@ static void orion_spi_set_cs(struct spi_device *spi, bool enable)
         * as it is handled by a GPIO, but that doesn't matter. What we need
         * is to deassert the old chip select and assert some other chip select.
         */
-       val |= ORION_SPI_CS(spi->chip_select);
+       val |= ORION_SPI_CS(spi_get_chipselect(spi, 0));
 
        /*
         * Chip select logic is inverted from spi_set_cs(). For lines using a
@@ -470,7 +470,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer)
        unsigned int count;
        int word_len;
        struct orion_spi *orion_spi;
-       int cs = spi->chip_select;
+       int cs = spi_get_chipselect(spi, 0);
        void __iomem *vaddr;
 
        word_len = spi->bits_per_word;
index a31c3b612a430707ce386626f45ef29e00e88425..1c5731641a04425b039712ee195a5e3f83182639 100644 (file)
@@ -116,11 +116,11 @@ static void pci1xxxx_spi_set_cs(struct spi_device *spi, bool enable)
        regval = readl(par->reg_base + SPI_MST_CTL_REG_OFFSET(p->hw_inst));
        if (enable) {
                regval &= ~SPI_MST_CTL_DEVSEL_MASK;
-               regval |= (spi->chip_select << 25);
+               regval |= (spi_get_chipselect(spi, 0) << 25);
                writel(regval,
                       par->reg_base + SPI_MST_CTL_REG_OFFSET(p->hw_inst));
        } else {
-               regval &= ~(spi->chip_select << 25);
+               regval &= ~(spi_get_chipselect(spi, 0) << 25);
                writel(regval,
                       par->reg_base + SPI_MST_CTL_REG_OFFSET(p->hw_inst));
 
index 4c8493f34fcace32760ed25b59b3b72997094539..51dfb49523f3466d9d22fdcf3079b3857f6b1499 100644 (file)
@@ -267,7 +267,7 @@ static int pic32_sqi_one_transfer(struct pic32_sqi *sqi,
        u32 nbits;
 
        /* Device selection */
-       bd_ctrl = spi->chip_select << BD_DEVSEL_SHIFT;
+       bd_ctrl = spi_get_chipselect(spi, 0) << BD_DEVSEL_SHIFT;
 
        /* half-duplex: select transfer buffer, direction and lane */
        if (xfer->rx_buf) {
index 5a64ad0c94fecab57a4e61e99c9c2a3e2874cabe..8a02073a354d7cd9cf8ac7f97a869add3257016c 100644 (file)
@@ -591,7 +591,7 @@ static int pic32_spi_setup(struct spi_device *spi)
         * unreliable/erroneous SPI transactions.
         * To avoid that we will always handle /CS by toggling GPIO.
         */
-       if (!spi->cs_gpiod)
+       if (!spi_get_csgpiod(spi, 0))
                return -EINVAL;
 
        return 0;
@@ -600,7 +600,7 @@ static int pic32_spi_setup(struct spi_device *spi)
 static void pic32_spi_cleanup(struct spi_device *spi)
 {
        /* de-activate cs-gpio, gpiolib will handle inversion */
-       gpiod_direction_output(spi->cs_gpiod, 0);
+       gpiod_direction_output(spi_get_csgpiod(spi, 0), 0);
 }
 
 static int pic32_spi_dma_prep(struct pic32_spi *pic32s, struct device *dev)
index a17ff839117f91f350f5fc4f2b755c1b9b9b64ae..982407bc5d9f9e2ba087ee6f035360455c4279b2 100644 (file)
@@ -1587,9 +1587,9 @@ static int pl022_transfer_one_message(struct spi_master *master,
 
        /* Setup the SPI using the per chip configuration */
        pl022->cur_chip = spi_get_ctldata(msg->spi);
-       pl022->cur_cs = msg->spi->chip_select;
+       pl022->cur_cs = spi_get_chipselect(msg->spi, 0);
        /* This is always available but may be set to -ENOENT */
-       pl022->cur_gpiod = msg->spi->cs_gpiod;
+       pl022->cur_gpiod = spi_get_csgpiod(msg->spi, 0);
 
        restore_state(pl022);
        flush(pl022);
index a75ba2993f3c3600d8d24ceea04b8b66d89f0e1e..d04e8cb987e906f6e5ced3c5e65a27b2eaa41b92 100644 (file)
@@ -368,7 +368,7 @@ static void lpss_ssp_select_cs(struct spi_device *spi,
 
        value = __lpss_ssp_read_priv(drv_data, config->reg_cs_ctrl);
 
-       cs = spi->chip_select;
+       cs = spi_get_chipselect(spi, 0);
        cs <<= config->cs_sel_shift;
        if (cs != (value & config->cs_sel_mask)) {
                /*
@@ -429,7 +429,7 @@ static void cs_assert(struct spi_device *spi)
                spi_controller_get_devdata(spi->controller);
 
        if (drv_data->ssp_type == CE4100_SSP) {
-               pxa2xx_spi_write(drv_data, SSSR, spi->chip_select);
+               pxa2xx_spi_write(drv_data, SSSR, spi_get_chipselect(spi, 0));
                return;
        }
 
@@ -1217,7 +1217,7 @@ static int setup(struct spi_device *spi)
                        return -ENOMEM;
 
                if (drv_data->ssp_type == CE4100_SSP) {
-                       if (spi->chip_select > 4) {
+                       if (spi_get_chipselect(spi, 0) > 4) {
                                dev_err(&spi->dev,
                                        "failed setup: cs number must not be > 4.\n");
                                kfree(chip);
index 15c4e21cd562c645cf9c37e14596e7b28d58b82d..aa91a6c9ab55e3106f2123cf4fc15e603956a31f 100644 (file)
@@ -311,7 +311,7 @@ static int qcom_qspi_prepare_message(struct spi_master *master,
 
        mstr_cfg = readl(ctrl->base + MSTR_CONFIG);
        mstr_cfg &= ~CHIP_SELECT_NUM;
-       if (message->spi->chip_select)
+       if (spi_get_chipselect(message->spi, 0))
                mstr_cfg |= CHIP_SELECT_NUM;
 
        mstr_cfg |= FB_CLK_EN | PIN_WPN | PIN_HOLDN | SBL_EN | FULL_CYCLE_MODE;
index e312b30b733bbe0b8d49a281804cd69aaeac0d03..5073736d3d1fdc2b14c9fd99b236c14625403a96 100644 (file)
@@ -107,7 +107,7 @@ static int rb4xx_transfer_one(struct spi_master *master,
         * command set was designed to almost not clash with that of the
         * boot flash.
         */
-       if (spi->chip_select == 2)
+       if (spi_get_chipselect(spi, 0) == 2)
                /* MMC */
                spi_ioc = AR71XX_SPI_IOC_CS0;
        else
index 80e1ee110d3189f3b7e11c97e4431a986848efb2..4fabd2e0439f0b748e07d89c85487a2ad86d1a91 100644 (file)
@@ -346,7 +346,7 @@ static int rockchip_sfc_xfer_setup(struct rockchip_sfc *sfc,
 
        /* set the Controller */
        ctrl |= SFC_CTRL_PHASE_SEL_NEGETIVE;
-       cmd |= mem->spi->chip_select << SFC_CMD_CS_SHIFT;
+       cmd |= spi_get_chipselect(mem->spi, 0) << SFC_CMD_CS_SHIFT;
 
        dev_dbg(sfc->dev, "sfc addr.nbytes=%x(x%d) dummy.nbytes=%x(x%d)\n",
                op->addr.nbytes, op->addr.buswidth,
index a66fff0ee20e902771f9169377120bc8284a2965..143ede958ac16c1f4fb4c1da5f489bb265273a72 100644 (file)
@@ -246,28 +246,30 @@ static void rockchip_spi_set_cs(struct spi_device *spi, bool enable)
        bool cs_asserted = spi->mode & SPI_CS_HIGH ? enable : !enable;
 
        /* Return immediately for no-op */
-       if (cs_asserted == rs->cs_asserted[spi->chip_select])
+       if (cs_asserted == rs->cs_asserted[spi_get_chipselect(spi, 0)])
                return;
 
        if (cs_asserted) {
                /* Keep things powered as long as CS is asserted */
                pm_runtime_get_sync(rs->dev);
 
-               if (spi->cs_gpiod)
+               if (spi_get_csgpiod(spi, 0))
                        ROCKCHIP_SPI_SET_BITS(rs->regs + ROCKCHIP_SPI_SER, 1);
                else
-                       ROCKCHIP_SPI_SET_BITS(rs->regs + ROCKCHIP_SPI_SER, BIT(spi->chip_select));
+                       ROCKCHIP_SPI_SET_BITS(rs->regs + ROCKCHIP_SPI_SER,
+                                             BIT(spi_get_chipselect(spi, 0)));
        } else {
-               if (spi->cs_gpiod)
+               if (spi_get_csgpiod(spi, 0))
                        ROCKCHIP_SPI_CLR_BITS(rs->regs + ROCKCHIP_SPI_SER, 1);
                else
-                       ROCKCHIP_SPI_CLR_BITS(rs->regs + ROCKCHIP_SPI_SER, BIT(spi->chip_select));
+                       ROCKCHIP_SPI_CLR_BITS(rs->regs + ROCKCHIP_SPI_SER,
+                                             BIT(spi_get_chipselect(spi, 0)));
 
                /* Drop reference from when we first asserted CS */
                pm_runtime_put(rs->dev);
        }
 
-       rs->cs_asserted[spi->chip_select] = cs_asserted;
+       rs->cs_asserted[spi_get_chipselect(spi, 0)] = cs_asserted;
 }
 
 static void rockchip_spi_handle_err(struct spi_controller *ctlr,
@@ -541,7 +543,7 @@ static int rockchip_spi_config(struct rockchip_spi *rs,
        if (spi->mode & SPI_LSB_FIRST)
                cr0 |= CR0_FBM_LSB << CR0_FBM_OFFSET;
        if (spi->mode & SPI_CS_HIGH)
-               cr0 |= BIT(spi->chip_select) << CR0_SOI_OFFSET;
+               cr0 |= BIT(spi_get_chipselect(spi, 0)) << CR0_SOI_OFFSET;
 
        if (xfer->rx_buf && xfer->tx_buf)
                cr0 |= CR0_XFM_TR << CR0_XFM_OFFSET;
@@ -724,7 +726,7 @@ static int rockchip_spi_setup(struct spi_device *spi)
        struct rockchip_spi *rs = spi_controller_get_devdata(spi->controller);
        u32 cr0;
 
-       if (!spi->cs_gpiod && (spi->mode & SPI_CS_HIGH) && !rs->cs_high_supported) {
+       if (!spi_get_csgpiod(spi, 0) && (spi->mode & SPI_CS_HIGH) && !rs->cs_high_supported) {
                dev_warn(&spi->dev, "setup: non GPIO CS can't be active-high\n");
                return -EINVAL;
        }
@@ -735,10 +737,10 @@ static int rockchip_spi_setup(struct spi_device *spi)
 
        cr0 &= ~(0x3 << CR0_SCPH_OFFSET);
        cr0 |= ((spi->mode & 0x3) << CR0_SCPH_OFFSET);
-       if (spi->mode & SPI_CS_HIGH && spi->chip_select <= 1)
-               cr0 |= BIT(spi->chip_select) << CR0_SOI_OFFSET;
-       else if (spi->chip_select <= 1)
-               cr0 &= ~(BIT(spi->chip_select) << CR0_SOI_OFFSET);
+       if (spi->mode & SPI_CS_HIGH && spi_get_chipselect(spi, 0) <= 1)
+               cr0 |= BIT(spi_get_chipselect(spi, 0)) << CR0_SOI_OFFSET;
+       else if (spi_get_chipselect(spi, 0) <= 1)
+               cr0 &= ~(BIT(spi_get_chipselect(spi, 0)) << CR0_SOI_OFFSET);
 
        writel_relaxed(cr0, rs->regs + ROCKCHIP_SPI_CTRLR0);
 
index f494c86bafea4feb13de483eda3dc93025221e0c..f50a39efaf96d890272105a124ca00721917e42e 100644 (file)
@@ -950,7 +950,7 @@ static int rspi_setup(struct spi_device *spi)
        struct rspi_data *rspi = spi_controller_get_devdata(spi->controller);
        u8 sslp;
 
-       if (spi->cs_gpiod)
+       if (spi_get_csgpiod(spi, 0))
                return 0;
 
        pm_runtime_get_sync(&rspi->pdev->dev);
@@ -958,9 +958,9 @@ static int rspi_setup(struct spi_device *spi)
 
        sslp = rspi_read8(rspi, RSPI_SSLP);
        if (spi->mode & SPI_CS_HIGH)
-               sslp |= SSLP_SSLP(spi->chip_select);
+               sslp |= SSLP_SSLP(spi_get_chipselect(spi, 0));
        else
-               sslp &= ~SSLP_SSLP(spi->chip_select);
+               sslp &= ~SSLP_SSLP(spi_get_chipselect(spi, 0));
        rspi_write8(rspi, sslp, RSPI_SSLP);
 
        spin_unlock_irq(&rspi->lock);
@@ -1001,8 +1001,8 @@ static int rspi_prepare_message(struct spi_controller *ctlr,
                rspi->spcmd |= SPCMD_LSBF;
 
        /* Configure slave signal to assert */
-       rspi->spcmd |= SPCMD_SSLA(spi->cs_gpiod ? rspi->ctlr->unused_native_cs
-                                               : spi->chip_select);
+       rspi->spcmd |= SPCMD_SSLA(spi_get_csgpiod(spi, 0) ? rspi->ctlr->unused_native_cs
+                                               : spi_get_chipselect(spi, 0));
 
        /* CMOS output mode and MOSI signal from previous transfer */
        rspi->sppcr = 0;
index cc69f8ffdbdc928491893c57468f516b1c51e948..7ac17f0d18a95510a48c8c0f3f99d7a04e421e66 100644 (file)
@@ -891,7 +891,7 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
 
        /* NULL is fine, we just avoid using the FB delay (=0) */
        if (IS_ERR(cs)) {
-               dev_err(&spi->dev, "No CS for SPI(%d)\n", spi->chip_select);
+               dev_err(&spi->dev, "No CS for SPI(%d)\n", spi_get_chipselect(spi, 0));
                return -ENODEV;
        }
 
index 983b3621bc2ad08e1f2a6e46f38916c966b2e90d..a12adc68731b3c3be01d116bba6da91ff49261e1 100644 (file)
@@ -70,7 +70,7 @@ static int sc18is602_txrx(struct sc18is602 *hw, struct spi_message *msg,
 
        if (hw->tlen == 0) {
                /* First byte (I2C command) is chip select */
-               hw->buffer[0] = 1 << msg->spi->chip_select;
+               hw->buffer[0] = 1 << spi_get_chipselect(msg->spi, 0);
                hw->tlen = 1;
                hw->rindex = 0;
        }
@@ -229,7 +229,7 @@ static int sc18is602_setup(struct spi_device *spi)
        struct sc18is602 *hw = spi_master_get_devdata(spi->master);
 
        /* SC18IS602 does not support CS2 */
-       if (hw->id == sc18is602 && spi->chip_select == 2)
+       if (hw->id == sc18is602 && (spi_get_chipselect(spi, 0) == 2))
                return -ENXIO;
 
        return 0;
index d828a3b370b8e8389b371b52b4b546ed41af19b7..50498c4eb661d09f0d99561bf5716699eb278cc9 100644 (file)
@@ -554,7 +554,7 @@ static int sh_msiof_spi_setup(struct spi_device *spi)
                spi_controller_get_devdata(spi->controller);
        u32 clr, set, tmp;
 
-       if (spi->cs_gpiod || spi_controller_is_slave(p->ctlr))
+       if (spi_get_csgpiod(spi, 0) || spi_controller_is_slave(p->ctlr))
                return 0;
 
        if (p->native_cs_inited &&
@@ -587,11 +587,11 @@ static int sh_msiof_prepare_message(struct spi_controller *ctlr,
        u32 ss, cs_high;
 
        /* Configure pins before asserting CS */
-       if (spi->cs_gpiod) {
+       if (spi_get_csgpiod((struct spi_device *)spi, 0)) {
                ss = ctlr->unused_native_cs;
                cs_high = p->native_cs_high;
        } else {
-               ss = spi->chip_select;
+               ss = spi_get_chipselect((struct spi_device *)spi, 0);
                cs_high = !!(spi->mode & SPI_CS_HIGH);
        }
        sh_msiof_spi_set_pin_regs(p, ss, !!(spi->mode & SPI_CPOL),
index 0fdfec2de47ada0def2f1ca0ee566574e4c94b56..92ca3f2d61bab945d55474521e280d5ab70c8d0f 100644 (file)
@@ -108,7 +108,7 @@ static void sh_sci_spi_chipselect(struct spi_device *dev, int value)
        struct sh_sci_spi *sp = spi_master_get_devdata(dev->master);
 
        if (sp->info->chip_select)
-               (sp->info->chip_select)(sp->info, dev->chip_select, value);
+               (sp->info->chip_select)(sp->info, spi_get_chipselect(dev, 0), value);
 }
 
 static int sh_sci_spi_probe(struct platform_device *dev)
index 055de44e0d2251d7d79dbe37f0ced0c4aef3245b..dae9e097c3336e159ab81edf248b2fda6e088dda 100644 (file)
@@ -135,13 +135,13 @@ sifive_spi_prepare_message(struct spi_master *master, struct spi_message *msg)
 
        /* Update the chip select polarity */
        if (device->mode & SPI_CS_HIGH)
-               spi->cs_inactive &= ~BIT(device->chip_select);
+               spi->cs_inactive &= ~BIT(spi_get_chipselect(device, 0));
        else
-               spi->cs_inactive |= BIT(device->chip_select);
+               spi->cs_inactive |= BIT(spi_get_chipselect(device, 0));
        sifive_spi_write(spi, SIFIVE_SPI_REG_CSDEF, spi->cs_inactive);
 
        /* Select the correct device */
-       sifive_spi_write(spi, SIFIVE_SPI_REG_CSID, device->chip_select);
+       sifive_spi_write(spi, SIFIVE_SPI_REG_CSID, spi_get_chipselect(device, 0));
 
        /* Set clock mode */
        sifive_spi_write(spi, SIFIVE_SPI_REG_SCKMODE,
index 644ae34f623ba99271645fba77108833f6341eb2..d64100f881815a965a9cb9b70c71e5f71b80e49f 100644 (file)
@@ -267,7 +267,7 @@ static void f_ospi_config_indir_protocol(struct f_ospi *ospi,
        int unit;
 
        /* Set one chip select */
-       writel(BIT(spi->chip_select), ospi->base + OSPI_SSEL);
+       writel(BIT(spi_get_chipselect(spi, 0)), ospi->base + OSPI_SSEL);
 
        mode = f_ospi_get_mode(ospi, op->cmd.buswidth, 1);
        prot |= FIELD_PREP(OSPI_PROT_MODE_CODE_MASK, mode);
index 9141f19c7f8e12208fbcb6bb0927409ab2f35308..7fcff9c539e23971dd9dda5cacd0f7016c3606e0 100644 (file)
@@ -183,7 +183,7 @@ static int spi_st_setup(struct spi_device *spi)
                return -EINVAL;
        }
 
-       if (!spi->cs_gpiod) {
+       if (!spi_get_csgpiod(spi, 0)) {
                dev_err(&spi->dev, "no valid gpio assigned\n");
                return -EINVAL;
        }
index 29125af0afdb4817572ab10542bc168d7753e91d..2b6804aa6901bafd0bfff92e569cc0a4b72e5016 100644 (file)
@@ -359,7 +359,7 @@ static int stm32_qspi_get_mode(u8 buswidth)
 static int stm32_qspi_send(struct spi_device *spi, const struct spi_mem_op *op)
 {
        struct stm32_qspi *qspi = spi_controller_get_devdata(spi->master);
-       struct stm32_qspi_flash *flash = &qspi->flash[spi->chip_select];
+       struct stm32_qspi_flash *flash = &qspi->flash[spi_get_chipselect(spi, 0)];
        u32 ccr, cr;
        int timeout, err = 0, err_poll_status = 0;
 
@@ -564,7 +564,7 @@ static int stm32_qspi_transfer_one_message(struct spi_controller *ctrl,
        struct spi_mem_op op;
        int ret = 0;
 
-       if (!spi->cs_gpiod)
+       if (!spi_get_csgpiod(spi, 0))
                return -EOPNOTSUPP;
 
        ret = pm_runtime_resume_and_get(qspi->dev);
@@ -573,7 +573,7 @@ static int stm32_qspi_transfer_one_message(struct spi_controller *ctrl,
 
        mutex_lock(&qspi->lock);
 
-       gpiod_set_value_cansleep(spi->cs_gpiod, true);
+       gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), true);
 
        list_for_each_entry(transfer, &msg->transfers, transfer_list) {
                u8 dummy_bytes = 0;
@@ -626,7 +626,7 @@ static int stm32_qspi_transfer_one_message(struct spi_controller *ctrl,
        }
 
 end_of_transfer:
-       gpiod_set_value_cansleep(spi->cs_gpiod, false);
+       gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), false);
 
        mutex_unlock(&qspi->lock);
 
@@ -669,8 +669,8 @@ static int stm32_qspi_setup(struct spi_device *spi)
 
        presc = DIV_ROUND_UP(qspi->clk_rate, spi->max_speed_hz) - 1;
 
-       flash = &qspi->flash[spi->chip_select];
-       flash->cs = spi->chip_select;
+       flash = &qspi->flash[spi_get_chipselect(spi, 0)];
+       flash->cs = spi_get_chipselect(spi, 0);
        flash->presc = presc;
 
        mutex_lock(&qspi->lock);
index 994d0fb50e682b5792a7255f387ccdb6f76aed06..b8947265d329e48fb9517d73c768296c0427fe42 100644 (file)
@@ -167,7 +167,7 @@ static void sun4i_spi_set_cs(struct spi_device *spi, bool enable)
        reg = sun4i_spi_read(sspi, SUN4I_CTL_REG);
 
        reg &= ~SUN4I_CTL_CS_MASK;
-       reg |= SUN4I_CTL_CS(spi->chip_select);
+       reg |= SUN4I_CTL_CS(spi_get_chipselect(spi, 0));
 
        /* We want to control the chip select manually */
        reg |= SUN4I_CTL_CS_MANUAL;
index 43c29afea6bb2511fc9a185c4bc8335728f8749f..7532c85a352c61f3f3ccb10f20abcef1da383a8d 100644 (file)
@@ -174,7 +174,7 @@ static void sun6i_spi_set_cs(struct spi_device *spi, bool enable)
 
        reg = sun6i_spi_read(sspi, SUN6I_TFR_CTL_REG);
        reg &= ~SUN6I_TFR_CTL_CS_MASK;
-       reg |= SUN6I_TFR_CTL_CS(spi->chip_select);
+       reg |= SUN6I_TFR_CTL_CS(spi_get_chipselect(spi, 0));
 
        if (enable)
                reg |= SUN6I_TFR_CTL_CS_LEVEL;
index 3a92f722a6c5041435b0945ca4d0c601b7deed64..aeaf7db022f09cd37dca228435b374c20bda8150 100644 (file)
@@ -250,7 +250,7 @@ static int synquacer_spi_config(struct spi_master *master,
        }
 
        mode = spi->mode;
-       cs = spi->chip_select;
+       cs = spi_get_chipselect(spi, 0);
        speed = xfer->speed_hz;
        bpw = xfer->bits_per_word;
 
@@ -344,7 +344,7 @@ static int synquacer_spi_config(struct spi_master *master,
        sspi->bpw = bpw;
        sspi->mode = mode;
        sspi->speed = speed;
-       sspi->cs = spi->chip_select;
+       sspi->cs = spi_get_chipselect(spi, 0);
        sspi->bus_width = bus_width;
 
        return 0;
@@ -488,7 +488,7 @@ static void synquacer_spi_set_cs(struct spi_device *spi, bool enable)
        val = readl(sspi->regs + SYNQUACER_HSSPI_REG_DMSTART);
        val &= ~(SYNQUACER_HSSPI_DMPSEL_CS_MASK <<
                 SYNQUACER_HSSPI_DMPSEL_CS_SHIFT);
-       val |= spi->chip_select << SYNQUACER_HSSPI_DMPSEL_CS_SHIFT;
+       val |= spi_get_chipselect(spi, 0) << SYNQUACER_HSSPI_DMPSEL_CS_SHIFT;
 
        if (!enable)
                val |= SYNQUACER_HSSPI_DMSTOP_STOP;
index b6bee922a92c12bf7364b44f68ee0362937b4c00..9e7d762d0ee639fec94f8a39c44e0455cdfd1d5b 100644 (file)
@@ -747,7 +747,7 @@ static int tegra_spi_set_hw_cs_timing(struct spi_device *spi)
        if (setup_dly && hold_dly) {
                setup_hold = SPI_SETUP_HOLD(setup_dly - 1, hold_dly - 1);
                spi_cs_timing = SPI_CS_SETUP_HOLD(tspi->spi_cs_timing1,
-                                                 spi->chip_select,
+                                                 spi_get_chipselect(spi, 0),
                                                  setup_hold);
                if (tspi->spi_cs_timing1 != spi_cs_timing) {
                        tspi->spi_cs_timing1 = spi_cs_timing;
@@ -760,9 +760,9 @@ static int tegra_spi_set_hw_cs_timing(struct spi_device *spi)
                inactive_cycles--;
        cs_state = inactive_cycles ? 0 : 1;
        spi_cs_timing = tspi->spi_cs_timing2;
-       SPI_SET_CS_ACTIVE_BETWEEN_PACKETS(spi_cs_timing, spi->chip_select,
+       SPI_SET_CS_ACTIVE_BETWEEN_PACKETS(spi_cs_timing, spi_get_chipselect(spi, 0),
                                          cs_state);
-       SPI_SET_CYCLES_BETWEEN_PACKETS(spi_cs_timing, spi->chip_select,
+       SPI_SET_CYCLES_BETWEEN_PACKETS(spi_cs_timing, spi_get_chipselect(spi, 0),
                                       inactive_cycles);
        if (tspi->spi_cs_timing2 != spi_cs_timing) {
                tspi->spi_cs_timing2 = spi_cs_timing;
@@ -831,8 +831,8 @@ static u32 tegra_spi_setup_transfer_one(struct spi_device *spi,
                        tegra_spi_writel(tspi, command1, SPI_COMMAND1);
 
                /* GPIO based chip select control */
-               if (spi->cs_gpiod)
-                       gpiod_set_value(spi->cs_gpiod, 1);
+               if (spi_get_csgpiod(spi, 0))
+                       gpiod_set_value(spi_get_csgpiod(spi, 0), 1);
 
                if (is_single_xfer && !(t->cs_change)) {
                        tspi->use_hw_based_cs = true;
@@ -846,7 +846,7 @@ static u32 tegra_spi_setup_transfer_one(struct spi_device *spi,
                                command1 &= ~SPI_CS_SW_VAL;
                }
 
-               if (tspi->last_used_cs != spi->chip_select) {
+               if (tspi->last_used_cs != spi_get_chipselect(spi, 0)) {
                        if (cdata && cdata->tx_clk_tap_delay)
                                tx_tap = cdata->tx_clk_tap_delay;
                        if (cdata && cdata->rx_clk_tap_delay)
@@ -855,7 +855,7 @@ static u32 tegra_spi_setup_transfer_one(struct spi_device *spi,
                                   SPI_RX_TAP_DELAY(rx_tap);
                        if (command2 != tspi->def_command2_reg)
                                tegra_spi_writel(tspi, command2, SPI_COMMAND2);
-                       tspi->last_used_cs = spi->chip_select;
+                       tspi->last_used_cs = spi_get_chipselect(spi, 0);
                }
 
        } else {
@@ -896,7 +896,7 @@ static int tegra_spi_start_transfer_one(struct spi_device *spi,
                command1 |= SPI_TX_EN;
                tspi->cur_direction |= DATA_DIR_TX;
        }
-       command1 |= SPI_CS_SEL(spi->chip_select);
+       command1 |= SPI_CS_SEL(spi_get_chipselect(spi, 0));
        tegra_spi_writel(tspi, command1, SPI_COMMAND1);
        tspi->command1_reg = command1;
 
@@ -980,14 +980,14 @@ static int tegra_spi_setup(struct spi_device *spi)
 
        spin_lock_irqsave(&tspi->lock, flags);
        /* GPIO based chip select control */
-       if (spi->cs_gpiod)
-               gpiod_set_value(spi->cs_gpiod, 0);
+       if (spi_get_csgpiod(spi, 0))
+               gpiod_set_value(spi_get_csgpiod(spi, 0), 0);
 
        val = tspi->def_command1_reg;
        if (spi->mode & SPI_CS_HIGH)
-               val &= ~SPI_CS_POL_INACTIVE(spi->chip_select);
+               val &= ~SPI_CS_POL_INACTIVE(spi_get_chipselect(spi, 0));
        else
-               val |= SPI_CS_POL_INACTIVE(spi->chip_select);
+               val |= SPI_CS_POL_INACTIVE(spi_get_chipselect(spi, 0));
        tspi->def_command1_reg = val;
        tegra_spi_writel(tspi, tspi->def_command1_reg, SPI_COMMAND1);
        spin_unlock_irqrestore(&tspi->lock, flags);
@@ -1002,8 +1002,8 @@ static void tegra_spi_transfer_end(struct spi_device *spi)
        int cs_val = (spi->mode & SPI_CS_HIGH) ? 0 : 1;
 
        /* GPIO based chip select control */
-       if (spi->cs_gpiod)
-               gpiod_set_value(spi->cs_gpiod, 0);
+       if (spi_get_csgpiod(spi, 0))
+               gpiod_set_value(spi_get_csgpiod(spi, 0), 0);
 
        if (!tspi->use_hw_based_cs) {
                if (cs_val)
index ed82530ea64b8a544bbc58c0feb0daff489d02c6..4286310628a2bdf868f1d75058d7568dd6363cc8 100644 (file)
@@ -280,7 +280,7 @@ static int tegra_sflash_start_transfer_one(struct spi_device *spi,
                        command |= SPI_ACTIVE_SCLK_DRIVE_HIGH;
                else
                        command |= SPI_ACTIVE_SCLK_DRIVE_LOW;
-               command |= SPI_CS0_EN << spi->chip_select;
+               command |= SPI_CS0_EN << spi_get_chipselect(spi, 0);
        } else {
                command = tsd->command_reg;
                command &= ~SPI_BIT_LENGTH(~0);
index ac7933bc03e2536909d21c29f24e562e42c782f0..c2915f7672ccb05a81a0ea88d82b09a5e2cdbe63 100644 (file)
@@ -758,9 +758,9 @@ static int tegra_slink_setup(struct spi_device *spi)
        spin_lock_irqsave(&tspi->lock, flags);
        val = tspi->def_command_reg;
        if (spi->mode & SPI_CS_HIGH)
-               val |= cs_pol_bit[spi->chip_select];
+               val |= cs_pol_bit[spi_get_chipselect(spi, 0)];
        else
-               val &= ~cs_pol_bit[spi->chip_select];
+               val &= ~cs_pol_bit[spi_get_chipselect(spi, 0)];
        tspi->def_command_reg = val;
        tegra_slink_writel(tspi, tspi->def_command_reg, SLINK_COMMAND);
        spin_unlock_irqrestore(&tspi->lock, flags);
@@ -781,7 +781,7 @@ static int tegra_slink_prepare_message(struct spi_master *master,
        tspi->command_reg |= SLINK_CS_SW | SLINK_CS_VALUE;
 
        tspi->command2_reg = tspi->def_command2_reg;
-       tspi->command2_reg |= SLINK_SS_EN_CS(spi->chip_select);
+       tspi->command2_reg |= SLINK_SS_EN_CS(spi_get_chipselect(spi, 0));
 
        tspi->command_reg &= ~SLINK_MODES;
        if (spi->mode & SPI_CPHA)
index fd0d532364e2d344b55eece39ae69097c63fc7bb..325b4427491cf5ec921666242e9cb65aedec963c 100644 (file)
@@ -829,7 +829,7 @@ static u32 tegra_qspi_setup_transfer_one(struct spi_device *spi, struct spi_tran
                tegra_qspi_mask_clear_irq(tqspi);
 
                command1 = tqspi->def_command1_reg;
-               command1 |= QSPI_CS_SEL(spi->chip_select);
+               command1 |= QSPI_CS_SEL(spi_get_chipselect(spi, 0));
                command1 |= QSPI_BIT_LENGTH(bits_per_word - 1);
 
                command1 &= ~QSPI_CONTROL_MODE_MASK;
@@ -960,11 +960,11 @@ static int tegra_qspi_setup(struct spi_device *spi)
 
        /* keep default cs state to inactive */
        val = tqspi->def_command1_reg;
-       val |= QSPI_CS_SEL(spi->chip_select);
+       val |= QSPI_CS_SEL(spi_get_chipselect(spi, 0));
        if (spi->mode & SPI_CS_HIGH)
-               val &= ~QSPI_CS_POL_INACTIVE(spi->chip_select);
+               val &= ~QSPI_CS_POL_INACTIVE(spi_get_chipselect(spi, 0));
        else
-               val |= QSPI_CS_POL_INACTIVE(spi->chip_select);
+               val |= QSPI_CS_POL_INACTIVE(spi_get_chipselect(spi, 0));
 
        tqspi->def_command1_reg = val;
        tegra_qspi_writel(tqspi, tqspi->def_command1_reg, QSPI_COMMAND1);
index 60086869bcae4303bd031315519176b0f0002820..5914335ff63db0521ee2a16866147ba2d9206bc0 100644 (file)
@@ -533,10 +533,10 @@ static void ti_qspi_enable_memory_map(struct spi_device *spi)
        if (qspi->ctrl_base) {
                regmap_update_bits(qspi->ctrl_base, qspi->ctrl_reg,
                                   MEM_CS_MASK,
-                                  MEM_CS_EN(spi->chip_select));
+                                  MEM_CS_EN(spi_get_chipselect(spi, 0)));
        }
        qspi->mmap_enabled = true;
-       qspi->current_cs = spi->chip_select;
+       qspi->current_cs = spi_get_chipselect(spi, 0);
 }
 
 static void ti_qspi_disable_memory_map(struct spi_device *spi)
@@ -572,7 +572,7 @@ static void ti_qspi_setup_mmap_read(struct spi_device *spi, u8 opcode,
        memval |= ((addr_width - 1) << QSPI_SETUP_ADDR_SHIFT |
                   dummy_bytes << QSPI_SETUP_DUMMY_SHIFT);
        ti_qspi_write(qspi, memval,
-                     QSPI_SPI_SETUP_REG(spi->chip_select));
+                     QSPI_SPI_SETUP_REG(spi_get_chipselect(spi, 0)));
 }
 
 static int ti_qspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
@@ -623,7 +623,7 @@ static int ti_qspi_exec_mem_op(struct spi_mem *mem,
 
        mutex_lock(&qspi->list_lock);
 
-       if (!qspi->mmap_enabled || qspi->current_cs != mem->spi->chip_select) {
+       if (!qspi->mmap_enabled || qspi->current_cs != spi_get_chipselect(mem->spi, 0)) {
                ti_qspi_setup_clk(qspi, mem->spi->max_speed_hz);
                ti_qspi_enable_memory_map(mem->spi);
        }
@@ -673,11 +673,11 @@ static int ti_qspi_start_transfer_one(struct spi_master *master,
        qspi->dc = 0;
 
        if (spi->mode & SPI_CPHA)
-               qspi->dc |= QSPI_CKPHA(spi->chip_select);
+               qspi->dc |= QSPI_CKPHA(spi_get_chipselect(spi, 0));
        if (spi->mode & SPI_CPOL)
-               qspi->dc |= QSPI_CKPOL(spi->chip_select);
+               qspi->dc |= QSPI_CKPOL(spi_get_chipselect(spi, 0));
        if (spi->mode & SPI_CS_HIGH)
-               qspi->dc |= QSPI_CSPOL(spi->chip_select);
+               qspi->dc |= QSPI_CSPOL(spi_get_chipselect(spi, 0));
 
        frame_len_words = 0;
        list_for_each_entry(t, &m->transfers, transfer_list)
@@ -686,7 +686,7 @@ static int ti_qspi_start_transfer_one(struct spi_master *master,
 
        /* setup command reg */
        qspi->cmd = 0;
-       qspi->cmd |= QSPI_EN_CS(spi->chip_select);
+       qspi->cmd |= QSPI_EN_CS(spi_get_chipselect(spi, 0));
        qspi->cmd |= QSPI_FLEN(frame_len_words);
 
        ti_qspi_write(qspi, qspi->dc, QSPI_SPI_DC_REG);
index 1679a0ba3d62e68846e45a7a66fd6b586bc64fb9..af5846cfe5e915187d2b54c98b60ffb875ac5bc2 100644 (file)
@@ -499,7 +499,7 @@ static inline void pch_spi_select_chip(struct pch_spi_data *data,
                                       struct spi_device *pspi)
 {
        if (data->current_chip != NULL) {
-               if (pspi->chip_select != data->n_curnt_chip) {
+               if (spi_get_chipselect(pspi, 0) != data->n_curnt_chip) {
                        dev_dbg(&pspi->dev, "%s : different slave\n", __func__);
                        data->current_chip = NULL;
                }
@@ -507,7 +507,7 @@ static inline void pch_spi_select_chip(struct pch_spi_data *data,
 
        data->current_chip = pspi;
 
-       data->n_curnt_chip = data->current_chip->chip_select;
+       data->n_curnt_chip = spi_get_chipselect(data->current_chip, 0);
 
        dev_dbg(&pspi->dev, "%s :Invoking pch_spi_setup_transfer\n", __func__);
        pch_spi_setup_transfer(pspi);
index ab33710d50ac8b7791f1aca14e4165f5f3479475..f15312fdcdaf05cc2ae219dde4fd4414979b831d 100644 (file)
@@ -158,7 +158,7 @@ static int wpcm_fiu_normal_exec(struct spi_mem *mem, const struct spi_mem_op *op
        if (op->data.dir == SPI_MEM_DATA_OUT)
                wpcm_fiu_set_data(fiu, op->data.buf.out, op->data.nbytes);
 
-       ret = wpcm_fiu_do_uma(fiu, mem->spi->chip_select, op->addr.nbytes == 3,
+       ret = wpcm_fiu_do_uma(fiu, spi_get_chipselect(mem->spi, 0), op->addr.nbytes == 3,
                              op->data.dir == SPI_MEM_DATA_OUT, op->data.nbytes);
 
        if (op->data.dir == SPI_MEM_DATA_IN)
@@ -196,7 +196,7 @@ static bool wpcm_fiu_4ba_match(const struct spi_mem_op *op)
 static int wpcm_fiu_4ba_exec(struct spi_mem *mem, const struct spi_mem_op *op)
 {
        struct wpcm_fiu_spi *fiu = spi_controller_get_devdata(mem->spi->controller);
-       int cs = mem->spi->chip_select;
+       int cs = spi_get_chipselect(mem->spi, 0);
 
        wpcm_fiu_ects_assert(fiu, cs);
 
@@ -241,7 +241,7 @@ static bool wpcm_fiu_rdid_match(const struct spi_mem_op *op)
 static int wpcm_fiu_rdid_exec(struct spi_mem *mem, const struct spi_mem_op *op)
 {
        struct wpcm_fiu_spi *fiu = spi_controller_get_devdata(mem->spi->controller);
-       int cs = mem->spi->chip_select;
+       int cs = spi_get_chipselect(mem->spi, 0);
 
        /* First transfer */
        wpcm_fiu_set_opcode(fiu, op->cmd.opcode);
@@ -278,7 +278,7 @@ static bool wpcm_fiu_dummy_match(const struct spi_mem_op *op)
 static int wpcm_fiu_dummy_exec(struct spi_mem *mem, const struct spi_mem_op *op)
 {
        struct wpcm_fiu_spi *fiu = spi_controller_get_devdata(mem->spi->controller);
-       int cs = mem->spi->chip_select;
+       int cs = spi_get_chipselect(mem->spi, 0);
 
        wpcm_fiu_ects_assert(fiu, cs);
 
@@ -376,7 +376,7 @@ static int wpcm_fiu_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
 static int wpcm_fiu_dirmap_create(struct spi_mem_dirmap_desc *desc)
 {
        struct wpcm_fiu_spi *fiu = spi_controller_get_devdata(desc->mem->spi->controller);
-       int cs = desc->mem->spi->chip_select;
+       int cs = spi_get_chipselect(desc->mem->spi, 0);
 
        if (desc->info.op_tmpl.data.dir != SPI_MEM_DATA_IN)
                return -ENOTSUPP;
@@ -400,7 +400,7 @@ static int wpcm_fiu_dirmap_create(struct spi_mem_dirmap_desc *desc)
 static ssize_t wpcm_fiu_direct_read(struct spi_mem_dirmap_desc *desc, u64 offs, size_t len, void *buf)
 {
        struct wpcm_fiu_spi *fiu = spi_controller_get_devdata(desc->mem->spi->controller);
-       int cs = desc->mem->spi->chip_select;
+       int cs = spi_get_chipselect(desc->mem->spi, 0);
 
        if (offs >= MAX_MEMORY_SIZE_PER_CS)
                return -ENOTSUPP;
index 8628241ec99e4f19d2766d1af67916e4f214188b..5d23411f2a3e9c021fc011f40ffd1b98659f7ff7 100644 (file)
@@ -58,7 +58,7 @@ static int spi_xcomm_sync_config(struct spi_xcomm *spi_xcomm, unsigned int len)
 static void spi_xcomm_chipselect(struct spi_xcomm *spi_xcomm,
        struct spi_device *spi, int is_active)
 {
-       unsigned long cs = spi->chip_select;
+       unsigned long cs = spi_get_chipselect(spi, 0);
        uint16_t chipselect = spi_xcomm->chipselect;
 
        if (is_active)
index d2f9eea5e09375e75308d80b42738646a63dfd4e..5dd3d190141270f464592825f079c14bab0f8d32 100644 (file)
@@ -213,7 +213,7 @@ static void xilinx_spi_chipselect(struct spi_device *spi, int is_on)
         */
 
        cs = xspi->cs_inactive;
-       cs ^= BIT(spi->chip_select);
+       cs ^= BIT(spi_get_chipselect(spi, 0));
 
        /* Activate the chip select */
        xspi->write_fn(cs, xspi->regs + XSPI_SSR_OFFSET);
@@ -228,9 +228,9 @@ static int xilinx_spi_setup_transfer(struct spi_device *spi,
        struct xilinx_spi *xspi = spi_master_get_devdata(spi->master);
 
        if (spi->mode & SPI_CS_HIGH)
-               xspi->cs_inactive &= ~BIT(spi->chip_select);
+               xspi->cs_inactive &= ~BIT(spi_get_chipselect(spi, 0));
        else
-               xspi->cs_inactive |= BIT(spi->chip_select);
+               xspi->cs_inactive |= BIT(spi_get_chipselect(spi, 0));
 
        return 0;
 }
index e5707fe5c8f15b7b3c627ae2a83ceba1191f0dff..3b91cdd5ae21e781e3b0e6489fbb580f97e0e3d9 100644 (file)
@@ -139,7 +139,7 @@ static int xlp_spi_setup(struct spi_device *spi)
        int cs;
 
        xspi = spi_master_get_devdata(spi->master);
-       cs = spi->chip_select;
+       cs = spi_get_chipselect(spi, 0);
        /*
         * The value of fdiv must be between 4 and 65535.
         */
@@ -350,7 +350,7 @@ static int xlp_spi_transfer_one(struct spi_master *master,
        struct xlp_spi_priv *xspi = spi_master_get_devdata(master);
        int ret = 0;
 
-       xspi->cs = spi->chip_select;
+       xspi->cs = spi_get_chipselect(spi, 0);
        xspi->dev = spi->dev;
 
        if (spi_transfer_is_last(master, t))
index 8558c0fe37753a8180302754129aec6fdf859180..ee1995b912878103ff8c87781755eeaf8fbeb5a9 100644 (file)
@@ -296,7 +296,7 @@ static void zynq_qspi_chipselect(struct spi_device *spi, bool assert)
        /* Select the lower (CS0) or upper (CS1) memory */
        if (ctlr->num_chipselect > 1) {
                config_reg = zynq_qspi_read(xqspi, ZYNQ_QSPI_LINEAR_CFG_OFFSET);
-               if (!spi->chip_select)
+               if (!spi_get_chipselect(spi, 0))
                        config_reg &= ~ZYNQ_QSPI_LCFG_U_PAGE;
                else
                        config_reg |= ZYNQ_QSPI_LCFG_U_PAGE;
index 270d28a3f8eb8687e8361a1c5ac02194c3124e6a..fb2ca9b90eabf1a419051639480d94f2ce59d129 100644 (file)
@@ -468,7 +468,7 @@ static void zynqmp_qspi_chipselect(struct spi_device *qspi, bool is_high)
        genfifoentry |= GQSPI_GENFIFO_MODE_SPI;
 
        if (!is_high) {
-               if (!qspi->chip_select) {
+               if (!spi_get_chipselect(qspi, 0)) {
                        xqspi->genfifobus = GQSPI_GENFIFO_BUS_LOWER;
                        xqspi->genfifocs = GQSPI_GENFIFO_CS_LOWER;
                } else {
index 5a038c6674018ba0df331888009a8bc04f3e57de..a399c617ca25f781d7b3c4b0b40306595aa87cc1 100644 (file)
@@ -393,7 +393,7 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
                        struct spi_controller *ctlr = spi->controller;
 
                        if (ctlr->use_gpio_descriptors && ctlr->cs_gpiods &&
-                           ctlr->cs_gpiods[spi->chip_select])
+                           ctlr->cs_gpiods[spi_get_chipselect(spi, 0)])
                                tmp &= ~SPI_CS_HIGH;
                }
 
@@ -432,7 +432,7 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
                        }
 
                        if (ctlr->use_gpio_descriptors && ctlr->cs_gpiods &&
-                           ctlr->cs_gpiods[spi->chip_select])
+                           ctlr->cs_gpiods[spi_get_chipselect(spi, 0)])
                                tmp |= SPI_CS_HIGH;
 
                        tmp |= spi->mode & ~SPI_MODE_MASK;
@@ -805,7 +805,7 @@ static int spidev_probe(struct spi_device *spi)
                spidev->devt = MKDEV(SPIDEV_MAJOR, minor);
                dev = device_create(spidev_class, &spi->dev, spidev->devt,
                                    spidev, "spidev%d.%d",
-                                   spi->master->bus_num, spi->chip_select);
+                                   spi->master->bus_num, spi_get_chipselect(spi, 0));
                status = PTR_ERR_OR_ZERO(dev);
        } else {
                dev_dbg(&spi->dev, "no minor number available!\n");
index c0d9844befd7ad643fca0561cd01530bf96135c9..c0248a8fa79c9a5a729b40903ffacdc07d85c849 100644 (file)
@@ -57,7 +57,7 @@ TRACE_EVENT(spi_setup,
 
        TP_fast_assign(
                __entry->bus_num = spi->controller->bus_num;
-               __entry->chip_select = spi->chip_select;
+               __entry->chip_select =  spi_get_chipselect(spi, 0);
                __entry->mode = spi->mode;
                __entry->bits_per_word = spi->bits_per_word;
                __entry->max_speed_hz = spi->max_speed_hz;
@@ -88,7 +88,7 @@ TRACE_EVENT(spi_set_cs,
 
        TP_fast_assign(
                __entry->bus_num = spi->controller->bus_num;
-               __entry->chip_select = spi->chip_select;
+               __entry->chip_select = spi_get_chipselect(spi, 0);
                __entry->mode = spi->mode;
                __entry->enable = enable;
        ),
@@ -113,7 +113,7 @@ DECLARE_EVENT_CLASS(spi_message,
 
        TP_fast_assign(
                __entry->bus_num = msg->spi->controller->bus_num;
-               __entry->chip_select = msg->spi->chip_select;
+               __entry->chip_select = spi_get_chipselect(msg->spi, 0);
                __entry->msg = msg;
        ),
 
@@ -154,7 +154,7 @@ TRACE_EVENT(spi_message_done,
 
        TP_fast_assign(
                __entry->bus_num = msg->spi->controller->bus_num;
-               __entry->chip_select = msg->spi->chip_select;
+               __entry->chip_select = spi_get_chipselect(msg->spi, 0);
                __entry->msg = msg;
                __entry->frame = msg->frame_length;
                __entry->actual = msg->actual_length;
@@ -197,7 +197,7 @@ DECLARE_EVENT_CLASS(spi_transfer,
 
        TP_fast_assign(
                __entry->bus_num = msg->spi->controller->bus_num;
-               __entry->chip_select = msg->spi->chip_select;
+               __entry->chip_select = spi_get_chipselect(msg->spi, 0);
                __entry->xfer = xfer;
                __entry->len = xfer->len;