Linux 3.12.39
[linux/fpc-iii.git] / drivers / platform / x86 / intel-smartconnect.c
blob52259dcabecb8251edad2a0e0dc7eccb9b174500
1 /*
2 * Copyright 2013 Matthew Garrett <mjg59@srcf.ucam.org>
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.
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.
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.
20 #include <linux/init.h>
21 #include <linux/module.h>
22 #include <acpi/acpi_drivers.h>
24 MODULE_LICENSE("GPL");
26 static int smartconnect_acpi_init(struct acpi_device *acpi)
28 struct acpi_object_list input;
29 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
30 union acpi_object *result;
31 union acpi_object param;
32 acpi_status status;
34 status = acpi_evaluate_object(acpi->handle, "GAOS", NULL, &output);
35 if (!ACPI_SUCCESS(status))
36 return -EINVAL;
38 result = output.pointer;
40 if (result->type != ACPI_TYPE_INTEGER) {
41 kfree(result);
42 return -EINVAL;
45 if (result->integer.value & 0x1) {
46 param.type = ACPI_TYPE_INTEGER;
47 param.integer.value = 0;
49 input.count = 1;
50 input.pointer = &param;
52 dev_info(&acpi->dev, "Disabling Intel Smart Connect\n");
53 status = acpi_evaluate_object(acpi->handle, "SAOS", &input,
54 NULL);
57 kfree(result);
59 return 0;
62 static const struct acpi_device_id smartconnect_ids[] = {
63 {"INT33A0", 0},
64 {"", 0}
67 static struct acpi_driver smartconnect_driver = {
68 .owner = THIS_MODULE,
69 .name = "intel_smart_connect",
70 .class = "intel_smart_connect",
71 .ids = smartconnect_ids,
72 .ops = {
73 .add = smartconnect_acpi_init,
77 module_acpi_driver(smartconnect_driver);
79 MODULE_DEVICE_TABLE(acpi, smartconnect_ids);