From nobody Sat Apr 11 15:28:08 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 9CF25C2BB47 for ; Tue, 9 Aug 2022 22:05:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229820AbiHIWFK (ORCPT ); Tue, 9 Aug 2022 18:05:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229684AbiHIWE6 (ORCPT ); Tue, 9 Aug 2022 18:04:58 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EF73F5A7 for ; Tue, 9 Aug 2022 15:04:56 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id j7so15786174wrh.3 for ; Tue, 09 Aug 2022 15:04: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; bh=72yNggrXYncxa0ZMrFg4FnZQ/1fgWA3cdk/X57DF3Mg=; b=ne+KAmbCrpntUQWrPy3ItnvT2wGrtXto6IlRX9aP7igzhWJkf/cjjuR1Ye1TfX/djE P2FoUFozTSgbKnT14sJpT+gu43tmOFH9X4mtjuB8FlPSvdjzmOFxw5GaoGe2Aug4fJez HFxPou263xYQa83KH7EobLewrVO7FgNcRtUaYnq5Avwlzpw7QSDA3mUXgV/OOc/hPvn8 pF6w8yQ9oJuN+YaATsPvKw+490q4M59+rzOUvD4Xbso5jV4iDTir6p2eSZKqWUSfMEaP mlpPC7ZObBTSXAODFkUUCDERyzwDod7aAS1qetdANknuSajaa/gY/jjRwnm04rY4+FJP PEyA== 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; bh=72yNggrXYncxa0ZMrFg4FnZQ/1fgWA3cdk/X57DF3Mg=; b=N/bmYMuBkI0rE9/V9CgDBUHJoJsOHDwDp0+Bs1ckxsR4X4bS7P1lgFjKH0M5kdobMu v2d3IsY8CiAFtGFK9lFyjPT6nTW9ojPB9c77J5g8Yx1IhQQhbsDxSLZHnmT1kdKiDwQz WbDH6KMrB+9s0w/dymS59FjRV8LE1c5pnksH+xq8Y9wIXI2TrbQuXjsgqSyfkFjtKtyF yt6JqDcRWd1tGc4Wy7mNwox8/SxEZ74WAxq0a7EyZUkFW42SLIzupIKj3prEUwHkwOkB pyoTug2uJHnFYYHjSLkVCsvU44SPjOZPHC1NwtZTeHRwFgiTCRSA0cbpcDH02L55xyiI 217Q== X-Gm-Message-State: ACgBeo0gfeArTKpkFSxKPNU+At0el5S/OEvwXh3xbUOzbwksmZHfUY5y 4a9vpzcNvxxsBGJmZVbw7fiRXg== X-Google-Smtp-Source: AA6agR5BrLFUKPRiElxUcvEqU8+T6nZ6yLx5S7ZcG6zMUn6QiunFnprGxL0HgyAVNqDdLNk+2PlIKg== X-Received: by 2002:adf:e0cb:0:b0:21e:9ed9:d862 with SMTP id m11-20020adfe0cb000000b0021e9ed9d862mr15484006wri.518.1660082694333; Tue, 09 Aug 2022 15:04:54 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.04.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:04:53 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria Subject: [PATCH v2 01/26] thermal/core: encapsulate ops->get_trip_* ops into a function Date: Wed, 10 Aug 2022 00:04:11 +0200 Message-Id: <20220809220436.711020-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 --- drivers/thermal/thermal_core.c | 69 ++++++++++++++++++++----------- drivers/thermal/thermal_core.h | 8 ++++ drivers/thermal/thermal_helpers.c | 28 ++++++------- drivers/thermal/thermal_netlink.c | 21 ++++------ drivers/thermal/thermal_sysfs.c | 66 ++++++++++++----------------- 5 files changed, 103 insertions(+), 89 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 10c979dce512..5891b86758c1 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -354,35 +354,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); /* * Alright, we handled this trip successfully. * So, start monitoring again. @@ -1162,6 +1158,34 @@ 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_trip(struct thermal_zone_device *tz, int trip_id, + struct thermal_trip *trip) +{ + int ret; + + if (!tz || trip_id < 0 || trip_id >=3D tz->num_trips || !trip) + return -EINVAL; + + if (tz->trips) { + *trip =3D tz->trips[trip_id]; + return 0; + } + + if (tz->ops->get_trip_hyst) { + ret =3D tz->ops->get_trip_hyst(tz, trip_id, &trip->hysteresis); + if (ret) + return ret; + } else trip->hysteresis =3D 0; + + ret =3D tz->ops->get_trip_temp(tz, trip_id, &trip->temperature); + if (ret) + return ret; + + return tz->ops->get_trip_type(tz, trip_id, &trip->type); +} +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 @@ -1194,8 +1218,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; @@ -1222,7 +1244,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); @@ -1272,9 +1294,10 @@ thermal_zone_device_register_with_trips(const char *= type, struct thermal_trip *t goto release_device; =20 for (count =3D 0; count < num_trips; count++) { - if (tz->ops->get_trip_type(tz, count, &trip_type) || - tz->ops->get_trip_temp(tz, count, &trip_temp) || - !trip_temp) + struct thermal_trip trip; + + result =3D thermal_zone_get_trip(tz, count, &trip); + if (result) set_bit(count, &tz->trips_disabled); } =20 diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 2241d2dce017..194e98a5b102 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -110,6 +110,14 @@ void thermal_unregister_governor(struct thermal_govern= or *); int thermal_zone_device_set_policy(struct thermal_zone_device *, char *); int thermal_build_list_of_policies(char *buf); =20 +int thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id, + struct thermal_trip *trip); + +static inline int thermal_zone_get_num_trips(struct thermal_zone_device *t= z) +{ + return tz->num_trips; +} + /* Helpers */ void thermal_zone_set_trips(struct thermal_zone_device *tz); =20 diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_he= lpers.c index 690890f054a3..626a70d70567 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -79,7 +79,7 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz,= int *temp) int ret =3D -EINVAL; int count; int crit_temp =3D INT_MAX; - enum thermal_trip_type type; + struct thermal_trip trip; =20 if (!tz || IS_ERR(tz) || !tz->ops->get_temp) goto exit; @@ -90,10 +90,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; } } @@ -127,29 +126,30 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_temp); */ 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 mutex_lock(&tz->lock); =20 - if (!tz->ops->set_trips || !tz->ops->get_trip_hyst) + if (!tz->ops->set_trips) goto exit; =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) + goto exit; =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 3c513561d346..2b53927f3263 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -79,20 +79,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: @@ -111,37 +108,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 @@ -153,21 +144,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 @@ -205,18 +192,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 --=20 2.34.1 From nobody Sat Apr 11 15:28:08 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 6EA69C2BB43 for ; Tue, 9 Aug 2022 22:05:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229613AbiHIWFG (ORCPT ); Tue, 9 Aug 2022 18:05:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229706AbiHIWE6 (ORCPT ); Tue, 9 Aug 2022 18:04: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 0B1F2FD05 for ; Tue, 9 Aug 2022 15:04:57 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id bv3so15738867wrb.5 for ; Tue, 09 Aug 2022 15:04: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; bh=RscIum3lwOQWXIrcp1oY+m6OrdEEekgn0AWhfm6yIUI=; b=K6F4dQEZJMYate5rS22n6XTtEL0i94DXlh3UVJpE7WqW1lvQP+cguYzWUU0CF9JC/1 +JpT4FGmL2nD0Shk8s2U6C/vLP9TMQ7sEAyhiKXmuFFch9p2EB1INaP0jHc1sagsbNzq siNcowZXLP69RK+Ne+pP/FHN/R8TyHhydVDBe+/EhM4yYZgEv35nqnO1WTgKeKpCUCzc MTIuNF6b7VAeESXqwqjGdP2SDpK5BVyd8OMsQZFlyOpKE0Lxc2e37tlzS+BTMUCHONTY gbIuaDMm9qCupBgmrWCKSorFOrtoxlyQEQveODOil87ShCy8OXPF0OmAC4DZjKySf4yb DVcQ== 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; bh=RscIum3lwOQWXIrcp1oY+m6OrdEEekgn0AWhfm6yIUI=; b=XDSADnpklsIGQ/pZN1xqGaLuR/ubVdzUx3UVLii2v2UmUfurTSeJJlIrM7idN9Z6Jk UJi35s5mVGjFksg0AoZOMhj4/nPh552PEtXeHFUrq3uVi8bOYN+hJVE9KRBv01Ar8M8r AB0jHdb6Xxiljl5m7nBcjbz4QYvk7tbGCWUxgKHnUlwJgcUm0ZT32xeVfUOO4sSd2c4T +TwID6dSVocnVHW1wbYLIXq1Qdga2ABwfa9NX+s9FdAmCbNyelAdAEqNk9AFTbdheUGR k/HsGabD7a8bIuZlF4XtDjUl6FpNkGfsycE4rpzaVbJsk2vgfMV/iInH3JgLcVHOyIQJ VaAQ== X-Gm-Message-State: ACgBeo1+OqF1FfMMf6kiZxHOTbHFv+6vEhdtOcVwRsqOr25WiDez85Ym kI/ZlVYjhBSnjMQNFO7IdfPoeA== X-Google-Smtp-Source: AA6agR4BYROaqB1HYsHe6kKmwpxlSBPXwDMMzJhkcbbaqKWJToljtQAjJvocPabq72DsluGZi7IBkQ== X-Received: by 2002:a05:6000:1d89:b0:21d:5655:eb72 with SMTP id bk9-20020a0560001d8900b0021d5655eb72mr15507032wrb.110.1660082695518; Tue, 09 Aug 2022 15:04:55 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:04:55 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria Subject: [PATCH v2 02/26] thermal/sysfs: Do not make get_trip_hyst optional Date: Wed, 10 Aug 2022 00:04:12 +0200 Message-Id: <20220809220436.711020-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 2b53927f3263..bc3337826ae2 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -420,23 +420,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 @@ -469,9 +466,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 @@ -508,8 +502,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 Sat Apr 11 15:28:08 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 1684FC2BB47 for ; Tue, 9 Aug 2022 22:06:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230058AbiHIWFt (ORCPT ); Tue, 9 Aug 2022 18:05:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229769AbiHIWE7 (ORCPT ); Tue, 9 Aug 2022 18:04:59 -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 82F15B862 for ; Tue, 9 Aug 2022 15:04:58 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id q30so15717966wra.11 for ; Tue, 09 Aug 2022 15:04:58 -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; bh=faENzfdLEIc3OGEyTrIL1keHRAXh0simrj9p3sTfVj4=; b=vQha2B/RbJTWKUqLHpayEnyR1V5iOcpkdXlfRFYTl3NqCP5HHdD7hsCPi5K34owGY6 vdonwUQL0BfWmp1uZBRxefZZ1HW8IsFIQDbdZvH3sxJaBh88I3Ly3qyl5QlTEuzHOnII lgjoR5nEN9YhzF1WR6AwH3rpuf99XQ6Ejei0vkpN0V73DzWF5fXKY6tc8GqRuDEjWuvA NqXv9qXsRtjCHHChk077EAIFD9k9DxwayYtc5X3kArEyXlP7M2mz4JN20YIfhz4f8aYR NxEmXL3ZKWdlAjzUErz/QaGjJq4gwN2atZnUpCITdufw+VJ0QCR47WHrwZnC0Gbaa9sY k3cA== 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; bh=faENzfdLEIc3OGEyTrIL1keHRAXh0simrj9p3sTfVj4=; b=Gbzm48b6ai+dLW0l+MWVy+A5G9DlTJA3XixYLNqLHL9THh2G8IXlPHo25i+oFhBzHc F6T+0o74dCXh5NdoPLoPfNxurAYJf81kUVjKkokUVoK4Tjwim4mVYg+zJ331gV5qG+zL yDT4u5Gu5YVYefGo1PghSm85DC13FMjB3g8r7Hd9YY/AQPGSa9E89wq3GEI+ljK8VO2V fBdhlaYS+piYya0O1EJngkJ0W2a55iM0VI+pK8ljrQ54Tiz63PkYKLx2HyH9uWyGBdt2 qjQV95VcpyYfhR7gnK/IA09WMG964oOF2ak9Np/70A9dgtV2aHjlLro4aw3OXj0Gdj4D FdYw== X-Gm-Message-State: ACgBeo3jbVl37+Wu73cr2KcVZQocR0GPmgAUkTMwVIYgrYiYYkVR+tkr MXwjN77k4xuQbUf7OuNNzL6Zyw== X-Google-Smtp-Source: AA6agR7H4dt/ZjseY2Pck65pRVm8zwgAliekIX9+pRzmTS+3xbSj3apLPy8MAqTSnGF2vRomKYGxwA== X-Received: by 2002:a05:6000:1ac8:b0:220:6af3:935d with SMTP id i8-20020a0560001ac800b002206af3935dmr15260864wry.549.1660082696842; Tue, 09 Aug 2022 15:04:56 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:04:56 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Lukasz Luba Subject: [PATCH v2 03/26] thermal/core/governors: Use thermal_zone_get_trip() instead of ops functions Date: Wed, 10 Aug 2022 00:04:13 +0200 Message-Id: <20220809220436.711020-4-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 --- 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 991a1c54296d..de59ea9e2f7b 100644 --- a/drivers/thermal/gov_bang_bang.c +++ b/drivers/thermal/gov_bang_bang.c @@ -13,28 +13,21 @@ =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 mutex_lock(&tz->lock); =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 */ @@ -52,10 +45,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 6a2abcfc648f..877d52605871 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 1d5052470967..54ba05d532db 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 @@ -528,10 +527,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, @@ -539,14 +538,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; @@ -643,7 +642,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) @@ -669,13 +668,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); @@ -705,24 +703,23 @@ 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 /* * 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); @@ -731,16 +728,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 9729b46d0258..886016c7cd3d 100644 --- a/drivers/thermal/gov_step_wise.c +++ b/drivers/thermal/gov_step_wise.c @@ -95,32 +95,30 @@ 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 mutex_lock(&tz->lock); =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; @@ -134,11 +132,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 Sat Apr 11 15:28:08 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 8DB98C32765 for ; Tue, 9 Aug 2022 22:06:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230076AbiHIWFz (ORCPT ); Tue, 9 Aug 2022 18:05:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229781AbiHIWFB (ORCPT ); Tue, 9 Aug 2022 18:05:01 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D8C1E00D for ; Tue, 9 Aug 2022 15:05:00 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id c187-20020a1c35c4000000b003a30d88fe8eso126578wma.2 for ; Tue, 09 Aug 2022 15:05:00 -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; bh=p+Fs/P7gXsm/5qHeFX0rzCcy4XeIXDeOEwU0TTt39+U=; b=Q10d+Kj+4+QxPnASk+OFQkMzHet7iJEXepHq9lMZ/GsOjz41BKrdhSTNwCO1ITIyGG Ue/MRMgPagk/uraL1/ICfJGRDzXV4JR70963kdB41Il1yEQ7dq/KS44IFgWwLfgaxDla RluTYe88k6LbQ7tvibgpSEsxkwQiyvYndL7PHn+QrLSeRIeyLg8rbXXcQJngEIWKMWXo lIIh/BO2YztdinupBHIFMte1EZ4Xj9FS5MVkDpoB7SBIDyhGapYV6o7bsAjppxQu6pZL 4IJVGhg1X+5E5OGdBCM2aL1nJ9xetphQ/m9YcSwcMYJEb/t3d2URg77u1CyeiQRvM2cn IJzQ== 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; bh=p+Fs/P7gXsm/5qHeFX0rzCcy4XeIXDeOEwU0TTt39+U=; b=hUMpZaOSmap3hQ+shynJMrph68r1viUVPgp3+EasRDgC97gTgYqiLz+cbuSiXEx1R/ 2Z2eKQa2w9GLyiD70EQyMSHQxWeWzphrKtix/ka9IPXObuBL+a94VoFHhpgw79lSieWj Ol2hpRU321GHYimVn6pTsZKSUDS7DnQSRKfQ+7lwfYTJEahruURK+LnO1y7FLGcxEbSa f4g3xtOqJohtRbUj+ot37LrVJhVU22fMpWBugtFzT5tr5wp3sV3s1lXq3B4OHp9IhoH5 OSAiwqj3hWkEsO3f0T85IHEpr4m5jIYLYqNKVF1p13xiW0IrHFgOUjmkAdhDKbEql9i/ qZGg== X-Gm-Message-State: ACgBeo2qctQnifP83KhX3etBfh5xfrSLucK7FxLecDwte0lXTYFO58XJ okSMQSCFQhhnfEMQvdDyfVAD72xg/VDjaw== X-Google-Smtp-Source: AA6agR5CO+KUXGsg/6WoplZ/mFRti+YTNqdCa1P1PXUwBEm6Au6L8KxbMD6+x5Sb8PTDWwU5FoVH9Q== X-Received: by 2002:a05:600c:3b02:b0:3a5:2460:f059 with SMTP id m2-20020a05600c3b0200b003a52460f059mr266889wms.129.1660082698606; Tue, 09 Aug 2022 15:04:58 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.04.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:04:58 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria Subject: [PATCH v2 04/26] thermal/drivers/st: Use generic trip points Date: Wed, 10 Aug 2022 00:04:14 +0200 Message-Id: <20220809220436.711020-5-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 Sat Apr 11 15:28:08 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 4468FC3F6B0 for ; Tue, 9 Aug 2022 22:06:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230028AbiHIWFm (ORCPT ); Tue, 9 Aug 2022 18:05:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229582AbiHIWFE (ORCPT ); Tue, 9 Aug 2022 18:05:04 -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 79BABB862 for ; Tue, 9 Aug 2022 15:05:03 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id v131-20020a1cac89000000b003a4bb3f786bso138929wme.0 for ; Tue, 09 Aug 2022 15:05:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=XsxTgl9OJhYT/B2dXFDz/rl/9WpF5J4y9HKMzylFxc4=; b=d9+OHlBFphzloY6wEELe+yRIgxmD3nNCY3tRAfxpL6p+TeR4hbO2XcQYbFbL+H90iT oUwWHhSa40nHWNDNqJ39gRQOUIS2WmTh+WnMJrFYz0guAPmpumjp6keJC1sCHesHWFC3 3b/SfrKCx3dQkJzzlmvWEmcP74W6APMUDybCM6k9dK/9g7gDSWO9t+DfhDmOgAQ5wgqM 0cFqDWuwLAVoWkb8S7ZWC4PPj55xdnnGT17T3XYiLxp6veI036XANXrMxPgQIMS1Rw5Q Bk5Xr6FQLfrGhmD+8v5APsxAJgX/jN4/KGpWGTQv9dAHsNV4809eDEfioT/ZmmfiEgWo igvQ== 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; bh=XsxTgl9OJhYT/B2dXFDz/rl/9WpF5J4y9HKMzylFxc4=; b=A+bUJajB7JoxhX9F3Zyk8D8bHx4etBwRTTr1ioxN3sPm/BzcoRRltq778orXZ/u9b+ KCjYSgmzDKL9HN37OIPvSbNnTdk9znzH8VOXaSJrlup9ZKnNkLkCYolnOGpomTZFevmg 7Nov8iwmozwEaF5YoO6GgwUphrJzPil9FV2jsGCz2F9+Nad+Hl5J/+LxwnlJ+45US9Fs RZx0ARj28nXJEHU2T6NxfD4GuqTvzCod5aHU0b2AYSmOMP3Ke2f76ACdLuDrIUrV1f66 I5pc3lYCECknXatOStKfhLdgNgnSSo64bqZ4fNnmwlcSQF2RjvkEo/Q+jQqfn6MsqorU SReQ== X-Gm-Message-State: ACgBeo1EYdnwgIge78FhzOMFaj0ke1c9+U1VCHw1xypXpfbRw7CnFyvU +afZYGpS/2QESwAn7Q7uNe5fwA== X-Google-Smtp-Source: AA6agR53msdu1DjtOBl2XYk3uzVsG5JtKlmAb9LlkHKszuAvebi3yFUmkf6Va0e11OJtBbUxwkU6AQ== X-Received: by 2002:a05:600c:5029:b0:3a3:7308:6a43 with SMTP id n41-20020a05600c502900b003a373086a43mr254415wmr.99.1660082703013; Tue, 09 Aug 2022 15:05:03 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:02 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Thierry Reding , Jonathan Hunter , Dmitry Osipenko , linux-tegra@vger.kernel.org (open list:TEGRA ARCHITECTURE SUPPORT) Subject: [PATCH v2 05/26] thermal/drivers/tegra: Use generic thermal_zone_get_trip() function Date: Wed, 10 Aug 2022 00:04:15 +0200 Message-Id: <20220809220436.711020-6-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 Sat Apr 11 15:28:08 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 E81DBC32768 for ; Tue, 9 Aug 2022 22:06:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230101AbiHIWGB (ORCPT ); Tue, 9 Aug 2022 18:06:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbiHIWFH (ORCPT ); Tue, 9 Aug 2022 18:05:07 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C57AB862 for ; Tue, 9 Aug 2022 15:05:06 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id a11so6920322wmq.3 for ; Tue, 09 Aug 2022 15:05:05 -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; bh=xYvlHjUzJ1gAdl8KtmAH0mCHcP29B+tCMOTUThwt7jg=; b=IfxKVt/JZ0AOJv+hwBANodMmP0Ryq13MqavjzhwHj9nPDUIwIcSjlvt8WM9wh1hnyY 6XjsLexOMG+AvFRutSNjLAcDU5fS8BKfx0qC/Um1NDO2Z214hJ6IoAb56tiVLw/2htIg DLGBl94Kuwzb4dGPT3ouPX6WEn57GGPIN1e/n3q8mYSzLL2ms3+CzMhhVQhLYjnA62F8 ZLd+hSq/+dElNl/zHz3lPRNhhBBiVjGKMvnaGrJKATWdJYI0UYQV2d0G3/jayPY2Gpvl SZE6cJMHncQkGk0VfTdukdhc/DDHYMgP0ZLkNDx1V2jfcoRjTjyl/+XOW04l33oPiL1o fwmw== 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; bh=xYvlHjUzJ1gAdl8KtmAH0mCHcP29B+tCMOTUThwt7jg=; b=cdIBu+ZSq3r1O1EE0qMGtDeieF/RVG/6S/fvPVewaur6o76t9MUSM7vAkpfMfBjQWy pdc6GGGYPWRpKjaNL8p49aCLEIsD5KKO1rBhGp/LvZ2LTFIqu7jOvExlOObcUTrj91Ik j7sVlviq3hopPFMnJr9I4bG65tcSPoCL70bYR+33+8GnIIpanYCrN1l8TBwqmLWLMRzy cN9FsSWW3tm2OrhPFg5iB0nq2m6ULJAWf+JgL84Mq/qDo9EdyI9aQ0vd3GH/7dE/UwC+ Go1GVErnewivF3XS9hld5TMeaQtHhycoHnU+jayvvlUp1nc9ts9Le3wYgGptoF46YE4t qwOQ== X-Gm-Message-State: ACgBeo1m8Tvpwb7C4BjgN5vLRvnQWbY/ca/s7c//R7G5NWjJZQf/3+45 UPqHuF6N9sWwpuGpRXaRE/+5dg== X-Google-Smtp-Source: AA6agR6oxMWhcDAvzsX5CTgXZ9ExGxmdqb76msJzsVDXEQFT1OLZB+jFkDDVl8ZOLXOJP1HhWtDUKQ== X-Received: by 2002:a1c:ed05:0:b0:3a5:3af:f5c3 with SMTP id l5-20020a1ced05000000b003a503aff5c3mr284834wmh.52.1660082704400; Tue, 09 Aug 2022 15:05:04 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:03 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, 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 v2 06/26] thermal/drivers/imx: Use generic thermal_zone_get_trip() function Date: Wed, 10 Aug 2022 00:04:16 +0200 Message-Id: <20220809220436.711020-7-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 Sat Apr 11 15:28:08 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 E6D2DC25B08 for ; Tue, 9 Aug 2022 22:06:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230112AbiHIWGE (ORCPT ); Tue, 9 Aug 2022 18:06:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229791AbiHIWFJ (ORCPT ); Tue, 9 Aug 2022 18:05:09 -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 6478DBC33 for ; Tue, 9 Aug 2022 15:05:07 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id v5so6943306wmj.0 for ; Tue, 09 Aug 2022 15:05:07 -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; bh=TF9d/nemwW4seLDRwY31H3s8bycRRHtQhzma4c2u+BA=; b=nPiHnTftf153bX1UvWEkGGxy9RtvfKmFaMLbSUzn4T7fFJy76RV3cljGGmzSgVsFqm se5DM7yAGmR9aNVYxSiK/I1Dk8nIPd8eQqjXtA28Mx5DyNhiELphXepURBCY/LNjNWBK IXwTvq8RcK2N14Bi7FE6O/GY02EyzTF1Jum/4rSCujvm/f89gv094iiGPH0FAlWnF7Lm QsmMBlo79OKm0Pgm7LzyEsJwUTRSZd7Ewre4f0uv1bMAgh73jAs01J0/nDn6SuV2xSEB nsVDkadIuPAgioGqvvIylz/CnVJA0g3PRFDq1A5En8DSnUtFHzGxj3VMVA5f4aQ22OD2 zCHQ== 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; bh=TF9d/nemwW4seLDRwY31H3s8bycRRHtQhzma4c2u+BA=; b=XvpyZkoerIGPVgcWvmk0b3ZV2cxb98S6If4dn2H9dfQzSLtkfOzcjDl8XGbpFyWYWG O4WCk4Qq/ByG7n7I1EaPXcGSVxChZwaF/LXnAFDl0CRNl5fbKjPKsXT/bzDn4qSdjerA LL2sWl9x45ZYMdGWykk2yWNtK30JGaEuGKGywooB3GHjPeMndfSNIMKi3HWtJenzDcdV SPlb8lC7VboSWDA8iIh3IpIgZPka1xof54c0WJhizcy276idhk9jSnG9n6xhtJftzWC9 kE7n30B9KzZdTI4aouvF/vmob9IDc+ah6aJ5wu/UNJtSvojS9gFdQJx6LKCcrNKMgKWT N93w== X-Gm-Message-State: ACgBeo0DG8+Jdf62ZQbGro6QF+fdiBrVSjS3HesWv4mNdiOory+BhlJv SntbaLi1A4dT+RbAVONIjn/DlA== X-Google-Smtp-Source: AA6agR43neCLErly3cXAS2Q2X8N3HubTvn6N39SDVqept2mG8mtwXhWf8Y0r6hqglUkWUW0ehF1f3A== X-Received: by 2002:a05:600c:4e52:b0:3a3:33b1:7b63 with SMTP id e18-20020a05600c4e5200b003a333b17b63mr277467wmq.51.1660082705795; Tue, 09 Aug 2022 15:05:05 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:05 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, 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 v2 07/26] thermal/drivers/exynos: Use generic thermal_zone_get_trip() function Date: Wed, 10 Aug 2022 00:04:17 +0200 Message-Id: <20220809220436.711020-8-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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/samsung/exynos_tmu.c | 41 ++++++++++------------------ 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung= /exynos_tmu.c index 51874d0a284c..5204e343d5b0 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,21 @@ 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 (trip =3D=3D 0) { + thermal_zone_get_trip(data->tzd, 0, &trip); + 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 Sat Apr 11 15:28:08 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 89AA2C2BB47 for ; Tue, 9 Aug 2022 22:06:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230138AbiHIWGJ (ORCPT ); Tue, 9 Aug 2022 18:06:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229843AbiHIWFK (ORCPT ); Tue, 9 Aug 2022 18:05:10 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02C90B862 for ; Tue, 9 Aug 2022 15:05:09 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id l22so15764530wrz.7 for ; Tue, 09 Aug 2022 15:05:08 -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; bh=3LbT+i5JAOF13BKiDcy7sF/Ytx5HM8wW7yjSAT5yeTY=; b=cxtT92hK+noUuGFyDZmEbq2zUm+A2mKihLtpkMj83w4NhXc4OF2gtY0RwzaqjOObaz Wvjvab8q9fsrJ0Pa9HJ7wYon2fNcZDzBxfHAouIJspYTk3Z6nht5gcNidIvdWmUHItLt VPWR1N573S0UluAfKvguNUYag5i2zN3KW811cD156aBCZ64h3b2z2x0bNc1VFlQBvVOd jTvZqZLtI7fUKBbUZNcdo7qPho3lkM/KcsKsZI5zTQVD54ziIPxU/974TJBTQPB4lJqz ATWnN/guGvk5KPi3IqgD+FH2L4B4TMZxHLOV9ZmPRKlhjKnoHlAghRbwYrv3HcgZLcnp v/jQ== 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; bh=3LbT+i5JAOF13BKiDcy7sF/Ytx5HM8wW7yjSAT5yeTY=; b=UxiF57uunvKEgIaHUuqn03LuCl0v7meBTKJXNaH4WNodOMOFwt/IVb0vAg0MfpQsHi WymRewIe4SDcQNz5lWV/jR9OjL4gqwlrUDBP906wsSZOHNR4F7kzbhMRl3g49oI17ZFu FvRte/vDQzWEXGKkh2ZDoWCFAaqud2llAM3QVqJ5CKy8zWEjtyKrzKpXjKTOelNsH8J9 qiGkj7+TLFqeWPOLLBnhbZAw3D+hiKFXQ9g/eV0siG+LwaAIlnxqkAJRiGmK98k4TGP1 q0bRiWb1cr9ddVmnBGtbSI7nwuKTedbDD8ItoQt7Agv90CK4rnkLPChoiIT/L4a0Bo68 7GeA== X-Gm-Message-State: ACgBeo3ggwGGEsrVGwH2rnxqeBYPfFuUl1u/WcXijkwntLY/Efe/dXVt ZbCLBzU1QdtMHBEh+l99nhO5EFKrLvPLcw== X-Google-Smtp-Source: AA6agR5Cu6cdrOlw/RnQZUYMoANWaz5D83/mavePTngUcaGqLSHsiHAtOW3HoK/8j8EFCQ1yJzOrRA== X-Received: by 2002:a5d:5a94:0:b0:221:6cec:2589 with SMTP id bp20-20020a5d5a94000000b002216cec2589mr13883414wrb.336.1660082707471; Tue, 09 Aug 2022 15:05:07 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:06 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Amit Kucheria , linux-renesas-soc@vger.kernel.org (open list:RENESAS R-CAR THERMAL DRIVERS) Subject: [PATCH v2 08/26] thermal/drivers/rcar: Use generic thermal_zone_get_trip() function Date: Wed, 10 Aug 2022 00:04:18 +0200 Message-Id: <20220809220436.711020-9-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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: 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 Sat Apr 11 15:28:08 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 375F9C25B06 for ; Tue, 9 Aug 2022 22:06:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229484AbiHIWGU (ORCPT ); Tue, 9 Aug 2022 18:06:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229684AbiHIWFM (ORCPT ); Tue, 9 Aug 2022 18:05:12 -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 8CA51BC33 for ; Tue, 9 Aug 2022 15:05:10 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id az6-20020a05600c600600b003a530cebbe3so129248wmb.0 for ; Tue, 09 Aug 2022 15:05:10 -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; bh=a0tkxQ3BVQ7QDdW+F+13SmYlJx7XIUccYaqSyISXxKQ=; b=oNwW+r7s9GvOV/yExM5fCvQD3Qs3rvwgPpSoZbu3tJEGRoP338HKirtKIGVQfSKFSy 0/3XS5JLayFWC4qBIG0LEi4IuyTQ9TL4uXIR8GcPvflaz4C98Q8ZfdNaI7FBmOsOueef nibzX3Juw8ZvhokQ5mKL1xSjwDexH4ORUGAe0nnw8dbR5WJfS0e54iKy6PhRgIrujt33 8CG6QH6mvSTXUXxFBXKqfrF12GHdmuFDvH62aNlP/AhsP301TMAAhahaUIShxWprVqcQ NYdkMycJ0wVvWEOzH+g2T3abi8WqSLy7wg4EnRs5SAgonX7NTU9qRqQRhr0jIIWVSprN GFUw== 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; bh=a0tkxQ3BVQ7QDdW+F+13SmYlJx7XIUccYaqSyISXxKQ=; b=CvE/B09stYu+Nj4WV+afDcLFnG3jaOCamVgTo7S+W2CNI/7YxyWeo54KphQOeb9nZB EkjtGFme+zYX9MeFTY7cd72ZECptmM1RPMvwzGMEFVA5RS5PTt5dNOQ8LmM3SiRLgksz zX7BtUgHz7d90bgLyU/p13RxygOWBuRz7F29yeEOfga1vkHdpXSkMnV2j63Xx4+reVqf Ui8BGWCvEs7V/v74KCIJ7XzRZk6DpEMySybr57tvnT4tpVOTdAQnZE3jrhDaUxLGLW7C oUgx4bcIH9gwzCNGz5Uno8AkaLqmMsh0gLW+/GEP/xHw+RC1b05J8Qvp/tlir7MNX33s EG5g== X-Gm-Message-State: ACgBeo3nw4VBRSYkoSKMH/Miy4lhRc2Shg1ZjJ5DeMt4bx6FKR7mAyh0 jfCWGobNmO29ARIK5Y/EpCJe3A== X-Google-Smtp-Source: AA6agR604SuevAmE7qWjfqroYSOrm0a6UHax8u7NRuopKV2cKJFjhLpw437CPILQSdnsIluXDJfPqA== X-Received: by 2002:a1c:44d5:0:b0:3a5:4fa3:b260 with SMTP id r204-20020a1c44d5000000b003a54fa3b260mr260348wma.165.1660082708949; Tue, 09 Aug 2022 15:05:08 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:08 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Kunihiko Hayashi , Masami Hiramatsu , linux-arm-kernel@lists.infradead.org (moderated list:ARM/UNIPHIER ARCHITECTURE) Subject: [PATCH v2 09/26] thermal/drivers/uniphier: Use generic thermal_zone_get_trip() function Date: Wed, 10 Aug 2022 00:04:19 +0200 Message-Id: <20220809220436.711020-10-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/thermal/uniphier_thermal.c b/drivers/thermal/uniphier_= thermal.c index 4111d99ef50e..1675174480aa 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,17 @@ 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; + + thermal_zone_get_trip(tdev->tz_dev, i, &trip); + =09 + 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 Sat Apr 11 15:28:08 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 90893C32766 for ; Tue, 9 Aug 2022 22:06:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230032AbiHIWGO (ORCPT ); Tue, 9 Aug 2022 18:06:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229935AbiHIWFM (ORCPT ); Tue, 9 Aug 2022 18:05:12 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77497DFC6 for ; Tue, 9 Aug 2022 15:05:11 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id p10so15734090wru.8 for ; Tue, 09 Aug 2022 15:05:11 -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; bh=pEJ2fI5oyXSDkm4TFagk1yPb1z/Mu52z3/w3W5mIhos=; b=gukC8b/QtpzlyuOSf2HZMDcLd361sAiOCbFHcmG31rZ1AJIiFYQx3AYv9k4a07LNr4 EwTzmCGB9dRv3vMSW38S4e+z5Im17IsXi+Hjnf7kTCkmGOBj8WskYC4n0+Gi2ok09oTy fcNSe/CzoW6WL+FvBvNhNYRjBhyK+tuoj5rWZAjSoK73NtrFSMGRYT71Gmbma1O8CfGS m/NMqCmpqmtyseKI/HKonGeZNhRzzAEqo0PNNhlKJv56s4rLaW46DCNbNJ0HfqnM698n TbW+VIuLFm2MgZyqEwN1an8ICRK+EFPMy277KAmgQTXvzOMD5OrAaOuQ0pzi5twYSM2/ JYIA== 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; bh=pEJ2fI5oyXSDkm4TFagk1yPb1z/Mu52z3/w3W5mIhos=; b=m7ZOwWO5hDztORXVIjIsT2cmKyVTCW2KaDOrdkPjb/5IKQAasir4vR1SVPaTXMsCly tDK+16RpTLNIZyrWYEOcGaUcdmnT+eD2sKgUy/IvbpelEC5NjZ0h+NmGUnaw4hXn0LA+ knsxNe1nBIuJ4GeSGcykyYKa2V5VIkhRQkLAGm1Z36vu+usYVw6IIJvo1qDxRGVvbr4g fFSUJZwcxYJdmCOVYfHaN7Zscp1mu8tpNk0S6k02NB9vv/17c74XoAp4uhI3XG9BVvfZ TnNs5phvd0pdBjqD1niveY1PqLn2hXybX10550lzMx/AkhAuhdiUDBynKJ57xVHgjd9s 19oQ== X-Gm-Message-State: ACgBeo1OrmhL+C1TN/GU1bSykwbVvaRmzYKyWobk1DUsYwhs7eW1XxDD C/xQbrMMwD3yDMBloRR/s2i6VQ== X-Google-Smtp-Source: AA6agR42y1dsm01IqTnuE1ghurPV48QcVTLBaiYLz53iE4d+SEFarwylT/XtidEzeKRinG9/QyPYQA== X-Received: by 2002:adf:fe81:0:b0:21a:3574:ec8e with SMTP id l1-20020adffe81000000b0021a3574ec8emr15996076wrr.410.1660082710038; Tue, 09 Aug 2022 15:05:10 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:09 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria Subject: [PATCH v2 10/26] thermal/drivers/hisi: Use generic thermal_zone_get_trip() function Date: Wed, 10 Aug 2022 00:04:20 +0200 Message-Id: <20220809220436.711020-11-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 cc5da71b6f55..914dc73f4263 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -490,7 +490,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, @@ -503,11 +503,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 Sat Apr 11 15:28:08 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 AE7F5C32770 for ; Tue, 9 Aug 2022 22:06:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230253AbiHIWGc (ORCPT ); Tue, 9 Aug 2022 18:06:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229771AbiHIWFP (ORCPT ); Tue, 9 Aug 2022 18:05:15 -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 D2A53F5A7 for ; Tue, 9 Aug 2022 15:05:12 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id j15so15780042wrr.2 for ; Tue, 09 Aug 2022 15:05:12 -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; bh=/DpVb9+AKUGgq8A4EZDNel0xrsv5+R31U81PHZWHu7A=; b=peaXh+eEG5QHYmztdj96PE7qEz/UpxATK7V0Vf+VweXe5zhcDDmwAMl5qKeDZM6S0T ZN+fYhE4gzlCnRhQMXeIonK+MBUmOXEayUy0hYsnZ5tgm9WCgqBb/OH2qKDObnVFMVb8 +oaY2BQWMLGKmmI3NSURZg37gn7yHQrsuyUA2djRLpZBdgv32DpwGlVMBmwM+i04/u0r AybzcRMjen8PuB7syVvnQD2MUDeay9VcgjqQfoM344vkeDgov/JwH1UZ20d+wd/qd3xG PnsfVYf69ywTg/DaOi+IpCW2WltmBuoAg3m3cELi2ChntMc74VLbBxFzbLq2wS68kZmD 92Ww== 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; bh=/DpVb9+AKUGgq8A4EZDNel0xrsv5+R31U81PHZWHu7A=; b=2Z64s/dvBmGseReA/+gaLKpC1wTcRxe7lNbnO+4l22obYDVcl65GZicEN+sGVrMwCR 0bzhpE5ctS4hQC+WsAgV7tkzEoY2rCdV2t3ZW3giHvOzSnvaCUZvaIDzBoiExvmUPL5t Ksasrynf7l6Xf5ePCF1+2XrE/xfcE774e8cxAkNoZabpQPaqxA/QJ0lZXLBKsF4kmS4K IrqnO2MSRYLMBlzdNrQRf02Ttjd8BBNVndN2+s4IxDQ+YKcao203PmET+Yb/I/NAvJvg RT/NZLrVg8MV+jafPxig3sI2rK5eemo+XF0WVejS0IOk9wT0qGCTzcImn32iVlMoDWLI jDfw== X-Gm-Message-State: ACgBeo0hll8g0wC4qncxIlITb0YHQRdMIfQ1w4jY5z5V04k4Im0OMhQ7 eWKOLvapPOvcQofEi1mBe47yrQ== X-Google-Smtp-Source: AA6agR49+PetY/UezFl3VCgkiFx0TG/DJQh2wnNGRrH82UOhV3w3/UK0yMaLKbaosKyrxScGgmPoHw== X-Received: by 2002:a5d:5a92:0:b0:223:7af9:be0e with SMTP id bp18-20020a5d5a92000000b002237af9be0emr195542wrb.259.1660082711298; Tue, 09 Aug 2022 15:05:11 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:10 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Thara Gopinath , Andy Gross , Bjorn Andersson , linux-arm-msm@vger.kernel.org (open list:QUALCOMM TSENS THERMAL DRIVER) Subject: [PATCH v2 11/26] thermal/drivers/qcom: Use generic thermal_zone_get_trip() function Date: Wed, 10 Aug 2022 00:04:21 +0200 Message-Id: <20220809220436.711020-12-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 Sat Apr 11 15:28:08 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 9A0A5C3276E for ; Tue, 9 Aug 2022 22:06:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230204AbiHIWG1 (ORCPT ); Tue, 9 Aug 2022 18:06:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229946AbiHIWFP (ORCPT ); Tue, 9 Aug 2022 18:05:15 -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 E99DCBC22 for ; Tue, 9 Aug 2022 15:05:13 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id l4so15720022wrm.13 for ; Tue, 09 Aug 2022 15:05:13 -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; bh=FDZNsuY2Fz02k6+2isiLLrmXfm/GSYt18ZvQTGmfKxk=; b=D/wpuEd826M7uLn1nuZvCb69MBy+JlPzPpuLzqpKQlS7eVVJ1LqcnVW4GVSw37atQU uIpglDfeo9dsn06GSK6ONB7epSxQmZVM5xjNMoESmj4wvknyvMVBJ0jaenuPpeQrkDl2 NWrEoOikJWWIIcgnqBIRwZ5ojuO/C+D3PSaBJtRb3r3DAC1Q1r23vauZNIGPrJmUep8X 4hHhOQCASr+4hVVRYvNUAM2BfKYqe5uGtR6efdrRB2mb6a0BBBKd5iZcVWpkwguHAiPh 0UZMsKbSMrQ9qYYE++1n8XLl/24ABxrVHXzZ9akN+Te1m4QwYWoXl74tj8lgSGy71n5+ zbyA== 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; bh=FDZNsuY2Fz02k6+2isiLLrmXfm/GSYt18ZvQTGmfKxk=; b=d6Kqk2+EiRhbKzS2CaZBnKQlFe0jihVdWuXfNfUlxpHzvrcyKbxo46/NLuSqBq5TdA 5xNNZT0mEEyqWNaqRrtkVqPQKR76FBldY30ZP9elkIFUU5Ti3RYqg18At+j9ZCriFufb hKicskOwHD+4H6mkrHgM+K23l9un2Q/GKYWxkcZ/TauohaKr//eNt+d8oq2XO2nL5OaS YQr9dU8kusWR4rvlaRG8sePI3kXxrY5J59nfBFD12Tuh55tj/EFucZM4CrXDUCWvwehG Ovb/L8mWo+XD1jer0aPPAJhEyT+Mtv9qk+Fqx8FJ1Vjh4rbm7Xnygx1BIwn1HaZVcmP+ J+eQ== X-Gm-Message-State: ACgBeo3kIZnoV5WBzzsI5qkv1AewvIxG5TISL039pdeZvPQsRtuoEobp ZU8UxoTaCm95pQRmvuZNMSEAA/gMZgCOHw== X-Google-Smtp-Source: AA6agR6y2W3+rO3v7v71n3PyD6PyZL03SK/5X/O4VqZHdh4YluhRPu0ukUOO9xhV1Ehjzj5bcq4qEg== X-Received: by 2002:a05:6000:549:b0:220:5a5d:e2e2 with SMTP id b9-20020a056000054900b002205a5de2e2mr15931000wrf.695.1660082712447; Tue, 09 Aug 2022 15:05:12 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:11 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria Subject: [PATCH v2 12/26] thermal/drivers/OF: Use generic thermal_zone_get_trip() function Date: Wed, 10 Aug 2022 00:04:22 +0200 Message-Id: <20220809220436.711020-13-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 fd2fb84bf246..70171fb4283f 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) { @@ -670,9 +637,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 Sat Apr 11 15:28:08 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 63885C19F2D for ; Tue, 9 Aug 2022 22:07:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230019AbiHIWGm (ORCPT ); Tue, 9 Aug 2022 18:06:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229953AbiHIWFR (ORCPT ); Tue, 9 Aug 2022 18:05:17 -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 D4F5DF5A0 for ; Tue, 9 Aug 2022 15:05:15 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id n4so13986844wrp.10 for ; Tue, 09 Aug 2022 15:05:15 -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; bh=cMvv+kIwS7Npnyybgo7TEwbxPHKi63Y9shqXlNy7AcU=; b=Wy4maNlOnCV1LXAjXjAfVgIJ2ZxBRik+aPTBw/K+HrfLwGp7bIwu96onm/TUyySd58 3gADwckPF/GySG3UWIOjJb5iy6MruNbzk4F3LBRJXKhP/cTA8mMEqiaNEXqHejpWrvZD m1oVrtsfRksdUdaNGoUetwOM3pimQA0PaaYNn71tSSNck8oFExv94ORHcxbm8ADxuhDr zsgXFh1y5Is4yeghoijjQesHHHLzxlBACVGIcwPB1n2hjbSTon2CwfNZfIug8G0os8AJ U5Fvxdq2XmpY2DxKAOCOv+Rsrnf5t6ky1/pkfxzZWIJgyP5dx6jttJubFml9szv9hJ3X cKgg== 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; bh=cMvv+kIwS7Npnyybgo7TEwbxPHKi63Y9shqXlNy7AcU=; b=OiJ9UfhXIrtD3070zy9xZhMMXYLcbaqKSE5N5oW7IdWpR4GNTDDPljikNZcdLjupCw AUBjw+bXqjEzPvx4iZo24fVhBpAe3rPc/+/gXHYmB+/9qbr6wW8IJZ48/Rc7YwRLwWpz xE5JCdkDl6m5NMhfwKPG7yDe3OLjiT4BesO9nVMKzfbzSvX5AFyNiv0WRF0Bj0mP7GVK kSDzhHImugUg++Zbayh8MH2YzlWgkcs0AfGJ3CwBdoNkzo7mcpHUzix3+qSH0EQBmvwz DIrJxkfRbHTTB8wJaK7yG2Kn2v6Clv8MimQSggR5+SOZmi7chnATmJdS+AHjZtUvZch+ fzLQ== X-Gm-Message-State: ACgBeo2f6bGfOAB0T8MmJYtU0XwWpkryCWtJbritCLwe8C0vewmYExqa WCsNvXykjbE8uWlAKYXbwc+Cxw== X-Google-Smtp-Source: AA6agR5VK5Ea8Uy76QcOYiWMc4YQbWMKjaVVyuFIrJ1I1u6uPPVBuyWR3KlPWTHIFpLpmFRpzJfrfA== X-Received: by 2002:a5d:6b12:0:b0:21f:1568:c7e1 with SMTP id v18-20020a5d6b12000000b0021f1568c7e1mr15438289wrw.532.1660082714324; Tue, 09 Aug 2022 15:05:14 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:13 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Miquel Raynal , Amit Kucheria Subject: [PATCH v2 13/26] thermal/drivers/armada: Use generic thermal_zone_get_trip() function Date: Wed, 10 Aug 2022 00:04:23 +0200 Message-Id: <20220809220436.711020-14-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 Sat Apr 11 15:28:08 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 263E4C25B08 for ; Tue, 9 Aug 2022 22:07:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229984AbiHIWGj (ORCPT ); Tue, 9 Aug 2022 18:06:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229955AbiHIWFS (ORCPT ); Tue, 9 Aug 2022 18:05:18 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1497AA8 for ; Tue, 9 Aug 2022 15:05:17 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id n185so6924250wmn.4 for ; Tue, 09 Aug 2022 15:05:16 -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; bh=DCGZJNnTNRxapeV7V7/86oJke50DUo9T/8u4uKpg7OE=; b=BH43yErG6uHSnDVJb4xyCvjIkvUmTzsxEmCrsHjMgxaWTPulZoQNpfNMwuUXmCa5Ot zPml5m0HBlfkf293YzAW3jMf5/aHKm5PSTIlwM5Y7YENWOb0ufUhC3pWmWeils9HxEWo YiY1YOfavxNJdnKpkA5GIQ7lF6HvESqL8W2dZ4W+naSeybsDkk/eSh6Hmk0e9PZSptnf jFE2riJ8ay3eHMKtdyP6mOgBHJwUvuImMErcLixHxKUs6gB0DKYIIaWyZZbPcrFWpeYY pOwlnEmJbRq9uwFedt2ZdNHJUnTk1IoA41Z5S8zAd14Q6jraazJ1EEq4tqD/qOmj9BEd iLjA== 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; bh=DCGZJNnTNRxapeV7V7/86oJke50DUo9T/8u4uKpg7OE=; b=bAEFXo4KaSbyQhVZBh5ikU956PjMNBSG5tXdMl06kvIth0ALx489hGTrT8FNHz+VF0 WctdlEOI8OLCGxxBtz+i1HZiEOXTkOWc5QdS5PoN9fmo7o8CuUJPF/Oazs4hIW9s3F7r bQqlPywMkSupFCkBjlkAQfwQue8Tz4sP+vv/qlbK0h6BO4ma1vtoFdH7bS68YHwqw/wP W9Wy6QrfDC2WTPvogn+mz8PPJZTA1dNK3KcxQ5jCCRJTpGVSUd/HApKAr+jCFuYYQFGh EBNSdwChL6gtR9+5E0cuy9tNHS9IWEFls3OH5fjpDMPugr7ZdhAfpRSKXb6kvDAIWjxO X1TA== X-Gm-Message-State: ACgBeo3AjLqOjz0VfPgJKTX5kzRZ58x4ArJhNZ0c2GMuOmrSzLv3SIaJ LYo/Q/fgSXq6Uqke1uPJRkKbpg== X-Google-Smtp-Source: AA6agR5bPqPTfTNhvaPfu/PwGgBm+2Yslrbp0QONkaANUUSWaPfcPPNeSupgay29AgJrD1wi3qZnOQ== X-Received: by 2002:a05:600c:19cc:b0:3a3:3cfe:d548 with SMTP id u12-20020a05600c19cc00b003a33cfed548mr293243wmq.6.1660082715542; Tue, 09 Aug 2022 15:05:15 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:15 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria Subject: [PATCH v2 14/26] thermal/core/OF: Remove unused functions Date: Wed, 10 Aug 2022 00:04:24 +0200 Message-Id: <20220809220436.711020-15-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 194e98a5b102..04565746afbf 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -145,8 +145,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) { @@ -157,11 +155,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 70171fb4283f..d8bba0009194 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 Sat Apr 11 15:28:08 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 7333BC3F6B0 for ; Tue, 9 Aug 2022 22:07:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230046AbiHIWGq (ORCPT ); Tue, 9 Aug 2022 18:06:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229960AbiHIWFS (ORCPT ); Tue, 9 Aug 2022 18:05:18 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FF51DFC6 for ; Tue, 9 Aug 2022 15:05:17 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id z16so15692062wrh.12 for ; Tue, 09 Aug 2022 15:05:17 -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; bh=ME7U3FPobKax1KYwLl1XPXCJbdioC2XXIlGU9MgSMCM=; b=AIwaIKyUSk71dsbeRWyNOHNl0rH1HMHpN5A/4SEtFr3f36+EXXcPbMz5QElDntdDqj lGsLljvNfv5u8GvPucPOF0SPBq1e2CdtKmikEZYEYYj5FGWi/R01dj0Bx+6XpGRh2FVF AEo1ppEhb6AdKpgwaPwFHOuu02KPWcjLATTv4OQi3XSgUIw1471vxV//w/WlSA6IILDS vjveXFYY9Z58dnfLZfDk1LRYjjlAxOGj6UsC1X++oM83FtZvZRzRtkqPYYcxqiFDVIsc mx9SiWDekV5natM+1D3gZnFY61OO6s2zUMbJC4eiAIE28ETC9rerePguzqbgxfXKsSTt I8fQ== 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; bh=ME7U3FPobKax1KYwLl1XPXCJbdioC2XXIlGU9MgSMCM=; b=uYT/XoJF8VuogjRyf+wWTuBvU5tOYTuiSBIBKpFRwpoUGUy80zP3mquKkTeMSARaOV Vs0lg6K3cNi47sHCE10X0BMSy2tkXEXKCliYcQRRayn5ZKfLrzDIc+qtASg+MKlYt0UW PviWdPqHbDT7Jp+vl6uYJMGz6B/hO1FibyS/o6CmdEusbHcKE2r5Lj+jVmFo2vGVo/CL uWd1TS6sX4a6GhOskhjS00YD3WtTHP2PqZQtVpJnpia8hDrYE+XDreRZJ1Ljpxcj0Aan WLqrcXkKS+ohnD0FjCo+vOq2THXlIMby+jun1U62mSppcpCH0K7jg9w/Y+f+b7lEcDpF axIQ== X-Gm-Message-State: ACgBeo27/dGupFe+IToIlbpgP+gzr5AIgp3wBPBDv/LYw64IIf7/wRoa uU4UL4UrJHUU/q4SaYV9SQHhcA== X-Google-Smtp-Source: AA6agR4nhJw1P8909w3i5RuVBXtWc/pf3Uc0ZiMHJ2uIWaxBL13m4Qc3X+C5zA4z1Gk3B3ilEX3CZQ== X-Received: by 2002:adf:f282:0:b0:221:7a12:7a48 with SMTP id k2-20020adff282000000b002217a127a48mr12287080wro.459.1660082716783; Tue, 09 Aug 2022 15:05:16 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:16 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Amit Kucheria , linux-renesas-soc@vger.kernel.org (open list:RENESAS R-CAR THERMAL DRIVERS) Subject: [PATCH v2 15/26] thermal/drivers/rcar_gen3: Use the generic function to get the number of trips Date: Wed, 10 Aug 2022 00:04:25 +0200 Message-Id: <20220809220436.711020-16-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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: 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 40ec63ad0a1b..6a6aaad2bcac 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c @@ -525,7 +525,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 Sat Apr 11 15:28:08 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 9B065C25B0D for ; Tue, 9 Aug 2022 22:07:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230111AbiHIWGz (ORCPT ); Tue, 9 Aug 2022 18:06:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229967AbiHIWFV (ORCPT ); Tue, 9 Aug 2022 18:05:21 -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 AACD8BC22 for ; Tue, 9 Aug 2022 15:05:19 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id i128-20020a1c3b86000000b003a536d58f73so116731wma.4 for ; Tue, 09 Aug 2022 15:05:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=Dtsn+qHePIXkfLwiYhYSs7MDeRS5UWjSoQeV0DC4IrQ=; b=iwarO3CIexAFy05WuDYuhU+vOtx1AsCy/sZkh+hlYJ/QRSOXp3NLVsIWafaFT79jph noaLzAWR4SH+E8koHK8Dql7gkKhgx+yDeBAzAD7uemcTUznbUlIBUyi4MHGVWLZ+N5Ge CTVEyjSF8RKK2f0rqSs58y112TxHK+aaUdrRM6jV1MvF0qq3xYzHL0BTudA78O06nERZ S1QfesPyK/Bf+PUwAXXzY9XU1lVmBOejuXOkQY6sNG1mwYsc7P7eO2VxzOZBCEyfl0FO +pABrjMsEp3PFqzfODLa2xixNDJ+qRl0VIccPJwAAhtCEJACQAOzm9KYk7JrVvrt9urH n81A== 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; bh=Dtsn+qHePIXkfLwiYhYSs7MDeRS5UWjSoQeV0DC4IrQ=; b=kv9UP7212rmWhqygTZjWKee2wEkkk8eplrCaC/8oeTxEs9RiVajORMtB6gP14Nuzoz eSdDki58eXM4uOpDUaAHxcaClBphjn1K4YW4oXdow0Mmuzz2780ilL+Pu3IL2HcXvwcq X6psSYE2o/c1tQL7WlZf7WKR67gOjdMyR2jCgdVqP08ORwL3yM41J4C61pGV6kiimuKR 1QTHm6EuNGfUreFgGCgfmOhhd00Am7AmHRFDJy/gWhOYau5ifgGS9bK40wOXMbta09rZ ee/EajwHet93ghrbUnOJua0QRRmilZyBXEb6kjSIZZ/dOmwBj8CVWvKmAfgkze3iO5tF HA4w== X-Gm-Message-State: ACgBeo3uacXYI+nyOpVEWBD9F3Jh0GkFO5lNd4P2KoUiBiZgFBiHJKi8 4co0y6iXxGIJFE8TSfh9gsAVZQ== X-Google-Smtp-Source: AA6agR5BLj4meEP0OErMKJ3xPVCx+0sgrKGHOpVy5tF2q9LI+yGJ3PpYE9yfYQZwow0TMV9p0T1VmA== X-Received: by 2002:a1c:4c0d:0:b0:3a5:98fa:3a4a with SMTP id z13-20020a1c4c0d000000b003a598fa3a4amr283578wmf.92.1660082718206; Tue, 09 Aug 2022 15:05:18 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:17 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, 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 v2 16/26] thermal/drivers/exynos: of_thermal_get_ntrips() Date: Wed, 10 Aug 2022 00:04:26 +0200 Message-Id: <20220809220436.711020-17-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 5204e343d5b0..ac47c716c1f0 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 Sat Apr 11 15:28:08 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 BAF4EC25B06 for ; Tue, 9 Aug 2022 22:07:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230306AbiHIWHB (ORCPT ); Tue, 9 Aug 2022 18:07:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229971AbiHIWFW (ORCPT ); Tue, 9 Aug 2022 18:05:22 -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 0A576A8 for ; Tue, 9 Aug 2022 15:05:21 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id a11so6920599wmq.3 for ; Tue, 09 Aug 2022 15:05:20 -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; bh=Lgd8N3uU6gTm5GRjFj2JU4gbJeAjMmL1s0Ycq3bcw1w=; b=ZOZ364iCXqO3rFkPWZSXeqXB0+ptW3ZMFBapQ63J+HscT0rId8fEnHXunULdRppQ5S ZORadCG43mxRCkOtkuinFBx+zylDg8IE8+hwfn6qpeaTsZ1MvzV8BXKuZ8NHAEjzcBpU uf5ro3kA8tCa8jKFM5N10C1adgUpSnhdQKhJluBI0qnSFbH7NbNel6i6gWhazNxVXSTC vfSreiOlEcQqGS5s7CNQxZPr4wrvXiY9RgZAsVqoB8OQgCp+rCLcKUVLwJX58RIfzOd1 uDSgwHwJjIWxTiTIUqoziEQi/y8DyX9fVoV9CArnt5ST0IQFUf7xxll/y1Om1rE0bQqr DHWw== 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; bh=Lgd8N3uU6gTm5GRjFj2JU4gbJeAjMmL1s0Ycq3bcw1w=; b=Pg6LdvJGXeFMRfbNzK/1l/oIHzgBrYev+EmUfsUF3faMeWL0OmFvBdB6OD2M3W1UNd MI7+KO8F7Rr/XyQtlxgo51U+66NjXolSvYPZWsd/MFu7xoG5dEr8VcEWUGjMtJUa/ZqN W0swkFD61PvKIwsalYonO5Khj8meT03ZTvHwo5f79Lj0YA9rKli3hxWoUNmv1c4v06zV OFEldDVsIAq2cJOwBAL1oNkIvNJNEeLKoRnPLMweX3NbubHPiQ+1RCI+bTlZ3DCOC4AR OSDRB5HtxDRQT9WWgtW8XwiYYuVhWtCpYJsh84g/akfnoJ6s07c6N05QurK3/HUQcjxW vaBA== X-Gm-Message-State: ACgBeo3pG/jP0+bgzbU/tBdmDOyoOMQ90bCTODNU9xb/7YAEPiDdPCUT v3+J0kKZv2tI+7Rvksrw7Tdwnw== X-Google-Smtp-Source: AA6agR5eWXzvEi3SVBsTklUemakYhJ3EPm68LCEhMU3ifLXDQ4h6zmfmOTIDLlPjlCzrMFlFp/0cag== X-Received: by 2002:a05:600c:2d05:b0:3a5:36eb:6ae9 with SMTP id x5-20020a05600c2d0500b003a536eb6ae9mr271239wmf.33.1660082719471; Tue, 09 Aug 2022 15:05:19 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:18 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria Subject: [PATCH v2 17/26] thermal/core/of: Remove of_thermal_get_ntrips() Date: Wed, 10 Aug 2022 00:04:27 +0200 Message-Id: <20220809220436.711020-18-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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" 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 04565746afbf..ed60b3be9082 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -143,13 +143,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 d8bba0009194..d1208b196b21 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 Sat Apr 11 15:28:08 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 857A8C19F2D for ; Tue, 9 Aug 2022 22:07:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230325AbiHIWHI (ORCPT ); Tue, 9 Aug 2022 18:07:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229983AbiHIWFX (ORCPT ); Tue, 9 Aug 2022 18:05:23 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75E99DFC6 for ; Tue, 9 Aug 2022 15:05:22 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id h13so15764253wrf.6 for ; Tue, 09 Aug 2022 15:05: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; bh=sBYa4Rhtbyvq+yIdiazGYXFIbq9Mwdu4iyysvjHUIN4=; b=mEX3xTvfFlN0NV1z/xNRux4lUTX5w7XjFn0/jm7NWAOE6isEbikoTlNpysc7AdceU8 EcGs71KybDrzC7iHrsMpao2m8tNXmSE2GivlJJ3jAmblj9CpFyB26pkbdu6O3nG1qAV/ YhlUlsG2MgRgHACjx3ZySwVBY2d4Kwky1mpbfU5l/86F0X/a+/uEMPg+GXL4Tcavyavn fZElqmE8FCRhbNrZap5z7e//BH0fj3kzuQ7ymUvK1DrwLV7CGaEogg1X7TwT0F3l3BrI UZQl1xVISD+dmfEnIdw9lajBsCvfKALErTBjvNzXHUW2I7HGRqS/012czxq/BHP/95Wy L0ng== 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; bh=sBYa4Rhtbyvq+yIdiazGYXFIbq9Mwdu4iyysvjHUIN4=; b=TzGce7dUgOVsPhFbF5M4LqR6jiV/AfbFOxMLQJvjUmaHi+n/sDHetX/nf6PYhiwwbv zr7RfSIHjREMT2TKTSJZV9XkOJyF0IjT5TD3t5XGa93q0VSkkvw+lJOzCWDqvHvzV3JW gzEKfv/6UZxZ2q0FUkq3M3ovOx8daiC+Dp32xKjlV0rwoCDQcP4LzXEnMq75TPyJogHj 8kHtVYQd6udJp8xoiKQwYzr6/920B2tThdN2pGTDp4oQDDbMnhIuDKhiGFm07bQfe64M ieu0R+iC6B4oI7+mmgQJrF6azRkPrHk4dxDYQ/gnz+xnMrPUnFu+yHZp3FVCa7xf1iIB 77bA== X-Gm-Message-State: ACgBeo29BkDhlIcEk2wgDwKmUXOQVIIv7yrNxWWsC49c/eeV0QIYlMYQ pWuRHMHwasMOdpUnnsvPLk+/gA== X-Google-Smtp-Source: AA6agR7xH6WppoqE1kaWBqcxMOWRBv4HmMyJqcF+ejWZ5KwQd7WWsQhSatAYRK+3Q08IiH3qghHtSg== X-Received: by 2002:a05:6000:188a:b0:21f:c4c:8368 with SMTP id a10-20020a056000188a00b0021f0c4c8368mr15842851wri.299.1660082720826; Tue, 09 Aug 2022 15:05:20 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:20 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, 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 v2 18/26] thermal/drivers/exynos: Replace of_thermal_is_trip_valid() by thermal_zone_get_trip() Date: Wed, 10 Aug 2022 00:04:28 +0200 Message-Id: <20220809220436.711020-19-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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" Signed-off-by: Daniel Lezcano --- drivers/thermal/samsung/exynos_tmu.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung= /exynos_tmu.c index ac47c716c1f0..9def8c76ef9a 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -552,13 +552,15 @@ 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 @@ -582,13 +584,15 @@ 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 @@ -613,13 +617,15 @@ 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 Sat Apr 11 15:28:08 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 CA91DC25B0F for ; Tue, 9 Aug 2022 22:07:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230313AbiHIWHF (ORCPT ); Tue, 9 Aug 2022 18:07:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229976AbiHIWFX (ORCPT ); Tue, 9 Aug 2022 18:05:23 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 768C011A38 for ; Tue, 9 Aug 2022 15:05:22 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id q30so15718924wra.11 for ; Tue, 09 Aug 2022 15:05: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; bh=mcqvl7P2tMp4cqPIcszOgPsr8Wnw9dXPIC7QNOz6O1k=; b=rxs/j6Ljj8ksqZlbC1OXmElheN+CD/HJDdaVUj7PCZMQthx1c4YA04gd5tmlApW7zo Yd8Z2FyWM79/A7lEgTA3wNeJT1VCATFBMN+YYY9lo/PFIdfhCrMHbfLMA8K7FKzYz614 SbGrciKxomvM4vDJiapLS+eyEqGwFwkiWKp037oVIyvwZI10N8OuugwCDptt4+cg8/PW d9GjQAcjFAwRVxIfa1mUA80sM97utX0C6oTuOZvq14owAIRbSnObl+6hRhjgJQPG4Fm8 3RoHVxPj+pU+pUIDdsGNtOU4LpG5mqShOm0kVIHjcdhkZKK530p6mrmLwWP72f5OUYjw 4p3w== 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; bh=mcqvl7P2tMp4cqPIcszOgPsr8Wnw9dXPIC7QNOz6O1k=; b=zkjMY7q/o+UEUea6q/ERjrcXoR/l0bAo6GHi1WOkBvpbbvO2nMPnH6XOQCjES/ngn8 5S96G2FWe7fvOR7PyswDbB6RcSup8InHqt3yI2pbsKauy0CNnvvwo9ceGCmvVdnJ25gY dR1m8SUmfhh+EgNYO0CkEIS1Tyco7GRLkNGeddTKcV3vpc+bzlMoCWRCI/G5B274bkOZ kovCPrWW6umyyfTjfw6NGna5y1SMiKemin9i5Z/zAi0uLFdgQPTDehXd8taqXYm+1AKB pkz0WAkjJgEFTEPtWbsjgchDULarOsu040fIL9K5rvchxuHFfAlQlit+nJQGLM+iS2GI Dn7Q== X-Gm-Message-State: ACgBeo2886ucNG3YTEPlxMDul8gN1o+ZwuHKVufO7FNmHaMrgmIQaK+4 9doRl8eo0TlmV4FiM1p2iw41hA== X-Google-Smtp-Source: AA6agR4CIQYSMIXd3v7taFCva4wBjJNAsuhGFodu7kMgNZ2iX2ej1pAoGMZreaLYcxRxEio3bAXxRA== X-Received: by 2002:a05:6000:1f1d:b0:221:6c4c:4995 with SMTP id bv29-20020a0560001f1d00b002216c4c4995mr13971265wrb.675.1660082722036; Tue, 09 Aug 2022 15:05:22 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:21 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria Subject: [PATCH v2 19/26] thermal/core/of: Remove of_thermal_is_trip_valid() Date: Wed, 10 Aug 2022 00:04:29 +0200 Message-Id: <20220809220436.711020-20-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 ed60b3be9082..b66e12f49042 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -142,16 +142,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 d1208b196b21..ded7ea2fc794 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 Sat Apr 11 15:28:08 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 98C86C3F6B0 for ; Tue, 9 Aug 2022 22:07:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230146AbiHIWHO (ORCPT ); Tue, 9 Aug 2022 18:07:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229987AbiHIWF0 (ORCPT ); Tue, 9 Aug 2022 18:05:26 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55E9ADFC6 for ; Tue, 9 Aug 2022 15:05:25 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id j15so15780486wrr.2 for ; Tue, 09 Aug 2022 15:05: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; bh=RuOkdBUevpNwOF5uxKYPUxVuiSYnY/XeiYrwbyLTKVs=; b=jCNREL2wvW5Mt/Jx47kkKqrkQYSxrNhtbo/YUXfdyuGbaMqFonANOTppRgCHOvVlRh nAO8aL/UEwwb2MXaPozfGKUhb+nB7ztAqZ3MZ4ChLnkrU0PQaTCEl8UljO6HAtCLBQ8g bNkqOH56RW1+trgVV3mCHeYSlX++/c2y6xvjKqd2QYlLF+1h2CRcjwASR0Z5SyxFh9wK XvqFQjWkPUB9tg74PqHmQetBYqaTNulmjnE+VYSCWeRgxh1vn/IhfSYT49ff1i9QmFy5 0kj88VosKBabAVvaUEMiS1Q5n+mMr5OPPCApaTPbgTzMbEy2TD3llXndJKN7LuwKWuXE FL8A== 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; bh=RuOkdBUevpNwOF5uxKYPUxVuiSYnY/XeiYrwbyLTKVs=; b=b4GlFmx0NJubXOgJjGLN4NClAt9t+ZPVmJAcTxxlgmfp+TBKdc1V7gBz860yiwkEfo W3b8zk+8oHaRgfmPZAag8kf1CHK5tnpyHcueK9loblONL3/7L6YBECq65MdcU60Zj+Vo UlL/OJMKQmwm0I89L97ALNIYN2lJieUPa/m+kZQpn4ncxRM9lM/tlempyFr2j2YrzdHb WDkEHLRrYpQYznadaJ2NM8vDrk+wi7DbWE/PfrYIyr8aSzR+Np3DNBCNb4ey64/2AX52 Ut49cW5kT75BlFIZGP4KlSUBjCo5/kpemh3J9H5kUeDM6s4keQtY4xuTxRgqMY/pXNUA hSDQ== X-Gm-Message-State: ACgBeo2gV85MSi1KTLc4MUMWSj7rnWGdzh93sTSUSPT+ksDOPcuwcmnX IsBTa4/MZjf9MWqcmFCXqpLnFg== X-Google-Smtp-Source: AA6agR5NGbThSbhVZ+tZO3ogBhTmCAhnaSQPK4NshdFqQqNV6OfuTIurkNF/5/N9B6xXxOhrZOKwEQ== X-Received: by 2002:adf:d4c2:0:b0:21e:ddf3:8b14 with SMTP id w2-20020adfd4c2000000b0021eddf38b14mr15888310wrk.355.1660082723860; Tue, 09 Aug 2022 15:05:23 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:23 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Florian Fainelli , Ray Jui , Scott Branden , Broadcom Kernel Team , Nicolas Saenz Julienne , 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 v2 20/26] thermal/drivers/broadcom: Use generic thermal_zone_get_trip() function Date: Wed, 10 Aug 2022 00:04:30 +0200 Message-Id: <20220809220436.711020-21-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 Sat Apr 11 15:28:08 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 A9994C25B08 for ; Tue, 9 Aug 2022 22:07:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230159AbiHIWHT (ORCPT ); Tue, 9 Aug 2022 18:07:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229990AbiHIWF2 (ORCPT ); Tue, 9 Aug 2022 18:05:28 -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 75FD411156 for ; Tue, 9 Aug 2022 15:05:26 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id z12so15742428wrs.9 for ; Tue, 09 Aug 2022 15:05:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=Eqqwo4NRGb/R9bBoEOfjhue5dvKyh7+jYOQsxqGgIDw=; b=gCX6A2tx7o8NoFJY2E6BFuOaDPkRZwyhkEfIyzPPhPe6lRI9IZzhsZ0yjdsYp3OVSq 5iSeA+QXTmivT41Dujg6xQV4mLFQ4GzUEAttOI/uC/rQveyMZcv62dpPUp6SrYfaX1xw S1dSgVfZFLq8I0oqnP/zcoPtUZBf+tjbNo60ZHPTwf7ZleExN6R/4YALIVzpe3Npsc4G 2JtcI5Z6UDBOFpsSIt9S59Hl4geGSWgiIahnGIoKIB1fi7wdmvEDwLfzB80E3mqvWaMv m10dh/QBC6IpXHGfsmnHJI69XMayMWwaiYDVJS3l18fUj6hXXuT7ruff03yeN9fIf4JU u54Q== 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; bh=Eqqwo4NRGb/R9bBoEOfjhue5dvKyh7+jYOQsxqGgIDw=; b=sZNG8prwNUUjP6gq+TNjh5Mu8OaouMgcPQLIxx778l5032mXWb7n6MZKvk1vMkR/nQ VJYgG0V+yova4U/XV1LkwH8+hcxQ8rmPB4zCIpiyEz4UlAZSCHI7dRLE8za3q4ttFadD 5jmnVqqWSk102CQ+YId4F+rJKHKtAHDL+3/miaschL0cWWSH12gOOien1BRZGQsUIUUe OfxUVdTHFmSHyaWE6GGW5ZxXZOO2oCWDLclIlPXeMxv8oNhs/en5djz3C958LDfZNcpe lBKhdJq0M5QHSzuuNMSmVZjCI0nqT5UKvFW7Nn/heHdNN+wDqHOW53NGicS25PmxpwS7 Dw1Q== X-Gm-Message-State: ACgBeo2j7Gr1U7t7xEpGCC8FatJ1vXEJHJB2PKD+Gb1ra5iFMF3z475q /rbBCf4F+bBbK71cseYZQclMv8LSuggf6g== X-Google-Smtp-Source: AA6agR5t39ShUXBViJRY98DvS3gz7FR80LPQwM0SjLsaErfQPdkRWDe+jlNV6zsYijg5Idwf3HUs4Q== X-Received: by 2002:a05:6000:1d89:b0:21d:5655:eb72 with SMTP id bk9-20020a0560001d8900b0021d5655eb72mr15507896wrb.110.1660082725010; Tue, 09 Aug 2022 15:05:25 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:24 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Support Opensource , Amit Kucheria Subject: [PATCH v2 21/26] thermal/drivers/da9062: Use generic thermal_zone_get_trip() function Date: Wed, 10 Aug 2022 00:04:31 +0200 Message-Id: <20220809220436.711020-22-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 Sat Apr 11 15:28:08 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 4078EC25B0E for ; Tue, 9 Aug 2022 22:07:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230202AbiHIWH1 (ORCPT ); Tue, 9 Aug 2022 18:07:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229993AbiHIWFb (ORCPT ); Tue, 9 Aug 2022 18:05:31 -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 C4D8BF5A7 for ; Tue, 9 Aug 2022 15:05:27 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id l4so15720522wrm.13 for ; Tue, 09 Aug 2022 15:05: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; bh=v9HOYNemLB65v2s3X2Chh/1DsPPvYHZYg0+K/15aDgQ=; b=bFg1GUKpiDV2Wa5Z/VYETOFzVV963xVsUH3QvrLhSGNNWPp/xqMyOGX0Zhl/qKKmxm Ad7Osv2Yqq93VYOQQMjNugMHyQJ1xs+ZaGpl+qsYoyeFEHJX0gGV/noCTwbzy978WuGO lZVYICEtV3/CnRGA0iJjDqUggzqzsx2gp7OyOBwwNf+Bk7wBGi/aiGzmcwavyZ0YAmuZ tMpTgI/zmUYFxNZn9SJh3d9XqXtZc2k/9ZBt8cObjbPdZBF8lvUREOO73qEPf/bNYT2v a6iNxynWotqme7RyFH++cw2Ra0e/e7OmEY/Q7Rv6ssADcG53xF2TE5kxFQtXsrlceanf s3kg== 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; bh=v9HOYNemLB65v2s3X2Chh/1DsPPvYHZYg0+K/15aDgQ=; b=y6LJNZvYoJJ7gygqNGY/frBrboRNGB8hKs3V5VS1pLyI6j9teS9hDYdZsmPLRFNNjO xU5LGZPtyoeNHlwcKy1gDXnY51J6g9yOlCKWl8mmLO672UGz8wElUdKso6EDQ4L/CIux amtCxuERttXvyg9dK7Wjyot8HiLU7SnlKGUbY9pgSuZlyeBf471mKyaY0IBDX7LXahT2 tZKUmRYbI2EUp52ID0rQ6WOGi1S9r0/1lPNrPxaGU9OHsvqLDTbuYJS4x13MS+wbBkyv vEENeRy/t8OS5B3+ASBUfBbphqCQMzzRTauu1B+XMlG3qwW7CRELt5DTNYJ/SGTgxXRm 102Q== X-Gm-Message-State: ACgBeo1Mn5l7zPQ3Ze4CeHFzmOfXfQnL5/bM59bnkRh85V2YvnYwsLGK mnUN3tWNSQKNDk1Ys2nOg/G4Fw== X-Google-Smtp-Source: AA6agR5IekVvgBURn6hz3jtsSLj3jSB1ikOgx3VaKNEVj6epeJRQ6Y5gecqcxCHvhKAWmzCetU715g== X-Received: by 2002:a05:6000:1ac8:b0:220:6af3:935d with SMTP id i8-20020a0560001ac800b002206af3935dmr15261728wry.549.1660082726323; Tue, 09 Aug 2022 15:05:26 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:25 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Eduardo Valentin , Keerthy , Amit Kucheria , linux-omap@vger.kernel.org (open list:TI BANDGAP AND THERMAL DRIVER) Subject: [PATCH v2 22/26] thermal/drivers/ti: Remove unused macros ti_thermal_get_trip_value() / ti_thermal_trip_is_valid() Date: Wed, 10 Aug 2022 00:04:32 +0200 Message-Id: <20220809220436.711020-23-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 Sat Apr 11 15:28:08 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 205DAC25B06 for ; Tue, 9 Aug 2022 22:07:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229925AbiHIWHW (ORCPT ); Tue, 9 Aug 2022 18:07:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229996AbiHIWFb (ORCPT ); Tue, 9 Aug 2022 18:05:31 -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 09F5012744 for ; Tue, 9 Aug 2022 15:05:28 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id z12so15742502wrs.9 for ; Tue, 09 Aug 2022 15:05: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; bh=Bvo7EJO01qiFSqaGbT4JiAGDEh8uk0vvz3ltgjeJ4xY=; b=CAWsRL4Ep4kicXkJntoYYRIcd5mxS+P+lyhev3U4OgFFKo31iklfxZ8YBswYrWQo8q r/7/d7aaRZyY0QjEAprQWpzmQvCErYj3/ESOm+yenMF1AmwmopLxHHkZ6bhIjLyvUa2E mx9Pl7YIEkZFIxkeTLe97cmpc7b3Eox4Qnkg8+wrftdtcWob5llvFamt98DJGvzxclFb oz2J0+x/OFDEE+v4CO43Nc2mVzGvqsvpdavHoMM2k8uYEZ93m/gJ6DQRO0FeDcuIhdYf YpI23rxd4CsZqAruWv/kqq8A9BcwWvtDasVKL9qB8dB8X1d9wH+QMPugcEbzRWvPo4tf a5MA== 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; bh=Bvo7EJO01qiFSqaGbT4JiAGDEh8uk0vvz3ltgjeJ4xY=; b=L/vRK8H0KBuy6cIaeDyALfUgTIVw28x805xHSo2YbOxcXQmiXqaGJdBjWXfYREGAr9 v8Djb8oawm0crlAHLqOhkyzVZGWfM/DjJWm89FzQWyKdXsQToNQs2UqvD+fJQJpxfp+A WlkkFHzoWHaIwCzTqvDr6yGpIu/lHh9F+s+LFpw/48r9PARQ6boKO3w6zG5gydPgjxut eZTSZtg1Pko5bxKeU+IFKbg8VjsfvoCBeFuWWplSNdD6f/owrOlwFN6cLI99pM/ZDykF vmhbfl1MR1kskwToluKXElL/uXUobx2ZW8RwAZq3FfLBuiycPvdaZnTrdOjKN7oUDlfm 6qFw== X-Gm-Message-State: ACgBeo1RGyCgW6WubtjHMXbaF05fSK7uy2u+LDpL4+ZLfmeoODnoeZP2 mxn/XvErcZY92mPB+gp1bLFsRg== X-Google-Smtp-Source: AA6agR73C8FYlygjs2eWSiL4P5CCNWIL9h5r5LJCnL/XSF0M8E+RfGw1MC6lcPFkWKuYH6Yi8UW67A== X-Received: by 2002:adf:f94b:0:b0:21e:46fe:bcdb with SMTP id q11-20020adff94b000000b0021e46febcdbmr14731147wrr.143.1660082727580; Tue, 09 Aug 2022 15:05:27 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:27 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, 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 v2 23/26] thermal/drivers/acerhdf: Use generic thermal_zone_get_trip() function Date: Wed, 10 Aug 2022 00:04:33 +0200 Message-Id: <20220809220436.711020-24-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 Sat Apr 11 15:28:08 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 6A9E3C282E7 for ; Tue, 9 Aug 2022 22:07:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230333AbiHIWHf (ORCPT ); Tue, 9 Aug 2022 18:07:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230010AbiHIWFh (ORCPT ); Tue, 9 Aug 2022 18:05:37 -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 6CADA12AF5 for ; Tue, 9 Aug 2022 15:05:29 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id n4so13987407wrp.10 for ; Tue, 09 Aug 2022 15:05:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=qkEQMAFlFrUq6t0pAagx8mtMZ2aPJX8cpHX423TQAwM=; b=uXFuuXPIk5YZpv5fxfWZTycPEBW26AlQ0Z/sdH2vUqzo8aI/6xrbnSStYFLxYzZ+Oj Zz5PP7G4DmTpFw7M8W9inRzGpMEg8/MtCeIe1u3kDorWDGlk+mDUULMeCR/JEJ6kpBkV KuOejQuOTAf7kAd6c5LdiCnmul5CjANOP882WB9WeitsymtypVrVCddgtG28n5Gve3dw 4gTHayTethKgt4CYtSwlDmymnmZdqX5u2Z/X+GDr+NP6UTiT9Re72wfUqNounMKYd0vY Y0EuBnojzdA/BDzqq47+BHv5nTG2SqEicRiQVRm+WVHsECFdMsVa8v6fGQGcogmVSCDY WBtA== 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; bh=qkEQMAFlFrUq6t0pAagx8mtMZ2aPJX8cpHX423TQAwM=; b=euxFyn90OteZIQTB4csH7kLseHBhYi5TDXnTEYDmBlGMfRAS/pg3NFt+WRiE7QAmd4 +l+Gj9tZCzAv1Viq8BXuY7kRWMWcMGyXlRv89acvMajpNr+3Q6r5i37EJNiJ7ee/HnY4 Rg2Pv5s03vBo7b92Uz9U3cA4O80QNgw4OdvHYC+vTTQW0P1SpWO+E41wDA6UvHHxVE7m BeFFufkyZwyYFFhfg18IQSo9tR05OIiQZQ6WMI0xgYlzXGZx+gOcACw0ErhHqRd1DQ18 AKW0CCZjroSfLLaROE0GEvRynTMAV7euDBcfNj89cEQgxVSDX5hArYIh/Rm9iFWv7yqy tgnA== X-Gm-Message-State: ACgBeo0v1tyrrFfrsfMxCR8MFXSTQV+XeXHONMprE+Y9DcR9oXyyV7qK LyNfG+j4tFFiYSt4H1T0hXyojA== X-Google-Smtp-Source: AA6agR4wxoZUg83IFf35QmSsc8I2+UGGkx7cAiV5AJbu7XOKEmmG2Nx4D0+JiaHZrrtQCA8c/aYRMQ== X-Received: by 2002:a05:6000:18a3:b0:21f:d6a4:1aec with SMTP id b3-20020a05600018a300b0021fd6a41aecmr15458409wri.468.1660082728921; Tue, 09 Aug 2022 15:05:28 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:28 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski , Raju Rangoju , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org (open list:CXGB4 ETHERNET DRIVER (CXGB4)) Subject: [PATCH v2 24/26] thermal/drivers/cxgb4: Use generic thermal_zone_get_trip() function Date: Wed, 10 Aug 2022 00:04:34 +0200 Message-Id: <20220809220436.711020-25-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 Sat Apr 11 15:28:08 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 57EA1C25B0D for ; Tue, 9 Aug 2022 22:07:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230212AbiHIWHc (ORCPT ); Tue, 9 Aug 2022 18:07:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230017AbiHIWFh (ORCPT ); Tue, 9 Aug 2022 18:05:37 -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 6098113D3C for ; Tue, 9 Aug 2022 15:05:32 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id q30so15719318wra.11 for ; Tue, 09 Aug 2022 15:05:32 -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; bh=KZ8EnQSq9ZUNp2qj7akZkpIkjIeNnNIZanKBvoVLLJ0=; b=XCoUr7sBHnk+0QY/3THFAhoFnuzbE2KiubzzizZGNMmGYGKZa+PplFfIxv8SwrWVzJ KH4MLa/sijXAnwUu7noaTzimFztQxnPmM6qHfiaHbVJJlFHsAa981JOizIsX59c1Ax4k 0WRVBby5i6dtJfUSn3KiXPquhYQ+ucCWO6c+p3tX9vNnQoY+aTFGKUR3BtiW5UQomwSL iW/63KbTX2P6MoQfHRDKKi1YU501Dqa8epyjMQ4LlYfmK03704asgU5TmuNZvHJ00OL9 fe6cNg2wPemm28X19gxW575dtPceXUy7z+FZ5r2yXowMPHgmmpVDBgY77MLuUn+bA4OF xjSA== 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; bh=KZ8EnQSq9ZUNp2qj7akZkpIkjIeNnNIZanKBvoVLLJ0=; b=WYExrivqV23BGbXonHwiFt7GKR0FlVy1uiTaSMrC98zRuiHB7Jt/wklkUCISIgx5q1 yTOVmGKJ3Cry+uX9LKR8CUFtbhTL7XIVns1YHv4fYMm1hDD+Fr0z2/qXoAdZLJsEa+jA WSJe9Isrp2GmcsqL3dLUtjP4pxe4bIpMtHQRjCzLrok0X7fw6m4mdJe5KcAtRfJy4xG2 Yiq4S3fyxZnp/DUOKnkggMARfElUTODEi7YQEvdhBgUzx0GNrL9OtBSdBqX4QzCukPmY +lOFMU3OXjwvf9t2NkBliS4pM9ifSj+F634KPSgmLnQEZsZbWDFZfcH4IHqnF6QbwQgc QpkA== X-Gm-Message-State: ACgBeo3P5dc05sExRQrcEDRndZM3g1ZsvHlp9defjoVNV+UFaQK4eORL 6cokJ869Bf/NX2S/ANVPbgyR1A== X-Google-Smtp-Source: AA6agR5uOrLwYRVtjojM8KiL67oA67hj5njjnZoUSgs//2DDP8aJnZDQCeDbL9+SkN9zflYAR6BvUA== X-Received: by 2002:adf:ef8b:0:b0:220:8235:124 with SMTP id d11-20020adfef8b000000b0022082350124mr15038859wro.628.1660082731747; Tue, 09 Aug 2022 15:05:31 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:30 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada , Amit Kucheria , Antoine Tenart Subject: [PATCH v2 25/26] thermal/intel/int340x: Replace parameter to simplify Date: Wed, 10 Aug 2022 00:04:35 +0200 Message-Id: <20220809220436.711020-26-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 Sat Apr 11 15:28:08 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 63AFEC25B08 for ; Tue, 9 Aug 2022 22:08:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230226AbiHIWHp (ORCPT ); Tue, 9 Aug 2022 18:07:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230038AbiHIWFm (ORCPT ); Tue, 9 Aug 2022 18:05:42 -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 7F36513F73 for ; Tue, 9 Aug 2022 15:05:34 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id c187-20020a1c35c4000000b003a30d88fe8eso127071wma.2 for ; Tue, 09 Aug 2022 15:05: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; bh=89E/CxlN8Tp3lczCV5jVp3NK0Ss9lUiOGh8dJwP7JXg=; b=tQaWHRdToEGk9WyjVRDEXaOnmacVEHhEh9WTJBVy4a9+NSpbr3U00Bqsd3yAkmoj4V irOjiq2E8FpsIhKj0MpKRSzda70bUfDcYjfnKWq6k4UIlpZ5jgBboSIPRdR5RVgQFen+ /iUjSrK6LSWDrbL/dYy562SG7MQYDt/k9+qUnOyOC6E3xvZ4DQZamws1IdA7FF8sOktK TBjZlXQUnW4iefsiY8VMKEeHWk3pX5XttoYNvn6LO5w5u6sxWATq0vM7X78x0qPdt5+Z 9uiqfoN+R3LC6al9mZ+IbecJ5ooYK3Fa+9nciGy/4RjcrUIpLjccuzJtSX/5+EfiElAP dHnA== 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; bh=89E/CxlN8Tp3lczCV5jVp3NK0Ss9lUiOGh8dJwP7JXg=; b=ifTbBq15jmCb71vA+6sWqR161olfolkitDomAp6RHghjp5nPsTI2a5F8ezIZr9jDWc 0KB9XLsw0h4kwvVSETn3XO5AC31Jf7Hgxkad/IFNypsK5TGIXA0SpmdZMbr8ZElWZsBm QZPD7fYlt0xFN/UfuejG5gHQLkHgkHbngyG/E/PJUIKxIQzUw1XqBOwKdAgON+LEupxf tEYWuBFjhPc8sybNt805uqHiIc48ByvBykLTQ8XF9LLlDjXfS+X6Ev6MxyztddqvQ+Qp WmFO83umT79y2z4q7l8GIfIJyGdBDj5QIkgssVlr2nER0uB15kuhM3BMaj7zPuNvdYAS WjZw== X-Gm-Message-State: ACgBeo1jA0nY/bE5jnzatdDmkJsxCzKPZwnCv1/PMdQ+e1++aO7z0xBG wrE3RIF9kIPGsdxCoC5uoSFfDw== X-Google-Smtp-Source: AA6agR5H3wiH8mgnBiSDgOR3YUyQt9nGqs0bbssfxeVDisk8h603TP07ShOGbwrr1Fh33JtOTXe7Lg== X-Received: by 2002:a05:600c:3d93:b0:3a3:3a93:fb16 with SMTP id bi19-20020a05600c3d9300b003a33a93fb16mr290789wmb.190.1660082733455; Tue, 09 Aug 2022 15:05:33 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:32 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria Subject: [PATCH v2 26/26] thermal/drivers/intel: Use generic thermal_zone_get_trip() function Date: Wed, 10 Aug 2022 00:04:36 +0200 Message-Id: <20220809220436.711020-27-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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 Reported-by: kernel test robot --- 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 4d8edc61a78b..c28a98c82f97 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