From nobody Thu Apr 2 19:54:44 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 13B16ECAAD8 for ; Wed, 21 Sep 2022 09:44:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231768AbiIUJoC (ORCPT ); Wed, 21 Sep 2022 05:44:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231451AbiIUJn1 (ORCPT ); Wed, 21 Sep 2022 05:43:27 -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 25E4492F42 for ; Wed, 21 Sep 2022 02:43:23 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id t4so92362wmj.5 for ; Wed, 21 Sep 2022 02:43: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=3d392gfN5HL23OdaD2iWzbEdDL5X4YtbWtg9iygu8fY=; b=j9uDAw83iG/kgxZ4Z9blexoHPNnDEzvFRTpW8E0fW37/aZoIXSmx+qYeAvhFyFfUwJ A9wetJ9gIlbPtthr52neE7IWu+u4AUrrT1UzBv19uZGhWiTbTkMciKkrsvMO4MrnS/Ti GepdxY8SgUFz+ySXOksaIB7LoroIK1TZxNF0F6nDF1i3bEvt65BzB9EtKE8W8NfZHBEd CRx7AfN79HEkdumAjeny2W3WEc6+lglkh0uc6yZXUsGQbJ18qtA5uiQwc5/XwxDV+5o6 TJ/tT2S+L/mplSH9UqgVhNKcDy8tMZxRQgQDGhqBvdkakpvtl8tGbHJJigCtkNxmkpQF nz1g== 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=3d392gfN5HL23OdaD2iWzbEdDL5X4YtbWtg9iygu8fY=; b=BaHTtpv5V4Uy9uJARIm0034qtMbsi0l59o/cBFQ5cHDz3GD0SHg432oL2M3GEP+F+m HnFrR7hXBdNAiQN7Q6ZnLRZZeA0ys3Wl+nPhGshD1kjnTARh2ylgV3MUZ2gxThROGRYw cQqqbbd7aD0wiFA3jYGSaPYs5PvABWh059H8xHEkXOL7V+KM9dGlXYTjulQfg8XlgbFq vycNxr09K9/Sg1SP2MVBu00OVkvxA9b1rq9mzY9FlRTQKnmYB/+tnLsc00weC7MwkMxf Uh98T5vYhTMFSqdFS2wgo9Jot3YBHGmxSEPjqK2QqIW+5u7jMkKpVjQ9jQzZ/I2BBOnQ xAJw== X-Gm-Message-State: ACrzQf3GYe2mzMUrKMmihggJbOGnpnOdlJYY7/1q5tfxOkSKwmrwCpR7 Tzh7uBLfYvrJcLc/O8xT9+aLpQ== X-Google-Smtp-Source: AMsMyM5OHMH+3WYmOYwx3ic70WUV4j/yo2sjfFFzsqbmpsKtLI5VAj1uex16tEufv51kgReYvaPePg== X-Received: by 2002:a05:600c:4856:b0:3b4:9aa3:cb57 with SMTP id j22-20020a05600c485600b003b49aa3cb57mr5403346wmo.116.1663753401147; Wed, 21 Sep 2022 02:43:21 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43: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 v4 01/30] thermal/core: Add a generic thermal_zone_get_trip() function Date: Wed, 21 Sep 2022 11:42:14 +0200 Message-Id: <20220921094244.606948-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 | 87 +++++++++++++++++++++++-------- drivers/thermal/thermal_helpers.c | 28 +++++----- drivers/thermal/thermal_netlink.c | 21 ++++---- drivers/thermal/thermal_sysfs.c | 66 +++++++++-------------- include/linux/thermal.h | 5 ++ 5 files changed, 118 insertions(+), 89 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 99c0c19fa5a6..381d85ec74a0 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,52 @@ 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); + +static int __thermal_zone_get_trip(struct thermal_zone_device *tz, int tri= p_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 +1216,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 +1242,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 +1292,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_helpers.c b/drivers/thermal/thermal_he= lpers.c index c65cdce8f856..e1264940136a 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..ce56d441c88c 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 Thu Apr 2 19:54:44 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 D180EC32771 for ; Wed, 21 Sep 2022 09:44:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231836AbiIUJoR (ORCPT ); Wed, 21 Sep 2022 05:44:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231686AbiIUJng (ORCPT ); Wed, 21 Sep 2022 05:43:36 -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 593D292F4E for ; Wed, 21 Sep 2022 02:43:24 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id e10-20020a05600c4e4a00b003b4eff4ab2cso3022196wmq.4 for ; Wed, 21 Sep 2022 02:43: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=re6cY3b7LhtgjVns3TGnT3S1+gVlK6XqwvcFa/mv1ME=; b=if94fkKyVeDmS4rsrjEKY0jLhqt8RAB7MHcZOSlPXfssiLW4b5XZrr9HRLjGDDWD45 BMWFLw896t3N1Oh3z8DCSSB4v0d5la8UBsobrHmrYRe4cu42eRZ4u1dCBGsIgEcPnmsZ FAPIOL6ouVt/eM5fh8XrH549WCt0NZy12+5EuvrlSEUq6qc7oVxZ8iEjNjgDL3CszSxr LH8AGT06vUxrI8XKP8+wCKYYCgqhr3KbEWd/8Y0cR/ee7ZuSq1oZdLMmWvJ2xrfnCpQC Tf0ROVrGxMsXfIShi6TXTcVahIY12JKP0rTDiSLvfCmaRCw0OTHTPuTL0zlBCLzRGWKt 12VA== 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=jkzpJzOxcS4fkfmVFAXYktpu/eJ1R5Oxb34D6BOfR7Wa5BkBzFeayh6QKRwS3ccp+0 Rb6GEAdsECEAPWBOd2j8hHPXCg/YnRkcpSGZur3mgyAPBF1ZARTBbfRYtRrNohUxl3Hn 1QWUdg0qwMfuinoEBjNnNArcFE5I/hWULA2OlkQ7H0+83W8N6nMrOUUHVPIQ58QVWHnM K+TKvQS4Esz65eDPcEq4CacbE4eMUzAGOrJyr380P4+tSX7Rn9BfR/jt+UCQfaQhcIi2 JmAFvG9gR7yXy92W0b8DlzLldyWON/wvM4pxin2gJAuOVEQbQiVnmJ4cl7BHArq+afNs whWw== X-Gm-Message-State: ACrzQf028+Bp1zrosAqdzU7bPCGYmHeRhKgdh5zbbpC1By8FRWO5w2bI u81OTEuULTIKuA504N2XgN424Q== X-Google-Smtp-Source: AMsMyM6GcTTKoFbTWYmunOFf6EX3vj9zN0d69lNq97Xxg6r6qieqUYC8uSJFrhiMWk7bvhoaTbN18w== X-Received: by 2002:a05:600c:3843:b0:3b4:f86b:e0a4 with SMTP id s3-20020a05600c384300b003b4f86be0a4mr1778407wmr.195.1663753402476; Wed, 21 Sep 2022 02:43:22 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43: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, Amit Kucheria Subject: [PATCH v4 02/30] thermal/sysfs: Do not make get_trip_hyst optional Date: Wed, 21 Sep 2022 11:42:15 +0200 Message-Id: <20220921094244.606948-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 48E42ECAAD8 for ; Wed, 21 Sep 2022 09:44:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229596AbiIUJoN (ORCPT ); Wed, 21 Sep 2022 05:44:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231699AbiIUJnh (ORCPT ); Wed, 21 Sep 2022 05:43:37 -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 7687C92F5A for ; Wed, 21 Sep 2022 02:43:25 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id k3-20020a05600c1c8300b003b4fa1a85f8so848729wms.3 for ; Wed, 21 Sep 2022 02:43: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=Ot6aPvSiYXAp0Hkm+zPI98RcgU3lQfSUO9dLDinpKfk=; b=mUjk1QIbqi1+YwFxY5dIDY0nUXFOL7uYUbwkbIp+k0yGF2zAF59PtOrP7X1foeB89z Ajd7TYHPvsZZVUdjRhQgHVIM52KyZjIie8OyciYQjbNCfKoAmBZ3gyWw6YBhB13pWpHd rJFjxh2vSogqkUhHLuoDCnv5o6h5HDxfKDk6TBuV+KiZwcXQIqJEz2YeRRQ0zh6waJO9 clSuu3ktKXjcvJECF5AfprN7bux1dFwDLvAeQLeDFv+FMM5bti21zfMGhSEDvttVRqYo GbFk6emamloDqBXnI1MkNcoKw3RhQmII6zjlWNdnKo28x6YsAhWZKMEZ7lX1x/rxLJf3 Yxcw== 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=Ot6aPvSiYXAp0Hkm+zPI98RcgU3lQfSUO9dLDinpKfk=; b=Z7Y8DQLW55DcICknN9IrCo1IolGC4EdzzNQ7LijhdIHSS0OetFM57ETDGzb76IRIFl w+Vg3PzIrFj1uRMIWv5hq8UrZaxTRo89aJ6imcrPdSjHcjkp63BjJpZHah/en0W2SFDv jFnjtmy33GDKXYCJC/H3dgxs5+z0J4Z1WAceQGz9zx7KqEV1LDOBDNolT3xF2OMjal7k C8BcEErHI5m5C8iSyEAyTmyCgos452ICNU96vHZ9Ff63YXobUm88C1cTOKV6dYSxQSnQ Ycg8acnq+/ETg7F33PcAFlEI7fKW0s/k3UMcwzsjWQ8IhYOfdLP+/dASsa+BirCiFMMl MfsA== X-Gm-Message-State: ACrzQf3GjM1HTwlJ67dWMmy5l/+f/8Wi6bQmzKufxua+hm/eXSQzw0+4 5b0KFZ4GcFkHo2s2njf9lTqQKg== X-Google-Smtp-Source: AMsMyM5rvlBo1e6PdbmztUWGzkZEaiKzw1bqYCOZpNp2cyY9HgFtzhz7sgdCvt1qsorxjm7+sivpRQ== X-Received: by 2002:a05:600c:2c47:b0:3b4:fcdf:d783 with SMTP id r7-20020a05600c2c4700b003b4fcdfd783mr424060wmg.157.1663753403670; Wed, 21 Sep 2022 02:43:23 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43: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 v4 03/30] thermal/core: Add a generic thermal_zone_set_trip() function Date: Wed, 21 Sep 2022 11:42:16 +0200 Message-Id: <20220921094244.606948-4-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Reviewed-by: Zhang Rui --- drivers/thermal/thermal_core.c | 44 ++++++++++++++++++++++++++++++ drivers/thermal/thermal_sysfs.c | 48 +++++++++++---------------------- include/linux/thermal.h | 3 +++ 3 files changed, 63 insertions(+), 32 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 381d85ec74a0..fa0f89a24b68 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1183,6 +1183,50 @@ 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; +} =20 /** * thermal_zone_device_register_with_trips() - register a new thermal zone= device 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 Thu Apr 2 19:54:44 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 E73B2C6FA8E for ; Wed, 21 Sep 2022 09:43:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229751AbiIUJn4 (ORCPT ); Wed, 21 Sep 2022 05:43:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231718AbiIUJnj (ORCPT ); Wed, 21 Sep 2022 05:43:39 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 340AE92F65 for ; Wed, 21 Sep 2022 02:43:27 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id e18so4009597wmq.3 for ; Wed, 21 Sep 2022 02:43: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=yxHcU1hX4elGm4XFMd+giLQwBSqd0y+6MVuYVIhVRhA=; b=AGE6SlQC5fST7A8hLnGpiw3pw13JnBLmPaet5nBFAAp77pCQG76vl5OFYX64iXA2Mu v0z1XM3WybDKlhnrc9QDIpDytfEd9ef4wKMA3ODtSxjp3ZbmZkvZ52TfxHeEIolylul6 gzukVQXOR7KgaP8PtSeQQMMiFccqAZsTKEPfNyTqvAbzhJMfv2PO7aT+6upg2XQ3M+uN cMQ1EYtGQ/B/mpAC7Q9Z/QpR8vhWEevKMysnFjdqRzH17bRS7NZ4Pn82s3ROcAvKt3Fl qC6psXuz70Jtb6h88NxvL45ufzrPThRDHtjkaTaR0Q9Z2Djzgq/gJCpZYbPO8qN5Xeeh 6l5w== 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=yxHcU1hX4elGm4XFMd+giLQwBSqd0y+6MVuYVIhVRhA=; b=2ZDThOhanLYlQkLKdpwKvlIdHiMyRRBJAM6GDDJk/GlmSGkxyd0jP6Y1IrVsnOeoFp 0q2Y8pJcheZPvQlEAfTQjd2uKE6vix17V1/vKj9y9m4XxVpcxAoRKBSSdI2iA27m95qm D9iaFX20+r3mhhpbpKqNcjaGc+5EYA2QymogZZNA/igQbW8hpwOxCHUGybcPm+kiwlyt FPzkyATx4UBzXCH04yxFkV0y+vDnwkoupmfKtL9xzfnrJAG7PJ+1hSh2aQqB9FEpqsHp CHiP21nn8RPq/eOTFUqCs9SQHaQ6rc2+kV3M3dyxp9xlq8oPlMwagJfuclELIqCaYzV/ jLRg== X-Gm-Message-State: ACrzQf0R1bbrVn0adQ0CPFCmquNLlZAViN5+Tr4v+0GLrnRU9u7/ZNBH EPtuiS9Da/kyXELdevsJHls93A== X-Google-Smtp-Source: AMsMyM697CfXTEn1H2PKV8IVJAJaEW+EcQzErjxWZg1L2SnxXcL6qAFfz9aDQQvfCfivZBpnSV5KTg== X-Received: by 2002:a05:600c:a47:b0:3a6:5848:4bde with SMTP id c7-20020a05600c0a4700b003a658484bdemr5140977wmq.189.1663753405269; Wed, 21 Sep 2022 02:43:25 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43:24 -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 v4 04/30] thermal/core: Add a generic thermal_zone_get_crit_temp() function Date: Wed, 21 Sep 2022 11:42:17 +0200 Message-Id: <20220921094244.606948-5-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 --- drivers/thermal/thermal_core.c | 27 +++++++++++++++++++++++++++ include/linux/thermal.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index fa0f89a24b68..2495c174a226 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1144,6 +1144,33 @@ int thermal_zone_get_num_trips(struct thermal_zone_d= evice *tz) } EXPORT_SYMBOL_GPL(thermal_zone_get_num_trips); =20 +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); + static int __thermal_zone_get_trip(struct thermal_zone_device *tz, int tri= p_id, struct thermal_trip *trip) { 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 Thu Apr 2 19:54:44 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 AD538ECAAD8 for ; Wed, 21 Sep 2022 09:44:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231815AbiIUJo1 (ORCPT ); Wed, 21 Sep 2022 05:44:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231719AbiIUJnj (ORCPT ); Wed, 21 Sep 2022 05:43:39 -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 3415792F66 for ; Wed, 21 Sep 2022 02:43:27 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id z6so8961796wrq.1 for ; Wed, 21 Sep 2022 02:43: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=7quZAPuMcAvt+QXLI2xXiL2djdLPPOTNpr/QroOkKRY=; b=sByVIPNDLmDYSFTGYcTERiiNfEOuoQBslOrtQDNC00W2kxzxcRnc6MpaAgAQIXSOVZ 9BSuOjTHh4wSPezXiKS2cSPXVmi0pBTXKd3UKdVufS7dKcX3aPHpdZIdVu+Eycz5UeK1 4BH8wGjDawRKACIEe2xAJm0B3y4NBifmBQsb8CX/aCEv/oC5fndK88GKjWAJr1wP3yfo jtziyV3tXRDrSBgLKbouGMRI+ITgYUeDR7ZKYGxDGDvufPYf+jMrbDBCl5oQvF0az/E/ IUqEh8cjclwOaG04ZAkBCDr3Ly+x4PfvrC+6LLRokHIAR4DBaVAd5ZZMTRtrsHdaDq8m p8qw== 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=7quZAPuMcAvt+QXLI2xXiL2djdLPPOTNpr/QroOkKRY=; b=PjjCkUCfAMgk0WDXhwfWaSprk6EFNym78aM2XgQIPpnpiizlO9mIjWVFRr+dtOpJKF 9q4YBhDgxGSccRXhs54gWlkdAi7D+fqKa+u2xNotiSPjBXbJhcAMq9pvMv7lD34z7spq Lc4ejmUW57pLg82jcEUZfMJA9HzHncPKDgiBcd1W+REbNjNMg9+nkylYqmW8DwhahF2D PyKFo00XBxVDY+aSFOKPn882OfbFdjWhyFdtaEyyPPWWX8a16Tc3B3YfzEi8I2pNmp+s 0mQgjq/zOIBZQiP86zTdPa1/R0bz3fS6NYb9V/nkjoXP6vsqwW1UOnGb3LtgjmJRfV0p lekA== X-Gm-Message-State: ACrzQf0VkP6XsQMJf3UpbXmIzpdsg6EyPdL1ldyve1GTJJRLgpXiStyh en32Ta8MqtJdBGCnzkEJlTdhtA== X-Google-Smtp-Source: AMsMyM4GaTpuAZvarnVQi/zmxslSM+uiX4cFvH3cZ7LGjti0lmceFW62GVIVNv+IyWvariq/nH03/g== X-Received: by 2002:a05:6000:1d9d:b0:22a:745b:9f00 with SMTP id bk29-20020a0560001d9d00b0022a745b9f00mr16509094wrb.280.1663753406662; Wed, 21 Sep 2022 02:43:26 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43: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, Amit Kucheria , Lukasz Luba Subject: [PATCH v4 05/30] thermal/core/governors: Use thermal_zone_get_trip() instead of ops functions Date: Wed, 21 Sep 2022 11:42:18 +0200 Message-Id: <20220921094244.606948-6-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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: Lukasz Luba Reviewed-by: Zhang Rui --- drivers/thermal/gov_bang_bang.c | 23 +++++------- drivers/thermal/gov_fair_share.c | 18 ++++------ drivers/thermal/gov_power_allocator.c | 51 ++++++++++++--------------- drivers/thermal/gov_step_wise.c | 22 ++++++------ 4 files changed, 47 insertions(+), 67 deletions(-) diff --git a/drivers/thermal/gov_bang_bang.c b/drivers/thermal/gov_bang_ban= g.c index a08bbe33be96..09234f3d2fb9 100644 --- a/drivers/thermal/gov_bang_bang.c +++ b/drivers/thermal/gov_bang_bang.c @@ -13,26 +13,19 @@ =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; =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); + thermal_zone_get_trip(tz, trip_id, &trip); =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 +43,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..c515e7a52294 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..2ef86ced4c7c 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..3cb16d7e65d1 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 Thu Apr 2 19:54:44 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 35904ECAAD8 for ; Wed, 21 Sep 2022 09:46:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231922AbiIUJq3 (ORCPT ); Wed, 21 Sep 2022 05:46:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231721AbiIUJnj (ORCPT ); Wed, 21 Sep 2022 05:43:39 -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 D0E9592F6C for ; Wed, 21 Sep 2022 02:43:28 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id t7so8855143wrm.10 for ; Wed, 21 Sep 2022 02:43:28 -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=Zsrvb3mh+DU+uq04wshQdZ/fl6vUAZ6Rn+tYDUa9JYYGCFrCHQ94KJXrfUMzknkMoo 1smMNmbkcAm3Ynlzpj6C7E2InZ749X67xqnIMG66QCrPVgEKUGPWyN2koqGQkSM/nHVz /g5BsZdUV6yl9tQfoKTDpLMeTtkS+uoDJBVOK/c0285ZckytjP3ytTHrg+YzqA4tfQuB LaGjRGHS+/tBB+rIybB8J1kt4+ru3Z4f/cSAeAa3SpKLInIiW5JEMscKVKA+WLBk5uMO sR9oPOevvrF6E5dhJYkO+u0L30vYSPv7qkjcW6DGo/FQpeTk2xSvEknXD8qfv2PIl12j Xfww== 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=aBwqEBiNMxl/d7dNYtmahf3j7hKgMkW41Vn+6ezX4EFdCFnkj/OzZD7MTGn1762JGb 52b4qquIFkF5fn25+GjyaAf63xs3dMOudmo3HjWXc7DS3E+wDFHExwKbH88ADRubRODo KN6qqIHYSnwGlF0XN2K51nGCMpJVQMJ/VrjDi2FqWZNNcEvZIrVVnmS+yK4Dsdc0JVOd ejXsOPMZ56VC4gB8jbsYYUBBhjaVGVB1LpfB+JWNaNQHBvO1mDQR5h/uwRNtjECGnT6q tFKaZSSi1oZz+Eyjz3f5ST7SU02K5TpykcXIhoA4K87v4O5+KOXs0oi/rsZiB+JQJ/cL Hq/Q== X-Gm-Message-State: ACrzQf22DhBZP9xyzBpiZHrXhQ4M+Cy4aabQ8/Zwk0mHMcc9NEdmVZzZ 4TisRomzuiZaTyC5L6StDHZYBw== X-Google-Smtp-Source: AMsMyM7oleeE3uJP8SvXFvgO75gAdkEdMSFbe03N6TMcjxB2OAojRmiDVm7qragD1ndSLXM67oreug== X-Received: by 2002:a05:6000:38e:b0:22a:e302:28e6 with SMTP id u14-20020a056000038e00b0022ae30228e6mr15168907wrf.595.1663753407844; Wed, 21 Sep 2022 02:43:27 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43:27 -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 v4 06/30] thermal/of: Use generic thermal_zone_get_trip() function Date: Wed, 21 Sep 2022 11:42:19 +0200 Message-Id: <20220921094244.606948-7-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 29003ECAAD8 for ; Wed, 21 Sep 2022 09:44:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229667AbiIUJoI (ORCPT ); Wed, 21 Sep 2022 05:44:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231756AbiIUJnn (ORCPT ); Wed, 21 Sep 2022 05:43:43 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8E8192F7A for ; Wed, 21 Sep 2022 02:43:30 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id x18so2886828wrm.7 for ; Wed, 21 Sep 2022 02:43:30 -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=Brk79K68Pth5JpZf/n4X97+hyNwde3ZvZaEoGdSbClA=; b=dmnUeKZ9VmxqZ4xOtAH5mntnS4VbRL2DzZYxE5575fTKF6+nYj2L7QRBc1ftzZgdC0 m3FMZ+nUww3dJIRmpri2+CGbUSCDjp0bYvR+isl+Z0/87QTRbJFjkWmBKWoEA1AU0bcc 8zqVahCPpTuOr31/OFo6+9xfmMb15G59QTPBY3LUpLvGStcZSWqGNv0MvjZT1Q01FDGd GRqRfOafPKf+7mCJklkGLoOXC7H3GCARMML+qyJiFwBoKnmKw06ldCN4rYshPY8YoSzu NeDlLn5ykBAOd9AdqMvs+uCqPztsmxrJpqFCewUDmPyJ5VoFCDEdOJwyoGAwlF+8IxAy iXlw== 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=Brk79K68Pth5JpZf/n4X97+hyNwde3ZvZaEoGdSbClA=; b=OE94aC4wmtFdAp+Uuc7W4dGm/ftxZtQ4p1p8xjBmT8lMm0tyhbCYruPE7zVWPL+4hd zUC+aSCxZhBHu0Zks1rDiBGDIzt4CMg9MhAfE/udyz17BorR3FxHog/+X7AanlEZfdWB PJ1nHcHB/qsb7Y5OG/gJ155qni2DV9H0B1kLm7CKPReORA4NISxHQYJljN1zXkv3WTEC oDUdBg3wgHY/t96m9jr9EaRYjZYGV3447Rc3Gu1y4pyFzEEMpx7mVKK/NNtr9yDxJ933 EWgZiX+8Z4FLHp7vIJMzbkEwQMW61+Z4Ok++qKTSe0JF/ONkeBDUsBmY3+fZUWnVuA/z 2niA== X-Gm-Message-State: ACrzQf3vco/i5ILDFCIHPNnXedJm0RTo/m6IGKyhKot+ctRBj5jBVBIX 2+vL7qVGaoHIA3sABdoABuZo+A== X-Google-Smtp-Source: AMsMyM6tASOb4dFSvzUlr8tlPtjXpzMLi9X4S6s5u6l08yr+UBi33sCrMuAVFW5fHLVRMmYgSnpYug== X-Received: by 2002:adf:ed81:0:b0:226:a509:14b6 with SMTP id c1-20020adfed81000000b00226a50914b6mr16511433wro.150.1663753409132; Wed, 21 Sep 2022 02:43:29 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43: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, Amit Kucheria Subject: [PATCH v4 07/30] thermal/of: Remove unused functions Date: Wed, 21 Sep 2022 11:42:20 +0200 Message-Id: <20220921094244.606948-8-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 1571917bd3c8..99a5d5281037 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -139,8 +139,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) { @@ -151,11 +149,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 Thu Apr 2 19:54:44 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 87044C6FA8E for ; Wed, 21 Sep 2022 09:44:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231854AbiIUJod (ORCPT ); Wed, 21 Sep 2022 05:44:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231750AbiIUJnm (ORCPT ); Wed, 21 Sep 2022 05:43:42 -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 B3B6993200 for ; Wed, 21 Sep 2022 02:43:31 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id r133-20020a1c448b000000b003b494ffc00bso8140472wma.0 for ; Wed, 21 Sep 2022 02:43: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=aNmMz3cRMj5kxPfKCvTpL8Ywx++ZqyPMyM5lgZsCem0=; b=opBVigkRy1OeHJrzgVEv50Om8MwOvmKtdXtGwDmTqDiVeKIVBTX9lyRdNNyru+jQpf pvHxkjNQDbdCSku4L0BzhyYs8MC3x533ztjIKkKKHK9xqBnfIAroNYuUGZHcPR4SKq7B FLgZnDwCHlwDxSirS6wY+jzARCYEFuYEnEUOcO1Qw1mr6riViPYm6NRi2t+rqGo3RZhg LxF87n6cjFqA4Q7MJdW8b+Boouz8tDTWD6P1Eg+IRMHihWo6wX2Dd+Re1QwFQZ/KDEXU +6GCsa7FaQ3YqbYcke8pcLCZ7Pz9y2kwrLYW62BRHvz5VG6q1gZO8ovwfSzTWKvxTQOs kKvw== 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=3+T3emqNHzKlMZSdE+jf1SSf7Tt4j28CykKZwi70CDR7Q22MH2gNKTe2mSfkXqpW7p FGddt+MdrTJqz+0fU59fCMew7TG8Un+wGa+6w20nha/vjHASoW20atulh640hv+0IRih 6PRUiXsg8riqxVhkYXzZCSiBDEHwzR2PX9FFW+PTEulURZFVJ2JOmE0jELtKhyGbxbde 9/GWGdgPJ+qUUAvIWHA7Xmz6jEfg0h4LxNHdvaqW3zkuOk5RW138RzT6GLe9cKxe0iyo Wpg6vZIjpB3WO8g0yRg7P9gdyYnjqxUbK2j+2mtnycTzNtqiT4q1NUzZNvvubJ7q8nIh Ah3g== X-Gm-Message-State: ACrzQf24wXiViufaXOkNDEgTsIJuPa7c4pCT2Itftg+tLd2QlGsJCyOD w8mVZahNgGxtOSM0UzCXJZ36Gw== X-Google-Smtp-Source: AMsMyM591OTlLMxQsmmUWR66w2WKMc3P6675xLoxproqZsL80SdIV9dgnd2ab52ATVMOcbZgomjCmA== X-Received: by 2002:a05:600c:4c22:b0:3b4:766a:4f76 with SMTP id d34-20020a05600c4c2200b003b4766a4f76mr4978885wmp.101.1663753411232; Wed, 21 Sep 2022 02:43:31 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43:30 -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 v4 08/30] thermal/drivers/exynos: Use generic thermal_zone_get_trip() function Date: Wed, 21 Sep 2022 11:42:21 +0200 Message-Id: <20220921094244.606948-9-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 DE778C32771 for ; Wed, 21 Sep 2022 09:44:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231861AbiIUJol (ORCPT ); Wed, 21 Sep 2022 05:44:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231765AbiIUJno (ORCPT ); Wed, 21 Sep 2022 05:43:44 -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 C3A4F93208 for ; Wed, 21 Sep 2022 02:43:34 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id fn7-20020a05600c688700b003b4fb113b86so525495wmb.0 for ; Wed, 21 Sep 2022 02:43:34 -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=e20xgygl/W7Al3uqyaecsrMJ91Ab42V4qJSgOrn8Idc7eHJxQinjwe/x6WKSe5oxV4 pvQ6g9h7YLr6xf0iV4G7qRI8F7W/FYWX0wtin2MBV0aW2sJkDBx41zBUhLvG82cGlbH9 n+6BPSzl9EGrkCparVCrg3XLABbSd/hWhMriZ+9U3Phdqsb6Tttf40xPTB/4Y+dDjWRC i4U24vVm6HvhdEy0/iPcIkcb/TKUBMaKJmGF0vSOZrJoqMxFeukfepi8eI/fEKrATb2X qlGWwz9EoZoyDchOaAyu+nc1nQZX425oCa9X1Ybo5mSEGQPk+nRxsTpyNtvtgy5CFhRC zXKA== 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=cdpGJvlCyrQJYR2HDbZ4Tc1/0GtLgHna6KrxaoNgHknLDyCm/yPcXziQ8qv0MvihTO wCyYc7xydAchaBYzgtMhYrcrIu3Jpgt/aM5kOWvCrZB9E/WzOjuPJJUirnoLDrn2PK9b +ftzn8V6FBMmgGSCn2RG1n3kaGgIUQTTtqimjoKQSgwghyzKWjEdcLPXAOoHj5Zb2Uej VbCqRPtlLMdd5XIJ05InGEMZYZdcS8hr5+gDIabKod7+eSsbyG9b1AYmZLVDeYIfB2fU brDHPxzzsBIfPMyNHi3nzhlGQeUlZupQI+fco2ld0WbewKy13tXbKJOCs2EDtWzlDBZT aP8g== X-Gm-Message-State: ACrzQf1EPf64Q6AEjm+VBK/Bh1ZTcjw+eHW7XVVSawN4DlUBwl1Adq36 fz92maOZMYqdAkwgvCS7kS+pvQ== X-Google-Smtp-Source: AMsMyM6rT0cWg1zSdFG4vgNDcbVpnOwWP7a0hP4q6ulsTk1oJ6pe/IvaWqH8AZ6UYJ5Pa6rhxNdigg== X-Received: by 2002:a7b:c404:0:b0:3b4:faca:cf50 with SMTP id k4-20020a7bc404000000b003b4facacf50mr1123082wmi.67.1663753413047; Wed, 21 Sep 2022 02:43:33 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43: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, 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 v4 09/30] thermal/drivers/exynos: of_thermal_get_ntrips() Date: Wed, 21 Sep 2022 11:42:22 +0200 Message-Id: <20220921094244.606948-10-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 7D4E3ECAAD8 for ; Wed, 21 Sep 2022 09:44:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229900AbiIUJor (ORCPT ); Wed, 21 Sep 2022 05:44:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231771AbiIUJno (ORCPT ); Wed, 21 Sep 2022 05:43:44 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24D0D9320E for ; Wed, 21 Sep 2022 02:43:36 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id fn7-20020a05600c688700b003b4fb113b86so525527wmb.0 for ; Wed, 21 Sep 2022 02:43:36 -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=STS/hkaX5fTFQngJMGA3ECsx0YNz/DGYRFInjs+Pvwg4Ke/RBoKCJf2tDQlQj66ZPt LtFaOLblPP5sDEAwlxxwRcjgYSotQwt6s1+hIFkB9F3CymD0S9DPgqt9DMSgAAIYIUIc /ihaJ90YfFmBZLy1nvUECuoY+VfNvQXGC/MpcGMPiXMkzg/K5vg1uRgWeq2E4LtEUEKL R9xWj7G+0RpgE1NvR4OHOriTA3Mu7dkZQeJDvfeelamAkf/VCVjgoiIqCokMdwRFCv3w qEN37vFopu5zsv+OKKa1nNuZryLAqkyI32+rHwU6nyO7r3i9/g8LD7ssEfqaetxvi7Se KkDw== 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=mch7mqtr6WvnLkcO9R1AfxTQsHiYDXsqhBOQ8mS9dImgCt9zazO4EjoVNGxC0Jpu9r jGEG0PUP/I8oFFw9hTfcsXW1YsU0mSGsLOBfa5wZJKnTrVyP0F9KdDM09+JB5wJGt420 o5vyo4rBGDdpsUIlaDwcSLb+c3qDs1zwH5xEQupVJqzQd2IGx4usRIBFMN77ck5qyTYS Ojb5AjBVogSzOxPhr29dc2NvFVl+8VJWISVHGsSx1WMAQei/BPz8PjtGf4oJpW772t57 UOj5hV8oL2zvuwE1DsdaLWJ+VhdBoqJBvAKTBQCFYfLvd7xqtlEVHYNmbZdF6taJjyL6 tvZw== X-Gm-Message-State: ACrzQf3lSuoYQwrz1OyyRQSFpgevcG2Qp+z+xsU2cHR41Mtf8HBu9W5A xndidST5zYzXXAmb3l/fa4mESA== X-Google-Smtp-Source: AMsMyM4/4rjQZEXF1J3b3NG9zZlSdlTtoeb2ny8YHaNelDL6+kKKZEIcL1QAm6vOKKrxdRDfZPVqyw== X-Received: by 2002:a05:600c:2050:b0:3b4:a51a:a1f5 with SMTP id p16-20020a05600c205000b003b4a51aa1f5mr5044066wmg.177.1663753414618; Wed, 21 Sep 2022 02:43:34 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43: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, 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 v4 10/30] thermal/drivers/exynos: Replace of_thermal_is_trip_valid() by thermal_zone_get_trip() Date: Wed, 21 Sep 2022 11:42:23 +0200 Message-Id: <20220921094244.606948-11-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Reviewed-by: Krzysztof Kozlowski --- 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 Thu Apr 2 19:54:44 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 D60BBC6FA90 for ; Wed, 21 Sep 2022 09:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230129AbiIUJpB (ORCPT ); Wed, 21 Sep 2022 05:45:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231789AbiIUJnp (ORCPT ); Wed, 21 Sep 2022 05:43:45 -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 CB09693218 for ; Wed, 21 Sep 2022 02:43:38 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id i203-20020a1c3bd4000000b003b3df9a5ecbso8675594wma.1 for ; Wed, 21 Sep 2022 02:43: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=XsxTgl9OJhYT/B2dXFDz/rl/9WpF5J4y9HKMzylFxc4=; b=u0mxhacmQxIDsYhufw+34LhjN3eUn9K5O8FWLsoTNemZF6+Z3ucjvD9AFKCCum+ckP K9CW2cb3J5znddARofJL4JR4d3rRHqF2ds+9g2GCiPmKfWH6Ge/cyP9ZwL+6SqIKkrdy iSU1VCKd4e7h2aQ+qk2ZMj7O4KYz1hKk8ka7T/bsWhR3Of506eFfCLSZj48t8RcEEtud rSKdTcC4/7OLgIWBMv+ANkGZqLcbalrEGktOopwF3nWu4f4V4Q0UbLgSfs54TJ7S/sM6 G3gnpP1PLebIa7r7LRN3OR1lk0RUzhW53ddErgDJDL7six2+Df6B5IUZC7n1uprb2rn2 PYzg== 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=22Eep4uSgnWDVl5m3gAXWZWITrVOozsJyTmUp6q/dXRKNlWoDgtalFdLgELgrbc3Mj 54KKBb7IUvBiBJNO3EXZz46qtVeG4eavied9Ky1G2e+RkPKTv3mE2W1HZA9CuPuixi9F bJT1N8BJCI8Xgde0YkT+ET6GGzVR+Da6LmkeQBVSWW/MWwYORMlrE68sqBiZLZXncxmw N5/0EGkCCqrTY/7G/1sVHvbG+2LIFwOX8LVvo5Y5F59/xzFMdOPZ/E6KjoqDKlDd7uvD MR/tWcYUdnlrOavI3dsa99ac1VQ+T4s+3y+A+jUjzF/tr7dTs9EcxemdUL6crFDjtVYo tPqQ== X-Gm-Message-State: ACrzQf0rtXMPipfx24rbsk3yYC4Tk03WPIsZw4daxakFMEGRDUq8L7RZ VbomvXX6aWMgTwsx+2lGXU0fVg== X-Google-Smtp-Source: AMsMyM4tWySi0xBEIkP7CeEstg7kcGTgsx/2lbSxzqD9yMdT2Xnkgr6JbQnkLsmJAXZ1l0qVOo4w6w== X-Received: by 2002:a7b:c00d:0:b0:3b4:6331:2fc5 with SMTP id c13-20020a7bc00d000000b003b463312fc5mr5133169wmb.11.1663753416909; Wed, 21 Sep 2022 02:43:36 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43: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 , Thierry Reding , Jonathan Hunter , linux-tegra@vger.kernel.org (open list:TEGRA ARCHITECTURE SUPPORT) Subject: [PATCH v4 11/30] thermal/drivers/tegra: Use generic thermal_zone_get_trip() function Date: Wed, 21 Sep 2022 11:42:24 +0200 Message-Id: <20220921094244.606948-12-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 8C60AC32771 for ; Wed, 21 Sep 2022 09:44:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230346AbiIUJo4 (ORCPT ); Wed, 21 Sep 2022 05:44:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231788AbiIUJnp (ORCPT ); Wed, 21 Sep 2022 05:43:45 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82450923CF for ; Wed, 21 Sep 2022 02:43:41 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id e18so4010040wmq.3 for ; Wed, 21 Sep 2022 02:43: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=zhkHfGU+506U13gs0KttMlfYYtmPZTAW+1/ApMCut14=; b=Cd78V+hNDtPBQjgKS7E3dkx3SdHiwTUacLcEWR5lWrDKzQ/y5kQuUUblCjmIn2s4R+ YHORsHemDGnilhFnKZIFRYOuzqdTMW19JeX1UDQZ/5yuFxm5XncX9b8k4QP4lTf/MtzL kE6n5I//yo6fl8tguS+MXw7SQ9DBUIHS3iA9Kbhf+Cd20tLJeIfSpokdUKLe0ENXVSBk J4rN40J33C74qpSSOeQb3SC2J4nQIhBlCbF1MIK+2EhUeKgvSXcDlc6emC7zyO/zpjI3 XTV56CtMHNkp6Gb7mVcPRAssM9cJyCBUX7X4UjewNIgPBFHJR5c+eHmuFmAbXnj7HBod atEg== 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=hF0GS1+n5/atG1SCuXy6Cv8s8naB8rvODt/H8RAjAVxh1EavFNEqiu0YszVHgIQhfp pnAU2awAj72gOc2o7+BORv3Uj+64jemBPw+ovoWjdaKk6dS4Pu3n5EiQbIYAlanJfOFi gv3UTJw+19f///JUY3yWPCWwBWBZpryYkuRgp2lzEADS61eofX7//z1p9c8WmiYDZvi4 HBp285pEM0SL3/vs2URbc7MIs6I5cr+rz/rEc7gcMyNzsLYG3aXCfEkG+sPNNxg6RAz6 1qmpbis+dk8b6kpz5w9Sxda+GzhHy0zx3GDEVaUP9UVyE/cj2gUE1T531MEphr3O++HE nO+Q== X-Gm-Message-State: ACrzQf3/MXDPNHGgf6AHymHcoGH8wSnzsYufnG9I6rb2cx55TpY/yHDm haOUmAu5z557AIE4TgniEGHVng== X-Google-Smtp-Source: AMsMyM76b+PPLpOyiWJzirLIYSxD8CrJEaBxAd/lp2nYzsLnUNujUsoFlPF7v1Ql1BgMaxOa2tmcIg== X-Received: by 2002:a05:600c:1c19:b0:3b4:c1cb:d46d with SMTP id j25-20020a05600c1c1900b003b4c1cbd46dmr5225318wms.172.1663753418150; Wed, 21 Sep 2022 02:43:38 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43: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, Kunihiko Hayashi , Amit Kucheria , Masami Hiramatsu , linux-arm-kernel@lists.infradead.org (moderated list:ARM/UNIPHIER ARCHITECTURE) Subject: [PATCH v4 12/30] thermal/drivers/uniphier: Use generic thermal_zone_get_trip() function Date: Wed, 21 Sep 2022 11:42:25 +0200 Message-Id: <20220921094244.606948-13-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 BA4F0C32771 for ; Wed, 21 Sep 2022 09:44:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229880AbiIUJov (ORCPT ); Wed, 21 Sep 2022 05:44:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231791AbiIUJnp (ORCPT ); Wed, 21 Sep 2022 05:43:45 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2518F92F42 for ; Wed, 21 Sep 2022 02:43:42 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id n12so8874897wrx.9 for ; Wed, 21 Sep 2022 02:43: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=F16FcP49uIGOwU3Sf8ns9eXu8wz72Lx9ob6lOEA95bs=; b=HiA3EfjWkOce7HwilnMsNfPhOfemF/8YL8t+8lZHmM5THJGFye6sXuc2WOQuNkuYGc IJNRokWV+QLpeV7kcY7pkPnQrjNKVQW/WHEDtcjgUL7e6SXZf7HRAH8XBtRKWUJtSYTq K6Zu0noiOKiIdlA3di/oIW7dCCBKLtZONbToCEKVIZTEJz8WBBDQ1yznH05XcRIqUxge HZv2MarsMNF+4vTDqZ/BvZiYeKv4Pq6kTKUNLAv6oRTYEc3IhVjQD4D5trYKuHjEg0a7 g1Dss0cy8Si4/T4uQwqgGNIWj8+htpRKLnUNrGQDk4Ty/Qqa1pTFekXHythD+zjsaA1v zbSQ== 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=En2ZWyOgoFiLRbyNsPpg10OE/UgZ+0WlkNIqUBXaPKGU5UyIUi/YGRrwNgOUt2KCcE B9qOUB7rbu/oA/B60dR5Z6N9jNl7o53nN3VcXZNRPEE9GiUI7WvqySdYtGToWD+LjHH1 J+G9emLuBG2/gwazmW8aHkH90nbdmdha/h6Tlry0pN+cDg7J/nGXdVwohZLsM/MQUS+r 0Q9EsBrwAw+LEi464XuFm1+RiqiOWL/XOPemKXJsX0+mmvG2KkhWsACy6Db9SsIY3MKg r7pxvIXNZ5THNISVztBbm61lingWgqOYprMz1N+0cf/Aobx52gGWWdJ0lkGzWkXC9BhC J2RQ== X-Gm-Message-State: ACrzQf1sVVHiu0O9uFRl2C/8vmFNeooU3EWOnJ1cxlymxi8UGsfZ8j+5 9MHQwrx77aY2FusvZepDmwxuIA== X-Google-Smtp-Source: AMsMyM6NfenDQBTBp7WJSQFB8n58E4eQqGgdYyhShAn/pvOtGqYuaxoJdDoba+Fjvj4KZxef1xoG1Q== X-Received: by 2002:a5d:5c0a:0:b0:228:db53:22cc with SMTP id cc10-20020a5d5c0a000000b00228db5322ccmr15551040wrb.126.1663753421667; Wed, 21 Sep 2022 02:43:41 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43: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 v4 13/30] thermal/drivers/hisi: Use generic thermal_zone_get_trip() function Date: Wed, 21 Sep 2022 11:42:26 +0200 Message-Id: <20220921094244.606948-14-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 50170C32771 for ; Wed, 21 Sep 2022 09:45:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231665AbiIUJpI (ORCPT ); Wed, 21 Sep 2022 05:45:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231800AbiIUJnq (ORCPT ); Wed, 21 Sep 2022 05:43:46 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A324092F4A for ; Wed, 21 Sep 2022 02:43:44 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id ay7-20020a05600c1e0700b003b49861bf48so2185104wmb.0 for ; Wed, 21 Sep 2022 02:43: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=/DpVb9+AKUGgq8A4EZDNel0xrsv5+R31U81PHZWHu7A=; b=QdsG1ymFNNiUZbnTdJ1KWqCpM1aQhUGIFkxq9WokmcevhYiAhnrpFhUa6aMDMqJRXV DdPdlu4EG+qTh+5VwpTWhNpingU15CTKOEYUl1sba6Oj0LRuOH1Bfan4iaqVwxaWRZ4R Q9DGgKCX1ZjdrrMi+ehVn9/oT0IroNsEiBzJBwEgAwyWZgwvo67ma4+Eodrz4h/901gY fwxw9YVvAl75EIiqarBJ2Fq3jW3o7L7tEMeRNF35JgdV7D+o3y9kle+IQTrrQXb2Je1C ysoMxuhqpWkLWvjmTuSvlfyORGvz+vfcedL1JuMgjozPguukgtiywGJbbOQDmpe5zFF5 QDCQ== 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=pypvTB/fP11jjYP4iBBhhz4oCFFIYTesKxYCFL9cfDLdac+Y3OKaswIMJR2T7OmXuO 2Tp/q/4EUZ2bCV/Ykkclmsea48RMhdWT4bKvRE2lSV0kXy0IUlDAUzZQ4ndMzuHzwbjx PBDTHIHKuEyPYLJxP+ausVUZh+0UOBW9l+kk4Sqvlf/RuQ33zk64ZsszSFURcYv1MOUm QXHKTNU0dfj9twKtW3T9NLdy8vcc8YEg0zJRHSnM9Bi/mBPCb6sdi5yEvhYtuJLpvVta 8NR3Gjm60kzjFyHqfSAeJGi+mNbnWSzhDqG2VWdW6LAUBsoM77joN4FxTTO2h8VAZrQ4 IMmw== X-Gm-Message-State: ACrzQf2VAs3C5J3CVtmi6W5VtHV+gPsgWDIXuCC7c6QneOM3Sauhc35c fGLA+z8K3uFuyAkSngzqYj3N6w== X-Google-Smtp-Source: AMsMyM6LZgjJ3A752FbEvRveClI2LMOZ+Jb7oJ9Svw95WP2iHDODUitKmaEXcumptezuOF3m8mBa0Q== X-Received: by 2002:a05:600c:5007:b0:3b4:adf4:8cf6 with SMTP id n7-20020a05600c500700b003b4adf48cf6mr5464753wmr.150.1663753423070; Wed, 21 Sep 2022 02:43:43 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43:42 -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 , Thara Gopinath , Andy Gross , Bjorn Andersson , Konrad Dybcio , linux-arm-msm@vger.kernel.org (open list:QUALCOMM TSENS THERMAL DRIVER) Subject: [PATCH v4 14/30] thermal/drivers/qcom: Use generic thermal_zone_get_trip() function Date: Wed, 21 Sep 2022 11:42:27 +0200 Message-Id: <20220921094244.606948-15-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 A0FB4C32771 for ; Wed, 21 Sep 2022 09:45:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229911AbiIUJpN (ORCPT ); Wed, 21 Sep 2022 05:45:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231803AbiIUJnq (ORCPT ); Wed, 21 Sep 2022 05:43:46 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9DC192F4E for ; Wed, 21 Sep 2022 02:43:44 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id r7so8944561wrm.2 for ; Wed, 21 Sep 2022 02:43: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=cMvv+kIwS7Npnyybgo7TEwbxPHKi63Y9shqXlNy7AcU=; b=w7YOAHF+Mo749ReVRayXWiXMtDEx78SmXA5hC2nF7+MA3C91wATBu0a02Qn7CU8j6P +lh5AndC3u/CB57mmREWvAFy6d5mlTnOhbKM7wKoxFeaKEvKZD467dEaSaOxhBP7p5rR cc+0vILWFLJsKydLAOwdm1OKu4f1sgz4eetA27kVPpU9xtMfXGQk+Nr9Dfl3jZ1RG11y YjkBy0F/LetLWVz5tLqn+x988dKSTYqJFHknu4fTuiJaRhz674ubnKykiDPxxZSqzz5z TrwLWUidkJQYayoc9XCCxTHbwfKe+QllGcvTjXRkAfmAQIr1wx0aQ6CO5Z6fqHCCqKH8 quSQ== 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=n6pIy+0ufI+bWu0BepSglOmT1tEFCqQQx0XLJAHMEtiUTRshRjmHjuQHQN9NiWmRJX 3EsKwKO8eezEBsahRXtvOWrCk4uXJ1gCGxqE/9zgHJbkZSfL/bKacIjV21p50IaFMBAm Jqy5FvxYE0b+3BaPV54Sp2D5MVG3wo29wlM/Aw6OFoKFziwnFWsJAKEbVY94WBVWno85 sfymHQyFzwfzXUIbikZVwVdsgnhmI/Jr4Vx6M0juwj7Qwjh+wHbbluwyy5/xhrBaLoNj 5uFMUOPCRVExFUJs8p3LsUNJTgdWEpS2JttcYrhV0i0Da+yW7C/YlpxRE3E5HAqLioTh GQdA== X-Gm-Message-State: ACrzQf3Xmd1pD3NSTJP7ApWLAu7FKw+PlL7NPT8qJjr/pDHvclQedTAp xk4ZSFcy+PvaFazHUj9kUGQgnw== X-Google-Smtp-Source: AMsMyM7b/bKDaPaFv9Rq2zLpIrEgKpeyNjVrzjIZx2uTbPvgvxj1FxRvBu2O98Q/8QSP9tMqrRFvYg== X-Received: by 2002:a05:6000:38e:b0:22a:e302:28e6 with SMTP id u14-20020a056000038e00b0022ae30228e6mr15169501wrf.595.1663753424295; Wed, 21 Sep 2022 02:43:44 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43: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, Miquel Raynal , Amit Kucheria Subject: [PATCH v4 15/30] thermal/drivers/armada: Use generic thermal_zone_get_trip() function Date: Wed, 21 Sep 2022 11:42:28 +0200 Message-Id: <20220921094244.606948-16-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 98164C32771 for ; Wed, 21 Sep 2022 09:45:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231284AbiIUJpU (ORCPT ); Wed, 21 Sep 2022 05:45:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231816AbiIUJns (ORCPT ); Wed, 21 Sep 2022 05:43:48 -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 265DC92F5D for ; Wed, 21 Sep 2022 02:43:47 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id z6so8963065wrq.1 for ; Wed, 21 Sep 2022 02:43: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=XrpGuF2vxbaEuk6VfKG2/A6XesW21KLMiogPr2+Ux0s=; b=CvbqxYvWLlH7YwxqIy9n50Zj/oeha4OoIrdgPE+mNnkr2pyBlbcU0Gy/jZyRcG0eXU 40bTphoOn+/9vXysdosPiaUP15+f9sUP+LoZU9m/A/n80k8RqH+TtuxmABLSXn9WW3H8 ZPxSTcerUs7ARkfxB94bQjwMiGh3//FRKJX8+W7wBlGxOd0fFVXr9l9abz0LLJxKCzM7 jRLxhjprQrmOx+tNOXFFGvWFCd+qd9bnjkKz96pqS1pWiXHksU9h5hVCGcwbvY579CPV S9yIrjITEYMZkc+abBngKsmWc//iVcciMhiMbRmAXlE3GGiMQmkflpOrgOURUPLf+PLe WQgg== 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=q/tmjhuZ0wcSxnaL6EOGTl5RH8+JdhG/k12HG1hEaZBObK8KSEShtDyup0s+opmrwr IUF6Thg3CoAhn+DoXX1NSrEbi2tvSy7denAMGtv+olFRjK+tWK4g6mzPqALS/2iZ8b/9 lhiEAl7us0O3Ro4n8Eua/D6n2tr1ydEwT8BBqACJPqPBVX9Ts9yovmHkR7DhwPTVAght EZV0BYblmIYJhI6gRpKG6HUxf5mC0WOiWa1+Cpw7N1UetqaWS6uRiTrDxmMpUlsEAP1f OZ5E6Fzj2HzwulYqLZ/u7jSmeHf39MCP43P00aR9FDjd6oeylTGhCaqO1JYDjyg7ohW0 pDxA== X-Gm-Message-State: ACrzQf0WjikJGz614nwanmdgEMDZSutFXerWdvj4n4jTo26xijPULRjQ NwIQiuG5DsAQ8pH/n1urB43dwQEff3MCng== X-Google-Smtp-Source: AMsMyM6htcl1h2Rv2GIsHgmCdaubTQZpA3Zj9T7e3kQIg7c5nWcyGFLMOLz0reJ9UaOzgwNvj/z1+Q== X-Received: by 2002:adf:f408:0:b0:228:d6f6:3bb9 with SMTP id g8-20020adff408000000b00228d6f63bb9mr16680389wro.398.1663753425574; Wed, 21 Sep 2022 02:43:45 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43: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, =?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 v4 16/30] thermal/drivers/rcar_gen3: Use the generic function to get the number of trips Date: Wed, 21 Sep 2022 11:42:29 +0200 Message-Id: <20220921094244.606948-17-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 24B93C32771 for ; Wed, 21 Sep 2022 09:45:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231786AbiIUJp1 (ORCPT ); Wed, 21 Sep 2022 05:45:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231705AbiIUJnv (ORCPT ); Wed, 21 Sep 2022 05:43:51 -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 E6C1292F65 for ; Wed, 21 Sep 2022 02:43:48 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id t4so93119wmj.5 for ; Wed, 21 Sep 2022 02:43:48 -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=wKElCC452+uQH9oPG73me3V/zKr0MM7IvUS5jZU3ITo=; b=AWx3Cda2QSlM0q9A/EXQu8wsdHcl7/UyCHLIFjGeOM2Ru7n9tgfREM9M3cUTr4izEZ U5Wj/01p9Ry48o2n1LM3G0UV/qsHhmB9cw7XxthYQN0L+LyvC9fYhMGus7OLLBaXXKSC Wm5YsSxH+R3kn8CqIGMIYrr7oJkoGJbrztVa/Po09BRc8waW1fARXC3LMrgepUAiqmXP O33TSa2wisGKRwIXcv023IBu54N35bqfU7uRIepwwJyYuVN/TstdKsIyjuJJaoVI1YLy 47xULmi5Xn5oJYnX59MjAiU7+Jf5q506tVogT5OHPgGRV0nus3nhFu98YFg4PDWMmFSp VfAQ== 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=wKElCC452+uQH9oPG73me3V/zKr0MM7IvUS5jZU3ITo=; b=13cMUmUmiv/cklI5hyLuzDEIDZtSrq/8+1DNWHEwq8VrkGHw7keBgAVDL+4j13UCnm TleQq3dH6Hpq3/wI/urM7yWfou8btfDVivvGUUumSqiX+HljpWo4y3+nVfmeqm7n3G6i O0eAEDBgL+gugi+RVpfD8BxALKb821RjOvfk6BVtoBuUp6fzMw+GuO/ArbgOaQ1lBoXv TxrNl7ADQGV+rduQYLoG0Bg3KBRTDIg9M/rw5izpK/9qFXAE/cXpXjf1OGOfxtEg/LjA g/yh1hWJLRaHYBKxltym5dMoD0dC11LDom0S3r+TGj8lhqYtNJSCVpESFAgK/rlAmRu7 PFAw== X-Gm-Message-State: ACrzQf01qfkIZNbZ9MGZHd0pt7WWn/b1Mz1mW40t6iC7Y/2gdtSMQluV hoVRWU3n6uY/bUIhgorHmjZy9A== X-Google-Smtp-Source: AMsMyM4RwSXbgtxEvyH6G4shUG1Vs7m0/Uzr5JBgqREIMQIEpqEj536yH5hZQQpdJOzYcEABiaEW8Q== X-Received: by 2002:a05:600c:3506:b0:3b4:c086:fa37 with SMTP id h6-20020a05600c350600b003b4c086fa37mr5493360wmq.165.1663753427034; Wed, 21 Sep 2022 02:43:47 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43:46 -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 v4 17/30] thermal/of: Remove of_thermal_get_ntrips() Date: Wed, 21 Sep 2022 11:42:30 +0200 Message-Id: <20220921094244.606948-18-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 99a5d5281037..0139bc1e4f87 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -137,13 +137,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 Thu Apr 2 19:54:44 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 E9FEAC32771 for ; Wed, 21 Sep 2022 09:45:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231803AbiIUJpc (ORCPT ); Wed, 21 Sep 2022 05:45:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229599AbiIUJnv (ORCPT ); Wed, 21 Sep 2022 05:43:51 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C887192F63 for ; Wed, 21 Sep 2022 02:43:48 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id e18so4010316wmq.3 for ; Wed, 21 Sep 2022 02:43:48 -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=NFzfcStR9W+Nwf1uLdi1lXL2TUYpkWfd9XSuLVSwMnk=; b=OFhfxi08zetOvSfj0CGLPTauK+j/KNX61LmDyV4cNzbFtaIFiUB9OxpwZ3Sz7IgrR1 ziuPAICaIKCarjrv6O6BHG6gvDpI2EqCz19QYay8UNrXxW7Fdi3SYmSzRBdDR1Gkx5Zm Ql3+y9//rZhWw7obN8XGkn6zSL++iO7X6/NMmhVkiQkVaPVdbiOaCJhuXoaIxoXbtocg 1Y9W+jmYVAKxwk/FLJGrJyAsTkxe7G0j6MsNEEJBd23fbtPug1b1+fdug7YU2rOy8E82 3t+i+clVnhEE13vD2Q9sW/muqy5yGAjp7wHNar9DfmJAXOKruTeNwGy6Q2QS6VynHkbx sBZw== 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=NFzfcStR9W+Nwf1uLdi1lXL2TUYpkWfd9XSuLVSwMnk=; b=ZpzA4pQyG7u8bEbwxQWONk4e+37/TlH1XkoYkrczKeOSMy7/ioUr7GoDDqsi9JQ+gh OLbNlZn/7fBavde8rpEMAAfm2467hidRIamDgmk2cjDccnPur2KrJ3ODNdyPD2yrORG7 +l5sJffBNijea/RmYzXLwh9onDfSdIsmFRSlNFQGuFh63zFLuufTaVv5osixUzJpPNpN DpIcx6E8QEEqSjtissDARRveDHKGJpGGKLOjr6KwJVRu8ioL+ADiK6I4Fx2MApXehY+l UDd4QVDFfDN3PU2q96N9g4bzhyo79c1QpTZLrMDjLXpeDs//GGhdH9oDWoW6+z0wzC8u hTGA== X-Gm-Message-State: ACrzQf30Tafb3yfNdBqKSYDzPoE/XFLfz+XnO8pK+FUbhSEr/eSXZD3F QX+QUzUJcaT8wDFkQowvi0A/1w== X-Google-Smtp-Source: AMsMyM54SSbst017kUHJ/kRvSaUTvDDuiwBy6e6yjxo/iFlnpkJnIf2iqh/R/keVni6O9LysJ63CMg== X-Received: by 2002:a1c:6a0b:0:b0:3b3:3ed4:9bef with SMTP id f11-20020a1c6a0b000000b003b33ed49befmr5512802wmc.84.1663753428323; Wed, 21 Sep 2022 02:43:48 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43:47 -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 v4 18/30] thermal/of: Remove of_thermal_is_trip_valid() Date: Wed, 21 Sep 2022 11:42:31 +0200 Message-Id: <20220921094244.606948-19-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 0139bc1e4f87..4d1af11a6eb4 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -136,16 +136,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 Thu Apr 2 19:54:44 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 8E468C32771 for ; Wed, 21 Sep 2022 09:45:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231844AbiIUJpk (ORCPT ); Wed, 21 Sep 2022 05:45:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230115AbiIUJnw (ORCPT ); Wed, 21 Sep 2022 05:43:52 -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 039CF92F69 for ; Wed, 21 Sep 2022 02:43:51 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id bq9so8932140wrb.4 for ; Wed, 21 Sep 2022 02:43:50 -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=NspiL8xBWtxFZk4xO58c4h8PCilOME2upvEL2MDhBVpLETfcOqoi+Tb4f2jIc0frbg 6CvUC/Djm2URTXlqK22pC3SOrZai+bKjOcd1ZKAz5Y6p1Na5C7EQ+EdY3vdBvKHD6Yup A5O582+buH0igDPx/lC5xvqBL+Qf7GMkMd7iUNFuNR/Yq8GgV14nj5g/9sYElgaqTGVn SPDw0+8m7mJTBgL9O7GbHk1xUZPhjL98pO8sZCYTFS5RTHIeowE+qqB0mtZvHiPTqxUy im2qFrc8GqmhvDdFlUmhly6UlrAsUJXot3g/Esm+Xb9oaDuzeJhX9bOpzUyQu6MDWIUM UIxw== 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=2/pz7Ax6RExU2QsxW1mt5/hok5kXSzNICxsElJYfOnsVIXkNIbUkqVQxv3X5NxCgXf opRtXpQfP7A/u5hAyZgMYRJns1TXGOhZhoQFlfDwrgbHXd7IQf6qzc6QZ7/kIR1PNBGI YNyyO06ABHj7+0BCHrmkPJhZElLjdGDYCGGBE4AtfV3B3A1K6JzY/bz1aCItU6lcl9hk 6IoCMFXFRSRc2s1O6SsF4mom57MjCpYjGt7T+/QLPdWtoOvwIoEsaqYOvNKHOtjVGUyL 7xPNfEHRq6FdkHmgmuO708Mlq6/fY5l5DoW+PfpV4xH8UTNbQf06HsEiyl55ydRPir0I 1pMQ== X-Gm-Message-State: ACrzQf0WO7nfSGRIPV98FUbNkOuCpCrnwoyyaGyUmgk2lWvlpIyI0NsY qYxpqoiNNdnLwgwdQOhwOLMw7Q== X-Google-Smtp-Source: AMsMyM7Sf3DMIyE4rAZmaGC6IdbRUGqfxWS1HPCPY/JWVS7LneJM6e089hZIfjClcagq4gtM9moekg== X-Received: by 2002:a5d:64e5:0:b0:22a:3cae:93bf with SMTP id g5-20020a5d64e5000000b0022a3cae93bfmr16811393wri.323.1663753429413; Wed, 21 Sep 2022 02:43:49 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43:49 -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 v4 19/30] thermal/of: Remove of_thermal_set_trip_hyst() Date: Wed, 21 Sep 2022 11:42:32 +0200 Message-Id: <20220921094244.606948-20-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 91926C32771 for ; Wed, 21 Sep 2022 09:45:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231873AbiIUJpg (ORCPT ); Wed, 21 Sep 2022 05:45:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231709AbiIUJnv (ORCPT ); Wed, 21 Sep 2022 05:43:51 -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 E96E592F68 for ; Wed, 21 Sep 2022 02:43:50 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id k3-20020a05600c1c8300b003b4fa1a85f8so849354wms.3 for ; Wed, 21 Sep 2022 02:43:50 -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=K14JYYfltM5e6DhctguBDMDG6gANKg/guX6Cskv0XezmqFtEwuxu+qtRKjkfivm9wE GEQvfu/oZlIt2txxz313ppgPFTB9HDYKgj1lNuTuKvAXyKvOD5IEUi7PJBnuXftziyjM 8mpWzqCEECtawpB+YbJf8cTKRc+8pJR5srNt/2YwRunzgnKDXx5NdHvZ8JKMIUgNYMr9 6oT/hsWfHgrASf72ALGQmnaQSZBRCXFxm7p4EUuec54RU+1bGtfSYsxp+JbzVywJG3EA 6qQgsxtwn3YgME8FxBnTF7CLw9GgBanBQHJj9ZqUgbqWaKQNyctL9dS8KGfqD5iS9sTz WV+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=OHXbaNWdyZ0Wkkc1xL/nI14ReQ0AVnlGlwSXS+lV7dA=; b=tHAX0v7LPuDrrwYApkF2zgp48pRjSiYTr8PqkPPR/63r0rz5iQzVCk9ojyLKU6+0mU Yc0IaJ9SJKGzGT4HDAa2cmnOjq3N5De6L8YnV/sXF1Ta9ipwwHwflcBMTiH6KQ5RJrXT StXyJuobrOVwSGDazxxIATl5oIG35atkVKTh9xg5X499Mpo5cwDmACy1sxcDXeCVPndO Ia3eXa0GQvLk2djAInnRJ7ZyWzXgZsPmf1/KaktcPTZBf83AyxUnkmnGta6lBUllsO/6 BarsGvh4b2yqvGUJjDEmg0uthQPcQXp49cNrpetHG4nwaTV2oMTa4jlEG3Yhm5mqWMn3 R6mg== X-Gm-Message-State: ACrzQf1Vl/j+Q8Pc0mC9ryCZCJOoygy5tz/wy1Q88/32saOy7jUMNwF0 aKfTT94PSmZJCrdrRgrAXdcLAQ== X-Google-Smtp-Source: AMsMyM64H/u/UhdGI3J638/N7/v1XbmrbMisCRv4KeCvuIVxsawhquL+yrAorxkMb480hr9M6LWvXQ== X-Received: by 2002:a05:600c:3d8d:b0:3b4:cd96:171b with SMTP id bi13-20020a05600c3d8d00b003b4cd96171bmr5365658wmb.43.1663753430445; Wed, 21 Sep 2022 02:43:50 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43: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, Amit Kucheria Subject: [PATCH v4 20/30] thermal/of: Remove of_thermal_get_crit_temp() Date: Wed, 21 Sep 2022 11:42:33 +0200 Message-Id: <20220921094244.606948-21-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 21D87ECAAD8 for ; Wed, 21 Sep 2022 09:45:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230514AbiIUJpq (ORCPT ); Wed, 21 Sep 2022 05:45:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231681AbiIUJnx (ORCPT ); Wed, 21 Sep 2022 05:43: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 A5F33923F8 for ; Wed, 21 Sep 2022 02:43:52 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id s14so6917470wro.0 for ; Wed, 21 Sep 2022 02:43:52 -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=YlKrfk8RE2F5000dDu+v0V/biI5dCrVqLGu7QlklQ2VQZuUtUPB5hZtQ7bxnTZLqR4 ZxJI97ai6fONmSjjXj8o5u48bIuIamdK2YkasqKqvBQrEsDhjWEG1peqy40CKTtjkuYc RC+XXmUlOhzDi+ooD3s/96IiEoaFSV7NL8U3HYIi831eYtzdXA95/H9gks84YH0+R3xU QINJ8jsNEhqQ7F1YDJJLf9j/U97dGOXwHyV64yOrPcDGLCIGHBaMxriHlK/kh5PL7j80 hPMHAZPYizCKtptGr+Ae1FM/7ZjpteBiqCm6GaLBALN+yreIxImDNotIOz1DA1FFQACy HRbQ== 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=aM/TXvaz6P/XGOvYHKOYlPrR6q9N0rng7IhuyRpgnTtnVDfOERWPBLKCDNN/RsjMx7 RB26c7uMszvfH7gKwvGtBXdwLs90JwiPqLHSbcEZ93gF9LDgLcTGqId0fJ9umoZyuC2B XXG0uVLFWi+2oBfEvlwNhyqUHfyo3RknWjOpNOwS9NtsGOJbOrW0t/pGiLjhaOpxbFNA OvRPj9yQUpAU5InBErPSTqiMEnw9LoHtz2cjvvC/TWX2VGTT4Xyx9nma8p+Fmp5563rg UznfDacBj0NZ14mODw+GyxYqLV6NvbYFoYRAvCj6RIllwfpTAI0jtr8Lzj+KTJImUXi/ udlQ== X-Gm-Message-State: ACrzQf0AZS/a1ySiGz7a9Rk1xC96cJxt5s6J0C4cjEz3n+JGJ8GnoIDi 2pSYpIdPUjcFYnXs0I/MSkMKmQ== X-Google-Smtp-Source: AMsMyM5lA2FlwPWZwjhbhB8WsnWSj7OG43VpvJgzm7PuJax9Ul+507ve7BJiR4MCIGWCzUJanqIL9w== X-Received: by 2002:a5d:5942:0:b0:225:7425:4e39 with SMTP id e2-20020a5d5942000000b0022574254e39mr16213887wri.566.1663753432145; Wed, 21 Sep 2022 02:43:52 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43:51 -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 v4 21/30] thermal/drivers/st: Use generic trip points Date: Wed, 21 Sep 2022 11:42:34 +0200 Message-Id: <20220921094244.606948-22-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 44230C32771 for ; Wed, 21 Sep 2022 09:45:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229785AbiIUJpv (ORCPT ); Wed, 21 Sep 2022 05:45:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230364AbiIUJn6 (ORCPT ); Wed, 21 Sep 2022 05:43:58 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79ADA92F74 for ; Wed, 21 Sep 2022 02:43:55 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id n15so1985998wrq.5 for ; Wed, 21 Sep 2022 02:43: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=xYvlHjUzJ1gAdl8KtmAH0mCHcP29B+tCMOTUThwt7jg=; b=YCRrd/usxnKkpiLy18bVj0hse8a+14RUASw/m8mSNGcX5IY1K/+POqGzyaf8FNIsGi IzeYS6yPp86Bvyr/MvWA1fAPTO7k8mPkJGHuXiABc+n1TdoGepvqzB7HBniDJZNAaENU spZggjKMHx3LU4L8MwCScMw3LeTxjWonuNxNH2hDy5Ck36ljKR0j4EicQ/mgLSzTd9AI 8hoUU9Eh9rGkOCJrSK3IrI4yz59raduEQfO6OyDBjeiN+h03cyhgfjl9wu0HuNoZR82q SmbM7YuOWy+YNJPxUbMElDq3Ea/7uTHFx9qshUOlInLc3o22ha32dmMeq3/1AdFrr759 vlgw== 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=K0jO1ZRW3Auhx1tj4s9kWfsSktszx0gsLbs3qMzTuQy1jnIFKXpHng7RxUw5JGQNHT yURrgFNH+LizNHSUk1MpCbMZlaVJZQ5WJa2eBqAApxz5yYqrpSN3HQDZovYbw/1IKOEL 68EoDl1QxY6fQZFRc793gYs0mWa9oMrCyQ5FY68eJS2jPGBbDjyXS1DMKMwXJYCTeaXZ 8wQ6H31tgVsZklM0yYIQzSLi7v+25pZXxCdvn6J7xn1MK7VS7W0KxmpMTH+e3Osz8ijg kx4PZE6BbcMBSHlmlP4ItrNXQHKXMa8DusBZ1lZVLebraIp37qGs8jTI2cV2cJUlXeew OpYA== X-Gm-Message-State: ACrzQf1NzZTgeUMh9EBkPw/8txzuwhrUSyjQqgZJu1hW/ntjTW7dvXNJ z3yrKTDr+RLQ369VBMjmXKK4Mg== X-Google-Smtp-Source: AMsMyM6xzdW8cX8vf+PL3jDq34mo7OYJSGjafHyGUEbXZDgtk839KBHs4xgUuabSXGfQsDdOWJTlTg== X-Received: by 2002:a5d:6483:0:b0:226:db59:2f94 with SMTP id o3-20020a5d6483000000b00226db592f94mr16581198wri.200.1663753433531; Wed, 21 Sep 2022 02:43:53 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43:53 -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 v4 22/30] thermal/drivers/imx: Use generic thermal_zone_get_trip() function Date: Wed, 21 Sep 2022 11:42:35 +0200 Message-Id: <20220921094244.606948-23-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 2B4DDECAAD8 for ; Wed, 21 Sep 2022 09:46:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231899AbiIUJqE (ORCPT ); Wed, 21 Sep 2022 05:46:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231753AbiIUJn7 (ORCPT ); Wed, 21 Sep 2022 05:43:59 -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 0277D92F7C for ; Wed, 21 Sep 2022 02:43:56 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id n12so8875823wrx.9 for ; Wed, 21 Sep 2022 02:43:56 -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=zQbmfBmegjos4DstNIyh4h3OfgjszA3bL7nsBwXGl/h1Rh1x03+MeT9QU8UpnjjUrv MB4FZYymJ9XdqFI5WTo05b2iK/TyqXb/IbvqFsoc8Dj1Ow8qlyiHsQ3Vt2FuJe5uR492 fOC068b6lAjpy9eQ8R7bcM4+UQyY3Kyiz2DHxz3xLqt1RELb0RVRhso6JbQqYpF5BgqN fEpI+FpSF1dyhxqrFLcIyLbx8nIZin0jG4VXiBDFlJU/9Ir9+UaIAjqSJztcgVBtnHG2 ShmfOqw644YZqLiRvOAzigLsm9XFbFNsEqehgBYa9hj7na3+xCxQ511pw7LY7RDiUUNP AkQg== 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=cp/PHEJ8toOIpdPplzWb8Dvhnl2niTr/DnoqJ2rgOkDRNkGEVPgZB/1FlzAxhbvklH 4T6Da+FIgG0kKwPou+lFdsT4FzU0n2ERcBm+YeuDG8aJhRBuE7dKhN/JYHb7gXxPIK4X lvBl8ujciAIZx57+jC4wL6SbsvexPbhMgYqyvdJOGrVORHqnskB2Ili1w5X+tdqSr9wg 4dnvYg5eO8NNuzdqq1efZhWKWRBjmMdX63VtNBn5B1rsrW+9sFqXUVAYzSk/8cp4h2Wp 5xud6m9gEDkeXCrUgOVj1TqqAUizfiVhVjNpKdEnxiwl+7wgZea994db4rB233ikEVxu Xcrw== X-Gm-Message-State: ACrzQf0u9f5TTPiegwusqn0QdE6Pml52Lk7JS8LRKbwV3dkrp7Baug8F zxo2CoeTAxsbD+7N/cpNFjqulA== X-Google-Smtp-Source: AMsMyM5Fy5rsKtsYjouyAotA7L+Pne0w+FWVZ0x6QfNVNWl4vzzA09eOpseqiZdhv/eLWnoKGpc7AQ== X-Received: by 2002:a05:6000:1866:b0:228:e373:ad68 with SMTP id d6-20020a056000186600b00228e373ad68mr16155764wri.605.1663753434825; Wed, 21 Sep 2022 02:43:54 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43: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, =?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 v4 23/30] thermal/drivers/rcar: Use generic thermal_zone_get_trip() function Date: Wed, 21 Sep 2022 11:42:36 +0200 Message-Id: <20220921094244.606948-24-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 65E68C32771 for ; Wed, 21 Sep 2022 09:46:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231814AbiIUJqA (ORCPT ); Wed, 21 Sep 2022 05:46:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231752AbiIUJn7 (ORCPT ); Wed, 21 Sep 2022 05:43:59 -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 2428692F44 for ; Wed, 21 Sep 2022 02:43:57 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id k3-20020a05600c1c8300b003b4fa1a85f8so849520wms.3 for ; Wed, 21 Sep 2022 02:43: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=RuOkdBUevpNwOF5uxKYPUxVuiSYnY/XeiYrwbyLTKVs=; b=H7uUgV5bbaO8IhsA0NSgBx8cQTkdCMY13Map5H+yPhwkG1tjFGDj/3L9F5+Syn1WGD oxruQ1g3iQHEBtADdxkCsY9cxkvl0IICBlY569n3FO+p3No/uNn3rkQVEVRUZQurfKYt 4h2XffbxvHrkH2XoJHdy2NstDcKoWuu+Yvn7YjhyZfP3qsIXOI2pxEB/0gK5GEO3VHtY UYBM4A/zXUody8cSgBJyjJd+25lL2gJZD00td5LuJHpsx0+ljyGvIz2hwQnIi9+TvdBy QZIevi7rRLS8zk4ssKYgz0djbsxR++NkuumLG76nUiEKDWhcOOO8OdJ2rGPHe4+ZWVUB bRLQ== 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=SMzlKViLf6ylbs0N06Kns7jMXUxj60TgCIh/tuc8o9vY8CXjStMRepvB5CEwpkwKd2 lK2LD04PO34Djh78isWF/JHLGfq/pjTRhUq2g2ffCMGGQNGo/nA25bz8HJjzmd3b8MCw Gy4FR8fiV37XD0kwQoy3Tk9dYbndT5R6tJzZatIMA2WEtGiN78GBNQhuhyi7r00lxsB2 818j83cc558O3wYcP7mNmXjsjq6KC2hSIl+4zKRJM5LKYPTk66ws9K0RQC1OFwjsdP8Q lSIRMQdLdA7uVGxWR6j9Ck+7jHnt/+KaVgVHQG27z6bp0NwLr8NB4s06EqH90ulewC+T weyg== X-Gm-Message-State: ACrzQf38VZyJbiD7y0zGO8uCB0aNEmvSXDCpmqo7wsQzPjjWPdU3Hvdb CjqWvQbq6Qm5lwXi6bxOwFLXpw== X-Google-Smtp-Source: AMsMyM6Eo+bq69cC3CQibwo2iSeKRah3MVdlH4RMxCQH6V7JNTE0FdMNswpRvblkbci+zFv7/Un/bA== X-Received: by 2002:a05:600c:2050:b0:3b4:a51a:a1f5 with SMTP id p16-20020a05600c205000b003b4a51aa1f5mr5044930wmg.177.1663753436656; Wed, 21 Sep 2022 02:43:56 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43:56 -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 , Ray Jui , Scott Branden , Broadcom internal kernel review list , 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 v4 24/30] thermal/drivers/broadcom: Use generic thermal_zone_get_trip() function Date: Wed, 21 Sep 2022 11:42:37 +0200 Message-Id: <20220921094244.606948-25-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 C81D6C32771 for ; Wed, 21 Sep 2022 09:46:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229942AbiIUJqM (ORCPT ); Wed, 21 Sep 2022 05:46:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231764AbiIUJoB (ORCPT ); Wed, 21 Sep 2022 05:44: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 A1FA392F6C for ; Wed, 21 Sep 2022 02:43:59 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id z6so8963832wrq.1 for ; Wed, 21 Sep 2022 02:43: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=kNTESOeVOVH9BHNMsa7BlHA2jeppHM3L2UNE800z/X4=; b=spC8itzQ8Zu07i902LsnviwBg3i7BeeP9FVIKUq6RuScZOrs7MWKBO1vka1Cq6kToQ tWwDlIHH61SlicyCjd+RY60+H8lN6jUsw5uopblNw0o2zrUH825oHPRZtIvp0nh2lmWP QdTTSg5M9MuwV+L1rcdvZQbdaNodY7rCfy2BmpwDYajWfGRvZh3fQzlV9GGQCVYkkZkQ Ta5g+DGqSYxnbI/DdgLLz+Pgu6y7QT/YwCTtZj5Arr9k5DUGsStM2+x5xs9trjChOD79 CDTn0Z8Z1Op+tfkEoJfkyRiPTRjg+hBpbkHCea7ChHh2FXWM2bd3XsTULmcOI3mpFl/M frAQ== 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=Yct90kCyVsCgeOUtJZV9L6SkaJYjamb7vYGlBa4oggQCZ2aO7Js3NfAF3/MU8tIF1D mLAEg1dJrTY7zmpuRrQZNKMk5drhWqF1qJkwBYbttj4hITNvjxkteYqzGPAvIVavJ+lD tyFciSnReFa5ORx3pWdnez19MPMwhWA4SSC2OHXFAcpNKy3kUs3nSArEpBJQSfWJhPHp AJ5cyJZajKCr5KKyyxO8cVXQurXUihRVwqptWlFBJM6c3PEoUoBjEy1Qw0/cxV9Tkl7y C5LzCb9SqXKGwV7hq+5KmMNdPCoGmnBK5VdR70pvKKNpgTLk3jI4PgqMCAZstCQ8Jfsy HF+Q== X-Gm-Message-State: ACrzQf3TIYWbV8aK8uVJDzNAiQ+chlzeJZxd5MXcPGr8bAQ/RNyv8dyc kJ1RLWiNn2EN9o9uP4e/t1RTEw== X-Google-Smtp-Source: AMsMyM5CMzCtQp7qke8QoVEmBj72+j+rjWl2TQ32E2YQvISKP5i9p6jbY0juB+pB4xs/o1b1bVVuZQ== X-Received: by 2002:adf:fbc7:0:b0:220:6004:18ca with SMTP id d7-20020adffbc7000000b00220600418camr16220603wrs.632.1663753437819; Wed, 21 Sep 2022 02:43:57 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43: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, Adam Ward , Support Opensource , Amit Kucheria Subject: [PATCH v4 25/30] thermal/drivers/da9062: Use generic thermal_zone_get_trip() function Date: Wed, 21 Sep 2022 11:42:38 +0200 Message-Id: <20220921094244.606948-26-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 41FF9ECAAD8 for ; Wed, 21 Sep 2022 09:46:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230094AbiIUJqI (ORCPT ); Wed, 21 Sep 2022 05:46:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231761AbiIUJoB (ORCPT ); Wed, 21 Sep 2022 05:44:01 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C035B93209 for ; Wed, 21 Sep 2022 02:43:59 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id n10so8849259wrw.12 for ; Wed, 21 Sep 2022 02:43: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=v9HOYNemLB65v2s3X2Chh/1DsPPvYHZYg0+K/15aDgQ=; b=rHEU2V/5h7AUju8XBTiGugYh57qpJGzWG4/z/sjkKjsCe8H+5YNWYGeY0tjhKUXFIM d6VhnbR3sMKtq04xyakS6XUxNbS4hwVZ4ADa1Ro5qrEExkJ9CSaVmZaY2jkw+BiW9FtT HC3zcaLEeOhh25OY9xq66LqOLApy2085B+wjmlMD+WrZ+V5U1WcLeRz2YNrB2shhQRm3 eTsvw1LLmkNR1jxdoQjKJawH4hjt0JUeUXXVeTV9dm2YE1hLVJtvWn39i38YjqI9wvto mRtq6M/HgvUngXsZHUiobXGbYwaTz8CFhpxOL34Mq1YT1QWLbG8I4v/JNh3zKAS88D2Z Uwdw== 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=ODZ+1nsPA2UdsLvVzUXYpAn5FKqdUiB8IChafdFsBuu+WYjisyN375Os395H0obq20 +NF1Vm3aCY+hmxwrrGuxBa66A3AXnUS+CJa2PJtZwXO/5ku1zHf4JHIZgTNyLhhh29/u v85DpcDSp7kUPzlqXVUaZOCAohdP9uwAIoNit/cLYQjeygMAWUAwhA+wB5fwTEx68CpC OweoaZ4zzO2jqjIYi+3uy4IMnb4wQjvu6irsK2gU9LmU78d57f/qzED033BW6Nvb+x2a xz8Q0uvogHOWXQxPgyRVlK9KEbq8dCdL0zZ847FKP0kF3NXFAuwQIrLNX5OvfWLA4vy7 6MZA== X-Gm-Message-State: ACrzQf25mydFn9oaMpkFrY5bS2pVI+En7atvxvTJZXWNHs7saz+WCiY1 ilyoq+g97R0ncR0Rs/WN2hDFPw== X-Google-Smtp-Source: AMsMyM4EbiNhabTwa86yTniIUhffp+MRd+tRP/UupO9SXRQXndeFlIhugsjyS8hcyVe7KKdCvNG/ZQ== X-Received: by 2002:adf:ee89:0:b0:228:7bdf:47d with SMTP id b9-20020adfee89000000b002287bdf047dmr16160602wro.641.1663753439002; Wed, 21 Sep 2022 02:43:59 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43: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, Eduardo Valentin , Keerthy , Amit Kucheria , linux-omap@vger.kernel.org (open list:TI BANDGAP AND THERMAL DRIVER) Subject: [PATCH v4 26/30] thermal/drivers/ti: Remove unused macros ti_thermal_get_trip_value() / ti_thermal_trip_is_valid() Date: Wed, 21 Sep 2022 11:42:39 +0200 Message-Id: <20220921094244.606948-27-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 B807CC32771 for ; Wed, 21 Sep 2022 09:46:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231911AbiIUJqR (ORCPT ); Wed, 21 Sep 2022 05:46:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231795AbiIUJoH (ORCPT ); Wed, 21 Sep 2022 05:44:07 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE54693215 for ; Wed, 21 Sep 2022 02:44:01 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id g3so8845722wrq.13 for ; Wed, 21 Sep 2022 02:44:01 -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=FII0FKD7EYmszAgfhMPVPNvzM+si3gxauf+OmOBs20THfzI8f6gB2Oi55i+LQfA9eI +2A2aE5LG89RKJR1UxmboZGwUPXDePHsehHxE+9d1Md5EOaMwy1QH8EOSCN89ho+59Lk 5wVWoqES7De6/wuUGrQ6sskulYfeofKyA6WJr4QvwHhh60zwrJDrYTKgqyr9ImVSm59c bTqm8LfsIous3UYzqqMVrJ25tpgbu4IX+wTX9VD5aUYVceVDIKYlYHWmtn13e00zYdK/ MELxMfUu7LdDzhneZ4VkZql7EAESFaTnpaxIPjmdK43PTI7TOmmtY2UKLH93UHoOd38S lUnQ== 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=sEcaF6SDy0Y7fZ/b4qg+J/5KVLWn0sMxMq8bVU7ZNkcLM7ek1Sr9eNq94dyF0rgPlE 0TuVO5QQAvImoKuEykRectu68q3es6M/ptJQlQq4R/IBrOVFZ6qx3WN0PDY34fq5JH4Z Wh0J6ufUZaXPRj8/Eb0FEb/b11DTsAvvWpBhGg0IprH/M6ezfirZ8d3y2rKo4pZg2cPs CuQ/4ZyzmXSRZODbeLEoOTsJ/TBK88rmYH19s4ui7pxTC4efoRvdAToO+mIXufOP+UX7 NzKmibi8OWHkjDAaK1aw42yIxjcR0+5FQvwMsag6/gfv1nG0KOTVP1Ux0OqWpjTHklyS aHqQ== X-Gm-Message-State: ACrzQf0igaRXA3UEEhhLq7H95lg2K8HzMHvKA8406lAapvIJ9peZzb+T yKn8ZY2RjT/Pzk/EPRkwm9bRtg== X-Google-Smtp-Source: AMsMyM6sOMM8c9ZZEY2Az0U+JOTira4bXTDGeTcKa8WT1mv/7lKxMh+j3GvkAKgsr25bnGbX/aRaJA== X-Received: by 2002:a05:6000:1051:b0:228:e1a0:7221 with SMTP id c17-20020a056000105100b00228e1a07221mr16362532wrx.165.1663753440186; Wed, 21 Sep 2022 02:44:00 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.43.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:43:59 -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 v4 27/30] thermal/drivers/acerhdf: Use generic thermal_zone_get_trip() function Date: Wed, 21 Sep 2022 11:42:40 +0200 Message-Id: <20220921094244.606948-28-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 6C46EC6FA8E for ; Wed, 21 Sep 2022 09:46:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231553AbiIUJqY (ORCPT ); Wed, 21 Sep 2022 05:46:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231827AbiIUJoH (ORCPT ); Wed, 21 Sep 2022 05:44:07 -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 F33AA93216 for ; Wed, 21 Sep 2022 02:44:01 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id v3-20020a1cac03000000b003b4fd0fe6c0so158309wme.5 for ; Wed, 21 Sep 2022 02:44:01 -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=ogHqoEENLPo5SoQ9S2Vi25qoB7gOOZ7+XSWy/Dw+YQUbu9gjo1fQvdRGCGzO8xBaEC cUf80Vt9k4k1Exyo34PXuipr7TvCKnBY1Wloo5hQdoa6x6ImrAAhw1Viii4Pmx+ZcG29 W0VgIBLgI9XNUDQQ+qVSaz0aje/VH9ezpZuV3ivcdnclZOFalH1UE0d3vBNioLO+KJCF PYP0tHowrPBXKpICwXGCBuLzurxmqQTh1OpSp0MgaKAVBSDL8Vwe/VeIDq4jptrLDa0m KigVNq0LUJqqlXiJqopQPCYWEw889Doji96nrPtTeLZNHJ5iyUor2LWZO2u0HeI4omW1 P2vQ== 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=HgBwChe7ncDsjk6XQt9/3CLjF1Z8o47J/wKaKXIkGbxgCtPGDX6sWy6NC4lFnLXdIN VL7Oua9WdMfwXMOD9J+43OA5sXOhHdLcJQ38a/kqYrNApbThH1M4+/ZHw4TPplfybfPS /9FceGCrOf/xFQySaxQqe0+dM40VsXx/o2Y8itLQRIZuT98ZT/AddiHCC4qZ++vRHbZE GHilGrpYOg5aMKgSyPI4xa8TwPgwVGfaStjOmpj9eyMtyzgACpNucBC7MVsseSz7NnhV 76BNFC0Rpr8V0GVnLU04E/U9QbpktPJkmuDaI0BjX/DgYVXLZHUKXD00E0ZPT0CwYcu2 Gcfw== X-Gm-Message-State: ACrzQf2BD8MeWwym/Hujyn18R15NyO5PahaBr7OegHFALNibWgd8gJSg zBrN/JLIDcwPMqBIIrVks+J2Yw== X-Google-Smtp-Source: AMsMyM58Z8/99S2gEqNRt3pt4wFPxXB4uXZRW1kZiffVxq+pcNC/TDo9mB2ziCv56t7Ctox7Gt7QqA== X-Received: by 2002:a05:600c:1c19:b0:3b4:c1cb:d46d with SMTP id j25-20020a05600c1c1900b003b4c1cbd46dmr5226287wms.172.1663753441506; Wed, 21 Sep 2022 02:44:01 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.44.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:44: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, Jakub Kicinski , Raju Rangoju , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org (open list:CXGB4 ETHERNET DRIVER (CXGB4)) Subject: [PATCH v4 28/30] thermal/drivers/cxgb4: Use generic thermal_zone_get_trip() function Date: Wed, 21 Sep 2022 11:42:41 +0200 Message-Id: <20220921094244.606948-29-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 B1103C32771 for ; Wed, 21 Sep 2022 09:46:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231927AbiIUJqe (ORCPT ); Wed, 21 Sep 2022 05:46:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231338AbiIUJoZ (ORCPT ); Wed, 21 Sep 2022 05:44:25 -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 EE53593226 for ; Wed, 21 Sep 2022 02:44:04 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id n12so8876521wrx.9 for ; Wed, 21 Sep 2022 02:44:04 -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=G+CeFcNCH2CKkENy9Wbs5iCK8XF4BHT27zkHlg8gEqcmPUEiBlueP004t3GkOWH3sK XU25lyzPT9vFjSlagDgOpmqkWR30FaRUl41tk/bFKFYsxjQwnqJGb+/auRX0exU/qOfC zrjVGBY0jSiEdT2QiiGn0aZ8OByJ9iO78ivFhVFTZtKkJJziVqNzSvlO2vmCx6CPRCVr jz2WhGZabdGwGbjfzXQSPC6k4UXlUPJVOizP9NkNWISSMyUwj1Hg1kImDIqP4KLBEiSy j43XZaZHkPugIIbk0g7rMZ58apdkBzV5++Q+YEi0iQZj2TTLk1jPo5dLvoYxm/lv096Y X33Q== 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=4b7pJFY6tb1qDQeIHOiQnWNi3eO/qTpzsyzFWb1zahTZjAwxteAsEoEkqS5PxrNcS0 wL5ECQ8tjdh3gDv7liMA5asXJWkXoEAN884al0FLtNvJg6ObJJprE1l63SQE1IoQkI8u 0n8e+PxqYUmDiQPHnCatxqARX9x1biiOSuOFiwGTYc9nvqbsCa/scUare6uRhDWK1zSy o3Wa7iUdJ7CmGEKPUpynWG8qXvNr+wucopx7UK4a+dWIcWhlgtHMsbrJOdZxuL/3+2YJ 29pdxHopMUq+Tyvg+u/Bhom7ZPlpPTXzXrs0MNUIH+U8rIUH0DWJQo1KV+4rzDMBZvvy 0d2Q== X-Gm-Message-State: ACrzQf23Dc/HBQVYHEFdCpvHQYDxVgMpuNp8WcDtq+T7KGadLP5uo9b5 k4HqE7cyOqenJSsZLTNnltTCG05fxtaJQA== X-Google-Smtp-Source: AMsMyM4+hGLUu9pr1xrTn3EV4qiO2mreNCk92f/pPhJuNg0x7F7GLynzRvMsDKxuyFry6dPVKSF6RA== X-Received: by 2002:a05:6000:1d9d:b0:22a:745b:9f00 with SMTP id bk29-20020a0560001d9d00b0022a745b9f00mr16510473wrb.280.1663753444336; Wed, 21 Sep 2022 02:44:04 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.44.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:44:03 -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 , Antoine Tenart Subject: [PATCH v4 29/30] thermal/intel/int340x: Replace parameter to simplify Date: Wed, 21 Sep 2022 11:42:42 +0200 Message-Id: <20220921094244.606948-30-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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 Thu Apr 2 19:54:44 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 BCDB9C32771 for ; Wed, 21 Sep 2022 09:46:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229980AbiIUJqo (ORCPT ); Wed, 21 Sep 2022 05:46:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231807AbiIUJoZ (ORCPT ); Wed, 21 Sep 2022 05:44:25 -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 C114493231 for ; Wed, 21 Sep 2022 02:44:06 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id k3-20020a05600c1c8300b003b4fa1a85f8so849763wms.3 for ; Wed, 21 Sep 2022 02:44: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=xG1f2CQif+pNWsZ405kq05pJzbYuR72YhBpkdKF14wo+WNlpGgHtvYODC97eKDjwmS iTdViefZEBDvMcMOBNOt9/J++cfbbTM3a3XTkEuIYKdfuf/2DaA2onmVhAJTPDwvqgdg 0HXVy2IV3J/LIp92miRAq7h7BtSfl2iQtOSStYHYeWWyRVzdTufFWcICuNYrftOE8nrb ZXHvVWKPnOibLPMeeSzJC2H1FdkhX2lydpq8P/bt24rR2fLb0u2QJD1z3CKOKqRUSRTs LuDQlCfhUZAyJLQfnpbjlJ4N67o2s8gvsOd67vfNjPZ/kGTqBRLr8hxu3D9DvMHSlPfO ki8g== 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=QgteCHOxofKGYSbyuXsfFNlV8LS3k2OVs869ZnbuQnubw/e8arvJCNyo9BHeTuuKCD QgF+KXNSkQroSklbAOEdQpnPEPozL3ydhPz/OHxEsqHhwSNrAgE3OnPb2xhvlZgOTKze tgnFw5+6hLE5TiJzaJtZGjWPX5gBdqvM7EpXT8SeZOCZxzXA4sjGEF4Ya2i0YXPPSMTo 70A+wRI4GqRlnS7Pdo0OoCigypkC4wgScPDl1ld8BT+hVvEPpMugp+YG9Mh+h7elZrne S1BSpdUgDM1rkvA7cDbfROZ0GSitVZVDKhI3JGWDs3z+/ExhhL2kNSc+dNEGMVOwpGZm oqUQ== X-Gm-Message-State: ACrzQf3oUmEVWHYgXKuj/FULotEN2wLs6l//lXxROcgmm69ed4M5/xT1 xJ8ReJLHghL+39BI8SRXQ4ZGOA== X-Google-Smtp-Source: AMsMyM60i+9Xvh/4CXGn8V/CfG288kD+DUyA5IRHPsj4urHE8ej8o9H5Ln7Ma7h6DzKUZ6Z09dQg4w== X-Received: by 2002:a05:600c:3d8e:b0:3b4:a61c:52cc with SMTP id bi14-20020a05600c3d8e00b003b4a61c52ccmr5472880wmb.7.1663753446060; Wed, 21 Sep 2022 02:44:06 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id r123-20020a1c2b81000000b003a62052053csm2763917wmr.18.2022.09.21.02.44.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 02:44:05 -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 v4 30/30] thermal/drivers/intel: Use generic thermal_zone_get_trip() function Date: Wed, 21 Sep 2022 11:42:43 +0200 Message-Id: <20220921094244.606948-31-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220921094244.606948-1-daniel.lezcano@linaro.org> References: <20220921094244.606948-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