* [PATCH v6 1/9] acpi/bus: Introduce wrappers for ACPICA event handler install/remove
2023-06-30 18:33 [PATCH v6 0/9] Remove .notify callback in acpi_device_ops Michal Wilczynski
@ 2023-06-30 18:33 ` Michal Wilczynski
2023-06-30 18:33 ` [PATCH v6 2/9] acpi/bus: Set driver_data to NULL every time .add() fails Michal Wilczynski
` (7 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Michal Wilczynski @ 2023-06-30 18:33 UTC (permalink / raw)
To: linux-acpi
Cc: rafael, dan.j.williams, vishal.l.verma, lenb, dave.jiang,
ira.weiny, rui.zhang, linux-kernel, nvdimm, Michal Wilczynski,
Rafael J . Wysocki
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.
Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
---
drivers/acpi/bus.c | 26 ++++++++++++++++++++++++++
include/acpi/acpi_bus.h | 6 ++++++
2 files changed, 32 insertions(+)
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 20cdfb37da79..2d6f1f45d44e 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -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
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index c941d99162c0..23fbe4a16972 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -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 *);
--
2.41.0
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH v6 2/9] acpi/bus: Set driver_data to NULL every time .add() fails
2023-06-30 18:33 [PATCH v6 0/9] Remove .notify callback in acpi_device_ops Michal Wilczynski
2023-06-30 18:33 ` [PATCH v6 1/9] acpi/bus: Introduce wrappers for ACPICA event handler install/remove Michal Wilczynski
@ 2023-06-30 18:33 ` Michal Wilczynski
2023-06-30 18:33 ` [PATCH v6 3/9] acpi/ac: Move handler installing logic to driver Michal Wilczynski
` (6 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Michal Wilczynski @ 2023-06-30 18:33 UTC (permalink / raw)
To: linux-acpi
Cc: rafael, dan.j.williams, vishal.l.verma, lenb, dave.jiang,
ira.weiny, rui.zhang, linux-kernel, nvdimm, Michal Wilczynski
Most 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.
Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
---
drivers/acpi/bus.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 2d6f1f45d44e..c087fd6e8398 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -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);
--
2.41.0
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH v6 3/9] acpi/ac: Move handler installing logic to driver
2023-06-30 18:33 [PATCH v6 0/9] Remove .notify callback in acpi_device_ops Michal Wilczynski
2023-06-30 18:33 ` [PATCH v6 1/9] acpi/bus: Introduce wrappers for ACPICA event handler install/remove Michal Wilczynski
2023-06-30 18:33 ` [PATCH v6 2/9] acpi/bus: Set driver_data to NULL every time .add() fails Michal Wilczynski
@ 2023-06-30 18:33 ` Michal Wilczynski
2023-06-30 18:33 ` [PATCH v6 4/9] acpi/video: " Michal Wilczynski
` (5 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Michal Wilczynski @ 2023-06-30 18:33 UTC (permalink / raw)
To: linux-acpi
Cc: rafael, dan.j.williams, vishal.l.verma, lenb, dave.jiang,
ira.weiny, rui.zhang, linux-kernel, nvdimm, Michal Wilczynski,
Rafael J . Wysocki
Currently 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.
Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
---
drivers/acpi/ac.c | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 1ace70b831cd..f6feff1f3118 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -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);
--
2.41.0
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH v6 4/9] acpi/video: Move handler installing logic to driver
2023-06-30 18:33 [PATCH v6 0/9] Remove .notify callback in acpi_device_ops Michal Wilczynski
` (2 preceding siblings ...)
2023-06-30 18:33 ` [PATCH v6 3/9] acpi/ac: Move handler installing logic to driver Michal Wilczynski
@ 2023-06-30 18:33 ` Michal Wilczynski
2023-06-30 18:33 ` [PATCH v6 5/9] acpi/battery: " Michal Wilczynski
` (4 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Michal Wilczynski @ 2023-06-30 18:33 UTC (permalink / raw)
To: linux-acpi
Cc: rafael, dan.j.williams, vishal.l.verma, lenb, dave.jiang,
ira.weiny, rui.zhang, linux-kernel, nvdimm, Michal Wilczynski,
Rafael J . Wysocki
Currently 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.
Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
---
drivers/acpi/acpi_video.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 62f4364e4460..168bb43e0c65 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -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);
--
2.41.0
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH v6 5/9] acpi/battery: Move handler installing logic to driver
2023-06-30 18:33 [PATCH v6 0/9] Remove .notify callback in acpi_device_ops Michal Wilczynski
` (3 preceding siblings ...)
2023-06-30 18:33 ` [PATCH v6 4/9] acpi/video: " Michal Wilczynski
@ 2023-06-30 18:33 ` Michal Wilczynski
2023-06-30 18:33 ` [PATCH v6 6/9] acpi/hed: " Michal Wilczynski
` (3 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Michal Wilczynski @ 2023-06-30 18:33 UTC (permalink / raw)
To: linux-acpi
Cc: rafael, dan.j.williams, vishal.l.verma, lenb, dave.jiang,
ira.weiny, rui.zhang, linux-kernel, nvdimm, Michal Wilczynski,
Rafael J . Wysocki
Currently 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.
Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
---
drivers/acpi/battery.c | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 9c67ed02d797..4c634a4c32dd 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -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,
};
--
2.41.0
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH v6 6/9] acpi/hed: Move handler installing logic to driver
2023-06-30 18:33 [PATCH v6 0/9] Remove .notify callback in acpi_device_ops Michal Wilczynski
` (4 preceding siblings ...)
2023-06-30 18:33 ` [PATCH v6 5/9] acpi/battery: " Michal Wilczynski
@ 2023-06-30 18:33 ` Michal Wilczynski
2023-06-30 18:33 ` [PATCH v6 7/9] acpi/nfit: " Michal Wilczynski
` (2 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Michal Wilczynski @ 2023-06-30 18:33 UTC (permalink / raw)
To: linux-acpi
Cc: rafael, dan.j.williams, vishal.l.verma, lenb, dave.jiang,
ira.weiny, rui.zhang, linux-kernel, nvdimm, Michal Wilczynski,
Rafael J . Wysocki
Currently 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.
Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
---
drivers/acpi/hed.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/acpi/hed.c b/drivers/acpi/hed.c
index 78d44e3fe129..8f54560c6d1c 100644
--- a/drivers/acpi/hed.c
+++ b/drivers/acpi/hed.c
@@ -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);
--
2.41.0
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH v6 7/9] acpi/nfit: Move handler installing logic to driver
2023-06-30 18:33 [PATCH v6 0/9] Remove .notify callback in acpi_device_ops Michal Wilczynski
` (5 preceding siblings ...)
2023-06-30 18:33 ` [PATCH v6 6/9] acpi/hed: " Michal Wilczynski
@ 2023-06-30 18:33 ` Michal Wilczynski
2023-06-30 20:47 ` kernel test robot
2023-06-30 18:33 ` [PATCH v6 8/9] acpi/nfit: Remove unnecessary .remove callback Michal Wilczynski
2023-06-30 18:33 ` [PATCH v6 9/9] acpi/thermal: Move handler installing logic to driver Michal Wilczynski
8 siblings, 1 reply; 11+ messages in thread
From: Michal Wilczynski @ 2023-06-30 18:33 UTC (permalink / raw)
To: linux-acpi
Cc: rafael, dan.j.williams, vishal.l.verma, lenb, dave.jiang,
ira.weiny, rui.zhang, linux-kernel, nvdimm, Michal Wilczynski,
Rafael J . Wysocki
Currently 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().
Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
---
drivers/acpi/nfit/core.c | 41 +++++++++++++++++++++++++++++++---------
1 file changed, 32 insertions(+), 9 deletions(-)
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 07204d482968..ee2365a80aa1 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -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);
+}
+
+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,
},
};
--
2.41.0
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH v6 7/9] acpi/nfit: Move handler installing logic to driver
2023-06-30 18:33 ` [PATCH v6 7/9] acpi/nfit: " Michal Wilczynski
@ 2023-06-30 20:47 ` kernel test robot
0 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2023-06-30 20:47 UTC (permalink / raw)
To: Michal Wilczynski, linux-acpi
Cc: oe-kbuild-all, rafael, dan.j.williams, vishal.l.verma, lenb,
dave.jiang, ira.weiny, rui.zhang, linux-kernel, nvdimm,
Michal Wilczynski, Rafael J . Wysocki
Hi Michal,
kernel test robot noticed the following build warnings:
[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on nvdimm/libnvdimm-for-next]
[cannot apply to nvdimm/dax-misc]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Michal-Wilczynski/acpi-bus-Introduce-wrappers-for-ACPICA-event-handler-install-remove/20230701-023629
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link: https://lore.kernel.org/r/20230630183344.891077-8-michal.wilczynski%40intel.com
patch subject: [PATCH v6 7/9] acpi/nfit: Move handler installing logic to driver
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20230701/202307010426.IaTkXyNX-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230701/202307010426.IaTkXyNX-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202307010426.IaTkXyNX-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/acpi/nfit/core.c:3294:6: warning: no previous prototype for 'acpi_nfit_remove_notify_handler' [-Wmissing-prototypes]
3294 | void acpi_nfit_remove_notify_handler(void *data)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +/acpi_nfit_remove_notify_handler +3294 drivers/acpi/nfit/core.c
3293
> 3294 void acpi_nfit_remove_notify_handler(void *data)
3295 {
3296 struct acpi_device *adev = data;
3297
3298 acpi_dev_remove_notify_handler(adev,
3299 ACPI_DEVICE_NOTIFY,
3300 acpi_nfit_notify);
3301 }
3302
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v6 8/9] acpi/nfit: Remove unnecessary .remove callback
2023-06-30 18:33 [PATCH v6 0/9] Remove .notify callback in acpi_device_ops Michal Wilczynski
` (6 preceding siblings ...)
2023-06-30 18:33 ` [PATCH v6 7/9] acpi/nfit: " Michal Wilczynski
@ 2023-06-30 18:33 ` Michal Wilczynski
2023-06-30 18:33 ` [PATCH v6 9/9] acpi/thermal: Move handler installing logic to driver Michal Wilczynski
8 siblings, 0 replies; 11+ messages in thread
From: Michal Wilczynski @ 2023-06-30 18:33 UTC (permalink / raw)
To: linux-acpi
Cc: rafael, dan.j.williams, vishal.l.verma, lenb, dave.jiang,
ira.weiny, rui.zhang, linux-kernel, nvdimm, 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 <dan.j.williams@intel.com>
Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
---
drivers/acpi/nfit/core.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index ee2365a80aa1..daaea23cacfd 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -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
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH v6 9/9] acpi/thermal: Move handler installing logic to driver
2023-06-30 18:33 [PATCH v6 0/9] Remove .notify callback in acpi_device_ops Michal Wilczynski
` (7 preceding siblings ...)
2023-06-30 18:33 ` [PATCH v6 8/9] acpi/nfit: Remove unnecessary .remove callback Michal Wilczynski
@ 2023-06-30 18:33 ` Michal Wilczynski
8 siblings, 0 replies; 11+ messages in thread
From: Michal Wilczynski @ 2023-06-30 18:33 UTC (permalink / raw)
To: linux-acpi
Cc: rafael, dan.j.williams, vishal.l.verma, lenb, dave.jiang,
ira.weiny, rui.zhang, linux-kernel, nvdimm, Michal Wilczynski,
Rafael J . Wysocki
Currently 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.
Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
---
drivers/acpi/thermal.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index f9f6ebb08fdb..97858ad59d68 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -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,
};
--
2.41.0
^ permalink raw reply [flat|nested] 11+ messages in thread