spi: Merge up fixes from Linus' tree
authorMark Brown <broonie@kernel.org>
Sun, 30 Jul 2023 22:38:59 +0000 (23:38 +0100)
committerMark Brown <broonie@kernel.org>
Sun, 30 Jul 2023 22:38:59 +0000 (23:38 +0100)
Gets us pine64plus back if nothing else.

85 files changed:
Documentation/devicetree/bindings/spi/nvidia,tegra114-spi.txt [deleted file]
Documentation/devicetree/bindings/spi/nvidia,tegra114-spi.yaml [new file with mode: 0644]
Documentation/devicetree/bindings/spi/nvidia,tegra20-sflash.txt [deleted file]
Documentation/devicetree/bindings/spi/nvidia,tegra20-sflash.yaml [new file with mode: 0644]
Documentation/devicetree/bindings/spi/nvidia,tegra20-slink.txt [deleted file]
Documentation/devicetree/bindings/spi/nvidia,tegra20-slink.yaml [new file with mode: 0644]
Documentation/devicetree/bindings/spi/spi-fsl-lpspi.yaml
Documentation/devicetree/bindings/spi/spi-nxp-fspi.yaml
Documentation/devicetree/bindings/spi/spi-pl022.yaml
drivers/spi/spi-amd.c
drivers/spi/spi-amlogic-spifc-a1.c
drivers/spi/spi-ar934x.c
drivers/spi/spi-armada-3700.c
drivers/spi/spi-at91-usart.c
drivers/spi/spi-ath79.c
drivers/spi/spi-atmel.c
drivers/spi/spi-bcm2835.c
drivers/spi/spi-bcm2835aux.c
drivers/spi/spi-bitbang-txrx.h
drivers/spi/spi-bitbang.c
drivers/spi/spi-cadence-quadspi.c
drivers/spi/spi-cadence-xspi.c
drivers/spi/spi-cadence.c
drivers/spi/spi-cavium-thunderx.c
drivers/spi/spi-coldfire-qspi.c
drivers/spi/spi-davinci.c
drivers/spi/spi-dw-core.c
drivers/spi/spi-ep93xx.c
drivers/spi/spi-falcon.c
drivers/spi/spi-fsl-dspi.c
drivers/spi/spi-fsl-lib.c
drivers/spi/spi-fsl-lib.h
drivers/spi/spi-fsl-lpspi.c
drivers/spi/spi-fsl-qspi.c
drivers/spi/spi-gpio.c
drivers/spi/spi-gxp.c
drivers/spi/spi-imx.c
drivers/spi/spi-ingenic.c
drivers/spi/spi-lantiq-ssc.c
drivers/spi/spi-loopback-test.c
drivers/spi/spi-lp8841-rtc.c
drivers/spi/spi-meson-spicc.c
drivers/spi/spi-microchip-core.c
drivers/spi/spi-mt65xx.c
drivers/spi/spi-mt7621.c
drivers/spi/spi-mtk-nor.c
drivers/spi/spi-mtk-snfi.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-orion.c
drivers/spi/spi-pci1xxxx.c
drivers/spi/spi-pic32-sqi.c
drivers/spi/spi-pic32.c
drivers/spi/spi-qcom-qspi.c
drivers/spi/spi-qup.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-rzv2m-csi.c
drivers/spi/spi-s3c64xx.c
drivers/spi/spi-sc18is602.c
drivers/spi/spi-sh-msiof.c
drivers/spi/spi-sifive.c
drivers/spi/spi-slave-mt27xx.c
drivers/spi/spi-sn-f-ospi.c
drivers/spi/spi-sprd-adi.c
drivers/spi/spi-sprd.c
drivers/spi/spi-stm32-qspi.c
drivers/spi/spi-stm32.c
drivers/spi/spi-sun6i.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-wpcm-fiu.c
drivers/spi/spi-xcomm.c
drivers/spi/spi-xtensa-xtfpga.c
drivers/spi/spi-zynqmp-gqspi.c
drivers/spi/spi.c
include/linux/spi/spi.h
include/trace/events/spi.h

diff --git a/Documentation/devicetree/bindings/spi/nvidia,tegra114-spi.txt b/Documentation/devicetree/bindings/spi/nvidia,tegra114-spi.txt
deleted file mode 100644 (file)
index db8e0d7..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-NVIDIA Tegra114 SPI controller.
-
-Required properties:
-- compatible : For Tegra114, must contain "nvidia,tegra114-spi".
-  Otherwise, must contain '"nvidia,<chip>-spi", "nvidia,tegra114-spi"' where
-  <chip> is tegra124, tegra132, or tegra210.
-- reg: Should contain SPI registers location and length.
-- interrupts: Should contain SPI interrupts.
-- clock-names : Must include the following entries:
-  - spi
-- resets : Must contain an entry for each entry in reset-names.
-  See ../reset/reset.txt for details.
-- reset-names : Must include the following entries:
-  - spi
-- dmas : Must contain an entry for each entry in clock-names.
-  See ../dma/dma.txt for details.
-- dma-names : Must include the following entries:
-  - rx
-  - tx
-- clocks : Must contain an entry for each entry in clock-names.
-  See ../clocks/clock-bindings.txt for details.
-
-Recommended properties:
-- spi-max-frequency: Definition as per
-                     Documentation/devicetree/bindings/spi/spi-bus.txt
-Optional properties:
-- nvidia,tx-clk-tap-delay: Delays the clock going out to the external device
-  with this tap value. This property is used to tune the outgoing data from
-  Tegra SPI master with respect to outgoing Tegra SPI master clock.
-  Tap values vary based on the platform design trace lengths from Tegra SPI
-  to corresponding slave devices. Valid tap values are from 0 thru 63.
-- nvidia,rx-clk-tap-delay: Delays the clock coming in from the external device
-  with this tap value. This property is used to adjust the Tegra SPI master
-  clock with respect to the data from the SPI slave device.
-  Tap values vary based on the platform design trace lengths from Tegra SPI
-  to corresponding slave devices. Valid tap values are from 0 thru 63.
-
-Example:
-
-spi@7000d600 {
-       compatible = "nvidia,tegra114-spi";
-       reg = <0x7000d600 0x200>;
-       interrupts = <0 82 0x04>;
-       spi-max-frequency = <25000000>;
-       #address-cells = <1>;
-       #size-cells = <0>;
-       clocks = <&tegra_car 44>;
-       clock-names = "spi";
-       resets = <&tegra_car 44>;
-       reset-names = "spi";
-       dmas = <&apbdma 16>, <&apbdma 16>;
-       dma-names = "rx", "tx";
-       <spi-client>@<bus_num> {
-               ...
-               ...
-               nvidia,rx-clk-tap-delay = <0>;
-               nvidia,tx-clk-tap-delay = <16>;
-               ...
-       };
-
-};
diff --git a/Documentation/devicetree/bindings/spi/nvidia,tegra114-spi.yaml b/Documentation/devicetree/bindings/spi/nvidia,tegra114-spi.yaml
new file mode 100644 (file)
index 0000000..58222ff
--- /dev/null
@@ -0,0 +1,100 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/spi/nvidia,tegra114-spi.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NVIDIA Tegra114 SPI controller
+
+maintainers:
+  - Thierry Reding <thierry.reding@gmail.com>
+  - Jon Hunter <jonathanh@nvidia.com>
+
+properties:
+  compatible:
+    oneOf:
+      - const: nvidia,tegra114-spi
+      - items:
+          - enum:
+              - nvidia,tegra210-spi
+              - nvidia,tegra124-spi
+          - const: nvidia,tegra114-spi
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: SPI module clock
+
+  clock-names:
+    items:
+      - const: spi
+
+  resets:
+    items:
+      - description: SPI module reset
+
+  reset-names:
+    items:
+      - const: spi
+
+  dmas:
+    items:
+      - description: DMA channel for the reception FIFO
+      - description: DMA channel for the transmission FIFO
+
+  dma-names:
+    items:
+      - const: rx
+      - const: tx
+
+  spi-max-frequency:
+    description: Maximum SPI clocking speed of the controller in Hz.
+    $ref: /schemas/types.yaml#/definitions/uint32
+
+allOf:
+  - $ref: spi-controller.yaml
+
+unevaluatedProperties: false
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - resets
+  - reset-names
+  - dmas
+  - dma-names
+
+examples:
+  - |
+    spi@7000d600 {
+        compatible = "nvidia,tegra114-spi";
+        reg = <0x7000d600 0x200>;
+        interrupts = <0 82 0x04>;
+        clocks = <&tegra_car 44>;
+        clock-names = "spi";
+        resets = <&tegra_car 44>;
+        reset-names = "spi";
+        dmas = <&apbdma 16>, <&apbdma 16>;
+        dma-names = "rx", "tx";
+
+        spi-max-frequency = <25000000>;
+
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        flash@0 {
+            compatible = "jedec,spi-nor";
+            reg = <0>;
+            spi-max-frequency = <20000000>;
+            nvidia,rx-clk-tap-delay = <0>;
+            nvidia,tx-clk-tap-delay = <16>;
+        };
+    };
diff --git a/Documentation/devicetree/bindings/spi/nvidia,tegra20-sflash.txt b/Documentation/devicetree/bindings/spi/nvidia,tegra20-sflash.txt
deleted file mode 100644 (file)
index c212491..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-NVIDIA Tegra20 SFLASH controller.
-
-Required properties:
-- compatible : should be "nvidia,tegra20-sflash".
-- reg: Should contain SFLASH registers location and length.
-- interrupts: Should contain SFLASH interrupts.
-- clocks : Must contain one entry, for the module clock.
-  See ../clocks/clock-bindings.txt for details.
-- resets : Must contain an entry for each entry in reset-names.
-  See ../reset/reset.txt for details.
-- reset-names : Must include the following entries:
-  - spi
-- dmas : Must contain an entry for each entry in clock-names.
-  See ../dma/dma.txt for details.
-- dma-names : Must include the following entries:
-  - rx
-  - tx
-
-Recommended properties:
-- spi-max-frequency: Definition as per
-                     Documentation/devicetree/bindings/spi/spi-bus.txt
-
-Example:
-
-spi@7000c380 {
-       compatible = "nvidia,tegra20-sflash";
-       reg = <0x7000c380 0x80>;
-       interrupts = <0 39 0x04>;
-       spi-max-frequency = <25000000>;
-       #address-cells = <1>;
-       #size-cells = <0>;
-       clocks = <&tegra_car 43>;
-       resets = <&tegra_car 43>;
-       reset-names = "spi";
-       dmas = <&apbdma 11>, <&apbdma 11>;
-       dma-names = "rx", "tx";
-};
diff --git a/Documentation/devicetree/bindings/spi/nvidia,tegra20-sflash.yaml b/Documentation/devicetree/bindings/spi/nvidia,tegra20-sflash.yaml
new file mode 100644 (file)
index 0000000..e245bad
--- /dev/null
@@ -0,0 +1,81 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/spi/nvidia,tegra20-sflash.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NVIDIA Tegra20 SFLASH controller
+
+maintainers:
+  - Thierry Reding <thierry.reding@gmail.com>
+  - Jon Hunter <jonathanh@nvidia.com>
+
+properties:
+  compatible:
+    const: nvidia,tegra20-sflash
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: module clock
+
+  resets:
+    items:
+      - description: module reset
+
+  reset-names:
+    items:
+      - const: spi
+
+  dmas:
+    items:
+      - description: DMA channel used for reception
+      - description: DMA channel used for transmission
+
+  dma-names:
+    items:
+      - const: rx
+      - const: tx
+
+  spi-max-frequency:
+    description: Maximum SPI clocking speed of the controller in Hz.
+    $ref: /schemas/types.yaml#/definitions/uint32
+
+allOf:
+  - $ref: spi-controller.yaml
+
+unevaluatedProperties: false
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - resets
+  - reset-names
+  - dmas
+  - dma-names
+
+examples:
+  - |
+    #include <dt-bindings/clock/tegra20-car.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    spi@7000c380 {
+        compatible = "nvidia,tegra20-sflash";
+        reg = <0x7000c380 0x80>;
+        interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>;
+        spi-max-frequency = <25000000>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+        clocks = <&tegra_car TEGRA20_CLK_SPI>;
+        resets = <&tegra_car 43>;
+        reset-names = "spi";
+        dmas = <&apbdma 11>, <&apbdma 11>;
+        dma-names = "rx", "tx";
+    };
diff --git a/Documentation/devicetree/bindings/spi/nvidia,tegra20-slink.txt b/Documentation/devicetree/bindings/spi/nvidia,tegra20-slink.txt
deleted file mode 100644 (file)
index 40d80b9..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-NVIDIA Tegra20/Tegra30 SLINK controller.
-
-Required properties:
-- compatible : should be "nvidia,tegra20-slink", "nvidia,tegra30-slink".
-- reg: Should contain SLINK registers location and length.
-- interrupts: Should contain SLINK interrupts.
-- clocks : Must contain one entry, for the module clock.
-  See ../clocks/clock-bindings.txt for details.
-- resets : Must contain an entry for each entry in reset-names.
-  See ../reset/reset.txt for details.
-- reset-names : Must include the following entries:
-  - spi
-- dmas : Must contain an entry for each entry in clock-names.
-  See ../dma/dma.txt for details.
-- dma-names : Must include the following entries:
-  - rx
-  - tx
-
-Recommended properties:
-- spi-max-frequency: Definition as per
-                     Documentation/devicetree/bindings/spi/spi-bus.txt
-
-Example:
-
-spi@7000d600 {
-       compatible = "nvidia,tegra20-slink";
-       reg = <0x7000d600 0x200>;
-       interrupts = <0 82 0x04>;
-       spi-max-frequency = <25000000>;
-       #address-cells = <1>;
-       #size-cells = <0>;
-       clocks = <&tegra_car 44>;
-       resets = <&tegra_car 44>;
-       reset-names = "spi";
-       dmas = <&apbdma 16>, <&apbdma 16>;
-       dma-names = "rx", "tx";
-};
diff --git a/Documentation/devicetree/bindings/spi/nvidia,tegra20-slink.yaml b/Documentation/devicetree/bindings/spi/nvidia,tegra20-slink.yaml
new file mode 100644 (file)
index 0000000..291c25e
--- /dev/null
@@ -0,0 +1,90 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/spi/nvidia,tegra20-slink.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NVIDIA Tegra20/30 SLINK controller
+
+maintainers:
+  - Thierry Reding <thierry.reding@gmail.com>
+  - Jon Hunter <jonathanh@nvidia.com>
+
+properties:
+  compatible:
+    enum:
+      - nvidia,tegra20-slink
+      - nvidia,tegra30-slink
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: module clock
+
+  resets:
+    items:
+      - description: module reset
+
+  reset-names:
+    items:
+      - const: spi
+
+  dmas:
+    items:
+      - description: DMA channel used for reception
+      - description: DMA channel used for transmission
+
+  dma-names:
+    items:
+      - const: rx
+      - const: tx
+
+  operating-points-v2:
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+  power-domains:
+    items:
+      - description: phandle to the core power domain
+
+  spi-max-frequency:
+    description: Maximum SPI clocking speed of the controller in Hz.
+    $ref: /schemas/types.yaml#/definitions/uint32
+
+allOf:
+  - $ref: spi-controller.yaml
+
+unevaluatedProperties: false
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - resets
+  - reset-names
+  - dmas
+  - dma-names
+
+examples:
+  - |
+    #include <dt-bindings/clock/tegra20-car.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    spi@7000d600 {
+        compatible = "nvidia,tegra20-slink";
+        reg = <0x7000d600 0x200>;
+        interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
+        spi-max-frequency = <25000000>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+        clocks = <&tegra_car TEGRA20_CLK_SBC2>;
+        resets = <&tegra_car 44>;
+        reset-names = "spi";
+        dmas = <&apbdma 16>, <&apbdma 16>;
+        dma-names = "rx", "tx";
+    };
index e914250..727c534 100644 (file)
@@ -63,6 +63,9 @@ properties:
     maximum: 2
     default: 1
 
+  power-domains:
+    maxItems: 1
+
 required:
   - compatible
   - reg
index a813c97..7fd5911 100644 (file)
@@ -45,6 +45,9 @@ properties:
       - const: fspi_en
       - const: fspi
 
+  power-domains:
+    maxItems: 1
+
 required:
   - compatible
   - reg
index 91e540a..5e5a704 100644 (file)
@@ -11,6 +11,7 @@ maintainers:
 
 allOf:
   - $ref: spi-controller.yaml#
+  - $ref: /schemas/arm/primecell.yaml#
 
 # We need a select here so we don't match all nodes with 'arm,primecell'
 select:
index fecead7..b197665 100644 (file)
@@ -404,7 +404,7 @@ static int amd_spi_probe(struct platform_device *pdev)
        master->bus_num = 0;
        master->num_chipselect = 4;
        master->mode_bits = 0;
-       master->flags = SPI_MASTER_HALF_DUPLEX;
+       master->flags = SPI_CONTROLLER_HALF_DUPLEX;
        master->max_speed_hz = AMD_SPI_MAX_HZ;
        master->min_speed_hz = AMD_SPI_MIN_HZ;
        master->setup = amd_spi_master_setup;
