2005-04-16 16:20:36 -06:00
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/seq_file.h>
|
2011-10-26 14:22:14 -06:00
|
|
|
#include <linux/export.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <linux/suspend.h>
|
|
|
|
#include <linux/bcd.h>
|
2013-12-02 17:49:16 -07:00
|
|
|
#include <linux/acpi.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <asm/uaccess.h>
|
|
|
|
|
|
|
|
#include "sleep.h"
|
2013-12-17 02:34:17 -07:00
|
|
|
#include "internal.h"
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
#define _COMPONENT ACPI_SYSTEM_COMPONENT
|
2007-07-24 00:16:50 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* this file provides support for:
|
|
|
|
* /proc/acpi/wakeup
|
|
|
|
*/
|
|
|
|
|
2005-08-04 22:44:28 -06:00
|
|
|
ACPI_MODULE_NAME("sleep")
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
static int
|
|
|
|
acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
|
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
struct list_head *node, *next;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-04-25 13:20:10 -06:00
|
|
|
seq_printf(seq, "Device\tS-state\t Status Sysfs node\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2009-04-06 20:24:29 -06:00
|
|
|
mutex_lock(&acpi_device_lock);
|
2005-04-16 16:20:36 -06:00
|
|
|
list_for_each_safe(node, next, &acpi_wakeup_device_list) {
|
2005-08-04 22:44:28 -06:00
|
|
|
struct acpi_device *dev =
|
|
|
|
container_of(node, struct acpi_device, wakeup_list);
|
2012-08-17 00:44:09 -06:00
|
|
|
struct acpi_device_physical_node *entry;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if (!dev->wakeup.flags.valid)
|
|
|
|
continue;
|
2007-04-25 13:20:10 -06:00
|
|
|
|
2012-08-17 00:44:09 -06:00
|
|
|
seq_printf(seq, "%s\t S%d\t",
|
2005-08-04 22:44:28 -06:00
|
|
|
dev->pnp.bus_id,
|
2012-08-17 00:44:09 -06:00
|
|
|
(u32) dev->wakeup.sleep_state);
|
|
|
|
|
2013-08-05 18:26:22 -06:00
|
|
|
mutex_lock(&dev->physical_node_lock);
|
|
|
|
|
2013-01-27 07:17:55 -07:00
|
|
|
if (!dev->physical_node_count) {
|
2012-08-17 00:44:09 -06:00
|
|
|
seq_printf(seq, "%c%-8s\n",
|
2013-01-27 07:17:55 -07:00
|
|
|
dev->wakeup.flags.run_wake ? '*' : ' ',
|
|
|
|
device_may_wakeup(&dev->dev) ?
|
|
|
|
"enabled" : "disabled");
|
|
|
|
} else {
|
2012-08-17 00:44:09 -06:00
|
|
|
struct device *ldev;
|
|
|
|
list_for_each_entry(entry, &dev->physical_node_list,
|
|
|
|
node) {
|
|
|
|
ldev = get_device(entry->dev);
|
|
|
|
if (!ldev)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (&entry->node !=
|
|
|
|
dev->physical_node_list.next)
|
|
|
|
seq_printf(seq, "\t\t");
|
|
|
|
|
|
|
|
seq_printf(seq, "%c%-8s %s:%s\n",
|
|
|
|
dev->wakeup.flags.run_wake ? '*' : ' ',
|
|
|
|
(device_may_wakeup(&dev->dev) ||
|
2014-01-30 04:55:15 -07:00
|
|
|
device_may_wakeup(ldev)) ?
|
2012-08-17 00:44:09 -06:00
|
|
|
"enabled" : "disabled",
|
|
|
|
ldev->bus ? ldev->bus->name :
|
|
|
|
"no-bus", dev_name(ldev));
|
|
|
|
put_device(ldev);
|
|
|
|
}
|
|
|
|
}
|
2013-08-05 18:26:22 -06:00
|
|
|
|
|
|
|
mutex_unlock(&dev->physical_node_lock);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
2009-04-06 20:24:29 -06:00
|
|
|
mutex_unlock(&acpi_device_lock);
|
2005-04-16 16:20:36 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-10-03 16:23:49 -06:00
|
|
|
static void physical_device_enable_wakeup(struct acpi_device *adev)
|
|
|
|
{
|
2012-08-17 00:44:09 -06:00
|
|
|
struct acpi_device_physical_node *entry;
|
2008-10-03 16:23:49 -06:00
|
|
|
|
2013-08-05 18:26:22 -06:00
|
|
|
mutex_lock(&adev->physical_node_lock);
|
|
|
|
|
2012-08-17 00:44:09 -06:00
|
|
|
list_for_each_entry(entry,
|
|
|
|
&adev->physical_node_list, node)
|
|
|
|
if (entry->dev && device_can_wakeup(entry->dev)) {
|
|
|
|
bool enable = !device_may_wakeup(entry->dev);
|
|
|
|
device_set_wakeup_enable(entry->dev, enable);
|
|
|
|
}
|
2013-08-05 18:26:22 -06:00
|
|
|
|
|
|
|
mutex_unlock(&adev->physical_node_lock);
|
2008-10-03 16:23:49 -06:00
|
|
|
}
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
static ssize_t
|
2005-08-04 22:44:28 -06:00
|
|
|
acpi_system_write_wakeup_device(struct file *file,
|
|
|
|
const char __user * buffer,
|
|
|
|
size_t count, loff_t * ppos)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
struct list_head *node, *next;
|
|
|
|
char strbuf[5];
|
|
|
|
char str[5] = "";
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2012-11-22 15:20:31 -07:00
|
|
|
if (count > 4)
|
|
|
|
count = 4;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2012-11-22 15:20:31 -07:00
|
|
|
if (copy_from_user(strbuf, buffer, count))
|
2005-04-16 16:20:36 -06:00
|
|
|
return -EFAULT;
|
2012-11-22 15:20:31 -07:00
|
|
|
strbuf[count] = '\0';
|
2005-04-16 16:20:36 -06:00
|
|
|
sscanf(strbuf, "%s", str);
|
|
|
|
|
2009-04-06 20:24:29 -06:00
|
|
|
mutex_lock(&acpi_device_lock);
|
2005-04-16 16:20:36 -06:00
|
|
|
list_for_each_safe(node, next, &acpi_wakeup_device_list) {
|
2005-08-04 22:44:28 -06:00
|
|
|
struct acpi_device *dev =
|
|
|
|
container_of(node, struct acpi_device, wakeup_list);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (!dev->wakeup.flags.valid)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!strncmp(dev->pnp.bus_id, str, 4)) {
|
2011-01-06 15:34:22 -07:00
|
|
|
if (device_can_wakeup(&dev->dev)) {
|
|
|
|
bool enable = !device_may_wakeup(&dev->dev);
|
|
|
|
device_set_wakeup_enable(&dev->dev, enable);
|
|
|
|
} else {
|
|
|
|
physical_device_enable_wakeup(dev);
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-04-06 20:24:29 -06:00
|
|
|
mutex_unlock(&acpi_device_lock);
|
2005-04-16 16:20:36 -06:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file)
|
|
|
|
{
|
2005-08-04 22:44:28 -06:00
|
|
|
return single_open(file, acpi_system_wakeup_device_seq_show,
|
2013-03-31 16:16:14 -06:00
|
|
|
PDE_DATA(inode));
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2006-07-04 11:06:00 -06:00
|
|
|
static const struct file_operations acpi_system_wakeup_device_fops = {
|
2008-04-29 02:02:27 -06:00
|
|
|
.owner = THIS_MODULE,
|
2005-08-04 22:44:28 -06:00
|
|
|
.open = acpi_system_wakeup_device_open_fs,
|
|
|
|
.read = seq_read,
|
|
|
|
.write = acpi_system_write_wakeup_device,
|
|
|
|
.llseek = seq_lseek,
|
|
|
|
.release = single_release,
|
2005-04-16 16:20:36 -06:00
|
|
|
};
|
|
|
|
|
2015-09-11 08:49:22 -06:00
|
|
|
void __init acpi_sleep_proc_init(void)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2005-08-04 22:37:45 -06:00
|
|
|
/* 'wakeup device' [R/W] */
|
2008-04-29 02:02:27 -06:00
|
|
|
proc_create("wakeup", S_IFREG | S_IRUGO | S_IWUSR,
|
|
|
|
acpi_root_dir, &acpi_system_wakeup_device_fops);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|