public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/9] ACPI: driver: Cleanups and fixes, mostly related to acpi_device_name/class()
@ 2026-03-05 20:09 Rafael J. Wysocki
  2026-03-05 20:10 ` [PATCH v1 1/9] ACPI: AC: Get rid of unnecessary declarations Rafael J. Wysocki
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-03-05 20:09 UTC (permalink / raw)
  To: Linux ACPI; +Cc: LKML, Hans de Goede

Hi All,

This series 

 * Cleans up a few wonky things in the core ACPI drivers (patches [1-4/9])
 * Updates several drivers to stop setting acpi_device_name(), which
   is not used anywhere later (patch [5/9])
 * Adjusts notification APIs to be more consistent and in preparation for
   the next change (patch [6-7/9])
 * Updates several drivers to stop setting acpi_device_class(), which is not
   used anywhere later, and one driver still using it (button) to clear it
   on remove (patch [8/9])
 * Consolidates the ACPI_AC_CLASS definitions (patch [9/9]).

Thanks!




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v1 1/9] ACPI: AC: Get rid of unnecessary declarations
  2026-03-05 20:09 [PATCH v1 0/9] ACPI: driver: Cleanups and fixes, mostly related to acpi_device_name/class() Rafael J. Wysocki
@ 2026-03-05 20:10 ` Rafael J. Wysocki
  2026-03-05 20:11 ` [PATCH v1 2/9] ACPI: PAD: Rearrange notify handler installation and removal Rafael J. Wysocki
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-03-05 20:10 UTC (permalink / raw)
  To: Linux ACPI; +Cc: LKML, Hans de Goede

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

Drop unnecessary forward declarations of 4 functions and move the
SIMPLE_DEV_PM_OPS() definition after the definition of the resume
callback function.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/ac.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index c5d77c3cb4bc..e0560a2c71a0 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -33,22 +33,12 @@ MODULE_AUTHOR("Paul Diefenbaugh");
 MODULE_DESCRIPTION("ACPI AC Adapter Driver");
 MODULE_LICENSE("GPL");
 
-static int acpi_ac_probe(struct platform_device *pdev);
-static void acpi_ac_remove(struct platform_device *pdev);
-
-static void acpi_ac_notify(acpi_handle handle, u32 event, void *data);
-
 static const struct acpi_device_id ac_device_ids[] = {
 	{"ACPI0003", 0},
 	{"", 0},
 };
 MODULE_DEVICE_TABLE(acpi, ac_device_ids);
 
-#ifdef CONFIG_PM_SLEEP
-static int acpi_ac_resume(struct device *dev);
-#endif
-static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume);
-
 static int ac_sleep_before_get_state_ms;
 static int ac_only;
 
@@ -272,10 +262,10 @@ static int acpi_ac_resume(struct device *dev)
 
 	return 0;
 }
-#else
-#define acpi_ac_resume NULL
 #endif
 
+static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume);
+
 static void acpi_ac_remove(struct platform_device *pdev)
 {
 	struct acpi_ac *ac = platform_get_drvdata(pdev);
-- 
2.51.0





^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v1 2/9] ACPI: PAD: Rearrange notify handler installation and removal
  2026-03-05 20:09 [PATCH v1 0/9] ACPI: driver: Cleanups and fixes, mostly related to acpi_device_name/class() Rafael J. Wysocki
  2026-03-05 20:10 ` [PATCH v1 1/9] ACPI: AC: Get rid of unnecessary declarations Rafael J. Wysocki
@ 2026-03-05 20:11 ` Rafael J. Wysocki
  2026-03-05 20:12 ` [PATCH v1 3/9] ACPI: video: Consolidate pnp.bus_id workarounds handling Rafael J. Wysocki
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-03-05 20:11 UTC (permalink / raw)
  To: Linux ACPI; +Cc: LKML, Hans de Goede

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

Use acpi_dev_install_notify_handler() and acpi_dev_remove_notify_handler()
for installing and removing the ACPI notify handler, respectively, which
allows acpi_pad_notify() and acpi_pad_remove() to be simplified quite a
bit.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/acpi_pad.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index c9a0bcaba2e4..407a0d68525c 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -407,8 +407,7 @@ static void acpi_pad_handle_notify(acpi_handle handle)
 	mutex_unlock(&isolated_cpus_lock);
 }
 
-static void acpi_pad_notify(acpi_handle handle, u32 event,
-	void *data)
+static void acpi_pad_notify(acpi_handle handle, u32 event, void *data)
 {
 	struct acpi_device *adev = data;
 
@@ -427,30 +426,22 @@ static void acpi_pad_notify(acpi_handle handle, u32 event,
 static int acpi_pad_probe(struct platform_device *pdev)
 {
 	struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
-	acpi_status status;
 
 	strscpy(acpi_device_name(adev), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME);
 	strscpy(acpi_device_class(adev), ACPI_PROCESSOR_AGGREGATOR_CLASS);
 
-	status = acpi_install_notify_handler(adev->handle,
-		ACPI_DEVICE_NOTIFY, acpi_pad_notify, adev);
-
-	if (ACPI_FAILURE(status))
-		return -ENODEV;
-
-	return 0;
+	return acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
+					       acpi_pad_notify, adev);
 }
 
 static void acpi_pad_remove(struct platform_device *pdev)
 {
-	struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
-
 	mutex_lock(&isolated_cpus_lock);
 	acpi_pad_idle_cpus(0);
 	mutex_unlock(&isolated_cpus_lock);
 
-	acpi_remove_notify_handler(adev->handle,
-		ACPI_DEVICE_NOTIFY, acpi_pad_notify);
+	acpi_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev),
+				       ACPI_DEVICE_NOTIFY, acpi_pad_notify);
 }
 
 static const struct acpi_device_id pad_device_ids[] = {
-- 
2.51.0





^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v1 3/9] ACPI: video: Consolidate pnp.bus_id workarounds handling
  2026-03-05 20:09 [PATCH v1 0/9] ACPI: driver: Cleanups and fixes, mostly related to acpi_device_name/class() Rafael J. Wysocki
  2026-03-05 20:10 ` [PATCH v1 1/9] ACPI: AC: Get rid of unnecessary declarations Rafael J. Wysocki
  2026-03-05 20:11 ` [PATCH v1 2/9] ACPI: PAD: Rearrange notify handler installation and removal Rafael J. Wysocki
@ 2026-03-05 20:12 ` Rafael J. Wysocki
  2026-03-05 20:16 ` [PATCH v1 4/9] ACPI: video: Rework checking for duplicate video bus devices Rafael J. Wysocki
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-03-05 20:12 UTC (permalink / raw)
  To: Linux ACPI; +Cc: LKML, Hans de Goede

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

Reduce code duplication related to pnp.bus_id workarounds by combining
the two existing cases.

Also move the definition of static variable "instance" into
acpi_video_bus_probe() because it is only used there.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/acpi_video.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 3fa28f1abca3..6337376be196 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1978,12 +1978,11 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
 	return 0;
 }
 
