From patchwork Tue Sep 27 14:32: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: 609667 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 D79DDC6FA82 for ; Tue, 27 Sep 2022 14:33:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232496AbiI0Ody (ORCPT ); Tue, 27 Sep 2022 10:33:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232580AbiI0OdO (ORCPT ); Tue, 27 Sep 2022 10:33:14 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A06595F7E4 for ; Tue, 27 Sep 2022 07:33:11 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id h7so2913720wru.10 for ; Tue, 27 Sep 2022 07:33:11 -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=wWHPNc9KiPFjFJPGPM1cmcCNOLkxsnFdo3qlLmlcGNsDgozzeDodboy37a1hgyU+Em 8Wf+hHWPHct4UAPPSoCL1fe8+ZfSmUBUm7ZEUPAovTqsZPsCgtuu+DrK0lvVrGsW0R+e o5S5pNzCiwisspUCsaQpCZ8RdiC7h77ipIhTihZsjD2TlE5lfZh0rXXpSSejq7gpzj7B cSRNNNtVBNFT85TITwi0TGRG3YUj3ju/nGccydy0kyjxHpsGUAjZyo0UYMz/ejEN4GLf fdz74xdPkMHBMP1u5CEAsHd2euoQR73mocSVYfMBkEjqgN/nSXLIx8b2ZwQX/FPgmN+B dTOg== 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=fbd0pZMcmKT9rQEle39IQLpIxh1tmKJBWz4YZO4MRJARJ9mbIveXhTTOsNeckreAPQ Hdw0825NJy8PpxFTHmrV5WELvOKgPXNu5JM0+q5651OHC5bi2niA5i7fUrqPRNfc5G1u Tev2dnio14/LB6KIkppgZlX0L1CWHDmJJ27kckXmUbRIS9hxknHE7C+PultpK9pSpF81 4ojnl7ukxd2rFU3p/Lhqqbx60vXuAU6EzLZe3kIXiKJEWpI84bk7e4o3eq0wJbavyNm5 b8fgDAOpykRc6WtVOc8MTXh9quqVhVaq4aHRmWGWQ7/La9gKEbHpBlzUGXpQiF240Eqo QGbQ== X-Gm-Message-State: ACrzQf2QBLg1SOC5fpjszUtxd7eZgnLyIB6Bt7CyRm3OK5qYzKUCRBhr 2thjtzVJK0WXWSBgwjr4yvC7Ow== X-Google-Smtp-Source: AMsMyM6HlnqOd9arHzbjJM9erMfyIAzq8I+BPrvB9ienm/bm0vdAoY9IgENNNfK+8T4trX26hz1s2Q== X-Received: by 2002:adf:ef06:0:b0:228:d60c:cf74 with SMTP id e6-20020adfef06000000b00228d60ccf74mr17020049wro.302.1664289189932; Tue, 27 Sep 2022 07:33:09 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id l6-20020a05600c4f0600b003b4924493bfsm17518371wmq.9.2022.09.27.07.33.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 07:33:09 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria , Andy Gross , Bjorn Andersson , Konrad Dybcio , Thara Gopinath , linux-arm-msm@vger.kernel.org (open list:ARM/QUALCOMM SUPPORT) Subject: [PATCH v6 13/29] thermal/drivers/qcom: Use generic thermal_zone_get_trip() function Date: Tue, 27 Sep 2022 16:32:23 +0200 Message-Id: <20220927143239.376737-14-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927143239.376737-1-daniel.lezcano@linaro.org> References: <20220927143239.376737-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 --- 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;