Linux Audio

Check our new training course

Loading...
v4.6
 
  1/*
  2 *  Copyright 2013 Matthew Garrett <mjg59@srcf.ucam.org>
  3 *
  4 *  This program is free software; you can redistribute it and/or modify
  5 *  it under the terms of the GNU General Public License as published by
  6 *  the Free Software Foundation; either version 2 of the License, or
  7 *  (at your option) any later version.
  8 *
  9 *  This program is distributed in the hope that it will be useful,
 10 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12 *  GNU General Public License for more details.
 13 *
 14 *  You should have received a copy of the GNU General Public License along
 15 *  with this program; if not, write to the Free Software Foundation, Inc.,
 16 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 17 */
 18
 19
 20#include <linux/init.h>
 21#include <linux/module.h>
 22#include <linux/slab.h>
 23#include <linux/acpi.h>
 24
 25MODULE_LICENSE("GPL");
 26
 27static ssize_t irst_show_wakeup_events(struct device *dev,
 28				       struct device_attribute *attr,
 29				       char *buf)
 30{
 31	struct acpi_device *acpi;
 32	unsigned long long value;
 33	acpi_status status;
 34
 35	acpi = to_acpi_device(dev);
 36
 37	status = acpi_evaluate_integer(acpi->handle, "GFFS", NULL, &value);
 38	if (ACPI_FAILURE(status))
 39		return -EINVAL;
 40
 41	return sprintf(buf, "%lld\n", value);
 42}
 43
 44static ssize_t irst_store_wakeup_events(struct device *dev,
 45					struct device_attribute *attr,
 46					const char *buf, size_t count)
 47{
 48	struct acpi_device *acpi;
 49	acpi_status status;
 50	unsigned long value;
 51	int error;
 52
 53	acpi = to_acpi_device(dev);
 54
 55	error = kstrtoul(buf, 0, &value);
 56
 57	if (error)
 58		return error;
 59
 60	status = acpi_execute_simple_method(acpi->handle, "SFFS", value);
 61
 62	if (ACPI_FAILURE(status))
 63		return -EINVAL;
 64
 65	return count;
 66}
 67
 68static struct device_attribute irst_wakeup_attr = {
 69	.attr = { .name = "wakeup_events", .mode = 0600 },
 70	.show = irst_show_wakeup_events,
 71	.store = irst_store_wakeup_events
 72};
 73
 74static ssize_t irst_show_wakeup_time(struct device *dev,
 75				     struct device_attribute *attr, char *buf)
 76{
 77	struct acpi_device *acpi;
 78	unsigned long long value;
 79	acpi_status status;
 80
 81	acpi = to_acpi_device(dev);
 82
 83	status = acpi_evaluate_integer(acpi->handle, "GFTV", NULL, &value);
 84	if (ACPI_FAILURE(status))
 85		return -EINVAL;
 86
 87	return sprintf(buf, "%lld\n", value);
 88}
 89
 90static ssize_t irst_store_wakeup_time(struct device *dev,
 91				      struct device_attribute *attr,
 92				      const char *buf, size_t count)
 93{
 94	struct acpi_device *acpi;
 95	acpi_status status;
 96	unsigned long value;
 97	int error;
 98
 99	acpi = to_acpi_device(dev);
100
101	error = kstrtoul(buf, 0, &value);
102
103	if (error)
104		return error;
105
106	status = acpi_execute_simple_method(acpi->handle, "SFTV", value);
107
108	if (ACPI_FAILURE(status))
109		return -EINVAL;
110
111	return count;
112}
113
114static struct device_attribute irst_timeout_attr = {
115	.attr = { .name = "wakeup_time", .mode = 0600 },
116	.show = irst_show_wakeup_time,
117	.store = irst_store_wakeup_time
118};
119
120static int irst_add(struct acpi_device *acpi)
121{
122	int error;
123
124	error = device_create_file(&acpi->dev, &irst_timeout_attr);
125	if (unlikely(error))
126		return error;
127
128	error = device_create_file(&acpi->dev, &irst_wakeup_attr);
129	if (unlikely(error))
130		device_remove_file(&acpi->dev, &irst_timeout_attr);
131
132	return error;
133}
134
135static int irst_remove(struct acpi_device *acpi)
136{
137	device_remove_file(&acpi->dev, &irst_wakeup_attr);
138	device_remove_file(&acpi->dev, &irst_timeout_attr);
139
140	return 0;
141}
142
143static const struct acpi_device_id irst_ids[] = {
144	{"INT3392", 0},
145	{"", 0}
146};
147
148static struct acpi_driver irst_driver = {
149	.owner = THIS_MODULE,
150	.name = "intel_rapid_start",
151	.class = "intel_rapid_start",
152	.ids = irst_ids,
153	.ops = {
154		.add = irst_add,
155		.remove = irst_remove,
156	},
157};
158
159module_acpi_driver(irst_driver);
160
161MODULE_DEVICE_TABLE(acpi, irst_ids);
v5.4
  1// SPDX-License-Identifier: GPL-2.0+
  2/*
  3 *  Copyright 2013 Matthew Garrett <mjg59@srcf.ucam.org>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  4 */
  5
  6#include <linux/acpi.h>
 
  7#include <linux/module.h>
  8#include <linux/slab.h>
 
  9
 10MODULE_LICENSE("GPL");
 11
 12static ssize_t irst_show_wakeup_events(struct device *dev,
 13				       struct device_attribute *attr,
 14				       char *buf)
 15{
 16	struct acpi_device *acpi;
 17	unsigned long long value;
 18	acpi_status status;
 19
 20	acpi = to_acpi_device(dev);
 21
 22	status = acpi_evaluate_integer(acpi->handle, "GFFS", NULL, &value);
 23	if (ACPI_FAILURE(status))
 24		return -EINVAL;
 25
 26	return sprintf(buf, "%lld\n", value);
 27}
 28
 29static ssize_t irst_store_wakeup_events(struct device *dev,
 30					struct device_attribute *attr,
 31					const char *buf, size_t count)
 32{
 33	struct acpi_device *acpi;
 34	acpi_status status;
 35	unsigned long value;
 36	int error;
 37
 38	acpi = to_acpi_device(dev);
 39
 40	error = kstrtoul(buf, 0, &value);
 
 41	if (error)
 42		return error;
 43
 44	status = acpi_execute_simple_method(acpi->handle, "SFFS", value);
 
 45	if (ACPI_FAILURE(status))
 46		return -EINVAL;
 47
 48	return count;
 49}
 50
 51static struct device_attribute irst_wakeup_attr = {
 52	.attr = { .name = "wakeup_events", .mode = 0600 },
 53	.show = irst_show_wakeup_events,
 54	.store = irst_store_wakeup_events
 55};
 56
 57static ssize_t irst_show_wakeup_time(struct device *dev,
 58				     struct device_attribute *attr, char *buf)
 59{
 60	struct acpi_device *acpi;
 61	unsigned long long value;
 62	acpi_status status;
 63
 64	acpi = to_acpi_device(dev);
 65
 66	status = acpi_evaluate_integer(acpi->handle, "GFTV", NULL, &value);
 67	if (ACPI_FAILURE(status))
 68		return -EINVAL;
 69
 70	return sprintf(buf, "%lld\n", value);
 71}
 72
 73static ssize_t irst_store_wakeup_time(struct device *dev,
 74				      struct device_attribute *attr,
 75				      const char *buf, size_t count)
 76{
 77	struct acpi_device *acpi;
 78	acpi_status status;
 79	unsigned long value;
 80	int error;
 81
 82	acpi = to_acpi_device(dev);
 83
 84	error = kstrtoul(buf, 0, &value);
 
 85	if (error)
 86		return error;
 87
 88	status = acpi_execute_simple_method(acpi->handle, "SFTV", value);
 
 89	if (ACPI_FAILURE(status))
 90		return -EINVAL;
 91
 92	return count;
 93}
 94
 95static struct device_attribute irst_timeout_attr = {
 96	.attr = { .name = "wakeup_time", .mode = 0600 },
 97	.show = irst_show_wakeup_time,
 98	.store = irst_store_wakeup_time
 99};
100
101static int irst_add(struct acpi_device *acpi)
102{
103	int error;
104
105	error = device_create_file(&acpi->dev, &irst_timeout_attr);
106	if (unlikely(error))
107		return error;
108
109	error = device_create_file(&acpi->dev, &irst_wakeup_attr);
110	if (unlikely(error))
111		device_remove_file(&acpi->dev, &irst_timeout_attr);
112
113	return error;
114}
115
116static int irst_remove(struct acpi_device *acpi)
117{
118	device_remove_file(&acpi->dev, &irst_wakeup_attr);
119	device_remove_file(&acpi->dev, &irst_timeout_attr);
120
121	return 0;
122}
123
124static const struct acpi_device_id irst_ids[] = {
125	{"INT3392", 0},
126	{"", 0}
127};
128
129static struct acpi_driver irst_driver = {
130	.owner = THIS_MODULE,
131	.name = "intel_rapid_start",
132	.class = "intel_rapid_start",
133	.ids = irst_ids,
134	.ops = {
135		.add = irst_add,
136		.remove = irst_remove,
137	},
138};
139
140module_acpi_driver(irst_driver);
141
142MODULE_DEVICE_TABLE(acpi, irst_ids);