Remove .notify callback in acpi_device_ops
Subsystems (4)
v7 cover Remove .notify callback in acpi_device_ops
*** IMPORTANT ***
This is part 1 - only drivers in acpi directory to ease up review process. Rest of the drivers will be handled in separate patchsets.
Currently drivers support ACPI event handlers by defining .notify callback in acpi_device_ops. This solution is suboptimal as event handler installer installs intermediary function acpi_notify_device as a handler in every driver. Also this approach requires extra variable 'flags' for specifying event types that the driver want to subscribe to. Additionally this is a pre-work required to align acpi_driver with platform_driver and eventually replace acpi_driver with platform_driver.
Remove .notify callback from the acpi_device_ops. Replace it with each driver installing and removing it's event handlers.
This is part 1 - only drivers in acpi directory to ease up review process.
v7:
- fix warning by declaring acpi_nfit_remove_notify_handler() as static
v6:
- fixed unnecessary RCT in all drivers, as it's not a purpose of this patch series
- changed error label names to simplify them
- dropped commit that remove a comma
- squashed commit moving code for nfit
- improved nfit driver to use devm instead of .remove()
- re-based as Rafael changes [1] are merged already
v5:
- rebased on top of Rafael changes [1], they're not merged yet
- fixed rollback in multiple drivers so they don't leak resources on failure
- made this part 1, meaning only drivers in acpi directory, rest of the drivers will be handled in separate patchsets to ease up review
v4:
- added one commit for previously missed driver sony-laptop, refactored return statements, added NULL check for event installer
v3:
- lkp still reported some failures for eeepc, fujitsu and toshiba_bluetooth, fix those
v2:
- fix compilation errors for drivers
[1]: https://lore.kernel.org/linux-acpi/1847933.atdPhlSkOF@kreacher/
Michal Wilczynski (9):
acpi/bus: Introduce wrappers for ACPICA event handler install/remove acpi/bus: Set driver_data to NULL every time .add() fails acpi/ac: Move handler installing logic to driver acpi/video: Move handler installing logic to driver acpi/battery: Move handler installing logic to driver acpi/hed: Move handler installing logic to driver acpi/nfit: Move handler installing logic to driver acpi/nfit: Remove unnecessary .remove callback acpi/thermal: Move handler installing logic to driver
drivers/acpi/ac.c | 29 ++++++++++++++++++------- drivers/acpi/acpi_video.c | 22 ++++++++++++++++--- drivers/acpi/battery.c | 26 +++++++++++++++++----- drivers/acpi/bus.c | 30 +++++++++++++++++++++++++- drivers/acpi/hed.c | 17 ++++++++++++--- drivers/acpi/nfit/core.c | 45 +++++++++++++++++++++++++++------------ drivers/acpi/thermal.c | 25 +++++++++++++++++----- include/acpi/acpi_bus.h | 6 ++++++ 8 files changed, 161 insertions(+), 39 deletions(-)
Signature · 1 line
2.41.0
PATCH v7 1/9 acpi/bus: Introduce wrappers for ACPICA event handler install/remove
Introduce new acpi_dev_install_notify_handler() and acpi_dev_remove_notify_handler(). Those functions are replacing old installers, and after all drivers switch to the new model, old installers will be removed.
Make acpi_dev_install_notify_handler() and acpi_dev_remove_notify_handler() non-static, and export symbols. This will allow the drivers to call them directly, instead of relying on .notify callback.
--- drivers/acpi/bus.c | 26 ++++++++++++++++++++++++++ include/acpi/acpi_bus.h | 6 ++++++ 2 files changed, 32 insertions(+)
drivers/acpi/bus.c +26 -0
@@ -554,6 +554,32 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device,acpi_os_wait_events_complete (); } +int acpi_dev_install_notify_handler (struct acpi_device *adev, +u32 handler_type, +acpi_notify_handler handler) +{ +acpi_status status; + + status =acpi_install_notify_handler (adev->handle, + handler_type, + handler, + adev); +if (ACPI_FAILURE (status)) +return -ENODEV ; + +return 0 ; +} +EXPORT_SYMBOL (acpi_dev_install_notify_handler); + +void acpi_dev_remove_notify_handler (struct acpi_device *adev, +u32 handler_type, +acpi_notify_handler handler) +{ +acpi_remove_notify_handler (adev->handle, handler_type, handler); +acpi_os_wait_events_complete (); +} +EXPORT_SYMBOL (acpi_dev_remove_notify_handler); +/* Handle events targeting \_SB device (at present only graceful shutdown) */ #define ACPI_SB_NOTIFY_SHUTDOWN_REQUEST 0x81
include/acpi/acpi_bus.h +6 -0
@@ -515,6 +515,12 @@ void acpi_bus_private_data_handler(acpi_handle, void *);int acpi_bus_get_private_data (acpi_handle ,void **);int acpi_bus_attach_private_data (acpi_handle ,void *);void acpi_bus_detach_private_data (acpi_handle ); +int acpi_dev_install_notify_handler (struct acpi_device *adev, +u32 handler_type, +acpi_notify_handler handler); +void acpi_dev_remove_notify_handler (struct acpi_device *adev, +u32 handler_type, +acpi_notify_handler handler);extern int acpi_notifier_call_chain (struct acpi_device *,u32 ,u32 );extern int register_acpi_notifier (struct notifier_block *);extern int unregister_acpi_notifier (struct notifier_block *);
Signature · 1 line
2.41.0
PATCH v7 2/9 acpi/bus: Set driver_data to NULL every time .add() fails
In reply to Michal WilczynskiMost drivers set driver_data during .add() callback, but usually they don't set it back to NULL in case of a failure. Set driver_data to NULL in acpi_device_probe() to avoid code duplication.
--- drivers/acpi/bus.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/acpi/bus.c +3 -1
@@ -1014,8 +1014,10 @@ static int acpi_device_probe(struct device *dev)return -ENOSYS ; ret = acpi_drv->ops.add (acpi_dev); -if (ret) +if (ret) { + acpi_dev->driver_data =NULL ;return ret; + }pr_debug ("Driver [%s] successfully bound to device [%s]\n" , acpi_drv->name, acpi_dev->pnp.bus_id);
Signature · 1 line
2.41.0
PATCH v7 3/9 acpi/ac: Move handler installing logic to driver
In reply to Michal WilczynskiCurrently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance.
Call acpi_dev_install_notify_handler() at the end of .add() callback. Call acpi_dev_remove_notify_handler() at the beginning of .remove() callback. Change arguments passed to the notify function to match with what's required by acpi_dev_install_notify_handler(). Remove .notify callback initialization in acpi_driver.
--- drivers/acpi/ac.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-)
drivers/acpi/ac.c +21 -8
@@ -34,7 +34,7 @@ MODULE_LICENSE("GPL");static int acpi_ac_add (struct acpi_device *device);static void acpi_ac_remove (struct acpi_device *device); -static void acpi_ac_notify (struct acpi_device *device,u32 event); +static void acpi_ac_notify (acpi_handle handle,u32 event,void *data);static const struct acpi_device_id ac_device_ids[] = { {"ACPI0003" ,0 },
@@ -54,11 +54,9 @@ static struct acpi_driver acpi_ac_driver = { .name = "ac", .class = ACPI_AC_CLASS, .ids = ac_device_ids, - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, .ops = { .add = acpi_ac_add, .remove = acpi_ac_remove, - .notify = acpi_ac_notify, }, .drv.pm = &acpi_ac_pm, };
@@ -128,8 +126,9 @@ static enum power_supply_property ac_props[] = { };/* Driver Model */ -static void acpi_ac_notify (struct acpi_device *device,u32 event) +static void acpi_ac_notify (acpi_handle handle,u32 event,void *data) { +struct acpi_device *device = data;struct acpi_ac *ac =acpi_driver_data (device);if (!ac)
@@ -235,7 +234,7 @@ static int acpi_ac_add(struct acpi_device *device) result =acpi_ac_get_state (ac);if (result) - goto end; + goto err_release_ac; psy_cfg.drv_data = ac;
@@ -248,7 +247,7 @@ static int acpi_ac_add(struct acpi_device *device) &ac->charger_desc, &psy_cfg);if (IS_ERR (ac->charger)) { result =PTR_ERR (ac->charger); - goto end; + goto err_release_ac; } pr_info("%s [%s] (%s)\n", acpi_device_name(device),
@@ -256,9 +255,20 @@ static int acpi_ac_add(struct acpi_device *device) ac->battery_nb.notifier_call = acpi_ac_battery_notify;register_acpi_notifier (&ac->battery_nb); -end: + + result =acpi_dev_install_notify_handler (device, +ACPI_ALL_NOTIFY , + acpi_ac_notify);if (result) -kfree (ac); + goto err_unregister; + +return 0 ; + +err_unregister: +power_supply_unregister (ac->charger); +unregister_acpi_notifier (&ac->battery_nb); +err_release_ac: +kfree (ac);return result; }
@@ -297,6 +307,9 @@ static void acpi_ac_remove(struct acpi_device *device) ac =acpi_driver_data (device); +acpi_dev_remove_notify_handler (device, +ACPI_ALL_NOTIFY , + acpi_ac_notify);power_supply_unregister (ac->charger);unregister_acpi_notifier (&ac->battery_nb);
Signature · 1 line
2.41.0
PATCH v7 4/9 acpi/video: Move handler installing logic to driver
In reply to Michal WilczynskiCurrently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance.
Call acpi_dev_install_notify_handler() at the end of .add() callback. Call acpi_dev_remove_notify_handler() at the beginning of .remove() callback. Change arguments passed to the notify function to match with what's required by acpi_dev_install_notify_handler(). Remove .notify callback initialization in acpi_driver.
--- drivers/acpi/acpi_video.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/acpi/acpi_video.c +19 -3
@@ -77,7 +77,7 @@ static DEFINE_MUTEX(video_list_lock);static LIST_HEAD (video_bus_head);static int acpi_video_bus_add (struct acpi_device *device);static void acpi_video_bus_remove (struct acpi_device *device); -static void acpi_video_bus_notify (struct acpi_device *device,u32 event); +static void acpi_video_bus_notify (acpi_handle handle,u32 event,void *data);/* * Indices in the _BCL method response: the first two items are special,
@@ -104,7 +104,6 @@ static struct acpi_driver acpi_video_bus = { .ops = { .add = acpi_video_bus_add, .remove = acpi_video_bus_remove, - .notify = acpi_video_bus_notify, }, };
@@ -1527,8 +1526,9 @@ static int acpi_video_bus_stop_devices(struct acpi_video_bus *video) acpi_osi_is_win8() ? 0 : 1); } -static void acpi_video_bus_notify (struct acpi_device *device,u32 event) +static void acpi_video_bus_notify (acpi_handle handle,u32 event,void *data) { +struct acpi_device *device = data;struct acpi_video_bus *video =acpi_driver_data (device);struct input_dev *input;int keycode =0 ;
@@ -2053,8 +2053,20 @@ static int acpi_video_bus_add(struct acpi_device *device)acpi_video_bus_add_notify_handler (video); + error =acpi_dev_install_notify_handler (device, +ACPI_DEVICE_NOTIFY , + acpi_video_bus_notify); +if (error) + goto err_remove; +return 0 ; +err_remove: +mutex_lock (&video_list_lock); +list_del (&video->entry); +mutex_unlock (&video_list_lock); +acpi_video_bus_remove_notify_handler (video); +acpi_video_bus_unregister_backlight (video); err_put_video:acpi_video_bus_put_devices (video);kfree (video->attached_array);
@@ -2075,6 +2087,10 @@ static void acpi_video_bus_remove(struct acpi_device *device) video =acpi_driver_data (device); +acpi_dev_remove_notify_handler (device, +ACPI_DEVICE_NOTIFY , + acpi_video_bus_notify); +mutex_lock (&video_list_lock);list_del (&video->entry);mutex_unlock (&video_list_lock);
Signature · 1 line
2.41.0
PATCH v7 5/9 acpi/battery: Move handler installing logic to driver
In reply to Michal WilczynskiCurrently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance.
Call acpi_dev_install_notify_handler() at the end of .add() callback. Call acpi_dev_remove_notify_handler() at the beginning of .remove() callback. Change arguments passed to the notify function to match with what's required by acpi_dev_install_notify_handler(). Remove .notify callback initialization in acpi_driver.
While at it, fix lack of whitespaces in .remove() callback.
--- drivers/acpi/battery.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
drivers/acpi/battery.c +21 -5
@@ -1034,8 +1034,9 @@ static void acpi_battery_refresh(struct acpi_battery *battery) }/* Driver Interface */ -static void acpi_battery_notify (struct acpi_device *device,u32 event) +static void acpi_battery_notify (acpi_handle handle,u32 event,void *data) { +struct acpi_device *device = data;struct acpi_battery *battery =acpi_driver_data (device);struct power_supply *old;
@@ -1212,13 +1213,23 @@ static int acpi_battery_add(struct acpi_device *device)device_init_wakeup (&device->dev,1 ); -return result; + result =acpi_dev_install_notify_handler (device, +ACPI_ALL_NOTIFY , + acpi_battery_notify); +if (result) + goto fail_pm; + +return 0 ; +fail_pm: +device_init_wakeup (&device->dev,0 ); +unregister_pm_notifier (&battery->pm_nb); fail:sysfs_remove_battery (battery);mutex_destroy (&battery->lock);mutex_destroy (&battery->sysfs_lock);kfree (battery); +return result; }
@@ -1228,10 +1239,17 @@ static void acpi_battery_remove(struct acpi_device *device)if (!device || !acpi_driver_data (device))return ; -device_init_wakeup (&device->dev,0 ); + battery =acpi_driver_data (device); + +acpi_dev_remove_notify_handler (device, +ACPI_ALL_NOTIFY , + acpi_battery_notify); + +device_init_wakeup (&device->dev,0 );unregister_pm_notifier (&battery->pm_nb);sysfs_remove_battery (battery); +mutex_destroy (&battery->lock);mutex_destroy (&battery->sysfs_lock);kfree (battery);
@@ -1264,11 +1282,9 @@ static struct acpi_driver acpi_battery_driver = { .name = "battery", .class = ACPI_BATTERY_CLASS, .ids = battery_device_ids, - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, .ops = { .add = acpi_battery_add, .remove = acpi_battery_remove, - .notify = acpi_battery_notify, }, .drv.pm = &acpi_battery_pm, };
Signature · 1 line
2.41.0
PATCH v7 6/9 acpi/hed: Move handler installing logic to driver
In reply to Michal WilczynskiCurrently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance.
Call acpi_dev_install_notify_handler() at the end of .add() callback. Call acpi_dev_remove_notify_handler() at the beginning of .remove() callback. Change arguments passed to the notify function to match with what's required by acpi_dev_install_notify_handler(). Remove .notify callback initialization in acpi_driver.
--- drivers/acpi/hed.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/acpi/hed.c +14 -3
@@ -42,22 +42,34 @@ EXPORT_SYMBOL_GPL(unregister_acpi_hed_notifier);* it is used by HEST Generic Hardware Error Source with notify type * SCI. */ -static void acpi_hed_notify (struct acpi_device *device,u32 event) +static void acpi_hed_notify (acpi_handle handle,u32 event,void *data) {blocking_notifier_call_chain (&acpi_hed_notify_list,0 ,NULL ); }static int acpi_hed_add (struct acpi_device *device) { +int err; +/* Only one hardware error device */ if (hed_handle)return -EINVAL ; hed_handle = device->handle; -return 0 ; + + err =acpi_dev_install_notify_handler (device, +ACPI_DEVICE_NOTIFY , + acpi_hed_notify); +if (err) + hed_handle =NULL ; + +return err; }static void acpi_hed_remove (struct acpi_device *device) { +acpi_dev_remove_notify_handler (device, +ACPI_DEVICE_NOTIFY , + acpi_hed_notify); hed_handle =NULL ; }
@@ -68,7 +80,6 @@ static struct acpi_driver acpi_hed_driver = { .ops = { .add = acpi_hed_add, .remove = acpi_hed_remove, - .notify = acpi_hed_notify, }, };module_acpi_driver (acpi_hed_driver);
Signature · 1 line
2.41.0
PATCH v7 7/9 acpi/nfit: Move handler installing logic to driver
In reply to Michal WilczynskiCurrently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance.
Call acpi_dev_install_notify_handler() at the end of .add() callback. Call acpi_dev_remove_notify_handler() at the beginning of acpi_nfit_shutdown(). Change arguments passed to the notify function to match with what's required by acpi_dev_install_notify_handler(). Remove .notify callback initialization in acpi_driver.
Introduce a new devm action acpi_nfit_remove_notify_handler.
Move acpi_nfit_notify() upwards in the file, so it can be used inside acpi_nfit_add() and acpi_nfit_remove_notify_handler().
--- drivers/acpi/nfit/core.c | 41 +++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-)
drivers/acpi/nfit/core.c +32 -9
@@ -3282,6 +3282,24 @@ static void acpi_nfit_put_table(void *table)acpi_put_table (table); } +static void acpi_nfit_notify (acpi_handle handle,u32 event,void *data) +{ +struct acpi_device *adev = data; + +device_lock (&adev->dev); +__acpi_nfit_notify (&adev->dev, handle, event); +device_unlock (&adev->dev); +} + +static void acpi_nfit_remove_notify_handler (void *data) +{ +struct acpi_device *adev = data; + +acpi_dev_remove_notify_handler (adev, +ACPI_DEVICE_NOTIFY , + acpi_nfit_notify); +} +void acpi_nfit_shutdown (void *data) {struct acpi_nfit_desc *acpi_desc = data;
@@ -3368,7 +3386,20 @@ static int acpi_nfit_add(struct acpi_device *adev)if (rc)return rc; -return devm_add_action_or_reset (dev, acpi_nfit_shutdown, acpi_desc); + + rc =devm_add_action_or_reset (dev, acpi_nfit_shutdown, acpi_desc); +if (rc) +return rc; + + rc =acpi_dev_install_notify_handler (adev, +ACPI_DEVICE_NOTIFY , + acpi_nfit_notify); +if (rc) +return rc; + +return devm_add_action_or_reset (dev, + acpi_nfit_remove_notify_handler, + adev); }static void acpi_nfit_remove (struct acpi_device *adev)
@@ -3446,13 +3477,6 @@ void __acpi_nfit_notify(struct device *dev, acpi_handle handle, u32 event) }EXPORT_SYMBOL_GPL (__acpi_nfit_notify); -static void acpi_nfit_notify (struct acpi_device *adev,u32 event) -{ -device_lock (&adev->dev); -__acpi_nfit_notify (&adev->dev, adev->handle, event); -device_unlock (&adev->dev); -} -static const struct acpi_device_id acpi_nfit_ids[] = { {"ACPI0012" ,0 }, {"" ,0 },
@@ -3465,7 +3489,6 @@ static struct acpi_driver acpi_nfit_driver = { .ops = { .add = acpi_nfit_add, .remove = acpi_nfit_remove, - .notify = acpi_nfit_notify, }, };
Signature · 1 line
2.41.0
Rafael J. Wysocki
maintainerRe: [PATCH v7 7/9] acpi/nfit: Move handler installing logic to driver
Quoted 14 lines · Michal Wilczynski
Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct
acpi_driver. Preparations are being made to replaceacpi_driverwith more generic structplatform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly throughacpi_notify_device(), which decreases performance.Call
acpi_dev_install_notify_handler()at the end of .add() callback. Callacpi_dev_remove_notify_handler()at the beginning ofacpi_nfit_shutdown(). Change arguments passed to the notify function to match with what's required byacpi_dev_install_notify_handler(). Remove .notify callback initialization inacpi_driver.
Quoted 4 lines
Introduce a new devm action
acpi_nfit_remove_notify_handler.Move
acpi_nfit_notify()upwards in the file, so it can be used insideacpi_nfit_add()andacpi_nfit_remove_notify_handler().
Dan, any objections?
Quoted 80 lines
Suggested-by Rafael J. Wysocki <[email protected]>Signed-off-by Michal Wilczynski <[email protected]>--- drivers/acpi/nfit/core.c | 41 +++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-)drivers/acpi/nfit/core.c +32
-10@@ -3282,6 +3282,24 @@ static void acpi_nfit_put_table(void *table)acpi_put_table (table); } +static void acpi_nfit_notify (acpi_handle handle,u32 event,void *data) +{ +struct acpi_device *adev = data; + +device_lock (&adev->dev); +__acpi_nfit_notify (&adev->dev, handle, event); +device_unlock (&adev->dev); +} + +static void acpi_nfit_remove_notify_handler (void *data) +{ +struct acpi_device *adev = data; + +acpi_dev_remove_notify_handler (adev, +ACPI_DEVICE_NOTIFY , + acpi_nfit_notify); +} +void acpi_nfit_shutdown (void *data) {struct acpi_nfit_desc *acpi_desc = data;@@ -3368,7 +3386,20 @@ static int acpi_nfit_add(struct acpi_device *adev)if (rc)return rc; -return devm_add_action_or_reset (dev, acpi_nfit_shutdown, acpi_desc); + + rc =devm_add_action_or_reset (dev, acpi_nfit_shutdown, acpi_desc); +if (rc) +return rc; + + rc =acpi_dev_install_notify_handler (adev, +ACPI_DEVICE_NOTIFY , + acpi_nfit_notify); +if (rc) +return rc; + +return devm_add_action_or_reset (dev, + acpi_nfit_remove_notify_handler, + adev); }static void acpi_nfit_remove (struct acpi_device *adev)@@ -3446,13 +3477,6 @@ void __acpi_nfit_notify(struct device *dev, acpi_handle handle, u32 event) }EXPORT_SYMBOL_GPL (__acpi_nfit_notify); -static void acpi_nfit_notify (struct acpi_device *adev,u32 event) -{ -device_lock (&adev->dev); -__acpi_nfit_notify (&adev->dev, adev->handle, event); -device_unlock (&adev->dev); -} -static const struct acpi_device_id acpi_nfit_ids[] = { {"ACPI0012" ,0 }, {"" ,0 },@@ -3465,7 +3489,6 @@ static struct acpi_driver acpi_nfit_driver = { .ops = { .add = acpi_nfit_add, .remove = acpi_nfit_remove, - .notify = acpi_nfit_notify, }, }; --
PATCH v7 8/9 acpi/nfit: Remove unnecessary .remove callback
In reply to Michal WilczynskiNfit driver doesn't use .remove() callback and provide an empty function as it's .remove() callback. Remove empty acpi_nfit_remove() and initialization of callback.
--- drivers/acpi/nfit/core.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/acpi/nfit/core.c +0 -6
@@ -3402,11 +3402,6 @@ static int acpi_nfit_add(struct acpi_device *adev) adev); } -static void acpi_nfit_remove (struct acpi_device *adev) -{ -/* see acpi_nfit_unregister */ -} -static void acpi_nfit_update_notify (struct device *dev,acpi_handle handle) {struct acpi_nfit_desc *acpi_desc =dev_get_drvdata (dev);
@@ -3488,7 +3483,6 @@ static struct acpi_driver acpi_nfit_driver = { .ids = acpi_nfit_ids, .ops = { .add = acpi_nfit_add, - .remove = acpi_nfit_remove, }, };
Signature · 1 line
2.41.0
Rafael J. Wysocki
maintainerRe: [PATCH v7 8/9] acpi/nfit: Remove unnecessary .remove callback
Quoted 7 lines · Michal Wilczynski
Nfit driver doesn't use .remove() callback and provide an empty function as it's .remove() callback. Remove empty
acpi_nfit_remove()and initialization of callback.Suggested-by Dan Williams <[email protected]>Signed-off-by Michal Wilczynski <[email protected]>
This one is not strictly related to the rest of the series, but it does depend on the previous one, so assuming that the previous one is not objectionable, I suppose I can take them both. Dan?
Quoted 31 lines
--- drivers/acpi/nfit/core.c | 6 ------ 1 file changed, 6 deletions(-)drivers/acpi/nfit/core.c +0
-7@@ -3402,11 +3402,6 @@ static int acpi_nfit_add(struct acpi_device *adev) adev); } -static void acpi_nfit_remove (struct acpi_device *adev) -{ -/* see acpi_nfit_unregister */ -} -static void acpi_nfit_update_notify (struct device *dev,acpi_handle handle) {struct acpi_nfit_desc *acpi_desc =dev_get_drvdata (dev);@@ -3488,7 +3483,6 @@ static struct acpi_driver acpi_nfit_driver = { .ids = acpi_nfit_ids, .ops = { .add = acpi_nfit_add, - .remove = acpi_nfit_remove, }, }; --2.41.0
PATCH v7 9/9 acpi/thermal: Move handler installing logic to driver
In reply to Michal WilczynskiCurrently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance.
Call acpi_dev_install_notify_handler() at the end of .add() callback. Call acpi_dev_remove_notify_handler() at the beginning of .remove() callback. Change arguments passed to the notify function to match with what's required by acpi_dev_install_notify_handler(). Remove .notify callback initialization in acpi_driver.
While at it, fix whitespaces in .remove() callback.
--- drivers/acpi/thermal.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
drivers/acpi/thermal.c +20 -5
@@ -825,8 +825,9 @@ static void acpi_queue_thermal_check(struct acpi_thermal *tz)queue_work (acpi_thermal_pm_queue, &tz->thermal_check_work); } -static void acpi_thermal_notify (struct acpi_device *device,u32 event) +static void acpi_thermal_notify (acpi_handle handle,u32 event,void *data) { +struct acpi_device *device = data;struct acpi_thermal *tz =acpi_driver_data (device);if (!tz)
@@ -997,11 +998,21 @@ static int acpi_thermal_add(struct acpi_device *device)pr_info ("%s [%s] (%ld C)\n" ,acpi_device_name (device),acpi_device_bid (device),deci_kelvin_to_celsius (tz->temperature)); - goto end; + result =acpi_dev_install_notify_handler (device, +ACPI_DEVICE_NOTIFY , + acpi_thermal_notify); +if (result) + goto flush_wq; + +return 0 ; + +flush_wq: +flush_workqueue (acpi_thermal_pm_queue); +acpi_thermal_unregister_thermal_zone (tz); free_memory:kfree (tz); -end: +return result; }
@@ -1012,10 +1023,15 @@ static void acpi_thermal_remove(struct acpi_device *device)if (!device || !acpi_driver_data (device))return ; -flush_workqueue (acpi_thermal_pm_queue); tz =acpi_driver_data (device); +acpi_dev_remove_notify_handler (device, +ACPI_DEVICE_NOTIFY , + acpi_thermal_notify); + +flush_workqueue (acpi_thermal_pm_queue);acpi_thermal_unregister_thermal_zone (tz); +kfree (tz); }
@@ -1078,7 +1094,6 @@ static struct acpi_driver acpi_thermal_driver = { .ops = { .add = acpi_thermal_add, .remove = acpi_thermal_remove, - .notify = acpi_thermal_notify, }, .drv.pm = &acpi_thermal_pm, };
Signature · 1 line
2.41.0
Rafael J. Wysocki
maintainerQuoted 49 lines · Michal Wilczynski
*** IMPORTANT ***
This is part 1 - only drivers in acpi directory to ease up review process. Rest of the drivers will be handled in separate patchsets.Currently drivers support ACPI event handlers by defining .notify callback in
acpi_device_ops. This solution is suboptimal as event handler installer installs intermediary functionacpi_notify_deviceas a handler in every driver. Also this approach requires extra variable 'flags' for specifying event types that the driver want to subscribe to. Additionally this is a pre-work required to alignacpi_driverwithplatform_driverand eventually replaceacpi_driverwithplatform_driver.Remove .notify callback from the
acpi_device_ops. Replace it with each driver installing and removing it's event handlers.This is part 1 - only drivers in acpi directory to ease up review process.
v7:
- fix warning by declaringacpi_nfit_remove_notify_handler()as staticv6:
- fixed unnecessary RCT in all drivers, as it's not a purpose of this patch series
- changed error label names to simplify them
- dropped commit that remove a comma
- squashed commit moving code for nfit
- improved nfit driver to use devm instead of .remove()
- re-based as Rafael changes [1] are merged alreadyv5:
- rebased on top of Rafael changes [1], they're not merged yet
- fixed rollback in multiple drivers so they don't leak resources on failure
- made this part 1, meaning only drivers in acpi directory, rest of the drivers will be handled in separate patchsets to ease up reviewv4:
- added one commit for previously missed driver sony-laptop, refactored return statements, added NULL check for event installer
v3:
- lkp still reported some failures for eeepc, fujitsu andtoshiba_bluetooth, fix those
v2:
- fix compilation errors for drivers[1]: https://lore.kernel.org/linux-acpi/1847933.atdPhlSkOF@kreacher/
Quoted 10 lines
Michal Wilczynski (9):
acpi/bus: Introduce wrappers for ACPICA event handler install/remove acpi/bus: Setdriver_datato NULL every time .add() fails acpi/ac: Move handler installing logic to driver acpi/video: Move handler installing logic to driver acpi/battery: Move handler installing logic to driver acpi/hed: Move handler installing logic to driver acpi/nfit: Move handler installing logic to driver acpi/nfit: Remove unnecessary .remove callback acpi/thermal: Move handler installing logic to driver
Dan hasn't spoken up yet, but I went ahead and queued up the patches (with some modifications) for 6.6.
I've edited the subjects and rewritten the changelogs and I've adjusted some white space around function calls (nothing major).
Thanks!