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