linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/3] spi: convert to BIT() all spi_device flags
@ 2020-11-24 10:21 Alexandru Ardelean
  2020-11-24 10:21 ` [PATCH v2 2/3] spi: Add SPI_NO_TX/RX support Alexandru Ardelean
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Alexandru Ardelean @ 2020-11-24 10:21 UTC (permalink / raw)
  To: linux-spi, devicetree, linux-kernel
  Cc: broonie, robh+dt, andy.shevchenko, dragos.bogdan, Alexandru Ardelean

This change converts all bit flags for the 'struct spi_device' mode to the
BIT() macro. The change is mostly for readability. Since adding more bit
fields, might as well convert it now.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---

Changelog v1 -> v2:
* https://lore.kernel.org/linux-spi/20201111141529.98147-1-alexandru.ardelean@analog.com/
* add patch 'spi: convert to BIT() all spi_device flags'
* for patch 'spi: Add SPI_NO_TX/RX support'
  convert comment to new multi-line format
* add patch 'spi: dt-bindings: document zero value for spi-{rx,tx}-bus-width properties'

 include/linux/spi/spi.h | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index aa09fdc8042d..66c7d8e45563 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -165,27 +165,27 @@ struct spi_device {
 	u8			bits_per_word;
 	bool			rt;
 	u32			mode;
-#define	SPI_CPHA	0x01			/* clock phase */
-#define	SPI_CPOL	0x02			/* clock polarity */
+#define	SPI_CPHA	BIT(0)			/* clock phase */
+#define	SPI_CPOL	BIT(1)			/* clock polarity */
 #define	SPI_MODE_0	(0|0)			/* (original MicroWire) */
 #define	SPI_MODE_1	(0|SPI_CPHA)
 #define	SPI_MODE_2	(SPI_CPOL|0)
 #define	SPI_MODE_3	(SPI_CPOL|SPI_CPHA)
 #define	SPI_MODE_X_MASK	(SPI_CPOL|SPI_CPHA)
-#define	SPI_CS_HIGH	0x04			/* chipselect active high? */
-#define	SPI_LSB_FIRST	0x08			/* per-word bits-on-wire */
-#define	SPI_3WIRE	0x10			/* SI/SO signals shared */
-#define	SPI_LOOP	0x20			/* loopback mode */
-#define	SPI_NO_CS	0x40			/* 1 dev/bus, no chipselect */
-#define	SPI_READY	0x80			/* slave pulls low to pause */
-#define	SPI_TX_DUAL	0x100			/* transmit with 2 wires */
-#define	SPI_TX_QUAD	0x200			/* transmit with 4 wires */
-#define	SPI_RX_DUAL	0x400			/* receive with 2 wires */
-#define	SPI_RX_QUAD	0x800			/* receive with 4 wires */
-#define	SPI_CS_WORD	0x1000			/* toggle cs after each word */
-#define	SPI_TX_OCTAL	0x2000			/* transmit with 8 wires */
-#define	SPI_RX_OCTAL	0x4000			/* receive with 8 wires */
-#define	SPI_3WIRE_HIZ	0x8000			/* high impedance turnaround */
+#define	SPI_CS_HIGH	BIT(2)			/* chipselect active high? */
+#define	SPI_LSB_FIRST	BIT(3)			/* per-word bits-on-wire */
+#define	SPI_3WIRE	BIT(4)			/* SI/SO signals shared */
+#define	SPI_LOOP	BIT(5)			/* loopback mode */
+#define	SPI_NO_CS	BIT(6)			/* 1 dev/bus, no chipselect */
+#define	SPI_READY	BIT(7)			/* slave pulls low to pause */
+#define	SPI_TX_DUAL	BIT(8)			/* transmit with 2 wires */
+#define	SPI_TX_QUAD	BIT(9)			/* transmit with 4 wires */
+#define	SPI_RX_DUAL	BIT(10)			/* receive with 2 wires */
+#define	SPI_RX_QUAD	BIT(11)			/* receive with 4 wires */
+#define	SPI_CS_WORD	BIT(12)			/* toggle cs after each word */
+#define	SPI_TX_OCTAL	BIT(13)			/* transmit with 8 wires */
+#define	SPI_RX_OCTAL	BIT(14)			/* receive with 8 wires */
+#define	SPI_3WIRE_HIZ	BIT(15)			/* high impedance turnaround */
 	int			irq;
 	void			*controller_state;
 	void			*controller_data;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 2/3] spi: Add SPI_NO_TX/RX support
  2020-11-24 10:21 [PATCH v2 1/3] spi: convert to BIT() all spi_device flags Alexandru Ardelean
@ 2020-11-24 10:21 ` Alexandru Ardelean
  2020-11-24 10:21 ` [PATCH v2 3/3] spi: dt-bindings: document zero value for spi-{rx,tx}-bus-width properties Alexandru Ardelean
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Alexandru Ardelean @ 2020-11-24 10:21 UTC (permalink / raw)
  To: linux-spi, devicetree, linux-kernel
  Cc: broonie, robh+dt, andy.shevchenko, dragos.bogdan, Alexandru Ardelean

From: Dragos Bogdan <dragos.bogdan@analog.com>

Transmit/receive only is a valid SPI mode. For example, the MOSI/TX line
might be missing from an ADC while for a DAC the MISO/RX line may be
optional. This patch adds these two new modes: SPI_NO_TX and
SPI_NO_RX. This way, the drivers will be able to identify if any of
these two lines is missing and to adjust the transfers accordingly.

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---

Changelog v1 -> v2:
* https://lore.kernel.org/linux-spi/20201111141529.98147-1-alexandru.ardelean@analog.com/
* convert comment to new multi-line format

 drivers/spi/spi.c       | 26 +++++++++++++++++++++-----
 include/linux/spi/spi.h |  2 ++
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 0c3f3a962448..5784fa8d9d74 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1939,6 +1939,9 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
 	/* Device DUAL/QUAD mode */
 	if (!of_property_read_u32(nc, "spi-tx-bus-width", &value)) {
 		switch (value) {
+		case 0:
+			spi->mode |= SPI_NO_TX;
+			break;
 		case 1:
 			break;
 		case 2:
@@ -1960,6 +1963,9 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
 
 	if (!of_property_read_u32(nc, "spi-rx-bus-width", &value)) {
 		switch (value) {
+		case 0:
+			spi->mode |= SPI_NO_RX;
+			break;
 		case 1:
 			break;
 		case 2:
@@ -3327,12 +3333,17 @@ int spi_setup(struct spi_device *spi)
 	unsigned	bad_bits, ugly_bits;
 	int		status;
 
-	/* check mode to prevent that DUAL and QUAD set at the same time
+	/*
+	 * check mode to prevent that any two of DUAL, QUAD and NO_MOSI/MISO
+	 * are set at the same time
 	 */
-	if (((spi->mode & SPI_TX_DUAL) && (spi->mode & SPI_TX_QUAD)) ||
-		((spi->mode & SPI_RX_DUAL) && (spi->mode & SPI_RX_QUAD))) {
+	if ((hweight_long(spi->mode &
+		(SPI_TX_DUAL | SPI_TX_QUAD | SPI_NO_TX)) > 1) ||
+	    (hweight_long(spi->mode &
+		(SPI_RX_DUAL | SPI_RX_QUAD | SPI_NO_RX)) > 1)) {
 		dev_err(&spi->dev,
-		"setup: can not select dual and quad at the same time\n");
+		"setup: can not select any two of dual, quad and no-rx/tx "
+		"at the same time\n");
 		return -EINVAL;
 	}
 	/* if it is SPI_3WIRE mode, DUAL and QUAD should be forbidden
@@ -3346,7 +3357,8 @@ int spi_setup(struct spi_device *spi)
 	 * SPI_CS_WORD has a fallback software implementation,
 	 * so it is ignored here.
 	 */
-	bad_bits = spi->mode & ~(spi->controller->mode_bits | SPI_CS_WORD);
+	bad_bits = spi->mode & ~(spi->controller->mode_bits | SPI_CS_WORD |
+				 SPI_NO_TX | SPI_NO_RX);
 	/* nothing prevents from working with active-high CS in case if it
 	 * is driven by GPIO.
 	 */
@@ -3607,6 +3619,8 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
 		 * 2. check tx/rx_nbits match the mode in spi_device
 		 */
 		if (xfer->tx_buf) {
+			if (spi->mode & SPI_NO_TX)
+				return -EINVAL;
 			if (xfer->tx_nbits != SPI_NBITS_SINGLE &&
 				xfer->tx_nbits != SPI_NBITS_DUAL &&
 				xfer->tx_nbits != SPI_NBITS_QUAD)
@@ -3620,6 +3634,8 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
 		}
 		/* check transfer rx_nbits */
 		if (xfer->rx_buf) {
+			if (spi->mode & SPI_NO_RX)
+				return -EINVAL;
 			if (xfer->rx_nbits != SPI_NBITS_SINGLE &&
 				xfer->rx_nbits != SPI_NBITS_DUAL &&
 				xfer->rx_nbits != SPI_NBITS_QUAD)
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 66c7d8e45563..8f3343d3ac27 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -186,6 +186,8 @@ struct spi_device {
 #define	SPI_TX_OCTAL	BIT(13)			/* transmit with 8 wires */
 #define	SPI_RX_OCTAL	BIT(14)			/* receive with 8 wires */
 #define	SPI_3WIRE_HIZ	BIT(15)			/* high impedance turnaround */
+#define	SPI_NO_TX	BIT(16)			/* no transmit wire */
+#define	SPI_NO_RX	BIT(17)			/* no receive wire */
 	int			irq;
 	void			*controller_state;
 	void			*controller_data;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 3/3] spi: dt-bindings: document zero value for spi-{rx,tx}-bus-width properties
  2020-11-24 10:21 [PATCH v2 1/3] spi: convert to BIT() all spi_device flags Alexandru Ardelean
  2020-11-24 10:21 ` [PATCH v2 2/3] spi: Add SPI_NO_TX/RX support Alexandru Ardelean
