// SPDX-License-Identifier: GPL-2.0-only /* * linux/kernel/power/user.c * * This file provides the user space interface for software suspend/resume. * * Copyright (C) 2006 Rafael J. Wysocki <rjw@sisk.pl>
*/
data = filp->private_data; if (!data->ready) {
res = -ENODATA; goto Unlock;
} if (!pg_offp) { /* on page boundary? */
res = snapshot_read_next(&data->handle); if (res <= 0) goto Unlock;
} else {
res = PAGE_SIZE - pg_offp;
}
res = simple_read_from_buffer(buf, count, &pg_offp,
data_of(data->handle), res); if (res > 0)
*offp += res;
/* * User space encodes device types as two-byte values, * so we need to recode them
*/
data->swap = swap_type_of(swdev, offset); if (data->swap < 0) return swdev ? -ENODEV : -EINVAL;
data->dev = swdev; return 0;
}
case SNAPSHOT_ATOMIC_RESTORE:
error = snapshot_write_finalize(&data->handle); if (error) break; if (data->mode != O_WRONLY || !data->frozen ||
!snapshot_image_loaded(&data->handle)) {
error = -EPERM; break;
}
error = hibernation_restore(data->platform_support); break;
case SNAPSHOT_FREE:
swsusp_free();
memset(&data->handle, 0, sizeof(struct snapshot_handle));
data->ready = false; /* * It is necessary to thaw kernel threads here, because * SNAPSHOT_CREATE_IMAGE may be invoked directly after * SNAPSHOT_FREE. In that case, if kernel threads were not * thawed, the preallocation of memory carried out by * hibernation_snapshot() might run into problems (i.e. it * might fail or even deadlock).
*/
thaw_kernel_threads(); break;
case SNAPSHOT_PREF_IMAGE_SIZE:
image_size = arg; break;
case SNAPSHOT_FREE_SWAP_PAGES: if (data->swap < 0 || data->swap >= MAX_SWAPFILES) {
error = -ENODEV; break;
}
free_all_swap_pages(data->swap); break;
case SNAPSHOT_S2RAM: if (!data->frozen) {
error = -EPERM; break;
} /* * Tasks are frozen and the notifiers have been called with * PM_HIBERNATION_PREPARE
*/
error = suspend_devices_and_enter(PM_SUSPEND_MEM);
data->ready = false; break;
case SNAPSHOT_PLATFORM_SUPPORT:
data->platform_support = !!arg; break;
case SNAPSHOT_POWER_OFF: if (data->platform_support)
error = hibernation_platform_enter(); break;
case SNAPSHOT_SET_SWAP_AREA:
error = snapshot_set_swap_area(data, (void __user *)arg); break;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.