1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2013 Matthew Garrett <mjg59@srcf.ucam.org>
*/
#include <linux/acpi.h>
#include <linux/module.h>
#include <linux/slab.h>
MODULE_LICENSE("GPL");
static ssize_t irst_show_wakeup_events(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct acpi_device *acpi;
unsigned long long value;
acpi_status status;
acpi = to_acpi_device(dev);
status = acpi_evaluate_integer(acpi->handle, "GFFS", NULL, &value);
if (ACPI_FAILURE(status))
return -EINVAL;
return sprintf(buf, "%lld\n", value);
}
static ssize_t irst_store_wakeup_events(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct acpi_device *acpi;
acpi_status status;
unsigned long value;
int error;
acpi = to_acpi_device(dev);
error = kstrtoul(buf, 0, &value);
if (error)
return error;
status = acpi_execute_simple_method(acpi->handle, "SFFS", value);
if (ACPI_FAILURE(status))
return -EINVAL;
return count;
}
static struct device_attribute irst_wakeup_attr = {
.attr = { .name = "wakeup_events", .mode = 0600 },
.show = irst_show_wakeup_events,
.store = irst_store_wakeup_events
};
static ssize_t irst_show_wakeup_time(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct acpi_device *acpi;
unsigned long long value;
acpi_status status;
acpi = to_acpi_device(dev);
status = acpi_evaluate_integer(acpi->handle, "GFTV", NULL, &value);
if (ACPI_FAILURE(status))
return -EINVAL;
return sprintf(buf, "%lld\n", value);
}
static ssize_t irst_store_wakeup_time(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct acpi_device *acpi;
acpi_status status;
unsigned long value;
int error;
acpi = to_acpi_device(dev);
error = kstrtoul(buf, 0, &value);
if (error)
return error;
status = acpi_execute_simple_method(acpi->handle, "SFTV", value);
if (ACPI_FAILURE(status))
return -EINVAL;
return count;
}
static struct device_attribute irst_timeout_attr = {
.attr = { .name = "wakeup_time", .mode = 0600 },
.show = irst_show_wakeup_time,
.store = irst_store_wakeup_time
};
static int irst_add(struct acpi_device *acpi)
{
int error;
error = device_create_file(&acpi->dev, &irst_timeout_attr);
if (unlikely(error))
return error;
error = device_create_file(&acpi->dev, &irst_wakeup_attr);
if (unlikely(error))
device_remove_file(&acpi->dev, &irst_timeout_attr);
return error;
}
static void irst_remove(struct acpi_device *acpi)
{
device_remove_file(&acpi->dev, &irst_wakeup_attr);
device_remove_file(&acpi->dev, &irst_timeout_attr);
}
static const struct acpi_device_id irst_ids[] = {
{"INT3392", 0},
{"", 0}
};
static struct acpi_driver irst_driver = {
.name = "intel_rapid_start",
.class = "intel_rapid_start",
.ids = irst_ids,
.ops = {
.add = irst_add,
.remove = irst_remove,
},
};
module_acpi_driver(irst_driver);
MODULE_DEVICE_TABLE(acpi, irst_ids);
|