aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorIke Panhc <ike.pan@canonical.com>2010-12-13 05:00:27 -0500
committerMatthew Garrett <mjg@redhat.com>2011-01-07 17:03:46 -0500
commitc9f718d0c6b4cf8033aa0f5ac892d68ddfb865aa (patch)
tree1e6d54f4c46b5bc8b5dac599e4e39445b1111b6a /drivers/platform
parent98ee69191d3af68e2292528cbb16dcba3d8e2b81 (diff)
ideapad: let camera power control entry under platform driver
The entry was at /sys/devices/LNXSYSTM:00/../VPC2004:00/camera_power move to /sys/devices/platform/ideapad/camera_power Add document about usage of ideapad node in sysfs. Signed-off-by: Ike Panhc <ike.pan@canonical.com> Signed-off-by: Matthew Garrett <mjg@redhat.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/ideapad-laptop.c55
1 files changed, 25 insertions, 30 deletions
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 5998ae14a220..49f207fc61d2 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -282,6 +282,15 @@ static void ideapad_unregister_rfkill(struct acpi_device *adevice, int dev)
282/* 282/*
283 * Platform device 283 * Platform device
284 */ 284 */
285static struct attribute *ideapad_attributes[] = {
286 &dev_attr_camera_power.attr,
287 NULL
288};
289
290static struct attribute_group ideapad_attribute_group = {
291 .attrs = ideapad_attributes
292};
293
285static int __devinit ideapad_platform_init(void) 294static int __devinit ideapad_platform_init(void)
286{ 295{
287 int result; 296 int result;
@@ -295,8 +304,14 @@ static int __devinit ideapad_platform_init(void)
295 if (result) 304 if (result)
296 goto fail_platform_device; 305 goto fail_platform_device;
297 306
307 result = sysfs_create_group(&ideapad_priv->platform_device->dev.kobj,
308 &ideapad_attribute_group);
309 if (result)
310 goto fail_sysfs;
298 return 0; 311 return 0;
299 312
313fail_sysfs:
314 platform_device_del(ideapad_priv->platform_device);
300fail_platform_device: 315fail_platform_device:
301 platform_device_put(ideapad_priv->platform_device); 316 platform_device_put(ideapad_priv->platform_device);
302 return result; 317 return result;
@@ -304,6 +319,8 @@ fail_platform_device:
304 319
305static void ideapad_platform_exit(void) 320static void ideapad_platform_exit(void)
306{ 321{
322 sysfs_remove_group(&ideapad_priv->platform_device->dev.kobj,
323 &ideapad_attribute_group);
307 platform_device_unregister(ideapad_priv->platform_device); 324 platform_device_unregister(ideapad_priv->platform_device);
308} 325}
309/* the above is platform device */ 326/* the above is platform device */
@@ -317,50 +334,30 @@ MODULE_DEVICE_TABLE(acpi, ideapad_device_ids);
317static int ideapad_acpi_add(struct acpi_device *adevice) 334static int ideapad_acpi_add(struct acpi_device *adevice)
318{ 335{
319 int ret, i, cfg; 336 int ret, i, cfg;
320 int devs_present[5];
321 struct ideapad_private *priv; 337 struct ideapad_private *priv;
322 338
323 if (read_method_int(adevice->handle, "_CFG", &cfg)) 339 if (read_method_int(adevice->handle, "_CFG", &cfg))
324 return -ENODEV; 340 return -ENODEV;
325 341
326 for (i = IDEAPAD_DEV_CAMERA; i < IDEAPAD_DEV_KILLSW; i++) {
327 if (test_bit(ideapad_rfk_data[i].cfgbit, (unsigned long *)&cfg))
328 devs_present[i] = 1;
329 else
330 devs_present[i] = 0;
331 }
332
333 /* The hardware switch is always present */
334 devs_present[IDEAPAD_DEV_KILLSW] = 1;
335
336 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 342 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
337 if (!priv) 343 if (!priv)
338 return -ENOMEM; 344 return -ENOMEM;
339 ideapad_priv = priv; 345 ideapad_priv = priv;
346 priv->handle = adevice->handle;
347 dev_set_drvdata(&adevice->dev, priv);
340 348
341 ret = ideapad_platform_init(); 349 ret = ideapad_platform_init();
342 if (ret) 350 if (ret)
343 goto platform_failed; 351 goto platform_failed;
344 352
345 if (devs_present[IDEAPAD_DEV_CAMERA]) { 353 for (i = IDEAPAD_DEV_WLAN; i < IDEAPAD_DEV_KILLSW; i++) {
346 ret = device_create_file(&adevice->dev, &dev_attr_camera_power); 354 if (test_bit(ideapad_rfk_data[i].cfgbit, (unsigned long *)&cfg))
347 if (ret) 355 ideapad_register_rfkill(adevice, i);
348 goto camera_failed;
349 }
350
351 priv->handle = adevice->handle;
352 dev_set_drvdata(&adevice->dev, priv);
353 for (i = IDEAPAD_DEV_WLAN; i <= IDEAPAD_DEV_KILLSW; i++) {
354 if (!devs_present[i])
355 continue;
356
357 ideapad_register_rfkill(adevice, i);
358 } 356 }
359 ideapad_sync_rfk_state(adevice); 357 ideapad_sync_rfk_state(adevice);
358
360 return 0; 359 return 0;
361 360
362camera_failed:
363 ideapad_platform_exit();
364platform_failed: 361platform_failed:
365 kfree(priv); 362 kfree(priv);
366 return ret; 363 return ret;
@@ -371,14 +368,12 @@ static int ideapad_acpi_remove(struct acpi_device *adevice, int type)
371 struct ideapad_private *priv = dev_get_drvdata(&adevice->dev); 368 struct ideapad_private *priv = dev_get_drvdata(&adevice->dev);
372 int i; 369 int i;
373 370
374 device_remove_file(&adevice->dev, &dev_attr_camera_power); 371 for (i = IDEAPAD_DEV_WLAN; i < IDEAPAD_DEV_KILLSW; i++)
375
376 for (i = IDEAPAD_DEV_WLAN; i <= IDEAPAD_DEV_KILLSW; i++)
377 ideapad_unregister_rfkill(adevice, i); 372 ideapad_unregister_rfkill(adevice, i);
378
379 ideapad_platform_exit(); 373 ideapad_platform_exit();
380 dev_set_drvdata(&adevice->dev, NULL); 374 dev_set_drvdata(&adevice->dev, NULL);
381 kfree(priv); 375 kfree(priv);
376
382 return 0; 377 return 0;
383} 378}
384 379