From patchwork Tue Aug 9 22:04: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: 596243 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 3AA5EC2BB9D for ; Tue, 9 Aug 2022 22:06:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230059AbiHIWFu (ORCPT ); Tue, 9 Aug 2022 18:05:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229944AbiHIWFO (ORCPT ); Tue, 9 Aug 2022 18:05:14 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2960F5A0 for ; Tue, 9 Aug 2022 15:05:12 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id bv3so15739452wrb.5 for ; Tue, 09 Aug 2022 15:05:12 -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; bh=/DpVb9+AKUGgq8A4EZDNel0xrsv5+R31U81PHZWHu7A=; b=peaXh+eEG5QHYmztdj96PE7qEz/UpxATK7V0Vf+VweXe5zhcDDmwAMl5qKeDZM6S0T ZN+fYhE4gzlCnRhQMXeIonK+MBUmOXEayUy0hYsnZ5tgm9WCgqBb/OH2qKDObnVFMVb8 +oaY2BQWMLGKmmI3NSURZg37gn7yHQrsuyUA2djRLpZBdgv32DpwGlVMBmwM+i04/u0r AybzcRMjen8PuB7syVvnQD2MUDeay9VcgjqQfoM344vkeDgov/JwH1UZ20d+wd/qd3xG PnsfVYf69ywTg/DaOi+IpCW2WltmBuoAg3m3cELi2ChntMc74VLbBxFzbLq2wS68kZmD 92Ww== 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; bh=/DpVb9+AKUGgq8A4EZDNel0xrsv5+R31U81PHZWHu7A=; b=VsTZpFt5Ax4OQBYPdxEM6LPnADvj5oOz+ASNt4iTz4Wnmaj9Dly4V3SDZ8hz4BImyE EGiGAzsXXceHOhXeDTUnBoGNxWuYrAj91nYl78fnbXuJy76H3Fxa/3fXSOkkRPlPzeYM L2TWoMLu6RWMPOVMdhAMifwWEAnWXYz6jIFeyWp4hAjXA9NE3nYvusDpmzJZElh6gwpP 4kkDR7QDpGp4GCOzHwn78dnl+5IcmvRbp+Qfi4JLM1lunYZkvhZWMZRDECUz3HjWeyIV oRnSWBBnR2lhAGTzIvbm78dyI612FD3IvyAccFqoASFcEkOMg28Oaz/JYJCSqJXuTLO7 2xTw== X-Gm-Message-State: ACgBeo0ERuLzcdiqye6k0U8APPHQeJVSCvZip+urXPeofxFZfrhBMArT KoqT8CcqahKyn1n6tmWczCjdWQ== X-Google-Smtp-Source: AA6agR49+PetY/UezFl3VCgkiFx0TG/DJQh2wnNGRrH82UOhV3w3/UK0yMaLKbaosKyrxScGgmPoHw== X-Received: by 2002:a5d:5a92:0:b0:223:7af9:be0e with SMTP id bp18-20020a5d5a92000000b002237af9be0emr195542wrb.259.1660082711298; Tue, 09 Aug 2022 15:05:11 -0700 (PDT) Received: from localhost.localdomain (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c3b1500b003a317ee3036sm293583wms.2.2022.08.09.15.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:10 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , Thara Gopinath , Andy Gross , Bjorn Andersson , linux-arm-msm@vger.kernel.org (open list:QUALCOMM TSENS THERMAL DRIVER) Subject: [PATCH v2 11/26] thermal/drivers/qcom: Use generic thermal_zone_get_trip() function Date: Wed, 10 Aug 2022 00:04:21 +0200 Message-Id: <20220809220436.711020-12-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809220436.711020-1-daniel.lezcano@linaro.org> References: <20220809220436.711020-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;