diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-20 12:03:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-20 12:03:55 -0400 |
commit | 46ee9645094ad1eb5b4888882ecaa1fb87dcd2a3 (patch) | |
tree | d0a48e993568b6a2415cfc21fc06eaa2fd886429 /kernel/power/user.c | |
parent | fa5312d9e87e7222c6c384c4e930dc149bc1178d (diff) | |
parent | 25f3a5a2854dce8b8413fd24cc9d5b9e3632be54 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6:
PM: PM QOS update fix
Freezer / cgroup freezer: Update stale locking comments
PM / platform_bus: Allow runtime PM by default
i2c: Fix bus-level power management callbacks
PM QOS update
PM / Hibernate: Fix block_io.c printk warning
PM / Hibernate: Group swap ops
PM / Hibernate: Move the first_sector out of swsusp_write
PM / Hibernate: Separate block_io
PM / Hibernate: Snapshot cleanup
FS / libfs: Implement simple_write_to_buffer
PM / Hibernate: document open(/dev/snapshot) side effects
PM / Runtime: Add sysfs debug files
PM: Improve device power management document
PM: Update device power management document
PM: Allow runtime_suspend methods to call pm_schedule_suspend()
PM: pm_wakeup - switch to using bool
Diffstat (limited to 'kernel/power/user.c')
-rw-r--r-- | kernel/power/user.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/kernel/power/user.c b/kernel/power/user.c index a8c96212bc1b..e819e17877ca 100644 --- a/kernel/power/user.c +++ b/kernel/power/user.c | |||
@@ -151,6 +151,7 @@ static ssize_t snapshot_read(struct file *filp, char __user *buf, | |||
151 | { | 151 | { |
152 | struct snapshot_data *data; | 152 | struct snapshot_data *data; |
153 | ssize_t res; | 153 | ssize_t res; |
154 | loff_t pg_offp = *offp & ~PAGE_MASK; | ||
154 | 155 | ||
155 | mutex_lock(&pm_mutex); | 156 | mutex_lock(&pm_mutex); |
156 | 157 | ||
@@ -159,14 +160,19 @@ static ssize_t snapshot_read(struct file *filp, char __user *buf, | |||
159 | res = -ENODATA; | 160 | res = -ENODATA; |
160 | goto Unlock; | 161 | goto Unlock; |
161 | } | 162 | } |
162 | res = snapshot_read_next(&data->handle, count); | 163 | if (!pg_offp) { /* on page boundary? */ |
163 | if (res > 0) { | 164 | res = snapshot_read_next(&data->handle); |
164 | if (copy_to_user(buf, data_of(data->handle), res)) | 165 | if (res <= 0) |
165 | res = -EFAULT; | 166 | goto Unlock; |
166 | else | 167 | } else { |
167 | *offp = data->handle.offset; | 168 | res = PAGE_SIZE - pg_offp; |
168 | } | 169 | } |
169 | 170 | ||
171 | res = simple_read_from_buffer(buf, count, &pg_offp, | ||
172 | data_of(data->handle), res); | ||
173 | if (res > 0) | ||
174 | *offp += res; | ||
175 | |||
170 | Unlock: | 176 | Unlock: |
171 | mutex_unlock(&pm_mutex); | 177 | mutex_unlock(&pm_mutex); |
172 | 178 | ||
@@ -178,18 +184,25 @@ static ssize_t snapshot_write(struct file *filp, const char __user *buf, | |||
178 | { | 184 | { |
179 | struct snapshot_data *data; | 185 | struct snapshot_data *data; |
180 | ssize_t res; | 186 | ssize_t res; |
187 | loff_t pg_offp = *offp & ~PAGE_MASK; | ||
181 | 188 | ||
182 | mutex_lock(&pm_mutex); | 189 | mutex_lock(&pm_mutex); |
183 | 190 | ||
184 | data = filp->private_data; | 191 | data = filp->private_data; |
185 | res = snapshot_write_next(&data->handle, count); | 192 | |
186 | if (res > 0) { | 193 | if (!pg_offp) { |
187 | if (copy_from_user(data_of(data->handle), buf, res)) | 194 | res = snapshot_write_next(&data->handle); |
188 | res = -EFAULT; | 195 | if (res <= 0) |
189 | else | 196 | goto unlock; |
190 | *offp = data->handle.offset; | 197 | } else { |
198 | res = PAGE_SIZE - pg_offp; | ||
191 | } | 199 | } |
192 | 200 | ||
201 | res = simple_write_to_buffer(data_of(data->handle), res, &pg_offp, | ||
202 | buf, count); | ||
203 | if (res > 0) | ||
204 | *offp += res; | ||
205 | unlock: | ||
193 | mutex_unlock(&pm_mutex); | 206 | mutex_unlock(&pm_mutex); |
194 | 207 | ||
195 | return res; | 208 | return res; |