Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2558419rwb; Mon, 3 Oct 2022 02:32:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4dgZ3OmZFQiP9DISqxqPzUhlhkjws/s4CJj/1HaE5n+AVULljuwZboUfESNwRdpr5K0Wu6 X-Received: by 2002:a17:906:7315:b0:782:66dc:4b76 with SMTP id di21-20020a170906731500b0078266dc4b76mr14338007ejc.751.1664789539451; Mon, 03 Oct 2022 02:32:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664789539; cv=none; d=google.com; s=arc-20160816; b=M3rKtWLyyO54Db0cEdatY4iWbG+JLyGT6F/+l6zmwlSDcebAGCcv2QSoBnn5IN9T4Z Oarxk684Cc8aCNROIisEvOWbpt9Z5MKqXJnzNdwzTUfVZhQkXOtNJjf+0Sul6cSeNvek 18cU7gxI2FH/sB+jEIDMvcTMyY5iDTgBFWVj7qPFbCk6QgIyik4vkDR0GROgpq62kgZF BlbDqev4/6H56t5ug7BnutwjG6Elj4CJWosxmPa/8mv7mBNhssb7xLkZY+IYg7n7wrax q65OA+v0C8kJaZTYh4REsZVL/PTEHCxn6/U2I21NttdZLpMSWLTAEtN2qRjq2bn0t8fA 8BiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XsxTgl9OJhYT/B2dXFDz/rl/9WpF5J4y9HKMzylFxc4=; b=buhpueyMMBwpdKS2BHnrFXrQeY4bggJL9maM+RgNY8YsT8SYvYkmjlabgM9VHUWcHe zXgzqxkL9Kj83DCaZ7gDAhrTiSOuTURzfEyHHg/IJngPkeFhf8dDRa3831/xRb3VKt9h vgKjtREFMO2dEpllxmrmAtMJqnNEEL3PFr5zsi4FoLZ0J2R+CZRu6tSVWJAAnerXt4fT SvRJCpS7s9TJlA3wTFlvv8PO5HU4ilfAnV7YebD3np8ba7WBJIRmvks0640A/Cttev7U RgJ2nizNGkQBi6C/JozjdndZ4+jJGWmG9Yv20xgx3Oq8Mc28b291CLc7t/17bV7qcaII tMEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sB6EDvxD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji9-20020a170907980900b0078a30f54c57si3679738ejc.32.2022.10.03.02.31.51; Mon, 03 Oct 2022 02:32:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sB6EDvxD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230109AbiJCJ21 (ORCPT + 99 others); Mon, 3 Oct 2022 05:28:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231536AbiJCJ1E (ORCPT ); Mon, 3 Oct 2022 05:27:04 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B11B419BD for ; Mon, 3 Oct 2022 02:26:48 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id b4so8819519wrs.1 for ; Mon, 03 Oct 2022 02:26:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=XsxTgl9OJhYT/B2dXFDz/rl/9WpF5J4y9HKMzylFxc4=; b=sB6EDvxDT/L09X3f/yefb3A7d20jrji6bRzG9zfPuMwU7f7IhjKfEQ8Z9zS9dBn9tR ywHcmRRaO0g6EJDkN+mGvtSrhJekJ7sRJHnEFOTN2acPB0kDyANbmNTCTa3O71/TO0JN IHeazfvtPsX4UGnwMvHwo3dMetq0uzsrhL+Vfr7q3wGF47FzgKoQiGRDUfJhiaisSxAV IZOrOHHL8MrvzOS6KD90WCNViPVF1VbNvqZfuDK0E2uIg1dTUrJxrunzvbYkjBgN+h9t wAwED3bBNGpwK1KGtTHrsd624PHLomfnFsa3x5QAHHNFMl2W1KWfS89Owz3pyqRVKFfC ouOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=XsxTgl9OJhYT/B2dXFDz/rl/9WpF5J4y9HKMzylFxc4=; b=2+pfBl6V/DLLutUJOwPPWDrD5hjzHZYEISbZ+ladii/idxyOwCSvANeaiuFfKTEv+e 8BN8YutBROUY3Jolho7nLGuRKF9Zm2Q1Nc4v4BN+/uPiIZ0ZD6z4/H02LT8k/bQ1Puyy MMdBlp3YWmLyRLWRqj4bUWMKJT4ctDc+sjL5DJzGScrcvriEJyin1yaJHQCfq4rFplSL 36jPLOWjpzscnUzDfCHxK9sl8bUvZBKVUiEKud4Pkco2S6UM6bR0uyEutMKbbOJNjkZZ gopEXMgp/+GzYdvpQv/Z/G2cH8aRGPYRnJN8je66sRMcW93z0wI7m7hVv49bQFsebtez pQDQ== X-Gm-Message-State: ACrzQf2v5AxqtFnva82ZChn6rzjCCiYgPkswA0WtNhy4US+PT/c3dl3U Bd2x64XtFQqoHZ3DjrW/T7AanA== X-Received: by 2002:a5d:4f09:0:b0:22e:3f04:2820 with SMTP id c9-20020a5d4f09000000b0022e3f042820mr1659263wru.219.1664789207708; Mon, 03 Oct 2022 02:26:47 -0700 (PDT) Received: from mai.. ([2a05:6e02:1041:c10:f3a:9f5e:1605:a75a]) by smtp.gmail.com with ESMTPSA id ay3-20020a5d6f03000000b0022cc157bf26sm9707520wrb.85.2022.10.03.02.26.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 02:26:47 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Raju Rangoju , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Peter Kaestle , Hans de Goede , Mark Gross , Miquel Raynal , Amit Kucheria , Nicolas Saenz Julienne , Broadcom Kernel Team , Florian Fainelli , Ray Jui , Scott Branden , Support Opensource , Lukasz Luba , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Thara Gopinath , Andy Gross , Bjorn Andersson , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , Eduardo Valentin , Keerthy , Kunihiko Hayashi , Masami Hiramatsu , Antoine Tenart , Srinivas Pandruvada , Dmitry Osipenko , netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v8 10/29] thermal/drivers/tegra: Use generic thermal_zone_get_trip() function Date: Mon, 3 Oct 2022 11:25:43 +0200 Message-Id: <20221003092602.1323944-11-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221003092602.1323944-1-daniel.lezcano@linaro.org> References: <20221003092602.1323944-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace a single call to thermal_zone_get_trip() to get a trip point instead of calling the different ops->get_trip* Signed-off-by: Daniel Lezcano --- drivers/thermal/tegra/soctherm.c | 33 +++++++++++-------------- drivers/thermal/tegra/tegra30-tsensor.c | 17 ++++++------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index 1efe470f31e9..96b541458ccd 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -582,23 +582,23 @@ static int tsensor_group_thermtrip_get(struct tegra_soctherm *ts, int id) return temp; } -static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip, int temp) +static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip_id, int temp) { struct tegra_thermctl_zone *zone = tz->devdata; struct tegra_soctherm *ts = zone->ts; + struct thermal_trip trip; const struct tegra_tsensor_group *sg = zone->sg; struct device *dev = zone->dev; - enum thermal_trip_type type; int ret; if (!tz) return -EINVAL; - ret = tz->ops->get_trip_type(tz, trip, &type); + ret = thermal_zone_get_trip(tz, trip_id, &trip); if (ret) return ret; - if (type == THERMAL_TRIP_CRITICAL) { + if (trip.type == THERMAL_TRIP_CRITICAL) { /* * If thermtrips property is set in DT, * doesn't need to program critical type trip to HW, @@ -609,7 +609,7 @@ static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip else return 0; - } else if (type == THERMAL_TRIP_HOT) { + } else if (trip.type == THERMAL_TRIP_HOT) { int i; for (i = 0; i < THROTTLE_SIZE; i++) { @@ -620,7 +620,7 @@ static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip continue; cdev = ts->throt_cfgs[i].cdev; - if (get_thermal_instance(tz, cdev, trip)) + if (get_thermal_instance(tz, cdev, trip_id)) stc = find_throttle_cfg_by_name(ts, cdev->type); else continue; @@ -687,25 +687,20 @@ static const struct thermal_zone_device_ops tegra_of_thermal_ops = { .set_trips = tegra_thermctl_set_trips, }; -static int get_hot_temp(struct thermal_zone_device *tz, int *trip, int *temp) +static int get_hot_temp(struct thermal_zone_device *tz, int *trip_id, int *temp) { - int ntrips, i, ret; - enum thermal_trip_type type; + int i, ret; + struct thermal_trip trip; - ntrips = of_thermal_get_ntrips(tz); - if (ntrips <= 0) - return -EINVAL; + for (i = 0; i < thermal_zone_get_num_trips(tz); i++) { - for (i = 0; i < ntrips; i++) { - ret = tz->ops->get_trip_type(tz, i, &type); + ret = thermal_zone_get_trip(tz, i, &trip); if (ret) return -EINVAL; - if (type == THERMAL_TRIP_HOT) { - ret = tz->ops->get_trip_temp(tz, i, temp); - if (!ret) - *trip = i; - return ret; + if (trip.type == THERMAL_TRIP_HOT) { + *trip_id = i; + return 0; } } diff --git a/drivers/thermal/tegra/tegra30-tsensor.c b/drivers/thermal/tegra/tegra30-tsensor.c index c34501287e96..cbaad2245f1d 100644 --- a/drivers/thermal/tegra/tegra30-tsensor.c +++ b/drivers/thermal/tegra/tegra30-tsensor.c @@ -316,18 +316,17 @@ static void tegra_tsensor_get_hw_channel_trips(struct thermal_zone_device *tzd, *hot_trip = 85000; *crit_trip = 90000; - for (i = 0; i < tzd->num_trips; i++) { - enum thermal_trip_type type; - int trip_temp; + for (i = 0; i < thermal_zone_get_num_trips(tzd); i++) { - tzd->ops->get_trip_temp(tzd, i, &trip_temp); - tzd->ops->get_trip_type(tzd, i, &type); + struct thermal_trip trip; - if (type == THERMAL_TRIP_HOT) - *hot_trip = trip_temp; + thermal_zone_get_trip(tzd, i, &trip); + + if (trip.type == THERMAL_TRIP_HOT) + *hot_trip = trip.temperature; - if (type == THERMAL_TRIP_CRITICAL) - *crit_trip = trip_temp; + if (trip.type == THERMAL_TRIP_CRITICAL) + *crit_trip = trip.temperature; } /* clamp hardware trips to the calibration limits */ -- 2.34.1