@ 2020-11-24 10:21 ` Alexandru Ardelean
  2020-11-24 11:41 ` [PATCH v2 1/3] spi: convert to BIT() all spi_device flags kernel test robot
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Alexandru Ardelean @ 2020-11-24 10:21 UTC (permalink / raw)
  To: linux-spi, devicetree, linux-kernel
  Cc: broonie, robh+dt, andy.shevchenko, dragos.bogdan, Alexandru Ardelean

Following a change to the SPI framework, providing a value of zero for
'spi-rx-bus-width' and 'spi-tx-bus-width' is now possible and will
essentially mean than no RX or TX is allowed.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---

Changelog v1 -> v2:
* https://lore.kernel.org/linux-spi/20201111141529.98147-1-alexandru.ardelean@analog.com/
* add patch 'spi: dt-bindings: document zero value for spi-{rx,tx}-bus-width properties'

 Documentation/devicetree/bindings/spi/spi-controller.yaml | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/spi/spi-controller.yaml b/Documentation/devicetree/bindings/spi/spi-controller.yaml
index 1b56d5e40f1f..f1aaaf9b3709 100644
--- a/Documentation/devicetree/bindings/spi/spi-controller.yaml
+++ b/Documentation/devicetree/bindings/spi/spi-controller.yaml
@@ -125,8 +125,9 @@ patternProperties:
       spi-rx-bus-width:
         description:
           Bus width to the SPI bus used for read transfers.
