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

ACPI: thermal: Use white space more consistently



The usage of white space in the ACPI thermal driver is not very
consistent, so improve that a bit.

While at it, add missing braces to if()/else in a few places.

No functional impact.

Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
parent 9388076b
Loading
Loading
Loading
Loading
+92 −98
Original line number Diff line number Diff line
@@ -270,8 +270,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)

	/* Critical Shutdown */
	if (flag & ACPI_TRIPS_CRITICAL) {
		status = acpi_evaluate_integer(tz->device->handle,
				"_CRT", NULL, &tmp);
		status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL, &tmp);
		tz->trips.critical.temperature = tmp;
		/*
		 * Treat freezing temperatures as invalid as well; some
@@ -284,8 +283,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
			acpi_handle_debug(tz->device->handle,
					  "No critical threshold\n");
		} else if (tmp <= 2732) {
			pr_info(FW_BUG "Invalid critical threshold (%llu)\n",
				tmp);
			pr_info(FW_BUG "Invalid critical threshold (%llu)\n", tmp);
			tz->trips.critical.flags.valid = 0;
		} else {
			tz->trips.critical.flags.valid = 1;
@@ -312,8 +310,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)

	/* Critical Sleep (optional) */
	if (flag & ACPI_TRIPS_HOT) {
		status = acpi_evaluate_integer(tz->device->handle,
				"_HOT", NULL, &tmp);
		status = acpi_evaluate_integer(tz->device->handle, "_HOT", NULL, &tmp);
		if (ACPI_FAILURE(status)) {
			tz->trips.hot.flags.valid = 0;
			acpi_handle_debug(tz->device->handle,
@@ -341,29 +338,28 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
						       "_PSV", NULL, &tmp);
		}

		if (ACPI_FAILURE(status))
		if (ACPI_FAILURE(status)) {
			tz->trips.passive.flags.valid = 0;
		else {
		} else {
			tz->trips.passive.temperature = tmp;
			tz->trips.passive.flags.valid = 1;
			if (flag == ACPI_TRIPS_INIT) {
				status = acpi_evaluate_integer(
						tz->device->handle, "_TC1",
						NULL, &tmp);
				status = acpi_evaluate_integer(tz->device->handle,
							       "_TC1", NULL, &tmp);
				if (ACPI_FAILURE(status))
					tz->trips.passive.flags.valid = 0;
				else
					tz->trips.passive.tc1 = tmp;
				status = acpi_evaluate_integer(
						tz->device->handle, "_TC2",
						NULL, &tmp);

				status = acpi_evaluate_integer(tz->device->handle,
							       "_TC2", NULL, &tmp);
				if (ACPI_FAILURE(status))
					tz->trips.passive.flags.valid = 0;
				else
					tz->trips.passive.tc2 = tmp;
				status = acpi_evaluate_integer(
						tz->device->handle, "_TSP",
						NULL, &tmp);

				status = acpi_evaluate_integer(tz->device->handle,
							       "_TSP", NULL, &tmp);
				if (ACPI_FAILURE(status))
					tz->trips.passive.flags.valid = 0;
				else
@@ -379,9 +375,9 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
			acpi_handle_info(tz->device->handle,
					 "Invalid passive threshold\n");
			tz->trips.passive.flags.valid = 0;
		}
		else
		} else {
			tz->trips.passive.flags.valid = 1;
		}

		if (memcmp(&tz->trips.passive.devices, &devices,
			   sizeof(struct acpi_handle_list))) {
@@ -411,11 +407,12 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
				tz->trips.active[i].flags.valid = 0;
				if (i == 0)
					break;

				if (act <= 0)
					break;

				if (i == 1)
					tz->trips.active[0].temperature =
						celsius_to_deci_kelvin(act);
					tz->trips.active[0].temperature = celsius_to_deci_kelvin(act);
				else
					/*
					 * Don't allow override higher than
@@ -426,6 +423,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
						celsius_to_deci_kelvin(act) ?
						tz->trips.active[i-2].temperature :
						celsius_to_deci_kelvin(act));

				break;
			} else {
				tz->trips.active[i].temperature = tmp;
@@ -442,9 +440,9 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
				acpi_handle_info(tz->device->handle,
						 "Invalid active%d threshold\n", i);
				tz->trips.active[i].flags.valid = 0;
			}
			else
			} else {
				tz->trips.active[i].flags.valid = 1;
			}

			if (memcmp(&tz->trips.active[i].devices, &devices,
				   sizeof(struct acpi_handle_list))) {
@@ -465,8 +463,8 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
		memset(&devices, 0, sizeof(devices));
		status = acpi_evaluate_reference(tz->device->handle, "_TZD",
						 NULL, &devices);
		if (ACPI_SUCCESS(status)
		    && memcmp(&tz->devices, &devices, sizeof(devices))) {
		if (ACPI_SUCCESS(status) &&
		    memcmp(&tz->devices, &devices, sizeof(devices))) {
			tz->devices = devices;
			ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "device");
		}
@@ -548,8 +546,7 @@ static int thermal_get_trip_type(struct thermal_zone_device *thermal,
		trip--;
	}

	for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE &&
		tz->trips.active[i].flags.valid; i++) {
	for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->trips.active[i].flags.valid; i++) {
		if (!trip) {
			*type = THERMAL_TRIP_ACTIVE;
			return 0;
@@ -657,9 +654,8 @@ static int thermal_get_trend(struct thermal_zone_device *thermal,
	 * tz->temperature has already been updated by generic thermal layer,
	 * before this callback being invoked
	 */
	i = (tz->trips.passive.tc1 * (tz->temperature - tz->last_temperature))
		+ (tz->trips.passive.tc2
		* (tz->temperature - tz->trips.passive.temperature));
	i = (tz->trips.passive.tc1 * (tz->temperature - tz->last_temperature)) +
	    (tz->trips.passive.tc2 * (tz->temperature - tz->trips.passive.temperature));

	if (i > 0)
		*trend = THERMAL_TREND_RAISING;
@@ -667,6 +663,7 @@ static int thermal_get_trend(struct thermal_zone_device *thermal,
		*trend = THERMAL_TREND_DROPPING;
	else
		*trend = THERMAL_TREND_STABLE;

	return 0;
}

@@ -711,22 +708,23 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,

	if (tz->trips.passive.flags.valid) {
		trip++;
		for (i = 0; i < tz->trips.passive.devices.count;
		    i++) {
		for (i = 0; i < tz->trips.passive.devices.count; i++) {
			handle = tz->trips.passive.devices.handles[i];
			dev = acpi_fetch_acpi_dev(handle);
			if (dev != device)
				continue;

			if (bind)
				result =
					thermal_zone_bind_cooling_device
					(thermal, trip, cdev,
					 THERMAL_NO_LIMIT, THERMAL_NO_LIMIT,
				result = thermal_zone_bind_cooling_device(
						thermal, trip, cdev,
						THERMAL_NO_LIMIT,
						THERMAL_NO_LIMIT,
						THERMAL_WEIGHT_DEFAULT);
			else
				result =
					thermal_zone_unbind_cooling_device
					(thermal, trip, cdev);
					thermal_zone_unbind_cooling_device(
						thermal, trip, cdev);

			if (result)
				goto failed;
		}
@@ -735,22 +733,24 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
	for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
		if (!tz->trips.active[i].flags.valid)
			break;

		trip++;
		for (j = 0;
		    j < tz->trips.active[i].devices.count;
		    j++) {
		for (j = 0; j < tz->trips.active[i].devices.count; j++) {
			handle = tz->trips.active[i].devices.handles[j];
			dev = acpi_fetch_acpi_dev(handle);
			if (dev != device)
				continue;

			if (bind)
				result = thermal_zone_bind_cooling_device
					(thermal, trip, cdev,
					 THERMAL_NO_LIMIT, THERMAL_NO_LIMIT,
				result = thermal_zone_bind_cooling_device(
						thermal, trip, cdev,
						THERMAL_NO_LIMIT,
						THERMAL_NO_LIMIT,
						THERMAL_WEIGHT_DEFAULT);
			else
				result = thermal_zone_unbind_cooling_device
					(thermal, trip, cdev);
				result = thermal_zone_unbind_cooling_device(
						thermal, trip, cdev);

			if (result)
				goto failed;
		}
@@ -802,12 +802,11 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
	if (tz->trips.passive.flags.valid)
		trips++;

	for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE &&
			tz->trips.active[i].flags.valid; i++, trips++);
	for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->trips.active[i].flags.valid;
	     i++, trips++);

	if (tz->trips.passive.flags.valid)
		tz->thermal_zone =
			thermal_zone_device_register("acpitz", trips, 0, tz,
		tz->thermal_zone = thermal_zone_device_register("acpitz", trips, 0, tz,
								&acpi_thermal_zone_ops, NULL,
								tz->trips.passive.tsp * 100,
								tz->polling_frequency * 100);
@@ -816,6 +815,7 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
			thermal_zone_device_register("acpitz", trips, 0, tz,
						     &acpi_thermal_zone_ops, NULL,
						     0, tz->polling_frequency * 100);

	if (IS_ERR(tz->thermal_zone))
		return -ENODEV;

@@ -881,7 +881,6 @@ static void acpi_thermal_notify(struct acpi_device *device, u32 event)
{
	struct acpi_thermal *tz = acpi_driver_data(device);


	if (!tz)
		return;

@@ -944,7 +943,6 @@ static int acpi_thermal_get_info(struct acpi_thermal *tz)
{
	int result = 0;


	if (!tz)
		return -EINVAL;

@@ -1023,7 +1021,6 @@ static int acpi_thermal_add(struct acpi_device *device)
	int result = 0;
	struct acpi_thermal *tz = NULL;


	if (!device)
		return -EINVAL;

@@ -1099,6 +1096,7 @@ static int acpi_thermal_resume(struct device *dev)
	for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
		if (!tz->trips.active[i].flags.valid)
			break;

		tz->trips.active[i].flags.enabled = 1;
		for (j = 0; j < tz->trips.active[i].devices.count; j++) {
			result = acpi_bus_update_power(
@@ -1119,7 +1117,6 @@ static int acpi_thermal_resume(struct device *dev)
#endif

static int thermal_act(const struct dmi_system_id *d) {

	if (act == 0) {
		pr_notice("%s detected: disabling all active thermal trip points\n",
			  d->ident);
@@ -1128,14 +1125,12 @@ static int thermal_act(const struct dmi_system_id *d) {
	return 0;
}
static int thermal_nocrt(const struct dmi_system_id *d) {

	pr_notice("%s detected: disabling all critical thermal trip point actions.\n",
		  d->ident);
	nocrt = 1;
	return 0;
}
static int thermal_tzp(const struct dmi_system_id *d) {

	if (tzp == 0) {
		pr_notice("%s detected: enabling thermal zone polling\n",
			  d->ident);
@@ -1144,7 +1139,6 @@ static int thermal_tzp(const struct dmi_system_id *d) {
	return 0;
}
static int thermal_psv(const struct dmi_system_id *d) {

	if (psv == 0) {
		pr_notice("%s detected: disabling all passive thermal trip points\n",
			  d->ident);