apm-emulation.c (ec208491936d6adb8a70c3dd4a517cdfe54e823d) apm-emulation.c (55929332c92e5d34d65a8f784604c92677ea3e15)
1/*
2 * bios-less APM driver for ARM Linux
3 * Jamey Hicks <jamey@crl.dec.com>
4 * adapted from the APM BIOS driver for Linux by Stephen Rothwell (sfr@linuxcare.com)
5 *
6 * APM 1.2 Reference:
7 * Intel Corporation, Microsoft Corporation. Advanced Power Management
8 * (APM) BIOS Interface Specification, Revision 1.2, February 1996.

--- 251 unchanged lines hidden (view full) ---

260 *
261 * APM_IOC_SUSPEND
262 * This IOCTL is overloaded, and performs two functions. It is used to:
263 * - initiate a suspend
264 * - acknowledge a suspend read from /dev/apm_bios.
265 * Only when everyone who has opened /dev/apm_bios with write permission
266 * has acknowledge does the actual suspend happen.
267 */
1/*
2 * bios-less APM driver for ARM Linux
3 * Jamey Hicks <jamey@crl.dec.com>
4 * adapted from the APM BIOS driver for Linux by Stephen Rothwell (sfr@linuxcare.com)
5 *
6 * APM 1.2 Reference:
7 * Intel Corporation, Microsoft Corporation. Advanced Power Management
8 * (APM) BIOS Interface Specification, Revision 1.2, February 1996.

--- 251 unchanged lines hidden (view full) ---

260 *
261 * APM_IOC_SUSPEND
262 * This IOCTL is overloaded, and performs two functions. It is used to:
263 * - initiate a suspend
264 * - acknowledge a suspend read from /dev/apm_bios.
265 * Only when everyone who has opened /dev/apm_bios with write permission
266 * has acknowledge does the actual suspend happen.
267 */
268static int
269apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
268static long
269apm_ioctl(struct file *filp, u_int cmd, u_long arg)
270{
271 struct apm_user *as = filp->private_data;
272 int err = -EINVAL;
273
274 if (!as->suser || !as->writer)
275 return -EPERM;
276
270{
271 struct apm_user *as = filp->private_data;
272 int err = -EINVAL;
273
274 if (!as->suser || !as->writer)
275 return -EPERM;
276
277 lock_kernel();
277 switch (cmd) {
278 case APM_IOC_SUSPEND:
279 mutex_lock(&state_lock);
280
281 as->suspend_result = -EINTR;
282
283 switch (as->suspend_state) {
284 case SUSPEND_READ:

--- 44 unchanged lines hidden (view full) ---

329 }
330
331 mutex_lock(&state_lock);
332 err = as->suspend_result;
333 as->suspend_state = SUSPEND_NONE;
334 mutex_unlock(&state_lock);
335 break;
336 }
278 switch (cmd) {
279 case APM_IOC_SUSPEND:
280 mutex_lock(&state_lock);
281
282 as->suspend_result = -EINTR;
283
284 switch (as->suspend_state) {
285 case SUSPEND_READ:

--- 44 unchanged lines hidden (view full) ---

330 }
331
332 mutex_lock(&state_lock);
333 err = as->suspend_result;
334 as->suspend_state = SUSPEND_NONE;
335 mutex_unlock(&state_lock);
336 break;
337 }
338 unlock_kernel();
337
338 return err;
339}
340
341static int apm_release(struct inode * inode, struct file * filp)
342{
343 struct apm_user *as = filp->private_data;
344

--- 47 unchanged lines hidden (view full) ---

392
393 return as ? 0 : -ENOMEM;
394}
395
396static const struct file_operations apm_bios_fops = {
397 .owner = THIS_MODULE,
398 .read = apm_read,
399 .poll = apm_poll,
339
340 return err;
341}
342
343static int apm_release(struct inode * inode, struct file * filp)
344{
345 struct apm_user *as = filp->private_data;
346

--- 47 unchanged lines hidden (view full) ---

394
395 return as ? 0 : -ENOMEM;
396}
397
398static const struct file_operations apm_bios_fops = {
399 .owner = THIS_MODULE,
400 .read = apm_read,
401 .poll = apm_poll,
400 .ioctl = apm_ioctl,
402 .unlocked_ioctl = apm_ioctl,
401 .open = apm_open,
402 .release = apm_release,
403};
404
405static struct miscdevice apm_device = {
406 .minor = APM_MINOR_DEV,
407 .name = "apm_bios",
408 .fops = &apm_bios_fops

--- 339 unchanged lines hidden ---
403 .open = apm_open,
404 .release = apm_release,
405};
406
407static struct miscdevice apm_device = {
408 .minor = APM_MINOR_DEV,
409 .name = "apm_bios",
410 .fops = &apm_bios_fops

--- 339 unchanged lines hidden ---