From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Andrew Morton <akpm@osdl.org>
Cc: Pavel Machek <pavel@suse.cz>, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH -mm] swsusp: userland interface fixes
Date: Wed, 25 Jan 2006 23:41:36 +0100 [thread overview]
Message-ID: <200601252341.37361.rjw@sisk.pl> (raw)
Hi,
This patch contains some minor fixes of the swsusp userland interface:
1) use atomic_add_unless() instead of atomic_dec_and_test()/atomic_inc(),
2) remove a (unnecessary) memory barrier,
3) drop (unnecessary) access_ok() (actually the page will get released when
the device is closed, so we don't need to worry if put_user() fails).
Please consider for applying.
Greetings,
Rafael
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
kernel/power/user.c | 11 ++---------
1 files changed, 2 insertions(+), 9 deletions(-)
Index: linux-2.6.16-rc1-mm3/kernel/power/user.c
===================================================================
--- linux-2.6.16-rc1-mm3.orig/kernel/power/user.c 2006-01-25 21:21:13.000000000 +0100
+++ linux-2.6.16-rc1-mm3/kernel/power/user.c 2006-01-25 21:53:52.000000000 +0100
@@ -40,10 +40,8 @@ static int snapshot_open(struct inode *i
{
struct snapshot_data *data;
- if (!atomic_dec_and_test(&device_available)) {
- atomic_inc(&device_available);
+ if (!atomic_add_unless(&device_available, -1, 0))
return -EBUSY;
- }
if ((filp->f_flags & O_ACCMODE) == O_RDWR)
return -ENOSYS;
@@ -198,7 +196,6 @@ static int snapshot_ioctl(struct inode *
pm_prepare_console();
error = device_suspend(PMSG_FREEZE);
if (!error) {
- mb();
error = swsusp_resume();
device_resume();
}
@@ -223,10 +220,6 @@ static int snapshot_ioctl(struct inode *
break;
case SNAPSHOT_GET_SWAP_PAGE:
- if (!access_ok(VERIFY_WRITE, (unsigned long __user *)arg, _IOC_SIZE(cmd))) {
- error = -EINVAL;
- break;
- }
if (data->swap < 0 || data->swap >= MAX_SWAPFILES) {
error = -ENODEV;
break;
@@ -241,7 +234,7 @@ static int snapshot_ioctl(struct inode *
offset = alloc_swap_page(data->swap, data->bitmap);
if (offset) {
offset <<= PAGE_SHIFT;
- __put_user(offset, (loff_t __user *)arg);
+ error = put_user(offset, (loff_t __user *)arg);
} else {
error = -ENOSPC;
}
reply other threads:[~2006-01-25 22:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200601252341.37361.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@suse.cz \
/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
all inboxes | Powered by JetHome®