+          If 0 is provided, then no RX will be possible on this devices.
         $ref: /schemas/types.yaml#/definitions/uint32
-        enum: [1, 2, 4, 8]
+        enum: [0, 1, 2, 4, 8]
         default: 1
 
       spi-rx-delay-us:
@@ -136,8 +137,9 @@ patternProperties:
       spi-tx-bus-width:
         description:
           Bus width to the SPI bus used for write transfers.
+          If 0 is provided, then no RX will be possible on this devices.
         $ref: /schemas/types.yaml#/definitions/uint32
-        enum: [1, 2, 4, 8]
+        enum: [0, 1, 2, 4, 8]
         default: 1
 
       spi-tx-delay-us:
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/3] spi: convert to BIT() all spi_device flags
  2020-11-24 10:21 [PATCH v2 1/3] spi: convert to BIT() all spi_device flags Alexandru Ardelean
  2020-11-24 10:21 ` [PATCH v2 2/3] spi: Add SPI_NO_TX/RX support Alexandru Ardelean
  2020-11-24 10:21 ` [PATCH v2 3/3] spi: dt-bindings: document zero value for spi-{rx,tx}-bus-width properties Alexandru Ardelean
@ 2020-11-24 11:41 ` kernel test robot
  2020-11-24 11:41 ` kernel test robot
  2020-11-24 11:47 ` Andy Shevchenko
  4 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2020-11-24 11:41 UTC (permalink / raw)
  To: Alexandru Ardelean, linux-spi, devicetree, linux-kernel
  Cc: kbuild-all, broonie, robh+dt, andy.shevchenko, dragos.bogdan,
	Alexandru Ardelean

[-- Attachment #1: Type: text/plain, Size: 10298 bytes --]

Hi Alexandru,

I love your patch! Perhaps something to improve:

[auto build test WARNING on spi/for-next]
[also build test WARNING on next-20201123]
[cannot apply to v5.10-rc5]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Alexandru-Ardelean/spi-convert-to-BIT-all-spi_device-flags/20201124-181801
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
config: i386-randconfig-a016-20201124 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/1d45734a72568cc2118c14f912affda571a5f9dc
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Alexandru-Ardelean/spi-convert-to-BIT-all-spi_device-flags/20201124-181801
        git checkout 1d45734a72568cc2118c14f912affda571a5f9dc
        # save the attached .config to linux build tree
        make W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from include/linux/device.h:15,
                    from include/linux/dmaengine.h:8,
                    from drivers/spi/spi-stm32.c:11:
   drivers/spi/spi-stm32.c: In function 'stm32_spi_prepare_msg':
>> drivers/spi/spi-stm32.c:1030:20: warning: format '%d' expects argument of type 'int', but argument 4 has type 'long unsigned int' [-Wformat=]
    1030 |  dev_dbg(spi->dev, "cpol=%d cpha=%d lsb_first=%d cs_high=%d\n",
         |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:19:22: note: in definition of macro 'dev_fmt'
      19 | #define dev_fmt(fmt) fmt
         |                      ^~~
   drivers/spi/spi-stm32.c:1030:2: note: in expansion of macro 'dev_dbg'
    1030 |  dev_dbg(spi->dev, "cpol=%d cpha=%d lsb_first=%d cs_high=%d\n",
         |  ^~~~~~~
   drivers/spi/spi-stm32.c:1030:27: note: format string is defined here
    1030 |  dev_dbg(spi->dev, "cpol=%d cpha=%d lsb_first=%d cs_high=%d\n",
         |                          ~^
         |                           |
         |                           int
         |                          %ld
   In file included from include/linux/device.h:15,
                    from include/linux/dmaengine.h:8,
                    from drivers/spi/spi-stm32.c:11:
   drivers/spi/spi-stm32.c:1030:20: warning: format '%d' expects argument of type 'int', but argument 5 has type 'long unsigned int' [-Wformat=]
    1030 |  dev_dbg(spi->dev, "cpol=%d cpha=%d lsb_first=%d cs_high=%d\n",
         |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:19:22: note: in definition of macro 'dev_fmt'
      19 | #define dev_fmt(fmt) fmt
         |                      ^~~
   drivers/spi/spi-stm32.c:1030:2: note: in expansion of macro 'dev_dbg'
    1030 |  dev_dbg(spi->dev, "cpol=%d cpha=%d lsb_first=%d cs_high=%d\n",
         |  ^~~~~~~
   drivers/spi/spi-stm32.c:1030:35: note: format string is defined here
    1030 |  dev_dbg(spi->dev, "cpol=%d cpha=%d lsb_first=%d cs_high=%d\n",
         |                                  ~^
         |                                   |
         |                                   int
         |                                  %ld
   In file included from include/linux/device.h:15,
                    from include/linux/dmaengine.h:8,
                    from drivers/spi/spi-stm32.c:11:
   drivers/spi/spi-stm32.c:1030:20: warning: format '%d' expects argument of type 'int', but argument 6 has type 'long unsigned int' [-Wformat=]
    1030 |  dev_dbg(spi->dev, "cpol=%d cpha=%d lsb_first=%d cs_high=%d\n",
         |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:19:22: note: in definition of macro 'dev_fmt'
      19 | #define dev_fmt(fmt) fmt
         |                      ^~~
   drivers/spi/spi-stm32.c:1030:2: note: in expansion of macro 'dev_dbg'
    1030 |  dev_dbg(spi->dev, "cpol=%d cpha=%d lsb_first=%d cs_high=%d\n",
         |  ^~~~~~~
   drivers/spi/spi-stm32.c:1030:48: note: format string is defined here
    1030 |  dev_dbg(spi->dev, "cpol=%d cpha=%d lsb_first=%d cs_high=%d\n",
         |                                               ~^
         |                                                |
         |                                                int
         |                                               %ld
   In file included from include/linux/device.h:15,
                    from include/linux/dmaengine.h:8,
                    from drivers/spi/spi-stm32.c:11:
   drivers/spi/spi-stm32.c:1030:20: warning: format '%d' expects argument of type 'int', but argument 7 has type 'long unsigned int' [-Wformat=]
    1030 |  dev_dbg(spi->dev, "cpol=%d cpha=%d lsb_first=%d cs_high=%d\n",
         |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:19:22: note: in definition of macro 'dev_fmt'
      19 | #define dev_fmt(fmt) fmt
         |                      ^~~
   drivers/spi/spi-stm32.c:1030:2: note: in expansion of macro 'dev_dbg'
    1030 |  dev_dbg(spi->dev, "cpol=%d cpha=%d lsb_first=%d cs_high=%d\n",
         |  ^~~~~~~
   drivers/spi/spi-stm32.c:1030:59: note: format string is defined here
    1030 |  dev_dbg(spi->dev, "cpol=%d cpha=%d lsb_first=%d cs_high=%d\n",
         |                                                          ~^
         |                                                           |
         |                                                           int
         |                                                          %ld

vim +1030 drivers/spi/spi-stm32.c

dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21   995  
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21   996  /**
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21   997   * stm32_spi_prepare_msg - set up the controller to transfer a single message
1c52be8bed83e1a Alain Volmat    2020-03-20   998   * @master: controller master interface
1c52be8bed83e1a Alain Volmat    2020-03-20   999   * @msg: pointer to spi message
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1000   */
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1001  static int stm32_spi_prepare_msg(struct spi_master *master,
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1002  				 struct spi_message *msg)
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1003  {
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1004  	struct stm32_spi *spi = spi_master_get_devdata(master);
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1005  	struct spi_device *spi_dev = msg->spi;
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1006  	struct device_node *np = spi_dev->dev.of_node;
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1007  	unsigned long flags;
55166853b2f56ce Cezary Gapinski 2018-12-24  1008  	u32 clrb = 0, setb = 0;
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1009  
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1010  	/* SPI slave device may need time between data frames */
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1011  	spi->cur_midi = 0;
042c1c60df7b854 Amelie Delaunay 2017-06-27  1012  	if (np && !of_property_read_u32(np, "st,spi-midi-ns", &spi->cur_midi))
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1013  		dev_dbg(spi->dev, "%dns inter-data idleness\n", spi->cur_midi);
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1014  
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1015  	if (spi_dev->mode & SPI_CPOL)
55166853b2f56ce Cezary Gapinski 2018-12-24  1016  		setb |= spi->cfg->regs->cpol.mask;
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1017  	else
55166853b2f56ce Cezary Gapinski 2018-12-24  1018  		clrb |= spi->cfg->regs->cpol.mask;
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1019  
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1020  	if (spi_dev->mode & SPI_CPHA)
55166853b2f56ce Cezary Gapinski 2018-12-24  1021  		setb |= spi->cfg->regs->cpha.mask;
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1022  	else
55166853b2f56ce Cezary Gapinski 2018-12-24  1023  		clrb |= spi->cfg->regs->cpha.mask;
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1024  
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1025  	if (spi_dev->mode & SPI_LSB_FIRST)
55166853b2f56ce Cezary Gapinski 2018-12-24  1026  		setb |= spi->cfg->regs->lsb_first.mask;
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1027  	else
55166853b2f56ce Cezary Gapinski 2018-12-24  1028  		clrb |= spi->cfg->regs->lsb_first.mask;
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1029  
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21 @1030  	dev_dbg(spi->dev, "cpol=%d cpha=%d lsb_first=%d cs_high=%d\n",
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1031  		spi_dev->mode & SPI_CPOL,
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1032  		spi_dev->mode & SPI_CPHA,
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1033  		spi_dev->mode & SPI_LSB_FIRST,
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1034  		spi_dev->mode & SPI_CS_HIGH);
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1035  
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1036  	spin_lock_irqsave(&spi->lock, flags);
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1037  
55166853b2f56ce Cezary Gapinski 2018-12-24  1038  	/* CPOL, CPHA and LSB FIRST bits have common register */
55166853b2f56ce Cezary Gapinski 2018-12-24  1039  	if (clrb || setb)
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1040  		writel_relaxed(
55166853b2f56ce Cezary Gapinski 2018-12-24  1041  			(readl_relaxed(spi->base + spi->cfg->regs->cpol.reg) &
55166853b2f56ce Cezary Gapinski 2018-12-24  1042  			 ~clrb) | setb,
55166853b2f56ce Cezary Gapinski 2018-12-24  1043  			spi->base + spi->cfg->regs->cpol.reg);
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1044  
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1045  	spin_unlock_irqrestore(&spi->lock, flags);
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1046  
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1047  	return 0;
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1048  }
dcbe0d84dfa5a3e Amelie Delaunay 2017-06-21  1049  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 41568 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/3] spi: convert to BIT() all spi_device flags
  2020-11-24 10:21 [PATCH v2 1/3] spi: convert to BIT() all spi_device flags Alexandru Ardelean
                   ` (2 preceding siblings ...)
  2020-11-24 11:41 ` [PATCH v2 1/3] spi: convert to BIT() all spi_device flags kernel test robot
@ 2020-11-24 11:41 ` kernel test robot
  2020-11-24 11:49   ` Andy Shevchenko
  2020-11-24 11:47 ` Andy Shevchenko
  4 siblings, 1 reply; 9+ messages in thread