-static int instance;
-
 static int acpi_video_bus_probe(struct platform_device *pdev)
 {
 	struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
 	struct acpi_video_bus *video;
+	static int instance;
 	bool auto_detect;
 	int error;
 	acpi_status status;
@@ -2006,16 +2005,15 @@ static int acpi_video_bus_probe(struct platform_device *pdev)
 	if (!video)
 		return -ENOMEM;
 
-	/* a hack to fix the duplicate name "VID" problem on T61 */
-	if (!strcmp(device->pnp.bus_id, "VID")) {
-		if (instance)
-			device->pnp.bus_id[3] = '0' + instance;
-		instance++;
-	}
-	/* a hack to fix the duplicate name "VGA" problem on Pa 3553 */
-	if (!strcmp(device->pnp.bus_id, "VGA")) {
+	/*
+	 * A hack to fix the duplicate name "VID" problem on T61 and the
+	 * duplicate name "VGA" problem on Pa 3553.
+	 */
+	if (!strcmp(device->pnp.bus_id, "VID") ||
+	    !strcmp(device->pnp.bus_id, "VGA")) {
 		if (instance)
 			device->pnp.bus_id[3] = '0' + instance;
+
 		instance++;
 	}
 
-- 
2.51.0





^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v1 4/9] ACPI: video: Rework checking for duplicate video bus devices
  2026-03-05 20:09 [PATCH v1 0/9] ACPI: driver: Cleanups and fixes, mostly related to acpi_device_name/class() Rafael J. Wysocki
                   ` (2 preceding siblings ...)
  2026-03-05 20:12 ` [PATCH v1 3/9] ACPI: video: Consolidate pnp.bus_id workarounds handling Rafael J. Wysocki
@ 2026-03-05 20:16 ` Rafael J. Wysocki
  2026-03-05 20:17 ` [PATCH v1 5/9] ACPI: driver: Do not set acpi_device_name() unnecessarily Rafael J. Wysocki
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-03-05 20:16 UTC (permalink / raw)
  To: Linux ACPI; +Cc: LKML, Hans de Goede

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

The current way of checking for duplicate video bus devices in
acpi_video_bus_probe() is based on walking the ACPI namespace which is
not necessary after converting the driver to a platform one proper.  It
is also susceptible to race conditions (for example, if two video bus
devices are probed at the same time) and ordering issues.

Instead of doing it the old way, inspect the children of the parent of
the platform device being probed, excluding the latter and the children
that are not platform devices.  For each of the remaining children,
check if any of the entries in the video_bus_head list is equal to its
driver data which can only happen if the given child has been processed
by acpi_video_bus_probe() successfully and so it is a duplicate of the
one being probed.

Moreover, to prevent acpi_video_bus_probe() from processing two devices
concurrently, which might defeat the above check, use a new internal
mutex in it.

Also, print the FW_BUG message only if allow_duplicates is unset which
allows the entire duplicates check to be skipped in that case (doing
it just to print the message about the case that is going to be
ignored anyway is kind of pointless).

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/acpi_video.c |   57 +++++++++++++++++++++++-----------------------
 1 file changed, 29 insertions(+), 28 deletions(-)

--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1683,26 +1683,6 @@ static int acpi_video_resume(struct noti
 	return NOTIFY_DONE;
 }
 
-static acpi_status
-acpi_video_bus_match(acpi_handle handle, u32 level, void *context,
-			void **return_value)
-{
-	struct acpi_device *device = context;
-	struct acpi_device *sibling;
-
-	if (handle == device->handle)
-		return AE_CTRL_TERMINATE;
-
-	sibling = acpi_fetch_acpi_dev(handle);
-	if (!sibling)
-		return AE_OK;
-
-	if (!strcmp(acpi_device_name(sibling), ACPI_VIDEO_BUS_NAME))
-			return AE_ALREADY_EXISTS;
-
-	return AE_OK;
-}
-
 static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
 {
 	struct backlight_properties props;
@@ -1978,27 +1958,48 @@ static int acpi_video_bus_put_devices(st
 	return 0;
 }
 
+static int duplicate_dev_check(struct device *sibling, void *data)
+{
+	struct acpi_video_bus *video;
+
+	if (sibling == data || !dev_is_platform(sibling))
+		return 0;
+
+	guard(mutex)(&video_list_lock);
+
+	list_for_each_entry(video, &video_bus_head, entry) {
+		if (video == dev_get_drvdata(sibling))
+			return -EEXIST;
+	}
+
+	return 0;
+}
+
+static bool acpi_video_bus_dev_is_duplicate(struct platform_device *pdev)
+{
+	return device_for_each_child(pdev->dev.parent, &pdev->dev,
+				     duplicate_dev_check);
+}
+
 static int acpi_video_bus_probe(struct platform_device *pdev)
 {
 	struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
+	static DEFINE_MUTEX(probe_lock);
 	struct acpi_video_bus *video;
 	static int instance;
 	bool auto_detect;
 	int error;
-	acpi_status status;
 
-	status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
-				acpi_dev_parent(device)->handle, 1,
-				acpi_video_bus_match, NULL,
-				device, NULL);
-	if (status == AE_ALREADY_EXISTS) {
+	/* Probe one video bus device at a time in case there are duplicates. */
+	guard(mutex)(&probe_lock);
+
+	if (!allow_duplicates && acpi_video_bus_dev_is_duplicate(pdev)) {
 		pr_info(FW_BUG
 			"Duplicate ACPI video bus devices for the"
 			" same VGA controller, please try module "
 			"parameter \"video.allow_duplicates=1\""
 			"if the current driver doesn't work.\n");
-		if (!allow_duplicates)
-			return -ENODEV;
+		return -ENODEV;
 	}
 
 	video = kzalloc_obj(struct acpi_video_bus);




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v1 5/9] ACPI: driver: Do not set acpi_device_name() unnecessarily
  2026-03-05 20:09 [PATCH v1 0/9] ACPI: driver: Cleanups and fixes, mostly related to acpi_device_name/class() Rafael J. Wysocki
                   ` (3 preceding siblings ...)
  2026-03-05 20:16 ` [PATCH v1 4/9] ACPI: video: Rework checking for duplicate video bus devices Rafael J. Wysocki
@ 2026-03-05 20:17 ` Rafael J. Wysocki
  2026-03-05 20:18 ` [PATCH v1 6/9] ACPI: event: Redefine acpi_notifier_call_chain() Rafael J. Wysocki
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-03-05 20:17 UTC (permalink / raw)
  To: Linux ACPI; +Cc: LKML, Hans de Goede

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

ACPI drivers usually set acpi_device_name() for the given struct
acpi_device to whatever they like, but that value is never used unless
the driver itself uses it and, quite unfortunately, drivers neglect to
clear it on remove.  Some drivers use it for printing messages or
initializing the names of subordinate devices, but it is better to use
string literals for that, especially if the given one is used just once.

To eliminate unnecessary overhead related to acpi_device_name()
handling, rework multiple core ACPI device drivers to stop setting
acpi_device_name() for struct acpi_device objects manipulated
by them and use a string literal instead of it where applicable.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/ac.c              |  6 ++----
 drivers/acpi/acpi_memhotplug.c |  2 --
 drivers/acpi/acpi_pad.c        |  2 --
 drivers/acpi/acpi_processor.c  |  1 -
 drivers/acpi/acpi_video.c      | 16 +++++-----------
 drivers/acpi/battery.c         |  3 ---
 drivers/acpi/button.c          |  7 +++----
 drivers/acpi/ec.c              |  2 --
 drivers/acpi/pci_link.c        |  2 --
 drivers/acpi/pci_root.c        |  7 ++-----
 drivers/acpi/power.c           |  2 --
 drivers/acpi/sbs.c             |  1 -
 drivers/acpi/sbshc.c           |  2 --
 drivers/acpi/thermal.c         |  6 ++----
 include/acpi/processor.h       |  1 -
 15 files changed, 14 insertions(+), 46 deletions(-)

diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index e0560a2c71a0..4985c8890609 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -22,7 +22,6 @@
 #include <acpi/battery.h>
 
 #define ACPI_AC_CLASS			"ac_adapter"
-#define ACPI_AC_DEVICE_NAME		"AC Adapter"
 #define ACPI_AC_FILE_STATE		"state"
 #define ACPI_AC_NOTIFY_STATUS		0x80
 #define ACPI_AC_STATUS_OFFLINE		0x00
@@ -203,7 +202,6 @@ static int acpi_ac_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	ac->device = adev;
-	strscpy(acpi_device_name(adev), ACPI_AC_DEVICE_NAME);
 	strscpy(acpi_device_class(adev), ACPI_AC_CLASS);
 
 	platform_set_drvdata(pdev, ac);
@@ -226,8 +224,8 @@ static int acpi_ac_probe(struct platform_device *pdev)
 		goto err_release_ac;
 	}
 
-	pr_info("%s [%s] (%s-line)\n", acpi_device_name(adev),
-		acpi_device_bid(adev), str_on_off(ac->state));
+	pr_info("AC Adapter [%s] (%s-line)\n", acpi_device_bid(adev),
+		str_on_off(ac->state));
 
 	ac->battery_nb.notifier_call = acpi_ac_battery_notify;
 	register_acpi_notifier(&ac->battery_nb);
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 02a472fa85fc..7f021e6d8b0e 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -20,7 +20,6 @@
 
 #define ACPI_MEMORY_DEVICE_CLASS		"memory"
 #define ACPI_MEMORY_DEVICE_HID			"PNP0C80"
-#define ACPI_MEMORY_DEVICE_NAME			"Hotplug Mem Device"
 
 static const struct acpi_device_id memory_device_ids[] = {
 	{ACPI_MEMORY_DEVICE_HID, 0},
@@ -297,7 +296,6 @@ static int acpi_memory_device_add(struct acpi_device *device,
 	INIT_LIST_HEAD(&mem_device->res_list);
 	mem_device->device = device;
 	mem_device->mgid = -1;
-	sprintf(acpi_device_name(device), "%s", ACPI_MEMORY_DEVICE_NAME);
 	sprintf(acpi_device_class(device), "%s", ACPI_MEMORY_DEVICE_CLASS);
 	device->driver_data = mem_device;
 
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index 407a0d68525c..1f735f77fd1a 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -24,7 +24,6 @@
 #include <xen/xen.h>
 
 #define ACPI_PROCESSOR_AGGREGATOR_CLASS	"acpi_pad"
-#define ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME "Processor Aggregator"
 #define ACPI_PROCESSOR_AGGREGATOR_NOTIFY 0x80
 
 #define ACPI_PROCESSOR_AGGREGATOR_STATUS_SUCCESS	0
@@ -427,7 +426,6 @@ static int acpi_pad_probe(struct platform_device *pdev)
 {
 	struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
 
-	strscpy(acpi_device_name(adev), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME);
 	strscpy(acpi_device_class(adev), ACPI_PROCESSOR_AGGREGATOR_CLASS);
 
 	return acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index b34a48068a8d..46020a49a7ed 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -438,7 +438,6 @@ static int acpi_processor_add(struct acpi_device *device,
 	}
 
 	pr->handle = device->handle;
-	strscpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME);
 	strscpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
 	device->driver_data = pr;
 
diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 124e58eb9087..4fc2e52401a6 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -30,9 +30,6 @@
 #include <linux/uaccess.h>
 #include <linux/string_choices.h>
 
-#define ACPI_VIDEO_BUS_NAME		"Video Bus"
-#define ACPI_VIDEO_DEVICE_NAME		"Video Device"
-
 #define MAX_NAME_LEN	20
 
 MODULE_AUTHOR("Bruno Ducrot");
@@ -1146,7 +1143,6 @@ static int acpi_video_bus_get_one_device(struct acpi_device *device, void *arg)
 		return -ENOMEM;
 	}
 
-	strscpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME);
 	strscpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
 
 	data->device_id = device_id;
@@ -1884,7 +1880,7 @@ static int acpi_video_bus_add_notify_handler(struct acpi_video_bus *video,
 	snprintf(video->phys, sizeof(video->phys),
 			"%s/video/input0", acpi_device_hid(video->device));
 
-	input->name = acpi_device_name(video->device);
+	input->name = "Video Bus";
 	input->phys = video->phys;
 	input->id.bustype = BUS_HOST;
 	input->id.product = 0x06;
@@ -2021,7 +2017,6 @@ static int acpi_video_bus_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, video);
 
 	video->device = device;
-	strscpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME);
 	strscpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
 	device->driver_data = video;
 