index 3c4224c..605e9e4 100644 (file)
@@ -72,7 +72,7 @@
 
 #define SPIFC_A1_USER_DBUF_ADDR_REG    0x248
 
-#define SPIFC_A1_BUFFER_SIZE           512
+#define SPIFC_A1_BUFFER_SIZE           512U
 
 #define SPIFC_A1_MAX_HZ                        200000000
 #define SPIFC_A1_MIN_HZ                        1000000
@@ -107,6 +107,7 @@ struct amlogic_spifc_a1 {
        struct clk *clk;
        struct device *dev;
        void __iomem *base;
+       u32 curr_speed_hz;
 };
 
 static int amlogic_spifc_a1_request(struct amlogic_spifc_a1 *spifc, bool read)
@@ -235,66 +236,68 @@ static int amlogic_spifc_a1_write(struct amlogic_spifc_a1 *spifc,
        return amlogic_spifc_a1_request(spifc, false);
 }
 
-static int amlogic_spifc_a1_exec_op(struct spi_mem *mem,
-                                   const struct spi_mem_op *op)
+static int amlogic_spifc_a1_set_freq(struct amlogic_spifc_a1 *spifc, u32 freq)
 {
-       struct amlogic_spifc_a1 *spifc =
-               spi_controller_get_devdata(mem->spi->controller);
-       size_t off, nbytes = op->data.nbytes;
-       u32 cmd_cfg, addr_cfg, dummy_cfg, dmode;
        int ret;
 
-       amlogic_spifc_a1_user_init(spifc);
-
-       cmd_cfg = SPIFC_A1_USER_CMD(op);
-       amlogic_spifc_a1_set_cmd(spifc, cmd_cfg);
+       if (freq == spifc->curr_speed_hz)
+               return 0;
 
-       if (op->addr.nbytes) {
-               addr_cfg = SPIFC_A1_USER_ADDR(op);
-               amlogic_spifc_a1_set_addr(spifc, op->addr.val, addr_cfg);
-       }
+       ret = clk_set_rate(spifc->clk, freq);
+       if (ret)
+               return ret;
 
-       if (op->dummy.nbytes) {
-               dummy_cfg = SPIFC_A1_USER_DUMMY(op);
-               amlogic_spifc_a1_set_dummy(spifc, dummy_cfg);
-       }
+       spifc->curr_speed_hz = freq;
+       return 0;
+}
 
-       if (!op->data.nbytes)
-               return amlogic_spifc_a1_request(spifc, false);
+static int amlogic_spifc_a1_exec_op(struct spi_mem *mem,
+                                   const struct spi_mem_op *op)
+{
+       struct amlogic_spifc_a1 *spifc =
+               spi_controller_get_devdata(mem->spi->controller);
+       size_t data_size = op->data.nbytes;
+       int ret;
 
-       dmode = ilog2(op->data.buswidth);
-       off = 0;
+       ret = amlogic_spifc_a1_set_freq(spifc, mem->spi->max_speed_hz);
+       if (ret)
+               return ret;
 
-       do {
-               size_t block_size = min_t(size_t, nbytes, SPIFC_A1_BUFFER_SIZE);
+       amlogic_spifc_a1_user_init(spifc);
+       amlogic_spifc_a1_set_cmd(spifc, SPIFC_A1_USER_CMD(op));
 
-               amlogic_spifc_a1_set_cmd(spifc, cmd_cfg);
+       if (op->addr.nbytes)
+               amlogic_spifc_a1_set_addr(spifc, op->addr.val,
+                                         SPIFC_A1_USER_ADDR(op));
 
-               if (op->addr.nbytes)
-                       amlogic_spifc_a1_set_addr(spifc, op->addr.val + off,
-                                                 addr_cfg);
+       if (op->dummy.nbytes)
+               amlogic_spifc_a1_set_dummy(spifc, SPIFC_A1_USER_DUMMY(op));
 
-               if (op->dummy.nbytes)
-                       amlogic_spifc_a1_set_dummy(spifc, dummy_cfg);
+       if (data_size) {
+               u32 mode = ilog2(op->data.buswidth);
 
                writel(0, spifc->base + SPIFC_A1_USER_DBUF_ADDR_REG);
 
                if (op->data.dir == SPI_MEM_DATA_IN)
-                       ret = amlogic_spifc_a1_read(spifc,
-                                                   op->data.buf.in + off,
-                                                   block_size, dmode);
+                       ret = amlogic_spifc_a1_read(spifc, op->data.buf.in,
+                                                   data_size, mode);
                else
-                       ret = amlogic_spifc_a1_write(spifc,
-                                                    op->data.buf.out + off,
-                                                    block_size, dmode);
-
-               nbytes -= block_size;
-               off += block_size;
-       } while (nbytes != 0 && !ret);
+                       ret = amlogic_spifc_a1_write(spifc, op->data.buf.out,
+                                                    data_size, mode);
+       } else {
+               ret = amlogic_spifc_a1_request(spifc, false);
+       }
 
        return ret;
 }
 
+static int amlogic_spifc_a1_adjust_op_size(struct spi_mem *mem,
+                                          struct spi_mem_op *op)
+{
+       op->data.nbytes = min(op->data.nbytes, SPIFC_A1_BUFFER_SIZE);
+       return 0;
+}
+
 static void amlogic_spifc_a1_hw_init(struct amlogic_spifc_a1 *spifc)
 {
        u32 regv;
@@ -314,6 +317,7 @@ static void amlogic_spifc_a1_hw_init(struct amlogic_spifc_a1 *spifc)
 
 static const struct spi_controller_mem_ops amlogic_spifc_a1_mem_ops = {
        .exec_op = amlogic_spifc_a1_exec_op,
+       .adjust_op_size = amlogic_spifc_a1_adjust_op_size,
 };
 
 static int amlogic_spifc_a1_probe(struct platform_device *pdev)
index 9dcada8..58b98ce 100644 (file)
@@ -14,7 +14,8 @@
 #include <linux/iopoll.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
 #include <linux/spi/spi.h>
 
 #define DRIVER_NAME "spi-ar934x"
index a7fb7c9..0103ac0 100644 (file)
@@ -17,8 +17,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_irq.h>
-#include <linux/of_device.h>
+#include <linux/platform_device.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/spi/spi.h>
 
index 7854d97..75d9bc6 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/of_platform.h>
 #include <linux/gpio/consumer.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
@@ -527,7 +526,7 @@ static int at91_usart_spi_probe(struct platform_device *pdev)
        controller->dev.of_node = pdev->dev.parent->of_node;
        controller->bits_per_word_mask = SPI_BPW_MASK(8);
        controller->setup = at91_usart_spi_setup;
-       controller->flags = SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX;
+       controller->flags = SPI_CONTROLLER_MUST_RX | SPI_CONTROLLER_MUST_TX;
        controller->transfer_one = at91_usart_spi_transfer_one;
        controller->prepare_message = at91_usart_spi_prepare_message;
        controller->unprepare_message = at91_usart_spi_unprepare_message;
index d3dd213..1b6d977 100644 (file)
@@ -185,7 +185,7 @@ static int ath79_spi_probe(struct platform_device *pdev)
 
        host->use_gpio_descriptors = true;
        host->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
-       host->flags = SPI_MASTER_GPIO_SS;
+       host->flags = SPI_CONTROLLER_GPIO_SS;
        host->num_chipselect = 3;
        host->mem_ops = &ath79_mem_ops;
 
index 152cd67..6aa8adb 100644 (file)
@@ -1450,10 +1450,6 @@ static int atmel_spi_probe(struct platform_device *pdev)
        /* Select default pin state */
        pinctrl_pm_select_default_state(&pdev->dev);
 
-       regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!regs)
-               return -ENXIO;
-
        irq = platform_get_irq(pdev, 0);
        if (irq < 0)
                return irq;
@@ -1475,8 +1471,8 @@ static int atmel_spi_probe(struct platform_device *pdev)
        host->bus_num = pdev->id;
        host->num_chipselect = 4;
        host->setup = atmel_spi_setup;
-       host->flags = (SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX |
-                       SPI_MASTER_GPIO_SS);
+       host->flags = (SPI_CONTROLLER_MUST_RX | SPI_CONTROLLER_MUST_TX |
+                       SPI_CONTROLLER_GPIO_SS);
        host->transfer_one = atmel_spi_one_transfer;
        host->set_cs = atmel_spi_set_cs;
        host->cleanup = atmel_spi_cleanup;
@@ -1490,7 +1486,7 @@ static int atmel_spi_probe(struct platform_device *pdev)
        spin_lock_init(&as->lock);
 
        as->pdev = pdev;
