Message ID | 20210521010359.635717-4-russell.h.weight@intel.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | fpga: Use standard class dev_release function | expand |
Hi Russ,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linux/master]
[also build test WARNING on linus/master v5.13-rc2 next-20210521]
[cannot apply to xlnx/master]
[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/Russ-Weight/fpga-Use-standard-class-dev_release-function/20210522-205631
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git dd860052c99b1e088352bdd4fb7aef46f8d2ef47
config: x86_64-randconfig-a014-20210522 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project e84a9b9bb3051c35dea993cdad7b3d2575638f85)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/2bd6e6762866ff1b80bea0d0d8377bcf9d2253ce
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Russ-Weight/fpga-Use-standard-class-dev_release-function/20210522-205631
git checkout 2bd6e6762866ff1b80bea0d0d8377bcf9d2253ce
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
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 >>):
>> drivers/fpga/fpga-region.c:193: warning: expecting prototype for fpga_region_create(). Prototype was for fpga_region_register() instead
vim +193 drivers/fpga/fpga-region.c
41a8b2c56470b7 Wu Hao 2018-06-30 181
9f368977b4589e Alan Tull 2018-05-16 182 /**
9f368977b4589e Alan Tull 2018-05-16 183 * fpga_region_create - alloc and init a struct fpga_region
9f368977b4589e Alan Tull 2018-05-16 184 * @dev: device parent
9f368977b4589e Alan Tull 2018-05-16 185 * @mgr: manager that programs this region
9f368977b4589e Alan Tull 2018-05-16 186 * @get_bridges: optional function to get bridges to a list
9f368977b4589e Alan Tull 2018-05-16 187 *
2bd6e6762866ff Russ Weight 2021-05-20 188 * Returns a struct fpga_region pointer on success, or ERR_PTR() on error.
9f368977b4589e Alan Tull 2018-05-16 189 */
2bd6e6762866ff Russ Weight 2021-05-20 190 struct fpga_region *
2bd6e6762866ff Russ Weight 2021-05-20 191 fpga_region_register(struct device *dev, struct fpga_manager *mgr,
9f368977b4589e Alan Tull 2018-05-16 192 int (*get_bridges)(struct fpga_region *))
0fa20cdfcc1f68 Alan Tull 2016-11-01 @193 {
9f368977b4589e Alan Tull 2018-05-16 194 struct fpga_region *region;
0fa20cdfcc1f68 Alan Tull 2016-11-01 195 int id, ret = 0;
0fa20cdfcc1f68 Alan Tull 2016-11-01 196
9f368977b4589e Alan Tull 2018-05-16 197 region = kzalloc(sizeof(*region), GFP_KERNEL);
9f368977b4589e Alan Tull 2018-05-16 198 if (!region)
2bd6e6762866ff Russ Weight 2021-05-20 199 return ERR_PTR(-ENOMEM);
9f368977b4589e Alan Tull 2018-05-16 200
0fa20cdfcc1f68 Alan Tull 2016-11-01 201 id = ida_simple_get(&fpga_region_ida, 0, 0, GFP_KERNEL);
52a3a7ccce07e7 Alan Tull 2017-11-15 202 if (id < 0)
9f368977b4589e Alan Tull 2018-05-16 203 goto err_free;
0fa20cdfcc1f68 Alan Tull 2016-11-01 204
9f368977b4589e Alan Tull 2018-05-16 205 region->mgr = mgr;
9f368977b4589e Alan Tull 2018-05-16 206 region->get_bridges = get_bridges;
0fa20cdfcc1f68 Alan Tull 2016-11-01 207 mutex_init(®ion->mutex);
0fa20cdfcc1f68 Alan Tull 2016-11-01 208 INIT_LIST_HEAD(®ion->bridge_list);
9f368977b4589e Alan Tull 2018-05-16 209
0fa20cdfcc1f68 Alan Tull 2016-11-01 210 region->dev.class = fpga_region_class;
0fa20cdfcc1f68 Alan Tull 2016-11-01 211 region->dev.parent = dev;
52a3a7ccce07e7 Alan Tull 2017-11-15 212 region->dev.of_node = dev->of_node;
0fa20cdfcc1f68 Alan Tull 2016-11-01 213 region->dev.id = id;
0fa20cdfcc1f68 Alan Tull 2016-11-01 214
0fa20cdfcc1f68 Alan Tull 2016-11-01 215 ret = dev_set_name(®ion->dev, "region%d", id);
0fa20cdfcc1f68 Alan Tull 2016-11-01 216 if (ret)
0fa20cdfcc1f68 Alan Tull 2016-11-01 217 goto err_remove;
0fa20cdfcc1f68 Alan Tull 2016-11-01 218
2bd6e6762866ff Russ Weight 2021-05-20 219 ret = device_register(®ion->dev);
2bd6e6762866ff Russ Weight 2021-05-20 220 if (ret) {
2bd6e6762866ff Russ Weight 2021-05-20 221 put_device(®ion->dev);
2bd6e6762866ff Russ Weight 2021-05-20 222 return ERR_PTR(ret);
2bd6e6762866ff Russ Weight 2021-05-20 223 }
2bd6e6762866ff Russ Weight 2021-05-20 224
9f368977b4589e Alan Tull 2018-05-16 225 return region;
52a3a7ccce07e7 Alan Tull 2017-11-15 226
52a3a7ccce07e7 Alan Tull 2017-11-15 227 err_remove:
52a3a7ccce07e7 Alan Tull 2017-11-15 228 ida_simple_remove(&fpga_region_ida, id);
9f368977b4589e Alan Tull 2018-05-16 229 err_free:
9f368977b4589e Alan Tull 2018-05-16 230 kfree(region);
9f368977b4589e Alan Tull 2018-05-16 231
2bd6e6762866ff Russ Weight 2021-05-20 232 return ERR_PTR(ret);
52a3a7ccce07e7 Alan Tull 2017-11-15 233 }
52a3a7ccce07e7 Alan Tull 2017-11-15 234 EXPORT_SYMBOL_GPL(fpga_region_register);
52a3a7ccce07e7 Alan Tull 2017-11-15 235
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Hi Russ,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linux/master]
[also build test WARNING on linus/master v5.13-rc2 next-20210521]
[cannot apply to xlnx/master]
[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/Russ-Weight/fpga-Use-standard-class-dev_release-function/20210522-205631
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git dd860052c99b1e088352bdd4fb7aef46f8d2ef47
config: arm64-randconfig-p001-20210522 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/2bd6e6762866ff1b80bea0d0d8377bcf9d2253ce
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Russ-Weight/fpga-Use-standard-class-dev_release-function/20210522-205631
git checkout 2bd6e6762866ff1b80bea0d0d8377bcf9d2253ce
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm64
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 >>):
>> drivers/fpga/fpga-region.c:193: warning: expecting prototype for fpga_region_create(). Prototype was for fpga_region_register() instead
vim +193 drivers/fpga/fpga-region.c
41a8b2c56470b7 Wu Hao 2018-06-30 181
9f368977b4589e Alan Tull 2018-05-16 182 /**
9f368977b4589e Alan Tull 2018-05-16 183 * fpga_region_create - alloc and init a struct fpga_region
9f368977b4589e Alan Tull 2018-05-16 184 * @dev: device parent
9f368977b4589e Alan Tull 2018-05-16 185 * @mgr: manager that programs this region
9f368977b4589e Alan Tull 2018-05-16 186 * @get_bridges: optional function to get bridges to a list
9f368977b4589e Alan Tull 2018-05-16 187 *
2bd6e6762866ff Russ Weight 2021-05-20 188 * Returns a struct fpga_region pointer on success, or ERR_PTR() on error.
9f368977b4589e Alan Tull 2018-05-16 189 */
2bd6e6762866ff Russ Weight 2021-05-20 190 struct fpga_region *
2bd6e6762866ff Russ Weight 2021-05-20 191 fpga_region_register(struct device *dev, struct fpga_manager *mgr,
9f368977b4589e Alan Tull 2018-05-16 192 int (*get_bridges)(struct fpga_region *))
0fa20cdfcc1f68 Alan Tull 2016-11-01 @193 {
9f368977b4589e Alan Tull 2018-05-16 194 struct fpga_region *region;
0fa20cdfcc1f68 Alan Tull 2016-11-01 195 int id, ret = 0;
0fa20cdfcc1f68 Alan Tull 2016-11-01 196
9f368977b4589e Alan Tull 2018-05-16 197 region = kzalloc(sizeof(*region), GFP_KERNEL);
9f368977b4589e Alan Tull 2018-05-16 198 if (!region)
2bd6e6762866ff Russ Weight 2021-05-20 199 return ERR_PTR(-ENOMEM);
9f368977b4589e Alan Tull 2018-05-16 200
0fa20cdfcc1f68 Alan Tull 2016-11-01 201 id = ida_simple_get(&fpga_region_ida, 0, 0, GFP_KERNEL);
52a3a7ccce07e7 Alan Tull 2017-11-15 202 if (id < 0)
9f368977b4589e Alan Tull 2018-05-16 203 goto err_free;
0fa20cdfcc1f68 Alan Tull 2016-11-01 204
9f368977b4589e Alan Tull 2018-05-16 205 region->mgr = mgr;
9f368977b4589e Alan Tull 2018-05-16 206 region->get_bridges = get_bridges;
0fa20cdfcc1f68 Alan Tull 2016-11-01 207 mutex_init(®ion->mutex);
0fa20cdfcc1f68 Alan Tull 2016-11-01 208 INIT_LIST_HEAD(®ion->bridge_list);
9f368977b4589e Alan Tull 2018-05-16 209
0fa20cdfcc1f68 Alan Tull 2016-11-01 210 region->dev.class = fpga_region_class;
0fa20cdfcc1f68 Alan Tull 2016-11-01 211 region->dev.parent = dev;
52a3a7ccce07e7 Alan Tull 2017-11-15 212 region->dev.of_node = dev->of_node;
0fa20cdfcc1f68 Alan Tull 2016-11-01 213 region->dev.id = id;
0fa20cdfcc1f68 Alan Tull 2016-11-01 214
0fa20cdfcc1f68 Alan Tull 2016-11-01 215 ret = dev_set_name(®ion->dev, "region%d", id);
0fa20cdfcc1f68 Alan Tull 2016-11-01 216 if (ret)
0fa20cdfcc1f68 Alan Tull 2016-11-01 217 goto err_remove;
0fa20cdfcc1f68 Alan Tull 2016-11-01 218
2bd6e6762866ff Russ Weight 2021-05-20 219 ret = device_register(®ion->dev);
2bd6e6762866ff Russ Weight 2021-05-20 220 if (ret) {
2bd6e6762866ff Russ Weight 2021-05-20 221 put_device(®ion->dev);
2bd6e6762866ff Russ Weight 2021-05-20 222 return ERR_PTR(ret);
2bd6e6762866ff Russ Weight 2021-05-20 223 }
2bd6e6762866ff Russ Weight 2021-05-20 224
9f368977b4589e Alan Tull 2018-05-16 225 return region;
52a3a7ccce07e7 Alan Tull 2017-11-15 226
52a3a7ccce07e7 Alan Tull 2017-11-15 227 err_remove:
52a3a7ccce07e7 Alan Tull 2017-11-15 228 ida_simple_remove(&fpga_region_ida, id);
9f368977b4589e Alan Tull 2018-05-16 229 err_free:
9f368977b4589e Alan Tull 2018-05-16 230 kfree(region);
9f368977b4589e Alan Tull 2018-05-16 231
2bd6e6762866ff Russ Weight 2021-05-20 232 return ERR_PTR(ret);
52a3a7ccce07e7 Alan Tull 2017-11-15 233 }
52a3a7ccce07e7 Alan Tull 2017-11-15 234 EXPORT_SYMBOL_GPL(fpga_region_register);
52a3a7ccce07e7 Alan Tull 2017-11-15 235
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff --git a/drivers/fpga/dfl-fme-region.c b/drivers/fpga/dfl-fme-region.c index 1eeb42af1012..631c8ce160e3 100644 --- a/drivers/fpga/dfl-fme-region.c +++ b/drivers/fpga/dfl-fme-region.c @@ -39,9 +39,9 @@ static int fme_region_probe(struct platform_device *pdev) if (IS_ERR(mgr)) return -EPROBE_DEFER; - region = devm_fpga_region_create(dev, mgr, fme_region_get_bridges); - if (!region) { - ret = -ENOMEM; + region = fpga_region_register(dev, mgr, fme_region_get_bridges); + if (IS_ERR(region)) { + ret = PTR_ERR(region); goto eprobe_mgr_put; } @@ -49,10 +49,6 @@ static int fme_region_probe(struct platform_device *pdev) region->compat_id = mgr->compat_id; platform_set_drvdata(pdev, region); - ret = fpga_region_register(region); - if (ret) - goto eprobe_mgr_put; - dev_dbg(dev, "DFL FME FPGA Region probed\n"); return 0; diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c index 511b20ff35a3..2fb3a5bfe4df 100644 --- a/drivers/fpga/dfl.c +++ b/drivers/fpga/dfl.c @@ -1400,9 +1400,9 @@ dfl_fpga_feature_devs_enumerate(struct dfl_fpga_enum_info *info) if (!cdev) return ERR_PTR(-ENOMEM); - cdev->region = devm_fpga_region_create(info->dev, NULL, NULL); - if (!cdev->region) { - ret = -ENOMEM; + cdev->region = fpga_region_register(info->dev, NULL, NULL); + if (IS_ERR(cdev->region)) { + ret = PTR_ERR(cdev->region); goto free_cdev_exit; } @@ -1410,10 +1410,6 @@ dfl_fpga_feature_devs_enumerate(struct dfl_fpga_enum_info *info) mutex_init(&cdev->lock); INIT_LIST_HEAD(&cdev->port_dev_list); - ret = fpga_region_register(cdev->region); - if (ret) - goto free_cdev_exit; - /* create and init build info for enumeration */ binfo = devm_kzalloc(info->dev, sizeof(*binfo), GFP_KERNEL); if (!binfo) { diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c index c3134b89c3fe..622b9d598758 100644 --- a/drivers/fpga/fpga-region.c +++ b/drivers/fpga/fpga-region.c @@ -185,23 +185,18 @@ ATTRIBUTE_GROUPS(fpga_region); * @mgr: manager that programs this region * @get_bridges: optional function to get bridges to a list * - * The caller of this function is responsible for freeing the resulting region - * struct with fpga_region_free(). Using devm_fpga_region_create() instead is - * recommended. - * - * Return: struct fpga_region or NULL + * Returns a struct fpga_region pointer on success, or ERR_PTR() on error. */ -struct fpga_region -*fpga_region_create(struct device *dev, - struct fpga_manager *mgr, - int (*get_bridges)(struct fpga_region *)) +struct fpga_region * +fpga_region_register(struct device *dev, struct fpga_manager *mgr, + int (*get_bridges)(struct fpga_region *)) { struct fpga_region *region; int id, ret = 0; region = kzalloc(sizeof(*region), GFP_KERNEL); if (!region) - return NULL; + return ERR_PTR(-ENOMEM); id = ida_simple_get(&fpga_region_ida, 0, 0, GFP_KERNEL); if (id < 0) @@ -212,7 +207,6 @@ struct fpga_region mutex_init(®ion->mutex); INIT_LIST_HEAD(®ion->bridge_list); - device_initialize(®ion->dev); region->dev.class = fpga_region_class; region->dev.parent = dev; region->dev.of_node = dev->of_node; @@ -222,6 +216,12 @@ struct fpga_region if (ret) goto err_remove; + ret = device_register(®ion->dev); + if (ret) { + put_device(®ion->dev); + return ERR_PTR(ret); + } + return region; err_remove: @@ -229,76 +229,7 @@ struct fpga_region err_free: kfree(region); - return NULL; -} -EXPORT_SYMBOL_GPL(fpga_region_create); - -/** - * fpga_region_free - free a FPGA region created by fpga_region_create() - * @region: FPGA region - */ -void fpga_region_free(struct fpga_region *region) -{ - ida_simple_remove(&fpga_region_ida, region->dev.id); - kfree(region); -} -EXPORT_SYMBOL_GPL(fpga_region_free); - -static void devm_fpga_region_release(struct device *dev, void *res) -{ - struct fpga_region *region = *(struct fpga_region **)res; - - fpga_region_free(region); -} - -/** - * devm_fpga_region_create - create and initialize a managed FPGA region struct - * @dev: device parent - * @mgr: manager that programs this region - * @get_bridges: optional function to get bridges to a list - * - * This function is intended for use in a FPGA region driver's probe function. - * After the region driver creates the region struct with - * devm_fpga_region_create(), it should register it with fpga_region_register(). - * The region driver's remove function should call fpga_region_unregister(). - * The region struct allocated with this function will be freed automatically on - * driver detach. This includes the case of a probe function returning error - * before calling fpga_region_register(), the struct will still get cleaned up. - * - * Return: struct fpga_region or NULL - */ -struct fpga_region -*devm_fpga_region_create(struct device *dev, - struct fpga_manager *mgr, - int (*get_bridges)(struct fpga_region *)) -{ - struct fpga_region **ptr, *region; - - ptr = devres_alloc(devm_fpga_region_release, sizeof(*ptr), GFP_KERNEL); - if (!ptr) - return NULL; - - region = fpga_region_create(dev, mgr, get_bridges); - if (!region) { - devres_free(ptr); - } else { - *ptr = region; - devres_add(dev, ptr); - } - - return region; -} -EXPORT_SYMBOL_GPL(devm_fpga_region_create); - -/** - * fpga_region_register - register a FPGA region - * @region: FPGA region - * - * Return: 0 or -errno - */ -int fpga_region_register(struct fpga_region *region) -{ - return device_add(®ion->dev); + return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(fpga_region_register); @@ -316,6 +247,10 @@ EXPORT_SYMBOL_GPL(fpga_region_unregister); static void fpga_region_dev_release(struct device *dev) { + struct fpga_region *region = to_fpga_region(dev); + + ida_simple_remove(&fpga_region_ida, region->dev.id); + kfree(region); } /** diff --git a/drivers/fpga/of-fpga-region.c b/drivers/fpga/of-fpga-region.c index e405309baadc..466e083654ae 100644 --- a/drivers/fpga/of-fpga-region.c +++ b/drivers/fpga/of-fpga-region.c @@ -405,16 +405,12 @@ static int of_fpga_region_probe(struct platform_device *pdev) if (IS_ERR(mgr)) return -EPROBE_DEFER; - region = devm_fpga_region_create(dev, mgr, of_fpga_region_get_bridges); - if (!region) { - ret = -ENOMEM; + region = fpga_region_register(dev, mgr, of_fpga_region_get_bridges); + if (IS_ERR(region)) { + ret = PTR_ERR(region); goto eprobe_mgr_put; } - ret = fpga_region_register(region); - if (ret) - goto eprobe_mgr_put; - of_platform_populate(np, fpga_region_of_match, NULL, ®ion->dev); platform_set_drvdata(pdev, region); diff --git a/include/linux/fpga/fpga-region.h b/include/linux/fpga/fpga-region.h index 27cb706275db..ca793f43af14 100644 --- a/include/linux/fpga/fpga-region.h +++ b/include/linux/fpga/fpga-region.h @@ -37,15 +37,9 @@ struct fpga_region *fpga_region_class_find( int fpga_region_program_fpga(struct fpga_region *region); -struct fpga_region -*fpga_region_create(struct device *dev, struct fpga_manager *mgr, - int (*get_bridges)(struct fpga_region *)); -void fpga_region_free(struct fpga_region *region); -int fpga_region_register(struct fpga_region *region); +struct fpga_region * +fpga_region_register(struct device *dev, struct fpga_manager *mgr, + int (*get_bridges)(struct fpga_region *)); void fpga_region_unregister(struct fpga_region *region); -struct fpga_region -*devm_fpga_region_create(struct device *dev, struct fpga_manager *mgr, - int (*get_bridges)(struct fpga_region *)); - #endif /* _FPGA_REGION_H */
The FPGA region class driver data structure is being treated as a managed resource instead of using standard dev_release call-back to release the class data structure. This change removes the managed resource code and combines the create() and register() functions into a single register() function. Signed-off-by: Russ Weight <russell.h.weight@intel.com> --- drivers/fpga/dfl-fme-region.c | 10 +--- drivers/fpga/dfl.c | 10 +--- drivers/fpga/fpga-region.c | 97 ++++++-------------------------- drivers/fpga/of-fpga-region.c | 10 +--- include/linux/fpga/fpga-region.h | 12 +--- 5 files changed, 28 insertions(+), 111 deletions(-)