From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: Zhang Rui <rui.zhang@intel.com>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Linux ACPI <linux-acpi@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
David Box <david.e.box@linux.intel.com>
Subject: [PATCH v1 5/8] thermal: intel: intel_pch: Fold two functions into their callers
Date: Mon, 30 Jan 2023 20:03:11 +0100 [thread overview]
Message-ID: <3662399.MHq7AAxBmi@kreacher> (raw)
In-Reply-To: <1751684.VLH7GnMWUR@kreacher>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Fold two functions, pch_hw_init() and pch_get_temp(), that each have
only one caller, into their respective callers to make the code somewhat
easier to follow.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/thermal/intel/intel_pch_thermal.c | 98 ++++++++++++------------------
1 file changed, 42 insertions(+), 56 deletions(-)
Index: linux-pm/drivers/thermal/intel/intel_pch_thermal.c
===================================================================
--- linux-pm.orig/drivers/thermal/intel/intel_pch_thermal.c
+++ linux-pm/drivers/thermal/intel/intel_pch_thermal.c
@@ -117,57 +117,6 @@ static int pch_wpt_add_acpi_psv_trip(str
}
#endif
-static int pch_hw_init(struct pch_thermal_device *ptd)
-{
- int nr_trips = 0;
- u16 trip_temp;
- u8 tsel;
-
- /* Check if BIOS has already enabled thermal sensor */
- if (WPT_TSEL_ETS & readb(ptd->hw_base + WPT_TSEL)) {
- ptd->bios_enabled = true;
- goto read_trips;
- }
-
- tsel = readb(ptd->hw_base + WPT_TSEL);
- /*
- * When TSEL's Policy Lock-Down bit is 1, TSEL become RO.
- * If so, thermal sensor cannot enable. Bail out.
- */
- if (tsel & WPT_TSEL_PLDB) {
- dev_err(&ptd->pdev->dev, "Sensor can't be enabled\n");
- return -ENODEV;
- }
-
- writeb(tsel|WPT_TSEL_ETS, ptd->hw_base + WPT_TSEL);
- if (!(WPT_TSEL_ETS & readb(ptd->hw_base + WPT_TSEL))) {
- dev_err(&ptd->pdev->dev, "Sensor can't be enabled\n");
- return -ENODEV;
- }
-
-read_trips:
- trip_temp = readw(ptd->hw_base + WPT_CTT);
- trip_temp &= 0x1FF;
- if (trip_temp) {
- ptd->trips[nr_trips].temperature = GET_WPT_TEMP(trip_temp);
- ptd->trips[nr_trips++].type = THERMAL_TRIP_CRITICAL;
- }
-
- trip_temp = readw(ptd->hw_base + WPT_PHL);
- trip_temp &= 0x1FF;
- if (trip_temp) {
- ptd->trips[nr_trips].temperature = GET_WPT_TEMP(trip_temp);
- ptd->trips[nr_trips++].type = THERMAL_TRIP_HOT;
- }
-
- return nr_trips + pch_wpt_add_acpi_psv_trip(ptd, nr_trips);
-}
-
-static int pch_get_temp(struct pch_thermal_device *ptd)
-{
- return GET_WPT_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP));
-}
-
/* Cool the PCH when it's overheat in .suspend_noirq phase */
static int pch_suspend(struct pch_thermal_device *ptd)
{
@@ -254,7 +203,7 @@ static int pch_thermal_get_temp(struct t
{
struct pch_thermal_device *ptd = tzd->devdata;
- *temp = pch_get_temp(ptd);
+ *temp = GET_WPT_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP));
return 0;
}
@@ -310,8 +259,10 @@ static int intel_pch_thermal_probe(struc
enum board_ids board_id = id->driver_data;
const struct board_info *bi = &board_info[board_id];
struct pch_thermal_device *ptd;
- int err;
+ u16 trip_temp;
int nr_trips;
+ u8 tsel;
+ int err;
ptd = devm_kzalloc(&pdev->dev, sizeof(*ptd), GFP_KERNEL);
if (!ptd)
@@ -339,12 +290,47 @@ static int intel_pch_thermal_probe(struc
goto error_release;
}
- nr_trips = pch_hw_init(ptd);
- if (nr_trips < 0) {
- err = nr_trips;
+ /* Check if BIOS has already enabled thermal sensor */
+ if (WPT_TSEL_ETS & readb(ptd->hw_base + WPT_TSEL)) {
+ ptd->bios_enabled = true;
+ goto read_trips;
+ }
+
+ tsel = readb(ptd->hw_base + WPT_TSEL);
+ /*
+ * When TSEL's Policy Lock-Down bit is 1, TSEL become RO.
+ * If so, thermal sensor cannot enable. Bail out.
+ */
+ if (tsel & WPT_TSEL_PLDB) {
+ dev_err(&ptd->pdev->dev, "Sensor can't be enabled\n");
+ err = -ENODEV;
goto error_cleanup;
}
+ writeb(tsel|WPT_TSEL_ETS, ptd->hw_base + WPT_TSEL);
+ if (!(WPT_TSEL_ETS & readb(ptd->hw_base + WPT_TSEL))) {
+ dev_err(&ptd->pdev->dev, "Sensor can't be enabled\n");
+ err = -ENODEV;
+ goto error_cleanup;
+ }
+
+read_trips:
+ trip_temp = readw(ptd->hw_base + WPT_CTT);
+ trip_temp &= 0x1FF;
+ if (trip_temp) {
+ ptd->trips[nr_trips].temperature = GET_WPT_TEMP(trip_temp);
+ ptd->trips[nr_trips++].type = THERMAL_TRIP_CRITICAL;
+ }
+
+ trip_temp = readw(ptd->hw_base + WPT_PHL);
+ trip_temp &= 0x1FF;
+ if (trip_temp) {
+ ptd->trips[nr_trips].temperature = GET_WPT_TEMP(trip_temp);
+ ptd->trips[nr_trips++].type = THERMAL_TRIP_HOT;
+ }
+
+ nr_trips += pch_wpt_add_acpi_psv_trip(ptd, nr_trips);
+
ptd->tzd = thermal_zone_device_register_with_trips(bi->name, ptd->trips,
nr_trips, 0, ptd,
&tzd_ops, NULL, 0, 0);
next prev parent reply other threads:[~2023-01-30 19:07 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-30 18:56 [PATCH v1 0/8] thermal: intel: intel_pch: Code simplification and cleanups Rafael J. Wysocki
2023-01-30 18:58 ` [PATCH v1 1/8] thermal: intel: intel_pch: Make pch_wpt_add_acpi_psv_trip() return int Rafael J. Wysocki
2023-01-31 13:16 ` Daniel Lezcano
2023-01-30 18:59 ` [PATCH v1 2/8] thermal: intel: intel_pch: Eliminate redundant return pointers Rafael J. Wysocki
2023-01-31 13:19 ` Daniel Lezcano
2023-01-31 14:54 ` Daniel Lezcano
2023-01-30 19:00 ` [PATCH v1 3/8] thermal: intel: intel_pch: Rename device operations callbacks Rafael J. Wysocki
2023-01-31 14:55 ` Daniel Lezcano
2023-01-30 19:02 ` [PATCH v1 4/8] thermal: intel: intel_pch: Eliminate device operations object Rafael J. Wysocki
2023-01-31 14:57 ` Daniel Lezcano
2023-01-30 19:03 ` Rafael J. Wysocki [this message]
2023-01-31 15:58 ` [PATCH v1 5/8] thermal: intel: intel_pch: Fold two functions into their callers Daniel Lezcano
2023-01-30 19:04 ` [PATCH v1 6/8] thermal: intel: intel_pch: Fold suspend and resume routines " Rafael J. Wysocki
2023-01-31 15:59 ` Daniel Lezcano
2023-01-30 19:04 ` [PATCH v1 7/8] thermal: intel: intel_pch: Rename board ID symbols Rafael J. Wysocki
2023-01-31 11:17 ` Zhang, Rui
2023-01-31 13:08 ` Rafael J. Wysocki
2023-01-31 16:00 ` Daniel Lezcano
2023-01-30 19:07 ` [PATCH v1 8/8] thermal: intel: intel_pch: Refer to thermal zone name directly Rafael J. Wysocki
2023-01-31 16:02 ` Daniel Lezcano
2023-01-31 19:20 ` Rafael J. Wysocki
2023-01-31 23:41 ` Daniel Lezcano
2023-01-30 19:13 ` [PATCH v1 0/8] thermal: intel: intel_pch: Code simplification and cleanups Rafael J. Wysocki
2023-02-01 9:30 ` Zhang, Rui
2023-02-01 9:06 ` Zhang, Rui
2023-02-01 9:08 ` Zhang, Rui
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=3662399.MHq7AAxBmi@kreacher \
--to=rjw@rjwysocki.net \
--cc=david.e.box@linux.intel.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.