From patchwork Tue Aug 9 22:04:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12940022 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 5CEC0C32762 for ; Tue, 9 Aug 2022 22:06:40 +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=iEZLfC7rCW8PVF+tC1MLp/rtFuney2nZqcRjFvWee2M=; b=oSrubFHgRoGLv2 4WpTrImJc8vd5gZva+9vw26VVj59ZDNXRcFGFUFzZS9yYCRIRuMqGtRrx6mw0Re8Vm3o5F0U5XgxO VK0UJChlDfNhjfuVf11yi2oWgDtGDOERJXGylrMlk3dYtYfZe0CVf2P36npZvM2491otNQl6fq7v7 8RGK7mnHoXejjwvRv2kL21FlbA5U/VcBaeQzN4ZeTI4zacuYJ48Qv88m8jAWnX+RvQ64/ta4Rkojf IdoxJAia9GidAarEFn5wNClB04QoiViaK7bNAWubRkdyKnZlx0Aw7MJRvA/Zj1qfylh/GsYLDDmsw EEHC3PIkm8MtMi0wbcTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oLXLy-006utE-DL; Tue, 09 Aug 2022 22:05:34 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oLXLb-006ujz-Er for linux-arm-kernel@lists.infradead.org; Tue, 09 Aug 2022 22:05:13 +0000 Received: by mail-wm1-x32f.google.com with SMTP id ay36-20020a05600c1e2400b003a4e30d7995so115106wmb.5 for ; Tue, 09 Aug 2022 15:05:10 -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=a0tkxQ3BVQ7QDdW+F+13SmYlJx7XIUccYaqSyISXxKQ=; b=oNwW+r7s9GvOV/yExM5fCvQD3Qs3rvwgPpSoZbu3tJEGRoP338HKirtKIGVQfSKFSy 0/3XS5JLayFWC4qBIG0LEi4IuyTQ9TL4uXIR8GcPvflaz4C98Q8ZfdNaI7FBmOsOueef nibzX3Juw8ZvhokQ5mKL1xSjwDexH4ORUGAe0nnw8dbR5WJfS0e54iKy6PhRgIrujt33 8CG6QH6mvSTXUXxFBXKqfrF12GHdmuFDvH62aNlP/AhsP301TMAAhahaUIShxWprVqcQ NYdkMycJ0wVvWEOzH+g2T3abi8WqSLy7wg4EnRs5SAgonX7NTU9qRqQRhr0jIIWVSprN GFUw== 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=a0tkxQ3BVQ7QDdW+F+13SmYlJx7XIUccYaqSyISXxKQ=; b=ZtDwZPd1SjV2t5kYtUv7HcNeCsaR3+4ZPgHj0DgZVBaHvKT5ZgdyzXx5zGLdwpH1WR ejzWMk9YqUiA1iCe5LCG+X0nj0s0zppXAT6ptmvJujLqc21K8k63TexN1h5mDcRmE1qd Tl+ATi7BmytOn5Aq73gor8Rz7AiKUjwtmC98hBHpl/I5Mxg1kIFDPTzKrLy8QwibHFcw o8P6jcNiOsbPHSyzoI364+2nFwfselELmUA8X5HYqOoIKwqOXJM5/mhqhP0uawkJ1NN9 KTc3dg/PB4enIEKBFaeTrwtjHbNo8pgJqc3yNeKD1/g+zmeQBCm7iUqzPj3FeIzjlNEd nRkw== X-Gm-Message-State: ACgBeo2k7Jah+MN441EzKZv67OYWXVm7vXj/7GT3HHognyB8EZRVfjdL TwIuC8uzv92gL0feMcXekyFFPw== X-Google-Smtp-Source: AA6agR604SuevAmE7qWjfqroYSOrm0a6UHax8u7NRuopKV2cKJFjhLpw437CPILQSdnsIluXDJfPqA== X-Received: by 2002:a1c:44d5:0:b0:3a5:4fa3:b260 with SMTP id r204-20020a1c44d5000000b003a54fa3b260mr260348wma.165.1660082708949; Tue, 09 Aug 2022 15:05:08 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 15:05:08 -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 v2 09/26] thermal/drivers/uniphier: Use generic thermal_zone_get_trip() function Date: Wed, 10 Aug 2022 00:04:19 +0200 Message-Id: <20220809220436.711020-10-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220809_150511_544687_BB6A2D8E X-CRM114-Status: GOOD ( 14.55 ) 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 Reviewed-by: Kunihiko Hayashi --- 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) {