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

Merge back updates of core ACPI drivers for 7.1

parents e7648ffe 236ad358
Loading
Loading
Loading
Loading
+9 −22
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@
#include <linux/acpi.h>
#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
@@ -33,22 +31,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;

@@ -141,10 +129,11 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
			msleep(ac_sleep_before_get_state_ms);

		acpi_ac_get_state(ac);
		acpi_bus_generate_netlink_event(adev->pnp.device_class,
		acpi_bus_generate_netlink_event(ACPI_AC_CLASS,
						dev_name(&adev->dev), event,
						  (u32) ac->state);
		acpi_notifier_call_chain(adev, event, (u32) ac->state);
						ac->state);
		acpi_notifier_call_chain(ACPI_AC_CLASS, acpi_device_bid(adev),
					 event, ac->state);
		power_supply_changed(ac->charger);
	}
}
@@ -213,8 +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);

@@ -236,8 +223,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);
@@ -272,10 +259,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);
+0 −4
Original line number Diff line number Diff line
@@ -18,9 +18,7 @@

#include "internal.h"

#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,8 +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_name(device), "%s", ACPI_MEMORY_DEVICE_NAME);
	sprintf(acpi_device_class(device), "%s", ACPI_MEMORY_DEVICE_CLASS);
	device->driver_data = mem_device;

	/* Get the range from the _CRS */
+7 −21
Original line number Diff line number Diff line
@@ -23,8 +23,6 @@
#include <asm/mwait.h>
#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
@@ -407,15 +405,14 @@ 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;

	switch (event) {
	case ACPI_PROCESSOR_AGGREGATOR_NOTIFY:
		acpi_pad_handle_notify(handle);
		acpi_bus_generate_netlink_event(adev->pnp.device_class,
		acpi_bus_generate_netlink_event("acpi_pad",
						dev_name(&adev->dev), event, 0);
		break;
	default:
@@ -427,29 +424,18 @@ 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_dev_remove_notify_handler(ACPI_COMPANION(&pdev->dev),
				       ACPI_DEVICE_NOTIFY, acpi_pad_notify);
}

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

	result = acpi_processor_get_info(device);
+46 −54
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,9 +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;
	data->video = video;
	data->dev = device;
@@ -1570,7 +1564,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;

@@ -1611,7 +1606,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;
	}

@@ -1644,7 +1640,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);
@@ -1681,26 +1678,6 @@ static int acpi_video_resume(struct notifier_block *nb,
	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;
@@ -1902,7 +1879,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;
@@ -1976,28 +1953,47 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
	return 0;
}

static int instance;
static int duplicate_dev_check(struct device *sibling, void *data)
{
	struct acpi_video_bus *video;

	if (sibling == data || !dev_is_auxiliary(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 device *dev)
{
	return device_for_each_child(dev->parent, dev, duplicate_dev_check);
}

static int acpi_video_bus_probe(struct auxiliary_device *aux_dev,
				const struct auxiliary_device_id *id_unused)
{
	struct acpi_device *device = ACPI_COMPANION(&aux_dev->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(&aux_dev->dev)) {
		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;
	}

@@ -2005,24 +2001,21 @@ static int acpi_video_bus_probe(struct auxiliary_device *aux_dev,
	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++;
	}

	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;

	acpi_video_bus_find_cap(video);
@@ -2043,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