From patchwork Wed Feb 8 19:03:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 13133609 X-Patchwork-Delegate: geert@linux-m68k.org 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 493D9C636D7 for ; Wed, 8 Feb 2023 19:04:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231591AbjBHTEX (ORCPT ); Wed, 8 Feb 2023 14:04:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231588AbjBHTEV (ORCPT ); Wed, 8 Feb 2023 14:04:21 -0500 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 AD5D758280 for ; Wed, 8 Feb 2023 11:03:47 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id bg13-20020a05600c3c8d00b003d9712b29d2so2203567wmb.2 for ; Wed, 08 Feb 2023 11:03:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gNVN/OO+jfgI5RvM56FJVYGYKwTjLRnzHtKeSKViuh8=; b=f3557eDV+KHfVT++hnwi2wo0VAnOYvMdvVcfRK8Nji/dEenEWGvtQ8f184Z/eVHDpl 3VJx60468pDqvy3oMf71lW47Vikk2VEJMmosYze9XFvO8NHI3L47jB1JM1NkR3fh3kna AG0geGuH1PI1tAZ6grXJUCkg+jSpucp0ggYQWX3tstxnOobMyPzctzkXrrqbjXpy4Kxb TTtpwgFZr6qp9nNx4yJVfFv5JuyJpYv+o7WomccOBGf1oc9d17DmX3tlNKTjNDFUYnnD A8ACUGgLlHhsXLEPpx6YK+bSMzAebnN8mJ3Kpp4fNC94Nf08Li/xFLLtMNBzBiTxeV9C mA3w== 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:message-id:reply-to; bh=gNVN/OO+jfgI5RvM56FJVYGYKwTjLRnzHtKeSKViuh8=; b=yQiK6/SQoDn0w13LXh22swT85kkGQRN9K3BrdUb30O0YWnBrOFpFrUo9Dk95fdWNLE IPKJxggRA3gFEez6x8IbMXkC80w+IIGULEHtVdarkEvMNSQ/jsCn6s5D9L/JDq+zm/nI yv/Oe7FJoFC51uhajTFPP/w0Pnj8Lap0mgMPKZ2+TryCIOP1N9e9mzYd8kwaG2swFv9l eUvCx4897i/dxQuwBlcZYGPnEkHrHPxiyYVevHUH5taUF+lC8NQKWKjtlvE0kHWqymZl 3xt3oLItEjlXHoqRT5Y8BH2UTOWeiilIU/KlnbMiuZQcghLcvWXdYRNgNqnjugFOtibH VrJg== X-Gm-Message-State: AO0yUKVqHIpD2IhO+25zrRTgJJlSTNirpYEJwfk/yPuYKgvqZTNVYCJp QpZSvKYPdW5m9fa8RdVG0Cy0mQ== X-Google-Smtp-Source: AK7set80PmuLRQIV/7yvZj67igffYoysm1Ao6c0nxiz36R0NxuhtCHp46KA4pu2PnnIpzqt59kUALA== X-Received: by 2002:a05:600c:44d5:b0:3df:30c9:4865 with SMTP id f21-20020a05600c44d500b003df30c94865mr7394165wmo.26.1675883025680; Wed, 08 Feb 2023 11:03:45 -0800 (PST) Received: from sleipner.berto.se (p4fca2792.dip0.t-ipconnect.de. [79.202.39.146]) by smtp.googlemail.com with ESMTPSA id c12-20020adffb4c000000b002b6bcc0b64dsm14201382wrs.4.2023.02.08.11.03.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 11:03:45 -0800 (PST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Daniel Lezcano , Wolfram Sang , linux-pm@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH v2 1/3] drivers/thermal/rcar_gen3_thermal: Do not call set_trips() when resuming Date: Wed, 8 Feb 2023 20:03:31 +0100 Message-Id: <20230208190333.3159879-2-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230208190333.3159879-1-niklas.soderlund+renesas@ragnatech.se> References: <20230208190333.3159879-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org There is no need to explicitly call set_trips() when resuming from suspend. The thermal framework calls thermal_zone_device_update() that restores the trip points. Suggested-by: Daniel Lezcano Signed-off-by: Niklas Söderlund --- drivers/thermal/rcar_gen3_thermal.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c index 4c1c6f89aa2f..5a715a58f18b 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c @@ -556,12 +556,8 @@ static int __maybe_unused rcar_gen3_thermal_resume(struct device *dev) for (i = 0; i < priv->num_tscs; i++) { struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; - struct thermal_zone_device *zone = tsc->zone; priv->thermal_init(tsc); - if (zone->ops->set_trips) - rcar_gen3_thermal_set_trips(zone, zone->prev_low_trip, - zone->prev_high_trip); } return 0; From patchwork Wed Feb 8 19:03:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 13133610 X-Patchwork-Delegate: geert@linux-m68k.org 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 5586DC64EC7 for ; Wed, 8 Feb 2023 19:04:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231491AbjBHTEY (ORCPT ); Wed, 8 Feb 2023 14:04:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231598AbjBHTEV (ORCPT ); Wed, 8 Feb 2023 14:04:21 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B14EF53E6F for ; Wed, 8 Feb 2023 11:03:48 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id j23so2612956wra.0 for ; Wed, 08 Feb 2023 11:03:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jN3EiqJyvn4WjrvJBWvfv/N7NKVUHz807+CSDIxAiKk=; b=f2O7JSZ2YSDWC9F1IS7+KoE4SVzMqYi6vsR/Cnyuuw4I5w5fPw3ui2xKaNFJ0Tl6bR 80+ohGjc4x5jE2Dq22obS8UXraZ1enZuerkdCkCmNJjLZm97I4gYkqKYjv9q5mGtOfRP WDhMLUIxxQXGw0JdEECT9hN2Z28RPGkfZcTGuE3cvjK44DuBHaInuWMTdOpkGlBoo54D 3Y+hZmHi+oDrI2Uw54IfOQGLO/e11WbSwFgaNVrSYG01n3rju5dAEpB0/XorhCpu+Ed7 IE0FQaQ/2/CiWBOkhTvetPP9MQAxVQSnogQqv3kj6TT1xjIfyCt0lcp+fZS7uDwEDTrZ n8Lg== 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:message-id:reply-to; bh=jN3EiqJyvn4WjrvJBWvfv/N7NKVUHz807+CSDIxAiKk=; b=BNiC55pN2rKoSAVrkv1pna3t8Vih0KA4cXX5Ud+fr6SgACCX98uOOc6FRfyMjBuNbC mwM75Hd0n2+vbstLsIJymRHAzp/Tjv2M73WfobGUoSwnBVto0UysQorPLKv6g65IX/M3 uSdoIpGdOmTOshMSPuyzbqgOPlLiVs/DnbkZqjuY7LOTW97HI233TW5/frhIwji4zQRy kRreFm5rUoL2kcY0ikSyNVLlHtbRow+e4t4GW2FZf+UuUVLahhXkjmX8qEE+Z9MVtIdi XUFsH8UvWRSxop/Mfbb7EXfiOxKut+IVbUFneCu0921iAVbGpprQWD+mvyQMiP9uHugr HZ5w== X-Gm-Message-State: AO0yUKXDOGo2QaQW8WVWoz2hjnhMUud1EkeYuwyS4aMv9la2GRHKXUiV 62vYIGSotQTsafyuWCvo5WaJwA== X-Google-Smtp-Source: AK7set/IdpWkLrIuf+jbWO1nK4GHLhkWBnm/ElDGKSGklL4AHetwl1nQ9JFsRsUJoyWRADPXwMeGCA== X-Received: by 2002:adf:fac9:0:b0:2c4:645:da3f with SMTP id a9-20020adffac9000000b002c40645da3fmr1796644wrs.48.1675883026423; Wed, 08 Feb 2023 11:03:46 -0800 (PST) Received: from sleipner.berto.se (p4fca2792.dip0.t-ipconnect.de. [79.202.39.146]) by smtp.googlemail.com with ESMTPSA id c12-20020adffb4c000000b002b6bcc0b64dsm14201382wrs.4.2023.02.08.11.03.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 11:03:46 -0800 (PST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Daniel Lezcano , Wolfram Sang , linux-pm@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Wolfram Sang Subject: [PATCH v2 2/3] drivers/thermal/rcar_gen3_thermal: Create device local ops struct Date: Wed, 8 Feb 2023 20:03:32 +0100 Message-Id: <20230208190333.3159879-3-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230208190333.3159879-1-niklas.soderlund+renesas@ragnatech.se> References: <20230208190333.3159879-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The callback operations are modified on a driver global level. If one device tree description do not define interrupts, the set_trips() operation was disabled globally for all users of the driver. Fix this by creating a device local copy of the operations structure and modify the copy depending on what the device can do. Signed-off-by: Niklas Söderlund Reviewed-by: Wolfram Sang --- drivers/thermal/rcar_gen3_thermal.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c index 5a715a58f18b..2dfce4f09631 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c @@ -87,6 +87,7 @@ struct rcar_gen3_thermal_tsc { struct rcar_gen3_thermal_priv { struct rcar_gen3_thermal_tsc *tscs[TSC_MAX_NUM]; + struct thermal_zone_device_ops ops; unsigned int num_tscs; void (*thermal_init)(struct rcar_gen3_thermal_tsc *tsc); int ptat[3]; @@ -225,7 +226,7 @@ static int rcar_gen3_thermal_set_trips(struct thermal_zone_device *tz, int low, return 0; } -static struct thermal_zone_device_ops rcar_gen3_tz_of_ops = { +static const struct thermal_zone_device_ops rcar_gen3_tz_of_ops = { .get_temp = rcar_gen3_thermal_get_temp, .set_trips = rcar_gen3_thermal_set_trips, }; @@ -466,6 +467,7 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) if (!priv) return -ENOMEM; + priv->ops = rcar_gen3_tz_of_ops; priv->thermal_init = rcar_gen3_thermal_init; if (soc_device_match(r8a7795es1)) priv->thermal_init = rcar_gen3_thermal_init_r8a7795es1; @@ -473,7 +475,7 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) platform_set_drvdata(pdev, priv); if (rcar_gen3_thermal_request_irqs(priv, pdev)) - rcar_gen3_tz_of_ops.set_trips = NULL; + priv->ops.set_trips = NULL; pm_runtime_enable(dev); pm_runtime_get_sync(dev); @@ -508,8 +510,7 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) for (i = 0; i < priv->num_tscs; i++) { struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; - zone = devm_thermal_of_zone_register(dev, i, tsc, - &rcar_gen3_tz_of_ops); + zone = devm_thermal_of_zone_register(dev, i, tsc, &priv->ops); if (IS_ERR(zone)) { dev_err(dev, "Sensor %u: Can't register thermal zone\n", i); ret = PTR_ERR(zone); From patchwork Wed Feb 8 19:03:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 13133611 X-Patchwork-Delegate: geert@linux-m68k.org 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 7BB69C64EC6 for ; Wed, 8 Feb 2023 19:04:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231610AbjBHTEY (ORCPT ); Wed, 8 Feb 2023 14:04:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231608AbjBHTEW (ORCPT ); Wed, 8 Feb 2023 14:04:22 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D252F5649A for ; Wed, 8 Feb 2023 11:03:49 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id bg26so14066460wmb.0 for ; Wed, 08 Feb 2023 11:03:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W/hFyX9rV0l+08XHcIQph4Ja17yEnvPyO1rQ3FXTg9g=; b=iZ3UKTWLbcC42VpoBxl+wmKmUgBfhYJC8+DxqWoO6A5DfeMCuuY5UkCvo4fIG/d8Er KKhlMAsGanIGUYMeIuNpmwycqeD0tzAGOr006ZKNs9FqGwAwMsqFdBGbAM0r6lYHOtkM kIeTMVglMt870tJbNw/dLiZB/ljvO7kuzP9owO6LSx8pUI3beo+pkOQmsKAB7wKAia8X yTYKLdzsyfHR06DL7TUl1sos8jIxak4OxHoniXB/8oXhW6dRcw6cdhT2wqBLcaT8EQEo JSc1PNjETHZY95HrGSHAFuyLYVcCl67xN980A3lqGJw9F8alWpKSlPInfYKyPwIkSb+Y avSQ== 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:message-id:reply-to; bh=W/hFyX9rV0l+08XHcIQph4Ja17yEnvPyO1rQ3FXTg9g=; b=QRNhQIukxSbwnq285X5XUXaoAodoXELdT3olGuV/K4xuKQPiGcp7MTBW6mNPUFt6w3 slu5SJHe0HZnyywqmZNB9YBi2q8eAeUmcDpCYmNTls4uw0AMPRVHLTuS/c/EkCVWOLml Eo4QP+GTKkEhIj2rMqXnEKrZ5onMAgpT7oRRAHd9tVlD63ZCpsvKxhbCWLQNppuZ8hln CuN+wVb7hxzv4OYWt3nkqGzRhZuoXUKc+Ss2e5Ptz2/3UYiTx/3gX8V06qmEUCa/AWt7 gpV1TfFChEc5xio7fVjJvBW8ptEcSbfuNPWXfXQRFpTmh7TglltFXYpsxvfEycZIkfNM QnXg== X-Gm-Message-State: AO0yUKXCq6u37aipRgwzeKiITWG8wN20wRrfEXTQclOI0Hx+1v6Macdo 7EB8Du/ty+co5QgduSQ1mEAvqw== X-Google-Smtp-Source: AK7set/M0kHxIB5VlBD4+m8E9LdWeGxGGit3wERna/aHAFCL9ieNlU3k9h0TW639wGarLUEYGc319A== X-Received: by 2002:a05:600c:2e83:b0:3e1:787:d70f with SMTP id p3-20020a05600c2e8300b003e10787d70fmr2124785wmn.32.1675883027176; Wed, 08 Feb 2023 11:03:47 -0800 (PST) Received: from sleipner.berto.se (p4fca2792.dip0.t-ipconnect.de. [79.202.39.146]) by smtp.googlemail.com with ESMTPSA id c12-20020adffb4c000000b002b6bcc0b64dsm14201382wrs.4.2023.02.08.11.03.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 11:03:46 -0800 (PST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Daniel Lezcano , Wolfram Sang , linux-pm@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= , Wolfram Sang Subject: [PATCH v2 3/3] drivers/thermal/rcar_gen3_thermal: Fix device initialization Date: Wed, 8 Feb 2023 20:03:33 +0100 Message-Id: <20230208190333.3159879-4-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230208190333.3159879-1-niklas.soderlund+renesas@ragnatech.se> References: <20230208190333.3159879-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The thermal zone is registered before the device is register and the thermal coefficients are calculated, providing a window for very incorrect readings. The reason why the zone was register before the device was fully initialized was that the presence of the set_trips() callback is used to determine if the driver supports interrupt or not, as it is not defined if the device is incapable of interrupts. Fix this by using the operations structure in the private data instead of the zone to determine if interrupts are available or not, and initialize the device before registering the zone. Signed-off-by: Niklas Söderlund Reviewed-by: Wolfram Sang --- drivers/thermal/rcar_gen3_thermal.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c index 2dfce4f09631..8835846884d1 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c @@ -89,7 +89,8 @@ struct rcar_gen3_thermal_priv { struct rcar_gen3_thermal_tsc *tscs[TSC_MAX_NUM]; struct thermal_zone_device_ops ops; unsigned int num_tscs; - void (*thermal_init)(struct rcar_gen3_thermal_tsc *tsc); + void (*thermal_init)(struct rcar_gen3_thermal_priv *priv, + struct rcar_gen3_thermal_tsc *tsc); int ptat[3]; }; @@ -240,7 +241,7 @@ static irqreturn_t rcar_gen3_thermal_irq(int irq, void *data) for (i = 0; i < priv->num_tscs; i++) { status = rcar_gen3_thermal_read(priv->tscs[i], REG_GEN3_IRQSTR); rcar_gen3_thermal_write(priv->tscs[i], REG_GEN3_IRQSTR, 0); - if (status) + if (status && priv->tscs[i]->zone) thermal_zone_device_update(priv->tscs[i]->zone, THERMAL_EVENT_UNSPECIFIED); } @@ -311,7 +312,8 @@ static bool rcar_gen3_thermal_read_fuses(struct rcar_gen3_thermal_priv *priv) return true; } -static void rcar_gen3_thermal_init_r8a7795es1(struct rcar_gen3_thermal_tsc *tsc) +static void rcar_gen3_thermal_init_r8a7795es1(struct rcar_gen3_thermal_priv *priv, + struct rcar_gen3_thermal_tsc *tsc) { rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, CTSR_THBGR); rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, 0x0); @@ -322,7 +324,7 @@ static void rcar_gen3_thermal_init_r8a7795es1(struct rcar_gen3_thermal_tsc *tsc) rcar_gen3_thermal_write(tsc, REG_GEN3_IRQCTL, 0x3F); rcar_gen3_thermal_write(tsc, REG_GEN3_IRQMSK, 0); - if (tsc->zone->ops->set_trips) + if (priv->ops.set_trips) rcar_gen3_thermal_write(tsc, REG_GEN3_IRQEN, IRQ_TEMPD1 | IRQ_TEMP2); @@ -338,7 +340,8 @@ static void rcar_gen3_thermal_init_r8a7795es1(struct rcar_gen3_thermal_tsc *tsc) usleep_range(1000, 2000); } -static void rcar_gen3_thermal_init(struct rcar_gen3_thermal_tsc *tsc) +static void rcar_gen3_thermal_init(struct rcar_gen3_thermal_priv *priv, + struct rcar_gen3_thermal_tsc *tsc) { u32 reg_val; @@ -350,7 +353,7 @@ static void rcar_gen3_thermal_init(struct rcar_gen3_thermal_tsc *tsc) rcar_gen3_thermal_write(tsc, REG_GEN3_IRQCTL, 0); rcar_gen3_thermal_write(tsc, REG_GEN3_IRQMSK, 0); - if (tsc->zone->ops->set_trips) + if (priv->ops.set_trips) rcar_gen3_thermal_write(tsc, REG_GEN3_IRQEN, IRQ_TEMPD1 | IRQ_TEMP2); @@ -510,6 +513,9 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) for (i = 0; i < priv->num_tscs; i++) { struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; + priv->thermal_init(priv, tsc); + rcar_gen3_thermal_calc_coefs(priv, tsc, *ths_tj_1); + zone = devm_thermal_of_zone_register(dev, i, tsc, &priv->ops); if (IS_ERR(zone)) { dev_err(dev, "Sensor %u: Can't register thermal zone\n", i); @@ -518,9 +524,6 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) } tsc->zone = zone; - priv->thermal_init(tsc); - rcar_gen3_thermal_calc_coefs(priv, tsc, *ths_tj_1); - tsc->zone->tzp->no_hwmon = false; ret = thermal_add_hwmon_sysfs(tsc->zone); if (ret) @@ -558,7 +561,7 @@ static int __maybe_unused rcar_gen3_thermal_resume(struct device *dev) for (i = 0; i < priv->num_tscs; i++) { struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; - priv->thermal_init(tsc); + priv->thermal_init(priv, tsc); } return 0;