lkml.org 
[lkml]   [2009]   [Aug]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 3/5] dell-laptop: create a platform device as a parent for the rfkill devices etc.
    Date
    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>
    ---
    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 8fbff38..a13a9f7 100644
    --- a/drivers/platform/x86/dell-laptop.c
    +++ b/drivers/platform/x86/dell-laptop.c
    @@ -58,6 +58,14 @@ static int da_command_code;
    static int da_num_tokens;
    static struct calling_interface_token *da_tokens;

    +static struct platform_driver platform_driver = {
    + .driver = {
    + .name = "dell-laptop",
    + .owner = THIS_MODULE,
    + }
    +};
    +
    +static struct platform_device *platform_device;
    static struct backlight_device *dell_backlight_device;
    static struct rfkill *wifi_rfkill;
    static struct rfkill *bluetooth_rfkill;
    @@ -217,7 +225,8 @@ static int dell_setup_rfkill(void)
    status = buffer.output[1];

    if ((status & (1<<2|1<<8)) == (1<<2|1<<8)) {
    - wifi_rfkill = rfkill_alloc("dell-wifi", NULL, RFKILL_TYPE_WLAN,
    + wifi_rfkill = rfkill_alloc("dell-wifi", &platform_device->dev,
    + RFKILL_TYPE_WLAN,
    &dell_rfkill_ops, (void *) 1);
    if (!wifi_rfkill) {
    ret = -ENOMEM;
    @@ -229,7 +238,8 @@ static int dell_setup_rfkill(void)
    }

    if ((status & (1<<3|1<<9)) == (1<<3|1<<9)) {
    - bluetooth_rfkill = rfkill_alloc("dell-bluetooth", NULL,
    + bluetooth_rfkill = rfkill_alloc("dell-bluetooth",
    + &platform_device->dev,
    RFKILL_TYPE_BLUETOOTH,
    &dell_rfkill_ops, (void *) 2);
    if (!bluetooth_rfkill) {
    @@ -242,7 +252,9 @@ static int dell_setup_rfkill(void)
    }

    if ((status & (1<<4|1<<10)) == (1<<4|1<<10)) {
    - wwan_rfkill = rfkill_alloc("dell-wwan", NULL, RFKILL_TYPE_WWAN,
    + wwan_rfkill = rfkill_alloc("dell-wwan",
    + &platform_device->dev,
    + RFKILL_TYPE_WWAN,
    &dell_rfkill_ops, (void *) 3);
    if (!wwan_rfkill) {
    ret = -ENOMEM;
    @@ -342,6 +354,18 @@ static int __init dell_init(void)
    return -ENODEV;
    }

    + ret = platform_driver_register(&platform_driver);
    + if (ret)
    + goto fail_platform_driver;
    + platform_device = platform_device_alloc("dell-laptop", -1);
    + if (!platform_device) {
    + ret = -ENOMEM;
    + goto fail_platform_device1;
    + }
    + ret = platform_device_add(platform_device);
    + if (ret)
    + goto fail_platform_device2;
    +
    ret = dell_setup_rfkill();

    if (ret) {
    @@ -368,7 +392,7 @@ static int __init dell_init(void)
    if (max_intensity) {
    dell_backlight_device = backlight_device_register(
    "dell_backlight",
    - NULL, NULL,
    + &platform_device->dev, NULL,
    &dell_ops);

    if (IS_ERR(dell_backlight_device)) {
    @@ -388,6 +412,12 @@ static int __init dell_init(void)
    fail_backlight:
    dell_cleanup_rfkill();
    fail_rfkill:
    + platform_device_del(platform_device);
    +fail_platform_device2:
    + platform_device_put(platform_device);
    +fail_platform_device1:
    + platform_driver_unregister(&platform_driver);
    +fail_platform_driver:
    kfree(da_tokens);
    return ret;
    }
    --
    1.6.3.2


    \
     
     \ /
      Last update: 2009-08-19 16:15    [W:0.053 / U:152.624 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site