diff options
author | Alan Jenkins <alan-jenkins@tuffmail.co.uk> | 2009-08-19 10:06:49 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-12-10 00:01:47 -0500 |
commit | ada3248a5d38654b33b0ae2eabe1d7e3d9a9ffce (patch) | |
tree | ac6212cce1384d39581c9deea4ec380a869403a2 /drivers/platform/x86/dell-laptop.c | |
parent | 4311bb230e0f7e4daa5fd5bc0cc536e2bd1eff20 (diff) |
dell-laptop: create a platform device as a parent for the rfkill devices etc.
dell-laptop may not need to export any sysfs files, but it should still
create a platform device as a parent for the rfkill and backlight
devices. Otherwise sysfs will display these as "virtual" devices,
with no connection to either physical hardware or the dell-laptop
module.
Apparently this is useful for hardware detection.
Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Acked-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/platform/x86/dell-laptop.c')
-rw-r--r-- | drivers/platform/x86/dell-laptop.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c index 94139d530c75..a4ce64244f65 100644 --- a/drivers/platform/x86/dell-laptop.c +++ b/drivers/platform/x86/dell-laptop.c | |||
@@ -58,6 +58,14 @@ static int da_command_code; | |||
58 | static int da_num_tokens; | 58 | static int da_num_tokens; |
59 | static struct calling_interface_token *da_tokens; | 59 | static struct calling_interface_token *da_tokens; |
60 | 60 | ||
61 | static struct platform_driver platform_driver = { | ||
62 | .driver = { | ||
63 | .name = "dell-laptop", | ||
64 | .owner = THIS_MODULE, | ||
65 | } | ||
66 | }; | ||
67 | |||
68 | static struct platform_device *platform_device; | ||
61 | static struct backlight_device *dell_backlight_device; | 69 | static struct backlight_device *dell_backlight_device; |
62 | static struct rfkill *wifi_rfkill; | 70 | static struct rfkill *wifi_rfkill; |
63 | static struct rfkill *bluetooth_rfkill; | 71 | static struct rfkill *bluetooth_rfkill; |
@@ -217,7 +225,8 @@ static int dell_setup_rfkill(void) | |||
217 | status = buffer.output[1]; | 225 | status = buffer.output[1]; |
218 | 226 | ||
219 | if ((status & (1<<2|1<<8)) == (1<<2|1<<8)) { | 227 | if ((status & (1<<2|1<<8)) == (1<<2|1<<8)) { |
220 | wifi_rfkill = rfkill_alloc("dell-wifi", NULL, RFKILL_TYPE_WLAN, | 228 | wifi_rfkill = rfkill_alloc("dell-wifi", &platform_device->dev, |
229 | RFKILL_TYPE_WLAN, | ||
221 | &dell_rfkill_ops, (void *) 1); | 230 | &dell_rfkill_ops, (void *) 1); |
222 | if (!wifi_rfkill) { | 231 | if (!wifi_rfkill) { |
223 | ret = -ENOMEM; | 232 | ret = -ENOMEM; |
@@ -229,7 +238,8 @@ static int dell_setup_rfkill(void) | |||
229 | } | 238 | } |
230 | 239 | ||
231 | if ((status & (1<<3|1<<9)) == (1<<3|1<<9)) { | 240 | if ((status & (1<<3|1<<9)) == (1<<3|1<<9)) { |
232 | bluetooth_rfkill = rfkill_alloc("dell-bluetooth", NULL, | 241 | bluetooth_rfkill = rfkill_alloc("dell-bluetooth", |
242 | &platform_device->dev, | ||
233 | RFKILL_TYPE_BLUETOOTH, | 243 | RFKILL_TYPE_BLUETOOTH, |
234 | &dell_rfkill_ops, (void *) 2); | 244 | &dell_rfkill_ops, (void *) 2); |
235 | if (!bluetooth_rfkill) { | 245 | if (!bluetooth_rfkill) { |
@@ -242,7 +252,9 @@ static int dell_setup_rfkill(void) | |||
242 | } | 252 | } |
243 | 253 | ||
244 | if ((status & (1<<4|1<<10)) == (1<<4|1<<10)) { | 254 | if ((status & (1<<4|1<<10)) == (1<<4|1<<10)) { |
245 | wwan_rfkill = rfkill_alloc("dell-wwan", NULL, RFKILL_TYPE_WWAN, | 255 | wwan_rfkill = rfkill_alloc("dell-wwan", |
256 | &platform_device->dev, | ||
257 | RFKILL_TYPE_WWAN, | ||
246 | &dell_rfkill_ops, (void *) 3); | 258 | &dell_rfkill_ops, (void *) 3); |
247 | if (!wwan_rfkill) { | 259 | if (!wwan_rfkill) { |
248 | ret = -ENOMEM; | 260 | ret = -ENOMEM; |
@@ -342,6 +354,18 @@ static int __init dell_init(void) | |||
342 | return -ENODEV; | 354 | return -ENODEV; |
343 | } | 355 | } |
344 | 356 | ||
357 | ret = platform_driver_register(&platform_driver); | ||
358 | if (ret) | ||
359 | goto fail_platform_driver; | ||
360 | platform_device = platform_device_alloc("dell-laptop", -1); | ||
361 | if (!platform_device) { | ||
362 | ret = -ENOMEM; | ||
363 | goto fail_platform_device1; | ||
364 | } | ||
365 | ret = platform_device_add(platform_device); | ||
366 | if (ret) | ||
367 | goto fail_platform_device2; | ||
368 | |||
345 | ret = dell_setup_rfkill(); | 369 | ret = dell_setup_rfkill(); |
346 | 370 | ||
347 | if (ret) { | 371 | if (ret) { |
@@ -368,7 +392,7 @@ static int __init dell_init(void) | |||
368 | if (max_intensity) { | 392 | if (max_intensity) { |
369 | dell_backlight_device = backlight_device_register( | 393 | dell_backlight_device = backlight_device_register( |
370 | "dell_backlight", | 394 | "dell_backlight", |
371 | NULL, NULL, | 395 | &platform_device->dev, NULL, |
372 | &dell_ops); | 396 | &dell_ops); |
373 | 397 | ||
374 | if (IS_ERR(dell_backlight_device)) { | 398 | if (IS_ERR(dell_backlight_device)) { |
@@ -388,6 +412,12 @@ static int __init dell_init(void) | |||
388 | fail_backlight: | 412 | fail_backlight: |
389 | dell_cleanup_rfkill(); | 413 | dell_cleanup_rfkill(); |
390 | fail_rfkill: | 414 | fail_rfkill: |
415 | platform_device_del(platform_device); | ||
416 | fail_platform_device2: | ||
417 | platform_device_put(platform_device); | ||
418 | fail_platform_device1: | ||
419 | platform_driver_unregister(&platform_driver); | ||
420 | fail_platform_driver: | ||
391 | kfree(da_tokens); | 421 | kfree(da_tokens); |
392 | return ret; | 422 | return ret; |
393 | } | 423 | } |