From nobody Mon Apr 6 14:08:59 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 AC656ECAAD5 for ; Tue, 6 Sep 2022 17:01:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239256AbiIFRBQ (ORCPT ); Tue, 6 Sep 2022 13:01:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238965AbiIFQ77 (ORCPT ); Tue, 6 Sep 2022 12:59:59 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BC408034B for ; Tue, 6 Sep 2022 09:47:40 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id b16so16353768wru.7 for ; Tue, 06 Sep 2022 09:47:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=3d392gfN5HL23OdaD2iWzbEdDL5X4YtbWtg9iygu8fY=; b=g7xZ1KODlZstd2/o3YaWHn1oxIYjKeg2q4EVHNxLShNj9o88yl8qJq1kKmqA/G1Gl1 kpU8hoE8vN7DRIhSSCrdaFxYVeacv37eykRvy2fFu74kO2SMH250ujTEHfOZ4dR7Torq 7H5wpn+sHxWahbFwYO6lh9DxLvAabT7oA2IkRhEjap8+favyR4BtwwtqDRMtcb2EAiNz aAzwcJlKtsJpdoDD6Ffuw79YNZ2QUl1PfWfg9Y7dpNdE+K3Ze74uEk8o3viE/9hBxob0 zQj1quPglHxxX3jPn9Gvdwppr6P/Uz2fZyy0IvFTkGrhZiKItmPiqtFIMQjq3VspKS+3 LXng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=3d392gfN5HL23OdaD2iWzbEdDL5X4YtbWtg9iygu8fY=; b=2jVA8GPbQ5OUy8hjD05g8OGynIAMMFJwqZsXt9jM0g/a89Oec48foxmfauTNWgdJ5g 1qVYMDb1y4ju/bo4qZV8kojFvPwDjfv5SGd7ZGN8sxW9bgu7v6HhPj+ooqsyqlb/ZV+H FiW9Gy3fKX2DEqMOMFev0Q0CT/aezbvehr5LISwp5ZhfoW1xwOo3NRzMJtSEt+YqHsAb Kff3V8wyzKSlGDwOZlqn/CIjtHrkweY9n+5DSDepYNWXXscqvTv4wkGG+W8Z/+xbQPch 1qcu/LFNJFFuMpA+XqhGXf/5b0g+WIyrCZ9bF3PLTz1Jg+bAJw1v2Nf4B28ddJPVihch Bk/w== X-Gm-Message-State: ACgBeo2uqxiownb26vis/10wAUjDrC1WMzxlusWSPh+ql7EONVE9Q7zO Pl8VF+SCDSbHGwNMsGmqjcgMvA== X-Google-Smtp-Source: AA6agR67v/zkn92yGh2TthU9BV/bvIsZ9u/3dkBchVlEwSbYv/xoeMgsPx8JVEF/2hWLWSj3qnUpbQ== X-Received: by 2002:adf:a70b:0:b0:226:e1f5:7889 with SMTP id c11-20020adfa70b000000b00226e1f57889mr20592726wrd.108.1662482858998; Tue, 06 Sep 2022 09:47:38 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.47.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:47:38 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v3 01/30] thermal/core: Add a generic thermal_zone_get_trip() function Date: Tue, 6 Sep 2022 18:46:51 +0200 Message-Id: <20220906164720.330701-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-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 | 87 +++++++++++++++++++++++-------- drivers/thermal/thermal_helpers.c | 28 +++++----- drivers/thermal/thermal_netlink.c | 21 ++++---- drivers/thermal/thermal_sysfs.c | 66 +++++++++-------------- include/linux/thermal.h | 5 ++ 5 files changed, 118 insertions(+), 89 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 99c0c19fa5a6..381d85ec74a0 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -341,35 +341,31 @@ static void handle_critical_trips(struct thermal_zone= _device *tz, tz->ops->critical(tz); } =20 -static void handle_thermal_trip(struct thermal_zone_device *tz, int trip) +static void handle_thermal_trip(struct thermal_zone_device *tz, int trip_i= d) { - enum thermal_trip_type type; - int trip_temp, hyst =3D 0; + struct thermal_trip trip; =20 /* Ignore disabled trip points */ - if (test_bit(trip, &tz->trips_disabled)) + if (test_bit(trip_id, &tz->trips_disabled)) return; =20 - tz->ops->get_trip_temp(tz, trip, &trip_temp); - tz->ops->get_trip_type(tz, trip, &type); - if (tz->ops->get_trip_hyst) - tz->ops->get_trip_hyst(tz, trip, &hyst); + thermal_zone_get_trip(tz, trip_id, &trip); =20 if (tz->last_temperature !=3D THERMAL_TEMP_INVALID) { - if (tz->last_temperature < trip_temp && - tz->temperature >=3D trip_temp) - thermal_notify_tz_trip_up(tz->id, trip, + if (tz->last_temperature < trip.temperature && + tz->temperature >=3D trip.temperature) + thermal_notify_tz_trip_up(tz->id, trip_id, tz->temperature); - if (tz->last_temperature >=3D trip_temp && - tz->temperature < (trip_temp - hyst)) - thermal_notify_tz_trip_down(tz->id, trip, + if (tz->last_temperature >=3D trip.temperature && + tz->temperature < (trip.temperature - trip.hysteresis)) + thermal_notify_tz_trip_down(tz->id, trip_id, tz->temperature); } =20 - if (type =3D=3D THERMAL_TRIP_CRITICAL || type =3D=3D THERMAL_TRIP_HOT) - handle_critical_trips(tz, trip, trip_temp, type); + if (trip.type =3D=3D THERMAL_TRIP_CRITICAL || trip.type =3D=3D THERMAL_TR= IP_HOT) + handle_critical_trips(tz, trip_id, trip.temperature, trip.type); else - handle_non_critical_trips(tz, trip); + handle_non_critical_trips(tz, trip_id); } =20 static void update_temperature(struct thermal_zone_device *tz) @@ -1142,6 +1138,52 @@ static void thermal_set_delay_jiffies(unsigned long = *delay_jiffies, int delay_ms *delay_jiffies =3D round_jiffies(*delay_jiffies); } =20 +int thermal_zone_get_num_trips(struct thermal_zone_device *tz) +{ + return tz->num_trips; +} +EXPORT_SYMBOL_GPL(thermal_zone_get_num_trips); + +static int __thermal_zone_get_trip(struct thermal_zone_device *tz, int tri= p_id, + struct thermal_trip *trip) +{ + int ret; + + if (!tz || trip_id < 0 || trip_id >=3D tz->num_trips || !trip) + return -EINVAL; + + if (tz->trips) { + *trip =3D tz->trips[trip_id]; + return 0; + } + + if (tz->ops->get_trip_hyst) { + ret =3D tz->ops->get_trip_hyst(tz, trip_id, &trip->hysteresis); + if (ret) + return ret; + } else trip->hysteresis =3D 0; + + ret =3D tz->ops->get_trip_temp(tz, trip_id, &trip->temperature); + if (ret) + return ret; + + return tz->ops->get_trip_type(tz, trip_id, &trip->type); +} + +int thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id, + struct thermal_trip *trip) +{ + int ret; + + mutex_lock(&tz->lock); + ret =3D __thermal_zone_get_trip(tz, trip_id, trip); + mutex_unlock(&tz->lock); + + return ret; +} +EXPORT_SYMBOL_GPL(thermal_zone_get_trip); + + /** * thermal_zone_device_register_with_trips() - register a new thermal zone= device * @type: the thermal zone device type @@ -1174,8 +1216,6 @@ thermal_zone_device_register_with_trips(const char *t= ype, struct thermal_trip *t int polling_delay) { struct thermal_zone_device *tz; - enum thermal_trip_type trip_type; - int trip_temp; int id; int result; int count; @@ -1202,7 +1242,7 @@ thermal_zone_device_register_with_trips(const char *t= ype, struct thermal_trip *t return ERR_PTR(-EINVAL); } =20 - if (num_trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp)) + if (num_trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp) && !tri= ps) return ERR_PTR(-EINVAL); =20 tz =3D kzalloc(sizeof(*tz), GFP_KERNEL); @@ -1252,9 +1292,10 @@ thermal_zone_device_register_with_trips(const char *= type, struct thermal_trip *t goto release_device; =20 for (count =3D 0; count < num_trips; count++) { - if (tz->ops->get_trip_type(tz, count, &trip_type) || - tz->ops->get_trip_temp(tz, count, &trip_temp) || - !trip_temp) + struct thermal_trip trip; + + result =3D thermal_zone_get_trip(tz, count, &trip); + if (result) set_bit(count, &tz->trips_disabled); } =20 diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_he= lpers.c index c65cdce8f856..e1264940136a 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -69,7 +69,7 @@ int __thermal_zone_get_temp(struct thermal_zone_device *t= z, int *temp) int ret =3D -EINVAL; int count; int crit_temp =3D INT_MAX; - enum thermal_trip_type type; + struct thermal_trip trip; =20 lockdep_assert_held(&tz->lock); =20 @@ -80,10 +80,9 @@ int __thermal_zone_get_temp(struct thermal_zone_device *= tz, int *temp) =20 if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) { for (count =3D 0; count < tz->num_trips; count++) { - ret =3D tz->ops->get_trip_type(tz, count, &type); - if (!ret && type =3D=3D THERMAL_TRIP_CRITICAL) { - ret =3D tz->ops->get_trip_temp(tz, count, - &crit_temp); + ret =3D thermal_zone_get_trip(tz, count, &trip); + if (!ret && trip.type =3D=3D THERMAL_TRIP_CRITICAL) { + crit_temp =3D trip.temperature; break; } } @@ -124,29 +123,30 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_temp); =20 void __thermal_zone_set_trips(struct thermal_zone_device *tz) { - int low =3D -INT_MAX; - int high =3D INT_MAX; - int trip_temp, hysteresis; + struct thermal_trip trip; + int low =3D -INT_MAX, high =3D INT_MAX; int i, ret; =20 lockdep_assert_held(&tz->lock); =20 - if (!tz->ops->set_trips || !tz->ops->get_trip_hyst) + if (!tz->ops->set_trips) return; =20 for (i =3D 0; i < tz->num_trips; i++) { int trip_low; =20 - tz->ops->get_trip_temp(tz, i, &trip_temp); - tz->ops->get_trip_hyst(tz, i, &hysteresis); + ret =3D thermal_zone_get_trip(tz, i , &trip); + if (ret) + return; =20 - trip_low =3D trip_temp - hysteresis; + trip_low =3D trip.temperature - trip.hysteresis; =20 if (trip_low < tz->temperature && trip_low > low) low =3D trip_low; =20 - if (trip_temp > tz->temperature && trip_temp < high) - high =3D trip_temp; + if (trip.temperature > tz->temperature && + trip.temperature < high) + high =3D trip.temperature; } =20 /* No need to change trip points */ diff --git a/drivers/thermal/thermal_netlink.c b/drivers/thermal/thermal_ne= tlink.c index 050d243a5fa1..ce56d441c88c 100644 --- a/drivers/thermal/thermal_netlink.c +++ b/drivers/thermal/thermal_netlink.c @@ -452,7 +452,8 @@ static int thermal_genl_cmd_tz_get_trip(struct param *p) struct sk_buff *msg =3D p->msg; struct thermal_zone_device *tz; struct nlattr *start_trip; - int i, id; + struct thermal_trip trip; + int ret, i, id; =20 if (!p->attrs[THERMAL_GENL_ATTR_TZ_ID]) return -EINVAL; @@ -471,18 +472,14 @@ static int thermal_genl_cmd_tz_get_trip(struct param = *p) =20 for (i =3D 0; i < tz->num_trips; i++) { =20 - enum thermal_trip_type type; - int temp, hyst =3D 0; - - tz->ops->get_trip_type(tz, i, &type); - tz->ops->get_trip_temp(tz, i, &temp); - if (tz->ops->get_trip_hyst) - tz->ops->get_trip_hyst(tz, i, &hyst); - + ret =3D thermal_zone_get_trip(tz, i, &trip); + if (ret) + goto out_cancel_nest; + =09 if (nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, i) || - nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, type) || - nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TEMP, temp) || - nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_HYST, hyst)) + nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, trip.type) || + nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TEMP, trip.temperature) || + nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_HYST, trip.hysteresis)) goto out_cancel_nest; } =20 diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysf= s.c index 78c5841bdfae..75f6b151a58b 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -83,20 +83,17 @@ trip_point_type_show(struct device *dev, struct device_= attribute *attr, char *buf) { struct thermal_zone_device *tz =3D to_thermal_zone(dev); - enum thermal_trip_type type; - int trip, result; + struct thermal_trip trip; + int trip_id, result; =20 - if (!tz->ops->get_trip_type) - return -EPERM; - - if (sscanf(attr->attr.name, "trip_point_%d_type", &trip) !=3D 1) + if (sscanf(attr->attr.name, "trip_point_%d_type", &trip_id) !=3D 1) return -EINVAL; =20 - result =3D tz->ops->get_trip_type(tz, trip, &type); + result =3D thermal_zone_get_trip(tz, trip_id, &trip); if (result) return result; =20 - switch (type) { + switch (trip.type) { case THERMAL_TRIP_CRITICAL: return sprintf(buf, "critical\n"); case THERMAL_TRIP_HOT: @@ -115,37 +112,31 @@ trip_point_temp_store(struct device *dev, struct devi= ce_attribute *attr, const char *buf, size_t count) { struct thermal_zone_device *tz =3D to_thermal_zone(dev); - int trip, ret; - int temperature, hyst =3D 0; - enum thermal_trip_type type; + struct thermal_trip trip; + int trip_id, ret; =20 if (!tz->ops->set_trip_temp && !tz->trips) return -EPERM; =20 - if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip) !=3D 1) + if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip_id) !=3D 1) return -EINVAL; =20 - if (kstrtoint(buf, 10, &temperature)) + if (kstrtoint(buf, 10, &trip.temperature)) return -EINVAL; =20 - ret =3D tz->ops->set_trip_temp(tz, trip, temperature); + ret =3D tz->ops->set_trip_temp(tz, trip_id, trip.temperature); if (ret) return ret; =20 if (tz->trips) - tz->trips[trip].temperature =3D temperature; - - if (tz->ops->get_trip_hyst) { - ret =3D tz->ops->get_trip_hyst(tz, trip, &hyst); - if (ret) - return ret; - } + tz->trips[trip_id].temperature =3D trip.temperature; =20 - ret =3D tz->ops->get_trip_type(tz, trip, &type); + ret =3D thermal_zone_get_trip(tz, trip_id, &trip); if (ret) return ret; =20 - thermal_notify_tz_trip_change(tz->id, trip, type, temperature, hyst); + thermal_notify_tz_trip_change(tz->id, trip_id, trip.type, + trip.temperature, trip.hysteresis); =20 thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); =20 @@ -157,21 +148,17 @@ trip_point_temp_show(struct device *dev, struct devic= e_attribute *attr, char *buf) { struct thermal_zone_device *tz =3D to_thermal_zone(dev); - int trip, ret; - int temperature; - - if (!tz->ops->get_trip_temp) - return -EPERM; + struct thermal_trip trip; + int trip_id, ret; =20 - if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip) !=3D 1) + if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip_id) !=3D 1) return -EINVAL; =20 - ret =3D tz->ops->get_trip_temp(tz, trip, &temperature); - + ret =3D thermal_zone_get_trip(tz, trip_id, &trip); if (ret) return ret; =20 - return sprintf(buf, "%d\n", temperature); + return sprintf(buf, "%d\n", trip.temperature); } =20 static ssize_t @@ -209,18 +196,17 @@ trip_point_hyst_show(struct device *dev, struct devic= e_attribute *attr, char *buf) { struct thermal_zone_device *tz =3D to_thermal_zone(dev); - int trip, ret; - int temperature; + struct thermal_trip trip; + int trip_id, ret; =20 - if (!tz->ops->get_trip_hyst) - return -EPERM; - - if (sscanf(attr->attr.name, "trip_point_%d_hyst", &trip) !=3D 1) + if (sscanf(attr->attr.name, "trip_point_%d_hyst", &trip_id) !=3D 1) return -EINVAL; =20 - ret =3D tz->ops->get_trip_hyst(tz, trip, &temperature); + ret =3D thermal_zone_get_trip(tz, trip_id, &trip); + if (ret) + return ret; =20 - return ret ? ret : sprintf(buf, "%d\n", temperature); + return ret ? ret : sprintf(buf, "%d\n", trip.hysteresis); } =20 static ssize_t diff --git a/include/linux/thermal.h b/include/linux/thermal.h index a5a18351a898..09dc09228717 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -335,6 +335,11 @@ static inline void devm_thermal_of_zone_unregister(str= uct device *dev, } #endif =20 +int thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id, + struct thermal_trip *trip); + +int thermal_zone_get_num_trips(struct thermal_zone_device *tz); + #ifdef CONFIG_THERMAL struct thermal_zone_device *thermal_zone_device_register(const char *, int= , int, void *, struct thermal_zone_device_ops *, --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 2931AECAAA1 for ; Tue, 6 Sep 2022 17:01:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231913AbiIFRBL (ORCPT ); Tue, 6 Sep 2022 13:01:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234062AbiIFQ77 (ORCPT ); Tue, 6 Sep 2022 12:59:59 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADC0080360 for ; Tue, 6 Sep 2022 09:47:42 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id j26so7220850wms.0 for ; Tue, 06 Sep 2022 09:47:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=re6cY3b7LhtgjVns3TGnT3S1+gVlK6XqwvcFa/mv1ME=; b=KjpL9gPce9GfquWmLZi31YA4capzkankRSmSWEHvHGCJqpZp2eH3IRWL9Acf5kIS6Q 3aUZxPD/Y1UXUopYYuU0VdHxx55s4aEMydWcmDkScpww6MJiHOeOwThcDXZ3vDMRRg2q fWblLaZ46l7AieQ9aOlvGMcBmR9M0LfhahCz4ifCVJvfhOsCT6nWaFP+dAv2g9LcVxaR mCEYrYyZrF3F78hQ/un6Q4+MC8kfyPxOZRXjM0NUBkwM4TWnIfsiC0ie/vnkk5RQP12I oxhC6/mvxO+w11rEQF+SjSy0uZupQmyUSKGa99vDaRkAViSg2u6eLndUoBfFHXH1ydJT 5+qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=re6cY3b7LhtgjVns3TGnT3S1+gVlK6XqwvcFa/mv1ME=; b=DQWe3pNC7xcgelpUQP/u9fs2nfx3HsQ6W8Kw4L3iBwvoHHDGfwMtybEw8V2xDhhqGe NQQacxUhnGBdXravagwkNil1r2Ote/C1NFUK9461gC0VaURJ1z4O9L5E601rOPQUW/Tt Xg5WFZWLqDU1H0Q7tU0UZznKPG4Q7hQz3nu4p8dozlqVwHi7+mskldpzOaToM37Dlsty mKZu6RS6mCgV8gbeKX2fnxtDiZKW5pW9RtyU3omgU78d4ttF9Jp423/IvGwLRy/C6fqh vb6c0ID05o7WL5TVeD36/kXoEQ3KcA+ozdBpT23SSytOUyxluycinJaq0glcGfLAg80Y Kf/A== X-Gm-Message-State: ACgBeo0AFunr5wkQzjRTNE0QM9J0SFEXgEtK0WyfafJtSqxPimEXGmRL nWPiD8+KngGNhdRx+KKVYiHiSQ== X-Google-Smtp-Source: AA6agR5zfI3EV/KSyUhZtILFIlXY+U646eq+jbERhN32np9LTr3WVIhNttonSI7tKZfIDEN518zprA== X-Received: by 2002:a05:600c:358f:b0:3a6:145:3500 with SMTP id p15-20020a05600c358f00b003a601453500mr14878386wmq.64.1662482860172; Tue, 06 Sep 2022 09:47:40 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:47:39 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v3 02/30] thermal/sysfs: Do not make get_trip_hyst optional Date: Tue, 6 Sep 2022 18:46:52 +0200 Message-Id: <20220906164720.330701-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The get_trip_hyst() ops is optional. It results all around the thermal framework code a check against the ops pointer and different action adding more complexity and making the code less readable and understandable. A zero hysteresis value is perfectly valid, so instead of adding more circumvolutions in the code, create unconditionnaly the hysteresis and use the thermal_zone_get_trip() function which returns a zero hysteresis if the get_trip_hyst() is not defined. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_sysfs.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysf= s.c index 75f6b151a58b..18cdd7cd0008 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -424,23 +424,20 @@ static int create_trip_attrs(struct thermal_zone_devi= ce *tz, int mask) return -ENOMEM; } =20 - if (tz->ops->get_trip_hyst) { - tz->trip_hyst_attrs =3D kcalloc(tz->num_trips, - sizeof(*tz->trip_hyst_attrs), - GFP_KERNEL); - if (!tz->trip_hyst_attrs) { - kfree(tz->trip_type_attrs); - kfree(tz->trip_temp_attrs); - return -ENOMEM; - } + tz->trip_hyst_attrs =3D kcalloc(tz->num_trips, + sizeof(*tz->trip_hyst_attrs), + GFP_KERNEL); + if (!tz->trip_hyst_attrs) { + kfree(tz->trip_type_attrs); + kfree(tz->trip_temp_attrs); + return -ENOMEM; } =20 attrs =3D kcalloc(tz->num_trips * 3 + 1, sizeof(*attrs), GFP_KERNEL); if (!attrs) { kfree(tz->trip_type_attrs); kfree(tz->trip_temp_attrs); - if (tz->ops->get_trip_hyst) - kfree(tz->trip_hyst_attrs); + kfree(tz->trip_hyst_attrs); return -ENOMEM; } =20 @@ -473,9 +470,6 @@ static int create_trip_attrs(struct thermal_zone_device= *tz, int mask) } attrs[indx + tz->num_trips] =3D &tz->trip_temp_attrs[indx].attr.attr; =20 - /* create Optional trip hyst attribute */ - if (!tz->ops->get_trip_hyst) - continue; snprintf(tz->trip_hyst_attrs[indx].name, THERMAL_NAME_LENGTH, "trip_point_%d_hyst", indx); =20 @@ -512,8 +506,7 @@ static void destroy_trip_attrs(struct thermal_zone_devi= ce *tz) =20 kfree(tz->trip_type_attrs); kfree(tz->trip_temp_attrs); - if (tz->ops->get_trip_hyst) - kfree(tz->trip_hyst_attrs); + kfree(tz->trip_hyst_attrs); kfree(tz->trips_attribute_group.attrs); } =20 --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 2CCDDECAAA1 for ; Tue, 6 Sep 2022 17:00:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239183AbiIFRAx (ORCPT ); Tue, 6 Sep 2022 13:00:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238989AbiIFQ77 (ORCPT ); Tue, 6 Sep 2022 12:59:59 -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 AF8F380492 for ; Tue, 6 Sep 2022 09:47:42 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id bp20so15868582wrb.9 for ; Tue, 06 Sep 2022 09:47:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Ot6aPvSiYXAp0Hkm+zPI98RcgU3lQfSUO9dLDinpKfk=; b=R9LKx1uTzEaYApU3EXTyHatqRhMBCHBwziqyhSZSAwX4hmbIZQAzfKf0RwSiHUtsi4 haMiGCiGnIc2WyS8oVn0QkiWCeMNWLSk0YyLbAx4ZEcjIjVF30GXHrEcNT6+yUhlRqHF tGxsx4SmXmtiQGY2lvVHhBuAYuvczUgI3YcUwCnYV4vjQIMLUchLSME38qQLGOZtGT3+ AJyq/E0JDLCoZFMWieXRj/QJNrC6sQc2y1igYDzUjPfy33LiYJKUNkhpGxXpDLCgujub jd18lzUZ4ziwVrClO8+SktoA+pOBPuZRgzFImTTV/gibSJ7997aaZDlYTrdRIetKV2q/ RGIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Ot6aPvSiYXAp0Hkm+zPI98RcgU3lQfSUO9dLDinpKfk=; b=x273qr+/Uf5UeMeVZ9+DXFfhCgdP3Hd7xlXj6oHf9I6hnW7dPlK5BcItu3hnuFQTjo As6xFdGWx6YT4lEKV76DZZaWVFBbUEp4N7tUqd5PmrMw56W5Y4cfNP4pdVU+M414f/3F Hx+PYQtgs/QE7Ot7GNmHaD8vJF5k5T6cwF3o1USk5auIXNFtLK/5FkX6cHtLWiYNv/E+ eNKLDV8ZK6ll6LZOYhBfhAPWWbikYdanLitH/Xv+FjEe56X8FM08he2NDZ6cZpOpwnmP c0dj5bcNr5qdX30LaepfqS8v1Ft3DPn1EK4o+AmzbRBjkKLJKghxfNTbpYdhUcqJcw0N 00sg== X-Gm-Message-State: ACgBeo3/zWTTtkKi0Gqljd3lqWxo0Cdr3od7VKb9Od3+zvRkAbqUMkB+ b7mBSPpR/1NUj87cJkpn6HUn8KJVBjmMKg== X-Google-Smtp-Source: AA6agR58hF/EPIE5pyJMbSrXNtT73b2qqm7uOYKunTKqhahhIjGCiIQolZm3CYpiKzgStA3nAKStqg== X-Received: by 2002:adf:f051:0:b0:228:830a:4963 with SMTP id t17-20020adff051000000b00228830a4963mr6304620wro.586.1662482861365; Tue, 06 Sep 2022 09:47:41 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.47.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:47:40 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v3 03/30] thermal/core: Add a generic thermal_zone_set_trip() function Date: Tue, 6 Sep 2022 18:46:53 +0200 Message-Id: <20220906164720.330701-4-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal zone ops defines a set_trip callback where we can invoke the backend driver to set an interrupt for the next trip point temperature being crossed the way up or down, or setting the low level with the hysteresis. The ops is only called from the thermal sysfs code where the userspace has the ability to modify a trip point characteristic. With the effort of encapsulating the thermal framework core code, let's create a thermal_zone_set_trip() which is the writable side of the thermal_zone_get_trip() and put there all the ops encapsulation. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.c | 44 ++++++++++++++++++++++++++++++ drivers/thermal/thermal_sysfs.c | 48 +++++++++++---------------------- include/linux/thermal.h | 3 +++ 3 files changed, 63 insertions(+), 32 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 381d85ec74a0..fa0f89a24b68 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1183,6 +1183,50 @@ int thermal_zone_get_trip(struct thermal_zone_device= *tz, int trip_id, } EXPORT_SYMBOL_GPL(thermal_zone_get_trip); =20 +int thermal_zone_set_trip(struct thermal_zone_device *tz, int trip_id, + const struct thermal_trip *trip) +{ + struct thermal_trip t; + int ret =3D -EINVAL; + + mutex_lock(&tz->lock); + + if (!tz->ops->set_trip_temp && !tz->ops->set_trip_hyst && !tz->trips) + goto out; + + ret =3D __thermal_zone_get_trip(tz, trip_id, &t); + if (ret) + goto out; + + if ((t.temperature !=3D trip->temperature) && tz->ops->set_trip_temp) { + + ret =3D tz->ops->set_trip_temp(tz, trip_id, trip->temperature); + if (ret) + goto out; + } + + if ((t.hysteresis !=3D trip->hysteresis) && tz->ops->set_trip_hyst) { + + ret =3D tz->ops->set_trip_hyst(tz, trip_id, trip->hysteresis); + if (ret) + goto out; + } + + if (((t.temperature !=3D trip->temperature) || + (t.hysteresis !=3D trip->hysteresis)) && tz->trips) + tz->trips[trip_id] =3D *trip; + +out: + mutex_unlock(&tz->lock); + + if (!ret) { + thermal_notify_tz_trip_change(tz->id, trip_id, trip->type, + trip->temperature, trip->hysteresis); + thermal_zone_device_update(tz, THERMAL_TRIP_CHANGED); + } +=09 + return ret; +} =20 /** * thermal_zone_device_register_with_trips() - register a new thermal zone= device diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysf= s.c index 18cdd7cd0008..8d7b25ab67c2 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -115,31 +115,20 @@ trip_point_temp_store(struct device *dev, struct devi= ce_attribute *attr, struct thermal_trip trip; int trip_id, ret; =20 - if (!tz->ops->set_trip_temp && !tz->trips) - return -EPERM; - if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip_id) !=3D 1) return -EINVAL; =20 - if (kstrtoint(buf, 10, &trip.temperature)) - return -EINVAL; - - ret =3D tz->ops->set_trip_temp(tz, trip_id, trip.temperature); + ret =3D thermal_zone_get_trip(tz, trip_id, &trip); if (ret) return ret; =20 - if (tz->trips) - tz->trips[trip_id].temperature =3D trip.temperature; + if (kstrtoint(buf, 10, &trip.temperature)) + return -EINVAL; =20 - ret =3D thermal_zone_get_trip(tz, trip_id, &trip); + ret =3D thermal_zone_set_trip(tz, trip_id, &trip); if (ret) return ret; =20 - thermal_notify_tz_trip_change(tz->id, trip_id, trip.type, - trip.temperature, trip.hysteresis); - - thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); - return count; } =20 @@ -166,29 +155,24 @@ trip_point_hyst_store(struct device *dev, struct devi= ce_attribute *attr, const char *buf, size_t count) { struct thermal_zone_device *tz =3D to_thermal_zone(dev); - int trip, ret; - int temperature; - - if (!tz->ops->set_trip_hyst) - return -EPERM; + struct thermal_trip trip; + int trip_id, ret; =20 - if (sscanf(attr->attr.name, "trip_point_%d_hyst", &trip) !=3D 1) + if (sscanf(attr->attr.name, "trip_point_%d_hyst", &trip_id) !=3D 1) return -EINVAL; =20 - if (kstrtoint(buf, 10, &temperature)) - return -EINVAL; + ret =3D thermal_zone_get_trip(tz, trip_id, &trip); + if (ret) + return ret; =20 - /* - * We are not doing any check on the 'temperature' value - * here. The driver implementing 'set_trip_hyst' has to - * take care of this. - */ - ret =3D tz->ops->set_trip_hyst(tz, trip, temperature); + if (kstrtoint(buf, 10, &trip.hysteresis)) + return -EINVAL; =20 - if (!ret) - thermal_zone_set_trips(tz); + ret =3D thermal_zone_set_trip(tz, trip_id, &trip); + if (ret) + return ret; =20 - return ret ? ret : count; + return count; } =20 static ssize_t diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 09dc09228717..5350a437f245 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -338,6 +338,9 @@ static inline void devm_thermal_of_zone_unregister(stru= ct device *dev, int thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id, struct thermal_trip *trip); =20 +int thermal_zone_set_trip(struct thermal_zone_device *tz, int trip_id, + const struct thermal_trip *trip); + int thermal_zone_get_num_trips(struct thermal_zone_device *tz); =20 #ifdef CONFIG_THERMAL --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 91358ECAAD5 for ; Tue, 6 Sep 2022 17:01:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239207AbiIFRA5 (ORCPT ); Tue, 6 Sep 2022 13:00:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233687AbiIFRAA (ORCPT ); Tue, 6 Sep 2022 13:00:00 -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 5A0C91180C for ; Tue, 6 Sep 2022 09:47:44 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id ay39-20020a05600c1e2700b003a5503a80cfso7816681wmb.2 for ; Tue, 06 Sep 2022 09:47:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=yxHcU1hX4elGm4XFMd+giLQwBSqd0y+6MVuYVIhVRhA=; b=wC0u5ZDKxe8XektZYNhAzGgvvSfEj7QchsVhEdjnPiI4VTbCufKAwpamuaVENu/3cj Ggl91i5CGv+W/OtgeYuGftKjatlwKhcNy7tBrxLnY5a9+/xJry8qDtOEPR0A0mMPAxWR 5HPfLTdxjxV/OSLWCIQFFnVapWizHqJf2OZAWNCz0ziMTh+WQrNJrzuqeqQdj+692WMW RQkG2wze3vtJTx2MsXa8qOBl2v28YoGZA+2FnVXH+Mv2A/BRoUc1v+baCjjvyf7/gnTr Tzd01xWRK4oVdiWQbCoRjSZ5OUmDWqhqAB1ffi4A4wI1m5orpAaiXM2Dxmp5J77hz0bd 9F+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=yxHcU1hX4elGm4XFMd+giLQwBSqd0y+6MVuYVIhVRhA=; b=iQKWBi3eq1/q+TKsU1vLwWy+UJFmCkjaKoxW+jAafrhkBYw7lhQP5p/sPL30RvtLXW /xhZ9beSP9IoARU6ATgkuPUn6dp+VIIP89hMhRUZNKPFhlzq/xJen0+z09Ebom5mex5J zqEeas2hQERwEz19TaWA3iVEdbF3B7PBJrmgCZM8W7ueDjJqVvxjoxuy80A5NV6sSwvZ XxqnHg7HZFASPr7PABMgvVl7AYtg6fw1uagnN2ANj8CnBQkbGyejownZFs3FA55zKZpD 7CBYtE85yKa6noMHFBLsHAz0e+Ua8kWjL4EepDSqydfXeDusjXqXQQnY7Iu2PkyMLMjq eyAg== X-Gm-Message-State: ACgBeo2kZT6AWGDpxgf9Losr+kAxPoTAeeVDLnUvXfy0aF57wk3RiHE1 wP+U27FSRoENEwkrZ1+KwUXC2A== X-Google-Smtp-Source: AA6agR7zpWKGpwuAeGWCXAABPKqNUO2h1nGOBfQ+nCTtY820MxbzTgfZPxJXHaBZLmpJMmCpfXVnnA== X-Received: by 2002:a05:600c:a0a:b0:3a6:71e5:fb70 with SMTP id z10-20020a05600c0a0a00b003a671e5fb70mr14114058wmp.141.1662482862434; Tue, 06 Sep 2022 09:47:42 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.47.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:47:42 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v3 04/30] thermal/core: Add a generic thermal_zone_get_crit_temp() function Date: Tue, 6 Sep 2022 18:46:54 +0200 Message-Id: <20220906164720.330701-5-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal zone ops defines a callback to retrieve the critical temperature. As the trip handling is being reworked, all the trip points will be the same whatever the driver and consequently finding the critical trip temperature will be just a loop to search for a critical trip point type. Provide such a generic function, so we encapsulate the ops get_crit_temp() which can be removed when all the backend drivers are using the generic trip points handling. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.c | 27 +++++++++++++++++++++++++++ include/linux/thermal.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index fa0f89a24b68..2495c174a226 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1144,6 +1144,33 @@ int thermal_zone_get_num_trips(struct thermal_zone_d= evice *tz) } EXPORT_SYMBOL_GPL(thermal_zone_get_num_trips); =20 +int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp) +{ + int i, ret =3D 0; + + if (tz->ops->get_crit_temp) + return tz->ops->get_crit_temp(tz, temp); +=09 + if (!tz->trips) + return -EINVAL; + + mutex_lock(&tz->lock); + + for (i =3D 0; i < tz->num_trips; i++) { + if (tz->trips[i].type =3D=3D THERMAL_TRIP_CRITICAL) { + *temp =3D tz->trips[i].temperature; + goto out; + } + } + + ret =3D -EINVAL; +out: + mutex_unlock(&tz->lock); + + return ret; +} +EXPORT_SYMBOL_GPL(thermal_zone_get_crit_temp); + static int __thermal_zone_get_trip(struct thermal_zone_device *tz, int tri= p_id, struct thermal_trip *trip) { diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 5350a437f245..66373f872237 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -343,6 +343,8 @@ int thermal_zone_set_trip(struct thermal_zone_device *t= z, int trip_id, =20 int thermal_zone_get_num_trips(struct thermal_zone_device *tz); =20 +int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp); + #ifdef CONFIG_THERMAL struct thermal_zone_device *thermal_zone_device_register(const char *, int= , int, void *, struct thermal_zone_device_ops *, --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 F3D11ECAAD5 for ; Tue, 6 Sep 2022 17:01:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237638AbiIFRBW (ORCPT ); Tue, 6 Sep 2022 13:01:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233997AbiIFRAB (ORCPT ); Tue, 6 Sep 2022 13:00:01 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 505F1B1D1 for ; Tue, 6 Sep 2022 09:47:46 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id n17-20020a05600c501100b003a84bf9b68bso7799929wmr.3 for ; Tue, 06 Sep 2022 09:47:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=7quZAPuMcAvt+QXLI2xXiL2djdLPPOTNpr/QroOkKRY=; b=b/gK5Dxsy/lafTFAJjJ5yingaUhta2x4KQEobPkeYo82YOvbWpiO1zZHmjJgaRF60i LGhForBwPwhQ/Pgv8t1qlZqmGcMfBBJX1tAbbwgr+wZPQAJkoPC2pNLAcNGBjfioKIvn rT2/WliyhgEGpx8EW37Fp7emHC9SFHLxBqvdSTLh3XefHocQCP7zn2fGFztwINfNc484 BsbTO5xXK76tNEiBOblB6bbxO8lRbtVTf1YaYBkNfGa8P8cyAXi+5WzE3k2hF6KUSmcC Wx5CggosdtXo0UrTSTDGucLhKvLTNeCRK98NVhLEDIHHSJAm2KqEFnEtE+u4QO6hBa4m 056A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=7quZAPuMcAvt+QXLI2xXiL2djdLPPOTNpr/QroOkKRY=; b=uGncW/VLc35pvNwavjdA99XCRL1Ca12HccCLeyhz3oUOfybWjC0iKwA+fsusua4gQP bHWQnFYgUTFfmVzEVOH/n0oHXhRnCVH4Elici3JqbHfZQRJqQX4uZxeFTeDZtF0colqx ajdNr+ZKwrqFTcr5X30cVWlgZGiKXbX/wBjSw+DtMSf/vH0nMoUZB2aGiDv2UeGIFHMn x0F1qsmMeqX5aihhEf/k3+2/mTPAf8F1qzkO0u/cW7aYOGfvvqEb+enkVJLVJmhSoAZt 9RSHP9DuM9ELfLZyIzRuUpW2LAseOtzl5FNj8TJUJV2aRKfYm1QxvUMZm1HMujhXv2Gl /4zw== X-Gm-Message-State: ACgBeo12hIiXunZKWsqP4PmQqI1WsFEdbuXrHdewz3FoIfNjp5QmJgjl O9UMtAMk5b/X3GG26AhZJimuoxjWcANW/w== X-Google-Smtp-Source: AA6agR5y1ttzSs50fLwE7af5SertSL0xpIfzvHoAEqlZ0YU8PzkMShSE3eYZVcV0D3HcRL31D7oq7g== X-Received: by 2002:a05:600c:1e8b:b0:3a6:1a09:2a89 with SMTP id be11-20020a05600c1e8b00b003a61a092a89mr14108660wmb.108.1662482863621; Tue, 06 Sep 2022 09:47:43 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.47.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:47:43 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Amit Kucheria , Zhang Rui , Lukasz Luba Subject: [PATCH v3 05/30] thermal/core/governors: Use thermal_zone_get_trip() instead of ops functions Date: Tue, 6 Sep 2022 18:46:55 +0200 Message-Id: <20220906164720.330701-6-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-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 a08bbe33be96..09234f3d2fb9 100644 --- a/drivers/thermal/gov_bang_bang.c +++ b/drivers/thermal/gov_bang_bang.c @@ -13,26 +13,19 @@ =20 #include "thermal_core.h" =20 -static void thermal_zone_trip_update(struct thermal_zone_device *tz, int t= rip) +static void thermal_zone_trip_update(struct thermal_zone_device *tz, int t= rip_id) { - int trip_temp, trip_hyst; + struct thermal_trip trip; struct thermal_instance *instance; =20 - tz->ops->get_trip_temp(tz, trip, &trip_temp); - - if (!tz->ops->get_trip_hyst) { - pr_warn_once("Undefined get_trip_hyst for thermal zone %s - " - "running with default hysteresis zero\n", tz->type); - trip_hyst =3D 0; - } else - tz->ops->get_trip_hyst(tz, trip, &trip_hyst); + thermal_zone_get_trip(tz, trip_id, &trip); =20 dev_dbg(&tz->device, "Trip%d[temp=3D%d]:temp=3D%d:hyst=3D%d\n", - trip, trip_temp, tz->temperature, - trip_hyst); + trip_id, trip.temperature, tz->temperature, + trip.hysteresis); =20 list_for_each_entry(instance, &tz->thermal_instances, tz_node) { - if (instance->trip !=3D trip) + if (instance->trip !=3D trip_id) continue; =20 /* in case fan is in initial state, switch the fan off */ @@ -50,10 +43,10 @@ static void thermal_zone_trip_update(struct thermal_zon= e_device *tz, int trip) * enable fan when temperature exceeds trip_temp and disable * the fan in case it falls below trip_temp minus hysteresis */ - if (instance->target =3D=3D 0 && tz->temperature >=3D trip_temp) + if (instance->target =3D=3D 0 && tz->temperature >=3D trip.temperature) instance->target =3D 1; else if (instance->target =3D=3D 1 && - tz->temperature <=3D trip_temp - trip_hyst) + tz->temperature <=3D trip.temperature - trip.hysteresis) instance->target =3D 0; =20 dev_dbg(&instance->cdev->device, "target=3D%d\n", diff --git a/drivers/thermal/gov_fair_share.c b/drivers/thermal/gov_fair_sh= are.c index a4ee4661e9cc..c515e7a52294 100644 --- a/drivers/thermal/gov_fair_share.c +++ b/drivers/thermal/gov_fair_share.c @@ -21,16 +21,12 @@ */ static int get_trip_level(struct thermal_zone_device *tz) { - int count =3D 0; - int trip_temp; - enum thermal_trip_type trip_type; - - if (tz->num_trips =3D=3D 0 || !tz->ops->get_trip_temp) - return 0; + struct thermal_trip trip; + int count; =20 for (count =3D 0; count < tz->num_trips; count++) { - tz->ops->get_trip_temp(tz, count, &trip_temp); - if (tz->temperature < trip_temp) + thermal_zone_get_trip(tz, count, &trip); + if (tz->temperature < trip.temperature) break; } =20 @@ -38,10 +34,8 @@ static int get_trip_level(struct thermal_zone_device *tz) * count > 0 only if temperature is greater than first trip * point, in which case, trip_point =3D count - 1 */ - if (count > 0) { - tz->ops->get_trip_type(tz, count - 1, &trip_type); - trace_thermal_zone_trip(tz, count - 1, trip_type); - } + if (count > 0) + trace_thermal_zone_trip(tz, count - 1, trip.type); =20 return count; } diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_po= wer_allocator.c index 2d1aeaba38a8..2ef86ced4c7c 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -125,16 +125,15 @@ static void estimate_pid_constants(struct thermal_zon= e_device *tz, u32 sustainable_power, int trip_switch_on, int control_temp) { + struct thermal_trip trip; + u32 temperature_threshold =3D control_temp; int ret; - int switch_on_temp; - u32 temperature_threshold; s32 k_i; =20 - ret =3D tz->ops->get_trip_temp(tz, trip_switch_on, &switch_on_temp); - if (ret) - switch_on_temp =3D 0; + ret =3D thermal_zone_get_trip(tz, trip_switch_on, &trip); + if (!ret) + temperature_threshold -=3D trip.temperature; =20 - temperature_threshold =3D control_temp - switch_on_temp; /* * estimate_pid_constants() tries to find appropriate default * values for thermal zones that don't provide them. If a @@ -520,10 +519,10 @@ static void get_governor_trips(struct thermal_zone_de= vice *tz, last_passive =3D INVALID_TRIP; =20 for (i =3D 0; i < tz->num_trips; i++) { - enum thermal_trip_type type; + struct thermal_trip trip; int ret; =20 - ret =3D tz->ops->get_trip_type(tz, i, &type); + ret =3D thermal_zone_get_trip(tz, i, &trip); if (ret) { dev_warn(&tz->device, "Failed to get trip point %d type: %d\n", i, @@ -531,14 +530,14 @@ static void get_governor_trips(struct thermal_zone_de= vice *tz, continue; } =20 - if (type =3D=3D THERMAL_TRIP_PASSIVE) { + if (trip.type =3D=3D THERMAL_TRIP_PASSIVE) { if (!found_first_passive) { params->trip_switch_on =3D i; found_first_passive =3D true; } else { last_passive =3D i; } - } else if (type =3D=3D THERMAL_TRIP_ACTIVE) { + } else if (trip.type =3D=3D THERMAL_TRIP_ACTIVE) { last_active =3D i; } else { break; @@ -633,7 +632,7 @@ static int power_allocator_bind(struct thermal_zone_dev= ice *tz) { int ret; struct power_allocator_params *params; - int control_temp; + struct thermal_trip trip; =20 ret =3D check_power_actors(tz); if (ret) @@ -659,13 +658,12 @@ static int power_allocator_bind(struct thermal_zone_d= evice *tz) get_governor_trips(tz, params); =20 if (tz->num_trips > 0) { - ret =3D tz->ops->get_trip_temp(tz, - params->trip_max_desired_temperature, - &control_temp); + ret =3D thermal_zone_get_trip(tz, params->trip_max_desired_temperature, + &trip); if (!ret) estimate_pid_constants(tz, tz->tzp->sustainable_power, params->trip_switch_on, - control_temp); + trip.temperature); } =20 reset_pid_controller(params); @@ -695,11 +693,11 @@ static void power_allocator_unbind(struct thermal_zon= e_device *tz) tz->governor_data =3D NULL; } =20 -static int power_allocator_throttle(struct thermal_zone_device *tz, int tr= ip) +static int power_allocator_throttle(struct thermal_zone_device *tz, int tr= ip_id) { - int ret; - int switch_on_temp, control_temp; struct power_allocator_params *params =3D tz->governor_data; + struct thermal_trip trip; + int ret; bool update; =20 lockdep_assert_held(&tz->lock); @@ -708,13 +706,12 @@ static int power_allocator_throttle(struct thermal_zo= ne_device *tz, int trip) * We get called for every trip point but we only need to do * our calculations once */ - if (trip !=3D params->trip_max_desired_temperature) + if (trip_id !=3D params->trip_max_desired_temperature) return 0; =20 - ret =3D tz->ops->get_trip_temp(tz, params->trip_switch_on, - &switch_on_temp); - if (!ret && (tz->temperature < switch_on_temp)) { - update =3D (tz->last_temperature >=3D switch_on_temp); + ret =3D thermal_zone_get_trip(tz, params->trip_switch_on, &trip); + if (!ret && (tz->temperature < trip.temperature)) { + update =3D (tz->last_temperature >=3D trip.temperature); tz->passive =3D 0; reset_pid_controller(params); allow_maximum_power(tz, update); @@ -723,16 +720,14 @@ static int power_allocator_throttle(struct thermal_zo= ne_device *tz, int trip) =20 tz->passive =3D 1; =20 - ret =3D tz->ops->get_trip_temp(tz, params->trip_max_desired_temperature, - &control_temp); + ret =3D thermal_zone_get_trip(tz, params->trip_max_desired_temperature, &= trip); if (ret) { - dev_warn(&tz->device, - "Failed to get the maximum desired temperature: %d\n", + dev_warn(&tz->device, "Failed to get the maximum desired temperature: %d= \n", ret); return ret; } =20 - return allocate_power(tz, control_temp); + return allocate_power(tz, trip.temperature); } =20 static struct thermal_governor thermal_gov_power_allocator =3D { diff --git a/drivers/thermal/gov_step_wise.c b/drivers/thermal/gov_step_wis= e.c index cdd3354bc27f..3cb16d7e65d1 100644 --- a/drivers/thermal/gov_step_wise.c +++ b/drivers/thermal/gov_step_wise.c @@ -95,30 +95,28 @@ static void update_passive_instance(struct thermal_zone= _device *tz, tz->passive +=3D value; } =20 -static void thermal_zone_trip_update(struct thermal_zone_device *tz, int t= rip) +static void thermal_zone_trip_update(struct thermal_zone_device *tz, int t= rip_id) { - int trip_temp; - enum thermal_trip_type trip_type; enum thermal_trend trend; struct thermal_instance *instance; + struct thermal_trip trip; bool throttle =3D false; int old_target; =20 - tz->ops->get_trip_temp(tz, trip, &trip_temp); - tz->ops->get_trip_type(tz, trip, &trip_type); + thermal_zone_get_trip(tz, trip_id, &trip); =20 - trend =3D get_tz_trend(tz, trip); + trend =3D get_tz_trend(tz, trip_id); =20 - if (tz->temperature >=3D trip_temp) { + if (tz->temperature >=3D trip.temperature) { throttle =3D true; - trace_thermal_zone_trip(tz, trip, trip_type); + trace_thermal_zone_trip(tz, trip_id, trip.type); } =20 dev_dbg(&tz->device, "Trip%d[type=3D%d,temp=3D%d]:trend=3D%d,throttle=3D%= d\n", - trip, trip_type, trip_temp, trend, throttle); + trip_id, trip.type, trip.temperature, trend, throttle); =20 list_for_each_entry(instance, &tz->thermal_instances, tz_node) { - if (instance->trip !=3D trip) + if (instance->trip !=3D trip_id) continue; =20 old_target =3D instance->target; @@ -132,11 +130,11 @@ static void thermal_zone_trip_update(struct thermal_z= one_device *tz, int trip) /* Activate a passive thermal instance */ if (old_target =3D=3D THERMAL_NO_TARGET && instance->target !=3D THERMAL_NO_TARGET) - update_passive_instance(tz, trip_type, 1); + update_passive_instance(tz, trip.type, 1); /* Deactivate a passive thermal instance */ else if (old_target !=3D THERMAL_NO_TARGET && instance->target =3D=3D THERMAL_NO_TARGET) - update_passive_instance(tz, trip_type, -1); + update_passive_instance(tz, trip.type, -1); =20 instance->initialized =3D true; mutex_lock(&instance->cdev->lock); --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 5BF19ECAAD5 for ; Tue, 6 Sep 2022 17:01:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234621AbiIFRBb (ORCPT ); Tue, 6 Sep 2022 13:01:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234573AbiIFRAC (ORCPT ); Tue, 6 Sep 2022 13:00:02 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5882B1AD98 for ; Tue, 6 Sep 2022 09:47:46 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id bd26-20020a05600c1f1a00b003a5e82a6474so7804196wmb.4 for ; Tue, 06 Sep 2022 09:47:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=NVPF6vnmjrMx5FQU0j+pKHlND8VmvL5OT3fQ9b1KMis=; b=VonoxkcxIL2unigQaZGkuIci+dOBagh1r3V28iduu70oMma3G18boGx+QtwykPWQtk hbbdVfFoeX5JumIQxIalywTLJoFC3QH/9bfZ9ibIlsVXDGMlxL3f9KbtYOT8PCFcLMHm xoziLjJdzpVGmd6ud3cYyCcj/SXI9guiSU6PdNUk3JIT8S7O8lES4usvY++yD5EqF/kc YZMK+CnL9rUyLOGYYI2uXSF+yarh143ol3U+jqJWULGcWlDJuaVgDEfMpEi0tSu7NAeO YvyijtUitgtU9Tkn2EMCxurP2MvgPKJmxqOC2QHxrZ0sRMuuOtI2vQOZb3zOX90I00zO n9/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=NVPF6vnmjrMx5FQU0j+pKHlND8VmvL5OT3fQ9b1KMis=; b=JViwAwnKd+/6NS/hKFjM2Vf7vD6CwEb0tlkV2LcpS3LIaOnD+gYyd7FCawp9oJn4qA 0l2MR/yBGVyTttXtcI1OMzNvVYj8K4DwwlUAN1tMXaRR4l2uv1xtVVHAxtMPwt6IQhE8 Zy+nB0q4DPk4Lt7MpgmpWFRF2dcVKOBWUtpj4nGbmp3traUFJOu1vSk0MV1y1pY2HUS+ VpN8RR/ZsCnv3eDAaaB8NC2o+NjFhUJCuARLq52CYpStKbYvitjAKBvt8zbajLJ3TN2Y 6ZjVRQFvyiLoXfZBE8/U9JQWHp36PzkeyloK5M1gGWTQ0cg63rK4gcCaNAFjOdC/Dt0B pVeg== X-Gm-Message-State: ACgBeo0Cmt5PD9DIhnzpIsGu4iRHS32Op4I1xijk/+Vcd7tm2ZADAk0T Ya9QhRsyqOK8UhApaO9lIJ5LqA== X-Google-Smtp-Source: AA6agR7wKi7L4yH40a5HX1OTjeK0srJpIUh1sQ+Wyk/tiNO/QgoEMma0Y4ta99lDwAR3CUoSwKGIMQ== X-Received: by 2002:a05:600c:3556:b0:3a6:220e:6242 with SMTP id i22-20020a05600c355600b003a6220e6242mr13849422wmq.145.1662482864680; Tue, 06 Sep 2022 09:47:44 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.47.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:47:44 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v3 06/30] thermal/of: Use generic thermal_zone_get_trip() function Date: Tue, 6 Sep 2022 18:46:56 +0200 Message-Id: <20220906164720.330701-7-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. The thermal OF code uses the thermal_zone_device_register_with_trips() function. It builds the trips array and pass it to the register function. That means the get_trip_* ops are duplicated with what does already the core code. Remove them. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index d4b6335ace15..5cce83639085 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -71,39 +71,6 @@ of_thermal_get_trip_points(struct thermal_zone_device *t= z) } EXPORT_SYMBOL_GPL(of_thermal_get_trip_points); =20 -static int of_thermal_get_trip_type(struct thermal_zone_device *tz, int tr= ip, - enum thermal_trip_type *type) -{ - if (trip >=3D tz->num_trips || trip < 0) - return -EDOM; - - *type =3D tz->trips[trip].type; - - return 0; -} - -static int of_thermal_get_trip_temp(struct thermal_zone_device *tz, int tr= ip, - int *temp) -{ - if (trip >=3D tz->num_trips || trip < 0) - return -EDOM; - - *temp =3D tz->trips[trip].temperature; - - return 0; -} - -static int of_thermal_get_trip_hyst(struct thermal_zone_device *tz, int tr= ip, - int *hyst) -{ - if (trip >=3D tz->num_trips || trip < 0) - return -EDOM; - - *hyst =3D tz->trips[trip].hysteresis; - - return 0; -} - static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int tr= ip, int hyst) { @@ -626,9 +593,6 @@ struct thermal_zone_device *thermal_of_zone_register(st= ruct device_node *sensor, goto out_kfree_trips; } =20 - of_ops->get_trip_type =3D of_ops->get_trip_type ? : of_thermal_get_trip_t= ype; - of_ops->get_trip_temp =3D of_ops->get_trip_temp ? : of_thermal_get_trip_t= emp; - of_ops->get_trip_hyst =3D of_ops->get_trip_hyst ? : of_thermal_get_trip_h= yst; of_ops->set_trip_hyst =3D of_ops->set_trip_hyst ? : of_thermal_set_trip_h= yst; of_ops->get_crit_temp =3D of_ops->get_crit_temp ? : of_thermal_get_crit_t= emp; of_ops->bind =3D thermal_of_bind; --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 710D8ECAAD5 for ; Tue, 6 Sep 2022 17:01:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239225AbiIFRBG (ORCPT ); Tue, 6 Sep 2022 13:01:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232417AbiIFRAA (ORCPT ); Tue, 6 Sep 2022 13:00:00 -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 01F651ADBB for ; Tue, 6 Sep 2022 09:47:46 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id bq9so3444793wrb.4 for ; Tue, 06 Sep 2022 09:47:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Brk79K68Pth5JpZf/n4X97+hyNwde3ZvZaEoGdSbClA=; b=jObwUaNeQVo3B8xvm7KVeFg8MPjFZ0xfyWRYhOlBbUCRb9chVNg/QtV1JfrSyNI0Gn ijk1xiKAGKyS8Pp3OAN8fL3nt+HFD3m1KyykqIJerck7bvpIOmgyGOk4aW0kTiPQdDuj B5hBjO219QAq6BfP0nGTTsQuBMf253if+rj8ykit7A0zj1US7OfhjSyKH7+JvPtjiUOP 4qFnEHXdZoj6olrol+8XuRNC3o8oUq9PHCPSX2DQh/OpaZ3wiyosYyxoUG2qM4xeCSkP vGBwRu663wZNMp7ewN5f7jCDnPlikElaF+pcUH699mOORUb1B6//92tpd9z9nVCADQxz rc3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Brk79K68Pth5JpZf/n4X97+hyNwde3ZvZaEoGdSbClA=; b=x2A01kHsnpVmaovcgCxynuxM9TrLmpXXuhz45aWhcbn126G9f8DtnFnluSQhAm7DeB Mr7OvxfcNMS8WtMJ3K0xARyJqpKiWHu00wGPN1dGg6JpAqaFYE5TwEpPCgzZaDbFlVVH 4q8iODxfvFPmtsI3sAH2A0p+NpfVE8KulLLPqPUFFiQKvMwgAfvww7UoWf7SqpBp1tHX gWL/qv7WGdxMT9d1S/zC+6NigkjoR0uh7mtM3IyM8lcxJmc1hLkVEHhe7hhJWPh68cnf AMaXA4NFem3RSp2XCatr6FQMk0iVqjCiGpUg2JB3T/cnd7TSolOD+JrN/oGpRLQ6tFLo iKdQ== X-Gm-Message-State: ACgBeo2F7URHopwSMdrOyREzH2nYemgiFT/UEXljkIotI7OWDrZBkyew IRVymex3fALVIVbhkTs8jCFVwg== X-Google-Smtp-Source: AA6agR7O6ixwCX6kbf6Gq+MqS0DkGwc5S54QbBzEfZMb1tqJ1YIQ8vrgacetb+2nmxpdYRCk3zY6dA== X-Received: by 2002:adf:e109:0:b0:225:4ca5:80d5 with SMTP id t9-20020adfe109000000b002254ca580d5mr27573916wrz.465.1662482865881; Tue, 06 Sep 2022 09:47:45 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.47.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:47:45 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v3 07/30] thermal/of: Remove unused functions Date: Tue, 6 Sep 2022 18:46:57 +0200 Message-Id: <20220906164720.330701-8-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Remove the dead code: of_thermal_get_trip_points() Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.h | 7 ------- drivers/thermal/thermal_of.c | 17 ----------------- 2 files changed, 24 deletions(-) diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 1571917bd3c8..99a5d5281037 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -139,8 +139,6 @@ thermal_cooling_device_stats_update(struct thermal_cool= ing_device *cdev, #ifdef CONFIG_THERMAL_OF int of_thermal_get_ntrips(struct thermal_zone_device *); bool of_thermal_is_trip_valid(struct thermal_zone_device *, int); -const struct thermal_trip * -of_thermal_get_trip_points(struct thermal_zone_device *); #else static inline int of_thermal_get_ntrips(struct thermal_zone_device *tz) { @@ -151,11 +149,6 @@ static inline bool of_thermal_is_trip_valid(struct the= rmal_zone_device *tz, { return false; } -static inline const struct thermal_trip * -of_thermal_get_trip_points(struct thermal_zone_device *tz) -{ - return NULL; -} #endif =20 int thermal_zone_device_is_enabled(struct thermal_zone_device *tz); diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 5cce83639085..2f533fc94917 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -54,23 +54,6 @@ bool of_thermal_is_trip_valid(struct thermal_zone_device= *tz, int trip) } EXPORT_SYMBOL_GPL(of_thermal_is_trip_valid); =20 -/** - * of_thermal_get_trip_points - function to get access to a globally expor= ted - * trip points - * - * @tz: pointer to a thermal zone - * - * This function provides a pointer to trip points table - * - * Return: pointer to trip points table, NULL otherwise - */ -const struct thermal_trip * -of_thermal_get_trip_points(struct thermal_zone_device *tz) -{ - return tz->trips; -} -EXPORT_SYMBOL_GPL(of_thermal_get_trip_points); - static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int tr= ip, int hyst) { --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 D8A81ECAAA1 for ; Tue, 6 Sep 2022 17:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232756AbiIFRBm (ORCPT ); Tue, 6 Sep 2022 13:01:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237220AbiIFRAD (ORCPT ); Tue, 6 Sep 2022 13:00:03 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06E9ADF1E for ; Tue, 6 Sep 2022 09:47:48 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id d12-20020a05600c34cc00b003a83d20812fso7817476wmq.1 for ; Tue, 06 Sep 2022 09:47:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Ffj/+IgRhlrRkOtYFWbfnlVsquqreXwCxJyvoKvBP5M=; b=W6OowTe7nX5Tu83zZ06/DlToCVod/nz1UmaXYt1n0TdoeHsLqBI4Dtsi4GhqPZP8GV f7AMVFRH25AMn8/j+KocZjyvK/QWuUsQQMlpFm2r7askDFLpphuYA2MskzfvLWHcmwTR IsLEE67H0SnejCnIXovCYTRmda0ZNSkek5LMMWHnR4+EOhGU6St7o15zAVWSNySEtu/k rSc3myDJaPxa5xJjmcADoTci5TJWlsqxdmHrRtd0Q2XX5hie1ZJkoZ4FcnjjcKrTGjxl qslGA5EYksVxR9ugcFenjaEkwCriSe2bNHkfoMo0tCftIlZ3Osk9uq3GuMuikmwF6hLf EasA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Ffj/+IgRhlrRkOtYFWbfnlVsquqreXwCxJyvoKvBP5M=; b=7gzAf8/7d77cslNgRA+f8PDfyoqLmMyn9WvkzpatS8d3we8dcRfoyfJUFUdg7YfyOK mBXWO/LJb8Nwt7c+8PGKx02qo3IOkg6Ft0IvOE+bywM2x8dBFSVBwLjYuPLR2z//ZCmh fD2Xg90gGIdiXfFPY4j3qiKp01YZ9MU30TYheYClHbmIWcA/BxEg+2rvoiTtsvaW14X/ X/9WVQxoO/mBtxJFOIO9aVLTnYZcr1GlFux40m/NVWhjZAtt6EgtVdNgL51K1WT2DkX2 iEqSaJcH/3EyXgzgrrgO/9Us0Z8as2Q9/FjD/H73UCblX56LM1nYULjnl9GIJ1l7yU2w PQHg== X-Gm-Message-State: ACgBeo0QJ9N13rHom5qZaNFuf/kprrp0zs3Wqr5EIn0oKLP7NgONyI3B 6iCkn30aufw0akxK5BG7eeONww== X-Google-Smtp-Source: AA6agR6qJr5AYVHcV76y6t8qEWii+bNh4lhZPz7VLjl4bBuOCz5W0Lg7wxRDpy26vsY+GTX5K7BuGw== X-Received: by 2002:a05:600c:35d0:b0:3a5:f7ee:82be with SMTP id r16-20020a05600c35d000b003a5f7ee82bemr14267865wmq.206.1662482867071; Tue, 06 Sep 2022 09:47:47 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:47:46 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Amit Kucheria , Zhang Rui , 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 v3 08/30] thermal/drivers/exynos: Use generic thermal_zone_get_trip() function Date: Tue, 6 Sep 2022 18:46:58 +0200 Message-Id: <20220906164720.330701-9-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano Acked-by: Krzysztof Kozlowski --- drivers/thermal/samsung/exynos_tmu.c | 41 +++++++++++----------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung= /exynos_tmu.c index 51874d0a284c..0e33d32a9d2e 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -260,16 +260,8 @@ static int exynos_tmu_initialize(struct platform_devic= e *pdev) { struct exynos_tmu_data *data =3D platform_get_drvdata(pdev); struct thermal_zone_device *tzd =3D data->tzd; - const struct thermal_trip * const trips =3D - of_thermal_get_trip_points(tzd); unsigned int status; - int ret =3D 0, temp, hyst; - - if (!trips) { - dev_err(&pdev->dev, - "Cannot get trip points from device tree!\n"); - return -ENODEV; - } + int ret =3D 0, temp; =20 if (data->soc !=3D SOC_ARCH_EXYNOS5433) /* FIXME */ ret =3D tzd->ops->get_crit_temp(tzd, &temp); @@ -303,19 +295,16 @@ static int exynos_tmu_initialize(struct platform_devi= ce *pdev) =20 /* Write temperature code for rising and falling threshold */ for (i =3D 0; i < ntrips; i++) { - /* Write temperature code for rising threshold */ - ret =3D tzd->ops->get_trip_temp(tzd, i, &temp); - if (ret) - goto err; - temp /=3D MCELSIUS; - data->tmu_set_trip_temp(data, i, temp); =20 - /* Write temperature code for falling threshold */ - ret =3D tzd->ops->get_trip_hyst(tzd, i, &hyst); + struct thermal_trip trip; + =09 + ret =3D thermal_zone_get_trip(tzd, i, &trip); if (ret) goto err; - hyst /=3D MCELSIUS; - data->tmu_set_trip_hyst(data, i, temp, hyst); + + data->tmu_set_trip_temp(data, i, trip.temperature / MCELSIUS); + data->tmu_set_trip_hyst(data, i, trip.temperature / MCELSIUS, + trip.hysteresis / MCELSIUS); } =20 data->tmu_clear_irqs(data); @@ -360,21 +349,23 @@ static void exynos_tmu_control(struct platform_device= *pdev, bool on) } =20 static void exynos4210_tmu_set_trip_temp(struct exynos_tmu_data *data, - int trip, u8 temp) + int trip_id, u8 temp) { - const struct thermal_trip * const trips =3D - of_thermal_get_trip_points(data->tzd); + struct thermal_trip trip; u8 ref, th_code; =20 - ref =3D trips[0].temperature / MCELSIUS; + if (thermal_zone_get_trip(data->tzd, 0, &trip)) + return; =20 - if (trip =3D=3D 0) { + ref =3D trip.temperature / MCELSIUS; +=09 + if (trip_id =3D=3D 0) { th_code =3D temp_to_code(data, ref); writeb(th_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP); } =20 temp -=3D ref; - writeb(temp, data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0 + trip * 4); + writeb(temp, data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0 + trip_id * 4); } =20 /* failing thresholds are not supported on Exynos4210 */ --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 4177AECAAD5 for ; Tue, 6 Sep 2022 17:01:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238870AbiIFRBs (ORCPT ); Tue, 6 Sep 2022 13:01:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238332AbiIFRAG (ORCPT ); Tue, 6 Sep 2022 13:00:06 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 419D92715F for ; Tue, 6 Sep 2022 09:47:50 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id m17-20020a7bce11000000b003a5bedec07bso10000689wmc.0 for ; Tue, 06 Sep 2022 09:47:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=YzUTWEHUQYeukAyJEfTuM3PzyJlxwwnF0DoykmVbPWw=; b=yDo8TXj9fCjqieUCk3hVb901d8qIcTCqR9xiEQlNyW5Fs0IG+yPdUxPIRDIvAWe4Cz P8k9Nwi5MHbjDsvau4h3duQ4A82oDQJiMRKfRlqzbn2PYPQ9z3AiVWc3iPhgd9X9c031 QBNk1Ht9SI7LqxtIvQVuYxP90AkEvbZBLrkFmgtQ3vb9WJ8XxGyrO5RYgNm//+yF2QbE M05Rh+KPe+NdtncAOBLvn/b1PQhnNAI11JfibnUtHQT3zSQDZMpd+hUkdDRfEg7UB9H/ +r4e+tKyj4i7e003+vo+SJ1kD9FLyEpulApDTmkJv3mvCGbOQ950GeEq6jf9iBUKZ/05 FgQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=YzUTWEHUQYeukAyJEfTuM3PzyJlxwwnF0DoykmVbPWw=; b=7skAz3CexbR+hWIWSGFE4LUy+ngy1ThLWJaCL8p/P/RnqM13FJ8qggAk+ieBVqmzDe DzoOKxm6L8Ts/zscIXt9xZIJKGAAdMmR9xqR+LtrwKNowzZSAwsyPVCPAOpSHhno9BTC gEoLpjf6WtHSuzAOx46dlrc/BycsJxuhkB48BfcQicVtnzSpxCFzSP+FFjC8PBAenBJB 7lVUTxR42DGcdnNd9CLsI5MEpNrSEVNjQy3ZpducguLJeGqLuMKZtgt/g40j6PqqtEUq MRG3yAQDN8zAICXsi+DIJ/DreCPtLFokFh1j78cnhU4/sxQOLwLdHHKYATGofXru5rjg EIVg== X-Gm-Message-State: ACgBeo0RgeP7lMZcY2IwjMJ8uwYYQpyC1xPbVF4WQ4IHgQs2xSNwfgWu 2CNwBJJpgK3MREHO0zSDjl0ugQ== X-Google-Smtp-Source: AA6agR67oi4cMlUYeqQPPz6/1Bzsf6GWTinHyeHohnzUkgN6Wlpzl/y8KkFAry44BFgmgKq8e2owfA== X-Received: by 2002:a05:600c:a4c:b0:39c:34d0:fd25 with SMTP id c12-20020a05600c0a4c00b0039c34d0fd25mr14773449wmq.172.1662482868338; Tue, 06 Sep 2022 09:47:48 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.47.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:47:47 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Amit Kucheria , Zhang Rui , 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 v3 09/30] thermal/drivers/exynos: of_thermal_get_ntrips() Date: Tue, 6 Sep 2022 18:46:59 +0200 Message-Id: <20220906164720.330701-10-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal core framework allows to get the number of thermal trips, use it instead of visiting the thermal core structure internals. Signed-off-by: Daniel Lezcano Reviewed-by: Krzysztof Kozlowski --- drivers/thermal/samsung/exynos_tmu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung= /exynos_tmu.c index 0e33d32a9d2e..91e6860b5ec4 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -260,6 +260,7 @@ static int exynos_tmu_initialize(struct platform_device= *pdev) { struct exynos_tmu_data *data =3D platform_get_drvdata(pdev); struct thermal_zone_device *tzd =3D data->tzd; + int num_trips =3D thermal_zone_get_num_trips(tzd); unsigned int status; int ret =3D 0, temp; =20 @@ -271,12 +272,12 @@ static int exynos_tmu_initialize(struct platform_devi= ce *pdev) goto out; } =20 - if (of_thermal_get_ntrips(tzd) > data->ntrip) { + if (num_trips > data->ntrip) { dev_info(&pdev->dev, "More trip points than supported by this TMU.\n"); dev_info(&pdev->dev, "%d trip points should be configured in polling mode.\n", - (of_thermal_get_ntrips(tzd) - data->ntrip)); + num_trips - data->ntrip); } =20 mutex_lock(&data->lock); @@ -289,7 +290,7 @@ static int exynos_tmu_initialize(struct platform_device= *pdev) ret =3D -EBUSY; } else { int i, ntrips =3D - min_t(int, of_thermal_get_ntrips(tzd), data->ntrip); + min_t(int, num_trips, data->ntrip); =20 data->tmu_initialize(pdev); =20 --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 C1D4BECAAD5 for ; Tue, 6 Sep 2022 17:01:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239343AbiIFRBx (ORCPT ); Tue, 6 Sep 2022 13:01:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238338AbiIFRAQ (ORCPT ); Tue, 6 Sep 2022 13:00:16 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 241AC237DD for ; Tue, 6 Sep 2022 09:47:51 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id n23-20020a7bc5d7000000b003a62f19b453so9979498wmk.3 for ; Tue, 06 Sep 2022 09:47:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=oNc/Egu7W9i4cqdcSij4tEhGV2B445vyRVmU8PhGBRc=; b=mKCr01jcJ8zdQI4yFI/IbCAx737nabTno52UgseGmdhxzYjTcDFBfiyx5PNkkSjWBB ApkahD/RS0tr7hB4ZgVQirgM10JE9BI49sOocLUdlev6zLNIijtiIiRE8lRphhrD4ip8 hLTwjfEWzZiO8IU/UMuobm/CsoVnmxL/v3wOadMdFFTvW2ejQpkeQDoCTbsdgckD0BCK FqMp0oYyO39cIlOwmEjQrdjZ88fXNV93a7J6Gzomu/ibhG8a4BBKTXMIjXl+ePqwueUW WLbTf7iGBvWm/17cIS58fauG7bNUqJ3iFPjqKwF+DkEmXWimq6U7ROaTdY9OcySr8Bws ru/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=oNc/Egu7W9i4cqdcSij4tEhGV2B445vyRVmU8PhGBRc=; b=HmDri3XMqReaetmma5MJ3LbiIITwfpL77BSq2MiHH1eLbuwHbH3BsZAtbrhugwsmVa NBVr6oGWr4b/79VigV/VnCTbU6GfTQi/mjAfyhbYwN2Wo5M4OD9Bme8m/CwKnQLvsFVx sihntzu3UGNB748lXKXl/fm8wdWjHySUz5tCLjELGWgLWzZkV+TKo1KIHXe+DaxiLxVm 3Ex5KEsLHlZSLx8uuefFSQCmGi9r1q49yS8xE1SOEICdJ2iNH8ifWfa/NT6UL7limuFV ITPhJUFdkyuW2KG+mfS0szgzjjDaMSprWv0eq9R7yjRi/XQRcazpRSRdyO67hwUrSYtM eVJg== X-Gm-Message-State: ACgBeo1AMCF5+U55Hj9tTNHbQjZsm6UD8+3+fJhHItay7g80Olk/K+f5 dtU1VmlpC7SOgYjs42BjD6j/pg== X-Google-Smtp-Source: AA6agR4fPXKttV0xYCvVJFloujzY4AEz8TfxiziTaDMpSDgkWyATYs3LmG0aMLlEeoACyArMRFeQWw== X-Received: by 2002:a1c:4c0d:0:b0:3a5:98fa:3a4a with SMTP id z13-20020a1c4c0d000000b003a598fa3a4amr14646316wmf.92.1662482869546; Tue, 06 Sep 2022 09:47:49 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.47.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:47:49 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Amit Kucheria , Zhang Rui , 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 v3 10/30] thermal/drivers/exynos: Replace of_thermal_is_trip_valid() by thermal_zone_get_trip() Date: Tue, 6 Sep 2022 18:47:00 +0200 Message-Id: <20220906164720.330701-11-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal_zone_get_trip() does the same check as of_thermal_is_trip_valid(). Replace the call to of_thermal_is_trip_valid() by thermal_zone_get_trip(). Signed-off-by: Daniel Lezcano --- drivers/thermal/samsung/exynos_tmu.c | 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 91e6860b5ec4..5e6bb74c67f0 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -554,13 +554,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 @@ -584,13 +586,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 @@ -615,13 +619,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 Mon Apr 6 14:08:59 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 E6C14ECAAA1 for ; Tue, 6 Sep 2022 17:01:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239086AbiIFRB5 (ORCPT ); Tue, 6 Sep 2022 13:01:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238543AbiIFRA0 (ORCPT ); Tue, 6 Sep 2022 13:00:26 -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 81F472E6A8 for ; Tue, 6 Sep 2022 09:47:53 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id ay12so7204077wmb.1 for ; Tue, 06 Sep 2022 09:47:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=XsxTgl9OJhYT/B2dXFDz/rl/9WpF5J4y9HKMzylFxc4=; b=PAWWdlymzjqyLPcoNRb1L6qlikcPu6u+TyZaT37Vl9cBK/SHvf1i2tmvu02d4qKZQ4 DtMJ+EFOnxwRZeDWVzhNaXVacviBa7Dh+aUJ/PHrpFTFhr09NU6gT7pMUVWYDv4QqiPO V8SZe2MCkWIlf5UeVuB0MascbQvUmQUGNodMsWmHAa2da3tKiip/9bfm2w2jDOqRbia7 vlsv2dOEMlV5ZShLdnDGKAJ7YTaFUBEVuJ37ZHxf5/dI/CUSSNuIK+Bi7abOpR6dokYR bqDazXzTJmx3z6oPNAPK/K/qDuEpXb3cSFbTglT7GYtHyrZxwehWrSw8QxpyDT871lvZ mqMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=XsxTgl9OJhYT/B2dXFDz/rl/9WpF5J4y9HKMzylFxc4=; b=lMaWkmWneQzeLgMPMdTBYsMtJ2oVUGkgf7ViW5wp9f5zKyuFxRxX+KBLpOIwB5iyKk yPhChZ/3Z6wGmjCfEqlvNxhzawNO7dkP5Q+/bETwifp+zvgyelEbC2aM+1jkcYeqtcN7 jJJPPFo77YE4oy58jeA4GNfyetYAR37Bg386tcWGI6YVTA6F8YCUmHqlpQCRtnxv0C/0 GYOPIvDC783tLW+61RwXPRueXFyEO93oYAXrs9U4oIw3DNAm5hHvInRlsyAVPfxexFvi YsEcqyU0UPn1B/yUyXJDONHgnAo+zp+u+4+F3qxuioJd1A41OtCKtB2QtlHG96MXRtUw fj/w== X-Gm-Message-State: ACgBeo2fT0d6RHSD8l+WfwHbGxfS/a5RQYA9OgJVUgyecHa9i55giDg5 Pqhnm3fC/EkwrwCai17tK57ZaMFVGZx0lg== X-Google-Smtp-Source: AA6agR7TTFk3YgOPlL+9C6TUwAfwOlLFM0YXFCK/P5v+ajG82oXuLeZAdoIc3R5bilRxv5ibXcqU+g== X-Received: by 2002:a05:600c:19d3:b0:3a8:46a0:149f with SMTP id u19-20020a05600c19d300b003a846a0149fmr14470152wmq.185.1662482871857; Tue, 06 Sep 2022 09:47:51 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.47.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:47:51 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Amit Kucheria , Zhang Rui , Thierry Reding , Jonathan Hunter , linux-tegra@vger.kernel.org (open list:TEGRA ARCHITECTURE SUPPORT) Subject: [PATCH v3 11/30] thermal/drivers/tegra: Use generic thermal_zone_get_trip() function Date: Tue, 6 Sep 2022 18:47:01 +0200 Message-Id: <20220906164720.330701-12-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replace a single call to thermal_zone_get_trip() to get a trip point instead of calling the different ops->get_trip* Signed-off-by: Daniel Lezcano --- drivers/thermal/tegra/soctherm.c | 33 +++++++++++-------------- drivers/thermal/tegra/tegra30-tsensor.c | 17 ++++++------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/socth= erm.c index 1efe470f31e9..96b541458ccd 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -582,23 +582,23 @@ static int tsensor_group_thermtrip_get(struct tegra_s= octherm *ts, int id) return temp; } =20 -static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, in= t trip, int temp) +static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, in= t trip_id, int temp) { struct tegra_thermctl_zone *zone =3D tz->devdata; struct tegra_soctherm *ts =3D zone->ts; + struct thermal_trip trip; const struct tegra_tsensor_group *sg =3D zone->sg; struct device *dev =3D zone->dev; - enum thermal_trip_type type; int ret; =20 if (!tz) return -EINVAL; =20 - ret =3D tz->ops->get_trip_type(tz, trip, &type); + ret =3D thermal_zone_get_trip(tz, trip_id, &trip); if (ret) return ret; =20 - if (type =3D=3D THERMAL_TRIP_CRITICAL) { + if (trip.type =3D=3D THERMAL_TRIP_CRITICAL) { /* * If thermtrips property is set in DT, * doesn't need to program critical type trip to HW, @@ -609,7 +609,7 @@ static int tegra_thermctl_set_trip_temp(struct thermal_= zone_device *tz, int trip else return 0; =20 - } else if (type =3D=3D THERMAL_TRIP_HOT) { + } else if (trip.type =3D=3D THERMAL_TRIP_HOT) { int i; =20 for (i =3D 0; i < THROTTLE_SIZE; i++) { @@ -620,7 +620,7 @@ static int tegra_thermctl_set_trip_temp(struct thermal_= zone_device *tz, int trip continue; =20 cdev =3D ts->throt_cfgs[i].cdev; - if (get_thermal_instance(tz, cdev, trip)) + if (get_thermal_instance(tz, cdev, trip_id)) stc =3D find_throttle_cfg_by_name(ts, cdev->type); else continue; @@ -687,25 +687,20 @@ static const struct thermal_zone_device_ops tegra_of_= thermal_ops =3D { .set_trips =3D tegra_thermctl_set_trips, }; =20 -static int get_hot_temp(struct thermal_zone_device *tz, int *trip, int *te= mp) +static int get_hot_temp(struct thermal_zone_device *tz, int *trip_id, int = *temp) { - int ntrips, i, ret; - enum thermal_trip_type type; + int i, ret; + struct thermal_trip trip; =20 - ntrips =3D of_thermal_get_ntrips(tz); - if (ntrips <=3D 0) - return -EINVAL; + for (i =3D 0; i < thermal_zone_get_num_trips(tz); i++) { =20 - for (i =3D 0; i < ntrips; i++) { - ret =3D tz->ops->get_trip_type(tz, i, &type); + ret =3D thermal_zone_get_trip(tz, i, &trip); if (ret) return -EINVAL; - if (type =3D=3D THERMAL_TRIP_HOT) { - ret =3D tz->ops->get_trip_temp(tz, i, temp); - if (!ret) - *trip =3D i; =20 - return ret; + if (trip.type =3D=3D THERMAL_TRIP_HOT) { + *trip_id =3D i; + return 0;=09 } } =20 diff --git a/drivers/thermal/tegra/tegra30-tsensor.c b/drivers/thermal/tegr= a/tegra30-tsensor.c index c34501287e96..cbaad2245f1d 100644 --- a/drivers/thermal/tegra/tegra30-tsensor.c +++ b/drivers/thermal/tegra/tegra30-tsensor.c @@ -316,18 +316,17 @@ static void tegra_tsensor_get_hw_channel_trips(struct= thermal_zone_device *tzd, *hot_trip =3D 85000; *crit_trip =3D 90000; =20 - for (i =3D 0; i < tzd->num_trips; i++) { - enum thermal_trip_type type; - int trip_temp; + for (i =3D 0; i < thermal_zone_get_num_trips(tzd); i++) { =20 - tzd->ops->get_trip_temp(tzd, i, &trip_temp); - tzd->ops->get_trip_type(tzd, i, &type); + struct thermal_trip trip; =20 - if (type =3D=3D THERMAL_TRIP_HOT) - *hot_trip =3D trip_temp; + thermal_zone_get_trip(tzd, i, &trip); + =09 + if (trip.type =3D=3D THERMAL_TRIP_HOT) + *hot_trip =3D trip.temperature; =20 - if (type =3D=3D THERMAL_TRIP_CRITICAL) - *crit_trip =3D trip_temp; + if (trip.type =3D=3D THERMAL_TRIP_CRITICAL) + *crit_trip =3D trip.temperature; } =20 /* clamp hardware trips to the calibration limits */ --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 7B8BAECAAA1 for ; Tue, 6 Sep 2022 17:02:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230165AbiIFRCD (ORCPT ); Tue, 6 Sep 2022 13:02:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237674AbiIFRA0 (ORCPT ); Tue, 6 Sep 2022 13:00:26 -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 81EE82B27D for ; Tue, 6 Sep 2022 09:47:53 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id b5so16357691wrr.5 for ; Tue, 06 Sep 2022 09:47:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=zhkHfGU+506U13gs0KttMlfYYtmPZTAW+1/ApMCut14=; b=Th8YiUXJY8DYoYMTJhR7p6ct3jT3QTtfDMxrkwLP8mHuq0wFkSJzpxAEDdL7/+Rckr xbF1yZrk4nZD/Sy59+HkqI1nOavbwIyllvxPYclSUz3lV+PC7rmUoBciWw/7mBsjLc45 tv2AUdE+JPxVr8DzsLY+m/nLOYThFqeLQjs7FVy7UAtT1JgD7VJJ7qFosyAnsBSI0ku8 f8pKVc/KWQ2qg390fNi3MI9MJOjkf/2Tun+FAzLo0OD7hYLG5TLUUaSSt1AXgEq7EYbE anieUPaJYTGO+QoxQRJ9Vgx6whb/DaWG2jVMS02iWhqyXrc0LrRaJx0iLZ1s9tOl/YBr nvpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=zhkHfGU+506U13gs0KttMlfYYtmPZTAW+1/ApMCut14=; b=7MVTVNCRokSw8wkOc/xTAMGeRRh4pFGe9C5dSYP17dLNTtX+7nda0hFhhriymOYmDI 8HFynLqta4FfXLxGVDWz/vZjQ9L3/tJmYeeyWckS7wLbYebwt6YWVeRNh4GlprUOyEBE DOOZGtszUqDDXivoR+2l6Eh2VXixPfINgNrq+sZmorQ7dq9FLLGUqR86iAWVIidx0wrg z05fGJ3lgrRkaOrhkRxKhtaPjBNUTLHnO79CUPWVyyHu0/+LGDcQqQcWn5B+hhcgn0Fx SSwOw33xpmQf5m8ogP/qi/i7lEjJBTdwCJQ04gc458T94KXWuq3al2xBj0FuSR+gdrUY CCHg== X-Gm-Message-State: ACgBeo3HTp1NHM9ExUpgV9I0gD2Nu7FSRF2sZoCxktuA9MlCG0/qzNGA qIfnVkF/Kk7I5UIdNocNTrX6iA== X-Google-Smtp-Source: AA6agR7wINrCePHeVs2TMkvqGiR/IRUfgMtH5I4tZVRbaGeKyMht9ahIL1Pvt2KiIEak8VBoyVlboQ== X-Received: by 2002:a5d:58cb:0:b0:228:dc7f:b9b3 with SMTP id o11-20020a5d58cb000000b00228dc7fb9b3mr1426297wrf.98.1662482873002; Tue, 06 Sep 2022 09:47:53 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:47:52 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Kunihiko Hayashi , Amit Kucheria , Zhang Rui , Masami Hiramatsu , linux-arm-kernel@lists.infradead.org (moderated list:ARM/UNIPHIER ARCHITECTURE) Subject: [PATCH v3 12/30] thermal/drivers/uniphier: Use generic thermal_zone_get_trip() function Date: Tue, 6 Sep 2022 18:47:02 +0200 Message-Id: <20220906164720.330701-13-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano Reviewed-by: Kunihiko Hayashi --- drivers/thermal/uniphier_thermal.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/thermal/uniphier_thermal.c b/drivers/thermal/uniphier_= thermal.c index 4111d99ef50e..277ae300c5b1 100644 --- a/drivers/thermal/uniphier_thermal.c +++ b/drivers/thermal/uniphier_thermal.c @@ -248,8 +248,7 @@ static int uniphier_tm_probe(struct platform_device *pd= ev) struct regmap *regmap; struct device_node *parent; struct uniphier_tm_dev *tdev; - const struct thermal_trip *trips; - int i, ret, irq, ntrips, crit_temp =3D INT_MAX; + int i, ret, irq, crit_temp =3D INT_MAX; =20 tdev =3D devm_kzalloc(dev, sizeof(*tdev), GFP_KERNEL); if (!tdev) @@ -296,20 +295,18 @@ static int uniphier_tm_probe(struct platform_device *= pdev) return PTR_ERR(tdev->tz_dev); } =20 - /* get trip points */ - trips =3D of_thermal_get_trip_points(tdev->tz_dev); - ntrips =3D of_thermal_get_ntrips(tdev->tz_dev); - if (ntrips > ALERT_CH_NUM) { - dev_err(dev, "thermal zone has too many trips\n"); - return -E2BIG; - } - /* set alert temperatures */ - for (i =3D 0; i < ntrips; i++) { - if (trips[i].type =3D=3D THERMAL_TRIP_CRITICAL && - trips[i].temperature < crit_temp) - crit_temp =3D trips[i].temperature; - uniphier_tm_set_alert(tdev, i, trips[i].temperature); + for (i =3D 0; i < thermal_zone_get_num_trips(tdev->tz_dev); i++) { + struct thermal_trip trip; + + ret =3D thermal_zone_get_trip(tdev->tz_dev, i, &trip); + if (ret) + return ret; + + if (trip.type =3D=3D THERMAL_TRIP_CRITICAL && + trip.temperature < crit_temp) + crit_temp =3D trip.temperature; + uniphier_tm_set_alert(tdev, i, trip.temperature); tdev->alert_en[i] =3D true; } if (crit_temp > CRITICAL_TEMP_LIMIT) { --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 C4CC2ECAAA1 for ; Tue, 6 Sep 2022 17:02:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234251AbiIFRCP (ORCPT ); Tue, 6 Sep 2022 13:02:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238753AbiIFRA2 (ORCPT ); Tue, 6 Sep 2022 13:00:28 -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 87A613ECE6 for ; Tue, 6 Sep 2022 09:47:55 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id k9so16389000wri.0 for ; Tue, 06 Sep 2022 09:47:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=F16FcP49uIGOwU3Sf8ns9eXu8wz72Lx9ob6lOEA95bs=; b=SAvsaLnOlt88T31BJg3d/NE6I1Fikz4B/1KIa3gznPIlyumnWKkN+Vy8PKEF0QgVZC bkGr0XGsjoB9QzG+WNb7LrLxBAbIsCnITif3W6Tz+u35t39t2kL3UMCX3lHsVuRzFtAo 7O+LALOQ0lw1aNkpeI7+3cCYC/+bb0XmQL/5bVqx6d19e2OrCgM9T8LAvMb6gBf8Ho95 P3otz7ieT8wLOiH1wVp/OmYtPfUQIllEiNYULV3GyMJRq9d9uyMZbiJF/fbCKzmxZMdj SMnWUKaf6et49/2Izb9W7wUwMTTt8alpiho0R6hBk63EL22wNJkRMK7Mqte5mXJDMqhh IpVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=F16FcP49uIGOwU3Sf8ns9eXu8wz72Lx9ob6lOEA95bs=; b=D3VM4SzYPAo08ua+hzBrJ4MFFKO4U4EiCVzyxySOWU8bwyOF7aosoTsPuoUxFCBQ5+ F9I/3jFaU7pG7eFtibm/CUJtgF8P4weAHO6vi+TjFvJ/mcntGKrQkmtO8kUU0/VGRGtC QNS1VoyXh/PS/gG6QVvqKLK9sq/qaKvjuzCQV3kkwwXqEG2sulW0iuDdcJkLSyAHUjk1 lGgz9R7jYeSZMreNul5pClVk8BiESFe5/enR2r0/IinFpzeZDooqjNWxf71XU/xb/PeH jAk+nCptigEXmuij++IM61YQscQ0/OkYC5cFOQwIRtGU9sTFkGVhv4By4FaKHJssUMA1 TbTA== X-Gm-Message-State: ACgBeo2xk8SlPZ6ju9Jo08MTTiB+L3GHHow0BlZdHlyY099iAy99W3H5 5ePIoZ7IMUpgO0P109qFiaaP6w== X-Google-Smtp-Source: AA6agR4yqaf3T+RQFZVMp7sDoWHkvl4zxJu4orXD8DRdx9+5cECkQlLXmtyK7XOmfceQibo6YtJ6pA== X-Received: by 2002:a5d:5581:0:b0:20f:fc51:7754 with SMTP id i1-20020a5d5581000000b0020ffc517754mr29121262wrv.413.1662482873999; Tue, 06 Sep 2022 09:47:53 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:47:53 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v3 13/30] thermal/drivers/hisi: Use generic thermal_zone_get_trip() function Date: Tue, 6 Sep 2022 18:47:03 +0200 Message-Id: <20220906164720.330701-14-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index d6974db7aaf7..45226cab466e 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -482,7 +482,7 @@ static int hisi_thermal_register_sensor(struct platform= _device *pdev, struct hisi_thermal_sensor *sensor) { int ret, i; - const struct thermal_trip *trip; + struct thermal_trip trip; =20 sensor->tzd =3D devm_thermal_of_zone_register(&pdev->dev, sensor->id, sensor, @@ -495,11 +495,12 @@ static int hisi_thermal_register_sensor(struct platfo= rm_device *pdev, return ret; } =20 - trip =3D of_thermal_get_trip_points(sensor->tzd); + for (i =3D 0; i < thermal_zone_get_num_trips(sensor->tzd); i++) { =20 - for (i =3D 0; i < of_thermal_get_ntrips(sensor->tzd); i++) { - if (trip[i].type =3D=3D THERMAL_TRIP_PASSIVE) { - sensor->thres_temp =3D trip[i].temperature; + thermal_zone_get_trip(sensor->tzd, i, &trip); + + if (trip.type =3D=3D THERMAL_TRIP_PASSIVE) { + sensor->thres_temp =3D trip.temperature; break; } } --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 98772C38145 for ; Tue, 6 Sep 2022 17:02:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239163AbiIFRCK (ORCPT ); Tue, 6 Sep 2022 13:02:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238789AbiIFRA2 (ORCPT ); Tue, 6 Sep 2022 13:00:28 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C32A51A83F for ; Tue, 6 Sep 2022 09:47:55 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id t7so11325355wrm.10 for ; Tue, 06 Sep 2022 09:47:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=/DpVb9+AKUGgq8A4EZDNel0xrsv5+R31U81PHZWHu7A=; b=X1YQe4f852MWDEDIbxLyzt5EWKhqVbyY6KreD6n8q9N6gvC4i5WIAkAzHEI8dxRQw2 T4b4m7BwfLcHYcdzVERs6l2W8E+H4GpJhLC8IrZYCL528FKDWNHlWXC6PTvkSj6jbCpm VCmB3xaFeU0IFsA/r9xJ92FaeOzlD9rTbJUN0L9w1QOY77nEKGDBTYH2+HsDyR7R3ssd JLEUG/KkypsRIDRloNuetGhHaNobFHXm4VCxBtHscQYXC2wf9BJtse7X+THpJ5rz10JD 3jcOl3Mk1zLbgjzqFTdPpzHhw7uYKsp2+pj102XoPdHncWPhOWf/46R+CSvdlP8UCEXO +h5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=/DpVb9+AKUGgq8A4EZDNel0xrsv5+R31U81PHZWHu7A=; b=H1Wlt6RwDzxw2y2YBl+30uF3W84/ooUt7Hcb5vvYzwxqiZORcKRd6aPD6STmaueQkE 3z6KhzKdymDYY6Z1WIPU2CLDP/yFE68HeVprhVKOutF+beDy+nCmmVPmcgE1Dc4tohVC wRDNkfkBXJjWLS2ClNniFfhiqTnYyXU/+QqbeyIiBlhDURyQAuSadTbpGV1NhZ93N/ZS sqQgSMVt9W7Me91Iy3gPivYgogqmJQa8AEOaIk0JCQJA5Nvs62+PMxgzi/zJob1XqTbz jCFNT+BZRdhpphE4m25gxGY2LGumUAc66645RMvjhjcjVNx3su0JdOTw12mlvdCMG9wm swsw== X-Gm-Message-State: ACgBeo2y5UrPRImm8W5gCcmR52fLG71pYqvivfAKqW+H8nmCLykMKJ5L kZ6dlNeKAPYyrUK+YYtSxn564Q== X-Google-Smtp-Source: AA6agR7726/EhQnxyUAI0pB44o1EaZhJhbR16yBCc7vE9TFIiuCwg9pWS0Hms7JxnJjgbdDiSwJYdQ== X-Received: by 2002:adf:ec03:0:b0:228:76bd:76fc with SMTP id x3-20020adfec03000000b0022876bd76fcmr6904673wrn.533.1662482875286; Tue, 06 Sep 2022 09:47:55 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.47.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:47:54 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Amit Kucheria , Thara Gopinath , Andy Gross , Bjorn Andersson , Konrad Dybcio , Zhang Rui , linux-arm-msm@vger.kernel.org (open list:QUALCOMM TSENS THERMAL DRIVER) Subject: [PATCH v3 14/30] thermal/drivers/qcom: Use generic thermal_zone_get_trip() function Date: Tue, 6 Sep 2022 18:47:04 +0200 Message-Id: <20220906164720.330701-15-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano Acked-by: Amit Kucheria --- drivers/thermal/qcom/qcom-spmi-temp-alarm.c | 39 +++++++++------------ 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/drivers/thermal/qcom/qcom-spmi-temp-alarm.c b/drivers/thermal/= qcom/qcom-spmi-temp-alarm.c index be785ab37e53..127e8c90211c 100644 --- a/drivers/thermal/qcom/qcom-spmi-temp-alarm.c +++ b/drivers/thermal/qcom/qcom-spmi-temp-alarm.c @@ -263,17 +263,17 @@ static int qpnp_tm_update_critical_trip_temp(struct q= pnp_tm_chip *chip, return qpnp_tm_write(chip, QPNP_TM_REG_SHUTDOWN_CTRL1, reg); } =20 -static int qpnp_tm_set_trip_temp(struct thermal_zone_device *tz, int trip,= int temp) +static int qpnp_tm_set_trip_temp(struct thermal_zone_device *tz, int trip_= id, int temp) { struct qpnp_tm_chip *chip =3D tz->devdata; - const struct thermal_trip *trip_points; + struct thermal_trip trip; int ret; =20 - trip_points =3D of_thermal_get_trip_points(chip->tz_dev); - if (!trip_points) - return -EINVAL; + ret =3D thermal_zone_get_trip(chip->tz_dev, trip_id, &trip); + if (ret) + return ret; =20 - if (trip_points[trip].type !=3D THERMAL_TRIP_CRITICAL) + if (trip.type !=3D THERMAL_TRIP_CRITICAL) return 0; =20 mutex_lock(&chip->lock); @@ -299,22 +299,17 @@ static irqreturn_t qpnp_tm_isr(int irq, void *data) =20 static int qpnp_tm_get_critical_trip_temp(struct qpnp_tm_chip *chip) { - int ntrips; - const struct thermal_trip *trips; - int i; - - ntrips =3D of_thermal_get_ntrips(chip->tz_dev); - if (ntrips <=3D 0) - return THERMAL_TEMP_INVALID; - - trips =3D of_thermal_get_trip_points(chip->tz_dev); - if (!trips) - return THERMAL_TEMP_INVALID; - - for (i =3D 0; i < ntrips; i++) { - if (of_thermal_is_trip_valid(chip->tz_dev, i) && - trips[i].type =3D=3D THERMAL_TRIP_CRITICAL) - return trips[i].temperature; + struct thermal_trip trip; + int i, ret; + + for (i =3D 0; i < thermal_zone_get_num_trips(chip->tz_dev); i++) { + + ret =3D thermal_zone_get_trip(chip->tz_dev, i, &trip); + if (ret) + continue; + + if (trip.type =3D=3D THERMAL_TRIP_CRITICAL) + return trip.temperature; } =20 return THERMAL_TEMP_INVALID; --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 C4223ECAAD5 for ; Tue, 6 Sep 2022 17:02:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239401AbiIFRCW (ORCPT ); Tue, 6 Sep 2022 13:02:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238812AbiIFRA3 (ORCPT ); Tue, 6 Sep 2022 13:00:29 -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 D46BC3ED46 for ; Tue, 6 Sep 2022 09:47:56 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id b5so16357927wrr.5 for ; Tue, 06 Sep 2022 09:47:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=cMvv+kIwS7Npnyybgo7TEwbxPHKi63Y9shqXlNy7AcU=; b=o2Drx44fkG4j30Cv18Jj0fH8NYaJNqOoQ2Y9uNDGN/HImEDm1CzWmPt4QyBXERmIFY s33uHIZguNwiHpAJJdwH4QT/OyxoQRvY9kqDDbczu8WpzqxXjL9BTIU5BgGKNM4qi/gN oaBgvtcbZifPqdSLMRHousXkh/IwwOhRLbx8ALXzHpvVhUUrN0nysGBKD21FqsdU6qWq nXTKchuulIad6+GWIl8v5pVFeDG8Lcn4IGtFKR3XuA+qMRKaCj4hgG0tAvXNeHHD0x0S JzcmpGWHSqEj+XApFODrGSuC1Szk2oOHcecEDQ4zXDG01bZ/K7SKv1YvygpACAiKUV9g GgCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=cMvv+kIwS7Npnyybgo7TEwbxPHKi63Y9shqXlNy7AcU=; b=S9xCr/DgrpTcDPbE7clus4THEwYfqpw2ACOZGK2rlFdlB3j99fHbWnGZXShubrhSQ+ 57kj88y9LQvsi+8/MNh+2j689do3fkdCLLwjhGR5GxFycfJhBrMDjT/rT5N2P9lgt0Xx gmhMn7Ls+WfuGZ6wRujTxeMku/Vm/9L3eWxBXYrtKhv+eQCHV5juLvH4MyVL47hfgFdd LwBm/BmZxNBpq+i0E4nxQp44t3euuXnFexHQdV8MoVMZFeeSE/gRQwwRNwqWXipQEvDF 75miPnGUWcOI5xttqD8SXhCowwddQnNstASZAgLBRqEO+EA29fwkin1h4Z6eXiYzdWdl QLZQ== X-Gm-Message-State: ACgBeo0NExYDEW4SniVyk2xb3pTRbIJ6EdFayhKasrGdwggbQI/98e7k PWTk3F51ATa1w3QYmnZiNkHvjQ== X-Google-Smtp-Source: AA6agR6L/A1f6iTqUUlJYsPdQq4UZhycMAPeB0XlufMbFv05QWUVdUMlwE45Nar+AlIbBaEyxleQCw== X-Received: by 2002:adf:de83:0:b0:228:d8ad:c0c6 with SMTP id w3-20020adfde83000000b00228d8adc0c6mr2612614wrl.500.1662482876379; Tue, 06 Sep 2022 09:47:56 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.47.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:47:56 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Miquel Raynal , Amit Kucheria , Zhang Rui Subject: [PATCH v3 15/30] thermal/drivers/armada: Use generic thermal_zone_get_trip() function Date: Tue, 6 Sep 2022 18:47:05 +0200 Message-Id: <20220906164720.330701-16-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano --- drivers/thermal/armada_thermal.c | 39 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_ther= mal.c index 52d63b3997fe..9444e5a22ca0 100644 --- a/drivers/thermal/armada_thermal.c +++ b/drivers/thermal/armada_thermal.c @@ -785,33 +785,34 @@ static int armada_configure_overheat_int(struct armad= a_thermal_priv *priv, int sensor_id) { /* Retrieve the critical trip point to enable the overheat interrupt */ - const struct thermal_trip *trips =3D of_thermal_get_trip_points(tz); + struct thermal_trip trip; int ret; int i; =20 - if (!trips) - return -EINVAL; - - for (i =3D 0; i < of_thermal_get_ntrips(tz); i++) - if (trips[i].type =3D=3D THERMAL_TRIP_CRITICAL) - break; + for (i =3D 0; i < thermal_zone_get_num_trips(tz); i++) { =20 - if (i =3D=3D of_thermal_get_ntrips(tz)) - return -EINVAL; + ret =3D thermal_zone_get_trip(tz, i, &trip); + if (ret) + return ret; + =09 + if (trip.type !=3D THERMAL_TRIP_CRITICAL)=20 + continue; =20 - ret =3D armada_select_channel(priv, sensor_id); - if (ret) - return ret; + ret =3D armada_select_channel(priv, sensor_id); + if (ret) + return ret; + =09 + armada_set_overheat_thresholds(priv, trip.temperature, + trip.hysteresis); + priv->overheat_sensor =3D tz; + priv->interrupt_source =3D sensor_id; =20 - armada_set_overheat_thresholds(priv, - trips[i].temperature, - trips[i].hysteresis); - priv->overheat_sensor =3D tz; - priv->interrupt_source =3D sensor_id; + armada_enable_overheat_interrupt(priv); =20 - armada_enable_overheat_interrupt(priv); + return 0; + } =20 - return 0; + return -EINVAL; } =20 static int armada_thermal_probe(struct platform_device *pdev) --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 D1B10ECAAD5 for ; Tue, 6 Sep 2022 17:02:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238965AbiIFRC2 (ORCPT ); Tue, 6 Sep 2022 13:02:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239080AbiIFRAa (ORCPT ); Tue, 6 Sep 2022 13:00:30 -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 A1A6063F11 for ; Tue, 6 Sep 2022 09:47:59 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id e13so16372060wrm.1 for ; Tue, 06 Sep 2022 09:47:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=XrpGuF2vxbaEuk6VfKG2/A6XesW21KLMiogPr2+Ux0s=; b=qAKEWIoNgOigeWuMnnQ7710KwiB9KxoCjnfatE43czuKubcbr+XgcpbHhJFUSvh++U /qpLFovGMOGfukaguXxplYgAo05apsKFPK93u7d/eirN+CgKxgC/XLzxnmLJWkBMg1Qa Qc1RBI2GlufsnAm4KdP6V2OMdwMMCXKcCs1wXLGCsAh5lnUjpODHMAo5fOj+H4YRdcHO wsFfH6uxYqoECguDKgDktWtBZBZri+wX3NlG/BokoGxrTJN+iCaBUzL79JVCKr8Nu0T7 11AlYC74ufkcXGW2zUoBNXCec+r20e0D2HFb1ZuFB9Izc07tk5jQ1BpXH63NUpOahk7f YNGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=XrpGuF2vxbaEuk6VfKG2/A6XesW21KLMiogPr2+Ux0s=; b=vtg15SrSEcS+OyO16eXOeX7lyS2OnQHRWtCqdAr735qeiIr4sgBC7uRbuQ3/rE0Cbo XxSOORaaga7O12xSnAYeCiEafKP01IttJqwJHorgDJ2cgP8k89cdNmUBrIxVkXgTCpZa vQ+SqxYbTJcg/rnihbhbjEjr1ATUkDqyiXU99SMtDjJ/rrfbr1NVJIfHcZvLUy/+spUI kcfeae4tj/68KQIMr1l9e9E0VW9EuuNYy1E0nycezFXs+G93MyLqF2EGSD3waQP0BvQ0 jT5+xM8ulkfegSMD8W+lWsdn59ka5vGEMC8GWtvF/Cz3QP+ApWKJq8wmRDtI6b2Yqcml t7dA== X-Gm-Message-State: ACgBeo1kiiqa5xS8h4zZBigl0uSmeEl6kDMiy3p9CXUijizw0x7WBRkg uRakVDoqTnYY4LyvRC6PJlS75A== X-Google-Smtp-Source: AA6agR6KijxpTZE70JOmNG2AY9zoGbp7ZufFdGRs4K90HaoUGdD4f2+XFgZJ5ovNh5VHRTD3uoKyfw== X-Received: by 2002:adf:f051:0:b0:228:830a:4963 with SMTP id t17-20020adff051000000b00228830a4963mr6305270wro.586.1662482877759; Tue, 06 Sep 2022 09:47:57 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.47.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:47:57 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, =?UTF-8?q?Niklas=20S=C3=B6derlund?= , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Amit Kucheria , Zhang Rui , linux-renesas-soc@vger.kernel.org (open list:RENESAS R-CAR THERMAL DRIVERS) Subject: [PATCH v3 16/30] thermal/drivers/rcar_gen3: Use the generic function to get the number of trips Date: Tue, 6 Sep 2022 18:47:06 +0200 Message-Id: <20220906164720.330701-17-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The thermal core framework allows to get the number of thermal trips, use it instead of visiting the thermal core structure internals. Signed-off-by: Daniel Lezcano Reviewed-by: Niklas S=C3=B6derlund --- drivers/thermal/rcar_gen3_thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen= 3_thermal.c index 4c1c6f89aa2f..4ef927437842 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c @@ -529,7 +529,7 @@ static int rcar_gen3_thermal_probe(struct platform_devi= ce *pdev) if (ret) goto error_unregister; =20 - ret =3D of_thermal_get_ntrips(tsc->zone); + ret =3D thermal_zone_get_num_trips(tsc->zone); if (ret < 0) goto error_unregister; =20 --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 CA6E8C38145 for ; Tue, 6 Sep 2022 17:02:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230340AbiIFRCb (ORCPT ); Tue, 6 Sep 2022 13:02:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231809AbiIFRAc (ORCPT ); Tue, 6 Sep 2022 13:00:32 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 895245C9C2 for ; Tue, 6 Sep 2022 09:47:59 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id bj14so3080363wrb.12 for ; Tue, 06 Sep 2022 09:47:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=wKElCC452+uQH9oPG73me3V/zKr0MM7IvUS5jZU3ITo=; b=I0UanIPG6cavD3RAbIQDu3/9sgsbVr9VIqgemy5st9ic9vxiBP9bkzOCx7iFf+FE4x 4/AosVO9pVb5R+zdmZbJXE0lXvjbWjMXOhf8Gmip81yCD/k1tkQoTrPhchA4ChmSilTS yKzGjOJzhtJhXnNE9F8xEK474N/iQqwQVMog+pRFwfTc4IHE813ArtxrRYdnKnyVYMB1 xet1IbKiJ8Uhd7behB4tHXSb2xzHbHcJ3hO15UPlZUA5GQs4pl7uwHYnwpSfSdpqigQP DnIL7IQg/vpg/sb/OLumy4wDL7GujMduAAa3qri2TTj7ZqqDwEfYzQeIZXBupaRj0DDz /USA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=wKElCC452+uQH9oPG73me3V/zKr0MM7IvUS5jZU3ITo=; b=yZr56OnDgFc/3/s0+FP17ELizmL7MsahH6P/MAXMpnhXXc7xYYCWyI/hUdIoe45upe RCryV+n1zV//wgN9uGA/gdbeWSCo47o6Q8F/Xgxg3pemK3xb9JFX080ejArvh7DAasI9 1mRrCwH9pepXhdGMjm3fsxL/3Rkgl8TiRNzOCpxX9BTsKC0ZnhhK8EeJkPzoi/Pbhvrq i56g10yOyxrWQtvjel2JEg/w2FziFLRa9JyzIWJEezbCt4P1Q8pF1vtYtrRMNvwvqQ45 odT9FcR3LpCjmXoUA9dp0w5ZT+6QeVEjNEmMBeEt68y6LtbjBOlwShf9yMefW6Aq2Nc1 n6CA== X-Gm-Message-State: ACgBeo2b0VpvyQn2KmwW9UgAtQo4aTZC6CWMVyfCX64pODfXweUUTPYS TefVrxDU+lOIbJNt1kctnM6zxw== X-Google-Smtp-Source: AA6agR4UcazUuIL9MtGniarrvFOJph+eNwzOfx24809rri6jRiTGqofStNM60MlWuZ0P5gvZBHBGOw== X-Received: by 2002:adf:e109:0:b0:225:4ca5:80d5 with SMTP id t9-20020adfe109000000b002254ca580d5mr27574446wrz.465.1662482878837; Tue, 06 Sep 2022 09:47:58 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.47.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:47:58 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v3 17/30] thermal/of: Remove of_thermal_get_ntrips() Date: Tue, 6 Sep 2022 18:47:07 +0200 Message-Id: <20220906164720.330701-18-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal OF code uses the generic trip points to initialize the thermal zone. Consequently thermal_zone_get_num_trips() can be used and the of_thermal_get_ntrips() is no longer needed. Remove it. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.h | 5 ----- drivers/thermal/thermal_of.c | 16 ---------------- 2 files changed, 21 deletions(-) diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 99a5d5281037..0139bc1e4f87 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -137,13 +137,8 @@ thermal_cooling_device_stats_update(struct thermal_coo= ling_device *cdev, =20 /* device tree support */ #ifdef CONFIG_THERMAL_OF -int of_thermal_get_ntrips(struct thermal_zone_device *); bool of_thermal_is_trip_valid(struct thermal_zone_device *, int); #else -static inline int of_thermal_get_ntrips(struct thermal_zone_device *tz) -{ - return 0; -} static inline bool of_thermal_is_trip_valid(struct thermal_zone_device *tz, int trip) { diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 2f533fc94917..89afa59c4915 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -19,22 +19,6 @@ =20 #include "thermal_core.h" =20 -/** - * of_thermal_get_ntrips - function to export number of available trip - * points. - * @tz: pointer to a thermal zone - * - * This function is a globally visible wrapper to get number of trip points - * stored in the local struct __thermal_zone - * - * Return: number of available trip points, -ENODEV when data not available - */ -int of_thermal_get_ntrips(struct thermal_zone_device *tz) -{ - return tz->num_trips; -} -EXPORT_SYMBOL_GPL(of_thermal_get_ntrips); - /** * of_thermal_is_trip_valid - function to check if trip point is valid * --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 56897C38145 for ; Tue, 6 Sep 2022 17:02:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234071AbiIFRCh (ORCPT ); Tue, 6 Sep 2022 13:02:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239124AbiIFRAd (ORCPT ); Tue, 6 Sep 2022 13:00:33 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DBC43D599 for ; Tue, 6 Sep 2022 09:48:00 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id d12-20020a05600c34cc00b003a83d20812fso7817813wmq.1 for ; Tue, 06 Sep 2022 09:48: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:subject:date; bh=NFzfcStR9W+Nwf1uLdi1lXL2TUYpkWfd9XSuLVSwMnk=; b=GlrL7+cd7i15KGj/i03cteP5PlR0MefSntaqtO8bBVZNn0tLzJ0+yxoh51iMWUHsMv iw1C5tT7/flSA8XgPjK0POZ3eudCtxJYEEIKvVr6IaFG8vCMUo5uD8mlkji7t2zD0rCp HSm1oz0t1F3lUUDXgkFPn8++XMmG9TMGr1xipsyZ+gxdINkzKlUD/yAdL45oXRoxjzDZ Kk6g76vJhtmj0woHBIh8PcsJfT+yWmfFbMF+nqA7lsNdggx4t2cq0N7yLZv6NhfsWRMc MnndEE9u+pWge8p56G4PQwM/a4D9MGueaj4qTORREJXC9u8ShM6NaCxMoqsAmTvmtsbm BO7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=NFzfcStR9W+Nwf1uLdi1lXL2TUYpkWfd9XSuLVSwMnk=; b=OAsKAjzMu5UcHpD15DraFrN3q52DqTLACtBB7nx8z3S09KVNP/KYrGRbrSv/7ePawR qWFCpsyrcUKU17TKV9hEPMm8hVPPKp7ZVrZsrI3Mkjq5yapdd8ipS6JNpSG/7RxCoT1U BgAchNFx+M5+wozaW8uxhBTOlKEw38A2Fu3XkX6I/iQiJA8G1lkBMHanl+pgqXJc2yXi l9fzBYS7BEwxGnuee1Vm+NSAQZt+lch3Hk2R+7VO/ClZ0YDnsl17EJhTBmjBjqSyGZ2I Vg3Nr7825UmRHnvIVam3U5j7f6Jt/LOXt+kd81cymZNqBpy+A8cc5SUiqqrO17cjk6bH aHEw== X-Gm-Message-State: ACgBeo109P+1liI52jILaA7k7JHzBHQmU5kBSr39U8KeaEQOhJfANW6T CkGiaOYSt5IRc6I2WKRh/uFBRw== X-Google-Smtp-Source: AA6agR7OEjpnE/6nP3TJEobMFoznkT/eqpKORo8rgq1q+/Ayp66Gc1kLu2gHOPg96pxYxVpU0fNRKg== X-Received: by 2002:a05:600c:4e15:b0:3a6:152a:9143 with SMTP id b21-20020a05600c4e1500b003a6152a9143mr14260140wmq.20.1662482879938; Tue, 06 Sep 2022 09:47:59 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.47.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:47:59 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v3 18/30] thermal/of: Remove of_thermal_is_trip_valid() Date: Tue, 6 Sep 2022 18:47:08 +0200 Message-Id: <20220906164720.330701-19-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There is no benefit with the of_thermal_is_trip_valid() function as it does the check the thermal_zone_get_trip() is already doing for the sake of getting the trip point. As all the calls have been replaced by thermal_zone_get_trip(), there is no more users of of_thermal_is_trip_valid(). Remove the function. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.h | 10 ---------- drivers/thermal/thermal_of.c | 19 ------------------- 2 files changed, 29 deletions(-) diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 0139bc1e4f87..4d1af11a6eb4 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -136,16 +136,6 @@ thermal_cooling_device_stats_update(struct thermal_coo= ling_device *cdev, #endif /* CONFIG_THERMAL_STATISTICS */ =20 /* device tree support */ -#ifdef CONFIG_THERMAL_OF -bool of_thermal_is_trip_valid(struct thermal_zone_device *, int); -#else -static inline bool of_thermal_is_trip_valid(struct thermal_zone_device *tz, - int trip) -{ - return false; -} -#endif - int thermal_zone_device_is_enabled(struct thermal_zone_device *tz); =20 #endif /* __THERMAL_CORE_H__ */ diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 89afa59c4915..4e54d62720dc 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -19,25 +19,6 @@ =20 #include "thermal_core.h" =20 -/** - * of_thermal_is_trip_valid - function to check if trip point is valid - * - * @tz: pointer to a thermal zone - * @trip: trip point to evaluate - * - * This function is responsible for checking if passed trip point is valid - * - * Return: true if trip point is valid, false otherwise - */ -bool of_thermal_is_trip_valid(struct thermal_zone_device *tz, int trip) -{ - if (trip >=3D tz->num_trips || trip < 0) - return false; - - return true; -} -EXPORT_SYMBOL_GPL(of_thermal_is_trip_valid); - static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int tr= ip, int hyst) { --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 5EE84ECAAA1 for ; Tue, 6 Sep 2022 17:02:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232957AbiIFRCm (ORCPT ); Tue, 6 Sep 2022 13:02:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239152AbiIFRAe (ORCPT ); Tue, 6 Sep 2022 13:00:34 -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 E2B0F6F573 for ; Tue, 6 Sep 2022 09:48:01 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id n23-20020a7bc5d7000000b003a62f19b453so9979880wmk.3 for ; Tue, 06 Sep 2022 09:48:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=KY22MjtoUlIwWIKxWwfuHh0wn9QBG3Vjtz/Dduvf6bU=; b=aN9PiFxFulWh9P/V4Crz48Fw6Up0k2wSiTJGHPwyPLdmF6RuT7ut5Bz2PC0utfF+Jh akGbJVYbzYi5H0EvB2HE9R2mqfLaxaUJLoQS69VxQao6Y1OeE9BjKNLi71TaLhtNyaAR RCDcT4W9JkLAr4cFlwHWCEXvrZgWZCutA4ECBl0yWbHsV92jGL2GRs8lFTJfnK4CVAth XdmpxvrQ9UVgnjJ+hPaaF3MefxcDVv5Cn63ON374fTl53sH9rcyZoK282N6k5VeX9jxv yYE5WJ25AH7LkTtat7FkbSUtlYeDsucK6ZS+Bp806ln6twOJZ2Dh2eZ7uNnHu8/8ROJE 10EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=KY22MjtoUlIwWIKxWwfuHh0wn9QBG3Vjtz/Dduvf6bU=; b=VkGUuXT0KeV2ZOVt5Om8S2d3cGhqYvMwJWPcvFRuAw6EtvqktcG7xLVwEowd7vUbrP N8/3iT/6qqpSx8PIzaLN14Tc6J/FfrlY1nRVRemk9KN0D3ubmqDLI5KuelYHm5y7o6/f Cfntbha8Fg38p9iezHr4pSR1J6HJL7Ucr3bFaVci+0x91ez7x3SG7Jb7qWEH8CdtXyxw K/66Xot1gAU2/8kkRAqeboTHnOIWQz0W9Ymk3Zk3LjsR6Om0WywpE+jIWCmoMp+j6TsQ If4gnAZiY0ZQ3E99FhuCR8o6kNxgavoit8ziccsnTxUmHkjvZi4ja65AQmWxMpjtgCTy eQCQ== X-Gm-Message-State: ACgBeo0omKLN8jajBuyNPpbZkBIxY1v3RtI/VZQSC7rSl9mc3IwZ4OgI wsaBCQ4UCEc1JuewXmZxIhM9lbHpzUncIg== X-Google-Smtp-Source: AA6agR5r5Ak8QiMHIGoePFRUr0EK5M9YEiNFMot3mkX+bjnBZ/bGRqe2PY/dlL7LW20MtsV1yDNLPw== X-Received: by 2002:a05:600c:3556:b0:3a6:220e:6242 with SMTP id i22-20020a05600c355600b003a6220e6242mr13850056wmq.145.1662482881017; Tue, 06 Sep 2022 09:48:01 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.48.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:48:00 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v3 19/30] thermal/of: Remove of_thermal_set_trip_hyst() Date: Tue, 6 Sep 2022 18:47:09 +0200 Message-Id: <20220906164720.330701-20-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal core is providing the generic thermal_zone_set_trip() function which does exactly what the OF ops function is doing. It is pointless to define our own version, just remove the ops and the thermal_zone_set_trip() will take care of it. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 4e54d62720dc..494e9c319541 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -19,18 +19,6 @@ =20 #include "thermal_core.h" =20 -static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int tr= ip, - int hyst) -{ - if (trip >=3D tz->num_trips || trip < 0) - return -EDOM; - - /* thermal framework should take care of data->mask & (1 << trip) */ - tz->trips[trip].hysteresis =3D hyst; - - return 0; -} - static int of_thermal_get_crit_temp(struct thermal_zone_device *tz, int *temp) { @@ -541,7 +529,6 @@ struct thermal_zone_device *thermal_of_zone_register(st= ruct device_node *sensor, goto out_kfree_trips; } =20 - of_ops->set_trip_hyst =3D of_ops->set_trip_hyst ? : of_thermal_set_trip_h= yst; of_ops->get_crit_temp =3D of_ops->get_crit_temp ? : of_thermal_get_crit_t= emp; of_ops->bind =3D thermal_of_bind; of_ops->unbind =3D thermal_of_unbind; --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 0118CECAAA1 for ; Tue, 6 Sep 2022 17:02:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239463AbiIFRCt (ORCPT ); Tue, 6 Sep 2022 13:02:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239170AbiIFRAe (ORCPT ); Tue, 6 Sep 2022 13:00:34 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A58C480362 for ; Tue, 6 Sep 2022 09:48:02 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id m17-20020a7bce11000000b003a5bedec07bso10001078wmc.0 for ; Tue, 06 Sep 2022 09:48:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=OHXbaNWdyZ0Wkkc1xL/nI14ReQ0AVnlGlwSXS+lV7dA=; b=CzyMlGwNMuWv+cFzFuo6jtNX8TSHXlGC9Xzcc4djbsEt1Nolp+eTdLRV1XA3YiMPt7 YpBDmcaKi+4RkPydZnvdstdcn374ChRdgiDIAQ1T/Uun5itQ6vWFF7EOPR2JokY+pJ5O eRDxxZMjXLM9v66sLZQmGN8XxHxZ7ChMl593W95N3v4zjSe4ESlzQOrnCRFTQC7wSMPK hfegFwwGJuwoCbuMq9VqF5ZXFQYGtgtd6KpGq21o4SH/JgZFbOvrhx3Hhp9w/EK7AsiJ 0SpSm7uBBmZThHuIHs42ZyJCNDtXdCprHlhOiSiqIhe1t1mikgzroY4GLpofvEwA/y7W kD0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=OHXbaNWdyZ0Wkkc1xL/nI14ReQ0AVnlGlwSXS+lV7dA=; b=iiEvhonqLadNS1IryEDZjAI14SKN+kOjfohtWNhdWrdSHt49SSninh0yjxkVhUc0ll s9jOoqYlUelyKPhlXwFea+d5VRNG+/m8CQTPqA1lI2AEI6dIkIW1xJxaRQDpHt7moo8o 2lCfDxZJS/LsGio5dSHFA7r1HrACK9XJO1v+cNZoOay5HY1jXHJy2/yf8yK/sglK2Uqk e6VHLDNGwiA+HRbOae9ODWpi258tKKIIKpQ7pEIkLPSx4tLkYNZwXjmGU1G2QpI23FUL fkjH0Pc/QeetMVA3MEr8PeGJy1HwmFv1g5oPljHnQydLnABI/rpX9VgK4ltx1gGrx5su 4Pow== X-Gm-Message-State: ACgBeo0CWkYanwRYqGbUFKSJAR4k02pzBwxNQQid5Qa2nptDrWKj+WV9 h2mqADwOcbdG3a68QHX7RXmHlw== X-Google-Smtp-Source: AA6agR59Lc5T6LmLLEGeP2MxLdnTw/CCIK7z4Jk5oL8Yyf+mgy2XuAwlPGWqQyEXR6G0r0LTbmqrGQ== X-Received: by 2002:a05:600c:2256:b0:3a5:c27d:bfb2 with SMTP id a22-20020a05600c225600b003a5c27dbfb2mr14019410wmm.102.1662482882025; Tue, 06 Sep 2022 09:48:02 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.48.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:48:01 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v3 20/30] thermal/of: Remove of_thermal_get_crit_temp() Date: Tue, 6 Sep 2022 18:47:10 +0200 Message-Id: <20220906164720.330701-21-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The generic version of of_thermal_get_crit_temp() can be used. Let's remove this ops which is pointless. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 494e9c319541..bd872183e521 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -19,20 +19,6 @@ =20 #include "thermal_core.h" =20 -static int of_thermal_get_crit_temp(struct thermal_zone_device *tz, - int *temp) -{ - int i; - - for (i =3D 0; i < tz->num_trips; i++) - if (tz->trips[i].type =3D=3D THERMAL_TRIP_CRITICAL) { - *temp =3D tz->trips[i].temperature; - return 0; - } - - return -EINVAL; -} - /*** functions parsing device tree nodes ***/ =20 static int of_find_trip_id(struct device_node *np, struct device_node *tri= p) @@ -529,7 +515,6 @@ struct thermal_zone_device *thermal_of_zone_register(st= ruct device_node *sensor, goto out_kfree_trips; } =20 - of_ops->get_crit_temp =3D of_ops->get_crit_temp ? : of_thermal_get_crit_t= emp; of_ops->bind =3D thermal_of_bind; of_ops->unbind =3D thermal_of_unbind; =20 --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 B9E83ECAAD5 for ; Tue, 6 Sep 2022 17:02:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238558AbiIFRC4 (ORCPT ); Tue, 6 Sep 2022 13:02:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234303AbiIFRAx (ORCPT ); Tue, 6 Sep 2022 13:00:53 -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 184266E2DC for ; Tue, 6 Sep 2022 09:48:05 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id bp20so15869930wrb.9 for ; Tue, 06 Sep 2022 09:48: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:subject:date; bh=p+Fs/P7gXsm/5qHeFX0rzCcy4XeIXDeOEwU0TTt39+U=; b=EKosuhPmamKh8eudEZ2RzXf5XbSruIwibMeFNYl82Yy+t7A4utedR5Ygq9u1JiPtiF EWtFH+tYTimbNnYMMd0othiT7OZmLs+jTvY7gGZ1DaLD4EHI69QLUnBZn3ebykybLjhm yACddMSIDxxOR1w+XBrtrcM6BBng9p5eKv82pX/mfzUMPnWuqjfWe/hPvUVXA3JGV/N2 FipS2jzylHOn5naGFC9Jr3ISmvXSXKhNgFXUT9UtkVGEg4Yf22kuZ96u/0lb9A8b4UWa /HhZjZcyk3zeJXR9wAQfWPCU2K9dR6xbBta1NRKp06O2vzn6jsbBe/Z8V3okVVl+1cwp 8o1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=p+Fs/P7gXsm/5qHeFX0rzCcy4XeIXDeOEwU0TTt39+U=; b=78cTPslwGDhp6zkXc9bnEVeSuK19MsH2f9vEu8B67WlOrvimnC5Kiqxr9u6Kaf3+WU MFOrx165m/6M08JQy7+oVX1UPagor3G0HBbpONe0ejQLCzeZ7uuZHBlwRxa1StnoyyIS 1fm4zbNfAzYTARwvIpP1G+jCZlD8YV+pdtV+uRRhAw/IRh/4tZmZ0a7/bIb81AbNAecK w4YinupDA7HXcRhYmEIQKjCcenXcLMizzC+M9Nv4uJnCtp9CfXLcjVzMuVGc8/P3eNyi EH2wzr5cLaLIu/bBnPymDX4HD6VunZFWKfRn/DhSukhataVRC8uzMv1eqTXqHbTp8/L8 8V8A== X-Gm-Message-State: ACgBeo0eC+dePMAWDrbcaUlt4SF+tWxX+aMoICa86d5xr34uCS2UrNMU ZPlHK0jyyeSBpyYSVTVyWfPmzw== X-Google-Smtp-Source: AA6agR4J05UbRmdHYPYTJtZXUoFCiI/16fLjg7zBs9gpPVM5ZWo/WW23zG1rT35tPKwOfxAKuz3wkw== X-Received: by 2002:a5d:6d8f:0:b0:225:6285:47fb with SMTP id l15-20020a5d6d8f000000b00225628547fbmr29029509wrs.211.1662482883567; Tue, 06 Sep 2022 09:48:03 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.48.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:48:03 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v3 21/30] thermal/drivers/st: Use generic trip points Date: Tue, 6 Sep 2022 18:47:11 +0200 Message-Id: <20220906164720.330701-22-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert to the generic trip points Signed-off-by: Daniel Lezcano --- drivers/thermal/st/st_thermal.c | 47 +++++---------------------------- 1 file changed, 7 insertions(+), 40 deletions(-) diff --git a/drivers/thermal/st/st_thermal.c b/drivers/thermal/st/st_therma= l.c index 1276b95604fe..c0d45cdd1c2f 100644 --- a/drivers/thermal/st/st_thermal.c +++ b/drivers/thermal/st/st_thermal.c @@ -134,48 +134,12 @@ static int st_thermal_get_temp(struct thermal_zone_de= vice *th, int *temperature) return 0; } =20 -static int st_thermal_get_trip_type(struct thermal_zone_device *th, - int trip, enum thermal_trip_type *type) -{ - struct st_thermal_sensor *sensor =3D th->devdata; - struct device *dev =3D sensor->dev; - - switch (trip) { - case 0: - *type =3D THERMAL_TRIP_CRITICAL; - break; - default: - dev_err(dev, "invalid trip point\n"); - return -EINVAL; - } - - return 0; -} - -static int st_thermal_get_trip_temp(struct thermal_zone_device *th, - int trip, int *temp) -{ - struct st_thermal_sensor *sensor =3D th->devdata; - struct device *dev =3D sensor->dev; - - switch (trip) { - case 0: - *temp =3D mcelsius(sensor->cdata->crit_temp); - break; - default: - dev_err(dev, "Invalid trip point\n"); - return -EINVAL; - } - - return 0; -} - static struct thermal_zone_device_ops st_tz_ops =3D { .get_temp =3D st_thermal_get_temp, - .get_trip_type =3D st_thermal_get_trip_type, - .get_trip_temp =3D st_thermal_get_trip_temp, }; =20 +static struct thermal_trip trip; + int st_thermal_register(struct platform_device *pdev, const struct of_device_id *st_thermal_of_match) { @@ -238,9 +202,12 @@ int st_thermal_register(struct platform_device *pdev, =20 polling_delay =3D sensor->ops->register_enable_irq ? 0 : 1000; =20 + trip.temperature =3D sensor->cdata->crit_temp; + trip.type =3D THERMAL_TRIP_CRITICAL; +=09 sensor->thermal_dev =3D - thermal_zone_device_register(dev_name(dev), 1, 0, sensor, - &st_tz_ops, NULL, 0, polling_delay); + thermal_zone_device_register_with_trips(dev_name(dev), &trip, 1, 0, sens= or, + &st_tz_ops, NULL, 0, polling_delay); if (IS_ERR(sensor->thermal_dev)) { dev_err(dev, "failed to register thermal zone device\n"); ret =3D PTR_ERR(sensor->thermal_dev); --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 E949DECAAD5 for ; Tue, 6 Sep 2022 17:03:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231496AbiIFRDB (ORCPT ); Tue, 6 Sep 2022 13:03:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239042AbiIFRBG (ORCPT ); Tue, 6 Sep 2022 13:01:06 -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 7E21F28E20 for ; Tue, 6 Sep 2022 09:48:06 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id t7so11325958wrm.10 for ; Tue, 06 Sep 2022 09:48:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=xYvlHjUzJ1gAdl8KtmAH0mCHcP29B+tCMOTUThwt7jg=; b=moC3maNbMcCB2llQTrHIAjv3Uko04+bbQ646kv8FkteCDfagAT5TuR7KeM23KlIEs/ OcplE2OdFRxYUK6Cg/2IuVMhTGDjoH21fZKUyuvenj5cpjTWIuIxuH2aAv7K1yDJfGCr G8Ohjwk6vJ8MEic+RtNdArmxMQRjK0wR0jAEp62+xhwzGmXdD2UBnh6H7Dyg9bhVqh+m joPUUT36PL9VaUS5MrMM6o1mTJIn4xTfsRE7i4JzXmRSW2ZHcn3fHSnUE6s6C0hli7+D rqyNNpI5T2r1/Hzam7+RFXcoLjPardiDeGl+Rl3r9uX5bcqwrocZ7rEEZuLi4kngkmvx 0RjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=xYvlHjUzJ1gAdl8KtmAH0mCHcP29B+tCMOTUThwt7jg=; b=xaqCHISA5+kpoNrz2iLndj/sZT44PgEL7urSXo2iwQV2c78U/tneAsii3rdv1rYitc hTXvLsYt8i1lOH7MxTQ8wm7BCKN3IA3fmyjBw0qgHY9YUrvpMJUy3C/pJVyGUUaZKJc9 B7VIU1gLIiVC2NpK+8kkbX7EZJwf/BSk636cLbK2W1Z3Z+RByZKwW6g850lF7VUaGckt nQhsAJnZEAtvhy6likC8Bpr2Q27cofSUOlscSEnp6KtBLHGqdqkfFhA/EexeoGoMsvoe A9KuzbTXWIL4IVa7vMao6Qf/EFW6x/ZwPD5ZxyPUIVtQROZ+9OV+1uLPjDbQWSWy+e/1 MguA== X-Gm-Message-State: ACgBeo3pXcUBoGhSAby/X0A0WLjU+9n/1JujDWqPro2OuRuX+C0QarND wsaKr9wzQ+zEuM1Ugr0ZPtXfLQ== X-Google-Smtp-Source: AA6agR7YA/ljrEdsHBL85CzD6qPwWP2Najg0eOC3hzrXlO4v6/SPE9waPAj0mwb+cElH4fzGdLXDrQ== X-Received: by 2002:a5d:47ce:0:b0:228:5769:489e with SMTP id o14-20020a5d47ce000000b002285769489emr9127537wrc.188.1662482884940; Tue, 06 Sep 2022 09:48:04 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.48.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:48:04 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Amit Kucheria , Zhang Rui , 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 v3 22/30] thermal/drivers/imx: Use generic thermal_zone_get_trip() function Date: Tue, 6 Sep 2022 18:47:12 +0200 Message-Id: <20220906164720.330701-23-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano --- drivers/thermal/imx_thermal.c | 72 +++++++++++++---------------------- 1 file changed, 27 insertions(+), 45 deletions(-) diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 16663373b682..fb0d5cab70af 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -76,7 +76,6 @@ enum imx_thermal_trip { IMX_TRIP_PASSIVE, IMX_TRIP_CRITICAL, - IMX_TRIP_NUM, }; =20 #define IMX_POLLING_DELAY 2000 /* millisecond */ @@ -115,6 +114,11 @@ struct thermal_soc_data { u32 low_alarm_shift; }; =20 +static struct thermal_trip trips[] =3D { + [IMX_TRIP_PASSIVE] =3D { .type =3D THERMAL_TRIP_PASSIVE }, + [IMX_TRIP_CRITICAL] =3D { .type =3D THERMAL_TRIP_CRITICAL }, +}; + static struct thermal_soc_data thermal_imx6q_data =3D { .version =3D TEMPMON_IMX6Q, =20 @@ -201,8 +205,6 @@ struct imx_thermal_data { struct thermal_cooling_device *cdev; struct regmap *tempmon; u32 c1, c2; /* See formula in imx_init_calib() */ - int temp_passive; - int temp_critical; int temp_max; int alarm_temp; int last_temp; @@ -279,12 +281,12 @@ static int imx_get_temp(struct thermal_zone_device *t= z, int *temp) =20 /* Update alarm value to next higher trip point for TEMPMON_IMX6Q */ if (data->socdata->version =3D=3D TEMPMON_IMX6Q) { - if (data->alarm_temp =3D=3D data->temp_passive && - *temp >=3D data->temp_passive) - imx_set_alarm_temp(data, data->temp_critical); - if (data->alarm_temp =3D=3D data->temp_critical && - *temp < data->temp_passive) { - imx_set_alarm_temp(data, data->temp_passive); + if (data->alarm_temp =3D=3D trips[IMX_TRIP_PASSIVE].temperature && + *temp >=3D trips[IMX_TRIP_PASSIVE].temperature) + imx_set_alarm_temp(data, trips[IMX_TRIP_CRITICAL].temperature); + if (data->alarm_temp =3D=3D trips[IMX_TRIP_CRITICAL].temperature && + *temp < trips[IMX_TRIP_PASSIVE].temperature) { + imx_set_alarm_temp(data, trips[IMX_TRIP_PASSIVE].temperature); dev_dbg(&tz->device, "thermal alarm off: T < %d\n", data->alarm_temp / 1000); } @@ -330,29 +332,10 @@ static int imx_change_mode(struct thermal_zone_device= *tz, return 0; } =20 -static int imx_get_trip_type(struct thermal_zone_device *tz, int trip, - enum thermal_trip_type *type) -{ - *type =3D (trip =3D=3D IMX_TRIP_PASSIVE) ? THERMAL_TRIP_PASSIVE : - THERMAL_TRIP_CRITICAL; - return 0; -} - static int imx_get_crit_temp(struct thermal_zone_device *tz, int *temp) { - struct imx_thermal_data *data =3D tz->devdata; - - *temp =3D data->temp_critical; - return 0; -} - -static int imx_get_trip_temp(struct thermal_zone_device *tz, int trip, - int *temp) -{ - struct imx_thermal_data *data =3D tz->devdata; + *temp =3D trips[IMX_TRIP_CRITICAL].temperature; =20 - *temp =3D (trip =3D=3D IMX_TRIP_PASSIVE) ? data->temp_passive : - data->temp_critical; return 0; } =20 @@ -371,10 +354,10 @@ static int imx_set_trip_temp(struct thermal_zone_devi= ce *tz, int trip, return -EPERM; =20 /* do not allow passive to be set higher than critical */ - if (temp < 0 || temp > data->temp_critical) + if (temp < 0 || temp > trips[IMX_TRIP_CRITICAL].temperature) return -EINVAL; =20 - data->temp_passive =3D temp; + trips[IMX_TRIP_PASSIVE].temperature =3D temp; =20 imx_set_alarm_temp(data, temp); =20 @@ -423,8 +406,6 @@ static struct thermal_zone_device_ops imx_tz_ops =3D { .unbind =3D imx_unbind, .get_temp =3D imx_get_temp, .change_mode =3D imx_change_mode, - .get_trip_type =3D imx_get_trip_type, - .get_trip_temp =3D imx_get_trip_temp, .get_crit_temp =3D imx_get_crit_temp, .set_trip_temp =3D imx_set_trip_temp, }; @@ -507,8 +488,8 @@ static void imx_init_temp_grade(struct platform_device = *pdev, u32 ocotp_mem0) * Set the critical trip point at 5 =C2=B0C under max * Set the passive trip point at 10 =C2=B0C under max (changeable via sys= fs) */ - data->temp_critical =3D data->temp_max - (1000 * 5); - data->temp_passive =3D data->temp_max - (1000 * 10); + trips[IMX_TRIP_PASSIVE].temperature =3D data->temp_max - (1000 * 10); + trips[IMX_TRIP_CRITICAL].temperature =3D data->temp_max - (1000 * 5); } =20 static int imx_init_from_tempmon_data(struct platform_device *pdev) @@ -743,12 +724,13 @@ static int imx_thermal_probe(struct platform_device *= pdev) goto legacy_cleanup; } =20 - data->tz =3D thermal_zone_device_register("imx_thermal_zone", - IMX_TRIP_NUM, - BIT(IMX_TRIP_PASSIVE), data, - &imx_tz_ops, NULL, - IMX_PASSIVE_DELAY, - IMX_POLLING_DELAY); + data->tz =3D thermal_zone_device_register_with_trips("imx_thermal_zone", + trips, + ARRAY_SIZE(trips), + BIT(IMX_TRIP_PASSIVE), data, + &imx_tz_ops, NULL, + IMX_PASSIVE_DELAY, + IMX_POLLING_DELAY); if (IS_ERR(data->tz)) { ret =3D PTR_ERR(data->tz); dev_err(&pdev->dev, @@ -758,8 +740,8 @@ static int imx_thermal_probe(struct platform_device *pd= ev) =20 dev_info(&pdev->dev, "%s CPU temperature grade - max:%dC" " critical:%dC passive:%dC\n", data->temp_grade, - data->temp_max / 1000, data->temp_critical / 1000, - data->temp_passive / 1000); + data->temp_max / 1000, trips[IMX_TRIP_CRITICAL].temperature / 1000, + trips[IMX_TRIP_PASSIVE].temperature / 1000); =20 /* Enable measurements at ~ 10 Hz */ regmap_write(map, data->socdata->measure_freq_ctrl + REG_CLR, @@ -767,10 +749,10 @@ static int imx_thermal_probe(struct platform_device *= pdev) measure_freq =3D DIV_ROUND_UP(32768, 10); /* 10 Hz */ regmap_write(map, data->socdata->measure_freq_ctrl + REG_SET, measure_freq << data->socdata->measure_freq_shift); - imx_set_alarm_temp(data, data->temp_passive); + imx_set_alarm_temp(data, trips[IMX_TRIP_PASSIVE].temperature); =20 if (data->socdata->version =3D=3D TEMPMON_IMX6SX) - imx_set_panic_temp(data, data->temp_critical); + imx_set_panic_temp(data, trips[IMX_TRIP_CRITICAL].temperature); =20 regmap_write(map, data->socdata->sensor_ctrl + REG_CLR, data->socdata->power_down_mask); --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 ACCBAC38145 for ; Tue, 6 Sep 2022 17:03:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232380AbiIFRDH (ORCPT ); Tue, 6 Sep 2022 13:03:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236944AbiIFRBS (ORCPT ); Tue, 6 Sep 2022 13:01:18 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC3F47391C for ; Tue, 6 Sep 2022 09:48:07 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id bz13so12941920wrb.2 for ; Tue, 06 Sep 2022 09:48: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:subject:date; bh=1g7iD3leIss4w6BJ5qO+L1jz4YwsNBVACOWMBVjZgpk=; b=ETMe3sp/Q+As/P6Y8jJMD+gUZU7ML+tORbT3cbliZHs2yWfCYz+fqU9Y8ZlkQTfI4w FJS0oI/NxqtMbKYQ0hbW5h569iSjJ0CfnUi5HeCs208eRNhsn+vjap4db4WljtpdE+Qc lKNH7L0jkL9kPvvfVNCZF6eThkfMMi0+C65WAqfnhqJnNPk/Wa+RVJtP51uff9YZobgQ aRqPjw/PkCs51d6TBs5dZ9NGFm0/7YfClW5bAageevbuDRuMGmhbuJ7fqiMMrsI90CMr PCBbBqQlw22lb+h0zVOiNsNKMkZ0jt9iYhpbGokl1xS1MGpgmPEqkz2y66FmySNSzdTv 8l2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=1g7iD3leIss4w6BJ5qO+L1jz4YwsNBVACOWMBVjZgpk=; b=g08Rz7rFt+7hAJhG8PRgMoXauNwgVUR1POjKZ/r7Pvm5qLqZOBIPdDjAHHQWFqCF4Y yVfDaOZLrSbCDa4a1X5fWeY8T34CQhQld+a1Q1kZbn0DJJsttEWtR8jW/e4SEflJYFZn rhAiP9fpD1w3onA3IzPgVE9NNrFXuPTHvF/wtVq5AvePMmdm0VyMgu0u97qaSxNmE/z8 q3CRXP744UmINVJPx/JoPJ8pLnYA85l/3T/1agFdtoBjTxgVomlxi/P60/6UJ8UonfV7 HGdZ67s0ZeWcvqmw/gpBMROCjbRqBDxa3cs/XdGej9Qnr+mbp8kC8QhjbrWz4jq9CzBJ 20Kw== X-Gm-Message-State: ACgBeo3esQ4UnliSVrd2GRgS6UE4LAuaGCG5JT0YEusD8kfnLI9+o/Sv NLK3yK/J6Uav1mYVXmbtlj2rgA== X-Google-Smtp-Source: AA6agR7Bfv2PPU+Ow16wDD+XaQzj7m39/KlnCs4wBa0domDpH+LAomiPy0yyMEiLt8ehOAi2SU9ZBQ== X-Received: by 2002:a5d:69c6:0:b0:228:c119:987f with SMTP id s6-20020a5d69c6000000b00228c119987fmr4967593wrw.268.1662482886151; Tue, 06 Sep 2022 09:48:06 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.48.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:48:05 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, =?UTF-8?q?Niklas=20S=C3=B6derlund?= , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Amit Kucheria , Zhang Rui , linux-renesas-soc@vger.kernel.org (open list:RENESAS R-CAR THERMAL DRIVERS) Subject: [PATCH v3 23/30] thermal/drivers/rcar: Use generic thermal_zone_get_trip() function Date: Tue, 6 Sep 2022 18:47:13 +0200 Message-Id: <20220906164720.330701-24-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano Reviewed-by: Niklas S=C3=B6derlund --- drivers/thermal/rcar_thermal.c | 49 +++++----------------------------- 1 file changed, 6 insertions(+), 43 deletions(-) diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index 4df42d70d867..003457810072 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c @@ -278,52 +278,16 @@ static int rcar_thermal_get_temp(struct thermal_zone_= device *zone, int *temp) return rcar_thermal_get_current_temp(priv, temp); } =20 -static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone, - int trip, enum thermal_trip_type *type) -{ - struct rcar_thermal_priv *priv =3D rcar_zone_to_priv(zone); - struct device *dev =3D rcar_priv_to_dev(priv); - - /* see rcar_thermal_get_temp() */ - switch (trip) { - case 0: /* +90 <=3D temp */ - *type =3D THERMAL_TRIP_CRITICAL; - break; - default: - dev_err(dev, "rcar driver trip error\n"); - return -EINVAL; - } - - return 0; -} - -static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone, - int trip, int *temp) -{ - struct rcar_thermal_priv *priv =3D rcar_zone_to_priv(zone); - struct device *dev =3D rcar_priv_to_dev(priv); - - /* see rcar_thermal_get_temp() */ - switch (trip) { - case 0: /* +90 <=3D temp */ - *temp =3D MCELSIUS(90); - break; - default: - dev_err(dev, "rcar driver trip error\n"); - return -EINVAL; - } - - return 0; -} - static struct thermal_zone_device_ops rcar_thermal_zone_of_ops =3D { .get_temp =3D rcar_thermal_get_temp, }; =20 static struct thermal_zone_device_ops rcar_thermal_zone_ops =3D { .get_temp =3D rcar_thermal_get_temp, - .get_trip_type =3D rcar_thermal_get_trip_type, - .get_trip_temp =3D rcar_thermal_get_trip_temp, +}; + +static struct thermal_trip trips[] =3D { + { .type =3D THERMAL_TRIP_CRITICAL, .temperature =3D 90000 } }; =20 /* @@ -531,9 +495,8 @@ static int rcar_thermal_probe(struct platform_device *p= dev) dev, i, priv, &rcar_thermal_zone_of_ops); } else { - priv->zone =3D thermal_zone_device_register( - "rcar_thermal", - 1, 0, priv, + priv->zone =3D thermal_zone_device_register_with_trips( + "rcar_thermal", trips, ARRAY_SIZE(trips), 0, priv, &rcar_thermal_zone_ops, NULL, 0, idle); =20 --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 2B792ECAAD5 for ; Tue, 6 Sep 2022 17:03:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232799AbiIFRDQ (ORCPT ); Tue, 6 Sep 2022 13:03:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230459AbiIFRBW (ORCPT ); Tue, 6 Sep 2022 13:01:22 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93E205AC65 for ; Tue, 6 Sep 2022 09:48:08 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id t7so11326119wrm.10 for ; Tue, 06 Sep 2022 09:48: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:subject:date; bh=RuOkdBUevpNwOF5uxKYPUxVuiSYnY/XeiYrwbyLTKVs=; b=MXGgRNozmSiTJDrSQGhOqLAYkNyQdEf+MvlRK6wDRULEIyGehPAVkS2pWBu+v4KVI3 r2M7fKLCgA/0xSUzN5utm3rPHu5wwsD9VFO7d9ohljX8r1o/U6zdh+tYT+SR7qJ6TDm8 zp0ACWwSlMW3Fc3pW3a5J24CTo+HA931m30KwrcblwOorqVJEIOKr8xRB+A7go5R541Q fKEWSZMwfEzKoRvfx97BbXgfC6Q0yJi07gQ68/cDhBRVSAZBq+rTbN0A7traz+VSWHDo qDOs7p4UwIHAMmExnVHZ1TgMnBm0WFF7u6hC0SEfI4GlvsDfLqhzMu1iON8FHYHzdJZm smDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=RuOkdBUevpNwOF5uxKYPUxVuiSYnY/XeiYrwbyLTKVs=; b=y1wwojF7m5gWcYR8GDtuyWFcCYsOr93u56lgo9bU+PVmhQLpKm4skLrBXeOYq8Aqwk 5aMVesupR82Xe09arAzJ8sXeJgTI+8S9xh2YuYhia8NYtSAZdSKww5xyOnlreh5kNKWI 3HUpNUv5dBO2U2mS9Dl0wWtw5DGWw+AAzPHGe9MhmeoVOVRHJDqgQLEGgOLUrFey34Z+ CzdZRVTDmiKHO6Mtx1fsiMQ6ud7TRlzhcl4Bdfxbbq8faFTE4SOQQHO6EzszR7SAtwlW K6yHjiCtP3GsLyhf2/Tqd4wsqMu+DIgIXIr/W2aunQh+IgP0whO8oThuC/rYYxsbcBEB f7NQ== X-Gm-Message-State: ACgBeo12R6TMj+BtM5xk5IguZS8rxP5EsbLwEErpVBngOPXNLPob+MBR Wm+YRN1OZoYr0yP7VFEfGIX9xQ== X-Google-Smtp-Source: AA6agR6XIRcEoeyLaSxHMBLKwQF0QhLuHuR3B1cYfC3PJXE0abDpIDYcpQwEP9X88VuDatj0oVwNxg== X-Received: by 2002:a5d:5887:0:b0:220:81c9:8ab7 with SMTP id n7-20020a5d5887000000b0022081c98ab7mr27763590wrf.702.1662482887974; Tue, 06 Sep 2022 09:48:07 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.48.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:48:07 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Amit Kucheria , Zhang Rui , Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE) Subject: [PATCH v3 24/30] thermal/drivers/broadcom: Use generic thermal_zone_get_trip() function Date: Tue, 6 Sep 2022 18:47:14 +0200 Message-Id: <20220906164720.330701-25-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano --- drivers/thermal/broadcom/bcm2835_thermal.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/broadcom/bcm2835_thermal.c b/drivers/thermal/b= roadcom/bcm2835_thermal.c index 2c67841a1115..5485e59d03a9 100644 --- a/drivers/thermal/broadcom/bcm2835_thermal.c +++ b/drivers/thermal/broadcom/bcm2835_thermal.c @@ -18,6 +18,7 @@ #include #include =20 +#include "../thermal_core.h" #include "../thermal_hwmon.h" =20 #define BCM2835_TS_TSENSCTL 0x00 @@ -224,7 +225,8 @@ static int bcm2835_thermal_probe(struct platform_device= *pdev) */ val =3D readl(data->regs + BCM2835_TS_TSENSCTL); if (!(val & BCM2835_TS_TSENSCTL_RSTB)) { - int trip_temp, offset, slope; + struct thermal_trip trip; + int offset, slope; =20 slope =3D thermal_zone_get_slope(tz); offset =3D thermal_zone_get_offset(tz); @@ -232,7 +234,7 @@ static int bcm2835_thermal_probe(struct platform_device= *pdev) * For now we deal only with critical, otherwise * would need to iterate */ - err =3D tz->ops->get_trip_temp(tz, 0, &trip_temp); + err =3D thermal_zone_get_trip(tz, 0, &trip); if (err < 0) { dev_err(&pdev->dev, "Not able to read trip_temp: %d\n", @@ -249,7 +251,7 @@ static int bcm2835_thermal_probe(struct platform_device= *pdev) val |=3D (0xFE << BCM2835_TS_TSENSCTL_RSTDELAY_SHIFT); =20 /* trip_adc value from info */ - val |=3D bcm2835_thermal_temp2adc(trip_temp, + val |=3D bcm2835_thermal_temp2adc(trip.temperature, offset, slope) << BCM2835_TS_TSENSCTL_THOLD_SHIFT; --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 59F75ECAAD5 for ; Tue, 6 Sep 2022 17:03:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239367AbiIFRDa (ORCPT ); Tue, 6 Sep 2022 13:03:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234573AbiIFRBg (ORCPT ); Tue, 6 Sep 2022 13:01:36 -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 C35CE95AE6 for ; Tue, 6 Sep 2022 09:48:10 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id m3-20020a05600c3b0300b003a5e0557150so8443995wms.0 for ; Tue, 06 Sep 2022 09:48: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:subject:date; bh=kNTESOeVOVH9BHNMsa7BlHA2jeppHM3L2UNE800z/X4=; b=T/MiZX+s52gnVr1Qtivo5WE2IHoCStCwlt9AgGfbSquQ1ErxcOGXn5eUa/PRZimxpx x2ey6PBEXkC6K0FQP0SchxWsOyZ+UkWpEIL+7JQ7rb/2KX+8k209BiujtG4fJMrXlAY4 yOGuY1hzvKsI1P+j9EETkPGcmkPNBoSHTFI0a7mKKG3Ba20M171pHm4b1IVTz2kyMl1n prlRNByKHxsYjwKiOcuw+6462rkUPuwhiLbhDv4iaGZoDQBQz45OM0d8yeWb4hgOmW30 m/Lh8fXaFbrhNm2jTWTcv3227Y9gPm3HrAdGifBoiBaC1JeqpG0uknsZxWDFJLMzJwcq gHQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=kNTESOeVOVH9BHNMsa7BlHA2jeppHM3L2UNE800z/X4=; b=Xil7g/wR5xM/bZEhBhG2Y/sM6ejdT5kxBKTp7zjZzvbwFdDxt7X2sk0VWAUrAy4pdF 0w8ltq6Q+tW/Kk0SjqITU84wJW3MkF0PFE5nf3AQ4CI9wmdlgL0zPKF0mEAe3pPaUFX5 NBqPojNtqeTL69VKwwunGSnkSZOps+2SRI8j9UHmqbMCzod5XbGdoceE4/0C3j79KLkh STEG3RH+bPofj6kwyhHGxMC3YYnT/38mryYPw6KIovimoMm/wgn6dakflEQuec0IIMOp oDWIU6tEAEU2DUrRb+xKlUg6KPOPmjcVF3BO1r2pTCS0W+K4aixTl1w7gCBWWWidVVIm fjMg== X-Gm-Message-State: ACgBeo0P5bYvxIDh2h8D9+vasmZcFwvaqq0pqdllLg6ynOTpjcmdbrCz WzaQWZvWeIpK6xEl6IEFD+jDTQ== X-Google-Smtp-Source: AA6agR7fexFPp/KtQLXMbVzbtku8KIH4pfBqYbxr50g74IjIv1DzKpyZcAEN5f8957Ep4F5BPyttMA== X-Received: by 2002:a05:600c:198f:b0:3a6:2482:b2be with SMTP id t15-20020a05600c198f00b003a62482b2bemr14574196wmq.110.1662482889185; Tue, 06 Sep 2022 09:48:09 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.48.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:48:08 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Adam Ward , Support Opensource , Amit Kucheria , Zhang Rui Subject: [PATCH v3 25/30] thermal/drivers/da9062: Use generic thermal_zone_get_trip() function Date: Tue, 6 Sep 2022 18:47:15 +0200 Message-Id: <20220906164720.330701-26-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano Reviewed-by: Adam Ward --- drivers/thermal/da9062-thermal.c | 52 +++++--------------------------- 1 file changed, 8 insertions(+), 44 deletions(-) diff --git a/drivers/thermal/da9062-thermal.c b/drivers/thermal/da9062-ther= mal.c index 180edec34e07..1e163e90d6b6 100644 --- a/drivers/thermal/da9062-thermal.c +++ b/drivers/thermal/da9062-thermal.c @@ -120,44 +120,6 @@ static irqreturn_t da9062_thermal_irq_handler(int irq,= void *data) return IRQ_HANDLED; } =20 -static int da9062_thermal_get_trip_type(struct thermal_zone_device *z, - int trip, - enum thermal_trip_type *type) -{ - struct da9062_thermal *thermal =3D z->devdata; - - switch (trip) { - case 0: - *type =3D THERMAL_TRIP_HOT; - break; - default: - dev_err(thermal->dev, - "Driver does not support more than 1 trip-wire\n"); - return -EINVAL; - } - - return 0; -} - -static int da9062_thermal_get_trip_temp(struct thermal_zone_device *z, - int trip, - int *temp) -{ - struct da9062_thermal *thermal =3D z->devdata; - - switch (trip) { - case 0: - *temp =3D DA9062_MILLI_CELSIUS(125); - break; - default: - dev_err(thermal->dev, - "Driver does not support more than 1 trip-wire\n"); - return -EINVAL; - } - - return 0; -} - static int da9062_thermal_get_temp(struct thermal_zone_device *z, int *temp) { @@ -172,8 +134,10 @@ static int da9062_thermal_get_temp(struct thermal_zone= _device *z, =20 static struct thermal_zone_device_ops da9062_thermal_ops =3D { .get_temp =3D da9062_thermal_get_temp, - .get_trip_type =3D da9062_thermal_get_trip_type, - .get_trip_temp =3D da9062_thermal_get_trip_temp, +}; + +static struct thermal_trip trips[] =3D { + { .temperature =3D DA9062_MILLI_CELSIUS(125), .type =3D THERMAL_TRIP_HOT = }, }; =20 static const struct da9062_thermal_config da9062_config =3D { @@ -228,10 +192,10 @@ static int da9062_thermal_probe(struct platform_devic= e *pdev) INIT_DELAYED_WORK(&thermal->work, da9062_thermal_poll_on); mutex_init(&thermal->lock); =20 - thermal->zone =3D thermal_zone_device_register(thermal->config->name, - 1, 0, thermal, - &da9062_thermal_ops, NULL, pp_tmp, - 0); + thermal->zone =3D thermal_zone_device_register_with_trips(thermal->config= ->name, + trips, ARRAY_SIZE(trips), 0, thermal, + &da9062_thermal_ops, NULL, pp_tmp, + 0); if (IS_ERR(thermal->zone)) { dev_err(&pdev->dev, "Cannot register thermal zone device\n"); ret =3D PTR_ERR(thermal->zone); --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 1553AECAAA1 for ; Tue, 6 Sep 2022 17:03:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237080AbiIFRDU (ORCPT ); Tue, 6 Sep 2022 13:03:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237754AbiIFRBX (ORCPT ); Tue, 6 Sep 2022 13:01:23 -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 C228195AD7 for ; Tue, 6 Sep 2022 09:48:10 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id t14so9068315wrx.8 for ; Tue, 06 Sep 2022 09:48: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:subject:date; bh=v9HOYNemLB65v2s3X2Chh/1DsPPvYHZYg0+K/15aDgQ=; b=KBk40v1OT946i4B+d+vkBk8cyimrj8gg6lHkT8hIOqFVzup+L566ZgcfQ4sFes+FND 3IupKc/pLXicihX1oQtR0nl+/cJRxFhpQVlPsJIlNqL9EbCF2LTfTPUAJLevuKDFhnt5 b4squC4IrhDisgAUsnWtYXC4AA9S/wLw3+HSJhu3DOPeDfoCrm3uy8Et5S3hGQHDv+LZ I6pUcuypMDWt8n6CVtt4z64pRCqXkOUsax+8gRXWR3o4p0rdv7qPoTkrtQwN1BZXlO8G 9jfPt94QTNArPqcuhkhwb4fEMo6BHLFq3Ec7qNJdws74PO8KergoXU3cXkquudV2PePM cSbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=v9HOYNemLB65v2s3X2Chh/1DsPPvYHZYg0+K/15aDgQ=; b=wuTw5N1E5eCQL7FS0+Yas+sKzL4GSGjcGR+ZU+fEqGjb+expu0tlrAdAjdAIBfEmrQ nBdfLiibwvG/4gh6WP6Nm8DekBhBu9LWw7P23K2RqaWEaznXyFzmVwbvbGH8v+wfEaBa wM2GB5CwnhzDmZviOvsSY5M6llWxu4FIWKM1QT/MCzCqcGfUejBnCU+rqMLeGkQIr80L qCM31XUJ5mg5g/fCDlmaOaVQ/F6pQ0L+Sl5qfEfJuaW3sUcP0mC4bcVMbyRG7IyCXweR eVDS84JqX4+Ti906G8VgGCHVKqEo+3Yw7Fr8KpljBvoOEEL03o4zumCUe5iyyVZyRQd0 v7iQ== X-Gm-Message-State: ACgBeo3Jc1kW7WYd51zRIiafb2spRbhn1iDFnyTu0ooGGFryKj4xmGQd EIpvmK04PcqKrW1Mt96ExXWcBQ== X-Google-Smtp-Source: AA6agR53hPoulIcRoB7W/3CjESueW5s+EE+CW6YumiyGq+fG3CkgKrQkayB+sRAxzfiUb6wYk7+KjA== X-Received: by 2002:a05:6000:1a87:b0:222:2c85:2f5b with SMTP id f7-20020a0560001a8700b002222c852f5bmr28683893wry.654.1662482890291; Tue, 06 Sep 2022 09:48:10 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.48.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:48:09 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Eduardo Valentin , Keerthy , Amit Kucheria , Zhang Rui , linux-omap@vger.kernel.org (open list:TI BANDGAP AND THERMAL DRIVER) Subject: [PATCH v3 26/30] thermal/drivers/ti: Remove unused macros ti_thermal_get_trip_value() / ti_thermal_trip_is_valid() Date: Tue, 6 Sep 2022 18:47:16 +0200 Message-Id: <20220906164720.330701-27-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The macros: ti_thermal_get_trip_value() ti_thermal_trip_is_valid() are unused. Remove them. Signed-off-by: Daniel Lezcano --- drivers/thermal/ti-soc-thermal/ti-thermal.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal.h b/drivers/thermal/= ti-soc-thermal/ti-thermal.h index c388ecf31834..4fd2c20182d7 100644 --- a/drivers/thermal/ti-soc-thermal/ti-thermal.h +++ b/drivers/thermal/ti-soc-thermal/ti-thermal.h @@ -38,21 +38,6 @@ /* Update rates */ #define FAST_TEMP_MONITORING_RATE 250 =20 -/* helper macros */ -/** - * ti_thermal_get_trip_value - returns trip temperature based on index - * @i: trip index - */ -#define ti_thermal_get_trip_value(i) \ - (OMAP_TRIP_HOT + ((i) * OMAP_TRIP_STEP)) - -/** - * ti_thermal_is_valid_trip - check for trip index - * @i: trip index - */ -#define ti_thermal_is_valid_trip(trip) \ - ((trip) >=3D 0 && (trip) < OMAP_TRIP_NUMBER) - #ifdef CONFIG_TI_THERMAL int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id, char *domain); int ti_thermal_remove_sensor(struct ti_bandgap *bgp, int id); --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 D716BC38145 for ; Tue, 6 Sep 2022 17:03:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239548AbiIFRDi (ORCPT ); Tue, 6 Sep 2022 13:03:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238584AbiIFRBo (ORCPT ); Tue, 6 Sep 2022 13:01:44 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88AD495E49 for ; Tue, 6 Sep 2022 09:48:13 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id b16so16355857wru.7 for ; Tue, 06 Sep 2022 09:48: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:subject:date; bh=Bvo7EJO01qiFSqaGbT4JiAGDEh8uk0vvz3ltgjeJ4xY=; b=PCzElyvISj5qWfubEWFk/604t2S+HL6Am3VsTrI8JH6HFKBPnnHUuVAK3RZu5VQbnZ yZ+kKc2PVSmX98UhEMyD23ay7DopBE5dm9+J7/YOEuJDwEv8LBhEnw5491up/s8dkcsv M1hgUvo+MT9iWH8gOOwv4n2TWF/8xgK0slBLWsUXS30Pw2eGWsrz2Nly4pdHY+/htqtZ yZgUn/Dhxo+J27UkQJsZfByJHXD4kxwxYFyCIE79kjBDcynuyUUnM1+bObFVJYCNMmf9 EwquFk2g6UfDNf97PS1S/mSca1F6T62XchlkX5yja//6RgmwT2ZDuVjEC2cM4A7tlAjB kO1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Bvo7EJO01qiFSqaGbT4JiAGDEh8uk0vvz3ltgjeJ4xY=; b=NuIStoqbuZCqN9BNPxl1H3YOuU+WZtyDv5xgnQlxeUT640CYT/X+RdEFg8nbTW57wL 14aqwcIQAAlRjsKx0wzaHR9d3z1/B8v21kSP0YvDZzHuAupt2KYJwi1xQ4M4nezbDaTB O7R20OtwS7PXawaBdPXnSkGFTXdqJbBljEKdGriQGOn2lNndYBxNCfsm4UYI2SdWSOXa 0Jxb8EpgdKCw1UYL01RbBYWEf0pfBkFcAI7SEYlaBV55hpAuBdZ+bxF3lgpRCQoFjF/y xcIcCgw4GgMKbf5s6eWHYlMFkOXNTnpNNFZl0E7psmjBjwyZ68SOEb/24r+Rkw0/LPU9 Y9tg== X-Gm-Message-State: ACgBeo2IlMt08hahXsHFj0zY53R5T8TlfbZKgz3z9HrJ5eHWa5Dyj56h 3Sdjz1LTQYFLSOsNZAkdm+AmZw== X-Google-Smtp-Source: AA6agR4KiTG3Eru17Vb3ip7FH2DYgJ0MzL1zIUo8LKJZHLF/vSbp07/4ddqSaZWzBerIAzbaCURF+A== X-Received: by 2002:a5d:58cb:0:b0:228:dc7f:b9b3 with SMTP id o11-20020a5d58cb000000b00228dc7fb9b3mr1427048wrf.98.1662482891357; Tue, 06 Sep 2022 09:48:11 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.48.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:48:11 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@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 v3 27/30] thermal/drivers/acerhdf: Use generic thermal_zone_get_trip() function Date: Tue, 6 Sep 2022 18:47:17 +0200 Message-Id: <20220906164720.330701-28-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano Acked-by: Hans de Goede Acked-by: Peter K=C3=A4stle --- drivers/platform/x86/acerhdf.c | 73 ++++++++++++---------------------- 1 file changed, 26 insertions(+), 47 deletions(-) diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c index 3463629f8764..a7407aa032ba 100644 --- a/drivers/platform/x86/acerhdf.c +++ b/drivers/platform/x86/acerhdf.c @@ -46,6 +46,8 @@ * measured by the on-die thermal monitor are within 0 <=3D Tj <=3D 90. So, * assume 89=C2=B0C is critical temperature. */ +#define ACERHDF_DEFAULT_TEMP_FANON 60000 +#define ACERHDF_DEFAULT_TEMP_FANOFF 53000 #define ACERHDF_TEMP_CRIT 89000 #define ACERHDF_FAN_OFF 0 #define ACERHDF_FAN_AUTO 1 @@ -70,8 +72,8 @@ static int kernelmode; #endif =20 static unsigned int interval =3D 10; -static unsigned int fanon =3D 60000; -static unsigned int fanoff =3D 53000; +static unsigned int fanon =3D ACERHDF_DEFAULT_TEMP_FANON; +static unsigned int fanoff =3D ACERHDF_DEFAULT_TEMP_FANOFF; static unsigned int verbose; static unsigned int list_supported; static unsigned int fanstate =3D ACERHDF_FAN_AUTO; @@ -137,6 +139,15 @@ struct ctrl_settings { int mcmd_enable; }; =20 +static struct thermal_trip trips[] =3D { + [0] =3D { .temperature =3D ACERHDF_DEFAULT_TEMP_FANON, + .hysteresis =3D ACERHDF_DEFAULT_TEMP_FANON - ACERHDF_DEFAULT_TEMP_FANOFF, + .type =3D THERMAL_TRIP_ACTIVE }, + + [1] =3D { .temperature =3D ACERHDF_TEMP_CRIT, + .type =3D THERMAL_TRIP_CRITICAL } +}; + static struct ctrl_settings ctrl_cfg __read_mostly; =20 /* Register addresses and values for different BIOS versions */ @@ -326,6 +337,15 @@ static void acerhdf_check_param(struct thermal_zone_de= vice *thermal) fanon =3D ACERHDF_MAX_FANON; } =20 + if (fanon < fanoff) { + pr_err("fanoff temperature (%d) is above fanon temperature (%d), clampin= g to %d\n", + fanoff, fanon, fanon); + fanoff =3D fanon; + }; + + trips[0].temperature =3D fanon; + trips[0].hysteresis =3D fanon - fanoff; + if (kernelmode && prev_interval !=3D interval) { if (interval > ACERHDF_MAX_INTERVAL) { pr_err("interval too high, set to %d\n", @@ -424,43 +444,6 @@ static int acerhdf_change_mode(struct thermal_zone_dev= ice *thermal, return 0; } =20 -static int acerhdf_get_trip_type(struct thermal_zone_device *thermal, int = trip, - enum thermal_trip_type *type) -{ - if (trip =3D=3D 0) - *type =3D THERMAL_TRIP_ACTIVE; - else if (trip =3D=3D 1) - *type =3D THERMAL_TRIP_CRITICAL; - else - return -EINVAL; - - return 0; -} - -static int acerhdf_get_trip_hyst(struct thermal_zone_device *thermal, int = trip, - int *temp) -{ - if (trip !=3D 0) - return -EINVAL; - - *temp =3D fanon - fanoff; - - return 0; -} - -static int acerhdf_get_trip_temp(struct thermal_zone_device *thermal, int = trip, - int *temp) -{ - if (trip =3D=3D 0) - *temp =3D fanon; - else if (trip =3D=3D 1) - *temp =3D ACERHDF_TEMP_CRIT; - else - return -EINVAL; - - return 0; -} - static int acerhdf_get_crit_temp(struct thermal_zone_device *thermal, int *temperature) { @@ -474,13 +457,9 @@ static struct thermal_zone_device_ops acerhdf_dev_ops = =3D { .unbind =3D acerhdf_unbind, .get_temp =3D acerhdf_get_ec_temp, .change_mode =3D acerhdf_change_mode, - .get_trip_type =3D acerhdf_get_trip_type, - .get_trip_hyst =3D acerhdf_get_trip_hyst, - .get_trip_temp =3D acerhdf_get_trip_temp, .get_crit_temp =3D acerhdf_get_crit_temp, }; =20 - /* * cooling device callback functions * get maximal fan cooling state @@ -710,10 +689,10 @@ static int __init acerhdf_register_thermal(void) if (IS_ERR(cl_dev)) return -EINVAL; =20 - thz_dev =3D thermal_zone_device_register("acerhdf", 2, 0, NULL, - &acerhdf_dev_ops, - &acerhdf_zone_params, 0, - (kernelmode) ? interval*1000 : 0); + thz_dev =3D thermal_zone_device_register_with_trips("acerhdf", trips, ARR= AY_SIZE(trips), + 0, NULL, &acerhdf_dev_ops, + &acerhdf_zone_params, 0, + (kernelmode) ? interval*1000 : 0); if (IS_ERR(thz_dev)) return -EINVAL; =20 --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 C0FF8ECAAA1 for ; Tue, 6 Sep 2022 17:03:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239494AbiIFRDf (ORCPT ); Tue, 6 Sep 2022 13:03:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238555AbiIFRBm (ORCPT ); Tue, 6 Sep 2022 13:01:42 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6046895E46 for ; Tue, 6 Sep 2022 09:48:13 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id bj14so3081318wrb.12 for ; Tue, 06 Sep 2022 09:48: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:subject:date; bh=qkEQMAFlFrUq6t0pAagx8mtMZ2aPJX8cpHX423TQAwM=; b=DnOGkv/KYL8gcy8iyMtlv3MMxHyG/2pKRadRuY3FexCysYlKZYHL09csaLylqDDN4H MArGzMAU2lyJWYAVsC6oq4smwmUW9PTr80vEJvu6aMeUdm0K59o/vhyQHDQC5MBtKagw O3Pj1UVREYXacGofgXd8Q1kco268ZMjQT9Q44T1OLCMuTlvGJyVtSQzLW6b37x7YGTSF ZpQF0CX9PJyWQxxOz1XMFIqZSvfWao/2njAqjRSlaBHIF9fsPAUtS0Asy460HaQApVEC NGUUZaYZNZxRwpzW7O/jmBy6tgRLbZ7hv+tmn/w3Nvan+cfQdJAa4MsSxu6yrDm+QM9j xesg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=qkEQMAFlFrUq6t0pAagx8mtMZ2aPJX8cpHX423TQAwM=; b=LYECr0wEjzdjw0Kdt+HUIfxbX+/yOJ9Y9CD8JHkPtG28z9gQ1ksRZyEBT2tmYU4f6H H8cAWewnQaSItqI52tOTxvGPrEcLHKtB6IRV+/SkH4iaM5yYCVsrMh7lJ53pBmLrHA05 KI+3qduqAbHB5rP3L0ONRFAh6U1HQ3vCKTR1xSN3ydcY1h15fVxi/RiGFt3jW8v9N6ri d9ezD85kbZizs3IU5k0n8v+fDmcDaLRESyFnYA2AhgX9IYLN9+TF6n03c6fVmOB3eKU9 LnL8ngZnreXwgHx3t5IYInZCtt2WPHbSEpHm/AfqACQwtF6F0xQ1E5ADK+quwOfbGSq7 Irqw== X-Gm-Message-State: ACgBeo2TMEtZ14RpG2wTY+JYa5Yh2zWH8vQYIdNz/54xQWdwCwFpoU4N SHF7hE3ECTMHVLR2SNETUjBA7A== X-Google-Smtp-Source: AA6agR6pYidUqQfaw5PiqdmgwSPcOM7ujKy471ATA8rF5Ex957kqrXg0qovVF/YXl4DKIswXTn92qg== X-Received: by 2002:a05:6000:1446:b0:222:c466:58a0 with SMTP id v6-20020a056000144600b00222c46658a0mr28946592wrx.53.1662482892540; Tue, 06 Sep 2022 09:48:12 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.48.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:48:12 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@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 v3 28/30] thermal/drivers/cxgb4: Use generic thermal_zone_get_trip() function Date: Tue, 6 Sep 2022 18:47:18 +0200 Message-Id: <20220906164720.330701-29-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano Acked-by: Jakub Kicinski --- drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 2 - .../ethernet/chelsio/cxgb4/cxgb4_thermal.c | 41 ++++--------------- 2 files changed, 8 insertions(+), 35 deletions(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ether= net/chelsio/cxgb4/cxgb4.h index 5657ac8cfca0..fca9533bc011 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h @@ -1079,8 +1079,6 @@ struct mbox_list { #if IS_ENABLED(CONFIG_THERMAL) struct ch_thermal { struct thermal_zone_device *tzdev; - int trip_temp; - int trip_type; }; #endif =20 diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c b/drivers/n= et/ethernet/chelsio/cxgb4/cxgb4_thermal.c index 9a6d65243334..1d49cfe3e2ab 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c @@ -29,36 +29,12 @@ static int cxgb4_thermal_get_temp(struct thermal_zone_d= evice *tzdev, return 0; } =20 -static int cxgb4_thermal_get_trip_type(struct thermal_zone_device *tzdev, - int trip, enum thermal_trip_type *type) -{ - struct adapter *adap =3D tzdev->devdata; - - if (!adap->ch_thermal.trip_temp) - return -EINVAL; - - *type =3D adap->ch_thermal.trip_type; - return 0; -} - -static int cxgb4_thermal_get_trip_temp(struct thermal_zone_device *tzdev, - int trip, int *temp) -{ - struct adapter *adap =3D tzdev->devdata; - - if (!adap->ch_thermal.trip_temp) - return -EINVAL; - - *temp =3D adap->ch_thermal.trip_temp; - return 0; -} - static struct thermal_zone_device_ops cxgb4_thermal_ops =3D { .get_temp =3D cxgb4_thermal_get_temp, - .get_trip_type =3D cxgb4_thermal_get_trip_type, - .get_trip_temp =3D cxgb4_thermal_get_trip_temp, }; =20 +static struct thermal_trip trip =3D { .type =3D THERMAL_TRIP_CRITICAL } ; + int cxgb4_thermal_init(struct adapter *adap) { struct ch_thermal *ch_thermal =3D &adap->ch_thermal; @@ -79,15 +55,14 @@ int cxgb4_thermal_init(struct adapter *adap) if (ret < 0) { num_trip =3D 0; /* could not get trip temperature */ } else { - ch_thermal->trip_temp =3D val * 1000; - ch_thermal->trip_type =3D THERMAL_TRIP_CRITICAL; + trip.temperature =3D val * 1000; } - +=09 snprintf(ch_tz_name, sizeof(ch_tz_name), "cxgb4_%s", adap->name); - ch_thermal->tzdev =3D thermal_zone_device_register(ch_tz_name, num_trip, - 0, adap, - &cxgb4_thermal_ops, - NULL, 0, 0); + ch_thermal->tzdev =3D thermal_zone_device_register_with_trips(ch_tz_name,= &trip, num_trip, + 0, adap, + &cxgb4_thermal_ops, + NULL, 0, 0); if (IS_ERR(ch_thermal->tzdev)) { ret =3D PTR_ERR(ch_thermal->tzdev); dev_err(adap->pdev_dev, "Failed to register thermal zone\n"); --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 DCE98ECAAD5 for ; Tue, 6 Sep 2022 17:03:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229629AbiIFRD4 (ORCPT ); Tue, 6 Sep 2022 13:03:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239092AbiIFRB5 (ORCPT ); Tue, 6 Sep 2022 13:01:57 -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 039FC95E63 for ; Tue, 6 Sep 2022 09:48:17 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id s23so7201135wmj.4 for ; Tue, 06 Sep 2022 09:48: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:subject:date; bh=KZ8EnQSq9ZUNp2qj7akZkpIkjIeNnNIZanKBvoVLLJ0=; b=UJznYQKPx0Om/s6q1M2ps9btaAsW56sf3j5rTh1QisMeU6SKjq3peyJ6OKFOAbYjNx Pt5R+W6VSEmGZNMOFNKXCxyOqEhrI1gPRNQ7kFN8zFk2vS6M/pz+6yMRxAiRclKa8/aA D9ktMMFz84TrgK4Gmo3eSOsEnT8uLUOl4A2NpxqnKdTvGnLd7BXwfBHushPmbDpAIzlj uU0bo9D5AjzKhc7JRezdkxE1buIH4nKzHpjhK/EeJEFgLwKiAZYCPv109UpC9loahxrG CLesJ3YfaDQu0PtGWzpmVNQeTPvVwoBzsUXct5QX0CR2SpDRmvsU79fAPk26GVlRt1uN 31Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=KZ8EnQSq9ZUNp2qj7akZkpIkjIeNnNIZanKBvoVLLJ0=; b=GG8VgVvMJGu0lkvGTW9NAw/0Q7J2m93+5ciEVODVLljposvQG3JdSZuajyZhow8tby 81Kejip55OJVeleB6+BnL6ndBRcKaDDk4mf4oazRPzlJwJgcl4IVTxnwPBD+GekcDs38 5YU1x5IkKzAqFSq+539ja5DE8Y0wTclPB3S6ggcpx4v70O8ssBtDZd/ucK7++wsSKiNi msaRnKN3H+ldXGaLCCuW80VVHF8O+UNzAT4u+jx/eBadC4CvEEgNctknmsg3CnACNDSS J3KbBVVHEbfTmpr6sXjsZegjE/pU4p6CFA+kvimUO3TT8cYoSSji2NWcF1zhz8voz7hp llIQ== X-Gm-Message-State: ACgBeo2s73UwUMGjadGR6J9bVzO/7b/ShWEguDXa/EycBuYhDUlnVh82 GHY26G8oH469AkqvAOzacqizJQ== X-Google-Smtp-Source: AA6agR62qcqbNlx2Azz8nrGtLL7Q0eISrdio5jujWotkBlWZC//0aHt2ksbMdQZdy0hhwOlngICs+w== X-Received: by 2002:a05:600c:22ca:b0:3a5:c30d:ca9f with SMTP id 10-20020a05600c22ca00b003a5c30dca9fmr14348241wmg.25.1662482895760; Tue, 06 Sep 2022 09:48:15 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.48.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:48:15 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Srinivas Pandruvada , Amit Kucheria , Zhang Rui , Antoine Tenart Subject: [PATCH v3 29/30] thermal/intel/int340x: Replace parameter to simplify Date: Tue, 6 Sep 2022 18:47:19 +0200 Message-Id: <20220906164720.330701-30-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In the process of replacing the get_trip_* ops by the generic trip points, the current code has an 'override' property to add another indirection to a different ops. Rework this approach to prevent this indirection and make the code ready for the generic trip points conversion. Actually the get_temp() is different regarding the platform, so it is pointless to add a new set of ops but just create dynamically the ops at init time. Signed-off-by: Daniel Lezcano Reviewed-by: Srinivas Pandruvada --- .../int340x_thermal/int340x_thermal_zone.c | 31 ++++++++----------- .../int340x_thermal/int340x_thermal_zone.h | 4 +-- .../processor_thermal_device.c | 10 ++---- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c b= /drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c index 62c0aa5d0783..10731b9a140a 100644 --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c @@ -18,9 +18,6 @@ static int int340x_thermal_get_zone_temp(struct thermal_z= one_device *zone, unsigned long long tmp; acpi_status status; =20 - if (d->override_ops && d->override_ops->get_temp) - return d->override_ops->get_temp(zone, temp); - status =3D acpi_evaluate_integer(d->adev->handle, "_TMP", NULL, &tmp); if (ACPI_FAILURE(status)) return -EIO; @@ -46,9 +43,6 @@ static int int340x_thermal_get_trip_temp(struct thermal_z= one_device *zone, struct int34x_thermal_zone *d =3D zone->devdata; int i; =20 - if (d->override_ops && d->override_ops->get_trip_temp) - return d->override_ops->get_trip_temp(zone, trip, temp); - if (trip < d->aux_trip_nr) *temp =3D d->aux_trips[trip]; else if (trip =3D=3D d->crt_trip_id) @@ -79,9 +73,6 @@ static int int340x_thermal_get_trip_type(struct thermal_z= one_device *zone, struct int34x_thermal_zone *d =3D zone->devdata; int i; =20 - if (d->override_ops && d->override_ops->get_trip_type) - return d->override_ops->get_trip_type(zone, trip, type); - if (trip < d->aux_trip_nr) *type =3D THERMAL_TRIP_PASSIVE; else if (trip =3D=3D d->crt_trip_id) @@ -112,9 +103,6 @@ static int int340x_thermal_set_trip_temp(struct thermal= _zone_device *zone, acpi_status status; char name[10]; =20 - if (d->override_ops && d->override_ops->set_trip_temp) - return d->override_ops->set_trip_temp(zone, trip, temp); - snprintf(name, sizeof(name), "PAT%d", trip); status =3D acpi_execute_simple_method(d->adev->handle, name, millicelsius_to_deci_kelvin(temp)); @@ -134,9 +122,6 @@ static int int340x_thermal_get_trip_hyst(struct thermal= _zone_device *zone, acpi_status status; unsigned long long hyst; =20 - if (d->override_ops && d->override_ops->get_trip_hyst) - return d->override_ops->get_trip_hyst(zone, trip, temp); - status =3D acpi_evaluate_integer(d->adev->handle, "GTSH", NULL, &hyst); if (ACPI_FAILURE(status)) *temp =3D 0; @@ -217,7 +202,7 @@ static struct thermal_zone_params int340x_thermal_param= s =3D { }; =20 struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *a= dev, - struct thermal_zone_device_ops *override_ops) + int (*get_temp) (struct thermal_zone_device *, int *)) { struct int34x_thermal_zone *int34x_thermal_zone; acpi_status status; @@ -231,8 +216,15 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(s= truct acpi_device *adev, return ERR_PTR(-ENOMEM); =20 int34x_thermal_zone->adev =3D adev; - int34x_thermal_zone->override_ops =3D override_ops; =20 + int34x_thermal_zone->ops =3D kmemdup(&int340x_thermal_zone_ops, + sizeof(int340x_thermal_zone_ops), GFP_KERNEL); + if (!int34x_thermal_zone->ops) + goto err_ops_alloc; + + if (get_temp) + int34x_thermal_zone->ops->get_temp =3D get_temp; +=09 status =3D acpi_evaluate_integer(adev->handle, "PATC", NULL, &trip_cnt); if (ACPI_FAILURE(status)) trip_cnt =3D 0; @@ -262,7 +254,7 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(st= ruct acpi_device *adev, acpi_device_bid(adev), trip_cnt, trip_mask, int34x_thermal_zone, - &int340x_thermal_zone_ops, + int34x_thermal_zone->ops, &int340x_thermal_params, 0, 0); if (IS_ERR(int34x_thermal_zone->zone)) { @@ -281,6 +273,8 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(st= ruct acpi_device *adev, acpi_lpat_free_conversion_table(int34x_thermal_zone->lpat_table); kfree(int34x_thermal_zone->aux_trips); err_trip_alloc: + kfree(int34x_thermal_zone->ops); +err_ops_alloc: kfree(int34x_thermal_zone); return ERR_PTR(ret); } @@ -292,6 +286,7 @@ void int340x_thermal_zone_remove(struct int34x_thermal_= zone thermal_zone_device_unregister(int34x_thermal_zone->zone); acpi_lpat_free_conversion_table(int34x_thermal_zone->lpat_table); kfree(int34x_thermal_zone->aux_trips); + kfree(int34x_thermal_zone->ops); kfree(int34x_thermal_zone); } EXPORT_SYMBOL_GPL(int340x_thermal_zone_remove); diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h b= /drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h index 3b4971df1b33..e28ab1ba5e06 100644 --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h @@ -29,13 +29,13 @@ struct int34x_thermal_zone { int hot_temp; int hot_trip_id; struct thermal_zone_device *zone; - struct thermal_zone_device_ops *override_ops; + struct thermal_zone_device_ops *ops; void *priv_data; struct acpi_lpat_conversion_table *lpat_table; }; =20 struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *, - struct thermal_zone_device_ops *override_ops); + int (*get_temp) (struct thermal_zone_device *, int *)); void int340x_thermal_zone_remove(struct int34x_thermal_zone *); int int340x_thermal_read_trips(struct int34x_thermal_zone *int34x_zone); =20 diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device= .c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c index a8d98f1bd6c6..317703027ce9 100644 --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c @@ -207,10 +207,6 @@ static int proc_thermal_get_zone_temp(struct thermal_z= one_device *zone, return ret; } =20 -static struct thermal_zone_device_ops proc_thermal_local_ops =3D { - .get_temp =3D proc_thermal_get_zone_temp, -}; - static int proc_thermal_read_ppcc(struct proc_thermal_device *proc_priv) { int i; @@ -285,7 +281,7 @@ int proc_thermal_add(struct device *dev, struct proc_th= ermal_device *proc_priv) struct acpi_device *adev; acpi_status status; unsigned long long tmp; - struct thermal_zone_device_ops *ops =3D NULL; + int (*get_temp) (struct thermal_zone_device *, int *) =3D NULL; int ret; =20 adev =3D ACPI_COMPANION(dev); @@ -304,10 +300,10 @@ int proc_thermal_add(struct device *dev, struct proc_= thermal_device *proc_priv) /* there is no _TMP method, add local method */ stored_tjmax =3D get_tjmax(); if (stored_tjmax > 0) - ops =3D &proc_thermal_local_ops; + get_temp =3D proc_thermal_get_zone_temp; } =20 - proc_priv->int340x_zone =3D int340x_thermal_zone_add(adev, ops); + proc_priv->int340x_zone =3D int340x_thermal_zone_add(adev, get_temp); if (IS_ERR(proc_priv->int340x_zone)) { return PTR_ERR(proc_priv->int340x_zone); } else --=20 2.34.1 From nobody Mon Apr 6 14:08:59 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 B612DECAAD5 for ; Tue, 6 Sep 2022 17:04:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234094AbiIFREB (ORCPT ); Tue, 6 Sep 2022 13:04:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234600AbiIFRB6 (ORCPT ); Tue, 6 Sep 2022 13:01:58 -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 E16F726EE for ; Tue, 6 Sep 2022 09:48:19 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id c131-20020a1c3589000000b003a84b160addso9277434wma.2 for ; Tue, 06 Sep 2022 09:48:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=vRZj1TG9rH/sMfp9OkBiGp6t4OgUDQ5YYefsVMCB1eo=; b=GBWG4tL/hKbvJxKxG2T2ulhqTSAvLQIuLVRncjwt3m9xhGleA4sA7LSp5SQkCDnUsV wTEAJUI0cmEZjCuEMU9y7E9A65bwpTOAjtyYd4/rQsYxKvnlZwS7Ff4ywTx66Gm0OKQL GK3iwRjP0lMK6B3AKfWGLx7l4hMmTmWVRozznD/EFCjz8mNk1ZZYkEd0M0LeBfr/yKvx RkoRVk998hyTpjBb75hak1P0gI/ktAovPX7DNRD3cBhzcraqzZ80DY+RyuBNY4dCx6pP NHbPTbdO4H52eE/qQugUjs+FR0biH1mHY7882cWGoGLsJB/a0PtcloGxo95aLXtIE1+e r+cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=vRZj1TG9rH/sMfp9OkBiGp6t4OgUDQ5YYefsVMCB1eo=; b=0mdowFF53RdAH5OvY4Oh3OAqsaDDp4QpEe5QzrxzFOpAkMaC3HDWTLHg41h52iCbGb G8QuKs/LMKMFsRgbYQXE0inX6/vhmNC/WHAUUhv74HgT5TKQhUcT8W9vBnzDPunC6ktM rWLoAi6rpWS/NR/jaEI7mXQ3Vi42bun3aBxnow6jtkZGJfOKwqRbIHj/sHJlJo/ZZkdj NdTHc4V1QUX8eoGkUgqAenyNdQioMNUFpjBlVQ0DOUQNpMEhu7uypamd4+MxS/byENn8 61Nm9plmQNV8NTY8xnJEs3dY2pHFSB3h+W7l7ZV0/kwyyTMb+ygHWp90zHzwis5U5Knd 37Yg== X-Gm-Message-State: ACgBeo1pUPde55XhpJFQWhmm13jJSNeZxKOa/rW+B4E7AHq/wIkPalAp xvbEQ55NTz7kusbqb7Nm7VilIQ== X-Google-Smtp-Source: AA6agR6uwdfDBK1mqOgN5okUQ2V9qzzDkkcWpezu9zCRVpAY/osMRW6z4hV2BpC+JOar8ASx6VEksw== X-Received: by 2002:a05:600c:354a:b0:3a5:b01b:2ab0 with SMTP id i10-20020a05600c354a00b003a5b01b2ab0mr13962312wmq.61.1662482897587; Tue, 06 Sep 2022 09:48:17 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id e27-20020adf9bdb000000b0021f0ff1bc6csm7426600wrc.41.2022.09.06.09.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 09:48:17 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Amit Kucheria , Zhang Rui , Jiang Jian Subject: [PATCH v3 30/30] thermal/drivers/intel: Use generic thermal_zone_get_trip() function Date: Tue, 6 Sep 2022 18:47:20 +0200 Message-Id: <20220906164720.330701-31-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906164720.330701-1-daniel.lezcano@linaro.org> References: <20220906164720.330701-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with t= he thermal zone. Signed-off-by: Daniel Lezcano Reviewed-by: Srinivas Pandruvada --- drivers/thermal/intel/x86_pkg_temp_thermal.c | 120 ++++++++++--------- 1 file changed, 66 insertions(+), 54 deletions(-) diff --git a/drivers/thermal/intel/x86_pkg_temp_thermal.c b/drivers/thermal= /intel/x86_pkg_temp_thermal.c index a0e234fce71a..e7c3b78d959c 100644 --- a/drivers/thermal/intel/x86_pkg_temp_thermal.c +++ b/drivers/thermal/intel/x86_pkg_temp_thermal.c @@ -53,6 +53,7 @@ struct zone_device { u32 msr_pkg_therm_high; struct delayed_work work; struct thermal_zone_device *tzone; + struct thermal_trip *trips; struct cpumask cpumask; }; =20 @@ -138,40 +139,6 @@ static int sys_get_curr_temp(struct thermal_zone_devic= e *tzd, int *temp) return -EINVAL; } =20 -static int sys_get_trip_temp(struct thermal_zone_device *tzd, - int trip, int *temp) -{ - struct zone_device *zonedev =3D tzd->devdata; - unsigned long thres_reg_value; - u32 mask, shift, eax, edx; - int ret; - - if (trip >=3D MAX_NUMBER_OF_TRIPS) - return -EINVAL; - - if (trip) { - mask =3D THERM_MASK_THRESHOLD1; - shift =3D THERM_SHIFT_THRESHOLD1; - } else { - mask =3D THERM_MASK_THRESHOLD0; - shift =3D THERM_SHIFT_THRESHOLD0; - } - - ret =3D rdmsr_on_cpu(zonedev->cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT, - &eax, &edx); - if (ret < 0) - return ret; - - thres_reg_value =3D (eax & mask) >> shift; - if (thres_reg_value) - *temp =3D zonedev->tj_max - thres_reg_value * 1000; - else - *temp =3D THERMAL_TEMP_INVALID; - pr_debug("sys_get_trip_temp %d\n", *temp); - - return 0; -} - static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp) { @@ -212,18 +179,9 @@ sys_set_trip_temp(struct thermal_zone_device *tzd, int= trip, int temp) l, h); } =20 -static int sys_get_trip_type(struct thermal_zone_device *thermal, int trip, - enum thermal_trip_type *type) -{ - *type =3D THERMAL_TRIP_PASSIVE; - return 0; -} - /* Thermal zone callback registry */ static struct thermal_zone_device_ops tzone_ops =3D { .get_temp =3D sys_get_curr_temp, - .get_trip_temp =3D sys_get_trip_temp, - .get_trip_type =3D sys_get_trip_type, .set_trip_temp =3D sys_set_trip_temp, }; =20 @@ -328,6 +286,48 @@ static int pkg_thermal_notify(u64 msr_val) return 0; } =20 +static struct thermal_trip *pkg_temp_thermal_trips_init(int cpu, int tj_ma= x, int num_trips) +{ + struct thermal_trip *trips; + unsigned long thres_reg_value; + u32 mask, shift, eax, edx; + int ret, i; + + trips =3D kzalloc(sizeof(*trips) * num_trips, GFP_KERNEL); + if (!trips) + return ERR_PTR(-ENOMEM); +=09 + for (i =3D 0; i < num_trips; i++) { + + if (i) { + mask =3D THERM_MASK_THRESHOLD1; + shift =3D THERM_SHIFT_THRESHOLD1; + } else { + mask =3D THERM_MASK_THRESHOLD0; + shift =3D THERM_SHIFT_THRESHOLD0; + } + + ret =3D rdmsr_on_cpu(cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT, + &eax, &edx); + if (ret < 0) { + kfree(trips); + return ERR_PTR(ret); + } + + thres_reg_value =3D (eax & mask) >> shift; + + trips[i].temperature =3D thres_reg_value ? + tj_max - thres_reg_value * 1000 : THERMAL_TEMP_INVALID; + + trips[i].type =3D THERMAL_TRIP_PASSIVE; + =09 + pr_debug("%s: cpu=3D%d, trip=3D%d, temp=3D%d\n", + __func__, cpu, i, trips[i].temperature); + } + + return trips; +} + static int pkg_temp_thermal_device_add(unsigned int cpu) { int id =3D topology_logical_die_id(cpu); @@ -353,24 +353,27 @@ static int pkg_temp_thermal_device_add(unsigned int c= pu) if (!zonedev) return -ENOMEM; =20 + zonedev->trips =3D pkg_temp_thermal_trips_init(cpu, tj_max, thres_count); + if (IS_ERR(zonedev->trips)) { + err =3D PTR_ERR(zonedev->trips); + goto out_kfree_zonedev; + } +=09 INIT_DELAYED_WORK(&zonedev->work, pkg_temp_thermal_threshold_work_fn); zonedev->cpu =3D cpu; zonedev->tj_max =3D tj_max; - zonedev->tzone =3D thermal_zone_device_register("x86_pkg_temp", - thres_count, + zonedev->tzone =3D thermal_zone_device_register_with_trips("x86_pkg_temp", + zonedev->trips, thres_count, (thres_count =3D=3D MAX_NUMBER_OF_TRIPS) ? 0x03 : 0x01, zonedev, &tzone_ops, &pkg_temp_tz_params, 0, 0); if (IS_ERR(zonedev->tzone)) { err =3D PTR_ERR(zonedev->tzone); - kfree(zonedev); - return err; + goto out_kfree_trips; } err =3D thermal_zone_device_enable(zonedev->tzone); - if (err) { - thermal_zone_device_unregister(zonedev->tzone); - kfree(zonedev); - return err; - } + if (err) + goto out_unregister_tz; + /* Store MSR value for package thermal interrupt, to restore at exit */ rdmsr(MSR_IA32_PACKAGE_THERM_INTERRUPT, zonedev->msr_pkg_therm_low, zonedev->msr_pkg_therm_high); @@ -379,7 +382,14 @@ static int pkg_temp_thermal_device_add(unsigned int cp= u) raw_spin_lock_irq(&pkg_temp_lock); zones[id] =3D zonedev; raw_spin_unlock_irq(&pkg_temp_lock); - return 0; + +out_unregister_tz:=09 + thermal_zone_device_unregister(zonedev->tzone); +out_kfree_trips: + kfree(zonedev->trips); +out_kfree_zonedev: + kfree(zonedev); + return err; } =20 static int pkg_thermal_cpu_offline(unsigned int cpu) @@ -463,8 +473,10 @@ static int pkg_thermal_cpu_offline(unsigned int cpu) raw_spin_unlock_irq(&pkg_temp_lock); =20 /* Final cleanup if this is the last cpu */ - if (lastcpu) + if (lastcpu) { + kfree(zonedev->trips); kfree(zonedev); + } return 0; } =20 --=20 2.34.1