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

Merge ACPI thermal driver changes for 6.6-rc1.

This reworks the ACPI thermal driver to use a table of generic trip
point structures on top of the internal representation of trip points
and removes thermal zone callbacks that are not necessary any more
from it.

It requires some relatively small changes to be made in the thermal core
too and it is based on top of changes reworking ACPI device notification
handling that are included in this merge.

* acpi-thermal: (24 commits)
  ACPI: thermal: Eliminate code duplication from acpi_thermal_notify()
  ACPI: thermal: Drop unnecessary thermal zone callbacks
  ACPI: thermal: Rework thermal_get_trend()
  ACPI: thermal: Use trip point table to register thermal zones
  thermal: core: Rework and rename __for_each_thermal_trip()
  ACPI: thermal: Introduce struct acpi_thermal_trip
  ACPI: thermal: Carry out trip point updates under zone lock
  ACPI: thermal: Clean up acpi_thermal_register_thermal_zone()
  thermal: core: Add priv pointer to struct thermal_trip
  thermal: core: Introduce thermal_zone_device_exec()
  thermal: core: Do not handle trip points with invalid temperature
  ACPI: thermal: Drop redundant local variable from acpi_thermal_resume()
  ACPI: thermal: Do not attach private data to ACPI handles
  ACPI: thermal: Drop enabled flag from struct acpi_thermal_active
  ACPI: thermal: Drop nocrt parameter
  ACPI: thermal: Install Notify() handler directly
  ACPI: NFIT: Remove unnecessary .remove callback
  ACPI: NFIT: Install Notify() handler directly
  ACPI: HED: Install Notify() handler directly
  ACPI: battery: Install Notify() handler directly
  ...
parents 9f15b43f 4ab4b3b1
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -6243,10 +6243,6 @@
			-1: disable all critical trip points in all thermal zones
			<degrees C>: override all critical trip points

	thermal.nocrt=	[HW,ACPI]
			Set to disable actions on ACPI thermal zone
			critical and hot trip points.

	thermal.off=	[HW,ACPI]
			1: disable ACPI thermal control

+19 −8
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ MODULE_LICENSE("GPL");

static int acpi_ac_add(struct acpi_device *device);
static void acpi_ac_remove(struct acpi_device *device);
static void acpi_ac_notify(struct acpi_device *device, u32 event);
static void acpi_ac_notify(acpi_handle handle, u32 event, void *data);

