Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v2.6.14 125 lines 2.4 kB view raw
1/* 2 * resume.c - Functions for waking devices up. 3 * 4 * Copyright (c) 2003 Patrick Mochel 5 * Copyright (c) 2003 Open Source Development Labs 6 * 7 * This file is released under the GPLv2 8 * 9 */ 10 11#include <linux/device.h> 12#include "power.h" 13 14extern int sysdev_resume(void); 15 16 17/** 18 * resume_device - Restore state for one device. 19 * @dev: Device. 20 * 21 */ 22 23int resume_device(struct device * dev) 24{ 25 int error = 0; 26 27 down(&dev->sem); 28 if (dev->power.pm_parent 29 && dev->power.pm_parent->power.power_state.event) { 30 dev_err(dev, "PM: resume from %d, parent %s still %d\n", 31 dev->power.power_state.event, 32 dev->power.pm_parent->bus_id, 33 dev->power.pm_parent->power.power_state.event); 34 } 35 if (dev->bus && dev->bus->resume) { 36 dev_dbg(dev,"resuming\n"); 37 error = dev->bus->resume(dev); 38 } 39 up(&dev->sem); 40 return error; 41} 42 43 44 45void dpm_resume(void) 46{ 47 down(&dpm_list_sem); 48 while(!list_empty(&dpm_off)) { 49 struct list_head * entry = dpm_off.next; 50 struct device * dev = to_device(entry); 51 52 get_device(dev); 53 list_del_init(entry); 54 list_add_tail(entry, &dpm_active); 55 56 up(&dpm_list_sem); 57 if (!dev->power.prev_state.event) 58 resume_device(dev); 59 down(&dpm_list_sem); 60 put_device(dev); 61 } 62 up(&dpm_list_sem); 63} 64 65 66/** 67 * device_resume - Restore state of each device in system. 68 * 69 * Walk the dpm_off list, remove each entry, resume the device, 70 * then add it to the dpm_active list. 71 */ 72 73void device_resume(void) 74{ 75 down(&dpm_sem); 76 dpm_resume(); 77 up(&dpm_sem); 78} 79 80EXPORT_SYMBOL_GPL(device_resume); 81 82 83/** 84 * device_power_up_irq - Power on some devices. 85 * 86 * Walk the dpm_off_irq list and power each device up. This 87 * is used for devices that required they be powered down with 88 * interrupts disabled. As devices are powered on, they are moved to 89 * the dpm_suspended list. 90 * 91 * Interrupts must be disabled when calling this. 92 */ 93 94void dpm_power_up(void) 95{ 96 while(!list_empty(&dpm_off_irq)) { 97 struct list_head * entry = dpm_off_irq.next; 98 struct device * dev = to_device(entry); 99 100 get_device(dev); 101 list_del_init(entry); 102 list_add_tail(entry, &dpm_active); 103 resume_device(dev); 104 put_device(dev); 105 } 106} 107 108 109/** 110 * device_pm_power_up - Turn on all devices that need special attention. 111 * 112 * Power on system devices then devices that required we shut them down 113 * with interrupts disabled. 114 * Called with interrupts disabled. 115 */ 116 117void device_power_up(void) 118{ 119 sysdev_resume(); 120 dpm_power_up(); 121} 122 123EXPORT_SYMBOL_GPL(device_power_up); 124 125