[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <74eae7ad-151c-4dd4-a14d-44da0d000e54@huawei.com>
Date: Thu, 12 Dec 2024 09:21:17 +0800
From: Jijie Shao <shaojijie@...wei.com>
To: Jakub Kicinski <kuba@...nel.org>
CC: <shaojijie@...wei.com>, <davem@...emloft.net>, <edumazet@...gle.com>,
<pabeni@...hat.com>, <andrew+netdev@...n.ch>, <horms@...nel.org>,
<gregkh@...uxfoundation.org>, <shenjian15@...wei.com>,
<wangpeiyang1@...wei.com>, <liuyonglong@...wei.com>, <chenhao418@...wei.com>,
<sudongming1@...wei.com>, <xujunsheng@...wei.com>, <shiyongbang@...wei.com>,
<libaihan@...wei.com>, <jonathan.cameron@...wei.com>,
<shameerali.kolothum.thodi@...wei.com>, <salil.mehta@...wei.com>,
<netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<hkelam@...vell.com>
Subject: Re: [PATCH V6 net-next 1/7] net: hibmcge: Add debugfs supported in
this module
on 2024/12/11 22:00, Jakub Kicinski wrote:
> On Tue, 10 Dec 2024 21:48:49 +0800 Jijie Shao wrote:
>> + debugfs_create_devm_seqfile(dev, hbg_dbg_infos[i].name,
>> + root, hbg_dbg_infos[i].read);
> Like I said last time, if you devm_ the entire folder you don't have to
> devm_ each individual file. debugfs_remove_recursive() removes all files
> under specified directory.
I think debugfs_create_devm_seqfile()is a better choice, if not use it. and I might need to code like so: static const struct file_operations
hbg_dbg_fops = { .owner = THIS_MODULE, ... }; static int
hbg_dbg_file_init(struct hbg_priv *priv, u32 cmd, const char *name) {
struct hbg_dbg_pri_data *data; data = devm_kzalloc(&priv->pdev->dev,
sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; data->priv =
priv; data->cmd = cmd; debugfs_create_file(name, HBG_DBG_FILE_MODE,
priv->debugfs.root, data, &hbg_dbg_fops); return 0; } int
hbg_debugfs_init(struct hbg_priv *priv) { ... for (i = 0; i < ARRAY_SIZE(hbg_dbg_infos); i++) { ret = hbg_dbg_file_init(priv, i, hbg_dbg_infos[i].name); ... } But use debugfs_create_devm_seqfile(), I only need:void hbg_debugfs_init(struct hbg_priv *priv)
{
...
for (i = 0; i < ARRAY_SIZE(hbg_dbg_infos); i++)
debugfs_create_devm_seqfile(dev, hbg_dbg_infos[i].name,
root, hbg_dbg_infos[i].read);
Actually i think debugfs_create_devm_seqfile() is actually similar to hbg_dbg_file_init().
And in debugfs_create_devm_seqfile(), debugfs_create_file() is also called, and the code is simplified.
Thanks,
Jijie Shao
Powered by blists - more mailing lists