Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp737797ybt; Fri, 26 Jun 2020 10:18:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2p/Hd6GwH7NcCl2+IrMhu0qe1ohfwdqixcAngQhvaRejqcUdojHnnB6FOfU7eF434lSEX X-Received: by 2002:a05:6402:706:: with SMTP id w6mr4312582edx.326.1593191889604; Fri, 26 Jun 2020 10:18:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593191889; cv=none; d=google.com; s=arc-20160816; b=NtsfAaeG88SrSAD3KtTaJA0yUPsP/gTsRrM1v9PzzC8fkCmM8IABwP1OnN9wU3F85A WxZaiN+jOZKHNnoZsHo3E1b0etDwfpJrdGBQJfd4AkDZpFNkKho/CQZTVsWJec6HiU0O 5eZbG3qQuFAoEfzvHxId1xSMqcY9LdIr6Quyrf2VXbhv+vQUynPAd66cDkm3GDdqcTqC pwz7wJ2v78XaU+/7lXawa+Q8L7HNiCo9LmFVwUmZdh/mXGH9X6R/oLMc7sOFPtAP+4S6 UMaSnVPjJTgMSyU+xw8urJSzC2etn6EuNLYWD9x/E0oop0LuaJXqMp9mvuRK1LH7/D4V e4oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=LwJFPwXnKkI5Ci5Bbc7b0AAi+U5QO38FMl+MLRpLHEg=; b=SZdRlOQWCIEijivGhWbEoTApgBEiUwu0G03v7tzRJnJSqcI6PMYjinC6RK9mgy4M+o yYzSpTH3Y9Wyf/EY/dtS8e4coLj95J+4rDeqxDlDqsfv2g/pqpOBtLj68TF9pMeVwqc3 MEBlS3I4csjJckaShvS6ZHT83h+St7zaL40clsX+MwfJo8deyjvCT5D8SmodvcAUi+ik qbenYWl35MwnqAcMxtsLa87XLI/1BYrM3rCrugooY5PscybjzyG0DHtTVhopsMyrqmBG 6UUMl9fcAW5t2g90K2KscavZKZzSdLOp+OGzf/szQ2E3jrl1yNuRJ6naSQhFALo9iv7l qiYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cf23si17201415ejb.540.2020.06.26.10.17.37; Fri, 26 Jun 2020 10:18:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726700AbgFZQJB (ORCPT + 99 others); Fri, 26 Jun 2020 12:09:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725807AbgFZQJA (ORCPT ); Fri, 26 Jun 2020 12:09:00 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE976C03E979; Fri, 26 Jun 2020 09:09:00 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id CD5392A2DA9 Subject: Re: [PATCH v4 07/11] thermal: Use mode helpers in drivers To: Bartlomiej Zolnierkiewicz Cc: linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, "Rafael J . Wysocki" , Len Brown , Vishal Kulkarni , "David S . Miller" , Jiri Pirko , Ido Schimmel , Johannes Berg , Emmanuel Grumbach , Luca Coelho , Intel Linux Wireless , Kalle Valo , Peter Kaestle , Darren Hart , Andy Shevchenko , Sebastian Reichel , Miquel Raynal , Daniel Lezcano , Amit Kucheria , Support Opensource , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , =?UTF-8?Q?Niklas_S=c3=b6derlund?= , Heiko Stuebner , Orson Zhai , Baolin Wang , Chunyan Zhang , Zhang Rui , Allison Randal , Enrico Weigelt , Gayatri Kammela , Thomas Gleixner , kernel@collabora.com References: <20200528192051.28034-1-andrzej.p@collabora.com> <20200528192051.28034-8-andrzej.p@collabora.com> <313ca24a-0cc4-a976-19bb-0f30aa845226@samsung.com> From: Andrzej Pietrasiewicz Message-ID: Date: Fri, 26 Jun 2020 18:08:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <313ca24a-0cc4-a976-19bb-0f30aa845226@samsung.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Hi Bartlomiej, W dniu 24.06.2020 o 11:51, Bartlomiej Zolnierkiewicz pisze: > > On 5/28/20 9:20 PM, Andrzej Pietrasiewicz wrote: >> Use thermal_zone_device_{en|dis}able() and thermal_zone_device_is_enabled(). >> >> Consequently, all set_mode() implementations in drivers: >> >> - can stop modifying tzd's "mode" member, >> - shall stop taking tzd's lock, as it is taken in the helpers >> - shall stop calling thermal_zone_device_update() as it is called in the >> helpers >> - can assume they are called when the mode truly changes, so checks to >> verify that can be dropped >> >> Not providing set_mode() by a driver no longer prevents the core from >> being able to set tzd's mode, so the relevant check in mode_store() is >> removed. >> >> Other comments: >> >> - acpi/thermal.c: tz->thermal_zone->mode will be updated only after we >> return from set_mode(), so use function parameter in thermal_set_mode() >> instead, no need to call acpi_thermal_check() in set_mode() >> - thermal/imx_thermal.c: regmap writes and mode assignment are done in >> thermal_zone_device_{en|dis}able() and set_mode() callback >> - thermal/intel/intel_quark_dts_thermal.c: soc_dts_{en|dis}able() are a >> part of set_mode() callback, so they don't need to modify tzd->mode, and >> don't need to fall back to the opposite mode if unsuccessful, as the return >> value will be propagated to thermal_zone_device_{en|dis}able() and >> ultimately tzd's member will not be changed in thermal_zone_device_set_mode(). >> - thermal/of-thermal.c: no need to set zone->mode to DISABLED in >> of_parse_thermal_zones() as a tzd is kzalloc'ed so mode is DISABLED anyway >> >> Signed-off-by: Andrzej Pietrasiewicz >> --- >> drivers/acpi/thermal.c | 21 ++++++----- >> .../ethernet/mellanox/mlxsw/core_thermal.c | 37 +++++++++---------- >> drivers/platform/x86/acerhdf.c | 17 +++++---- >> drivers/thermal/da9062-thermal.c | 6 ++- >> drivers/thermal/hisi_thermal.c | 6 ++- >> drivers/thermal/imx_thermal.c | 33 +++++++---------- >> .../intel/int340x_thermal/int3400_thermal.c | 5 +-- >> .../thermal/intel/intel_quark_dts_thermal.c | 18 ++------- >> drivers/thermal/rockchip_thermal.c | 6 ++- >> drivers/thermal/sprd_thermal.c | 6 ++- >> drivers/thermal/thermal_core.c | 2 +- >> drivers/thermal/thermal_of.c | 10 +---- >> drivers/thermal/thermal_sysfs.c | 11 ++---- >> 13 files changed, 80 insertions(+), 98 deletions(-) > > [...] > >> diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c >> index 32c5fe16b7f7..3efe749dc5a0 100644 >> --- a/drivers/platform/x86/acerhdf.c >> +++ b/drivers/platform/x86/acerhdf.c >> @@ -397,19 +397,16 @@ static inline void acerhdf_revert_to_bios_mode(void) >> { >> acerhdf_change_fanstate(ACERHDF_FAN_AUTO); >> kernelmode = 0; >> - if (thz_dev) { >> - thz_dev->mode = THERMAL_DEVICE_DISABLED; >> + if (thz_dev) >> thz_dev->polling_delay = 0; >> - } >> + >> pr_notice("kernel mode fan control OFF\n"); >> } >> static inline void acerhdf_enable_kernelmode(void) >> { >> kernelmode = 1; >> - thz_dev->mode = THERMAL_DEVICE_ENABLED; >> >> thz_dev->polling_delay = interval*1000; >> - thermal_zone_device_update(thz_dev, THERMAL_EVENT_UNSPECIFIED); >> pr_notice("kernel mode fan control ON\n"); >> } >> >> @@ -723,6 +720,8 @@ static void acerhdf_unregister_platform(void) >> >> static int __init acerhdf_register_thermal(void) >> { >> + int ret; >> + >> cl_dev = thermal_cooling_device_register("acerhdf-fan", NULL, >> &acerhdf_cooling_ops); >> >> @@ -736,8 +735,12 @@ static int __init acerhdf_register_thermal(void) >> if (IS_ERR(thz_dev)) >> return -EINVAL; >> >> - thz_dev->mode = kernelmode ? >> - THERMAL_DEVICE_ENABLED : THERMAL_DEVICE_DISABLED; >> + if (kernelmode) >> + ret = thermal_zone_device_enable(thz_dev); >> + else >> + ret = thermal_zone_device_disable(thz_dev); >> + if (ret) > > Cleanup on error seems to be missing here. It does seem so, but it is not the case. acerhdf_register_thermal() is called from acerhdf_init(). The latter checks the return value of the former and on error jumps to the err_unreg label, where thermal zone(s) is/are unregistered. Regards, Andrzej