From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Subject: [PATCH v3 3/4] devres: No need to call remove_nodes() when there none present
Date: Wed, 14 Apr 2021 19:25:10 +0300 [thread overview]
Message-ID: <20210414162511.59466-3-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20210414162511.59466-1-andriy.shevchenko@linux.intel.com>
If a list of devres nodes is empty, no need to call remove_nodes().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v3: new patch
drivers/base/devres.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index db1f3137fc81..dee48858663f 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -526,6 +526,10 @@ int devres_release_all(struct device *dev)
if (WARN_ON(dev->devres_head.next == NULL))
return -ENODEV;
+ /* Nothing to release if list is empty */
+ if (list_empty(&dev->devres_head))
+ return 0;
+
spin_lock_irqsave(&dev->devres_lock, flags);
cnt = remove_nodes(dev, dev->devres_head.next, &dev->devres_head, &todo);
spin_unlock_irqrestore(&dev->devres_lock, flags);
--
2.30.2
next prev parent reply other threads:[~2021-04-14 16:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-14 16:25 [PATCH v3 1/4] devres: Make locking straight forward in release_nodes() Andy Shevchenko
2021-04-14 16:25 ` [PATCH v3 2/4] devres: Use list_for_each_safe_from() in remove_nodes() Andy Shevchenko
2021-04-14 16:25 ` Andy Shevchenko [this message]
2021-04-14 16:25 ` [PATCH v3 4/4] devres: Enable trace events Andy Shevchenko
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=20210414162511.59466-3-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=bgolaszewski@baylibre.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--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;
as well as URLs for NNTP newsgroup(s).