From nobody Mon Apr 6 11:51:42 2026 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 BD4EFC6FA83 for ; Mon, 26 Sep 2022 15:19:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236154AbiIZPTr (ORCPT ); Mon, 26 Sep 2022 11:19:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236274AbiIZPSy (ORCPT ); Mon, 26 Sep 2022 11:18:54 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAE41814C0 for ; Mon, 26 Sep 2022 07:06:18 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id n10so10350623wrw.12 for ; Mon, 26 Sep 2022 07:06:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=j/sw+9v9gHiW9pHGV3mguUPhfmVIDCytTXg7SBg1sj8=; b=Eo/t9eBHevO74uyM5oV/2YegJJUw7PsuFzrVrhhGrHIDNx7TBTmevHGUiD0gSv2XiN Jx8we1lnkPuwjPSt5Iq3CxsFE+gHQ40E7LNAKK9QPvlJMajbJUPZ7HjcTtU5tpKp8Q1P nDdCQ6S1StPyAMADQTgL3aoHqLGv3SIBDil9Zc5SGrNXgIkMbSjubPaZvpkJzIO79snD ZGYyCaHdGeKRebirSFwajboSAyjA68xr/rjuVbxQXqiuHuNqkdudEIWSgvwtjJkGmyE0 8E5EKQKDSEfU4raTA2jpTQ99KZ6rZt+CDet15i1VrtShUbA7ZRgkargqPkq4T+KtkU6x 0Dbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=j/sw+9v9gHiW9pHGV3mguUPhfmVIDCytTXg7SBg1sj8=; b=Oh1VVXZD1e3PJti9wN/XPXXiBgEvikOnqypRRpWQX8SaDZpCZcXMFNttO5fZTaBAxr AbzqhPAAt8co407MeevbH7tAT6a1WGuKyw1KGGbm+crCq7J/Oso9zSpeEwhhPeHlnVso OEvyUJLNMPPgT8h+7u7i+ceGoJ9tHmLlgv6EUeZ7bTfQ289kcruzJSSIUIpTLxJz/0Vj zl3vkUUDRib1YfrocM0o0ZhHQ52WpRHAynJa+60P+IZN8m8BprNT2/Wm74xqBweIhqOQ 2rANqs/5HfxSp6n5rkT8NBdBaBRaSUvZ7vPYlnE0oUEb65++UQmOrpWmsvFQ/oiEhSaR D3hQ== X-Gm-Message-State: ACrzQf3w24G3+dgaSLjPo9PRR07OZxaUOQnWuHWzo2nHMBLDTlf8XI9x rHA1fMouMQhUB+cFvTOlosSIew== X-Google-Smtp-Source: AMsMyM787/UG3phpis9oZlPkkucDGnPIZJhFlWP88JgMD57rQiHYGGXaNqhfJAl04W6OClCE/i3ERw== X-Received: by 2002:adf:cd10:0:b0:22c:a109:f51d with SMTP id w16-20020adfcd10000000b0022ca109f51dmr4460754wrm.238.1664201176873; Mon, 26 Sep 2022 07:06:16 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:15 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria Subject: [PATCH v5 01/30] thermal/core: Add a generic thermal_zone_get_trip() function Date: Mon, 26 Sep 2022 16:05:35 +0200 Message-Id: <20220926140604.4173723-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal_zone_device_ops structure defines a set of ops family, get_trip_temp(), get_trip_hyst(), get_trip_type(). Each of them is returning a property of a trip point. The result is the code is calling the ops everywhere to get a trip point which is supposed to be defined in the backend driver. It is a non-sense as a thermal trip can be generic and used by the backend driver to declare its trip points. Part of the thermal framework has been changed and all the OF thermal drivers are using the same definition for the trip point and use a thermal zone registration variant to pass those trip points which are part of the thermal zone device structure. Consequently, we can use a generic function to get the trip points when they are stored in the thermal zone device structure. This approach can be generalized to all the drivers and we can get rid of the ops->get_trip_*. That will result to a much more simpler code and make possible to rework how the thermal trip are handled in the thermal core framework as discussed previously. This change adds a function thermal_zone_get_trip() where we get the thermal trip point structure which contains all the properties (type, temp, hyst) instead of doing multiple calls to ops->get_trip_*. That opens the door for trip point extension with more attributes. For instance, replacing the trip points disabled bitmask with a 'disabled' field in the structure. Here we replace all the calls to ops->get_trip_* in the thermal core code with a call to the thermal_zone_get_trip() function. While at it, add the thermal_zone_get_num_trips() to encapsulate the code more and reduce the grip with the thermal framework internals. Signed-off-by: Daniel Lezcano Reviewed-by: Zhang Rui --- drivers/thermal/thermal_core.c | 115 ++++++++++++++++++++++++------ drivers/thermal/thermal_core.h | 2 + drivers/thermal/thermal_helpers.c | 28 ++++---- drivers/thermal/thermal_netlink.c | 21 +++--- drivers/thermal/thermal_sysfs.c | 66 +++++++---------- include/linux/thermal.h | 5 ++ 6 files changed, 148 insertions(+), 89 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 99c0c19fa5a6..903a858df35f 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -341,35 +341,31 @@ static void handle_critical_trips(struct thermal_zone= _device *tz, tz->ops->critical(tz); } =20 -static void handle_thermal_trip(struct thermal_zone_device *tz, int trip) +static void handle_thermal_trip(struct thermal_zone_device *tz, int trip_i= d) { - enum thermal_trip_type type; - int trip_temp, hyst =3D 0; + struct thermal_trip trip; =20 /* Ignore disabled trip points */ - if (test_bit(trip, &tz->trips_disabled)) + if (test_bit(trip_id, &tz->trips_disabled)) return; =20 - tz->ops->get_trip_temp(tz, trip, &trip_temp); - tz->ops->get_trip_type(tz, trip, &type); - if (tz->ops->get_trip_hyst) - tz->ops->get_trip_hyst(tz, trip, &hyst); + __thermal_zone_get_trip(tz, trip_id, &trip); =20 if (tz->last_temperature !=3D THERMAL_TEMP_INVALID) { - if (tz->last_temperature < trip_temp && - tz->temperature >=3D trip_temp) - thermal_notify_tz_trip_up(tz->id, trip, + if (tz->last_temperature < trip.temperature && + tz->temperature >=3D trip.temperature) + thermal_notify_tz_trip_up(tz->id, trip_id, tz->temperature); - if (tz->last_temperature >=3D trip_temp && - tz->temperature < (trip_temp - hyst)) - thermal_notify_tz_trip_down(tz->id, trip, + if (tz->last_temperature >=3D trip.temperature && + tz->temperature < (trip.temperature - trip.hysteresis)) + thermal_notify_tz_trip_down(tz->id, trip_id, tz->temperature); } =20 - if (type =3D=3D THERMAL_TRIP_CRITICAL || type =3D=3D THERMAL_TRIP_HOT) - handle_critical_trips(tz, trip, trip_temp, type); + if (trip.type =3D=3D THERMAL_TRIP_CRITICAL || trip.type =3D=3D THERMAL_TR= IP_HOT) + handle_critical_trips(tz, trip_id, trip.temperature, trip.type); else - handle_non_critical_trips(tz, trip); + handle_non_critical_trips(tz, trip_id); } =20 static void update_temperature(struct thermal_zone_device *tz) @@ -1142,6 +1138,80 @@ static void thermal_set_delay_jiffies(unsigned long = *delay_jiffies, int delay_ms *delay_jiffies =3D round_jiffies(*delay_jiffies); } =20 +int thermal_zone_get_num_trips(struct thermal_zone_device *tz) +{ + return tz->num_trips; +} +EXPORT_SYMBOL_GPL(thermal_zone_get_num_trips); + +int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp) +{ + int i, ret =3D 0; + + if (tz->ops->get_crit_temp) + return tz->ops->get_crit_temp(tz, temp); +=09 + if (!tz->trips) + return -EINVAL; + + mutex_lock(&tz->lock); + + for (i =3D 0; i < tz->num_trips; i++) { + if (tz->trips[i].type =3D=3D THERMAL_TRIP_CRITICAL) { + *temp =3D tz->trips[i].temperature; + goto out; + } + } + + ret =3D -EINVAL; +out: + mutex_unlock(&tz->lock); + + return ret; +} +EXPORT_SYMBOL_GPL(thermal_zone_get_crit_temp); + +int __thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id, + struct thermal_trip *trip) +{ + int ret; + + if (!tz || trip_id < 0 || trip_id >=3D tz->num_trips || !trip) + return -EINVAL; + + if (tz->trips) { + *trip =3D tz->trips[trip_id]; + return 0; + } + + if (tz->ops->get_trip_hyst) { + ret =3D tz->ops->get_trip_hyst(tz, trip_id, &trip->hysteresis); + if (ret) + return ret; + } else { + trip->hysteresis =3D 0; + } + + ret =3D tz->ops->get_trip_temp(tz, trip_id, &trip->temperature); + if (ret) + return ret; + + return tz->ops->get_trip_type(tz, trip_id, &trip->type); +} + +int thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id, + struct thermal_trip *trip) +{ + int ret; + + mutex_lock(&tz->lock); + ret =3D __thermal_zone_get_trip(tz, trip_id, trip); + mutex_unlock(&tz->lock); + + return ret; +} +EXPORT_SYMBOL_GPL(thermal_zone_get_trip); + /** * thermal_zone_device_register_with_trips() - register a new thermal zone= device * @type: the thermal zone device type @@ -1174,8 +1244,6 @@ thermal_zone_device_register_with_trips(const char *t= ype, struct thermal_trip *t int polling_delay) { struct thermal_zone_device *tz; - enum thermal_trip_type trip_type; - int trip_temp; int id; int result; int count; @@ -1202,7 +1270,7 @@ thermal_zone_device_register_with_trips(const char *t= ype, struct thermal_trip *t return ERR_PTR(-EINVAL); } =20 - if (num_trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp)) + if (num_trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp) && !tri= ps) return ERR_PTR(-EINVAL); =20 tz =3D kzalloc(sizeof(*tz), GFP_KERNEL); @@ -1252,9 +1320,10 @@ thermal_zone_device_register_with_trips(const char *= type, struct thermal_trip *t goto release_device; =20 for (count =3D 0; count < num_trips; count++) { - if (tz->ops->get_trip_type(tz, count, &trip_type) || - tz->ops->get_trip_temp(tz, count, &trip_temp) || - !trip_temp) + struct thermal_trip trip; + + result =3D thermal_zone_get_trip(tz, count, &trip); + if (result) set_bit(count, &tz->trips_disabled); } =20 diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 1571917bd3c8..879e91a48435 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -113,6 +113,8 @@ int thermal_build_list_of_policies(char *buf); /* Helpers */ void thermal_zone_set_trips(struct thermal_zone_device *tz); void __thermal_zone_set_trips(struct thermal_zone_device *tz); +int __thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id, + struct thermal_trip *trip); int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp); =20 /* sysfs I/F */ diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_he= lpers.c index c65cdce8f856..06dded36e95e 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -69,7 +69,7 @@ int __thermal_zone_get_temp(struct thermal_zone_device *t= z, int *temp) int ret =3D -EINVAL; int count; int crit_temp =3D INT_MAX; - enum thermal_trip_type type; + struct thermal_trip trip; =20 lockdep_assert_held(&tz->lock); =20 @@ -80,10 +80,9 @@ int __thermal_zone_get_temp(struct thermal_zone_device *= tz, int *temp) =20 if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) { for (count =3D 0; count < tz->num_trips; count++) { - ret =3D tz->ops->get_trip_type(tz, count, &type); - if (!ret && type =3D=3D THERMAL_TRIP_CRITICAL) { - ret =3D tz->ops->get_trip_temp(tz, count, - &crit_temp); + ret =3D __thermal_zone_get_trip(tz, count, &trip); + if (!ret && trip.type =3D=3D THERMAL_TRIP_CRITICAL) { + crit_temp =3D trip.temperature; break; } } @@ -124,29 +123,30 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_temp); =20 void __thermal_zone_set_trips(struct thermal_zone_device *tz) { - int low =3D -INT_MAX; - int high =3D INT_MAX; - int trip_temp, hysteresis; + struct thermal_trip trip; + int low =3D -INT_MAX, high =3D INT_MAX; int i, ret; =20 lockdep_assert_held(&tz->lock); =20 - if (!tz->ops->set_trips || !tz->ops->get_trip_hyst) + if (!tz->ops->set_trips) return; =20 for (i =3D 0; i < tz->num_trips; i++) { int trip_low; =20 - tz->ops->get_trip_temp(tz, i, &trip_temp); - tz->ops->get_trip_hyst(tz, i, &hysteresis); + ret =3D __thermal_zone_get_trip(tz, i , &trip); + if (ret) + return; =20 - trip_low =3D trip_temp - hysteresis; + trip_low =3D trip.temperature - trip.hysteresis; =20 if (trip_low < tz->temperature && trip_low > low) low =3D trip_low; =20 - if (trip_temp > tz->temperature && trip_temp < high) - high =3D trip_temp; + if (trip.temperature > tz->temperature && + trip.temperature < high) + high =3D trip.temperature; } =20 /* No need to change trip points */ diff --git a/drivers/thermal/thermal_netlink.c b/drivers/thermal/thermal_ne= tlink.c index 050d243a5fa1..2a3190d55358 100644 --- a/drivers/thermal/thermal_netlink.c +++ b/drivers/thermal/thermal_netlink.c @@ -452,7 +452,8 @@ static int thermal_genl_cmd_tz_get_trip(struct param *p) struct sk_buff *msg =3D p->msg; struct thermal_zone_device *tz; struct nlattr *start_trip; - int i, id; + struct thermal_trip trip; + int ret, i, id; =20 if (!p->attrs[THERMAL_GENL_ATTR_TZ_ID]) return -EINVAL; @@ -471,18 +472,14 @@ static int thermal_genl_cmd_tz_get_trip(struct param = *p) =20 for (i =3D 0; i < tz->num_trips; i++) { =20 - enum thermal_trip_type type; - int temp, hyst =3D 0; - - tz->ops->get_trip_type(tz, i, &type); - tz->ops->get_trip_temp(tz, i, &temp); - if (tz->ops->get_trip_hyst) - tz->ops->get_trip_hyst(tz, i, &hyst); - + ret =3D __thermal_zone_get_trip(tz, i, &trip); + if (ret) + goto out_cancel_nest; + =09 if (nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, i) || - nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, type) || - nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TEMP, temp) || - nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_HYST, hyst)) + nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, trip.type) || + nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TEMP, trip.temperature) || + nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_HYST, trip.hysteresis)) goto out_cancel_nest; } =20 diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysf= s.c index 78c5841bdfae..75f6b151a58b 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -83,20 +83,17 @@ trip_point_type_show(struct device *dev, struct device_= attribute *attr, char *buf) { struct thermal_zone_device *tz =3D to_thermal_zone(dev); - enum thermal_trip_type type; - int trip, result; + struct thermal_trip trip; + int trip_id, result; =20 - if (!tz->ops->get_trip_type) - return -EPERM; - - if (sscanf(attr->attr.name, "trip_point_%d_type", &trip) !=3D 1) + if (sscanf(attr->attr.name, "trip_point_%d_type", &trip_id) !=3D 1) return -EINVAL; =20 - result =3D tz->ops->get_trip_type(tz, trip, &type); + result =3D thermal_zone_get_trip(tz, trip_id, &trip); if (result) return result; =20 - switch (type) { + switch (trip.type) { case THERMAL_TRIP_CRITICAL: return sprintf(buf, "critical\n"); case THERMAL_TRIP_HOT: @@ -115,37 +112,31 @@ trip_point_temp_store(struct device *dev, struct devi= ce_attribute *attr, const char *buf, size_t count) { struct thermal_zone_device *tz =3D to_thermal_zone(dev); - int trip, ret; - int temperature, hyst =3D 0; - enum thermal_trip_type type; + struct thermal_trip trip; + int trip_id, ret; =20 if (!tz->ops->set_trip_temp && !tz->trips) return -EPERM; =20 - if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip) !=3D 1) + if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip_id) !=3D 1) return -EINVAL; =20 - if (kstrtoint(buf, 10, &temperature)) + if (kstrtoint(buf, 10, &trip.temperature)) return -EINVAL; =20 - ret =3D tz->ops->set_trip_temp(tz, trip, temperature); + ret =3D tz->ops->set_trip_temp(tz, trip_id, trip.temperature); if (ret) return ret; =20 if (tz->trips) - tz->trips[trip].temperature =3D temperature; - - if (tz->ops->get_trip_hyst) { - ret =3D tz->ops->get_trip_hyst(tz, trip, &hyst); - if (ret) - return ret; - } + tz->trips[trip_id].temperature =3D trip.temperature; =20 - ret =3D tz->ops->get_trip_type(tz, trip, &type); + ret =3D thermal_zone_get_trip(tz, trip_id, &trip); if (ret) return ret; =20 - thermal_notify_tz_trip_change(tz->id, trip, type, temperature, hyst); + thermal_notify_tz_trip_change(tz->id, trip_id, trip.type, + trip.temperature, trip.hysteresis); =20 thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); =20 @@ -157,21 +148,17 @@ trip_point_temp_show(struct device *dev, struct devic= e_attribute *attr, char *buf) { struct thermal_zone_device *tz =3D to_thermal_zone(dev); - int trip, ret; - int temperature; - - if (!tz->ops->get_trip_temp) - return -EPERM; + struct thermal_trip trip; + int trip_id, ret; =20 - if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip) !=3D 1) + if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip_id) !=3D 1) return -EINVAL; =20 - ret =3D tz->ops->get_trip_temp(tz, trip, &temperature); - + ret =3D thermal_zone_get_trip(tz, trip_id, &trip); if (ret) return ret; =20 - return sprintf(buf, "%d\n", temperature); + return sprintf(buf, "%d\n", trip.temperature); } =20 static ssize_t @@ -209,18 +196,17 @@ trip_point_hyst_show(struct device *dev, struct devic= e_attribute *attr, char *buf) { struct thermal_zone_device *tz =3D to_thermal_zone(dev); - int trip, ret; - int temperature; + struct thermal_trip trip; + int trip_id, ret; =20 - if (!tz->ops->get_trip_hyst) - return -EPERM; - - if (sscanf(attr->attr.name, "trip_point_%d_hyst", &trip) !=3D 1) + if (sscanf(attr->attr.name, "trip_point_%d_hyst", &trip_id) !=3D 1) return -EINVAL; =20 - ret =3D tz->ops->get_trip_hyst(tz, trip, &temperature); + ret =3D thermal_zone_get_trip(tz, trip_id, &trip); + if (ret) + return ret; =20 - return ret ? ret : sprintf(buf, "%d\n", temperature); + return ret ? ret : sprintf(buf, "%d\n", trip.hysteresis); } =20 static ssize_t diff --git a/include/linux/thermal.h b/include/linux/thermal.h index a5a18351a898..09dc09228717 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -335,6 +335,11 @@ static inline void devm_thermal_of_zone_unregister(str= uct device *dev, } #endif =20 +int thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id, + struct thermal_trip *trip); + +int thermal_zone_get_num_trips(struct thermal_zone_device *tz); + #ifdef CONFIG_THERMAL struct thermal_zone_device *thermal_zone_device_register(const char *, int= , int, void *, struct thermal_zone_device_ops *, --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 16993C07E9D for ; Mon, 26 Sep 2022 15:19:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235931AbiIZPTm (ORCPT ); Mon, 26 Sep 2022 11:19:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236269AbiIZPSx (ORCPT ); Mon, 26 Sep 2022 11:18:53 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D537C80F5E for ; Mon, 26 Sep 2022 07:06:19 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id n15so10421580wrq.5 for ; Mon, 26 Sep 2022 07:06:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=re6cY3b7LhtgjVns3TGnT3S1+gVlK6XqwvcFa/mv1ME=; b=UArrlRfiA7hARrUKxyfl5qW5zdqodgK/nppx0Qeo6Z/EJdqqMPBoC/UCikPkNEwTrE lBAoUIl/x4G/04V/BApjMHBMdKDHRzN8E/qaxzUlkK7rHiGTRgzLdMrG1q0J3wsgnnVL bcN8FS7xv105kiyJrwcTUuwNz5YE85Jji0WjSVqkRfuRHCZlTEu/RD30Z04+IHa7uUgD ewnho3xP3gZGvAAB6EabBd1MgKPjhhGg3ycL7L2SNURc2F4cykFcGmI0ABEF3Zq2lume +bfjp6DH21cnDgFr9VixSciEa1dyLp86NobKr26L3h5dV2Eaev3k2qxQ6bPp41KkOwW3 gWNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=re6cY3b7LhtgjVns3TGnT3S1+gVlK6XqwvcFa/mv1ME=; b=kZQKaCl8dwa1jflaAEHHA3pEpk3ymkG/fHE4hKkKFL95VA1OSLJQ3hJdq1Vv6DO2az 7Wx0X55CRumV+TLBMs8jUFe6npuD2iqAmZq+m+isjG03wbvfZWu9vEdN9jHzoTEiq2FU M7MpmvDjD+0Q1Pm+NiAS8VgmZzgb5y6/ipiSoIh3w1bFjmDqT19kD/ky7/0s0ypigKLS bbVekUdGy9UTQkLhke2xaEPqKDtY9q/1G9zttNOk2oHBWUiGwaDAfuNfhWGs94v0Vt9y Ae5RIVvaOhgKGEqEr/eutgyPKrCgSIA0hIbwruMyfvfFkig3rne9/YPokwFjUdS1/bGn ZgAQ== X-Gm-Message-State: ACrzQf0hdqo2n3PyfkRU73FtSkRm1bO36jhYFkKlszOFIPFp+5MF7ljA c2SfG8G2IEPSdrXzYxRM4gSwaA== X-Google-Smtp-Source: AMsMyM7x8Bz2InUxuLwoQQqUMfcUpSu5SW4qKXBpq6+/e1iKeNRs9vA4dkjkDNjUT01Bccc3Cia69Q== X-Received: by 2002:a05:6000:1864:b0:22a:e349:f031 with SMTP id d4-20020a056000186400b0022ae349f031mr13752016wri.476.1664201178267; Mon, 26 Sep 2022 07:06:18 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:17 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria Subject: [PATCH v5 02/30] thermal/sysfs: Do not make get_trip_hyst optional Date: Mon, 26 Sep 2022 16:05:36 +0200 Message-Id: <20220926140604.4173723-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The get_trip_hyst() ops is optional. It results all around the thermal framework code a check against the ops pointer and different action adding more complexity and making the code less readable and understandable. A zero hysteresis value is perfectly valid, so instead of adding more circumvolutions in the code, create unconditionnaly the hysteresis and use the thermal_zone_get_trip() function which returns a zero hysteresis if the get_trip_hyst() is not defined. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_sysfs.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysf= s.c index 75f6b151a58b..18cdd7cd0008 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -424,23 +424,20 @@ static int create_trip_attrs(struct thermal_zone_devi= ce *tz, int mask) return -ENOMEM; } =20 - if (tz->ops->get_trip_hyst) { - tz->trip_hyst_attrs =3D kcalloc(tz->num_trips, - sizeof(*tz->trip_hyst_attrs), - GFP_KERNEL); - if (!tz->trip_hyst_attrs) { - kfree(tz->trip_type_attrs); - kfree(tz->trip_temp_attrs); - return -ENOMEM; - } + tz->trip_hyst_attrs =3D kcalloc(tz->num_trips, + sizeof(*tz->trip_hyst_attrs), + GFP_KERNEL); + if (!tz->trip_hyst_attrs) { + kfree(tz->trip_type_attrs); + kfree(tz->trip_temp_attrs); + return -ENOMEM; } =20 attrs =3D kcalloc(tz->num_trips * 3 + 1, sizeof(*attrs), GFP_KERNEL); if (!attrs) { kfree(tz->trip_type_attrs); kfree(tz->trip_temp_attrs); - if (tz->ops->get_trip_hyst) - kfree(tz->trip_hyst_attrs); + kfree(tz->trip_hyst_attrs); return -ENOMEM; } =20 @@ -473,9 +470,6 @@ static int create_trip_attrs(struct thermal_zone_device= *tz, int mask) } attrs[indx + tz->num_trips] =3D &tz->trip_temp_attrs[indx].attr.attr; =20 - /* create Optional trip hyst attribute */ - if (!tz->ops->get_trip_hyst) - continue; snprintf(tz->trip_hyst_attrs[indx].name, THERMAL_NAME_LENGTH, "trip_point_%d_hyst", indx); =20 @@ -512,8 +506,7 @@ static void destroy_trip_attrs(struct thermal_zone_devi= ce *tz) =20 kfree(tz->trip_type_attrs); kfree(tz->trip_temp_attrs); - if (tz->ops->get_trip_hyst) - kfree(tz->trip_hyst_attrs); + kfree(tz->trip_hyst_attrs); kfree(tz->trips_attribute_group.attrs); } =20 --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 140C9C6FA83 for ; Mon, 26 Sep 2022 15:19:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236165AbiIZPTt (ORCPT ); Mon, 26 Sep 2022 11:19:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236271AbiIZPSx (ORCPT ); Mon, 26 Sep 2022 11:18:53 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25D0981696 for ; Mon, 26 Sep 2022 07:06:21 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id e18so4580263wmq.3 for ; Mon, 26 Sep 2022 07:06:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=LWUSHCJ7OfLyXhypGb9pb8SFllwy6yIkhbdWXrtw3Z8=; b=ZkGpFlM6gwmZgkWKZDjSlzYO+KxUpTRkG88i8pb74UEmWlvIOSEXh3KP/KS4MjvS7b uWIvf3M4P6fyfze1LiZ+qd+rfJGegXLD4kp8xCicietAjMJJKKjSy3Cl5DouU7wlWdBA bxZsaae0LHpYMEMNqIkT9XmfY+hUttPC+a6Xic8ffyqLjPxbrwtVtmoM2mkBZttadgUz 62mjK9l4TpmuGkE2dEHF3m7pgrl0QkaFqlER/IHVH4PbzsR9zhpZt0AqhAb5GwG9Jjnc rawChWTeILVxdAaRXnqc1eEuaEL7oEgppkCcvuyNPIZCgLBREF96ZumeIdu50xxATGsn 6iYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=LWUSHCJ7OfLyXhypGb9pb8SFllwy6yIkhbdWXrtw3Z8=; b=WWppB+5G6BJ94vEVjMWx3lgxWvGnrSS43lES8WkTmsz3K1gmbWhAJ+5zffcZIYYZXH jsHRz7kxAAUq0Rc1JZi0hrpLnTDc+mhExPj7jlb03nX+hHqSPxVKOVXVu2nmni10TiCR 3CIffT7q3NxHbfs1LjoSW/ZL9hJUzhiktfNfhP6c6rq559J0YT8IMpsIHNmgc+x5R+rg OqlpR91p866l7DuhvxY+P2aJQNRnzNh+KLA3Nf0Cuiys1PM+Usw1gq8NNKKilyS1JY6M agtAKWpWZ9DejcGVICUd7CFZvYnnfggYjsCIVUYdNSEfDn6ek5TF5I77QaF32PvEN0sf UyaQ== X-Gm-Message-State: ACrzQf3KmZm+tm217ksuB0pxbdqC1Mfsg1drDP6pPWxoeL4+5Ep5dh1W N1dnlVZthPuhP70hpaAMlvQ6kA== X-Google-Smtp-Source: AMsMyM7XW/SjYQTZ1CbbYJencjUx2l8y8/VQ6y+UtBJcd8bqpASCG4qJQlMLZTuvU3CJOyIBOV2MFQ== X-Received: by 2002:a05:600c:23ca:b0:3b4:6199:8ab9 with SMTP id p10-20020a05600c23ca00b003b461998ab9mr21727232wmb.20.1664201179580; Mon, 26 Sep 2022 07:06:19 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:19 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria Subject: [PATCH v5 03/30] thermal/core: Add a generic thermal_zone_set_trip() function Date: Mon, 26 Sep 2022 16:05:37 +0200 Message-Id: <20220926140604.4173723-4-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal zone ops defines a set_trip callback where we can invoke the backend driver to set an interrupt for the next trip point temperature being crossed the way up or down, or setting the low level with the hysteresis. The ops is only called from the thermal sysfs code where the userspace has the ability to modify a trip point characteristic. With the effort of encapsulating the thermal framework core code, let's create a thermal_zone_set_trip() which is the writable side of the thermal_zone_get_trip() and put there all the ops encapsulation. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.c | 45 +++++++++++++++++++++++++++++++ drivers/thermal/thermal_sysfs.c | 48 +++++++++++---------------------- include/linux/thermal.h | 3 +++ 3 files changed, 64 insertions(+), 32 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 903a858df35f..9f61b0ab57b7 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1212,6 +1212,51 @@ int thermal_zone_get_trip(struct thermal_zone_device= *tz, int trip_id, } EXPORT_SYMBOL_GPL(thermal_zone_get_trip); =20 +int thermal_zone_set_trip(struct thermal_zone_device *tz, int trip_id, + const struct thermal_trip *trip) +{ + struct thermal_trip t; + int ret =3D -EINVAL; + + mutex_lock(&tz->lock); + + if (!tz->ops->set_trip_temp && !tz->ops->set_trip_hyst && !tz->trips) + goto out; + + ret =3D __thermal_zone_get_trip(tz, trip_id, &t); + if (ret) + goto out; + + if ((t.temperature !=3D trip->temperature) && tz->ops->set_trip_temp) { + + ret =3D tz->ops->set_trip_temp(tz, trip_id, trip->temperature); + if (ret) + goto out; + } + + if ((t.hysteresis !=3D trip->hysteresis) && tz->ops->set_trip_hyst) { + + ret =3D tz->ops->set_trip_hyst(tz, trip_id, trip->hysteresis); + if (ret) + goto out; + } + + if (((t.temperature !=3D trip->temperature) || + (t.hysteresis !=3D trip->hysteresis)) && tz->trips) + tz->trips[trip_id] =3D *trip; + +out: + mutex_unlock(&tz->lock); + + if (!ret) { + thermal_notify_tz_trip_change(tz->id, trip_id, trip->type, + trip->temperature, trip->hysteresis); + thermal_zone_device_update(tz, THERMAL_TRIP_CHANGED); + } +=09 + return ret; +} + /** * thermal_zone_device_register_with_trips() - register a new thermal zone= device * @type: the thermal zone device type diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysf= s.c index 18cdd7cd0008..8d7b25ab67c2 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -115,31 +115,20 @@ trip_point_temp_store(struct device *dev, struct devi= ce_attribute *attr, struct thermal_trip trip; int trip_id, ret; =20 - if (!tz->ops->set_trip_temp && !tz->trips) - return -EPERM; - if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip_id) !=3D 1) return -EINVAL; =20 - if (kstrtoint(buf, 10, &trip.temperature)) - return -EINVAL; - - ret =3D tz->ops->set_trip_temp(tz, trip_id, trip.temperature); + ret =3D thermal_zone_get_trip(tz, trip_id, &trip); if (ret) return ret; =20 - if (tz->trips) - tz->trips[trip_id].temperature =3D trip.temperature; + if (kstrtoint(buf, 10, &trip.temperature)) + return -EINVAL; =20 - ret =3D thermal_zone_get_trip(tz, trip_id, &trip); + ret =3D thermal_zone_set_trip(tz, trip_id, &trip); if (ret) return ret; =20 - thermal_notify_tz_trip_change(tz->id, trip_id, trip.type, - trip.temperature, trip.hysteresis); - - thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); - return count; } =20 @@ -166,29 +155,24 @@ trip_point_hyst_store(struct device *dev, struct devi= ce_attribute *attr, const char *buf, size_t count) { struct thermal_zone_device *tz =3D to_thermal_zone(dev); - int trip, ret; - int temperature; - - if (!tz->ops->set_trip_hyst) - return -EPERM; + struct thermal_trip trip; + int trip_id, ret; =20 - if (sscanf(attr->attr.name, "trip_point_%d_hyst", &trip) !=3D 1) + if (sscanf(attr->attr.name, "trip_point_%d_hyst", &trip_id) !=3D 1) return -EINVAL; =20 - if (kstrtoint(buf, 10, &temperature)) - return -EINVAL; + ret =3D thermal_zone_get_trip(tz, trip_id, &trip); + if (ret) + return ret; =20 - /* - * We are not doing any check on the 'temperature' value - * here. The driver implementing 'set_trip_hyst' has to - * take care of this. - */ - ret =3D tz->ops->set_trip_hyst(tz, trip, temperature); + if (kstrtoint(buf, 10, &trip.hysteresis)) + return -EINVAL; =20 - if (!ret) - thermal_zone_set_trips(tz); + ret =3D thermal_zone_set_trip(tz, trip_id, &trip); + if (ret) + return ret; =20 - return ret ? ret : count; + return count; } =20 static ssize_t diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 09dc09228717..5350a437f245 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -338,6 +338,9 @@ static inline void devm_thermal_of_zone_unregister(stru= ct device *dev, int thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id, struct thermal_trip *trip); =20 +int thermal_zone_set_trip(struct thermal_zone_device *tz, int trip_id, + const struct thermal_trip *trip); + int thermal_zone_get_num_trips(struct thermal_zone_device *tz); =20 #ifdef CONFIG_THERMAL --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 3BA55C32771 for ; Mon, 26 Sep 2022 15:19:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236172AbiIZPTx (ORCPT ); Mon, 26 Sep 2022 11:19:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236286AbiIZPSz (ORCPT ); Mon, 26 Sep 2022 11:18:55 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CE21816AE for ; Mon, 26 Sep 2022 07:06:23 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id bk15so2650729wrb.13 for ; Mon, 26 Sep 2022 07:06:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=jmpCz9X5WVxh1IdlD0BjEhB4jAKQCO/83Z0tz1CW7NQ=; b=Unj4fsRjSapJWLRiFGOi/9WlHeSp6j1ZX58v54hU5ozvLpi+exiOKyQlOCR2lYf2Hi fYvVjRurDnsQ3WPDVkXCtLPg7OTrz0mEVzLv/kGBGoI0o74I2PsgBS/KIrkbI5Idgkia sV4LrrCvW04KdbPdiDT0exoEhy8c6bUs7FyZLftnl6C3dw8pJDfg1lVha9ktTeuQ60mX cvJ5xlOSXbv3UPaHkGXnBuvduIbg7wbmdGH6k0vOlrD88bG95fdS2YQN0nWQGw61Z2CR WB2CzQ6T4C+nd3xxU7eJzTiNm6+klk86UyU24RESrWc6ju4NGHHQFC0091Dc1nXcmL9/ sJ4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=jmpCz9X5WVxh1IdlD0BjEhB4jAKQCO/83Z0tz1CW7NQ=; b=Tl6lyw/KfD7s+UHz0b2OFf1c8XMIXUfAj5MqRU4no8Yjp7M7Qb8tM01Q48yry6JELp u2Q96ZnMAOKE+qSfJneBxclDb7lzPF04pg0cOHnKYcCnAS+0fsgmwOo2ulhnqheP4OPH /AgZets05cipvgMl6hMwSVV/rg9hSAfqK3JrzmTp5vTzV+a8dhohge7RTQ0Wo69XBXho +ZjNsPklRo6WqsZ9kYyeWf4T1fY85YYNybB0etkXY84D8ZrVNGQUroNa2fBoNW0rypiM PB09zcllyLL8Y4nt/6uC8EIhtPwiIzxeI8z37IsGEKOce4kPcj/oITYQKXdT1YhIn098 1yNw== X-Gm-Message-State: ACrzQf29/4+FFaKwGtpxP+dYudHXTk1EgUQJm5b4ZnuGLxQ6lIprHmOx 3wIKSbKR7Png12dShjEyFsHI3g== X-Google-Smtp-Source: AMsMyM5EYPBaxhG7sUBR7UFiqb5ixd3MZAfz3SJXSrKw3i+AlWtnzb+g5TMD3a4r2OaxwnaM8Nwsaw== X-Received: by 2002:adf:d0d2:0:b0:22a:daf4:87e8 with SMTP id z18-20020adfd0d2000000b0022adaf487e8mr13522466wrh.167.1664201181346; Mon, 26 Sep 2022 07:06:21 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:20 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria Subject: [PATCH v5 04/30] thermal/core: Add a generic thermal_zone_get_crit_temp() function Date: Mon, 26 Sep 2022 16:05:38 +0200 Message-Id: <20220926140604.4173723-5-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal zone ops defines a callback to retrieve the critical temperature. As the trip handling is being reworked, all the trip points will be the same whatever the driver and consequently finding the critical trip temperature will be just a loop to search for a critical trip point type. Provide such a generic function, so we encapsulate the ops get_crit_temp() which can be removed when all the backend drivers are using the generic trip points handling. Signed-off-by: Daniel Lezcano Reviewed-by: Zhang Rui --- include/linux/thermal.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 5350a437f245..66373f872237 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -343,6 +343,8 @@ int thermal_zone_set_trip(struct thermal_zone_device *t= z, int trip_id, =20 int thermal_zone_get_num_trips(struct thermal_zone_device *tz); =20 +int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp); + #ifdef CONFIG_THERMAL struct thermal_zone_device *thermal_zone_device_register(const char *, int= , int, void *, struct thermal_zone_device_ops *, --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 2AABBC07E9D for ; Mon, 26 Sep 2022 15:20:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236179AbiIZPUC (ORCPT ); Mon, 26 Sep 2022 11:20:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236291AbiIZPS4 (ORCPT ); Mon, 26 Sep 2022 11:18:56 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79B73248EA for ; Mon, 26 Sep 2022 07:06:24 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id o20-20020a05600c4fd400b003b4a516c479so3795196wmq.1 for ; Mon, 26 Sep 2022 07:06:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=WOJI4VTZybfWll0BTLktHx/CwB/dkoqbgO5uP71FtsI=; b=HwQRABrP3VI3Igs09vw3jaG0HX7ALnvCYmi0TYZrpC2kVlCz+dkH22fhsIKZEPPPgb l21FOo4yqkubqtEZkODNuYx/MDkNsh8Es6ThqB1mOgpZxnNx1ozep4pAiVGJR5pDYwoO CfAdNmOSFyPitqkGVEIa2K6W3t+I1k7LFtWHThuhYUtvmbv5n/LWRFBssr2Sf7362CKy M5DoxrORy8CCrh15x+pnYy01oQQ7NI6g8zkmyOFEik+dk+NcwmrYPuO8+o0bdGbYBAHv tfcqDwL9XQiDpMXkchLzW1vIftj0XB9YQMi+XHSMMSV5Ul475I7B3OOlAipxc2JlYwPr dpow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=WOJI4VTZybfWll0BTLktHx/CwB/dkoqbgO5uP71FtsI=; b=oUCD/PFBbcm65pSakaoPLwdDxr1AlXb9pZdL3YHg57DwAYa0JaMI988BG4EBZ1cRLL PNdCrq3RwtlUyYJ7dLVF8fxo3O017OLigZ4UQmoj2bSfuGZKDBCIAFi1etu6gaAtHsLl Ui4fJoe0rCzKinSwcgmmqedlSlW/Om0FJ/MN6RvYvn7quY3/iXllfxHYoEMvKaAY8vK4 t2T4EF3PBywe/ttRY/eO2nU/7Wm2UuzUxPY9Pt4Qc0jzmskZrq8cTvqmdrtUUZjgyh8o c2Bx8KEP5jDMe3pM9oVTzNS6an0f20ch0O/q47DvPnOvY8Iuelm9OZokUQdsClWSUR4q DaaA== X-Gm-Message-State: ACrzQf2D8cDl/XNGOjYtVr7Xw3G19Uq1B7eIEHu+evJ19LW/h3XtYUVi 0REywzi7gLfHkUR4UlwjuV7gxA== X-Google-Smtp-Source: AMsMyM6YlGRzRnxeAfnA42lsDcgViQ862yPsGeXk7n1boCl9dTGs5dpSkEWy0RiFirXYWulcPB8Kew== X-Received: by 2002:a05:600c:4f89:b0:3b4:a6fc:89e5 with SMTP id n9-20020a05600c4f8900b003b4a6fc89e5mr21479401wmq.149.1664201182664; Mon, 26 Sep 2022 07:06:22 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:22 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Lukasz Luba , Amit Kucheria Subject: [PATCH v5 05/30] thermal/core/governors: Use thermal_zone_get_trip() instead of ops functions Date: Mon, 26 Sep 2022 16:05:39 +0200 Message-Id: <20220926140604.4173723-6-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The governors are using the ops->get_trip_* functions, Replace these calls with thermal_zone_get_trip(). Signed-off-by: Daniel Lezcano Reviewed-by: Zhang Rui Reviewed-by: Lukasz Luba # IPA --- drivers/thermal/gov_bang_bang.c | 29 ++++++++------- drivers/thermal/gov_fair_share.c | 18 ++++------ drivers/thermal/gov_power_allocator.c | 51 ++++++++++++--------------- drivers/thermal/gov_step_wise.c | 22 ++++++------ 4 files changed, 53 insertions(+), 67 deletions(-) diff --git a/drivers/thermal/gov_bang_bang.c b/drivers/thermal/gov_bang_ban= g.c index a08bbe33be96..f5b85e5ea707 100644 --- a/drivers/thermal/gov_bang_bang.c +++ b/drivers/thermal/gov_bang_bang.c @@ -13,26 +13,25 @@ =20 #include "thermal_core.h" =20 -static void thermal_zone_trip_update(struct thermal_zone_device *tz, int t= rip) +static void thermal_zone_trip_update(struct thermal_zone_device *tz, int t= rip_id) { - int trip_temp, trip_hyst; + struct thermal_trip trip; struct thermal_instance *instance; + int ret; =20 - tz->ops->get_trip_temp(tz, trip, &trip_temp); - - if (!tz->ops->get_trip_hyst) { - pr_warn_once("Undefined get_trip_hyst for thermal zone %s - " - "running with default hysteresis zero\n", tz->type); - trip_hyst =3D 0; - } else - tz->ops->get_trip_hyst(tz, trip, &trip_hyst); + ret =3D __thermal_zone_get_trip(tz, trip_id, &trip); + if (ret) + pr_warn_once("Failed to retrieve trip point %d\n", trip_id); +=09 + if (!trip.hysteresis) + pr_warn_once("Zero hysteresis value for thermal zone %s\n", tz->type); =20 dev_dbg(&tz->device, "Trip%d[temp=3D%d]:temp=3D%d:hyst=3D%d\n", - trip, trip_temp, tz->temperature, - trip_hyst); + trip_id, trip.temperature, tz->temperature, + trip.hysteresis); =20 list_for_each_entry(instance, &tz->thermal_instances, tz_node) { - if (instance->trip !=3D trip) + if (instance->trip !=3D trip_id) continue; =20 /* in case fan is in initial state, switch the fan off */ @@ -50,10 +49,10 @@ static void thermal_zone_trip_update(struct thermal_zon= e_device *tz, int trip) * enable fan when temperature exceeds trip_temp and disable * the fan in case it falls below trip_temp minus hysteresis */ - if (instance->target =3D=3D 0 && tz->temperature >=3D trip_temp) + if (instance->target =3D=3D 0 && tz->temperature >=3D trip.temperature) instance->target =3D 1; else if (instance->target =3D=3D 1 && - tz->temperature <=3D trip_temp - trip_hyst) + tz->temperature <=3D trip.temperature - trip.hysteresis) instance->target =3D 0; =20 dev_dbg(&instance->cdev->device, "target=3D%d\n", diff --git a/drivers/thermal/gov_fair_share.c b/drivers/thermal/gov_fair_sh= are.c index a4ee4661e9cc..bca60cd21655 100644 --- a/drivers/thermal/gov_fair_share.c +++ b/drivers/thermal/gov_fair_share.c @@ -21,16 +21,12 @@ */ static int get_trip_level(struct thermal_zone_device *tz) { - int count =3D 0; - int trip_temp; - enum thermal_trip_type trip_type; - - if (tz->num_trips =3D=3D 0 || !tz->ops->get_trip_temp) - return 0; + struct thermal_trip trip; + int count; =20 for (count =3D 0; count < tz->num_trips; count++) { - tz->ops->get_trip_temp(tz, count, &trip_temp); - if (tz->temperature < trip_temp) + __thermal_zone_get_trip(tz, count, &trip); + if (tz->temperature < trip.temperature) break; } =20 @@ -38,10 +34,8 @@ static int get_trip_level(struct thermal_zone_device *tz) * count > 0 only if temperature is greater than first trip * point, in which case, trip_point =3D count - 1 */ - if (count > 0) { - tz->ops->get_trip_type(tz, count - 1, &trip_type); - trace_thermal_zone_trip(tz, count - 1, trip_type); - } + if (count > 0) + trace_thermal_zone_trip(tz, count - 1, trip.type); =20 return count; } diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_po= wer_allocator.c index 2d1aeaba38a8..eafb28839281 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -125,16 +125,15 @@ static void estimate_pid_constants(struct thermal_zon= e_device *tz, u32 sustainable_power, int trip_switch_on, int control_temp) { + struct thermal_trip trip; + u32 temperature_threshold =3D control_temp; int ret; - int switch_on_temp; - u32 temperature_threshold; s32 k_i; =20 - ret =3D tz->ops->get_trip_temp(tz, trip_switch_on, &switch_on_temp); - if (ret) - switch_on_temp =3D 0; + ret =3D __thermal_zone_get_trip(tz, trip_switch_on, &trip); + if (!ret) + temperature_threshold -=3D trip.temperature; =20 - temperature_threshold =3D control_temp - switch_on_temp; /* * estimate_pid_constants() tries to find appropriate default * values for thermal zones that don't provide them. If a @@ -520,10 +519,10 @@ static void get_governor_trips(struct thermal_zone_de= vice *tz, last_passive =3D INVALID_TRIP; =20 for (i =3D 0; i < tz->num_trips; i++) { - enum thermal_trip_type type; + struct thermal_trip trip; int ret; =20 - ret =3D tz->ops->get_trip_type(tz, i, &type); + ret =3D __thermal_zone_get_trip(tz, i, &trip); if (ret) { dev_warn(&tz->device, "Failed to get trip point %d type: %d\n", i, @@ -531,14 +530,14 @@ static void get_governor_trips(struct thermal_zone_de= vice *tz, continue; } =20 - if (type =3D=3D THERMAL_TRIP_PASSIVE) { + if (trip.type =3D=3D THERMAL_TRIP_PASSIVE) { if (!found_first_passive) { params->trip_switch_on =3D i; found_first_passive =3D true; } else { last_passive =3D i; } - } else if (type =3D=3D THERMAL_TRIP_ACTIVE) { + } else if (trip.type =3D=3D THERMAL_TRIP_ACTIVE) { last_active =3D i; } else { break; @@ -633,7 +632,7 @@ static int power_allocator_bind(struct thermal_zone_dev= ice *tz) { int ret; struct power_allocator_params *params; - int control_temp; + struct thermal_trip trip; =20 ret =3D check_power_actors(tz); if (ret) @@ -659,13 +658,12 @@ static int power_allocator_bind(struct thermal_zone_d= evice *tz) get_governor_trips(tz, params); =20 if (tz->num_trips > 0) { - ret =3D tz->ops->get_trip_temp(tz, - params->trip_max_desired_temperature, - &control_temp); + ret =3D __thermal_zone_get_trip(tz, params->trip_max_desired_temperature, + &trip); if (!ret) estimate_pid_constants(tz, tz->tzp->sustainable_power, params->trip_switch_on, - control_temp); + trip.temperature); } =20 reset_pid_controller(params); @@ -695,11 +693,11 @@ static void power_allocator_unbind(struct thermal_zon= e_device *tz) tz->governor_data =3D NULL; } =20 -static int power_allocator_throttle(struct thermal_zone_device *tz, int tr= ip) +static int power_allocator_throttle(struct thermal_zone_device *tz, int tr= ip_id) { - int ret; - int switch_on_temp, control_temp; struct power_allocator_params *params =3D tz->governor_data; + struct thermal_trip trip; + int ret; bool update; =20 lockdep_assert_held(&tz->lock); @@ -708,13 +706,12 @@ static int power_allocator_throttle(struct thermal_zo= ne_device *tz, int trip) * We get called for every trip point but we only need to do * our calculations once */ - if (trip !=3D params->trip_max_desired_temperature) + if (trip_id !=3D params->trip_max_desired_temperature) return 0; =20 - ret =3D tz->ops->get_trip_temp(tz, params->trip_switch_on, - &switch_on_temp); - if (!ret && (tz->temperature < switch_on_temp)) { - update =3D (tz->last_temperature >=3D switch_on_temp); + ret =3D __thermal_zone_get_trip(tz, params->trip_switch_on, &trip); + if (!ret && (tz->temperature < trip.temperature)) { + update =3D (tz->last_temperature >=3D trip.temperature); tz->passive =3D 0; reset_pid_controller(params); allow_maximum_power(tz, update); @@ -723,16 +720,14 @@ static int power_allocator_throttle(struct thermal_zo= ne_device *tz, int trip) =20 tz->passive =3D 1; =20 - ret =3D tz->ops->get_trip_temp(tz, params->trip_max_desired_temperature, - &control_temp); + ret =3D __thermal_zone_get_trip(tz, params->trip_max_desired_temperature,= &trip); if (ret) { - dev_warn(&tz->device, - "Failed to get the maximum desired temperature: %d\n", + dev_warn(&tz->device, "Failed to get the maximum desired temperature: %d= \n", ret); return ret; } =20 - return allocate_power(tz, control_temp); + return allocate_power(tz, trip.temperature); } =20 static struct thermal_governor thermal_gov_power_allocator =3D { diff --git a/drivers/thermal/gov_step_wise.c b/drivers/thermal/gov_step_wis= e.c index cdd3354bc27f..31235e169c5a 100644 --- a/drivers/thermal/gov_step_wise.c +++ b/drivers/thermal/gov_step_wise.c @@ -95,30 +95,28 @@ static void update_passive_instance(struct thermal_zone= _device *tz, tz->passive +=3D value; } =20 -static void thermal_zone_trip_update(struct thermal_zone_device *tz, int t= rip) +static void thermal_zone_trip_update(struct thermal_zone_device *tz, int t= rip_id) { - int trip_temp; - enum thermal_trip_type trip_type; enum thermal_trend trend; struct thermal_instance *instance; + struct thermal_trip trip; bool throttle =3D false; int old_target; =20 - tz->ops->get_trip_temp(tz, trip, &trip_temp); - tz->ops->get_trip_type(tz, trip, &trip_type); + __thermal_zone_get_trip(tz, trip_id, &trip); =20 - trend =3D get_tz_trend(tz, trip); + trend =3D get_tz_trend(tz, trip_id); =20 - if (tz->temperature >=3D trip_temp) { + if (tz->temperature >=3D trip.temperature) { throttle =3D true; - trace_thermal_zone_trip(tz, trip, trip_type); + trace_thermal_zone_trip(tz, trip_id, trip.type); } =20 dev_dbg(&tz->device, "Trip%d[type=3D%d,temp=3D%d]:trend=3D%d,throttle=3D%= d\n", - trip, trip_type, trip_temp, trend, throttle); + trip_id, trip.type, trip.temperature, trend, throttle); =20 list_for_each_entry(instance, &tz->thermal_instances, tz_node) { - if (instance->trip !=3D trip) + if (instance->trip !=3D trip_id) continue; =20 old_target =3D instance->target; @@ -132,11 +130,11 @@ static void thermal_zone_trip_update(struct thermal_z= one_device *tz, int trip) /* Activate a passive thermal instance */ if (old_target =3D=3D THERMAL_NO_TARGET && instance->target !=3D THERMAL_NO_TARGET) - update_passive_instance(tz, trip_type, 1); + update_passive_instance(tz, trip.type, 1); /* Deactivate a passive thermal instance */ else if (old_target !=3D THERMAL_NO_TARGET && instance->target =3D=3D THERMAL_NO_TARGET) - update_passive_instance(tz, trip_type, -1); + update_passive_instance(tz, trip.type, -1); =20 instance->initialized =3D true; mutex_lock(&instance->cdev->lock); --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 BE21EC32771 for ; Mon, 26 Sep 2022 15:20:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236187AbiIZPUG (ORCPT ); Mon, 26 Sep 2022 11:20:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236298AbiIZPS5 (ORCPT ); Mon, 26 Sep 2022 11:18:57 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B28E781B14 for ; Mon, 26 Sep 2022 07:06:25 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id l8so4590577wmi.2 for ; Mon, 26 Sep 2022 07:06:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=NVPF6vnmjrMx5FQU0j+pKHlND8VmvL5OT3fQ9b1KMis=; b=q6F58RMG/CMiHPhirXWdqVThjSJN+Lv/Gb+jJukat3JD1FDQCR+3yFve9EP8sKjVYX 8hMLZJj3qLGAwYqJ5+zWAjuWa3byOkA2aFuM1EapleRzA9m83nkCI3uwUrCNkE4irycl EVlOMuB6qSHpsQMP23qyYJWRU0Ha+f+4tcMFxP+490t8e5La9Y7cuGWb+R7abVMIBfyU bqRJ9OGIUA6cqM60LXiPULsy0TgFee/tySD2WLiIpcLw2R+2IpI0nI3vPStEA2b71QDX OU2An5Hco6vHBNF0hXAaC3mXVW2W4sJniKUanlY6wHn+yx/dmR1ZyuTHuLF5t165hAjX IHhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=NVPF6vnmjrMx5FQU0j+pKHlND8VmvL5OT3fQ9b1KMis=; b=wUoqwTj63Co4J6EZVLTzinoL538uOYHwivqqw+i/Gjg9PsWIfaIKPQNJOjbJttphEu j5cLZRjqdccFBkguXhIFtlQjMPVL87RKSTsa5CRBhFSvojhZByv4Xb4+KfK/57zxQ+fO scwm5l/4QNobO/JCvwDRL3ew3+HlvgPuyTjRwJuOsaSDxwpqX/WT5a/ysrGdFdJB9Qij fS6JLrTXGgQCC7nKwwIeFSBOIqdm0U+LvjTPhoAuZ/aHQxgmsIsYY5/Lpq+2hG8MsLok Y20KDMLIrI0YlfG52NDpU59io6183qNV44BrKfhAaFSNXZW6nvNsk+MFasYQ0+w1wqrB 88Lw== X-Gm-Message-State: ACrzQf0zwb2+Nb2uSGjJOHaMM8l8DYZt2GTVDIsKqqU0IrM10iEAZUKv S7fKesiYRUAo8dkBVmunjkdDrw== X-Google-Smtp-Source: AMsMyM66yuOfwKy0F2kk0nzaweyrEXkQCGNN4mwPp6Zo70vQ/WDq/CuTWExMV2Vt7Zr7ia8PlCXrCg== X-Received: by 2002:a05:600c:24c:b0:3b4:fa20:6f6b with SMTP id 12-20020a05600c024c00b003b4fa206f6bmr15493108wmj.14.1664201184078; Mon, 26 Sep 2022 07:06:24 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:23 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria Subject: [PATCH v5 06/30] thermal/of: Use generic thermal_zone_get_trip() function Date: Mon, 26 Sep 2022 16:05:40 +0200 Message-Id: <20220926140604.4173723-7-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. The thermal OF code uses the thermal_zone_device_register_with_trips() function. It builds the trips array and pass it to the register function. That means the get_trip_* ops are duplicated with what does already the core code. Remove them. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index d4b6335ace15..5cce83639085 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -71,39 +71,6 @@ of_thermal_get_trip_points(struct thermal_zone_device *t= z) } EXPORT_SYMBOL_GPL(of_thermal_get_trip_points); =20 -static int of_thermal_get_trip_type(struct thermal_zone_device *tz, int tr= ip, - enum thermal_trip_type *type) -{ - if (trip >=3D tz->num_trips || trip < 0) - return -EDOM; - - *type =3D tz->trips[trip].type; - - return 0; -} - -static int of_thermal_get_trip_temp(struct thermal_zone_device *tz, int tr= ip, - int *temp) -{ - if (trip >=3D tz->num_trips || trip < 0) - return -EDOM; - - *temp =3D tz->trips[trip].temperature; - - return 0; -} - -static int of_thermal_get_trip_hyst(struct thermal_zone_device *tz, int tr= ip, - int *hyst) -{ - if (trip >=3D tz->num_trips || trip < 0) - return -EDOM; - - *hyst =3D tz->trips[trip].hysteresis; - - return 0; -} - static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int tr= ip, int hyst) { @@ -626,9 +593,6 @@ struct thermal_zone_device *thermal_of_zone_register(st= ruct device_node *sensor, goto out_kfree_trips; } =20 - of_ops->get_trip_type =3D of_ops->get_trip_type ? : of_thermal_get_trip_t= ype; - of_ops->get_trip_temp =3D of_ops->get_trip_temp ? : of_thermal_get_trip_t= emp; - of_ops->get_trip_hyst =3D of_ops->get_trip_hyst ? : of_thermal_get_trip_h= yst; of_ops->set_trip_hyst =3D of_ops->set_trip_hyst ? : of_thermal_set_trip_h= yst; of_ops->get_crit_temp =3D of_ops->get_crit_temp ? : of_thermal_get_crit_t= emp; of_ops->bind =3D thermal_of_bind; --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 6C52CC07E9D for ; Mon, 26 Sep 2022 15:20:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236153AbiIZPUL (ORCPT ); Mon, 26 Sep 2022 11:20:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236302AbiIZPS5 (ORCPT ); Mon, 26 Sep 2022 11:18:57 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 800DA81B28 for ; Mon, 26 Sep 2022 07:06:26 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id bk15so2651092wrb.13 for ; Mon, 26 Sep 2022 07:06:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=crQJQSZoczKrIegK5IuceoLZkv1wMF3jvS/SHAicAiM=; b=a9ZySv9e5P7H8Q1EIEly3YzEJl+KMEPT31kejbP4aANBigxpRxiuylzWaPPEvwLDJM IFkclcNjn463vjOjFKn0sMjtL8GAJ+BUOl1RWhIUQFZPOOs+d0JFti0DkDhLkEO5aUVm 5NbqRF0tCsHH6AiOVwGG8DZFPHE3X2SYh88CVDHNdBPw71nk14HqU5TI4HAfLgnVuW1F SVlZDl8pe/3cziRHUvzvnTR3IR6T08mnEUvFqxwHoexuyIb4UqwzOGoK6cBxxcHszjC3 FJEd7DypxT+cF1hSyVwfRYomN7GfrcAGai7SCa0d5nzost8+UB9RRPq0v/YRKUeCdkkk u5tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=crQJQSZoczKrIegK5IuceoLZkv1wMF3jvS/SHAicAiM=; b=N3Q/yJTR+DRQVt0fQhEy4fHQRPhjxmDngmsNaq2Z0Gvm1fpav3twp5ZVsoJLYwnOsj MC3awmsWm2WbFOZAMd8jNJZdzC2ttPSbprE0JV+J5THiOuekSPU9/T3YJi9tAFXdUQIM H+gXPcuLrc4HikQz7SoAS1Zew3bMMMaoMUPe4bNPqmN16LXCBCoNRvhQxFz82hIC2M5U /tzsqtZ63qWMk4KUSfv44TuPBqxErWNlPAaZSc7R90zB6GmdQgEbZ27UbSgDw3184G6z eu4NXkqtH34SueZeVk6qobKrfJWpXyVl3jUOyU99okt87+8PANnJH0PBFUTAHBXy+Wa/ pyHg== X-Gm-Message-State: ACrzQf18tz34+DF0y4fZPzSoBmUja7G5q3Dnjf49PKQi1mGl3OFlJ4e4 mhBsWCwV/fuI8zaNiBGq1oj4Zw== X-Google-Smtp-Source: AMsMyM7b1QzKLeJ0fdfHUp7z8GwM8yJmEKaC32bF2k1iRaPgeUeVxQoK4D2dSGQbotZphJI98DV7nQ== X-Received: by 2002:a5d:59a9:0:b0:22b:e6a:4796 with SMTP id p9-20020a5d59a9000000b0022b0e6a4796mr13463925wrr.47.1664201185873; Mon, 26 Sep 2022 07:06:25 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:25 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria Subject: [PATCH v5 07/30] thermal/of: Remove unused functions Date: Mon, 26 Sep 2022 16:05:41 +0200 Message-Id: <20220926140604.4173723-8-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Remove the dead code: of_thermal_get_trip_points() Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.h | 7 ------- drivers/thermal/thermal_of.c | 17 ----------------- 2 files changed, 24 deletions(-) diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 879e91a48435..c5990a3fcf8a 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -141,8 +141,6 @@ thermal_cooling_device_stats_update(struct thermal_cool= ing_device *cdev, #ifdef CONFIG_THERMAL_OF int of_thermal_get_ntrips(struct thermal_zone_device *); bool of_thermal_is_trip_valid(struct thermal_zone_device *, int); -const struct thermal_trip * -of_thermal_get_trip_points(struct thermal_zone_device *); #else static inline int of_thermal_get_ntrips(struct thermal_zone_device *tz) { @@ -153,11 +151,6 @@ static inline bool of_thermal_is_trip_valid(struct the= rmal_zone_device *tz, { return false; } -static inline const struct thermal_trip * -of_thermal_get_trip_points(struct thermal_zone_device *tz) -{ - return NULL; -} #endif =20 int thermal_zone_device_is_enabled(struct thermal_zone_device *tz); diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 5cce83639085..2f533fc94917 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -54,23 +54,6 @@ bool of_thermal_is_trip_valid(struct thermal_zone_device= *tz, int trip) } EXPORT_SYMBOL_GPL(of_thermal_is_trip_valid); =20 -/** - * of_thermal_get_trip_points - function to get access to a globally expor= ted - * trip points - * - * @tz: pointer to a thermal zone - * - * This function provides a pointer to trip points table - * - * Return: pointer to trip points table, NULL otherwise - */ -const struct thermal_trip * -of_thermal_get_trip_points(struct thermal_zone_device *tz) -{ - return tz->trips; -} -EXPORT_SYMBOL_GPL(of_thermal_get_trip_points); - static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int tr= ip, int hyst) { --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 5709DC32771 for ; Mon, 26 Sep 2022 15:20:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236200AbiIZPUP (ORCPT ); Mon, 26 Sep 2022 11:20:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236319AbiIZPTB (ORCPT ); Mon, 26 Sep 2022 11:19:01 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5970982759 for ; Mon, 26 Sep 2022 07:06:28 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id c11so10366721wrp.11 for ; Mon, 26 Sep 2022 07:06:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=aNmMz3cRMj5kxPfKCvTpL8Ywx++ZqyPMyM5lgZsCem0=; b=Q23c4HAkgnl6Z9MaLlFBlkJQVlfuiThqrS8mJukwVIImKsYum75U4XdgrkNKk/0lwy lJzQv8+rsPlnw3WHwSmLxe9y/2uppUm+i374ZBcbjH37fLsr40lP26hZuauGkID+qu/1 rkApvZIf8Uu9MEmrkKhZJr53pIANT6XnDdzR5+74zNMG7IulxvRiGCWOyqJHhtiPgm/W REvizDF2fQ/Wa8Jg+yFs01HqT+Kb1zrvk4flQq8vtWLbINHUIegDGwW8rbkwsVlD8Bkj 7txsRB08UgJlDH24uEb550keyWuhzfNb+XK4KY7FG9iGIVaHBjHGW2Wl7RU4Sgi+g4pO ZLow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=aNmMz3cRMj5kxPfKCvTpL8Ywx++ZqyPMyM5lgZsCem0=; b=6qyeVHl8xpTxg/fpniyWBpOzalRSDU9i5Kh5fMKMfuw4w/f4XDZHALVXeJduxxi5nc MtvY/2NmmjInQ6NUdNN/zYiy3Or/zB/C6K+i8q7cQUJXyrrKw8VyVVoQxFKE8aZJ4cU8 x7yMTjb4hCRD5tlWmivTYTDqm7nboQyqn+dUr3jgC1ltq+r+hOUhS6rTSiOLtfHQ917p 1kTgsu0EP9uW66Tb6RU2KfORBV2IbJon5sjbJ0G8ysQNlFsjLYdnWzjLNqOlcMsp2g13 rIk26hi+jkGGItGbUpuix32yJR9zc+o3o+XLFLBOBLkEy9Xi8Jatv5wh1ToVoF2rYAD8 67cg== X-Gm-Message-State: ACrzQf2oQRtqpvf0AO7ZiJNU4Y2ETc1e9HcHMpKVDeaVPq1WxBadgnOS ze9hlw34bqKZbElpHSJi12rP7Q== X-Google-Smtp-Source: AMsMyM6rJqmC1nrOEeRLrZJBMGkup0bYQbcQRJMYdBAN9BZM81uzWYQNn0pJhWUuTj55jrrdI43ezw== X-Received: by 2002:a5d:6147:0:b0:22a:6035:a878 with SMTP id y7-20020a5d6147000000b0022a6035a878mr13188016wrt.528.1664201187409; Mon, 26 Sep 2022 07:06:27 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:26 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Amit Kucheria , Alim Akhtar , linux-samsung-soc@vger.kernel.org (open list:SAMSUNG THERMAL DRIVER), linux-arm-kernel@lists.infradead.org (moderated list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES) Subject: [PATCH v5 08/30] thermal/drivers/exynos: Use generic thermal_zone_get_trip() function Date: Mon, 26 Sep 2022 16:05:42 +0200 Message-Id: <20220926140604.4173723-9-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano Acked-by: Krzysztof Kozlowski --- drivers/thermal/samsung/exynos_tmu.c | 41 +++++++++++----------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung= /exynos_tmu.c index 51874d0a284c..0e33d32a9d2e 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -260,16 +260,8 @@ static int exynos_tmu_initialize(struct platform_devic= e *pdev) { struct exynos_tmu_data *data =3D platform_get_drvdata(pdev); struct thermal_zone_device *tzd =3D data->tzd; - const struct thermal_trip * const trips =3D - of_thermal_get_trip_points(tzd); unsigned int status; - int ret =3D 0, temp, hyst; - - if (!trips) { - dev_err(&pdev->dev, - "Cannot get trip points from device tree!\n"); - return -ENODEV; - } + int ret =3D 0, temp; =20 if (data->soc !=3D SOC_ARCH_EXYNOS5433) /* FIXME */ ret =3D tzd->ops->get_crit_temp(tzd, &temp); @@ -303,19 +295,16 @@ static int exynos_tmu_initialize(struct platform_devi= ce *pdev) =20 /* Write temperature code for rising and falling threshold */ for (i =3D 0; i < ntrips; i++) { - /* Write temperature code for rising threshold */ - ret =3D tzd->ops->get_trip_temp(tzd, i, &temp); - if (ret) - goto err; - temp /=3D MCELSIUS; - data->tmu_set_trip_temp(data, i, temp); =20 - /* Write temperature code for falling threshold */ - ret =3D tzd->ops->get_trip_hyst(tzd, i, &hyst); + struct thermal_trip trip; + =09 + ret =3D thermal_zone_get_trip(tzd, i, &trip); if (ret) goto err; - hyst /=3D MCELSIUS; - data->tmu_set_trip_hyst(data, i, temp, hyst); + + data->tmu_set_trip_temp(data, i, trip.temperature / MCELSIUS); + data->tmu_set_trip_hyst(data, i, trip.temperature / MCELSIUS, + trip.hysteresis / MCELSIUS); } =20 data->tmu_clear_irqs(data); @@ -360,21 +349,23 @@ static void exynos_tmu_control(struct platform_device= *pdev, bool on) } =20 static void exynos4210_tmu_set_trip_temp(struct exynos_tmu_data *data, - int trip, u8 temp) + int trip_id, u8 temp) { - const struct thermal_trip * const trips =3D - of_thermal_get_trip_points(data->tzd); + struct thermal_trip trip; u8 ref, th_code; =20 - ref =3D trips[0].temperature / MCELSIUS; + if (thermal_zone_get_trip(data->tzd, 0, &trip)) + return; =20 - if (trip =3D=3D 0) { + ref =3D trip.temperature / MCELSIUS; +=09 + if (trip_id =3D=3D 0) { th_code =3D temp_to_code(data, ref); writeb(th_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP); } =20 temp -=3D ref; - writeb(temp, data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0 + trip * 4); + writeb(temp, data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0 + trip_id * 4); } =20 /* failing thresholds are not supported on Exynos4210 */ --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 5351AC07E9D for ; Mon, 26 Sep 2022 15:20:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236215AbiIZPUT (ORCPT ); Mon, 26 Sep 2022 11:20:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236335AbiIZPTD (ORCPT ); Mon, 26 Sep 2022 11:19:03 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A521E82775 for ; Mon, 26 Sep 2022 07:06:29 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id t7so10368299wrm.10 for ; Mon, 26 Sep 2022 07:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=YzUTWEHUQYeukAyJEfTuM3PzyJlxwwnF0DoykmVbPWw=; b=YVY6NIlG8E5MYLRDa2EiAoJgns8PVyfYKnGRLgZZLm7fx8zerSdtoskRa91POGwnsc KzA+kBKLt/IvYFHVQX08ps11j0X9q90x5cEamJ13yQPAfMurnqQIWWd58GYbKcgYx0+W isVYYTBHM4veXgds5rVH3lxZEoJNNYAMQ1LgAVzVtByqGNZdWAYAirwC8HLF9zZuzLtP l2a0DdiUpyGB/gH1srv75MVg1Ih5UN4STdwOniy7xvHzMzXhAetI3FR9fKZZDXVztbCa WbFrO13ViwlC7GbUSx82BMsKYvoX7fLEnyK5ci9Hp6n+AINetViPxB6qnfsuann3yViD ov7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=YzUTWEHUQYeukAyJEfTuM3PzyJlxwwnF0DoykmVbPWw=; b=V8ehpy3/iJwELjVRXk3vUX3oKb2cbR+/74gkAfvL0Wzuw+48HKU1pen6rpxW5hewit wuK8N30gCabn46/kKqSgwa+9OCdG0vks+QmCekXv3K9JekHNgwYABmQO2BYC/u7nfznG MIOQrUCPz5n8h5C0aU2/mzpu8G5IXJCMdUHvm0BuMmRWM4SXoRVHMU1iZE2FMrEFSqYy WnJRTS9LNcMlRIRPKE9x7H/K57KN+BZxRqaRR/iLrtzvcm1Mf/JYzX6Fhgvm6vGmWUxv N+0gG9xCfCuZ91QjtDpikSMH8p8cF1bS2hjgnInpXY7wjOHMDXv1JGVU66y26VluRUlQ CbEw== X-Gm-Message-State: ACrzQf1pudfDyqYOdZ0YvrN3IWXio4qha+rKUKut7IzB3TawC6VSQzkU b+L6Pm9Xw1IrJaM1LidBT4awgQ== X-Google-Smtp-Source: AMsMyM5veGH4dyYihTWvuy0zbsnz2bzt49D2I3XuR+AiNTbAalnoODS/c84isgnulFd8jc1u1OMlCg== X-Received: by 2002:a05:6000:78e:b0:22a:7e99:da93 with SMTP id bu14-20020a056000078e00b0022a7e99da93mr13503449wrb.20.1664201188818; Mon, 26 Sep 2022 07:06:28 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:28 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Amit Kucheria , Alim Akhtar , linux-samsung-soc@vger.kernel.org (open list:SAMSUNG THERMAL DRIVER), linux-arm-kernel@lists.infradead.org (moderated list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES) Subject: [PATCH v5 09/30] thermal/drivers/exynos: of_thermal_get_ntrips() Date: Mon, 26 Sep 2022 16:05:43 +0200 Message-Id: <20220926140604.4173723-10-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal core framework allows to get the number of thermal trips, use it instead of visiting the thermal core structure internals. Signed-off-by: Daniel Lezcano Reviewed-by: Krzysztof Kozlowski --- drivers/thermal/samsung/exynos_tmu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung= /exynos_tmu.c index 0e33d32a9d2e..91e6860b5ec4 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -260,6 +260,7 @@ static int exynos_tmu_initialize(struct platform_device= *pdev) { struct exynos_tmu_data *data =3D platform_get_drvdata(pdev); struct thermal_zone_device *tzd =3D data->tzd; + int num_trips =3D thermal_zone_get_num_trips(tzd); unsigned int status; int ret =3D 0, temp; =20 @@ -271,12 +272,12 @@ static int exynos_tmu_initialize(struct platform_devi= ce *pdev) goto out; } =20 - if (of_thermal_get_ntrips(tzd) > data->ntrip) { + if (num_trips > data->ntrip) { dev_info(&pdev->dev, "More trip points than supported by this TMU.\n"); dev_info(&pdev->dev, "%d trip points should be configured in polling mode.\n", - (of_thermal_get_ntrips(tzd) - data->ntrip)); + num_trips - data->ntrip); } =20 mutex_lock(&data->lock); @@ -289,7 +290,7 @@ static int exynos_tmu_initialize(struct platform_device= *pdev) ret =3D -EBUSY; } else { int i, ntrips =3D - min_t(int, of_thermal_get_ntrips(tzd), data->ntrip); + min_t(int, num_trips, data->ntrip); =20 data->tmu_initialize(pdev); =20 --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 4CE9DC32771 for ; Mon, 26 Sep 2022 15:20:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236106AbiIZPUj (ORCPT ); Mon, 26 Sep 2022 11:20:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236352AbiIZPTF (ORCPT ); Mon, 26 Sep 2022 11:19:05 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B176582852 for ; Mon, 26 Sep 2022 07:06:31 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id t4so4579692wmj.5 for ; Mon, 26 Sep 2022 07:06:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=7e6ctEATW9s/XP6ppX0yJV3WjnU6tGYDDticrBE+dlY=; b=yXgAz7fHswCIEtOIYeo9cgpLiiJBWfgvR4uHjBK+K3qUYbnA8Y++ovFczH2C2Z7gtU N9C2D/iFJgdiYBdSN8O/VHkxCnNTG45plxKso6KCjXls1Jyot4+M4i82ezxMXH6d7U24 TG2E+oksIjDAputjsIhcsdUgxOX8SKFQYt+8WdKoC13fpMeTX/VQDK/tFu/VJfWdG+ny snjNU2/Xgz7PLDUjyfNwSLF+WOOoiJXEJVo0Qyuky86Wm2qjhG1STdPTdjEUJPIAe/uB hHZqWe/jK0wKdeMATM2ltoobIgkwpjo5Uwra5cIi8i4cE1ARfJYc01OvLEFAW9NF2j5c R1FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=7e6ctEATW9s/XP6ppX0yJV3WjnU6tGYDDticrBE+dlY=; b=FIQFxfSXnJrxcnlmq1K01Jzrgvtmzbw8Z+9+I2JKbQ+p9cyL6X0IsGAwKdg7WXrDTT l82oZ/HqgBsGpU4rN2/+ONL/bJidNSamnegdw+nbI9DPwupSBvaMBAS15cNxZGsk9X4i VZr5SqdmswGFSTFyJLFbWKErq4wxgIIlMnfljGkjYwJUAKuDAJ9mFRyvotOxrt3mMrx9 Vmmd8FvE4ujP2Qzk/xL2cONeFrYlp/R1WPGCIsMLX9FHaefPAr+9cYybvMWztPJfGuRt JoZB3PLVJ7xblqRtn83DpNVwP1TI4RCK8pUgt2aBMF4znfC0E3bTWu/IyopEbmQaTb1m yo/w== X-Gm-Message-State: ACrzQf1e7P7dAVQVTv3tpL3Al978WTccuL9QcmTqY0mo9MAHTNAVUDEi 4Pg1jXo9+cJgcarSBx5q++M8SA== X-Google-Smtp-Source: AMsMyM7TAKm/5G7gkn7KlWPaE8c2DactDCCCu5Mc+JzPmPF6T54v2Ql/KNI5i3Xl9udNqwWnFigHQQ== X-Received: by 2002:a7b:c050:0:b0:3b4:fae1:6bce with SMTP id u16-20020a7bc050000000b003b4fae16bcemr14732183wmc.131.1664201190192; Mon, 26 Sep 2022 07:06:30 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:29 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Amit Kucheria , Alim Akhtar , linux-samsung-soc@vger.kernel.org (open list:SAMSUNG THERMAL DRIVER), linux-arm-kernel@lists.infradead.org (moderated list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES) Subject: [PATCH v5 10/30] thermal/drivers/exynos: Replace of_thermal_is_trip_valid() by thermal_zone_get_trip() Date: Mon, 26 Sep 2022 16:05:44 +0200 Message-Id: <20220926140604.4173723-11-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal_zone_get_trip() does the same check as of_thermal_is_trip_valid(). Replace the call to of_thermal_is_trip_valid() by thermal_zone_get_trip(). Signed-off-by: Daniel Lezcano --- drivers/thermal/samsung/exynos_tmu.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung= /exynos_tmu.c index 91e6860b5ec4..34b460092308 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -554,13 +554,14 @@ static void exynos4210_tmu_control(struct platform_de= vice *pdev, bool on) { struct exynos_tmu_data *data =3D platform_get_drvdata(pdev); struct thermal_zone_device *tz =3D data->tzd; + struct thermal_trip trip; unsigned int con, interrupt_en =3D 0, i; =20 con =3D get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL)); =20 if (on) { for (i =3D 0; i < data->ntrip; i++) { - if (!of_thermal_is_trip_valid(tz, i)) + if (thermal_zone_get_trip(tz, i, &trip)) continue; =20 interrupt_en |=3D @@ -584,13 +585,14 @@ static void exynos5433_tmu_control(struct platform_de= vice *pdev, bool on) { struct exynos_tmu_data *data =3D platform_get_drvdata(pdev); struct thermal_zone_device *tz =3D data->tzd; + struct thermal_trip trip; unsigned int con, interrupt_en =3D 0, pd_det_en, i; =20 con =3D get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL)); =20 if (on) { for (i =3D 0; i < data->ntrip; i++) { - if (!of_thermal_is_trip_valid(tz, i)) + if (thermal_zone_get_trip(tz, i, &trip)) continue; =20 interrupt_en |=3D @@ -615,13 +617,14 @@ static void exynos7_tmu_control(struct platform_devic= e *pdev, bool on) { struct exynos_tmu_data *data =3D platform_get_drvdata(pdev); struct thermal_zone_device *tz =3D data->tzd; + struct thermal_trip trip; unsigned int con, interrupt_en =3D 0, i; =20 con =3D get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL)); =20 if (on) { for (i =3D 0; i < data->ntrip; i++) { - if (!of_thermal_is_trip_valid(tz, i)) + if (thermal_zone_get_trip(tz, i, &trip)) continue; =20 interrupt_en |=3D --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 B3B68C32771 for ; Mon, 26 Sep 2022 15:20:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236227AbiIZPUZ (ORCPT ); Mon, 26 Sep 2022 11:20:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236380AbiIZPTI (ORCPT ); Mon, 26 Sep 2022 11:19:08 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59C6A8286B for ; Mon, 26 Sep 2022 07:06:33 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id x18so10393810wrm.7 for ; Mon, 26 Sep 2022 07:06:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=XsxTgl9OJhYT/B2dXFDz/rl/9WpF5J4y9HKMzylFxc4=; b=byaL6Co33zcMqRsIQxKrHagcUNGaNLSN9oYWTlW/fmH8INoeBfEdAe/jPLF7WTofVv HbUlEOO26IAXH8A5Hrc8ZmgYR+Y4wmmxsxwfKh0MMw9ZMJaO2hUSmg+8fwzuztxpD3rb +hr5/YVr3hp1YWqOtk28e0jWVLVMAJY9fZlRqiVuln7Tcm1GQwdngHvNIRE7KD2GIn9+ lsVtlC+HWn4Hw7tXKfooeUu0P0BeKVicxRDXn5oi3Tl2rTq1Xp/PuCXIHcqTHCIGmbJ5 3VA54wXwI/sAQ0v4DDri4nq6GOjwBMuAyTQ2s5O1zqXawqI41veLWVUSmbKEBCE3xgse Keeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=XsxTgl9OJhYT/B2dXFDz/rl/9WpF5J4y9HKMzylFxc4=; b=buLhiiEvDNJeJOCTAZSqgKMwIEmteENugG0CHdsIfm9z6l+uypqqow9nG2PozPmxu2 Ag1YpZ7CiMnPiIfoArp+RbTP0e81oU5p7OQZISNjLTpC5DkaeHTmzOawOo8nudcIFf5y zE97O4xUNOiVCG+WLYLtoPP1vUmUSnN2PLQzThRZN423aX4SKZKiQXcOQyc4BTEY/qER RRo917FcDMHdxvGfUGes86joE3pUKoDeFml6pGgwSnKG3PZzv+y9NAktBU3wy7syHXS8 T8lxoIpi0P5xZWQIIIA1WjUTLW7k2gIc/RkBGKXIXIZe0GytOKtH2sgyY8Xob8gcUmsp tV5A== X-Gm-Message-State: ACrzQf2uJrfkNpsiLmQ4j9M144NLq4/uTvinUQzOzKadJGN2HNIL89O5 AKzy3ICWByuEn4awL3r2/LZ5ig== X-Google-Smtp-Source: AMsMyM7GO05lXHeMDo00l32UE42s+9a7pW3jwHggiLVUDjiWEjTRnCy0ffW2w8R35bJMGIN3S4pjLw== X-Received: by 2002:adf:cd10:0:b0:22c:a109:f51d with SMTP id w16-20020adfcd10000000b0022ca109f51dmr4461773wrm.238.1664201192703; Mon, 26 Sep 2022 07:06:32 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:32 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria , Thierry Reding , Jonathan Hunter , linux-tegra@vger.kernel.org (open list:TEGRA ARCHITECTURE SUPPORT) Subject: [PATCH v5 11/30] thermal/drivers/tegra: Use generic thermal_zone_get_trip() function Date: Mon, 26 Sep 2022 16:05:45 +0200 Message-Id: <20220926140604.4173723-12-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replace a single call to thermal_zone_get_trip() to get a trip point instead of calling the different ops->get_trip* Signed-off-by: Daniel Lezcano --- drivers/thermal/tegra/soctherm.c | 33 +++++++++++-------------- drivers/thermal/tegra/tegra30-tsensor.c | 17 ++++++------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/socth= erm.c index 1efe470f31e9..96b541458ccd 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -582,23 +582,23 @@ static int tsensor_group_thermtrip_get(struct tegra_s= octherm *ts, int id) return temp; } =20 -static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, in= t trip, int temp) +static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, in= t trip_id, int temp) { struct tegra_thermctl_zone *zone =3D tz->devdata; struct tegra_soctherm *ts =3D zone->ts; + struct thermal_trip trip; const struct tegra_tsensor_group *sg =3D zone->sg; struct device *dev =3D zone->dev; - enum thermal_trip_type type; int ret; =20 if (!tz) return -EINVAL; =20 - ret =3D tz->ops->get_trip_type(tz, trip, &type); + ret =3D thermal_zone_get_trip(tz, trip_id, &trip); if (ret) return ret; =20 - if (type =3D=3D THERMAL_TRIP_CRITICAL) { + if (trip.type =3D=3D THERMAL_TRIP_CRITICAL) { /* * If thermtrips property is set in DT, * doesn't need to program critical type trip to HW, @@ -609,7 +609,7 @@ static int tegra_thermctl_set_trip_temp(struct thermal_= zone_device *tz, int trip else return 0; =20 - } else if (type =3D=3D THERMAL_TRIP_HOT) { + } else if (trip.type =3D=3D THERMAL_TRIP_HOT) { int i; =20 for (i =3D 0; i < THROTTLE_SIZE; i++) { @@ -620,7 +620,7 @@ static int tegra_thermctl_set_trip_temp(struct thermal_= zone_device *tz, int trip continue; =20 cdev =3D ts->throt_cfgs[i].cdev; - if (get_thermal_instance(tz, cdev, trip)) + if (get_thermal_instance(tz, cdev, trip_id)) stc =3D find_throttle_cfg_by_name(ts, cdev->type); else continue; @@ -687,25 +687,20 @@ static const struct thermal_zone_device_ops tegra_of_= thermal_ops =3D { .set_trips =3D tegra_thermctl_set_trips, }; =20 -static int get_hot_temp(struct thermal_zone_device *tz, int *trip, int *te= mp) +static int get_hot_temp(struct thermal_zone_device *tz, int *trip_id, int = *temp) { - int ntrips, i, ret; - enum thermal_trip_type type; + int i, ret; + struct thermal_trip trip; =20 - ntrips =3D of_thermal_get_ntrips(tz); - if (ntrips <=3D 0) - return -EINVAL; + for (i =3D 0; i < thermal_zone_get_num_trips(tz); i++) { =20 - for (i =3D 0; i < ntrips; i++) { - ret =3D tz->ops->get_trip_type(tz, i, &type); + ret =3D thermal_zone_get_trip(tz, i, &trip); if (ret) return -EINVAL; - if (type =3D=3D THERMAL_TRIP_HOT) { - ret =3D tz->ops->get_trip_temp(tz, i, temp); - if (!ret) - *trip =3D i; =20 - return ret; + if (trip.type =3D=3D THERMAL_TRIP_HOT) { + *trip_id =3D i; + return 0;=09 } } =20 diff --git a/drivers/thermal/tegra/tegra30-tsensor.c b/drivers/thermal/tegr= a/tegra30-tsensor.c index c34501287e96..cbaad2245f1d 100644 --- a/drivers/thermal/tegra/tegra30-tsensor.c +++ b/drivers/thermal/tegra/tegra30-tsensor.c @@ -316,18 +316,17 @@ static void tegra_tsensor_get_hw_channel_trips(struct= thermal_zone_device *tzd, *hot_trip =3D 85000; *crit_trip =3D 90000; =20 - for (i =3D 0; i < tzd->num_trips; i++) { - enum thermal_trip_type type; - int trip_temp; + for (i =3D 0; i < thermal_zone_get_num_trips(tzd); i++) { =20 - tzd->ops->get_trip_temp(tzd, i, &trip_temp); - tzd->ops->get_trip_type(tzd, i, &type); + struct thermal_trip trip; =20 - if (type =3D=3D THERMAL_TRIP_HOT) - *hot_trip =3D trip_temp; + thermal_zone_get_trip(tzd, i, &trip); + =09 + if (trip.type =3D=3D THERMAL_TRIP_HOT) + *hot_trip =3D trip.temperature; =20 - if (type =3D=3D THERMAL_TRIP_CRITICAL) - *crit_trip =3D trip_temp; + if (trip.type =3D=3D THERMAL_TRIP_CRITICAL) + *crit_trip =3D trip.temperature; } =20 /* clamp hardware trips to the calibration limits */ --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 E7309C32771 for ; Mon, 26 Sep 2022 15:20:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236239AbiIZPU3 (ORCPT ); Mon, 26 Sep 2022 11:20:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236395AbiIZPTK (ORCPT ); Mon, 26 Sep 2022 11:19:10 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A5DB5C9CD for ; Mon, 26 Sep 2022 07:06:35 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id r3-20020a05600c35c300b003b4b5f6c6bdso3791100wmq.2 for ; Mon, 26 Sep 2022 07:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=zhkHfGU+506U13gs0KttMlfYYtmPZTAW+1/ApMCut14=; b=sqO/O1aFXJtFOKef2CLDy2KKoGo8mS1jDc0v38LlO4RsfpXxavOpN1TxtCAobC4yO3 kNv2B00br95zTYjJS9brJ+w5p6aI1B2nSj1JtpnHAoQqcKTO+B3NZht/kub2MfdwOxet Evm4oMZyp6uCsSlcx+dSf7ZvAADUW2jSacn8Y74kT7yhK8gG5sL92VCKetIy/uef5lNI 0MkUVZCHihEcwswFI6nNmpVOJ8Ke0AgMDB+K5q3xHGBwtIYohPQtlDZg1/kDkpndeiVw Jhih4H1DDmdVMIr+2pSA9TCh9m1wGYQGKyVGAJiAsyXkbcBmaVWQoPmZJb0sZA/2SvDE b/KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=zhkHfGU+506U13gs0KttMlfYYtmPZTAW+1/ApMCut14=; b=Gd0E2dOphIlsRJiIAm6GQhEwuhHEWCNuMg2pQDSQjtVeKmKfrWO/D4M7LciFGBbmzD Pc4U1wOfyXh8ZKcvGIWWN6jmqTsKOeF+t5wfwc+pNBPIOAZ3SOc7aMmz771mpt1VSri9 EdVuuWUJzCkL6KnKkjqeuCwMEe7sQNsibp+33yktES6PAbVriN/RIpPyGmXj3sJUgam2 7PwoJUlqioTY1rsJnG93tLzE3Mh7dE8yMC0ew4UAEX6wL0qbi7S9xmqPq9okxZiStCrd N3MRCoDngChVl5CUCUKH9AiN4Qfiqor6ARfKz/thQhlptoQjSiYbOxQkj7+lh1O5X2kp C0Xw== X-Gm-Message-State: ACrzQf2OtWAk+IWMyh2LBNVJ5/jdVADKlgt2DJvZpvzc2PvXgfXyU9TS xKehzsNf6hsHvrFLirovDXnluw== X-Google-Smtp-Source: AMsMyM6HXTifdgRuNXtogg59dwFlxvk/9EzRjUIZBwKpxkvtUZNRBVRRWpFOp6S2LnET4G2WYaRKQw== X-Received: by 2002:a7b:cbc4:0:b0:3b4:fd67:d70d with SMTP id n4-20020a7bcbc4000000b003b4fd67d70dmr16957755wmi.98.1664201193975; Mon, 26 Sep 2022 07:06:33 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:33 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Kunihiko Hayashi , Amit Kucheria , Masami Hiramatsu , linux-arm-kernel@lists.infradead.org (moderated list:ARM/UNIPHIER ARCHITECTURE) Subject: [PATCH v5 12/30] thermal/drivers/uniphier: Use generic thermal_zone_get_trip() function Date: Mon, 26 Sep 2022 16:05:46 +0200 Message-Id: <20220926140604.4173723-13-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano Reviewed-by: Kunihiko Hayashi --- drivers/thermal/uniphier_thermal.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/thermal/uniphier_thermal.c b/drivers/thermal/uniphier_= thermal.c index 4111d99ef50e..277ae300c5b1 100644 --- a/drivers/thermal/uniphier_thermal.c +++ b/drivers/thermal/uniphier_thermal.c @@ -248,8 +248,7 @@ static int uniphier_tm_probe(struct platform_device *pd= ev) struct regmap *regmap; struct device_node *parent; struct uniphier_tm_dev *tdev; - const struct thermal_trip *trips; - int i, ret, irq, ntrips, crit_temp =3D INT_MAX; + int i, ret, irq, crit_temp =3D INT_MAX; =20 tdev =3D devm_kzalloc(dev, sizeof(*tdev), GFP_KERNEL); if (!tdev) @@ -296,20 +295,18 @@ static int uniphier_tm_probe(struct platform_device *= pdev) return PTR_ERR(tdev->tz_dev); } =20 - /* get trip points */ - trips =3D of_thermal_get_trip_points(tdev->tz_dev); - ntrips =3D of_thermal_get_ntrips(tdev->tz_dev); - if (ntrips > ALERT_CH_NUM) { - dev_err(dev, "thermal zone has too many trips\n"); - return -E2BIG; - } - /* set alert temperatures */ - for (i =3D 0; i < ntrips; i++) { - if (trips[i].type =3D=3D THERMAL_TRIP_CRITICAL && - trips[i].temperature < crit_temp) - crit_temp =3D trips[i].temperature; - uniphier_tm_set_alert(tdev, i, trips[i].temperature); + for (i =3D 0; i < thermal_zone_get_num_trips(tdev->tz_dev); i++) { + struct thermal_trip trip; + + ret =3D thermal_zone_get_trip(tdev->tz_dev, i, &trip); + if (ret) + return ret; + + if (trip.type =3D=3D THERMAL_TRIP_CRITICAL && + trip.temperature < crit_temp) + crit_temp =3D trip.temperature; + uniphier_tm_set_alert(tdev, i, trip.temperature); tdev->alert_en[i] =3D true; } if (crit_temp > CRITICAL_TEMP_LIMIT) { --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 C6C21C6FA83 for ; Mon, 26 Sep 2022 15:20:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236254AbiIZPUf (ORCPT ); Mon, 26 Sep 2022 11:20:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236396AbiIZPTK (ORCPT ); Mon, 26 Sep 2022 11:19:10 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F6C382871 for ; Mon, 26 Sep 2022 07:06:35 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id z6so10444615wrq.1 for ; Mon, 26 Sep 2022 07:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=F16FcP49uIGOwU3Sf8ns9eXu8wz72Lx9ob6lOEA95bs=; b=pRTzPS4VucxqbPjgMvXGtKhOH/eC6RPMSKxRskaJJ0oIdmzrfep+Anvh7x8gUg9DFq 9vuDSLuCIq0s1oEJoup8xs4RWciI2/Qowlqk/CfsOtI/2G32yOl9aR3/siR8ijvV765L 69G0De4pgYLY38skdsk+Q88isHA61exK7+L6FG6dLBFJGIWYyN+0pddH6a2Fa3BD5AQ/ rIGkpDNf49imowH7Ijd+/cyKeR+K4NL5HSAGEnWhgQ8ov3d/K7ImBy6VMuk/hpiKSQqz 8RVbUlArjmF7v/aJAiphhE2jq5DXAbVh5FQDte56lofbsXp5aKZp/EULOyorPJCLtkJY FaEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=F16FcP49uIGOwU3Sf8ns9eXu8wz72Lx9ob6lOEA95bs=; b=Xnlc+0ZotvKE/kWYgWeDCteMt/E2hVdu2M6V9eUIjkICoWCK09fkPi17CSxjl3WY6G K8m5URnpQWwtuTS6Xmh3I2Zn0Hk3rKNvyOS1EUovTyZqI110IzS5cjQQaz6XotdmCl8N byth4upq02e7pwc1iFkGOoPLkD7lQIK2h++M6uColS0u92DYq7HlyqR99qdlhG5Ww/+r 5YzDCpYTe/s0kMxfRfOljbX2FJfDNmjWvQHlrIhsFK9iY/eZtbL87hKumJIJG1HA0gHK thjza9Hbtrf4a+K/LXnBQNFSu9YTUfZQNZp8njXDBvY0GS5/rguTe/ky0r/XLg0He5El KmZA== X-Gm-Message-State: ACrzQf3M7ibMyH6U0dUlYOCm+1JkDTrWb+mMjadGTLIPD2hiFEbR1Jaw AQRgS3CyLGz01T9LthEdXaMdlQ== X-Google-Smtp-Source: AMsMyM6TUZrs5KscYZv4KbmKV0JD99hbD9qUa3kk0L2ooG26LORx2BbUygrg9qDUyqqeIICw7Lcgzg== X-Received: by 2002:a5d:62d2:0:b0:22a:3a88:e902 with SMTP id o18-20020a5d62d2000000b0022a3a88e902mr13602432wrv.637.1664201195088; Mon, 26 Sep 2022 07:06:35 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:34 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria Subject: [PATCH v5 13/30] thermal/drivers/hisi: Use generic thermal_zone_get_trip() function Date: Mon, 26 Sep 2022 16:05:47 +0200 Message-Id: <20220926140604.4173723-14-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index d6974db7aaf7..45226cab466e 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -482,7 +482,7 @@ static int hisi_thermal_register_sensor(struct platform= _device *pdev, struct hisi_thermal_sensor *sensor) { int ret, i; - const struct thermal_trip *trip; + struct thermal_trip trip; =20 sensor->tzd =3D devm_thermal_of_zone_register(&pdev->dev, sensor->id, sensor, @@ -495,11 +495,12 @@ static int hisi_thermal_register_sensor(struct platfo= rm_device *pdev, return ret; } =20 - trip =3D of_thermal_get_trip_points(sensor->tzd); + for (i =3D 0; i < thermal_zone_get_num_trips(sensor->tzd); i++) { =20 - for (i =3D 0; i < of_thermal_get_ntrips(sensor->tzd); i++) { - if (trip[i].type =3D=3D THERMAL_TRIP_PASSIVE) { - sensor->thres_temp =3D trip[i].temperature; + thermal_zone_get_trip(sensor->tzd, i, &trip); + + if (trip.type =3D=3D THERMAL_TRIP_PASSIVE) { + sensor->thres_temp =3D trip.temperature; break; } } --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 015D5C07E9D for ; Mon, 26 Sep 2022 15:20:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236265AbiIZPUm (ORCPT ); Mon, 26 Sep 2022 11:20:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236429AbiIZPTN (ORCPT ); Mon, 26 Sep 2022 11:19:13 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1123282D0E for ; Mon, 26 Sep 2022 07:06:38 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id k3-20020a05600c1c8300b003b4fa1a85f8so3782514wms.3 for ; Mon, 26 Sep 2022 07:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=/DpVb9+AKUGgq8A4EZDNel0xrsv5+R31U81PHZWHu7A=; b=WX3OvpQFA+M9INHpNy4Py5kKdxy5cfqEVZL375Jc/6L8OMcOpg9sqElg7DCTxP/x0F /54NRSlGurAKIoKRlRMjNrQJ/vEiT8OxGW27RIc+V6r48AxKSdrsl5a6INwzaQJsgv4G vlUzn89BfKonHFjj39dYQUJOGBE1CVqMSo8bUKkrqjxMNvGgKdJYE9H7cvTeYh3GdCd3 7w8vlWxvnBd6igvNHoZ0s9s44dQOejOs5rnTq0+VxUVSmUwsFHXP+Tw4a8cWfGy1LkrH PH7VlEnKVv0qq/E7ufVO7jIUVARcbQ3S4VH36qGW/HW0+IpUOu1uoOCHTk3v3+oLrIR3 QL+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=/DpVb9+AKUGgq8A4EZDNel0xrsv5+R31U81PHZWHu7A=; b=bAPvtE3vqj+hCXnWol4HhsIYbszkZkWkE/uYsKc/U9mIBlT2qetXFvnOKJ0MOI/m+j L7u98f2R0Ava8kSFfVmNFFVolms7AXcm0n0gmqvMX4U0TxKgaCNN4YUDgB2tpUt6flfX AEAO8n3WOyk0Ko0xEvRTRJskFVHc6e9kG8OsSQxbfvpi8RRYEHXaWsSxE5f7z8uczGfr GPxUxsISLpmWSxm7a8KL4sfaygyebXFjjs63eJ0inUMhYFbn32V9eYAxHGsCprGwdEzZ PAtqRjK0+ordH7kjy1LuathctlkkMpjkCrz0BQunkNn03wjBJUcCLCZaWVJiaF+wbhku P7Cw== X-Gm-Message-State: ACrzQf280nd6PQKfAcHlPFGvbkEcCpwzceq2tAxPx5r/UiA88R0ObU4P O/+3gSh9ZJjzOdotLmg8DxY+jg== X-Google-Smtp-Source: AMsMyM7428UZktkIZgkcsoeeRa7QJH2nQ/49f5LZT+CS/3G/N/SXB0obuvQV6dEoQlM05iLibcLMnA== X-Received: by 2002:a05:600c:1f05:b0:3b4:ae0a:b2e5 with SMTP id bd5-20020a05600c1f0500b003b4ae0ab2e5mr15829413wmb.104.1664201196515; Mon, 26 Sep 2022 07:06:36 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:36 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria , Andy Gross , Bjorn Andersson , Konrad Dybcio , Thara Gopinath , linux-arm-msm@vger.kernel.org (open list:ARM/QUALCOMM SUPPORT) Subject: [PATCH v5 14/30] thermal/drivers/qcom: Use generic thermal_zone_get_trip() function Date: Mon, 26 Sep 2022 16:05:48 +0200 Message-Id: <20220926140604.4173723-15-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano Acked-by: Amit Kucheria --- drivers/thermal/qcom/qcom-spmi-temp-alarm.c | 39 +++++++++------------ 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/drivers/thermal/qcom/qcom-spmi-temp-alarm.c b/drivers/thermal/= qcom/qcom-spmi-temp-alarm.c index be785ab37e53..127e8c90211c 100644 --- a/drivers/thermal/qcom/qcom-spmi-temp-alarm.c +++ b/drivers/thermal/qcom/qcom-spmi-temp-alarm.c @@ -263,17 +263,17 @@ static int qpnp_tm_update_critical_trip_temp(struct q= pnp_tm_chip *chip, return qpnp_tm_write(chip, QPNP_TM_REG_SHUTDOWN_CTRL1, reg); } =20 -static int qpnp_tm_set_trip_temp(struct thermal_zone_device *tz, int trip,= int temp) +static int qpnp_tm_set_trip_temp(struct thermal_zone_device *tz, int trip_= id, int temp) { struct qpnp_tm_chip *chip =3D tz->devdata; - const struct thermal_trip *trip_points; + struct thermal_trip trip; int ret; =20 - trip_points =3D of_thermal_get_trip_points(chip->tz_dev); - if (!trip_points) - return -EINVAL; + ret =3D thermal_zone_get_trip(chip->tz_dev, trip_id, &trip); + if (ret) + return ret; =20 - if (trip_points[trip].type !=3D THERMAL_TRIP_CRITICAL) + if (trip.type !=3D THERMAL_TRIP_CRITICAL) return 0; =20 mutex_lock(&chip->lock); @@ -299,22 +299,17 @@ static irqreturn_t qpnp_tm_isr(int irq, void *data) =20 static int qpnp_tm_get_critical_trip_temp(struct qpnp_tm_chip *chip) { - int ntrips; - const struct thermal_trip *trips; - int i; - - ntrips =3D of_thermal_get_ntrips(chip->tz_dev); - if (ntrips <=3D 0) - return THERMAL_TEMP_INVALID; - - trips =3D of_thermal_get_trip_points(chip->tz_dev); - if (!trips) - return THERMAL_TEMP_INVALID; - - for (i =3D 0; i < ntrips; i++) { - if (of_thermal_is_trip_valid(chip->tz_dev, i) && - trips[i].type =3D=3D THERMAL_TRIP_CRITICAL) - return trips[i].temperature; + struct thermal_trip trip; + int i, ret; + + for (i =3D 0; i < thermal_zone_get_num_trips(chip->tz_dev); i++) { + + ret =3D thermal_zone_get_trip(chip->tz_dev, i, &trip); + if (ret) + continue; + + if (trip.type =3D=3D THERMAL_TRIP_CRITICAL) + return trip.temperature; } =20 return THERMAL_TEMP_INVALID; --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 84BEEC32771 for ; Mon, 26 Sep 2022 15:20:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236274AbiIZPUp (ORCPT ); Mon, 26 Sep 2022 11:20:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236434AbiIZPTN (ORCPT ); Mon, 26 Sep 2022 11:19:13 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9143482D16 for ; Mon, 26 Sep 2022 07:06:38 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id bk15so2652055wrb.13 for ; Mon, 26 Sep 2022 07:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=cMvv+kIwS7Npnyybgo7TEwbxPHKi63Y9shqXlNy7AcU=; b=yg0w3HEfNXGtnBBhO8Cz9xNPnCqn8b9SdcuxEqWkp0YubNFanaltpZ00oRcemcsH3D k64GiXeXxW47t8afssig/+CNlxxvrbMBDg/R9eUS0Eq4zb8kcht8bEA/uyXUXcm4dTqo ISO3f+0KUPHO5wpalccaBQLy8I9wRuL3ESHXrp4LjnIU1V34M9vPxq9D39v8kW0PDAxe 0T7EoTI/PEyXd0DayS6FWCRtP7/Iyy1dhKs+JS1IApCv9/bjHi0k8HcmDBlD20jdsA28 OAHoQLfpP/7bMBIA/cmoxCut/rb4LQsT5YsXcha6pdgycnuNPxVQvT4kS9v/C04SA2+V e2CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=cMvv+kIwS7Npnyybgo7TEwbxPHKi63Y9shqXlNy7AcU=; b=u7KdyXavEBN21B7ysdjamK2HeKRKsQ3VVGl16Zk5EhlQEqT4HZ1cb3Bt4RwQYBODzL PdScNTMgcA8ztcBAaB/JN04k/R6r+KTdrCrGGfsYysIUZmMG6VM9LXSRzuucfxr/xAB2 XFDQaNpOi5C8DsIs20xbfTyl+H222UYo0txYTk4hrtEg3050Y+QBJ1Ek3YxKt2+4+wq6 70qYn+cLZdDK0vW3QqbhX3iUSVplpB00Wuk4gu6DOzkulwmSIXWwD5zlNpzF1sb8d8Ga wS9Cja4wmZxJB7QPucYZsrWhZXyNlXKnfoSEAT3+UssG6xs2kmVmEKz2nG1AaZgOEtZf EiVQ== X-Gm-Message-State: ACrzQf2E1SkYSozz7GCoY2NKS4Cac7II8R1qAvpcrsXXnA+G8qXTJhkn swky+KKos3n03QdQJ1skrZvgyA== X-Google-Smtp-Source: AMsMyM4zW+nU32TzlZYB7xZBNRPL1pZLN8fPKdGijDdPGplygM302nIxXzt0O6PYvnsGBLrTPdtgTQ== X-Received: by 2002:adf:d0d2:0:b0:22a:daf4:87e8 with SMTP id z18-20020adfd0d2000000b0022adaf487e8mr13523497wrh.167.1664201197751; Mon, 26 Sep 2022 07:06:37 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:37 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Miquel Raynal , Amit Kucheria Subject: [PATCH v5 15/30] thermal/drivers/armada: Use generic thermal_zone_get_trip() function Date: Mon, 26 Sep 2022 16:05:49 +0200 Message-Id: <20220926140604.4173723-16-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano --- drivers/thermal/armada_thermal.c | 39 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_ther= mal.c index 52d63b3997fe..9444e5a22ca0 100644 --- a/drivers/thermal/armada_thermal.c +++ b/drivers/thermal/armada_thermal.c @@ -785,33 +785,34 @@ static int armada_configure_overheat_int(struct armad= a_thermal_priv *priv, int sensor_id) { /* Retrieve the critical trip point to enable the overheat interrupt */ - const struct thermal_trip *trips =3D of_thermal_get_trip_points(tz); + struct thermal_trip trip; int ret; int i; =20 - if (!trips) - return -EINVAL; - - for (i =3D 0; i < of_thermal_get_ntrips(tz); i++) - if (trips[i].type =3D=3D THERMAL_TRIP_CRITICAL) - break; + for (i =3D 0; i < thermal_zone_get_num_trips(tz); i++) { =20 - if (i =3D=3D of_thermal_get_ntrips(tz)) - return -EINVAL; + ret =3D thermal_zone_get_trip(tz, i, &trip); + if (ret) + return ret; + =09 + if (trip.type !=3D THERMAL_TRIP_CRITICAL)=20 + continue; =20 - ret =3D armada_select_channel(priv, sensor_id); - if (ret) - return ret; + ret =3D armada_select_channel(priv, sensor_id); + if (ret) + return ret; + =09 + armada_set_overheat_thresholds(priv, trip.temperature, + trip.hysteresis); + priv->overheat_sensor =3D tz; + priv->interrupt_source =3D sensor_id; =20 - armada_set_overheat_thresholds(priv, - trips[i].temperature, - trips[i].hysteresis); - priv->overheat_sensor =3D tz; - priv->interrupt_source =3D sensor_id; + armada_enable_overheat_interrupt(priv); =20 - armada_enable_overheat_interrupt(priv); + return 0; + } =20 - return 0; + return -EINVAL; } =20 static int armada_thermal_probe(struct platform_device *pdev) --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 75F11C07E9D for ; Mon, 26 Sep 2022 15:21:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236292AbiIZPVC (ORCPT ); Mon, 26 Sep 2022 11:21:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236457AbiIZPTR (ORCPT ); Mon, 26 Sep 2022 11:19:17 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71B9382D2D for ; Mon, 26 Sep 2022 07:06:39 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id c192-20020a1c35c9000000b003b51339d350so5163260wma.3 for ; Mon, 26 Sep 2022 07:06:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=XrpGuF2vxbaEuk6VfKG2/A6XesW21KLMiogPr2+Ux0s=; b=wWv1m+XXCoVQHb8PDskWeYfQYLfcMm1SCoVxR85JW/Ecblj4tvHkHfBE5gF13woWHW uGnvaL5vR1TiZeybhAcNf45ADUOyIierTlgELJRA30Qb2AD+9Cmt2TxTbfvsXf8/O4ti C2j7OY68Wg3u8lyMynjHPw/7ts8QcXTAs0pcDZNewijPNrpt7Fx2uskzRbZt8qIprK0r wKpXiNHKmOg8uWn5WfJGP7UloBuHgkVNYeLOtNiTR6unUWICLMaoDM9QIJDnUVtv7TGf hVy+AyEhmtH9nMzAv1pt29EyYAAgCoJ8N4dvLOepmayWa+z+YJRBCU9kn2Fyq+5v1jBB eKLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=XrpGuF2vxbaEuk6VfKG2/A6XesW21KLMiogPr2+Ux0s=; b=2PVR4kYOawlH28TGkdjC7TUfYDBesYU2kySiQ/z/3ONoAo/Tqv9ULLFP0K+b2xMKXk RX8maFRV/UXinAkYHt9FO+w7uDeL/FE7Zq0ZQZzlmJ7sSemO07Lb8L5m10wboWloSHU3 mi8HYpuDgKGInXCmA7fHu652jPz+0p39Whupsw2qqJrZu9Vr9KmIbaOlPKs6MuKIUMre bl0MjYIiQ7AFDyT0s3yPrMtg5vNb8pfpDP2C5c6X4n/rJ+iqeojcMvAYcrTCoMxHK+d4 IffPwW0NgAMXOImR1dXOlCnt5q2JN5dkK5q3hNN2sX4oktuaeLtparFR8R7HrN9L4utl PT0w== X-Gm-Message-State: ACrzQf0ep2gR/j1F/FfwVv+lwySPMMMB4Gl1GiL0DcZnFJ1jh+47GAX4 OzUlX3hdR5EeLy1+biL80CR3BA== X-Google-Smtp-Source: AMsMyM4XD9QOxU0BEk9+OLqsbpu/aWVwF7Yy9OQHxWQNqCOXN85C7JYpF2F4vQjYYL6iva8Dwj5c7g== X-Received: by 2002:a05:600c:3c89:b0:3b5:e3:bd0f with SMTP id bg9-20020a05600c3c8900b003b500e3bd0fmr15666943wmb.199.1664201199365; Mon, 26 Sep 2022 07:06:39 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:38 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, =?UTF-8?q?Niklas=20S=C3=B6derlund?= , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Amit Kucheria , linux-renesas-soc@vger.kernel.org (open list:RENESAS R-CAR THERMAL DRIVERS) Subject: [PATCH v5 16/30] thermal/drivers/rcar_gen3: Use the generic function to get the number of trips Date: Mon, 26 Sep 2022 16:05:50 +0200 Message-Id: <20220926140604.4173723-17-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The thermal core framework allows to get the number of thermal trips, use it instead of visiting the thermal core structure internals. Signed-off-by: Daniel Lezcano Reviewed-by: Niklas S=C3=B6derlund --- drivers/thermal/rcar_gen3_thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen= 3_thermal.c index 4c1c6f89aa2f..4ef927437842 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c @@ -529,7 +529,7 @@ static int rcar_gen3_thermal_probe(struct platform_devi= ce *pdev) if (ret) goto error_unregister; =20 - ret =3D of_thermal_get_ntrips(tsc->zone); + ret =3D thermal_zone_get_num_trips(tsc->zone); if (ret < 0) goto error_unregister; =20 --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 C4E9BC32771 for ; Mon, 26 Sep 2022 15:21:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236312AbiIZPVF (ORCPT ); Mon, 26 Sep 2022 11:21:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236473AbiIZPTU (ORCPT ); Mon, 26 Sep 2022 11:19:20 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50ED383042 for ; Mon, 26 Sep 2022 07:06:41 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id bq9so10432558wrb.4 for ; Mon, 26 Sep 2022 07:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=G/YO0fJeKfkSzRqdgqFU3ij4yJaDOnZPHmbsRpXJf/A=; b=HpElmg1xiU/vguSyDzJ1AVanARz2FCVZ1PxbcRCFVeKyhTaIHkeqfn/IojyB2w0HO4 Xi+G2LDqzZOsYp2W0z8luiIbB3njOLZ+B0QGF5MkMKXFHEfqP93A4CKOxQRuniq5PmJm pAko7VTCs3uPqq1Ui41khWR2zYnsQShFi9lLPJvfRAWLW5mX/b6GdFUOUk+D5dvKAitz u+8WMlbY+bl8Rltp71qjdElQvVsTCdAcnMUXYoHxMX7w72U0hCyrjdQwcel3+TpuiFf0 BfCe9H28ZLWf3TMdlTuP8pJ1oiehJEIgkAkG+IkBeaXC+nfBdtKcZp8o4bYEi4IoTy9A 8fAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=G/YO0fJeKfkSzRqdgqFU3ij4yJaDOnZPHmbsRpXJf/A=; b=xk4QFPzW6+DJ2yQaiHBYJxGJAvwAsJnuf1BEdD45PGIwgnUF50g3q9KeTb46BHH6vl zwTI1MJWTichRr0Kwov8qeDYQ+miO686iDYG9NmovOnmKHjz+mB+02BEPaRCh+7hFayy oh+ioECoxez392DxgFvxoBki1rALTMpBtOV0cRZJ8fGUdUMPl7c7NTzzw37tew9sQsOE 5KRUPtW8Wlg9E7pVJr0fEfhMnciwA2jNbCVgieaZ/QWSvkMjwV277lA5bF1TAomteBlT dGwRpiYaVctd8z8JP13BYtRNNMh2QtXk/MZPh5Fnr/CAd3WTi0rvv+bjxvMKtyvieymI djXw== X-Gm-Message-State: ACrzQf28xgoVRPos/xGb8ckyao4gZ2oGT1NkqtcZ+GCElZkto484SO2t JwRqqaAlNqOp4W5dmn1gsOVluQ== X-Google-Smtp-Source: AMsMyM4R1nrXWrLOxDa4zUaQAaa+sznK9GNS8ItYzxSWCtLIvEau8p5ub7y1UiUcsuWn2pS6FtTlQw== X-Received: by 2002:a5d:5089:0:b0:229:3151:2865 with SMTP id a9-20020a5d5089000000b0022931512865mr13264139wrt.81.1664201200781; Mon, 26 Sep 2022 07:06:40 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:40 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria Subject: [PATCH v5 17/30] thermal/of: Remove of_thermal_get_ntrips() Date: Mon, 26 Sep 2022 16:05:51 +0200 Message-Id: <20220926140604.4173723-18-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal OF code uses the generic trip points to initialize the thermal zone. Consequently thermal_zone_get_num_trips() can be used and the of_thermal_get_ntrips() is no longer needed. Remove it. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.h | 5 ----- drivers/thermal/thermal_of.c | 16 ---------------- 2 files changed, 21 deletions(-) diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index c5990a3fcf8a..b00fc1913734 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -139,13 +139,8 @@ thermal_cooling_device_stats_update(struct thermal_coo= ling_device *cdev, =20 /* device tree support */ #ifdef CONFIG_THERMAL_OF -int of_thermal_get_ntrips(struct thermal_zone_device *); bool of_thermal_is_trip_valid(struct thermal_zone_device *, int); #else -static inline int of_thermal_get_ntrips(struct thermal_zone_device *tz) -{ - return 0; -} static inline bool of_thermal_is_trip_valid(struct thermal_zone_device *tz, int trip) { diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 2f533fc94917..89afa59c4915 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -19,22 +19,6 @@ =20 #include "thermal_core.h" =20 -/** - * of_thermal_get_ntrips - function to export number of available trip - * points. - * @tz: pointer to a thermal zone - * - * This function is a globally visible wrapper to get number of trip points - * stored in the local struct __thermal_zone - * - * Return: number of available trip points, -ENODEV when data not available - */ -int of_thermal_get_ntrips(struct thermal_zone_device *tz) -{ - return tz->num_trips; -} -EXPORT_SYMBOL_GPL(of_thermal_get_ntrips); - /** * of_thermal_is_trip_valid - function to check if trip point is valid * --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 B37FFC32771 for ; Mon, 26 Sep 2022 15:21:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236318AbiIZPVI (ORCPT ); Mon, 26 Sep 2022 11:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233214AbiIZPTW (ORCPT ); Mon, 26 Sep 2022 11:19:22 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E021B8304E for ; Mon, 26 Sep 2022 07:06:42 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id k3-20020a05600c1c8300b003b4fa1a85f8so3782665wms.3 for ; Mon, 26 Sep 2022 07:06:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=vcQTbtSOs9FbsFbv8V2t/E69I1IFg9ZKCW8F5npsSmY=; b=z5G8IkXBIKXhd7qT+UB7xxqOj6f3Eq8ax/RzqIl0XorZS+Xr/fqHotZJoYnnDaLgYx RU+AboprBDINIgSrCT17V2VQkFIcIl1hD9e+vSnbHnoV4QqqR++JiOL6d9NPipzK5/TI dX+38uP4uEZLIq+g1Xuomd5NqZ7tgSU8w0Lod1GFR/FbDnwRARfTg2BZ8DzmoiYLndqt SFrjMRemT9KbH8hl8wieeTrr/D1/TQ05iMXt9YvSIhkzgcIjA2wkzutajp8ld2X+E/Mu mLyMagte7bGjcjht40IFMoY9KDdNRe1SR2II8S3lY7R5RHdIWdU0MGNpEITtZTihHq8m ILMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=vcQTbtSOs9FbsFbv8V2t/E69I1IFg9ZKCW8F5npsSmY=; b=zUcapnW4NmQwLwyiIUwaSPdlzi0DZBYqmDGEp+9NNKj+7quxJEraziul1YDzTYDvk+ iMEM39fxO6ucL9XgeOi4OvJvFWTvHxCeG03RrubD2NtH40XcCxeuRUMAZAbnz1A/0aI8 lu4XwalDGE/tPF1nEHCBWNJC/ntFMf5NNQbxw4S732ySswC8u3DNjuinNUVEtsx3AGt9 6ou14Rv9ALORO5dPcpAGrVRex+itjZBKRN51G/ZAnVCTP0R9KD6PzMMC68pEh8CNE82P U7CMjbjouBLWyNm64AiRleDCUV5ydoPpYIW9uO2KoFSkjvSDOt+WTtAaPkRBx3nNrULm l8mQ== X-Gm-Message-State: ACrzQf1IvIcdLqploTV2HToXqheKAWMlSsJqUoAMWSecG0F6YLAr926U +reGub7YUENsiAKAG5iPOf6b8Q== X-Google-Smtp-Source: AMsMyM513Uavgx2NJuLiJ2uLHUthzvwVsVfjgpzOEqdTKG+7IuRHAT8POOi+Ek0OBjiSxJDR9lp2cg== X-Received: by 2002:a05:600c:3b1f:b0:3b4:b1fc:4797 with SMTP id m31-20020a05600c3b1f00b003b4b1fc4797mr22404966wms.129.1664201202274; Mon, 26 Sep 2022 07:06:42 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:41 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria Subject: [PATCH v5 18/30] thermal/of: Remove of_thermal_is_trip_valid() Date: Mon, 26 Sep 2022 16:05:52 +0200 Message-Id: <20220926140604.4173723-19-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There is no benefit with the of_thermal_is_trip_valid() function as it does the check the thermal_zone_get_trip() is already doing for the sake of getting the trip point. As all the calls have been replaced by thermal_zone_get_trip(), there is no more users of of_thermal_is_trip_valid(). Remove the function. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.h | 10 ---------- drivers/thermal/thermal_of.c | 19 ------------------- 2 files changed, 29 deletions(-) diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index b00fc1913734..e9b3af6c2084 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -138,16 +138,6 @@ thermal_cooling_device_stats_update(struct thermal_coo= ling_device *cdev, #endif /* CONFIG_THERMAL_STATISTICS */ =20 /* device tree support */ -#ifdef CONFIG_THERMAL_OF -bool of_thermal_is_trip_valid(struct thermal_zone_device *, int); -#else -static inline bool of_thermal_is_trip_valid(struct thermal_zone_device *tz, - int trip) -{ - return false; -} -#endif - int thermal_zone_device_is_enabled(struct thermal_zone_device *tz); =20 #endif /* __THERMAL_CORE_H__ */ diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 89afa59c4915..4e54d62720dc 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -19,25 +19,6 @@ =20 #include "thermal_core.h" =20 -/** - * of_thermal_is_trip_valid - function to check if trip point is valid - * - * @tz: pointer to a thermal zone - * @trip: trip point to evaluate - * - * This function is responsible for checking if passed trip point is valid - * - * Return: true if trip point is valid, false otherwise - */ -bool of_thermal_is_trip_valid(struct thermal_zone_device *tz, int trip) -{ - if (trip >=3D tz->num_trips || trip < 0) - return false; - - return true; -} -EXPORT_SYMBOL_GPL(of_thermal_is_trip_valid); - static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int tr= ip, int hyst) { --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 5ACA3C32771 for ; Mon, 26 Sep 2022 15:21:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236328AbiIZPVO (ORCPT ); Mon, 26 Sep 2022 11:21:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235661AbiIZPTW (ORCPT ); Mon, 26 Sep 2022 11:19:22 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D38983060 for ; Mon, 26 Sep 2022 07:06:45 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id o5so4603881wms.1 for ; Mon, 26 Sep 2022 07:06:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=KY22MjtoUlIwWIKxWwfuHh0wn9QBG3Vjtz/Dduvf6bU=; b=EpvKvHSwStgMICfq57+AHEBgNTsZCGHu4zDwSNFuBuPQ2UEKfocQK/30SpAMYBT1F9 GCSYXU5+D4iBDFg7NUeec7imLqJ82HssPSs/tIv0TLYebUEQT0kqYQAauZ3iGIAkL6LS QsFBYx71/vqTlKvlVQIHddyArmUbT5QHln/Ld/kmDubpbo+lYkpkXvPKiWcZ4pmoY5ss ILtGblkDQxADV8Wb6oYOrVeDR3cmBDH565RIp/7DOcoKVk33Tjw0LEzfeemw1uiiStvj 21Bsg/z72x6H7GcotuoMIYjMu6IIQ7H5/l+30+rVBCh3RKg4Wu9cvQDlCDoB+wgMM3MB CQXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=KY22MjtoUlIwWIKxWwfuHh0wn9QBG3Vjtz/Dduvf6bU=; b=UKY5VCk/gDf6W6ryp/f/5rLoKfkQR8Thm/xInSOsP7vIvghesFL4L544wehQNzTPZm D2xN4DF7srbtqI9GKAMsroRS8zurWKZGJxQ2Dxe2vi46vD2BJOYdX4RIvfFRIohDgzjf j5GfI1w2k5JbicxcJuvHsja6fHlpeMvqpyYAyf/RRvv4jU+gLtU0e3wF178eBpTQ2rcO n5rhZe79T2eS2Q4xtBaTxjecx67N39BA/vNPkkQiHCKyjeB+DSr1xBBAfz95D3n8ChhY MalwMaD9JOYzwj87bI5lN8o2YuzYyauUyBUmjgVfDUZFas4q0bGn0F4y1kRdPZ2Zcrbe ayww== X-Gm-Message-State: ACrzQf29IfEYoLduLJZTEGNTnLzBy79CH2RJXY5aPTvFpr+bNvdIO0i7 zJFk0ByXjqMFy1uJGcMBwRmNuZTkROKyWw== X-Google-Smtp-Source: AMsMyM7ph8+YGuzkaWydlGbxcmLfQj31Wy1YMb/EFgCFTEjKDhVspNRf4G1OwUurnCUM4ZZJ07FLpA== X-Received: by 2002:a05:600c:23ca:b0:3b4:6199:8ab9 with SMTP id p10-20020a05600c23ca00b003b461998ab9mr21728823wmb.20.1664201203569; Mon, 26 Sep 2022 07:06:43 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:43 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria Subject: [PATCH v5 19/30] thermal/of: Remove of_thermal_set_trip_hyst() Date: Mon, 26 Sep 2022 16:05:53 +0200 Message-Id: <20220926140604.4173723-20-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal core is providing the generic thermal_zone_set_trip() function which does exactly what the OF ops function is doing. It is pointless to define our own version, just remove the ops and the thermal_zone_set_trip() will take care of it. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 4e54d62720dc..494e9c319541 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -19,18 +19,6 @@ =20 #include "thermal_core.h" =20 -static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int tr= ip, - int hyst) -{ - if (trip >=3D tz->num_trips || trip < 0) - return -EDOM; - - /* thermal framework should take care of data->mask & (1 << trip) */ - tz->trips[trip].hysteresis =3D hyst; - - return 0; -} - static int of_thermal_get_crit_temp(struct thermal_zone_device *tz, int *temp) { @@ -541,7 +529,6 @@ struct thermal_zone_device *thermal_of_zone_register(st= ruct device_node *sensor, goto out_kfree_trips; } =20 - of_ops->set_trip_hyst =3D of_ops->set_trip_hyst ? : of_thermal_set_trip_h= yst; of_ops->get_crit_temp =3D of_ops->get_crit_temp ? : of_thermal_get_crit_t= emp; of_ops->bind =3D thermal_of_bind; of_ops->unbind =3D thermal_of_unbind; --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 79F4AC32771 for ; Mon, 26 Sep 2022 15:21:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236347AbiIZPVR (ORCPT ); Mon, 26 Sep 2022 11:21:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235862AbiIZPTX (ORCPT ); Mon, 26 Sep 2022 11:19:23 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5565082D1E for ; Mon, 26 Sep 2022 07:06:46 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id r133-20020a1c448b000000b003b494ffc00bso7605597wma.0 for ; Mon, 26 Sep 2022 07:06:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=OHXbaNWdyZ0Wkkc1xL/nI14ReQ0AVnlGlwSXS+lV7dA=; b=JL73WR17Wo9QtiWEbhImaTC+IY7m0f8+Gxb/T/yG0u1LYZIlnRv6/Hux7V6Y5ZdDyd expWew6jX2nlPDAHqOwy550lJYkPZuVTrhdZbZYt51MVbjAo5P/q+5CeHmFEJ/qkbtUz muc4aGInDU6KV8AMk4zyjW8fwAgoKSNgj9rybamoQxK5T/TE7dtk4+4sBvw/mZDNfzvV NWUdE4wDfXls4nUxh1zeg7paA/InfLF4c5xje02HzoyaVKvZ2Z1cdIaDjfyinfAToFWG /DPFQ0GM3mjlkSZcCvCpgbFy5dAUL2Znxa8bjUPV56B2FAUT5kcf2HVQmpD8BE6CLz2y JlrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=OHXbaNWdyZ0Wkkc1xL/nI14ReQ0AVnlGlwSXS+lV7dA=; b=qjsQOcjWHI8HXdENlECcqOCZjN+tDo5+SB2MXkudy7mw0oPuhndDXJqo7i5g9L32kg JejGloBd7htWL8Dq4CTab7kYUVv7WWQsI3oqX1X/qVLlfJrHG6EekV5soV8sSyxJ1fdP 1ekwW0eVa+ofcrKNpjyf5ZWFcfK+2wbEB4Blpz1WWLZdMoQGOBI++z+LEhM1oDApvAzH xoIj977y0OyQ1vGUgsWbKbtvCKvFhQnieFosFl3bJ4Zg2yMjtXlOENDFhwn1TsScvuC/ aYOci/Eh4Ev5ouAh32GOrOcAIchfcSBSg8lbvSjfF10msFoImCoLNkGy+hpuoVDM8eVz Wscw== X-Gm-Message-State: ACrzQf3AjhhFNCatCtGh9btexHl5Az7LgT9McwNEK3pKk15vJ1Yx1WoB 6Ji5ki6NnncqH+eewuw1rkguDA== X-Google-Smtp-Source: AMsMyM56pTcOgbo3gwYCH+yf6BtTYLM+gY5LVnEdvtHImGNDlx0rf0hyDBYaRCXNdkMcu6atF85ong== X-Received: by 2002:a05:600c:1d2a:b0:3b4:6e31:92da with SMTP id l42-20020a05600c1d2a00b003b46e3192damr21415076wms.103.1664201204691; Mon, 26 Sep 2022 07:06:44 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:44 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria Subject: [PATCH v5 20/30] thermal/of: Remove of_thermal_get_crit_temp() Date: Mon, 26 Sep 2022 16:05:54 +0200 Message-Id: <20220926140604.4173723-21-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The generic version of of_thermal_get_crit_temp() can be used. Let's remove this ops which is pointless. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 494e9c319541..bd872183e521 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -19,20 +19,6 @@ =20 #include "thermal_core.h" =20 -static int of_thermal_get_crit_temp(struct thermal_zone_device *tz, - int *temp) -{ - int i; - - for (i =3D 0; i < tz->num_trips; i++) - if (tz->trips[i].type =3D=3D THERMAL_TRIP_CRITICAL) { - *temp =3D tz->trips[i].temperature; - return 0; - } - - return -EINVAL; -} - /*** functions parsing device tree nodes ***/ =20 static int of_find_trip_id(struct device_node *np, struct device_node *tri= p) @@ -529,7 +515,6 @@ struct thermal_zone_device *thermal_of_zone_register(st= ruct device_node *sensor, goto out_kfree_trips; } =20 - of_ops->get_crit_temp =3D of_ops->get_crit_temp ? : of_thermal_get_crit_t= emp; of_ops->bind =3D thermal_of_bind; of_ops->unbind =3D thermal_of_unbind; =20 --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 D45B3C32771 for ; Mon, 26 Sep 2022 15:21:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236021AbiIZPVT (ORCPT ); Mon, 26 Sep 2022 11:21:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235926AbiIZPTY (ORCPT ); Mon, 26 Sep 2022 11:19:24 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B08283072 for ; Mon, 26 Sep 2022 07:06:47 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id iv17so4581963wmb.4 for ; Mon, 26 Sep 2022 07:06:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=p+Fs/P7gXsm/5qHeFX0rzCcy4XeIXDeOEwU0TTt39+U=; b=Uyb0eyU1G7y4T0z0CnKTq+d4m6oHlieEpg+zi1Pz0zaS3HM67ZbeZa4l3MDly6njfi x731btnmUL7zNF7XrhVQ8L3hvbed0kawbHa08YKKdX1+T+3bojSnhNSzAWksFvoyaEcl oshiva9TCScpwL1I4RtFpmogSebfIHwVy5xKH2A25wQFpp1BcSDhP3owKviOVHtPAeUA uTGoSCmb2i1WuiKFYWGzQPUJ9CFYqJntgbHI5v+j1BD7qmshLyrqABJPKkufRAcsu1Qm cFl1HVALOnDp0/2wm5/+VBQU23ssR5KYyb8Mc2kQX9T+w5P5vorcJCSJO6xB4vEOMirX L/Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=p+Fs/P7gXsm/5qHeFX0rzCcy4XeIXDeOEwU0TTt39+U=; b=WMdiYJzma483LX/7eWvYesnO71G0Y5FGgtUP/p+E6woq12fwin4uzbO0r1o04g2l3l h1N9jU/kHwRWlxujsk1LgLkXmO4safDZHD2Z+pt0LpXuw4ouxxqKdLUoeIA7RIFrk1qv VPxrw8IB4GaO0ykLHEJlhI+ehWrPqrFqswvz630HXzDy01YhT5bxn5lUpY2E/bnqxBS+ Ql6NPR9lHBF/lOKbEmYaXVjw2QTVpCeTPmwIY9a5vMo3BFs0PZQZFTEPgTXVrc9tkr62 ekdcfw1aLVXUEj3KqlUDtZpmnHzBA02EbB44JetjMoxo1GkMcS3S9oFMnC1V2o+9BMyj Yb/A== X-Gm-Message-State: ACrzQf3UpxrE4Tw+YQBY7IiRrUEEq3xPCIe8nz1/ycSW5plyQpF5ppRd Za6twsYZVGC9wbo6y+m4rAnIug== X-Google-Smtp-Source: AMsMyM5L1gGBMlXU1EhsCLiLL1k/0Trfvb0Zs04EUaIadrrwVMgHghkmyPfYrIkJFSp13GpIU9cutw== X-Received: by 2002:a05:600c:35c5:b0:3b4:bf50:f84a with SMTP id r5-20020a05600c35c500b003b4bf50f84amr14722636wmq.22.1664201206627; Mon, 26 Sep 2022 07:06:46 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:45 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria Subject: [PATCH v5 21/30] thermal/drivers/st: Use generic trip points Date: Mon, 26 Sep 2022 16:05:55 +0200 Message-Id: <20220926140604.4173723-22-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert to the generic trip points Signed-off-by: Daniel Lezcano --- drivers/thermal/st/st_thermal.c | 47 +++++---------------------------- 1 file changed, 7 insertions(+), 40 deletions(-) diff --git a/drivers/thermal/st/st_thermal.c b/drivers/thermal/st/st_therma= l.c index 1276b95604fe..c0d45cdd1c2f 100644 --- a/drivers/thermal/st/st_thermal.c +++ b/drivers/thermal/st/st_thermal.c @@ -134,48 +134,12 @@ static int st_thermal_get_temp(struct thermal_zone_de= vice *th, int *temperature) return 0; } =20 -static int st_thermal_get_trip_type(struct thermal_zone_device *th, - int trip, enum thermal_trip_type *type) -{ - struct st_thermal_sensor *sensor =3D th->devdata; - struct device *dev =3D sensor->dev; - - switch (trip) { - case 0: - *type =3D THERMAL_TRIP_CRITICAL; - break; - default: - dev_err(dev, "invalid trip point\n"); - return -EINVAL; - } - - return 0; -} - -static int st_thermal_get_trip_temp(struct thermal_zone_device *th, - int trip, int *temp) -{ - struct st_thermal_sensor *sensor =3D th->devdata; - struct device *dev =3D sensor->dev; - - switch (trip) { - case 0: - *temp =3D mcelsius(sensor->cdata->crit_temp); - break; - default: - dev_err(dev, "Invalid trip point\n"); - return -EINVAL; - } - - return 0; -} - static struct thermal_zone_device_ops st_tz_ops =3D { .get_temp =3D st_thermal_get_temp, - .get_trip_type =3D st_thermal_get_trip_type, - .get_trip_temp =3D st_thermal_get_trip_temp, }; =20 +static struct thermal_trip trip; + int st_thermal_register(struct platform_device *pdev, const struct of_device_id *st_thermal_of_match) { @@ -238,9 +202,12 @@ int st_thermal_register(struct platform_device *pdev, =20 polling_delay =3D sensor->ops->register_enable_irq ? 0 : 1000; =20 + trip.temperature =3D sensor->cdata->crit_temp; + trip.type =3D THERMAL_TRIP_CRITICAL; +=09 sensor->thermal_dev =3D - thermal_zone_device_register(dev_name(dev), 1, 0, sensor, - &st_tz_ops, NULL, 0, polling_delay); + thermal_zone_device_register_with_trips(dev_name(dev), &trip, 1, 0, sens= or, + &st_tz_ops, NULL, 0, polling_delay); if (IS_ERR(sensor->thermal_dev)) { dev_err(dev, "failed to register thermal zone device\n"); ret =3D PTR_ERR(sensor->thermal_dev); --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 9424FC6FA83 for ; Mon, 26 Sep 2022 15:21:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236087AbiIZPVZ (ORCPT ); Mon, 26 Sep 2022 11:21:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236025AbiIZPT0 (ORCPT ); Mon, 26 Sep 2022 11:19:26 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0294983232 for ; Mon, 26 Sep 2022 07:06:50 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id iv17so4582097wmb.4 for ; Mon, 26 Sep 2022 07:06:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=xYvlHjUzJ1gAdl8KtmAH0mCHcP29B+tCMOTUThwt7jg=; b=liAY8kSwesGP7MaoIOTZ0IAN4Zvdt1iNYHsul5rTsE5mLrMsDXWx/ix7SCWx/J4hf5 4AySUU//BfnXeu2vZcGG9pC2zZLY5eApN/QwONGLz6USScpIbYoSBLgZJ0G3NH/f1pk5 s+MyzQio66riivkHY6CO8TkU7GVr4/ojTP1OBNCwmGoyUQbq0dBWfNcTaV3qIMoIpGYe MrtvJ47R2q/GJPEInGnCuLu3CtprwCF0srNOtgP3IxSqulfAtqFfNocH2U3Efss13L3F 7xbI/SqYqKkt/4E7ZAkHdqX7m4sL0ueBQlABUY1UCQnxpRevmKHL+25gOzjgGVj5KZHD cCRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=xYvlHjUzJ1gAdl8KtmAH0mCHcP29B+tCMOTUThwt7jg=; b=p7mFshykBkS85EIb59NbmFpncDmUns8owX07UU1++7MGx2wcX1a49zEg3/LLbdHNpC haoRESpsgCpingpJoBT+HF8Z557qGv1qslpJl58br7vKyIb84vnO7AN8rSRjHE4XD/ah p+PWvo+srBBj/Cz2YV6D5sm64T08nB1DKFRa0Hs5rZgRLM5XFIOV0nBNtn5RNwkECnKv pHs+UYzpreFiupOVEj6GTVRE6TdUg1UiwopqDKDKg9QFF5K8UnjrCustTO2ivUSsYtMS UFWkB1tJfnphsZEkb6mXHm7i8tt1iTHRhgjRQd0xbiBh0ZdekTgRpwUcVaPmlhF1Bt7w sdmg== X-Gm-Message-State: ACrzQf3FVhlUakt5lOtPzYFj/ocD4XVsaJCSNVwNdLAA8udKCPKaLpo7 ilSsSTFNuNwRts190C/ISlP9lA== X-Google-Smtp-Source: AMsMyM4pLzup1JiIdIX2dTkpa05sv5SO7a4FV3of23FpqW+uHfHa2p2IS87RxHo3MO3PI/jvWGdumQ== X-Received: by 2002:a05:600c:24c:b0:3b4:fa20:6f6b with SMTP id 12-20020a05600c024c00b003b4fa206f6bmr15494737wmj.14.1664201209466; Mon, 26 Sep 2022 07:06:49 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:48 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE) Subject: [PATCH v5 22/30] thermal/drivers/imx: Use generic thermal_zone_get_trip() function Date: Mon, 26 Sep 2022 16:05:56 +0200 Message-Id: <20220926140604.4173723-23-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano --- drivers/thermal/imx_thermal.c | 72 +++++++++++++---------------------- 1 file changed, 27 insertions(+), 45 deletions(-) diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 16663373b682..fb0d5cab70af 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -76,7 +76,6 @@ enum imx_thermal_trip { IMX_TRIP_PASSIVE, IMX_TRIP_CRITICAL, - IMX_TRIP_NUM, }; =20 #define IMX_POLLING_DELAY 2000 /* millisecond */ @@ -115,6 +114,11 @@ struct thermal_soc_data { u32 low_alarm_shift; }; =20 +static struct thermal_trip trips[] =3D { + [IMX_TRIP_PASSIVE] =3D { .type =3D THERMAL_TRIP_PASSIVE }, + [IMX_TRIP_CRITICAL] =3D { .type =3D THERMAL_TRIP_CRITICAL }, +}; + static struct thermal_soc_data thermal_imx6q_data =3D { .version =3D TEMPMON_IMX6Q, =20 @@ -201,8 +205,6 @@ struct imx_thermal_data { struct thermal_cooling_device *cdev; struct regmap *tempmon; u32 c1, c2; /* See formula in imx_init_calib() */ - int temp_passive; - int temp_critical; int temp_max; int alarm_temp; int last_temp; @@ -279,12 +281,12 @@ static int imx_get_temp(struct thermal_zone_device *t= z, int *temp) =20 /* Update alarm value to next higher trip point for TEMPMON_IMX6Q */ if (data->socdata->version =3D=3D TEMPMON_IMX6Q) { - if (data->alarm_temp =3D=3D data->temp_passive && - *temp >=3D data->temp_passive) - imx_set_alarm_temp(data, data->temp_critical); - if (data->alarm_temp =3D=3D data->temp_critical && - *temp < data->temp_passive) { - imx_set_alarm_temp(data, data->temp_passive); + if (data->alarm_temp =3D=3D trips[IMX_TRIP_PASSIVE].temperature && + *temp >=3D trips[IMX_TRIP_PASSIVE].temperature) + imx_set_alarm_temp(data, trips[IMX_TRIP_CRITICAL].temperature); + if (data->alarm_temp =3D=3D trips[IMX_TRIP_CRITICAL].temperature && + *temp < trips[IMX_TRIP_PASSIVE].temperature) { + imx_set_alarm_temp(data, trips[IMX_TRIP_PASSIVE].temperature); dev_dbg(&tz->device, "thermal alarm off: T < %d\n", data->alarm_temp / 1000); } @@ -330,29 +332,10 @@ static int imx_change_mode(struct thermal_zone_device= *tz, return 0; } =20 -static int imx_get_trip_type(struct thermal_zone_device *tz, int trip, - enum thermal_trip_type *type) -{ - *type =3D (trip =3D=3D IMX_TRIP_PASSIVE) ? THERMAL_TRIP_PASSIVE : - THERMAL_TRIP_CRITICAL; - return 0; -} - static int imx_get_crit_temp(struct thermal_zone_device *tz, int *temp) { - struct imx_thermal_data *data =3D tz->devdata; - - *temp =3D data->temp_critical; - return 0; -} - -static int imx_get_trip_temp(struct thermal_zone_device *tz, int trip, - int *temp) -{ - struct imx_thermal_data *data =3D tz->devdata; + *temp =3D trips[IMX_TRIP_CRITICAL].temperature; =20 - *temp =3D (trip =3D=3D IMX_TRIP_PASSIVE) ? data->temp_passive : - data->temp_critical; return 0; } =20 @@ -371,10 +354,10 @@ static int imx_set_trip_temp(struct thermal_zone_devi= ce *tz, int trip, return -EPERM; =20 /* do not allow passive to be set higher than critical */ - if (temp < 0 || temp > data->temp_critical) + if (temp < 0 || temp > trips[IMX_TRIP_CRITICAL].temperature) return -EINVAL; =20 - data->temp_passive =3D temp; + trips[IMX_TRIP_PASSIVE].temperature =3D temp; =20 imx_set_alarm_temp(data, temp); =20 @@ -423,8 +406,6 @@ static struct thermal_zone_device_ops imx_tz_ops =3D { .unbind =3D imx_unbind, .get_temp =3D imx_get_temp, .change_mode =3D imx_change_mode, - .get_trip_type =3D imx_get_trip_type, - .get_trip_temp =3D imx_get_trip_temp, .get_crit_temp =3D imx_get_crit_temp, .set_trip_temp =3D imx_set_trip_temp, }; @@ -507,8 +488,8 @@ static void imx_init_temp_grade(struct platform_device = *pdev, u32 ocotp_mem0) * Set the critical trip point at 5 =C2=B0C under max * Set the passive trip point at 10 =C2=B0C under max (changeable via sys= fs) */ - data->temp_critical =3D data->temp_max - (1000 * 5); - data->temp_passive =3D data->temp_max - (1000 * 10); + trips[IMX_TRIP_PASSIVE].temperature =3D data->temp_max - (1000 * 10); + trips[IMX_TRIP_CRITICAL].temperature =3D data->temp_max - (1000 * 5); } =20 static int imx_init_from_tempmon_data(struct platform_device *pdev) @@ -743,12 +724,13 @@ static int imx_thermal_probe(struct platform_device *= pdev) goto legacy_cleanup; } =20 - data->tz =3D thermal_zone_device_register("imx_thermal_zone", - IMX_TRIP_NUM, - BIT(IMX_TRIP_PASSIVE), data, - &imx_tz_ops, NULL, - IMX_PASSIVE_DELAY, - IMX_POLLING_DELAY); + data->tz =3D thermal_zone_device_register_with_trips("imx_thermal_zone", + trips, + ARRAY_SIZE(trips), + BIT(IMX_TRIP_PASSIVE), data, + &imx_tz_ops, NULL, + IMX_PASSIVE_DELAY, + IMX_POLLING_DELAY); if (IS_ERR(data->tz)) { ret =3D PTR_ERR(data->tz); dev_err(&pdev->dev, @@ -758,8 +740,8 @@ static int imx_thermal_probe(struct platform_device *pd= ev) =20 dev_info(&pdev->dev, "%s CPU temperature grade - max:%dC" " critical:%dC passive:%dC\n", data->temp_grade, - data->temp_max / 1000, data->temp_critical / 1000, - data->temp_passive / 1000); + data->temp_max / 1000, trips[IMX_TRIP_CRITICAL].temperature / 1000, + trips[IMX_TRIP_PASSIVE].temperature / 1000); =20 /* Enable measurements at ~ 10 Hz */ regmap_write(map, data->socdata->measure_freq_ctrl + REG_CLR, @@ -767,10 +749,10 @@ static int imx_thermal_probe(struct platform_device *= pdev) measure_freq =3D DIV_ROUND_UP(32768, 10); /* 10 Hz */ regmap_write(map, data->socdata->measure_freq_ctrl + REG_SET, measure_freq << data->socdata->measure_freq_shift); - imx_set_alarm_temp(data, data->temp_passive); + imx_set_alarm_temp(data, trips[IMX_TRIP_PASSIVE].temperature); =20 if (data->socdata->version =3D=3D TEMPMON_IMX6SX) - imx_set_panic_temp(data, data->temp_critical); + imx_set_panic_temp(data, trips[IMX_TRIP_CRITICAL].temperature); =20 regmap_write(map, data->socdata->sensor_ctrl + REG_CLR, data->socdata->power_down_mask); --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 45F6EC07E9D for ; Mon, 26 Sep 2022 15:21:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236367AbiIZPV2 (ORCPT ); Mon, 26 Sep 2022 11:21:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236040AbiIZPT0 (ORCPT ); Mon, 26 Sep 2022 11:19:26 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EECD4832C3 for ; Mon, 26 Sep 2022 07:06:51 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id z6so10445805wrq.1 for ; Mon, 26 Sep 2022 07:06:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=1g7iD3leIss4w6BJ5qO+L1jz4YwsNBVACOWMBVjZgpk=; b=tnnDjaBUtnc7oQrQbRebViXzmDjDdl9T/DEuZNUa9/JCDkDEp4iP53y1QtaSPi98g7 +vBxLVToAlC9nmdKHBjptrLQORY/qiSyHCq9wlVFLXOUH7A/iK8R9RyquHplpBVNBD8g ZrnGKD3wDUl4TdphCW7hwjPVqClPb4iH12hN/2srvVDBes1jZL/Ts/yUoapAQ+Du2hGk 0AWbJxxqH5Z9pBf7KLV9nVueV2+OYe19maKGCS30q5XXT9+KZaBu6Hx+35s4qyIR2mYf F+sGY0Slo13wCBkKp7Q7o6RFh2kwDAr1xMaMP4bLPChHOB39YLUJ6BTtuBvRUcINqmUg 5apg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=1g7iD3leIss4w6BJ5qO+L1jz4YwsNBVACOWMBVjZgpk=; b=OFjjlmF7YL8Yd1hiwp0uhylMcGU9s7fSZOfwetOZPm51L0UL911aQyDjqXvGsabfhb ShhNKY3GS+9QIMtyvAxjQW2z1ccqWW/es+tw4eWGdP7fpVTCV+ISDrg/6cmIRegV/0FM fhldhjCqCtsUvptc6IiCS3WqYCYV27RWx7ZEltPsvQuCm+nkpBXV+wNJD3jqqWdb7y98 fzWuKJP0F9QuJFu4Pp8R6nA4OIX0jr9tsm6ECt43bT1guu/+vqC/DTaEWApQjdGEfiiB zNH6KW4hXgGLCBHFgl6s7maTolPS/xeqOL9Jdtbftp2t8DzRmXqmOePmMSrYquLuxqOp jlhA== X-Gm-Message-State: ACrzQf21stpBiDQ4vf80k4QQRQwe3g05WztxGUVvw26HhZ3FNxejL1zx Ndomt2RuHY4Nv0HrHTTtueUrHw== X-Google-Smtp-Source: AMsMyM4IjuisRUSZFfhh5aV/d+IDBRRQK/plI/EtN4XB30ApYlP4YdMBrxfzv20ceoHjV3K0TdPGqA== X-Received: by 2002:a5d:6147:0:b0:22a:6035:a878 with SMTP id y7-20020a5d6147000000b0022a6035a878mr13189438wrt.528.1664201211500; Mon, 26 Sep 2022 07:06:51 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:50 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, =?UTF-8?q?Niklas=20S=C3=B6derlund?= , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Amit Kucheria , linux-renesas-soc@vger.kernel.org (open list:RENESAS R-CAR THERMAL DRIVERS) Subject: [PATCH v5 23/30] thermal/drivers/rcar: Use generic thermal_zone_get_trip() function Date: Mon, 26 Sep 2022 16:05:57 +0200 Message-Id: <20220926140604.4173723-24-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano Reviewed-by: Niklas S=C3=B6derlund --- drivers/thermal/rcar_thermal.c | 49 +++++----------------------------- 1 file changed, 6 insertions(+), 43 deletions(-) diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index 4df42d70d867..003457810072 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c @@ -278,52 +278,16 @@ static int rcar_thermal_get_temp(struct thermal_zone_= device *zone, int *temp) return rcar_thermal_get_current_temp(priv, temp); } =20 -static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone, - int trip, enum thermal_trip_type *type) -{ - struct rcar_thermal_priv *priv =3D rcar_zone_to_priv(zone); - struct device *dev =3D rcar_priv_to_dev(priv); - - /* see rcar_thermal_get_temp() */ - switch (trip) { - case 0: /* +90 <=3D temp */ - *type =3D THERMAL_TRIP_CRITICAL; - break; - default: - dev_err(dev, "rcar driver trip error\n"); - return -EINVAL; - } - - return 0; -} - -static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone, - int trip, int *temp) -{ - struct rcar_thermal_priv *priv =3D rcar_zone_to_priv(zone); - struct device *dev =3D rcar_priv_to_dev(priv); - - /* see rcar_thermal_get_temp() */ - switch (trip) { - case 0: /* +90 <=3D temp */ - *temp =3D MCELSIUS(90); - break; - default: - dev_err(dev, "rcar driver trip error\n"); - return -EINVAL; - } - - return 0; -} - static struct thermal_zone_device_ops rcar_thermal_zone_of_ops =3D { .get_temp =3D rcar_thermal_get_temp, }; =20 static struct thermal_zone_device_ops rcar_thermal_zone_ops =3D { .get_temp =3D rcar_thermal_get_temp, - .get_trip_type =3D rcar_thermal_get_trip_type, - .get_trip_temp =3D rcar_thermal_get_trip_temp, +}; + +static struct thermal_trip trips[] =3D { + { .type =3D THERMAL_TRIP_CRITICAL, .temperature =3D 90000 } }; =20 /* @@ -531,9 +495,8 @@ static int rcar_thermal_probe(struct platform_device *p= dev) dev, i, priv, &rcar_thermal_zone_of_ops); } else { - priv->zone =3D thermal_zone_device_register( - "rcar_thermal", - 1, 0, priv, + priv->zone =3D thermal_zone_device_register_with_trips( + "rcar_thermal", trips, ARRAY_SIZE(trips), 0, priv, &rcar_thermal_zone_ops, NULL, 0, idle); =20 --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 6B8B9C6FA93 for ; Mon, 26 Sep 2022 15:21:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236208AbiIZPVb (ORCPT ); Mon, 26 Sep 2022 11:21:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236148AbiIZPTp (ORCPT ); Mon, 26 Sep 2022 11:19:45 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51D04832DB for ; Mon, 26 Sep 2022 07:06:55 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id e10-20020a05600c4e4a00b003b4eff4ab2cso7560723wmq.4 for ; Mon, 26 Sep 2022 07:06:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=RuOkdBUevpNwOF5uxKYPUxVuiSYnY/XeiYrwbyLTKVs=; b=T+qYO3llwUwso32BkYS1kv3SBonRyZ9HsFQWCOev8fDPELdQc56lwcRjbNa63bPjsJ AaK79jaNovAimi7tlaHVhvniTBHRV7hW+FOu/EH8GGJxIzm065Bpps4tFmlkiglF1UyJ RnQ3bbwNQ63gu6tEXBSnBfG8Py9YJIG3Dcl/YjXeLnBvraZGS5nXDqDrpQEho5uBlrjt xqWiHi+aqbEOkvMk15ibG+u4pIZ2zH2B863kKw+d1p9a9uC+MMkm8zfiw4qY3EkLRqXv nwrLU3IZNbo00BYmLVBQaCM+zUNbvGoV/Av6zNt0VbpME2DMw6Lg9Pd4jJWulb6djHL+ tKqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=RuOkdBUevpNwOF5uxKYPUxVuiSYnY/XeiYrwbyLTKVs=; b=cPart4wYrPBCgeqpnBXDr+8ZEci/iGmntGigmS5WFJHwF8Qit34RlptFoB4wjV9cBq 5fHfeCYzNilf6CXMmg7ZQLbVwyJVzI6uxIZeNBRq82nJHetNUj+rL9o+zOAJaVr/EK2V 7Dw4V1xX8cNqiHtG89ASO6CoK5PR7vWb4Hfn2h29QVoMs2CWvRND+gihALOgptT1CWDE 1DNv7/SjpDFsOEC2y+vQ+8TwUKxQNlx2DzprNaJop4cjUN68jEtVgmm16pbCexHPsDB5 fTb9zkPiwq6eG0b97MgkFzLMvLvzcF8YPLSrgxoh5IxR2aSct6Io/qh1Vyi1DXjf7paA d2ZQ== X-Gm-Message-State: ACrzQf1c0wkVJfOt1Y1UnLrLPvUG+d6WmcT6ecxCxWF179F8derYI7rd sOM3bDaVVa4O1+ezgK7VV71iBA== X-Google-Smtp-Source: AMsMyM7KmIDtVH4wXUQBQWMer4IDmi6aj2W1A3NPf9b5sqTNvsh7yYTzc41bHp9m8L4yiccyBTvqTA== X-Received: by 2002:a7b:cb41:0:b0:3b3:34d6:189f with SMTP id v1-20020a7bcb41000000b003b334d6189fmr22308524wmj.6.1664201213772; Mon, 26 Sep 2022 07:06:53 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:52 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE) Subject: [PATCH v5 24/30] thermal/drivers/broadcom: Use generic thermal_zone_get_trip() function Date: Mon, 26 Sep 2022 16:05:58 +0200 Message-Id: <20220926140604.4173723-25-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano --- drivers/thermal/broadcom/bcm2835_thermal.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/broadcom/bcm2835_thermal.c b/drivers/thermal/b= roadcom/bcm2835_thermal.c index 2c67841a1115..5485e59d03a9 100644 --- a/drivers/thermal/broadcom/bcm2835_thermal.c +++ b/drivers/thermal/broadcom/bcm2835_thermal.c @@ -18,6 +18,7 @@ #include #include =20 +#include "../thermal_core.h" #include "../thermal_hwmon.h" =20 #define BCM2835_TS_TSENSCTL 0x00 @@ -224,7 +225,8 @@ static int bcm2835_thermal_probe(struct platform_device= *pdev) */ val =3D readl(data->regs + BCM2835_TS_TSENSCTL); if (!(val & BCM2835_TS_TSENSCTL_RSTB)) { - int trip_temp, offset, slope; + struct thermal_trip trip; + int offset, slope; =20 slope =3D thermal_zone_get_slope(tz); offset =3D thermal_zone_get_offset(tz); @@ -232,7 +234,7 @@ static int bcm2835_thermal_probe(struct platform_device= *pdev) * For now we deal only with critical, otherwise * would need to iterate */ - err =3D tz->ops->get_trip_temp(tz, 0, &trip_temp); + err =3D thermal_zone_get_trip(tz, 0, &trip); if (err < 0) { dev_err(&pdev->dev, "Not able to read trip_temp: %d\n", @@ -249,7 +251,7 @@ static int bcm2835_thermal_probe(struct platform_device= *pdev) val |=3D (0xFE << BCM2835_TS_TSENSCTL_RSTDELAY_SHIFT); =20 /* trip_adc value from info */ - val |=3D bcm2835_thermal_temp2adc(trip_temp, + val |=3D bcm2835_thermal_temp2adc(trip.temperature, offset, slope) << BCM2835_TS_TSENSCTL_THOLD_SHIFT; --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 E3767C32771 for ; Mon, 26 Sep 2022 15:21:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236390AbiIZPVe (ORCPT ); Mon, 26 Sep 2022 11:21:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236156AbiIZPTs (ORCPT ); Mon, 26 Sep 2022 11:19:48 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96C09832E3 for ; Mon, 26 Sep 2022 07:06:55 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id l8so4591916wmi.2 for ; Mon, 26 Sep 2022 07:06:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=kNTESOeVOVH9BHNMsa7BlHA2jeppHM3L2UNE800z/X4=; b=Fe8kj3lSLJbpH2Bjue8Xpkt9j8RTQPfTKlf2Tav3s6oYchj4vsu6qnavhzm/mlzVJn xf6J4fINPX2xnNrEjEStWEkmiVNCpxyL8D9mT8w8q9dMRa9q6zQqWHUo90TAA1JSG0aU bRs9NY9+DbYR2OP8bmzVevSh1QTLN+vWx6uqNMSk9pNwa9O5QRsScX5/vc6wdr6bBdt3 jyl0LAyNPdqIaZf8XlYaCL1b6BAweLJhUf2E9Qx9UyuFuf7ZLB44cm8MzMNi3wdbnyGN /zQL0qnRSp83ZSag8Kw9u3Jbp52xi1ZY4G0+uHTU8WRzSzJgxnxo1+gNR0IGFO/GjtIO s0nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=kNTESOeVOVH9BHNMsa7BlHA2jeppHM3L2UNE800z/X4=; b=J+kHMRATplk/Tcs/vzW5Ak8Nvftld0vcIZlHV090DQwogsxGK1ZNyE/OG6Ez1ShRYl pr42yk/J4uaPahxx7t1dKA2/ChDKkk0FnUrumstGGIhegDL+VbFXiowuokjz+mdX3eX4 oPqsIPUicspmgc+D2eDLNzXCy9E1GpOuvC7ciwn/86g6sMCeonqkgZpxaIb/9NImtvhX OQ6arb5qw/bZWUXpA8tmzlqsOjHbgMtLvqXiZDL++A6oryk6QQdQ8+tAsehnJW7aLvw0 PrV/ZcmQCmYQqaJl/Kt+0pOsXFjEXQKcbb+ebApk/2RLtIOXRHKDg4z0L394KFg+rL5g u2QA== X-Gm-Message-State: ACrzQf0h5MUXNAZpQj/FvgYKOPsnHz85mSpvUfFP/xpTAQUVWdfy+EgR TbZahZ60jII+rzoH59Nk7qYhXw== X-Google-Smtp-Source: AMsMyM7rjqJemvsHKCwlSSbjCB715qLC8H61WEcCvZBmalbWSCozWi68sTkcFPftEgjyGVwnV89Ctw== X-Received: by 2002:a05:600c:3c89:b0:3b5:e3:bd0f with SMTP id bg9-20020a05600c3c8900b003b500e3bd0fmr15668009wmb.199.1664201215081; Mon, 26 Sep 2022 07:06:55 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:54 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Adam Ward , Support Opensource , Amit Kucheria Subject: [PATCH v5 25/30] thermal/drivers/da9062: Use generic thermal_zone_get_trip() function Date: Mon, 26 Sep 2022 16:05:59 +0200 Message-Id: <20220926140604.4173723-26-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano Reviewed-by: Adam Ward --- drivers/thermal/da9062-thermal.c | 52 +++++--------------------------- 1 file changed, 8 insertions(+), 44 deletions(-) diff --git a/drivers/thermal/da9062-thermal.c b/drivers/thermal/da9062-ther= mal.c index 180edec34e07..1e163e90d6b6 100644 --- a/drivers/thermal/da9062-thermal.c +++ b/drivers/thermal/da9062-thermal.c @@ -120,44 +120,6 @@ static irqreturn_t da9062_thermal_irq_handler(int irq,= void *data) return IRQ_HANDLED; } =20 -static int da9062_thermal_get_trip_type(struct thermal_zone_device *z, - int trip, - enum thermal_trip_type *type) -{ - struct da9062_thermal *thermal =3D z->devdata; - - switch (trip) { - case 0: - *type =3D THERMAL_TRIP_HOT; - break; - default: - dev_err(thermal->dev, - "Driver does not support more than 1 trip-wire\n"); - return -EINVAL; - } - - return 0; -} - -static int da9062_thermal_get_trip_temp(struct thermal_zone_device *z, - int trip, - int *temp) -{ - struct da9062_thermal *thermal =3D z->devdata; - - switch (trip) { - case 0: - *temp =3D DA9062_MILLI_CELSIUS(125); - break; - default: - dev_err(thermal->dev, - "Driver does not support more than 1 trip-wire\n"); - return -EINVAL; - } - - return 0; -} - static int da9062_thermal_get_temp(struct thermal_zone_device *z, int *temp) { @@ -172,8 +134,10 @@ static int da9062_thermal_get_temp(struct thermal_zone= _device *z, =20 static struct thermal_zone_device_ops da9062_thermal_ops =3D { .get_temp =3D da9062_thermal_get_temp, - .get_trip_type =3D da9062_thermal_get_trip_type, - .get_trip_temp =3D da9062_thermal_get_trip_temp, +}; + +static struct thermal_trip trips[] =3D { + { .temperature =3D DA9062_MILLI_CELSIUS(125), .type =3D THERMAL_TRIP_HOT = }, }; =20 static const struct da9062_thermal_config da9062_config =3D { @@ -228,10 +192,10 @@ static int da9062_thermal_probe(struct platform_devic= e *pdev) INIT_DELAYED_WORK(&thermal->work, da9062_thermal_poll_on); mutex_init(&thermal->lock); =20 - thermal->zone =3D thermal_zone_device_register(thermal->config->name, - 1, 0, thermal, - &da9062_thermal_ops, NULL, pp_tmp, - 0); + thermal->zone =3D thermal_zone_device_register_with_trips(thermal->config= ->name, + trips, ARRAY_SIZE(trips), 0, thermal, + &da9062_thermal_ops, NULL, pp_tmp, + 0); if (IS_ERR(thermal->zone)) { dev_err(&pdev->dev, "Cannot register thermal zone device\n"); ret =3D PTR_ERR(thermal->zone); --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 53AC6C32771 for ; Mon, 26 Sep 2022 15:21:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236396AbiIZPVh (ORCPT ); Mon, 26 Sep 2022 11:21:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236185AbiIZPUM (ORCPT ); Mon, 26 Sep 2022 11:20:12 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0819B832EC for ; Mon, 26 Sep 2022 07:06:58 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id iv17so4582420wmb.4 for ; Mon, 26 Sep 2022 07:06:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=v9HOYNemLB65v2s3X2Chh/1DsPPvYHZYg0+K/15aDgQ=; b=FI1oyr+D9871we4e977QPagSCksT3Vn7/qJpbsueClzMSG2AwheE5iFNGGcPEWufel iyxpUf5nJIy8r/zyl21f72M3v2gAF64QhIYWHhvjm+0x3c5pPNlz4p4iqlZLrNKOtQCv eMlW95TYtzCKYhMdSZxQRzJUi3i49nJcKHM0sBsH4F7YB9Sgs5sZvh6DnVZcqSyptluf ISVKXupseoR3M7XTZUop4rIAqmcDNr7H2v1CQ0Uu5upIJesE55OBbFhDAabfWAx8nN4C WC1xRxXcaG9H4Thc7/P73siRGhzcEqkTupW2EZtjR12EGPRaKooCX8l0oJRQhIut25Db LgrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=v9HOYNemLB65v2s3X2Chh/1DsPPvYHZYg0+K/15aDgQ=; b=E/5ozGOXCKoh72IWBJOVqZFDYQiiL1sS4u+R35uaHTN182b2E2of4nxF/XGs1s2wiw uZiwAQKUoQSyV2ngGoj1Q97qYIhhkZyD8XmrI5FTOTBcsKkVuit0lezoQKRSPhhu8FBM k+E5is2JLpfp1IWxwj3DslinWNfDctrinjI8rqko0TTgDSeiFwVtr+YRsuEKd5R1mIDj 9lNdf7NOVCTU5Xwt4+0MZuD5W5E8bqm18+GFfenRoy5/NL8aPmQ9k7d+hqBWvpNFBUdG zyO7lUYk60oHfdtVlpDat/xwTJvVk4aWLmxL/s0jJBCBiis4hTBSXFSw73a1coao8zGT Mnvg== X-Gm-Message-State: ACrzQf2Q0KnoLLBNwkSIiUmJFb642n3Wl6gih1QOXiEeCT6B4qUg8IDS Ht8dD9874ArAD1LjZpeH05xbvg== X-Google-Smtp-Source: AMsMyM6xkd/pk1GXwnK4P4u9p8j8iWl4vDDrWGvxUXOc+roZrlpfbTZv4DWRAHQRzgMvcUrpoMBWpA== X-Received: by 2002:a05:600c:6025:b0:3b4:8c0c:f3c9 with SMTP id az37-20020a05600c602500b003b48c0cf3c9mr21934841wmb.206.1664201216379; Mon, 26 Sep 2022 07:06:56 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:55 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Eduardo Valentin , Keerthy , Amit Kucheria , linux-omap@vger.kernel.org (open list:TI BANDGAP AND THERMAL DRIVER) Subject: [PATCH v5 26/30] thermal/drivers/ti: Remove unused macros ti_thermal_get_trip_value() / ti_thermal_trip_is_valid() Date: Mon, 26 Sep 2022 16:06:00 +0200 Message-Id: <20220926140604.4173723-27-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The macros: ti_thermal_get_trip_value() ti_thermal_trip_is_valid() are unused. Remove them. Signed-off-by: Daniel Lezcano --- drivers/thermal/ti-soc-thermal/ti-thermal.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal.h b/drivers/thermal/= ti-soc-thermal/ti-thermal.h index c388ecf31834..4fd2c20182d7 100644 --- a/drivers/thermal/ti-soc-thermal/ti-thermal.h +++ b/drivers/thermal/ti-soc-thermal/ti-thermal.h @@ -38,21 +38,6 @@ /* Update rates */ #define FAST_TEMP_MONITORING_RATE 250 =20 -/* helper macros */ -/** - * ti_thermal_get_trip_value - returns trip temperature based on index - * @i: trip index - */ -#define ti_thermal_get_trip_value(i) \ - (OMAP_TRIP_HOT + ((i) * OMAP_TRIP_STEP)) - -/** - * ti_thermal_is_valid_trip - check for trip index - * @i: trip index - */ -#define ti_thermal_is_valid_trip(trip) \ - ((trip) >=3D 0 && (trip) < OMAP_TRIP_NUMBER) - #ifdef CONFIG_TI_THERMAL int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id, char *domain); int ti_thermal_remove_sensor(struct ti_bandgap *bgp, int id); --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 DF664C6FA86 for ; Mon, 26 Sep 2022 15:21:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236242AbiIZPVq (ORCPT ); Mon, 26 Sep 2022 11:21:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236202AbiIZPUQ (ORCPT ); Mon, 26 Sep 2022 11:20:16 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56E85832EF for ; Mon, 26 Sep 2022 07:06:59 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id fn7-20020a05600c688700b003b4fb113b86so3818278wmb.0 for ; Mon, 26 Sep 2022 07:06:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Bvo7EJO01qiFSqaGbT4JiAGDEh8uk0vvz3ltgjeJ4xY=; b=FAE2j0go+IJoVbSOEoS/wABZka52n31gX/OBRtsHZ8JZMRuxdBmePkjjo6z/BlAixW Pdm00JdDcaKRRkjyQ8WHjxQagb6jLtuqz6exeGmeI7a9YSv7ASu9hvageY7giMSIICna sHbrYljjkAeh/kKUtshKIdkadD5fQjyoqCgOtqo6JScf6eAapxVquUYwhwLuHzWWzWpM Re/KHDXfteQtRlnZd3g6lCsjAMxhC4Hm0dl/qhDjsOSJHgH11828dCx/MrjxpBD1PviK 8Fjd/AVPS+3o0SUvr8X2DXR30b6iSdptr1EHIxIoRoASaUS0mLopFtXLAv834cXxkgmJ EPvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Bvo7EJO01qiFSqaGbT4JiAGDEh8uk0vvz3ltgjeJ4xY=; b=AVUq7sZo/XtsGJVLqFjDYYwFympXGP4xRilEwgVk9cRD0LDPwpf0i0GL9woGSUf6uh ReJKK/2/7YK1NqQKz3kx0vMfD6YUnwHRGINwHwW/A+KVsfik19Mpo8zNeg+b3FxkrHDd pwZRMIMXmH5OKUfALqbsfs2ZOs7umiqx+aoxY+j+/YPota97iJbdKzTxCgM1JLIGyEU3 ylHiurPKYXFs52keHnsffM/NGLynYIVDMBEBYkB+KbQSAfdFMX+2G4iTX2lZqjvPrNxM 2sFSM53hb5PJOxoafqcatdTds8WGfOiQtEWaUawMUpWDb75hw3wVrBai3PPvtil8CGsQ qBVw== X-Gm-Message-State: ACrzQf1MquSI4I6jEEVJYyommhrE6pIIVpEZpb6PLG+0rAbWeZVaoRso tp9uFxxCtzSVjo2AZAb2Ey3RFw== X-Google-Smtp-Source: AMsMyM5brRbVIu8prE+s9fHo4GykS/cr7HtVSKhmJZW4eCeuMB4nsb5ZIQ1U5D9kLdTmOzJDbFYxhw== X-Received: by 2002:a05:600c:3b1f:b0:3b4:b1fc:4797 with SMTP id m31-20020a05600c3b1f00b003b4b1fc4797mr22405991wms.129.1664201217638; Mon, 26 Sep 2022 07:06:57 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:57 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Hans de Goede , =?UTF-8?q?Peter=20K=C3=A4stle?= , Mark Gross , platform-driver-x86@vger.kernel.org (open list:ACER ASPIRE ONE TEMPERATURE AND FAN DRIVER) Subject: [PATCH v5 27/30] thermal/drivers/acerhdf: Use generic thermal_zone_get_trip() function Date: Mon, 26 Sep 2022 16:06:01 +0200 Message-Id: <20220926140604.4173723-28-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano Acked-by: Hans de Goede Acked-by: Peter K=C3=A4stle --- drivers/platform/x86/acerhdf.c | 73 ++++++++++++---------------------- 1 file changed, 26 insertions(+), 47 deletions(-) diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c index 3463629f8764..a7407aa032ba 100644 --- a/drivers/platform/x86/acerhdf.c +++ b/drivers/platform/x86/acerhdf.c @@ -46,6 +46,8 @@ * measured by the on-die thermal monitor are within 0 <=3D Tj <=3D 90. So, * assume 89=C2=B0C is critical temperature. */ +#define ACERHDF_DEFAULT_TEMP_FANON 60000 +#define ACERHDF_DEFAULT_TEMP_FANOFF 53000 #define ACERHDF_TEMP_CRIT 89000 #define ACERHDF_FAN_OFF 0 #define ACERHDF_FAN_AUTO 1 @@ -70,8 +72,8 @@ static int kernelmode; #endif =20 static unsigned int interval =3D 10; -static unsigned int fanon =3D 60000; -static unsigned int fanoff =3D 53000; +static unsigned int fanon =3D ACERHDF_DEFAULT_TEMP_FANON; +static unsigned int fanoff =3D ACERHDF_DEFAULT_TEMP_FANOFF; static unsigned int verbose; static unsigned int list_supported; static unsigned int fanstate =3D ACERHDF_FAN_AUTO; @@ -137,6 +139,15 @@ struct ctrl_settings { int mcmd_enable; }; =20 +static struct thermal_trip trips[] =3D { + [0] =3D { .temperature =3D ACERHDF_DEFAULT_TEMP_FANON, + .hysteresis =3D ACERHDF_DEFAULT_TEMP_FANON - ACERHDF_DEFAULT_TEMP_FANOFF, + .type =3D THERMAL_TRIP_ACTIVE }, + + [1] =3D { .temperature =3D ACERHDF_TEMP_CRIT, + .type =3D THERMAL_TRIP_CRITICAL } +}; + static struct ctrl_settings ctrl_cfg __read_mostly; =20 /* Register addresses and values for different BIOS versions */ @@ -326,6 +337,15 @@ static void acerhdf_check_param(struct thermal_zone_de= vice *thermal) fanon =3D ACERHDF_MAX_FANON; } =20 + if (fanon < fanoff) { + pr_err("fanoff temperature (%d) is above fanon temperature (%d), clampin= g to %d\n", + fanoff, fanon, fanon); + fanoff =3D fanon; + }; + + trips[0].temperature =3D fanon; + trips[0].hysteresis =3D fanon - fanoff; + if (kernelmode && prev_interval !=3D interval) { if (interval > ACERHDF_MAX_INTERVAL) { pr_err("interval too high, set to %d\n", @@ -424,43 +444,6 @@ static int acerhdf_change_mode(struct thermal_zone_dev= ice *thermal, return 0; } =20 -static int acerhdf_get_trip_type(struct thermal_zone_device *thermal, int = trip, - enum thermal_trip_type *type) -{ - if (trip =3D=3D 0) - *type =3D THERMAL_TRIP_ACTIVE; - else if (trip =3D=3D 1) - *type =3D THERMAL_TRIP_CRITICAL; - else - return -EINVAL; - - return 0; -} - -static int acerhdf_get_trip_hyst(struct thermal_zone_device *thermal, int = trip, - int *temp) -{ - if (trip !=3D 0) - return -EINVAL; - - *temp =3D fanon - fanoff; - - return 0; -} - -static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int = trip, - int *temp) -{ - if (trip =3D=3D 0) - *temp =3D fanon; - else if (trip =3D=3D 1) - *temp =3D ACERHDF_TEMP_CRIT; - else - return -EINVAL; - - return 0; -} - static int acerhdf_get_crit_temp(struct thermal_zone_device *thermal, int *temperature) { @@ -474,13 +457,9 @@ static struct thermal_zone_device_ops acerhdf_dev_ops = =3D { .unbind =3D acerhdf_unbind, .get_temp =3D acerhdf_get_ec_temp, .change_mode =3D acerhdf_change_mode, - .get_trip_type =3D acerhdf_get_trip_type, - .get_trip_hyst =3D acerhdf_get_trip_hyst, - .get_trip_temp =3D acerhdf_get_trip_temp, .get_crit_temp =3D acerhdf_get_crit_temp, }; =20 - /* * cooling device callback functions * get maximal fan cooling state @@ -710,10 +689,10 @@ static int __init acerhdf_register_thermal(void) if (IS_ERR(cl_dev)) return -EINVAL; =20 - thz_dev =3D thermal_zone_device_register("acerhdf", 2, 0, NULL, - &acerhdf_dev_ops, - &acerhdf_zone_params, 0, - (kernelmode) ? interval*1000 : 0); + thz_dev =3D thermal_zone_device_register_with_trips("acerhdf", trips, ARR= AY_SIZE(trips), + 0, NULL, &acerhdf_dev_ops, + &acerhdf_zone_params, 0, + (kernelmode) ? interval*1000 : 0); if (IS_ERR(thz_dev)) return -EINVAL; =20 --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 C6C20C32771 for ; Mon, 26 Sep 2022 15:21:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236401AbiIZPVl (ORCPT ); Mon, 26 Sep 2022 11:21:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236207AbiIZPUR (ORCPT ); Mon, 26 Sep 2022 11:20:17 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA7E9832F5 for ; Mon, 26 Sep 2022 07:06:59 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id x18so10395887wrm.7 for ; Mon, 26 Sep 2022 07:06:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=qkEQMAFlFrUq6t0pAagx8mtMZ2aPJX8cpHX423TQAwM=; b=xDRypCVJOOBrUVPYKY74P2USId5xHlVNEvoXFDm+N3UgPg9E4pPYzzIwfzb8BCHSUJ M8AZeuaUbJWDyvou67mMvxkRf3BzVBSuDmgKWmJ6HD0dfQf0IchmYudSHB02ZvXbhUxT iBjOmxaKlKEUdwVRy93PDuBLcnaZaZ9Qt470bwb7cKsVyrrbv76VqkvLSuPsGRuUCN1K +ViFfK7sHUe4/ztkrtpSgHiwYmK8T1iTj1Mkspn/F0jcb0X78ntG/zFr6Y65r4ngDjkR 4bPm/BpRioUDqicQrMMgbLHwTnsWgQEaXslDR9FVxOKiZzOnchGQ0owf7IHzAI67Fpcx 5CcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=qkEQMAFlFrUq6t0pAagx8mtMZ2aPJX8cpHX423TQAwM=; b=Zc07u9mSEu1RKQVSkHCjKlWkrtKX0VVqY8x6fnI8HwX5eih3ZoIg377W1I0b3fNhj5 dDJ+3X/didDJgqID/oBpfjG41vnr84cPE7aH8lgr2Cre2j9CaDDj5wT4+qfPRy4rDPWT ZQ172ArTDeBHhIpx0Cg5McyuQiytDbg/t+hhXGhgcAjJ1dz7X22Mm82R2Q35vixTPeKI DgQ1e7S3wW420928xlxMWWWSSAO2FajNA5KKjqZ9oDX8a6xpDxFW+ZGwH51se/o/q7Ps DNMgd6gNAQJnjBeqOcpzlZmMT1XvjBKanpc4SGdttDc91hXNzECHPE528T9SM9qyrEcj lf1w== X-Gm-Message-State: ACrzQf0+Vb27Qs+V1frvZga3u33Sji7c0uaN1HoPOsuDtDpZ9O9i1g9u wKS6OFeHXeICwKDAjTBvZXd+YQ== X-Google-Smtp-Source: AMsMyM6q4AMv4cqASiSW7HejHMKL9jni9voPK7VjIxylg1FgOgGS9Is+Vj/kzqdSultE61PDVeqwrg== X-Received: by 2002:a5d:6a07:0:b0:228:dba4:2138 with SMTP id m7-20020a5d6a07000000b00228dba42138mr13238082wru.346.1664201219192; Mon, 26 Sep 2022 07:06:59 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.06.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:06:58 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Jakub Kicinski , Raju Rangoju , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org (open list:CXGB4 ETHERNET DRIVER (CXGB4)) Subject: [PATCH v5 28/30] thermal/drivers/cxgb4: Use generic thermal_zone_get_trip() function Date: Mon, 26 Sep 2022 16:06:02 +0200 Message-Id: <20220926140604.4173723-29-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano Acked-by: Jakub Kicinski --- drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 2 - .../ethernet/chelsio/cxgb4/cxgb4_thermal.c | 41 ++++--------------- 2 files changed, 8 insertions(+), 35 deletions(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ether= net/chelsio/cxgb4/cxgb4.h index 5657ac8cfca0..fca9533bc011 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h @@ -1079,8 +1079,6 @@ struct mbox_list { #if IS_ENABLED(CONFIG_THERMAL) struct ch_thermal { struct thermal_zone_device *tzdev; - int trip_temp; - int trip_type; }; #endif =20 diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c b/drivers/n= et/ethernet/chelsio/cxgb4/cxgb4_thermal.c index 9a6d65243334..1d49cfe3e2ab 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c @@ -29,36 +29,12 @@ static int cxgb4_thermal_get_temp(struct thermal_zone_d= evice *tzdev, return 0; } =20 -static int cxgb4_thermal_get_trip_type(struct thermal_zone_device *tzdev, - int trip, enum thermal_trip_type *type) -{ - struct adapter *adap =3D tzdev->devdata; - - if (!adap->ch_thermal.trip_temp) - return -EINVAL; - - *type =3D adap->ch_thermal.trip_type; - return 0; -} - -static int cxgb4_thermal_get_trip_temp(struct thermal_zone_device *tzdev, - int trip, int *temp) -{ - struct adapter *adap =3D tzdev->devdata; - - if (!adap->ch_thermal.trip_temp) - return -EINVAL; - - *temp =3D adap->ch_thermal.trip_temp; - return 0; -} - static struct thermal_zone_device_ops cxgb4_thermal_ops =3D { .get_temp =3D cxgb4_thermal_get_temp, - .get_trip_type =3D cxgb4_thermal_get_trip_type, - .get_trip_temp =3D cxgb4_thermal_get_trip_temp, }; =20 +static struct thermal_trip trip =3D { .type =3D THERMAL_TRIP_CRITICAL } ; + int cxgb4_thermal_init(struct adapter *adap) { struct ch_thermal *ch_thermal =3D &adap->ch_thermal; @@ -79,15 +55,14 @@ int cxgb4_thermal_init(struct adapter *adap) if (ret < 0) { num_trip =3D 0; /* could not get trip temperature */ } else { - ch_thermal->trip_temp =3D val * 1000; - ch_thermal->trip_type =3D THERMAL_TRIP_CRITICAL; + trip.temperature =3D val * 1000; } - +=09 snprintf(ch_tz_name, sizeof(ch_tz_name), "cxgb4_%s", adap->name); - ch_thermal->tzdev =3D thermal_zone_device_register(ch_tz_name, num_trip, - 0, adap, - &cxgb4_thermal_ops, - NULL, 0, 0); + ch_thermal->tzdev =3D thermal_zone_device_register_with_trips(ch_tz_name,= &trip, num_trip, + 0, adap, + &cxgb4_thermal_ops, + NULL, 0, 0); if (IS_ERR(ch_thermal->tzdev)) { ret =3D PTR_ERR(ch_thermal->tzdev); dev_err(adap->pdev_dev, "Failed to register thermal zone\n"); --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 67F45C07E9D for ; Mon, 26 Sep 2022 15:21:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236423AbiIZPVu (ORCPT ); Mon, 26 Sep 2022 11:21:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236223AbiIZPUY (ORCPT ); Mon, 26 Sep 2022 11:20:24 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4944983BD6 for ; Mon, 26 Sep 2022 07:07:03 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id z13-20020a7bc7cd000000b003b5054c6f9bso7050924wmk.2 for ; Mon, 26 Sep 2022 07:07:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=KZ8EnQSq9ZUNp2qj7akZkpIkjIeNnNIZanKBvoVLLJ0=; b=Qx2fE6wuyi3rzIg/90cnrEvW3pXmh0EBLKulLETWC/iB8oJh9uMnHvNH99WjYzPhkr vfRk6x8D+TWr7M1lbVuyDgLYD5TWt+c4NrTo2KatD3tp2Cn76rAShjJAlqaiSMRvtQPJ GwnihtGzvRy96EoXDf+ijkzJOYybcl9OzbHnTK4zpc5qlj2bvUygbeOnH5eeRRgbG4ZK nG1LOuUfPPURatHTQxLFjNWl1wcFAYOEXtK+Ac5667QtIgK9WJoNaWuaPZcUzO0RBOdM GEKvZ/eiBdl/m5x7VbagiUycRTJuab3qByWOqTrRIAnYcglIydysL6CRuub8SEk/LIdG 500Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=KZ8EnQSq9ZUNp2qj7akZkpIkjIeNnNIZanKBvoVLLJ0=; b=zhe5MGXOI1vobDGJGI0efksy8AYRp5dGjfDqe7p+DLtw1masrMzApzFMijvPtOqQeo CisWX/pKuTucWZJw/mtdFURktaoor75QLv3M1nAxCrOI4s0InJfZZLi+qBKYHGa3KglS 1jvBaBLhpDOvs6Px22L1l3X0GcWvUESrzFQDwN8YkLf7PeJpVSn7awHKGrMU0DLLJdke Lv492WVyuw/D42Pydx6WWR5rNDfvpdBUEGxgdoJn9hF1ekZ+vLWneUbzA7Ew7jYBPcWJ TIMoPFZRvl6NYDPIsk6h2cgvFdfhyHkWafrzWNZFxPCgSKxJRfFSLoSaZ4ASymYb5rCI /kvw== X-Gm-Message-State: ACrzQf2id2oxtqCaoRd3kb6EOrVG9gfm7/jFgpzLikulP3+EvVl0LRKC vOeESircFHMm2dpc5Doh2spmOg== X-Google-Smtp-Source: AMsMyM6AsJX7rp2Tz3d4FiAMfTy0IDkbMtC/VYyWqe76Zvb6NW6drIQVTtFUU7bl42HbRgI7df/D8w== X-Received: by 2002:a05:600c:3555:b0:3b4:c0fd:918e with SMTP id i21-20020a05600c355500b003b4c0fd918emr14808605wmq.61.1664201222706; Mon, 26 Sep 2022 07:07:02 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.07.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:07:01 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Srinivas Pandruvada , Amit Kucheria , Nathan Chancellor , Antoine Tenart Subject: [PATCH v5 29/30] thermal/intel/int340x: Replace parameter to simplify Date: Mon, 26 Sep 2022 16:06:03 +0200 Message-Id: <20220926140604.4173723-30-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In the process of replacing the get_trip_* ops by the generic trip points, the current code has an 'override' property to add another indirection to a different ops. Rework this approach to prevent this indirection and make the code ready for the generic trip points conversion. Actually the get_temp() is different regarding the platform, so it is pointless to add a new set of ops but just create dynamically the ops at init time. Signed-off-by: Daniel Lezcano Reviewed-by: Srinivas Pandruvada --- .../int340x_thermal/int340x_thermal_zone.c | 31 ++++++++----------- .../int340x_thermal/int340x_thermal_zone.h | 4 +-- .../processor_thermal_device.c | 10 ++---- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c b= /drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c index 62c0aa5d0783..10731b9a140a 100644 --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c @@ -18,9 +18,6 @@ static int int340x_thermal_get_zone_temp(struct thermal_z= one_device *zone, unsigned long long tmp; acpi_status status; =20 - if (d->override_ops && d->override_ops->get_temp) - return d->override_ops->get_temp(zone, temp); - status =3D acpi_evaluate_integer(d->adev->handle, "_TMP", NULL, &tmp); if (ACPI_FAILURE(status)) return -EIO; @@ -46,9 +43,6 @@ static int int340x_thermal_get_trip_temp(struct thermal_z= one_device *zone, struct int34x_thermal_zone *d =3D zone->devdata; int i; =20 - if (d->override_ops && d->override_ops->get_trip_temp) - return d->override_ops->get_trip_temp(zone, trip, temp); - if (trip < d->aux_trip_nr) *temp =3D d->aux_trips[trip]; else if (trip =3D=3D d->crt_trip_id) @@ -79,9 +73,6 @@ static int int340x_thermal_get_trip_type(struct thermal_z= one_device *zone, struct int34x_thermal_zone *d =3D zone->devdata; int i; =20 - if (d->override_ops && d->override_ops->get_trip_type) - return d->override_ops->get_trip_type(zone, trip, type); - if (trip < d->aux_trip_nr) *type =3D THERMAL_TRIP_PASSIVE; else if (trip =3D=3D d->crt_trip_id) @@ -112,9 +103,6 @@ static int int340x_thermal_set_trip_temp(struct thermal= _zone_device *zone, acpi_status status; char name[10]; =20 - if (d->override_ops && d->override_ops->set_trip_temp) - return d->override_ops->set_trip_temp(zone, trip, temp); - snprintf(name, sizeof(name), "PAT%d", trip); status =3D acpi_execute_simple_method(d->adev->handle, name, millicelsius_to_deci_kelvin(temp)); @@ -134,9 +122,6 @@ static int int340x_thermal_get_trip_hyst(struct thermal= _zone_device *zone, acpi_status status; unsigned long long hyst; =20 - if (d->override_ops && d->override_ops->get_trip_hyst) - return d->override_ops->get_trip_hyst(zone, trip, temp); - status =3D acpi_evaluate_integer(d->adev->handle, "GTSH", NULL, &hyst); if (ACPI_FAILURE(status)) *temp =3D 0; @@ -217,7 +202,7 @@ static struct thermal_zone_params int340x_thermal_param= s =3D { }; =20 struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *a= dev, - struct thermal_zone_device_ops *override_ops) + int (*get_temp) (struct thermal_zone_device *, int *)) { struct int34x_thermal_zone *int34x_thermal_zone; acpi_status status; @@ -231,8 +216,15 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(s= truct acpi_device *adev, return ERR_PTR(-ENOMEM); =20 int34x_thermal_zone->adev =3D adev; - int34x_thermal_zone->override_ops =3D override_ops; =20 + int34x_thermal_zone->ops =3D kmemdup(&int340x_thermal_zone_ops, + sizeof(int340x_thermal_zone_ops), GFP_KERNEL); + if (!int34x_thermal_zone->ops) + goto err_ops_alloc; + + if (get_temp) + int34x_thermal_zone->ops->get_temp =3D get_temp; +=09 status =3D acpi_evaluate_integer(adev->handle, "PATC", NULL, &trip_cnt); if (ACPI_FAILURE(status)) trip_cnt =3D 0; @@ -262,7 +254,7 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(st= ruct acpi_device *adev, acpi_device_bid(adev), trip_cnt, trip_mask, int34x_thermal_zone, - &int340x_thermal_zone_ops, + int34x_thermal_zone->ops, &int340x_thermal_params, 0, 0); if (IS_ERR(int34x_thermal_zone->zone)) { @@ -281,6 +273,8 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(st= ruct acpi_device *adev, acpi_lpat_free_conversion_table(int34x_thermal_zone->lpat_table); kfree(int34x_thermal_zone->aux_trips); err_trip_alloc: + kfree(int34x_thermal_zone->ops); +err_ops_alloc: kfree(int34x_thermal_zone); return ERR_PTR(ret); } @@ -292,6 +286,7 @@ void int340x_thermal_zone_remove(struct int34x_thermal_= zone thermal_zone_device_unregister(int34x_thermal_zone->zone); acpi_lpat_free_conversion_table(int34x_thermal_zone->lpat_table); kfree(int34x_thermal_zone->aux_trips); + kfree(int34x_thermal_zone->ops); kfree(int34x_thermal_zone); } EXPORT_SYMBOL_GPL(int340x_thermal_zone_remove); diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h b= /drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h index 3b4971df1b33..e28ab1ba5e06 100644 --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h @@ -29,13 +29,13 @@ struct int34x_thermal_zone { int hot_temp; int hot_trip_id; struct thermal_zone_device *zone; - struct thermal_zone_device_ops *override_ops; + struct thermal_zone_device_ops *ops; void *priv_data; struct acpi_lpat_conversion_table *lpat_table; }; =20 struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *, - struct thermal_zone_device_ops *override_ops); + int (*get_temp) (struct thermal_zone_device *, int *)); void int340x_thermal_zone_remove(struct int34x_thermal_zone *); int int340x_thermal_read_trips(struct int34x_thermal_zone *int34x_zone); =20 diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device= .c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c index a8d98f1bd6c6..317703027ce9 100644 --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c @@ -207,10 +207,6 @@ static int proc_thermal_get_zone_temp(struct thermal_z= one_device *zone, return ret; } =20 -static struct thermal_zone_device_ops proc_thermal_local_ops =3D { - .get_temp =3D proc_thermal_get_zone_temp, -}; - static int proc_thermal_read_ppcc(struct proc_thermal_device *proc_priv) { int i; @@ -285,7 +281,7 @@ int proc_thermal_add(struct device *dev, struct proc_th= ermal_device *proc_priv) struct acpi_device *adev; acpi_status status; unsigned long long tmp; - struct thermal_zone_device_ops *ops =3D NULL; + int (*get_temp) (struct thermal_zone_device *, int *) =3D NULL; int ret; =20 adev =3D ACPI_COMPANION(dev); @@ -304,10 +300,10 @@ int proc_thermal_add(struct device *dev, struct proc_= thermal_device *proc_priv) /* there is no _TMP method, add local method */ stored_tjmax =3D get_tjmax(); if (stored_tjmax > 0) - ops =3D &proc_thermal_local_ops; + get_temp =3D proc_thermal_get_zone_temp; } =20 - proc_priv->int340x_zone =3D int340x_thermal_zone_add(adev, ops); + proc_priv->int340x_zone =3D int340x_thermal_zone_add(adev, get_temp); if (IS_ERR(proc_priv->int340x_zone)) { return PTR_ERR(proc_priv->int340x_zone); } else --=20 2.34.1 From nobody Mon Apr 6 11:51:42 2026 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 64B05C07E9D for ; Mon, 26 Sep 2022 15:21:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236431AbiIZPVy (ORCPT ); Mon, 26 Sep 2022 11:21:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236240AbiIZPU3 (ORCPT ); Mon, 26 Sep 2022 11:20:29 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 594E083BC6 for ; Mon, 26 Sep 2022 07:07:06 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id n12so10390488wrx.9 for ; Mon, 26 Sep 2022 07:07:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=jLn+zEfCM4URHe7bMSEwNlD2QENA2eAivlgbUdbannc=; b=vy8LnAcjLNAJXlYC+r09WeuqmkA8ME0wkQKu4x4sPawq0JQfhl0zn6UWYCiPfBQAkW 1bCKK3cnwhlKnjsHfiQ8V34Fpb94cFTBeZjyeBHlW21VaFiYibwEavmbkuwDomEDIizm qBUXTuIhtW0P3Ded4ubdLH2ajONfv0SbaUpy5DPwHA8urpJ8eo7kkwMopMsjun0jCYdI 77DtSViTnDdu/Im3SadmA/9bUGUHZc8j5I/d0nfGVbGN4EJaiTeLqEBmmXfAb3Jm6YmQ xy5vCprMrPGXyNlrJDTlZe0cy1BphP6z5WGbPe/z1kYhBtI+TRxRzjhp6aF6/v9mdugi KsOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=jLn+zEfCM4URHe7bMSEwNlD2QENA2eAivlgbUdbannc=; b=0itHM2GIW+ZzG50KAMEo+0u0ZfZ/tu0PvyLjEHNjOvUO+NiZ20ltBCwgqAPhurs9m7 hHzYnArfz4zgEpfeHPq34tFcAYpevUUycg8AvJrH5wLIcB+E+aUTJjkiWPUxPsD4kz2H qRFro6G0N5DSeWAIUOmezJJP+zz2R//PgNFIQfKwZhcBue5uEKzXQOg98CesS/k9Wq4q 4b7+1SLz9sdaQF3csmqK0Gzr1hx8sHq05Y3V24cE0frf//d1/WBrpVj8QPkFvGIOFqRs U2kvbsyWeX1cxu4mSGmZPflKIvBrYvSkZ9vjSiHBj8s2MnfUf3OTCeUHuL3m8HRV8/op rcng== X-Gm-Message-State: ACrzQf2TO2tqA5RIJuREDlyVT+yTzp3hgzCZFrziYpqK0oNn3ImYBwby DgNT5NQo/AT52jZofMixY7dLMg== X-Google-Smtp-Source: AMsMyM4s5sa3BH++/KEIOI4jOeHvCqwZ06qzpF8BCexacl1uVT2OHoNbUvPwkoLE5XIDGAyogOpRUA== X-Received: by 2002:adf:cd10:0:b0:22c:a109:f51d with SMTP id w16-20020adfcd10000000b0022ca109f51dmr4463755wrm.238.1664201224762; Mon, 26 Sep 2022 07:07:04 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id v3-20020adfebc3000000b0022adf321d22sm14310731wrn.92.2022.09.26.07.07.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 07:07:04 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Srinivas Pandruvada , Amit Kucheria , Jiang Jian Subject: [PATCH v5 30/30] thermal/drivers/intel: Use generic thermal_zone_get_trip() function Date: Mon, 26 Sep 2022 16:06:04 +0200 Message-Id: <20220926140604.4173723-31-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220926140604.4173723-1-daniel.lezcano@linaro.org> References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano Reviewed-by: Srinivas Pandruvada --- drivers/thermal/intel/x86_pkg_temp_thermal.c | 120 ++++++++++--------- 1 file changed, 66 insertions(+), 54 deletions(-) diff --git a/drivers/thermal/intel/x86_pkg_temp_thermal.c b/drivers/thermal= /intel/x86_pkg_temp_thermal.c index a0e234fce71a..e7c3b78d959c 100644 --- a/drivers/thermal/intel/x86_pkg_temp_thermal.c +++ b/drivers/thermal/intel/x86_pkg_temp_thermal.c @@ -53,6 +53,7 @@ struct zone_device { u32 msr_pkg_therm_high; struct delayed_work work; struct thermal_zone_device *tzone; + struct thermal_trip *trips; struct cpumask cpumask; }; =20 @@ -138,40 +139,6 @@ static int sys_get_curr_temp(struct thermal_zone_devic= e *tzd, int *temp) return -EINVAL; } =20 -static int sys_get_trip_temp(struct thermal_zone_device *tzd, - int trip, int *temp) -{ - struct zone_device *zonedev =3D tzd->devdata; - unsigned long thres_reg_value; - u32 mask, shift, eax, edx; - int ret; - - if (trip >=3D MAX_NUMBER_OF_TRIPS) - return -EINVAL; - - if (trip) { - mask =3D THERM_MASK_THRESHOLD1; - shift =3D THERM_SHIFT_THRESHOLD1; - } else { - mask =3D THERM_MASK_THRESHOLD0; - shift =3D THERM_SHIFT_THRESHOLD0; - } - - ret =3D rdmsr_on_cpu(zonedev->cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT, - &eax, &edx); - if (ret < 0) - return ret; - - thres_reg_value =3D (eax & mask) >> shift; - if (thres_reg_value) - *temp =3D zonedev->tj_max - thres_reg_value * 1000; - else - *temp =3D THERMAL_TEMP_INVALID; - pr_debug("sys_get_trip_temp %d\n", *temp); - - return 0; -} - static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp) { @@ -212,18 +179,9 @@ sys_set_trip_temp(struct thermal_zone_device *tzd, int= trip, int temp) l, h); } =20 -static int sys_get_trip_type(struct thermal_zone_device *thermal, int trip, - enum thermal_trip_type *type) -{ - *type =3D THERMAL_TRIP_PASSIVE; - return 0; -} - /* Thermal zone callback registry */ static struct thermal_zone_device_ops tzone_ops =3D { .get_temp =3D sys_get_curr_temp, - .get_trip_temp =3D sys_get_trip_temp, - .get_trip_type =3D sys_get_trip_type, .set_trip_temp =3D sys_set_trip_temp, }; =20 @@ -328,6 +286,48 @@ static int pkg_thermal_notify(u64 msr_val) return 0; } =20 +static struct thermal_trip *pkg_temp_thermal_trips_init(int cpu, int tj_ma= x, int num_trips) +{ + struct thermal_trip *trips; + unsigned long thres_reg_value; + u32 mask, shift, eax, edx; + int ret, i; + + trips =3D kzalloc(sizeof(*trips) * num_trips, GFP_KERNEL); + if (!trips) + return ERR_PTR(-ENOMEM); +=09 + for (i =3D 0; i < num_trips; i++) { + + if (i) { + mask =3D THERM_MASK_THRESHOLD1; + shift =3D THERM_SHIFT_THRESHOLD1; + } else { + mask =3D THERM_MASK_THRESHOLD0; + shift =3D THERM_SHIFT_THRESHOLD0; + } + + ret =3D rdmsr_on_cpu(cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT, + &eax, &edx); + if (ret < 0) { + kfree(trips); + return ERR_PTR(ret); + } + + thres_reg_value =3D (eax & mask) >> shift; + + trips[i].temperature =3D thres_reg_value ? + tj_max - thres_reg_value * 1000 : THERMAL_TEMP_INVALID; + + trips[i].type =3D THERMAL_TRIP_PASSIVE; + =09 + pr_debug("%s: cpu=3D%d, trip=3D%d, temp=3D%d\n", + __func__, cpu, i, trips[i].temperature); + } + + return trips; +} + static int pkg_temp_thermal_device_add(unsigned int cpu) { int id =3D topology_logical_die_id(cpu); @@ -353,24 +353,27 @@ static int pkg_temp_thermal_device_add(unsigned int c= pu) if (!zonedev) return -ENOMEM; =20 + zonedev->trips =3D pkg_temp_thermal_trips_init(cpu, tj_max, thres_count); + if (IS_ERR(zonedev->trips)) { + err =3D PTR_ERR(zonedev->trips); + goto out_kfree_zonedev; + } +=09 INIT_DELAYED_WORK(&zonedev->work, pkg_temp_thermal_threshold_work_fn); zonedev->cpu =3D cpu; zonedev->tj_max =3D tj_max; - zonedev->tzone =3D thermal_zone_device_register("x86_pkg_temp", - thres_count, + zonedev->tzone =3D thermal_zone_device_register_with_trips("x86_pkg_temp", + zonedev->trips, thres_count, (thres_count =3D=3D MAX_NUMBER_OF_TRIPS) ? 0x03 : 0x01, zonedev, &tzone_ops, &pkg_temp_tz_params, 0, 0); if (IS_ERR(zonedev->tzone)) { err =3D PTR_ERR(zonedev->tzone); - kfree(zonedev); - return err; + goto out_kfree_trips; } err =3D thermal_zone_device_enable(zonedev->tzone); - if (err) { - thermal_zone_device_unregister(zonedev->tzone); - kfree(zonedev); - return err; - } + if (err) + goto out_unregister_tz; + /* Store MSR value for package thermal interrupt, to restore at exit */ rdmsr(MSR_IA32_PACKAGE_THERM_INTERRUPT, zonedev->msr_pkg_therm_low, zonedev->msr_pkg_therm_high); @@ -379,7 +382,14 @@ static int pkg_temp_thermal_device_add(unsigned int cp= u) raw_spin_lock_irq(&pkg_temp_lock); zones[id] =3D zonedev; raw_spin_unlock_irq(&pkg_temp_lock); - return 0; + +out_unregister_tz:=09 + thermal_zone_device_unregister(zonedev->tzone); +out_kfree_trips: + kfree(zonedev->trips); +out_kfree_zonedev: + kfree(zonedev); + return err; } =20 static int pkg_thermal_cpu_offline(unsigned int cpu) @@ -463,8 +473,10 @@ static int pkg_thermal_cpu_offline(unsigned int cpu) raw_spin_unlock_irq(&pkg_temp_lock); =20 /* Final cleanup if this is the last cpu */ - if (lastcpu) + if (lastcpu) { + kfree(zonedev->trips); kfree(zonedev); + } return 0; } =20 --=20 2.34.1