From patchwork Wed Mar 1 20:14:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 658031 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 60B52C7EE3A for ; Wed, 1 Mar 2023 20:16:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229962AbjCAUQl (ORCPT ); Wed, 1 Mar 2023 15:16:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230013AbjCAUQT (ORCPT ); Wed, 1 Mar 2023 15:16:19 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 811FB515E9 for ; Wed, 1 Mar 2023 12:15:53 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id j2so14483076wrh.9 for ; Wed, 01 Mar 2023 12:15:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677701747; 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=B+RTeMjiH2Yk42W57PYAK6Mb85gdhTfPcaFRy4giwH0=; b=oq9JmkyeN552QfxOHHg4bR675vpphKbJsVoET11pinW7JQA+jqNXdJAr4H1KeeIZLU quTT2XEFLZfpGXGmqt2GO3lv4+gc2zqQ+Ojc2d/tm27K8VJztJR335Qr8mw4MzS/E9Mz AJxjpbRQ0bAh0BqAwgG6cJqrC/+/3jeTdI2v4aL/EnfGrdR0xf/9Ro7D9XB3rCMkF5/m smlEDf+3lK2/eNKbRQDrxdiOY9HCMyhT32kugRCJAZ2370lxSv0oxFzXGWMtal4bHE+Z OWGL81xIsLH2AKPqAwerfg+8F5V55ajFRIivK0ssQ7qKldceNtaF/Bs0K+He2rMYwu1I DmgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677701747; 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=B+RTeMjiH2Yk42W57PYAK6Mb85gdhTfPcaFRy4giwH0=; b=vORSz6ywuv6n5z0oMQvjcVcTq0U5Xr3i64d1V/Ntvo27ri2xFTV0HWFhDCWnrmrbow LStIRnn3c6vILfsjGz3U4nNQUOazn4mRmq39EqrafT/yty8274/lW4ODEo7OHGBA4ymh 6EHrOwlV5euHVU2LSqyedA52t58nrjKKEfUnM5AXcghNjaudLD27Ztiow7eBuEVwpGZ8 NH4w/iG9qxDMJ7IcW9gmRR81D2vwhjPPHGA12WpHbLhQlOW2MJZA44nSoLa98AAcbk95 GRApbgGEy2HMTD+tlbN16k1JROl/QZb+qsDtEDdiv9Gl/O96sgIQOBvPrWNxkunlPKnN FKhA== X-Gm-Message-State: AO0yUKUS91acX6oGBepu7cRKQeb3i/GZhbkyIiKGLB7XG3dYK4uAyvoZ NZLEmH5waFFPLCs+WXSSnC647w== X-Google-Smtp-Source: AK7set/ta+emcyYFeYNSomT5+PEoW2hHSBBrGWkfa4OG0hChcsGtB27pUUXj1KAZ2oYslu7puUedzA== X-Received: by 2002:adf:ed82:0:b0:2c7:a39:7453 with SMTP id c2-20020adfed82000000b002c70a397453mr5688650wro.54.1677701747255; Wed, 01 Mar 2023 12:15:47 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:6ffe:ce4f:bd31:1e6d]) by smtp.gmail.com with ESMTPSA id x16-20020a1c7c10000000b003e70a7c1b73sm576546wmc.16.2023.03.01.12.15.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Mar 2023 12:15:46 -0800 (PST) From: Daniel Lezcano To: rafael@kernel.org, daniel.lezcano@linaro.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Adam Ward , Support Opensource , Amit Kucheria , Zhang Rui Subject: [PATCH v5 14/18] thermal/drivers/da9062: Don't access the thermal zone device fields Date: Wed, 1 Mar 2023 21:14:42 +0100 Message-Id: <20230301201446.3713334-15-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230301201446.3713334-1-daniel.lezcano@linaro.org> References: <20230301201446.3713334-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The driver is reading the passive polling rate in the thermal zone structure. We want to prevent the drivers to rummage around in the thermal zone structure. On the other side, the delay is what the driver passed to the thermal_zone_device_register() function, so it has already the information. Reuse the information we have instead of reading the information we set. Signed-off-by: Daniel Lezcano Reviewed-by: Adam Ward --- drivers/thermal/da9062-thermal.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/da9062-thermal.c b/drivers/thermal/da9062-thermal.c index e7097f354750..2d31b1f73423 100644 --- a/drivers/thermal/da9062-thermal.c +++ b/drivers/thermal/da9062-thermal.c @@ -41,6 +41,8 @@ #define DA9062_MILLI_CELSIUS(t) ((t) * 1000) +static unsigned int pp_tmp = DA9062_DEFAULT_POLLING_MS_PERIOD; + struct da9062_thermal_config { const char *name; }; @@ -95,7 +97,10 @@ static void da9062_thermal_poll_on(struct work_struct *work) thermal_zone_device_update(thermal->zone, THERMAL_EVENT_UNSPECIFIED); - delay = thermal->zone->passive_delay_jiffies; + /* + * pp_tmp is between 1s and 10s, so we can round the jiffies + */ + delay = round_jiffies(msecs_to_jiffies(pp_tmp)); queue_delayed_work(system_freezable_wq, &thermal->work, delay); return; } @@ -155,7 +160,6 @@ static int da9062_thermal_probe(struct platform_device *pdev) { struct da9062 *chip = dev_get_drvdata(pdev->dev.parent); struct da9062_thermal *thermal; - unsigned int pp_tmp = DA9062_DEFAULT_POLLING_MS_PERIOD; const struct of_device_id *match; int ret = 0; @@ -208,8 +212,7 @@ static int da9062_thermal_probe(struct platform_device *pdev) } dev_dbg(&pdev->dev, - "TJUNC temperature polling period set at %d ms\n", - jiffies_to_msecs(thermal->zone->passive_delay_jiffies)); + "TJUNC temperature polling period set at %d ms\n", pp_tmp); ret = platform_get_irq_byname(pdev, "THERMAL"); if (ret < 0)