mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -mm] swsusp: userland interface fixes
@ 2006-01-25 22:41 Rafael J. Wysocki
  0 siblings, 0 replies; only message in thread
From: Rafael J. Wysocki @ 2006-01-25 22:41 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Pavel Machek, LKML

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-01-25 22:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-25 22:41 [PATCH -mm] swsusp: userland interface fixes Rafael J. Wysocki

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®