diff options
Diffstat (limited to 'drivers/platform/x86/tc1100-wmi.c')
-rw-r--r-- | drivers/platform/x86/tc1100-wmi.c | 116 |
1 files changed, 56 insertions, 60 deletions
diff --git a/drivers/platform/x86/tc1100-wmi.c b/drivers/platform/x86/tc1100-wmi.c index 44166003d4ef..1fe0f1feff71 100644 --- a/drivers/platform/x86/tc1100-wmi.c +++ b/drivers/platform/x86/tc1100-wmi.c | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
29 | #include <linux/module.h> | 29 | #include <linux/module.h> |
30 | #include <linux/slab.h> | ||
30 | #include <linux/init.h> | 31 | #include <linux/init.h> |
31 | #include <linux/types.h> | 32 | #include <linux/types.h> |
32 | #include <acpi/acpi.h> | 33 | #include <acpi/acpi.h> |
@@ -47,22 +48,6 @@ MODULE_DESCRIPTION("HP Compaq TC1100 Tablet WMI Extras"); | |||
47 | MODULE_LICENSE("GPL"); | 48 | MODULE_LICENSE("GPL"); |
48 | MODULE_ALIAS("wmi:C364AC71-36DB-495A-8494-B439D472A505"); | 49 | MODULE_ALIAS("wmi:C364AC71-36DB-495A-8494-B439D472A505"); |
49 | 50 | ||
50 | static int tc1100_probe(struct platform_device *device); | ||
51 | static int tc1100_remove(struct platform_device *device); | ||
52 | static int tc1100_suspend(struct platform_device *device, pm_message_t state); | ||
53 | static int tc1100_resume(struct platform_device *device); | ||
54 | |||
55 | static struct platform_driver tc1100_driver = { | ||
56 | .driver = { | ||
57 | .name = "tc1100-wmi", | ||
58 | .owner = THIS_MODULE, | ||
59 | }, | ||
60 | .probe = tc1100_probe, | ||
61 | .remove = tc1100_remove, | ||
62 | .suspend = tc1100_suspend, | ||
63 | .resume = tc1100_resume, | ||
64 | }; | ||
65 | |||
66 | static struct platform_device *tc1100_device; | 51 | static struct platform_device *tc1100_device; |
67 | 52 | ||
68 | struct tc1100_data { | 53 | struct tc1100_data { |
@@ -183,51 +168,35 @@ static DEVICE_ATTR(value, S_IWUGO | S_IRUGO | S_IWUSR, \ | |||
183 | show_set_bool(wireless, TC1100_INSTANCE_WIRELESS); | 168 | show_set_bool(wireless, TC1100_INSTANCE_WIRELESS); |
184 | show_set_bool(jogdial, TC1100_INSTANCE_JOGDIAL); | 169 | show_set_bool(jogdial, TC1100_INSTANCE_JOGDIAL); |
185 | 170 | ||
186 | static void remove_fs(void) | 171 | static struct attribute *tc1100_attributes[] = { |
187 | { | 172 | &dev_attr_wireless.attr, |
188 | device_remove_file(&tc1100_device->dev, &dev_attr_wireless); | 173 | &dev_attr_jogdial.attr, |
189 | device_remove_file(&tc1100_device->dev, &dev_attr_jogdial); | 174 | NULL |
190 | } | 175 | }; |
191 | |||
192 | static int add_fs(void) | ||
193 | { | ||
194 | int ret; | ||
195 | |||
196 | ret = device_create_file(&tc1100_device->dev, &dev_attr_wireless); | ||
197 | if (ret) | ||
198 | goto add_sysfs_error; | ||
199 | |||
200 | ret = device_create_file(&tc1100_device->dev, &dev_attr_jogdial); | ||
201 | if (ret) | ||
202 | goto add_sysfs_error; | ||
203 | |||
204 | return ret; | ||
205 | 176 | ||
206 | add_sysfs_error: | 177 | static struct attribute_group tc1100_attribute_group = { |
207 | remove_fs(); | 178 | .attrs = tc1100_attributes, |
208 | return ret; | 179 | }; |
209 | } | ||
210 | 180 | ||
211 | /* -------------------------------------------------------------------------- | 181 | /* -------------------------------------------------------------------------- |
212 | Driver Model | 182 | Driver Model |
213 | -------------------------------------------------------------------------- */ | 183 | -------------------------------------------------------------------------- */ |
214 | 184 | ||
215 | static int tc1100_probe(struct platform_device *device) | 185 | static int __init tc1100_probe(struct platform_device *device) |
216 | { | 186 | { |
217 | int result = 0; | 187 | return sysfs_create_group(&device->dev.kobj, &tc1100_attribute_group); |
218 | |||
219 | result = add_fs(); | ||
220 | return result; | ||
221 | } | 188 | } |
222 | 189 | ||
223 | 190 | ||
224 | static int tc1100_remove(struct platform_device *device) | 191 | static int __devexit tc1100_remove(struct platform_device *device) |
225 | { | 192 | { |
226 | remove_fs(); | 193 | sysfs_remove_group(&device->dev.kobj, &tc1100_attribute_group); |
194 | |||
227 | return 0; | 195 | return 0; |
228 | } | 196 | } |
229 | 197 | ||
230 | static int tc1100_suspend(struct platform_device *dev, pm_message_t state) | 198 | #ifdef CONFIG_PM |
199 | static int tc1100_suspend(struct device *dev) | ||
231 | { | 200 | { |
232 | int ret; | 201 | int ret; |
233 | 202 | ||
@@ -239,10 +208,10 @@ static int tc1100_suspend(struct platform_device *dev, pm_message_t state) | |||
239 | if (ret) | 208 | if (ret) |
240 | return ret; | 209 | return ret; |
241 | 210 | ||
242 | return ret; | 211 | return 0; |
243 | } | 212 | } |
244 | 213 | ||
245 | static int tc1100_resume(struct platform_device *dev) | 214 | static int tc1100_resume(struct device *dev) |
246 | { | 215 | { |
247 | int ret; | 216 | int ret; |
248 | 217 | ||
@@ -254,34 +223,61 @@ static int tc1100_resume(struct platform_device *dev) | |||
254 | if (ret) | 223 | if (ret) |
255 | return ret; | 224 | return ret; |
256 | 225 | ||
257 | return ret; | 226 | return 0; |
258 | } | 227 | } |
259 | 228 | ||
229 | static const struct dev_pm_ops tc1100_pm_ops = { | ||
230 | .suspend = tc1100_suspend, | ||
231 | .resume = tc1100_resume, | ||
232 | .freeze = tc1100_suspend, | ||
233 | .restore = tc1100_resume, | ||
234 | }; | ||
235 | #endif | ||
236 | |||
237 | static struct platform_driver tc1100_driver = { | ||
238 | .driver = { | ||
239 | .name = "tc1100-wmi", | ||
240 | .owner = THIS_MODULE, | ||
241 | #ifdef CONFIG_PM | ||
242 | .pm = &tc1100_pm_ops, | ||
243 | #endif | ||
244 | }, | ||
245 | .remove = __devexit_p(tc1100_remove), | ||
246 | }; | ||
247 | |||
260 | static int __init tc1100_init(void) | 248 | static int __init tc1100_init(void) |
261 | { | 249 | { |
262 | int result = 0; | 250 | int error; |
263 | 251 | ||
264 | if (!wmi_has_guid(GUID)) | 252 | if (!wmi_has_guid(GUID)) |
265 | return -ENODEV; | 253 | return -ENODEV; |
266 | 254 | ||
267 | result = platform_driver_register(&tc1100_driver); | ||
268 | if (result) | ||
269 | return result; | ||
270 | |||
271 | tc1100_device = platform_device_alloc("tc1100-wmi", -1); | 255 | tc1100_device = platform_device_alloc("tc1100-wmi", -1); |
272 | platform_device_add(tc1100_device); | 256 | if (!tc1100_device) |
257 | return -ENOMEM; | ||
258 | |||
259 | error = platform_device_add(tc1100_device); | ||
260 | if (error) | ||
261 | goto err_device_put; | ||
262 | |||
263 | error = platform_driver_probe(&tc1100_driver, tc1100_probe); | ||
264 | if (error) | ||
265 | goto err_device_del; | ||
273 | 266 | ||
274 | printk(TC1100_INFO "HP Compaq TC1100 Tablet WMI Extras loaded\n"); | 267 | printk(TC1100_INFO "HP Compaq TC1100 Tablet WMI Extras loaded\n"); |
268 | return 0; | ||
275 | 269 | ||
276 | return result; | 270 | err_device_del: |
271 | platform_device_del(tc1100_device); | ||
272 | err_device_put: | ||
273 | platform_device_put(tc1100_device); | ||
274 | return error; | ||
277 | } | 275 | } |
278 | 276 | ||
279 | static void __exit tc1100_exit(void) | 277 | static void __exit tc1100_exit(void) |
280 | { | 278 | { |
281 | platform_device_del(tc1100_device); | 279 | platform_device_unregister(tc1100_device); |
282 | platform_driver_unregister(&tc1100_driver); | 280 | platform_driver_unregister(&tc1100_driver); |
283 | |||
284 | printk(TC1100_INFO "HP Compaq TC1100 Tablet WMI Extras unloaded\n"); | ||
285 | } | 281 | } |
286 | 282 | ||
287 | module_init(tc1100_init); | 283 | module_init(tc1100_init); |