Re:Re: [PATCH v2] media:v4l2-async:add debugfs under CONFIG_DEBUG_FS
From: luo.liu.linux
Date: Thu Mar 12 2026 - 03:07:16 EST
Hi Sakari,
Thank you very much for your review and suggestions.
I considered wrapping the entire block in a single #ifdef, but since v4l2_async_init and v4l2_async_exit are mandatory module entry points, they cannot be omitted even when CONFIG_DEBUG_FS is disabled.
Therefore, the #ifdef guards inside these functions are necessary to prevent references to undefined symbols (like pending_subdevs_fops and v4l2_async_debugfs_dir) while keeping the function definitions themselves intact
I have consolidated all debugfs-specific definitions (the show function and the directory pointer) into one block to keep the code clean, leaving only the minimal necessary guards inside the init/exit functions
At 2026-03-11 17:20:41, "Sakari Ailus" <sakari.ailus@xxxxxxxxxxxxxxx> wrote:
>On Fri, Mar 06, 2026 at 05:41:17PM +0800, luo.liu.linux wrote:
>>
>> Hello Sakari and Mauro,
>>
>> Gentle ping ....
>>
>>
>> At 2026-01-21 11:14:56, "luo.liu" <luo.liu.linux@xxxxxxx> wrote:
>> >All debugfs-related code is guarded by CONFIG_DEBUG_FS to avoid
>> >bloating the kernel when debugfs is disabled.
>> >
>> >Signed-off-by: luo.liu <luo.liu.linux@xxxxxxx>
>> >---
>> > drivers/media/v4l2-core/v4l2-async.c | 6 ++++++
>> > 1 file changed, 6 insertions(+)
>> >
>> >diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
>> >index 1c08bba9ecb9..f6a1a57149ba 100644
>> >--- a/drivers/media/v4l2-core/v4l2-async.c
>> >+++ b/drivers/media/v4l2-core/v4l2-async.c
>> >@@ -947,6 +947,7 @@ v4l2_async_nf_name(struct v4l2_async_notifier *notifier)
>> > return "nil";
>> > }
>> >
>> >+#ifdef CONFIG_DEBUG_FS
>> > static int pending_subdevs_show(struct seq_file *s, void *data)
>> > {
>> > struct v4l2_async_notifier *notif;
>> >@@ -967,20 +968,25 @@ static int pending_subdevs_show(struct seq_file *s, void *data)
>> > DEFINE_SHOW_ATTRIBUTE(pending_subdevs);
>> >
>> > static struct dentry *v4l2_async_debugfs_dir;
>> >+#endif
>> >
>> > static int __init v4l2_async_init(void)
>> > {
>> >+#ifdef CONFIG_DEBUG_FS
>> > v4l2_async_debugfs_dir = debugfs_create_dir("v4l2-async", NULL);
>> > debugfs_create_file("pending_async_subdevices", 0444,
>> > v4l2_async_debugfs_dir, NULL,
>> > &pending_subdevs_fops);
>> >
>> >+#endif
>> > return 0;
>> > }
>> >
>> > static void __exit v4l2_async_exit(void)
>> > {
>> >+#ifdef CONFIG_DEBUG_FS
>> > debugfs_remove_recursive(v4l2_async_debugfs_dir);
>> >+#endif
>> > }
>
>If debugfs is disabled, the init functions won't do anything. You can put
>these behind a single #ifdef .. #endif.
>
>--
>Sakari Ailus