Skip to content

Commit e189470

Browse files
committed
ACPI: driver: Do not set acpi_device_class() unnecessarily
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
1 parent 76866c9 commit e189470

16 files changed

Lines changed: 5 additions & 32 deletions

drivers/acpi/ac.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ static int acpi_ac_probe(struct platform_device *pdev)
203203
return -ENOMEM;
204204

205205
ac->device = adev;
206-
strscpy(acpi_device_class(adev), ACPI_AC_CLASS);
207206

208207
platform_set_drvdata(pdev, ac);
209208

drivers/acpi/acpi_memhotplug.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#include "internal.h"
2020

21-
#define ACPI_MEMORY_DEVICE_CLASS "memory"
2221
#define ACPI_MEMORY_DEVICE_HID "PNP0C80"
2322

2423
static const struct acpi_device_id memory_device_ids[] = {
@@ -296,7 +295,6 @@ static int acpi_memory_device_add(struct acpi_device *device,
296295
INIT_LIST_HEAD(&mem_device->res_list);
297296
mem_device->device = device;
298297
mem_device->mgid = -1;
299-
sprintf(acpi_device_class(device), "%s", ACPI_MEMORY_DEVICE_CLASS);
300298
device->driver_data = mem_device;
301299

302300
/* Get the range from the _CRS */

drivers/acpi/acpi_pad.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <asm/mwait.h>
2424
#include <xen/xen.h>
2525

26-
#define ACPI_PROCESSOR_AGGREGATOR_CLASS "acpi_pad"
2726
#define ACPI_PROCESSOR_AGGREGATOR_NOTIFY 0x80
2827

2928
#define ACPI_PROCESSOR_AGGREGATOR_STATUS_SUCCESS 0
@@ -413,7 +412,7 @@ static void acpi_pad_notify(acpi_handle handle, u32 event, void *data)
413412
switch (event) {
414413
case ACPI_PROCESSOR_AGGREGATOR_NOTIFY:
415414
acpi_pad_handle_notify(handle);
416-
acpi_bus_generate_netlink_event(ACPI_PROCESSOR_AGGREGATOR_CLASS,
415+
acpi_bus_generate_netlink_event("acpi_pad",
417416
dev_name(&adev->dev), event, 0);
418417
break;
419418
default:
@@ -426,8 +425,6 @@ static int acpi_pad_probe(struct platform_device *pdev)
426425
{
427426
struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
428427

429-
strscpy(acpi_device_class(adev), ACPI_PROCESSOR_AGGREGATOR_CLASS);
430-
431428
return acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
432429
acpi_pad_notify, adev);
433430
}

drivers/acpi/acpi_processor.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,6 @@ static int acpi_processor_add(struct acpi_device *device,
438438
}
439439

440440
pr->handle = device->handle;
441-
strscpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
442441
device->driver_data = pr;
443442

444443
result = acpi_processor_get_info(device);

drivers/acpi/acpi_video.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,8 +1141,6 @@ static int acpi_video_bus_get_one_device(struct acpi_device *device, void *arg)
11411141
return -ENOMEM;
11421142
}
11431143

1144-
strscpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
1145-
11461144
data->device_id = device_id;
11471145
data->video = video;
11481146
data->dev = device;
@@ -2018,7 +2016,6 @@ static int acpi_video_bus_probe(struct auxiliary_device *aux_dev,
20182016
auxiliary_set_drvdata(aux_dev, video);
20192017

20202018
video->device = device;
2021-
strscpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
20222019
device->driver_data = video;
20232020

20242021
acpi_video_bus_find_cap(video);

drivers/acpi/battery.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,6 @@ static int acpi_battery_probe(struct platform_device *pdev)
12281228
platform_set_drvdata(pdev, battery);
12291229

12301230
battery->device = device;
1231-
strscpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
12321231

12331232
result = devm_mutex_init(&pdev->dev, &battery->update_lock);
12341233
if (result)

drivers/acpi/button.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,8 @@ static void acpi_button_remove(struct platform_device *pdev)
697697
acpi_button_remove_fs(button);
698698
input_unregister_device(button->input);
699699
kfree(button);
700+
701+
memset(acpi_device_class(adev), 0, sizeof(acpi_device_class));
700702
}
701703

702704
static int param_set_lid_init_state(const char *val,

drivers/acpi/ec.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535

3636
#include "internal.h"
3737

38-
#define ACPI_EC_CLASS "embedded_controller"
39-
4038
/* EC status register */
4139
#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */
4240
#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */
@@ -1680,8 +1678,6 @@ static int acpi_ec_probe(struct platform_device *pdev)
16801678
struct acpi_ec *ec;
16811679
int ret;
16821680

1683-
strscpy(acpi_device_class(device), ACPI_EC_CLASS);
1684-
16851681
if (boot_ec && (boot_ec->handle == device->handle ||
16861682
!strcmp(acpi_device_hid(device), ACPI_ECDT_HID))) {
16871683
/* Fast path: this device corresponds to the boot EC. */

drivers/acpi/pci_link.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
#include "internal.h"
3131

32-
#define ACPI_PCI_LINK_CLASS "pci_irq_routing"
3332
#define ACPI_PCI_LINK_MAX_POSSIBLE 16
3433

3534
static int acpi_pci_link_add(struct acpi_device *device,
@@ -724,7 +723,6 @@ static int acpi_pci_link_add(struct acpi_device *device,
724723
return -ENOMEM;
725724

726725
link->device = device;
727-
strscpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS);
728726
device->driver_data = link;
729727

730728
mutex_lock(&acpi_link_lock);

drivers/acpi/pci_root.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <linux/platform_data/x86/apple.h>
2525
#include "internal.h"
2626

27-
#define ACPI_PCI_ROOT_CLASS "pci_bridge"
2827
static int acpi_pci_root_add(struct acpi_device *device,
2928
const struct acpi_device_id *not_used);
3029
static void acpi_pci_root_remove(struct acpi_device *device);
@@ -688,7 +687,6 @@ static int acpi_pci_root_add(struct acpi_device *device,
688687

689688
root->device = device;
690689
root->segment = segment & 0xFFFF;
691-
strscpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS);
692690
device->driver_data = root;
693691

694692
if (hotadd && dmar_device_add(handle)) {

0 commit comments

Comments
 (0)