Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1169095rwb; Wed, 28 Sep 2022 14:20:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6xKbmqDiNKoeDNssTCb4OloiuYNZhmtYIoiMTuvUsco5HVlvGmsG0Obrr6LduweWx8/atd X-Received: by 2002:a50:9510:0:b0:453:dded:60e with SMTP id u16-20020a509510000000b00453dded060emr35515384eda.204.1664400017476; Wed, 28 Sep 2022 14:20:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664400017; cv=none; d=google.com; s=arc-20160816; b=ynjj/iFkMgW2sXwMMD28cdipdm6mE85dsLxB0oe3wAkmPXRE2qYUHBLiZfqdXAZExv YK/7PbHFKmNsE/rSRxH65+lIxxAZ/erP5sXcnxqUgdgSm31RhyIB0fG9fMycFlPoZJKj 8zEpowcHFcmmGJldV5oL7SyGyATTSMdzlkJVKOYM+DD8KEiUn6TgtxeiACRvfW3R2tTK i+qspZEI7D6JTEv7TEYCtFTuh8du+THBrPV80oKh0FIEB0ymHtj6fTKU7CTIQLQ5A3Zt eOSZe7+ITBwnN2sotyLLL0DEa0LR472Zx+pMdGB9PTZ/FMr2t3oNGd0mSuMNAqYoh2Cc KAzQ== 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=/DpVb9+AKUGgq8A4EZDNel0xrsv5+R31U81PHZWHu7A=; b=L9ppr90R87BQLoQj93FX/K6/iYvMLL1XniLXCkEq/eSncEkzaiDwxFmuGPRHsOLvXW MefJprDzx9scDdjb7YNLHtXGrNYL048go+NqJY75hfhX3j0T1YgSHkxQWR2ezeMyO9hP E9Ddi5KgGFti+KgNP37gU7o/5RLmEO1INJfPwO49NYTynjd2qzzWkpvxGIw2OSJKUo8i T3WfvJdRFBPbFVhwa4vzXGqEOofF7ekrXP5oZeqCtA+OTLP2k/PYurApWgzajpSmXvgW Aa4t+kcMyBv8wPZO4FIiLCLaOd9JpBqyVAGDfcJjBFZVpVBXxGhgggaVqe1FGHhG9uye /lCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KdFPSErK; 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 h22-20020a1709063c1600b0077bab1f707esi5803057ejg.159.2022.09.28.14.19.51; Wed, 28 Sep 2022 14:20:17 -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=KdFPSErK; 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 S234597AbiI1VEi (ORCPT + 99 others); Wed, 28 Sep 2022 17:04:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233049AbiI1VDS (ORCPT ); Wed, 28 Sep 2022 17:03:18 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19316D74ED for ; Wed, 28 Sep 2022 14:01:53 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id cc5so21617855wrb.6 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=jLT7UfNBh+P6A3W3P5xe4Stk5bKwjlgmVYcUZXpBVQrw3lBxui4dddG97HRdeFvZyB bF+ZQLUKkFcMaQVewZO8OAX6k7AG2KTedahKlR/J4P6WS5Lza9yIrZnDmz20r2yn/74w Z5tnnIusCQWei/jFPB4joyQKEk7johjGJzKfNuF8ZjgtJJC1gYenf559umWrPEaZnox8 2vwxS2o2jbBM3EQdgUiHOY9I5nyQpLTF66z+nbo0IPNWBXi91hOZacOeupkSkfui6wSo 6NMlf+VsBx5HtQtrUG6nzxr8drlLN6U69KZysG6sAaU4VGdTZWa4neokTfJpvFrWZ9Bj 5tEg== X-Gm-Message-State: ACrzQf0R3+xwODfJWN7NkfxtLuAVyto/8HVYRwpD35DQw0ANVXH86Xbi gK9KjryF2HYwrMd2DS9d8KG9sw== 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=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, 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 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=unavailable 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 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; -- 2.34.1