-       as->regs = devm_ioremap_resource(&pdev->dev, regs);
+       as->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &regs);
        if (IS_ERR(as->regs)) {
                ret = PTR_ERR(as->regs);
                goto out_unmap_regs;
index 3b253da..83fd062 100644 (file)
@@ -24,7 +24,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
-#include <linux/of_device.h>
+#include <linux/platform_device.h>
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/machine.h> /* FIXME: using chip internals */
 #include <linux/gpio/driver.h> /* FIXME: using chip internals */
@@ -1363,7 +1363,9 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
        if (bs->irq <= 0)
                return bs->irq ? bs->irq : -ENODEV;
 
-       clk_prepare_enable(bs->clk);
+       err = clk_prepare_enable(bs->clk);
+       if (err)
+               return err;
        bs->clk_hz = clk_get_rate(bs->clk);
 
        err = bcm2835_dma_init(ctlr, &pdev->dev, bs);
index 288f7b9..8ace417 100644 (file)
@@ -20,9 +20,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_address.h>
-#include <linux/of_device.h>
-#include <linux/of_irq.h>
+#include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/spi/spi.h>
 #include <linux/spinlock.h>
index 2dcbe16..0cab48b 100644 (file)
@@ -57,7 +57,7 @@ bitbang_txrx_be_cpha0(struct spi_device *spi,
        for (word <<= (32 - bits); likely(bits); bits--) {
 
                /* setup MSB (to slave) on trailing edge */
-               if ((flags & SPI_MASTER_NO_TX) == 0) {
+               if ((flags & SPI_CONTROLLER_NO_TX) == 0) {
                        if ((word & (1 << 31)) != oldbit) {
                                setmosi(spi, word & (1 << 31));
                                oldbit = word & (1 << 31);
@@ -70,7 +70,7 @@ bitbang_txrx_be_cpha0(struct spi_device *spi,
 
                /* sample MSB (from slave) on leading edge */
                word <<= 1;
-               if ((flags & SPI_MASTER_NO_RX) == 0)
+               if ((flags & SPI_CONTROLLER_NO_RX) == 0)
                        word |= getmiso(spi);
                setsck(spi, cpol);
        }
@@ -90,7 +90,7 @@ bitbang_txrx_be_cpha1(struct spi_device *spi,
 
                /* setup MSB (to slave) on leading edge */
                setsck(spi, !cpol);
-               if ((flags & SPI_MASTER_NO_TX) == 0) {
+               if ((flags & SPI_CONTROLLER_NO_TX) == 0) {
                        if ((word & (1 << 31)) != oldbit) {
                                setmosi(spi, word & (1 << 31));
                                oldbit = word & (1 << 31);
@@ -103,7 +103,7 @@ bitbang_txrx_be_cpha1(struct spi_device *spi,
 
                /* sample MSB (from slave) on trailing edge */
                word <<= 1;
-               if ((flags & SPI_MASTER_NO_RX) == 0)
+               if ((flags & SPI_CONTROLLER_NO_RX) == 0)
                        word |= getmiso(spi);
        }
        return word;
@@ -122,7 +122,7 @@ bitbang_txrx_le_cpha0(struct spi_device *spi,
        for (; likely(bits); bits--) {
 
                /* setup LSB (to slave) on trailing edge */
-               if ((flags & SPI_MASTER_NO_TX) == 0) {
+               if ((flags & SPI_CONTROLLER_NO_TX) == 0) {
                        if ((word & 1) != oldbit) {
                                setmosi(spi, word & 1);
                                oldbit = word & 1;
@@ -135,7 +135,7 @@ bitbang_txrx_le_cpha0(struct spi_device *spi,
 
                /* sample LSB (from slave) on leading edge */
                word >>= 1;
-               if ((flags & SPI_MASTER_NO_RX) == 0)
+               if ((flags & SPI_CONTROLLER_NO_RX) == 0)
                        word |= getmiso(spi) << rxbit;
                setsck(spi, cpol);
        }
@@ -156,7 +156,7 @@ bitbang_txrx_le_cpha1(struct spi_device *spi,
 
                /* setup LSB (to slave) on leading edge */
                setsck(spi, !cpol);
-               if ((flags & SPI_MASTER_NO_TX) == 0) {
+               if ((flags & SPI_CONTROLLER_NO_TX) == 0) {
                        if ((word & 1) != oldbit) {
                                setmosi(spi, word & 1);
                                oldbit = word & 1;
@@ -169,7 +169,7 @@ bitbang_txrx_le_cpha1(struct spi_device *spi,
 
                /* sample LSB (from slave) on trailing edge */
                word >>= 1;
-               if ((flags & SPI_MASTER_NO_RX) == 0)
+               if ((flags & SPI_CONTROLLER_NO_RX) == 0)
                        word |= getmiso(spi) << rxbit;
        }
        return word;
index 27d0087..ecd4401 100644 (file)
@@ -248,7 +248,7 @@ static int spi_bitbang_bufs(struct spi_device *spi, struct spi_transfer *t)
        if (spi->mode & SPI_3WIRE) {
                unsigned flags;
 
-               flags = t->tx_buf ? SPI_MASTER_NO_RX : SPI_MASTER_NO_TX;
+               flags = t->tx_buf ? SPI_CONTROLLER_NO_RX : SPI_CONTROLLER_NO_TX;
                return cs->txrx_bufs(spi, cs->txrx_word, nsecs, t, flags);
        }
        return cs->txrx_bufs(spi, cs->txrx_word, nsecs, t, 0);
@@ -349,11 +349,11 @@ int spi_bitbang_init(struct spi_bitbang *bitbang)
        /*
         * We only need the chipselect callback if we are actually using it.
         * If we just use GPIO descriptors, it is surplus. If the
-        * SPI_MASTER_GPIO_SS flag is set, we always need to call the
+        * SPI_CONTROLLER_GPIO_SS flag is set, we always need to call the
         * driver-specific chipselect routine.
         */
        custom_cs = (!master->use_gpio_descriptors ||
-                    (master->flags & SPI_MASTER_GPIO_SS));
+                    (master->flags & SPI_CONTROLLER_GPIO_SS));
 
        if (custom_cs && !bitbang->chipselect)
                return -EINVAL;
@@ -371,7 +371,7 @@ int spi_bitbang_init(struct spi_bitbang *bitbang)
        master->transfer_one = spi_bitbang_transfer_one;
        /*
         * When using GPIO descriptors, the ->set_cs() callback doesn't even
-        * get called unless SPI_MASTER_GPIO_SS is set.
+        * get called unless SPI_CONTROLLER_GPIO_SS is set.
         */
        if (custom_cs)
                master->set_cs = spi_bitbang_set_cs;
index abf10f9..e1a8cf0 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/kernel.h>
 #include <linux/log2.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
index ce4a314..11d623c 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/iopoll.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
index de8fe3c..42f101d 100644 (file)
@@ -690,8 +690,6 @@ remove_ctlr:
  * This function is called if a device is physically removed from the system or
  * if the driver module is being unloaded. It frees all resources allocated to
  * the device.
- *
- * Return:     0 on success and error value on error
  */
 static void cdns_spi_remove(struct platform_device *pdev)
 {
index 60c0d69..535f7eb 100644 (file)
@@ -64,7 +64,7 @@ static int thunderx_spi_probe(struct pci_dev *pdev,
                p->sys_freq = SYS_FREQ_DEFAULT;
        dev_info(dev, "Set system clock to %u\n", p->sys_freq);
 
-       master->flags = SPI_MASTER_HALF_DUPLEX;
+       master->flags = SPI_CONTROLLER_HALF_DUPLEX;
        master->num_chipselect = 4;
        master->mode_bits = SPI_CPHA | SPI_CPOL | SPI_CS_HIGH |
                            SPI_LSB_FIRST | SPI_3WIRE;
index b1bd8a6..31174e7 100644 (file)
@@ -381,13 +381,12 @@ static int mcfqspi_probe(struct platform_device *pdev)
                goto fail0;
        }
 
-       mcfqspi->clk = devm_clk_get(&pdev->dev, "qspi_clk");
+       mcfqspi->clk = devm_clk_get_enabled(&pdev->dev, "qspi_clk");
        if (IS_ERR(mcfqspi->clk)) {
                dev_dbg(&pdev->dev, "clk_get failed\n");
                status = PTR_ERR(mcfqspi->clk);
                goto fail0;
        }
-       clk_prepare_enable(mcfqspi->clk);
 
        master->bus_num = pdata->bus_num;
        master->num_chipselect = pdata->num_chipselect;
@@ -396,7 +395,7 @@ static int mcfqspi_probe(struct platform_device *pdev)
        status = mcfqspi_cs_setup(mcfqspi);
        if (status) {
                dev_dbg(&pdev->dev, "error initializing cs_control\n");
-               goto fail1;
+               goto fail0;
        }
 
        init_waitqueue_head(&mcfqspi->waitq);
@@ -414,18 +413,16 @@ static int mcfqspi_probe(struct platform_device *pdev)
        status = devm_spi_register_master(&pdev->dev, master);
        if (status) {
                dev_dbg(&pdev->dev, "spi_register_master failed\n");
-               goto fail2;
+               goto fail1;
        }
 
        dev_info(&pdev->dev, "Coldfire QSPI bus driver\n");
 
        return 0;
 
-fail2:
+fail1:
        pm_runtime_disable(&pdev->dev);
        mcfqspi_cs_teardown(mcfqspi);
-fail1:
-       clk_disable_unprepare(mcfqspi->clk);
 fail0:
        spi_master_put(master);
 
index b04811c..9a9f3bc 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/dmaengine.h>
 #include <linux/dma-mapping.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/spi_bitbang.h>
 #include <linux/slab.h>
@@ -895,25 +894,16 @@ static int davinci_spi_probe(struct platform_device *pdev)
                goto free_master;
        }
 
-       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (r == NULL) {
-               ret = -ENOENT;
-               goto free_master;
-       }
-
-       dspi->pbase = r->start;
-
-       dspi->base = devm_ioremap_resource(&pdev->dev, r);
+       dspi->base = devm_platform_get_and_ioremap_resource(pdev, 0, &r);
        if (IS_ERR(dspi->base)) {
                ret = PTR_ERR(dspi->base);
                goto free_master;
        }
+       dspi->pbase = r->start;
 
        init_completion(&dspi->done);
 
        ret = platform_get_irq(pdev, 0);
-       if (ret == 0)
-               ret = -EINVAL;
        if (ret < 0)
                goto free_master;
        dspi->irq = ret;
@@ -939,7 +929,7 @@ static int davinci_spi_probe(struct platform_device *pdev)
        master->bus_num = pdev->id;
        master->num_chipselect = pdata->num_chipselect;
        master->bits_per_word_mask = SPI_BPW_RANGE_MASK(2, 16);
-       master->flags = SPI_MASTER_MUST_RX | SPI_MASTER_GPIO_SS;
+       master->flags = SPI_CONTROLLER_MUST_RX | SPI_CONTROLLER_GPIO_SS;
        master->setup = davinci_spi_setup;
        master->cleanup = davinci_spi_cleanup;
        master->can_dma = davinci_spi_can_dma;
index a8ba41a..45f5acc 100644 (file)
@@ -932,7 +932,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
        if (dws->mem_ops.exec_op)
                master->mem_ops = &dws->mem_ops;
        master->max_speed_hz = dws->max_freq;
-       master->flags = SPI_MASTER_GPIO_SS;
+       master->flags = SPI_CONTROLLER_GPIO_SS;
        master->auto_runtime_pm = true;
 
        /* Get default rx sample delay */
index 1615fd2..3693b3d 100644 (file)
@@ -661,13 +661,7 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
 
        irq = platform_get_irq(pdev, 0);
        if (irq < 0)
-               return -EBUSY;
-
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!res) {
-               dev_err(&pdev->dev, "unable to get iomem resource\n");
-               return -ENODEV;
-       }
+               return irq;
 
        master = spi_alloc_master(&pdev->dev, sizeof(*espi));
        if (!master)
@@ -705,13 +699,12 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
        master->max_speed_hz = clk_get_rate(espi->clk) / 2;
        master->min_speed_hz = clk_get_rate(espi->clk) / (254 * 256);
 
-       espi->sspdr_phys = res->start + SSPDR;
-
-       espi->mmio = devm_ioremap_resource(&pdev->dev, res);
+       espi->mmio = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
        if (IS_ERR(espi->mmio)) {
                error = PTR_ERR(espi->mmio);
                goto fail_release_master;
        }
+       espi->sspdr_phys = res->start + SSPDR;
 
        error = devm_request_irq(&pdev->dev, irq, ep93xx_spi_interrupt,
                                0, "ep93xx-spi", master);
index 4c103df..8a8414c 100644 (file)
@@ -401,7 +401,7 @@ static int falcon_sflash_probe(struct platform_device *pdev)
        priv->master = master;
 
        master->mode_bits = SPI_MODE_3;
-       master->flags = SPI_MASTER_HALF_DUPLEX;
+       master->flags = SPI_CONTROLLER_HALF_DUPLEX;
        master->setup = falcon_sflash_setup;
        master->transfer_one_message = falcon_sflash_xfer_one;
        master->dev.of_node = pdev->dev.of_node;
index 674cfe0..150d2eb 100644 (file)
@@ -13,7 +13,8 @@
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/regmap.h>
 #include <linux/spi/spi.h>
@@ -502,15 +503,14 @@ static int dspi_request_dma(struct fsl_dspi *dspi, phys_addr_t phy_addr)
 
        dma->chan_rx = dma_request_chan(dev, "rx");
        if (IS_ERR(dma->chan_rx)) {
-               dev_err(dev, "rx dma channel not available\n");
-               ret = PTR_ERR(dma->chan_rx);
-               return ret;
+               return dev_err_probe(dev, PTR_ERR(dma->chan_rx),
+                       "rx dma channel not available\n");
        }
 
        dma->chan_tx = dma_request_chan(dev, "tx");
        if (IS_ERR(dma->chan_tx)) {
-               dev_err(dev, "tx dma channel not available\n");
                ret = PTR_ERR(dma->chan_tx);
+               dev_err_probe(dev, ret, "tx dma channel not available\n");
                goto err_tx_channel;
        }
 
index 76e1192..885757c 100644 (file)
@@ -18,7 +18,8 @@
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/module.h>
-#include <linux/of_platform.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
 #include <linux/spi/spi.h>
 #ifdef CONFIG_FSL_SOC
 #include <sysdev/fsl_soc.h>
index 015a1ab..50a07f9 100644 (file)
@@ -103,12 +103,9 @@ extern void mpc8xxx_spi_rx_buf_u32(u32 data, struct mpc8xxx_spi *mpc8xxx_spi);
 
 extern struct mpc8xxx_spi_probe_info *to_of_pinfo(
                struct fsl_spi_platform_data *pdata);
-extern int mpc8xxx_spi_bufs(struct mpc8xxx_spi *mspi,
-               struct spi_transfer *t, unsigned int len);
 extern const char *mpc8xxx_spi_strmode(unsigned int flags);
 extern void mpc8xxx_spi_probe(struct device *dev, struct resource *mem,
                unsigned int irq);
-extern int mpc8xxx_spi_remove(struct device *dev);
 extern int of_mpc8xxx_spi_probe(struct platform_device *ofdev);
 
 #endif /* __SPI_FSL_LIB_H__ */
index fb68c72..e32e8ca 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/dma/imx-dma.h>
@@ -98,7 +97,6 @@ struct fsl_lpspi_data {
        struct clk *clk_ipg;
        struct clk *clk_per;
        bool is_slave;
-       u32 num_cs;
        bool is_only_cs1;
        bool is_first_byte;
 
@@ -826,6 +824,7 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
        struct spi_controller *controller;
        struct resource *res;
        int ret, irq;
+       u32 num_cs;
        u32 temp;
        bool is_slave;
 
@@ -847,22 +846,6 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
        fsl_lpspi->is_slave = is_slave;
        fsl_lpspi->is_only_cs1 = of_property_read_bool((&pdev->dev)->of_node,
                                                "fsl,spi-only-use-cs1-sel");
-       if (of_property_read_u32((&pdev->dev)->of_node, "num-cs",
-                                &fsl_lpspi->num_cs))
-               fsl_lpspi->num_cs = 1;
-
-       controller->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32);
-       controller->transfer_one = fsl_lpspi_transfer_one;
-       controller->prepare_transfer_hardware = lpspi_prepare_xfer_hardware;
-       controller->unprepare_transfer_hardware = lpspi_unprepare_xfer_hardware;
-       controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
-       controller->flags = SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX;
-       controller->dev.of_node = pdev->dev.of_node;
-       controller->bus_num = pdev->id;
-       controller->num_chipselect = fsl_lpspi->num_cs;
-       controller->slave_abort = fsl_lpspi_slave_abort;
-       if (!fsl_lpspi->is_slave)
-               controller->use_gpio_descriptors = true;
 
        init_completion(&fsl_lpspi->xfer_done);
 
@@ -912,6 +895,26 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
        temp = readl(fsl_lpspi->base + IMX7ULP_PARAM);
        fsl_lpspi->txfifosize = 1 << (temp & 0x0f);
        fsl_lpspi->rxfifosize = 1 << ((temp >> 8) & 0x0f);
+       if (of_property_read_u32((&pdev->dev)->of_node, "num-cs",
+                                &num_cs)) {
+               if (of_device_is_compatible(pdev->dev.of_node, "fsl,imx93-spi"))
+                       num_cs = ((temp >> 16) & 0xf);
+               else
+                       num_cs = 1;
+       }
+
+       controller->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32);
+       controller->transfer_one = fsl_lpspi_transfer_one;
+       controller->prepare_transfer_hardware = lpspi_prepare_xfer_hardware;
+       controller->unprepare_transfer_hardware = lpspi_unprepare_xfer_hardware;
+       controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
+       controller->flags = SPI_CONTROLLER_MUST_RX | SPI_CONTROLLER_MUST_TX;
+       controller->dev.of_node = pdev->dev.of_node;
+       controller->bus_num = pdev->id;
+       controller->num_chipselect = num_cs;
+       controller->slave_abort = fsl_lpspi_slave_abort;
+       if (!fsl_lpspi->is_slave)
+               controller->use_gpio_descriptors = true;
 
        ret = fsl_lpspi_dma_init(&pdev->dev, fsl_lpspi, controller);
        if (ret == -EPROBE_DEFER)
index 8ade61e..e3de812 100644 (file)
@@ -34,7 +34,6 @@
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/pm_qos.h>
 #include <linux/sizes.h>
index 092afc7..8aa905e 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/platform_device.h>
 #include <linux/gpio/consumer.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 
 #include <linux/spi/spi.h>
 #include <linux/spi/spi_bitbang.h>
@@ -170,7 +169,7 @@ static u32 spi_gpio_txrx_word_mode3(struct spi_device *spi,
 
 /*
  * These functions do not call setmosi or getmiso if respective flag
- * (SPI_MASTER_NO_RX or SPI_MASTER_NO_TX) is set, so they are safe to
+ * (SPI_CONTROLLER_NO_RX or SPI_CONTROLLER_NO_TX) is set, so they are safe to
  * call when such pin is not present or defined in the controller.
  * A separate set of callbacks is defined to get highest possible
  * speed in the generic case (when both MISO and MOSI lines are
@@ -416,11 +415,11 @@ static int spi_gpio_probe(struct platform_device *pdev)
        if (!spi_gpio->mosi) {
                /* HW configuration without MOSI pin
                 *
-                * No setting SPI_MASTER_NO_RX here - if there is only
+                * No setting SPI_CONTROLLER_NO_RX here - if there is only
                 * a MOSI pin connected the host can still do RX by
                 * changing the direction of the line.
                 */
-               master->flags = SPI_MASTER_NO_TX;
+               master->flags = SPI_CONTROLLER_NO_TX;
        }
 
        master->bus_num = pdev->id;
@@ -434,11 +433,11 @@ static int spi_gpio_probe(struct platform_device *pdev)
         * line, that we need to do on selection. This makes the local
         * callback for chipselect always get called.
         */
-       master->flags |= SPI_MASTER_GPIO_SS;
+       master->flags |= SPI_CONTROLLER_GPIO_SS;
        bb->chipselect = spi_gpio_chipselect;
        bb->set_line_direction = spi_gpio_set_direction;
 
-       if (master->flags & SPI_MASTER_NO_TX) {
+       if (master->flags & SPI_CONTROLLER_NO_TX) {
                bb->txrx_word[SPI_MODE_0] = spi_gpio_spec_txrx_word_mode0;
                bb->txrx_word[SPI_MODE_1] = spi_gpio_spec_txrx_word_mode1;
                bb->txrx_word[SPI_MODE_2] = spi_gpio_spec_txrx_word_mode2;
index 684d63f..88ab303 100644 (file)
@@ -3,7 +3,6 @@
 
 #include <linux/iopoll.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/spi-mem.h>
index 528ae46..3634fe8 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/spi/spi.h>
 #include <linux/types.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/property.h>
 
 #include <linux/dma/imx-dma.h>
@@ -659,9 +658,13 @@ static int mx51_ecspi_prepare_transfer(struct spi_imx_data *spi_imx,
        if (spi_imx->slave_mode && is_imx53_ecspi(spi_imx))
                ctrl |= (spi_imx->slave_burst * 8 - 1)
                        << MX51_ECSPI_CTRL_BL_OFFSET;
-       else
-               ctrl |= (spi_imx->bits_per_word - 1)
-                       << MX51_ECSPI_CTRL_BL_OFFSET;
+       else {
+               if (spi_imx->count >= 512)
+                       ctrl |= 0xFFF << MX51_ECSPI_CTRL_BL_OFFSET;
+               else
+                       ctrl |= (spi_imx->count*8 - 1)
+                               << MX51_ECSPI_CTRL_BL_OFFSET;
+       }
 
        /* set clock speed */
        ctrl &= ~(0xf << MX51_ECSPI_CTRL_POSTDIV_OFFSET |
@@ -1258,6 +1261,7 @@ static int spi_imx_setupxfer(struct spi_device *spi,
                spi_imx->spi_bus_clk = t->speed_hz;
 
        spi_imx->bits_per_word = t->bits_per_word;
+       spi_imx->count = t->len;
 
        /*
         * Initialize the functions for transfer. To transfer non byte-aligned
@@ -1779,7 +1783,7 @@ static int spi_imx_probe(struct platform_device *pdev)
 
        if (is_imx51_ecspi(spi_imx) || is_imx53_ecspi(spi_imx)) {
                controller->max_native_cs = 4;
-               controller->flags |= SPI_MASTER_GPIO_SS;
+               controller->flags |= SPI_CONTROLLER_GPIO_SS;
        }
 
        spi_imx->spi_drctl = spi_drctl;
index 7d4b515..cfa665a 100644 (file)
@@ -12,7 +12,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/iopoll.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/spi/spi.h>
index 8d6ecc5..6556827 100644 (file)
@@ -6,7 +6,8 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/delay.h>
index 675a73c..bbf2015 100644 (file)
@@ -14,8 +14,8 @@
 #include <linux/ktime.h>
 #include <linux/list.h>
 #include <linux/list_sort.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
 #include <linux/printk.h>
 #include <linux/vmalloc.h>
 #include <linux/spi/spi.h>
index 2d43654..b357461 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/spi/spi.h>
 
 #define DRIVER_NAME    "spi_lp8841_rtc"
@@ -75,14 +74,14 @@ bitbang_txrx_be_cpha0_lsb(struct spi_lp8841_rtc *data,
        for (; likely(bits); bits--) {
 
                /* setup LSB (to slave) on leading edge */
-               if ((flags & SPI_MASTER_NO_TX) == 0)
+               if ((flags & SPI_CONTROLLER_NO_TX) == 0)
                        setmosi(data, (word & 1));
 
                usleep_range(usecs, usecs + 1); /* T(setup) */
 
                /* sample LSB (from slave) on trailing edge */
                word >>= 1;
-               if ((flags & SPI_MASTER_NO_RX) == 0)
+               if ((flags & SPI_CONTROLLER_NO_RX) == 0)
                        word |= (getmiso(data) << 31);
 
                setsck(data, !cpol);
@@ -113,7 +112,7 @@ spi_lp8841_rtc_transfer_one(struct spi_master *master,
                while (likely(count > 0)) {
                        word = *tx++;
                        bitbang_txrx_be_cpha0_lsb(data, 1, 0,
-                                       SPI_MASTER_NO_RX, word, 8);
+                                       SPI_CONTROLLER_NO_RX, word, 8);
                        count--;
                }
        } else if (rx) {
@@ -121,7 +120,7 @@ spi_lp8841_rtc_transfer_one(struct spi_master *master,
                writeb(data->state, data->iomem);
                while (likely(count > 0)) {
                        word = bitbang_txrx_be_cpha0_lsb(data, 1, 0,
-                                       SPI_MASTER_NO_TX, word, 8);
+                                       SPI_CONTROLLER_NO_TX, word, 8);
                        *rx++ = word;
                        count--;
                }
@@ -191,7 +190,7 @@ spi_lp8841_rtc_probe(struct platform_device *pdev)
                return -ENOMEM;
        platform_set_drvdata(pdev, master);
 
-       master->flags = SPI_MASTER_HALF_DUPLEX;
+       master->flags = SPI_CONTROLLER_HALF_DUPLEX;
        master->mode_bits = SPI_CS_HIGH | SPI_3WIRE | SPI_LSB_FIRST;
 
        master->bus_num = pdev->id;
index 141562c..43d134f 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
 #include <linux/types.h>
@@ -864,7 +863,7 @@ static int meson_spicc_probe(struct platform_device *pdev)
                                     SPI_BPW_MASK(24) |
                                     SPI_BPW_MASK(16) |
                                     SPI_BPW_MASK(8);
-       master->flags = (SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX);
+       master->flags = (SPI_CONTROLLER_MUST_RX | SPI_CONTROLLER_MUST_TX);
        master->min_speed_hz = spicc->data->min_speed_hz;
        master->max_speed_hz = spicc->data->max_speed_hz;
        master->setup = meson_spicc_setup;
index b59e8a0..b451cd4 100644 (file)
@@ -530,10 +530,8 @@ static int mchp_corespi_probe(struct platform_device *pdev)
                return PTR_ERR(spi->regs);
 
        spi->irq = platform_get_irq(pdev, 0);
-       if (spi->irq <= 0)
-               return dev_err_probe(&pdev->dev, -ENXIO,
-                                    "invalid IRQ %d for SPI controller\n",
-                                    spi->irq);
+       if (spi->irq < 0)
+               return spi->irq;
 
        ret = devm_request_irq(&pdev->dev, spi->irq, mchp_corespi_interrupt,
                               IRQF_SHARED, dev_name(&pdev->dev), master);
index 39272ad..0757985 100644 (file)
@@ -1142,7 +1142,7 @@ static int mtk_spi_probe(struct platform_device *pdev)
                master->mode_bits |= SPI_CS_HIGH;
 
        if (mdata->dev_comp->must_tx)
-               master->flags = SPI_MASTER_MUST_TX;
+               master->flags = SPI_CONTROLLER_MUST_TX;
        if (mdata->dev_comp->ipm_design)
                master->mode_bits |= SPI_LOOP | SPI_RX_DUAL | SPI_TX_DUAL |
                                     SPI_RX_QUAD | SPI_TX_QUAD;
index 3e9d396..91600e5 100644 (file)
@@ -14,7 +14,9 @@
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/platform_device.h>
 #include <linux/reset.h>
 #include <linux/spi/spi.h>
 
index baa7a53..cf4ee8b 100644 (file)
@@ -13,7 +13,8 @@
 #include <linux/iopoll.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/spi-mem.h>
index bed8317..4433a8a 100644 (file)
@@ -76,7 +76,8 @@
 #include <linux/interrupt.h>
 #include <linux/dma-mapping.h>
 #include <linux/iopoll.h>
-#include <linux/of_platform.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
 #include <linux/mtd/nand-ecc-mtk.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/spi-mem.h>
index 963a53d..cd0e7ae 100644 (file)
@@ -572,7 +572,7 @@ static int mxs_spi_probe(struct platform_device *pdev)
        master->mode_bits = SPI_CPOL | SPI_CPHA;
        master->num_chipselect = 3;
        master->dev.of_node = np;
-       master->flags = SPI_MASTER_HALF_DUPLEX;
+       master->flags = SPI_CONTROLLER_HALF_DUPLEX;
        master->auto_runtime_pm = true;
 
        spi = spi_master_get_devdata(master);
index eb35356..9e8c914 100644 (file)
@@ -12,7 +12,7 @@
 #include <linux/io.h>
 #include <linux/vmalloc.h>
 #include <linux/regmap.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
 #include <linux/spi/spi-mem.h>
 #include <linux/mfd/syscon.h>
 
index 5440176..45a4acc 100644 (file)
@@ -47,7 +47,6 @@
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/pm_qos.h>
 #include <linux/regmap.h>
@@ -1157,12 +1156,10 @@ static int nxp_fspi_probe(struct platform_device *pdev)
 
        /* find the resources - configuration register address space */
        if (is_acpi_node(dev_fwnode(f->dev)))
-               res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+               f->iobase = devm_platform_ioremap_resource(pdev, 0);
        else
-               res = platform_get_resource_byname(pdev,
-                               IORESOURCE_MEM, "fspi_base");
+               f->iobase = devm_platform_ioremap_resource_byname(pdev, "fspi_base");
 
-       f->iobase = devm_ioremap_resource(dev, res);
        if (IS_ERR(f->iobase)) {
                ret = PTR_ERR(f->iobase);
                goto err_put_ctrl;
index 902d2e0..f89aa9e 100644 (file)
@@ -486,7 +486,7 @@ static int uwire_probe(struct platform_device *pdev)
        /* the spi->mode bits understood by this driver: */
        master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
        master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 16);
-       master->flags = SPI_MASTER_HALF_DUPLEX;
+       master->flags = SPI_CONTROLLER_HALF_DUPLEX;
 
        master->bus_num = 2;    /* "official" */
        master->num_chipselect = 4;
index ad9e83e..faf2764 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/pm_runtime.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
-#include <linux/of_device.h>
 #include <linux/clk.h>
 #include <linux/sizes.h>
 #include <asm/unaligned.h>
@@ -677,7 +676,7 @@ static int orion_spi_probe(struct platform_device *pdev)
        master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
        master->auto_runtime_pm = true;
        master->use_gpio_descriptors = true;
-       master->flags = SPI_MASTER_GPIO_SS;
+       master->flags = SPI_CONTROLLER_GPIO_SS;
 
        platform_set_drvdata(pdev, master);
 
index 4445d82..d23c428 100644 (file)
@@ -365,7 +365,7 @@ static int pci1xxxx_spi_probe(struct pci_dev *pdev, const struct pci_device_id *
                spi_host->bits_per_word_mask = SPI_BPW_MASK(8);
                spi_host->max_speed_hz = PCI1XXXX_SPI_MAX_CLOCK_HZ;
                spi_host->min_speed_hz = PCI1XXXX_SPI_MIN_CLOCK_HZ;
-               spi_host->flags = SPI_MASTER_MUST_TX;
+               spi_host->flags = SPI_CONTROLLER_MUST_TX;
                spi_master_set_devdata(spi_host, spi_sub_ptr);
                ret = devm_spi_register_master(dev, spi_host);
                if (ret)
index 51dfb49..5cbebcf 100644 (file)
@@ -648,7 +648,7 @@ static int pic32_sqi_probe(struct platform_device *pdev)
        master->dev.of_node     = pdev->dev.of_node;
        master->mode_bits       = SPI_MODE_3 | SPI_MODE_0 | SPI_TX_DUAL |
                                  SPI_RX_DUAL | SPI_TX_QUAD | SPI_RX_QUAD;
-       master->flags           = SPI_MASTER_HALF_DUPLEX;
+       master->flags           = SPI_CONTROLLER_HALF_DUPLEX;
        master->can_dma         = pic32_sqi_can_dma;
        master->bits_per_word_mask      = SPI_BPW_RANGE_MASK(8, 32);
        master->transfer_one_message    = pic32_sqi_one_message;
index f2af5e6..e9b4c9c 100644 (file)
@@ -773,7 +773,7 @@ static int pic32_spi_probe(struct platform_device *pdev)
        master->max_speed_hz    = clk_get_rate(pic32s->clk);
        master->setup           = pic32_spi_setup;
        master->cleanup         = pic32_spi_cleanup;
-       master->flags           = SPI_MASTER_MUST_TX | SPI_MASTER_MUST_RX;
+       master->flags           = SPI_CONTROLLER_MUST_TX | SPI_CONTROLLER_MUST_RX;
        master->bits_per_word_mask      = SPI_BPW_MASK(8) | SPI_BPW_MASK(16) |
                                          SPI_BPW_MASK(32);
        master->transfer_one            = pic32_spi_one_transfer;
index 1954c39..b9d5641 100644 (file)
@@ -9,7 +9,7 @@
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_platform.h>
+#include <linux/platform_device.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/pm_runtime.h>
 #include <linux/pm_opp.h>
@@ -767,7 +767,7 @@ static int qcom_qspi_probe(struct platform_device *pdev)
        master->mode_bits = SPI_MODE_0 |
                            SPI_TX_DUAL | SPI_RX_DUAL |
                            SPI_TX_QUAD | SPI_RX_QUAD;
-       master->flags = SPI_MASTER_HALF_DUPLEX;
+       master->flags = SPI_CONTROLLER_HALF_DUPLEX;
        master->prepare_message = qcom_qspi_prepare_message;
        master->transfer_one = qcom_qspi_transfer_one;
        master->handle_err = qcom_qspi_handle_err;
index 00e5e88..fd16acb 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/spi/spi.h>
index 5073736..c817889 100644 (file)
@@ -156,7 +156,7 @@ static int rb4xx_spi_probe(struct platform_device *pdev)
        master->num_chipselect = 3;
        master->mode_bits = SPI_TX_DUAL;
        master->bits_per_word_mask = SPI_BPW_MASK(8);
-       master->flags = SPI_MASTER_MUST_TX;
+       master->flags = SPI_CONTROLLER_MUST_TX;
        master->transfer_one = rb4xx_transfer_one;
        master->set_cs = rb4xx_set_cs;
 
index 583f418..bd550e7 100644 (file)
@@ -565,7 +565,7 @@ static int rockchip_sfc_probe(struct platform_device *pdev)
        if (!master)
                return -ENOMEM;
 
-       master->flags = SPI_MASTER_HALF_DUPLEX;
+       master->flags = SPI_CONTROLLER_HALF_DUPLEX;
        master->mem_ops = &rockchip_sfc_mem_ops;
        master->dev.of_node = pdev->dev.of_node;
        master->mode_bits = SPI_TX_QUAD | SPI_TX_DUAL | SPI_RX_QUAD | SPI_RX_DUAL;
index 143ede9..a379438 100644 (file)
@@ -858,7 +858,7 @@ static int rockchip_spi_probe(struct platform_device *pdev)
                ctlr->mode_bits |= SPI_NO_CS;
                ctlr->slave_abort = rockchip_spi_slave_abort;
        } else {
-               ctlr->flags = SPI_MASTER_GPIO_SS;
+               ctlr->flags = SPI_CONTROLLER_GPIO_SS;
                ctlr->max_native_cs = ROCKCHIP_SPI_MAX_CS_NUM;
                /*
                 * rk spi0 has two native cs, spi1..5 one cs only
index 08ceebb..83bb169 100644 (file)
@@ -19,7 +19,7 @@
 #include <linux/clk.h>
 #include <linux/dmaengine.h>
 #include <linux/dma-mapping.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
 #include <linux/pm_runtime.h>
 #include <linux/reset.h>
 #include <linux/sh_dma.h>
@@ -1317,8 +1317,7 @@ static int rspi_probe(struct platform_device *pdev)
        rspi->ops = ops;
        rspi->ctlr = ctlr;
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       rspi->addr = devm_ioremap_resource(&pdev->dev, res);
+       rspi->addr = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
        if (IS_ERR(rspi->addr)) {
                ret = PTR_ERR(rspi->addr);
                goto error1;
index 14ad65d..d098aef 100644 (file)
@@ -5,13 +5,17 @@
  * Copyright (C) 2023 Renesas Electronics Corporation
  */
 
+#include <linux/bits.h>
 #include <linux/clk.h>
 #include <linux/count_zeros.h>
 #include <linux/interrupt.h>
 #include <linux/iopoll.h>
+#include <linux/log2.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/reset.h>
 #include <linux/spi/spi.h>
+#include <linux/units.h>
 
 /* Registers */
 #define CSI_MODE               0x00    /* CSI mode control */
@@ -36,6 +40,7 @@
 /* CSI_CLKSEL */
 #define CSI_CLKSEL_CKP         BIT(17)
 #define CSI_CLKSEL_DAP         BIT(16)
+#define CSI_CLKSEL_MODE                (CSI_CLKSEL_CKP|CSI_CLKSEL_DAP)
 #define CSI_CLKSEL_SLAVE       BIT(15)
 #define CSI_CLKSEL_CKS         GENMASK(14, 1)
 
 /* CSI_FIFOTRG */
 #define CSI_FIFOTRG_R_TRG       GENMASK(2, 0)
 
-#define CSI_FIFO_SIZE_BYTES    32
-#define CSI_FIFO_HALF_SIZE     16
+#define CSI_FIFO_SIZE_BYTES    32U
+#define CSI_FIFO_HALF_SIZE     16U
 #define CSI_EN_DIS_TIMEOUT_US  100
-#define CSI_CKS_MAX            0x3FFF
+/*
+ * Clock "csiclk" gets divided by 2 * CSI_CLKSEL_CKS in order to generate the
+ * serial clock (output from master), with CSI_CLKSEL_CKS ranging from 0x1 (that
+ * means "csiclk" is divided by 2) to 0x3FFF ("csiclk" is divided by 32766).
+ */
+#define CSI_CKS_MAX            GENMASK(13, 0)
 
 #define UNDERRUN_ERROR         BIT(0)
 #define OVERFLOW_ERROR         BIT(1)
 #define TX_TIMEOUT_ERROR       BIT(2)
 #define RX_TIMEOUT_ERROR       BIT(3)
 
-#define CSI_MAX_SPI_SCKO       8000000
+#define CSI_MAX_SPI_SCKO       (8 * HZ_PER_MHZ)
 
 struct rzv2m_csi_priv {
        void __iomem *base;
@@ -78,33 +88,19 @@ struct rzv2m_csi_priv {
        struct clk *pclk;
        struct device *dev;
        struct spi_controller *controller;
-       const u8 *txbuf;
-       u8 *rxbuf;
-       int buffer_len;
-       int bytes_sent;
-       int bytes_received;
-       int bytes_to_transfer;
-       int words_to_transfer;
-       unsigned char bytes_per_word;
+       const void *txbuf;
+       void *rxbuf;
+       unsigned int buffer_len;
+       unsigned int bytes_sent;
+       unsigned int bytes_received;
+       unsigned int bytes_to_transfer;
+       unsigned int words_to_transfer;
+       unsigned int bytes_per_word;
        wait_queue_head_t wait;
-       u8 errors;
+       u32 errors;
        u32 status;
 };
 
-static const unsigned char x_trg[] = {
-       0, 1, 1, 2, 2, 2, 2, 3,
-       3, 3, 3, 3, 3, 3, 3, 4,
-       4, 4, 4, 4, 4, 4, 4, 4,
-       4, 4, 4, 4, 4, 4, 4, 5
-};
-
-static const unsigned char x_trg_words[] = {
-       1,  2,  2,  4,  4,  4,  4,  8,
-       8,  8,  8,  8,  8,  8,  8,  16,
-       16, 16, 16, 16, 16, 16, 16, 16,
-       16, 16, 16, 16, 16, 16, 16, 32
-};
-
 static void rzv2m_csi_reg_write_bit(const struct rzv2m_csi_priv *csi,
                                    int reg_offs, int bit_mask, u32 value)
 {
@@ -124,13 +120,12 @@ static int rzv2m_csi_sw_reset(struct rzv2m_csi_priv *csi, int assert)
 
        rzv2m_csi_reg_write_bit(csi, CSI_CNT, CSI_CNT_CSIRST, assert);
 
-       if (assert) {
-               return readl_poll_timeout(csi->base + CSI_MODE, reg,
-                                         !(reg & CSI_MODE_CSOT), 0,
-                                         CSI_EN_DIS_TIMEOUT_US);
-       }
+       if (!assert)
+               return 0;
 
-       return 0;
+       return readl_poll_timeout(csi->base + CSI_MODE, reg,
+                                 !(reg & CSI_MODE_CSOT), 0,
+                                 CSI_EN_DIS_TIMEOUT_US);
 }
 
 static int rzv2m_csi_start_stop_operation(const struct rzv2m_csi_priv *csi,
@@ -140,28 +135,28 @@ static int rzv2m_csi_start_stop_operation(const struct rzv2m_csi_priv *csi,
 
        rzv2m_csi_reg_write_bit(csi, CSI_MODE, CSI_MODE_CSIE, enable);
 
-       if (!enable && wait)
-               return readl_poll_timeout(csi->base + CSI_MODE, reg,
-                                         !(reg & CSI_MODE_CSOT), 0,
-                                         CSI_EN_DIS_TIMEOUT_US);
+       if (enable || !wait)
+               return 0;
 
-       return 0;
+       return readl_poll_timeout(csi->base + CSI_MODE, reg,
+                                 !(reg & CSI_MODE_CSOT), 0,
+                                 CSI_EN_DIS_TIMEOUT_US);
 }
 
 static int rzv2m_csi_fill_txfifo(struct rzv2m_csi_priv *csi)
 {
-       int i;
+       unsigned int i;
 
        if (readl(csi->base + CSI_OFIFOL))
                return -EIO;
 
        if (csi->bytes_per_word == 2) {
-               u16 *buf = (u16 *)csi->txbuf;
+               const u16 *buf = csi->txbuf;
 
                for (i = 0; i < csi->words_to_transfer; i++)
                        writel(buf[i], csi->base + CSI_OFIFO);
        } else {
-               u8 *buf = (u8 *)csi->txbuf;
+               const u8 *buf = csi->txbuf;
 
                for (i = 0; i < csi->words_to_transfer; i++)
                        writel(buf[i], csi->base + CSI_OFIFO);
@@ -175,18 +170,18 @@ static int rzv2m_csi_fill_txfifo(struct rzv2m_csi_priv *csi)
 
 static int rzv2m_csi_read_rxfifo(struct rzv2m_csi_priv *csi)
 {
-       int i;
+       unsigned int i;
 
        if (readl(csi->base + CSI_IFIFOL) != csi->bytes_to_transfer)
                return -EIO;
 
        if (csi->bytes_per_word == 2) {
-               u16 *buf = (u16 *)csi->rxbuf;
+               u16 *buf = csi->rxbuf;
 
                for (i = 0; i < csi->words_to_transfer; i++)
                        buf[i] = (u16)readl(csi->base + CSI_IFIFO);
        } else {
-               u8 *buf = (u8 *)csi->rxbuf;
+               u8 *buf = csi->rxbuf;
 
                for (i = 0; i < csi->words_to_transfer; i++)
                        buf[i] = (u8)readl(csi->base + CSI_IFIFO);
@@ -200,9 +195,9 @@ static int rzv2m_csi_read_rxfifo(struct rzv2m_csi_priv *csi)
 
 static inline void rzv2m_csi_calc_current_transfer(struct rzv2m_csi_priv *csi)
 {
-       int bytes_transferred = max_t(int, csi->bytes_received, csi->bytes_sent);
-       int bytes_remaining = csi->buffer_len - bytes_transferred;
-       int to_transfer;
+       unsigned int bytes_transferred = max(csi->bytes_received, csi->bytes_sent);
+       unsigned int bytes_remaining = csi->buffer_len - bytes_transferred;
+       unsigned int to_transfer;
 
        if (csi->txbuf)
                /*
@@ -210,9 +205,9 @@ static inline void rzv2m_csi_calc_current_transfer(struct rzv2m_csi_priv *csi)
                 * hard to raise an overflow error (which is only possible
                 * when IP transmits and receives at the same time).
                 */
-               to_transfer = min_t(int, CSI_FIFO_HALF_SIZE, bytes_remaining);
+               to_transfer = min(CSI_FIFO_HALF_SIZE, bytes_remaining);
        else
-               to_transfer = min_t(int, CSI_FIFO_SIZE_BYTES, bytes_remaining);
+               to_transfer = min(CSI_FIFO_SIZE_BYTES, bytes_remaining);
 
        if (csi->bytes_per_word == 2)
                to_transfer >>= 1;
@@ -223,7 +218,7 @@ static inline void rzv2m_csi_calc_current_transfer(struct rzv2m_csi_priv *csi)
         * less than or equal to the number of bytes we need to transfer.
         * This may result in multiple smaller transfers.
         */
-       csi->words_to_transfer = x_trg_words[to_transfer - 1];
+       csi->words_to_transfer = rounddown_pow_of_two(to_transfer);
 
        if (csi->bytes_per_word == 2)
                csi->bytes_to_transfer = csi->words_to_transfer << 1;
@@ -234,7 +229,7 @@ static inline void rzv2m_csi_calc_current_transfer(struct rzv2m_csi_priv *csi)
 static inline void rzv2m_csi_set_rx_fifo_trigger_level(struct rzv2m_csi_priv *csi)
 {
        rzv2m_csi_reg_write_bit(csi, CSI_FIFOTRG, CSI_FIFOTRG_R_TRG,
-                               x_trg[csi->words_to_transfer - 1]);
+                               ilog2(csi->words_to_transfer));
 }
 
 static inline void rzv2m_csi_enable_rx_trigger(struct rzv2m_csi_priv *csi,
@@ -307,7 +302,6 @@ static int rzv2m_csi_wait_for_tx_empty(struct rzv2m_csi_priv *csi)
                return 0;
 
        ret = rzv2m_csi_wait_for_interrupt(csi, CSI_INT_TREND, CSI_CNT_TREND_E);
-
        if (ret == -ETIMEDOUT)
                csi->errors |= TX_TIMEOUT_ERROR;
 
@@ -323,7 +317,6 @@ static inline int rzv2m_csi_wait_for_rx_ready(struct rzv2m_csi_priv *csi)
 
        ret = rzv2m_csi_wait_for_interrupt(csi, CSI_INT_R_TRGR,
                                           CSI_CNT_R_TRGR_E);
-
        if (ret == -ETIMEDOUT)
                csi->errors |= RX_TIMEOUT_ERROR;
 
@@ -332,7 +325,7 @@ static inline int rzv2m_csi_wait_for_rx_ready(struct rzv2m_csi_priv *csi)
 
 static irqreturn_t rzv2m_csi_irq_handler(int irq, void *data)
 {
-       struct rzv2m_csi_priv *csi = (struct rzv2m_csi_priv *)data;
+       struct rzv2m_csi_priv *csi = data;
 
        csi->status = readl(csi->base + CSI_INT);
        rzv2m_csi_disable_irqs(csi, csi->status);
@@ -402,10 +395,8 @@ static int rzv2m_csi_setup(struct spi_device *spi)
        writel(CSI_MODE_SETUP, csi->base + CSI_MODE);
 
        /* Setup clock polarity and phase timing */
-       rzv2m_csi_reg_write_bit(csi, CSI_CLKSEL, CSI_CLKSEL_CKP,
-                               !(spi->mode & SPI_CPOL));
-       rzv2m_csi_reg_write_bit(csi, CSI_CLKSEL, CSI_CLKSEL_DAP,
-                               !(spi->mode & SPI_CPHA));
+       rzv2m_csi_reg_write_bit(csi, CSI_CLKSEL, CSI_CLKSEL_MODE,
+                               ~spi->mode & SPI_MODE_X_MASK);
 
        /* Setup serial data order */
        rzv2m_csi_reg_write_bit(csi, CSI_MODE, CSI_MODE_DIR,
@@ -433,8 +424,8 @@ static int rzv2m_csi_setup(struct spi_device *spi)
 
 static int rzv2m_csi_pio_transfer(struct rzv2m_csi_priv *csi)
 {
-       bool tx_completed = csi->txbuf ? false : true;
-       bool rx_completed = csi->rxbuf ? false : true;
+       bool tx_completed = !csi->txbuf;
+       bool rx_completed = !csi->rxbuf;
        int ret = 0;
 
        /* Make sure the TX FIFO is empty */
@@ -599,12 +590,13 @@ static int rzv2m_csi_probe(struct platform_device *pdev)
        init_waitqueue_head(&csi->wait);
 
        controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;
-       controller->dev.of_node = pdev->dev.of_node;
        controller->bits_per_word_mask = SPI_BPW_MASK(16) | SPI_BPW_MASK(8);
        controller->setup = rzv2m_csi_setup;
        controller->transfer_one = rzv2m_csi_transfer_one;
        controller->use_gpio_descriptors = true;
 
+       device_set_node(&controller->dev, dev_fwnode(dev));
+
        ret = devm_request_irq(dev, irq, rzv2m_csi_irq_handler, 0,
                               dev_name(dev), csi);
        if (ret)
@@ -635,15 +627,13 @@ static int rzv2m_csi_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int rzv2m_csi_remove(struct platform_device *pdev)
+static void rzv2m_csi_remove(struct platform_device *pdev)
 {
        struct rzv2m_csi_priv *csi = platform_get_drvdata(pdev);
 
        spi_unregister_controller(csi->controller);
        rzv2m_csi_sw_reset(csi, 1);
        clk_disable_unprepare(csi->csiclk);
-
-       return 0;
 }
 
 static const struct of_device_id rzv2m_csi_match[] = {
@@ -654,7 +644,7 @@ MODULE_DEVICE_TABLE(of, rzv2m_csi_match);
 
 static struct platform_driver rzv2m_csi_drv = {
        .probe = rzv2m_csi_probe,
-       .remove = rzv2m_csi_remove,
+       .remove_new = rzv2m_csi_remove,
        .driver = {
                .name = "rzv2m_csi",
                .of_match_table = rzv2m_csi_match,
index b6c2659..bf7cb18 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/pm_runtime.h>
 #include <linux/spi/spi.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 
 #include <linux/platform_data/spi-s3c64xx.h>
 
@@ -1166,14 +1165,9 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
                return dev_err_probe(&pdev->dev, -ENODEV,
                                     "Platform_data missing!\n");
 
-       mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!mem_res)
-               return dev_err_probe(&pdev->dev, -ENXIO,
-                                    "Unable to get SPI MEM resource\n");
-
        irq = platform_get_irq(pdev, 0);
        if (irq < 0)
-               return dev_err_probe(&pdev->dev, irq, "Failed to get IRQ\n");
+               return irq;
 
        master = devm_spi_alloc_master(&pdev->dev, sizeof(*sdd));
        if (!master)
@@ -1187,7 +1181,6 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
        sdd->master = master;
        sdd->cntrlr_info = sci;
        sdd->pdev = pdev;
-       sdd->sfr_start = mem_res->start;
        if (pdev->dev.of_node) {
                ret = of_alias_get_id(pdev->dev.of_node, "spi");
                if (ret < 0)
@@ -1225,9 +1218,10 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
        if (!is_polling(sdd))
                master->can_dma = s3c64xx_spi_can_dma;
 
-       sdd->regs = devm_ioremap_resource(&pdev->dev, mem_res);
+       sdd->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &mem_res);
        if (IS_ERR(sdd->regs))
                return PTR_ERR(sdd->regs);
+       sdd->sfr_start = mem_res->start;
 
        if (sci->cfg_gpio && sci->cfg_gpio())
                return dev_err_probe(&pdev->dev, -EBUSY,
index d52ed67..c67a24d 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/i2c.h>
 #include <linux/delay.h>
 #include <linux/pm_runtime.h>
-#include <linux/of_device.h>
 #include <linux/of.h>
 #include <linux/platform_data/sc18is602.h>
 #include <linux/gpio/consumer.h>
index 9e90b4f..5c75b5c 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/sh_dma.h>
index dae9e09..2f77dae 100644 (file)
@@ -379,7 +379,7 @@ static int sifive_spi_probe(struct platform_device *pdev)
         * we need to "left-align" the bits (unless SPI_LSB_FIRST)
         */
        master->bits_per_word_mask = SPI_BPW_MASK(8);
-       master->flags = SPI_CONTROLLER_MUST_TX | SPI_MASTER_GPIO_SS;
+       master->flags = SPI_CONTROLLER_MUST_TX | SPI_CONTROLLER_GPIO_SS;
        master->prepare_message = sifive_spi_prepare_message;
        master->set_cs = sifive_spi_set_cs;
        master->transfer_one = sifive_spi_transfer_one;
index 4e4d426..6d67729 100644 (file)
@@ -414,7 +414,7 @@ static int mtk_spi_slave_probe(struct platform_device *pdev)
        mdata->dev_comp = of_id->data;
 
        if (mdata->dev_comp->must_rx)
-               ctlr->flags = SPI_MASTER_MUST_RX;
+               ctlr->flags = SPI_CONTROLLER_MUST_RX;
 
        platform_set_drvdata(pdev, ctlr);
 
index d64d3f7..85e4a01 100644 (file)
@@ -10,7 +10,7 @@
 #include <linux/iopoll.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/spi-mem.h>
index 22e39c4..bf01fee 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/reboot.h>
 #include <linux/spi/spi.h>
@@ -580,7 +579,7 @@ static int sprd_adi_probe(struct platform_device *pdev)
        ctlr->dev.of_node = pdev->dev.of_node;
        ctlr->bus_num = pdev->id;
        ctlr->num_chipselect = num_chipselect;
-       ctlr->flags = SPI_MASTER_HALF_DUPLEX;
+       ctlr->flags = SPI_CONTROLLER_HALF_DUPLEX;
        ctlr->bits_per_word_mask = 0;
        ctlr->transfer_one = sprd_adi_transfer_one;
 
index 518c7ea..95377cf 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/of_dma.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
index 2b6804a..def74ae 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/of_gpio.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/pm_runtime.h>
index 6d10fa4..d16ee6e 100644 (file)
@@ -238,6 +238,7 @@ struct stm32_spi;
  * @baud_rate_div_min: minimum baud rate divisor
  * @baud_rate_div_max: maximum baud rate divisor
  * @has_fifo: boolean to know if fifo is used for driver
+ * @has_device_mode: is this compatible capable to switch on device mode
  * @flags: compatible specific SPI controller flags used at registration time
  */
 struct stm32_spi_cfg {
@@ -259,6 +260,7 @@ struct stm32_spi_cfg {
        unsigned int baud_rate_div_min;
        unsigned int baud_rate_div_max;
        bool has_fifo;
+       bool has_device_mode;
        u16 flags;
 };
 
@@ -1750,7 +1752,8 @@ static const struct stm32_spi_cfg stm32f4_spi_cfg = {
        .baud_rate_div_min = STM32F4_SPI_BR_DIV_MIN,
        .baud_rate_div_max = STM32F4_SPI_BR_DIV_MAX,
        .has_fifo = false,
-       .flags = SPI_MASTER_MUST_TX,
+       .has_device_mode = false,
+       .flags = SPI_CONTROLLER_MUST_TX,
 };
 
 static const struct stm32_spi_cfg stm32h7_spi_cfg = {
@@ -1774,6 +1777,7 @@ static const struct stm32_spi_cfg stm32h7_spi_cfg = {
        .baud_rate_div_min = STM32H7_SPI_MBR_DIV_MIN,
        .baud_rate_div_max = STM32H7_SPI_MBR_DIV_MAX,
        .has_fifo = true,
+       .has_device_mode = true,
 };
 
 static const struct of_device_id stm32_spi_of_match[] = {
@@ -1798,8 +1802,13 @@ static int stm32_spi_probe(struct platform_device *pdev)
        struct device_node *np = pdev->dev.of_node;
        bool device_mode;
        int ret;
+       const struct stm32_spi_cfg *cfg = of_device_get_match_data(&pdev->dev);
 
        device_mode = of_property_read_bool(np, "spi-slave");
+       if (!cfg->has_device_mode && device_mode) {
+               dev_err(&pdev->dev, "spi-slave not supported\n");
+               return -EPERM;
+       }
 
        if (device_mode)
                ctrl = devm_spi_alloc_slave(&pdev->dev, sizeof(struct stm32_spi));
@@ -1817,9 +1826,7 @@ static int stm32_spi_probe(struct platform_device *pdev)
        spi->device_mode = device_mode;
        spin_lock_init(&spi->lock);
 
-       spi->cfg = (const struct stm32_spi_cfg *)
-               of_match_device(pdev->dev.driver->of_match_table,
-                               &pdev->dev)->data;
+       spi->cfg = cfg;
 
        spi->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
        if (IS_ERR(spi->base))
@@ -1829,8 +1836,7 @@ static int stm32_spi_probe(struct platform_device *pdev)
 
        spi->irq = platform_get_irq(pdev, 0);
        if (spi->irq <= 0)
-               return dev_err_probe(&pdev->dev, spi->irq,
-                                    "failed to get irq\n");
+               return spi->irq;
 
        ret = devm_request_threaded_irq(&pdev->dev, spi->irq,
                                        spi->cfg->irq_handler_event,
index 30d5416..3f5b155 100644 (file)
@@ -14,7 +14,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/reset.h>
@@ -83,6 +83,9 @@
 #define SUN6I_XMIT_CNT_REG             0x34
 
 #define SUN6I_BURST_CTL_CNT_REG                0x38
+#define SUN6I_BURST_CTL_CNT_STC_MASK           GENMASK(23, 0)
+#define SUN6I_BURST_CTL_CNT_DRM                        BIT(28)
+#define SUN6I_BURST_CTL_CNT_QUAD_EN            BIT(29)
 
 #define SUN6I_TXDATA_REG               0x200
 #define SUN6I_RXDATA_REG               0x300
@@ -90,6 +93,7 @@
 struct sun6i_spi_cfg {
        unsigned long           fifo_depth;
        bool                    has_clk_ctl;
+       u32                     mode_bits;
 };
 
 struct sun6i_spi {
@@ -266,7 +270,7 @@ static int sun6i_spi_transfer_one(struct spi_master *master,
        unsigned int div, div_cdr1, div_cdr2, timeout;
        unsigned int start, end, tx_time;
        unsigned int trig_level;
-       unsigned int tx_len = 0, rx_len = 0;
+       unsigned int tx_len = 0, rx_len = 0, nbits = 0;
        bool use_dma;
        int ret = 0;
        u32 reg;
@@ -418,13 +422,29 @@ static int sun6i_spi_transfer_one(struct spi_master *master,
        sun6i_spi_write(sspi, SUN6I_GBL_CTL_REG, reg);
 
        /* Setup the transfer now... */
-       if (sspi->tx_buf)
+       if (sspi->tx_buf) {
                tx_len = tfr->len;
+               nbits = tfr->tx_nbits;
+       } else if (tfr->rx_buf) {
+               nbits = tfr->rx_nbits;
+       }
+
+       switch (nbits) {
+       case SPI_NBITS_DUAL:
+               reg = SUN6I_BURST_CTL_CNT_DRM;
+               break;
+       case SPI_NBITS_QUAD:
+               reg = SUN6I_BURST_CTL_CNT_QUAD_EN;
+               break;
+       case SPI_NBITS_SINGLE:
+       default:
+               reg = FIELD_PREP(SUN6I_BURST_CTL_CNT_STC_MASK, tx_len);
+       }
 
        /* Setup the counters */
+       sun6i_spi_write(sspi, SUN6I_BURST_CTL_CNT_REG, reg);
        sun6i_spi_write(sspi, SUN6I_BURST_CNT_REG, tfr->len);
        sun6i_spi_write(sspi, SUN6I_XMIT_CNT_REG, tx_len);
-       sun6i_spi_write(sspi, SUN6I_BURST_CTL_CNT_REG, tx_len);
 
        if (!use_dma) {
                /* Fill the TX FIFO */
@@ -623,7 +643,8 @@ static int sun6i_spi_probe(struct platform_device *pdev)
        master->set_cs = sun6i_spi_set_cs;
        master->transfer_one = sun6i_spi_transfer_one;
        master->num_chipselect = 4;
-       master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST;
+       master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST |
+                           sspi->cfg->mode_bits;
        master->bits_per_word_mask = SPI_BPW_MASK(8);
        master->dev.of_node = pdev->dev.of_node;
        master->auto_runtime_pm = true;
@@ -740,6 +761,7 @@ static const struct sun6i_spi_cfg sun8i_h3_spi_cfg = {
 
 static const struct sun6i_spi_cfg sun50i_r329_spi_cfg = {
        .fifo_depth     = SUN8I_FIFO_DEPTH,
+       .mode_bits      = SPI_RX_DUAL | SPI_TX_DUAL | SPI_RX_QUAD | SPI_TX_QUAD,
 };
 
 static const struct of_device_id sun6i_spi_match[] = {
index 488df68..ca4bdd4 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/reset.h>
 #include <linux/spi/spi.h>
 
index 4286310..0c55074 100644 (file)
@@ -455,7 +455,11 @@ static int tegra_sflash_probe(struct platform_device *pdev)
                goto exit_free_master;
        }
 
-       tsd->irq = platform_get_irq(pdev, 0);
+       ret = platform_get_irq(pdev, 0);
+       if (ret < 0)
+               goto exit_free_master;
+       tsd->irq = ret;
+
        ret = request_irq(tsd->irq, tegra_sflash_isr, 0,
                        dev_name(&pdev->dev), tsd);
        if (ret < 0) {
index c2915f7..4d6db61 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/pm_opp.h>
 #include <linux/pm_runtime.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/reset.h>
 #include <linux/spi/spi.h>
 
@@ -1034,18 +1033,12 @@ static int tegra_slink_probe(struct platform_device *pdev)
                                 &master->max_speed_hz))
                master->max_speed_hz = 25000000; /* 25MHz */
 
-       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!r) {
-               dev_err(&pdev->dev, "No IO memory resource\n");
-               ret = -ENODEV;
-               goto exit_free_master;
-       }
-       tspi->phys = r->start;
-       tspi->base = devm_ioremap_resource(&pdev->dev, r);
+       tspi->base = devm_platform_get_and_ioremap_resource(pdev, 0, &r);
        if (IS_ERR(tspi->base)) {
                ret = PTR_ERR(tspi->base);
                goto exit_free_master;
        }
+       tspi->phys = r->start;
 
        /* disabled clock may cause interrupt storm upon request */
        tspi->clk = devm_clk_get(&pdev->dev, NULL);
index fbd14dd..e9ad9b0 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/reset.h>
 #include <linux/spi/spi.h>
 #include <linux/acpi.h>
index 5914335..4c81516 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/slab.h>
 #include <linux/pm_runtime.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
@@ -770,7 +769,7 @@ static int ti_qspi_probe(struct platform_device *pdev)
 
        master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_RX_DUAL | SPI_RX_QUAD;
 
-       master->flags = SPI_MASTER_HALF_DUPLEX;
+       master->flags = SPI_CONTROLLER_HALF_DUPLEX;
        master->setup = ti_qspi_setup;
        master->auto_runtime_pm = true;
        master->transfer_one_message = ti_qspi_start_transfer_one;
index f15312f..852ffe0 100644 (file)
@@ -3,9 +3,8 @@
 
 #include <linux/clk.h>
 #include <linux/mfd/syscon.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
-#include <linux/of_address.h>
-#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/spi/spi-mem.h>
index ae6218b..a3d5755 100644 (file)
@@ -218,7 +218,7 @@ static int spi_xcomm_probe(struct i2c_client *i2c)
        master->num_chipselect = 16;
        master->mode_bits = SPI_CPHA | SPI_CPOL | SPI_3WIRE;
        master->bits_per_word_mask = SPI_BPW_MASK(8);
-       master->flags = SPI_MASTER_HALF_DUPLEX;
+       master->flags = SPI_CONTROLLER_HALF_DUPLEX;
        master->transfer_one_message = spi_xcomm_transfer_one;
        master->dev.of_node = i2c->dev.of_node;
        i2c_set_clientdata(i2c, master);
index 24dc845..dbd85d7 100644 (file)
@@ -87,7 +87,7 @@ static int xtfpga_spi_probe(struct platform_device *pdev)
        if (!master)
                return -ENOMEM;
 
-       master->flags = SPI_MASTER_NO_RX;
+       master->flags = SPI_CONTROLLER_NO_RX;
        master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 16);
        master->bus_num = pdev->dev.id;
        master->dev.of_node = pdev->dev.of_node;
index fb2ca9b..a6b892d 100644 (file)
@@ -14,9 +14,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/module.h>
-#include <linux/of_irq.h>
-#include <linux/of_address.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/spi/spi.h>
index 9291b2a..8d6304c 100644 (file)
@@ -4,36 +4,36 @@
 // Copyright (C) 2005 David Brownell
 // Copyright (C) 2008 Secret Lab Technologies Ltd.
 
-#include <linux/kernel.h>
-#include <linux/device.h>
-#include <linux/init.h>
+#include <linux/acpi.h>
 #include <linux/cache.h>
-#include <linux/dma-mapping.h>
+#include <linux/clk/clk-conf.h>
+#include <linux/delay.h>
+#include <linux/device.h>
 #include <linux/dmaengine.h>
+#include <linux/dma-mapping.h>
+#include <linux/export.h>
+#include <linux/gpio/consumer.h>
+#include <linux/highmem.h>
+#include <linux/idr.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/kernel.h>
+#include <linux/kthread.h>
+#include <linux/mod_devicetable.h>
 #include <linux/mutex.h>
 #include <linux/of_device.h>
 #include <linux/of_irq.h>
-#include <linux/clk/clk-conf.h>
-#include <linux/slab.h>
-#include <linux/mod_devicetable.h>
-#include <linux/spi/spi.h>
-#include <linux/spi/spi-mem.h>
-#include <linux/gpio/consumer.h>
-#include <linux/pm_runtime.h>
+#include <linux/percpu.h>
+#include <linux/platform_data/x86/apple.h>
 #include <linux/pm_domain.h>
+#include <linux/pm_runtime.h>
 #include <linux/property.h>
-#include <linux/export.h>
+#include <linux/ptp_clock_kernel.h>
 #include <linux/sched/rt.h>
+#include <linux/slab.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/spi-mem.h>
 #include <uapi/linux/sched/types.h>
-#include <linux/delay.h>
-#include <linux/kthread.h>
-#include <linux/ioport.h>
-#include <linux/acpi.h>
-#include <linux/highmem.h>
-#include <linux/idr.h>
-#include <linux/platform_data/x86/apple.h>
-#include <linux/ptp_clock_kernel.h>
-#include <linux/percpu.h>
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/spi.h>
@@ -64,7 +64,7 @@ modalias_show(struct device *dev, struct device_attribute *a, char *buf)
        if (len != -ENODEV)
                return len;
 
-       return sprintf(buf, "%s%s\n", SPI_MODULE_PREFIX, spi->modalias);
+       return sysfs_emit(buf, "%s%s\n", SPI_MODULE_PREFIX, spi->modalias);
 }
 static DEVICE_ATTR_RO(modalias);
 
@@ -89,7 +89,7 @@ static ssize_t driver_override_show(struct device *dev,
        ssize_t len;
 
        device_lock(dev);
-       len = snprintf(buf, PAGE_SIZE, "%s\n", spi->driver_override ? : "");
+       len = sysfs_emit(buf, "%s\n", spi->driver_override ? : "");
        device_unlock(dev);
        return len;
 }
@@ -631,6 +631,16 @@ static int __spi_add_device(struct spi_device *spi)
        struct device *dev = ctlr->dev.parent;
        int status;
 
+       /* Chipselects are numbered 0..max; validate. */
+       if (spi_get_chipselect(spi, 0) >= ctlr->num_chipselect) {
+               dev_err(dev, "cs%d >= max %d\n", spi_get_chipselect(spi, 0),
+                       ctlr->num_chipselect);
+               return -EINVAL;
+       }
+
+       /* Set the bus ID string */
+       spi_dev_set_name(spi);
+
        /*
         * We need to make sure there's no other device with this
         * chipselect **BEFORE** we call setup(), else we'll trash
@@ -682,26 +692,15 @@ static int __spi_add_device(struct spi_device *spi)
  * @spi: spi_device to register
  *
  * Companion function to spi_alloc_device.  Devices allocated with
- * spi_alloc_device can be added onto the spi bus with this function.
+ * spi_alloc_device can be added onto the SPI bus with this function.
  *
  * Return: 0 on success; negative errno on failure
  */
 int spi_add_device(struct spi_device *spi)
 {
        struct spi_controller *ctlr = spi->controller;
-       struct device *dev = ctlr->dev.parent;
        int status;
 
-       /* Chipselects are numbered 0..max; validate. */
-       if (spi_get_chipselect(spi, 0) >= ctlr->num_chipselect) {
-               dev_err(dev, "cs%d >= max %d\n", spi_get_chipselect(spi, 0),
-                       ctlr->num_chipselect);
-               return -EINVAL;
-       }
-
-       /* Set the bus ID string */
-       spi_dev_set_name(spi);
-
        mutex_lock(&ctlr->add_lock);
        status = __spi_add_device(spi);
        mutex_unlock(&ctlr->add_lock);
@@ -709,25 +708,6 @@ int spi_add_device(struct spi_device *spi)
 }
 EXPORT_SYMBOL_GPL(spi_add_device);
 
-static int spi_add_device_locked(struct spi_device *spi)
-{
-       struct spi_controller *ctlr = spi->controller;
-       struct device *dev = ctlr->dev.parent;
-
-       /* Chipselects are numbered 0..max; validate. */
-       if (spi_get_chipselect(spi, 0) >= ctlr->num_chipselect) {
-               dev_err(dev, "cs%d >= max %d\n", spi_get_chipselect(spi, 0),
-                       ctlr->num_chipselect);
-               return -EINVAL;
-       }
-
-       /* Set the bus ID string */
-       spi_dev_set_name(spi);
-
-       WARN_ON(!mutex_is_locked(&ctlr->add_lock));
-       return __spi_add_device(spi);
-}
-
 /**
  * spi_new_device - instantiate one new SPI device
  * @ctlr: Controller to which device is connected
@@ -889,7 +869,7 @@ int spi_register_board_info(struct spi_board_info const *info, unsigned n)
  * spi_res_alloc - allocate a spi resource that is life-cycle managed
  *                 during the processing of a spi_message while using
  *                 spi_transfer_one
- * @spi:     the spi device for which we allocate memory
+ * @spi:     the SPI device for which we allocate memory
  * @release: the release code to execute for this resource
  * @size:    size to alloc and return
  * @gfp:     GFP allocation flags
@@ -915,7 +895,7 @@ static void *spi_res_alloc(struct spi_device *spi, spi_res_release_t release,
 }
 
 /**
- * spi_res_free - free an spi resource
+ * spi_res_free - free an SPI resource
  * @res: pointer to the custom data of a resource
  */
 static void spi_res_free(void *res)
@@ -931,7 +911,7 @@ static void spi_res_free(void *res)
 
 /**
  * spi_res_add - add a spi_res to the spi_message
- * @message: the spi message
+ * @message: the SPI message
  * @res:     the spi_resource
  */
 static void spi_res_add(struct spi_message *message, void *res)
@@ -943,7 +923,7 @@ static void spi_res_add(struct spi_message *message, void *res)
 }
 
 /**
- * spi_res_release - release all spi resources for this message
+ * spi_res_release - release all SPI resources for this message
  * @ctlr:  the @spi_controller
  * @message: the @spi_message
  */
@@ -1006,7 +986,7 @@ static void spi_set_cs(struct spi_device *spi, bool enable, bool force)
                                gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), activate);
                }
                /* Some SPI masters need both GPIO CS & slave_select */
-               if ((spi->controller->flags & SPI_MASTER_GPIO_SS) &&
+               if ((spi->controller->flags & SPI_CONTROLLER_GPIO_SS) &&
                    spi->controller->set_cs)
                        spi->controller->set_cs(spi, !enable);
        } else if (spi->controller->set_cs) {
@@ -1424,7 +1404,7 @@ int spi_delay_to_ns(struct spi_delay *_delay, struct spi_transfer *xfer)
                        return -EINVAL;
                /*
                 * If there is unknown effective speed, approximate it
-                * by underestimating with half of the requested hz.
+                * by underestimating with half of the requested Hz.
                 */
                hz = xfer->effective_speed_hz ?: xfer->speed_hz / 2;
                if (!hz)
@@ -1739,11 +1719,11 @@ static int __spi_pump_transfer_message(struct spi_controller *ctlr,
 }
 
 /**
- * __spi_pump_messages - function which processes spi message queue
+ * __spi_pump_messages - function which processes SPI message queue
  * @ctlr: controller to process queue for
  * @in_kthread: true if we are in the context of the message pump thread
  *
- * This function checks if there is any spi message in the queue that
+ * This function checks if there is any SPI message in the queue that
  * needs processing and if so call out to the driver to initialize hardware
  * and transfer each message.
  *
@@ -1758,7 +1738,7 @@ static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread)
        unsigned long flags;
        int ret;
 
-       /* Take the IO mutex */
+       /* Take the I/O mutex */
        mutex_lock(&ctlr->io_mutex);
 
        /* Lock queue */
@@ -2169,8 +2149,8 @@ static int __spi_queued_transfer(struct spi_device *spi,
 
 /**
  * spi_queued_transfer - transfer function for queued transfers
- * @spi: spi device which is requesting transfer
- * @msg: spi message which is to handled is queued to driver queue
+ * @spi: SPI device which is requesting transfer
+ * @msg: SPI message which is to handled is queued to driver queue
  *
  * Return: zero on success, else a negative error code.
  */
@@ -2399,9 +2379,6 @@ static void of_register_spi_devices(struct spi_controller *ctlr)
        struct spi_device *spi;
        struct device_node *nc;
 
-       if (!ctlr->dev.of_node)
-               return;
-
        for_each_available_child_of_node(ctlr->dev.of_node, nc) {
                if (of_node_test_and_set_flag(nc, OF_POPULATED))
                        continue;
@@ -2432,11 +2409,12 @@ static void of_register_spi_devices(struct spi_controller *ctlr) { }
 struct spi_device *spi_new_ancillary_device(struct spi_device *spi,
                                             u8 chip_select)
 {
+       struct spi_controller *ctlr = spi->controller;
        struct spi_device *ancillary;
        int rc = 0;
 
        /* Alloc an spi_device */
-       ancillary = spi_alloc_device(spi->controller);
+       ancillary = spi_alloc_device(ctlr);
        if (!ancillary) {
                rc = -ENOMEM;
                goto err_out;
@@ -2451,8 +2429,10 @@ struct spi_device *spi_new_ancillary_device(struct spi_device *spi,
        ancillary->max_speed_hz = spi->max_speed_hz;
        ancillary->mode = spi->mode;
 
+       WARN_ON(!mutex_is_locked(&ctlr->add_lock));
+
        /* Register the new device */
-       rc = spi_add_device_locked(ancillary);
+       rc = __spi_add_device(ancillary);
        if (rc) {
                dev_err(&spi->dev, "failed to register ancillary device\n");
                goto err_out;
@@ -2499,7 +2479,7 @@ static int acpi_spi_count(struct acpi_resource *ares, void *data)
  * acpi_spi_count_resources - Count the number of SpiSerialBus resources
  * @adev:      ACPI device
  *
- * Returns the number of SpiSerialBus resources in the ACPI-device's
+ * Return: the number of SpiSerialBus resources in the ACPI-device's
  * resource-list; or a negative error code.
  */
 int acpi_spi_count_resources(struct acpi_device *adev)
@@ -2633,10 +2613,10 @@ static int acpi_spi_add_resource(struct acpi_resource *ares, void *data)
  * @adev: ACPI Device for the spi device
  * @index: Index of the spi resource inside the ACPI Node
  *
- * This should be used to allocate a new spi device from and ACPI Node.
- * The caller is responsible for calling spi_add_device to register the spi device.
+ * This should be used to allocate a new SPI device from and ACPI Device node.
+ * The caller is responsible for calling spi_add_device to register the SPI device.
  *
- * If ctlr is set to NULL, the Controller for the spi device will be looked up
+ * If ctlr is set to NULL, the Controller for the SPI device will be looked up
  * using the resource.
  * If index is set to -1, index is not used.
  * Note: If index is -1, ctlr must be set.
@@ -2817,8 +2797,7 @@ static ssize_t slave_show(struct device *dev, struct device_attribute *attr,
        struct device *child;
 
        child = device_find_any_child(&ctlr->dev);
-       return sprintf(buf, "%s\n",
-                      child ? to_spi_device(child)->modalias : NULL);
+       return sysfs_emit(buf, "%s\n", child ? to_spi_device(child)->modalias : NULL);
 }
 
 static ssize_t slave_store(struct device *dev, struct device_attribute *attr,
@@ -3056,7 +3035,7 @@ static int spi_get_gpio_descs(struct spi_controller *ctlr)
 
        ctlr->unused_native_cs = ffs(~native_cs_mask) - 1;
 
-       if ((ctlr->flags & SPI_MASTER_GPIO_SS) && num_cs_gpios &&
+       if ((ctlr->flags & SPI_CONTROLLER_GPIO_SS) && num_cs_gpios &&
            ctlr->max_native_cs && ctlr->unused_native_cs >= ctlr->max_native_cs) {
                dev_err(dev, "No unused native chip select available\n");
                return -EINVAL;
@@ -3084,6 +3063,20 @@ static int spi_controller_check_ops(struct spi_controller *ctlr)
        return 0;
 }
 
+/* Allocate dynamic bus number using Linux idr */
+static int spi_controller_id_alloc(struct spi_controller *ctlr, int start, int end)
+{
+       int id;
+
+       mutex_lock(&board_lock);
+       id = idr_alloc(&spi_master_idr, ctlr, start, end, GFP_KERNEL);
+       mutex_unlock(&board_lock);
+       if (WARN(id < 0, "couldn't get idr"))
+               return id == -ENOSPC ? -EBUSY : id;
+       ctlr->bus_num = id;
+       return 0;
+}
+
 /**
  * spi_register_controller - register SPI master or slave controller
  * @ctlr: initialized master, originally from spi_alloc_master() or
@@ -3111,8 +3104,8 @@ int spi_register_controller(struct spi_controller *ctlr)
 {
        struct device           *dev = ctlr->dev.parent;
        struct boardinfo        *bi;
+       int                     first_dynamic;
        int                     status;
-       int                     id, first_dynamic;
 
        if (!dev)
                return -ENODEV;
@@ -3125,27 +3118,13 @@ int spi_register_controller(struct spi_controller *ctlr)
        if (status)
                return status;
 
+       if (ctlr->bus_num < 0)
+               ctlr->bus_num = of_alias_get_id(ctlr->dev.of_node, "spi");
        if (ctlr->bus_num >= 0) {
                /* Devices with a fixed bus num must check-in with the num */
-               mutex_lock(&board_lock);
-               id = idr_alloc(&spi_master_idr, ctlr, ctlr->bus_num,
-                       ctlr->bus_num + 1, GFP_KERNEL);
-               mutex_unlock(&board_lock);
-               if (WARN(id < 0, "couldn't get idr"))
-                       return id == -ENOSPC ? -EBUSY : id;
-               ctlr->bus_num = id;
-       } else if (ctlr->dev.of_node) {
-               /* Allocate dynamic bus number using Linux idr */
-               id = of_alias_get_id(ctlr->dev.of_node, "spi");
-               if (id >= 0) {
-                       ctlr->bus_num = id;
-                       mutex_lock(&board_lock);
-                       id = idr_alloc(&spi_master_idr, ctlr, ctlr->bus_num,
-                                      ctlr->bus_num + 1, GFP_KERNEL);
-                       mutex_unlock(&board_lock);
-                       if (WARN(id < 0, "couldn't get idr"))
-                               return id == -ENOSPC ? -EBUSY : id;
-               }
+               status = spi_controller_id_alloc(ctlr, ctlr->bus_num, ctlr->bus_num + 1);
+               if (status)
+                       return status;
        }
        if (ctlr->bus_num < 0) {
                first_dynamic = of_alias_get_highest_id("spi");
@@ -3154,13 +3133,9 @@ int spi_register_controller(struct spi_controller *ctlr)
                else
                        first_dynamic++;
 
-               mutex_lock(&board_lock);
-               id = idr_alloc(&spi_master_idr, ctlr, first_dynamic,
-                              0, GFP_KERNEL);
-               mutex_unlock(&board_lock);
-               if (WARN(id < 0, "couldn't get idr"))
-                       return id;
-               ctlr->bus_num = id;
+               status = spi_controller_id_alloc(ctlr, first_dynamic, 0);
+               if (status)
+                       return status;
        }
        ctlr->bus_lock_flag = 0;
        init_completion(&ctlr->xfer_completion);
@@ -3339,7 +3314,8 @@ void spi_unregister_controller(struct spi_controller *ctlr)
        if (IS_ENABLED(CONFIG_SPI_DYNAMIC))
                mutex_unlock(&ctlr->add_lock);
 
-       /* Release the last reference on the controller if its driver
+       /*
+        * Release the last reference on the controller if its driver
         * has not yet been converted to devm_spi_alloc_master/slave().
         */
        if (!ctlr->devm_allocated)
@@ -3552,7 +3528,7 @@ static int __spi_split_transfer_maxsize(struct spi_controller *ctlr,
 
        /* All the others need rx_buf/tx_buf also set */
        for (i = 1, offset = maxsize; i < count; offset += maxsize, i++) {
-               /* Update rx_buf, tx_buf and dma */
+               /* Update rx_buf, tx_buf and DMA */
                if (xfers[i].rx_buf)
                        xfers[i].rx_buf += offset;
                if (xfers[i].rx_dma)
@@ -3622,7 +3598,7 @@ EXPORT_SYMBOL_GPL(spi_split_transfers_maxsize);
 
 
 /**
- * spi_split_transfers_maxwords - split spi transfers into multiple transfers
+ * spi_split_transfers_maxwords - split SPI transfers into multiple transfers
  *                                when an individual transfer exceeds a
  *                                certain number of SPI words
  * @ctlr:     the @spi_controller for this transfer
@@ -3650,13 +3626,7 @@ int spi_split_transfers_maxwords(struct spi_controller *ctlr,
                size_t maxsize;
                int ret;
 
-               if (xfer->bits_per_word <= 8)
-                       maxsize = maxwords;
-               else if (xfer->bits_per_word <= 16)
-                       maxsize = 2 * maxwords;
-               else
-                       maxsize = 4 * maxwords;
-
+               maxsize = maxwords * roundup_pow_of_two(BITS_TO_BYTES(xfer->bits_per_word));
                if (xfer->len > maxsize) {
                        ret = __spi_split_transfer_maxsize(ctlr, msg, &xfer,
                                                           maxsize, gfp);
@@ -3671,7 +3641,8 @@ EXPORT_SYMBOL_GPL(spi_split_transfers_maxwords);
 
 /*-------------------------------------------------------------------------*/
 
-/* Core methods for SPI controller protocol drivers.  Some of the
+/*
+ * Core methods for SPI controller protocol drivers. Some of the
  * other core methods are currently defined as inline functions.
  */
 
@@ -3731,7 +3702,7 @@ static int spi_set_cs_timing(struct spi_device *spi)
  * changes those settings, and must be called from a context that can sleep.
  * Except for SPI_CS_HIGH, which takes effect immediately, the changes take
  * effect the next time the device is selected and data is transferred to
- * or from it.  When this function returns, the spi device is deselected.
+ * or from it.  When this function returns, the SPI device is deselected.
  *
  * Note that this call will fail if the protocol driver specifies an option
  * that the underlying controller or its driver does not support.  For
@@ -3906,11 +3877,9 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
         */
        if ((spi->mode & SPI_CS_WORD) && (!(ctlr->mode_bits & SPI_CS_WORD) ||
                                          spi_get_csgpiod(spi, 0))) {
-               size_t maxsize;
+               size_t maxsize = BITS_TO_BYTES(spi->bits_per_word);
                int ret;
 
-               maxsize = (spi->bits_per_word + 7) / 8;
-
                /* spi_split_transfers_maxsize() requires message->spi */
                message->spi = spi;
 
@@ -4071,7 +4040,7 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message)
  * spi_async - asynchronous SPI transfer
  * @spi: device with which data will be exchanged
  * @message: describes the data transfers, including completion callback
- * Context: any (irqs may be blocked, etc)
+ * Context: any (IRQs may be blocked, etc)
  *
  * This call may be used in_irq and other contexts which can't sleep,
  * as well as from task contexts which can sleep.
@@ -4125,7 +4094,7 @@ EXPORT_SYMBOL_GPL(spi_async);
  * spi_async_locked - version of spi_async with exclusive bus usage
  * @spi: device with which data will be exchanged
  * @message: describes the data transfers, including completion callback
- * Context: any (irqs may be blocked, etc)
+ * Context: any (IRQs may be blocked, etc)
  *
  * This call may be used in_irq and other contexts which can't sleep,
  * as well as from task contexts which can sleep.
@@ -4388,9 +4357,9 @@ static u8 *buf;
 /**
  * spi_write_then_read - SPI synchronous write followed by read
  * @spi: device with which data will be exchanged
- * @txbuf: data to be written (need not be dma-safe)
+ * @txbuf: data to be written (need not be DMA-safe)
  * @n_tx: size of txbuf, in bytes
- * @rxbuf: buffer into which data will be read (need not be dma-safe)
+ * @rxbuf: buffer into which data will be read (need not be DMA-safe)
  * @n_rx: size of rxbuf, in bytes
  * Context: can sleep
  *
@@ -4401,7 +4370,7 @@ static u8 *buf;
  *
  * Parameters to this routine are always copied using a small buffer.
  * Performance-sensitive or bulk transfer code should instead use
- * spi_{async,sync}() calls with dma-safe buffers.
+ * spi_{async,sync}() calls with DMA-safe buffers.
  *
  * Return: zero on success, else a negative error code.
  */
@@ -4446,7 +4415,7 @@ int spi_write_then_read(struct spi_device *spi,
        x[0].tx_buf = local_buf;
        x[1].rx_buf = local_buf + n_tx;
 
-       /* Do the i/o */
+       /* Do the I/O */
        status = spi_sync(spi, &message);
        if (status == 0)
                memcpy(rxbuf, x[1].rx_buf, n_rx);
index 32c94ea..7f8b478 100644 (file)
@@ -6,18 +6,19 @@
 #ifndef __LINUX_SPI_H
 #define __LINUX_SPI_H
 
+#include <linux/acpi.h>
 #include <linux/bits.h>
+#include <linux/completion.h>
 #include <linux/device.h>
-#include <linux/mod_devicetable.h>
-#include <linux/slab.h>
+#include <linux/gpio/consumer.h>
 #include <linux/kthread.h>
-#include <linux/completion.h>
+#include <linux/mod_devicetable.h>
+#include <linux/overflow.h>
 #include <linux/scatterlist.h>
-#include <linux/gpio/consumer.h>
+#include <linux/slab.h>
+#include <linux/u64_stats_sync.h>
 
 #include <uapi/linux/spi/spi.h>
-#include <linux/acpi.h>
-#include <linux/u64_stats_sync.h>
 
 struct dma_chan;
 struct software_node;
@@ -36,7 +37,7 @@ extern struct bus_type spi_bus_type;
 
 /**
  * struct spi_statistics - statistics for spi transfers
- * @syncp:         seqcount to protect members in this struct for per-cpu udate
+ * @syncp:         seqcount to protect members in this struct for per-cpu update
  *                 on 32-bit systems
  *
  * @messages:      number of spi-messages handled
@@ -55,7 +56,7 @@ extern struct bus_type spi_bus_type;
  * @bytes_rx:      number of bytes received from device
  *
  * @transfer_bytes_histo:
- *                 transfer bytes histogramm
+ *                 transfer bytes histogram
  *
  * @transfers_split_maxsize:
  *                 number of transfers that have been split because of
@@ -156,7 +157,7 @@ extern void spi_transfer_cs_change_delay_exec(struct spi_message *msg,
  *     the device will bind to the named driver and only the named driver.
  *     Do not set directly, because core frees it; use driver_set_override() to
  *     set or clear it.
- * @cs_gpiod: gpio descriptor of the chipselect line (optional, NULL when
+ * @cs_gpiod: GPIO descriptor of the chipselect line (optional, NULL when
  *     not using a GPIO line)
  * @word_delay: delay to be inserted between consecutive
  *     words of a transfer
@@ -212,7 +213,7 @@ struct spi_device {
        void                    *controller_data;
        char                    modalias[SPI_NAME_SIZE];
        const char              *driver_override;
-       struct gpio_desc        *cs_gpiod;      /* Chip select gpio desc */
+       struct gpio_desc        *cs_gpiod;      /* Chip select GPIO descriptor */
        struct spi_delay        word_delay; /* Inter-word delay */
        /* CS delays */
        struct spi_delay        cs_setup;
@@ -223,7 +224,7 @@ struct spi_device {
        struct spi_statistics __percpu  *pcpu_statistics;
 
        /*
-        * likely need more hooks for more protocol options affecting how
+        * Likely need more hooks for more protocol options affecting how
         * the controller talks to each chip, like:
         *  - memory packing (12 bit samples into low bits, others zeroed)
         *  - priority
@@ -299,11 +300,11 @@ static inline void spi_set_csgpiod(struct spi_device *spi, u8 idx, struct gpio_d
 /**
  * struct spi_driver - Host side "protocol" driver
  * @id_table: List of SPI devices supported by this driver
- * @probe: Binds this driver to the spi device.  Drivers can verify
+ * @probe: Binds this driver to the SPI device.  Drivers can verify
  *     that the device is actually present, and may need to configure
  *     characteristics (such as bits_per_word) which weren't needed for
  *     the initial configuration done during system setup.
- * @remove: Unbinds this driver from the spi device
+ * @remove: Unbinds this driver from the SPI device
  * @shutdown: Standard shutdown callback used during system state
  *     transitions such as powerdown/halt and kexec
  * @driver: SPI device drivers should initialize the name and owner
@@ -415,7 +416,7 @@ extern struct spi_device *spi_new_ancillary_device(struct spi_device *spi, u8 ch
  * @queued: whether this controller is providing an internal message queue
  * @kworker: pointer to thread struct for message pump
  * @pump_messages: work struct for scheduling work to the message pump
- * @queue_lock: spinlock to syncronise access to message queue
+ * @queue_lock: spinlock to synchronise access to message queue
  * @queue: message queue
  * @cur_msg: the currently in-flight message
  * @cur_msg_completion: a completion for the current in-flight message
@@ -473,7 +474,7 @@ extern struct spi_device *spi_new_ancillary_device(struct spi_device *spi, u8 ch
  * @unprepare_message: undo any work done by prepare_message().
  * @slave_abort: abort the ongoing transfer request on an SPI slave controller
  * @target_abort: abort the ongoing transfer request on an SPI target controller
- * @cs_gpiods: Array of GPIO descs to use as chip select lines; one per CS
+ * @cs_gpiods: Array of GPIO descriptors to use as chip select lines; one per CS
  *     number. Any individual value may be NULL for CS lines that
  *     are not GPIOs (driven by the SPI controller itself).
  * @use_gpio_descriptors: Turns on the code in the SPI core to parse and grab
@@ -500,7 +501,7 @@ extern struct spi_device *spi_new_ancillary_device(struct spi_device *spi, u8 ch
  *     If the driver does not set this, the SPI core takes the snapshot as
  *     close to the driver hand-over as possible.
  * @irq_flags: Interrupt enable state during PTP system timestamping
- * @fallback: fallback to pio if dma transfer return failure with
+ * @fallback: fallback to PIO if DMA transfer return failure with
  *     SPI_TRANS_FAIL_NO_START.
  * @queue_empty: signal green light for opportunistically skipping the queue
  *     for spi_sync transfers.
@@ -522,15 +523,17 @@ struct spi_controller {
 
        struct list_head list;
 
-       /* Other than negative (== assign one dynamically), bus_num is fully
-        * board-specific.  usually that simplifies to being SOC-specific.
-        * example:  one SOC has three SPI controllers, numbered 0..2,
-        * and one board's schematics might show it using SPI-2.  software
+       /*
+        * Other than negative (== assign one dynamically), bus_num is fully
+        * board-specific. Usually that simplifies to being SoC-specific.
+        * example: one SoC has three SPI controllers, numbered 0..2,
+        * and one board's schematics might show it using SPI-2. Software
         * would normally use bus_num=2 for that controller.
         */
        s16                     bus_num;
 
-       /* chipselects will be integral to many controllers; some others
+       /*
+        * Chipselects will be integral to many controllers; some others
         * might use board-specific GPIOs.
         */
        u16                     num_chipselect;
@@ -562,8 +565,7 @@ struct spi_controller {
 #define SPI_CONTROLLER_NO_TX           BIT(2)  /* Can't do buffer write */
 #define SPI_CONTROLLER_MUST_RX         BIT(3)  /* Requires rx */
 #define SPI_CONTROLLER_MUST_TX         BIT(4)  /* Requires tx */
-
-#define SPI_MASTER_GPIO_SS             BIT(5)  /* GPIO CS must select slave */
+#define SPI_CONTROLLER_GPIO_SS         BIT(5)  /* GPIO CS must select slave */
 
        /* Flag indicating if the allocation of this struct is devres-managed */
        bool                    devm_allocated;
@@ -576,8 +578,8 @@ struct spi_controller {
        };
 
        /*
-        * on some hardware transfer / message size may be constrained
-        * the limit may depend on device transfer settings
+        * On some hardware transfer / message size may be constrained
+        * the limit may depend on device transfer settings.
         */
        size_t (*max_transfer_size)(struct spi_device *spi);
        size_t (*max_message_size)(struct spi_device *spi);
@@ -595,7 +597,8 @@ struct spi_controller {
        /* Flag indicating that the SPI bus is locked for exclusive use */
        bool                    bus_lock_flag;
 
-       /* Setup mode and clock, etc (spi driver may call many times).
+       /*
+        * Setup mode and clock, etc (SPI driver may call many times).
         *
         * IMPORTANT:  this may be called when transfers to another
         * device are active.  DO NOT UPDATE SHARED REGISTERS in ways
@@ -613,18 +616,19 @@ struct spi_controller {
         */
        int (*set_cs_timing)(struct spi_device *spi);
 
-       /* Bidirectional bulk transfers
+       /*
+        * Bidirectional bulk transfers
         *
         * + The transfer() method may not sleep; its main role is
         *   just to add the message to the queue.
         * + For now there's no remove-from-queue operation, or
         *   any other request management
-        * + To a given spi_device, message queueing is pure fifo
+        * + To a given spi_device, message queueing is pure FIFO
         *
         * + The controller's main job is to process its message queue,
         *   selecting a chip (for masters), then transferring data
         * + If there are multiple spi_device children, the i/o queue
-        *   arbitration algorithm is unspecified (round robin, fifo,
+        *   arbitration algorithm is unspecified (round robin, FIFO,
         *   priority, reservations, preemption, etc)
         *
         * + Chipselect stays active during the entire message
@@ -705,7 +709,7 @@ struct spi_controller {
        const struct spi_controller_mem_ops *mem_ops;
        const struct spi_controller_mem_caps *mem_caps;
 
-       /* gpio chip select */
+       /* GPIO chip select */
        struct gpio_desc        **cs_gpiods;
        bool                    use_gpio_descriptors;
        s8                      unused_native_cs;
@@ -789,7 +793,7 @@ void spi_take_timestamp_post(struct spi_controller *ctlr,
                             struct spi_transfer *xfer,
                             size_t progress, bool irqs_off);
 
-/* The spi driver core manages memory for the spi_controller classdev */
+/* The SPI driver core manages memory for the spi_controller classdev */
 extern struct spi_controller *__spi_alloc_controller(struct device *host,
                                                unsigned int size, bool slave);
 
@@ -878,13 +882,13 @@ typedef void (*spi_res_release_t)(struct spi_controller *ctlr,
                                  void *res);
 
 /**
- * struct spi_res - spi resource management structure
+ * struct spi_res - SPI resource management structure
  * @entry:   list entry
  * @release: release code called prior to freeing this resource
  * @data:    extra data allocated for the specific use-case
  *
- * this is based on ideas from devres, but focused on life-cycle
- * management during spi_message processing
+ * This is based on ideas from devres, but focused on life-cycle
+ * management during spi_message processing.
  */
 struct spi_res {
        struct list_head        entry;
@@ -902,7 +906,7 @@ struct spi_res {
  *
  * The spi_messages themselves consist of a series of read+write transfer
  * segments.  Those segments always read the same number of bits as they
- * write; but one or the other is easily ignored by passing a null buffer
+ * write; but one or the other is easily ignored by passing a NULL buffer
  * pointer.  (This is unlike most types of I/O API, because SPI hardware
  * is full duplex.)
  *
@@ -913,8 +917,8 @@ struct spi_res {
 
 /**
  * struct spi_transfer - a read/write buffer pair
- * @tx_buf: data to be written (dma-safe memory), or NULL
- * @rx_buf: data to be read (dma-safe memory), or NULL
+ * @tx_buf: data to be written (DMA-safe memory), or NULL
+ * @rx_buf: data to be read (DMA-safe memory), or NULL
  * @tx_dma: DMA address of tx_buf, if @spi_message.is_dma_mapped
  * @rx_dma: DMA address of rx_buf, if @spi_message.is_dma_mapped
  * @tx_nbits: number of bits used for writing. If 0 the default
@@ -937,7 +941,7 @@ struct spi_res {
  * @word_delay: inter word delay to be introduced after each word size
  *     (set by bits_per_word) transmission.
  * @effective_speed_hz: the effective SCK-speed that was used to
- *      transfer this transfer. Set to 0 if the spi bus driver does
+ *      transfer this transfer. Set to 0 if the SPI bus driver does
  *      not support it.
  * @transfer_list: transfers are sequenced through @spi_message.transfers
  * @tx_sg: Scatterlist for transmit, currently not for client use
@@ -966,16 +970,16 @@ struct spi_res {
  *     transmitting the "pre" word, and the "post" timestamp after receiving
  *     transmit confirmation from the controller for the "post" word.
  * @timestamped: true if the transfer has been timestamped
- * @error: Error status logged by spi controller driver.
+ * @error: Error status logged by SPI controller driver.
  *
  * SPI transfers always write the same number of bytes as they read.
  * Protocol drivers should always provide @rx_buf and/or @tx_buf.
  * In some cases, they may also want to provide DMA addresses for
  * the data being transferred; that may reduce overhead, when the
- * underlying driver uses dma.
+ * underlying driver uses DMA.
  *
- * If the transmit buffer is null, zeroes will be shifted out
- * while filling @rx_buf.  If the receive buffer is null, the data
+ * If the transmit buffer is NULL, zeroes will be shifted out
+ * while filling @rx_buf.  If the receive buffer is NULL, the data
  * shifted in will be discarded.  Only "len" bytes shift out (or in).
  * It's an error to try to shift out a partial word.  (For example, by
  * shifting out three bytes with word size of sixteen or twenty bits;
@@ -1009,7 +1013,7 @@ struct spi_res {
  * Some devices need protocol transactions to be built from a series of
  * spi_message submissions, where the content of one message is determined
  * by the results of previous messages and where the whole transaction
- * ends when the chipselect goes intactive.
+ * ends when the chipselect goes inactive.
  *
  * When SPI can transfer in 1x,2x or 4x. It can get this transfer information
  * from device through @tx_nbits and @rx_nbits. In Bi-direction, these
@@ -1023,10 +1027,11 @@ struct spi_res {
  * and its transfers, ignore them until its completion callback.
  */
 struct spi_transfer {
-       /* It's ok if tx_buf == rx_buf (right?)
-        * for MicroWire, one buffer must be null
-        * buffers must work with dma_*map_single() calls, unless
-        *   spi_message.is_dma_mapped reports a pre-existing mapping
+       /*
+        * It's okay if tx_buf == rx_buf (right?).
+        * For MicroWire, one buffer must be NULL.
+        * Buffers must work with dma_*map_single() calls, unless
+        * spi_message.is_dma_mapped reports a pre-existing mapping.
         */
        const void      *tx_buf;
        void            *rx_buf;
@@ -1046,9 +1051,9 @@ struct spi_transfer {
        unsigned        tx_nbits:3;
        unsigned        rx_nbits:3;
        unsigned        timestamped:1;
-#define        SPI_NBITS_SINGLE        0x01 /* 1bit transfer */
-#define        SPI_NBITS_DUAL          0x02 /* 2bits transfer */
-#define        SPI_NBITS_QUAD          0x04 /* 4bits transfer */
+#define        SPI_NBITS_SINGLE        0x01 /* 1-bit transfer */
+#define        SPI_NBITS_DUAL          0x02 /* 2-bit transfer */
+#define        SPI_NBITS_QUAD          0x04 /* 4-bit transfer */
        u8              bits_per_word;
        struct spi_delay        delay;
        struct spi_delay        cs_change_delay;
@@ -1069,7 +1074,7 @@ struct spi_transfer {
  * struct spi_message - one multi-segment SPI transaction
  * @transfers: list of transfer segments in this transaction
  * @spi: SPI device to which the transaction is queued
- * @is_dma_mapped: if true, the caller provided both dma and cpu virtual
+ * @is_dma_mapped: if true, the caller provided both DMA and CPU virtual
  *     addresses for each transfer buffer
  * @complete: called to report transaction completions
  * @context: the argument to complete() when it's called
@@ -1079,8 +1084,10 @@ struct spi_transfer {
  * @status: zero for success, else negative errno
  * @queue: for use by whichever driver currently owns the message
  * @state: for use by whichever driver currently owns the message
- * @resources: for resource management when the spi message is processed
+ * @resources: for resource management when the SPI message is processed
  * @prepared: spi_prepare_message was called for the this message
+ * @t: for use with spi_message_alloc() when message and transfers have
+ *     been allocated together
  *
  * A @spi_message is used to execute an atomic sequence of data transfers,
  * each represented by a struct spi_transfer.  The sequence is "atomic"
@@ -1106,7 +1113,8 @@ struct spi_message {
        /* spi_prepare_message() was called for this message */
        bool                    prepared;
 
-       /* REVISIT:  we might want a flag affecting the behavior of the
+       /*
+        * REVISIT: we might want a flag affecting the behavior of the
         * last transfer ... allowing things like "read 16 bit length L"
         * immediately followed by "read L bytes".  Basically imposing
         * a specific message scheduling algorithm.
@@ -1124,15 +1132,19 @@ struct spi_message {
        unsigned                frame_length;
        unsigned                actual_length;
 
-       /* For optional use by whatever driver currently owns the
+       /*
+        * For optional use by whatever driver currently owns the
         * spi_message ...  between calls to spi_async and then later
         * complete(), that's the spi_controller controller driver.
         */
        struct list_head        queue;
        void                    *state;
 
-       /* List of spi_res reources when the spi message is processed */
+       /* List of spi_res resources when the SPI message is processed */
        struct list_head        resources;
+
+       /* For embedding transfers into the memory of the message */
+       struct spi_transfer     t[];
 };
 
 static inline void spi_message_init_no_memset(struct spi_message *m)
@@ -1168,7 +1180,7 @@ spi_transfer_delay_exec(struct spi_transfer *t)
 /**
  * spi_message_init_with_transfers - Initialize spi_message and append transfers
  * @m: spi_message to be initialized
- * @xfers: An array of spi transfers
+ * @xfers: An array of SPI transfers
  * @num_xfers: Number of items in the xfer array
  *
  * This function initializes the given spi_message and adds each spi_transfer in
@@ -1185,24 +1197,21 @@ struct spi_transfer *xfers, unsigned int num_xfers)
                spi_message_add_tail(&xfers[i], m);
 }
 
-/* It's fine to embed message and transaction structures in other data
+/*
+ * It's fine to embed message and transaction structures in other data
  * structures so long as you don't free them while they're in use.
  */
-
 static inline struct spi_message *spi_message_alloc(unsigned ntrans, gfp_t flags)
 {
        struct spi_message *m;
 
-       m = kzalloc(sizeof(struct spi_message)
-                       + ntrans * sizeof(struct spi_transfer),
-                       flags);
+       m = kzalloc(struct_size(m, t, ntrans), flags);
        if (m) {
                unsigned i;
-               struct spi_transfer *t = (struct spi_transfer *)(m + 1);
 
                spi_message_init_no_memset(m);
-               for (i = 0; i < ntrans; i++, t++)
-                       spi_message_add_tail(t, m);
+               for (i = 0; i < ntrans; i++)
+                       spi_message_add_tail(&m->t[i], m);
        }
        return m;
 }
@@ -1291,7 +1300,7 @@ typedef void (*spi_replaced_release_t)(struct spi_controller *ctlr,
  *                                 replacements that have occurred
  *                                 so that they can get reverted
  * @release:            some extra release code to get executed prior to
- *                      relasing this structure
+ *                      releasing this structure
  * @extradata:          pointer to some extra data if requested or NULL
  * @replaced_transfers: transfers that have been replaced and which need
  *                      to get restored
@@ -1301,9 +1310,9 @@ typedef void (*spi_replaced_release_t)(struct spi_controller *ctlr,
  * @inserted_transfers: array of spi_transfers of array-size @inserted,
  *                      that have been replacing replaced_transfers
  *
- * note: that @extradata will point to @inserted_transfers[@inserted]
+ * Note: that @extradata will point to @inserted_transfers[@inserted]
  * if some extra allocation is requested, so alignment will be the same
- * as for spi_transfers
+ * as for spi_transfers.
  */
 struct spi_replaced_transfers {
        spi_replaced_release_t release;
@@ -1329,7 +1338,8 @@ extern int spi_split_transfers_maxwords(struct spi_controller *ctlr,
 
 /*---------------------------------------------------------------------------*/
 
-/* All these synchronous SPI transfer routines are utilities layered
+/*
+ * All these synchronous SPI transfer routines are utilities layered
  * over the core async transfer primitive.  Here, "synchronous" means
  * they will sleep uninterruptibly until the async transfer completes.
  */
@@ -1472,7 +1482,7 @@ static inline ssize_t spi_w8r16(struct spi_device *spi, u8 cmd)
  *
  * Callable only from contexts that can sleep.
  *
- * Return: the (unsigned) sixteen bit number returned by the device in cpu
+ * Return: the (unsigned) sixteen bit number returned by the device in CPU
  * endianness, or else a negative error code.
  */
 static inline ssize_t spi_w8r16be(struct spi_device *spi, u8 cmd)
@@ -1500,7 +1510,7 @@ static inline ssize_t spi_w8r16be(struct spi_device *spi, u8 cmd)
  * As a rule, SPI devices can't be probed.  Instead, board init code
  * provides a table listing the devices which are present, with enough
  * information to bind and set up the device's driver.  There's basic
- * support for nonstatic configurations too; enough to handle adding
+ * support for non-static configurations too; enough to handle adding
  * parport adapters, or microcontrollers acting as USB-to-SPI bridges.
  */
 
@@ -1537,12 +1547,13 @@ static inline ssize_t spi_w8r16be(struct spi_device *spi, u8 cmd)
  * are active in some dynamic board configuration models.
  */
 struct spi_board_info {
-       /* The device name and module name are coupled, like platform_bus;
+       /*
+        * The device name and module name are coupled, like platform_bus;
         * "modalias" is normally the driver name.
         *
         * platform_data goes to spi_device.dev.platform_data,
         * controller_data goes to spi_device.controller_data,
-        * irq is copied too
+        * IRQ is copied too.
         */
        char            modalias[SPI_NAME_SIZE];
        const void      *platform_data;
@@ -1554,7 +1565,8 @@ struct spi_board_info {
        u32             max_speed_hz;
 
 
-       /* bus_num is board specific and matches the bus_num of some
+       /*
+        * bus_num is board specific and matches the bus_num of some
         * spi_controller that will probably be registered later.
         *
         * chip_select reflects how this chip is wired to that master;
@@ -1563,12 +1575,14 @@ struct spi_board_info {
        u16             bus_num;
        u16             chip_select;
 
-       /* mode becomes spi_device.mode, and is essential for chips
+       /*
+        * mode becomes spi_device.mode, and is essential for chips
         * where the default of SPI_CS_HIGH = 0 is wrong.
         */
        u32             mode;
 
-       /* ... may need additional spi_device chip config data here.
+       /*
+        * ... may need additional spi_device chip config data here.
         * avoid stuff protocol drivers can set; but include stuff
         * needed to behave without being bound to a driver:
         *  - quirks like clock rate mattering when not selected
@@ -1585,7 +1599,8 @@ spi_register_board_info(struct spi_board_info const *info, unsigned n)
        { return 0; }
 #endif
 
-/* If you're hotplugging an adapter with devices (parport, usb, etc)
+/*
+ * If you're hotplugging an adapter with devices (parport, USB, etc)
  * use spi_new_device() to describe each device.  You can also call
  * spi_unregister_device() to start making that device vanish, but
  * normally that would be handled by spi_unregister_controller().
@@ -1623,10 +1638,6 @@ spi_transfer_is_last(struct spi_controller *ctlr, struct spi_transfer *xfer)
 #define spi_master                     spi_controller
 
 #define SPI_MASTER_HALF_DUPLEX         SPI_CONTROLLER_HALF_DUPLEX
-#define SPI_MASTER_NO_RX               SPI_CONTROLLER_NO_RX
-#define SPI_MASTER_NO_TX               SPI_CONTROLLER_NO_TX
-#define SPI_MASTER_MUST_RX             SPI_CONTROLLER_MUST_RX
-#define SPI_MASTER_MUST_TX             SPI_CONTROLLER_MUST_TX
 
 #define spi_master_get_devdata(_ctlr)  spi_controller_get_devdata(_ctlr)
 #define spi_master_set_devdata(_ctlr, _data)   \
index c0248a8..e63d4a2 100644 (file)
@@ -167,7 +167,7 @@ TRACE_EVENT(spi_message_done,
 );
 
 /*
- * consider a buffer valid if non-NULL and if it doesn't match the dummy buffer
+ * Consider a buffer valid if non-NULL and if it doesn't match the dummy buffer
  * that only exist to work with controllers that have SPI_CONTROLLER_MUST_TX or
  * SPI_CONTROLLER_MUST_RX.
  */