From patchwork Tue Sep 27 14:32:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12990734 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 A7396C6FA8E for ; Tue, 27 Sep 2022 14:34:22 +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=mhfzgrom5oSav0O10og4H71uF7hH8UgHMowPkjlWf58=; b=q2ByeqrRQ5h6pj 5B34IDE1YV0sYhkATu/Q7lSA7EKytWLIbZrI1x7fZ4ZZpAFMhYgk+NtSEBjuuKSYxWOtJKTdeAHxO Zlz9+dCg46vYvjQSduFz4V0h+DdfVvkY/7RUqCpCaXYvbNhIBPB+tU/Jy96LkbPeV6Pf3m1SpyZ5y z4Gbd74PAl1imU4yD9WG+piSv3tBag2/Xy3FcO4AhtUv5CYKqmHhvMiplGUSVlYuvrXZEZc6So8aN 2rkDaS40ga9JPNVPksODigmgibaKTfh6vzmxTCLSzvqUWg7R51f0ltSXFI6d9qLBq9cX7MWjwc4in 2tZLDzPkZH6OZP5qQZFA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1odBdz-00BFyL-14; Tue, 27 Sep 2022 14:33:07 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1odBdw-00BFwb-9F for linux-arm-kernel@lists.infradead.org; Tue, 27 Sep 2022 14:33:05 +0000 Received: by mail-wm1-x336.google.com with SMTP id fn7-20020a05600c688700b003b4fb113b86so5584375wmb.0 for ; Tue, 27 Sep 2022 07:33:01 -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=YJPNu2c2u+YKcdthIFBPXjWjaT1chO3O3GL7U5n2dhQeOjZRu1KSY3TpcBOnAdw6VM eJtaDYcg51DJ4rBQPHA/wm3FuvKxYuCLU2AyuArdEdzbxWBF9DZKOJnGyyTnMNrzwjoJ kPHLxJWtwSL3EhYst+wIDtlKw1cxdlzIQUihK4dfuDjziLy0wvvwpDLRssLkI163l1/U r58oQRQ17wI+i81Gkp53gIjGgrNBf/OqKnH7W5iN40r+bdP40rlQ3n04TurYT8SQzFaB THoRhoVL92omDNVO2IKzEqk8tyaNjeh+7bcsM/QvVGw952ZcRV42itpl26Sm/E+C87nc 0rLQ== 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=75QMBiXFFsni8nd7ubf3lIhUbkpsv6TtnbUT6kMEmu0Ti5JUK5ZNklRvKyGGRrN9zu 5NA7jO9uEh6+k3vzRLZUKkSNCPK3OWe5sSQlrMhJEXUnQ7zsp/Mlyua4Gyx836lHDLFS BssvP3ryRtL8jgnQUQxkCGOSj+UBx65dc/KqjLaKipWJ9/DT/XI2qMdEEcj+Cr+qXVJl PIZbhZfcj8UqCVnF2JgWH+O+B0yzBUGG9KZaZr24PDJca1osVmdyv08ZDs/92y+q2yXc GvXTCAWH9lhDIIcj0b4SlIS/N28xY2c8RO5+cY0Lu8krUhCshTxV4SRkiEA2paitJ/Gt 0Uog== X-Gm-Message-State: ACrzQf2thodOPBSFCS8JIcY8DEolksP2IEjmlUcBPa9D9MPeEA6btAI2 8W7qygovaf7Ud8wJEvhmdXaklw== X-Google-Smtp-Source: AMsMyM52NmZE0NWZhXx9GyPvDR4jm+337wtjG/jlxB7ilRKJ6uNr1G2Zydb+y/1qaVRdmd3eg5r1qg== X-Received: by 2002:a7b:cb41:0:b0:3b3:34d6:189f with SMTP id v1-20020a7bcb41000000b003b334d6189fmr2985755wmj.6.1664289179788; Tue, 27 Sep 2022 07:32:59 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id l6-20020a05600c4f0600b003b4924493bfsm17518371wmq.9.2022.09.27.07.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 07:32:59 -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, Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Amit Kucheria , Alim Akhtar , linux-samsung-soc@vger.kernel.org (open list:SAMSUNG THERMAL DRIVER), linux-arm-kernel@lists.infradead.org (moderated list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES) Subject: [PATCH v6 07/29] thermal/drivers/exynos: Use generic thermal_zone_get_trip() function Date: Tue, 27 Sep 2022 16:32:17 +0200 Message-Id: <20220927143239.376737-8-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927143239.376737-1-daniel.lezcano@linaro.org> References: <20220927143239.376737-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-20220927_073304_350358_E9B8A783 X-CRM114-Status: GOOD ( 17.44 ) 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 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 */ From patchwork Tue Sep 27 14:32:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12990735 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 A1B84C6FA8E for ; Tue, 27 Sep 2022 14:34:29 +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=O9wvLqR9SRMzpM/g0XUQvpEf9e195aL14K53ZPFcsfU=; b=HZV0GdVgpgwVLa LuigbL4EDthE8GjSa/hm1LW1iVoyibmnXRn5rKb4T8joXUBSUoDu3x6+XsY+KmDKWkcoO8OLnJK5r paz9jz9DxkCIJvWt+pr9uVhw5de3B85q5r0yvhFDUbE7C/9+6jULTADP2S9TG8xBx23ucjgLLLNor Jk6uvHfymTCnKxj7tJKKaM5sEWuy5GrowtVA1f5cLVALaccinp/ko9t4P5H7AOQbBNx49NDlJX8K2 L+ooPH/PQpztAVQJ//arm5B0QTUCR1FVPDPIdZWDED6s0tc3EN0HloWwIDkf/mlPZzCpUT4hJCkYE Z+VnqKYlASUsJcsqoZ7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1odBe9-00BG2M-J2; Tue, 27 Sep 2022 14:33:17 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1odBdz-00BFwx-2J for linux-arm-kernel@lists.infradead.org; Tue, 27 Sep 2022 14:33:08 +0000 Received: by mail-wm1-x333.google.com with SMTP id t4so6659687wmj.5 for ; Tue, 27 Sep 2022 07:33:03 -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=YzUTWEHUQYeukAyJEfTuM3PzyJlxwwnF0DoykmVbPWw=; b=aaJjumvNEBmO1pdqhzLUg45NBZhTSmGrIjUIvzX5EMVjt3/hYkgkgZt5Gg3aTUuSH5 hWBl9VrxJGUtRE6gwub6BebrvJ/P+pALn7oOqeTQAMLKl6SQI6YsEgEB5UiG+YFhIu10 0F51+qNmFxwByMXyhJb4fMML5XtZEVNijQrzBAKc0lJoAF+QnaD3RE3EUgUtKUJDacdM ttEchCaS2ZQs4A/ZmmxZw2NpHGuxH2E91NRkNUk/qkKETwCePwXv54dflV0AD4cCPw1a iV5wysatnt4wAYko9Sh1QCPbOfvXQZbo3n3v49fNUa6CiOAeZ8XXWm540NMZ82itxZb9 VirA== 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=YzUTWEHUQYeukAyJEfTuM3PzyJlxwwnF0DoykmVbPWw=; b=opYGuDI8T/gMZ3dK3/36Izwz9HELf+y6uOmudUEuz7ds5X2EZzyoEFvrpWeIzXcx9c K6dTQ/TkmnovV3+K3d1ISEBNRpE8ZT3gAum4k/ujyDsBhl2nRY+K7Ai7agTwGkASz6fB INjswrUwB3sX1LOuS//jPTjZSoM/Q8XJzDlmzDq978jHdEkC9+qDzDdom1vBy0UEjI3w ZqM0GwDrIiM9OpOiOI138GW/lB768IGGRKVlr8LEpOzcITsRRgu81G+Y4zkTo3D1rML4 OFscYZky8z2QFoN5AvNOwmJcuvtFJZKQfR2V74HfCTH/7j3gxyOA4np1Yf30KPHwSW0d DFQw== X-Gm-Message-State: ACrzQf3viMdeXmHFAoGxfORfkzfq041es5TDyRFKkPIfJeDTD/BIKIS3 z4PO88wieZ1eUbPflqJilvOkjA== X-Google-Smtp-Source: AMsMyM5AJFAJVhSq7o/pFKDyWc1CQ6N8nrzebmubgUQtwJScCNIuDHbeaDWWJ2PNPq5i0lLwMTTn/w== X-Received: by 2002:a05:600c:35c5:b0:3b4:bf50:f84a with SMTP id r5-20020a05600c35c500b003b4bf50f84amr2894313wmq.22.1664289181760; Tue, 27 Sep 2022 07:33:01 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id l6-20020a05600c4f0600b003b4924493bfsm17518371wmq.9.2022.09.27.07.32.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 07:33:01 -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, Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Amit Kucheria , Alim Akhtar , linux-samsung-soc@vger.kernel.org (open list:SAMSUNG THERMAL DRIVER), linux-arm-kernel@lists.infradead.org (moderated list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES) Subject: [PATCH v6 08/29] thermal/drivers/exynos: of_thermal_get_ntrips() Date: Tue, 27 Sep 2022 16:32:18 +0200 Message-Id: <20220927143239.376737-9-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927143239.376737-1-daniel.lezcano@linaro.org> References: <20220927143239.376737-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-20220927_073307_129890_1BCE7D1F X-CRM114-Status: GOOD ( 13.85 ) 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 core framework allows to get the number of thermal trips, use it instead of visiting the thermal core structure internals. Signed-off-by: Daniel Lezcano Reviewed-by: Krzysztof Kozlowski --- drivers/thermal/samsung/exynos_tmu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 0e33d32a9d2e..91e6860b5ec4 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -260,6 +260,7 @@ 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; + int num_trips = thermal_zone_get_num_trips(tzd); unsigned int status; int ret = 0, temp; @@ -271,12 +272,12 @@ static int exynos_tmu_initialize(struct platform_device *pdev) goto out; } - if (of_thermal_get_ntrips(tzd) > data->ntrip) { + if (num_trips > data->ntrip) { dev_info(&pdev->dev, "More trip points than supported by this TMU.\n"); dev_info(&pdev->dev, "%d trip points should be configured in polling mode.\n", - (of_thermal_get_ntrips(tzd) - data->ntrip)); + num_trips - data->ntrip); } mutex_lock(&data->lock); @@ -289,7 +290,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev) ret = -EBUSY; } else { int i, ntrips = - min_t(int, of_thermal_get_ntrips(tzd), data->ntrip); + min_t(int, num_trips, data->ntrip); data->tmu_initialize(pdev); From patchwork Tue Sep 27 14:32: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: 12990736 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 93E97C6FA83 for ; Tue, 27 Sep 2022 14:34: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=6dN+3AOO95WL3XVe8Mlfc4M3KJH7NWXmGWuvtu3YSkg=; b=0wlxBzZ3wnCOUI 0hGCpRt98npsB/0Z29eymrDshyKBzajWPmES5bUymh9pqGAJB9G/gObPiFLRJEOjDvtHz5nNWupnJ u7gL+ReG1RYpnDr8cb1JR44GqDiW7oOfyJi5w5iJ4xuzIhT7BOkUxIAqMZaTgstE1E1IIEiPWNfL8 1Jcg4XPbYofmEFX0Y6s9LKfTadhjoPWGfrbpmdfuMRT+I57eHP7hxnGY/W3MHRfnVpowbcnDf5x/b UUX1teben+xioamHNz0wgohmxHcBLGOsbnYGWoz5Is9JBr+/2vG50U7X6y9grDlIbp4rTPV2I1e1I SXqtckCCgaOh7ZRI90bg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1odBeK-00BG5B-AN; Tue, 27 Sep 2022 14:33:28 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1odBe0-00BFxh-21 for linux-arm-kernel@lists.infradead.org; Tue, 27 Sep 2022 14:33:09 +0000 Received: by mail-wr1-x434.google.com with SMTP id cc5so15312771wrb.6 for ; Tue, 27 Sep 2022 07:33:04 -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=7e6ctEATW9s/XP6ppX0yJV3WjnU6tGYDDticrBE+dlY=; b=SEmC5HLruQb91q4xBajU66upItPLiebtVT+iFt8mtN7HOClv+DHAX4ENbahzbJnTwb SEdAu8gmbCLC6NEOOseU4HT3h/Yq+/aPIFuNY2b0Rl14tTKlF2KAwOHr2wcE7+8Mss66 +mybXU0pcrFQ5Z/pd0kQJ01p5cm9UwtTgjZUAWh+7YrcP3DF3XF4JmaeLwMMscQG9oKv 1F8ywgXTIUVnl/BL0XYojIghFRujPhMOaPy6ASX4QsLgzPp4tFXsX0sfG8zRYWbfVihU Y3pBO0vq+Cyqa3j5R5kU+FkNc32w8niSCS1RKh9aLwDsBITjQ6VFxjsrsu3fNOLE2UyI R0XQ== 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=7e6ctEATW9s/XP6ppX0yJV3WjnU6tGYDDticrBE+dlY=; b=gKfXAoxIO7qXNh+zH1O3yrXHHZgKtDu4IWzC8M3bht5kc9F3rc1Ml7zNnbb3T/qWyf dtg+JWKZRNCHpvKlTQzDplhGVsF30iYzFscWjIV78gGt0tJ6GIQiZC8gcE/jVabkAOya nFIljrY/+OzD9BwOsKqVoVq9+9qWED+ISDG2LtxAoNASj3AJHPCGoq9osQ+G76aDye6c lQqs718q1tBlPVa2Seld+EXQLjOwRcNZJM1Kj31EO9dA4jd2+leyi+UiTIhAEwvWS7cx dB0Q5lKAi4L3jzf9WwckZEpTkJr2Q+uuDgceZt5RO5e46Zu6tTR9b97Pxg55Bxamjd5Y 6QKQ== X-Gm-Message-State: ACrzQf0Mud4X+gpp1pb7t4xUdj77fHPEP9VsN8CoBFy4IHHOPxJI8Qmj q2EYD2OdVb6JfJCn3B4ShvDbWQ== X-Google-Smtp-Source: AMsMyM6+gMUdLIWCRExVkHM3ZcD1DnU1ZN99swSZ69fg1w96jdY+BmwDhRzTfea+KoLj36DG3IUmAw== X-Received: by 2002:adf:ebcf:0:b0:22c:9eb4:d6f6 with SMTP id v15-20020adfebcf000000b0022c9eb4d6f6mr8180737wrn.251.1664289183486; Tue, 27 Sep 2022 07:33:03 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id l6-20020a05600c4f0600b003b4924493bfsm17518371wmq.9.2022.09.27.07.33.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 07:33:03 -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, Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Amit Kucheria , Alim Akhtar , linux-samsung-soc@vger.kernel.org (open list:SAMSUNG THERMAL DRIVER), linux-arm-kernel@lists.infradead.org (moderated list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES) Subject: [PATCH v6 09/29] thermal/drivers/exynos: Replace of_thermal_is_trip_valid() by thermal_zone_get_trip() Date: Tue, 27 Sep 2022 16:32:19 +0200 Message-Id: <20220927143239.376737-10-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927143239.376737-1-daniel.lezcano@linaro.org> References: <20220927143239.376737-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-20220927_073308_124720_62348B98 X-CRM114-Status: GOOD ( 13.43 ) 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_zone_get_trip() does the same check as of_thermal_is_trip_valid(). Replace the call to of_thermal_is_trip_valid() by thermal_zone_get_trip(). Signed-off-by: Daniel Lezcano --- drivers/thermal/samsung/exynos_tmu.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 91e6860b5ec4..34b460092308 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -554,13 +554,14 @@ static void exynos4210_tmu_control(struct platform_device *pdev, bool on) { struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct thermal_zone_device *tz = data->tzd; + struct thermal_trip trip; unsigned int con, interrupt_en = 0, i; con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL)); if (on) { for (i = 0; i < data->ntrip; i++) { - if (!of_thermal_is_trip_valid(tz, i)) + if (thermal_zone_get_trip(tz, i, &trip)) continue; interrupt_en |= @@ -584,13 +585,14 @@ static void exynos5433_tmu_control(struct platform_device *pdev, bool on) { struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct thermal_zone_device *tz = data->tzd; + struct thermal_trip trip; unsigned int con, interrupt_en = 0, pd_det_en, i; con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL)); if (on) { for (i = 0; i < data->ntrip; i++) { - if (!of_thermal_is_trip_valid(tz, i)) + if (thermal_zone_get_trip(tz, i, &trip)) continue; interrupt_en |= @@ -615,13 +617,14 @@ static void exynos7_tmu_control(struct platform_device *pdev, bool on) { struct exynos_tmu_data *data = platform_get_drvdata(pdev); struct thermal_zone_device *tz = data->tzd; + struct thermal_trip trip; unsigned int con, interrupt_en = 0, i; con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL)); if (on) { for (i = 0; i < data->ntrip; i++) { - if (!of_thermal_is_trip_valid(tz, i)) + if (thermal_zone_get_trip(tz, i, &trip)) continue; interrupt_en |= From patchwork Tue Sep 27 14:32: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: 12990737 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 546E4C6FA83 for ; Tue, 27 Sep 2022 14:34:52 +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=78F2AfKVLdhe780bioU2XER+/Bp346Ozc5UfLQJ1tlo=; b=ytRur4bVzy8b45 jmzjmVIG88q+v4Qszx5XCjPYwnN+mCqVD9KYKToRjHBW3gUQenrm+PZKqfPQnhH5+U7koIrTAPNKb k2+gV490st2j6Q34Y8B3gR2gx04fA/9mVZRjDEMk20sxGyVmQF/z8vC0xcaVZztZO6OyqKKARavsN Ka0bwB3vjpF+ooECjtPLAG/ODtTi6c3bfOJo7QzEoEzTs3APyA8JOfRpiUEBaRevpjKoHRYKWBf0x TI1GGdczevBflV9CYfhoyFkHs2O2a+noywI+Q1DlA4LjigFMXwbWmD6ss6qDV0JCIj9FPhMKkw0KR 196CcXZ9AlYx2bXABGnw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1odBeX-00BG9m-Gn; Tue, 27 Sep 2022 14:33:41 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1odBe3-00BFzA-0z for linux-arm-kernel@lists.infradead.org; Tue, 27 Sep 2022 14:33:12 +0000 Received: by mail-wr1-x435.google.com with SMTP id bq9so15328814wrb.4 for ; Tue, 27 Sep 2022 07:33:08 -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=zhkHfGU+506U13gs0KttMlfYYtmPZTAW+1/ApMCut14=; b=XpDZF33EE05uIngBWvaB9h8R9rb9f1/0oqiaz46R/MC+bZp32EXGqmDwvGUVDw3STw ug8Tmjebv8p30ixOK43bIUQPqnNS/q8y48axCr2YfaQWU8iy8QIcz5Csdq1fIG1K5lyN Qr3HtuD2TwMPsp6T+ni3H638UquEajgMyZPjkjIjW1oSRlnJy/03nhihdHspmtzz4lI1 bCLUnZlYrVxVRyrgnZ1sTGsPUq7slfsG84lWycRqu/Ehk4woS/BS5Ha4tk66MHUIs47g cGUGkfbW5M3CwxyPKYG9FzO4PYrYxUh5GtFsZPUxZ25ZFgvpao40TihjmiOhdnVt2ujo mTcQ== 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=zhkHfGU+506U13gs0KttMlfYYtmPZTAW+1/ApMCut14=; b=taz/VJdeBjGAVBd/drgNwJSmWfmzXzEoN+WdD4CBpSBhxVCHCvYPnq9Zo//FUgblnB cl7d6L4rDjd0XXck+mBhJBXMGxUzYhAzi8Sfg8GuoPrTRxladkXyx1r9hBfd87LnPRdo buufU2utOWSBoPvcIzhsWVuKNa5ungLOSm3K3nMU9zzSipR4n8Ngk+kVzSM/LORwkUWC sLkrfblKhD9f1NFuy5PgeTWQk3c76nlF1DP01bMaKiq7PjjHqebO5t9kGjI4HN31axnV cWpfwqohCLzuRau+F/FrfFUgnjx0bU7CnokQIzbIqehsKECcdaERsjMu3WiBSqUxCclT DYTQ== X-Gm-Message-State: ACrzQf0jRz3KNxJh5XENng97JE39WeiH9uzuoFItZMY1rdZd9t0oyn0n r9LM4ejQyw+N97df0+87X3BpPDDevZVjXg== X-Google-Smtp-Source: AMsMyM6/RN9mXaJDzlUEuh6QRQ3y5A7USoF8Z3eA2/qD/SMsGfNyXN8jxDxtubAvUwWKcX3k6jKo0Q== X-Received: by 2002:a5d:50c1:0:b0:228:d77e:4b33 with SMTP id f1-20020a5d50c1000000b00228d77e4b33mr16694877wrt.677.1664289187297; Tue, 27 Sep 2022 07:33:07 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id l6-20020a05600c4f0600b003b4924493bfsm17518371wmq.9.2022.09.27.07.33.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 07:33:06 -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, Kunihiko Hayashi , Amit Kucheria , Masami Hiramatsu , linux-arm-kernel@lists.infradead.org (moderated list:ARM/UNIPHIER ARCHITECTURE) Subject: [PATCH v6 11/29] thermal/drivers/uniphier: Use generic thermal_zone_get_trip() function Date: Tue, 27 Sep 2022 16:32:21 +0200 Message-Id: <20220927143239.376737-12-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927143239.376737-1-daniel.lezcano@linaro.org> References: <20220927143239.376737-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-20220927_073311_112370_E94E43E9 X-CRM114-Status: GOOD ( 14.81 ) 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 | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/thermal/uniphier_thermal.c b/drivers/thermal/uniphier_thermal.c index 4111d99ef50e..277ae300c5b1 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,18 @@ 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; + + ret = thermal_zone_get_trip(tdev->tz_dev, i, &trip); + if (ret) + return ret; + + 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) { From patchwork Tue Sep 27 14:32:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12990738 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 19D22C6FA93 for ; Tue, 27 Sep 2022 14:35:12 +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=rC7VzmfyDg/a3jsZFMqHdzRbAMSkSiO4XK0b52m8aL0=; b=Y4dXtUsaeISHm+ LA030BLrLu5/OT0vdqQV2FQs97E/nncj2OqtO8LueldY69o+nNif+Vy05geaAw5OJS2tf19qdWbF9 gfsHP/tjkmQcP0wlngLQFF8Zt5bJvH5T5B9zbK4FjtbZbZIvXY4cO+e7aVu4vfsndFx+nz5P6leIo 8rZGYOgS4KpClAHSozzh7OyThlexZ4H22b/Wmb7gLXxyHXV+zOh4NAaryaLFsx2HfrSX5a+TJC3aQ z7IVLbNKgNWlcBb0OM17oM5HZhoyk0A0Cd3DfdrHkGpU6hgLwG5+xZQtkYQn1ovuTzX0wIqfqznqv BNEAhQro6a8LvO7GSzGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1odBer-00BGIu-7T; Tue, 27 Sep 2022 14:34:01 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1odBeG-00BG3Q-SZ for linux-arm-kernel@lists.infradead.org; Tue, 27 Sep 2022 14:33:26 +0000 Received: by mail-wm1-x331.google.com with SMTP id k3-20020a05600c1c8300b003b4fa1a85f8so5549253wms.3 for ; Tue, 27 Sep 2022 07:33:21 -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=xYvlHjUzJ1gAdl8KtmAH0mCHcP29B+tCMOTUThwt7jg=; b=QX9BzKfcBASFxtQ4MW5JxvOb+wYygM//84qzelToOCwnFzzj5bbXwqEbU1/NYlvJQM AkUkDeVCAjOfvJFh0MU4OAb/VBRo+Mn4K436Cf4fjxdcMaiZRHR07mMOT5fVeTQP2RNx 5OZXidycwCa6+zVEESgHCwQVfozCwhI9/Pn0aFLIxG1JUT/azmAceWiGedcdFeMLUoIp nyUGrEwyg/nH35MK783BDU/DR+uvwJuONcQ7kYaIuI6opC0/QAhx05Vof1nL1841SU4d 197lQvxGO4vyx8fzToCi7urGRKs8IGQewhXPHh2rrWlBsgcpGz6ZcvJjYFhQrT95Rpx1 97IQ== 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=xYvlHjUzJ1gAdl8KtmAH0mCHcP29B+tCMOTUThwt7jg=; b=Xh7NMAnB5dZsw179SihD/zul7lC0mxIaZgPTuTnq8N51CxYKECz56M8d/GzdLLqdIR rNiSPMxXJTRCvhLJ9xlDzeqqETVFBH5h143EOpsgevxBrK7vV4UOCgW9O0mGtfD7yS/y Q5rNY1pqcVRI811vGykXxAnVpQ3uFlPpPtaxBl7jq2K1OwNrWvsZyor2FQIUn2sQRywI X/cVorgU51RzhjInrakFF+kr/ArvRwgHGLmk0NXE9wTnWXA42PV34HRgMiOkPsxxRFeS 0NwbN9Gwq4erAyDX+76K4YPdCXVZk0YDRVqOQ84JjAuB2t7Kt1r70myzFhqnoRicCO2l Kniw== X-Gm-Message-State: ACrzQf3MYgxe8S9hE2d5d0ZRcAbgb76FjMcXHU1ZTNjGS7D4HjVGsA2V HuTKbKaYSI//wuqtDPyFJ1dH7A== X-Google-Smtp-Source: AMsMyM5PXZObBCto2bbeZ7EKxHpVSI3muQpkTPAKmWgm51HjCxxYbGeavBFlT+95vPLqtdq0dPdL2g== X-Received: by 2002:a05:600c:1e13:b0:3b4:74c3:620b with SMTP id ay19-20020a05600c1e1300b003b474c3620bmr3027122wmb.168.1664289200324; Tue, 27 Sep 2022 07:33:20 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id l6-20020a05600c4f0600b003b4924493bfsm17518371wmq.9.2022.09.27.07.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 07:33:19 -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, Amit Kucheria , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE) Subject: [PATCH v6 21/29] thermal/drivers/imx: Use generic thermal_zone_get_trip() function Date: Tue, 27 Sep 2022 16:32:31 +0200 Message-Id: <20220927143239.376737-22-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927143239.376737-1-daniel.lezcano@linaro.org> References: <20220927143239.376737-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-20220927_073324_954079_93C114BF X-CRM114-Status: GOOD ( 18.60 ) 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/imx_thermal.c | 72 +++++++++++++---------------------- 1 file changed, 27 insertions(+), 45 deletions(-) diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 16663373b682..fb0d5cab70af 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -76,7 +76,6 @@ enum imx_thermal_trip { IMX_TRIP_PASSIVE, IMX_TRIP_CRITICAL, - IMX_TRIP_NUM, }; #define IMX_POLLING_DELAY 2000 /* millisecond */ @@ -115,6 +114,11 @@ struct thermal_soc_data { u32 low_alarm_shift; }; +static struct thermal_trip trips[] = { + [IMX_TRIP_PASSIVE] = { .type = THERMAL_TRIP_PASSIVE }, + [IMX_TRIP_CRITICAL] = { .type = THERMAL_TRIP_CRITICAL }, +}; + static struct thermal_soc_data thermal_imx6q_data = { .version = TEMPMON_IMX6Q, @@ -201,8 +205,6 @@ struct imx_thermal_data { struct thermal_cooling_device *cdev; struct regmap *tempmon; u32 c1, c2; /* See formula in imx_init_calib() */ - int temp_passive; - int temp_critical; int temp_max; int alarm_temp; int last_temp; @@ -279,12 +281,12 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp) /* Update alarm value to next higher trip point for TEMPMON_IMX6Q */ if (data->socdata->version == TEMPMON_IMX6Q) { - if (data->alarm_temp == data->temp_passive && - *temp >= data->temp_passive) - imx_set_alarm_temp(data, data->temp_critical); - if (data->alarm_temp == data->temp_critical && - *temp < data->temp_passive) { - imx_set_alarm_temp(data, data->temp_passive); + if (data->alarm_temp == trips[IMX_TRIP_PASSIVE].temperature && + *temp >= trips[IMX_TRIP_PASSIVE].temperature) + imx_set_alarm_temp(data, trips[IMX_TRIP_CRITICAL].temperature); + if (data->alarm_temp == trips[IMX_TRIP_CRITICAL].temperature && + *temp < trips[IMX_TRIP_PASSIVE].temperature) { + imx_set_alarm_temp(data, trips[IMX_TRIP_PASSIVE].temperature); dev_dbg(&tz->device, "thermal alarm off: T < %d\n", data->alarm_temp / 1000); } @@ -330,29 +332,10 @@ static int imx_change_mode(struct thermal_zone_device *tz, return 0; } -static int imx_get_trip_type(struct thermal_zone_device *tz, int trip, - enum thermal_trip_type *type) -{ - *type = (trip == IMX_TRIP_PASSIVE) ? THERMAL_TRIP_PASSIVE : - THERMAL_TRIP_CRITICAL; - return 0; -} - static int imx_get_crit_temp(struct thermal_zone_device *tz, int *temp) { - struct imx_thermal_data *data = tz->devdata; - - *temp = data->temp_critical; - return 0; -} - -static int imx_get_trip_temp(struct thermal_zone_device *tz, int trip, - int *temp) -{ - struct imx_thermal_data *data = tz->devdata; + *temp = trips[IMX_TRIP_CRITICAL].temperature; - *temp = (trip == IMX_TRIP_PASSIVE) ? data->temp_passive : - data->temp_critical; return 0; } @@ -371,10 +354,10 @@ static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip, return -EPERM; /* do not allow passive to be set higher than critical */ - if (temp < 0 || temp > data->temp_critical) + if (temp < 0 || temp > trips[IMX_TRIP_CRITICAL].temperature) return -EINVAL; - data->temp_passive = temp; + trips[IMX_TRIP_PASSIVE].temperature = temp; imx_set_alarm_temp(data, temp); @@ -423,8 +406,6 @@ static struct thermal_zone_device_ops imx_tz_ops = { .unbind = imx_unbind, .get_temp = imx_get_temp, .change_mode = imx_change_mode, - .get_trip_type = imx_get_trip_type, - .get_trip_temp = imx_get_trip_temp, .get_crit_temp = imx_get_crit_temp, .set_trip_temp = imx_set_trip_temp, }; @@ -507,8 +488,8 @@ static void imx_init_temp_grade(struct platform_device *pdev, u32 ocotp_mem0) * Set the critical trip point at 5 °C under max * Set the passive trip point at 10 °C under max (changeable via sysfs) */ - data->temp_critical = data->temp_max - (1000 * 5); - data->temp_passive = data->temp_max - (1000 * 10); + trips[IMX_TRIP_PASSIVE].temperature = data->temp_max - (1000 * 10); + trips[IMX_TRIP_CRITICAL].temperature = data->temp_max - (1000 * 5); } static int imx_init_from_tempmon_data(struct platform_device *pdev) @@ -743,12 +724,13 @@ static int imx_thermal_probe(struct platform_device *pdev) goto legacy_cleanup; } - data->tz = thermal_zone_device_register("imx_thermal_zone", - IMX_TRIP_NUM, - BIT(IMX_TRIP_PASSIVE), data, - &imx_tz_ops, NULL, - IMX_PASSIVE_DELAY, - IMX_POLLING_DELAY); + data->tz = thermal_zone_device_register_with_trips("imx_thermal_zone", + trips, + ARRAY_SIZE(trips), + BIT(IMX_TRIP_PASSIVE), data, + &imx_tz_ops, NULL, + IMX_PASSIVE_DELAY, + IMX_POLLING_DELAY); if (IS_ERR(data->tz)) { ret = PTR_ERR(data->tz); dev_err(&pdev->dev, @@ -758,8 +740,8 @@ static int imx_thermal_probe(struct platform_device *pdev) dev_info(&pdev->dev, "%s CPU temperature grade - max:%dC" " critical:%dC passive:%dC\n", data->temp_grade, - data->temp_max / 1000, data->temp_critical / 1000, - data->temp_passive / 1000); + data->temp_max / 1000, trips[IMX_TRIP_CRITICAL].temperature / 1000, + trips[IMX_TRIP_PASSIVE].temperature / 1000); /* Enable measurements at ~ 10 Hz */ regmap_write(map, data->socdata->measure_freq_ctrl + REG_CLR, @@ -767,10 +749,10 @@ static int imx_thermal_probe(struct platform_device *pdev) measure_freq = DIV_ROUND_UP(32768, 10); /* 10 Hz */ regmap_write(map, data->socdata->measure_freq_ctrl + REG_SET, measure_freq << data->socdata->measure_freq_shift); - imx_set_alarm_temp(data, data->temp_passive); + imx_set_alarm_temp(data, trips[IMX_TRIP_PASSIVE].temperature); if (data->socdata->version == TEMPMON_IMX6SX) - imx_set_panic_temp(data, data->temp_critical); + imx_set_panic_temp(data, trips[IMX_TRIP_CRITICAL].temperature); regmap_write(map, data->socdata->sensor_ctrl + REG_CLR, data->socdata->power_down_mask); From patchwork Tue Sep 27 14:32:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 12990739 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 F2077C6FA82 for ; Tue, 27 Sep 2022 14:35:31 +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=mMjKODOPuxNSMHRx6sLDPA7/X4hPA9FdN7Okm/tRvOo=; b=PHIC1YG3O92wIw vog2J2WlOyoOVZ2R5vTYlEXtXzCWRI4h67+7U4Ks9PNXIromRtwV8kZyInvOIZisJ2/DuB3Qo4Fet CjrhGICeiWk2OFO3IwA4gratrtMu609nnk5jRLlbiro26bs8nJO36Wiq3ljGwQ9zTjq4Ru0Rjx7WJ BTtUsv0B25ILG/LJwklHGfJmGPlr67CHOjBu9gU2UEceZ2afYxrn+GUiH8yws6tkRlXms0ZYteo8+ Fnh24onUc8LLNif6dMRRMuENPFXAjhRyrUW0sW5NVuRXcv3ZWbSbO5sLk0r993za9LnZanhRZAvKz uQ05d20UGbTHnSkbequg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1odBf6-00BGR4-A3; Tue, 27 Sep 2022 14:34:16 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1odBeJ-00BG46-6m for linux-arm-kernel@lists.infradead.org; Tue, 27 Sep 2022 14:33:29 +0000 Received: by mail-wr1-x42f.google.com with SMTP id r7so15342878wrm.2 for ; Tue, 27 Sep 2022 07:33:24 -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=RuOkdBUevpNwOF5uxKYPUxVuiSYnY/XeiYrwbyLTKVs=; b=k8h9lvDET/68SfhS9eSROv/pLI+kzVzlDtP1wnyeA0Og+Q9nmzMmAfzLTwVM0QyiRN bYdCuTSQGqoZuKD/P7klIMZxMzkD2UhPJOJV4A+bOHkCJfxQM2YmXpg34OyI7iSmBxcn 23WV0d/LO/38lNgwKwZc7CqNfjBTxm7Kcwq0NduReGCF7udLJEO+cewAux52hmaHN7RV IL0DsyCxPTvCA/+ptYFFGVMs2JVsU1X9RUwsjPLygk8n2b9tS4y0HjJjMe8m+j0e11hM JGivnKjaI79qX+asnRuPa8QmT4AAKZsGYiI0Qjxs+7cc6jiudc7hdt9DEGHLv3xkhxnF 6dSQ== 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=RuOkdBUevpNwOF5uxKYPUxVuiSYnY/XeiYrwbyLTKVs=; b=DNtWcxDpyvg3xGLEX7274LNCQZU2s5I8lTohabxhAlQ2YdJhQx7wX+kS/5U88L/hp4 VTOSMwbHZHqM64tKlyqh2PHfVvakZcKgB6Fsd0N8QvRryYTVlYk3pmPmiA1c38PwMIRp 4jA+QIRnZgrT2+Mq3VfM1KmvLmOzsp5jFgi5QLJgfzycVb5cnv8mqbkN/dQJ989Xc4qK dW3bcWXhAZTWCsEo0a5locLAC+E3CusFnSW1CBUrQxNZHQ5C/IZKpe+KRjSrYB4XSJZ6 BHxdtj7OqjAioqgO4Ez+tdjo88qW+a5v1yiQtYcaQ6cOMhnMpn0aMumMFM1gslrlcPpm X40w== X-Gm-Message-State: ACrzQf3F7mghK75rJ4/aYR7ENPAOyDjpiY1hJDxXzwaYefUIxq961TpO uw8ET4HGokNyVEucwK95PzsOrA== X-Google-Smtp-Source: AMsMyM6lFx3bEN+boegewxS3Me7Ygx9201Z5Zs+qWIIPdE3RKNXQ9iptgbbnB1UXfy/E5uHTTJJwzQ== X-Received: by 2002:a5d:5a15:0:b0:228:cd90:ccd with SMTP id bq21-20020a5d5a15000000b00228cd900ccdmr18304306wrb.658.1664289203517; Tue, 27 Sep 2022 07:33:23 -0700 (PDT) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id l6-20020a05600c4f0600b003b4924493bfsm17518371wmq.9.2022.09.27.07.33.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 07:33:23 -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, Amit Kucheria , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE) Subject: [PATCH v6 23/29] thermal/drivers/broadcom: Use generic thermal_zone_get_trip() function Date: Tue, 27 Sep 2022 16:32:33 +0200 Message-Id: <20220927143239.376737-24-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927143239.376737-1-daniel.lezcano@linaro.org> References: <20220927143239.376737-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-20220927_073327_286741_246F1394 X-CRM114-Status: GOOD ( 15.34 ) 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/broadcom/bcm2835_thermal.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/broadcom/bcm2835_thermal.c b/drivers/thermal/broadcom/bcm2835_thermal.c index 2c67841a1115..5485e59d03a9 100644 --- a/drivers/thermal/broadcom/bcm2835_thermal.c +++ b/drivers/thermal/broadcom/bcm2835_thermal.c @@ -18,6 +18,7 @@ #include #include +#include "../thermal_core.h" #include "../thermal_hwmon.h" #define BCM2835_TS_TSENSCTL 0x00 @@ -224,7 +225,8 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) */ val = readl(data->regs + BCM2835_TS_TSENSCTL); if (!(val & BCM2835_TS_TSENSCTL_RSTB)) { - int trip_temp, offset, slope; + struct thermal_trip trip; + int offset, slope; slope = thermal_zone_get_slope(tz); offset = thermal_zone_get_offset(tz); @@ -232,7 +234,7 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) * For now we deal only with critical, otherwise * would need to iterate */ - err = tz->ops->get_trip_temp(tz, 0, &trip_temp); + err = thermal_zone_get_trip(tz, 0, &trip); if (err < 0) { dev_err(&pdev->dev, "Not able to read trip_temp: %d\n", @@ -249,7 +251,7 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) val |= (0xFE << BCM2835_TS_TSENSCTL_RSTDELAY_SHIFT); /* trip_adc value from info */ - val |= bcm2835_thermal_temp2adc(trip_temp, + val |= bcm2835_thermal_temp2adc(trip.temperature, offset, slope) << BCM2835_TS_TSENSCTL_THOLD_SHIFT;