aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2009-12-24 01:17:46 -0500
committerLen Brown <len.brown@intel.com>2009-12-24 01:17:46 -0500
commit78a5331dddcffabadef024ccc051f7a519b13238 (patch)
tree612915bee76ab646d1d281b8ab8c556ad0a4e337 /drivers
parentfe7fa9c51a76cf67934c2e77dc9d84800c9fbf79 (diff)
parent8e698a3c47887fe5aa5e2252c27bb6ff416a07e4 (diff)
Merge branch 'tc1100-wmi' into release
Diffstat (limited to 'drivers')
-rw-r--r--drivers/platform/x86/tc1100-wmi.c115
1 files changed, 55 insertions, 60 deletions
diff --git a/drivers/platform/x86/tc1100-wmi.c b/drivers/platform/x86/tc1100-wmi.c
index 44166003d4e..dd33b51c348 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");
47MODULE_LICENSE("GPL"); 47MODULE_LICENSE("GPL");
48MODULE_ALIAS("wmi:C364AC71-36DB-495A-8494-B439D472A505"); 48MODULE_ALIAS("wmi:C364AC71-36DB-495A-8494-B439D472A505");
49 49
50static int tc1100_probe(struct platform_device *device);
51static int tc1100_remove(struct platform_device *device);
52static int tc1100_suspend(struct platform_device *device, pm_message_t state);
53static int tc1100_resume(struct platform_device *device);
54
55static 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
66static struct platform_device *tc1100_device; 50static struct platform_device *tc1100_device;
67 51
68struct tc1100_data { 52struct tc1100_data {
@@ -183,51 +167,35 @@ static DEVICE_ATTR(value, S_IWUGO | S_IRUGO | S_IWUSR, \
183show_set_bool(wireless, TC1100_INSTANCE_WIRELESS); 167show_set_bool(wireless, TC1100_INSTANCE_WIRELESS);
184show_set_bool(jogdial, TC1100_INSTANCE_JOGDIAL); 168show_set_bool(jogdial, TC1100_INSTANCE_JOGDIAL);
185 169
186static void remove_fs(void) 170static 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
192static 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
206add_sysfs_error: 176static 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
215static int tc1100_probe(struct platform_device *device) 184static 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
224static int tc1100_remove(struct platform_device *device) 190static 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
230static int tc1100_suspend(struct platform_device *dev, pm_message_t state) 197#ifdef CONFIG_PM
198static 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
245static int tc1100_resume(struct platform_device *dev) 213static 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
228static 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
236static 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
260static int __init tc1100_init(void) 247static 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
279static void __exit tc1100_exit(void) 276static 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
287module_init(tc1100_init); 282module_init(tc1100_init);