diff mbox series

[v2,2/3] driver core: Read atomic counter once in driver_probe_done()

Message ID 20200324122023.9649-2-andriy.shevchenko@linux.intel.com (mailing list archive)
State Not Applicable, archived
Headers show
Series [v2,1/3] driver core: Break infinite loop when deferred probe can't be satisfied | expand

Commit Message

Andy Shevchenko March 24, 2020, 12:20 p.m. UTC
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>
Tested-by: Ferry Toth <fntoth@gmail.com>
---
v2: picked up tags
 drivers/base/dd.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Rafael J. Wysocki March 24, 2020, 12:55 p.m. UTC | #1
On Tue, Mar 24, 2020 at 1:20 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> 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>
> Tested-by: Ferry Toth <fntoth@gmail.com>

Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
> v2: picked up tags
>  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
>
diff mbox series

Patch

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;
 }