From patchwork Tue Apr 26 22:15:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 566397 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 D703BC433EF for ; Tue, 26 Apr 2022 22:15:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355682AbiDZWSt (ORCPT ); Tue, 26 Apr 2022 18:18:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355680AbiDZWSs (ORCPT ); Tue, 26 Apr 2022 18:18:48 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 776942AE28 for ; Tue, 26 Apr 2022 15:15:38 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id bg25so125405wmb.4 for ; Tue, 26 Apr 2022 15:15:38 -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=Ig54l1xdqr17o4YvNAsqxn7MN0zhygiBhw+8D8uvy5E=; b=dl1pcaURJ+oaIQrxmVIgcznmvSDVpezVgPO19LGaSjxawy2+fzKC3OE//jVkiQzXUe 3xwJeXhSsXZWUcZR/L4EBkdqWiyHULtu7RytgP1JtccsjlD9YeR4BX5snlF0Tv0Ifkvb i/l/5VbWV1U+KnQ7m5/RLl7l7l0Wo0Kpe8yCPupr8GrLxvjzOggfHVLM+AtblLFBjKyQ vVMCNOskUbb5w4aMKYuLSc3iW0mkMcP7YqxiIvfYeHBS4SpopUmAj8cp+j64uGOu1Tq5 cCT49Q/HFXGmAxhhA49iXfOcniDr4LLdGVFMshRuLb941JrrluEBw0365eKiwSbBf1NY o8JQ== 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=Ig54l1xdqr17o4YvNAsqxn7MN0zhygiBhw+8D8uvy5E=; b=ooEIfA/hqW6VOniQv5Xo8+wkKEqNKviIp3Fu7fYCpia5tBrMnBC7rT6JgHhjQQkfiZ 4LI1iPxCDJWNvVqjGGnSw8zNvQ8dmpod/Y4Pg6pJE6Nk+L3VbaQTlPID/8JGTccW5OW8 SmNrhyJHeWAGOVLu50o0lmJ30I7kN67JE7Zv2Tthfjbmn9eQnHulnnc5UYGYSV3+8aoF YcVH+njY8lefYFz/98CehsoI1GKk/sysaeOgyhXoifLDRioTTFZ/oeEu2urC/NuK4U4O oykf27uI8SvBP6/j7wu4jiOsx0BF4tShEBPyB+Fq98RFO0xkmxbx43ZKCMcoIgGk6RC9 IMNA== X-Gm-Message-State: AOAM531BLFpGsFN/34vG8MyGTng8mwc1HlUOreYpTXGb2VasiHDePYxK rNFU9xnn7kKRk289Z/GSkqbxIQ== X-Google-Smtp-Source: ABdhPJwb5l7zjRviUym9EQUnpRUGZGDWN8M7EKz8cH3mKooKy3itU9ttAIs1wFadeLV3UVbIGL0gbg== X-Received: by 2002:a1c:f413:0:b0:37b:d1de:5762 with SMTP id z19-20020a1cf413000000b0037bd1de5762mr23391013wma.108.1651011336959; Tue, 26 Apr 2022 15:15:36 -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 j19-20020adfb313000000b0020aed8ece65sm393314wrd.32.2022.04.26.15.15.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 15:15:36 -0700 (PDT) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/15] thermal/core: Change thermal_zone_ops to thermal_sensor_ops Date: Wed, 27 Apr 2022 00:15:10 +0200 Message-Id: <20220426221523.3056696-3-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426221523.3056696-1-daniel.lezcano@linexp.org> References: <20220426221523.3056696-1-daniel.lezcano@linexp.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 --- 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 113afc8c5479..6d207d89f736 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 *thermal_zone_register(char *type, int trips, int mask, void *devdata, - struct thermal_zone_ops *ops, + struct thermal_sensor_ops *ops, const struct thermal_zone_params *tzp, int passive_delay, int polling_delay)) diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 23373af58565..253089214185 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -774,7 +774,7 @@ acpi_thermal_unbind_cooling_device(struct thermal_zone *thermal, return acpi_thermal_cooling_device_cb(thermal, cdev, false); } -static struct thermal_zone_ops acpi_thermal_zone_ops = { +static struct thermal_sensor_ops acpi_thermal_sensor_ops = { .bind = acpi_thermal_bind_cooling_device, .unbind = acpi_thermal_unbind_cooling_device, .get_temp = 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 = thermal_zone_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 = thermal_zone_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/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c index 460a26699f68..92d8a63e48a9 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_zone *tzdev, return 0; } -static struct thermal_zone_ops cxgb4_thermal_ops = { +static struct thermal_sensor_ops cxgb4_thermal_ops = { .get_temp = cxgb4_thermal_get_temp, .get_trip_type = cxgb4_thermal_get_trip_type, .get_trip_temp = cxgb4_thermal_get_trip_temp, diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c index f70ca5525202..5c8d79103e76 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 = { .no_hwmon = true, }; -static struct thermal_zone_ops mlxsw_thermal_ops = { +static struct thermal_sensor_ops mlxsw_thermal_ops = { .bind = mlxsw_thermal_bind, .unbind = mlxsw_thermal_unbind, .get_temp = mlxsw_thermal_get_temp, @@ -553,7 +553,7 @@ static int mlxsw_thermal_module_trend_get(struct thermal_zone *tzdev, return 0; } -static struct thermal_zone_ops mlxsw_thermal_module_ops = { +static struct thermal_sensor_ops mlxsw_thermal_module_ops = { .bind = mlxsw_thermal_module_bind, .unbind = mlxsw_thermal_module_unbind, .get_temp = mlxsw_thermal_module_temp_get, @@ -590,7 +590,7 @@ static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone *tzdev, return 0; } -static struct thermal_zone_ops mlxsw_thermal_gearbox_ops = { +static struct thermal_sensor_ops mlxsw_thermal_gearbox_ops = { .bind = mlxsw_thermal_module_bind, .unbind = mlxsw_thermal_module_unbind, .get_temp = mlxsw_thermal_gearbox_temp_get, diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c index e20e5e46d342..09c691efd08a 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_zone *device, return ret; } -static struct thermal_zone_ops tzone_ops = { +static struct thermal_sensor_ops tzone_ops = { .get_temp = iwl_mvm_tzone_get_temp, .get_trip_temp = iwl_mvm_tzone_get_trip_temp, .get_trip_type = iwl_mvm_tzone_get_trip_type, diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c index f6be06d1e723..a2b081f8013f 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 *thermal, } /* bind callback functions to thermalzone */ -static struct thermal_zone_ops acerhdf_dev_ops = { +static struct thermal_sensor_ops acerhdf_dev_ops = { .bind = acerhdf_bind, .unbind = acerhdf_unbind, .get_temp = acerhdf_get_ec_temp, diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index 51b052774478..4af288168837 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 *tzd, return ret; } -static struct thermal_zone_ops psy_tzd_ops = { +static struct thermal_sensor_ops psy_tzd_ops = { .get_temp = power_supply_read_temp, }; diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c index 18707f34df1b..4ec5ebd8bc09 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 *thermal, return ret; } -static struct thermal_zone_ops legacy_ops = { +static struct thermal_sensor_ops legacy_ops = { .get_temp = armada_get_temp_legacy, }; diff --git a/drivers/thermal/da9062-thermal.c b/drivers/thermal/da9062-thermal.c index acabb93a5140..77862f8222cd 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 *z, return 0; } -static struct thermal_zone_ops da9062_thermal_ops = { +static struct thermal_sensor_ops da9062_thermal_ops = { .get_temp = da9062_thermal_get_temp, .get_trip_type = da9062_thermal_get_trip_type, .get_trip_temp = da9062_thermal_get_trip_temp, diff --git a/drivers/thermal/dove_thermal.c b/drivers/thermal/dove_thermal.c index 59a6adefde2f..f0e94e7a4292 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 *thermal, return 0; } -static struct thermal_zone_ops ops = { +static struct thermal_sensor_ops ops = { .get_temp = dove_get_temp, }; diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index f0cf4a6c6bc0..835cb99ddd78 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -418,7 +418,7 @@ static int imx_unbind(struct thermal_zone *tz, return 0; } -static struct thermal_zone_ops imx_tz_ops = { +static struct thermal_sensor_ops imx_tz_ops = { .bind = imx_bind, .unbind = imx_unbind, .get_temp = imx_get_temp, diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c index 12b0452b3142..135b59e15399 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_zone *thermal, return result; } -static struct thermal_zone_ops int3400_thermal_ops = { +static struct thermal_sensor_ops int3400_thermal_ops = { .get_temp = int3400_thermal_get_temp, .change_mode = 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 90c060c0e97f..d726fb7c846f 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_zone *zone) dev_dbg(&zone->device, "%s: critical temperature reached\n", zone->type); } -static struct thermal_zone_ops int340x_thermal_zone_ops = { +static struct thermal_sensor_ops int340x_thermal_sensor_ops = { .get_temp = int340x_thermal_get_zone_temp, .get_trip_temp = int340x_thermal_get_trip_temp, .get_trip_type = int340x_thermal_get_trip_type, @@ -217,7 +217,7 @@ static struct thermal_zone_params int340x_thermal_params = { }; struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev, - struct thermal_zone_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(struct 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 f6be7d8f59d5..01ce3415d4fd 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 *zone; - struct thermal_zone_ops *override_ops; + struct thermal_sensor_ops *override_ops; void *priv_data; struct acpi_lpat_conversion_table *lpat_table; }; struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *, - struct thermal_zone_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); diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c index 1da96d5f30c3..c60e466809ef 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_zone *zone, return ret; } -static struct thermal_zone_ops proc_thermal_local_ops = { +static struct thermal_sensor_ops proc_thermal_local_ops = { .get_temp = proc_thermal_get_zone_temp, }; @@ -285,7 +285,7 @@ int proc_thermal_add(struct device *dev, struct proc_thermal_device *proc_priv) struct acpi_device *adev; acpi_status status; unsigned long long tmp; - struct thermal_zone_ops *ops = NULL; + struct thermal_sensor_ops *ops = NULL; int ret; adev = 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 55f1c23d1235..f70f85ad752a 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 *tzd, int trip, int temp) return 0; } -static struct thermal_zone_ops tzone_ops = { +static struct thermal_sensor_ops tzone_ops = { .get_temp = sys_get_curr_temp, .get_trip_temp = sys_get_trip_temp, .get_trip_type = sys_get_trip_type, diff --git a/drivers/thermal/intel/intel_pch_thermal.c b/drivers/thermal/intel/intel_pch_thermal.c index 596949da0e7e..7f0118c23251 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 *tzd) dev_dbg(&tzd->device, "%s: critical temperature reached\n", tzd->type); } -static struct thermal_zone_ops tzd_ops = { +static struct thermal_sensor_ops tzd_ops = { .get_temp = pch_thermal_get_temp, .get_trip_type = pch_get_trip_type, .get_trip_temp = pch_get_trip_temp, diff --git a/drivers/thermal/intel/intel_quark_dts_thermal.c b/drivers/thermal/intel/intel_quark_dts_thermal.c index ad992fabb6ba..1744f81caf8b 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 *tzd, return ret; } -static struct thermal_zone_ops tzone_ops = { +static struct thermal_sensor_ops tzone_ops = { .get_temp = sys_get_curr_temp, .get_trip_temp = sys_get_trip_temp, .get_trip_type = sys_get_trip_type, diff --git a/drivers/thermal/intel/intel_soc_dts_iosf.c b/drivers/thermal/intel/intel_soc_dts_iosf.c index c395bafd4fef..5e6d8d92f1bb 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 *tzd, return 0; } -static struct thermal_zone_ops tzone_ops = { +static struct thermal_sensor_ops tzone_ops = { .get_temp = sys_get_curr_temp, .get_trip_temp = sys_get_trip_temp, .get_trip_type = 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 418e99a0f999..ab695aed96a5 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 *thermal, int trip, } /* Thermal zone callback registry */ -static struct thermal_zone_ops tzone_ops = { +static struct thermal_sensor_ops tzone_ops = { .get_temp = sys_get_curr_temp, .get_trip_temp = sys_get_trip_temp, .get_trip_type = sys_get_trip_type, diff --git a/drivers/thermal/kirkwood_thermal.c b/drivers/thermal/kirkwood_thermal.c index e4133fb20f1b..4da621d7bcb9 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 *thermal, return 0; } -static struct thermal_zone_ops ops = { +static struct thermal_sensor_ops ops = { .get_temp = kirkwood_get_temp, }; diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index ea296b0b02f3..a60a16b7be06 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_thermal_zone_of_ops = { .get_temp = rcar_thermal_of_get_temp, }; -static struct thermal_zone_ops rcar_thermal_zone_ops = { +static struct thermal_sensor_ops rcar_thermal_sensor_ops = { .get_temp = rcar_thermal_get_temp, .get_trip_type = rcar_thermal_get_trip_type, .get_trip_temp = rcar_thermal_get_trip_temp, @@ -534,7 +534,7 @@ static int rcar_thermal_probe(struct platform_device *pdev) priv->zone = thermal_zone_register( "rcar_thermal", 1, 0, priv, - &rcar_thermal_zone_ops, NULL, 0, + &rcar_thermal_sensor_ops, NULL, 0, idle); ret = thermal_zone_enable(priv->zone); diff --git a/drivers/thermal/spear_thermal.c b/drivers/thermal/spear_thermal.c index 0f4492ab927c..d32b3b0976df 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 *thermal, return 0; } -static struct thermal_zone_ops ops = { +static struct thermal_sensor_ops ops = { .get_temp = thermal_get_temp, }; diff --git a/drivers/thermal/st/st_thermal.c b/drivers/thermal/st/st_thermal.c index 97f2d8c3493a..1a09c7d24d82 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 *th, return 0; } -static struct thermal_zone_ops st_tz_ops = { +static struct thermal_sensor_ops st_tz_ops = { .get_temp = st_thermal_get_temp, .get_trip_type = st_thermal_get_trip_type, .get_trip_temp = st_thermal_get_trip_temp, diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 64f736b9e877..d0eef7297c99 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1184,7 +1184,7 @@ static void bind_tz(struct thermal_zone *tz) */ struct thermal_zone * thermal_zone_register(const char *type, int trips, int mask, - void *devdata, struct thermal_zone_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 f29d4f99522a..8d958bec69d9 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 *tz, return -EINVAL; } -static struct thermal_zone_ops of_thermal_ops = { +static struct thermal_sensor_ops of_thermal_ops = { .get_trip_type = of_thermal_get_trip_type, .get_trip_temp = of_thermal_get_trip_temp, .set_trip_temp = 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_ops *ops; + struct thermal_sensor_ops *ops; np = of_find_node_by_name(NULL, "thermal-zones"); if (!np) { diff --git a/include/linux/thermal.h b/include/linux/thermal.h index c599b7f8c9c5..06b6b743d5c4 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 */ }; -struct thermal_zone_ops { +struct thermal_sensor_ops { int (*bind) (struct thermal_zone *, struct thermal_cooling_device *); int (*unbind) (struct thermal_zone *, @@ -164,7 +164,7 @@ struct thermal_zone { int prev_low_trip; int prev_high_trip; atomic_t need_update; - struct thermal_zone_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 device *dev, #ifdef CONFIG_THERMAL struct thermal_zone *thermal_zone_register(const char *, int, int, - void *, struct thermal_zone_ops *, + void *, struct thermal_sensor_ops *, struct thermal_zone_params *, int, int); void thermal_zone_unregister(struct thermal_zone *); @@ -396,7 +396,7 @@ void thermal_zone_critical(struct thermal_zone *tz); #else static inline struct thermal_zone *thermal_zone_register( const char *type, int trips, int mask, void *devdata, - struct thermal_zone_ops *ops, + struct thermal_sensor_ops *ops, struct thermal_zone_params *tzp, int passive_delay, int polling_delay) { return ERR_PTR(-ENODEV); } From patchwork Tue Apr 26 22:15:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 566395 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 0C2DBC433FE for ; Tue, 26 Apr 2022 22:15:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355690AbiDZWS7 (ORCPT ); Tue, 26 Apr 2022 18:18:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355688AbiDZWSu (ORCPT ); Tue, 26 Apr 2022 18:18:50 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47B4D27CD3 for ; Tue, 26 Apr 2022 15:15:39 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id w4so27283384wrg.12 for ; Tue, 26 Apr 2022 15:15:39 -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=UGb/PghyfnVsqwJwviGzwvr95Mi6vW3yxA69Jls+3RM=; b=j/Z5rS9v7N18vfRM4FN3BKOCZJk907QaadhaQ3SyamQgNTCY35qicLhX/Xs2mWhDeJ EoMgr9m3365B26SZfcg9RrCy35LnfIN4PIqQ4xm4XxJY+fo9xeVGtlznAlImtb2wWL7J B83Bm1JB2034XpbxMcwt9sMgfGFirzQmaDTZjtdjN63Fwh2Lj4GI0/ZwmHXeofL3jMaA E04eCSKcqtsXPiV9LgK8YA6wEgd6o+mzRutp8TgRkRa0KYVHoV6N394oBLZcxLSTuSKs yr+JcGN+DxzQ+kVspcycdyIADstw1pB3R5C06AxsQP46byJG1sVyyS/+GF2tQhDs8M3S xUCg== 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=UGb/PghyfnVsqwJwviGzwvr95Mi6vW3yxA69Jls+3RM=; b=yDQv64yD4/Dy3bojam5AKeQ4JdoFbFCD7JerhUW4L/Gw0CjceBjkjxe4ar1BFnkhbp 9TiFeNVoSSD6AdABu0AfAE/HEiOmSMrkCLp03GZ4fjAgMc0SvNRmgtqeO8szPdnqSVfK R+3aG2+dPO8lFSebbwgw2jS/SQF+iGq3ySvWlJQB1XZhI8xVGodNUQdVS8LySNkqW4wN KAaVGyHwe94IuzaINgn0ZmEOjiRptxqrH19dWZpqPyEM36h9tXELdu/rsQ5VoilsGtFR d5KpbC0tWJ25D3WTTYqQrG0RoIxIbv7Vsr/R+Io/ifli8bM8NCLBh2cIqMH7nzFG42SQ l6Rw== X-Gm-Message-State: AOAM533X0tdoNtuxKpk9Dw2uXeyO/I29XQWI4OB0Bl55axH+CXIaSdpn XslAQY4LqxCPEE3UvcNOghwdQA== X-Google-Smtp-Source: ABdhPJwoVDkQkM9LXc3pdLoQgpULWMLEHnsfC+hWODHW3qgIZu49dmBH7dJTb9nbEp9xFyhRccgiUw== X-Received: by 2002:a5d:614c:0:b0:20a:e4cd:f7c2 with SMTP id y12-20020a5d614c000000b0020ae4cdf7c2mr4507457wrt.382.1651011337703; Tue, 26 Apr 2022 15:15:37 -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 j19-20020adfb313000000b0020aed8ece65sm393314wrd.32.2022.04.26.15.15.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 15:15:37 -0700 (PDT) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/15] thermal/core: Add a thermal sensor structure in the thermal zone Date: Wed, 27 Apr 2022 00:15:11 +0200 Message-Id: <20220426221523.3056696-4-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426221523.3056696-1-daniel.lezcano@linexp.org> References: <20220426221523.3056696-1-daniel.lezcano@linexp.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 --- 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/broadcom/bcm2835_thermal.c index b057d7a921da..9f274a017d32 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 = tz->ops->get_trip_temp(tz, 0, &trip_temp); + err = 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_bang.c index c899d16c23a0..02ef6a9b03eb 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_zone *tz, int trip) int trip_temp, trip_hyst; struct thermal_instance *instance; - tz->ops->get_trip_temp(tz, trip, &trip_temp); + tz->sensor.ops->get_trip_temp(tz, trip, &trip_temp); - 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 = 0; } else - tz->ops->get_trip_hyst(tz, trip, &trip_hyst); + tz->sensor.ops->get_trip_hyst(tz, trip, &trip_hyst); dev_dbg(&tz->device, "Trip%d[temp=%d]:temp=%d:hyst=%d\n", trip, trip_temp, tz->temperature, diff --git a/drivers/thermal/gov_fair_share.c b/drivers/thermal/gov_fair_share.c index b039df7ab506..3ce42a8e9dbd 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 *tz) int trip_temp; enum thermal_trip_type trip_type; - if (tz->trips == 0 || !tz->ops->get_trip_temp) + if (tz->trips == 0 || !tz->sensor.ops->get_trip_temp) return 0; for (count = 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 *tz) * point, in which case, trip_point = 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); } diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index dbb4c263eaaf..448baaa642a5 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 *tz, u32 temperature_threshold; s32 k_i; - ret = tz->ops->get_trip_temp(tz, trip_switch_on, &switch_on_temp); + ret = tz->sensor.ops->get_trip_temp(tz, trip_switch_on, &switch_on_temp); if (ret) switch_on_temp = 0; @@ -531,7 +531,7 @@ static void get_governor_trips(struct thermal_zone *tz, enum thermal_trip_type type; int ret; - ret = tz->ops->get_trip_type(tz, i, &type); + ret = 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 *tz) get_governor_trips(tz, params); if (tz->trips > 0) { - ret = tz->ops->get_trip_temp(tz, - params->trip_max_desired_temperature, - &control_temp); + ret = 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 *tz, int trip) if (trip != params->trip_max_desired_temperature) return 0; - ret = tz->ops->get_trip_temp(tz, params->trip_switch_on, - &switch_on_temp); + ret = tz->sensor.ops->get_trip_temp(tz, params->trip_switch_on, + &switch_on_temp); if (!ret && (tz->temperature < switch_on_temp)) { update = (tz->last_temperature >= switch_on_temp); tz->passive = 0; @@ -731,8 +731,8 @@ static int power_allocator_throttle(struct thermal_zone *tz, int trip) tz->passive = 1; - ret = tz->ops->get_trip_temp(tz, params->trip_max_desired_temperature, - &control_temp); + ret = tz->sensor.ops->get_trip_temp(tz, params->trip_max_desired_temperature, + &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_wise.c index de6997fba8eb..88bc16d69f98 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_zone *tz, int trip) bool throttle = false; int old_target; - 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); trend = get_tz_trend(tz, trip); diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c index 0b03c2d48495..c2d71b1631b2 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 rcar_gen3_thermal_tsc *tsc) 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); @@ -349,7 +349,7 @@ static void rcar_gen3_thermal_init(struct rcar_gen3_thermal_tsc *tsc) 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); @@ -555,7 +555,7 @@ static int __maybe_unused rcar_gen3_thermal_resume(struct device *dev) struct thermal_zone *zone = tsc->zone; 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 02ba99395cd1..3260f0717299 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) } if (data->soc != SOC_ARCH_EXYNOS5433) /* FIXME */ - ret = tzd->ops->get_crit_temp(tzd, &temp); + ret = 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_device *pdev) /* Write temperature code for rising and falling threshold */ for (i = 0; i < ntrips; i++) { /* Write temperature code for rising threshold */ - ret = tzd->ops->get_trip_temp(tzd, i, &temp); + ret = tzd->sensor.ops->get_trip_temp(tzd, i, &temp); if (ret) goto err; temp /= MCELSIUS; data->tmu_set_trip_temp(data, i, temp); /* Write temperature code for falling threshold */ - ret = tzd->ops->get_trip_hyst(tzd, i, &hyst); + ret = tzd->sensor.ops->get_trip_hyst(tzd, i, &hyst); if (ret) goto err; hyst /= MCELSIUS; diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index 43435e3892dd..6d9dff7cedd1 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; - ret = tz->ops->get_trip_type(tz, trip, &type); + ret = tz->sensor.ops->get_trip_type(tz, trip, &type); if (ret) return ret; @@ -643,7 +643,7 @@ static int tegra_thermctl_get_trend(void *data, int trip, if (!tz) return -EINVAL; - ret = tz->ops->get_trip_temp(zone->tz, trip, &trip_temp); + ret = tz->sensor.ops->get_trip_temp(zone->tz, trip, &trip_temp); if (ret) return ret; @@ -730,11 +730,11 @@ static int get_hot_temp(struct thermal_zone *tz, int *trip, int *temp) return -EINVAL; for (i = 0; i < ntrips; i++) { - ret = tz->ops->get_trip_type(tz, i, &type); + ret = tz->sensor.ops->get_trip_type(tz, i, &type); if (ret) return -EINVAL; if (type == THERMAL_TRIP_HOT) { - ret = tz->ops->get_trip_temp(tz, i, temp); + ret = tz->sensor.ops->get_trip_temp(tz, i, temp); if (!ret) *trip = i; @@ -780,7 +780,7 @@ static int tegra_soctherm_set_hwtrips(struct device *dev, /* Get thermtrips. If missing, try to get critical trips. */ temperature = tsensor_group_thermtrip_get(ts, sg->id); if (min_low_temp == temperature) - if (tz->ops->get_crit_temp(tz, &temperature)) + if (tz->sensor.ops->get_crit_temp(tz, &temperature)) temperature = max_high_temp; ret = thermtrip_program(dev, sg, temperature); diff --git a/drivers/thermal/tegra/tegra30-tsensor.c b/drivers/thermal/tegra/tegra30-tsensor.c index 80053571c53a..ad35a9694845 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 thermal_zone *tzd, enum thermal_trip_type type; int trip_temp; - 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); if (type == THERMAL_TRIP_HOT) *hot_trip = trip_temp; diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index d0eef7297c99..b1d20c8ba3d1 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 *tz, { int trip_temp; - tz->ops->get_trip_temp(tz, trip, &trip_temp); + tz->sensor.ops->get_trip_temp(tz, trip, &trip_temp); /* If we have not crossed the trip_temp, we do not care. */ if (trip_temp <= 0 || tz->temperature < trip_temp) @@ -352,10 +352,10 @@ static void handle_critical_trips(struct thermal_zone *tz, trace_thermal_zone_trip(tz, trip, trip_type); - if (trip_type == THERMAL_TRIP_HOT && tz->ops->hot) - tz->ops->hot(tz); + if (trip_type == THERMAL_TRIP_HOT && tz->sensor.ops->hot) + tz->sensor.ops->hot(tz); else if (trip_type == THERMAL_TRIP_CRITICAL) - tz->ops->critical(tz); + tz->sensor.ops->critical(tz); } static void handle_thermal_trip(struct thermal_zone *tz, int trip) @@ -367,10 +367,10 @@ static void handle_thermal_trip(struct thermal_zone *tz, int trip) if (test_bit(trip, &tz->trips_disabled)) return; - 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); if (tz->last_temperature != THERMAL_TEMP_INVALID) { if (tz->last_temperature < trip_temp && @@ -441,8 +441,8 @@ static int thermal_zone_set_mode(struct thermal_zone *tz, return ret; } - if (tz->ops->change_mode) - ret = tz->ops->change_mode(tz, mode); + if (tz->sensor.ops->change_mode) + ret = tz->sensor.ops->change_mode(tz, mode); if (!ret) tz->mode = mode; @@ -495,7 +495,7 @@ void thermal_zone_update(struct thermal_zone *tz, if (atomic_read(&in_suspend)) return; - 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; @@ -839,11 +839,11 @@ static void bind_cdev(struct thermal_cooling_device *cdev) mutex_lock(&thermal_list_lock); list_for_each_entry(pos, &thermal_tz_list, node) { - if (!pos->tzp && !pos->ops->bind) + if (!pos->tzp && !pos->sensor.ops->bind) continue; - if (pos->ops->bind) { - ret = pos->ops->bind(pos, cdev); + if (pos->sensor.ops->bind) { + ret = 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) /* 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; } @@ -1124,15 +1124,15 @@ static void bind_tz(struct thermal_zone *tz) struct thermal_cooling_device *pos = NULL; const struct thermal_zone_params *tzp = tz->tzp; - if (!tzp && !tz->ops->bind) + if (!tzp && !tz->sensor.ops->bind) return; mutex_lock(&thermal_list_lock); /* 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 = tz->ops->bind(tz, pos); + ret = tz->sensor.ops->bind(tz, pos); if (ret) print_bind_err_msg(tz, pos, ret); } @@ -1243,7 +1243,7 @@ thermal_zone_register(const char *type, int trips, int mask, if (!ops->critical) ops->critical = thermal_zone_critical; - tz->ops = ops; + tz->sensor.ops = ops; tz->tzp = tzp; tz->device.class = &thermal_class; tz->devdata = devdata; @@ -1266,8 +1266,8 @@ thermal_zone_register(const char *type, int trips, int mask, goto release_device; for (count = 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_unregister(struct thermal_zone *tz) /* 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; } diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_helpers.c index 841cb3f43036..41d6898ec5b3 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -27,8 +27,8 @@ int get_tz_trend(struct thermal_zone *tz, int trip) { enum thermal_trend trend; - 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 = THERMAL_TREND_RAISING; else if (tz->temperature < tz->last_temperature) @@ -82,19 +82,19 @@ int thermal_zone_get_temp(struct thermal_zone *tz, int *temp) int crit_temp = INT_MAX; enum thermal_trip_type type; - if (!tz || IS_ERR(tz) || !tz->ops->get_temp) + if (!tz || IS_ERR(tz) || !tz->sensor.ops->get_temp) goto exit; mutex_lock(&tz->lock); - ret = tz->ops->get_temp(tz, temp); + ret = tz->sensor.ops->get_temp(tz, temp); if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) { for (count = 0; count < tz->trips; count++) { - ret = tz->ops->get_trip_type(tz, count, &type); + ret = tz->sensor.ops->get_trip_type(tz, count, &type); if (!ret && type == THERMAL_TRIP_CRITICAL) { - ret = tz->ops->get_trip_temp(tz, count, - &crit_temp); + ret = tz->sensor.ops->get_trip_temp(tz, count, + &crit_temp); break; } } @@ -135,14 +135,14 @@ void thermal_zone_set_trips(struct thermal_zone *tz) mutex_lock(&tz->lock); - if (!tz->ops->set_trips || !tz->ops->get_trip_hyst) + if (!tz->sensor.ops->set_trips || !tz->sensor.ops->get_trip_hyst) goto exit; for (i = 0; i < tz->trips; i++) { int trip_low; - 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); trip_low = trip_temp - hysteresis; @@ -167,7 +167,7 @@ void thermal_zone_set_trips(struct thermal_zone *tz) * Set a temperature window. When this window is left the driver * must inform the thermal core via thermal_zone_update. */ - ret = tz->ops->set_trips(tz, low, high); + ret = tz->sensor.ops->set_trips(tz, low, high); if (ret) dev_err(&tz->device, "Failed to set trips: %d\n", ret); diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c index bdf5639fe214..c0900750735f 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_attribute *attr, char *buf) int temperature; int ret; - ret = tz->ops->get_crit_temp(tz, &temperature); + ret = tz->sensor.ops->get_crit_temp(tz, &temperature); if (ret) return ret; @@ -126,7 +126,7 @@ thermal_hwmon_lookup_temp(const struct thermal_hwmon_device *hwmon, static bool thermal_zone_crit_temp_valid(struct thermal_zone *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); } int thermal_add_hwmon_sysfs(struct thermal_zone *tz) diff --git a/drivers/thermal/thermal_netlink.c b/drivers/thermal/thermal_netlink.c index 88c28c5205b8..0e95f113d525 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 = 0; - tz->ops->get_trip_type(tz, i, &type); - tz->ops->get_trip_temp(tz, i, &temp); - if (tz->ops->get_trip_hyst) - tz->ops->get_trip_hyst(tz, i, &hyst); + 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); 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 8d958bec69d9..932b6450eac4 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 = ops; tz->sensor_data = data; - tzd->ops->get_temp = of_thermal_get_temp; - tzd->ops->get_trend = of_thermal_get_trend; + tzd->sensor.ops->get_temp = of_thermal_get_temp; + tzd->sensor.ops->get_trend = of_thermal_get_trend; /* * 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 = of_thermal_set_trips; + tzd->sensor.ops->set_trips = of_thermal_set_trips; if (ops->set_emul_temp) - tzd->ops->set_emul_temp = of_thermal_set_emul_temp; + tzd->sensor.ops->set_emul_temp = of_thermal_set_emul_temp; mutex_unlock(&tzd->lock); @@ -566,9 +566,9 @@ void thermal_zone_of_sensor_unregister(struct device *dev, thermal_zone_disable(tzd); mutex_lock(&tzd->lock); - tzd->ops->get_temp = NULL; - tzd->ops->get_trend = NULL; - tzd->ops->set_emul_temp = NULL; + tzd->sensor.ops->get_temp = NULL; + tzd->sensor.ops->get_trend = NULL; + tzd->sensor.ops->set_emul_temp = NULL; tz->ops = NULL; tz->sensor_data = NULL; @@ -1024,7 +1024,7 @@ static __init void of_thermal_destroy_zones(void) thermal_zone_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_sysfs.c index 083578e736cc..33d8c9f47990 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; - if (!tz->ops->get_trip_type) + if (!tz->sensor.ops->get_trip_type) return -EPERM; if (sscanf(attr->attr.name, "trip_point_%d_type", &trip) != 1) return -EINVAL; - result = tz->ops->get_trip_type(tz, trip, &type); + result = tz->sensor.ops->get_trip_type(tz, trip, &type); if (result) return result; @@ -115,7 +115,7 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr, int temperature, hyst = 0; enum thermal_trip_type type; - if (!tz->ops->set_trip_temp) + if (!tz->sensor.ops->set_trip_temp) return -EPERM; if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip) != 1) @@ -124,17 +124,17 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr, if (kstrtoint(buf, 10, &temperature)) return -EINVAL; - ret = tz->ops->set_trip_temp(tz, trip, temperature); + ret = tz->sensor.ops->set_trip_temp(tz, trip, temperature); if (ret) return ret; - if (tz->ops->get_trip_hyst) { - ret = tz->ops->get_trip_hyst(tz, trip, &hyst); + if (tz->sensor.ops->get_trip_hyst) { + ret = tz->sensor.ops->get_trip_hyst(tz, trip, &hyst); if (ret) return ret; } - ret = tz->ops->get_trip_type(tz, trip, &type); + ret = tz->sensor.ops->get_trip_type(tz, trip, &type); if (ret) return ret; @@ -153,13 +153,13 @@ trip_point_temp_show(struct device *dev, struct device_attribute *attr, int trip, ret; int temperature; - if (!tz->ops->get_trip_temp) + if (!tz->sensor.ops->get_trip_temp) return -EPERM; if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip) != 1) return -EINVAL; - ret = tz->ops->get_trip_temp(tz, trip, &temperature); + ret = tz->sensor.ops->get_trip_temp(tz, trip, &temperature); if (ret) return ret; @@ -175,7 +175,7 @@ trip_point_hyst_store(struct device *dev, struct device_attribute *attr, int trip, ret; int temperature; - if (!tz->ops->set_trip_hyst) + if (!tz->sensor.ops->set_trip_hyst) return -EPERM; if (sscanf(attr->attr.name, "trip_point_%d_hyst", &trip) != 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 = tz->ops->set_trip_hyst(tz, trip, temperature); + ret = tz->sensor.ops->set_trip_hyst(tz, trip, temperature); if (!ret) thermal_zone_set_trips(tz); @@ -205,13 +205,13 @@ trip_point_hyst_show(struct device *dev, struct device_attribute *attr, int trip, ret; int temperature; - if (!tz->ops->get_trip_hyst) + if (!tz->sensor.ops->get_trip_hyst) return -EPERM; if (sscanf(attr->attr.name, "trip_point_%d_hyst", &trip) != 1) return -EINVAL; - ret = tz->ops->get_trip_hyst(tz, trip, &temperature); + ret = tz->sensor.ops->get_trip_hyst(tz, trip, &temperature); return ret ? ret : sprintf(buf, "%d\n", temperature); } @@ -260,12 +260,12 @@ emul_temp_store(struct device *dev, struct device_attribute *attr, if (kstrtoint(buf, 10, &temperature)) return -EINVAL; - if (!tz->ops->set_emul_temp) { + if (!tz->sensor.ops->set_emul_temp) { mutex_lock(&tz->lock); tz->emul_temperature = temperature; mutex_unlock(&tz->lock); } else { - ret = tz->ops->set_emul_temp(tz, temperature); + ret = tz->sensor.ops->set_emul_temp(tz, temperature); } if (!ret) @@ -431,7 +431,7 @@ static int create_trip_attrs(struct thermal_zone *tz, int mask) return -ENOMEM; } - if (tz->ops->get_trip_hyst) { + if (tz->sensor.ops->get_trip_hyst) { tz->trip_hyst_attrs = kcalloc(tz->trips, sizeof(*tz->trip_hyst_attrs), GFP_KERNEL); @@ -446,7 +446,7 @@ static int create_trip_attrs(struct thermal_zone *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 *tz, int mask) attrs[indx + tz->trips] = &tz->trip_temp_attrs[indx].attr.attr; /* 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 *tz, int mask) tz->trip_hyst_attrs[indx].name; tz->trip_hyst_attrs[indx].attr.attr.mode = S_IRUGO; tz->trip_hyst_attrs[indx].attr.show = 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 |= S_IWUSR; tz->trip_hyst_attrs[indx].attr.store = trip_point_hyst_store; @@ -519,7 +519,7 @@ static void destroy_trip_attrs(struct thermal_zone *tz) 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 06b6b743d5c4..b3e8244af510 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -80,6 +80,11 @@ struct thermal_sensor_ops { void (*critical)(struct thermal_zone *); }; +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 { 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; From patchwork Tue Apr 26 22:15:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 568733 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 543AFC433F5 for ; Tue, 26 Apr 2022 22:15:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355687AbiDZWSu (ORCPT ); Tue, 26 Apr 2022 18:18:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355681AbiDZWSt (ORCPT ); Tue, 26 Apr 2022 18:18:49 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D923E3D48D for ; Tue, 26 Apr 2022 15:15:39 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id n126-20020a1c2784000000b0038e8af3e788so132837wmn.1 for ; Tue, 26 Apr 2022 15:15:39 -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=ZL8cQRMvYoW7iggfJuWncj/joC9twZND0+x25qwoH6c=; b=vIv/sfg28J4s9ZRXG8ce+pZ6/Gte/6OUlaDOmsENoRGWyIwaQyQhn82Yb0xfZGVQTT qVWf8++HOggrmlnZb8197yhP1no66n++QDTtV7t+gHxLHvYbSEdFpKea338AhWuPBS2v DY7OJHfMNAUi7hyRFf09+x86nbPZWRYx9zywnc/SLl8wZjsetqdXFjL5myT8CFdzbdFa ade5E93IqRNUeZbuVarNZqDml/I3nqSNgvuiGaKdKEykIoRSkLdL7qOBYbJEKEeW25NK MbM8Gvl2rSUCLi9OfWpaZd62v7DWLFbuJ6hxIJqAldbYRtPQSSH4OeodDXWa4L/xpWzX JgmA== 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=ZL8cQRMvYoW7iggfJuWncj/joC9twZND0+x25qwoH6c=; b=gJXwoa+4UbzUL5RDcynduFRzeXH7bwi1cxoRORKSHdYLeW7ucCXcLYxAV00/SA9GRi XWFpZ2ITEa62E/TTWDOPjs9KxJUEXsRgbwCm0fioQ6RNIuo8pV/+2QzwH5CXFjIzZUR8 Gqfl3SD4Jv7v2Ef4JE3AoWYTe3tbXiLGXVcan2EFCtZATHk1Yyit7HwxOc+Gvy+mXzSU C9SeWkXMa64woEzhMTwbKYlK+TbPZSMKJYwHObEJGVHY41dw/4ByEIhfgLqCJwTXe5Ei i6Hz8NtmG8v5zqA32kGN6kcc4XbCz5GpQU1lfTnQUkKpLyJaaFfXGnwZiju1+FNCDE8Q RnZw== X-Gm-Message-State: AOAM532dwNko1BaZfsuNE1BvpzeZonO5VBeSxDs/rJoXhKPkLRHm+TLh VQL70EqIdgdLZuIUEeACblDciw== X-Google-Smtp-Source: ABdhPJxAiwUaSF3XnKZJ/Xp3/zDR6siV6vR4q0ZAtoXBUcAkn9EGWOba4zAMVz9Y/r2PkzicWqU3hA== X-Received: by 2002:a05:600c:4e8d:b0:393:ee69:ec42 with SMTP id f13-20020a05600c4e8d00b00393ee69ec42mr8859502wmq.21.1651011338432; Tue, 26 Apr 2022 15:15:38 -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 j19-20020adfb313000000b0020aed8ece65sm393314wrd.32.2022.04.26.15.15.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 15:15:38 -0700 (PDT) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/15] thermal/core: Remove duplicate information when an error occurs Date: Wed, 27 Apr 2022 00:15:12 +0200 Message-Id: <20220426221523.3056696-5-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426221523.3056696-1-daniel.lezcano@linexp.org> References: <20220426221523.3056696-1-daniel.lezcano@linexp.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 b1d20c8ba3d1..a34c8cb31e91 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1197,23 +1197,23 @@ thermal_zone_register(const char *type, int trips, int mask, struct thermal_governor *governor; if (!type || strlen(type) == 0) { - pr_err("Error: No thermal zone type defined\n"); + pr_err("No thermal zone type defined\n"); return ERR_PTR(-EINVAL); } if (type && strlen(type) >= 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); } 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); } 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); } From patchwork Tue Apr 26 22:15:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 566396 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 71893C4332F for ; Tue, 26 Apr 2022 22:15:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355681AbiDZWS7 (ORCPT ); Tue, 26 Apr 2022 18:18:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355690AbiDZWSu (ORCPT ); Tue, 26 Apr 2022 18:18:50 -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 8E5403F309 for ; Tue, 26 Apr 2022 15:15:40 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id u3so22746wrg.3 for ; Tue, 26 Apr 2022 15:15:40 -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=41FtLqXJtllH7xzlv+T0azZoKG0dXHd+GSbdHbIp2ZQ=; b=Qrx3aJq7oPrN3VOcAhWURj9uRchyOfXcnjt7XkCbjy86TY4IV44E9sNytIqUuD1LWW HcDGQd5fcaQGYVr+uK0U3/dH9gNrQNwtMpK0lX3SPYEDXV0EDF9ayFeieMYFlTR1xH6j 2Fpmnn3XNdjV54YfUaAtZve6ogxsiuHSd/RWwfQRAXsv/vfbPf+//Jz+J9ReVQ+TrBhk vSF99rMa203saHyDF9Lh1Qwc5M4SRc9JDEQ5HEKK1y51TBFJrXPg7CRj0pFTD9kM84A3 xUtjr6oxbPe1hfkiguGUn+awReJqWF86k76pYGgmMPCSs69F25PODV5piJYI1tSVpKZ/ eHbA== 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=41FtLqXJtllH7xzlv+T0azZoKG0dXHd+GSbdHbIp2ZQ=; b=1zdbXjpyMWsilWPyXRElWnzHYglUz58Sl8L8G+DbEtrvrvAAQcnaXkt1SNeUlj1LW0 t2KzYzNb+JJoRYpKjNF2HbagY9ACe0+Bq7rc3tdxiI2SqxvoaWflNYAMU1fhazb9ajNl RQ8I06+5rjcIqtScM4Ev4kIk0qznVRr7h15q4eJsHx4DiG23u3T+G3LutqTYX6MCXz9+ tYhYty1et/wkBM3XIyD8NVeOwxw9Hklh7PfJqlrtiQ5Iz6uJH8Mbz8R00UU84TC/Kjc8 EJSf8DFXez6ATe4r/lSeJ3lX39tInTcCfEV0vB9rxxX8SKkgqEPg4qqaLFsH7nsY4FGR 1PAQ== X-Gm-Message-State: AOAM532PejMsSgZvxpYQmkJqo3A/GpFLBm5kRE0ySx2KUJ/CFL1SBtj7 GLEYG11Uf8n4q5rwIme5CkWCTA== X-Google-Smtp-Source: ABdhPJxHFpPzEug/JTYETIxBAjfSmRQW5zreh13yKs3zUkckoRjpvcKR0axofcLLoAiexADnNr2okg== X-Received: by 2002:a5d:4d8e:0:b0:20a:c54d:242c with SMTP id b14-20020a5d4d8e000000b0020ac54d242cmr19795892wru.338.1651011339135; Tue, 26 Apr 2022 15:15:39 -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 j19-20020adfb313000000b0020aed8ece65sm393314wrd.32.2022.04.26.15.15.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 15:15:38 -0700 (PDT) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/15] thermal/of: Replace device node match with device node search Date: Wed, 27 Apr 2022 00:15:13 +0200 Message-Id: <20220426221523.3056696-6-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426221523.3056696-1-daniel.lezcano@linexp.org> References: <20220426221523.3056696-1-daniel.lezcano@linexp.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 932b6450eac4..84c37493e27f 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_unregister); /*** functions parsing device tree nodes ***/ +static int of_find_trip_id(struct device_node *np, struct device_node *trip) +{ + struct device_node *trips; + struct device_node *t; + int i = 0; + + trips = 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 == trip) + goto out; + i++; + } + + i = -ENXIO; +out: + 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_unregister); * 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; /* Default weight. Usage is optional */ @@ -696,18 +724,14 @@ static int thermal_of_populate_bind_params(struct device_node *np, return -ENODEV; } - /* match using device_node */ - for (i = 0; i < ntrips; i++) - if (trip == trips[i].np) { - __tbp->trip_id = i; - break; - } - - if (i == ntrips) { - ret = -ENODEV; + trip_id = of_find_trip_id(np, trip); + if (trip_id < 0) { + ret = trip_id; goto end; } + __tbp->trip_id = trip_id; + count = of_count_phandle_with_args(np, "cooling-device", "#cooling-cells"); if (count <= 0) { @@ -856,6 +880,7 @@ static struct __thermal_zone __init *thermal_of_build_thermal_zone(struct device_node *np) { struct device_node *child = 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_node *np) } /* trips */ - child = of_get_child_by_name(np, "trips"); + trips = of_get_child_by_name(np, "trips"); /* No trips provided */ - if (!child) + if (!trips) goto finish; - tz->ntrips = of_get_child_count(child); + tz->ntrips = of_get_child_count(trips); if (tz->ntrips == 0) /* must have at least one child */ goto finish; @@ -915,14 +940,12 @@ __init *thermal_of_build_thermal_zone(struct device_node *np) } i = 0; - for_each_child_of_node(child, gchild) { + for_each_child_of_node(trips, gchild) { ret = thermal_of_populate_trip(gchild, &tz->trips[i++]); if (ret) goto free_trips; } - of_node_put(child); - /* cooling-maps */ child = of_get_child_by_name(np, "cooling-maps"); @@ -942,8 +965,7 @@ __init *thermal_of_build_thermal_zone(struct device_node *np) i = 0; for_each_child_of_node(child, gchild) { - ret = thermal_of_populate_bind_params(gchild, &tz->tbps[i++], - tz->trips, tz->ntrips); + ret = thermal_of_populate_bind_params(gchild, &tz->tbps[i++]); if (ret) goto free_tbps; } From patchwork Tue Apr 26 22:15:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 568731 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 AD2B3C433F5 for ; Tue, 26 Apr 2022 22:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355731AbiDZWTC (ORCPT ); Tue, 26 Apr 2022 18:19:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355695AbiDZWSu (ORCPT ); Tue, 26 Apr 2022 18:18:50 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BB872A71F for ; Tue, 26 Apr 2022 15:15:41 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id l62-20020a1c2541000000b0038e4570af2fso119512wml.5 for ; Tue, 26 Apr 2022 15:15:41 -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=PKFq37+jBQUG7PdwWKpR4OxPd8aMc8UBMumPMt9R4Pk=; b=L2LdCALCPibioN3tG8c+IZzrOHR9G6AphfS81JFXtvhiUGV2wu6STMvbWKcz8TRvwC RS6HiyNPs0xjneXwyVjxrAqJzNQ74xUpONnanQr4injGFw64JRZaxOpIro4/gd7bKkpG k2TMYNFN0y+h+DHIPVcO1CKq807r+LRWNQsjXTlIlDnYntCWt0vw9PYpxbvFoBO/EDc5 g8B5ZN2v/neBEXChfNP0ZJTnvSG8NfRoJxN3JMV8GeTQwv2YoiRj9T8KAzc5EjlBW6HU OJTpDqxVcOctHcIWPGgUXWl85lSXxlv3R4ixDD21N/UiB9FaLqtjxETts+ZDVxuMekdK TkjA== 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=PKFq37+jBQUG7PdwWKpR4OxPd8aMc8UBMumPMt9R4Pk=; b=zl5VjBZpHSmWLyKfZa0rH/UuLe0C43knIcLUsvoBC4Tb+rAvEJdlcDUlsgA/nqVuEU XILXMkP0cepUy+pddDvhmPqIuZtyrACRtoKsEKH5xGnT/LDBIjeKaEPmJGT7NBt7Scxt jtxxEnN581RIiRfjnnmJRf0/t9XonFDCbjERgfQIW+eOTKuSv15lOMbYb5ajo1UvyRhq JSJQdQeA9fC/Wkt+H8DnfagOsu7TMrUSa0DyuXNORuBvG78ElL8JDhIAcEaoWAq+RIDw XifVTulPVObhHBxXa2IA2AFoh1AGvN9X1ISRBaR+8epBwukggTF1w3ZfQNQjXwB+Rszk 59Bg== X-Gm-Message-State: AOAM532dalNHzWMFqSp5TA3lvMzP5TEQu2JBy7BkMarEyHe2c9/sVqsY kfX3PeYxnwoKUScaKO9vHCrmmw== X-Google-Smtp-Source: ABdhPJw4utDAbFShQjiI0UToflMA3TlA+dZvbWlListpLtD9mJ0uWVFSw0e1AYcn5IG7o45tCJxZhQ== X-Received: by 2002:a1c:acc6:0:b0:38e:b184:7721 with SMTP id v189-20020a1cacc6000000b0038eb1847721mr23090492wme.94.1651011339865; Tue, 26 Apr 2022 15:15:39 -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 j19-20020adfb313000000b0020aed8ece65sm393314wrd.32.2022.04.26.15.15.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 15:15:39 -0700 (PDT) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/15] thermal/of: Remove the device node pointer for thermal_trip Date: Wed, 27 Apr 2022 00:15:14 +0200 Message-Id: <20220426221523.3056696-7-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426221523.3056696-1-daniel.lezcano@linexp.org> References: <20220426221523.3056696-1-daniel.lezcano@linexp.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 a1e4e000f461..aca491086561 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -70,13 +70,11 @@ void __thermal_cdev_update(struct thermal_cooling_device *cdev); /** * 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 84c37493e27f..25ec70c8b7ed 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; } - /* Required for cooling map matching */ - trip->np = np; - of_node_get(np); - return 0; } @@ -988,8 +984,6 @@ __init *thermal_of_build_thermal_zone(struct device_node *np) kfree(tz->tbps); free_trips: - for (i = 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 __thermal_zone *tz) } kfree(tz->tbps); - for (i = 0; i < tz->ntrips; i++) - of_node_put(tz->trips[i].np); kfree(tz->trips); kfree(tz); } From patchwork Tue Apr 26 22:15:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 568732 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 3387FC43217 for ; Tue, 26 Apr 2022 22:15:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232124AbiDZWTC (ORCPT ); Tue, 26 Apr 2022 18:19:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355703AbiDZWSx (ORCPT ); Tue, 26 Apr 2022 18:18:53 -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 F0B774348D for ; Tue, 26 Apr 2022 15:15:41 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id e24so7458348wrc.9 for ; Tue, 26 Apr 2022 15:15:41 -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=+9QTsSn8BJcd3SpcSpuaKT3v/a6Dir+cAw5shol2H5E=; b=pLtct9jejMJ/CC8VMI9sj/WQSS3RbAMis0JBNJL94r6objqP5i79eipaFxjstPOX3P m7/vEg9zExyAR+hnbCoh6hAG3dmgCx3gNQGK625nRs9lYtH2qUqeu4/XNGaK5d+5MQt5 1pOn7sncDFA0K4mVh7LyRxjYmvnfTBbrlAq/7U/2zelkEH7p3daHvxMjZPa5dkayG0Ml /Vtd0nTvDXlZlBm+nQOqkmgK5Xa1z/VKLvlJa/wUwXX3jLMrRyf4y0S+jkG7QRlbU3Th quihzZklWtIONMrpUKXUZcCEVp0sierdB6PhvkjUlyROr+A3CYpW8n/mtUS5RAofykW8 3Qsg== 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=+9QTsSn8BJcd3SpcSpuaKT3v/a6Dir+cAw5shol2H5E=; b=RKtWIFduGyyq8QLzs7WM2veQtasRiOoSElu0E+re5hBNOgWtY8FZAHCr9cMAAeJdbg Q0ja9WMZQZiWq5veonqjXduwPpKRr9XX0YykWaRjne9gP36DVeD47bRBwpumaZ0JwI9N diK6laMIlF3NY1g/Xncx5teue5SNKDApZpyjJsun8f265tng294VP05OTFv4h4FIKPzy f61iVHeeYPNVSK3Xx3MYGa39sdeTT/ngmCOQq6kTltHN44/XT2eOeIk9yp69zfjGkJIZ 7l3kxDI/RjrynrXrF9av42HoBezC4IQ0MCji340/VGdEtwuAz7qmDaAJb3g1Qxgli2Vi Vi4A== X-Gm-Message-State: AOAM533JMv9FuWRFiPnBRwDKZYJLNyq5ejlA8V6hAh2IWRN355WTXt8i lwuijexVOR+jeU8Bb01Uv9cuMw== X-Google-Smtp-Source: ABdhPJwIE3R5YdLu6zJsytdCwDdPBc119MAN3BCUzFC2VJ+68+d+4K3KERd1QZ2D7sC2TtOnpAo1eg== X-Received: by 2002:a05:6000:18a1:b0:20a:dea1:2bf7 with SMTP id b1-20020a05600018a100b0020adea12bf7mr8126939wri.90.1651011340507; Tue, 26 Apr 2022 15:15:40 -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 j19-20020adfb313000000b0020aed8ece65sm393314wrd.32.2022.04.26.15.15.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 15:15:40 -0700 (PDT) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/15] thermal/of: Move thermal_trip structure to thermal.h Date: Wed, 27 Apr 2022 00:15:15 +0200 Message-Id: <20220426221523.3056696-8-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426221523.3056696-1-daniel.lezcano@linexp.org> References: <20220426221523.3056696-1-daniel.lezcano@linexp.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 aca491086561..9ecd12e8ef9b 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_cooling_device *cdev) void thermal_cdev_update(struct thermal_cooling_device *); void __thermal_cdev_update(struct thermal_cooling_device *cdev); -/** - * 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 *tz, int trip); struct thermal_instance * diff --git a/include/linux/thermal.h b/include/linux/thermal.h index b3e8244af510..c3bd01ac4cb0 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -80,6 +80,18 @@ struct thermal_sensor_ops { void (*critical)(struct thermal_zone *); }; +/** + * 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; From patchwork Tue Apr 26 22:15:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 566391 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 1A2A4C433F5 for ; Tue, 26 Apr 2022 22:16:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355710AbiDZWTl (ORCPT ); Tue, 26 Apr 2022 18:19:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355707AbiDZWSx (ORCPT ); Tue, 26 Apr 2022 18:18:53 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5F4743AC3 for ; Tue, 26 Apr 2022 15:15:42 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id n126-20020a1c2784000000b0038e8af3e788so132906wmn.1 for ; Tue, 26 Apr 2022 15:15:42 -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=iOP2NQFztziZ3pG+HriOirkDnCYWSf0u15l1vopF39g=; b=GLWRBwqChGmda03/DWLMG702tFwmIIfyNEXkhDZ6ihbsRy8Y3hMF6ClLKucK+56LwA 5gu1sbyyu3yMqj9hKC9ib/xqekxZHZ3Ryl0mYJru2IxLPZl+oWuRnCQ+75aw/SSZIXMD a/MvQN9piW40uYl9L70G9T4wV34Uy+rJDlAmcOtcl1nXETTJXvLLjFqujHOJMeJ8UFnk yl3ukEQ2AWERHwo1HoSgbRJZ0bHo+YjBAuBMTCa0qXxbMgwTQaecPqt8pHlymky1u+yM 1N2fNS2cGZcRvIT0Zr+T52MijGt3NDyB+2U0u4e3jrKVzFMW7HBqRJWP2sqQnFwj6He2 s8Ow== 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=iOP2NQFztziZ3pG+HriOirkDnCYWSf0u15l1vopF39g=; b=edlcKcIXqncNZMxThmCa0g/pe1speAwDQ9x3d/sp48n6ROMyiDesKYKFFUOykdoXe1 T4RUyV8mdoY/86OmoNjekY44kCwaJBNSZU7KWyUpAQTFrTQk2McIs7A7l/2YYRfbJDFo uFkU1JfS3TZA+6uyYU2pNDodwgIFJeMT13y6A8fpT02ABAHytigMMG6WS41ECW+ffKiN gpaomF0jXcr2v4xYJ7FCgTyRvIvfRTxY5j/yxyhHAObQSd5wRwzvIsVMVLcF+x9lgadt DU+BO5K4QsXbRXRBz21Yyi0IjmEDldT3lpy57U8h13sudc4+Am7diRQYw/UWUOfvxE+x 489Q== X-Gm-Message-State: AOAM530vZgpDXUTwQh5FFKT6+dxlbSdcrY6YHSOioExF0WRCJ5Ag32gX g6aN0e8pjV0yOYzg/1wgwMPlsw== X-Google-Smtp-Source: ABdhPJxRdwO9UJyj54JTQE6/hmyLh8iBaBLA2sQ+recJNzEUvb7jjlleG2eAPkRGzzITOvkuoMvsRw== X-Received: by 2002:a05:600c:4e4d:b0:38f:11ed:595 with SMTP id e13-20020a05600c4e4d00b0038f11ed0595mr23317660wmq.64.1651011341262; Tue, 26 Apr 2022 15:15:41 -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 j19-20020adfb313000000b0020aed8ece65sm393314wrd.32.2022.04.26.15.15.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 15:15:40 -0700 (PDT) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/15] thermal/core: Remove unneeded EXPORT_SYMBOLS Date: Wed, 27 Apr 2022 00:15:16 +0200 Message-Id: <20220426221523.3056696-9-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426221523.3056696-1-daniel.lezcano@linexp.org> References: <20220426221523.3056696-1-daniel.lezcano@linexp.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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_helpers.c index 41d6898ec5b3..76b831d9e0e9 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -39,7 +39,6 @@ int get_tz_trend(struct thermal_zone *tz, int trip) return trend; } -EXPORT_SYMBOL(get_tz_trend); struct thermal_instance * get_thermal_instance(struct thermal_zone *tz, @@ -228,7 +227,6 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev) } mutex_unlock(&cdev->lock); } -EXPORT_SYMBOL(thermal_cdev_update); /** * thermal_zone_get_slope - return the slope attribute of the thermal zone From patchwork Tue Apr 26 22:15:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 568728 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 02D5AC433EF for ; Tue, 26 Apr 2022 22:16:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355812AbiDZWTk (ORCPT ); Tue, 26 Apr 2022 18:19:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355710AbiDZWSy (ORCPT ); Tue, 26 Apr 2022 18:18:54 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D70D43AF8 for ; Tue, 26 Apr 2022 15:15:43 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id q20so139369wmq.1 for ; Tue, 26 Apr 2022 15:15:43 -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=ZLbpL2O4THqkOA2T7fA77zNe+VikV0QIHwrfCO5ZH9g=; b=UvgDzFtdTJF5q0RKUzObK80v8Xw9nrNu0dt5i4EiXvIGlydd80EvbGmS+8wnoi7SJY ERqWS1iJk6vEWurRXTTv8oIzuCpedLmi4+7j3U3fBv0BJDijYEZZLTeBi3g0sHaMOSg4 AW36EupfAAadusdJRtOBCN4WyNEOj845Ds1iT6oTmpRdppNtS+GkFAhKZfO9Ajm1sRfg g0yzZ/EqEFLieQ2FRHNHV/ndaSwLjM0m1izvqbSiuiC9E6zPDVgsWG93rahorVwuBEnU MUHtd1xmBrBCuq2lYo7ce8pbGV+4MzGG8RPETujs/IrXineLEPySOCKjSg1X7A4MGSHG jIJw== 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=ZLbpL2O4THqkOA2T7fA77zNe+VikV0QIHwrfCO5ZH9g=; b=TG78w+J198YITUi8EQiICbUALn93UXI/A6/Fo8aOsHgfmpfAUM7Wtzlqra6WevEFwQ Z0zWhPIzVxwqNY/Gi7+/PaH6gk0+f2fPT+TRRr2QMlaegY56Wa+jVNTQyx6m2GOuOf/Y PaK5pdyK8lqBnWqQ6Bsr0Q6Srk0gH88QNZ+BkpBM9xbav00VNyvTKeYHL9ABoUWSMGvd rAVq5WHQ3aRmvHiQX1gQ5wHTyUSWxogbQSLC4Wk/kgRUX0oTVDDSuiZNJJZ1FwCV0O4A atJmLafkNVa+pzdaB4f1DEp9vLrxmIgLwGVh+oiA5D2m2838F4GvN/t/NaI34m718UG4 pHnA== X-Gm-Message-State: AOAM533Ssefnyj3Plohd2uIJvcmW3UvkAcCpkGhzCmKZ1V09uyPtdMOo 4a8DNO8uHypbcrQW1/CZRkiXJs2hsUhPdp2eJLE= X-Google-Smtp-Source: ABdhPJwe4w6Sy0t5oaUh/SdM7Ot753PzTjsTfs+amEp/ItQYZeZtuW1ERBNh0tVAlFfShbpOlDtNJw== X-Received: by 2002:a7b:cc17:0:b0:38d:af7:3848 with SMTP id f23-20020a7bcc17000000b0038d0af73848mr23481127wmh.41.1651011342026; Tue, 26 Apr 2022 15:15:42 -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 j19-20020adfb313000000b0020aed8ece65sm393314wrd.32.2022.04.26.15.15.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 15:15:41 -0700 (PDT) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/15] thermal/core: Move thermal_set_delay_jiffies to static Date: Wed, 27 Apr 2022 00:15:17 +0200 Message-Id: <20220426221523.3056696-10-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426221523.3056696-1-daniel.lezcano@linexp.org> References: <20220426221523.3056696-1-daniel.lezcano@linexp.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 a34c8cb31e91..e741c932236e 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1158,6 +1158,13 @@ static void bind_tz(struct thermal_zone *tz) mutex_unlock(&thermal_list_lock); } +static void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms) +{ + *delay_jiffies = msecs_to_jiffies(delay_ms); + if (delay_ms > 1000) + *delay_jiffies = round_jiffies(*delay_jiffies); +} + /** * thermal_zone_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 9ecd12e8ef9b..ea92a959ad59 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); /* Helpers */ void thermal_zone_set_trips(struct thermal_zone *tz); -void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms); /* sysfs I/F */ int thermal_zone_create_device_groups(struct thermal_zone *, int); diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_helpers.c index 76b831d9e0e9..aa687dee4d64 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 *tz) mutex_unlock(&tz->lock); } -void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms) -{ - *delay_jiffies = msecs_to_jiffies(delay_ms); - if (delay_ms > 1000) - *delay_jiffies = round_jiffies(*delay_jiffies); -} - static void thermal_cdev_set_cur_state(struct thermal_cooling_device *cdev, int target) { From patchwork Tue Apr 26 22:15:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 568729 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 AC1E4C433EF for ; Tue, 26 Apr 2022 22:15:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355728AbiDZWTF (ORCPT ); Tue, 26 Apr 2022 18:19:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355712AbiDZWSy (ORCPT ); Tue, 26 Apr 2022 18:18:54 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2888A443CE for ; Tue, 26 Apr 2022 15:15:44 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id t6so18215wra.4 for ; Tue, 26 Apr 2022 15:15:44 -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=KKbX6FO2GIYX7t+AR9nk4m4a87rcbveIczrNA4fQ8gE=; b=iS9A7xMWFnINe+7RP/DTU6z5JTu5Pnrp5rPgiYIfZ0OBWbnW39Q9WFPVNK5+pGba0l ggiRtcvQucdlfjXy+GwFv2wn4gLGqo8wyWIg8Ch010T32+n9SdyJ60ddB85xb4MSiEMV LpP4wJR6vZYZXmSXSIj8eJ6TH+s3uymZR8W4eixhhK4VShGvpUkHP8NEvsdMeVeezO3y Vzous0qTO8xPjfXrKZKODZ8JO0Y+RCWMWMJSoZ8EwtYwiF/i+wx/No+s1l8KBZHYKfS+ ji66drRp1Jv+zk7PXzmTyo0bFpUFMOtB/aQbCIK9WugI/yvdxaWqxZM3CuFYxDXSTdUa VYmg== 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=KKbX6FO2GIYX7t+AR9nk4m4a87rcbveIczrNA4fQ8gE=; b=oL+k+SvLDOjqospBtvJqPXHw6nUytwOag7Q3cBBYYgclN77k6qtxMpbUT2fHPSQpMf MhvON2XKPgEvwuPdbmOpf/FN59IlCHWBCHnEqGGrHU+pd1RDDBFClpGBvbP+txLux5za QX19UZiEO0mXO+FpyyKy1Sfi/7kbnumE9otTwhro2wODG6UrwQhW8qvI2j7DQs6VYKGf xvguj5DZekzPeQ4EOBFoWQ7iivLcSYSye7pPXOEeclyjR6lo15EfPm/Kme9NBJJ+P57K Y5XyVgYcpwSrJjkBwn9NRp0AJIigXGi608og2Fn482ATbU22mqWJXCWriNs+qubFYtmu 9XAA== X-Gm-Message-State: AOAM531gyNmdwUcs3T6k7xG5b6S9h+801lKwDC3+4bhUZSR3sM3koQbG 3M20oJx7MBzDT3ScbeCA0k3uvw== X-Google-Smtp-Source: ABdhPJzMdHSFZVdhW6xZoKUo1QajId8O4xA4xs2xFAB5o0KCGmYRVEdDvBRVUe7Z1bVrSIxKe3tZ5w== X-Received: by 2002:a5d:6a85:0:b0:20a:d938:3879 with SMTP id s5-20020a5d6a85000000b0020ad9383879mr10950988wru.462.1651011342675; Tue, 26 Apr 2022 15:15:42 -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 j19-20020adfb313000000b0020aed8ece65sm393314wrd.32.2022.04.26.15.15.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 15:15:42 -0700 (PDT) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/15] thermal/core: Rename trips to ntrips Date: Wed, 27 Apr 2022 00:15:18 +0200 Message-Id: <20220426221523.3056696-11-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426221523.3056696-1-daniel.lezcano@linexp.org> References: <20220426221523.3056696-1-daniel.lezcano@linexp.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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_share.c index 3ce42a8e9dbd..82a89465a614 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 *tz) int trip_temp; enum thermal_trip_type trip_type; - if (tz->trips == 0 || !tz->sensor.ops->get_trip_temp) + if (tz->ntrips == 0 || !tz->sensor.ops->get_trip_temp) return 0; - for (count = 0; count < tz->trips; count++) { + for (count = 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 *tz, cdev->ops->get_max_state(cdev, &max_state); - return (long)(percentage * level * max_state) / (100 * tz->trips); + return (long)(percentage * level * max_state) / (100 * tz->ntrips); } /** diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index 448baaa642a5..3385e8345f73 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 *tz, last_active = INVALID_TRIP; last_passive = INVALID_TRIP; - for (i = 0; i < tz->trips; i++) { + for (i = 0; i < tz->ntrips; i++) { enum thermal_trip_type type; int ret; @@ -668,7 +668,7 @@ static int power_allocator_bind(struct thermal_zone *tz) get_governor_trips(tz, params); - if (tz->trips > 0) { + if (tz->ntrips > 0) { ret = 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/tegra/tegra30-tsensor.c index ad35a9694845..2678f2111070 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 thermal_zone *tzd, *hot_trip = 85000; *crit_trip = 90000; - for (i = 0; i < tzd->trips; i++) { + for (i = 0; i < tzd->ntrips; i++) { enum thermal_trip_type type; int trip_temp; diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index e741c932236e..79cb9e0a7229 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -505,7 +505,7 @@ void thermal_zone_update(struct thermal_zone *tz, tz->notify_event = event; - for (count = 0; count < tz->trips; count++) + for (count = 0; count < tz->ntrips; count++) handle_thermal_trip(tz, count); } EXPORT_SYMBOL_GPL(thermal_zone_update); @@ -630,7 +630,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zone *tz, unsigned long max_state; int result, ret; - if (trip >= tz->trips || trip < 0) + if (trip >= tz->ntrips || trip < 0) return -EINVAL; list_for_each_entry(pos1, &thermal_tz_list, node) { @@ -811,7 +811,7 @@ static void __bind(struct thermal_zone *tz, int mask, { int i, ret; - for (i = 0; i < tz->trips; i++) { + for (i = 0; i < tz->ntrips; i++) { if (mask & (1 << i)) { unsigned long upper, lower; @@ -1056,7 +1056,7 @@ static void __unbind(struct thermal_zone *tz, int mask, { int i; - for (i = 0; i < tz->trips; i++) + for (i = 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_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 * -thermal_zone_register(const char *type, int trips, int mask, +thermal_zone_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_register(const char *type, int trips, int mask, return ERR_PTR(-EINVAL); } - 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_register(const char *type, int trips, int mask, return ERR_PTR(-EINVAL); } - 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); tz = kzalloc(sizeof(*tz), GFP_KERNEL); @@ -1254,7 +1254,7 @@ thermal_zone_register(const char *type, int trips, int mask, tz->tzp = tzp; tz->device.class = &thermal_class; tz->devdata = devdata; - tz->trips = trips; + tz->ntrips = ntrips; 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_register(const char *type, int trips, int mask, if (result) goto release_device; - for (count = 0; count < trips; count++) { + for (count = 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_helpers.c index aa687dee4d64..183bbec4d492 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 *tz, int *temp) ret = tz->sensor.ops->get_temp(tz, temp); if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) { - for (count = 0; count < tz->trips; count++) { + for (count = 0; count < tz->ntrips; count++) { ret = tz->sensor.ops->get_trip_type(tz, count, &type); if (!ret && type == THERMAL_TRIP_CRITICAL) { ret = tz->sensor.ops->get_trip_temp(tz, count, @@ -137,7 +137,7 @@ void thermal_zone_set_trips(struct thermal_zone *tz) if (!tz->sensor.ops->set_trips || !tz->sensor.ops->get_trip_hyst) goto exit; - for (i = 0; i < tz->trips; i++) { + for (i = 0; i < tz->ntrips; i++) { int trip_low; tz->sensor.ops->get_trip_temp(tz, i, &trip_temp); diff --git a/drivers/thermal/thermal_netlink.c b/drivers/thermal/thermal_netlink.c index 0e95f113d525..0b770af9aab3 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) mutex_lock(&tz->lock); - for (i = 0; i < tz->trips; i++) { + for (i = 0; i < tz->ntrips; i++) { enum thermal_trip_type type; int temp, hyst = 0; diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index 33d8c9f47990..63ea7aad3217 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 *tz, int mask) int indx; /* This function works only for zones with at least one trip */ - if (tz->trips <= 0) + if (tz->ntrips <= 0) return -EINVAL; - tz->trip_type_attrs = kcalloc(tz->trips, sizeof(*tz->trip_type_attrs), + tz->trip_type_attrs = kcalloc(tz->ntrips, sizeof(*tz->trip_type_attrs), GFP_KERNEL); if (!tz->trip_type_attrs) return -ENOMEM; - tz->trip_temp_attrs = kcalloc(tz->trips, sizeof(*tz->trip_temp_attrs), + tz->trip_temp_attrs = 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 *tz, int mask) } if (tz->sensor.ops->get_trip_hyst) { - tz->trip_hyst_attrs = kcalloc(tz->trips, + tz->trip_hyst_attrs = 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 *tz, int mask) } } - attrs = kcalloc(tz->trips * 3 + 1, sizeof(*attrs), GFP_KERNEL); + attrs = 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 *tz, int mask) return -ENOMEM; } - for (indx = 0; indx < tz->trips; indx++) { + for (indx = 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 *tz, int mask) tz->trip_temp_attrs[indx].attr.store = trip_point_temp_store; } - attrs[indx + tz->trips] = &tz->trip_temp_attrs[indx].attr.attr; + attrs[indx + tz->ntrips] = &tz->trip_temp_attrs[indx].attr.attr; /* create Optional trip hyst attribute */ if (!tz->sensor.ops->get_trip_hyst) @@ -496,10 +496,10 @@ static int create_trip_attrs(struct thermal_zone *tz, int mask) tz->trip_hyst_attrs[indx].attr.store = trip_point_hyst_store; } - attrs[indx + tz->trips * 2] = + attrs[indx + tz->ntrips * 2] = &tz->trip_hyst_attrs[indx].attr.attr; } - attrs[tz->trips * 3] = NULL; + attrs[tz->ntrips * 3] = NULL; tz->trips_attribute_group.attrs = attrs; @@ -540,7 +540,7 @@ int thermal_zone_create_device_groups(struct thermal_zone *tz, for (i = 0; i < size - 2; i++) groups[i] = thermal_zone_attribute_groups[i]; - if (tz->trips) { + if (tz->ntrips) { result = create_trip_attrs(tz, mask); if (result) { kfree(groups); @@ -561,7 +561,7 @@ void thermal_zone_destroy_device_groups(struct thermal_zone *tz) if (!tz) return; - if (tz->trips) + if (tz->ntrips) destroy_trip_attrs(tz); kfree(tz->device.groups); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index c3bd01ac4cb0..e58a2f053e1c 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -170,7 +170,7 @@ struct thermal_zone { 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; From patchwork Tue Apr 26 22:15:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 566394 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 DB649C433EF for ; Tue, 26 Apr 2022 22:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355695AbiDZWTD (ORCPT ); Tue, 26 Apr 2022 18:19:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355714AbiDZWSy (ORCPT ); Tue, 26 Apr 2022 18:18:54 -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 D1F7A44757 for ; Tue, 26 Apr 2022 15:15:44 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id k2so14011wrd.5 for ; Tue, 26 Apr 2022 15:15:44 -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=wH0tuaCVxYZkZwsvsiS/Twq7F92ctIdlTQyOxZZNlXw=; b=pflkFKZnYcmXkLfj0oATpR+JBj3hv5X+H+5emrYjR9tVH5KWlAgJnYG3xtlVIgZACR 2Cy5HCeBC84zhwKk/OMiX/QkJrQATh+pVJgoFeogamogPeRlZ6jkhg2TU0nQ/R/R1MUr iKSP/IqVaDNDvJ90tNaxNgQwO3OFeiAg82qElrIYq97ChFhcxvsda+NTdOL1AMRQt29L UZdeWAROgEJk/HC0wP10VqhUVqh/yd+QXglwv5PufJrd9Nk/PnMdLDwCWcymDQ0OdCdC PQJc8eBKx4SVGr0x72WuyLsIfch/lvEcxeuLi7EJtli8MUmF52qLCwGwiD6j+ch4HR6E SGFw== 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=wH0tuaCVxYZkZwsvsiS/Twq7F92ctIdlTQyOxZZNlXw=; b=UIORvaHDj8/q1beOTFvxBdkI1Td2xWabWRJSBIvknVbTcOpusvhKl79047oTCvu7Ul wB0dVrwsF/PFU4ogOAEEbZnc0Vl7dklqMzfaP7qyfsRQZvvwVCZxwueSayYXwNbUiT7E e7e7KahEF5OO0AumEcbx+Q3ZacOAeZJa8uvKaHfCz//4pNpF0wqlfP1zr/X434N9Q+zN 4MLzCv3zyAdv1By2yHwl8xvU4owqup7cf03742VsfFicaOHy0yq400J5Z9Yw9dgkt9xH vaQFAKT4P2ElXsZYzuGeik/TFjR+y0FwtTroLIO5oumdRjBTZ9Y+4jNysoJka3kE8Cu+ V+Gw== X-Gm-Message-State: AOAM530proqIlivBM2hOmWj9rRKTJl3g5nGFhYUDZhw6u38SXMQXXeOO YHhgYnm0HHKkwwEa09yyiF1djw== X-Google-Smtp-Source: ABdhPJwQX3rj31lXRnPvoC1o5R9T3O58u7/Y+EQPpr6Cuq04nmM8rc0/hXFslDJP86YVr3NJnmksBw== X-Received: by 2002:adf:f244:0:b0:20a:c3ab:d009 with SMTP id b4-20020adff244000000b0020ac3abd009mr20068107wrp.10.1651011343373; Tue, 26 Apr 2022 15:15:43 -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 j19-20020adfb313000000b0020aed8ece65sm393314wrd.32.2022.04.26.15.15.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 15:15:43 -0700 (PDT) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/15] thermal/core: Add thermal_trip in thermal_zone Date: Wed, 27 Apr 2022 00:15:19 +0200 Message-Id: <20220426221523.3056696-12-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426221523.3056696-1-daniel.lezcano@linexp.org> References: <20220426221523.3056696-1-daniel.lezcano@linexp.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 ea92a959ad59..04f3d9f80db2 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 *tz); +static inline struct thermal_trip *thermal_zone_get_trips(struct thermal_zone *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 *, int); void thermal_zone_destroy_device_groups(struct thermal_zone *); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index e58a2f053e1c..9c75afff517a 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -184,6 +184,7 @@ struct thermal_zone { 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; From patchwork Tue Apr 26 22:15:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 568730 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 5BC42C433FE for ; Tue, 26 Apr 2022 22:15:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355755AbiDZWTE (ORCPT ); Tue, 26 Apr 2022 18:19:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355717AbiDZWSy (ORCPT ); Tue, 26 Apr 2022 18:18:54 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9C8927CD3 for ; Tue, 26 Apr 2022 15:15:45 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id n32-20020a05600c3ba000b00393ea7192faso130588wms.2 for ; Tue, 26 Apr 2022 15:15:45 -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=zH3Lt/m7esA/s8brWXuW3YNZ0o54R9cXMDjhBWwDDf0=; b=lKydNFrSUBa9fYyh9Eeuip2Zj3Va67JkokhU0Hhgo0ulArwe1sNYlb9f4Vy35jsKq5 bJ3bvYXTPG8yQOHtotJL/HdWHMx4NmOqZ9v6rIOWopboLnWKrh2bnWJYM/2sb9nQk+f3 yx0Ruy1wzWyc4ZxtL6OQ5+CB61XLX3iFSR5ooCOnPf9xwzhJTRI7cZ/IIVgh79PZTahR 6XGld+5vKG3jDOc25g+ATU6hje6nwj+1fH9rB9rRqDHO8+l5iZP2a4D1kzNFdlzVgInM W95QS3PhAvVL0P8ZHRtwQDz4zEhiFQYizS8PyvykWEybGD4okFWgO3RqlskM/H3TBGBy Q5/Q== 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=zH3Lt/m7esA/s8brWXuW3YNZ0o54R9cXMDjhBWwDDf0=; b=kShyJlV8+zuEbFXyj/oJDW29AmrGQy3SOXpn+1+G6HlAUTZFzNjmu0hjhg1fUHFjSt dViOvH4yFXtaiYHIZKV3YrAumzPxA/snjnUesxiQ0Nbkrow/mQBusdtzTgguFvk+90Mh PS7tSnYs9JL2GZ/7C2oGVdWZEAgb4HJxXxeGXLigYXu/FWy1VKCsaBdEG1RTXlNEfINa ebXw9+8sTcSGASyNBL3kANuYZvcMDreKz0Ndur7fXKz2XIEE7etXemuxeex2HcDyryZK SrCrprfft9a3rLx0l+0md0pYnwlCgbzpVbyY2LUOigdqnG+alMXag/3genQh9sTmOLwW m0vg== X-Gm-Message-State: AOAM533IPObc2vUxnB+6R0LYoVuZiYl38zJ9+sIkmmEpPQ6LBBog5LCE 3nPHq7gCTc5SB72uqSiHoCev5g== X-Google-Smtp-Source: ABdhPJwMDYMSYGDJyAgzt0o7iV4ybOvvnic7CH8KWW2yq4koFG1PedIKlpeJuGGjRLcp4jKPJ77nvw== X-Received: by 2002:a05:600c:4fd0:b0:393:eb2e:fb04 with SMTP id o16-20020a05600c4fd000b00393eb2efb04mr12334200wmq.167.1651011344334; Tue, 26 Apr 2022 15:15:44 -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 j19-20020adfb313000000b0020aed8ece65sm393314wrd.32.2022.04.26.15.15.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 15:15:43 -0700 (PDT) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/15] thermal/core: Register with the trip points Date: Wed, 27 Apr 2022 00:15:20 +0200 Message-Id: <20220426221523.3056696-13-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426221523.3056696-1-daniel.lezcano@linexp.org> References: <20220426221523.3056696-1-daniel.lezcano@linexp.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 | 17 +++++++++++++++-- include/linux/thermal.h | 6 ++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 79cb9e0a7229..822f97bc471f 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 } /** - * thermal_zone_register() - register a new thermal zone device + * thermal_zone_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,7 +1191,8 @@ static void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms * IS_ERR*() helpers. */ struct thermal_zone * -thermal_zone_register(const char *type, int ntrips, int mask, +thermal_zone_register_with_trips(const char *type, + struct thermal_trip *trips, int ntrips, int mask, void *devdata, struct thermal_sensor_ops *ops, struct thermal_zone_params *tzp, int passive_delay, int polling_delay) @@ -1255,6 +1257,7 @@ thermal_zone_register(const char *type, int ntrips, int mask, tz->device.class = &thermal_class; tz->devdata = devdata; tz->ntrips = ntrips; + tz->trips = trips; thermal_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay); thermal_set_delay_jiffies(&tz->polling_delay_jiffies, polling_delay); @@ -1332,6 +1335,16 @@ thermal_zone_register(const char *type, int ntrips, int mask, } EXPORT_SYMBOL_GPL(thermal_zone_register); +struct thermal_zone *thermal_zone_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_register_with_trips(type, NULL, ntrips, mask, + devdata, ops, tzp, + passive_delay, polling_delay); +} + /** * thermal_zone_unregister - removes the registered thermal zone device * @tz: the thermal zone device to remove diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 9c75afff517a..0c3b549601d3 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -381,6 +381,12 @@ void devm_thermal_zone_of_sensor_unregister(struct device *dev, struct thermal_zone *thermal_zone_register(const char *, int, int, void *, struct thermal_sensor_ops *, struct thermal_zone_params *, int, int); + +struct thermal_zone * +thermal_zone_register_with_trips(const char *, struct thermal_trip *, int, int, + void *, struct thermal_sensor_ops *, + struct thermal_zone_params *, int, int); + void thermal_zone_unregister(struct thermal_zone *); int thermal_zone_bind_cooling_device(struct thermal_zone *, int, From patchwork Tue Apr 26 22:15:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 566393 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 D3E24C433F5 for ; Tue, 26 Apr 2022 22:15:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355712AbiDZWTF (ORCPT ); Tue, 26 Apr 2022 18:19:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355723AbiDZWSz (ORCPT ); Tue, 26 Apr 2022 18:18:55 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 863002AE28 for ; Tue, 26 Apr 2022 15:15:46 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id n32-20020a05600c3ba000b00393ea7192faso130613wms.2 for ; Tue, 26 Apr 2022 15:15:46 -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=9xqo8cdwZZ7Q/0XbGV8OGpU2bIpfLRX69Ze0bOBuXZM=; b=BGWFkjuPN+z4ttF0UmF8Pk2FFczgajxL4OHrl/9N8HdkGRGnGxP/z9A3dBlcN+Kp25 g5LedZNfLm6BaVlieYI1A/Jry8K0eB59sTqdzRMo7V0FySw24yyh1gqZ9k3gHYysf9NP 02och3dCV+wvYrAPRG7NdALoqN50IE/UL1g9H+DtEQX0mzt6+INKlYt1vyf296wheVRC +QXhQXwpJSnts5oR7p3dT4ndR5kHBi8d3mMkMura9r3J7KxO7PN0VuRRiqCYEXRtP4IV cgyAnMiZmhCg1DK7FCWBf3IR10CICfQyTp0Sml+4XTiN239mEtiluy7WEBGHr+7hAzpJ 824Q== 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=9xqo8cdwZZ7Q/0XbGV8OGpU2bIpfLRX69Ze0bOBuXZM=; b=rWdlU9abxwEMgBEmGzXQfjb8zMv3LyaxxEx4Vrbs+D+k/qoVunync9WrEDJjx9iA5B CGNFy2n+yspR1xI2EHprY9zfHeTKUsnSVPBxOMJ9ABabf0UyqpAFGIOQc+hEW3Fwo7mm n75xeEh2uEo1urUecmxSyACQAZyv7jrJB7xeqGB1m1aLZvb0TGZvvZ5mzBbLb/T32Nsl D7/Xvzy+WhrRQe+VBG+g6YMBAjxj9ViRo/Mlu3FSv0GDB9RsSnqroWPOBLinegMgfvqE eZYFhtz2ODpb9C146xrhJYb/al7rxgLoXkBR6HEsKSsVZsYWZ6m9lP6xNua0YdYf1AWq c1Wg== X-Gm-Message-State: AOAM53233iwAvXz43yv2wKdONS/jQf7KLUeGuDEm0JqnfamJtkLpcfsc gk9RKDt/ExLUj7QujLE1pRszOw== X-Google-Smtp-Source: ABdhPJxPhhOKiPiX/8lriPpnQIomwLWWbla9zIeSYHjIy7+J6eWA/DsMwABJdJhTEiFCksgKHEVJMQ== X-Received: by 2002:a05:600c:ad1:b0:38c:8bf6:7d6b with SMTP id c17-20020a05600c0ad100b0038c8bf67d6bmr23444731wmr.84.1651011345148; Tue, 26 Apr 2022 15:15:45 -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 j19-20020adfb313000000b0020aed8ece65sm393314wrd.32.2022.04.26.15.15.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 15:15:44 -0700 (PDT) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/15] thermal/of: Store the trips in the thermal zone Date: Wed, 27 Apr 2022 00:15:21 +0200 Message-Id: <20220426221523.3056696-14-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426221523.3056696-1-daniel.lezcano@linexp.org> References: <20220426221523.3056696-1-daniel.lezcano@linexp.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 25ec70c8b7ed..069b421a54ae 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 = tz->slope; tzp->offset = tz->offset; - zone = thermal_zone_register(child->name, tz->ntrips, - mask, tz, - ops, tzp, - tz->passive_delay, - tz->polling_delay); + zone = thermal_zone_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)); From patchwork Tue Apr 26 22:15:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 568727 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 AB5C5C433EF for ; Tue, 26 Apr 2022 22:16:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355707AbiDZWTl (ORCPT ); Tue, 26 Apr 2022 18:19:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355733AbiDZWS4 (ORCPT ); Tue, 26 Apr 2022 18:18:56 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42D9D3F321 for ; Tue, 26 Apr 2022 15:15:47 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id n126-20020a1c2784000000b0038e8af3e788so133016wmn.1 for ; Tue, 26 Apr 2022 15:15:47 -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=P1RwEk6UMhSV0WlQ0OxuiFr38k8Axw4qKNQEGZIv6iU=; b=QKQybkVzURgeI+tMJ8w51LnBMOsyEpcW6GaYr2EWcgioEfA/zFfepWd47I1jyLod97 IWqQqSRg8mQJeuPG1dlbX96xNfk2QyyXGDeK1bgaOwhXFzjAHQii6b1tv0vRF3ADSPeW Iua2IjldIzTPTwBm9EGwt/6fxNGEbJTqmhU0cAzWzUoRh20FBqNhoHsz29o00YpP2HtD 3ChRcOruxOMapmMdGwdjNtmHcbvJKTGAM6tr+NzvH2uDvhHec3wMwRi1/yqe4EpyVy0f zRgnqRSXuY/Ifcm0RGkhGqje87+0MudBdAfOhLVCo5mUWo7kmKnx8jskwcgQqW7n85F3 Kvqw== 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=P1RwEk6UMhSV0WlQ0OxuiFr38k8Axw4qKNQEGZIv6iU=; b=e9QJOThLGYX/vX70aVm8SfVYhpnbVZITShunPbNKtNtxfHQckg9WDCBttbzqppR2sQ jU+stUzqTm0ix77vfxFECn1bpjbZ4PmSz/iRdagNIB1HbkleQXMUM5z0GUM7p9FVr4xh JEbyg/3B35PGSd+IS0rNYX7E1040UTDtvZBLxXAgxusozywpI0XLveEaYQeCDh67Qmbx kuEP2oxVnfS2lLC9XKVbDwNqZS3MTZtDefOpjVwZxYV4nY5rv+YM6Y/Xx//IMyxCTbil MEU+/Gyoxd9PpX4DKDjhov8KwhNACpyKIIaYO6wiERhEJZf1Um1Cu2V6oOkU4XdxlD5s Ua1g== X-Gm-Message-State: AOAM530DibfjEGjz3EjywcyC6lp0dhKJOephTH02VOYfhiyInPRpooW2 Wtmdldfh+P/X3SHVJH3eH4CQyQ== X-Google-Smtp-Source: ABdhPJxcZ4rRyWIm+bCZmxUETGu9bxO2QRKfNWK78Anhv9GWEXiyOvKUHwYfO7F4LI/+1nntyxu55A== X-Received: by 2002:a05:600c:3509:b0:393:ec9f:e884 with SMTP id h9-20020a05600c350900b00393ec9fe884mr10246330wmq.74.1651011345867; Tue, 26 Apr 2022 15:15:45 -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 j19-20020adfb313000000b0020aed8ece65sm393314wrd.32.2022.04.26.15.15.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 15:15:45 -0700 (PDT) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 14/15] thermal/of: Use thermal trips stored in the thermal zone Date: Wed, 27 Apr 2022 00:15:22 +0200 Message-Id: <20220426221523.3056696-15-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426221523.3056696-1-daniel.lezcano@linexp.org> References: <20220426221523.3056696-1-daniel.lezcano@linexp.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 069b421a54ae..a356a7b2d73d 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 *tz, */ int of_thermal_get_ntrips(struct thermal_zone *tz) { - struct __thermal_zone *data = tz->devdata; - - if (!data || IS_ERR(data)) - return -ENODEV; - - return data->ntrips; + return tz->ntrips; } EXPORT_SYMBOL_GPL(of_thermal_get_ntrips); @@ -139,9 +134,7 @@ EXPORT_SYMBOL_GPL(of_thermal_get_ntrips); */ bool of_thermal_is_trip_valid(struct thermal_zone *tz, int trip) { - struct __thermal_zone *data = tz->devdata; - - if (!data || trip >= data->ntrips || trip < 0) + if (trip >= tz->ntrips || trip < 0) return false; 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 *tz) { - struct __thermal_zone *data = tz->devdata; - - if (!data) - return NULL; - - return data->trips; + return tz->trips; } EXPORT_SYMBOL_GPL(of_thermal_get_trip_points); @@ -273,12 +261,10 @@ static int of_thermal_unbind(struct thermal_zone *thermal, static int of_thermal_get_trip_type(struct thermal_zone *tz, int trip, enum thermal_trip_type *type) { - struct __thermal_zone *data = tz->devdata; - - if (trip >= data->ntrips || trip < 0) + if (trip >= tz->ntrips || trip < 0) return -EDOM; - *type = data->trips[trip].type; + *type = tz->trips[trip].type; return 0; } @@ -286,12 +272,10 @@ static int of_thermal_get_trip_type(struct thermal_zone *tz, int trip, static int of_thermal_get_trip_temp(struct thermal_zone *tz, int trip, int *temp) { - struct __thermal_zone *data = tz->devdata; - - if (trip >= data->ntrips || trip < 0) + if (trip >= tz->ntrips || trip < 0) return -EDOM; - *temp = data->trips[trip].temperature; + *temp = tz->trips[trip].temperature; return 0; } @@ -301,7 +285,7 @@ static int of_thermal_set_trip_temp(struct thermal_zone *tz, int trip, { struct __thermal_zone *data = tz->devdata; - if (trip >= data->ntrips || trip < 0) + if (trip >= tz->ntrips || trip < 0) return -EDOM; if (data->ops && data->ops->set_trip_temp) { @@ -313,7 +297,7 @@ static int of_thermal_set_trip_temp(struct thermal_zone *tz, int trip, } /* thermal framework should take care of data->mask & (1 << trip) */ - data->trips[trip].temperature = temp; + tz->trips[trip].temperature = temp; return 0; } @@ -321,12 +305,10 @@ static int of_thermal_set_trip_temp(struct thermal_zone *tz, int trip, static int of_thermal_get_trip_hyst(struct thermal_zone *tz, int trip, int *hyst) { - struct __thermal_zone *data = tz->devdata; - - if (trip >= data->ntrips || trip < 0) + if (trip >= tz->ntrips || trip < 0) return -EDOM; - *hyst = data->trips[trip].hysteresis; + *hyst = tz->trips[trip].hysteresis; return 0; } @@ -334,13 +316,11 @@ static int of_thermal_get_trip_hyst(struct thermal_zone *tz, int trip, static int of_thermal_set_trip_hyst(struct thermal_zone *tz, int trip, int hyst) { - struct __thermal_zone *data = tz->devdata; - - if (trip >= data->ntrips || trip < 0) + if (trip >= tz->ntrips || trip < 0) return -EDOM; /* thermal framework should take care of data->mask & (1 << trip) */ - data->trips[trip].hysteresis = hyst; + tz->trips[trip].hysteresis = hyst; return 0; } @@ -348,12 +328,11 @@ static int of_thermal_set_trip_hyst(struct thermal_zone *tz, int trip, static int of_thermal_get_crit_temp(struct thermal_zone *tz, int *temp) { - struct __thermal_zone *data = tz->devdata; int i; - for (i = 0; i < data->ntrips; i++) - if (data->trips[i].type == THERMAL_TRIP_CRITICAL) { - *temp = data->trips[i].temperature; + for (i = 0; i < tz->ntrips; i++) + if (tz->trips[i].type == THERMAL_TRIP_CRITICAL) { + *temp = tz->trips[i].temperature; return 0; } From patchwork Tue Apr 26 22:15:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 566392 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 7DBE9C433FE for ; Tue, 26 Apr 2022 22:16:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355723AbiDZWTG (ORCPT ); Tue, 26 Apr 2022 18:19:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355737AbiDZWS5 (ORCPT ); Tue, 26 Apr 2022 18:18:57 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E33EF43AC1 for ; Tue, 26 Apr 2022 15:15:47 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id q20so139431wmq.1 for ; Tue, 26 Apr 2022 15:15:47 -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=RVhezk9B87ybbOk33dem3lxM0Kx2b5w34TWWJpET4nU=; b=c6/yMNhqpjRNkxbWUr6888LfBel4XBBaMHYXksJ6Q1/aI6GjRvcHd2b935fsZnRSr0 uKn00lK62rUjVMIyW5RgBdREupNxpcj1ZL5W/kib8bj639w+7jMVk5PtomunTHyLx82j rP//7MIeluu7nXebw8txykShT06kmAIME2oqw54yGN38jUbvTlGprc3ZgLHxtjo4sPb7 5z8o1QvNri3EW3qP6xgqWRz1ME5yV40trlzXC3ZTgXj8CtaHYALyJpPZt3EmawBZf3jR MnMwzunzBcowBw0ylWEA1PnEb7zawhw8JHJZ+FieEKV33gSX4Cq6o/X2sWc2IpvIa2JY zy+g== 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=RVhezk9B87ybbOk33dem3lxM0Kx2b5w34TWWJpET4nU=; b=aqKXaZs0/yzE/YttOXUGJuvEdg2bNcK6ImvixlCgM3wSHs6DVTL92HvCageCbfS2di joiOpuH+0K+90KtLyDfHJi5/mTk4yGDRIDWfqg8wtX+YR+WiMqELAGy65kfkdJcscwTm rSlLyliXxVRN/IURgTX+BXdD4CpWtj7qzPuzAK8HCQ0lXNsPGx4T/gRBrGZBJBaEk/d5 dWZhcEXORDt9WgyUvAkNtA0O5RbBQWdLSEfXnUONDcF+pSNKdI+3QOe0mZiLulGYMQOz +BhUR5UUYQpaoGcYUAchDOqP15SohU4c028voKYwzZdNNPYvChpY9qw7kJnWZF+wrtsw hWeA== X-Gm-Message-State: AOAM531tzP4/srs4wC2QsfwS7aKfqCcQblrAsPS/yhTlO+8c9TAsKmoJ Q6tXqgz+vShZsSN0hViHPfuWXQ== X-Google-Smtp-Source: ABdhPJwZCA1ixD3ixVK6T21Tn2CRBMAMUf/1DHBPhC2n8kWXxsd+B/9yx5FalBWFMzVO5L5B0YDrQQ== X-Received: by 2002:a05:600c:1910:b0:392:9143:27d3 with SMTP id j16-20020a05600c191000b00392914327d3mr23231890wmq.206.1651011346517; Tue, 26 Apr 2022 15:15:46 -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 j19-20020adfb313000000b0020aed8ece65sm393314wrd.32.2022.04.26.15.15.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 15:15:46 -0700 (PDT) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: khilman@baylibre.com, abailon@baylibre.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 15/15] thermal/of: Initialize trip points separately Date: Wed, 27 Apr 2022 00:15:23 +0200 Message-Id: <20220426221523.3056696-16-daniel.lezcano@linexp.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220426221523.3056696-1-daniel.lezcano@linexp.org> References: <20220426221523.3056696-1-daniel.lezcano@linexp.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 Reported-by: kernel test robot --- drivers/thermal/thermal_of.c | 79 ++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 25 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index a356a7b2d73d..ef9c2e7f1af4 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, struct 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 device_node *np, return -ENODEV; } - trip_id = of_find_trip_id(np, trip); + trip_id = of_find_trip_id(tz_np, trip); if (trip_id < 0) { ret = trip_id; goto end; @@ -837,6 +838,53 @@ static int thermal_of_populate_trip(struct device_node *np, return 0; } +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 = of_get_child_by_name(np, "trips"); + if (!trips) { + pr_err("Failed to find 'trips' node\n"); + return ERR_PTR(-EINVAL); + } + + count = of_get_child_count(trips); + if (!count) { + pr_err("No trip point defined\n"); + ret = -EINVAL; + goto out_of_node_put; + } + + tt = kzalloc(sizeof(*tt) * count, GFP_KERNEL); + if (!tt) { + ret = -ENOMEM; + goto out_of_node_put; + } + + *ntrips = count; + + count = 0; + for_each_child_of_node(trips, trip) { + ret = thermal_of_populate_trip(trip, &tt[count++]); + if (ret) + goto out_kfree; + } + + of_node_put(trips); + + return tt; + +out_kfree: + kfree(tt); + *ntrips = 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 = 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_node *np) tz->offset = 0; } - /* trips */ - trips = of_get_child_by_name(np, "trips"); - - /* No trips provided */ - if (!trips) + tz->trips = thermal_of_trips_init(np, &tz->ntrips); + if (IS_ERR(tz->trips)) { + ret = PTR_ERR(tz->trips); goto finish; - - tz->ntrips = of_get_child_count(trips); - if (tz->ntrips == 0) /* must have at least one child */ - goto finish; - - tz->trips = kcalloc(tz->ntrips, sizeof(*tz->trips), GFP_KERNEL); - if (!tz->trips) { - ret = -ENOMEM; - goto free_tz; - } - - i = 0; - for_each_child_of_node(trips, gchild) { - ret = thermal_of_populate_trip(gchild, &tz->trips[i++]); - if (ret) - goto free_trips; } /* cooling-maps */ @@ -940,7 +969,7 @@ __init *thermal_of_build_thermal_zone(struct device_node *np) i = 0; for_each_child_of_node(child, gchild) { - ret = thermal_of_populate_bind_params(gchild, &tz->tbps[i++]); + ret = thermal_of_populate_bind_params(np, gchild, &tz->tbps[i++]); if (ret) goto free_tbps; }