Message ID | 20201124102152.16548-1-alexandru.ardelean@analog.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2,1/3] spi: convert to BIT() all spi_device flags | expand |
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
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
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 */
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?
> -----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
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.
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;
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(-)