Thread (16 messages) flat view 16 messages, 2 authors, 2024-12-12

Re: [PATCH V6 net-next 1/7] net: hibmcge: Add debugfs supported in this module

From: Jijie Shao <shaojijie@huawei.com>
Date: 2024-12-12 01:21:26
Also in: lkml

on 2024/12/11 22:00, Jakub Kicinski wrote:
On Tue, 10 Dec 2024 21:48:49 +0800 Jijie Shao wrote:
quoted
+		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


Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help