Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1533309

[PATCH v2] drivers/base: use READ_ONCE instead of deprecated ACCESS_ONCE

From Davidlohr Bueso <dave@stgolabs.net>
Newsgroups linux.kernel
Subject [PATCH v2] drivers/base: use READ_ONCE instead of deprecated ACCESS_ONCE
Date 2016-11-30 15:00 +0100
Message-ID <sJdAt-6My-15@gated-at.bofh.it> (permalink)
References <sFjXP-OR-5@gated-at.bofh.it> <sIWgh-4bp-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


With the new standardized functions, we can replace all ACCESS_ONCE()
calls across relevant drivers/base/.

ACCESS_ONCE() does not work reliably on non-scalar types. For example
gcc 4.6 and 4.7 might remove the volatile tag for such accesses during
the SRA (scalar replacement of aggregates) step:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145

Update the new calls regardless of if it is a scalar type, this is
cleaner than having three alternatives.

Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
---
 drivers/base/core.c          | 2 +-
 drivers/base/power/runtime.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index ce057a568673..c0b3a2a03d72 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -101,7 +101,7 @@ const char *dev_driver_string(const struct device *dev)
 	 * so be careful about accessing it.  dev->bus and dev->class should
 	 * never change once they are set, so they don't need special care.
 	 */
-	drv = ACCESS_ONCE(dev->driver);
+	drv = READ_ONCE(dev->driver);
 	return drv ? drv->name :
 			(dev->bus ? dev->bus->name :
 			(dev->class ? dev->class->name : ""));
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 60ebb04d8140..747c19286250 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -132,11 +132,11 @@ unsigned long pm_runtime_autosuspend_expiration(struct device *dev)
 	if (!dev->power.use_autosuspend)
 		goto out;
 
-	autosuspend_delay = ACCESS_ONCE(dev->power.autosuspend_delay);
+	autosuspend_delay = READ_ONCE(dev->power.autosuspend_delay);
 	if (autosuspend_delay < 0)
 		goto out;
 
-	last_busy = ACCESS_ONCE(dev->power.last_busy);
+	last_busy = READ_ONCE(dev->power.last_busy);
 	elapsed = jiffies - last_busy;
 	if (elapsed < 0)
 		goto out;	/* jiffies has wrapped around. */
-- 
2.6.6

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH] drivers/base: use READ_ONCE instead of deprecated  ACCESS_ONCE Greg KH <gregkh@linuxfoundation.org> - 2016-11-29 20:30 +0100
  [PATCH v2] drivers/base: use READ_ONCE instead of deprecated  ACCESS_ONCE Davidlohr Bueso <dave@stgolabs.net> - 2016-11-30 15:00 +0100
    Re: [PATCH v2] drivers/base: use READ_ONCE instead of deprecated  ACCESS_ONCE Greg KH <gregkh@linuxfoundation.org> - 2016-11-30 15:00 +0100
      Re: [PATCH v2] drivers/base: use READ_ONCE instead of deprecated  ACCESS_ONCE Davidlohr Bueso <dave@stgolabs.net> - 2016-11-30 18:10 +0100
        Re: [PATCH v2] drivers/base: use READ_ONCE instead of deprecated  ACCESS_ONCE Greg KH <gregkh@linuxfoundation.org> - 2016-12-01 08:50 +0100

csiph-web