Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp431881ybt; Wed, 24 Jun 2020 02:54:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3Mm5D6rHgBHwIbtCKYpJWvgT2MJx54yNU2zGFc0ZORpGL712SGRg35qt2EtEKUJr+6Bkw X-Received: by 2002:a50:aacc:: with SMTP id r12mr25845864edc.219.1592992465104; Wed, 24 Jun 2020 02:54:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592992465; cv=none; d=google.com; s=arc-20160816; b=TcMSPf0mr9vPBqPCL/EEl/zrM4NKKb6MHlBwPKhizttzmrjuKHKs76kGUZeg93SS/9 nv1eUdOpZ8vwetClEwYilpLKZBlftR5CcV8CIzhw/iAATHJ4IpOKse4+wP8lERrz3CCP coSPINTzPBP4j3ydiAxinNHGfmOhXSuxQ3V/8ogkIiCbHQC+6bcgCWPr6bHJ/SxVkIGi ENLKaGKkOhlbx5hLLKGkKIFBoRLSqSt68whaY9fhpF9dKR8UGMPDv6F/asyCtck7bdq0 Z/vl9LmSwnDfFTNh6TNW7/QBG9600fyhiuUtsaJMYMWX8BR+LEwKtZ/L/rD9FliseODL Sjdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type :content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:cc:to:subject:from:dkim-signature :dkim-filter; bh=ZO5/qrGQfr7hzhZhYr2qv1+xBW+SnjBs6PMGC0QxS6c=; b=G6ZCNdlsX4F3zd8RSlRL5gxOmLh+szjQS6tSg8oH1R+tKYk207c3Tmawj/BVc4ZEp5 ylMvyBVUNZ4k98adKZR/nsDNCCjhnlXm4zn3/wxHr8tJhGUVd0I1ncDO0fU4RyO8J2dI tSHqG4S3Wp5r21E/95Bw/ftejeP7cy9XHT32BPeKSQ5Lz7a0i3O0xBbYd1sY82scw2lF d/XM9MJdE/gogbZPs2dNKWdm+oyfNq9AWK9phqST633e4r4Lu6GHPaqiz1VZqIpnHKcB m4K55x2gwl7EZ0/Czdrae5jG6aDFC/Uey/y+CU3VTqON3vIs66nkg22Ep7RURak65XZc hngA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=UdBDO6sc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o16si2363574edv.45.2020.06.24.02.53.56; Wed, 24 Jun 2020 02:54:25 -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; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=UdBDO6sc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390055AbgFXJvr (ORCPT + 99 others); Wed, 24 Jun 2020 05:51:47 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:34051 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389824AbgFXJvp (ORCPT ); Wed, 24 Jun 2020 05:51:45 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200624095143euoutp01616e0e718a425dbde5e68af86a82fcf7~bcg9qent02939529395euoutp01V; Wed, 24 Jun 2020 09:51:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200624095143euoutp01616e0e718a425dbde5e68af86a82fcf7~bcg9qent02939529395euoutp01V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1592992303; bh=ZO5/qrGQfr7hzhZhYr2qv1+xBW+SnjBs6PMGC0QxS6c=; h=From:Subject:To:Cc:Date:In-Reply-To:References:From; b=UdBDO6scpgve8SgJVtLkVm2Uojl4qx+y2Cegd/e+7fl2jEPK/FVCq0/45vkVWE+bJ olUPOU2D8Aqq0bYbLjrIENMqpbGiiCz5JT1Uy5/TWOyEJtz2piIHP1ojmov6hg6oyg DBdCMVm9MniMw8Fc2tndE73fArlKdYGxQfDpRpWQ= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200624095143eucas1p265a25817889932df1ef5cce4e63d8b79~bcg9hreoa1402514025eucas1p2U; Wed, 24 Jun 2020 09:51:43 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id AE.09.06318.F2223FE5; Wed, 24 Jun 2020 10:51:43 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200624095143eucas1p24640fa3ecba414c54ce3916e56d1aa1a~bcg9MZZXi1469214692eucas1p2X; Wed, 24 Jun 2020 09:51:43 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200624095143eusmtrp21b421527db9cf30eeef19116158e455c~bcg9LDyBf2538725387eusmtrp2t; Wed, 24 Jun 2020 09:51:43 +0000 (GMT) X-AuditID: cbfec7f5-38bff700000018ae-d0-5ef3222f9b73 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id D5.14.06314.F2223FE5; Wed, 24 Jun 2020 10:51:43 +0100 (BST) Received: from [106.120.51.71] (unknown [106.120.51.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200624095141eusmtip15e141546d7b9799a3ddc14276e979f32~bcg7T_idL1499814998eusmtip1w; Wed, 24 Jun 2020 09:51:41 +0000 (GMT) From: Bartlomiej Zolnierkiewicz Subject: Re: [PATCH v4 07/11] thermal: Use mode helpers in drivers To: Andrzej Pietrasiewicz 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 Message-ID: <313ca24a-0cc4-a976-19bb-0f30aa845226@samsung.com> Date: Wed, 24 Jun 2020 11:51:40 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20200528192051.28034-8-andrzej.p@collabora.com> Content-Language: en-US Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA01Tf1DTZRy+9/sbat7XafBGeV7r8i5OmEh/fK4fJFbX9/QuvY4r6wKb+g25 +OHtC5T2R3KGwAJEC9ExYRjJNjvBDcemtDhmkq2WueCEWMcEdZgjYVDi8aNt37j473me9/m8 z+d5716OVNaxSVxeYbGoLdTkq5h4y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HS1vL71X09j9xx5BI7WHJsJnFLYjyU+tW5wnRvTN jz+x1zLnlStXLR/MdT79aEv3h7ma192Diq70U5PrExcbvtI3SimnLdUVeSlfawbZNld9jeYd /Y7M0su/UZI96eBmy8T1gIoSi3XaTaRZ1P0LywTyErUDAAA= X-CMS-MailID: 20200624095143eucas1p24640fa3ecba414c54ce3916e56d1aa1a X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200528192211eucas1p1dc9b49e1288321503954ed16d9e3001b X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200528192211eucas1p1dc9b49e1288321503954ed16d9e3001b References: <20200528192051.28034-1-andrzej.p@collabora.com> <20200528192051.28034-8-andrzej.p@collabora.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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. > + return ret; > > if (strcmp(thz_dev->governor->name, > acerhdf_zone_params.governor_name)) { Best regards, -- Bartlomiej Zolnierkiewicz Samsung R&D Institute Poland Samsung Electronics