Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2558127rwb; Mon, 3 Oct 2022 02:32:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM44Dw0orUHR7B3NXBkq8V0r/DPSO6+mqB9ZZSkYwqNzW5hmOMVtLMBsxsjhDa9Q4Kow2Gow X-Received: by 2002:a05:6402:22ed:b0:458:bcd1:69cf with SMTP id dn13-20020a05640222ed00b00458bcd169cfmr8398955edb.260.1664789520657; Mon, 03 Oct 2022 02:32:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664789520; cv=none; d=google.com; s=arc-20160816; b=c18t56I0O/uCm/6Vt9rsn06uNgkU7KiI8AztoeLF1a/1+OmyqcOVHpaLrZd5onnoFc 23luTmEwVbPK9QeL2RkO3fh1NLIcq+QT8UBh6SWjgTtyiwnbLVfB1PzTtLWdGUqRrVPI p8rIzFJcOJm+bDpGCD9Y7G3dxy2DF5E7g8KiWeJ9dPNLJq+265d1+gOKhZoDgQi/ByFT dwcMBKAZLzAckkBAKWaPJmtRfuEVupVaqpjQ7CGZtrY1xd72xLDToTkqRa+y/+Yx2Kx0 DNn/uCH/9jNlP4t580YLvb7bHdWgo/Ea1J3EwWF0pq1j3K30ImVtPj6/eWyb29Sw0Av+ qZoA== 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=aNmMz3cRMj5kxPfKCvTpL8Ywx++ZqyPMyM5lgZsCem0=; b=Cyc+usVHafOTow4b1iIPTs4d63dG79fL8xfqo1BmKg/So4CCwKtAvzJBLAY2ufy4NQ Ui7WmTs6IUyJgUFR7j/SnSVbaRnlaVCnSzViHVFm+egPkiRFuEAY+gZVlpHPyrECJkJ3 3z2y8WggyK3UgyQFIn07ysdnYe89kAWFKe+9Bh4WQ5wKx+3BiMN+kCUkCCdWRxkrNiL1 XFN42y3k7RzNtJx/9t7ls4Ay6g2puz00ZxgJvmqNqyoNR3K14i+AGDBapyO6zgJNQUDL DukKQaWgFvhr1nKPY3zQsiO7Ebh1zN4zEY4zMu1f373CrzXB/UxBrcfCxpoDQjylGKEz NnbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qnvtx8Et; 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 2-20020a170906318200b00783ac0b4d32si6604255ejy.941.2022.10.03.02.31.33; Mon, 03 Oct 2022 02:32:00 -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=qnvtx8Et; 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 S231163AbiJCJ1g (ORCPT + 99 others); Mon, 3 Oct 2022 05:27:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231331AbiJCJ0u (ORCPT ); Mon, 3 Oct 2022 05:26:50 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C99C040E00 for ; Mon, 3 Oct 2022 02:26:37 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id e10-20020a05600c4e4a00b003b4eff4ab2cso8675407wmq.4 for ; Mon, 03 Oct 2022 02:26:37 -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=aNmMz3cRMj5kxPfKCvTpL8Ywx++ZqyPMyM5lgZsCem0=; b=qnvtx8EtxVFStYsXPpjraGOnXJJ6ndRjl07EioymTILSNoK1K5TRU5Y/xGGlvc9cge 2QwQC7mC1LO6XmlDYgGXMq4S1MoH2BVQY7YGKiFQqRro7Zzpx20tvDdCbTy73uaGMbEW Hfp+/I0lOqqw9JuGU/E2ycG9OiS20g3eG5k5EObolNhaRkG2f9RX+weRgZEgb/fJQ4KQ 9Ug8wgnlea/v4JonW6umdfmz1VgBB5WEsexfAf3K/M8FZKcw9LghpapiR5IrGq5In2h9 G4gAsX2nM19O+fmuqC68TWK0q5hRtOEoHZ60OVXZK+abS2e8DBKw+eoYxKtCpQNlBdOR 9+oQ== 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=aNmMz3cRMj5kxPfKCvTpL8Ywx++ZqyPMyM5lgZsCem0=; b=V1OGkuHJIqR31aUYERfUMR+MbybGaIn/Ewfit8qfyqrRFbhTOdy9McBrhIOQCc7h0i Io597QQomwXa9CO5lQXOoX5zc1sMuwCadUoAT5g8EuCqCzUC9FUXTKbV59H8jI83TPzm pkIoA72JgXwCiotfU2qgndkIisLSJOsJ0P5DgvcIcxpyYXilQ3UyiU2XOnj3Zt9Q7hQE iI/nOOD1JQyRe2OkfMwX0HrZW0I4/3DD9zx7ELFOwoxYpqmSl7cuBcmqDwag6ydwMFH7 lA8PpkOwReonFYRlVvq9WCr6F0DsV+rhxf/RtcWKtCUsZrfN7XwROz2Ftsg3DN8+aSQW IZvw== X-Gm-Message-State: ACrzQf3zecEFF66bIlk79Oh+sg60UmE81D89GNhBXus4xuTQ0B8j6drA olTwSdtJ8IXBRen6k1bDrd1elA== X-Received: by 2002:a05:600c:5486:b0:3b4:7e47:e19 with SMTP id iv6-20020a05600c548600b003b47e470e19mr6268513wmb.12.1664789197014; Mon, 03 Oct 2022 02:26:37 -0700 (PDT) Received: from mai.. ([2a05:6e02:1041:c10:f3a:9f5e:1605:a75a]) by smtp.gmail.com with ESMTPSA id ay3-20020a5d6f03000000b0022cc157bf26sm9707520wrb.85.2022.10.03.02.26.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 02:26:36 -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 Subject: [PATCH v8 07/29] thermal/drivers/exynos: Use generic thermal_zone_get_trip() function Date: Mon, 3 Oct 2022 11:25:40 +0200 Message-Id: <20221003092602.1323944-8-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221003092602.1323944-1-daniel.lezcano@linaro.org> References: <20221003092602.1323944-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=ham 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: Krzysztof Kozlowski --- drivers/thermal/samsung/exynos_tmu.c | 41 +++++++++++----------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 51874d0a284c..0e33d32a9d2e 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -260,16 +260,8 @@ static int exynos_tmu_initialize(struct platform_device *pdev) { struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct thermal_zone_device *tzd = data->tzd; - const struct thermal_trip * const trips = - of_thermal_get_trip_points(tzd); unsigned int status; - int ret = 0, temp, hyst; - - if (!trips) { - dev_err(&pdev->dev, - "Cannot get trip points from device tree!\n"); - return -ENODEV; - } + int ret = 0, temp; if (data->soc != SOC_ARCH_EXYNOS5433) /* FIXME */ ret = tzd->ops->get_crit_temp(tzd, &temp); @@ -303,19 +295,16 @@ static int exynos_tmu_initialize(struct platform_device *pdev) /* Write temperature code for rising and falling threshold */ for (i = 0; i < ntrips; i++) { - /* Write temperature code for rising threshold */ - ret = tzd->ops->get_trip_temp(tzd, i, &temp); - if (ret) - goto err; - temp /= MCELSIUS; - data->tmu_set_trip_temp(data, i, temp); - /* Write temperature code for falling threshold */ - ret = tzd->ops->get_trip_hyst(tzd, i, &hyst); + struct thermal_trip trip; + + ret = thermal_zone_get_trip(tzd, i, &trip); if (ret) goto err; - hyst /= MCELSIUS; - data->tmu_set_trip_hyst(data, i, temp, hyst); + + data->tmu_set_trip_temp(data, i, trip.temperature / MCELSIUS); + data->tmu_set_trip_hyst(data, i, trip.temperature / MCELSIUS, + trip.hysteresis / MCELSIUS); } data->tmu_clear_irqs(data); @@ -360,21 +349,23 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on) } static void exynos4210_tmu_set_trip_temp(struct exynos_tmu_data *data, - int trip, u8 temp) + int trip_id, u8 temp) { - const struct thermal_trip * const trips = - of_thermal_get_trip_points(data->tzd); + struct thermal_trip trip; u8 ref, th_code; - ref = trips[0].temperature / MCELSIUS; + if (thermal_zone_get_trip(data->tzd, 0, &trip)) + return; - if (trip == 0) { + ref = trip.temperature / MCELSIUS; + + if (trip_id == 0) { th_code = temp_to_code(data, ref); writeb(th_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP); } temp -= ref; - writeb(temp, data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0 + trip * 4); + writeb(temp, data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0 + trip_id * 4); } /* failing thresholds are not supported on Exynos4210 */ -- 2.34.1