mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
To: Li Zetao <lizetao1@huawei.com>,
	mchehab@kernel.org, gregkh@linuxfoundation.org,
	ricardo@marliere.net, ruanjinjie@huawei.com
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH -next v3 1/2] media: cec: remove redundant null pointer checks in cec_devnode_init()
Date: Fri, 11 Oct 2024 13:21:35 +0200	[thread overview]
Message-ID: <b4bb440e-3998-41df-93dd-d69012ca8a08@xs4all.nl> (raw)
In-Reply-To: <20240910154803.736951-1-lizetao1@huawei.com>

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) {


      parent reply	other threads:[~2024-10-11 11:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-10 15:48 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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b4bb440e-3998-41df-93dd-d69012ca8a08@xs4all.nl \
    --to=hverkuil-cisco@xs4all.nl \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=lizetao1@huawei.com \
    --cc=mchehab@kernel.org \
    --cc=ricardo@marliere.net \
    --cc=ruanjinjie@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®