* Re: [PATCH V5 net-next 1/8] debugfs: Add debugfs_create_devm_dir() helper
@ 2024-12-09 4:11 kernel test robot
0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2024-12-09 4:11 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20241206111629.3521865-2-shaojijie@huawei.com>
References: <20241206111629.3521865-2-shaojijie@huawei.com>
TO: Jijie Shao <shaojijie@huawei.com>
TO: davem@davemloft.net
TO: edumazet@google.com
TO: kuba@kernel.org
TO: pabeni@redhat.com
TO: andrew+netdev@lunn.ch
TO: horms@kernel.org
TO: gregkh@linuxfoundation.org
CC: shenjian15@huawei.com
CC: wangpeiyang1@huawei.com
CC: liuyonglong@huawei.com
CC: chenhao418@huawei.com
CC: sudongming1@huawei.com
CC: xujunsheng@huawei.com
CC: shiyongbang@huawei.com
CC: libaihan@huawei.com
CC: jonathan.cameron@huawei.com
CC: shameerali.kolothum.thodi@huawei.com
CC: salil.mehta@huawei.com
CC: netdev@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: shaojijie@huawei.com
CC: hkelam@marvell.com
Hi Jijie,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Jijie-Shao/debugfs-Add-debugfs_create_devm_dir-helper/20241206-192734
base: net-next/main
patch link: https://lore.kernel.org/r/20241206111629.3521865-2-shaojijie%40huawei.com
patch subject: [PATCH V5 net-next 1/8] debugfs: Add debugfs_create_devm_dir() helper
:::::: branch date: 20 hours ago
:::::: commit date: 20 hours ago
config: i386-randconfig-141-20241206 (https://download.01.org/0day-ci/archive/20241207/202412071523.XnSXmPPZ-lkp@intel.com/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
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>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202412071523.XnSXmPPZ-lkp@intel.com/
smatch warnings:
fs/debugfs/inode.c:643 debugfs_create_devm_dir() warn: unchecked 'ERR_PTR'
vim +/ERR_PTR +643 fs/debugfs/inode.c
d44644eefac450 Jijie Shao 2024-12-06 619
d44644eefac450 Jijie Shao 2024-12-06 620 /**
d44644eefac450 Jijie Shao 2024-12-06 621 * debugfs_create_devm_dir - Managed debugfs_create_dir()
d44644eefac450 Jijie Shao 2024-12-06 622 * @dev: Device that owns the action
d44644eefac450 Jijie Shao 2024-12-06 623 * @name: a pointer to a string containing the name of the directory to
d44644eefac450 Jijie Shao 2024-12-06 624 * create.
d44644eefac450 Jijie Shao 2024-12-06 625 * @parent: a pointer to the parent dentry for this file. This should be a
d44644eefac450 Jijie Shao 2024-12-06 626 * directory dentry if set. If this parameter is NULL, then the
d44644eefac450 Jijie Shao 2024-12-06 627 * directory will be created in the root of the debugfs filesystem.
d44644eefac450 Jijie Shao 2024-12-06 628 * Managed debugfs_create_dir(). dentry will automatically be remove on
d44644eefac450 Jijie Shao 2024-12-06 629 * driver detach.
d44644eefac450 Jijie Shao 2024-12-06 630 */
d44644eefac450 Jijie Shao 2024-12-06 631 struct dentry *debugfs_create_devm_dir(struct device *dev, const char *name,
d44644eefac450 Jijie Shao 2024-12-06 632 struct dentry *parent)
d44644eefac450 Jijie Shao 2024-12-06 633 {
d44644eefac450 Jijie Shao 2024-12-06 634 struct dentry *dentry;
d44644eefac450 Jijie Shao 2024-12-06 635 int ret;
d44644eefac450 Jijie Shao 2024-12-06 636
d44644eefac450 Jijie Shao 2024-12-06 637 dentry = debugfs_create_dir(name, parent);
d44644eefac450 Jijie Shao 2024-12-06 638 if (IS_ERR(dentry))
d44644eefac450 Jijie Shao 2024-12-06 639 return dentry;
d44644eefac450 Jijie Shao 2024-12-06 640
d44644eefac450 Jijie Shao 2024-12-06 641 ret = devm_add_action_or_reset(dev, debugfs_remove_devm, dentry);
d44644eefac450 Jijie Shao 2024-12-06 642 if (ret)
d44644eefac450 Jijie Shao 2024-12-06 @643 ERR_PTR(ret);
d44644eefac450 Jijie Shao 2024-12-06 644
d44644eefac450 Jijie Shao 2024-12-06 645 return dentry;
d44644eefac450 Jijie Shao 2024-12-06 646 }
d44644eefac450 Jijie Shao 2024-12-06 647 EXPORT_SYMBOL_GPL(debugfs_create_devm_dir);
d44644eefac450 Jijie Shao 2024-12-06 648
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH V5 net-next 0/8] Support some features for the HIBMCGE driver
@ 2024-12-06 11:16 Jijie Shao
2024-12-06 11:16 ` [PATCH V5 net-next 1/8] debugfs: Add debugfs_create_devm_dir() helper Jijie Shao
0 siblings, 1 reply; 8+ messages in thread
From: Jijie Shao @ 2024-12-06 11:16 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, andrew+netdev, horms, gregkh
Cc: shenjian15, wangpeiyang1, liuyonglong, chenhao418, sudongming1,
xujunsheng, shiyongbang, libaihan, jonathan.cameron,
shameerali.kolothum.thodi, salil.mehta, netdev, linux-kernel,
shaojijie, hkelam
In this patch series, The HIBMCGE driver implements some functions
such as dump register, unicast MAC address filtering, debugfs and reset.
---
ChangeLog:
v4 -> v5:
- Add debugfs_create_devm_dir() helper, suggested by Jakub.
- Simplify reset logic by optimizing release and re-hold rtnl lock, suggested by Jakub.
v4: https://lore.kernel.org/all/20241203150131.3139399-1-shaojijie@huawei.com/
v3 -> v4:
- Support auto-neg pause, suggested by Andrew.
v3: https://lore.kernel.org/all/20241111145558.1965325-1-shaojijie@huawei.com/
v2 -> v3:
- Not not dump in ethtool statistics which can be accessed via standard APIs,
suggested by Jakub. The relevant patche is removed from this patch series,
and the statistically relevant patches will be sent separately.
v2: https://lore.kernel.org/all/20241026115740.633503-1-shaojijie@huawei.com/
v1 -> v2:
- Remove debugfs file 'dev_specs' because the dump register
does the same thing, suggested by Andrew.
- Move 'tx timeout cnt' from debugfs to ethtool -S, suggested by Andrew.
- Ignore the error code of the debugfs initialization failure, suggested by Andrew.
- Add a new patch for debugfs file 'irq_info', suggested by Andrew.
- Add somme comments for filtering, suggested by Andrew.
- Not pass back ASCII text in dump register, suggested by Andrew.
v1: https://lore.kernel.org/all/20241023134213.3359092-1-shaojijie@huawei.com/
---
Jijie Shao (8):
debugfs: Add debugfs_create_devm_dir() helper
net: hibmcge: Add debugfs supported in this module
net: hibmcge: Add irq_info file to debugfs
net: hibmcge: Add unicast frame filter supported in this module
net: hibmcge: Add register dump supported in this module
net: hibmcge: Add pauseparam supported in this module
net: hibmcge: Add reset supported in this module
net: hibmcge: Add nway_reset supported in this module
.../net/ethernet/hisilicon/hibmcge/Makefile | 3 +-
.../ethernet/hisilicon/hibmcge/hbg_common.h | 30 +++
.../ethernet/hisilicon/hibmcge/hbg_debugfs.c | 155 +++++++++++++
.../ethernet/hisilicon/hibmcge/hbg_debugfs.h | 12 +
.../net/ethernet/hisilicon/hibmcge/hbg_err.c | 137 +++++++++++
.../net/ethernet/hisilicon/hibmcge/hbg_err.h | 13 ++
.../ethernet/hisilicon/hibmcge/hbg_ethtool.c | 187 +++++++++++++++
.../net/ethernet/hisilicon/hibmcge/hbg_hw.c | 48 +++-
.../net/ethernet/hisilicon/hibmcge/hbg_hw.h | 6 +-
.../net/ethernet/hisilicon/hibmcge/hbg_main.c | 212 ++++++++++++++++--
.../net/ethernet/hisilicon/hibmcge/hbg_mdio.c | 15 ++
.../net/ethernet/hisilicon/hibmcge/hbg_reg.h | 39 ++++
fs/debugfs/inode.c | 36 +++
include/linux/debugfs.h | 10 +
14 files changed, 875 insertions(+), 28 deletions(-)
create mode 100644 drivers/net/ethernet/hisilicon/hibmcge/hbg_debugfs.c
create mode 100644 drivers/net/ethernet/hisilicon/hibmcge/hbg_debugfs.h
create mode 100644 drivers/net/ethernet/hisilicon/hibmcge/hbg_err.c
create mode 100644 drivers/net/ethernet/hisilicon/hibmcge/hbg_err.h
--
2.33.0
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH V5 net-next 1/8] debugfs: Add debugfs_create_devm_dir() helper 2024-12-06 11:16 [PATCH V5 net-next 0/8] Support some features for the HIBMCGE driver Jijie Shao @ 2024-12-06 11:16 ` Jijie Shao 2024-12-06 11:40 ` Greg KH ` (2 more replies) 0 siblings, 3 replies; 8+ messages in thread From: Jijie Shao @ 2024-12-06 11:16 UTC (permalink / raw) To: davem, edumazet, kuba, pabeni, andrew+netdev, horms, gregkh Cc: shenjian15, wangpeiyang1, liuyonglong, chenhao418, sudongming1, xujunsheng, shiyongbang, libaihan, jonathan.cameron, shameerali.kolothum.thodi, salil.mehta, netdev, linux-kernel, shaojijie, hkelam Add debugfs_create_devm_dir() helper Signed-off-by: Jijie Shao <shaojijie@huawei.com> --- fs/debugfs/inode.c | 36 ++++++++++++++++++++++++++++++++++++ include/linux/debugfs.h | 10 ++++++++++ 2 files changed, 46 insertions(+) diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index 38a9c7eb97e6..f682c4952a27 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -610,6 +610,42 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) } EXPORT_SYMBOL_GPL(debugfs_create_dir); +static void debugfs_remove_devm(void *dentry_rwa) +{ + struct dentry *dentry = dentry_rwa; + + debugfs_remove(dentry); +} + +/** + * debugfs_create_devm_dir - Managed debugfs_create_dir() + * @dev: Device that owns the action + * @name: a pointer to a string containing the name of the directory to + * create. + * @parent: a pointer to the parent dentry for this file. This should be a + * directory dentry if set. If this parameter is NULL, then the + * directory will be created in the root of the debugfs filesystem. + * Managed debugfs_create_dir(). dentry will automatically be remove on + * driver detach. + */ +struct dentry *debugfs_create_devm_dir(struct device *dev, const char *name, + struct dentry *parent) +{ + struct dentry *dentry; + int ret; + + dentry = debugfs_create_dir(name, parent); + if (IS_ERR(dentry)) + return dentry; + + ret = devm_add_action_or_reset(dev, debugfs_remove_devm, dentry); + if (ret) + ERR_PTR(ret); + + return dentry; +} +EXPORT_SYMBOL_GPL(debugfs_create_devm_dir); + /** * debugfs_create_automount - create automount point in the debugfs filesystem * @name: a pointer to a string containing the name of the file to create. diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h index 59444b495d49..19d8c322debe 100644 --- a/include/linux/debugfs.h +++ b/include/linux/debugfs.h @@ -139,6 +139,9 @@ void debugfs_create_file_size(const char *name, umode_t mode, struct dentry *debugfs_create_dir(const char *name, struct dentry *parent); +struct dentry *debugfs_create_devm_dir(struct device *dev, const char *name, + struct dentry *parent); + struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, const char *dest); @@ -286,6 +289,13 @@ static inline struct dentry *debugfs_create_dir(const char *name, return ERR_PTR(-ENODEV); } +static inline struct dentry *debugfs_create_devm_dir(struct device *dev, + const char *name, + struct dentry *parent) +{ + return ERR_PTR(-ENODEV); +} + static inline struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, const char *dest) -- 2.33.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH V5 net-next 1/8] debugfs: Add debugfs_create_devm_dir() helper 2024-12-06 11:16 ` [PATCH V5 net-next 1/8] debugfs: Add debugfs_create_devm_dir() helper Jijie Shao @ 2024-12-06 11:40 ` Greg KH 2024-12-09 1:02 ` Jijie Shao 2024-12-06 14:57 ` kernel test robot 2024-12-06 16:50 ` kernel test robot 2 siblings, 1 reply; 8+ messages in thread From: Greg KH @ 2024-12-06 11:40 UTC (permalink / raw) To: Jijie Shao Cc: davem, edumazet, kuba, pabeni, andrew+netdev, horms, shenjian15, wangpeiyang1, liuyonglong, chenhao418, sudongming1, xujunsheng, shiyongbang, libaihan, jonathan.cameron, shameerali.kolothum.thodi, salil.mehta, netdev, linux-kernel, hkelam On Fri, Dec 06, 2024 at 07:16:22PM +0800, Jijie Shao wrote: > Add debugfs_create_devm_dir() helper > > Signed-off-by: Jijie Shao <shaojijie@huawei.com> > --- > fs/debugfs/inode.c | 36 ++++++++++++++++++++++++++++++++++++ > include/linux/debugfs.h | 10 ++++++++++ > 2 files changed, 46 insertions(+) > > diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c > index 38a9c7eb97e6..f682c4952a27 100644 > --- a/fs/debugfs/inode.c > +++ b/fs/debugfs/inode.c > @@ -610,6 +610,42 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) > } > EXPORT_SYMBOL_GPL(debugfs_create_dir); > > +static void debugfs_remove_devm(void *dentry_rwa) > +{ > + struct dentry *dentry = dentry_rwa; > + > + debugfs_remove(dentry); > +} > + > +/** > + * debugfs_create_devm_dir - Managed debugfs_create_dir() > + * @dev: Device that owns the action > + * @name: a pointer to a string containing the name of the directory to > + * create. > + * @parent: a pointer to the parent dentry for this file. This should be a > + * directory dentry if set. If this parameter is NULL, then the > + * directory will be created in the root of the debugfs filesystem. > + * Managed debugfs_create_dir(). dentry will automatically be remove on > + * driver detach. > + */ > +struct dentry *debugfs_create_devm_dir(struct device *dev, const char *name, > + struct dentry *parent) > +{ > + struct dentry *dentry; > + int ret; > + > + dentry = debugfs_create_dir(name, parent); > + if (IS_ERR(dentry)) > + return dentry; > + > + ret = devm_add_action_or_reset(dev, debugfs_remove_devm, dentry); > + if (ret) > + ERR_PTR(ret); You don't clean up the directory you created if this failed? Why not? thanks, greg k-h ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V5 net-next 1/8] debugfs: Add debugfs_create_devm_dir() helper 2024-12-06 11:40 ` Greg KH @ 2024-12-09 1:02 ` Jijie Shao 2024-12-09 6:31 ` Greg KH 0 siblings, 1 reply; 8+ messages in thread From: Jijie Shao @ 2024-12-09 1:02 UTC (permalink / raw) To: Greg KH Cc: shaojijie, davem, edumazet, kuba, pabeni, andrew+netdev, horms, shenjian15, wangpeiyang1, liuyonglong, chenhao418, sudongming1, xujunsheng, shiyongbang, libaihan, jonathan.cameron, shameerali.kolothum.thodi, salil.mehta, netdev, linux-kernel, hkelam on 2024/12/6 19:40, Greg KH wrote: > On Fri, Dec 06, 2024 at 07:16:22PM +0800, Jijie Shao wrote: >> Add debugfs_create_devm_dir() helper >> >> Signed-off-by: Jijie Shao <shaojijie@huawei.com> >> --- >> fs/debugfs/inode.c | 36 ++++++++++++++++++++++++++++++++++++ >> include/linux/debugfs.h | 10 ++++++++++ >> 2 files changed, 46 insertions(+) >> >> diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c >> index 38a9c7eb97e6..f682c4952a27 100644 >> --- a/fs/debugfs/inode.c >> +++ b/fs/debugfs/inode.c >> @@ -610,6 +610,42 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) >> } >> EXPORT_SYMBOL_GPL(debugfs_create_dir); >> >> +static void debugfs_remove_devm(void *dentry_rwa) >> +{ >> + struct dentry *dentry = dentry_rwa; >> + >> + debugfs_remove(dentry); >> +} >> + >> +/** >> + * debugfs_create_devm_dir - Managed debugfs_create_dir() >> + * @dev: Device that owns the action >> + * @name: a pointer to a string containing the name of the directory to >> + * create. >> + * @parent: a pointer to the parent dentry for this file. This should be a >> + * directory dentry if set. If this parameter is NULL, then the >> + * directory will be created in the root of the debugfs filesystem. >> + * Managed debugfs_create_dir(). dentry will automatically be remove on >> + * driver detach. >> + */ >> +struct dentry *debugfs_create_devm_dir(struct device *dev, const char *name, >> + struct dentry *parent) >> +{ >> + struct dentry *dentry; >> + int ret; >> + >> + dentry = debugfs_create_dir(name, parent); >> + if (IS_ERR(dentry)) >> + return dentry; >> + >> + ret = devm_add_action_or_reset(dev, debugfs_remove_devm, dentry); >> + if (ret) >> + ERR_PTR(ret); > You don't clean up the directory you created if this failed? Why not? Don't need to clean up. in devm_add_action_or_reset(), if failed, will call action: debugfs_remove_devm(), So, not clean up again. #define devm_add_action_or_reset(dev, action, data) \ __devm_add_action_or_reset(dev, action, data, #action) static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *), void *data, const char *name) { int ret; ret = __devm_add_action(dev, action, data, name); if (ret) action(data); return ret; } But there's a problem with this, I missed return. I will add return in v6. Thanks, Jijie Shao ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V5 net-next 1/8] debugfs: Add debugfs_create_devm_dir() helper 2024-12-09 1:02 ` Jijie Shao @ 2024-12-09 6:31 ` Greg KH 2024-12-09 10:33 ` Jijie Shao 0 siblings, 1 reply; 8+ messages in thread From: Greg KH @ 2024-12-09 6:31 UTC (permalink / raw) To: Jijie Shao Cc: davem, edumazet, kuba, pabeni, andrew+netdev, horms, shenjian15, wangpeiyang1, liuyonglong, chenhao418, sudongming1, xujunsheng, shiyongbang, libaihan, jonathan.cameron, shameerali.kolothum.thodi, salil.mehta, netdev, linux-kernel, hkelam On Mon, Dec 09, 2024 at 09:02:10AM +0800, Jijie Shao wrote: > > on 2024/12/6 19:40, Greg KH wrote: > > On Fri, Dec 06, 2024 at 07:16:22PM +0800, Jijie Shao wrote: > > > Add debugfs_create_devm_dir() helper > > > > > > Signed-off-by: Jijie Shao <shaojijie@huawei.com> > > > --- > > > fs/debugfs/inode.c | 36 ++++++++++++++++++++++++++++++++++++ > > > include/linux/debugfs.h | 10 ++++++++++ > > > 2 files changed, 46 insertions(+) > > > > > > diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c > > > index 38a9c7eb97e6..f682c4952a27 100644 > > > --- a/fs/debugfs/inode.c > > > +++ b/fs/debugfs/inode.c > > > @@ -610,6 +610,42 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) > > > } > > > EXPORT_SYMBOL_GPL(debugfs_create_dir); > > > +static void debugfs_remove_devm(void *dentry_rwa) > > > +{ > > > + struct dentry *dentry = dentry_rwa; > > > + > > > + debugfs_remove(dentry); > > > +} > > > + > > > +/** > > > + * debugfs_create_devm_dir - Managed debugfs_create_dir() > > > + * @dev: Device that owns the action > > > + * @name: a pointer to a string containing the name of the directory to > > > + * create. > > > + * @parent: a pointer to the parent dentry for this file. This should be a > > > + * directory dentry if set. If this parameter is NULL, then the > > > + * directory will be created in the root of the debugfs filesystem. > > > + * Managed debugfs_create_dir(). dentry will automatically be remove on > > > + * driver detach. > > > + */ > > > +struct dentry *debugfs_create_devm_dir(struct device *dev, const char *name, > > > + struct dentry *parent) > > > +{ > > > + struct dentry *dentry; > > > + int ret; > > > + > > > + dentry = debugfs_create_dir(name, parent); > > > + if (IS_ERR(dentry)) > > > + return dentry; > > > + > > > + ret = devm_add_action_or_reset(dev, debugfs_remove_devm, dentry); > > > + if (ret) > > > + ERR_PTR(ret); > > You don't clean up the directory you created if this failed? Why not? > > Don't need to clean up. > in devm_add_action_or_reset(), if failed, will call action: debugfs_remove_devm(), > So, not clean up again. > > #define devm_add_action_or_reset(dev, action, data) \ > __devm_add_action_or_reset(dev, action, data, #action) > > static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *), > void *data, const char *name) > { > int ret; > > ret = __devm_add_action(dev, action, data, name); > if (ret) > action(data); > > return ret; > } > > But there's a problem with this, I missed return. > I will add return in v6. As this did not even compile, how did you test any of this? I'm now loath to add this at all, please let's just keep this "open coded" in your driver for now until there are multiple users that need this and then convert them all to use the function when you add it. thanks, greg k-h ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V5 net-next 1/8] debugfs: Add debugfs_create_devm_dir() helper 2024-12-09 6:31 ` Greg KH @ 2024-12-09 10:33 ` Jijie Shao 0 siblings, 0 replies; 8+ messages in thread From: Jijie Shao @ 2024-12-09 10:33 UTC (permalink / raw) To: Greg KH Cc: shaojijie, davem, edumazet, kuba, pabeni, andrew+netdev, horms, shenjian15, wangpeiyang1, liuyonglong, chenhao418, sudongming1, xujunsheng, shiyongbang, libaihan, jonathan.cameron, shameerali.kolothum.thodi, salil.mehta, netdev, linux-kernel, hkelam on 2024/12/9 14:31, Greg KH wrote: > On Mon, Dec 09, 2024 at 09:02:10AM +0800, Jijie Shao wrote: >> on 2024/12/6 19:40, Greg KH wrote: >>> On Fri, Dec 06, 2024 at 07:16:22PM +0800, Jijie Shao wrote: >>>> Add debugfs_create_devm_dir() helper >>>> >>>> Signed-off-by: Jijie Shao <shaojijie@huawei.com> >>>> --- >>>> fs/debugfs/inode.c | 36 ++++++++++++++++++++++++++++++++++++ >>>> include/linux/debugfs.h | 10 ++++++++++ >>>> 2 files changed, 46 insertions(+) >>>> >>>> diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c >>>> index 38a9c7eb97e6..f682c4952a27 100644 >>>> --- a/fs/debugfs/inode.c >>>> +++ b/fs/debugfs/inode.c >>>> @@ -610,6 +610,42 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) >>>> } >>>> EXPORT_SYMBOL_GPL(debugfs_create_dir); >>>> +static void debugfs_remove_devm(void *dentry_rwa) >>>> +{ >>>> + struct dentry *dentry = dentry_rwa; >>>> + >>>> + debugfs_remove(dentry); >>>> +} >>>> + >>>> +/** >>>> + * debugfs_create_devm_dir - Managed debugfs_create_dir() >>>> + * @dev: Device that owns the action >>>> + * @name: a pointer to a string containing the name of the directory to >>>> + * create. >>>> + * @parent: a pointer to the parent dentry for this file. This should be a >>>> + * directory dentry if set. If this parameter is NULL, then the >>>> + * directory will be created in the root of the debugfs filesystem. >>>> + * Managed debugfs_create_dir(). dentry will automatically be remove on >>>> + * driver detach. >>>> + */ >>>> +struct dentry *debugfs_create_devm_dir(struct device *dev, const char *name, >>>> + struct dentry *parent) >>>> +{ >>>> + struct dentry *dentry; >>>> + int ret; >>>> + >>>> + dentry = debugfs_create_dir(name, parent); >>>> + if (IS_ERR(dentry)) >>>> + return dentry; >>>> + >>>> + ret = devm_add_action_or_reset(dev, debugfs_remove_devm, dentry); >>>> + if (ret) >>>> + ERR_PTR(ret); >>> You don't clean up the directory you created if this failed? Why not? >> Don't need to clean up. >> in devm_add_action_or_reset(), if failed, will call action: debugfs_remove_devm(), >> So, not clean up again. >> >> #define devm_add_action_or_reset(dev, action, data) \ >> __devm_add_action_or_reset(dev, action, data, #action) >> >> static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *), >> void *data, const char *name) >> { >> int ret; >> >> ret = __devm_add_action(dev, action, data, name); >> if (ret) >> action(data); >> >> return ret; >> } >> >> But there's a problem with this, I missed return. >> I will add return in v6. > As this did not even compile, how did you test any of this? > > I'm now loath to add this at all, please let's just keep this "open > coded" in your driver for now until there are multiple users that need > this and then convert them all to use the function when you add it. > > thanks, > > greg k-h I've tested and it's ok, But, there is a warning(warn_unused_result).. My test command does not check warning other than the hibmcge driver. This was caused by my carelessness. I'm very sorry. I've looked at other driver codes, and quite a few others have similar codes. As you suggest, this patchset still uses open code in next version. In the future, I will try to send a new independent patchset to introduce it. Thanks, Jijie Shao ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V5 net-next 1/8] debugfs: Add debugfs_create_devm_dir() helper 2024-12-06 11:16 ` [PATCH V5 net-next 1/8] debugfs: Add debugfs_create_devm_dir() helper Jijie Shao 2024-12-06 11:40 ` Greg KH @ 2024-12-06 14:57 ` kernel test robot 2024-12-06 16:50 ` kernel test robot 2 siblings, 0 replies; 8+ messages in thread From: kernel test robot @ 2024-12-06 14:57 UTC (permalink / raw) To: Jijie Shao, davem, edumazet, kuba, pabeni, andrew+netdev, horms, gregkh Cc: llvm, oe-kbuild-all, shenjian15, wangpeiyang1, liuyonglong, chenhao418, sudongming1, xujunsheng, shiyongbang, libaihan, jonathan.cameron, shameerali.kolothum.thodi, salil.mehta, netdev, linux-kernel, shaojijie, hkelam Hi Jijie, kernel test robot noticed the following build warnings: [auto build test WARNING on net-next/main] url: https://github.com/intel-lab-lkp/linux/commits/Jijie-Shao/debugfs-Add-debugfs_create_devm_dir-helper/20241206-192734 base: net-next/main patch link: https://lore.kernel.org/r/20241206111629.3521865-2-shaojijie%40huawei.com patch subject: [PATCH V5 net-next 1/8] debugfs: Add debugfs_create_devm_dir() helper config: powerpc-ebony_defconfig (https://download.01.org/0day-ci/archive/20241206/202412062221.GPVtNG5v-lkp@intel.com/config) compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241206/202412062221.GPVtNG5v-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/202412062221.GPVtNG5v-lkp@intel.com/ All warnings (new ones prefixed by >>): >> fs/debugfs/inode.c:643:3: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result] 643 | ERR_PTR(ret); | ^~~~~~~ ~~~ 1 warning generated. vim +/warn_unused_result +643 fs/debugfs/inode.c 619 620 /** 621 * debugfs_create_devm_dir - Managed debugfs_create_dir() 622 * @dev: Device that owns the action 623 * @name: a pointer to a string containing the name of the directory to 624 * create. 625 * @parent: a pointer to the parent dentry for this file. This should be a 626 * directory dentry if set. If this parameter is NULL, then the 627 * directory will be created in the root of the debugfs filesystem. 628 * Managed debugfs_create_dir(). dentry will automatically be remove on 629 * driver detach. 630 */ 631 struct dentry *debugfs_create_devm_dir(struct device *dev, const char *name, 632 struct dentry *parent) 633 { 634 struct dentry *dentry; 635 int ret; 636 637 dentry = debugfs_create_dir(name, parent); 638 if (IS_ERR(dentry)) 639 return dentry; 640 641 ret = devm_add_action_or_reset(dev, debugfs_remove_devm, dentry); 642 if (ret) > 643 ERR_PTR(ret); 644 645 return dentry; 646 } 647 EXPORT_SYMBOL_GPL(debugfs_create_devm_dir); 648 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V5 net-next 1/8] debugfs: Add debugfs_create_devm_dir() helper 2024-12-06 11:16 ` [PATCH V5 net-next 1/8] debugfs: Add debugfs_create_devm_dir() helper Jijie Shao 2024-12-06 11:40 ` Greg KH 2024-12-06 14:57 ` kernel test robot @ 2024-12-06 16:50 ` kernel test robot 2 siblings, 0 replies; 8+ messages in thread From: kernel test robot @ 2024-12-06 16:50 UTC (permalink / raw) To: Jijie Shao, davem, edumazet, kuba, pabeni, andrew+netdev, horms, gregkh Cc: oe-kbuild-all, shenjian15, wangpeiyang1, liuyonglong, chenhao418, sudongming1, xujunsheng, shiyongbang, libaihan, jonathan.cameron, shameerali.kolothum.thodi, salil.mehta, netdev, linux-kernel, shaojijie, hkelam Hi Jijie, kernel test robot noticed the following build warnings: [auto build test WARNING on net-next/main] url: https://github.com/intel-lab-lkp/linux/commits/Jijie-Shao/debugfs-Add-debugfs_create_devm_dir-helper/20241206-192734 base: net-next/main patch link: https://lore.kernel.org/r/20241206111629.3521865-2-shaojijie%40huawei.com patch subject: [PATCH V5 net-next 1/8] debugfs: Add debugfs_create_devm_dir() helper config: x86_64-buildonly-randconfig-003-20241206 (https://download.01.org/0day-ci/archive/20241207/202412070055.uUO1oKY8-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241207/202412070055.uUO1oKY8-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/202412070055.uUO1oKY8-lkp@intel.com/ All warnings (new ones prefixed by >>): fs/debugfs/inode.c: In function 'debugfs_create_devm_dir': >> fs/debugfs/inode.c:643:17: warning: ignoring return value of 'ERR_PTR' declared with attribute 'warn_unused_result' [-Wunused-result] 643 | ERR_PTR(ret); | ^~~~~~~~~~~~ vim +643 fs/debugfs/inode.c 619 620 /** 621 * debugfs_create_devm_dir - Managed debugfs_create_dir() 622 * @dev: Device that owns the action 623 * @name: a pointer to a string containing the name of the directory to 624 * create. 625 * @parent: a pointer to the parent dentry for this file. This should be a 626 * directory dentry if set. If this parameter is NULL, then the 627 * directory will be created in the root of the debugfs filesystem. 628 * Managed debugfs_create_dir(). dentry will automatically be remove on 629 * driver detach. 630 */ 631 struct dentry *debugfs_create_devm_dir(struct device *dev, const char *name, 632 struct dentry *parent) 633 { 634 struct dentry *dentry; 635 int ret; 636 637 dentry = debugfs_create_dir(name, parent); 638 if (IS_ERR(dentry)) 639 return dentry; 640 641 ret = devm_add_action_or_reset(dev, debugfs_remove_devm, dentry); 642 if (ret) > 643 ERR_PTR(ret); 644 645 return dentry; 646 } 647 EXPORT_SYMBOL_GPL(debugfs_create_devm_dir); 648 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-12-09 10:34 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-12-09 4:11 [PATCH V5 net-next 1/8] debugfs: Add debugfs_create_devm_dir() helper kernel test robot -- strict thread matches above, loose matches on Subject: below -- 2024-12-06 11:16 [PATCH V5 net-next 0/8] Support some features for the HIBMCGE driver Jijie Shao 2024-12-06 11:16 ` [PATCH V5 net-next 1/8] debugfs: Add debugfs_create_devm_dir() helper Jijie Shao 2024-12-06 11:40 ` Greg KH 2024-12-09 1:02 ` Jijie Shao 2024-12-09 6:31 ` Greg KH 2024-12-09 10:33 ` Jijie Shao 2024-12-06 14:57 ` kernel test robot 2024-12-06 16:50 ` kernel test robot
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.