From patchwork Wed Sep 28 21:00:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12993031 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 04AECC32771 for ; Wed, 28 Sep 2022 21:04:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234153AbiI1VEW (ORCPT ); Wed, 28 Sep 2022 17:04:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233695AbiI1VDQ (ORCPT ); Wed, 28 Sep 2022 17:03:16 -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 E6D56D74E0 for ; Wed, 28 Sep 2022 14:01:53 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id n10so21554743wrw.12 for ; Wed, 28 Sep 2022 14:01:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=/DpVb9+AKUGgq8A4EZDNel0xrsv5+R31U81PHZWHu7A=; b=KdFPSErKIFzGd1n7bkpEuvBpX3UmOHTRXdMCGe23szCNQiAc+CGubNfNfJhGw7bRH0 I7fQLY7KHnEd8bZ/dgAtMLhuVp06/z8Ry575nuN4/FJTYwEX7Ve3h0i5PR/Dj0rgzxH+ iJO4jcilhhCGHGFsV9g7mbULP/tNzFFgJBuPWGi1sYnC9FmmXynY223/CVErJ8Vfn7Vz ahojKFqHAKgRzQl7xqqah9suGBvyEtLGYQuNh5aP+Md+enWDZIEidIsZOYHtF6Qn9pDN puJKNKVtPrwT/16hWQfNmburkf6ciYwTE8n9aSCBveo972gHAunHJvgeniBNFmOz4WM8 9ntg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=/DpVb9+AKUGgq8A4EZDNel0xrsv5+R31U81PHZWHu7A=; b=aZsvflOGs41Jn6ovSnj18g98i1O4nj9fW53L/DZuzvL/oEtPRFZDVdkZZZ54QKQPAC DkXqmbb3pQs8+ngLR/6RYxbXKhL7x7S35VIZNNr360HahZUKVhyy4gTClVBup3bxgso3 QxL3COx/p14M60figNtbHQlfK4UbyubuOa+ENmu5YekAR5yzHgl1Q0r4A7ETJyOPwRnN FS08xPiQjWwNE4Kj3UASaEh4Ze8WMI1QVepdnp0Hms3t09dHoPPKSZFBhmRBUA7TNwrB crMDpUdH3dlnjWFpXX9k8iqgk/TSLNgX+KVU8EamyHBRU/WkSfZ2RX2xozYH92LqSpR5 anHg== X-Gm-Message-State: ACrzQf2hfFvBlUpguJcHdIwCTQEvdJpRkBdkXDP/DX9/HzpntggXdeWz rFD0oLSXR5l3VVH6cioxfTTfag== X-Google-Smtp-Source: AMsMyM5HkVaGDsNwxN5zYh1x5OXGdpP7JalqX/G1GmzEWJePpmTAkoTW8Ao46nCSK5WgM7cBPBAZXg== X-Received: by 2002:adf:f44c:0:b0:228:8686:552f with SMTP id f12-20020adff44c000000b002288686552fmr21330005wrp.587.1664398913109; Wed, 28 Sep 2022 14:01:53 -0700 (PDT) Received: from mai.. ([2a05:6e02:1041:c10:48a2:39eb:9d1b:8b8d]) by smtp.gmail.com with ESMTPSA id g20-20020a05600c4ed400b003b4931eb435sm2874300wmq.26.2022.09.28.14.01.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 14:01:52 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, 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_S=C3=B6derlu?= =?utf-8?q?nd?= , 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, Konrad Dybcio , Thara Gopinath Subject: [PATCH v7 13/29] thermal/drivers/qcom: Use generic thermal_zone_get_trip() function Date: Wed, 28 Sep 2022 23:00:43 +0200 Message-Id: <20220928210059.891387-14-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220928210059.891387-1-daniel.lezcano@linaro.org> References: <20220928210059.891387-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with the thermal zone. Signed-off-by: Daniel Lezcano Acked-by: Amit Kucheria Reviewed-by: Dmitry Baryshkov --- drivers/thermal/qcom/qcom-spmi-temp-alarm.c | 39 +++++++++------------ 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/drivers/thermal/qcom/qcom-spmi-temp-alarm.c b/drivers/thermal/qcom/qcom-spmi-temp-alarm.c index be785ab37e53..127e8c90211c 100644 --- a/drivers/thermal/qcom/qcom-spmi-temp-alarm.c +++ b/drivers/thermal/qcom/qcom-spmi-temp-alarm.c @@ -263,17 +263,17 @@ static int qpnp_tm_update_critical_trip_temp(struct qpnp_tm_chip *chip, return qpnp_tm_write(chip, QPNP_TM_REG_SHUTDOWN_CTRL1, reg); } -static int qpnp_tm_set_trip_temp(struct thermal_zone_device *tz, int trip, int temp) +static int qpnp_tm_set_trip_temp(struct thermal_zone_device *tz, int trip_id, int temp) { struct qpnp_tm_chip *chip = tz->devdata; - const struct thermal_trip *trip_points; + struct thermal_trip trip; int ret; - trip_points = of_thermal_get_trip_points(chip->tz_dev); - if (!trip_points) - return -EINVAL; + ret = thermal_zone_get_trip(chip->tz_dev, trip_id, &trip); + if (ret) + return ret; - if (trip_points[trip].type != THERMAL_TRIP_CRITICAL) + if (trip.type != THERMAL_TRIP_CRITICAL) return 0; mutex_lock(&chip->lock); @@ -299,22 +299,17 @@ static irqreturn_t qpnp_tm_isr(int irq, void *data) static int qpnp_tm_get_critical_trip_temp(struct qpnp_tm_chip *chip) { - int ntrips; - const struct thermal_trip *trips; - int i; - - ntrips = of_thermal_get_ntrips(chip->tz_dev); - if (ntrips <= 0) - return THERMAL_TEMP_INVALID; - - trips = of_thermal_get_trip_points(chip->tz_dev); - if (!trips) - return THERMAL_TEMP_INVALID; - - for (i = 0; i < ntrips; i++) { - if (of_thermal_is_trip_valid(chip->tz_dev, i) && - trips[i].type == THERMAL_TRIP_CRITICAL) - return trips[i].temperature; + struct thermal_trip trip; + int i, ret; + + for (i = 0; i < thermal_zone_get_num_trips(chip->tz_dev); i++) { + + ret = thermal_zone_get_trip(chip->tz_dev, i, &trip); + if (ret) + continue; + + if (trip.type == THERMAL_TRIP_CRITICAL) + return trip.temperature; } return THERMAL_TEMP_INVALID;