Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp752323ybt; Fri, 26 Jun 2020 10:39:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxu2V7cjoRf9cIMNJ6HUTNwxYfiTM/xICe1CcvorNmnX9POQbgxr6nJE5GFsLb4ftaJXe4L X-Received: by 2002:a17:907:35c2:: with SMTP id ap2mr3386816ejc.530.1593193173877; Fri, 26 Jun 2020 10:39:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593193173; cv=none; d=google.com; s=arc-20160816; b=tH86pFkJq4tARiUcq5DKiTWBrCklkte/E7kxZ6qQVPNVzUPg2YjevzmjtKW/12hAqW xejyjDHRWWmZ12Af0I1he2KRBpATkFu1M4YYVnqHYAfcyDuLlqZJjEw+xMPxMviQTmW3 J4oIvGAyTl/qIBh3H5Cyn0zq00Lun2vi61p30kCVTPFAs87mS+rO9N+rNhde/mL3e7w8 41ylRc0tYnXdB+2wrz5p/eRuVjPS+IxbGJF/eql+TGMMoU8DQXOuDRelM28TUmi2DssH PkAs/wgQjomOfKvHwapispB0sDaOp1d/r9AR+Put7eWV3A+uxlHtdoyN7sLI9f3e8iZP T2mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Tze3B2wHssDbZ2N0nr8UfcyjpeqtYgH7KxYdVkDBvjs=; b=WMqzpVEQnFdoxb0zYtF1R3t2BQJzFRPCkQVa0Jcu/1wjQ/JMDl56HRWpWxRg0caY4m z4ytlR+NYkw5DL6ZBw4/36L+zP/XjGzaaJ7wbE/PMCGfetx7wGZFnq8nD37+/nupA1kr LfzGYgwZuyjk42NLD949tNEfqNno2c/GPx1OCzOT1tgCM30aSl9+OQVBcQUYz8lBhEVs ThpCqH1AX9oHjmnAjzDVa+3yjudwEYZe0TfeQQs7AElPubgm6aqgwX0g1GvDkqoPLhM3 HWwOKeOLRxUOpmSk5HzF+Nl2y90T734HBkqQQsATAIaZ70UepmNsuwQno1YoqHsfvWHk soVQ== 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 e23si3630890edy.264.2020.06.26.10.39.10; Fri, 26 Jun 2020 10:39:33 -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 S1727943AbgFZRiS (ORCPT + 99 others); Fri, 26 Jun 2020 13:38:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725917AbgFZRiQ (ORCPT ); Fri, 26 Jun 2020 13:38:16 -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 86F9CC03E979; Fri, 26 Jun 2020 10:38:16 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id E33492A5E4E From: Andrzej Pietrasiewicz To: 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 Cc: "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=20S=C3=B6derlund?= , Heiko Stuebner , Orson Zhai , Baolin Wang , Chunyan Zhang , Zhang Rui , Allison Randal , Enrico Weigelt , Gayatri Kammela , Thomas Gleixner , Bartlomiej Zolnierkiewicz , Andrzej Pietrasiewicz , kernel@collabora.com Subject: [PATCH v5 06/11] thermal: Add mode helpers Date: Fri, 26 Jun 2020 19:37:50 +0200 Message-Id: <20200626173755.26379-7-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200626173755.26379-1-andrzej.p@collabora.com> References: <9cbffad6-69e4-0b33-4640-fde7c4f6a6e7@linaro.org> <20200626173755.26379-1-andrzej.p@collabora.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Prepare for making the drivers not access tzd's private members. Signed-off-by: Andrzej Pietrasiewicz Reviewed-by: Bartlomiej Zolnierkiewicz [EXPORT_SYMBOL -> EXPORT_SYMBOL_GPL] Signed-off-by: Andrzej Pietrasiewicz --- drivers/thermal/thermal_core.c | 53 ++++++++++++++++++++++++++++++++++ include/linux/thermal.h | 13 +++++++++ 2 files changed, 66 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 14d3b1b94c4f..3181295075b9 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -459,6 +459,59 @@ static void thermal_zone_device_reset(struct thermal_zone_device *tz) thermal_zone_device_init(tz); } +int thermal_zone_device_set_mode(struct thermal_zone_device *tz, + enum thermal_device_mode mode) +{ + int ret = 0; + + mutex_lock(&tz->lock); + + /* do nothing if mode isn't changing */ + if (mode == tz->mode) { + mutex_unlock(&tz->lock); + + return ret; + } + + if (tz->ops->set_mode) + ret = tz->ops->set_mode(tz, mode); + + if (!ret) + tz->mode = mode; + + mutex_unlock(&tz->lock); + + thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); + + return ret; +} + +int thermal_zone_device_enable(struct thermal_zone_device *tz) +{ + return thermal_zone_device_set_mode(tz, THERMAL_DEVICE_ENABLED); +} +EXPORT_SYMBOL_GPL(thermal_zone_device_enable); + +int thermal_zone_device_disable(struct thermal_zone_device *tz) +{ + return thermal_zone_device_set_mode(tz, THERMAL_DEVICE_DISABLED); +} +EXPORT_SYMBOL_GPL(thermal_zone_device_disable); + +int thermal_zone_device_is_enabled(struct thermal_zone_device *tz) +{ + enum thermal_device_mode mode; + + mutex_lock(&tz->lock); + + mode = tz->mode; + + mutex_unlock(&tz->lock); + + return mode == THERMAL_DEVICE_ENABLED; +} +EXPORT_SYMBOL_GPL(thermal_zone_device_is_enabled); + void thermal_zone_device_update(struct thermal_zone_device *tz, enum thermal_notify_event event) { diff --git a/include/linux/thermal.h b/include/linux/thermal.h index a808f6fa2777..df013c39ba9b 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -416,6 +416,9 @@ int thermal_zone_get_offset(struct thermal_zone_device *tz); void thermal_cdev_update(struct thermal_cooling_device *); void thermal_notify_framework(struct thermal_zone_device *, int); +int thermal_zone_device_enable(struct thermal_zone_device *tz); +int thermal_zone_device_disable(struct thermal_zone_device *tz); +int thermal_zone_device_is_enabled(struct thermal_zone_device *tz); #else static inline struct thermal_zone_device *thermal_zone_device_register( const char *type, int trips, int mask, void *devdata, @@ -463,6 +466,16 @@ static inline void thermal_cdev_update(struct thermal_cooling_device *cdev) static inline void thermal_notify_framework(struct thermal_zone_device *tz, int trip) { } + +static inline int thermal_zone_device_enable(struct thermal_zone_device *tz) +{ return -ENODEV; } + +static inline int thermal_zone_device_disable(struct thermal_zone_device *tz) +{ return -ENODEV; } + +static inline int +thermal_zone_device_is_enabled(struct thermal_zone_device *tz) +{ return -ENODEV; } #endif /* CONFIG_THERMAL */ #endif /* __THERMAL_H__ */ -- 2.17.1