Skip to contentSkip to conversation

fpga: lattice-sysconfig-spi: simplify with spi_get_device_match_data()

PATCH Superseded Andy Shevchenko 2 participants 3 messages May 8 – May 9 FPGA manager framework

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fpga: lattice-sysconfig-spi: simplify with spi_get_device_match_data()

Use spi_get_device_match_data() helper to simplify a bit the driver.

---
 drivers/fpga/lattice-sysconfig-spi.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/fpga/lattice-sysconfig-spi.c +1 -10
index 44691cfcf50a..6a906df45941 100644
@@ -85,7 +85,6 @@ static int sysconfig_spi_bitstream_burst_complete(struct sysconfig_priv *priv)
 
 static int sysconfig_spi_probe(struct spi_device *spi)
 {
-	const struct spi_device_id *dev_id;
 	struct device *dev = &spi->dev;
 	struct sysconfig_priv *priv;
 	const u32 *spi_max_speed;
@@ -94,15 +93,7 @@ static int sysconfig_spi_probe(struct spi_device *spi)
 	if (!priv)
 		return -ENOMEM;
 
-	spi_max_speed = device_get_match_data(dev);
-	if (!spi_max_speed) {
-		dev_id = spi_get_device_id(spi);
-		if (!dev_id)
-			return -ENODEV;
-
-		spi_max_speed = (const u32 *)dev_id->driver_data;
-	}
-
+	spi_max_speed = spi_get_device_match_data(dev);
 	if (!spi_max_speed)
 		return -EINVAL;
 
Signature · 1 line
2.50.1
#1 lore raw
kernel test robot noticed the following build errors:

Hi Andy,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v7.1-rc2 next-20260508]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/fpga-lattice-sysconfig-spi-simplify-with-spi_get_device_match_data/20260509-133025
base:   linus/master
patch link:    https://lore.kernel.org/r/20260508080650.1144588-1-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v1 1/1] fpga: lattice-sysconfig-spi: simplify with spi_get_device_match_data()
config: arm-randconfig-004-20260509 (https://download.01.org/0day-ci/archive/20260509/[email protected]/config)
compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project 5bac06718f502014fade905512f1d26d578a18f3)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260509/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/fpga/lattice-sysconfig-spi.c:96:44: error: incompatible pointer types passing 'struct device *' to parameter of type 'const struct spi_device *' [-Wincompatible-pointer-types]
      96 |         spi_max_speed = spi_get_device_match_data(dev);
         |                                                   ^~~
   include/linux/spi/spi.h:1757:52: note: passing argument to parameter 'sdev' here
    1757 | spi_get_device_match_data(const struct spi_device *sdev);
         |                                                    ^

1 error generated.

vim +96 drivers/fpga/lattice-sysconfig-spi.c

    85	
    86	static int sysconfig_spi_probe(struct spi_device *spi)
    87	{
    88		struct device *dev = &spi->dev;
    89		struct sysconfig_priv *priv;
    90		const u32 *spi_max_speed;
    91	
    92		priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
    93		if (!priv)
    94			return -ENOMEM;
    95	
  > 96		spi_max_speed = spi_get_device_match_data(dev);
    97		if (!spi_max_speed)
    98			return -EINVAL;
    99	

100 if (spi->max_speed_hz > *spi_max_speed) {
101 dev_err(dev, "SPI speed %u is too high, maximum speed is %u\n",
102 spi->max_speed_hz, *spi_max_speed);
103 return -EINVAL;
104 }
105
106 priv->dev = dev;
107 priv->command_transfer = sysconfig_spi_cmd_transfer;
108 priv->bitstream_burst_write_init = sysconfig_spi_bitstream_burst_init;
109 priv->bitstream_burst_write = sysconfig_spi_bitstream_burst_write;
110 priv->bitstream_burst_write_complete = sysconfig_spi_bitstream_burst_complete;
111
112 return sysconfig_probe(priv);
113 }
114

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#2 lore raw
In reply to Andy Shevchenko
kernel test robot noticed the following build errors:

Hi Andy,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v7.1-rc2 next-20260508]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/fpga-lattice-sysconfig-spi-simplify-with-spi_get_device_match_data/20260509-133025
base:   linus/master
patch link:    https://lore.kernel.org/r/20260508080650.1144588-1-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v1 1/1] fpga: lattice-sysconfig-spi: simplify with spi_get_device_match_data()
config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20260509/[email protected]/config)
compiler: arc-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260509/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/fpga/lattice-sysconfig-spi.c: In function 'sysconfig_spi_probe':

>> drivers/fpga/lattice-sysconfig-spi.c:96:51: error: passing argument 1 of 'spi_get_device_match_data' from incompatible pointer type [-Wincompatible-pointer-types]
      96 |         spi_max_speed = spi_get_device_match_data(dev);
         |                                                   ^~~
         |                                                   |
         |                                                   struct device *
   In file included from drivers/fpga/lattice-sysconfig-spi.c:7:
   include/linux/spi/spi.h:1757:52: note: expected 'const struct spi_device *' but argument is of type 'struct device *'
    1757 | spi_get_device_match_data(const struct spi_device *sdev);
         |                           ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~

vim +/spi_get_device_match_data +96 drivers/fpga/lattice-sysconfig-spi.c

    85	
    86	static int sysconfig_spi_probe(struct spi_device *spi)
    87	{
    88		struct device *dev = &spi->dev;
    89		struct sysconfig_priv *priv;
    90		const u32 *spi_max_speed;
    91	
    92		priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
    93		if (!priv)
    94			return -ENOMEM;
    95	
  > 96		spi_max_speed = spi_get_device_match_data(dev);
    97		if (!spi_max_speed)
    98			return -EINVAL;
    99	

100 if (spi->max_speed_hz > *spi_max_speed) {
101 dev_err(dev, "SPI speed %u is too high, maximum speed is %u\n",
102 spi->max_speed_hz, *spi_max_speed);
103 return -EINVAL;
104 }
105
106 priv->dev = dev;
107 priv->command_transfer = sysconfig_spi_cmd_transfer;
108 priv->bitstream_burst_write_init = sysconfig_spi_bitstream_burst_init;
109 priv->bitstream_burst_write = sysconfig_spi_bitstream_burst_write;
110 priv->bitstream_burst_write_complete = sysconfig_spi_bitstream_burst_complete;
111
112 return sysconfig_probe(priv);
113 }
114

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki