View | Details | Raw Unified | Return to bug 150611
Collapse All | Expand All

(-)a/drivers/platform/x86/toshiba-wmi.c (-8 / +22 lines)
Lines 24-39 Link Here
24
#include <linux/acpi.h>
24
#include <linux/acpi.h>
25
#include <linux/input.h>
25
#include <linux/input.h>
26
#include <linux/input/sparse-keymap.h>
26
#include <linux/input/sparse-keymap.h>
27
#include <linux/dmi.h>
27
28
28
MODULE_AUTHOR("Azael Avalos");
29
MODULE_AUTHOR("Azael Avalos");
29
MODULE_DESCRIPTION("Toshiba WMI Hotkey Driver");
30
MODULE_DESCRIPTION("Toshiba WMI Hotkey Driver");
30
MODULE_LICENSE("GPL");
31
MODULE_LICENSE("GPL");
31
32
32
#define TOSHIBA_WMI_EVENT_GUID	"59142400-C6A3-40FA-BADB-8A2652834100"
33
#define WMI_EVENT_GUID	"59142400-C6A3-40FA-BADB-8A2652834100"
33
34
34
MODULE_ALIAS("wmi:"TOSHIBA_WMI_EVENT_GUID);
35
MODULE_ALIAS("wmi:"WMI_EVENT_GUID);
35
36
36
static struct input_dev *toshiba_wmi_input_dev;
37
static struct input_dev *toshiba_wmi_input_dev;
38
static bool input_device_registered;
37
39
38
static const struct key_entry toshiba_wmi_keymap[] __initconst = {
40
static const struct key_entry toshiba_wmi_keymap[] __initconst = {
39
	/* TODO: Add keymap values once found... */
41
	/* TODO: Add keymap values once found... */
Lines 63-68 static void toshiba_wmi_notify(u32 value, void *context) Link Here
63
	kfree(response.pointer);
65
	kfree(response.pointer);
64
}
66
}
65
67
68
static struct dmi_system_id __initdata toshiba_wmi_dmi_table[] = {
69
	{
70
		.ident = "Toshiba laptop",
71
		.matches = {
72
			DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
73
		},
74
	},
75
	{}
76
};
77
66
static int __init toshiba_wmi_input_setup(void)
78
static int __init toshiba_wmi_input_setup(void)
67
{
79
{
68
	acpi_status status;
80
	acpi_status status;
Lines 81-87 static int __init toshiba_wmi_input_setup(void) Link Here
81
	if (err)
93
	if (err)
82
		goto err_free_dev;
94
		goto err_free_dev;
83
95
84
	status = wmi_install_notify_handler(TOSHIBA_WMI_EVENT_GUID,
96
	status = wmi_install_notify_handler(WMI_EVENT_GUID,
85
					    toshiba_wmi_notify, NULL);
97
					    toshiba_wmi_notify, NULL);
86
	if (ACPI_FAILURE(status)) {
98
	if (ACPI_FAILURE(status)) {
87
		err = -EIO;
99
		err = -EIO;
Lines 95-101 static int __init toshiba_wmi_input_setup(void) Link Here
95
	return 0;
107
	return 0;
96
108
97
 err_remove_notifier:
109
 err_remove_notifier:
98
	wmi_remove_notify_handler(TOSHIBA_WMI_EVENT_GUID);
110
	wmi_remove_notify_handler(WMI_EVENT_GUID);
99
 err_free_keymap:
111
 err_free_keymap:
100
	sparse_keymap_free(toshiba_wmi_input_dev);
112
	sparse_keymap_free(toshiba_wmi_input_dev);
101
 err_free_dev:
113
 err_free_dev:
Lines 105-111 static int __init toshiba_wmi_input_setup(void) Link Here
105
117
106
static void toshiba_wmi_input_destroy(void)
118
static void toshiba_wmi_input_destroy(void)
107
{
119
{
108
	wmi_remove_notify_handler(TOSHIBA_WMI_EVENT_GUID);
120
	wmi_remove_notify_handler(WMI_EVENT_GUID);
109
	sparse_keymap_free(toshiba_wmi_input_dev);
121
	sparse_keymap_free(toshiba_wmi_input_dev);
110
	input_unregister_device(toshiba_wmi_input_dev);
122
	input_unregister_device(toshiba_wmi_input_dev);
111
}
123
}
Lines 114-127 static int __init toshiba_wmi_init(void) Link Here
114
{
126
{
115
	int ret;
127
	int ret;
116
128
117
	if (!wmi_has_guid(TOSHIBA_WMI_EVENT_GUID))
129
	if (!wmi_has_guid(WMI_EVENT_GUID) &&
130
	    !dmi_check_system(toshiba_wmi_dmi_table))
118
		return -ENODEV;
131
		return -ENODEV;
119
132
120
	ret = toshiba_wmi_input_setup();
133
	ret = toshiba_wmi_input_setup();
121
	if (ret) {
134
	if (ret) {
122
		pr_err("Failed to setup input device\n");
135
		pr_err("Failed to setup input device\n");
136
		input_device_registered = false;
123
		return ret;
137
		return ret;
124
	}
138
	}
139
	input_device_registered = true;
125
140
126
	pr_info("Toshiba WMI Hotkey Driver\n");
141
	pr_info("Toshiba WMI Hotkey Driver\n");
127
142
Lines 130-136 static int __init toshiba_wmi_init(void) Link Here
130
145
131
static void __exit toshiba_wmi_exit(void)
146
static void __exit toshiba_wmi_exit(void)
132
{
147
{
133
	if (wmi_has_guid(TOSHIBA_WMI_EVENT_GUID))
148
	if (wmi_has_guid(WMI_EVENT_GUID) && input_device_registered)
134
		toshiba_wmi_input_destroy();
149
		toshiba_wmi_input_destroy();
135
}
150
}
136
151
137
- 

Return to bug 150611