Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1187822rwb; Wed, 28 Sep 2022 14:39:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4hZxcDDuQ4lYBWkCyAT/MYo5hhK7CK4STHOewZNtbHyG8Kcg+OW/+Z3fJ6vjiYfPKF0GzZ X-Received: by 2002:a17:902:a60f:b0:179:dc8a:4e6a with SMTP id u15-20020a170902a60f00b00179dc8a4e6amr11745plq.111.1664401185687; Wed, 28 Sep 2022 14:39:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664401185; cv=none; d=google.com; s=arc-20160816; b=hl+Lv/aQ0PcjNEWXq+l+srYK5HDk6O6RLLlr1pi1rvyOzTiBetjYqZTe/SdHMzf/LY bRqOt2TWoSzZxf1IGTOosaJLKkP4TbS80RCiQyF7JHr2k+FGYMBEnBTlKuRtW2ZNbhN/ pOBBiFGtyd9c/xhZDroMmNVvsXU6NuSyNGRwFUqp69ujAjQgpaAnr4ewvrkiLbqzaTE7 NoJ9msBtNm4yz2JZhlvfPg/m8I5QUidBmuQzZ+H34uElZNaYaCbYsb2Gq7up8zVMUbq2 S4HO4Odwsa+1dpmBVdYj+20OTz3r1tXpToTKLR+1nk5ZqbDfrUxJZibdHg3e7LmOIjo8 IwyA== 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=gNDmPuHQzQvcbMUd1/DpgjwVaA9d3BqAFvrb9MladEuuxjZq7nk55QLueqzOL3o0EM k0mC34wExxVXTneE8Zb1xeeFB89G/P8r0eFqtCyv0yetqaMut/rxkbZOqzUXEhxddNw+ RpISAa0XClJBRWYIkHLu6FpFGlZYjEs24712tToKmkXvxSEcjlUXyCr2xEC39gKBk775 RWNwrixihiMlXaNG7+2pf52QPkrUiJmIyAMOxFEVLwhkHbiQt2hVei25aCuIN+EccwtN uWYG74vJ4K6NqQomHvwLV+kA4jgfgvB3wa1MLTOQHhxy8X9LfQxvYkCZu3nGQPOT4C7p nkUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hLfcCqGT; 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 k11-20020a17090a514b00b001f4fc7af64esi2889615pjm.101.2022.09.28.14.39.34; Wed, 28 Sep 2022 14:39:45 -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=hLfcCqGT; 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 S234433AbiI1VDS (ORCPT + 99 others); Wed, 28 Sep 2022 17:03:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234132AbiI1VCS (ORCPT ); Wed, 28 Sep 2022 17:02:18 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C43027AC06 for ; Wed, 28 Sep 2022 14:01:34 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 130-20020a1c0288000000b003b494ffc00bso1521392wmc.0 for ; Wed, 28 Sep 2022 14:01:34 -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=hLfcCqGTFzGn2vf3gmoSYh29g/RSzwk0x3+pJar5VQ3ScWsooWJKDFwLJtEla/slWh WqDwe6Lw9fNUDYOQ8hQ2nXlvJSzh08f87Ut5/cOyqA4Nxx6qJ9shLIiv6JLo9mMkBVQj n6CjXSRUIsgIbKS40r1BAhuJG7GX8XBfMdDD+hb/VfgC9SNoRxfQqV+QADO7mXecnr+t Sv/XBG3dKci2+1GjbVrcHuHzhxwxD4rrX6gqTqw1kNRN5f5YSl2wjlRKZTH07dpzKcav VAk5vRgFi6XUI7NNVLPQd+GaKoJ7E0+kVR2l/DmhRKY95Q0ZR+LxC8cLSrDaa414lfNB KuxA== 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=HsQ1gM6M6juOR/74DEt4u5qg02lyNmX10kFciDRGIOIm+IdWkI5Hj+LIy2WEAs8QZc /L+7vkYbGFsCc+JBw+LmsKM7QNG8auXgUShZj/C+0ANwaiptxYhotMzpoePiD0UxyCZW Fd5rMvszH6XhBDECMwlnWPzyWnVRihzazfDQjhMye4gT7lzD9nJQqTmhOY1X/i+dW/b7 9gx1R/5OJMKCvB37IenXXpdnQTfoYoRtOB+GS0bPwuMKyXcyUUnnu+vnjkeEYY1QmCeK rYmbMs1fKnTqESrVEmQhcpQr2Je6+yWlgGDGYorwaAMKTB9w76YYZD9ozMD5tWJqzDuD Uo0w== X-Gm-Message-State: ACrzQf1QuJ/WhuxUt2t0g06XsVR4M5IY1cKcIebJqxqDfM6IHuZdsyfm 8w9IYiRedsLaZOUd76cGORiB0g== X-Received: by 2002:a05:600c:a185:b0:3b4:ffb5:63b7 with SMTP id id5-20020a05600ca18500b003b4ffb563b7mr8484695wmb.169.1664398893089; Wed, 28 Sep 2022 14:01:33 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 14:01:32 -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 v7 07/29] thermal/drivers/exynos: Use generic thermal_zone_get_trip() function Date: Wed, 28 Sep 2022 23:00:37 +0200 Message-Id: <20220928210059.891387-8-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: 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