Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp43202pxu; Wed, 2 Dec 2020 14:28:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJyVQ+In0uxPyWi/dSHPG5DDmM8r8jL4ONiv+CCT8rVBslKK/hQFdwkVHHnySGqH69msTc7T X-Received: by 2002:a05:6402:10c1:: with SMTP id p1mr200472edu.214.1606948089917; Wed, 02 Dec 2020 14:28:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606948089; cv=none; d=google.com; s=arc-20160816; b=efcwHI5q7xIllapa0p46AcxSA43ub9ZbcXMhXhoQ+CsUFJ7WxOO9NlTLmEDiz4M1LL Rg2Lc8HYSjYE5s8vQG/bVFNhKtgJOz/kpKwNdwE+3NWxiG/vpw+ONR1FyzqEx0x8M17R F7oy8lrDu3JwJ9HWkh43sF2qO65P/isaYSPprQiwgg0fUgM4GNg7BIB4Ah60pnOW+arm B2aSv7q0ZA/fGmOd/iHs602wrTtLb6Y8b/A1sQKSIOQjlkpH79ezyot6x6PBo/zxYr0/ MT0PlMZqIqoLXkCTn0c3My4ZZIqBatZ3021rpam4P79mqXFe9BfMScbSoetQT/pYjW0w 2Hgw== 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=LRXtGtQx0V38uULFsTPi/qjTFIKnBLoKo8MU7obqjyU=; b=nV313K/7GJ1vtJUlZBP0yEzKsXrsyIrw9JvjaMw53cJRsn/PGkHA1oYQyreFPB6ktL uVoNthEO2pgjCQdrUKhlGWawp+9xvkl4dwU9/SdTIt9fR+LWXqpB44T5Tf9Q4AyPef1U HtKnygWm8sK2UAyWcMZ1XxH0z0nwKtzIbYAzFDsXbZlSsocnzUYrv4EhvhofWCYeibLo tgWzdr1Y6/8fNhgFf23ufoJQo9lB3Li1mI5GBXSeqhZY4in1qHQgismEknuJsXF99mCt SN7ctfCvBmdO8E7UfaZwm9i/PPm79IG9v12wQJaiLxsU6lWc5Yntf5ZSEYqw4n+JAOpk Iwyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E06twwEM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k2si79001edr.526.2020.12.02.14.27.47; Wed, 02 Dec 2020 14:28:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E06twwEM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2387495AbgLBWXV (ORCPT + 99 others); Wed, 2 Dec 2020 17:23:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387477AbgLBWXU (ORCPT ); Wed, 2 Dec 2020 17:23:20 -0500 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 568D1C061A04 for ; Wed, 2 Dec 2020 14:22:34 -0800 (PST) Received: by mail-wm1-x344.google.com with SMTP id f190so654527wme.1 for ; Wed, 02 Dec 2020 14:22:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LRXtGtQx0V38uULFsTPi/qjTFIKnBLoKo8MU7obqjyU=; b=E06twwEMJ8K66tEsIJl1OyT2WbCBwVJRU0XbGlu1c/FOLMDuP3vUOkSGVgbowqMHOz N/4X85VeDi4KiWUjgpqymbeiDaMUoRzV48Eq9g6JsAEv+32InsBV2CRj2jV/MoiKqSQ2 J1k9Dl5ovU1lCA1ZFl+VcjBnSq6njDdIMb5a3t3k73L1v9Dt0xnPktb/3UaBxVIQiN2x iJpCeEnGOrC2rH0JJj4JE8/PRR6tH6bf9c3CWqBJLgYWi+w7saeego0T/SEHOyP9uFyw MDD9uWQYGrfCSc0VYP4Qh7tw2WDIeKsVigxQLadb+LtQp+nuwqzhrtooTwahCxvqUTRU ahMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LRXtGtQx0V38uULFsTPi/qjTFIKnBLoKo8MU7obqjyU=; b=KWp2/iF1Kz6iHKJO1WmxB1gQQQ7/Pbbj1gVAcyjTZe1n/pMtPA2lDTVBmLYYE1S7J8 KFpKI7mS/MyTBn1pUjSv8AuX8AqguqtcgpbBiZa4cT7l97KoFix6i6SnRIGBOu8PXWHc g/80VwUq97I5XT4wVo/4WR8fAJPkxWMmeIlxVnbvBnYffB9tjulOTswdi7FC1vVIcjg/ ll795x7fToFDCxsrB/0G7HcUEXV+HUHhR81a9E6A8w70CUh1Ie3M3Sl5UrtzZZlkyEUw oa0/06RSBwJ/1+rASxsbZSrE5tpi8sfrc7D2JFUSzGBUfT9Hyf5CBC+g/KqRNV9dEvUn /DyA== X-Gm-Message-State: AOAM531VCP9XGoGIwms+rhZ5eNaerT6BiLWMIALO5gGxWZ2+1Ob8+3+c 0f49UvxiJ/rNqxdw1LeLpIHqtA== X-Received: by 2002:a7b:ca47:: with SMTP id m7mr104009wml.33.1606947752953; Wed, 02 Dec 2020 14:22:32 -0800 (PST) Received: from mai.imgcgcw.net ([2a01:e34:ed2f:f020:1c7d:2d7a:9709:b9a2]) by smtp.gmail.com with ESMTPSA id s8sm63672wrn.33.2020.12.02.14.22.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 14:22:32 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org Cc: Peter Kaestle , Hans de Goede , Mark Gross , platform-driver-x86@vger.kernel.org (open list:ACER ASPIRE ONE TEMPERATURE AND FAN DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 2/2] platform/x86/drivers/acerhdf: Check the interval value when it is set Date: Wed, 2 Dec 2020 23:22:12 +0100 Message-Id: <20201202222212.2313242-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201202222212.2313242-1-daniel.lezcano@linaro.org> References: <20201202222212.2313242-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 Currently the code checks the interval value when the temperature is read which is bad for two reasons: - checking and setting the interval in the get_temp callback is inaccurate and awful, that can be done when changing the value. - Changing the thermal zone structure internals is an abuse of the exported structure, moreover no lock is taken here. The goal of this patch is to solve the first item by using the 'set' function called when changing the interval. The check is done there and removed from the get_temp function. If the thermal zone was not initialized yet, the interval is not updated in this case as that will happen in the init function when registering the thermal zone device. I don't have any hardware to test the changes. Signed-off-by: Daniel Lezcano --- drivers/platform/x86/acerhdf.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c index 19fc8ff2225c..084005841d56 100644 --- a/drivers/platform/x86/acerhdf.c +++ b/drivers/platform/x86/acerhdf.c @@ -334,7 +334,10 @@ static void acerhdf_check_param(struct thermal_zone_device *thermal) } if (verbose) pr_notice("interval changed to: %d\n", interval); - thermal->polling_delay = interval*1000; + + if (thermal) + thermal->polling_delay = interval*1000; + prev_interval = interval; } } @@ -349,8 +352,6 @@ static int acerhdf_get_ec_temp(struct thermal_zone_device *thermal, int *t) { int temp, err = 0; - acerhdf_check_param(thermal); - err = acerhdf_get_temp(&temp); if (err) return err; @@ -823,8 +824,19 @@ MODULE_ALIAS("dmi:*:*Acer*:pnExtensa*5420*:"); module_init(acerhdf_init); module_exit(acerhdf_exit); +int interval_set_uint(const char *val, const struct kernel_param *kp) +{ + ret = param_set_uint(val, kp); + if (ret) + return ret; + + acerhdf_check_param(thz_dev); + + return 0; +} + static const struct kernel_param_ops interval_ops = { - .set = param_set_uint, + .set = interval_set_uint, .get = param_get_uint, }; -- 2.25.1