]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ACPI: driver: Do not set acpi_device_name() unnecessarily
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 13 Mar 2026 12:58:30 +0000 (13:58 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 13 Mar 2026 15:48:23 +0000 (16:48 +0100)
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>
Link: https://patch.msgid.link/10840483.nUPlyArG6x@rafael.j.wysocki
15 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/sbs.c
drivers/acpi/sbshc.c
drivers/acpi/thermal.c
include/acpi/processor.h

index e0560a2c71a0bf65c89b719be12c3e929ad78c5b..4985c88906096e8384fd89b82513a27b7c614bbc 100644 (file)
@@ -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);
index 02a472fa85fc3531ca1ffd4cd141f43c32732e6b..7f021e6d8b0e8c2671287bd2916d205609525cd9 100644 (file)
@@ -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;
 
index 407a0d68525c9196f36f9a7ae4e2a1dc798e4930..1f735f77fd1a4b9c57be5aa74b08250d71ea1b21 100644 (file)
@@ -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,
index b34a48068a8d125d29c2c61a490670ab94c3bc68..46020a49a7edbd3df3f71ab543b3d4718ad4e517 100644 (file)
@@ -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;
 
index f48bc7817417ee998e896f8ea35805d79cc19273..30822d46a71ea1318a65e35a13b096cb9dcb87f8 100644 (file)
@@ -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");
@@ -1144,7 +1141,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;
@@ -1882,7 +1878,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;
@@ -2019,7 +2015,6 @@ static int acpi_video_bus_probe(struct auxiliary_device *aux_dev,
        auxiliary_set_drvdata(aux_dev, 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;
 
@@ -2041,11 +2036,10 @@ static int acpi_video_bus_probe(struct auxiliary_device *aux_dev,
         */
        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);
index 8fbad8bc465039f99185fc275f73237b73c53379..acf5dd2177a12a5d949f0b60b890e527300844e2 100644 (file)
@@ -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);
index 97b05246efab67e4a71bcb67fc58584b2adeb385..c57bd9c6305715fdcb9cb0db273c28bc8ae1ff45 100644 (file)
@@ -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;
index 5f63ed120a2c7133ad352f1390d15705fa5dedc1..4b21279012a7c81f26fc05e80ea9e4d838c75f3d 100644 (file)
@@ -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 ||
index 45bdfd06bd2134a3d614a752550c4a7659faa0b5..5745de24024c30d3f6e2623f74d6d4ba6b43dc69 100644 (file)
@@ -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;
 
index 4a882e9395256fbdd00315b26a337a529131cb0e..f4aa5b624d9b072ff899882a49c5a2d825be04c3 100644 (file)
@@ -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);
 
index 4611159ee734d407a3f6b87999d6ade4dd313b51..dcc9ad7790f0e958731c32afe648d3178bb96c21 100644 (file)
@@ -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;
index bbd3938f7b524a541724ca6f0a69d76c0dbab5d1..7e789290c5ad70d27fc8a028dd29babf47748dba 100644 (file)
@@ -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);
index 36850831910bcd1e30c4ab172ce9a5f9e32e2198..97eaa2fc31f22dbb7819dfc989305dffcc16364d 100644 (file)
@@ -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);
index 64356b004a57d874609fe829f4da309f045d6cde..6ccb364665d15b97f90425bd8f794487258994a4 100644 (file)
@@ -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);
index 7146a8e9e9c25bfb757c90ff43ccbf89886d42d8..43fe4a85fc0f2d845bd6e0bd9a59c82f4da59ece 100644 (file)
@@ -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"