From: Sven Eckelmann <sven@narfation.org>
To: linux-arch@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Sven Eckelmann <sven@narfation.org>,
Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
"Rafael J. Wysocki" <rjw@sisk.pl>,
linux-pm@lists.linux-foundation.org
Subject: [PATCHv4 04/11] PM: Use *_dec_not_zero instead of *_add_unless
Date: Wed, 27 Jul 2011 11:47:43 +0200 [thread overview]
Message-ID: <1311760070-21532-4-git-send-email-sven@narfation.org> (raw)
In-Reply-To: <1311760070-21532-1-git-send-email-sven@narfation.org>
atomic_dec_not_zero is defined for each architecture through
<linux/atomic.h> to provide the functionality of
atomic_add_unless(x, -1, 0).
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Cc: Len Brown <len.brown@intel.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: linux-pm@lists.linux-foundation.org
---
drivers/base/power/runtime.c | 4 ++--
include/linux/pm_runtime.h | 2 +-
kernel/power/hibernate.c | 4 ++--
kernel/power/user.c | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 8dc247c..bda10d9 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -401,7 +401,7 @@ static int rpm_suspend(struct device *dev, int rpmflags)
if (dev->parent) {
parent = dev->parent;
- atomic_add_unless(&parent->power.child_count, -1, 0);
+ atomic_dec_not_zero(&parent->power.child_count);
}
}
wake_up_all(&dev->power.wait_queue);
@@ -841,7 +841,7 @@ int __pm_runtime_set_status(struct device *dev, unsigned int status)
if (status == RPM_SUSPENDED) {
/* It always is possible to set the status to 'suspended'. */
if (parent) {
- atomic_add_unless(&parent->power.child_count, -1, 0);
+ atomic_dec_not_zero(&parent->power.child_count);
notify_parent = !parent->power.ignore_children;
}
goto out_set;
diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
index daac05d..3b4931c 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -63,7 +63,7 @@ static inline void pm_runtime_get_noresume(struct device *dev)
static inline void pm_runtime_put_noidle(struct device *dev)
{
- atomic_add_unless(&dev->power.usage_count, -1, 0);
+ atomic_dec_not_zero(&dev->power.usage_count);
}
static inline bool device_run_wake(struct device *dev)
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 8f7b1db..0ba8d87 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -606,7 +606,7 @@ int hibernate(void)
mutex_lock(&pm_mutex);
/* The snapshot device should not be opened while we're running */
- if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
+ if (!atomic_dec_not_zero(&snapshot_device_available)) {
error = -EBUSY;
goto Unlock;
}
@@ -756,7 +756,7 @@ static int software_resume(void)
goto Unlock;
/* The snapshot device should not be opened while we're running */
- if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
+ if (!atomic_dec_not_zero(&snapshot_device_available)) {
error = -EBUSY;
swsusp_close(FMODE_READ);
goto Unlock;
diff --git a/kernel/power/user.c b/kernel/power/user.c
index 42ddbc6..1c1cc01 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -72,7 +72,7 @@ static int snapshot_open(struct inode *inode, struct file *filp)
mutex_lock(&pm_mutex);
- if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
+ if (!atomic_dec_not_zero(&snapshot_device_available)) {
error = -EBUSY;
goto Unlock;
}
--
1.7.5.4
next prev parent reply other threads:[~2011-07-27 9:55 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-27 9:47 [PATCHv4 01/11] atomic: add *_dec_not_zero Sven Eckelmann
[not found] ` <1311760070-21532-1-git-send-email-sven-KaDOiPu9UxWEi8DpZVb4nw@public.gmane.org>
2011-07-27 9:47 ` [PATCHv4 02/11] batman-adv: Remove private define of atomic_dec_not_zero Sven Eckelmann
2011-07-27 9:47 ` Sven Eckelmann
2011-07-27 9:47 ` [PATCHv4 03/11] fault_inject: " Sven Eckelmann
2011-07-27 9:47 ` Sven Eckelmann
2011-07-27 9:47 ` Sven Eckelmann [this message]
2011-07-27 19:50 ` [PATCHv4 04/11] PM: Use *_dec_not_zero instead of *_add_unless Rafael J. Wysocki
2011-07-27 20:36 ` Pavel Machek
2011-07-27 20:36 ` Pavel Machek
2011-07-28 21:43 ` Rafael J. Wysocki
2011-07-28 21:43 ` Rafael J. Wysocki
2011-07-27 9:47 ` [PATCHv4 05/11] omap3isp: " Sven Eckelmann
2011-07-27 9:47 ` Sven Eckelmann
2011-07-31 15:00 ` Laurent Pinchart
2011-08-01 10:07 ` Sven Eckelmann
2011-08-01 11:10 ` Laurent Pinchart
2011-08-01 11:10 ` Laurent Pinchart
2011-07-27 9:47 ` [PATCHv4 06/11] qeth: " Sven Eckelmann
2011-07-27 9:47 ` Sven Eckelmann
2011-07-27 9:47 ` [PATCHv4 07/11] ext4: " Sven Eckelmann
2011-07-27 9:47 ` Sven Eckelmann
2011-07-27 9:47 ` [PATCHv4 08/11] xfs: " Sven Eckelmann
2011-07-27 9:47 ` Sven Eckelmann
2011-07-27 9:47 ` [PATCHv4 09/11] memcg: " Sven Eckelmann
2011-07-27 9:47 ` Sven Eckelmann
2011-07-27 11:58 ` Michal Hocko
2011-07-27 9:47 ` [PATCHv4 10/11] drop_monitor: " Sven Eckelmann
2011-07-27 9:47 ` Sven Eckelmann
2011-07-27 10:59 ` Neil Horman
2011-07-27 10:59 ` Neil Horman
2011-07-27 11:52 ` Sven Eckelmann
2011-07-27 14:25 ` Neil Horman
2011-07-27 14:25 ` Neil Horman
2011-07-27 9:47 ` [PATCHv4 11/11] Phonet: " Sven Eckelmann
2011-07-27 9:47 ` Sven Eckelmann
2011-07-27 10:29 ` Rémi Denis-Courmont
2011-08-02 9:58 ` [PATCHv4 01/11] atomic: add *_dec_not_zero Ralf Baechle
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=1311760070-21532-4-git-send-email-sven@narfation.org \
--to=sven@narfation.org \
--cc=len.brown@intel.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=pavel@ucw.cz \
--cc=rjw@sisk.pl \
/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