linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Linux ACPI <linux-acpi@vger.kernel.org>,
	Zhang Rui <rui.zhang@intel.com>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>
Subject: [PATCH v1 1/6] thermal: intel: int340x: Assorted minor cleanups
Date: Tue, 24 Jan 2023 20:13:44 +0100	[thread overview]
Message-ID: <4795442.GXAFRqVoOG@kreacher> (raw)
In-Reply-To: <12159228.O9o76ZdvQC@kreacher>

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Improve some inconsistent usage of white space in int340x_thermal_zone.c,
fix up one coding style issue in it (missing braces around an else
branch of a conditional) and while at it replace a !ACPI_FAILURE()
check with an equivalent ACPI_SUCCESS() one.

Also add INT340X_THERMAL_MAX_TRIP_COUNT to trip_cnt before using it
for the allocation of trips for more clarity.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c |   22 +++++------
 1 file changed, 10 insertions(+), 12 deletions(-)

Index: linux-pm/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
===================================================================
--- linux-pm.orig/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
+++ linux-pm/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
@@ -30,10 +30,10 @@ static int int340x_thermal_get_zone_temp
 			return conv_temp;
 
 		*temp = (unsigned long)conv_temp * 10;
-	} else
+	} else {
 		/* _TMP returns the temperature in tenths of degrees Kelvin */
 		*temp = deci_kelvin_to_millicelsius(tmp);
-
+	}
 	return 0;
 }
 
@@ -46,7 +46,7 @@ static int int340x_thermal_set_trip_temp
 
 	snprintf(name, sizeof(name), "PAT%d", trip);
 	status = acpi_execute_simple_method(d->adev->handle, name,
-			millicelsius_to_deci_kelvin(temp));
+					    millicelsius_to_deci_kelvin(temp));
 	if (ACPI_FAILURE(status))
 		return -EIO;
 
@@ -99,7 +99,6 @@ int int340x_thermal_read_trips(struct in
 		trip_cnt++;
 
 	for (i = 0; i < INT340X_THERMAL_MAX_ACT_TRIP_COUNT; i++) {
-
 		ret = thermal_acpi_trip_active(int34x_zone->adev, i, &int34x_zone->trips[trip_cnt]);
 		if (ret)
 			break;
@@ -125,8 +124,7 @@ struct int34x_thermal_zone *int340x_ther
 	acpi_status status;
 	int i, ret;
 
-	int34x_thermal_zone = kzalloc(sizeof(*int34x_thermal_zone),
-				      GFP_KERNEL);
+	int34x_thermal_zone = kzalloc(sizeof(*int34x_thermal_zone), GFP_KERNEL);
 	if (!int34x_thermal_zone)
 		return ERR_PTR(-ENOMEM);
 
@@ -143,14 +141,15 @@ struct int34x_thermal_zone *int340x_ther
 		int34x_thermal_zone->ops->get_temp = get_temp;
 
 	status = acpi_evaluate_integer(adev->handle, "PATC", NULL, &trip_cnt);
-	if (!ACPI_FAILURE(status)) {
+	if (ACPI_SUCCESS(status)) {
 		int34x_thermal_zone->aux_trip_nr = trip_cnt;
 		trip_mask = BIT(trip_cnt) - 1;
 	}
 
-	int34x_thermal_zone->trips = kzalloc(sizeof(*int34x_thermal_zone->trips) *
-					     (INT340X_THERMAL_MAX_TRIP_COUNT + trip_cnt),
-					      GFP_KERNEL);
+	trip_cnt += INT340X_THERMAL_MAX_TRIP_COUNT;
+
+	int34x_thermal_zone->trips = kzalloc(sizeof(*int34x_thermal_zone->trips) * trip_cnt,
+					     GFP_KERNEL);
 	if (!int34x_thermal_zone->trips) {
 		ret = -ENOMEM;
 		goto err_trips_alloc;
@@ -166,8 +165,7 @@ struct int34x_thermal_zone *int340x_ther
 		int34x_thermal_zone->trips[i].temperature = THERMAL_TEMP_INVALID;
 	}
 
-	int34x_thermal_zone->lpat_table = acpi_lpat_get_conversion_table(
-								adev->handle);
+	int34x_thermal_zone->lpat_table = acpi_lpat_get_conversion_table(adev->handle);
 
 	int34x_thermal_zone->zone = thermal_zone_device_register_with_trips(
 						acpi_device_bid(adev),




  reply	other threads:[~2023-01-24 19:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-24 19:07 [PATCH v1 0/6] thermal: intel: int340x: Assorted cleanup changes Rafael J. Wysocki
2023-01-24 19:13 ` Rafael J. Wysocki [this message]
2023-01-24 19:14 ` [PATCH v1 2/6] thermal: intel: int340x: Rename variable in int340x_thermal_zone_add() Rafael J. Wysocki
2023-01-24 19:16 ` [PATCH v1 3/6] thermal: intel: int340x: Evaluate GTSH once Rafael J. Wysocki
2023-01-24 19:17 ` [PATCH v1 4/6] thermal: intel: int340x: Rearrange int340x_thermal_read_trips() Rafael J. Wysocki
2023-01-24 19:18 ` [PATCH v1 5/6] thermal: intel: int340x: Populate auxiliary trip points first Rafael J. Wysocki
2023-01-24 19:18 ` [PATCH v1 6/6] thermal: intel: int340x: Drop pointless cast to unsigned long Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4795442.GXAFRqVoOG@kreacher \
    --to=rjw@rjwysocki.net \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).