From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E999CC6FA82 for ; Tue, 27 Sep 2022 14:34:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232720AbiI0OeA (ORCPT ); Tue, 27 Sep 2022 10:34:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232448AbiI0OdE (ORCPT ); Tue, 27 Sep 2022 10:33:04 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 583EA659C1 for ; Tue, 27 Sep 2022 07:33:01 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id e10-20020a05600c4e4a00b003b4eff4ab2cso9548240wmq.4 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=pOAT5mgu/c0q5UX3hvfov6qpLgvZ5/yfUgm6e19SsCH0SiC8yNUd6/yD3oQGMYOP0/ Kjv3DCbHoSy+A7OriEPVk7F0gBOJfc/xV3r4hIrIBXwmGYAWgHU0Khu8A/Y+dLnD99EZ j34FOwXWcHBDAbZNAV1eImJFgK2bznLLnu9rbCLBDrzySkrUrVX/NrnrTLdqZ8s7OdGr XNMI5YLKxXBIW12XbdJ456SJp/9e8JFaAZrVO4DJDdriCLEnwddnt1Ke4IxkpvCb66gm wk9w6bB+3VnREC1038ETcTPrXn778NSAUgxFSZ6sOsxlRx1HRSsXmjxzjMiolNjmTKz3 BGXg== X-Gm-Message-State: ACrzQf1+VNgXUP4RkMXVbHo9p112T9ORDQq99oeeteRpoZHsdRYm0xmK A51dQtlRujr8Gcfn3oizojqjnw== 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 Content-Transfer-Encoding: 8bit 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 From mboxrd@z Thu Jan 1 00:00:00 1970 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 */ -- 2.34.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel