Message ID | 20231104064650.972687-5-zhangxiaoxu@huaweicloud.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | spi: Introduce BPF based SPI mockup controller | expand |
Hi Zhang, kernel test robot noticed the following build warnings: [auto build test WARNING on next-20231103] url: https://github.com/intel-lab-lkp/linux/commits/Zhang-Xiaoxu/spi-mockup-Add-SPI-controller-testing-driver/20231104-144859 base: next-20231103 patch link: https://lore.kernel.org/r/20231104064650.972687-5-zhangxiaoxu%40huaweicloud.com patch subject: [PATCH v3 -next 4/5] spi: mockup: Add speed and flags attribute support config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20231104/202311041823.CPs0Ymwh-lkp@intel.com/config) compiler: m68k-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231104/202311041823.CPs0Ymwh-lkp@intel.com/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 <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202311041823.CPs0Ymwh-lkp@intel.com/ All warnings (new ones prefixed by >>): drivers/spi/spi-mockup.c:339:1: error: expected ',' or ';' before 'static' 339 | static ssize_t spi_mockup_ ## name ## _store(struct config_item *item, \ | ^~~~~~ drivers/spi/spi-mockup.c:364:1: note: in expansion of macro 'SPI_MOCKUP_ATTR' 364 | SPI_MOCKUP_ATTR(u32, max_speed) | ^~~~~~~~~~~~~~~ In file included from drivers/spi/spi-mockup.c:15: drivers/spi/spi-mockup.c:361:18: error: 'spi_mockup_max_speed_store' undeclared here (not in a function); did you mean 'spi_mockup_min_speed_store'? 361 | CONFIGFS_ATTR_WO(spi_mockup_, name) \ | ^~~~~~~~~~~ include/linux/configfs.h:145:27: note: in definition of macro 'CONFIGFS_ATTR_WO' 145 | .store = _pfx##_name##_store, \ | ^~~~ drivers/spi/spi-mockup.c:364:1: note: in expansion of macro 'SPI_MOCKUP_ATTR' 364 | SPI_MOCKUP_ATTR(u32, max_speed) | ^~~~~~~~~~~~~~~ drivers/spi/spi-mockup.c:339:1: error: expected ',' or ';' before 'static' 339 | static ssize_t spi_mockup_ ## name ## _store(struct config_item *item, \ | ^~~~~~ drivers/spi/spi-mockup.c:365:1: note: in expansion of macro 'SPI_MOCKUP_ATTR' 365 | SPI_MOCKUP_ATTR(u16, flags) | ^~~~~~~~~~~~~~~ drivers/spi/spi-mockup.c:361:18: error: 'spi_mockup_flags_store' undeclared here (not in a function); did you mean 'spi_mockup_enable_store'? 361 | CONFIGFS_ATTR_WO(spi_mockup_, name) \ | ^~~~~~~~~~~ include/linux/configfs.h:145:27: note: in definition of macro 'CONFIGFS_ATTR_WO' 145 | .store = _pfx##_name##_store, \ | ^~~~ drivers/spi/spi-mockup.c:365:1: note: in expansion of macro 'SPI_MOCKUP_ATTR' 365 | SPI_MOCKUP_ATTR(u16, flags) | ^~~~~~~~~~~~~~~ drivers/spi/spi-mockup.c:339:1: error: expected ',' or ';' before 'static' 339 | static ssize_t spi_mockup_ ## name ## _store(struct config_item *item, \ | ^~~~~~ drivers/spi/spi-mockup.c:366:1: note: in expansion of macro 'SPI_MOCKUP_ATTR' 366 | SPI_MOCKUP_ATTR(u16, num_cs) | ^~~~~~~~~~~~~~~ drivers/spi/spi-mockup.c:361:18: error: 'spi_mockup_num_cs_store' undeclared here (not in a function); did you mean 'spi_mockup_enable_store'? 361 | CONFIGFS_ATTR_WO(spi_mockup_, name) \ | ^~~~~~~~~~~ include/linux/configfs.h:145:27: note: in definition of macro 'CONFIGFS_ATTR_WO' 145 | .store = _pfx##_name##_store, \ | ^~~~ drivers/spi/spi-mockup.c:366:1: note: in expansion of macro 'SPI_MOCKUP_ATTR' 366 | SPI_MOCKUP_ATTR(u16, num_cs) | ^~~~~~~~~~~~~~~ drivers/spi/spi-mockup.c:368:1: error: expected ',' or ';' before 'static' 368 | static struct configfs_attribute *spi_mockup_configfs_attrs[] = { | ^~~~~~ drivers/spi/spi-mockup.c:380:27: error: 'spi_mockup_configfs_attrs' undeclared here (not in a function); did you mean 'spi_mockup_attrs'? 380 | .ct_attrs = spi_mockup_configfs_attrs, | ^~~~~~~~~~~~~~~~~~~~~~~~~ | spi_mockup_attrs >> drivers/spi/spi-mockup.c:361:18: warning: 'spi_mockup_attr_num_cs' defined but not used [-Wunused-variable] 361 | CONFIGFS_ATTR_WO(spi_mockup_, name) \ | ^~~~~~~~~~~ include/linux/configfs.h:141:34: note: in definition of macro 'CONFIGFS_ATTR_WO' 141 | static struct configfs_attribute _pfx##attr_##_name = { \ | ^~~~ drivers/spi/spi-mockup.c:366:1: note: in expansion of macro 'SPI_MOCKUP_ATTR' 366 | SPI_MOCKUP_ATTR(u16, num_cs) | ^~~~~~~~~~~~~~~ >> drivers/spi/spi-mockup.c:361:18: warning: 'spi_mockup_attr_flags' defined but not used [-Wunused-variable] 361 | CONFIGFS_ATTR_WO(spi_mockup_, name) \ | ^~~~~~~~~~~ include/linux/configfs.h:141:34: note: in definition of macro 'CONFIGFS_ATTR_WO' 141 | static struct configfs_attribute _pfx##attr_##_name = { \ | ^~~~ drivers/spi/spi-mockup.c:365:1: note: in expansion of macro 'SPI_MOCKUP_ATTR' 365 | SPI_MOCKUP_ATTR(u16, flags) | ^~~~~~~~~~~~~~~ >> drivers/spi/spi-mockup.c:361:18: warning: 'spi_mockup_attr_max_speed' defined but not used [-Wunused-variable] 361 | CONFIGFS_ATTR_WO(spi_mockup_, name) \ | ^~~~~~~~~~~ include/linux/configfs.h:141:34: note: in definition of macro 'CONFIGFS_ATTR_WO' 141 | static struct configfs_attribute _pfx##attr_##_name = { \ | ^~~~ drivers/spi/spi-mockup.c:364:1: note: in expansion of macro 'SPI_MOCKUP_ATTR' 364 | SPI_MOCKUP_ATTR(u32, max_speed) | ^~~~~~~~~~~~~~~ >> drivers/spi/spi-mockup.c:361:18: warning: 'spi_mockup_attr_min_speed' defined but not used [-Wunused-variable] 361 | CONFIGFS_ATTR_WO(spi_mockup_, name) \ | ^~~~~~~~~~~ include/linux/configfs.h:141:34: note: in definition of macro 'CONFIGFS_ATTR_WO' 141 | static struct configfs_attribute _pfx##attr_##_name = { \ | ^~~~ drivers/spi/spi-mockup.c:363:1: note: in expansion of macro 'SPI_MOCKUP_ATTR' 363 | SPI_MOCKUP_ATTR(u32, min_speed) | ^~~~~~~~~~~~~~~ >> drivers/spi/spi-mockup.c:336:18: warning: 'spi_mockup_attr_disable' defined but not used [-Wunused-variable] 336 | CONFIGFS_ATTR_WO(spi_mockup_, disable); | ^~~~~~~~~~~ include/linux/configfs.h:141:34: note: in definition of macro 'CONFIGFS_ATTR_WO' 141 | static struct configfs_attribute _pfx##attr_##_name = { \ | ^~~~ >> drivers/spi/spi-mockup.c:316:18: warning: 'spi_mockup_attr_enable' defined but not used [-Wunused-variable] 316 | CONFIGFS_ATTR_WO(spi_mockup_, enable); | ^~~~~~~~~~~ include/linux/configfs.h:141:34: note: in definition of macro 'CONFIGFS_ATTR_WO' 141 | static struct configfs_attribute _pfx##attr_##_name = { \ | ^~~~ Kconfig warnings: (for reference only) WARNING: unmet direct dependencies detected for BPF_EVENTS Depends on [n]: FTRACE [=n] && BPF_SYSCALL [=y] && (KPROBE_EVENTS [=n] || UPROBE_EVENTS [=n]) && PERF_EVENTS [=n] Selected by [y]: - SPI_MOCKUP [=y] && SPI [=y] && SPI_MASTER [=y] && OF [=y] vim +/spi_mockup_attr_num_cs +361 drivers/spi/spi-mockup.c 287 288 static ssize_t 289 spi_mockup_enable_store(struct config_item *item, const char *page, size_t len) 290 { 291 int ret = len; 292 struct platform_device_info pdevinfo = {0}; 293 struct spi_mockup_device *dev = to_spi_mockup_dev(item); 294 295 mutex_lock(&dev->lock); 296 if (dev->pdev) { 297 ret = -EEXIST; 298 goto out; 299 } 300 301 pdevinfo.name = "spi-mockup"; 302 pdevinfo.id = dev->bus_nr; 303 pdevinfo.data = &dev->data; 304 pdevinfo.size_data = sizeof(dev->data); 305 306 dev->pdev = platform_device_register_full(&pdevinfo); 307 if (IS_ERR(dev->pdev)) { 308 ret = PTR_ERR(dev->pdev); 309 dev->pdev = NULL; 310 goto out; 311 } 312 out: 313 mutex_unlock(&dev->lock); 314 return ret; 315 } > 316 CONFIGFS_ATTR_WO(spi_mockup_, enable); 317 318 static ssize_t 319 spi_mockup_disable_store(struct config_item *item, const char *page, size_t len) 320 { 321 int ret = len; 322 struct spi_mockup_device *dev = to_spi_mockup_dev(item); 323 324 mutex_lock(&dev->lock); 325 if (!dev->pdev) { 326 ret = -ENODEV; 327 goto out; 328 } 329 330 platform_device_unregister(dev->pdev); 331 dev->pdev = NULL; 332 out: 333 mutex_unlock(&dev->lock); 334 return ret; 335 } > 336 CONFIGFS_ATTR_WO(spi_mockup_, disable); 337 338 #define SPI_MOCKUP_ATTR(type, name) \ 339 static ssize_t spi_mockup_ ## name ## _store(struct config_item *item, \ 340 const char *page, size_t len) \ 341 { \ 342 int ret; \ 343 type val; \ 344 struct spi_mockup_device *dev = to_spi_mockup_dev(item); \ 345 \ 346 mutex_lock(&dev->lock); \ 347 if (dev->pdev) { \ 348 ret = -EBUSY; \ 349 goto out; \ 350 } \ 351 \ 352 ret = kstrto ## type(page, 0, &val); \ 353 if (ret) \ 354 goto out; \ 355 \ 356 dev->data.name = val; \ 357 out: \ 358 mutex_unlock(&dev->lock); \ 359 return ret ? ret : len; \ 360 } \ > 361 CONFIGFS_ATTR_WO(spi_mockup_, name) \ 362
diff --git a/drivers/spi/spi-mockup.c b/drivers/spi/spi-mockup.c index b449a2b7cdd4..06848504d144 100644 --- a/drivers/spi/spi-mockup.c +++ b/drivers/spi/spi-mockup.c @@ -207,11 +207,19 @@ static int spi_mockup_transfer(struct spi_controller *ctrl, return ret; } +struct spi_mockup_priv_data { + u32 min_speed; + u32 max_speed; + u16 flags; + u16 num_cs; +}; + static int spi_mockup_probe(struct platform_device *pdev) { int ret; struct mockup_spi *mock; struct spi_controller *ctrl; + struct spi_mockup_priv_data *data; ctrl = spi_alloc_host(&pdev->dev, sizeof(struct mockup_spi)); if (!ctrl) { @@ -228,6 +236,14 @@ static int spi_mockup_probe(struct platform_device *pdev) ctrl->bus_num = pdev->id; ctrl->transfer_one_message = spi_mockup_transfer; + data = dev_get_platdata(&pdev->dev); + if (data) { + ctrl->min_speed_hz = data->min_speed; + ctrl->max_speed_hz = data->max_speed; + ctrl->flags = data->flags; + ctrl->num_chipselect = data->num_cs; + } + mock = spi_controller_get_devdata(ctrl); mutex_init(&mock->lock); @@ -259,6 +275,7 @@ struct spi_mockup_device { unsigned int bus_nr; struct mutex lock; struct platform_device *pdev; + struct spi_mockup_priv_data data; }; static struct spi_mockup_device *to_spi_mockup_dev(struct config_item *item) @@ -283,6 +300,9 @@ spi_mockup_enable_store(struct config_item *item, const char *page, size_t len) pdevinfo.name = "spi-mockup"; pdevinfo.id = dev->bus_nr; + pdevinfo.data = &dev->data; + pdevinfo.size_data = sizeof(dev->data); + dev->pdev = platform_device_register_full(&pdevinfo); if (IS_ERR(dev->pdev)) { ret = PTR_ERR(dev->pdev); @@ -315,9 +335,43 @@ spi_mockup_disable_store(struct config_item *item, const char *page, size_t len) } CONFIGFS_ATTR_WO(spi_mockup_, disable); +#define SPI_MOCKUP_ATTR(type, name) \ +static ssize_t spi_mockup_ ## name ## _store(struct config_item *item, \ + const char *page, size_t len) \ +{ \ + int ret; \ + type val; \ + struct spi_mockup_device *dev = to_spi_mockup_dev(item); \ + \ + mutex_lock(&dev->lock); \ + if (dev->pdev) { \ + ret = -EBUSY; \ + goto out; \ + } \ + \ + ret = kstrto ## type(page, 0, &val); \ + if (ret) \ + goto out; \ + \ + dev->data.name = val; \ +out: \ + mutex_unlock(&dev->lock); \ + return ret ? ret : len; \ +} \ +CONFIGFS_ATTR_WO(spi_mockup_, name) \ + +SPI_MOCKUP_ATTR(u32, min_speed) +SPI_MOCKUP_ATTR(u32, max_speed) +SPI_MOCKUP_ATTR(u16, flags) +SPI_MOCKUP_ATTR(u16, num_cs) + static struct configfs_attribute *spi_mockup_configfs_attrs[] = { &spi_mockup_attr_enable, &spi_mockup_attr_disable, + &spi_mockup_attr_min_speed, + &spi_mockup_attr_max_speed, + &spi_mockup_attr_flags, + &spi_mockup_attr_num_cs, NULL, }; @@ -342,6 +396,7 @@ spi_mockup_config_make_device_group(struct config_group *group, if (!dev) return ERR_PTR(-ENOMEM); + dev->data.num_cs = MOCKUP_CHIPSELECT_MAX; dev->bus_nr = nr; mutex_init(&dev->lock);