From patchwork Tue Jan 24 19:13:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 646585 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38A50C25B4E for ; Tue, 24 Jan 2023 19:19:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234657AbjAXTT1 (ORCPT ); Tue, 24 Jan 2023 14:19:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234575AbjAXTTS (ORCPT ); Tue, 24 Jan 2023 14:19:18 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64D154F370; Tue, 24 Jan 2023 11:19:15 -0800 (PST) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.1.0) id 1ca963bc24d3b939; Tue, 24 Jan 2023 20:19:13 +0100 Received: from kreacher.localnet (unknown [213.134.189.30]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id F024C7A644A; Tue, 24 Jan 2023 20:19:12 +0100 (CET) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Linux ACPI , Zhang Rui , Srinivas Pandruvada , Daniel Lezcano Subject: [PATCH v1 1/6] thermal: intel: int340x: Assorted minor cleanups Date: Tue, 24 Jan 2023 20:13:44 +0100 Message-ID: <4795442.GXAFRqVoOG@kreacher> In-Reply-To: <12159228.O9o76ZdvQC@kreacher> References: <12159228.O9o76ZdvQC@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 213.134.189.30 X-CLIENT-HOSTNAME: 213.134.189.30 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedruddvtddguddvudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepvddufedrudefgedrudekledrfedtnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekledrfedtpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeeipdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthho pehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Rafael J. Wysocki 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 --- 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), From patchwork Tue Jan 24 19:14:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 646586 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A95FC25B50 for ; Tue, 24 Jan 2023 19:19:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234600AbjAXTTZ (ORCPT ); Tue, 24 Jan 2023 14:19:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234512AbjAXTTQ (ORCPT ); Tue, 24 Jan 2023 14:19:16 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C412F4ED00; Tue, 24 Jan 2023 11:19:13 -0800 (PST) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.1.0) id 899c60219e9c5128; Tue, 24 Jan 2023 20:19:12 +0100 Received: from kreacher.localnet (unknown [213.134.189.30]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 7D39D7A644A; Tue, 24 Jan 2023 20:19:11 +0100 (CET) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Linux ACPI , Zhang Rui , Srinivas Pandruvada , Daniel Lezcano Subject: [PATCH v1 2/6] thermal: intel: int340x: Rename variable in int340x_thermal_zone_add() Date: Tue, 24 Jan 2023 20:14:52 +0100 Message-ID: <2152349.irdbgypaU6@kreacher> In-Reply-To: <12159228.O9o76ZdvQC@kreacher> References: <12159228.O9o76ZdvQC@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 213.134.189.30 X-CLIENT-HOSTNAME: 213.134.189.30 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedruddvtddguddvudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepvddufedrudefgedrudekledrfedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekledrfedtpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeeipdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthho pehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Rafael J. Wysocki Rename local variable int34x_thermal_zone in int340x_thermal_zone_add() to int34x_zone which allows a number of code lines to become shorter and easier to read and adjust some white space for consistency. No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c | 69 +++++------ 1 file changed, 34 insertions(+), 35 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 @@ -118,82 +118,81 @@ static struct thermal_zone_params int340 struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev, int (*get_temp) (struct thermal_zone_device *, int *)) { - struct int34x_thermal_zone *int34x_thermal_zone; + struct int34x_thermal_zone *int34x_zone; unsigned long long trip_cnt = 0; int trip_mask = 0; acpi_status status; int i, ret; - int34x_thermal_zone = kzalloc(sizeof(*int34x_thermal_zone), GFP_KERNEL); - if (!int34x_thermal_zone) + int34x_zone = kzalloc(sizeof(*int34x_zone), GFP_KERNEL); + if (!int34x_zone) return ERR_PTR(-ENOMEM); - int34x_thermal_zone->adev = adev; + int34x_zone->adev = adev; - int34x_thermal_zone->ops = kmemdup(&int340x_thermal_zone_ops, - sizeof(int340x_thermal_zone_ops), GFP_KERNEL); - if (!int34x_thermal_zone->ops) { + int34x_zone->ops = kmemdup(&int340x_thermal_zone_ops, + sizeof(int340x_thermal_zone_ops), GFP_KERNEL); + if (!int34x_zone->ops) { ret = -ENOMEM; goto err_ops_alloc; } if (get_temp) - int34x_thermal_zone->ops->get_temp = get_temp; + int34x_zone->ops->get_temp = get_temp; status = acpi_evaluate_integer(adev->handle, "PATC", NULL, &trip_cnt); if (ACPI_SUCCESS(status)) { - int34x_thermal_zone->aux_trip_nr = trip_cnt; + int34x_zone->aux_trip_nr = trip_cnt; trip_mask = BIT(trip_cnt) - 1; } 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) { + int34x_zone->trips = kzalloc(sizeof(*int34x_zone->trips) * trip_cnt, GFP_KERNEL); + if (!int34x_zone->trips) { ret = -ENOMEM; goto err_trips_alloc; } - trip_cnt = int340x_thermal_read_trips(int34x_thermal_zone); + trip_cnt = int340x_thermal_read_trips(int34x_zone); for (i = 0; i < trip_cnt; ++i) - int340x_thermal_get_global_hyst(adev, &int34x_thermal_zone->trips[i].hysteresis); + int340x_thermal_get_global_hyst(adev, &int34x_zone->trips[i].hysteresis); - for (i = 0; i < int34x_thermal_zone->aux_trip_nr; i++) { - int34x_thermal_zone->trips[i].type = THERMAL_TRIP_PASSIVE; - int34x_thermal_zone->trips[i].temperature = THERMAL_TEMP_INVALID; + for (i = 0; i < int34x_zone->aux_trip_nr; i++) { + int34x_zone->trips[i].type = THERMAL_TRIP_PASSIVE; + int34x_zone->trips[i].temperature = THERMAL_TEMP_INVALID; } - int34x_thermal_zone->lpat_table = acpi_lpat_get_conversion_table(adev->handle); + int34x_zone->lpat_table = acpi_lpat_get_conversion_table(adev->handle); - int34x_thermal_zone->zone = thermal_zone_device_register_with_trips( - acpi_device_bid(adev), - int34x_thermal_zone->trips, - trip_cnt, - trip_mask, int34x_thermal_zone, - int34x_thermal_zone->ops, - &int340x_thermal_params, - 0, 0); - if (IS_ERR(int34x_thermal_zone->zone)) { - ret = PTR_ERR(int34x_thermal_zone->zone); + int34x_zone->zone = thermal_zone_device_register_with_trips( + acpi_device_bid(adev), + int34x_zone->trips, + trip_cnt, + trip_mask, int34x_zone, + int34x_zone->ops, + &int340x_thermal_params, + 0, 0); + if (IS_ERR(int34x_zone->zone)) { + ret = PTR_ERR(int34x_zone->zone); goto err_thermal_zone; } - ret = thermal_zone_device_enable(int34x_thermal_zone->zone); + ret = thermal_zone_device_enable(int34x_zone->zone); if (ret) goto err_enable; - return int34x_thermal_zone; + return int34x_zone; err_enable: - thermal_zone_device_unregister(int34x_thermal_zone->zone); + thermal_zone_device_unregister(int34x_zone->zone); err_thermal_zone: - kfree(int34x_thermal_zone->trips); - acpi_lpat_free_conversion_table(int34x_thermal_zone->lpat_table); + kfree(int34x_zone->trips); + acpi_lpat_free_conversion_table(int34x_zone->lpat_table); err_trips_alloc: - kfree(int34x_thermal_zone->ops); + kfree(int34x_zone->ops); err_ops_alloc: - kfree(int34x_thermal_zone); + kfree(int34x_zone); return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(int340x_thermal_zone_add); From patchwork Tue Jan 24 19:16:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 646076 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 808B5C25B4E for ; Tue, 24 Jan 2023 19:19:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233417AbjAXTTS (ORCPT ); Tue, 24 Jan 2023 14:19:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234492AbjAXTTN (ORCPT ); Tue, 24 Jan 2023 14:19:13 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 200A74C0D4; Tue, 24 Jan 2023 11:19:11 -0800 (PST) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.1.0) id b885dacc12dec74b; Tue, 24 Jan 2023 20:19:10 +0100 Received: from kreacher.localnet (unknown [213.134.189.30]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id BF0D27A644A; Tue, 24 Jan 2023 20:19:09 +0100 (CET) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Linux ACPI , Zhang Rui , Srinivas Pandruvada , Daniel Lezcano Subject: [PATCH v1 3/6] thermal: intel: int340x: Evaluate GTSH once Date: Tue, 24 Jan 2023 20:16:09 +0100 Message-ID: <2887081.e9J7NaK4W3@kreacher> In-Reply-To: <12159228.O9o76ZdvQC@kreacher> References: <12159228.O9o76ZdvQC@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 213.134.189.30 X-CLIENT-HOSTNAME: 213.134.189.30 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedruddvtddguddvudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepvddufedrudefgedrudekledrfedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekledrfedtpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeeipdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthho pehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Rafael J. Wysocki It is not necessary to evaluate the GTSH ACPI object for every trip point in int340x_thermal_zone_add() and the function used for that is not really necessary either, because it only has one caller. Accordingly, fold the evaluation of GTSH directly into int340x_thermal_zone_add(), evaluate it only once and populate the hysteresis for all of the trip points with the value produced by it. No expected functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c | 24 +++-------- 1 file changed, 8 insertions(+), 16 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 @@ -53,21 +53,6 @@ static int int340x_thermal_set_trip_temp return 0; } -static int int340x_thermal_get_global_hyst(struct acpi_device *adev, int *temp) -{ - acpi_status status; - unsigned long long hyst; - - status = acpi_evaluate_integer(adev->handle, "GTSH", NULL, &hyst); - if (ACPI_FAILURE(status)) - *temp = 0; - else - *temp = hyst * 100; - - return 0; -} - - static void int340x_thermal_critical(struct thermal_zone_device *zone) { dev_dbg(&zone->device, "%s: critical temperature reached\n", zone->type); @@ -120,6 +105,7 @@ struct int34x_thermal_zone *int340x_ther { struct int34x_thermal_zone *int34x_zone; unsigned long long trip_cnt = 0; + unsigned long long hyst; int trip_mask = 0; acpi_status status; int i, ret; @@ -156,8 +142,14 @@ struct int34x_thermal_zone *int340x_ther trip_cnt = int340x_thermal_read_trips(int34x_zone); + status = acpi_evaluate_integer(adev->handle, "GTSH", NULL, &hyst); + if (ACPI_SUCCESS(status)) + hyst *= 100; + else + hyst = 0; + for (i = 0; i < trip_cnt; ++i) - int340x_thermal_get_global_hyst(adev, &int34x_zone->trips[i].hysteresis); + int34x_zone->trips[i].hysteresis = hyst; for (i = 0; i < int34x_zone->aux_trip_nr; i++) { int34x_zone->trips[i].type = THERMAL_TRIP_PASSIVE; From patchwork Tue Jan 24 19:17:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 646587 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB534C25B50 for ; Tue, 24 Jan 2023 19:19:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234522AbjAXTTQ (ORCPT ); Tue, 24 Jan 2023 14:19:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234343AbjAXTTN (ORCPT ); Tue, 24 Jan 2023 14:19:13 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A561B32522; Tue, 24 Jan 2023 11:19:10 -0800 (PST) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.1.0) id 489f2acd983c5755; Tue, 24 Jan 2023 20:19:09 +0100 Received: from kreacher.localnet (unknown [213.134.189.30]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 501A47A644A; Tue, 24 Jan 2023 20:19:08 +0100 (CET) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Linux ACPI , Zhang Rui , Srinivas Pandruvada , Daniel Lezcano Subject: [PATCH v1 4/6] thermal: intel: int340x: Rearrange int340x_thermal_read_trips() Date: Tue, 24 Jan 2023 20:17:09 +0100 Message-ID: <3238718.44csPzL39Z@kreacher> In-Reply-To: <12159228.O9o76ZdvQC@kreacher> References: <12159228.O9o76ZdvQC@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 213.134.189.30 X-CLIENT-HOSTNAME: 213.134.189.30 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedruddvtddguddvudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepvddufedrudefgedrudekledrfedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekledrfedtpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeeipdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthho pehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Rafael J. Wysocki Use local variables trips and adev to store the addresses of the given thermal zone's trip point table and ACPI device, respectively, and use them to shorten some code lines. No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 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 @@ -66,25 +66,27 @@ static struct thermal_zone_device_ops in int int340x_thermal_read_trips(struct int34x_thermal_zone *int34x_zone) { + struct thermal_trip *trips = int34x_zone->trips; + struct acpi_device *adev = int34x_zone->adev; int trip_cnt; int i, ret; trip_cnt = int34x_zone->aux_trip_nr; - ret = thermal_acpi_trip_critical(int34x_zone->adev, &int34x_zone->trips[trip_cnt]); + ret = thermal_acpi_trip_critical(adev, &trips[trip_cnt]); if (!ret) trip_cnt++; - ret = thermal_acpi_trip_hot(int34x_zone->adev, &int34x_zone->trips[trip_cnt]); + ret = thermal_acpi_trip_hot(adev, &trips[trip_cnt]); if (!ret) trip_cnt++; - ret = thermal_acpi_trip_passive(int34x_zone->adev, &int34x_zone->trips[trip_cnt]); + ret = thermal_acpi_trip_passive(adev, &trips[trip_cnt]); if (!ret) 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]); + ret = thermal_acpi_trip_active(adev, i, &trips[trip_cnt]); if (ret) break; From patchwork Tue Jan 24 19:18:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 646077 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9F32C54EB4 for ; Tue, 24 Jan 2023 19:19:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234421AbjAXTTL (ORCPT ); Tue, 24 Jan 2023 14:19:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234343AbjAXTTK (ORCPT ); Tue, 24 Jan 2023 14:19:10 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05FA531E3B; Tue, 24 Jan 2023 11:19:08 -0800 (PST) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.1.0) id 86a9f70f4c250077; Tue, 24 Jan 2023 20:19:07 +0100 Received: from kreacher.localnet (unknown [213.134.189.30]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id A76BB7A644A; Tue, 24 Jan 2023 20:19:06 +0100 (CET) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Linux ACPI , Zhang Rui , Srinivas Pandruvada , Daniel Lezcano Subject: [PATCH v1 5/6] thermal: intel: int340x: Populate auxiliary trip points first Date: Tue, 24 Jan 2023 20:18:09 +0100 Message-ID: <10235439.nUPlyArG6x@kreacher> In-Reply-To: <12159228.O9o76ZdvQC@kreacher> References: <12159228.O9o76ZdvQC@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 213.134.189.30 X-CLIENT-HOSTNAME: 213.134.189.30 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedruddvtddguddvudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepvddufedrudefgedrudekledrfedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekledrfedtpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeeipdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthho pehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Rafael J. Wysocki Populate the auxiliary trip points in the int340x thermal zone before the "regular" ACPI ones, because they occupy the initial entries of the trip points table. No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 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 @@ -142,6 +142,11 @@ struct int34x_thermal_zone *int340x_ther goto err_trips_alloc; } + for (i = 0; i < int34x_zone->aux_trip_nr; i++) { + int34x_zone->trips[i].type = THERMAL_TRIP_PASSIVE; + int34x_zone->trips[i].temperature = THERMAL_TEMP_INVALID; + } + trip_cnt = int340x_thermal_read_trips(int34x_zone); status = acpi_evaluate_integer(adev->handle, "GTSH", NULL, &hyst); @@ -153,11 +158,6 @@ struct int34x_thermal_zone *int340x_ther for (i = 0; i < trip_cnt; ++i) int34x_zone->trips[i].hysteresis = hyst; - for (i = 0; i < int34x_zone->aux_trip_nr; i++) { - int34x_zone->trips[i].type = THERMAL_TRIP_PASSIVE; - int34x_zone->trips[i].temperature = THERMAL_TEMP_INVALID; - } - int34x_zone->lpat_table = acpi_lpat_get_conversion_table(adev->handle); int34x_zone->zone = thermal_zone_device_register_with_trips( From patchwork Tue Jan 24 19:18:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 646588 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9984C25B4E for ; Tue, 24 Jan 2023 19:19:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234228AbjAXTTK (ORCPT ); Tue, 24 Jan 2023 14:19:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229933AbjAXTTJ (ORCPT ); Tue, 24 Jan 2023 14:19:09 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4869A31E26; Tue, 24 Jan 2023 11:19:08 -0800 (PST) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.1.0) id 121f397b287e1538; Tue, 24 Jan 2023 20:19:06 +0100 Received: from kreacher.localnet (unknown [213.134.189.30]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 3D6BF7A644A; Tue, 24 Jan 2023 20:19:05 +0100 (CET) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Linux ACPI , Zhang Rui , Srinivas Pandruvada , Daniel Lezcano Subject: [PATCH v1 6/6] thermal: intel: int340x: Drop pointless cast to unsigned long Date: Tue, 24 Jan 2023 20:18:52 +0100 Message-ID: <1940542.PYKUYFuaPT@kreacher> In-Reply-To: <12159228.O9o76ZdvQC@kreacher> References: <12159228.O9o76ZdvQC@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 213.134.189.30 X-CLIENT-HOSTNAME: 213.134.189.30 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedruddvtddguddvudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepvddufedrudefgedrudekledrfedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekledrfedtpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeeipdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthho pehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Rafael J. Wysocki The explicit casting from int to unsigned long in int340x_thermal_get_zone_temp() is pointless, becuase the multiplication result is cast back to int by the assignment in the same statement, so drop it. No expected functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 @@ -29,7 +29,7 @@ static int int340x_thermal_get_zone_temp if (conv_temp < 0) return conv_temp; - *temp = (unsigned long)conv_temp * 10; + *temp = conv_temp * 10; } else { /* _TMP returns the temperature in tenths of degrees Kelvin */ *temp = deci_kelvin_to_millicelsius(tmp);