@@ -2043,11 +2038,10 @@ static int acpi_video_bus_probe(struct platform_device *pdev)
 	 */
 	acpi_device_fix_up_power_children(device);
 
-	pr_info("%s [%s] (multi-head: %s  rom: %s  post: %s)\n",
-	       ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
-	       str_yes_no(video->flags.multihead),
-	       str_yes_no(video->flags.rom),
-	       str_yes_no(video->flags.post));
+	pr_info("Video Device [%s] (multi-head: %s  rom: %s  post: %s)\n",
+		acpi_device_bid(device), str_yes_no(video->flags.multihead),
+		str_yes_no(video->flags.rom), str_yes_no(video->flags.post));
+
 	mutex_lock(&video_list_lock);
 	list_add_tail(&video->entry, &video_bus_head);
 	mutex_unlock(&video_list_lock);
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 8fbad8bc4650..acf5dd2177a1 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -33,8 +33,6 @@
 #define ACPI_BATTERY_CAPACITY_VALID(capacity) \
 	((capacity) != 0 && (capacity) != ACPI_BATTERY_VALUE_UNKNOWN)
 
-#define ACPI_BATTERY_DEVICE_NAME	"Battery"
-
 /* Battery power unit: 0 means mW, 1 means mA */
 #define ACPI_BATTERY_POWER_UNIT_MA	1
 
@@ -1229,7 +1227,6 @@ static int acpi_battery_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, battery);
 
 	battery->device = device;
-	strscpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
 	strscpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
 
 	result = devm_mutex_init(&pdev->dev, &battery->update_lock);
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 97b05246efab..c57bd9c63057 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -558,27 +558,26 @@ static int acpi_button_probe(struct platform_device *pdev)
 		goto err_free_button;
 	}
 
-	name = acpi_device_name(device);
 	class = acpi_device_class(device);
 
 	if (!strcmp(hid, ACPI_BUTTON_HID_POWER) ||
 	    !strcmp(hid, ACPI_BUTTON_HID_POWERF)) {
 		button->type = ACPI_BUTTON_TYPE_POWER;
 		handler = acpi_button_notify;
-		strscpy(name, ACPI_BUTTON_DEVICE_NAME_POWER, MAX_ACPI_DEVICE_NAME_LEN);
+		name = ACPI_BUTTON_DEVICE_NAME_POWER;
 		sprintf(class, "%s/%s",
 			ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER);
 	} else if (!strcmp(hid, ACPI_BUTTON_HID_SLEEP) ||
 		   !strcmp(hid, ACPI_BUTTON_HID_SLEEPF)) {
 		button->type = ACPI_BUTTON_TYPE_SLEEP;
 		handler = acpi_button_notify;
-		strscpy(name, ACPI_BUTTON_DEVICE_NAME_SLEEP, MAX_ACPI_DEVICE_NAME_LEN);
+		name = ACPI_BUTTON_DEVICE_NAME_SLEEP;
 		sprintf(class, "%s/%s",
 			ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP);
 	} else if (!strcmp(hid, ACPI_BUTTON_HID_LID)) {
 		button->type = ACPI_BUTTON_TYPE_LID;
 		handler = acpi_lid_notify;
-		strscpy(name, ACPI_BUTTON_DEVICE_NAME_LID, MAX_ACPI_DEVICE_NAME_LEN);
+		name = ACPI_BUTTON_DEVICE_NAME_LID;
 		sprintf(class, "%s/%s",
 			ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID);
 		input->open = acpi_lid_input_open;
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 5f63ed120a2c..4b21279012a7 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -36,7 +36,6 @@
 #include "internal.h"
 
 #define ACPI_EC_CLASS			"embedded_controller"
-#define ACPI_EC_DEVICE_NAME		"Embedded Controller"
 
 /* EC status register */
 #define ACPI_EC_FLAG_OBF	0x01	/* Output buffer full */
@@ -1681,7 +1680,6 @@ static int acpi_ec_probe(struct platform_device *pdev)
 	struct acpi_ec *ec;
 	int ret;
 
-	strscpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
 	strscpy(acpi_device_class(device), ACPI_EC_CLASS);
 
 	if (boot_ec && (boot_ec->handle == device->handle ||
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 45bdfd06bd21..5745de24024c 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -30,7 +30,6 @@
 #include "internal.h"
 
 #define ACPI_PCI_LINK_CLASS		"pci_irq_routing"
-#define ACPI_PCI_LINK_DEVICE_NAME	"PCI Interrupt Link"
 #define ACPI_PCI_LINK_MAX_POSSIBLE	16
 
 static int acpi_pci_link_add(struct acpi_device *device,
@@ -725,7 +724,6 @@ static int acpi_pci_link_add(struct acpi_device *device,
 		return -ENOMEM;
 
 	link->device = device;
-	strscpy(acpi_device_name(device), ACPI_PCI_LINK_DEVICE_NAME);
 	strscpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS);
 	device->driver_data = link;
 
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 4a882e939525..f4aa5b624d9b 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -25,7 +25,6 @@
 #include "internal.h"
 
 #define ACPI_PCI_ROOT_CLASS		"pci_bridge"
-#define ACPI_PCI_ROOT_DEVICE_NAME	"PCI Root Bridge"
 static int acpi_pci_root_add(struct acpi_device *device,
 			     const struct acpi_device_id *not_used);
 static void acpi_pci_root_remove(struct acpi_device *device);
@@ -689,7 +688,6 @@ static int acpi_pci_root_add(struct acpi_device *device,
 
 	root->device = device;
 	root->segment = segment & 0xFFFF;
-	strscpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME);
 	strscpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS);
 	device->driver_data = root;
 
@@ -698,9 +696,8 @@ static int acpi_pci_root_add(struct acpi_device *device,
 		goto end;
 	}
 
-	pr_info("%s [%s] (domain %04x %pR)\n",
-	       acpi_device_name(device), acpi_device_bid(device),
-	       root->segment, &root->secondary);
+	pr_info("PCI Root Bridge [%s] (domain %04x %pR)\n",
+		acpi_device_bid(device), root->segment, &root->secondary);
 
 	root->mcfg_addr = acpi_pci_root_get_mcfg_addr(handle);
 
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 4611159ee734..dcc9ad7790f0 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -38,7 +38,6 @@
 #include "internal.h"
 
 #define ACPI_POWER_CLASS		"power_resource"
-#define ACPI_POWER_DEVICE_NAME		"Power Resource"
 #define ACPI_POWER_RESOURCE_STATE_OFF	0x00
 #define ACPI_POWER_RESOURCE_STATE_ON	0x01
 #define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF
@@ -955,7 +954,6 @@ struct acpi_device *acpi_add_power_resource(acpi_handle handle)
 	mutex_init(&resource->resource_lock);
 	INIT_LIST_HEAD(&resource->list_node);
 	INIT_LIST_HEAD(&resource->dependents);
-	strscpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME);
 	strscpy(acpi_device_class(device), ACPI_POWER_CLASS);
 	device->power.state = ACPI_STATE_UNKNOWN;
 	device->flags.match_driver = true;
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index bbd3938f7b52..7e789290c5ad 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -648,7 +648,6 @@ static int acpi_sbs_probe(struct platform_device *pdev)
 
 	sbs->hc = dev_get_drvdata(pdev->dev.parent);
 	sbs->device = device;
-	strscpy(acpi_device_name(device), ACPI_SBS_DEVICE_NAME);
 	strscpy(acpi_device_class(device), ACPI_SBS_CLASS);
 
 	result = acpi_charger_add(sbs);
diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c
index 36850831910b..97eaa2fc31f2 100644
--- a/drivers/acpi/sbshc.c
+++ b/drivers/acpi/sbshc.c
@@ -19,7 +19,6 @@
 #include "internal.h"
 
 #define ACPI_SMB_HC_CLASS	"smbus_host_ctl"
-#define ACPI_SMB_HC_DEVICE_NAME	"ACPI SMBus HC"
 
 struct acpi_smb_hc {
 	struct acpi_ec *ec;
@@ -251,7 +250,6 @@ static int acpi_smbus_hc_probe(struct platform_device *pdev)
 		return -EIO;
 	}
 
-	strscpy(acpi_device_name(device), ACPI_SMB_HC_DEVICE_NAME);
 	strscpy(acpi_device_class(device), ACPI_SMB_HC_CLASS);
 
 	hc = kzalloc_obj(struct acpi_smb_hc);
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 64356b004a57..6ccb364665d1 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -35,7 +35,6 @@
 #include "internal.h"
 
 #define ACPI_THERMAL_CLASS		"thermal_zone"
-#define ACPI_THERMAL_DEVICE_NAME	"Thermal Zone"
 #define ACPI_THERMAL_NOTIFY_TEMPERATURE	0x80
 #define ACPI_THERMAL_NOTIFY_THRESHOLDS	0x81
 #define ACPI_THERMAL_NOTIFY_DEVICES	0x82
@@ -800,7 +799,6 @@ static int acpi_thermal_probe(struct platform_device *pdev)
 
 	tz->device = device;
 	strscpy(tz->name, device->pnp.bus_id);
-	strscpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME);
 	strscpy(acpi_device_class(device), ACPI_THERMAL_CLASS);
 
 	acpi_thermal_aml_dependency_fix(tz);
@@ -879,8 +877,8 @@ static int acpi_thermal_probe(struct platform_device *pdev)
 	mutex_init(&tz->thermal_check_lock);
 	INIT_WORK(&tz->thermal_check_work, acpi_thermal_check_fn);
 
-	pr_info("%s [%s] (%ld C)\n", acpi_device_name(device),
-		acpi_device_bid(device), deci_kelvin_to_celsius(tz->temp_dk));
+	pr_info("Thermal Zone [%s] (%ld C)\n", acpi_device_bid(device),
+		deci_kelvin_to_celsius(tz->temp_dk));
 
 	result = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY,
 						 acpi_thermal_notify, tz);
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 7146a8e9e9c2..43fe4a85fc0f 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -15,7 +15,6 @@
 #include <asm/acpi.h>
 
 #define ACPI_PROCESSOR_CLASS		"processor"
