linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: daniel.lezcano@linaro.org, rafael@kernel.org
Cc: linux-pm@vger.kernel.org, thierry.reding@gmail.com,
	linux-kernel@vger.kernel.org,
	srinivas.pandruvada@linux.intel.com,
	"Amit Kucheria" <amitk@kernel.org>,
	"Zhang Rui" <rui.zhang@intel.com>,
	"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>,
	"Baolin Wang" <baolin.wang@linux.alibaba.com>,
	"ye xingchen" <ye.xingchen@zte.com.cn>,
	"Lee, Chun-Yi" <joeyli.kernel@gmail.com>
Subject: [PATCH v2 3/4] thermal/drivers/int3400: Use thermal zone device wrappers
Date: Fri,  7 Jul 2023 22:37:30 +0200	[thread overview]
Message-ID: <20230707203731.848188-4-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <20230707203731.848188-1-daniel.lezcano@linaro.org>

Use the thermal core API to access the thermal zone "type" field
instead of directly using the structure field.  While here, remove
access to the temperature field, as this driver is reporting fake
temperature, which can be replaced with INT3400_FAKE_TEMP. Also
replace hardcoded 20C with INT3400_FAKE_TEMP

Acked-by: srinivas pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 .../thermal/intel/int340x_thermal/int3400_thermal.c  | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
index 5e1164226ada..72a6e28ded2e 100644
--- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
+++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
@@ -15,6 +15,7 @@
 #define INT3400_THERMAL_TABLE_CHANGED 0x83
 #define INT3400_ODVP_CHANGED 0x88
 #define INT3400_KEEP_ALIVE 0xA0
+#define INT3400_FAKE_TEMP (20 * 1000) /* faked temp sensor with 20C */
 
 enum int3400_thermal_uuid {
 	INT3400_THERMAL_ACTIVE = 0,
@@ -453,6 +454,7 @@ static void int3400_notify(acpi_handle handle,
 			void *data)
 {
 	struct int3400_thermal_priv *priv = data;
+	struct device *dev;
 	char *thermal_prop[5];
 	int therm_event;
 
@@ -475,12 +477,14 @@ static void int3400_notify(acpi_handle handle,
 		return;
 	}
 
-	thermal_prop[0] = kasprintf(GFP_KERNEL, "NAME=%s", priv->thermal->type);
-	thermal_prop[1] = kasprintf(GFP_KERNEL, "TEMP=%d", priv->thermal->temperature);
+	dev = thermal_zone_device(priv->thermal);
+	
+	thermal_prop[0] = kasprintf(GFP_KERNEL, "NAME=%s", thermal_zone_device_type(priv->thermal));
+	thermal_prop[1] = kasprintf(GFP_KERNEL, "TEMP=%d", INT3400_FAKE_TEMP);
 	thermal_prop[2] = kasprintf(GFP_KERNEL, "TRIP=");
 	thermal_prop[3] = kasprintf(GFP_KERNEL, "EVENT=%d", therm_event);
 	thermal_prop[4] = NULL;
-	kobject_uevent_env(&priv->thermal->device.kobj, KOBJ_CHANGE, thermal_prop);
+	kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, thermal_prop);
 	kfree(thermal_prop[0]);
 	kfree(thermal_prop[1]);
 	kfree(thermal_prop[2]);
@@ -490,7 +494,7 @@ static void int3400_notify(acpi_handle handle,
 static int int3400_thermal_get_temp(struct thermal_zone_device *thermal,
 			int *temp)
 {
-	*temp = 20 * 1000; /* faked temp sensor with 20C */
+	*temp = INT3400_FAKE_TEMP;
 	return 0;
 }
 
-- 
2.34.1


  parent reply	other threads:[~2023-07-07 20:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-07 20:37 [PATCH v2 0/4] One more step to the thermal zone structure encapsulation Daniel Lezcano
2023-07-07 20:37 ` [PATCH v2 1/4] thermal/core: Hardening the self-encapsulation Daniel Lezcano
2023-07-07 20:37 ` [PATCH v2 2/4] thermal/core: Reorder the headers inclusion Daniel Lezcano
2023-07-07 20:37 ` Daniel Lezcano [this message]
2023-07-07 20:37 ` [PATCH v2 4/4] thermal/drivers/int340x: Do not check the thermal zone state Daniel Lezcano
2023-07-13  9:33 ` [PATCH v2 0/4] One more step to the thermal zone structure encapsulation Daniel Lezcano
2023-07-13 11:30   ` Rafael J. Wysocki
2023-07-13 12:24     ` Daniel Lezcano
2023-07-13 13:02       ` Rafael J. Wysocki
2023-07-13 14:15         ` Daniel Lezcano

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=20230707203731.848188-4-daniel.lezcano@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=amitk@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=joeyli.kernel@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=thierry.reding@gmail.com \
    --cc=ye.xingchen@zte.com.cn \
    /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).