mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] cdev: simplify loop in cdev_by_device_node
Date: Thu, 4 Jan 2024 12:17:03 +0100	[thread overview]
Message-ID: <20240104111703.GO1318922@pengutronix.de> (raw)
In-Reply-To: <20240103102035.2630735-1-a.fatoum@pengutronix.de>

On Wed, Jan 03, 2024 at 11:20:34AM +0100, Ahmad Fatoum wrote:
> We don't need to compare the cdev's device node pointer both against NULL
> and against the searched for device node on each iteration.
> 
> Instead, it's sufficient to just compare the device nodes directly.
> To maintain previous behavior, when searching for a NULL device node, we
> shouldn't return the first cdev, but return NULL. Do that via an early
> exit instead of doing it after iterating over all cdevs.
> 
> No functional change.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  fs/devfs-core.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/fs/devfs-core.c b/fs/devfs-core.c
> index 244f76f62c52..c79b092a112e 100644
> --- a/fs/devfs-core.c
> +++ b/fs/devfs-core.c
> @@ -87,9 +87,10 @@ struct cdev *cdev_by_device_node(struct device_node *node)
>  {
>  	struct cdev *cdev;
>  
> +	if (!node)
> +		return NULL;
> +
>  	for_each_cdev(cdev) {
> -		if (!cdev->device_node)
> -			continue;
>  		if (cdev->device_node == node)
>  			return cdev_readlink(cdev);
>  	}
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      parent reply	other threads:[~2024-01-04 11:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-03 10:20 Ahmad Fatoum
2024-01-03 10:20 ` [PATCH 2/2] cdev: add cdev_alloc helper for creating cdevs Ahmad Fatoum
2024-01-04 11:17 ` Sascha Hauer [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=20240104111703.GO1318922@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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