From patchwork Fri Aug 5 14:57:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12937357 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 52FD7C19F2D for ; Fri, 5 Aug 2022 14:59:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=94Qu4RiL3O2lQg3jzw9lRUVNClq0QMNgylpM/OMI4H0=; b=osvge+Dsg6Hvrk cj/D2eZUG1cl+vKc2L+u3vdslcbnr4ujS/0t+YvY1fTr6VfBJMMT1+9B7LBPCjEvxn1T+MftJ7qUd 3Hqn7pZYz/CseKn5DKaMxwduKvi+xm9G55LmKSjmSk5yOJKR3rZyRq1Sjw9sT1EvFOl1JcXXbwsua CXIFJu7+TpuXFcE1CVYSwun0rFViVWssdofY3zo1upX7Ln07wDxkAudAFNoI/Y5ZQ8+R7teq2DM25 jBK05V0VTOjPjV2l3jBC65cmqcvIW3hES2Psz22ZY2xmjYo16IPJOLIyGmRqxiAHh0ItW7OCph5vv f8gPXAmt4b4S8yxf/9/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJymN-00G49F-PT; Fri, 05 Aug 2022 14:58:23 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJym1-00G3xg-OK for linux-arm-kernel@lists.infradead.org; Fri, 05 Aug 2022 14:58:03 +0000 Received: by mail-wr1-x42b.google.com with SMTP id j7so3565413wrh.3 for ; Fri, 05 Aug 2022 07:57:59 -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=kIpvuE+bW+eT/SFr+C12ZH/LKEUovzkS1DdxP7wVWjE=; b=wKk9VfbxvHMAVc7uI99CGYA3+IhnPdZriOODpeqDxwKDYCf2PmRwoo8vm8JoW/y3OO +oQStB1GJ5blh48C420xBWXMLzUIOvlFL88PFk2TTn/7yu5kUsbrvihZjxUjSumcKiJ3 6F/QGxHScm6ZWFx7QGUkiGF1EPXZpp7Yg5B1qmvd1D3Qe92JY/9+1NBJFSrxzz5xbIPm aBY33429clL/3IveC/oVcEE4h4gPfFgoyAtC7wBAcn3CxNpuOiG+PcjMIjikFt7d/hSb oW6hwxJXnP0TvlOGZQ2Ufz5HiB4R9f4ygJo8ZQQXTxTvyqhl4X1qL0LpRiEBRrCibxR1 aFpg== 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=kIpvuE+bW+eT/SFr+C12ZH/LKEUovzkS1DdxP7wVWjE=; b=nk5mYX/YOffiVsokyuz3Gx9uLBm5TIaQ440U763GlHjjXOlcIF89aFa4Fg5wer12xI msFd0Uwadd5AWQIBdCzJ8EkkYCBFZIcGYgttUVnyTniLfW9W0f1ekRCNgn9fiGZmq4SM CY4U4sw6jn7aJIbo1pO37uRwZZq1imeqUTm+x5XtX3FmO2kJsWVtOAKJi1wAR5OETtfb Sc8a116887DGs78QnfapgTH+8f0X7lE20j6CO7ec+30OnVQx8Uui/6YZmIN1QiXwnTgi 6lbbjTQyPfMddKKcxeIfD/L5MNMRKrlXRPykToo3exgPTQd05ur0lvEGJA1Wy9OhK+X5 0SUg== X-Gm-Message-State: ACgBeo2dsFIMXtVuLyivjVHN8V8HlQscQdmvwuANV68YYm7O5yLkGlwq 1UlPr//4V876GF0gc4rNioOR4g== X-Google-Smtp-Source: AA6agR45hdupSZOJcF2lOhYvVvylrAuSS8NnlhDTf1hMsh5B1lwK5QBrPzFlpZzjDYONDbDSWIxHBw== X-Received: by 2002:a5d:504b:0:b0:220:7ae9:d7df with SMTP id h11-20020a5d504b000000b002207ae9d7dfmr4481205wrt.465.1659711478058; Fri, 05 Aug 2022 07:57:58 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:aef0:8606:da6b:79ef]) by smtp.gmail.com with ESMTPSA id y1-20020adfd081000000b0022159d92004sm3102448wrh.82.2022.08.05.07.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 07:57:57 -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 , Kunihiko Hayashi , Masami Hiramatsu , linux-arm-kernel@lists.infradead.org (moderated list:ARM/UNIPHIER ARCHITECTURE) Subject: [PATCH v1 09/26] thermal/drivers/uniphier: Use generic thermal_zone_get_trip() function Date: Fri, 5 Aug 2022 16:57:12 +0200 Message-Id: <20220805145729.2491611-10-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220805145729.2491611-1-daniel.lezcano@linaro.org> References: <20220805145729.2491611-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220805_075801_818398_A104B03A X-CRM114-Status: GOOD ( 14.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 --- drivers/thermal/uniphier_thermal.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/thermal/uniphier_thermal.c b/drivers/thermal/uniphier_thermal.c index 4111d99ef50e..1675174480aa 100644 --- a/drivers/thermal/uniphier_thermal.c +++ b/drivers/thermal/uniphier_thermal.c @@ -248,8 +248,7 @@ static int uniphier_tm_probe(struct platform_device *pdev) struct regmap *regmap; struct device_node *parent; struct uniphier_tm_dev *tdev; - const struct thermal_trip *trips; - int i, ret, irq, ntrips, crit_temp = INT_MAX; + int i, ret, irq, crit_temp = INT_MAX; tdev = devm_kzalloc(dev, sizeof(*tdev), GFP_KERNEL); if (!tdev) @@ -296,20 +295,17 @@ static int uniphier_tm_probe(struct platform_device *pdev) return PTR_ERR(tdev->tz_dev); } - /* get trip points */ - trips = of_thermal_get_trip_points(tdev->tz_dev); - ntrips = of_thermal_get_ntrips(tdev->tz_dev); - if (ntrips > ALERT_CH_NUM) { - dev_err(dev, "thermal zone has too many trips\n"); - return -E2BIG; - } - /* set alert temperatures */ - for (i = 0; i < ntrips; i++) { - if (trips[i].type == THERMAL_TRIP_CRITICAL && - trips[i].temperature < crit_temp) - crit_temp = trips[i].temperature; - uniphier_tm_set_alert(tdev, i, trips[i].temperature); + for (i = 0; i < thermal_zone_get_num_trips(tdev->tz_dev); i++) { + + struct thermal_trip trip; + + thermal_zone_get_trip(tdev->tz_dev, i, &trip); + + if (trip.type == THERMAL_TRIP_CRITICAL && + trip.temperature < crit_temp) + crit_temp = trip.temperature; + uniphier_tm_set_alert(tdev, i, trip.temperature); tdev->alert_en[i] = true; } if (crit_temp > CRITICAL_TEMP_LIMIT) {