From: kernel test robot @ 2020-11-24 11:41 UTC (permalink / raw)
  To: Alexandru Ardelean, linux-spi, devicetree, linux-kernel
  Cc: kbuild-all, broonie, robh+dt, andy.shevchenko, dragos.bogdan,
	Alexandru Ardelean

[-- Attachment #1: Type: text/plain, Size: 10593 bytes --]

Hi Alexandru,

I love your patch! Perhaps something to improve:

[auto build test WARNING on spi/for-next]
[also build test WARNING on next-20201123]
[cannot apply to v5.10-rc5]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Alexandru-Ardelean/spi-convert-to-BIT-all-spi_device-flags/20201124-181801
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
config: i386-randconfig-a011-20201124 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/1d45734a72568cc2118c14f912affda571a5f9dc
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Alexandru-Ardelean/spi-convert-to-BIT-all-spi_device-flags/20201124-181801
        git checkout 1d45734a72568cc2118c14f912affda571a5f9dc
        # save the attached .config to linux build tree
        make W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from drivers/spi/spidev.c:26:
>> include/uapi/linux/spi/spidev.h:33: warning: "SPI_CPHA" redefined
      33 | #define SPI_CPHA  0x01
         | 
   In file included from drivers/spi/spidev.c:25:
   include/linux/spi/spi.h:168: note: this is the location of the previous definition
     168 | #define SPI_CPHA BIT(0)   /* clock phase */
         | 
   In file included from drivers/spi/spidev.c:26:
>> include/uapi/linux/spi/spidev.h:34: warning: "SPI_CPOL" redefined
      34 | #define SPI_CPOL  0x02
         | 
   In file included from drivers/spi/spidev.c:25:
   include/linux/spi/spi.h:169: note: this is the location of the previous definition
     169 | #define SPI_CPOL BIT(1)   /* clock polarity */
         | 
   In file included from drivers/spi/spidev.c:26:
>> include/uapi/linux/spi/spidev.h:41: warning: "SPI_CS_HIGH" redefined
      41 | #define SPI_CS_HIGH  0x04
         | 
   In file included from drivers/spi/spidev.c:25:
   include/linux/spi/spi.h:175: note: this is the location of the previous definition
     175 | #define SPI_CS_HIGH BIT(2)   /* chipselect active high? */
         | 
   In file included from drivers/spi/spidev.c:26:
>> include/uapi/linux/spi/spidev.h:42: warning: "SPI_LSB_FIRST" redefined
      42 | #define SPI_LSB_FIRST  0x08
         | 
   In file included from drivers/spi/spidev.c:25:
   include/linux/spi/spi.h:176: note: this is the location of the previous definition
     176 | #define SPI_LSB_FIRST BIT(3)   /* per-word bits-on-wire */
         | 
   In file included from drivers/spi/spidev.c:26:
>> include/uapi/linux/spi/spidev.h:43: warning: "SPI_3WIRE" redefined
      43 | #define SPI_3WIRE  0x10
         | 
   In file included from drivers/spi/spidev.c:25:
   include/linux/spi/spi.h:177: note: this is the location of the previous definition
     177 | #define SPI_3WIRE BIT(4)   /* SI/SO signals shared */
         | 
   In file included from drivers/spi/spidev.c:26:
>> include/uapi/linux/spi/spidev.h:44: warning: "SPI_LOOP" redefined
      44 | #define SPI_LOOP  0x20
         | 
   In file included from drivers/spi/spidev.c:25:
   include/linux/spi/spi.h:178: note: this is the location of the previous definition
     178 | #define SPI_LOOP BIT(5)   /* loopback mode */
         | 
   In file included from drivers/spi/spidev.c:26:
>> include/uapi/linux/spi/spidev.h:45: warning: "SPI_NO_CS" redefined
      45 | #define SPI_NO_CS  0x40
         | 
   In file included from drivers/spi/spidev.c:25:
   include/linux/spi/spi.h:179: note: this is the location of the previous definition
     179 | #define SPI_NO_CS BIT(6)   /* 1 dev/bus, no chipselect */
         | 
   In file included from drivers/spi/spidev.c:26:
>> include/uapi/linux/spi/spidev.h:46: warning: "SPI_READY" redefined
      46 | #define SPI_READY  0x80
         | 
   In file included from drivers/spi/spidev.c:25:
   include/linux/spi/spi.h:180: note: this is the location of the previous definition
     180 | #define SPI_READY BIT(7)   /* slave pulls low to pause */
         | 
   In file included from drivers/spi/spidev.c:26:
>> include/uapi/linux/spi/spidev.h:47: warning: "SPI_TX_DUAL" redefined
      47 | #define SPI_TX_DUAL  0x100
         | 
   In file included from drivers/spi/spidev.c:25:
   include/linux/spi/spi.h:181: note: this is the location of the previous definition
     181 | #define SPI_TX_DUAL BIT(8)   /* transmit with 2 wires */
         | 
   In file included from drivers/spi/spidev.c:26:
>> include/uapi/linux/spi/spidev.h:48: warning: "SPI_TX_QUAD" redefined
      48 | #define SPI_TX_QUAD  0x200
         | 
   In file included from drivers/spi/spidev.c:25:
   include/linux/spi/spi.h:182: note: this is the location of the previous definition
     182 | #define SPI_TX_QUAD BIT(9)   /* transmit with 4 wires */
         | 
   In file included from drivers/spi/spidev.c:26:
>> include/uapi/linux/spi/spidev.h:49: warning: "SPI_RX_DUAL" redefined
      49 | #define SPI_RX_DUAL  0x400
         | 
   In file included from drivers/spi/spidev.c:25:
   include/linux/spi/spi.h:183: note: this is the location of the previous definition
     183 | #define SPI_RX_DUAL BIT(10)   /* receive with 2 wires */
         | 
   In file included from drivers/spi/spidev.c:26:
>> include/uapi/linux/spi/spidev.h:50: warning: "SPI_RX_QUAD" redefined
      50 | #define SPI_RX_QUAD  0x800
         | 
   In file included from drivers/spi/spidev.c:25:
   include/linux/spi/spi.h:184: note: this is the location of the previous definition
     184 | #define SPI_RX_QUAD BIT(11)   /* receive with 4 wires */
         | 
   In file included from drivers/spi/spidev.c:26:
>> include/uapi/linux/spi/spidev.h:51: warning: "SPI_CS_WORD" redefined
      51 | #define SPI_CS_WORD  0x1000
         | 
   In file included from drivers/spi/spidev.c:25:
   include/linux/spi/spi.h:185: note: this is the location of the previous definition
     185 | #define SPI_CS_WORD BIT(12)   /* toggle cs after each word */
         | 
   In file included from drivers/spi/spidev.c:26:
>> include/uapi/linux/spi/spidev.h:52: warning: "SPI_TX_OCTAL" redefined
      52 | #define SPI_TX_OCTAL  0x2000
         | 
   In file included from drivers/spi/spidev.c:25:
   include/linux/spi/spi.h:186: note: this is the location of the previous definition
     186 | #define SPI_TX_OCTAL BIT(13)   /* transmit with 8 wires */
         | 
   In file included from drivers/spi/spidev.c:26:
>> include/uapi/linux/spi/spidev.h:53: warning: "SPI_RX_OCTAL" redefined
      53 | #define SPI_RX_OCTAL  0x4000
         | 
   In file included from drivers/spi/spidev.c:25:
   include/linux/spi/spi.h:187: note: this is the location of the previous definition
     187 | #define SPI_RX_OCTAL BIT(14)   /* receive with 8 wires */
         | 
   In file included from drivers/spi/spidev.c:26:
>> include/uapi/linux/spi/spidev.h:54: warning: "SPI_3WIRE_HIZ" redefined
      54 | #define SPI_3WIRE_HIZ  0x8000
         | 
   In file included from drivers/spi/spidev.c:25:
   include/linux/spi/spi.h:188: note: this is the location of the previous definition
     188 | #define SPI_3WIRE_HIZ BIT(15)   /* high impedance turnaround */
         | 

vim +/SPI_CPHA +33 include/uapi/linux/spi/spidev.h

814a8d50eb1d88c include/linux/spi/spidev.h      Andrea Paterniani  2007-05-08  28  
814a8d50eb1d88c include/linux/spi/spidev.h      Andrea Paterniani  2007-05-08  29  /* User space versions of kernel symbols for SPI clocking modes,
814a8d50eb1d88c include/linux/spi/spidev.h      Andrea Paterniani  2007-05-08  30   * matching <linux/spi/spi.h>
814a8d50eb1d88c include/linux/spi/spidev.h      Andrea Paterniani  2007-05-08  31   */
814a8d50eb1d88c include/linux/spi/spidev.h      Andrea Paterniani  2007-05-08  32  
814a8d50eb1d88c include/linux/spi/spidev.h      Andrea Paterniani  2007-05-08 @33  #define SPI_CPHA		0x01
814a8d50eb1d88c include/linux/spi/spidev.h      Andrea Paterniani  2007-05-08 @34  #define SPI_CPOL		0x02
814a8d50eb1d88c include/linux/spi/spidev.h      Andrea Paterniani  2007-05-08  35  
814a8d50eb1d88c include/linux/spi/spidev.h      Andrea Paterniani  2007-05-08  36  #define SPI_MODE_0		(0|0)
814a8d50eb1d88c include/linux/spi/spidev.h      Andrea Paterniani  2007-05-08  37  #define SPI_MODE_1		(0|SPI_CPHA)
814a8d50eb1d88c include/linux/spi/spidev.h      Andrea Paterniani  2007-05-08  38  #define SPI_MODE_2		(SPI_CPOL|0)
814a8d50eb1d88c include/linux/spi/spidev.h      Andrea Paterniani  2007-05-08  39  #define SPI_MODE_3		(SPI_CPOL|SPI_CPHA)
814a8d50eb1d88c include/linux/spi/spidev.h      Andrea Paterniani  2007-05-08  40  
6f166e3833d953f include/linux/spi/spidev.h      Anton Vorontsov    2007-07-31 @41  #define SPI_CS_HIGH		0x04
6f166e3833d953f include/linux/spi/spidev.h      Anton Vorontsov    2007-07-31 @42  #define SPI_LSB_FIRST		0x08
6f166e3833d953f include/linux/spi/spidev.h      Anton Vorontsov    2007-07-31 @43  #define SPI_3WIRE		0x10
6f166e3833d953f include/linux/spi/spidev.h      Anton Vorontsov    2007-07-31 @44  #define SPI_LOOP		0x20
b55f627feeb9d48 include/linux/spi/spidev.h      David Brownell     2009-06-30 @45  #define SPI_NO_CS		0x40
b55f627feeb9d48 include/linux/spi/spidev.h      David Brownell     2009-06-30 @46  #define SPI_READY		0x80
dc64d39b54c1e9d include/uapi/linux/spi/spidev.h Geert Uytterhoeven 2014-02-25 @47  #define SPI_TX_DUAL		0x100
dc64d39b54c1e9d include/uapi/linux/spi/spidev.h Geert Uytterhoeven 2014-02-25 @48  #define SPI_TX_QUAD		0x200
dc64d39b54c1e9d include/uapi/linux/spi/spidev.h Geert Uytterhoeven 2014-02-25 @49  #define SPI_RX_DUAL		0x400
dc64d39b54c1e9d include/uapi/linux/spi/spidev.h Geert Uytterhoeven 2014-02-25 @50  #define SPI_RX_QUAD		0x800
7bb64402a092136 include/uapi/linux/spi/spidev.h Qing Zhang         2020-06-11 @51  #define SPI_CS_WORD		0x1000
7bb64402a092136 include/uapi/linux/spi/spidev.h Qing Zhang         2020-06-11 @52  #define SPI_TX_OCTAL		0x2000
7bb64402a092136 include/uapi/linux/spi/spidev.h Qing Zhang         2020-06-11 @53  #define SPI_RX_OCTAL		0x4000
7bb64402a092136 include/uapi/linux/spi/spidev.h Qing Zhang         2020-06-11 @54  #define SPI_3WIRE_HIZ		0x8000
814a8d50eb1d88c include/linux/spi/spidev.h      Andrea Paterniani  2007-05-08  55  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35730 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/3] spi: convert to BIT() all spi_device flags
  2020-11-24 10:21 [PATCH v2 1/3] spi: convert to BIT() all spi_device flags Alexandru Ardelean
                   ` (3 preceding siblings ...)
  2020-11-24 11:41 ` kernel test robot
