Re: [PATCH RESEND net-next 5/5] net: wwan: core: make debugfs optional
From: Sergey Ryazanov <ryazanov.s.a@gmail.com>
Date: 2021-11-28 22:59:47
On Sun, Nov 28, 2021 at 8:05 PM Johannes Berg [off-list ref] wrote:
On Sun, 2021-11-28 at 15:55 +0300, Sergey Ryazanov wrote:quoted
+#ifdef CONFIG_WWAN_DEBUGFS struct dentry *wwan_get_debugfs_dir(struct device *parent); +#else +static inline struct dentry *wwan_get_debugfs_dir(struct device *parent) +{ + return NULL; +} +#endifNow I have to send another email anyway ... but this one probably should be ERR_PTR(-ENODEV) or something, a la debugfs_create_dir() if debugfs is disabled, because then a trivial user of wwan's debugfs doesn't even have to care about whether it's enabled or not, it can just debugfs_create_dir() for its own and the debugfs core code will check and return immediately. Yes that's a bit more code space, but if you just have a debugfs file or two, having an extra Kconfig option is possibly overkill too. Especially if we get into this path because DEBUG_FS is disabled *entirely*, and thus all the functions will be empty inlines (but it might not be, so it should be consistent with debugfs always returning non-NULL).
Nice catch, thank you! Will rework in V2 to return ERR_PTR(-ENODEV). -- Sergey