static const struct acpi_device_id ac_device_ids[] = {
	{"ACPI0003", 0},
@@ -54,11 +54,9 @@ static struct acpi_driver acpi_ac_driver = {
	.name = "ac",
	.class = ACPI_AC_CLASS,
	.ids = ac_device_ids,
	.flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
	.ops = {
		.add = acpi_ac_add,
		.remove = acpi_ac_remove,
		.notify = acpi_ac_notify,
		},
	.drv.pm = &acpi_ac_pm,
};
@@ -128,8 +126,9 @@ static enum power_supply_property ac_props[] = {
};

/* Driver Model */
static void acpi_ac_notify(struct acpi_device *device, u32 event)
static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
{
	struct acpi_device *device = data;
	struct acpi_ac *ac = acpi_driver_data(device);

	if (!ac)
@@ -235,7 +234,7 @@ static int acpi_ac_add(struct acpi_device *device)

	result = acpi_ac_get_state(ac);
	if (result)
		goto end;
		goto err_release_ac;

	psy_cfg.drv_data = ac;

@@ -248,7 +247,7 @@ static int acpi_ac_add(struct acpi_device *device)
					    &ac->charger_desc, &psy_cfg);
	if (IS_ERR(ac->charger)) {
		result = PTR_ERR(ac->charger);
		goto end;
		goto err_release_ac;
	}

	pr_info("%s [%s] (%s)\n", acpi_device_name(device),
@@ -256,8 +255,18 @@ static int acpi_ac_add(struct acpi_device *device)

	ac->battery_nb.notifier_call = acpi_ac_battery_notify;
	register_acpi_notifier(&ac->battery_nb);
end:

	result = acpi_dev_install_notify_handler(device, ACPI_ALL_NOTIFY,
						 acpi_ac_notify);
	if (result)
		goto err_unregister;

	return 0;

err_unregister:
	power_supply_unregister(ac->charger);
	unregister_acpi_notifier(&ac->battery_nb);
err_release_ac:
	kfree(ac);

	return result;
@@ -297,6 +306,8 @@ static void acpi_ac_remove(struct acpi_device *device)

	ac = acpi_driver_data(device);

	acpi_dev_remove_notify_handler(device, ACPI_ALL_NOTIFY,
				       acpi_ac_notify);
	power_supply_unregister(ac->charger);
	unregister_acpi_notifier(&ac->battery_nb);

+17 −3
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ static DEFINE_MUTEX(video_list_lock);
static LIST_HEAD(video_bus_head);
static int acpi_video_bus_add(struct acpi_device *device);
static void acpi_video_bus_remove(struct acpi_device *device);
static void acpi_video_bus_notify(struct acpi_device *device, u32 event);
static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data);

/*
 * Indices in the _BCL method response: the first two items are special,
@@ -104,7 +104,6 @@ static struct acpi_driver acpi_video_bus = {
	.ops = {
		.add = acpi_video_bus_add,
		.remove = acpi_video_bus_remove,
		.notify = acpi_video_bus_notify,
		},
};

@@ -1527,8 +1526,9 @@ static int acpi_video_bus_stop_devices(struct acpi_video_bus *video)
				  acpi_osi_is_win8() ? 0 : 1);
}

static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
{
	struct acpi_device *device = data;
	struct acpi_video_bus *video = acpi_driver_data(device);
	struct input_dev *input;
	int keycode = 0;
@@ -2053,8 +2053,19 @@ static int acpi_video_bus_add(struct acpi_device *device)

	acpi_video_bus_add_notify_handler(video);

	error = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY,
						acpi_video_bus_notify);
	if (error)
		goto err_remove;

	return 0;

err_remove:
	mutex_lock(&video_list_lock);
	list_del(&video->entry);
	mutex_unlock(&video_list_lock);
	acpi_video_bus_remove_notify_handler(video);
	acpi_video_bus_unregister_backlight(video);
err_put_video:
	acpi_video_bus_put_devices(video);
	kfree(video->attached_array);
@@ -2075,6 +2086,9 @@ static void acpi_video_bus_remove(struct acpi_device *device)

	video = acpi_driver_data(device);

	acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY,
				       acpi_video_bus_notify);

	mutex_lock(&video_list_lock);
	list_del(&video->entry);
	mutex_unlock(&video_list_lock);
+19 −5
Original line number Diff line number Diff line
@@ -1034,8 +1034,9 @@ static void acpi_battery_refresh(struct acpi_battery *battery)
}

/* Driver Interface */
static void acpi_battery_notify(struct acpi_device *device, u32 event)
static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
{
	struct acpi_device *device = data;
	struct acpi_battery *battery = acpi_driver_data(device);
	struct power_supply *old;

@@ -1212,13 +1213,22 @@ static int acpi_battery_add(struct acpi_device *device)

	device_init_wakeup(&device->dev, 1);

	return result;
	result = acpi_dev_install_notify_handler(device, ACPI_ALL_NOTIFY,
						 acpi_battery_notify);
	if (result)
		goto fail_pm;

	return 0;

fail_pm:
	device_init_wakeup(&device->dev, 0);
	unregister_pm_notifier(&battery->pm_nb);
fail:
	sysfs_remove_battery(battery);
	mutex_destroy(&battery->lock);
	mutex_destroy(&battery->sysfs_lock);
	kfree(battery);

	return result;
}

@@ -1228,10 +1238,16 @@ static void acpi_battery_remove(struct acpi_device *device)

	if (!device || !acpi_driver_data(device))
		return;
	device_init_wakeup(&device->dev, 0);

	battery = acpi_driver_data(device);

	acpi_dev_remove_notify_handler(device, ACPI_ALL_NOTIFY,
				       acpi_battery_notify);

	device_init_wakeup(&device->dev, 0);
	unregister_pm_notifier(&battery->pm_nb);
	sysfs_remove_battery(battery);

	mutex_destroy(&battery->lock);
	mutex_destroy(&battery->sysfs_lock);
	kfree(battery);
@@ -1264,11 +1280,9 @@ static struct acpi_driver acpi_battery_driver = {
	.name = "battery",
	.class = ACPI_BATTERY_CLASS,
	.ids = battery_device_ids,
	.flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
	.ops = {
		.add = acpi_battery_add,
		.remove = acpi_battery_remove,
		.notify = acpi_battery_notify,
		},
	.drv.pm = &acpi_battery_pm,
};
+27 −1
Original line number Diff line number Diff line
@@ -554,6 +554,30 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device,
	acpi_os_wait_events_complete();
}

int acpi_dev_install_notify_handler(struct acpi_device *adev,
				    u32 handler_type,
				    acpi_notify_handler handler)
{
	acpi_status status;

	status = acpi_install_notify_handler(adev->handle, handler_type,
					     handler, adev);
	if (ACPI_FAILURE(status))
		return -ENODEV;

	return 0;
}
EXPORT_SYMBOL_GPL(acpi_dev_install_notify_handler);

void acpi_dev_remove_notify_handler(struct acpi_device *adev,
				    u32 handler_type,
				    acpi_notify_handler handler)
{
	acpi_remove_notify_handler(adev->handle, handler_type, handler);
	acpi_os_wait_events_complete();
}
EXPORT_SYMBOL_GPL(acpi_dev_remove_notify_handler);

/* Handle events targeting \_SB device (at present only graceful shutdown) */

#define ACPI_SB_NOTIFY_SHUTDOWN_REQUEST 0x81
@@ -1005,8 +1029,10 @@ static int acpi_device_probe(struct device *dev)
		return -ENOSYS;

	ret = acpi_drv->ops.add(acpi_dev);
	if (ret)
	if (ret) {
		acpi_dev->driver_data = NULL;
		return ret;
	}

	pr_debug("Driver [%s] successfully bound to device [%s]\n",
		 acpi_drv->name, acpi_dev->pnp.bus_id);
Loading