-#define ACPI_PROCESSOR_DEVICE_NAME	"Processor"
 #define ACPI_PROCESSOR_DEVICE_HID	"ACPI0007"
 #define ACPI_PROCESSOR_CONTAINER_HID	"ACPI0010"
 
-- 
2.51.0





^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v1 6/9] ACPI: event: Redefine acpi_notifier_call_chain()
  2026-03-05 20:09 [PATCH v1 0/9] ACPI: driver: Cleanups and fixes, mostly related to acpi_device_name/class() Rafael J. Wysocki
                   ` (4 preceding siblings ...)
  2026-03-05 20:17 ` [PATCH v1 5/9] ACPI: driver: Do not set acpi_device_name() unnecessarily Rafael J. Wysocki
@ 2026-03-05 20:18 ` Rafael J. Wysocki
  2026-03-05 20:20 ` [PATCH v1 7/9] ACPI: driver: Avoid using pnp.device_class for netlink handling Rafael J. Wysocki
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-03-05 20:18 UTC (permalink / raw)
  To: Linux ACPI; +Cc: LKML, Hans de Goede

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

Notice that acpi_notifier_call_chain() only uses its device argument
to retrieve the pnp.device_class and pnp.bus_id values from there, so
it can be redefined to take pointers to those two strings as parameters
istead of a struct acpi_device pointer.

That allows all of its callers to pass a string literal as its first
argument, so they won't need to initialize pnp.device_class in
struct acpi_device objects operated by them any more, and its
signature becomes more similar to acpi_bus_generate_netlink_event()
then.

Update the code as per the above.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/ac.c         | 3 ++-
 drivers/acpi/acpi_video.c | 9 ++++++---
 drivers/acpi/battery.c    | 3 ++-
 drivers/acpi/event.c      | 7 ++++---
 include/acpi/acpi_bus.h   | 3 ++-
 5 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 4985c8890609..2b500e89169f 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -133,7 +133,8 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
 		acpi_bus_generate_netlink_event(adev->pnp.device_class,
 						  dev_name(&adev->dev), event,
 						  (u32) ac->state);
-		acpi_notifier_call_chain(adev, event, (u32) ac->state);
+		acpi_notifier_call_chain(ACPI_AC_CLASS, acpi_device_bid(adev),
+					 event, ac->state);
 		power_supply_changed(ac->charger);
 	}
 }
diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 4fc2e52401a6..be53afcfb948 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1568,7 +1568,8 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
 		break;
 	}
 
-	if (acpi_notifier_call_chain(device, event, 0))
+	if (acpi_notifier_call_chain(ACPI_VIDEO_CLASS, acpi_device_bid(device),
+				     event, 0))
 		/* Something vetoed the keypress. */
 		keycode = 0;
 
@@ -1609,7 +1610,8 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
 		if (video_device->backlight)
 			backlight_force_update(video_device->backlight,
 					       BACKLIGHT_UPDATE_HOTKEY);
-		acpi_notifier_call_chain(device, event, 0);
+		acpi_notifier_call_chain(ACPI_VIDEO_CLASS, acpi_device_bid(device),
+					 event, 0);
 		return;
 	}
 
@@ -1642,7 +1644,8 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
 	if (keycode)
 		may_report_brightness_keys = true;
 
