Revert "unicode: Don't special case ignorable code points"
[linux.git] / drivers / platform / x86 / intel / rst.c
blobf3a60e14d4c17c1d2359d0ec7f77fdb04f547973
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * Copyright 2013 Matthew Garrett <mjg59@srcf.ucam.org>
4 */
6 #include <linux/acpi.h>
7 #include <linux/module.h>
8 #include <linux/slab.h>
10 MODULE_DESCRIPTION("Intel Rapid Start Technology Driver");
11 MODULE_LICENSE("GPL");
13 static ssize_t irst_show_wakeup_events(struct device *dev,
14 struct device_attribute *attr,
15 char *buf)
17 struct acpi_device *acpi;
18 unsigned long long value;
19 acpi_status status;
21 acpi = to_acpi_device(dev);
23 status = acpi_evaluate_integer(acpi->handle, "GFFS", NULL, &value);
24 if (ACPI_FAILURE(status))
25 return -EINVAL;
27 return sprintf(buf, "%lld\n", value);
30 static ssize_t irst_store_wakeup_events(struct device *dev,
31 struct device_attribute *attr,
32 const char *buf, size_t count)
34 struct acpi_device *acpi;
35 acpi_status status;
36 unsigned long value;
37 int error;
39 acpi = to_acpi_device(dev);
41 error = kstrtoul(buf, 0, &value);
42 if (error)
43 return error;
45 status = acpi_execute_simple_method(acpi->handle, "SFFS", value);
46 if (ACPI_FAILURE(status))
47 return -EINVAL;
49 return count;
52 static struct device_attribute irst_wakeup_attr = {
53 .attr = { .name = "wakeup_events", .mode = 0600 },
54 .show = irst_show_wakeup_events,
55 .store = irst_store_wakeup_events
58 static ssize_t irst_show_wakeup_time(struct device *dev,
59 struct device_attribute *attr, char *buf)
61 struct acpi_device *acpi;
62 unsigned long long value;
63 acpi_status status;
65 acpi = to_acpi_device(dev);
67 status = acpi_evaluate_integer(acpi->handle, "GFTV", NULL, &value);
68 if (ACPI_FAILURE(status))
69 return -EINVAL;
71 return sprintf(buf, "%lld\n", value);
74 static ssize_t irst_store_wakeup_time(struct device *dev,
75 struct device_attribute *attr,
76 const char *buf, size_t count)
78 struct acpi_device *acpi;
79 acpi_status status;
80 unsigned long value;
81 int error;
83 acpi = to_acpi_device(dev);
85 error = kstrtoul(buf, 0, &value);
86 if (error)
87 return error;
89 status = acpi_execute_simple_method(acpi->handle, "SFTV", value);
90 if (ACPI_FAILURE(status))
91 return -EINVAL;
93 return count;
96 static struct device_attribute irst_timeout_attr = {
97 .attr = { .name = "wakeup_time", .mode = 0600 },
98 .show = irst_show_wakeup_time,
99 .store = irst_store_wakeup_time
102 static int irst_add(struct acpi_device *acpi)
104 int error;
106 error = device_create_file(&acpi->dev, &irst_timeout_attr);
107 if (unlikely(error))
108 return error;
110 error = device_create_file(&acpi->dev, &irst_wakeup_attr);
111 if (unlikely(error))
112 device_remove_file(&acpi->dev, &irst_timeout_attr);
114 return error;
117 static void irst_remove(struct acpi_device *acpi)
119 device_remove_file(&acpi->dev, &irst_wakeup_attr);
120 device_remove_file(&acpi->dev, &irst_timeout_attr);
123 static const struct acpi_device_id irst_ids[] = {
124 {"INT3392", 0},
125 {"", 0}
128 static struct acpi_driver irst_driver = {
129 .name = "intel_rapid_start",
130 .class = "intel_rapid_start",
131 .ids = irst_ids,
132 .ops = {
133 .add = irst_add,
134 .remove = irst_remove,
138 module_acpi_driver(irst_driver);
140 MODULE_DEVICE_TABLE(acpi, irst_ids);