* [PATCH -next v3 1/2] media: cec: remove redundant null pointer checks in cec_devnode_init()
@ 2024-09-10 15:48 Li Zetao
2024-09-10 15:48 ` [PATCH -next v3 2/2] media: siano: " Li Zetao
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Li Zetao @ 2024-09-10 15:48 UTC (permalink / raw)
To: hverkuil-cisco, mchehab, gregkh, ricardo, ruanjinjie
Cc: lizetao1, linux-media, linux-kernel
Since the debugfs_create_dir() never returns a null pointer, checking
the return value for a null pointer is redundant. Remove this check
since debugfs_create_file can handle IS_ERR pointers. At the same time,
debugfs_create_dir returns ERR_PTR (-ENODEV) by default when
CONFIG_DEBUG_FS=N, so there is no need for CONFIG_DEBUG_FS macro
isolation.
Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v2 -> v3: Drop the null pointer check for top_cec_dir
v2: https://lore.kernel.org/all/20240907034400.3693797-1-lizetao1@huawei.com/
v1 -> v2: Remove this check since debugfs_create_file can handle IS_ERR
pointers. And drop the ifdef CONFIG_DEBUG_FS statement.
v1: https://lore.kernel.org/all/20240903143607.2004802-1-lizetao1@huawei.com/
drivers/media/cec/core/cec-core.c | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/drivers/media/cec/core/cec-core.c b/drivers/media/cec/core/cec-core.c
index e0756826d629..2897283ebe72 100644
--- a/drivers/media/cec/core/cec-core.c
+++ b/drivers/media/cec/core/cec-core.c
@@ -374,10 +374,6 @@ int cec_register_adapter(struct cec_adapter *adap,
}
dev_set_drvdata(&adap->devnode.dev, adap);
-#ifdef CONFIG_DEBUG_FS
- if (!top_cec_dir)
- return 0;
-
adap->cec_dir = debugfs_create_dir(dev_name(&adap->devnode.dev),
top_cec_dir);
@@ -388,7 +384,6 @@ int cec_register_adapter(struct cec_adapter *adap,
return 0;
debugfs_create_file("error-inj", 0644, adap->cec_dir, adap,
&cec_error_inj_fops);
-#endif
return 0;
}
EXPORT_SYMBOL_GPL(cec_register_adapter);
@@ -439,13 +434,7 @@ static int __init cec_devnode_init(void)
return ret;
}
-#ifdef CONFIG_DEBUG_FS
top_cec_dir = debugfs_create_dir("cec", NULL);
- if (IS_ERR_OR_NULL(top_cec_dir)) {
- pr_warn("cec: Failed to create debugfs cec dir\n");
- top_cec_dir = NULL;
- }
-#endif
ret = bus_register(&cec_bus_type);
if (ret < 0) {
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH -next v3 2/2] media: siano: remove redundant null pointer checks in cec_devnode_init()
2024-09-10 15:48 [PATCH -next v3 1/2] media: cec: remove redundant null pointer checks in cec_devnode_init() Li Zetao
@ 2024-09-10 15:48 ` Li Zetao
2024-09-11 5:30 ` [PATCH -next v3 1/2] media: cec: " Greg KH
2024-10-11 11:21 ` Hans Verkuil
2 siblings, 0 replies; 4+ messages in thread
From: Li Zetao @ 2024-09-10 15:48 UTC (permalink / raw)
To: hverkuil-cisco, mchehab, gregkh, ricardo, ruanjinjie
Cc: lizetao1, linux-media, linux-kernel
Since the debugfs_create_dir() never returns a null pointer, checking
the return value for a null pointer is redundant, Remove this check
since debugfs_create_file can handle IS_ERR pointers.
Signed-off-by: Li Zetao <lizetao1@huawei.com>
---
v2 -> v3: Drop the redundant variable d and assign it directly
v2: https://lore.kernel.org/all/20240907034400.3693797-2-lizetao1@huawei.com/
v1 -> v2: Remove this check since debugfs_create_file can
handle IS_ERR pointers.
v1: https://lore.kernel.org/all/20240903143607.2004802-2-lizetao1@huawei.com/
drivers/media/common/siano/smsdvb-debugfs.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/media/common/siano/smsdvb-debugfs.c b/drivers/media/common/siano/smsdvb-debugfs.c
index 73990e469df9..d14ba271db50 100644
--- a/drivers/media/common/siano/smsdvb-debugfs.c
+++ b/drivers/media/common/siano/smsdvb-debugfs.c
@@ -398,8 +398,6 @@ void smsdvb_debugfs_release(struct smsdvb_client_t *client)
void smsdvb_debugfs_register(void)
{
- struct dentry *d;
-
/*
* FIXME: This was written to debug Siano USB devices. So, it creates
* the debugfs node under <debugfs>/usb.
@@ -410,12 +408,7 @@ void smsdvb_debugfs_register(void)
* node for sdio-based boards, but this may need some logic at sdio
* subsystem.
*/
- d = debugfs_create_dir("smsdvb", usb_debug_root);
- if (IS_ERR_OR_NULL(d)) {
- pr_err("Couldn't create sysfs node for smsdvb\n");
- return;
- }
- smsdvb_debugfs_usb_root = d;
+ smsdvb_debugfs_usb_root = debugfs_create_dir("smsdvb", usb_debug_root);
}
void smsdvb_debugfs_unregister(void)
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH -next v3 1/2] media: cec: remove redundant null pointer checks in cec_devnode_init()
2024-09-10 15:48 [PATCH -next v3 1/2] media: cec: remove redundant null pointer checks in cec_devnode_init() Li Zetao
2024-09-10 15:48 ` [PATCH -next v3 2/2] media: siano: " Li Zetao
@ 2024-09-11 5:30 ` Greg KH
2024-10-11 11:21 ` Hans Verkuil
2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2024-09-11 5:30 UTC (permalink / raw)
To: Li Zetao
Cc: hverkuil-cisco, mchehab, ricardo, ruanjinjie, linux-media,
linux-kernel
On Tue, Sep 10, 2024 at 11:48:02PM +0800, Li Zetao wrote:
> Since the debugfs_create_dir() never returns a null pointer, checking
> the return value for a null pointer is redundant. Remove this check
> since debugfs_create_file can handle IS_ERR pointers. At the same time,
> debugfs_create_dir returns ERR_PTR (-ENODEV) by default when
> CONFIG_DEBUG_FS=N, so there is no need for CONFIG_DEBUG_FS macro
> isolation.
>
> Signed-off-by: Li Zetao <lizetao1@huawei.com>
> ---
> v2 -> v3: Drop the null pointer check for top_cec_dir
> v2: https://lore.kernel.org/all/20240907034400.3693797-1-lizetao1@huawei.com/
> v1 -> v2: Remove this check since debugfs_create_file can handle IS_ERR
> pointers. And drop the ifdef CONFIG_DEBUG_FS statement.
> v1: https://lore.kernel.org/all/20240903143607.2004802-1-lizetao1@huawei.com/
>
> drivers/media/cec/core/cec-core.c | 11 -----------
> 1 file changed, 11 deletions(-)
>
> diff --git a/drivers/media/cec/core/cec-core.c b/drivers/media/cec/core/cec-core.c
> index e0756826d629..2897283ebe72 100644
> --- a/drivers/media/cec/core/cec-core.c
> +++ b/drivers/media/cec/core/cec-core.c
> @@ -374,10 +374,6 @@ int cec_register_adapter(struct cec_adapter *adap,
> }
>
> dev_set_drvdata(&adap->devnode.dev, adap);
> -#ifdef CONFIG_DEBUG_FS
> - if (!top_cec_dir)
> - return 0;
> -
> adap->cec_dir = debugfs_create_dir(dev_name(&adap->devnode.dev),
> top_cec_dir);
>
> @@ -388,7 +384,6 @@ int cec_register_adapter(struct cec_adapter *adap,
> return 0;
> debugfs_create_file("error-inj", 0644, adap->cec_dir, adap,
> &cec_error_inj_fops);
> -#endif
> return 0;
> }
> EXPORT_SYMBOL_GPL(cec_register_adapter);
> @@ -439,13 +434,7 @@ static int __init cec_devnode_init(void)
> return ret;
> }
>
> -#ifdef CONFIG_DEBUG_FS
> top_cec_dir = debugfs_create_dir("cec", NULL);
I'm going to be a pain here, and say "why do you need top_cec_dir at
all?"
Why not just look it up every time you want it after creating it with a
call to debugfs_lookup() or debugfs_lookup_and_remove()?
anyway, not a big deal, it's up to the maintainers here to want this as
well, just a thought for further calls cleanup work.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -next v3 1/2] media: cec: remove redundant null pointer checks in cec_devnode_init()
2024-09-10 15:48 [PATCH -next v3 1/2] media: cec: remove redundant null pointer checks in cec_devnode_init() Li Zetao
2024-09-10 15:48 ` [PATCH -next v3 2/2] media: siano: " Li Zetao
2024-09-11 5:30 ` [PATCH -next v3 1/2] media: cec: " Greg KH
@ 2024-10-11 11:21 ` Hans Verkuil
2 siblings, 0 replies; 4+ messages in thread
From: Hans Verkuil @ 2024-10-11 11:21 UTC (permalink / raw)
To: Li Zetao, mchehab, gregkh, ricardo, ruanjinjie; +Cc: linux-media, linux-kernel
On 10/09/2024 17:48, Li Zetao wrote:
> Since the debugfs_create_dir() never returns a null pointer, checking
> the return value for a null pointer is redundant. Remove this check
> since debugfs_create_file can handle IS_ERR pointers. At the same time,
> debugfs_create_dir returns ERR_PTR (-ENODEV) by default when
> CONFIG_DEBUG_FS=N, so there is no need for CONFIG_DEBUG_FS macro
> isolation.
>
> Signed-off-by: Li Zetao <lizetao1@huawei.com>
> ---
> v2 -> v3: Drop the null pointer check for top_cec_dir
> v2: https://lore.kernel.org/all/20240907034400.3693797-1-lizetao1@huawei.com/
> v1 -> v2: Remove this check since debugfs_create_file can handle IS_ERR
> pointers. And drop the ifdef CONFIG_DEBUG_FS statement.
> v1: https://lore.kernel.org/all/20240903143607.2004802-1-lizetao1@huawei.com/
>
> drivers/media/cec/core/cec-core.c | 11 -----------
> 1 file changed, 11 deletions(-)
>
> diff --git a/drivers/media/cec/core/cec-core.c b/drivers/media/cec/core/cec-core.c
> index e0756826d629..2897283ebe72 100644
> --- a/drivers/media/cec/core/cec-core.c
> +++ b/drivers/media/cec/core/cec-core.c
> @@ -374,10 +374,6 @@ int cec_register_adapter(struct cec_adapter *adap,
> }
>
> dev_set_drvdata(&adap->devnode.dev, adap);
> -#ifdef CONFIG_DEBUG_FS
> - if (!top_cec_dir)
> - return 0;
> -
> adap->cec_dir = debugfs_create_dir(dev_name(&adap->devnode.dev),
> top_cec_dir);
>
> @@ -388,7 +384,6 @@ int cec_register_adapter(struct cec_adapter *adap,
> return 0;
> debugfs_create_file("error-inj", 0644, adap->cec_dir, adap,
> &cec_error_inj_fops);
This still has to remain under #ifdef CONFIG_DEBUG_FS, otherwise cec_error_inj_fops
is not defined. You can probably move the #ifdef to just before the debugfs_create_file
call above.
Regards,
Hans
> -#endif
> return 0;
> }
> EXPORT_SYMBOL_GPL(cec_register_adapter);
> @@ -439,13 +434,7 @@ static int __init cec_devnode_init(void)
> return ret;
> }
>
> -#ifdef CONFIG_DEBUG_FS
> top_cec_dir = debugfs_create_dir("cec", NULL);
> - if (IS_ERR_OR_NULL(top_cec_dir)) {
> - pr_warn("cec: Failed to create debugfs cec dir\n");
> - top_cec_dir = NULL;
> - }
> -#endif
>
> ret = bus_register(&cec_bus_type);
> if (ret < 0) {
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-11 11:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-10 15:48 [PATCH -next v3 1/2] media: cec: remove redundant null pointer checks in cec_devnode_init() Li Zetao
2024-09-10 15:48 ` [PATCH -next v3 2/2] media: siano: " Li Zetao
2024-09-11 5:30 ` [PATCH -next v3 1/2] media: cec: " Greg KH
2024-10-11 11:21 ` Hans Verkuil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox