]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ACPI: driver: Do not set acpi_device_class() unnecessarily
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 13 Mar 2026 13:00:41 +0000 (14:00 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 13 Mar 2026 15:48:26 +0000 (16:48 +0100)
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>
Link: https://patch.msgid.link/3706295.iIbC2pHGDl@rafael.j.wysocki
16 files changed:
drivers/acpi/ac.c
drivers/acpi/acpi_memhotplug.c
drivers/acpi/acpi_pad.c
drivers/acpi/acpi_processor.c
drivers/acpi/acpi_video.c
drivers/acpi/battery.c
drivers/acpi/button.c
drivers/acpi/ec.c
drivers/acpi/pci_link.c
drivers/acpi/pci_root.c
drivers/acpi/power.c
drivers/acpi/processor_driver.c
drivers/acpi/sbs.c
drivers/acpi/sbshc.c
drivers/acpi/thermal.c
include/acpi/processor.h

index 41a085562c639e48b3e908694522a95fec4a2955..2825db974bd8b062b5086cff3d9629155176ad81 100644 (file)
@@ -203,7 +203,6 @@ static int acpi_ac_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        ac->device = adev;
-       strscpy(acpi_device_class(adev), ACPI_AC_CLASS);
 
        platform_set_drvdata(pdev, ac);
 
index 7f021e6d8b0e8c2671287bd2916d205609525cd9..1d7dfe4ee9a6160c4338d91cb054216095be5c0a 100644 (file)
@@ -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 acpi_device *device,
        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 */
index b46c4dd65fbe17e1c2330cd5dbab1d768a70222c..0a8e02bc8c8b6a7eed537ade1af73e6eaeab2c78 100644 (file)
@@ -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 handle, u32 event, void *data)
        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 platform_device *pdev)
 {
        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);
 }
index 46020a49a7edbd3df3f71ab543b3d4718ad4e517..2ac76f3b1cfd3bbc0db195e250e4e21d468522c5 100644 (file)
@@ -438,7 +438,6 @@ static int acpi_processor_add(struct acpi_device *device,
        }
 
        pr->handle = device->handle;
-       strscpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
        device->driver_data = pr;
 
        result = acpi_processor_get_info(device);
index c747827653d96888a889550b0502fe2d013effd0..05793ddef7875f6ecc0bd6253a8d8338565d57a2 100644 (file)
@@ -1141,8 +1141,6 @@ static int acpi_video_bus_get_one_device(struct acpi_device *device, void *arg)
                return -ENOMEM;
        }
 
-       strscpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
-
        data->device_id = device_id;
        data->video = video;
        data->dev = device;
@@ -2018,7 +2016,6 @@ static int acpi_video_bus_probe(struct auxiliary_device *aux_dev,
        auxiliary_set_drvdata(aux_dev, video);
 
        video->device = device;
-       strscpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
        device->driver_data = video;
 
        acpi_video_bus_find_cap(video);
index 54048438b5da7c5f174b20051e15af5d938fe97b..b4c25474f42f4d2cd516b8dafe3c5a5e2793c454 100644 (file)
@@ -1228,7 +1228,6 @@ static int acpi_battery_probe(struct platform_device *pdev)
        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)
index cc17d9d843ec58cf169696b386c7d2efa87ce5e6..dc064a388c23ea9123038bb25515bd3c2a77e0c7 100644 (file)
@@ -697,6 +697,8 @@ static void acpi_button_remove(struct platform_device *pdev)
        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,
index 4b21279012a7c81f26fc05e80ea9e4d838c75f3d..0624d86736793a4d17ddaab2077748a42882fa8b 100644 (file)
@@ -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_device *pdev)
        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. */
index 5745de24024c30d3f6e2623f74d6d4ba6b43dc69..e6ed13aee48d0cd2e82286e20fb72de5c7720bab 100644 (file)
@@ -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_device *device,
                return -ENOMEM;
 
        link->device = device;
-       strscpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS);
        device->driver_data = link;
 
        mutex_lock(&acpi_link_lock);
index f4aa5b624d9b072ff899882a49c5a2d825be04c3..a0ba64e45e8ab3633cc8a98e43c32cc9139dca76 100644 (file)
@@ -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_device *device,
 
        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)) {
index dcc9ad7790f0e958731c32afe648d3178bb96c21..6b1680ec369435fdc028652f0da32a6f7d01990e 100644 (file)
@@ -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_resource(acpi_handle handle)
        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;
 
index bbe2c5afb8baf0261c799c1e5579aacf9909124f..cda8fd7200004fb74f7b5628a6303ec1ee2d5cb8 100644 (file)
@@ -85,8 +85,8 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
                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);
index 7e789290c5ad70d27fc8a028dd29babf47748dba..e301d73ac420077aa91639632ec169c4ede2f534 100644 (file)
@@ -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 platform_device *pdev)
 
        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)
index 97eaa2fc31f22dbb7819dfc989305dffcc16364d..f413270415b687e00add06cef1cb627a63f89bb3 100644 (file)
@@ -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 platform_device *pdev)
                return -EIO;
        }
 
-       strscpy(acpi_device_class(device), ACPI_SMB_HC_CLASS);
-
        hc = kzalloc_obj(struct acpi_smb_hc);
        if (!hc)
                return -ENOMEM;
index e764641a43c1a37ece9765054ab7aa7e94198717..b8b487d89d25b128cf422e896d99dccae2bb8c5d 100644 (file)
@@ -799,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_class(device), ACPI_THERMAL_CLASS);
 
        acpi_thermal_aml_dependency_fix(tz);
 
index 43fe4a85fc0f2d845bd6e0bd9a59c82f4da59ece..554be224ce7666a842fb362faffd20905b3935fb 100644 (file)
@@ -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"