@ 2020-11-24 11:47 ` Andy Shevchenko
  4 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2020-11-24 11:47 UTC (permalink / raw)
  To: Alexandru Ardelean
  Cc: linux-spi, devicetree, Linux Kernel Mailing List, Mark Brown,
	Rob Herring, Bogdan, Dragos

On Tue, Nov 24, 2020 at 12:16 PM Alexandru Ardelean
<alexandru.ardelean@analog.com> wrote:
>
> This change converts all bit flags for the 'struct spi_device' mode to the
> BIT() macro. The change is mostly for readability. Since adding more bit
> fields, might as well convert it now.

...

#include <linux/bits.h>

And honestly I think the entire inclusion block with data type forward
declarations should be revisited here.

...

> +#define        SPI_CPHA        BIT(0)                  /* clock phase */
> +#define        SPI_CPOL        BIT(1)                  /* clock polarity */

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/3] spi: convert to BIT() all spi_device flags
  2020-11-24 11:41 ` kernel test robot
@ 2020-11-24 11:49   ` Andy Shevchenko
  2020-11-24 12:03     ` Ardelean, Alexandru
  0 siblings, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2020-11-24 11:49 UTC (permalink / raw)
  To: kernel test robot
  Cc: Alexandru Ardelean, linux-spi, devicetree,
	Linux Kernel Mailing List, kbuild-all, Mark Brown, Rob Herring,
	Bogdan, Dragos