-	acpi_notifier_call_chain(device, event, 0);
+	acpi_notifier_call_chain(ACPI_VIDEO_CLASS, acpi_device_bid(device),
+				 event, 0);
 
 	if (keycode && (report_key_events & REPORT_BRIGHTNESS_KEY_EVENTS)) {
 		input_report_key(input, keycode, 1);
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index acf5dd2177a1..1bfc4179e885 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -1081,7 +1081,8 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
 	acpi_bus_generate_netlink_event(device->pnp.device_class,
 					dev_name(&device->dev), event,
 					acpi_battery_present(battery));
-	acpi_notifier_call_chain(device, event, acpi_battery_present(battery));
+	acpi_notifier_call_chain(ACPI_BATTERY_CLASS, acpi_device_bid(device),
+				 event, acpi_battery_present(battery));
 	/* acpi_battery_update could remove power_supply object */
 	if (old && battery->bat)
 		power_supply_changed(battery->bat);
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index 96a9aaaaf9f7..4d840d2e7b98 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -24,12 +24,13 @@
 /* ACPI notifier chain */
 static BLOCKING_NOTIFIER_HEAD(acpi_chain_head);
 
-int acpi_notifier_call_chain(struct acpi_device *dev, u32 type, u32 data)
+int acpi_notifier_call_chain(const char *device_class,
+			     const char *bus_id, u32 type, u32 data)
 {
 	struct acpi_bus_event event;
 
-	strscpy(event.device_class, dev->pnp.device_class);
-	strscpy(event.bus_id, dev->pnp.bus_id);
+	strscpy(event.device_class, device_class);
+	strscpy(event.bus_id, bus_id);
 	event.type = type;
 	event.data = data;
 	return (blocking_notifier_call_chain(&acpi_chain_head, 0, (void *)&event)
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index aad1a95e6863..ff14c9362122 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -625,7 +625,8 @@ int acpi_dev_install_notify_handler(struct acpi_device *adev,
 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 acpi_notifier_call_chain(const char *device_class,
+				    const char *bus_id, u32 type, u32 data);
 extern int register_acpi_notifier(struct notifier_block *);
 extern int unregister_acpi_notifier(struct notifier_block *);
 
-- 
2.51.0





^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v1 7/9] ACPI: driver: Avoid using pnp.device_class for netlink handling
  2026-03-05 20:09 [PATCH v1 0/9] ACPI: driver: Cleanups and fixes, mostly related to acpi_device_name/class() Rafael J. Wysocki
                   ` (5 preceding siblings ...)
  2026-03-05 20:18 ` [PATCH v1 6/9] ACPI: event: Redefine acpi_notifier_call_chain() Rafael J. Wysocki
@ 2026-03-05 20:20 ` Rafael J. Wysocki
  2026-03-05 20:21 ` [PATCH v1 8/9] ACPI: driver: Do not set acpi_device_class() unnecessarily Rafael J. Wysocki
  2026-03-05 20:27 ` [PATCH v1 9/9] ACPI: AC: Define ACPI_AC_CLASS in one place Rafael J. Wysocki
  8 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-03-05 20:20 UTC (permalink / raw)
  To: Linux ACPI; +Cc: LKML, Hans de Goede

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Update several core ACPI device drivers that use
acpi_bus_generate_netlink_event() for generating netlink messages to
pass a string literal as its first argument instead of a pointer to
pnp.device_class in a given struct acpi_device, which will allow them
to avoid initializing the pnp.device_class field in the future.

The ACPI button driver that uses different acpi_device_class()
values for different button types will still pass it to
acpi_bus_generate_netlink_event(), but update it to use the
acpi_device_class() macro instead of open coding the pointer
access path.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/ac.c               |    6 +++---
 drivers/acpi/acpi_pad.c         |    4 ++--
 drivers/acpi/battery.c          |    2 +-
 drivers/acpi/button.c           |    2 +-
 drivers/acpi/processor_driver.c |   22 ++++++++--------------
 drivers/acpi/thermal.c          |    6 +++---
 6 files changed, 18 insertions(+), 24 deletions(-)

--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -130,9 +130,9 @@ static void acpi_ac_notify(acpi_handle h
 			msleep(ac_sleep_before_get_state_ms);
 
 		acpi_ac_get_state(ac);
-		acpi_bus_generate_netlink_event(adev->pnp.device_class,
-						  dev_name(&adev->dev), event,
-						  (u32) ac->state);
+		acpi_bus_generate_netlink_event(ACPI_AC_CLASS,
+						dev_name(&adev->dev), event,
+						ac->state);
 		acpi_notifier_call_chain(ACPI_AC_CLASS, acpi_device_bid(adev),
 					 event, ac->state);
 		power_supply_changed(ac->charger);
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -413,8 +413,8 @@ static void acpi_pad_notify(acpi_handle
 	switch (event) {
 	case ACPI_PROCESSOR_AGGREGATOR_NOTIFY:
 		acpi_pad_handle_notify(handle);
-		acpi_bus_generate_netlink_event(adev->pnp.device_class,
-			dev_name(&adev->dev), event, 0);
+		acpi_bus_generate_netlink_event(ACPI_PROCESSOR_AGGREGATOR_CLASS,
+						dev_name(&adev->dev), event, 0);
 		break;
 	default:
 		pr_warn("Unsupported event [0x%x]\n", event);
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -1078,7 +1078,7 @@ static void acpi_battery_notify(acpi_han
 	if (event == ACPI_BATTERY_NOTIFY_INFO)
 		acpi_battery_refresh(battery);
 	acpi_battery_update(battery, false);
-	acpi_bus_generate_netlink_event(device->pnp.device_class,
+	acpi_bus_generate_netlink_event(ACPI_BATTERY_CLASS,
 					dev_name(&device->dev), event,
 					acpi_battery_present(battery));
 	acpi_notifier_call_chain(ACPI_BATTERY_CLASS, acpi_device_bid(device),
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -468,7 +468,7 @@ static void acpi_button_notify(acpi_hand
 	input_report_key(input, keycode, 0);
 	input_sync(input);
 
-	acpi_bus_generate_netlink_event(device->pnp.device_class,
+	acpi_bus_generate_netlink_event(acpi_device_class(device),
 					dev_name(&device->dev),
 					event, ++button->pushed);
 }
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -53,7 +53,7 @@ static void acpi_processor_notify(acpi_h
 {
 	struct acpi_device *device = data;
 	struct acpi_processor *pr;
-	int saved;
+	int saved, ev_data = 0;
 
 	if (device->handle != handle)
 		return;
@@ -66,33 +66,27 @@ static void acpi_processor_notify(acpi_h
 	case ACPI_PROCESSOR_NOTIFY_PERFORMANCE:
 		saved = pr->performance_platform_limit;
 		acpi_processor_ppc_has_changed(pr, 1);
-		if (saved == pr->performance_platform_limit)
-			break;
-		acpi_bus_generate_netlink_event(device->pnp.device_class,
-						  dev_name(&device->dev), event,
-						  pr->performance_platform_limit);
+		ev_data = pr->performance_platform_limit;
+		if (saved == ev_data)
+			return;
+
 		break;
 	case ACPI_PROCESSOR_NOTIFY_POWER:
 		acpi_processor_power_state_has_changed(pr);
-		acpi_bus_generate_netlink_event(device->pnp.device_class,
-						  dev_name(&device->dev), event, 0);
 		break;
 	case ACPI_PROCESSOR_NOTIFY_THROTTLING:
 		acpi_processor_tstate_has_changed(pr);
-		acpi_bus_generate_netlink_event(device->pnp.device_class,
-						  dev_name(&device->dev), event, 0);
 		break;
 	case ACPI_PROCESSOR_NOTIFY_HIGEST_PERF_CHANGED:
 		cpufreq_update_limits(pr->id);
-		acpi_bus_generate_netlink_event(device->pnp.device_class,
-						  dev_name(&device->dev), event, 0);
 		break;
 	default:
 		acpi_handle_debug(handle, "Unsupported event [0x%x]\n", event);
-		break;
+		return;
 	}
 
-	return;
+	acpi_bus_generate_netlink_event(ACPI_PROCESSOR_CLASS,
+					dev_name(&device->dev), event, ev_data);
 }
 
 static int __acpi_processor_start(struct acpi_device *device);
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -340,7 +340,7 @@ static void acpi_thermal_trips_update(st
 	thermal_zone_for_each_trip(tz->thermal_zone,
 				   acpi_thermal_adjust_trip, &atd);
 	acpi_queue_thermal_check(tz);
-	acpi_bus_generate_netlink_event(adev->pnp.device_class,
+	acpi_bus_generate_netlink_event(ACPI_THERMAL_CLASS,
 					dev_name(&adev->dev), event, 0);
 }
 
@@ -542,7 +542,7 @@ static void acpi_thermal_zone_device_hot
 {
 	struct acpi_thermal *tz = thermal_zone_device_priv(thermal);
 
-	acpi_bus_generate_netlink_event(tz->device->pnp.device_class,
+	acpi_bus_generate_netlink_event(ACPI_THERMAL_CLASS,
 					dev_name(&tz->device->dev),
 					ACPI_THERMAL_NOTIFY_HOT, 1);
 }
@@ -551,7 +551,7 @@ static void acpi_thermal_zone_device_cri
 {
 	struct acpi_thermal *tz = thermal_zone_device_priv(thermal);
 
-	acpi_bus_generate_netlink_event(tz->device->pnp.device_class,
+	acpi_bus_generate_netlink_event(ACPI_THERMAL_CLASS,
 					dev_name(&tz->device->dev),
 					ACPI_THERMAL_NOTIFY_CRITICAL, 1);
 




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v1 8/9] ACPI: driver: Do not set acpi_device_class() unnecessarily
  2026-03-05 20:09 [PATCH v1 0/9] ACPI: driver: Cleanups and fixes, mostly related to acpi_device_name/class() Rafael J. Wysocki
                   ` (6 preceding siblings ...)
  2026-03-05 20:20 ` [PATCH v1 7/9] ACPI: driver: Avoid using pnp.device_class for netlink handling Rafael J. Wysocki
@ 2026-03-05 20:21 ` Rafael J. Wysocki
  2026-03-05 20:27 ` [PATCH v1 9/9] ACPI: AC: Define ACPI_AC_CLASS in one place Rafael J. Wysocki
  8 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-03-05 20:21 UTC (permalink / raw)
  To: Linux ACPI; +Cc: LKML, Hans de Goede

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Several core ACPI device drivers set acpi_device_class() for the given
struct acpi_device to whatever they like, but that value is never used
unless the driver itself uses it and, sadly, they neglect to clear it on
remove.  Since the only one of them still using acpi_device_class()
after previous changes is the button driver, update the others to stop
setting it in vain.  Also drop the related device class sybmols that
become redundant.

Since the ACPI button driver continues to use acpi_device_class(), make
it clear the struct field represented by acpi_device_class() in its
remove callback.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/ac.c               |    1 -
 drivers/acpi/acpi_memhotplug.c  |    2 --
 drivers/acpi/acpi_pad.c         |    5 +----
 drivers/acpi/acpi_processor.c   |    1 -
 drivers/acpi/acpi_video.c       |    3 ---
 drivers/acpi/battery.c          |    1 -
 drivers/acpi/button.c           |    2 ++
 drivers/acpi/ec.c               |    4 ----
 drivers/acpi/pci_link.c         |    2 --
 drivers/acpi/pci_root.c         |    2 --
 drivers/acpi/power.c            |    2 --
 drivers/acpi/processor_driver.c |    4 ++--
 drivers/acpi/sbs.c              |    2 --
 drivers/acpi/sbshc.c            |    4 ----
 drivers/acpi/thermal.c          |    1 -
 include/acpi/processor.h        |    1 -
 16 files changed, 5 insertions(+), 32 deletions(-)

--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -203,7 +203,6 @@ static int acpi_ac_probe(struct platform
 		return -ENOMEM;
 
 	ac->device = adev;
-	strscpy(acpi_device_class(adev), ACPI_AC_CLASS);
 
 	platform_set_drvdata(pdev, ac);
 
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -18,7 +18,6 @@
 
 #include "internal.h"
 
-#define ACPI_MEMORY_DEVICE_CLASS		"memory"
 #define ACPI_MEMORY_DEVICE_HID			"PNP0C80"
 
 static const struct acpi_device_id memory_device_ids[] = {
@@ -296,7 +295,6 @@ static int acpi_memory_device_add(struct
 	INIT_LIST_HEAD(&mem_device->res_list);
 	mem_device->device = device;
 	mem_device->mgid = -1;
-	sprintf(acpi_device_class(device), "%s", ACPI_MEMORY_DEVICE_CLASS);
 	device->driver_data = mem_device;
 
 	/* Get the range from the _CRS */
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -23,7 +23,6 @@
 #include <asm/mwait.h>
 #include <xen/xen.h>
 
-#define ACPI_PROCESSOR_AGGREGATOR_CLASS	"acpi_pad"
 #define ACPI_PROCESSOR_AGGREGATOR_NOTIFY 0x80
 
 #define ACPI_PROCESSOR_AGGREGATOR_STATUS_SUCCESS	0
@@ -413,7 +412,7 @@ static void acpi_pad_notify(acpi_handle
 	switch (event) {
 	case ACPI_PROCESSOR_AGGREGATOR_NOTIFY:
 		acpi_pad_handle_notify(handle);
-		acpi_bus_generate_netlink_event(ACPI_PROCESSOR_AGGREGATOR_CLASS,
+		acpi_bus_generate_netlink_event("acpi_pad",
 						dev_name(&adev->dev), event, 0);
 		break;
 	default:
@@ -426,8 +425,6 @@ static int acpi_pad_probe(struct platfor
 {
 	struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
 
-	strscpy(acpi_device_class(adev), ACPI_PROCESSOR_AGGREGATOR_CLASS);
-
 	return acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
 					       acpi_pad_notify, adev);
 }
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -438,7 +438,6 @@ static int acpi_processor_add(struct acp
 	}
 
 	pr->handle = device->handle;
-	strscpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
 	device->driver_data = pr;
 
 	result = acpi_processor_get_info(device);
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1143,8 +1143,6 @@ static int acpi_video_bus_get_one_device
 		return -ENOMEM;
 	}
 
-	strscpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
-
 	data->device_id = device_id;
 	data->video = video;
 	data->dev = device;
@@ -2020,7 +2018,6 @@ static int acpi_video_bus_probe(struct p
 	platform_set_drvdata(pdev, video);
 
 	video->device = device;
-	strscpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
 	device->driver_data = video;
 
 	acpi_video_bus_find_cap(video);
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -1228,7 +1228,6 @@ static int acpi_battery_probe(struct pla
 	platform_set_drvdata(pdev, battery);
 
 	battery->device = device;
-	strscpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
 
 	result = devm_mutex_init(&pdev->dev, &battery->update_lock);
 	if (result)
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -697,6 +697,8 @@ static void acpi_button_remove(struct pl
 	acpi_button_remove_fs(button);
 	input_unregister_device(button->input);
 	kfree(button);
+
+	memset(acpi_device_class(adev), 0, sizeof(acpi_device_class));
 }
 
 static int param_set_lid_init_state(const char *val,
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -35,8 +35,6 @@
 
 #include "internal.h"
 
-#define ACPI_EC_CLASS			"embedded_controller"
-
 /* EC status register */
 #define ACPI_EC_FLAG_OBF	0x01	/* Output buffer full */
 #define ACPI_EC_FLAG_IBF	0x02	/* Input buffer full */
@@ -1680,8 +1678,6 @@ static int acpi_ec_probe(struct platform
 	struct acpi_ec *ec;
 	int ret;
 
-	strscpy(acpi_device_class(device), ACPI_EC_CLASS);
-
 	if (boot_ec && (boot_ec->handle == device->handle ||
 	    !strcmp(acpi_device_hid(device), ACPI_ECDT_HID))) {
 		/* Fast path: this device corresponds to the boot EC. */
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -29,7 +29,6 @@
 
 #include "internal.h"
 
-#define ACPI_PCI_LINK_CLASS		"pci_irq_routing"
 #define ACPI_PCI_LINK_MAX_POSSIBLE	16
 
 static int acpi_pci_link_add(struct acpi_device *device,
@@ -724,7 +723,6 @@ static int acpi_pci_link_add(struct acpi
 		return -ENOMEM;
 
 	link->device = device;
-	strscpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS);
 	device->driver_data = link;
 
 	mutex_lock(&acpi_link_lock);
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -24,7 +24,6 @@
 #include <linux/platform_data/x86/apple.h>
 #include "internal.h"
 
-#define ACPI_PCI_ROOT_CLASS		"pci_bridge"
 static int acpi_pci_root_add(struct acpi_device *device,
 			     const struct acpi_device_id *not_used);
 static void acpi_pci_root_remove(struct acpi_device *device);
@@ -688,7 +687,6 @@ static int acpi_pci_root_add(struct acpi
 
 	root->device = device;
 	root->segment = segment & 0xFFFF;
-	strscpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS);
 	device->driver_data = root;
 
 	if (hotadd && dmar_device_add(handle)) {
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -37,7 +37,6 @@
 #include "sleep.h"
 #include "internal.h"
 
-#define ACPI_POWER_CLASS		"power_resource"
 #define ACPI_POWER_RESOURCE_STATE_OFF	0x00
 #define ACPI_POWER_RESOURCE_STATE_ON	0x01
 #define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF
@@ -954,7 +953,6 @@ struct acpi_device *acpi_add_power_resou
 	mutex_init(&resource->resource_lock);
 	INIT_LIST_HEAD(&resource->list_node);
 	INIT_LIST_HEAD(&resource->dependents);
-	strscpy(acpi_device_class(device), ACPI_POWER_CLASS);
 	device->power.state = ACPI_STATE_UNKNOWN;
 	device->flags.match_driver = true;
 
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -85,8 +85,8 @@ static void acpi_processor_notify(acpi_h
 		return;
 	}
 
-	acpi_bus_generate_netlink_event(ACPI_PROCESSOR_CLASS,
-					dev_name(&device->dev), event, ev_data);
+	acpi_bus_generate_netlink_event("processor", dev_name(&device->dev),
+					event, ev_data);
 }
 
 static int __acpi_processor_start(struct acpi_device *device);
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -26,7 +26,6 @@
 
 #include "sbshc.h"
 
-#define ACPI_SBS_CLASS			"sbs"
 #define ACPI_AC_CLASS			"ac_adapter"
 #define ACPI_SBS_DEVICE_NAME		"Smart Battery System"
 #define ACPI_BATTERY_DIR_NAME		"BAT%i"
@@ -648,7 +647,6 @@ static int acpi_sbs_probe(struct platfor
 
 	sbs->hc = dev_get_drvdata(pdev->dev.parent);
 	sbs->device = device;
-	strscpy(acpi_device_class(device), ACPI_SBS_CLASS);
 
 	result = acpi_charger_add(sbs);
 	if (result && result != -ENODEV)
--- a/drivers/acpi/sbshc.c
+++ b/drivers/acpi/sbshc.c
@@ -18,8 +18,6 @@
 #include "sbshc.h"
 #include "internal.h"
 
-#define ACPI_SMB_HC_CLASS	"smbus_host_ctl"
-
 struct acpi_smb_hc {
 	struct acpi_ec *ec;
 	struct mutex lock;
@@ -250,8 +248,6 @@ static int acpi_smbus_hc_probe(struct pl
 		return -EIO;
 	}
 
-	strscpy(acpi_device_class(device), ACPI_SMB_HC_CLASS);
-
 	hc = kzalloc_obj(struct acpi_smb_hc);
 	if (!hc)
 		return -ENOMEM;
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -799,7 +799,6 @@ static int acpi_thermal_probe(struct pla
 
 	tz->device = device;
 	strscpy(tz->name, device->pnp.bus_id);
-	strscpy(acpi_device_class(device), ACPI_THERMAL_CLASS);
 
 	acpi_thermal_aml_dependency_fix(tz);
 
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -14,7 +14,6 @@
 
 #include <asm/acpi.h>
 
-#define ACPI_PROCESSOR_CLASS		"processor"
 #define ACPI_PROCESSOR_DEVICE_HID	"ACPI0007"
 #define ACPI_PROCESSOR_CONTAINER_HID	"ACPI0010"
 




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v1 9/9] ACPI: AC: Define ACPI_AC_CLASS in one place
  2026-03-05 20:09 [PATCH v1 0/9] ACPI: driver: Cleanups and fixes, mostly related to acpi_device_name/class() Rafael J. Wysocki
                   ` (7 preceding siblings ...)
  2026-03-05 20:21 ` [PATCH v1 8/9] ACPI: driver: Do not set acpi_device_class() unnecessarily Rafael J. Wysocki
@ 2026-03-05 20:27 ` Rafael J. Wysocki
  2026-03-06 12:44   ` Ilpo Järvinen
  8 siblings, 1 reply; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-03-05 20:27 UTC (permalink / raw)
  To: Linux ACPI
  Cc: LKML, Hans de Goede, Ilpo Järvinen, platform-driver-x86,
	amd-gfx, Alex Deucher, Christian König

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

The ACPI_AC_CLASS symbol is defined in several places in the same way
which is rather unfortunate.

Instead, define it in one common header file (acpi_bus.h) that is
already included by all of its users.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/ac.c                         |    1 -
 drivers/acpi/sbs.c                        |    1 -
 drivers/gpu/drm/amd/include/amd_acpi.h    |    2 --
 drivers/gpu/drm/radeon/radeon_acpi.c      |    2 --
 drivers/platform/x86/hp/hp-wmi.c          |    2 --
 drivers/platform/x86/lenovo/wmi-capdata.c |    1 -
 include/acpi/acpi_bus.h                   |    2 ++
 7 files changed, 2 insertions(+), 9 deletions(-)

--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -21,7 +21,6 @@
 #include <linux/acpi.h>
 #include <acpi/battery.h>
 
-#define ACPI_AC_CLASS			"ac_adapter"
 #define ACPI_AC_FILE_STATE		"state"
 #define ACPI_AC_NOTIFY_STATUS		0x80
 #define ACPI_AC_STATUS_OFFLINE		0x00
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -26,7 +26,6 @@
 
 #include "sbshc.h"
 
-#define ACPI_AC_CLASS			"ac_adapter"
 #define ACPI_SBS_DEVICE_NAME		"Smart Battery System"
 #define ACPI_BATTERY_DIR_NAME		"BAT%i"
 #define ACPI_AC_DIR_NAME		"AC0"
--- a/drivers/gpu/drm/amd/include/amd_acpi.h
+++ b/drivers/gpu/drm/amd/include/amd_acpi.h
@@ -26,8 +26,6 @@
 
 #include <linux/types.h>
 
-#define ACPI_AC_CLASS           "ac_adapter"
-
 struct atif_verify_interface {
 	u16 size;		/* structure size in bytes (includes size field) */
 	u16 version;		/* version */
--- a/drivers/gpu/drm/radeon/radeon_acpi.c
+++ b/drivers/gpu/drm/radeon/radeon_acpi.c
@@ -44,8 +44,6 @@ bool radeon_atpx_dgpu_req_power_for_disp
 static inline bool radeon_atpx_dgpu_req_power_for_displays(void) { return false; }
 #endif
 
-#define ACPI_AC_CLASS           "ac_adapter"
-
 struct atif_verify_interface {
 	u16 size;		/* structure size in bytes (includes size field) */
 	u16 version;		/* version */
--- a/drivers/platform/x86/hp/hp-wmi.c
+++ b/drivers/platform/x86/hp/hp-wmi.c
@@ -58,8 +58,6 @@ enum hp_ec_offsets {
 #define HP_POWER_LIMIT_DEFAULT	 0x00
 #define HP_POWER_LIMIT_NO_CHANGE 0xFF
 
-#define ACPI_AC_CLASS "ac_adapter"
-
 #define zero_if_sup(tmp) (zero_insize_support?0:sizeof(tmp)) // use when zero insize is required
 
 enum hp_thermal_profile_omen_v0 {
--- a/drivers/platform/x86/lenovo/wmi-capdata.c
+++ b/drivers/platform/x86/lenovo/wmi-capdata.c
@@ -53,7 +53,6 @@
 #define LENOVO_CAPABILITY_DATA_01_GUID "7A8F5407-CB67-4D6E-B547-39B3BE018154"
 #define LENOVO_FAN_TEST_DATA_GUID "B642801B-3D21-45DE-90AE-6E86F164FB21"
 
-#define ACPI_AC_CLASS "ac_adapter"
 #define ACPI_AC_NOTIFY_STATUS 0x80
 
 #define LWMI_FEATURE_ID_FAN_TEST 0x05
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -613,6 +613,8 @@ struct acpi_bus_event {
 	u32 data;
 };
 
+#define ACPI_AC_CLASS	"ac_adapter"
+
 extern struct kobject *acpi_kobj;
 extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int);
 void acpi_bus_private_data_handler(acpi_handle, void *);




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v1 9/9] ACPI: AC: Define ACPI_AC_CLASS in one place
  2026-03-05 20:27 ` [PATCH v1 9/9] ACPI: AC: Define ACPI_AC_CLASS in one place Rafael J. Wysocki
@ 2026-03-06 12:44   ` Ilpo Järvinen
  2026-03-06 12:49     ` Rafael J. Wysocki
  0 siblings, 1 reply; 12+ messages in thread
From: Ilpo Järvinen @ 2026-03-06 12:44 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Linux ACPI, LKML, Hans de Goede, platform-driver-x86, amd-gfx,
	Alex Deucher, Christian König

[-- Attachment #1: Type: text/plain, Size: 3673 bytes --]

On Thu, 5 Mar 2026, Rafael J. Wysocki wrote:

> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> The ACPI_AC_CLASS symbol is defined in several places in the same way
> which is rather unfortunate.
> 
> Instead, define it in one common header file (acpi_bus.h) that is
> already included by all of its users.

It's a bit misleading to say it like that as acpi_bus.h is included only 
through another include (at least acpi/acpi.h) for most of the 
cases.

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

-- 
 i.

> No intentional functional impact.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>  drivers/acpi/ac.c                         |    1 -
>  drivers/acpi/sbs.c                        |    1 -
>  drivers/gpu/drm/amd/include/amd_acpi.h    |    2 --
>  drivers/gpu/drm/radeon/radeon_acpi.c      |    2 --
>  drivers/platform/x86/hp/hp-wmi.c          |    2 --
>  drivers/platform/x86/lenovo/wmi-capdata.c |    1 -
>  include/acpi/acpi_bus.h                   |    2 ++
>  7 files changed, 2 insertions(+), 9 deletions(-)
> 
> --- a/drivers/acpi/ac.c
> +++ b/drivers/acpi/ac.c
> @@ -21,7 +21,6 @@
>  #include <linux/acpi.h>
>  #include <acpi/battery.h>
>  
> -#define ACPI_AC_CLASS			"ac_adapter"
>  #define ACPI_AC_FILE_STATE		"state"
>  #define ACPI_AC_NOTIFY_STATUS		0x80
>  #define ACPI_AC_STATUS_OFFLINE		0x00
> --- a/drivers/acpi/sbs.c
> +++ b/drivers/acpi/sbs.c
> @@ -26,7 +26,6 @@
>  
>  #include "sbshc.h"
>  
> -#define ACPI_AC_CLASS			"ac_adapter"
>  #define ACPI_SBS_DEVICE_NAME		"Smart Battery System"
>  #define ACPI_BATTERY_DIR_NAME		"BAT%i"
>  #define ACPI_AC_DIR_NAME		"AC0"
> --- a/drivers/gpu/drm/amd/include/amd_acpi.h
> +++ b/drivers/gpu/drm/amd/include/amd_acpi.h
> @@ -26,8 +26,6 @@
>  
>  #include <linux/types.h>
>  
> -#define ACPI_AC_CLASS           "ac_adapter"
> -
>  struct atif_verify_interface {
>  	u16 size;		/* structure size in bytes (includes size field) */
>  	u16 version;		/* version */
> --- a/drivers/gpu/drm/radeon/radeon_acpi.c
> +++ b/drivers/gpu/drm/radeon/radeon_acpi.c
> @@ -44,8 +44,6 @@ bool radeon_atpx_dgpu_req_power_for_disp
>  static inline bool radeon_atpx_dgpu_req_power_for_displays(void) { return false; }
>  #endif
>  
> -#define ACPI_AC_CLASS           "ac_adapter"
> -
>  struct atif_verify_interface {
>  	u16 size;		/* structure size in bytes (includes size field) */
>  	u16 version;		/* version */
> --- a/drivers/platform/x86/hp/hp-wmi.c
> +++ b/drivers/platform/x86/hp/hp-wmi.c
> @@ -58,8 +58,6 @@ enum hp_ec_offsets {
>  #define HP_POWER_LIMIT_DEFAULT	 0x00
>  #define HP_POWER_LIMIT_NO_CHANGE 0xFF
>  
> -#define ACPI_AC_CLASS "ac_adapter"
> -
>  #define zero_if_sup(tmp) (zero_insize_support?0:sizeof(tmp)) // use when zero insize is required
>  
>  enum hp_thermal_profile_omen_v0 {
> --- a/drivers/platform/x86/lenovo/wmi-capdata.c
> +++ b/drivers/platform/x86/lenovo/wmi-capdata.c
> @@ -53,7 +53,6 @@
>  #define LENOVO_CAPABILITY_DATA_01_GUID "7A8F5407-CB67-4D6E-B547-39B3BE018154"
>  #define LENOVO_FAN_TEST_DATA_GUID "B642801B-3D21-45DE-90AE-6E86F164FB21"
>  
> -#define ACPI_AC_CLASS "ac_adapter"
>  #define ACPI_AC_NOTIFY_STATUS 0x80
>  
>  #define LWMI_FEATURE_ID_FAN_TEST 0x05
> --- a/include/acpi/acpi_bus.h
> +++ b/include/acpi/acpi_bus.h
> @@ -613,6 +613,8 @@ struct acpi_bus_event {
>  	u32 data;
>  };
>  
> +#define ACPI_AC_CLASS	"ac_adapter"
> +
>  extern struct kobject *acpi_kobj;
>  extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int);
>  void acpi_bus_private_data_handler(acpi_handle, void *);

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v1 9/9] ACPI: AC: Define ACPI_AC_CLASS in one place
  2026-03-06 12:44   ` Ilpo Järvinen
@ 2026-03-06 12:49     ` Rafael J. Wysocki
  0 siblings, 0 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2026-03-06 12:49 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Rafael J. Wysocki, Linux ACPI, LKML, Hans de Goede,
	platform-driver-x86, amd-gfx, Alex Deucher, Christian König

On Fri, Mar 6, 2026 at 1:44 PM Ilpo Järvinen
<ilpo.jarvinen@linux.intel.com> wrote:
>
> On Thu, 5 Mar 2026, Rafael J. Wysocki wrote:
>
> > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> >
> > The ACPI_AC_CLASS symbol is defined in several places in the same way
> > which is rather unfortunate.
> >
> > Instead, define it in one common header file (acpi_bus.h) that is
> > already included by all of its users.
>
> It's a bit misleading to say it like that as acpi_bus.h is included only
> through another include (at least acpi/acpi.h) for most of the
> cases.

Well, I've cut a corner here. :-)

I can say "that will cause it to be accessible to all of its users" instead.

> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Thanks!

> --
>  i.
>
> > No intentional functional impact.
> >
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > ---
> >  drivers/acpi/ac.c                         |    1 -
> >  drivers/acpi/sbs.c                        |    1 -
> >  drivers/gpu/drm/amd/include/amd_acpi.h    |    2 --
> >  drivers/gpu/drm/radeon/radeon_acpi.c      |    2 --
> >  drivers/platform/x86/hp/hp-wmi.c          |    2 --
> >  drivers/platform/x86/lenovo/wmi-capdata.c |    1 -
> >  include/acpi/acpi_bus.h                   |    2 ++
> >  7 files changed, 2 insertions(+), 9 deletions(-)
> >
> > --- a/drivers/acpi/ac.c
> > +++ b/drivers/acpi/ac.c
> > @@ -21,7 +21,6 @@
> >  #include <linux/acpi.h>
> >  #include <acpi/battery.h>
> >
> > -#define ACPI_AC_CLASS                        "ac_adapter"
> >  #define ACPI_AC_FILE_STATE           "state"
> >  #define ACPI_AC_NOTIFY_STATUS                0x80
> >  #define ACPI_AC_STATUS_OFFLINE               0x00
> > --- a/drivers/acpi/sbs.c
> > +++ b/drivers/acpi/sbs.c
> > @@ -26,7 +26,6 @@
> >
> >  #include "sbshc.h"
> >
> > -#define ACPI_AC_CLASS                        "ac_adapter"
> >  #define ACPI_SBS_DEVICE_NAME         "Smart Battery System"
> >  #define ACPI_BATTERY_DIR_NAME                "BAT%i"
> >  #define ACPI_AC_DIR_NAME             "AC0"
> > --- a/drivers/gpu/drm/amd/include/amd_acpi.h
> > +++ b/drivers/gpu/drm/amd/include/amd_acpi.h
> > @@ -26,8 +26,6 @@
> >
> >  #include <linux/types.h>
> >
> > -#define ACPI_AC_CLASS           "ac_adapter"
> > -
> >  struct atif_verify_interface {
> >       u16 size;               /* structure size in bytes (includes size field) */
> >       u16 version;            /* version */
> > --- a/drivers/gpu/drm/radeon/radeon_acpi.c
> > +++ b/drivers/gpu/drm/radeon/radeon_acpi.c
> > @@ -44,8 +44,6 @@ bool radeon_atpx_dgpu_req_power_for_disp
> >  static inline bool radeon_atpx_dgpu_req_power_for_displays(void) { return false; }
> >  #endif
> >
> > -#define ACPI_AC_CLASS           "ac_adapter"
> > -
> >  struct atif_verify_interface {
> >       u16 size;               /* structure size in bytes (includes size field) */
> >       u16 version;            /* version */
> > --- a/drivers/platform/x86/hp/hp-wmi.c
> > +++ b/drivers/platform/x86/hp/hp-wmi.c
> > @@ -58,8 +58,6 @@ enum hp_ec_offsets {
> >  #define HP_POWER_LIMIT_DEFAULT        0x00
> >  #define HP_POWER_LIMIT_NO_CHANGE 0xFF
> >
> > -#define ACPI_AC_CLASS "ac_adapter"
> > -
> >  #define zero_if_sup(tmp) (zero_insize_support?0:sizeof(tmp)) // use when zero insize is required
> >
> >  enum hp_thermal_profile_omen_v0 {
> > --- a/drivers/platform/x86/lenovo/wmi-capdata.c
> > +++ b/drivers/platform/x86/lenovo/wmi-capdata.c
> > @@ -53,7 +53,6 @@
> >  #define LENOVO_CAPABILITY_DATA_01_GUID "7A8F5407-CB67-4D6E-B547-39B3BE018154"
> >  #define LENOVO_FAN_TEST_DATA_GUID "B642801B-3D21-45DE-90AE-6E86F164FB21"
> >
> > -#define ACPI_AC_CLASS "ac_adapter"
> >  #define ACPI_AC_NOTIFY_STATUS 0x80
> >
> >  #define LWMI_FEATURE_ID_FAN_TEST 0x05
> > --- a/include/acpi/acpi_bus.h
> > +++ b/include/acpi/acpi_bus.h
> > @@ -613,6 +613,8 @@ struct acpi_bus_event {
> >       u32 data;
> >  };
> >
> > +#define ACPI_AC_CLASS        "ac_adapter"
> > +
> >  extern struct kobject *acpi_kobj;
> >  extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int);
> >  void acpi_bus_private_data_handler(acpi_handle, void *);

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-03-06 12:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05 20:09 [PATCH v1 0/9] ACPI: driver: Cleanups and fixes, mostly related to acpi_device_name/class() Rafael J. Wysocki
2026-03-05 20:10 ` [PATCH v1 1/9] ACPI: AC: Get rid of unnecessary declarations Rafael J. Wysocki
2026-03-05 20:11 ` [PATCH v1 2/9] ACPI: PAD: Rearrange notify handler installation and removal Rafael J. Wysocki
2026-03-05 20:12 ` [PATCH v1 3/9] ACPI: video: Consolidate pnp.bus_id workarounds handling Rafael J. Wysocki
2026-03-05 20:16 ` [PATCH v1 4/9] ACPI: video: Rework checking for duplicate video bus devices Rafael J. Wysocki
2026-03-05 20:17 ` [PATCH v1 5/9] ACPI: driver: Do not set acpi_device_name() unnecessarily Rafael J. Wysocki
2026-03-05 20:18 ` [PATCH v1 6/9] ACPI: event: Redefine acpi_notifier_call_chain() Rafael J. Wysocki
2026-03-05 20:20 ` [PATCH v1 7/9] ACPI: driver: Avoid using pnp.device_class for netlink handling Rafael J. Wysocki
2026-03-05 20:21 ` [PATCH v1 8/9] ACPI: driver: Do not set acpi_device_class() unnecessarily Rafael J. Wysocki
2026-03-05 20:27 ` [PATCH v1 9/9] ACPI: AC: Define ACPI_AC_CLASS in one place Rafael J. Wysocki
2026-03-06 12:44   ` Ilpo Järvinen
2026-03-06 12:49     ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox