Commit 97892d5f authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

ACPI: driver: Do not set acpi_device_name() unnecessarily



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: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/10840483.nUPlyArG6x@rafael.j.wysocki
parent 6a8e793c
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -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);
+0 −2
Original line number Diff line number Diff line
@@ -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;

+0 −2
Original line number Diff line number Diff line
@@ -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,
+0 −1
Original line number Diff line number Diff line
@@ -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;

+5 −11
Original line number Diff line number Diff line
@@ -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);
Loading