On Tue, Nov 24, 2020 at 1:42 PM kernel test robot <lkp@intel.com> wrote:

> All warnings (new ones prefixed by >>):
>
>    In file included from drivers/spi/spidev.c:26:
> >> include/uapi/linux/spi/spidev.h:33: warning: "SPI_CPHA" redefined
>       33 | #define SPI_CPHA  0x01

Argh! Can we have only one set of flags?

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH v2 1/3] spi: convert to BIT() all spi_device flags
  2020-11-24 11:49   ` Andy Shevchenko
@ 2020-11-24 12:03     ` Ardelean, Alexandru
  2020-11-24 13:55       ` Andy Shevchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Ardelean, Alexandru @ 2020-11-24 12:03 UTC (permalink / raw)
  To: Andy Shevchenko, kernel test robot
  Cc: linux-spi, devicetree, Linux Kernel Mailing List, kbuild-all,
	Mark Brown, Rob Herring, Bogdan, Dragos



> -----Original Message-----
> From: Andy Shevchenko <andy.shevchenko@gmail.com>
> Sent: Tuesday, November 24, 2020 1:50 PM
> To: kernel test robot <lkp@intel.com>
> Cc: Ardelean, Alexandru <alexandru.Ardelean@analog.com>; linux-spi <linux-
> spi@vger.kernel.org>; devicetree <devicetree@vger.kernel.org>; Linux Kernel
> Mailing List <linux-kernel@vger.kernel.org>; kbuild-all@lists.01.org; Mark
> Brown <broonie@kernel.org>; Rob Herring <robh+dt@kernel.org>; Bogdan,
> Dragos <Dragos.Bogdan@analog.com>
> Subject: Re: [PATCH v2 1/3] spi: convert to BIT() all spi_device flags
> 
> On Tue, Nov 24, 2020 at 1:42 PM kernel test robot <lkp@intel.com> wrote:
> 
> > All warnings (new ones prefixed by >>):
> >
> >    In file included from drivers/spi/spidev.c:26:
> > >> include/uapi/linux/spi/spidev.h:33: warning: "SPI_CPHA" redefined
> >       33 | #define SPI_CPHA  0x01
> 
> Argh! Can we have only one set of flags?
>

My bad here for not catching this earlier.

It might be an idea to create a "include/uapi/linux/spi/spi.h" and include this in " include/uapi/linux/spi/spidev.h "
Then the " include/uapi/linux/spi/spi.h " would also be included in " include/linux/spi/spi.h "
We would naturally drop the BIT() macros for the uapi header.


> --
> With Best Regards,
> Andy Shevchenko

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/3] spi: convert to BIT() all spi_device flags
  2020-11-24 12:03     ` Ardelean, Alexandru
