aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2005-09-28 23:13:36 -0400
committerPaul Mackerras <paulus@samba.org>2005-09-28 23:13:36 -0400
commitab11d1ea281e85895369ef57c5259ad8a432fabb (patch)
tree684147479c6a8bb2fbed21bdcf12de1dd519c730 /kernel
parent952ecef7a0479049c8abb7c34a688ec2981ceadd (diff)
parent664cceb0093b755739e56572b836a99104ee8a75 (diff)
Merge by hand from Linus' tree.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cpuset.c11
-rw-r--r--kernel/params.c10
-rw-r--r--kernel/power/power.h5
-rw-r--r--kernel/power/swsusp.c17
4 files changed, 28 insertions, 15 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 79866bc6b3a1..6a6e87b2f2fd 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -969,7 +969,7 @@ static ssize_t cpuset_common_file_read(struct file *file, char __user *buf,
969 ssize_t retval = 0; 969 ssize_t retval = 0;
970 char *s; 970 char *s;
971 char *start; 971 char *start;
972 size_t n; 972 ssize_t n;
973 973
974 if (!(page = (char *)__get_free_page(GFP_KERNEL))) 974 if (!(page = (char *)__get_free_page(GFP_KERNEL)))
975 return -ENOMEM; 975 return -ENOMEM;
@@ -999,12 +999,13 @@ static ssize_t cpuset_common_file_read(struct file *file, char __user *buf,
999 *s++ = '\n'; 999 *s++ = '\n';
1000 *s = '\0'; 1000 *s = '\0';
1001 1001
1002 /* Do nothing if *ppos is at the eof or beyond the eof. */
1003 if (s - page <= *ppos)
1004 return 0;
1005
1006 start = page + *ppos; 1002 start = page + *ppos;
1007 n = s - start; 1003 n = s - start;
1004
1005 /* Do nothing if *ppos is at the eof or beyond the eof. */
1006 if (n <= 0)
1007 goto out;
1008
1008 retval = n - copy_to_user(buf, start, min(n, nbytes)); 1009 retval = n - copy_to_user(buf, start, min(n, nbytes));
1009 *ppos += retval; 1010 *ppos += retval;
1010out: 1011out:
diff --git a/kernel/params.c b/kernel/params.c
index fbf173215fd2..1a8614bac5d5 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -80,8 +80,6 @@ static char *next_arg(char *args, char **param, char **val)
80 int in_quote = 0, quoted = 0; 80 int in_quote = 0, quoted = 0;
81 char *next; 81 char *next;
82 82
83 /* Chew any extra spaces */
84 while (*args == ' ') args++;
85 if (*args == '"') { 83 if (*args == '"') {
86 args++; 84 args++;
87 in_quote = 1; 85 in_quote = 1;
@@ -121,6 +119,10 @@ static char *next_arg(char *args, char **param, char **val)
121 next = args + i + 1; 119 next = args + i + 1;
122 } else 120 } else
123 next = args + i; 121 next = args + i;
122
123 /* Chew up trailing spaces. */
124 while (*next == ' ')
125 next++;
124 return next; 126 return next;
125} 127}
126 128
@@ -135,6 +137,10 @@ int parse_args(const char *name,
135 137
136 DEBUGP("Parsing ARGS: %s\n", args); 138 DEBUGP("Parsing ARGS: %s\n", args);
137 139
140 /* Chew leading spaces */
141 while (*args == ' ')
142 args++;
143
138 while (*args) { 144 while (*args) {
139 int ret; 145 int ret;
140 146
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 9c9167d910dd..6748de23e83c 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -9,6 +9,9 @@
9#define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1) 9#define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1)
10#endif 10#endif
11 11
12#define MAX_PBES ((PAGE_SIZE - sizeof(struct new_utsname) \
13 - 4 - 3*sizeof(unsigned long) - sizeof(int) \
14 - sizeof(void *)) / sizeof(swp_entry_t))
12 15
13struct swsusp_info { 16struct swsusp_info {
14 struct new_utsname uts; 17 struct new_utsname uts;
@@ -18,7 +21,7 @@ struct swsusp_info {
18 unsigned long image_pages; 21 unsigned long image_pages;
19 unsigned long pagedir_pages; 22 unsigned long pagedir_pages;
20 suspend_pagedir_t * suspend_pagedir; 23 suspend_pagedir_t * suspend_pagedir;
21 swp_entry_t pagedir[768]; 24 swp_entry_t pagedir[MAX_PBES];
22} __attribute__((aligned(PAGE_SIZE))); 25} __attribute__((aligned(PAGE_SIZE)));
23 26
24 27
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index 1cc9ff25e479..acf79ac1cb6d 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -402,15 +402,14 @@ static int write_page(unsigned long addr, swp_entry_t * loc)
402static void data_free(void) 402static void data_free(void)
403{ 403{
404 swp_entry_t entry; 404 swp_entry_t entry;
405 int i; 405 struct pbe * p;
406 406
407 for (i = 0; i < nr_copy_pages; i++) { 407 for_each_pbe(p, pagedir_nosave) {
408 entry = (pagedir_nosave + i)->swap_address; 408 entry = p->swap_address;
409 if (entry.val) 409 if (entry.val)
410 swap_free(entry); 410 swap_free(entry);
411 else 411 else
412 break; 412 break;
413 (pagedir_nosave + i)->swap_address = (swp_entry_t){0};
414 } 413 }
415} 414}
416 415
@@ -932,6 +931,10 @@ static int swsusp_alloc(void)
932 if (!enough_swap()) 931 if (!enough_swap())
933 return -ENOSPC; 932 return -ENOSPC;
934 933
934 if (MAX_PBES < nr_copy_pages / PBES_PER_PAGE +
935 !!(nr_copy_pages % PBES_PER_PAGE))
936 return -ENOSPC;
937
935 if (!(pagedir_save = alloc_pagedir(nr_copy_pages))) { 938 if (!(pagedir_save = alloc_pagedir(nr_copy_pages))) {
936 printk(KERN_ERR "suspend: Allocating pagedir failed.\n"); 939 printk(KERN_ERR "suspend: Allocating pagedir failed.\n");
937 return -ENOMEM; 940 return -ENOMEM;
@@ -1438,9 +1441,9 @@ static int read_pagedir(struct pbe *pblist)
1438 } 1441 }
1439 1442
1440 if (error) 1443 if (error)
1441 free_page((unsigned long)pblist); 1444 free_pagedir(pblist);
1442 1445 else
1443 BUG_ON(i != swsusp_info.pagedir_pages); 1446 BUG_ON(i != swsusp_info.pagedir_pages);
1444 1447
1445 return error; 1448 return error;
1446} 1449}