LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	linux-kernel@vger.kernel.org
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 2/3] driver core: Read atomic counter once in driver_probe_done()
Date: Mon,  9 Mar 2020 16:11:10 +0200	[thread overview]
Message-ID: <20200309141111.40576-2-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20200309141111.40576-1-andriy.shevchenko@linux.intel.com>

Between printing the debug message and actual check atomic counter can be
altered. For better debugging experience read atomic counter value only once.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/dd.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 43720beb5300..efd0e4c16ba5 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -669,9 +669,10 @@ static int really_probe_debug(struct device *dev, struct device_driver *drv)
  */
 int driver_probe_done(void)
 {
-	pr_debug("%s: probe_count = %d\n", __func__,
-		 atomic_read(&probe_count));
-	if (atomic_read(&probe_count))
+	int local_probe_count = atomic_read(&probe_count);
+
+	pr_debug("%s: probe_count = %d\n", __func__, local_probe_count);
+	if (local_probe_count)
 		return -EBUSY;
 	return 0;
 }
-- 
2.25.1


  reply	other threads:[~2020-03-09 14:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-09 14:11 [PATCH v1 1/3] driver core: Break infinite loop when deferred probe can't be satisfied Andy Shevchenko
2020-03-09 14:11 ` Andy Shevchenko [this message]
2020-03-18 23:49   ` [PATCH v1 2/3] driver core: Read atomic counter once in driver_probe_done() Ferry Toth
2020-03-09 14:11 ` [PATCH v1 3/3] driver core: Replace open-coded list_last_entry() Andy Shevchenko
2020-03-11  8:32 ` [PATCH v1 1/3] driver core: Break infinite loop when deferred probe can't be satisfied Peter Ujfalusi
2020-03-12 10:54   ` Andy Shevchenko
2020-03-13  7:35     ` Peter Ujfalusi
2020-03-13  8:50       ` Andy Shevchenko
2020-03-18 23:47 ` Ferry Toth

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=20200309141111.40576-2-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --subject='Re: [PATCH v1 2/3] driver core: Read atomic counter once in driver_probe_done()' \
    /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

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