@ 2020-11-24 13:55       ` Andy Shevchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2020-11-24 13:55 UTC (permalink / raw)
  To: Ardelean, Alexandru
  Cc: kernel test robot, linux-spi, devicetree,
	Linux Kernel Mailing List, kbuild-all, Mark Brown, Rob Herring,
	Bogdan, Dragos

On Tue, Nov 24, 2020 at 2:03 PM Ardelean, Alexandru
<alexandru.Ardelean@analog.com> wrote:

> > >    In file included from drivers/spi/spidev.c:26:
> > > >> include/uapi/linux/spi/spidev.h:33: warning: "SPI_CPHA" redefined
> > >       33 | #define SPI_CPHA  0x01
> >
> > Argh! Can we have only one set of flags?
> >
>
> My bad here for not catching this earlier.
>
> It might be an idea to create a "include/uapi/linux/spi/spi.h" and include this in " include/uapi/linux/spi/spidev.h "
> Then the " include/uapi/linux/spi/spi.h " would also be included in " include/linux/spi/spi.h "
> We would naturally drop the BIT() macros for the uapi header.

uAPI has its own _BIT*() macros.


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-11-24 13:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-24 10:21 [PATCH v2 1/3] spi: convert to BIT() all spi_device flags Alexandru Ardelean
2020-11-24 10:21 ` [PATCH v2 2/3] spi: Add SPI_NO_TX/RX support Alexandru Ardelean
2020-11-24 10:21 ` [PATCH v2 3/3] spi: dt-bindings: document zero value for spi-{rx,tx}-bus-width properties Alexandru Ardelean
2020-11-24 11:41 ` [PATCH v2 1/3] spi: convert to BIT() all spi_device flags kernel test robot
2020-11-24 11:41 ` kernel test robot
2020-11-24 11:49   ` Andy Shevchenko
2020-11-24 12:03     ` Ardelean, Alexandru
2020-11-24 13:55       ` Andy Shevchenko
2020-11-24 11:47 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).