platform/x86: xo15-ebook: Bind to a platform device instead of an ACPI one
Subsystems (2)
Rafael J. Wysocki
maintainercover platform/x86: xo15-ebook: Bind to a platform device instead of an ACPI one
Hi All,
This series is part of a larger effort to switch over all drivers using the struct acpi_driver interface to the more common struct platform_driver interface and eliminate the former. The background is explained in Documentation/driver-api/acpi/acpi-drivers.rst and in the changelog of the patch that introduced the above document:
https://lore.kernel.org/all/[email protected]/
The bottom line is that the kernel would be better off without struct acpi_driver and so it is better to get rid of it.
This series carries out driver conversion of the platform x86 xo15-ebook driver on top of 3 preliminary changes.
Patch [1/4] fixes the handling of a wakeup source and ACPI GPE in the driver during probe and removal.
Patch [2/4] cleans up label formatting in ebook_switch_add().
Patch [3/4] updates the driver to install an ACPI notify handler by itself instead of using the .notify() callback from struct acpi_driver, which is requisite for the driver conversion.
Patch [4/4] converts the driver to using struct platform_driver for device binding.
Thanks!
Rafael J. Wysocki
maintainerPATCH 1/4 platform/x86: xo15-ebook: Fix wakeup source and GPE handling
From: "Rafael J. Wysocki" <[email protected]>
The device_set_wakeup_enable() call in ebook_switch_add() doesn't actually do anything because power.can_wakeup is not set for ACPI device objects. Moreover, had it done anything, it would have registered a wakeup source object that wouldn't have been used going forward and that wakeup source would have been leaked after driver removal because ebook_switch_remove() doesn't clean it up. Accordingly, remove that call from ebook_switch_add().
Also prevent leaking an enabled ACPI GPE after removing the driver by adding appropriate cleanup code to ebook_switch_remove().
--- drivers/platform/x86/xo15-ebook.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/platform/x86/xo15-ebook.c +6 -1
@@ -38,6 +38,7 @@ MODULE_DEVICE_TABLE(acpi, ebook_device_ids);struct ebook_switch {struct input_dev *input;char phys[32 ];/* for input device */ +bool gpe_enabled; };static int ebook_send_state (struct acpi_device *device)
@@ -128,7 +129,7 @@ static int ebook_switch_add(struct acpi_device *device)/* Button's GPE is run-wake GPE */ acpi_enable_gpe (device->wakeup.gpe_device, device->wakeup.gpe_number); -device_set_wakeup_enable (&device->dev, true); + button->gpe_enabled = true; }return 0 ;
@@ -144,6 +145,10 @@ static void ebook_switch_remove(struct acpi_device *device) {struct ebook_switch *button =acpi_driver_data (device); +if (button->gpe_enabled) +acpi_disable_gpe (device->wakeup.gpe_device, + device->wakeup.gpe_number); +input_unregister_device (button->input);kfree (button); }
Rafael J. Wysocki
maintainerPATCH 2/4 platform/x86: xo15-ebook: Fix formatting of labels
In reply to Rafael J. WysockiFrom: "Rafael J. Wysocki" <[email protected]>
Fix formatting of two labels in ebook_switch_add() to make that function follow the current kernel coding style more closely.
No functional impact.
--- drivers/platform/x86/xo15-ebook.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/xo15-ebook.c +2 -2
@@ -134,9 +134,9 @@ static int ebook_switch_add(struct acpi_device *device)return 0 ; - err_free_input: +err_free_input:input_free_device (input); - err_free_button: +err_free_button:kfree (button);return error; }
Rafael J. Wysocki
maintainerPATCH 3/4 platform/x86: xo15-ebook: Register ACPI notify handler directly
In reply to Rafael J. WysockiFrom: "Rafael J. Wysocki" <[email protected]>
To facilitate subsequent conversion of the driver to a platform one, make it install an ACPI notify handler directly instead of using a .notify() callback in struct acpi_driver.
No intentional functional impact.
--- drivers/platform/x86/xo15-ebook.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
drivers/platform/x86/xo15-ebook.c +14 -5
@@ -57,16 +57,15 @@ static int ebook_send_state(struct acpi_device *device)return 0 ; } -static void ebook_switch_notify (struct acpi_device *device,u32 event) +static void ebook_switch_notify (acpi_handle handle,u32 event,void *data) {switch (event) {case ACPI_FIXED_HARDWARE_EVENT :case XO15_EBOOK_NOTIFY_STATUS : -ebook_send_state (device); +ebook_send_state (data);break ;default : -acpi_handle_debug (device->handle, -"Unsupported event [0x%x]\n" , event); +acpi_handle_debug (handle,"Unsupported event [0x%x]\n" , event);break ; } }
@@ -123,6 +122,11 @@ static int ebook_switch_add(struct acpi_device *device)if (error) goto err_free_input; + error =acpi_dev_install_notify_handler (device,ACPI_DEVICE_NOTIFY , + ebook_switch_notify, device); +if (error) + goto err_unregister_input; +ebook_send_state (device);if (device->wakeup.flags.valid) {
@@ -139,6 +143,10 @@ static int ebook_switch_add(struct acpi_device *device) err_free_button:kfree (button);return error; + +err_unregister_input: +input_unregister_device (input); + goto err_free_button; }static void ebook_switch_remove (struct acpi_device *device)
@@ -149,6 +157,8 @@ static void ebook_switch_remove(struct acpi_device *device)acpi_disable_gpe (device->wakeup.gpe_device, device->wakeup.gpe_number); +acpi_dev_remove_notify_handler (device,ACPI_DEVICE_NOTIFY , + ebook_switch_notify);input_unregister_device (button->input);kfree (button); }
@@ -160,7 +170,6 @@ static struct acpi_driver xo15_ebook_driver = { .ops = { .add = ebook_switch_add, .remove = ebook_switch_remove, - .notify = ebook_switch_notify, }, .drv.pm = &ebook_switch_pm, };
Ilpo Järvinen
maintainerRe: [PATCH v1 3/4] platform/x86: xo15-ebook: Register ACPI notify handler directly
Quoted 50 lines · Rafael J. Wysocki
From: "Rafael J. Wysocki" <[email protected]>
To facilitate subsequent conversion of the driver to a platform one, make it install an ACPI notify handler directly instead of using a .notify() callback in struct
acpi_driver.No intentional functional impact.
Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/platform/x86/xo15-ebook.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)drivers/platform/x86/xo15-ebook.c +8
-4@@ -57,16 +57,15 @@ static int ebook_send_state(struct acpi_device *device)return 0 ; } -static void ebook_switch_notify (struct acpi_device *device,u32 event) +static void ebook_switch_notify (acpi_handle handle,u32 event,void *data) {switch (event) {case ACPI_FIXED_HARDWARE_EVENT :case XO15_EBOOK_NOTIFY_STATUS : -ebook_send_state (device); +ebook_send_state (data);break ;default : -acpi_handle_debug (device->handle, -"Unsupported event [0x%x]\n" , event); +acpi_handle_debug (handle,"Unsupported event [0x%x]\n" , event);break ; } }@@ -123,6 +122,11 @@ static int ebook_switch_add(struct acpi_device *device)if (error) goto err_free_input; + error =acpi_dev_install_notify_handler (device,ACPI_DEVICE_NOTIFY , + ebook_switch_notify, device); +if (error) + goto err_unregister_input; +ebook_send_state (device);if (device->wakeup.flags.valid) {
drivers/platform/x86/xo15-ebook.c static int ebook_switch_add(struct acpi_device *device) · line 149
Quoted 7 lines
drivers/platform/x86/xo15-ebook.c +4
-0@@ -139,6 +143,10 @@ static int ebook_switch_add(struct acpi_device *device) err_free_button:kfree (button);return error; + +err_unregister_input: +input_unregister_device (input); + goto err_free_button;
The end result would be much simpler if there would be patch 5 to convert to devm_*().
Quoted 23 lines
drivers/platform/x86/xo15-ebook.c +2
-1}static void ebook_switch_remove (struct acpi_device *device)@@ -149,6 +157,8 @@ static void ebook_switch_remove(struct acpi_device *device)acpi_disable_gpe (device->wakeup.gpe_device, device->wakeup.gpe_number); +acpi_dev_remove_notify_handler (device,ACPI_DEVICE_NOTIFY , + ebook_switch_notify);input_unregister_device (button->input);kfree (button); }@@ -160,7 +170,6 @@ static struct acpi_driver xo15_ebook_driver = { .ops = { .add = ebook_switch_add, .remove = ebook_switch_remove, - .notify = ebook_switch_notify, }, .drv.pm = &ebook_switch_pm, };
Signature · 1 line
i.
Rafael J. Wysocki
maintainerRe: [PATCH v1 3/4] platform/x86: xo15-ebook: Register ACPI notify handler directly
Quoted 51 lines · Ilpo Järvinen
Quoted 48 lines · Rafael J. Wysocki
From: "Rafael J. Wysocki" <[email protected]>
To facilitate subsequent conversion of the driver to a platform one, make it install an ACPI notify handler directly instead of using a .notify() callback in struct
acpi_driver.No intentional functional impact.
Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/platform/x86/xo15-ebook.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)drivers/platform/x86/xo15-ebook.c +8
-4@@ -57,16 +57,15 @@ static int ebook_send_state(struct acpi_device *device)return 0 ; } -static void ebook_switch_notify (struct acpi_device *device,u32 event) +static void ebook_switch_notify (acpi_handle handle,u32 event,void *data) {switch (event) {case ACPI_FIXED_HARDWARE_EVENT :case XO15_EBOOK_NOTIFY_STATUS : -ebook_send_state (device); +ebook_send_state (data);break ;default : -acpi_handle_debug (device->handle, -"Unsupported event [0x%x]\n" , event); +acpi_handle_debug (handle,"Unsupported event [0x%x]\n" , event);break ; } }@@ -123,6 +122,11 @@ static int ebook_switch_add(struct acpi_device *device)if (error) goto err_free_input; + error =acpi_dev_install_notify_handler (device,ACPI_DEVICE_NOTIFY , + ebook_switch_notify, device); +if (error) + goto err_unregister_input; +ebook_send_state (device);
Quoted 12 lines
drivers/platform/x86/xo15-ebook.c static int ebook_switch_add(struct acpi_device *device) · line 149
Quoted 9 lines
drivers/platform/x86/xo15-ebook.c +4
-0if (device->wakeup.flags.valid) {@@ -139,6 +143,10 @@ static int ebook_switch_add(struct acpi_device *device) err_free_button:kfree (button);return error; + +err_unregister_input: +input_unregister_device (input); + goto err_free_button;The end result would be much simpler if there would be patch 5 to convert to devm_*().
Well, I can add one.
Do you want me to resend an update of the series for this?
Quoted 25 lines
Quoted 16 lines
drivers/platform/x86/xo15-ebook.c +2
-0}static void ebook_switch_remove (struct acpi_device *device)@@ -149,6 +157,8 @@ static void ebook_switch_remove(struct acpi_device *device)acpi_disable_gpe (device->wakeup.gpe_device, device->wakeup.gpe_number); +acpi_dev_remove_notify_handler (device,ACPI_DEVICE_NOTIFY , + ebook_switch_notify);input_unregister_device (button->input);kfree (button); }drivers/platform/x86/xo15-ebook.c static struct acpi_driver xo15_ebook_driver = { · line 175
Quoted 7 lines
drivers/platform/x86/xo15-ebook.c +0
-1@@ -160,7 +170,6 @@ static struct acpi_driver xo15_ebook_driver = { .ops = { .add = ebook_switch_add, .remove = ebook_switch_remove, - .notify = ebook_switch_notify, }, .drv.pm = &ebook_switch_pm, };--
Ilpo Järvinen
maintainerRe: [PATCH v1 3/4] platform/x86: xo15-ebook: Register ACPI notify handler directly
Quoted 66 lines · Rafael J. Wysocki
Quoted 51 lines · Ilpo Järvinen
Quoted 48 lines · Rafael J. Wysocki
From: "Rafael J. Wysocki" <[email protected]>
To facilitate subsequent conversion of the driver to a platform one, make it install an ACPI notify handler directly instead of using a .notify() callback in struct
acpi_driver.No intentional functional impact.
Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/platform/x86/xo15-ebook.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)drivers/platform/x86/xo15-ebook.c +8
-4@@ -57,16 +57,15 @@ static int ebook_send_state(struct acpi_device *device)return 0 ; } -static void ebook_switch_notify (struct acpi_device *device,u32 event) +static void ebook_switch_notify (acpi_handle handle,u32 event,void *data) {switch (event) {case ACPI_FIXED_HARDWARE_EVENT :case XO15_EBOOK_NOTIFY_STATUS : -ebook_send_state (device); +ebook_send_state (data);break ;default : -acpi_handle_debug (device->handle, -"Unsupported event [0x%x]\n" , event); +acpi_handle_debug (handle,"Unsupported event [0x%x]\n" , event);break ; } }@@ -123,6 +122,11 @@ static int ebook_switch_add(struct acpi_device *device)if (error) goto err_free_input; + error =acpi_dev_install_notify_handler (device,ACPI_DEVICE_NOTIFY , + ebook_switch_notify, device); +if (error) + goto err_unregister_input; +ebook_send_state (device);Quoted 12 lines
drivers/platform/x86/xo15-ebook.c static int ebook_switch_add(struct acpi_device *device) · line 149
Quoted 9 lines
drivers/platform/x86/xo15-ebook.c +4
-0if (device->wakeup.flags.valid) {@@ -139,6 +143,10 @@ static int ebook_switch_add(struct acpi_device *device) err_free_button:kfree (button);return error; + +err_unregister_input: +input_unregister_device (input); + goto err_free_button;The end result would be much simpler if there would be patch 5 to convert to devm_*().
Quoted 3 lines
Well, I can add one.
Do you want me to resend an update of the series for this?
Ah, right. I took these now to review-ilpo-next.
(I was initially thinking of making a little bit different suggestion which would have required changes to these patches but then realized it was better to just add the devm_*() conversion after these).
Signature · 1 line
i.
Rafael J. Wysocki
maintainerRe: [PATCH v1 3/4] platform/x86: xo15-ebook: Register ACPI notify handler directly
Quoted 71 lines · Ilpo Järvinen
Quoted 68 lines · Rafael J. Wysocki
Quoted 51 lines · Ilpo Järvinen
Quoted 48 lines · Rafael J. Wysocki
From: "Rafael J. Wysocki" <[email protected]>
To facilitate subsequent conversion of the driver to a platform one, make it install an ACPI notify handler directly instead of using a .notify() callback in struct
acpi_driver.No intentional functional impact.
Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/platform/x86/xo15-ebook.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)drivers/platform/x86/xo15-ebook.c +8
-4@@ -57,16 +57,15 @@ static int ebook_send_state(struct acpi_device *device)return 0 ; } -static void ebook_switch_notify (struct acpi_device *device,u32 event) +static void ebook_switch_notify (acpi_handle handle,u32 event,void *data) {switch (event) {case ACPI_FIXED_HARDWARE_EVENT :case XO15_EBOOK_NOTIFY_STATUS : -ebook_send_state (device); +ebook_send_state (data);break ;default : -acpi_handle_debug (device->handle, -"Unsupported event [0x%x]\n" , event); +acpi_handle_debug (handle,"Unsupported event [0x%x]\n" , event);break ; } }@@ -123,6 +122,11 @@ static int ebook_switch_add(struct acpi_device *device)if (error) goto err_free_input; + error =acpi_dev_install_notify_handler (device,ACPI_DEVICE_NOTIFY , + ebook_switch_notify, device); +if (error) + goto err_unregister_input; +ebook_send_state (device);Quoted 12 lines
drivers/platform/x86/xo15-ebook.c static int ebook_switch_add(struct acpi_device *device) · line 149
Quoted 9 lines
drivers/platform/x86/xo15-ebook.c +4
-0if (device->wakeup.flags.valid) {@@ -139,6 +143,10 @@ static int ebook_switch_add(struct acpi_device *device) err_free_button:kfree (button);return error; + +err_unregister_input: +input_unregister_device (input); + goto err_free_button;The end result would be much simpler if there would be patch 5 to convert to devm_*().
Well, I can add one.
Quoted 7 lines
Quoted 1 line
Do you want me to resend an update of the series for this?
Ah, right. I took these now to review-ilpo-next.
(I was initially thinking of making a little bit different suggestion which would have required changes to these patches but then realized it was better to just add the devm_*() conversion after these).
So I guess I'll prepare a follow-up patch for the devm_ conversion.
Note though that there's no devm_ counterpart of acpi_dev_install_notify_handler() ATM, so I may need to add one while at it.
Ilpo Järvinen
maintainerRe: [PATCH v1 3/4] platform/x86: xo15-ebook: Register ACPI notify handler directly
Quoted 81 lines · Rafael J. Wysocki
Quoted 71 lines · Ilpo Järvinen
Quoted 68 lines · Rafael J. Wysocki
Quoted 51 lines · Ilpo Järvinen
Quoted 48 lines · Rafael J. Wysocki
From: "Rafael J. Wysocki" <[email protected]>
To facilitate subsequent conversion of the driver to a platform one, make it install an ACPI notify handler directly instead of using a .notify() callback in struct
acpi_driver.No intentional functional impact.
Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/platform/x86/xo15-ebook.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)drivers/platform/x86/xo15-ebook.c +8
-4@@ -57,16 +57,15 @@ static int ebook_send_state(struct acpi_device *device)return 0 ; } -static void ebook_switch_notify (struct acpi_device *device,u32 event) +static void ebook_switch_notify (acpi_handle handle,u32 event,void *data) {switch (event) {case ACPI_FIXED_HARDWARE_EVENT :case XO15_EBOOK_NOTIFY_STATUS : -ebook_send_state (device); +ebook_send_state (data);break ;default : -acpi_handle_debug (device->handle, -"Unsupported event [0x%x]\n" , event); +acpi_handle_debug (handle,"Unsupported event [0x%x]\n" , event);break ; } }@@ -123,6 +122,11 @@ static int ebook_switch_add(struct acpi_device *device)if (error) goto err_free_input; + error =acpi_dev_install_notify_handler (device,ACPI_DEVICE_NOTIFY , + ebook_switch_notify, device); +if (error) + goto err_unregister_input; +ebook_send_state (device);Quoted 12 lines
drivers/platform/x86/xo15-ebook.c static int ebook_switch_add(struct acpi_device *device) · line 149
Quoted 9 lines
drivers/platform/x86/xo15-ebook.c +4
-0if (device->wakeup.flags.valid) {@@ -139,6 +143,10 @@ static int ebook_switch_add(struct acpi_device *device) err_free_button:kfree (button);return error; + +err_unregister_input: +input_unregister_device (input); + goto err_free_button;The end result would be much simpler if there would be patch 5 to convert to devm_*().
Well, I can add one.
Quoted 7 lines
Quoted 1 line
Do you want me to resend an update of the series for this?
Ah, right. I took these now to review-ilpo-next.
(I was initially thinking of making a little bit different suggestion which would have required changes to these patches but then realized it was better to just add the devm_*() conversion after these).
Quoted 5 lines
So I guess I'll prepare a follow-up patch for the
devm_conversion.Note though that there's no
devm_counterpart ofacpi_dev_install_notify_handler()ATM, so I may need to add one while at it.
While adding it will be able to remove acpi_dev_remove_notify_handler() call from ebook_switch_remove(), there's no such call in rollbacks for ebook_switch_probe() so it wouldn't be strictly required.
But it certainly wouldn't hurt to have one for other drivers.
Signature · 1 line
i.
Rafael J. Wysocki
maintainerRe: [PATCH v1 3/4] platform/x86: xo15-ebook: Register ACPI notify handler directly
Quoted 86 lines · Ilpo Järvinen
Quoted 83 lines · Rafael J. Wysocki
Quoted 71 lines · Ilpo Järvinen
Quoted 68 lines · Rafael J. Wysocki
Quoted 51 lines · Ilpo Järvinen
Quoted 48 lines · Rafael J. Wysocki
From: "Rafael J. Wysocki" <[email protected]>
To facilitate subsequent conversion of the driver to a platform one, make it install an ACPI notify handler directly instead of using a .notify() callback in struct
acpi_driver.No intentional functional impact.
Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/platform/x86/xo15-ebook.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)drivers/platform/x86/xo15-ebook.c +8
-4@@ -57,16 +57,15 @@ static int ebook_send_state(struct acpi_device *device)return 0 ; } -static void ebook_switch_notify (struct acpi_device *device,u32 event) +static void ebook_switch_notify (acpi_handle handle,u32 event,void *data) {switch (event) {case ACPI_FIXED_HARDWARE_EVENT :case XO15_EBOOK_NOTIFY_STATUS : -ebook_send_state (device); +ebook_send_state (data);break ;default : -acpi_handle_debug (device->handle, -"Unsupported event [0x%x]\n" , event); +acpi_handle_debug (handle,"Unsupported event [0x%x]\n" , event);break ; } }@@ -123,6 +122,11 @@ static int ebook_switch_add(struct acpi_device *device)if (error) goto err_free_input; + error =acpi_dev_install_notify_handler (device,ACPI_DEVICE_NOTIFY , + ebook_switch_notify, device); +if (error) + goto err_unregister_input; +ebook_send_state (device);Quoted 12 lines
drivers/platform/x86/xo15-ebook.c static int ebook_switch_add(struct acpi_device *device) · line 149
Quoted 9 lines
drivers/platform/x86/xo15-ebook.c +4
-0if (device->wakeup.flags.valid) {@@ -139,6 +143,10 @@ static int ebook_switch_add(struct acpi_device *device) err_free_button:kfree (button);return error; + +err_unregister_input: +input_unregister_device (input); + goto err_free_button;The end result would be much simpler if there would be patch 5 to convert to devm_*().
Well, I can add one.
Quoted 7 lines
Quoted 1 line
Do you want me to resend an update of the series for this?
Ah, right. I took these now to review-ilpo-next.
(I was initially thinking of making a little bit different suggestion which would have required changes to these patches but then realized it was better to just add the devm_*() conversion after these).
So I guess I'll prepare a follow-up patch for the
devm_conversion.
Quoted 7 lines
Quoted 3 lines
Note though that there's no
devm_counterpart ofacpi_dev_install_notify_handler()ATM, so I may need to add one while at it.While adding it will be able to remove
acpi_dev_remove_notify_handler()call fromebook_switch_remove(), there's no such call in rollbacks forebook_switch_probe()so it wouldn't be strictly required.
Right.
Quoted 1 line
But it certainly wouldn't hurt to have one for other drivers.
Sure, I definitely have a plan to add one.
Rafael J. Wysocki
maintainerPATCH 4/4 platform/x86: xo15-ebook: Convert ACPI driver to a platform one
In reply to Rafael J. WysockiFrom: "Rafael J. Wysocki" <[email protected]>
In all cases in which a struct acpi_driver is used for binding a driver to an ACPI device object, a corresponding platform device is created by the ACPI core and that device is regarded as a proper representation of underlying hardware. Accordingly, a struct platform_driver should be used by driver code to bind to that device. There are multiple reasons why drivers should not bind directly to ACPI device objects [1].
Overall, it is better to bind drivers to platform devices than to their ACPI companions, so convert the OLPC XO-1.5 ebook switch driver from an ACPI driver to a platform one.
After this change, the input device registered by the driver will appear under the platform device used for driver binding.
While this is not expected to alter functionality, it changes sysfs layout and so it will be visible to user space.
--- drivers/platform/x86/xo15-ebook.c | 44 ++++++++++++++++--------------- 1 file changed, 23 insertions(+), 21 deletions(-)
drivers/platform/x86/xo15-ebook.c +23 -21
@@ -15,6 +15,7 @@#include <linux/types.h> #include <linux/input.h> #include <linux/acpi.h> +#include <linux/platform_device.h> #define MODULE_NAME "xo15-ebook"
@@ -41,13 +42,13 @@ struct ebook_switch {bool gpe_enabled; }; -static int ebook_send_state (struct acpi_device *device) +static int ebook_send_state (struct device *dev) { -struct ebook_switch *button =acpi_driver_data (device); +struct ebook_switch *button =dev_get_drvdata (dev);unsigned long long state;acpi_status status; - status =acpi_evaluate_integer (device->handle,"EBK" ,NULL , &state); + status =acpi_evaluate_integer (ACPI_HANDLE (dev),"EBK" ,NULL , &state);if (ACPI_FAILURE (status))return -EIO ;
@@ -73,14 +74,15 @@ static void ebook_switch_notify(acpi_handle handle, u32 event, void *data)#ifdef CONFIG_PM_SLEEP static int ebook_switch_resume (struct device *dev) { -return ebook_send_state (to_acpi_device (dev)); +return ebook_send_state (dev); }#endif static SIMPLE_DEV_PM_OPS(ebook_switch_pm, NULL, ebook_switch_resume); -static int ebook_switch_add (struct acpi_device *device) +static int ebook_switch_probe (struct platform_device *pdev) { +struct acpi_device *device =ACPI_COMPANION (&pdev->dev);const struct acpi_device_id *id;struct ebook_switch *button;struct input_dev *input;
@@ -90,7 +92,7 @@ static int ebook_switch_add(struct acpi_device *device)if (!button)return -ENOMEM ; - device->driver_data = button; +platform_set_drvdata (pdev, button); button->input = input =input_allocate_device ();if (!input) {
@@ -100,7 +102,7 @@ static int ebook_switch_add(struct acpi_device *device) id =acpi_match_acpi_device (ebook_device_ids, device);if (!id) { -dev_err (&device->dev,"Unsupported hid\n" ); +dev_err (&pdev->dev,"Unsupported hid\n" ); error = -ENODEV ; goto err_free_input; }
@@ -113,7 +115,7 @@ static int ebook_switch_add(struct acpi_device *device) input->name =acpi_device_name (device); input->phys = button->phys; input->id.bustype =BUS_HOST ; - input->dev.parent = &device->dev; + input->dev.parent = &pdev->dev; input->evbit[0 ] =BIT_MASK (EV_SW );set_bit (SW_TABLET_MODE , input->swbit);
@@ -123,11 +125,11 @@ static int ebook_switch_add(struct acpi_device *device) goto err_free_input; error =acpi_dev_install_notify_handler (device,ACPI_DEVICE_NOTIFY , - ebook_switch_notify, device); + ebook_switch_notify, &pdev->dev);if (error) goto err_unregister_input; -ebook_send_state (device); +ebook_send_state (&pdev->dev);if (device->wakeup.flags.valid) {/* Button's GPE is run-wake GPE */
@@ -149,9 +151,10 @@ static int ebook_switch_add(struct acpi_device *device) goto err_free_button; } -static void ebook_switch_remove (struct acpi_device *device) +static void ebook_switch_remove (struct platform_device *pdev) { -struct ebook_switch *button =acpi_driver_data (device); +struct ebook_switch *button =platform_get_drvdata (pdev); +struct acpi_device *device =ACPI_COMPANION (&pdev->dev);if (button->gpe_enabled) acpi_disable_gpe(device->wakeup.gpe_device,
@@ -163,14 +166,13 @@ static void ebook_switch_remove(struct acpi_device *device)kfree (button); } -static struct acpi_driver xo15_ebook_driver = { - .name =MODULE_NAME , - .class =XO15_EBOOK_CLASS , - .ids = ebook_device_ids, - .ops = { - .add = ebook_switch_add, - .remove = ebook_switch_remove, +static struct platform_driver xo15_ebook_driver = { + .probe = ebook_switch_probe, + .remove = ebook_switch_remove, + .driver = { + .name =MODULE_NAME , + .acpi_match_table = ebook_device_ids, + .pm = &ebook_switch_pm, }, - .drv.pm = &ebook_switch_pm, }; -module_acpi_driver (xo15_ebook_driver); +module_platform_driver (xo15_ebook_driver);