From nobody Mon Jun 15 01:41:29 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 11C44C4332F for ; Sat, 7 May 2022 12:55:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385002AbiEGM7F (ORCPT ); Sat, 7 May 2022 08:59:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384917AbiEGM6w (ORCPT ); Sat, 7 May 2022 08:58:52 -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 3B6874B1C6 for ; Sat, 7 May 2022 05:55:03 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id j15so13459983wrb.2 for ; Sat, 07 May 2022 05:55:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2qW7EpFg+nLG6Nywn0ltS3weZ1OcAg1+DN7VidSEha4=; b=DUgal0hI6q/dV/vG4Qm/Ui5A8Mtdt9gHo3wbPLyIDcqkGYnvMVJ0UI0r/bO0x52Cf+ AZbcdXpWQGdkPGxCzr1i/kE6xCfbqDxLnN7r9sqTbk1pjcBPONhJVImQIZaGgmDENd6j 9BcRbzaKvT5SRCP2H9ba5LfRcn6YmhygHJGSJx878/oodYo3p2lBLXWMUmdpUSQYpXiK B490eUBYNgAARlm8lHZZDBtIPYBjIbGZ5gIal3JGgPVAk5JtgPQrght2BYseMcKm7qtY y+1nmYOxXB2kik66K9XRR9HCE1MJxgDyN/EjZQYB9wWPSxNOaSlR3bJ6F7eO3T8e6Tco 5ncQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2qW7EpFg+nLG6Nywn0ltS3weZ1OcAg1+DN7VidSEha4=; b=JaWKkxMSrN7rxOq28R2If5Wu3QGFasndtXErxcmPWLYcaWmXg60gQB64qh3pWiM0Ah ZJl4QOqXiDCmDQ+pfC9ZKTynuhn0CQ5AM18GmFT6WJ5nMqlMgggbZG//SMWc6Jy6gUJ6 w7sPrQApxHqyz/gLElcnXFv7ETZnAU3A0cpXCOXSzxbtpuSwIzLPb8noCrSAgLgMhPGz cGRRH34gxo5/fNo86WoMIoffFAoAX1Jn9N8CNXjTdozNY0Txhw7W/4FNNrSKScnpMF2Z /q14uZ6AHx9F9wPCuM265eMphWpa8tox7A1+d8K3Xv+hQ4jCKgRM33sGwWJdXfBAvBpK yV7g== X-Gm-Message-State: AOAM531+ZkhvVIj5/4VhMB0gpJmP7GlTFhvhbbkP8hX8ajyaQIcJJLjV 4bVWM4H5Qzp3LzjCRerCyOMG4Q== X-Google-Smtp-Source: ABdhPJz/8tc/51OAGSilxkiFqQAhLdZ8kqmZrfD/tldFiK7A2hCP1/g9uGjkQXY7m6O0cy51a7o0EA== X-Received: by 2002:a5d:5986:0:b0:20c:5844:820d with SMTP id n6-20020a5d5986000000b0020c5844820dmr6393841wri.192.1651928101605; Sat, 07 May 2022 05:55:01 -0700 (PDT) Received: from localhost.localdomain (static-176-182-171-101.ncc.abo.bbox.fr. [176.182.171.101]) by smtp.gmail.com with ESMTPSA id e9-20020a05600c218900b0039453fe55a7sm10470345wme.35.2022.05.07.05.54.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 May 2022 05:55:01 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Zhang Rui , Jonathan Corbet , Len Brown , Raju Rangoju , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Ido Schimmel , Petr Machata , Luca Coelho , Kalle Valo , Peter Kaestle , Hans de Goede , Mark Gross , Sebastian Reichel , Miquel Raynal , Support Opensource , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Miri Korenblit , Johannes Berg , Srinivas Pandruvada , Sumeet Pawnikar , Dan Carpenter , Chuansheng Liu , Jiasheng Jiang , Antoine Tenart , Andy Shevchenko , linux-doc@vger.kernel.org (open list:DOCUMENTATION), linux-acpi@vger.kernel.org (open list:ACPI THERMAL DRIVER), netdev@vger.kernel.org (open list:CXGB4 ETHERNET DRIVER (CXGB4)), linux-wireless@vger.kernel.org (open list:INTEL WIRELESS WIFI LINK (iwlwifi)), platform-driver-x86@vger.kernel.org (open list:ACER ASPIRE ONE TEMPERATURE AND FAN DRIVER), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-renesas-soc@vger.kernel.org (open list:RENESAS R-CAR THERMAL DRIVERS) Subject: [PATCH v2 01/14] thermal/core: Change thermal_zone_ops to thermal_sensor_ops Date: Sat, 7 May 2022 14:54:29 +0200 Message-Id: <20220507125443.2766939-2-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220507125443.2766939-1-daniel.lezcano@linexp.org> References: <20220507125443.2766939-1-daniel.lezcano@linexp.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" A thermal zone is software abstraction of a sensor associated with properties and cooling devices if any. The fact that we have thermal_zone and thermal_zone_ops mixed is confusing and does not clearly identify the different components entering in the thermal management process. A thermal zone appears to be a sensor while it is not. In order to set the scene for multiple thermal sensors aggregated into a single thermal zone. Rename the thermal_zone_ops to thermal_sensor_ops, that will appear clearyl the thermal zone is not a sensor but an abstraction of one [or multiple] sensor(s). Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano Acked-by: Andy Shevchenko Reviewed-by: Geert Uytterhoeven --- Documentation/driver-api/thermal/sysfs-api.rst | 2 +- drivers/acpi/thermal.c | 6 +++--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c | 2 +- drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 6 +++--- drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 2 +- drivers/platform/x86/acerhdf.c | 2 +- drivers/power/supply/power_supply_core.c | 2 +- drivers/thermal/armada_thermal.c | 2 +- drivers/thermal/da9062-thermal.c | 2 +- drivers/thermal/dove_thermal.c | 2 +- drivers/thermal/imx_thermal.c | 2 +- drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 2 +- .../thermal/intel/int340x_thermal/int340x_thermal_zone.c | 6 +++--- .../thermal/intel/int340x_thermal/int340x_thermal_zone.h | 4 ++-- .../intel/int340x_thermal/processor_thermal_device.c | 4 ++-- .../intel/int340x_thermal/processor_thermal_device_pci.c | 2 +- drivers/thermal/intel/intel_pch_thermal.c | 2 +- drivers/thermal/intel/intel_quark_dts_thermal.c | 2 +- drivers/thermal/intel/intel_soc_dts_iosf.c | 2 +- drivers/thermal/intel/x86_pkg_temp_thermal.c | 2 +- drivers/thermal/kirkwood_thermal.c | 2 +- drivers/thermal/rcar_thermal.c | 4 ++-- drivers/thermal/spear_thermal.c | 2 +- drivers/thermal/st/st_thermal.c | 2 +- drivers/thermal/thermal_core.c | 2 +- drivers/thermal/thermal_of.c | 4 ++-- include/linux/thermal.h | 8 ++++---- 27 files changed, 40 insertions(+), 40 deletions(-) diff --git a/Documentation/driver-api/thermal/sysfs-api.rst b/Documentation= /driver-api/thermal/sysfs-api.rst index 2e0f79a9e2ee..6dff5e6e1166 100644 --- a/Documentation/driver-api/thermal/sysfs-api.rst +++ b/Documentation/driver-api/thermal/sysfs-api.rst @@ -41,7 +41,7 @@ temperature) and throttle appropriate devices. struct thermal_zone_device *thermal_zone_device_register(char *type, int trips, int mask, void *devdata, - struct thermal_zone_device_ops *ops, + struct thermal_sensor_ops *ops, const struct thermal_zone_params *tzp, int passive_delay, int polling_delay)) =20 diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 539660ef93c7..c2b8100f9cd8 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -774,7 +774,7 @@ acpi_thermal_unbind_cooling_device(struct thermal_zone_= device *thermal, return acpi_thermal_cooling_device_cb(thermal, cdev, false); } =20 -static struct thermal_zone_device_ops acpi_thermal_zone_ops =3D { +static struct thermal_sensor_ops acpi_thermal_sensor_ops =3D { .bind =3D acpi_thermal_bind_cooling_device, .unbind =3D acpi_thermal_unbind_cooling_device, .get_temp =3D thermal_get_temp, @@ -808,13 +808,13 @@ static int acpi_thermal_register_thermal_zone(struct = acpi_thermal *tz) if (tz->trips.passive.flags.valid) tz->thermal_zone =3D thermal_zone_device_register("acpitz", trips, 0, tz, - &acpi_thermal_zone_ops, NULL, + &acpi_thermal_sensor_ops, NULL, tz->trips.passive.tsp*100, tz->polling_frequency*100); else tz->thermal_zone =3D thermal_zone_device_register("acpitz", trips, 0, tz, - &acpi_thermal_zone_ops, NULL, + &acpi_thermal_sensor_ops, NULL, 0, tz->polling_frequency*100); if (IS_ERR(tz->thermal_zone)) return -ENODEV; diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c b/drivers/n= et/ethernet/chelsio/cxgb4/cxgb4_thermal.c index 9a6d65243334..239824e90fbe 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c @@ -53,7 +53,7 @@ static int cxgb4_thermal_get_trip_temp(struct thermal_zon= e_device *tzdev, return 0; } =20 -static struct thermal_zone_device_ops cxgb4_thermal_ops =3D { +static struct thermal_sensor_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, diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/n= et/ethernet/mellanox/mlxsw/core_thermal.c index 05f54bd982c0..cf609dc39acd 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c @@ -361,7 +361,7 @@ static struct thermal_zone_params mlxsw_thermal_params = =3D { .no_hwmon =3D true, }; =20 -static struct thermal_zone_device_ops mlxsw_thermal_ops =3D { +static struct thermal_sensor_ops mlxsw_thermal_ops =3D { .bind =3D mlxsw_thermal_bind, .unbind =3D mlxsw_thermal_unbind, .get_temp =3D mlxsw_thermal_get_temp, @@ -553,7 +553,7 @@ static int mlxsw_thermal_module_trend_get(struct therma= l_zone_device *tzdev, return 0; } =20 -static struct thermal_zone_device_ops mlxsw_thermal_module_ops =3D { +static struct thermal_sensor_ops mlxsw_thermal_module_ops =3D { .bind =3D mlxsw_thermal_module_bind, .unbind =3D mlxsw_thermal_module_unbind, .get_temp =3D mlxsw_thermal_module_temp_get, @@ -590,7 +590,7 @@ static int mlxsw_thermal_gearbox_temp_get(struct therma= l_zone_device *tzdev, return 0; } =20 -static struct thermal_zone_device_ops mlxsw_thermal_gearbox_ops =3D { +static struct thermal_sensor_ops mlxsw_thermal_gearbox_ops =3D { .bind =3D mlxsw_thermal_module_bind, .unbind =3D mlxsw_thermal_module_unbind, .get_temp =3D mlxsw_thermal_gearbox_temp_get, diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c b/drivers/net/wire= less/intel/iwlwifi/mvm/tt.c index 69cf3a372759..74109a7d329f 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c @@ -718,7 +718,7 @@ static int iwl_mvm_tzone_set_trip_temp(struct thermal_z= one_device *device, return ret; } =20 -static struct thermal_zone_device_ops tzone_ops =3D { +static struct thermal_sensor_ops tzone_ops =3D { .get_temp =3D iwl_mvm_tzone_get_temp, .get_trip_temp =3D iwl_mvm_tzone_get_trip_temp, .get_trip_type =3D iwl_mvm_tzone_get_trip_type, diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c index 3463629f8764..b9e8f6c60714 100644 --- a/drivers/platform/x86/acerhdf.c +++ b/drivers/platform/x86/acerhdf.c @@ -469,7 +469,7 @@ static int acerhdf_get_crit_temp(struct thermal_zone_de= vice *thermal, } =20 /* bind callback functions to thermalzone */ -static struct thermal_zone_device_ops acerhdf_dev_ops =3D { +static struct thermal_sensor_ops acerhdf_dev_ops =3D { .bind =3D acerhdf_bind, .unbind =3D acerhdf_unbind, .get_temp =3D acerhdf_get_ec_temp, diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/suppl= y/power_supply_core.c index d925cb137e12..5ada4a94b4e3 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -1149,7 +1149,7 @@ static int power_supply_read_temp(struct thermal_zone= _device *tzd, return ret; } =20 -static struct thermal_zone_device_ops psy_tzd_ops =3D { +static struct thermal_sensor_ops psy_tzd_ops =3D { .get_temp =3D power_supply_read_temp, }; =20 diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_ther= mal.c index c2ebfb5be4b3..703ace32a217 100644 --- a/drivers/thermal/armada_thermal.c +++ b/drivers/thermal/armada_thermal.c @@ -416,7 +416,7 @@ static int armada_get_temp_legacy(struct thermal_zone_d= evice *thermal, return ret; } =20 -static struct thermal_zone_device_ops legacy_ops =3D { +static struct thermal_sensor_ops legacy_ops =3D { .get_temp =3D armada_get_temp_legacy, }; =20 diff --git a/drivers/thermal/da9062-thermal.c b/drivers/thermal/da9062-ther= mal.c index 180edec34e07..d29953eee39f 100644 --- a/drivers/thermal/da9062-thermal.c +++ b/drivers/thermal/da9062-thermal.c @@ -170,7 +170,7 @@ static int da9062_thermal_get_temp(struct thermal_zone_= device *z, return 0; } =20 -static struct thermal_zone_device_ops da9062_thermal_ops =3D { +static struct thermal_sensor_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, diff --git a/drivers/thermal/dove_thermal.c b/drivers/thermal/dove_thermal.c index 73182eb94bc0..170a1168ae38 100644 --- a/drivers/thermal/dove_thermal.c +++ b/drivers/thermal/dove_thermal.c @@ -109,7 +109,7 @@ static int dove_get_temp(struct thermal_zone_device *th= ermal, return 0; } =20 -static struct thermal_zone_device_ops ops =3D { +static struct thermal_sensor_ops ops =3D { .get_temp =3D dove_get_temp, }; =20 diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 16663373b682..c57fa2029ee0 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -418,7 +418,7 @@ static int imx_unbind(struct thermal_zone_device *tz, return 0; } =20 -static struct thermal_zone_device_ops imx_tz_ops =3D { +static struct thermal_sensor_ops imx_tz_ops =3D { .bind =3D imx_bind, .unbind =3D imx_unbind, .get_temp =3D imx_get_temp, diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/driv= ers/thermal/intel/int340x_thermal/int3400_thermal.c index 4954800b9850..cad48a886888 100644 --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c @@ -485,7 +485,7 @@ static int int3400_thermal_change_mode(struct thermal_z= one_device *thermal, return result; } =20 -static struct thermal_zone_device_ops int3400_thermal_ops =3D { +static struct thermal_sensor_ops int3400_thermal_ops =3D { .get_temp =3D int3400_thermal_get_temp, .change_mode =3D int3400_thermal_change_mode, }; diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c b= /drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c index 62c0aa5d0783..d78f29208352 100644 --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c @@ -151,7 +151,7 @@ static void int340x_thermal_critical(struct thermal_zon= e_device *zone) dev_dbg(&zone->device, "%s: critical temperature reached\n", zone->type); } =20 -static struct thermal_zone_device_ops int340x_thermal_zone_ops =3D { +static struct thermal_sensor_ops int340x_thermal_sensor_ops =3D { .get_temp =3D int340x_thermal_get_zone_temp, .get_trip_temp =3D int340x_thermal_get_trip_temp, .get_trip_type =3D int340x_thermal_get_trip_type, @@ -217,7 +217,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) + struct thermal_sensor_ops *override_ops) { struct int34x_thermal_zone *int34x_thermal_zone; acpi_status status; @@ -262,7 +262,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, + &int340x_thermal_sensor_ops, &int340x_thermal_params, 0, 0); if (IS_ERR(int34x_thermal_zone->zone)) { diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h b= /drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h index 3b4971df1b33..a25c45e2eb66 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_sensor_ops *override_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); + struct thermal_sensor_ops *override_ops); 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..4b8544f72a23 100644 --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c @@ -207,7 +207,7 @@ static int proc_thermal_get_zone_temp(struct thermal_zo= ne_device *zone, return ret; } =20 -static struct thermal_zone_device_ops proc_thermal_local_ops =3D { +static struct thermal_sensor_ops proc_thermal_local_ops =3D { .get_temp =3D proc_thermal_get_zone_temp, }; =20 @@ -285,7 +285,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; + struct thermal_sensor_ops *ops =3D NULL; int ret; =20 adev =3D ACPI_COMPANION(dev); diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device= _pci.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci= .c index ca40b0967cdd..5316143b09b2 100644 --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c @@ -200,7 +200,7 @@ static int sys_set_trip_temp(struct thermal_zone_device= *tzd, int trip, int temp return 0; } =20 -static struct thermal_zone_device_ops tzone_ops =3D { +static struct thermal_sensor_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, diff --git a/drivers/thermal/intel/intel_pch_thermal.c b/drivers/thermal/in= tel/intel_pch_thermal.c index 527c91f5960b..e2161ab647b0 100644 --- a/drivers/thermal/intel/intel_pch_thermal.c +++ b/drivers/thermal/intel/intel_pch_thermal.c @@ -331,7 +331,7 @@ static void pch_critical(struct thermal_zone_device *tz= d) dev_dbg(&tzd->device, "%s: critical temperature reached\n", tzd->type); } =20 -static struct thermal_zone_device_ops tzd_ops =3D { +static struct thermal_sensor_ops tzd_ops =3D { .get_temp =3D pch_thermal_get_temp, .get_trip_type =3D pch_get_trip_type, .get_trip_temp =3D pch_get_trip_temp, diff --git a/drivers/thermal/intel/intel_quark_dts_thermal.c b/drivers/ther= mal/intel/intel_quark_dts_thermal.c index 3eafc6b0e6c3..636286dc90fc 100644 --- a/drivers/thermal/intel/intel_quark_dts_thermal.c +++ b/drivers/thermal/intel/intel_quark_dts_thermal.c @@ -313,7 +313,7 @@ static int sys_change_mode(struct thermal_zone_device *= tzd, return ret; } =20 -static struct thermal_zone_device_ops tzone_ops =3D { +static struct thermal_sensor_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, diff --git a/drivers/thermal/intel/intel_soc_dts_iosf.c b/drivers/thermal/i= ntel/intel_soc_dts_iosf.c index 342b0bb5a56d..38ce8426fc35 100644 --- a/drivers/thermal/intel/intel_soc_dts_iosf.c +++ b/drivers/thermal/intel/intel_soc_dts_iosf.c @@ -243,7 +243,7 @@ static int sys_get_curr_temp(struct thermal_zone_device= *tzd, return 0; } =20 -static struct thermal_zone_device_ops tzone_ops =3D { +static struct thermal_sensor_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, diff --git a/drivers/thermal/intel/x86_pkg_temp_thermal.c b/drivers/thermal= /intel/x86_pkg_temp_thermal.c index 4d8edc61a78b..047e27db72fe 100644 --- a/drivers/thermal/intel/x86_pkg_temp_thermal.c +++ b/drivers/thermal/intel/x86_pkg_temp_thermal.c @@ -220,7 +220,7 @@ static int sys_get_trip_type(struct thermal_zone_device= *thermal, int trip, } =20 /* Thermal zone callback registry */ -static struct thermal_zone_device_ops tzone_ops =3D { +static struct thermal_sensor_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, diff --git a/drivers/thermal/kirkwood_thermal.c b/drivers/thermal/kirkwood_= thermal.c index 7fb6e476c82a..d8e24549428d 100644 --- a/drivers/thermal/kirkwood_thermal.c +++ b/drivers/thermal/kirkwood_thermal.c @@ -51,7 +51,7 @@ static int kirkwood_get_temp(struct thermal_zone_device *= thermal, return 0; } =20 -static struct thermal_zone_device_ops ops =3D { +static struct thermal_sensor_ops ops =3D { .get_temp =3D kirkwood_get_temp, }; =20 diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index b49f04daaf47..a7c22e85adc6 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c @@ -327,7 +327,7 @@ static const struct thermal_zone_of_device_ops rcar_the= rmal_zone_of_ops =3D { .get_temp =3D rcar_thermal_of_get_temp, }; =20 -static struct thermal_zone_device_ops rcar_thermal_zone_ops =3D { +static struct thermal_sensor_ops rcar_thermal_sensor_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, @@ -534,7 +534,7 @@ static int rcar_thermal_probe(struct platform_device *p= dev) priv->zone =3D thermal_zone_device_register( "rcar_thermal", 1, 0, priv, - &rcar_thermal_zone_ops, NULL, 0, + &rcar_thermal_sensor_ops, NULL, 0, idle); =20 ret =3D thermal_zone_device_enable(priv->zone); diff --git a/drivers/thermal/spear_thermal.c b/drivers/thermal/spear_therma= l.c index ee33ed692e4f..462a8d4bd1c8 100644 --- a/drivers/thermal/spear_thermal.c +++ b/drivers/thermal/spear_thermal.c @@ -41,7 +41,7 @@ static inline int thermal_get_temp(struct thermal_zone_de= vice *thermal, return 0; } =20 -static struct thermal_zone_device_ops ops =3D { +static struct thermal_sensor_ops ops =3D { .get_temp =3D thermal_get_temp, }; =20 diff --git a/drivers/thermal/st/st_thermal.c b/drivers/thermal/st/st_therma= l.c index 1276b95604fe..c42d9cae5e52 100644 --- a/drivers/thermal/st/st_thermal.c +++ b/drivers/thermal/st/st_thermal.c @@ -170,7 +170,7 @@ static int st_thermal_get_trip_temp(struct thermal_zone= _device *th, return 0; } =20 -static struct thermal_zone_device_ops st_tz_ops =3D { +static struct thermal_sensor_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, diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 82654dc8382b..065dfc179e53 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1184,7 +1184,7 @@ static void bind_tz(struct thermal_zone_device *tz) */ struct thermal_zone_device * thermal_zone_device_register(const char *type, int trips, int mask, - void *devdata, struct thermal_zone_device_ops *ops, + void *devdata, struct thermal_sensor_ops *ops, struct thermal_zone_params *tzp, int passive_delay, int polling_delay) { diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 9233f7e74454..ef953cba3504 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -360,7 +360,7 @@ static int of_thermal_get_crit_temp(struct thermal_zone= _device *tz, return -EINVAL; } =20 -static struct thermal_zone_device_ops of_thermal_ops =3D { +static struct thermal_sensor_ops of_thermal_ops =3D { .get_trip_type =3D of_thermal_get_trip_type, .get_trip_temp =3D of_thermal_get_trip_temp, .set_trip_temp =3D of_thermal_set_trip_temp, @@ -1046,7 +1046,7 @@ int __init of_parse_thermal_zones(void) { struct device_node *np, *child; struct __thermal_zone *tz; - struct thermal_zone_device_ops *ops; + struct thermal_sensor_ops *ops; =20 np =3D of_find_node_by_name(NULL, "thermal-zones"); if (!np) { diff --git a/include/linux/thermal.h b/include/linux/thermal.h index c314893970b3..991f7bc02d51 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -57,7 +57,7 @@ enum thermal_notify_event { THERMAL_EVENT_KEEP_ALIVE, /* Request for user space handler to respond */ }; =20 -struct thermal_zone_device_ops { +struct thermal_sensor_ops { int (*bind) (struct thermal_zone_device *, struct thermal_cooling_device *); int (*unbind) (struct thermal_zone_device *, @@ -164,7 +164,7 @@ struct thermal_zone_device { int prev_low_trip; int prev_high_trip; atomic_t need_update; - struct thermal_zone_device_ops *ops; + struct thermal_sensor_ops *ops; struct thermal_zone_params *tzp; struct thermal_governor *governor; void *governor_data; @@ -361,7 +361,7 @@ void devm_thermal_zone_of_sensor_unregister(struct devi= ce *dev, =20 #ifdef CONFIG_THERMAL struct thermal_zone_device *thermal_zone_device_register(const char *, int= , int, - void *, struct thermal_zone_device_ops *, + void *, struct thermal_sensor_ops *, struct thermal_zone_params *, int, int); void thermal_zone_device_unregister(struct thermal_zone_device *); =20 @@ -396,7 +396,7 @@ void thermal_zone_device_critical(struct thermal_zone_d= evice *tz); #else static inline struct thermal_zone_device *thermal_zone_device_register( const char *type, int trips, int mask, void *devdata, - struct thermal_zone_device_ops *ops, + struct thermal_sensor_ops *ops, struct thermal_zone_params *tzp, int passive_delay, int polling_delay) { return ERR_PTR(-ENODEV); } --=20 2.25.1 From nobody Mon Jun 15 01:41:29 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 94D52C433F5 for ; Sat, 7 May 2022 12:56:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1446409AbiEGM7y (ORCPT ); Sat, 7 May 2022 08:59:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385035AbiEGM7A (ORCPT ); Sat, 7 May 2022 08:59:00 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C7C64160B for ; Sat, 7 May 2022 05:55:10 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id u3so13446807wrg.3 for ; Sat, 07 May 2022 05:55:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sgVmBlxs9P9xbO7URgqtK6603JvDxqfpA8O1IfiKSAg=; b=vuLKoWpMVSU5Avp0DqYiciQK6xUT9dt3GWPB1iVDjZIgEvmx91bKN67HKh5kamsB2S vrae5nRl0m6lmxe5LF/4CrQpjupBPC71CZNoDSMmqeC2FmSyAdDLz7bqn5MO4AOlsTn1 PWH62lECJSWDSY/pCbY3TfLFpO4q1a00jJ17ebWFdVSJFQoA6HlPtRbpFr4SnduiP6fI Y3YDTc2Cb4FuDhV4hR6SCCaFRd3qxJCahtW0ep+g+bY32syAofZU0R4Cn5xQbzE51sTz rR9f8xo4qJNltfRkAfk/SECaB4H4TauiQPAW5gdXbfoP1P+4pBqAmr3FdQtzLcLQcHgH Ix1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sgVmBlxs9P9xbO7URgqtK6603JvDxqfpA8O1IfiKSAg=; b=Bs+5NKK+fRpxpgDOQiFGNoTryK4sdXIKe0X6Qx02fBmN4Yp6EemmvCeeK15lhPzqve bfWKmVju2wCv7gNmeHpARiY461vptmHiJCS/+TVmMe9ug0FdwE5X1ypHCo4AcwVJE6/o yz0AY0O1MNlo/248HAb3vVX17u+NCAu60ij2piYJsCORtAsZEvp3ukh09Loi9GQOO52W W8tNXUcv0Ta8UK9bJsBgkO8i11N+mlH0kvU4wvBmo1tiN7kQmDwlNt+R5iJTet5TgXFr rbWT3WPHqCX4ByddNgvClcPnaA3ye7Brgfdw7W0NsViM/ugwGpXiootr6cQ4zAEhgI5m GjpQ== X-Gm-Message-State: AOAM531xAMvmCgWeXy/k/ciMfBR75XyR0xWqWu4ZDgCY9IahIwKVSDPU QPmDO2Z7qvJYUvASDVRgMOQ3Ww== X-Google-Smtp-Source: ABdhPJzV1cB+uSlPR4NVFLewixdY+BtQCUIKTAb0oQMxP3auEYCNh95pIMSZtMwuefcd8/Yvo+JkDA== X-Received: by 2002:a5d:4344:0:b0:20c:9156:8ec with SMTP id u4-20020a5d4344000000b0020c915608ecmr6716035wrr.71.1651928108733; Sat, 07 May 2022 05:55:08 -0700 (PDT) Received: from localhost.localdomain (static-176-182-171-101.ncc.abo.bbox.fr. [176.182.171.101]) by smtp.gmail.com with ESMTPSA id e9-20020a05600c218900b0039453fe55a7sm10470345wme.35.2022.05.07.05.55.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 May 2022 05:55:08 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Zhang Rui , Nicolas Saenz Julienne , Broadcom Kernel Team , Florian Fainelli , Ray Jui , Scott Branden , Lukasz Luba , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , Dmitry Osipenko , 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), linux-renesas-soc@vger.kernel.org (open list:RENESAS R-CAR THERMAL DRIVERS), linux-samsung-soc@vger.kernel.org (open list:SAMSUNG THERMAL DRIVER), linux-tegra@vger.kernel.org (open list:TEGRA ARCHITECTURE SUPPORT) Subject: [PATCH v2 02/14] thermal/core: Add a thermal sensor structure in the thermal zone Date: Sat, 7 May 2022 14:54:30 +0200 Message-Id: <20220507125443.2766939-3-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220507125443.2766939-1-daniel.lezcano@linexp.org> References: <20220507125443.2766939-1-daniel.lezcano@linexp.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 sensor ops is directly defined in the thermal zone but still its data structuration makes the sensor ops and the thermal zone too much interconnected for multiple sensors per thermal zone. Create a dedicated structure for the thermal sensor to be included in the thermal zone structure so these components are clearly separated. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano Acked-by: Krzysztof Kozlowski Reviewed-by: Geert Uytterhoeven --- drivers/thermal/broadcom/bcm2835_thermal.c | 2 +- drivers/thermal/gov_bang_bang.c | 6 +-- drivers/thermal/gov_fair_share.c | 6 +-- drivers/thermal/gov_power_allocator.c | 18 ++++---- drivers/thermal/gov_step_wise.c | 4 +- drivers/thermal/rcar_gen3_thermal.c | 6 +-- drivers/thermal/samsung/exynos_tmu.c | 6 +-- drivers/thermal/tegra/soctherm.c | 10 ++--- drivers/thermal/tegra/tegra30-tsensor.c | 4 +- drivers/thermal/thermal_core.c | 48 +++++++++++----------- drivers/thermal/thermal_helpers.c | 22 +++++----- drivers/thermal/thermal_hwmon.c | 4 +- drivers/thermal/thermal_netlink.c | 8 ++-- drivers/thermal/thermal_of.c | 16 ++++---- drivers/thermal/thermal_sysfs.c | 40 +++++++++--------- include/linux/thermal.h | 7 +++- 16 files changed, 106 insertions(+), 101 deletions(-) diff --git a/drivers/thermal/broadcom/bcm2835_thermal.c b/drivers/thermal/b= roadcom/bcm2835_thermal.c index c8e4344d5a3d..a3feb82b560c 100644 --- a/drivers/thermal/broadcom/bcm2835_thermal.c +++ b/drivers/thermal/broadcom/bcm2835_thermal.c @@ -232,7 +232,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 tz->sensor.ops->get_trip_temp(tz, 0, &trip_temp); if (err < 0) { dev_err(&pdev->dev, "Not able to read trip_temp: %d\n", diff --git a/drivers/thermal/gov_bang_bang.c b/drivers/thermal/gov_bang_ban= g.c index 991a1c54296d..2d9695ded819 100644 --- a/drivers/thermal/gov_bang_bang.c +++ b/drivers/thermal/gov_bang_bang.c @@ -18,14 +18,14 @@ static void thermal_zone_trip_update(struct thermal_zon= e_device *tz, int trip) int trip_temp, trip_hyst; struct thermal_instance *instance; =20 - tz->ops->get_trip_temp(tz, trip, &trip_temp); + tz->sensor.ops->get_trip_temp(tz, trip, &trip_temp); =20 - if (!tz->ops->get_trip_hyst) { + if (!tz->sensor.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); + tz->sensor.ops->get_trip_hyst(tz, trip, &trip_hyst); =20 dev_dbg(&tz->device, "Trip%d[temp=3D%d]:temp=3D%d:hyst=3D%d\n", trip, trip_temp, tz->temperature, diff --git a/drivers/thermal/gov_fair_share.c b/drivers/thermal/gov_fair_sh= are.c index 1e5abf4822be..a157c621da59 100644 --- a/drivers/thermal/gov_fair_share.c +++ b/drivers/thermal/gov_fair_share.c @@ -25,11 +25,11 @@ static int get_trip_level(struct thermal_zone_device *t= z) int trip_temp; enum thermal_trip_type trip_type; =20 - if (tz->trips =3D=3D 0 || !tz->ops->get_trip_temp) + if (tz->trips =3D=3D 0 || !tz->sensor.ops->get_trip_temp) return 0; =20 for (count =3D 0; count < tz->trips; count++) { - tz->ops->get_trip_temp(tz, count, &trip_temp); + tz->sensor.ops->get_trip_temp(tz, count, &trip_temp); if (tz->temperature < trip_temp) break; } @@ -39,7 +39,7 @@ static int get_trip_level(struct thermal_zone_device *tz) * point, in which case, trip_point =3D count - 1 */ if (count > 0) { - tz->ops->get_trip_type(tz, count - 1, &trip_type); + tz->sensor.ops->get_trip_type(tz, count - 1, &trip_type); trace_thermal_zone_trip(tz, count - 1, trip_type); } =20 diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_po= wer_allocator.c index 13e375751d22..bcd146175f84 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -130,7 +130,7 @@ static void estimate_pid_constants(struct thermal_zone_= device *tz, u32 temperature_threshold; s32 k_i; =20 - ret =3D tz->ops->get_trip_temp(tz, trip_switch_on, &switch_on_temp); + ret =3D tz->sensor.ops->get_trip_temp(tz, trip_switch_on, &switch_on_temp= ); if (ret) switch_on_temp =3D 0; =20 @@ -531,7 +531,7 @@ static void get_governor_trips(struct thermal_zone_devi= ce *tz, enum thermal_trip_type type; int ret; =20 - ret =3D tz->ops->get_trip_type(tz, i, &type); + ret =3D tz->sensor.ops->get_trip_type(tz, i, &type); if (ret) { dev_warn(&tz->device, "Failed to get trip point %d type: %d\n", i, @@ -669,9 +669,9 @@ static int power_allocator_bind(struct thermal_zone_dev= ice *tz) get_governor_trips(tz, params); =20 if (tz->trips > 0) { - ret =3D tz->ops->get_trip_temp(tz, - params->trip_max_desired_temperature, - &control_temp); + ret =3D tz->sensor.ops->get_trip_temp(tz, + params->trip_max_desired_temperature, + &control_temp); if (!ret) estimate_pid_constants(tz, tz->tzp->sustainable_power, params->trip_switch_on, @@ -719,8 +719,8 @@ static int power_allocator_throttle(struct thermal_zone= _device *tz, int trip) if (trip !=3D params->trip_max_desired_temperature) return 0; =20 - ret =3D tz->ops->get_trip_temp(tz, params->trip_switch_on, - &switch_on_temp); + ret =3D tz->sensor.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); tz->passive =3D 0; @@ -731,8 +731,8 @@ static int power_allocator_throttle(struct thermal_zone= _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 tz->sensor.ops->get_trip_temp(tz, params->trip_max_desired_temper= ature, + &control_temp); if (ret) { dev_warn(&tz->device, "Failed to get the maximum desired temperature: %d\n", diff --git a/drivers/thermal/gov_step_wise.c b/drivers/thermal/gov_step_wis= e.c index 12acb12aac50..044cfd116eba 100644 --- a/drivers/thermal/gov_step_wise.c +++ b/drivers/thermal/gov_step_wise.c @@ -122,8 +122,8 @@ static void thermal_zone_trip_update(struct thermal_zon= e_device *tz, int 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); + tz->sensor.ops->get_trip_temp(tz, trip, &trip_temp); + tz->sensor.ops->get_trip_type(tz, trip, &trip_type); =20 trend =3D get_tz_trend(tz, trip); =20 diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen= 3_thermal.c index 43eb25b167bc..b205602ef6d8 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c @@ -321,7 +321,7 @@ static void rcar_gen3_thermal_init_r8a7795es1(struct rc= ar_gen3_thermal_tsc *tsc) =20 rcar_gen3_thermal_write(tsc, REG_GEN3_IRQCTL, 0x3F); rcar_gen3_thermal_write(tsc, REG_GEN3_IRQMSK, 0); - if (tsc->zone->ops->set_trips) + if (tsc->zone->sensor.ops->set_trips) rcar_gen3_thermal_write(tsc, REG_GEN3_IRQEN, IRQ_TEMPD1 | IRQ_TEMP2); =20 @@ -349,7 +349,7 @@ static void rcar_gen3_thermal_init(struct rcar_gen3_the= rmal_tsc *tsc) =20 rcar_gen3_thermal_write(tsc, REG_GEN3_IRQCTL, 0); rcar_gen3_thermal_write(tsc, REG_GEN3_IRQMSK, 0); - if (tsc->zone->ops->set_trips) + if (tsc->zone->sensor.ops->set_trips) rcar_gen3_thermal_write(tsc, REG_GEN3_IRQEN, IRQ_TEMPD1 | IRQ_TEMP2); =20 @@ -555,7 +555,7 @@ static int __maybe_unused rcar_gen3_thermal_resume(stru= ct device *dev) struct thermal_zone_device *zone =3D tsc->zone; =20 priv->thermal_init(tsc); - if (zone->ops->set_trips) + if (zone->sensor.ops->set_trips) rcar_gen3_thermal_set_trips(tsc, zone->prev_low_trip, zone->prev_high_trip); } diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung= /exynos_tmu.c index f4ab4c5b4b62..ff83c8c43893 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -272,7 +272,7 @@ static int exynos_tmu_initialize(struct platform_device= *pdev) } =20 if (data->soc !=3D SOC_ARCH_EXYNOS5433) /* FIXME */ - ret =3D tzd->ops->get_crit_temp(tzd, &temp); + ret =3D tzd->sensor.ops->get_crit_temp(tzd, &temp); if (ret) { dev_err(&pdev->dev, "No CRITICAL trip point defined in device tree!\n"); @@ -304,14 +304,14 @@ static int exynos_tmu_initialize(struct platform_devi= ce *pdev) /* 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); + ret =3D tzd->sensor.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); + ret =3D tzd->sensor.ops->get_trip_hyst(tzd, i, &hyst); if (ret) goto err; hyst /=3D MCELSIUS; diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/socth= erm.c index 210325f92559..f21deefe8682 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -595,7 +595,7 @@ static int tegra_thermctl_set_trip_temp(void *data, int= trip, int temp) if (!tz) return -EINVAL; =20 - ret =3D tz->ops->get_trip_type(tz, trip, &type); + ret =3D tz->sensor.ops->get_trip_type(tz, trip, &type); if (ret) return ret; =20 @@ -643,7 +643,7 @@ static int tegra_thermctl_get_trend(void *data, int tri= p, if (!tz) return -EINVAL; =20 - ret =3D tz->ops->get_trip_temp(zone->tz, trip, &trip_temp); + ret =3D tz->sensor.ops->get_trip_temp(zone->tz, trip, &trip_temp); if (ret) return ret; =20 @@ -730,11 +730,11 @@ static int get_hot_temp(struct thermal_zone_device *t= z, int *trip, int *temp) return -EINVAL; =20 for (i =3D 0; i < ntrips; i++) { - ret =3D tz->ops->get_trip_type(tz, i, &type); + ret =3D tz->sensor.ops->get_trip_type(tz, i, &type); if (ret) return -EINVAL; if (type =3D=3D THERMAL_TRIP_HOT) { - ret =3D tz->ops->get_trip_temp(tz, i, temp); + ret =3D tz->sensor.ops->get_trip_temp(tz, i, temp); if (!ret) *trip =3D i; =20 @@ -780,7 +780,7 @@ static int tegra_soctherm_set_hwtrips(struct device *de= v, /* Get thermtrips. If missing, try to get critical trips. */ temperature =3D tsensor_group_thermtrip_get(ts, sg->id); if (min_low_temp =3D=3D temperature) - if (tz->ops->get_crit_temp(tz, &temperature)) + if (tz->sensor.ops->get_crit_temp(tz, &temperature)) temperature =3D max_high_temp; =20 ret =3D thermtrip_program(dev, sg, temperature); diff --git a/drivers/thermal/tegra/tegra30-tsensor.c b/drivers/thermal/tegr= a/tegra30-tsensor.c index 9b6b693cbcf8..fab2709569c1 100644 --- a/drivers/thermal/tegra/tegra30-tsensor.c +++ b/drivers/thermal/tegra/tegra30-tsensor.c @@ -320,8 +320,8 @@ static void tegra_tsensor_get_hw_channel_trips(struct t= hermal_zone_device *tzd, enum thermal_trip_type type; int trip_temp; =20 - tzd->ops->get_trip_temp(tzd, i, &trip_temp); - tzd->ops->get_trip_type(tzd, i, &type); + tzd->sensor.ops->get_trip_temp(tzd, i, &trip_temp); + tzd->sensor.ops->get_trip_type(tzd, i, &type); =20 if (type =3D=3D THERMAL_TRIP_HOT) *hot_trip =3D trip_temp; diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 065dfc179e53..1a405854748a 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -344,7 +344,7 @@ static void handle_critical_trips(struct thermal_zone_d= evice *tz, { int trip_temp; =20 - tz->ops->get_trip_temp(tz, trip, &trip_temp); + tz->sensor.ops->get_trip_temp(tz, trip, &trip_temp); =20 /* If we have not crossed the trip_temp, we do not care. */ if (trip_temp <=3D 0 || tz->temperature < trip_temp) @@ -352,10 +352,10 @@ static void handle_critical_trips(struct thermal_zone= _device *tz, =20 trace_thermal_zone_trip(tz, trip, trip_type); =20 - if (trip_type =3D=3D THERMAL_TRIP_HOT && tz->ops->hot) - tz->ops->hot(tz); + if (trip_type =3D=3D THERMAL_TRIP_HOT && tz->sensor.ops->hot) + tz->sensor.ops->hot(tz); else if (trip_type =3D=3D THERMAL_TRIP_CRITICAL) - tz->ops->critical(tz); + tz->sensor.ops->critical(tz); } =20 static void handle_thermal_trip(struct thermal_zone_device *tz, int trip) @@ -367,10 +367,10 @@ static void handle_thermal_trip(struct thermal_zone_d= evice *tz, int trip) if (test_bit(trip, &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); + tz->sensor.ops->get_trip_temp(tz, trip, &trip_temp); + tz->sensor.ops->get_trip_type(tz, trip, &type); + if (tz->sensor.ops->get_trip_hyst) + tz->sensor.ops->get_trip_hyst(tz, trip, &hyst); =20 if (tz->last_temperature !=3D THERMAL_TEMP_INVALID) { if (tz->last_temperature < trip_temp && @@ -441,8 +441,8 @@ static int thermal_zone_device_set_mode(struct thermal_= zone_device *tz, return ret; } =20 - if (tz->ops->change_mode) - ret =3D tz->ops->change_mode(tz, mode); + if (tz->sensor.ops->change_mode) + ret =3D tz->sensor.ops->change_mode(tz, mode); =20 if (!ret) tz->mode =3D mode; @@ -495,7 +495,7 @@ void thermal_zone_device_update(struct thermal_zone_dev= ice *tz, if (atomic_read(&in_suspend)) return; =20 - if (WARN_ONCE(!tz->ops->get_temp, "'%s' must not be called without " + if (WARN_ONCE(!tz->sensor.ops->get_temp, "'%s' must not be called without= " "'get_temp' ops set\n", __func__)) return; =20 @@ -839,11 +839,11 @@ static void bind_cdev(struct thermal_cooling_device *= cdev) mutex_lock(&thermal_list_lock); =20 list_for_each_entry(pos, &thermal_tz_list, node) { - if (!pos->tzp && !pos->ops->bind) + if (!pos->tzp && !pos->sensor.ops->bind) continue; =20 - if (pos->ops->bind) { - ret =3D pos->ops->bind(pos, cdev); + if (pos->sensor.ops->bind) { + ret =3D pos->sensor.ops->bind(pos, cdev); if (ret) print_bind_err_msg(pos, cdev, ret); continue; @@ -1091,8 +1091,8 @@ void thermal_cooling_device_unregister(struct thermal= _cooling_device *cdev) =20 /* Unbind all thermal zones associated with 'this' cdev */ list_for_each_entry(tz, &thermal_tz_list, node) { - if (tz->ops->unbind) { - tz->ops->unbind(tz, cdev); + if (tz->sensor.ops->unbind) { + tz->sensor.ops->unbind(tz, cdev); continue; } =20 @@ -1124,15 +1124,15 @@ static void bind_tz(struct thermal_zone_device *tz) struct thermal_cooling_device *pos =3D NULL; const struct thermal_zone_params *tzp =3D tz->tzp; =20 - if (!tzp && !tz->ops->bind) + if (!tzp && !tz->sensor.ops->bind) return; =20 mutex_lock(&thermal_list_lock); =20 /* If there is ops->bind, try to use ops->bind */ - if (tz->ops->bind) { + if (tz->sensor.ops->bind) { list_for_each_entry(pos, &thermal_cdev_list, node) { - ret =3D tz->ops->bind(tz, pos); + ret =3D tz->sensor.ops->bind(tz, pos); if (ret) print_bind_err_msg(tz, pos, ret); } @@ -1243,7 +1243,7 @@ thermal_zone_device_register(const char *type, int tr= ips, int mask, if (!ops->critical) ops->critical =3D thermal_zone_device_critical; =20 - tz->ops =3D ops; + tz->sensor.ops =3D ops; tz->tzp =3D tzp; tz->device.class =3D &thermal_class; tz->devdata =3D devdata; @@ -1266,8 +1266,8 @@ thermal_zone_device_register(const char *type, int tr= ips, int mask, goto release_device; =20 for (count =3D 0; count < trips; count++) { - if (tz->ops->get_trip_type(tz, count, &trip_type) || - tz->ops->get_trip_temp(tz, count, &trip_temp) || + if (tz->sensor.ops->get_trip_type(tz, count, &trip_type) || + tz->sensor.ops->get_trip_temp(tz, count, &trip_temp) || !trip_temp) set_bit(count, &tz->trips_disabled); } @@ -1355,8 +1355,8 @@ void thermal_zone_device_unregister(struct thermal_zo= ne_device *tz) =20 /* Unbind all cdevs associated with 'this' thermal zone */ list_for_each_entry(cdev, &thermal_cdev_list, node) { - if (tz->ops->unbind) { - tz->ops->unbind(tz, cdev); + if (tz->sensor.ops->unbind) { + tz->sensor.ops->unbind(tz, cdev); continue; } =20 diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_he= lpers.c index 3edd047e144f..334478fe40fa 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -27,8 +27,8 @@ int get_tz_trend(struct thermal_zone_device *tz, int trip) { enum thermal_trend trend; =20 - if (tz->emul_temperature || !tz->ops->get_trend || - tz->ops->get_trend(tz, trip, &trend)) { + if (tz->emul_temperature || !tz->sensor.ops->get_trend || + tz->sensor.ops->get_trend(tz, trip, &trend)) { if (tz->temperature > tz->last_temperature) trend =3D THERMAL_TREND_RAISING; else if (tz->temperature < tz->last_temperature) @@ -82,19 +82,19 @@ int thermal_zone_get_temp(struct thermal_zone_device *t= z, int *temp) int crit_temp =3D INT_MAX; enum thermal_trip_type type; =20 - if (!tz || IS_ERR(tz) || !tz->ops->get_temp) + if (!tz || IS_ERR(tz) || !tz->sensor.ops->get_temp) goto exit; =20 mutex_lock(&tz->lock); =20 - ret =3D tz->ops->get_temp(tz, temp); + ret =3D tz->sensor.ops->get_temp(tz, temp); =20 if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) { for (count =3D 0; count < tz->trips; count++) { - ret =3D tz->ops->get_trip_type(tz, count, &type); + ret =3D tz->sensor.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 tz->sensor.ops->get_trip_temp(tz, count, + &crit_temp); break; } } @@ -135,14 +135,14 @@ void thermal_zone_set_trips(struct thermal_zone_devic= e *tz) =20 mutex_lock(&tz->lock); =20 - if (!tz->ops->set_trips || !tz->ops->get_trip_hyst) + if (!tz->sensor.ops->set_trips || !tz->sensor.ops->get_trip_hyst) goto exit; =20 for (i =3D 0; i < tz->trips; i++) { int trip_low; =20 - tz->ops->get_trip_temp(tz, i, &trip_temp); - tz->ops->get_trip_hyst(tz, i, &hysteresis); + tz->sensor.ops->get_trip_temp(tz, i, &trip_temp); + tz->sensor.ops->get_trip_hyst(tz, i, &hysteresis); =20 trip_low =3D trip_temp - hysteresis; =20 @@ -167,7 +167,7 @@ void thermal_zone_set_trips(struct thermal_zone_device = *tz) * Set a temperature window. When this window is left the driver * must inform the thermal core via thermal_zone_device_update. */ - ret =3D tz->ops->set_trips(tz, low, high); + ret =3D tz->sensor.ops->set_trips(tz, low, high); if (ret) dev_err(&tz->device, "Failed to set trips: %d\n", ret); =20 diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmo= n.c index ad03262cca56..e271729fa84e 100644 --- a/drivers/thermal/thermal_hwmon.c +++ b/drivers/thermal/thermal_hwmon.c @@ -77,7 +77,7 @@ temp_crit_show(struct device *dev, struct device_attribut= e *attr, char *buf) int temperature; int ret; =20 - ret =3D tz->ops->get_crit_temp(tz, &temperature); + ret =3D tz->sensor.ops->get_crit_temp(tz, &temperature); if (ret) return ret; =20 @@ -126,7 +126,7 @@ thermal_hwmon_lookup_temp(const struct thermal_hwmon_de= vice *hwmon, static bool thermal_zone_crit_temp_valid(struct thermal_zone_device *tz) { int temp; - return tz->ops->get_crit_temp && !tz->ops->get_crit_temp(tz, &temp); + return tz->sensor.ops->get_crit_temp && !tz->sensor.ops->get_crit_temp(tz= , &temp); } =20 int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz) diff --git a/drivers/thermal/thermal_netlink.c b/drivers/thermal/thermal_ne= tlink.c index 32fea5174cc0..b309b2412500 100644 --- a/drivers/thermal/thermal_netlink.c +++ b/drivers/thermal/thermal_netlink.c @@ -474,10 +474,10 @@ static int thermal_genl_cmd_tz_get_trip(struct param = *p) enum thermal_trip_type type; int temp, hyst =3D 0; =20 - 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); + tz->sensor.ops->get_trip_type(tz, i, &type); + tz->sensor.ops->get_trip_temp(tz, i, &temp); + if (tz->sensor.ops->get_trip_hyst) + tz->sensor.ops->get_trip_hyst(tz, i, &hyst); =20 if (nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, i) || nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, type) || diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index ef953cba3504..d6917f1bc486 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -395,18 +395,18 @@ thermal_zone_of_add_sensor(struct device_node *zone, tz->ops =3D ops; tz->sensor_data =3D data; =20 - tzd->ops->get_temp =3D of_thermal_get_temp; - tzd->ops->get_trend =3D of_thermal_get_trend; + tzd->sensor.ops->get_temp =3D of_thermal_get_temp; + tzd->sensor.ops->get_trend =3D of_thermal_get_trend; =20 /* * The thermal zone core will calculate the window if they have set the * optional set_trips pointer. */ if (ops->set_trips) - tzd->ops->set_trips =3D of_thermal_set_trips; + tzd->sensor.ops->set_trips =3D of_thermal_set_trips; =20 if (ops->set_emul_temp) - tzd->ops->set_emul_temp =3D of_thermal_set_emul_temp; + tzd->sensor.ops->set_emul_temp =3D of_thermal_set_emul_temp; =20 mutex_unlock(&tzd->lock); =20 @@ -566,9 +566,9 @@ void thermal_zone_of_sensor_unregister(struct device *d= ev, thermal_zone_device_disable(tzd); =20 mutex_lock(&tzd->lock); - tzd->ops->get_temp =3D NULL; - tzd->ops->get_trend =3D NULL; - tzd->ops->set_emul_temp =3D NULL; + tzd->sensor.ops->get_temp =3D NULL; + tzd->sensor.ops->get_trend =3D NULL; + tzd->sensor.ops->set_emul_temp =3D NULL; =20 tz->ops =3D NULL; tz->sensor_data =3D NULL; @@ -1024,7 +1024,7 @@ static __init void of_thermal_destroy_zones(void) =20 thermal_zone_device_unregister(zone); kfree(zone->tzp); - kfree(zone->ops); + kfree(zone->sensor.ops); of_thermal_free_zone(zone->devdata); } of_node_put(np); diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysf= s.c index f154bada2906..44212fa00c78 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -82,13 +82,13 @@ trip_point_type_show(struct device *dev, struct device_= attribute *attr, enum thermal_trip_type type; int trip, result; =20 - if (!tz->ops->get_trip_type) + if (!tz->sensor.ops->get_trip_type) return -EPERM; =20 if (sscanf(attr->attr.name, "trip_point_%d_type", &trip) !=3D 1) return -EINVAL; =20 - result =3D tz->ops->get_trip_type(tz, trip, &type); + result =3D tz->sensor.ops->get_trip_type(tz, trip, &type); if (result) return result; =20 @@ -115,7 +115,7 @@ trip_point_temp_store(struct device *dev, struct device= _attribute *attr, int temperature, hyst =3D 0; enum thermal_trip_type type; =20 - if (!tz->ops->set_trip_temp) + if (!tz->sensor.ops->set_trip_temp) return -EPERM; =20 if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip) !=3D 1) @@ -124,17 +124,17 @@ trip_point_temp_store(struct device *dev, struct devi= ce_attribute *attr, if (kstrtoint(buf, 10, &temperature)) return -EINVAL; =20 - ret =3D tz->ops->set_trip_temp(tz, trip, temperature); + ret =3D tz->sensor.ops->set_trip_temp(tz, trip, temperature); if (ret) return ret; =20 - if (tz->ops->get_trip_hyst) { - ret =3D tz->ops->get_trip_hyst(tz, trip, &hyst); + if (tz->sensor.ops->get_trip_hyst) { + ret =3D tz->sensor.ops->get_trip_hyst(tz, trip, &hyst); if (ret) return ret; } =20 - ret =3D tz->ops->get_trip_type(tz, trip, &type); + ret =3D tz->sensor.ops->get_trip_type(tz, trip, &type); if (ret) return ret; =20 @@ -153,13 +153,13 @@ trip_point_temp_show(struct device *dev, struct devic= e_attribute *attr, int trip, ret; int temperature; =20 - if (!tz->ops->get_trip_temp) + if (!tz->sensor.ops->get_trip_temp) return -EPERM; =20 if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip) !=3D 1) return -EINVAL; =20 - ret =3D tz->ops->get_trip_temp(tz, trip, &temperature); + ret =3D tz->sensor.ops->get_trip_temp(tz, trip, &temperature); =20 if (ret) return ret; @@ -175,7 +175,7 @@ trip_point_hyst_store(struct device *dev, struct device= _attribute *attr, int trip, ret; int temperature; =20 - if (!tz->ops->set_trip_hyst) + if (!tz->sensor.ops->set_trip_hyst) return -EPERM; =20 if (sscanf(attr->attr.name, "trip_point_%d_hyst", &trip) !=3D 1) @@ -189,7 +189,7 @@ trip_point_hyst_store(struct device *dev, struct device= _attribute *attr, * here. The driver implementing 'set_trip_hyst' has to * take care of this. */ - ret =3D tz->ops->set_trip_hyst(tz, trip, temperature); + ret =3D tz->sensor.ops->set_trip_hyst(tz, trip, temperature); =20 if (!ret) thermal_zone_set_trips(tz); @@ -205,13 +205,13 @@ trip_point_hyst_show(struct device *dev, struct devic= e_attribute *attr, int trip, ret; int temperature; =20 - if (!tz->ops->get_trip_hyst) + if (!tz->sensor.ops->get_trip_hyst) return -EPERM; =20 if (sscanf(attr->attr.name, "trip_point_%d_hyst", &trip) !=3D 1) return -EINVAL; =20 - ret =3D tz->ops->get_trip_hyst(tz, trip, &temperature); + ret =3D tz->sensor.ops->get_trip_hyst(tz, trip, &temperature); =20 return ret ? ret : sprintf(buf, "%d\n", temperature); } @@ -260,12 +260,12 @@ emul_temp_store(struct device *dev, struct device_att= ribute *attr, if (kstrtoint(buf, 10, &temperature)) return -EINVAL; =20 - if (!tz->ops->set_emul_temp) { + if (!tz->sensor.ops->set_emul_temp) { mutex_lock(&tz->lock); tz->emul_temperature =3D temperature; mutex_unlock(&tz->lock); } else { - ret =3D tz->ops->set_emul_temp(tz, temperature); + ret =3D tz->sensor.ops->set_emul_temp(tz, temperature); } =20 if (!ret) @@ -431,7 +431,7 @@ static int create_trip_attrs(struct thermal_zone_device= *tz, int mask) return -ENOMEM; } =20 - if (tz->ops->get_trip_hyst) { + if (tz->sensor.ops->get_trip_hyst) { tz->trip_hyst_attrs =3D kcalloc(tz->trips, sizeof(*tz->trip_hyst_attrs), GFP_KERNEL); @@ -446,7 +446,7 @@ static int create_trip_attrs(struct thermal_zone_device= *tz, int mask) if (!attrs) { kfree(tz->trip_type_attrs); kfree(tz->trip_temp_attrs); - if (tz->ops->get_trip_hyst) + if (tz->sensor.ops->get_trip_hyst) kfree(tz->trip_hyst_attrs); return -ENOMEM; } @@ -481,7 +481,7 @@ static int create_trip_attrs(struct thermal_zone_device= *tz, int mask) attrs[indx + tz->trips] =3D &tz->trip_temp_attrs[indx].attr.attr; =20 /* create Optional trip hyst attribute */ - if (!tz->ops->get_trip_hyst) + if (!tz->sensor.ops->get_trip_hyst) continue; snprintf(tz->trip_hyst_attrs[indx].name, THERMAL_NAME_LENGTH, "trip_point_%d_hyst", indx); @@ -491,7 +491,7 @@ static int create_trip_attrs(struct thermal_zone_device= *tz, int mask) tz->trip_hyst_attrs[indx].name; tz->trip_hyst_attrs[indx].attr.attr.mode =3D S_IRUGO; tz->trip_hyst_attrs[indx].attr.show =3D trip_point_hyst_show; - if (tz->ops->set_trip_hyst) { + if (tz->sensor.ops->set_trip_hyst) { tz->trip_hyst_attrs[indx].attr.attr.mode |=3D S_IWUSR; tz->trip_hyst_attrs[indx].attr.store =3D trip_point_hyst_store; @@ -519,7 +519,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) + if (tz->sensor.ops->get_trip_hyst) kfree(tz->trip_hyst_attrs); kfree(tz->trips_attribute_group.attrs); } diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 991f7bc02d51..10dea654df6c 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -80,6 +80,11 @@ struct thermal_sensor_ops { void (*critical)(struct thermal_zone_device *); }; =20 +struct thermal_sensor { + struct thermal_sensor_ops *ops; + struct device *dev; +}; + struct thermal_cooling_device_ops { int (*get_max_state) (struct thermal_cooling_device *, unsigned long *); int (*get_cur_state) (struct thermal_cooling_device *, unsigned long *); @@ -164,7 +169,7 @@ struct thermal_zone_device { int prev_low_trip; int prev_high_trip; atomic_t need_update; - struct thermal_sensor_ops *ops; + struct thermal_sensor sensor; struct thermal_zone_params *tzp; struct thermal_governor *governor; void *governor_data; --=20 2.25.1 From nobody Mon Jun 15 01:41:29 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 88CC7C433EF for ; Sat, 7 May 2022 12:55:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443325AbiEGM7U (ORCPT ); Sat, 7 May 2022 08:59:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384990AbiEGM67 (ORCPT ); Sat, 7 May 2022 08:58:59 -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 1CB8B3EBAD for ; Sat, 7 May 2022 05:55:10 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id b19so13424776wrh.11 for ; Sat, 07 May 2022 05:55:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i7ClBWhU0BsFP+r9fOAi97/XZv2iZQBCPscZpo8wov8=; b=ZMaeL/azudnELzx4AN94lhWK+xBt5yOgl9UURvYUas9fkJpxaMKIm5kXMh75EnxCm0 1IV8O5VsfIxyujffYTJW8dDRBF7b31NizsV34O2gtZk+tT2hl3fm0Ih/yXM3yyWGR4/7 lwQuU1J0aCbSBUCT27nQWWZg26Xd9jTRgi3jiC2vrGgAdLlrCQ6oRoRVlfTOCuLy7I+G P0uFZ2OSwXULOw5pkMLlxyBKrYX+5OEyHnaWAGOiyZ36swtl9M9wbzT/edJP7Tqg8Apk pq/viGRHwVf9MoL7lC8/nQEgzi7vdijTze6qCe6dEU0GQqtJOjPnGYidFxjOU7RkrWqN dUQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i7ClBWhU0BsFP+r9fOAi97/XZv2iZQBCPscZpo8wov8=; b=jx5Rw9U8VB1r1b4cmXvbSr4KiuMwOS5Lyj1yc1s+uuCVkwk8276AEiK/NCHIUv+ZtU YfsWB8/002gksChNZ51DNpSkQ5glBBP3iEiuXGWmGfdDLAsJAWmq4nqYNTTXr+KTBqTJ eX3L3f8nQo26PDuyVXrvWANbivfQkZ7gzq9ZXc9Va8lM/DSITGN1qmaR5lJXeMRLnItx M0dX/9mLVn3t+r8UFcrVw6mtt29mfFPiuudhvKqivReDAtFVTJzz7pNT1V6/RC9XAUw6 X3pP8gI6TIJzf0+IhHaaLCQ8pHzaPDUDVKW4BFffcli2TJ7LaladVW2f3K7wbk3zl9Pn F61Q== X-Gm-Message-State: AOAM530lCwyfUlJp2NTpVvQwZwxVeXYS7AcjJuyaN9BSYFD16TGQdYQ/ efehlJO0hVhzu6dGVkbHVXe4xw== X-Google-Smtp-Source: ABdhPJyQBnAgMemg9n9uktVI9bwElN474gBrco3BobKJ/odxA/zwYUvCC+X7LwC6anuyYnY3z480Qw== X-Received: by 2002:a5d:6b0d:0:b0:1f0:6497:b071 with SMTP id v13-20020a5d6b0d000000b001f06497b071mr6462214wrw.638.1651928109546; Sat, 07 May 2022 05:55:09 -0700 (PDT) Received: from localhost.localdomain (static-176-182-171-101.ncc.abo.bbox.fr. [176.182.171.101]) by smtp.gmail.com with ESMTPSA id e9-20020a05600c218900b0039453fe55a7sm10470345wme.35.2022.05.07.05.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 May 2022 05:55:09 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v2 03/14] thermal/core: Remove duplicate information when an error occurs Date: Sat, 7 May 2022 14:54:31 +0200 Message-Id: <20220507125443.2766939-4-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220507125443.2766939-1-daniel.lezcano@linexp.org> References: <20220507125443.2766939-1-daniel.lezcano@linexp.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 pr_err already tells it is an error, it is pointless to add the 'Error:' string in the messages. Remove them. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 1a405854748a..dc5a03d51f5c 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1197,23 +1197,23 @@ thermal_zone_device_register(const char *type, int = trips, int mask, struct thermal_governor *governor; =20 if (!type || strlen(type) =3D=3D 0) { - pr_err("Error: No thermal zone type defined\n"); + pr_err("No thermal zone type defined\n"); return ERR_PTR(-EINVAL); } =20 if (type && strlen(type) >=3D THERMAL_NAME_LENGTH) { - pr_err("Error: Thermal zone name (%s) too long, should be under %d chars= \n", + pr_err("Thermal zone name (%s) too long, should be under %d chars\n", type, THERMAL_NAME_LENGTH); return ERR_PTR(-EINVAL); } =20 if (trips > THERMAL_MAX_TRIPS || trips < 0 || mask >> trips) { - pr_err("Error: Incorrect number of thermal trips\n"); + pr_err("Incorrect number of thermal trips\n"); return ERR_PTR(-EINVAL); } =20 if (!ops) { - pr_err("Error: Thermal zone device ops not defined\n"); + pr_err("Thermal zone device ops not defined\n"); return ERR_PTR(-EINVAL); } =20 --=20 2.25.1 From nobody Mon Jun 15 01:41:29 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 44A62C433FE for ; Sat, 7 May 2022 12:55:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1446384AbiEGM7e (ORCPT ); Sat, 7 May 2022 08:59:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385013AbiEGM7A (ORCPT ); Sat, 7 May 2022 08:59:00 -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 190D945053 for ; Sat, 7 May 2022 05:55:12 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id n126-20020a1c2784000000b0038e8af3e788so5874339wmn.1 for ; Sat, 07 May 2022 05:55:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aJTpdtZ3Dvv2pgbB16rUZnzGfgzRayyB+EehmrYmI4I=; b=r8DEyWCaOn3aWY2lI6UgyxsgndLqA3OA747yuYprq1WCUe1gMkuX4+0zwPRLI0T+9r okytRUZk6Nu0/FQp6nM+0jBMjrZpzOfmAuxYKkpQ3+p/n5OnfKoIf95+p+nNwBo1uvRU vFBMdPEWEyJobBUPndajOygUtvmwQlZHrRwVga3C0/yHaoHSoOBv5JEhxk+YLPQHSuve am8qEsc+gava0AE6j98gwvKHhXD8YFRoEBOUtnrgc9FO0iSuf/DD/H0bedUcqIMEAZjj OT0ipqij64Faxxan8nl54xm3N8a6Sj51Lz1ufbqBxDPV3IaP0uMcewe0eQVi2RG1MWi+ fvQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aJTpdtZ3Dvv2pgbB16rUZnzGfgzRayyB+EehmrYmI4I=; b=NONUikgOZ6NlE124T/t2OqKkT2JaSSBMZCdc2Jx+q3OavpbF8CZ7LZUvpP8tOgUomr Z6EpCRzb+xsDZY+tO0baVNgm7psq8n9Q7nSiAxhsPdKiXzsqMRAdLayTfdHn2N3kN80O vFiuP3WB6XJDb9HoCxtT/XxgcwCfomZh5gbpCs2V1Q4AR8UjwHEVaVl/I255G/g9GqY2 8WDiJJuwDpz+kdj6v8JIPLD8wrcNi1IZehafMjY0lMX8DrCGK5g2peaSmW/POIpDGfmQ UEUgKEfMeukAnkt7ZbOL9/lWe3Qk+jarzYb6pwIQS5zpe8QA3v7GY81VgtxyqBIyflH6 luHg== X-Gm-Message-State: AOAM531EQP3JEa5rrNfP0h1f1RfzC8VYE+h0+Jvyvq/h++W6/BtXHwoE mJgGnhN6QxY/3WykuSvUFTfzwg== X-Google-Smtp-Source: ABdhPJwVzX01+jP/THCWZgaTNGuZUeO5WZLo7PjVFPBEODAUucRQdLdpDOc0XorIz8nqdXE/AoSclg== X-Received: by 2002:a1c:7512:0:b0:394:16ee:ab9b with SMTP id o18-20020a1c7512000000b0039416eeab9bmr7921228wmc.176.1651928110390; Sat, 07 May 2022 05:55:10 -0700 (PDT) Received: from localhost.localdomain (static-176-182-171-101.ncc.abo.bbox.fr. [176.182.171.101]) by smtp.gmail.com with ESMTPSA id e9-20020a05600c218900b0039453fe55a7sm10470345wme.35.2022.05.07.05.55.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 May 2022 05:55:10 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v2 04/14] thermal/of: Replace device node match with device node search Date: Sat, 7 May 2022 14:54:32 +0200 Message-Id: <20220507125443.2766939-5-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220507125443.2766939-1-daniel.lezcano@linexp.org> References: <20220507125443.2766939-1-daniel.lezcano@linexp.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 builds a trip array associated with the node pointer in order to compare the trip point phandle with the list. The thermal trip is a thermal zone property and should be moved there. If some sensors have hardcoded trip points, they should use the exported structure instead of redefining again and again their own structure and data to describe exactly the same things. In order to move this to the thermal.h header and allow more cleanup, we need to remove the node pointer from the structure. Instead of building storing the device node, we search directly in the device tree the corresponding node. That results in a simplification of the code and allows to move the structure to thermal.h Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 62 ++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index d6917f1bc486..d8b4a0ad2d5f 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -659,6 +659,35 @@ EXPORT_SYMBOL_GPL(devm_thermal_zone_of_sensor_unregist= er); =20 /*** functions parsing device tree nodes ***/ =20 +static int of_find_trip_id(struct device_node *np, struct device_node *tri= p) +{ + struct device_node *trips; + struct device_node *t; + int i =3D 0; + + trips =3D of_get_child_by_name(np, "trips"); + if (!trips) { + pr_err("Failed to find 'trips' node\n"); + return -EINVAL; + } + + /* + * Find the trip id point associated with the cooling device map + */ + for_each_child_of_node(trips, t) { + + if (t =3D=3D trip) + goto out; + i++; + } + + i =3D -ENXIO; +out:=09 + of_node_put(trips); + + return i; +} + /** * thermal_of_populate_bind_params - parse and fill cooling map data * @np: DT node containing a cooling-map node @@ -674,14 +703,13 @@ EXPORT_SYMBOL_GPL(devm_thermal_zone_of_sensor_unregis= ter); * Return: 0 on success, proper error code otherwise */ static int thermal_of_populate_bind_params(struct device_node *np, - struct __thermal_bind_params *__tbp, - struct thermal_trip *trips, - int ntrips) + struct __thermal_bind_params *__tbp) { struct of_phandle_args cooling_spec; struct __thermal_cooling_bind_param *__tcbp; struct device_node *trip; int ret, i, count; + int trip_id; u32 prop; =20 /* Default weight. Usage is optional */ @@ -696,18 +724,14 @@ static int thermal_of_populate_bind_params(struct dev= ice_node *np, return -ENODEV; } =20 - /* match using device_node */ - for (i =3D 0; i < ntrips; i++) - if (trip =3D=3D trips[i].np) { - __tbp->trip_id =3D i; - break; - } - - if (i =3D=3D ntrips) { - ret =3D -ENODEV; + trip_id =3D of_find_trip_id(np, trip); + if (trip_id < 0) { + ret =3D trip_id; goto end; } =20 + __tbp->trip_id =3D trip_id; +=09 count =3D of_count_phandle_with_args(np, "cooling-device", "#cooling-cells"); if (count <=3D 0) { @@ -856,6 +880,7 @@ static struct __thermal_zone __init *thermal_of_build_thermal_zone(struct device_node *np) { struct device_node *child =3D NULL, *gchild; + struct device_node *trips; struct __thermal_zone *tz; int ret, i; u32 prop, coef[2]; @@ -898,13 +923,13 @@ __init *thermal_of_build_thermal_zone(struct device_n= ode *np) } =20 /* trips */ - child =3D of_get_child_by_name(np, "trips"); + trips =3D of_get_child_by_name(np, "trips"); =20 /* No trips provided */ - if (!child) + if (!trips) goto finish; =20 - tz->ntrips =3D of_get_child_count(child); + tz->ntrips =3D of_get_child_count(trips); if (tz->ntrips =3D=3D 0) /* must have at least one child */ goto finish; =20 @@ -915,14 +940,12 @@ __init *thermal_of_build_thermal_zone(struct device_n= ode *np) } =20 i =3D 0; - for_each_child_of_node(child, gchild) { + for_each_child_of_node(trips, gchild) { ret =3D thermal_of_populate_trip(gchild, &tz->trips[i++]); if (ret) goto free_trips; } =20 - of_node_put(child); - /* cooling-maps */ child =3D of_get_child_by_name(np, "cooling-maps"); =20 @@ -942,8 +965,7 @@ __init *thermal_of_build_thermal_zone(struct device_nod= e *np) =20 i =3D 0; for_each_child_of_node(child, gchild) { - ret =3D thermal_of_populate_bind_params(gchild, &tz->tbps[i++], - tz->trips, tz->ntrips); + ret =3D thermal_of_populate_bind_params(gchild, &tz->tbps[i++]); if (ret) goto free_tbps; } --=20 2.25.1 From nobody Mon Jun 15 01:41:29 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 B5BBBC433F5 for ; Sat, 7 May 2022 12:55:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1446358AbiEGM73 (ORCPT ); Sat, 7 May 2022 08:59:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384994AbiEGM67 (ORCPT ); Sat, 7 May 2022 08:58:59 -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 8DE744474C for ; Sat, 7 May 2022 05:55:11 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id j15so13459983wrb.2 for ; Sat, 07 May 2022 05:55:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+Fhtgna0SXO11lyolbeD9TX1zF+jZgBIlJXC+kQtz6g=; b=xFD1YA0tsUnRveXB4wz1pSDBi/PdW63gXr5X9JyCHnEsDuMWXP7y8Jdywy4ZIkwovv p4KVovg7yYqo1lXnemwixXeeOsiwf0P5xoJY0Fg5kA1cwyl8b9kM/nEGeJFxWw8s2o2y UFAMNd34ZoyKGlKud0pRyFgfBPSNg3QaCTpJVNi4ZsVSNBEIPkp0ZYMBtMuR10HFS+C7 KY5A31zCGk2yID4TXbKdm31CvOaMyw6cOiVqcyaPQr53Tt3x7WEqUtpXTSfVBavmin84 3T7oBt6TwftmYmQn5SG8rPwxYGQGw0LSiTiW2ZJCEWMuMP1mwFXla51Bhidxzlnf91SQ MjPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+Fhtgna0SXO11lyolbeD9TX1zF+jZgBIlJXC+kQtz6g=; b=qgRUomCggmO/CImnpgaSe24IeQqxT7HiBClGa/IoTLOefmvG7Ya6eP9s/fTqF3qhkV hRdE3bBIuVB3v4jJlLqCi0h/5Mjg/c0KJF0oRgjh9ISgyUqN6AfZd6t0Y9tpaniuBfj+ 0cgE4MjcjiofRXbPlnH38CGLGG8AVEnB+v7yECz144iEzd3NOpnyjUPcDg1fs7RJL5hg cVDGz2uf0z6YIlICvtEXt2oXplcZh/GWiTvWQ9QOAZrevCRnXU/EJw/5QIzxcEHnYHru t79Jbk2O4gdjL4V29b1MMyY519W2ObBNXJmgfksdWl9I4d0YJK5+s8+YzNR8l1g49S2h OrgA== X-Gm-Message-State: AOAM531WIDKa5oD3PehmS35hE4jZgk1xLbW6rrDMNufj/EVoK0njE4do +r/WzSc7EU0ptJ4PcKZKhJnBMw== X-Google-Smtp-Source: ABdhPJzMymEKH74HWUo8C5GwkSp/38Pr1M06JMzc1zU8uSmNahO2ELY+L4cL85PCoMeNlK+d/rGH4g== X-Received: by 2002:adf:eb87:0:b0:20c:a5b5:6731 with SMTP id t7-20020adfeb87000000b0020ca5b56731mr6745222wrn.199.1651928111223; Sat, 07 May 2022 05:55:11 -0700 (PDT) Received: from localhost.localdomain (static-176-182-171-101.ncc.abo.bbox.fr. [176.182.171.101]) by smtp.gmail.com with ESMTPSA id e9-20020a05600c218900b0039453fe55a7sm10470345wme.35.2022.05.07.05.55.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 May 2022 05:55:11 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v2 05/14] thermal/of: Remove the device node pointer for thermal_trip Date: Sat, 7 May 2022 14:54:33 +0200 Message-Id: <20220507125443.2766939-6-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220507125443.2766939-1-daniel.lezcano@linexp.org> References: <20220507125443.2766939-1-daniel.lezcano@linexp.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 device node pointer is no longer needed in the thermal trip structure, remove it. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.h | 2 -- drivers/thermal/thermal_of.c | 8 -------- 2 files changed, 10 deletions(-) diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 726e327b4205..ff10cdda056c 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -70,13 +70,11 @@ void __thermal_cdev_update(struct thermal_cooling_devic= e *cdev); =20 /** * struct thermal_trip - representation of a point in temperature domain - * @np: pointer to struct device_node that this trip point was created from * @temperature: temperature value in miliCelsius * @hysteresis: relative hysteresis in miliCelsius * @type: trip point type */ struct thermal_trip { - struct device_node *np; int temperature; int hysteresis; enum thermal_trip_type type; diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index d8b4a0ad2d5f..a8a3cb309822 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -855,10 +855,6 @@ static int thermal_of_populate_trip(struct device_node= *np, return ret; } =20 - /* Required for cooling map matching */ - trip->np =3D np; - of_node_get(np); - return 0; } =20 @@ -988,8 +984,6 @@ __init *thermal_of_build_thermal_zone(struct device_nod= e *np) =20 kfree(tz->tbps); free_trips: - for (i =3D 0; i < tz->ntrips; i++) - of_node_put(tz->trips[i].np); kfree(tz->trips); of_node_put(gchild); free_tz: @@ -1014,8 +1008,6 @@ static __init void of_thermal_free_zone(struct __ther= mal_zone *tz) } =20 kfree(tz->tbps); - for (i =3D 0; i < tz->ntrips; i++) - of_node_put(tz->trips[i].np); kfree(tz->trips); kfree(tz); } --=20 2.25.1 From nobody Mon Jun 15 01:41:29 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 30C61C433F5 for ; Sat, 7 May 2022 12:56:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1446388AbiEGNAB (ORCPT ); Sat, 7 May 2022 09:00:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385029AbiEGM7A (ORCPT ); Sat, 7 May 2022 08:59:00 -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 7DA3D46B07 for ; Sat, 7 May 2022 05:55:13 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id j15so13460353wrb.2 for ; Sat, 07 May 2022 05:55:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XtCARZin/PmV3bTH/FtMmIwn3I6K19ONhR2W8qlbYlg=; b=Ujq3AJIZ9J5xQbbB0LooDPmoMlTAuhjn4KK59BgX+MVQthU4frlLVXFTtF7TWnDeha JebkWLKMsN34kPyjLT7H/fBkoApLXaAtZZj1zO1Z3F/oc/o36MUAJi4GxdPr7N8dk/v1 67pTpBfMWyaeYeFfIEXXThYkqvoEAxUsl0y1Q+nTZRkKf6Q0oi6TDtj2fo8fMu3oaRVF 6/xv+hEe5uIE94vC36PKpbNoc2yGFv1GITPMOcktWGCNt+w5iIUnsvlwGW40DlfUyywU gx2lXYoYUT2CSdJm0C+A/U87mMHspCMcxmigMDjAl5p241ypWv/TSfHgMTi9FHbQgSNs W3Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XtCARZin/PmV3bTH/FtMmIwn3I6K19ONhR2W8qlbYlg=; b=0BAXW8W+Ov4pRC+Vmg1QzEIXANU8pt0CC46LfxZzFeNTuFTPvYsr61ej03DLGDA/cd nDkmCdahfGHmOMW8MeITJ3j5exOwArEZ5ki2XRk1Ry2VUzFA6e6V5VsdYZ6G9KvIZ0oP SmiaQpWObfNe9bJ3B/e7nAETFa25jB9Pqpm7yZrF5+Q81ubozqh0ocAuKJ/l3QzomgIm 4jAXUq6UwgkCAoAncrt+MEDs4D5AYJDKp0YePJ0ulQcGo+fVdxjb4BG+gzEgR8V0W8Ex C8n6fEYuIeRcHiK/ydcU+XiFNXhnEFRqWKW2KV3BsjSWWXjCE6K6mIIucQ/o6ysOz716 Go9g== X-Gm-Message-State: AOAM530VidunKlJ0nGFo1QQ7f+3ytDh+bM3VMGyozkcDFZxY3wlR+5pb q2EjOXeq8jjdEjF6b21MtCB+tw== X-Google-Smtp-Source: ABdhPJxBMgNESv6YzNF2tBnMFSrH5fg2OQ70C7DT2o1bfxMzOh6EU2u2HQhGSVgi6QJfYR1UVS7TPg== X-Received: by 2002:adf:f6c1:0:b0:20a:daf6:9bd3 with SMTP id y1-20020adff6c1000000b0020adaf69bd3mr6467598wrp.425.1651928112048; Sat, 07 May 2022 05:55:12 -0700 (PDT) Received: from localhost.localdomain (static-176-182-171-101.ncc.abo.bbox.fr. [176.182.171.101]) by smtp.gmail.com with ESMTPSA id e9-20020a05600c218900b0039453fe55a7sm10470345wme.35.2022.05.07.05.55.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 May 2022 05:55:11 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v2 06/14] thermal/of: Move thermal_trip structure to thermal.h Date: Sat, 7 May 2022 14:54:34 +0200 Message-Id: <20220507125443.2766939-7-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220507125443.2766939-1-daniel.lezcano@linexp.org> References: <20220507125443.2766939-1-daniel.lezcano@linexp.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 structure thermal_trip is now generic and will be usable by the different sensor drivers in place of their own structure. Move its definition to thermal.h to make it accessible. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.h | 12 ------------ include/linux/thermal.h | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index ff10cdda056c..60844e2d59bb 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -68,18 +68,6 @@ static inline bool cdev_is_power_actor(struct thermal_co= oling_device *cdev) void thermal_cdev_update(struct thermal_cooling_device *); void __thermal_cdev_update(struct thermal_cooling_device *cdev); =20 -/** - * struct thermal_trip - representation of a point in temperature domain - * @temperature: temperature value in miliCelsius - * @hysteresis: relative hysteresis in miliCelsius - * @type: trip point type - */ -struct thermal_trip { - int temperature; - int hysteresis; - enum thermal_trip_type type; -}; - int get_tz_trend(struct thermal_zone_device *tz, int trip); =20 struct thermal_instance * diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 10dea654df6c..0b99b7707928 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -80,6 +80,18 @@ struct thermal_sensor_ops { void (*critical)(struct thermal_zone_device *); }; =20 +/** + * struct thermal_trip - representation of a point in temperature domain + * @temperature: temperature value in miliCelsius + * @hysteresis: relative hysteresis in miliCelsius + * @type: trip point type + */ +struct thermal_trip { + int temperature; + int hysteresis; + enum thermal_trip_type type; +}; + struct thermal_sensor { struct thermal_sensor_ops *ops; struct device *dev; --=20 2.25.1 From nobody Mon Jun 15 01:41:29 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 11B8FC433EF for ; Sat, 7 May 2022 12:56:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349886AbiEGM7s (ORCPT ); Sat, 7 May 2022 08:59:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385053AbiEGM7B (ORCPT ); Sat, 7 May 2022 08:59:01 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45A374B1C6 for ; Sat, 7 May 2022 05:55:14 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id n126-20020a1c2784000000b0038e8af3e788so5874376wmn.1 for ; Sat, 07 May 2022 05:55:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H9bQlM9gg7UBQwLA/AvFpX2Y6HQDQSBbVmYVoUf7zx8=; b=l64hwqcDceXvHHe2+llejtFh2jk8jX6S46HbYJ+N98So3DvC6m+iEEER5UGioOPsiB dKPOBdqogch8CLjrthyR72A89B+fsMoRcLilJlX5ZwijbvAcTkcxG7N8zrxrx8fH9XxN 7rLwJlRcFePwppdBfnRI0QJmiRzJ2FO9TB95qe7oiAuII1JChkG5GHBrRFGhTMDt727q KcprLIdTQLAsZPRHtT9I0vMAFHVYTQdYtD1uRTa3YgUDoi7wdUcQOZOgX1wdaDWOUKlx JoLKqDabg5fH9ZxHXLnW+6GktjphB7foqvLRG9+++SuzXr3h4BvDhwguyH0YOwCl2+DI WKeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H9bQlM9gg7UBQwLA/AvFpX2Y6HQDQSBbVmYVoUf7zx8=; b=u6H0Yws7YP0sdfIK4wO4ywLl2Zo1aB0RGAx5B1AUZfgeU9VZdpkhUNRDgy4j3QWKk8 F+giemltE9imEe1ldpwH0mDfpAX49jbkwjPtmeDNtA1AYTOE3ONUs5CYSKJIufKOryjm BYO4yMD5ndbFo/k0aO4Xo5mWQR/3FUaHHp157MsHM8/GkgjoErGIiCTy22ZgN2bxEnRa /pqsMcFOa0lKbLw+4VGQW3ktZao2vr5x17UlOdGSnYipCXFfr/y0WYdta9MFuY7DgjrS O6yT9Tr9abCw+49K1X+rbLuXRBdRZmv9zRPwxFryVq8wY/fPLVb3eE15Mdgz1v8xIBii 6E/A== X-Gm-Message-State: AOAM533wX87OCV4fvZIln1rTxgeVXTN2Ik+6c2an+yN4baf3VlJcv/as g6SGZacDGpx8l/CQo1rpoPp0tA== X-Google-Smtp-Source: ABdhPJxjwzxdFF9Unrndlh742n7Cnyqf12EENRFzGjxx9FUR2JNdz4S/dtZAIKYUf1E0IlOJvRWtVg== X-Received: by 2002:a05:600c:1552:b0:394:52a9:e48a with SMTP id f18-20020a05600c155200b0039452a9e48amr14473567wmg.45.1651928112897; Sat, 07 May 2022 05:55:12 -0700 (PDT) Received: from localhost.localdomain (static-176-182-171-101.ncc.abo.bbox.fr. [176.182.171.101]) by smtp.gmail.com with ESMTPSA id e9-20020a05600c218900b0039453fe55a7sm10470345wme.35.2022.05.07.05.55.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 May 2022 05:55:12 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v2 07/14] thermal/core: Remove unneeded EXPORT_SYMBOLS Date: Sat, 7 May 2022 14:54:35 +0200 Message-Id: <20220507125443.2766939-8-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220507125443.2766939-1-daniel.lezcano@linexp.org> References: <20220507125443.2766939-1-daniel.lezcano@linexp.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" Different functions are exporting the symbols but are actually only used by the thermal framework internals. Remove these EXPORT_SYMBOLS. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_helpers.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_he= lpers.c index 334478fe40fa..beb97cd6b799 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -39,7 +39,6 @@ int get_tz_trend(struct thermal_zone_device *tz, int trip) =20 return trend; } -EXPORT_SYMBOL(get_tz_trend); =20 struct thermal_instance * get_thermal_instance(struct thermal_zone_device *tz, @@ -228,7 +227,6 @@ void thermal_cdev_update(struct thermal_cooling_device = *cdev) } mutex_unlock(&cdev->lock); } -EXPORT_SYMBOL(thermal_cdev_update); =20 /** * thermal_zone_get_slope - return the slope attribute of the thermal zone --=20 2.25.1 From nobody Mon Jun 15 01:41:29 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 81976C433EF for ; Sat, 7 May 2022 12:55:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1446372AbiEGM7l (ORCPT ); Sat, 7 May 2022 08:59:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384944AbiEGM7C (ORCPT ); Sat, 7 May 2022 08:59:02 -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 2B3E83EBAD for ; Sat, 7 May 2022 05:55:15 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id j15so13460403wrb.2 for ; Sat, 07 May 2022 05:55:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0U/s6dQTEfoFEbpTJihWWY85W4BK/cbywxL1SeG1t9U=; b=2Qm8bNiXNCwkPjVehTglY1L/ALQ+SkYt0zoY5cJug/jsrR5na46y1dILW/DppzMKHl p6nVoj9OkynpqOHbnrXvRG3WgaCFEO0J64gUwqVx9TthjQczi0mUjTNpIy9rp2ndS7vE Q0FGaJYb1HQakrCV/uyRVS0aOPowdH0skbXuS3x1n6C3FxZ6UpcnRwPkzPW84Z+8xoIi MLNU1XU6Apth5WMB8WGEtKZ8RTYAinGu6tJ7UvQTlh2voT8DlDEHvDKrLyEfrtxb6QMl ctRKH11rc3KV7mNsXY6AmhQlhPNXPn0H0aM5WSAR4/INMt2cCjjVHcvRcHmz++QX0qgt Hg7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0U/s6dQTEfoFEbpTJihWWY85W4BK/cbywxL1SeG1t9U=; b=kKCRqQhVbTQ0Jy0xgkZSXqGecYg3qiRH5lV9iIuPoDlUMebbONTfYre4eTXomupr5Q tuisYm02DBhS5z652yj0wg0mC5Bl4JWhYo5cVrVDz4GtG/2rtOuz7FNN/rrIaQzIGfTA 204k2GIZ3DbqfSVWWMuv8PUv8Oys6/CTogEbnoF/fFJ1EcTCPAomNIZ+qXI4z0K3Izt6 E0FVTFKUKPsXKJf08UutSeQFOOfUqOJ6ITa1UKRQ0+PHyTmj5pCRv04fmL0fcck1XHkf k3uwa5HMGUQGKeqXOkyxtOWvtMVV5YDAE+b2TV1B7eCUULVBbzKUBx3k7OAO2X+oRFX+ wz3g== X-Gm-Message-State: AOAM531NpwIWJ04qRxBV1socli+VMo1aopcF/dReW1mD4ronTUKTUSoo RExRdDSNog6sWY1yTJCzdKmM1Q== X-Google-Smtp-Source: ABdhPJxk7AFrtzXjdxWAguuWuKWkzF2JF2G/mbGYTHXrWpUwSmLHl88tunPErUcVgLWNZY08bG/UnQ== X-Received: by 2002:a5d:47ce:0:b0:20c:6305:d8cb with SMTP id o14-20020a5d47ce000000b0020c6305d8cbmr6733219wrc.106.1651928113765; Sat, 07 May 2022 05:55:13 -0700 (PDT) Received: from localhost.localdomain (static-176-182-171-101.ncc.abo.bbox.fr. [176.182.171.101]) by smtp.gmail.com with ESMTPSA id e9-20020a05600c218900b0039453fe55a7sm10470345wme.35.2022.05.07.05.55.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 May 2022 05:55:13 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v2 08/14] thermal/core: Move thermal_set_delay_jiffies to static Date: Sat, 7 May 2022 14:54:36 +0200 Message-Id: <20220507125443.2766939-9-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220507125443.2766939-1-daniel.lezcano@linexp.org> References: <20220507125443.2766939-1-daniel.lezcano@linexp.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 function 'thermal_set_delay_jiffies' is only used in thermal_core.c but it is defined and implemented in a separate file. Move the function to thermal_core.c and make it static. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.c | 7 +++++++ drivers/thermal/thermal_core.h | 1 - drivers/thermal/thermal_helpers.c | 7 ------- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index dc5a03d51f5c..386453d46e94 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1158,6 +1158,13 @@ static void bind_tz(struct thermal_zone_device *tz) mutex_unlock(&thermal_list_lock); } =20 +static void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int de= lay_ms) +{ + *delay_jiffies =3D msecs_to_jiffies(delay_ms); + if (delay_ms > 1000) + *delay_jiffies =3D round_jiffies(*delay_jiffies); +} + /** * thermal_zone_device_register() - register a new thermal zone device * @type: the thermal zone device type diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 60844e2d59bb..c991bb290512 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -112,7 +112,6 @@ int thermal_build_list_of_policies(char *buf); =20 /* Helpers */ void thermal_zone_set_trips(struct thermal_zone_device *tz); -void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms); =20 /* sysfs I/F */ int thermal_zone_create_device_groups(struct thermal_zone_device *, int); diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_he= lpers.c index beb97cd6b799..3c7aa31686ad 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -174,13 +174,6 @@ void thermal_zone_set_trips(struct thermal_zone_device= *tz) mutex_unlock(&tz->lock); } =20 -void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms) -{ - *delay_jiffies =3D msecs_to_jiffies(delay_ms); - if (delay_ms > 1000) - *delay_jiffies =3D round_jiffies(*delay_jiffies); -} - static void thermal_cdev_set_cur_state(struct thermal_cooling_device *cdev, int target) { --=20 2.25.1 From nobody Mon Jun 15 01:41:29 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 C73C8C433EF for ; Sat, 7 May 2022 12:56:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1446411AbiEGNAK (ORCPT ); Sat, 7 May 2022 09:00:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385082AbiEGM7L (ORCPT ); Sat, 7 May 2022 08:59:11 -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 994F341FA8 for ; Sat, 7 May 2022 05:55:19 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id k2so13427024wrd.5 for ; Sat, 07 May 2022 05:55:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WqbegEmN/3MMIh2FzQitK1Mjou+MS3mTIl/jHPLE9Hs=; b=FjJ6YRX6I9ycv0vXmv5vkjK3o1acDF+bjIY+9GRFL/w6IYyFqf4J1yGdOK6Vl7SO+p Y9x4k2NPJJxwx11nmbs5XvUURmg+knpxvGv69AK1L8GI0aCCaXO9QVwWdBB8+0u1v/c1 beHb7UCH3XwfKyRYThZyJWWz1hqcuONa5wFfLX1UpTUvwTVLju5T4BvCPwW8+aBhUon6 oC37jh0UPH2gfTf4Kl7Pnsfy+AHcdEmFjEbZuo0Tu7fsolXlIytqVh2V+NeDFu6mSmJ3 DTwwxM+7/0bpt4XY7ztz25Asu4WHr/QYtmLStzlEYsO7lalnL6tVT+2ZhVf3P3gLFy6s stcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WqbegEmN/3MMIh2FzQitK1Mjou+MS3mTIl/jHPLE9Hs=; b=3BXWpM6FoaEkzOWwa9duqFXN2xcPLFiiLt3qsAkx6tx9pFrtE5k+gmozb65jxXrYdO Z+lPSwmtwVJnmXqT3ZnNdvthgHMDuMmHCJWCCVWOvO/1+HuqYP2l9Y/7ZdXSmy5yUTy5 0koQDLPRF6xzu0geJf0bqsEhWCFxdVjcIAN3iqgeBVtyZ7Akgm+W5iUEDc7rTZxwN9e7 n6nDYLVeU+mFtHB0aU4nEv1fsydaztqDT1xrTeOpCfvpl2TxjJ78FaCYWgl4FxB7Ww5p 07iaEoWPgQy51E3/VU81IzfV81cnWVGXAmrKIIQSJbHqlEEXwQB0RSkFkVg0H2BysxL5 n2BA== X-Gm-Message-State: AOAM533mj/qLOmUZBHZ8O0ivZSG+mMdQAzmpI1sbmG+fg95xn1U1e2Xk FoY4kZ7aBXZVVbzJ+XC6t3hkXA== X-Google-Smtp-Source: ABdhPJwpzsXPFfHpZKgUnXF6eHT+Otd6ftM4yJAPRkWcy+4RUfbKR597R8cjXN2b/S9kEpe/ZoTFIw== X-Received: by 2002:adf:b1db:0:b0:20a:bcb5:6526 with SMTP id r27-20020adfb1db000000b0020abcb56526mr6872945wra.305.1651928118177; Sat, 07 May 2022 05:55:18 -0700 (PDT) Received: from localhost.localdomain (static-176-182-171-101.ncc.abo.bbox.fr. [176.182.171.101]) by smtp.gmail.com with ESMTPSA id e9-20020a05600c218900b0039453fe55a7sm10470345wme.35.2022.05.07.05.55.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 May 2022 05:55:17 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Zhang Rui , Lukasz Luba , Thierry Reding , Jonathan Hunter , Dmitry Osipenko , linux-tegra@vger.kernel.org (open list:TEGRA ARCHITECTURE SUPPORT) Subject: [PATCH v2 09/14] thermal/core: Rename trips to ntrips Date: Sat, 7 May 2022 14:54:37 +0200 Message-Id: <20220507125443.2766939-10-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220507125443.2766939-1-daniel.lezcano@linexp.org> References: <20220507125443.2766939-1-daniel.lezcano@linexp.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 order to use thermal trips defined in the thermal structure, rename the 'trips' field to 'ntrips' to have the 'trips' field containing the thermal trip points. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano --- drivers/thermal/gov_fair_share.c | 6 +++--- drivers/thermal/gov_power_allocator.c | 4 ++-- drivers/thermal/tegra/tegra30-tsensor.c | 2 +- drivers/thermal/thermal_core.c | 20 ++++++++++---------- drivers/thermal/thermal_helpers.c | 4 ++-- drivers/thermal/thermal_netlink.c | 2 +- drivers/thermal/thermal_sysfs.c | 22 +++++++++++----------- include/linux/thermal.h | 2 +- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/drivers/thermal/gov_fair_share.c b/drivers/thermal/gov_fair_sh= are.c index a157c621da59..a5d95a69b033 100644 --- a/drivers/thermal/gov_fair_share.c +++ b/drivers/thermal/gov_fair_share.c @@ -25,10 +25,10 @@ static int get_trip_level(struct thermal_zone_device *t= z) int trip_temp; enum thermal_trip_type trip_type; =20 - if (tz->trips =3D=3D 0 || !tz->sensor.ops->get_trip_temp) + if (tz->ntrips =3D=3D 0 || !tz->sensor.ops->get_trip_temp) return 0; =20 - for (count =3D 0; count < tz->trips; count++) { + for (count =3D 0; count < tz->ntrips; count++) { tz->sensor.ops->get_trip_temp(tz, count, &trip_temp); if (tz->temperature < trip_temp) break; @@ -53,7 +53,7 @@ static long get_target_state(struct thermal_zone_device *= tz, =20 cdev->ops->get_max_state(cdev, &max_state); =20 - return (long)(percentage * level * max_state) / (100 * tz->trips); + return (long)(percentage * level * max_state) / (100 * tz->ntrips); } =20 /** diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_po= wer_allocator.c index bcd146175f84..86d0e6cc4b6a 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -527,7 +527,7 @@ static void get_governor_trips(struct thermal_zone_devi= ce *tz, last_active =3D INVALID_TRIP; last_passive =3D INVALID_TRIP; =20 - for (i =3D 0; i < tz->trips; i++) { + for (i =3D 0; i < tz->ntrips; i++) { enum thermal_trip_type type; int ret; =20 @@ -668,7 +668,7 @@ static int power_allocator_bind(struct thermal_zone_dev= ice *tz) =20 get_governor_trips(tz, params); =20 - if (tz->trips > 0) { + if (tz->ntrips > 0) { ret =3D tz->sensor.ops->get_trip_temp(tz, params->trip_max_desired_temperature, &control_temp); diff --git a/drivers/thermal/tegra/tegra30-tsensor.c b/drivers/thermal/tegr= a/tegra30-tsensor.c index fab2709569c1..308646e0d8be 100644 --- a/drivers/thermal/tegra/tegra30-tsensor.c +++ b/drivers/thermal/tegra/tegra30-tsensor.c @@ -316,7 +316,7 @@ static void tegra_tsensor_get_hw_channel_trips(struct t= hermal_zone_device *tzd, *hot_trip =3D 85000; *crit_trip =3D 90000; =20 - for (i =3D 0; i < tzd->trips; i++) { + for (i =3D 0; i < tzd->ntrips; i++) { enum thermal_trip_type type; int trip_temp; =20 diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 386453d46e94..f898032ec23a 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -505,7 +505,7 @@ void thermal_zone_device_update(struct thermal_zone_dev= ice *tz, =20 tz->notify_event =3D event; =20 - for (count =3D 0; count < tz->trips; count++) + for (count =3D 0; count < tz->ntrips; count++) handle_thermal_trip(tz, count); } EXPORT_SYMBOL_GPL(thermal_zone_device_update); @@ -630,7 +630,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zon= e_device *tz, unsigned long max_state; int result, ret; =20 - if (trip >=3D tz->trips || trip < 0) + if (trip >=3D tz->ntrips || trip < 0) return -EINVAL; =20 list_for_each_entry(pos1, &thermal_tz_list, node) { @@ -811,7 +811,7 @@ static void __bind(struct thermal_zone_device *tz, int = mask, { int i, ret; =20 - for (i =3D 0; i < tz->trips; i++) { + for (i =3D 0; i < tz->ntrips; i++) { if (mask & (1 << i)) { unsigned long upper, lower; =20 @@ -1056,7 +1056,7 @@ static void __unbind(struct thermal_zone_device *tz, = int mask, { int i; =20 - for (i =3D 0; i < tz->trips; i++) + for (i =3D 0; i < tz->ntrips; i++) if (mask & (1 << i)) thermal_zone_unbind_cooling_device(tz, i, cdev); } @@ -1168,7 +1168,7 @@ static void thermal_set_delay_jiffies(unsigned long *= delay_jiffies, int delay_ms /** * thermal_zone_device_register() - register a new thermal zone device * @type: the thermal zone device type - * @trips: the number of trip points the thermal zone support + * @ntrips: the number of trip points the thermal zone support * @mask: a bit string indicating the writeablility of trip points * @devdata: private device data * @ops: standard thermal zone device callbacks @@ -1190,7 +1190,7 @@ static void thermal_set_delay_jiffies(unsigned long *= delay_jiffies, int delay_ms * IS_ERR*() helpers. */ struct thermal_zone_device * -thermal_zone_device_register(const char *type, int trips, int mask, +thermal_zone_device_register(const char *type, int ntrips, int mask, void *devdata, struct thermal_sensor_ops *ops, struct thermal_zone_params *tzp, int passive_delay, int polling_delay) @@ -1214,7 +1214,7 @@ thermal_zone_device_register(const char *type, int tr= ips, int mask, return ERR_PTR(-EINVAL); } =20 - if (trips > THERMAL_MAX_TRIPS || trips < 0 || mask >> trips) { + if (ntrips > THERMAL_MAX_TRIPS || ntrips < 0 || mask >> ntrips) { pr_err("Incorrect number of thermal trips\n"); return ERR_PTR(-EINVAL); } @@ -1224,7 +1224,7 @@ thermal_zone_device_register(const char *type, int tr= ips, int mask, return ERR_PTR(-EINVAL); } =20 - if (trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp)) + if (ntrips > 0 && (!ops->get_trip_type || !ops->get_trip_temp)) return ERR_PTR(-EINVAL); =20 tz =3D kzalloc(sizeof(*tz), GFP_KERNEL); @@ -1254,7 +1254,7 @@ thermal_zone_device_register(const char *type, int tr= ips, int mask, tz->tzp =3D tzp; tz->device.class =3D &thermal_class; tz->devdata =3D devdata; - tz->trips =3D trips; + tz->ntrips =3D ntrips; =20 thermal_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay); thermal_set_delay_jiffies(&tz->polling_delay_jiffies, polling_delay); @@ -1272,7 +1272,7 @@ thermal_zone_device_register(const char *type, int tr= ips, int mask, if (result) goto release_device; =20 - for (count =3D 0; count < trips; count++) { + for (count =3D 0; count < ntrips; count++) { if (tz->sensor.ops->get_trip_type(tz, count, &trip_type) || tz->sensor.ops->get_trip_temp(tz, count, &trip_temp) || !trip_temp) diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_he= lpers.c index 3c7aa31686ad..50ca221367f7 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -89,7 +89,7 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz,= int *temp) ret =3D tz->sensor.ops->get_temp(tz, temp); =20 if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) { - for (count =3D 0; count < tz->trips; count++) { + for (count =3D 0; count < tz->ntrips; count++) { ret =3D tz->sensor.ops->get_trip_type(tz, count, &type); if (!ret && type =3D=3D THERMAL_TRIP_CRITICAL) { ret =3D tz->sensor.ops->get_trip_temp(tz, count, @@ -137,7 +137,7 @@ void thermal_zone_set_trips(struct thermal_zone_device = *tz) if (!tz->sensor.ops->set_trips || !tz->sensor.ops->get_trip_hyst) goto exit; =20 - for (i =3D 0; i < tz->trips; i++) { + for (i =3D 0; i < tz->ntrips; i++) { int trip_low; =20 tz->sensor.ops->get_trip_temp(tz, i, &trip_temp); diff --git a/drivers/thermal/thermal_netlink.c b/drivers/thermal/thermal_ne= tlink.c index b309b2412500..1639fa5c92bb 100644 --- a/drivers/thermal/thermal_netlink.c +++ b/drivers/thermal/thermal_netlink.c @@ -469,7 +469,7 @@ static int thermal_genl_cmd_tz_get_trip(struct param *p) =20 mutex_lock(&tz->lock); =20 - for (i =3D 0; i < tz->trips; i++) { + for (i =3D 0; i < tz->ntrips; i++) { =20 enum thermal_trip_type type; int temp, hyst =3D 0; diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysf= s.c index 44212fa00c78..fd1207201c48 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -416,15 +416,15 @@ static int create_trip_attrs(struct thermal_zone_devi= ce *tz, int mask) int indx; =20 /* This function works only for zones with at least one trip */ - if (tz->trips <=3D 0) + if (tz->ntrips <=3D 0) return -EINVAL; =20 - tz->trip_type_attrs =3D kcalloc(tz->trips, sizeof(*tz->trip_type_attrs), + tz->trip_type_attrs =3D kcalloc(tz->ntrips, sizeof(*tz->trip_type_attrs), GFP_KERNEL); if (!tz->trip_type_attrs) return -ENOMEM; =20 - tz->trip_temp_attrs =3D kcalloc(tz->trips, sizeof(*tz->trip_temp_attrs), + tz->trip_temp_attrs =3D kcalloc(tz->ntrips, sizeof(*tz->trip_temp_attrs), GFP_KERNEL); if (!tz->trip_temp_attrs) { kfree(tz->trip_type_attrs); @@ -432,7 +432,7 @@ static int create_trip_attrs(struct thermal_zone_device= *tz, int mask) } =20 if (tz->sensor.ops->get_trip_hyst) { - tz->trip_hyst_attrs =3D kcalloc(tz->trips, + tz->trip_hyst_attrs =3D kcalloc(tz->ntrips, sizeof(*tz->trip_hyst_attrs), GFP_KERNEL); if (!tz->trip_hyst_attrs) { @@ -442,7 +442,7 @@ static int create_trip_attrs(struct thermal_zone_device= *tz, int mask) } } =20 - attrs =3D kcalloc(tz->trips * 3 + 1, sizeof(*attrs), GFP_KERNEL); + attrs =3D kcalloc(tz->ntrips * 3 + 1, sizeof(*attrs), GFP_KERNEL); if (!attrs) { kfree(tz->trip_type_attrs); kfree(tz->trip_temp_attrs); @@ -451,7 +451,7 @@ static int create_trip_attrs(struct thermal_zone_device= *tz, int mask) return -ENOMEM; } =20 - for (indx =3D 0; indx < tz->trips; indx++) { + for (indx =3D 0; indx < tz->ntrips; indx++) { /* create trip type attribute */ snprintf(tz->trip_type_attrs[indx].name, THERMAL_NAME_LENGTH, "trip_point_%d_type", indx); @@ -478,7 +478,7 @@ static int create_trip_attrs(struct thermal_zone_device= *tz, int mask) tz->trip_temp_attrs[indx].attr.store =3D trip_point_temp_store; } - attrs[indx + tz->trips] =3D &tz->trip_temp_attrs[indx].attr.attr; + attrs[indx + tz->ntrips] =3D &tz->trip_temp_attrs[indx].attr.attr; =20 /* create Optional trip hyst attribute */ if (!tz->sensor.ops->get_trip_hyst) @@ -496,10 +496,10 @@ static int create_trip_attrs(struct thermal_zone_devi= ce *tz, int mask) tz->trip_hyst_attrs[indx].attr.store =3D trip_point_hyst_store; } - attrs[indx + tz->trips * 2] =3D + attrs[indx + tz->ntrips * 2] =3D &tz->trip_hyst_attrs[indx].attr.attr; } - attrs[tz->trips * 3] =3D NULL; + attrs[tz->ntrips * 3] =3D NULL; =20 tz->trips_attribute_group.attrs =3D attrs; =20 @@ -540,7 +540,7 @@ int thermal_zone_create_device_groups(struct thermal_zo= ne_device *tz, for (i =3D 0; i < size - 2; i++) groups[i] =3D thermal_zone_attribute_groups[i]; =20 - if (tz->trips) { + if (tz->ntrips) { result =3D create_trip_attrs(tz, mask); if (result) { kfree(groups); @@ -561,7 +561,7 @@ void thermal_zone_destroy_device_groups(struct thermal_= zone_device *tz) if (!tz) return; =20 - if (tz->trips) + if (tz->ntrips) destroy_trip_attrs(tz); =20 kfree(tz->device.groups); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 0b99b7707928..e11c3d922c18 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -170,7 +170,7 @@ struct thermal_zone_device { struct thermal_attr *trip_hyst_attrs; enum thermal_device_mode mode; void *devdata; - int trips; + int ntrips; unsigned long trips_disabled; /* bitmap for disabled trips */ unsigned long passive_delay_jiffies; unsigned long polling_delay_jiffies; --=20 2.25.1 From nobody Mon Jun 15 01:41:29 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 1F97EC433F5 for ; Sat, 7 May 2022 12:56:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1446386AbiEGNAF (ORCPT ); Sat, 7 May 2022 09:00:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239452AbiEGM7L (ORCPT ); Sat, 7 May 2022 08:59:11 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F96241334 for ; Sat, 7 May 2022 05:55:19 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id e2so13427635wrh.7 for ; Sat, 07 May 2022 05:55:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kBV1Agc9Pdc/aJxtc/EdKC25XzazArIEAhwHD2saev8=; b=5wzzR1Gx29D7UCg5Rn8b33Gcil8GrzuziYJ6DqgyLdYuX9aVBZY52pdOH6UvzlwXGu 7/3b09HtWXMapswWgkONWdoS5oj00CUkpILmOu2xnl9hlgYuHA/kuV73WJOjclR+Iajk TiqGzcHY6A3kbmXXA7/AhhEtx0lD0qTXbsxBgPLkz+HJFPLERWZ0GxYkfaSg4Q5ManfG XcXPuZjrKi+dmshUUGTIPOerQyO/C/RnmsXDbMGrd3iH3G6EsWaHdlYe8hI3LzYv9Lxu B5bujOc0gH+qpGGmAtccxruYjqSBC3CXgYfbR+2O35zWgV6zYmj0u3uUvhKKv4Lswxkf Jiwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kBV1Agc9Pdc/aJxtc/EdKC25XzazArIEAhwHD2saev8=; b=J3pfWt1EkjlDqh/WKDo6jYhDiazcYqeB8cup8Muhz2h2iRt3JjblhLnAb9yKl9FQhp 9atMe5N7EluzdyvZngI0CLKSuNfdlFBU5+sQNYNkNp7r2y7YC2atduzAS3oDHxu0b6Xg 5lFzI+4Xq8CulqRZsUTMxwx9TzaBM1DBCAYws9ylXoVKSlWec00Z0VYFW1cxWyQXwX67 LNm84u4avDYKJA73+W0RPqHX2afWaupJgWSW0ATOYbUmy46yCXM0UFARyUOzCZ+MFiOU nBkOzHGIyllr5b5Q0U3BKPT5rtDFbQJ6V5X9hKKJopmnIh0EnZyEefo1pzBCEf6S4hkK AfQA== X-Gm-Message-State: AOAM531SJIzkRJEPkIuCYX5TMMTzlkq2k60hHhheVInXrvjRogY9O7E8 l1t5zcID6hqJDofq9WkBYuEtvg== X-Google-Smtp-Source: ABdhPJwZz0TjvaRxteDz5LlnI0c6giwXgkh1Y/IRty4TL5F1Mj+InwcqJUS2j5CSCd5M2fXGSBXN/w== X-Received: by 2002:a05:6000:86:b0:20a:d7be:e09b with SMTP id m6-20020a056000008600b0020ad7bee09bmr6405140wrx.398.1651928119004; Sat, 07 May 2022 05:55:19 -0700 (PDT) Received: from localhost.localdomain (static-176-182-171-101.ncc.abo.bbox.fr. [176.182.171.101]) by smtp.gmail.com with ESMTPSA id e9-20020a05600c218900b0039453fe55a7sm10470345wme.35.2022.05.07.05.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 May 2022 05:55:18 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v2 10/14] thermal/core: Add thermal_trip in thermal_zone Date: Sat, 7 May 2022 14:54:38 +0200 Message-Id: <20220507125443.2766939-11-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220507125443.2766939-1-daniel.lezcano@linexp.org> References: <20220507125443.2766939-1-daniel.lezcano@linexp.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 trip points are properties of a thermal zone and the different sub systems should be able to save them in the thermal zone structure instead of having their own definition. Give the opportunity to the drivers to create a thermal zone with thermal trips which will be accessible directly from the thermal core framework. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.h | 10 ++++++++++ include/linux/thermal.h | 1 + 2 files changed, 11 insertions(+) diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index c991bb290512..84e341c1e0fc 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -113,6 +113,16 @@ int thermal_build_list_of_policies(char *buf); /* Helpers */ void thermal_zone_set_trips(struct thermal_zone_device *tz); =20 +static inline struct thermal_trip *thermal_zone_get_trips(struct thermal_z= one *tz) +{ + return tz->trips; +} + +static inline int thermal_zone_get_ntrips(struct thermal_zone *tz) +{ + return tz->ntrips; +} + /* sysfs I/F */ int thermal_zone_create_device_groups(struct thermal_zone_device *, int); void thermal_zone_destroy_device_groups(struct thermal_zone_device *); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index e11c3d922c18..a11c00062ef1 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -184,6 +184,7 @@ struct thermal_zone_device { struct thermal_sensor sensor; struct thermal_zone_params *tzp; struct thermal_governor *governor; + struct thermal_trip *trips; void *governor_data; struct list_head thermal_instances; struct ida ida; --=20 2.25.1 From nobody Mon Jun 15 01:41:29 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 70BBDC433EF for ; Sat, 7 May 2022 12:56:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390145AbiEGNAQ (ORCPT ); Sat, 7 May 2022 09:00:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385099AbiEGM7M (ORCPT ); Sat, 7 May 2022 08:59:12 -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 4C6C6398 for ; Sat, 7 May 2022 05:55:21 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id e2so13428257wrh.7 for ; Sat, 07 May 2022 05:55:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HPZ5SE9Cu1hgeYmUx81B/RyK2FJraRwiffWZMBqc/OU=; b=MldC2b2g/eYaYzHLzJC4/zRtnobY+d712xZYpu5A4H9zLGIduZbubJAqruaCGEtD5k JdFD11QvqKHbeYsw3JH+cAkyEBWi+p0lMmzKxjuIburFnIr+unWST/PPrn3JJAgW/8ib buKGic1pB8ueonanxIpE7llPiKQ/q7msmY9e8vhQbn3ccCA5jJTFc4MlIBKILCIkjo4K fvLMHUXTh1Gonjbv6FHLHCeLFDgMIDicD/Fns9pJe+BVbPA8JxFlM5PaM7iiCYLsMzTx Sc6pc4ec4lK5HhP6x8WB/umxSBZz1WbEhLpcCpNel8susC2p/jcn/DpcPX6x4G+RxyMe IQNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HPZ5SE9Cu1hgeYmUx81B/RyK2FJraRwiffWZMBqc/OU=; b=tqwJVE4v27RiBVK5g6jh/eoYIYNJqIOG/P1DO/yC5bYxpZCWCsmXDhIzBLZDS4pRGa d7KAtlNvdNXMEVdD69lpuYNcdbxmqfOrcGARhYmoRlQaf3GeSKoQAsEIJ0r4BlJzVdr0 NfbEZWXfbHZZ5DjE7DOrCVOBS5EolqBv+tfqvqdO+kz78cpoj9OXz00LkU+HMq6GGgnV 5QzrNCxcVQFIdDKQntO7nuwmNpJ1Az8jWA/PvCu55WJYrsIvSVRXFLym8yD6lg0Jd/jx BYv1qCvRRVK/tvpJ/AVzgYOlfwbfH8QYCCj/gHY6QEZ/UluHsUEB7SvFF5/ZvpK6cdcE hZog== X-Gm-Message-State: AOAM531srBR2QbzubuZx7xvghc9mWWwFel+Tu3Eq9gcIO+sAinmiBWnf lUeI2GGIskbBVrvOADIHPR8aiDE5MdPXcHrRtHs= X-Google-Smtp-Source: ABdhPJwPFJR9YChlsgK/W07m4YL8ZHjj/5xSjnaPSYtfyCDO2wVFp+X+p8U8UyijwwSxgTVODMCMVg== X-Received: by 2002:a05:6000:1f9d:b0:20c:87b6:e775 with SMTP id bw29-20020a0560001f9d00b0020c87b6e775mr6500353wrb.253.1651928119877; Sat, 07 May 2022 05:55:19 -0700 (PDT) Received: from localhost.localdomain (static-176-182-171-101.ncc.abo.bbox.fr. [176.182.171.101]) by smtp.gmail.com with ESMTPSA id e9-20020a05600c218900b0039453fe55a7sm10470345wme.35.2022.05.07.05.55.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 May 2022 05:55:19 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v2 11/14] thermal/core: Register with the trip points Date: Sat, 7 May 2022 14:54:39 +0200 Message-Id: <20220507125443.2766939-12-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220507125443.2766939-1-daniel.lezcano@linexp.org> References: <20220507125443.2766939-1-daniel.lezcano@linexp.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" As we added the thermal trip points structure in the thermal zone, let's extend the thermal zone register function to have the thermal trip structures as a parameter and store it in the 'trips' field of the thermal zone structure. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.c | 23 ++++++++++++++++++----- drivers/thermal/thermal_core.h | 4 ++-- include/linux/thermal.h | 6 ++++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index f898032ec23a..a0317be48b0c 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1166,8 +1166,9 @@ static void thermal_set_delay_jiffies(unsigned long *= delay_jiffies, int delay_ms } =20 /** - * thermal_zone_device_register() - register a new thermal zone device + * thermal_zone_device_register_with_trips() - register a new thermal zone= device * @type: the thermal zone device type + * @trips: a pointer to an array of thermal trips * @ntrips: the number of trip points the thermal zone support * @mask: a bit string indicating the writeablility of trip points * @devdata: private device data @@ -1190,10 +1191,11 @@ static void thermal_set_delay_jiffies(unsigned long= *delay_jiffies, int delay_ms * IS_ERR*() helpers. */ struct thermal_zone_device * -thermal_zone_device_register(const char *type, int ntrips, int mask, - void *devdata, struct thermal_sensor_ops *ops, - struct thermal_zone_params *tzp, int passive_delay, - int polling_delay) +thermal_zone_device_register_with_trips(const char *type, struct thermal_t= rip *trips, + int ntrips, int mask, + void *devdata, struct thermal_sensor_ops *ops, + struct thermal_zone_params *tzp, int passive_delay, + int polling_delay) { struct thermal_zone_device *tz; enum thermal_trip_type trip_type; @@ -1255,6 +1257,7 @@ thermal_zone_device_register(const char *type, int nt= rips, int mask, tz->device.class =3D &thermal_class; tz->devdata =3D devdata; tz->ntrips =3D ntrips; + tz->trips =3D trips; =20 thermal_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay); thermal_set_delay_jiffies(&tz->polling_delay_jiffies, polling_delay); @@ -1330,6 +1333,16 @@ thermal_zone_device_register(const char *type, int n= trips, int mask, kfree(tz); return ERR_PTR(result); } + +struct thermal_zone_device *thermal_zone_device_register(const char *type,= int ntrips, int mask, + void *devdata, struct thermal_sensor_ops *ops, + struct thermal_zone_params *tzp, int passive_delay, + int polling_delay) +{ + return thermal_zone_device_register_with_trips(type, NULL, ntrips, mask, + devdata, ops, tzp, + passive_delay, polling_delay); +} EXPORT_SYMBOL_GPL(thermal_zone_device_register); =20 /** diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 84e341c1e0fc..bbe3ec26d12e 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -113,12 +113,12 @@ int thermal_build_list_of_policies(char *buf); /* Helpers */ void thermal_zone_set_trips(struct thermal_zone_device *tz); =20 -static inline struct thermal_trip *thermal_zone_get_trips(struct thermal_z= one *tz) +static inline struct thermal_trip *thermal_zone_get_trips(struct thermal_z= one_device *tz) { return tz->trips; } =20 -static inline int thermal_zone_get_ntrips(struct thermal_zone *tz) +static inline int thermal_zone_get_ntrips(struct thermal_zone_device *tz) { return tz->ntrips; } diff --git a/include/linux/thermal.h b/include/linux/thermal.h index a11c00062ef1..8c4bc6d1de97 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -381,8 +381,14 @@ void devm_thermal_zone_of_sensor_unregister(struct dev= ice *dev, struct thermal_zone_device *thermal_zone_device_register(const char *, int= , int, void *, struct thermal_sensor_ops *, struct thermal_zone_params *, int, int); + void thermal_zone_device_unregister(struct thermal_zone_device *); =20 +struct thermal_zone_device * +thermal_zone_device_register_with_trips(const char *, struct thermal_trip = *, int, int, + void *, struct thermal_sensor_ops *, + struct thermal_zone_params *, int, int); + int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int, struct thermal_cooling_device *, unsigned long, unsigned long, --=20 2.25.1 From nobody Mon Jun 15 01:41:29 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 4605EC433EF for ; Sat, 7 May 2022 12:56:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1446382AbiEGNAV (ORCPT ); Sat, 7 May 2022 09:00:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1445367AbiEGM7T (ORCPT ); Sat, 7 May 2022 08:59:19 -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 0FA73B9C for ; Sat, 7 May 2022 05:55:22 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id x18so13466864wrc.0 for ; Sat, 07 May 2022 05:55:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z/3SG51L76j371xoLprO5E0bcUDIZoNhzkCxIpDaKlc=; b=d1aPND7vtBHTKlopYpAirXVaCBjuyPnzkKChgWratJAiSKtLNw02EMp02G16Jx5rE/ dBJcTfcHnlobFrBABVBNmF+qawvwJBFPPu1RGtGFIUCOX67fOeI1YqeOix/pVFJAoD7A YhFRJAIIIZ999lJ7a1G0NkjY6IHf23gBLR+JVLSj4/HUj/GWKlnJFzqh8yUniY3cOCgS rnH9+1zcLI6n8kMgIqpFssGmjVoKKQp6oc2fvIb4Js6yj91k1rzLt+vJUTL2a3Mx1twf 8otoX6QsSiE+YgWuDRjVXn6wCMd4+X7S+hSwkhYLBIQcJDpKO3Bnkt5Y5+5FS2ec4+sA B6pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z/3SG51L76j371xoLprO5E0bcUDIZoNhzkCxIpDaKlc=; b=t204c+qYteJFyMK0H9fkBqa9EaKG5109az8krqGIUimo2Q3kUZu3zrYYEf7/gA0pio NROZKRoe0cxrqeWXTXZnDmIiydu0vAyh1Zwqixk8xG9xqHvQYRYHCi2TOHCsHNFpv9rR nsvftnO/AHMHrdEZTPwBmGETObnAV7H3xnNuifOIKIBdo/ACnMG5b36Y/xyic5bmgpaU l2EREBuQ/ZrSBJYhdLdHVmNAKnHh4UjI5nYUOX6Dk8ypi7eASWn/akcKjipMN30/6ltt +/e6umcPcfOrEfPGFP7vlTfVonIJfsXZXAYvLBWS4zx4VXJtMsORdo5JKvLaLazxB1bG dPcA== X-Gm-Message-State: AOAM5308WDY3CFR9rirfRy+HybjfCEVcQ8eLXn4qFscH8dW90kiHKivJ o6vFQwYPfzpu8YWgvGQGFAHscA== X-Google-Smtp-Source: ABdhPJwg8CZ2XSeNZvkp6RLmvlUklOcTecMNk4pL2FHy6Iln0Hhp1MeArTV7/q2+oWYYalZl1gx7nQ== X-Received: by 2002:adf:cc82:0:b0:20a:cf3b:4624 with SMTP id p2-20020adfcc82000000b0020acf3b4624mr6532297wrj.573.1651928120674; Sat, 07 May 2022 05:55:20 -0700 (PDT) Received: from localhost.localdomain (static-176-182-171-101.ncc.abo.bbox.fr. [176.182.171.101]) by smtp.gmail.com with ESMTPSA id e9-20020a05600c218900b0039453fe55a7sm10470345wme.35.2022.05.07.05.55.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 May 2022 05:55:20 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v2 12/14] thermal/of: Store the trips in the thermal zone Date: Sat, 7 May 2022 14:54:40 +0200 Message-Id: <20220507125443.2766939-13-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220507125443.2766939-1-daniel.lezcano@linexp.org> References: <20220507125443.2766939-1-daniel.lezcano@linexp.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" As the thermal zone contains the trip point, we can store them directly in the when registering the thermal zone. That will allow another step forward to remove the duplicate thermal zone structure we find in the thermal_of code. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index a8a3cb309822..200d1d784211 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -1105,11 +1105,9 @@ int __init of_parse_thermal_zones(void) tzp->slope =3D tz->slope; tzp->offset =3D tz->offset; =20 - zone =3D thermal_zone_device_register(child->name, tz->ntrips, - mask, tz, - ops, tzp, - tz->passive_delay, - tz->polling_delay); + zone =3D thermal_zone_device_register_with_trips(child->name, tz->trips,= tz->ntrips, + mask, tz, ops, tzp, tz->passive_delay, + tz->polling_delay); if (IS_ERR(zone)) { pr_err("Failed to build %pOFn zone %ld\n", child, PTR_ERR(zone)); --=20 2.25.1 From nobody Mon Jun 15 01:41:29 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 F3B61C433EF for ; Sat, 7 May 2022 12:56:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1446377AbiEGNAY (ORCPT ); Sat, 7 May 2022 09:00:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442603AbiEGM7Q (ORCPT ); Sat, 7 May 2022 08:59:16 -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 E844BB5E for ; Sat, 7 May 2022 05:55:21 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id b19so13424776wrh.11 for ; Sat, 07 May 2022 05:55:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mNMbbnz7btHxGc8GohDuK10koCp0Ix4y578fYXBQdgs=; b=AmQ+2vPBw3hSjH5ZV0IP9Xp4FdgvOVjp+TJO4FYw6s35tzC4ew1VuRqTT2nH9zfHSK +lO8py9PsnTR3kKvcDhi9dKp4/hPqSCNFfDJkV4PPl5X1IWJtNcoa/wXIqk2gg9TAa9y O9uwpHIkWtWvSe7aW3HoiOYZcUgezt7ya2pe5gHLAlwn9o0byq5Z2D3T3NYPWlvCJR+t Yw26swMKL1nYGdbkI5ANAktm/pEAIAukCfvlBMo3fWPvZ0WDECNaJ+MWzixe6H3TTlBO PqK/TeptOM6S4oSghMx/ATVGQX40F9oZnm88Rafjz2zQFFWmb7brRzF4KM0xCJOYjUVZ /lSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mNMbbnz7btHxGc8GohDuK10koCp0Ix4y578fYXBQdgs=; b=M9Azzy4vmJFPK47YDMyXYDTcPLRFu3SC4c21f25K+HBzGrkrBbAWl4wg9Ta6+0Qtw5 rxLFS195EC2EpcodAtfVPadb9L7sxSUNb/kyqzsceyQ+KlM1HAiOihS7uXe18n8elL8O Sk1c6pVSzL67Nwq1KXU1PohZnKemcWUb6OTZmbWe/Hz4MVr1N79aSuEkKE1smEQfEfag UkGSrsLpl1KQ/jTuvYuikjGy1M6os9wKzi+9Y7jcimIDRsERAAI72o3rAr9y2NJCBgi6 VaZ8q7y6ju3xY47OWQEx7mcTyeAbNmdPp8CxqRchNV5qAaNIoSa2kixeJxHY1cD7YqvF S92g== X-Gm-Message-State: AOAM532DEZ8BsT0UV9FFS3v4LMG6Kvd1fkAb/ocDiy7OGAoqSKGCKqWK ikLbT21v3W5OPiDxNP2HgmmKOQ== X-Google-Smtp-Source: ABdhPJzV7QWoO76/KfhYOj7t6cwenAPOphaYTAO3t0HvYEB1yeBwNDWiAxd/Uz1y0HDHlGRO23nvOA== X-Received: by 2002:a05:6000:1449:b0:20c:59b4:e9b9 with SMTP id v9-20020a056000144900b0020c59b4e9b9mr6605879wrx.698.1651928121515; Sat, 07 May 2022 05:55:21 -0700 (PDT) Received: from localhost.localdomain (static-176-182-171-101.ncc.abo.bbox.fr. [176.182.171.101]) by smtp.gmail.com with ESMTPSA id e9-20020a05600c218900b0039453fe55a7sm10470345wme.35.2022.05.07.05.55.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 May 2022 05:55:21 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v2 13/14] thermal/of: Use thermal trips stored in the thermal zone Date: Sat, 7 May 2022 14:54:41 +0200 Message-Id: <20220507125443.2766939-14-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220507125443.2766939-1-daniel.lezcano@linexp.org> References: <20220507125443.2766939-1-daniel.lezcano@linexp.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" Now that we have the thermal trip stored in the thermal zone in a generic way, we can rely on them and remove one indirection we found in the thermal_of code and do one more step forward the removal of the duplicated structures. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 53 +++++++++++------------------------- 1 file changed, 16 insertions(+), 37 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 200d1d784211..64e5b9e92cb1 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -118,12 +118,7 @@ static int of_thermal_set_trips(struct thermal_zone_de= vice *tz, */ int of_thermal_get_ntrips(struct thermal_zone_device *tz) { - struct __thermal_zone *data =3D tz->devdata; - - if (!data || IS_ERR(data)) - return -ENODEV; - - return data->ntrips; + return tz->ntrips; } EXPORT_SYMBOL_GPL(of_thermal_get_ntrips); =20 @@ -139,9 +134,7 @@ EXPORT_SYMBOL_GPL(of_thermal_get_ntrips); */ bool of_thermal_is_trip_valid(struct thermal_zone_device *tz, int trip) { - struct __thermal_zone *data =3D tz->devdata; - - if (!data || trip >=3D data->ntrips || trip < 0) + if (trip >=3D tz->ntrips || trip < 0) return false; =20 return true; @@ -161,12 +154,7 @@ EXPORT_SYMBOL_GPL(of_thermal_is_trip_valid); const struct thermal_trip * of_thermal_get_trip_points(struct thermal_zone_device *tz) { - struct __thermal_zone *data =3D tz->devdata; - - if (!data) - return NULL; - - return data->trips; + return tz->trips; } EXPORT_SYMBOL_GPL(of_thermal_get_trip_points); =20 @@ -273,12 +261,10 @@ static int of_thermal_unbind(struct thermal_zone_devi= ce *thermal, static int of_thermal_get_trip_type(struct thermal_zone_device *tz, int tr= ip, enum thermal_trip_type *type) { - struct __thermal_zone *data =3D tz->devdata; - - if (trip >=3D data->ntrips || trip < 0) + if (trip >=3D tz->ntrips || trip < 0) return -EDOM; =20 - *type =3D data->trips[trip].type; + *type =3D tz->trips[trip].type; =20 return 0; } @@ -286,12 +272,10 @@ static int of_thermal_get_trip_type(struct thermal_zo= ne_device *tz, int trip, static int of_thermal_get_trip_temp(struct thermal_zone_device *tz, int tr= ip, int *temp) { - struct __thermal_zone *data =3D tz->devdata; - - if (trip >=3D data->ntrips || trip < 0) + if (trip >=3D tz->ntrips || trip < 0) return -EDOM; =20 - *temp =3D data->trips[trip].temperature; + *temp =3D tz->trips[trip].temperature; =20 return 0; } @@ -301,7 +285,7 @@ static int of_thermal_set_trip_temp(struct thermal_zone= _device *tz, int trip, { struct __thermal_zone *data =3D tz->devdata; =20 - if (trip >=3D data->ntrips || trip < 0) + if (trip >=3D tz->ntrips || trip < 0) return -EDOM; =20 if (data->ops && data->ops->set_trip_temp) { @@ -313,7 +297,7 @@ static int of_thermal_set_trip_temp(struct thermal_zone= _device *tz, int trip, } =20 /* thermal framework should take care of data->mask & (1 << trip) */ - data->trips[trip].temperature =3D temp; + tz->trips[trip].temperature =3D temp; =20 return 0; } @@ -321,12 +305,10 @@ static int of_thermal_set_trip_temp(struct thermal_zo= ne_device *tz, int trip, static int of_thermal_get_trip_hyst(struct thermal_zone_device *tz, int tr= ip, int *hyst) { - struct __thermal_zone *data =3D tz->devdata; - - if (trip >=3D data->ntrips || trip < 0) + if (trip >=3D tz->ntrips || trip < 0) return -EDOM; =20 - *hyst =3D data->trips[trip].hysteresis; + *hyst =3D tz->trips[trip].hysteresis; =20 return 0; } @@ -334,13 +316,11 @@ static int of_thermal_get_trip_hyst(struct thermal_zo= ne_device *tz, int trip, static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int tr= ip, int hyst) { - struct __thermal_zone *data =3D tz->devdata; - - if (trip >=3D data->ntrips || trip < 0) + if (trip >=3D tz->ntrips || trip < 0) return -EDOM; =20 /* thermal framework should take care of data->mask & (1 << trip) */ - data->trips[trip].hysteresis =3D hyst; + tz->trips[trip].hysteresis =3D hyst; =20 return 0; } @@ -348,12 +328,11 @@ static int of_thermal_set_trip_hyst(struct thermal_zo= ne_device *tz, int trip, static int of_thermal_get_crit_temp(struct thermal_zone_device *tz, int *temp) { - struct __thermal_zone *data =3D tz->devdata; int i; =20 - for (i =3D 0; i < data->ntrips; i++) - if (data->trips[i].type =3D=3D THERMAL_TRIP_CRITICAL) { - *temp =3D data->trips[i].temperature; + for (i =3D 0; i < tz->ntrips; i++) + if (tz->trips[i].type =3D=3D THERMAL_TRIP_CRITICAL) { + *temp =3D tz->trips[i].temperature; return 0; } =20 --=20 2.25.1 From nobody Mon Jun 15 01:41:29 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 68BE3C433EF for ; Sat, 7 May 2022 12:56:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1446415AbiEGNA2 (ORCPT ); Sat, 7 May 2022 09:00:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1445470AbiEGM7T (ORCPT ); Sat, 7 May 2022 08:59:19 -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 36E09C1E for ; Sat, 7 May 2022 05:55:22 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id j15so13459983wrb.2 for ; Sat, 07 May 2022 05:55:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linexp-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uK+avJ+Fc4U1Ga3etjhF2701RA/xhtvy4kO7NRlkCh0=; b=5dt7w3FElgfiClR0goQtIOCz/YFEmg8Ot6QNGa8xFXFXKH339rh3U3/mE4mv59hKlU fTzwgMbKxg/F0yJNBTlGhALMebzD52DxaPkdyiPSnz7aFiJWbWvX22Nq6DwoEdGO6Tb7 7d5jZW24QKV5T9aoKg80BmhEjQ35IeJsYWse4vS0Tm55wh477gD1gvrLvoSC5lq0SqKx ki38fjdzcp+kzZoyr4akDmx48k40aY40suAAANSlDf6k3p2Au62T9KDHH/g5ZMD4goLj B1U6EqIkymANSEDirKOKyhYGRiX7xyk4v548Stu5R7EzANpIplYgOqn5fFN/IvwgRdGC Wn1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uK+avJ+Fc4U1Ga3etjhF2701RA/xhtvy4kO7NRlkCh0=; b=k8nlrZVU2CliUt5w7d7oH4AExmWrXgQ5HfqjcwBZiWDqdL5fxMi+uEA+EUOYh5E0NR SGAPJFRKqOzjKwwYT3hh+qCG/HoqVZaGjA1utyY3E0+0QDfVaAH4hjd8YoCsxY23axQ0 oPcyqxAhs7+zm0nfo6wiay+fu7c4kBhet6N+e8giXQ8Px2y/0qS64W3HVwGCtJhpfSbh bGcGAF5hZWHnD/hEHSt6RO0u5iHMiWIdawZ0/czvUf8WaB+SjG0WWwW89p+dStaZPDfn elFDsOerDa4TlGHY+zrFCYl86qoslJIDlmkiAIybrSCSBVUq5OJpCvYQOr8kSxOdUd0H +ZCw== X-Gm-Message-State: AOAM533fO7YJbWXBmT2LrMmQzQaaDGfBK0VLiQuDd18FsNa67ZgDzCkJ 92tBSPEDjLn5sGqGWchAIkSM5A== X-Google-Smtp-Source: ABdhPJwCr2c+Ca883anoBDmg/lSekW6ek8XmHs2hS+jmDoKUfMI7FpDBjxE0NfPgAWuS57k4xJtfrg== X-Received: by 2002:a5d:5887:0:b0:20c:83c9:b72 with SMTP id n7-20020a5d5887000000b0020c83c90b72mr6558172wrf.588.1651928122387; Sat, 07 May 2022 05:55:22 -0700 (PDT) Received: from localhost.localdomain (static-176-182-171-101.ncc.abo.bbox.fr. [176.182.171.101]) by smtp.gmail.com with ESMTPSA id e9-20020a05600c218900b0039453fe55a7sm10470345wme.35.2022.05.07.05.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 May 2022 05:55:22 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Zhang Rui Subject: [PATCH v2 14/14] thermal/of: Initialize trip points separately Date: Sat, 7 May 2022 14:54:42 +0200 Message-Id: <20220507125443.2766939-15-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220507125443.2766939-1-daniel.lezcano@linexp.org> References: <20220507125443.2766939-1-daniel.lezcano@linexp.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" Self contain the trip initialization from the device tree in a single function for the sake of making the code flow more clear. Cc: Alexandre Bailon Cc: Kevin Hilman Cc; Eduardo Valentin Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_of.c | 84 ++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 27 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 64e5b9e92cb1..fd55e895258c 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -681,7 +681,8 @@ static int of_find_trip_id(struct device_node *np, stru= ct device_node *trip) * * Return: 0 on success, proper error code otherwise */ -static int thermal_of_populate_bind_params(struct device_node *np, +static int thermal_of_populate_bind_params(struct device_node *tz_np, + struct device_node *np, struct __thermal_bind_params *__tbp) { struct of_phandle_args cooling_spec; @@ -703,7 +704,7 @@ static int thermal_of_populate_bind_params(struct devic= e_node *np, return -ENODEV; } =20 - trip_id =3D of_find_trip_id(np, trip); + trip_id =3D of_find_trip_id(tz_np, trip); if (trip_id < 0) { ret =3D trip_id; goto end; @@ -837,6 +838,53 @@ static int thermal_of_populate_trip(struct device_node= *np, return 0; } =20 +static struct thermal_trip *thermal_of_trips_init(struct device_node *np, = int *ntrips) +{ + struct thermal_trip *tt; + struct device_node *trips, *trip; + int ret, count; + + trips =3D of_get_child_by_name(np, "trips"); + if (!trips) { + pr_err("Failed to find 'trips' node\n"); + return ERR_PTR(-EINVAL); + } + + count =3D of_get_child_count(trips); + if (!count) { + pr_err("No trip point defined\n"); + ret =3D -EINVAL; + goto out_of_node_put; + } + + tt =3D kzalloc(sizeof(*tt) * count, GFP_KERNEL); + if (!tt) { + ret =3D -ENOMEM; + goto out_of_node_put; + } + + *ntrips =3D count; + + count =3D 0; + for_each_child_of_node(trips, trip) { + ret =3D thermal_of_populate_trip(trip, &tt[count++]); + if (ret) + goto out_kfree; + } + + of_node_put(trips); +=09 + return tt; +=09 +out_kfree: + kfree(tt); + *ntrips =3D 0; +out_of_node_put: + of_node_put(trips); + + return ERR_PTR(ret); +} + /** * thermal_of_build_thermal_zone - parse and fill one thermal zone data * @np: DT node containing a thermal zone node @@ -855,7 +903,6 @@ static struct __thermal_zone __init *thermal_of_build_thermal_zone(struct device_node *np) { struct device_node *child =3D NULL, *gchild; - struct device_node *trips; struct __thermal_zone *tz; int ret, i; u32 prop, coef[2]; @@ -897,28 +944,10 @@ __init *thermal_of_build_thermal_zone(struct device_n= ode *np) tz->offset =3D 0; } =20 - /* trips */ - trips =3D of_get_child_by_name(np, "trips"); - - /* No trips provided */ - if (!trips) - goto finish; - - tz->ntrips =3D of_get_child_count(trips); - if (tz->ntrips =3D=3D 0) /* must have at least one child */ + tz->trips =3D thermal_of_trips_init(np, &tz->ntrips); + if (IS_ERR(tz->trips)) { + ret =3D PTR_ERR(tz->trips); goto finish; - - tz->trips =3D kcalloc(tz->ntrips, sizeof(*tz->trips), GFP_KERNEL); - if (!tz->trips) { - ret =3D -ENOMEM; - goto free_tz; - } - - i =3D 0; - for_each_child_of_node(trips, gchild) { - ret =3D thermal_of_populate_trip(gchild, &tz->trips[i++]); - if (ret) - goto free_trips; } =20 /* cooling-maps */ @@ -940,9 +969,11 @@ __init *thermal_of_build_thermal_zone(struct device_no= de *np) =20 i =3D 0; for_each_child_of_node(child, gchild) { - ret =3D thermal_of_populate_bind_params(gchild, &tz->tbps[i++]); - if (ret) + ret =3D thermal_of_populate_bind_params(np, gchild, &tz->tbps[i++]); + if (ret) { + of_node_put(gchild); goto free_tbps; + } } =20 finish: @@ -964,7 +995,6 @@ __init *thermal_of_build_thermal_zone(struct device_nod= e *np) kfree(tz->tbps); free_trips: kfree(tz->trips); - of_node_put(gchild); free_tz: kfree(tz); of_node_put(child); --=20 2.25.1