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>
This commit is contained in:
parent
4311bb230e
commit
ada3248a5d
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue