mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	linux-kernel@vger.kernel.org
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Subject: [PATCH v1 2/2] device property: Don't check for NULL twice in the loops
Date: Mon, 10 May 2021 12:56:13 +0300	[thread overview]
Message-ID: <20210510095613.3302755-2-andy.shevchenko@gmail.com> (raw)
In-Reply-To: <20210510095613.3302755-1-andy.shevchenko@gmail.com>

In fwnode_get_next_available_child_node() we check next_child for NULL
twice. All the same in fwnode_get_next_parent_dev() we may avoid checking
fwnode for NULL twice.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/base/property.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index dd98759d688b..62285f1b79e3 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -632,9 +632,10 @@ struct device *fwnode_get_next_parent_dev(struct fwnode_handle *fwnode)
 	fwnode_handle_get(fwnode);
 	do {
 		fwnode = fwnode_get_next_parent(fwnode);
-		if (fwnode)
-			dev = get_dev_from_fwnode(fwnode);
-	} while (fwnode && !dev);
+		if (!fwnode)
+			break;
+		dev = get_dev_from_fwnode(fwnode);
+	} while (!dev);
 	fwnode_handle_put(fwnode);
 	return dev;
 }
@@ -742,10 +743,9 @@ fwnode_get_next_available_child_node(const struct fwnode_handle *fwnode,
 
 	do {
 		next_child = fwnode_get_next_child_node(fwnode, next_child);
-
-		if (!next_child || fwnode_device_is_available(next_child))
+		if (!next_child)
 			break;
-	} while (next_child);
+	} while (!fwnode_device_is_available(next_child));
 
 	return next_child;
 }
-- 
2.31.1


  reply	other threads:[~2021-05-10  9:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-10  9:56 [PATCH v1 1/2] device property: Retrieve fwnode from of_node via accessor Andy Shevchenko
2021-05-10  9:56 ` Andy Shevchenko [this message]
2021-05-10 14:53   ` [PATCH v1 2/2] device property: Don't check for NULL twice in the loops Rafael J. Wysocki
2021-05-10 14:57 ` [PATCH v1 1/2] device property: Retrieve fwnode from of_node via accessor Rafael J. Wysocki

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=20210510095613.3302755-2-andy.shevchenko@gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.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

all inboxes | Powered by JetHome®