Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp648863ybm; Fri, 29 May 2020 08:52:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEY3keN/SPwS0GD6hs4JNaseQjqG8X+qSFJQsy6nW8jz37flc8siTkkHd7NzD5wDnmmIZx X-Received: by 2002:a50:f78d:: with SMTP id h13mr8749594edn.238.1590767577732; Fri, 29 May 2020 08:52:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590767577; cv=none; d=google.com; s=arc-20160816; b=U44BjVfE2RMBXBjCAFhdO56Gn13HbHY+fpZ71Vf7dzJX6kPJs+cnGA4Pwpu+C/Htus cEksHMdmfOtyxhmDETPJkRFZG7KgZF8/lH9E8ga3OvDkZ+9GRnAUqwAVhqO1QT7kF82a S4tzTtc7w3P4bWiZUJ/ksRjpeJMtRgEXtBsxdChB2ei0SXXeOtye5gZZuJDRLegFvdKo xwBXQhzI9g2jF/1j6JBkbwggKpbJKzd5Y7jNTRnuihDnSA2b68zm3GXHTuI5E3tu++Cv Wr0bFuMDcOeN7DM+816l6OUavDHMdGFzClm9syE8PdxEM45GDLSjHyl5j+MkMZvzxiey y0/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=Kr2DFnvRW9808DjObzViZreH2QLKCskc9zy5dtQmZdI=; b=S6MM5ufKoJJJrkT0T9/bzGhEy6hZtci11waY6l8TQiBXbDztBUgGFVsfuh2m8IPFho rdgWS7EYcav8d3LZ1Zk6IIxeKxnPl0USl7ZKuUAHTSmenuNqP2wmdfNJj72fueNZs62R JhI9NgzhZjAw/9Gkn2qbAXFbrj50Ox1m1+wnTPbfeM0JKacmulCRKe8KK+p3PZDQmzlp FH8UM11oXbQ1bsl5vd7NVjokk11uB+lj+pxWKQXalq+/TMyYp/kpzzueLD4n8nsJD7Eg Tl6hLxVVwIY5EMa3sp1tSOdCI9umBupb1uTtdNyuNVtjZ2O6BAYVLrEy/3okPPKKo5wE c5rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=calztOD7; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nh7si2915786ejb.155.2020.05.29.08.52.33; Fri, 29 May 2020 08:52:57 -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=fail header.i=@gmail.com header.s=20161025 header.b=calztOD7; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727875AbgE2PwJ (ORCPT + 99 others); Fri, 29 May 2020 11:52:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726838AbgE2PwI (ORCPT ); Fri, 29 May 2020 11:52:08 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D6D4C03E969; Fri, 29 May 2020 08:52:08 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id f3so1515752pfd.11; Fri, 29 May 2020 08:52:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=Kr2DFnvRW9808DjObzViZreH2QLKCskc9zy5dtQmZdI=; b=calztOD7MAQYZJLZ6WlEsjCp2RnV/0HiXuizF4nZHL9DybyCEERhbozciRw3D78NKL vUQ00WTLbGwfhAjfdRq/0M+cyXi0zgLtB9PsEBoWv36Cvdw2VgDG3GX7xMtarrSpSUIH 8nX0SsqLpX2eqT2Qy1dRy9csYEEyXxgxRS1QMnQYfq7MIKgm63Q4D4nHxBn2S3/LE7PW tnahKzvdEKXyg5oWiu8DmsR+hq6Jf7EQ72D23nX24ZZFNHnhyHRpTzEQsThwtuQWyOmZ ZMn8vWEGY7fOkBpsj5HCmAGHZ2ASS0GfXqG6JHl+vHiFca5CCJdTFUOg+bL3MMY8wTnk NmCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mime-version:content-disposition:user-agent; bh=Kr2DFnvRW9808DjObzViZreH2QLKCskc9zy5dtQmZdI=; b=mBQ6qOIQMPtb9I7rmy8xNkZUzr6pazYZ2dBy3I5ubHVJUABGswXBDdGtTr/HoC/5DF /jFUvf5DYT9Qhgp8BN68UUviyH3rvfNyyBv4uJ7OY/Z8pa1oLa61E+QPmc1nMtx9/MnI h5elsbVkvrRG4y9Jjt6ep1zUMejcoUfIJsz+sG2fwI+xDFpGdDfJMnC9ikyYgUItoJmC y95xAeAgDGaMi99GyRBgxEm0QvDsTL4PDXNx4f8nD/NcLD2CWSPxT7ZQKPVIV0uKByx8 4h6pVE9AJaR6axs+FtyLCIr/KgDb/g0EPiXfRaE0nV0F6AaYjAlrYHAQWk6bGifIScs1 GkqA== X-Gm-Message-State: AOAM531VDNfVM5G7uN7lu05UeRAajeIJ6ENYCHmbeu1pNetNGIVTVwB5 RmuWwzxYjcygZVDGEQp8Q54= X-Received: by 2002:a62:174c:: with SMTP id 73mr9027078pfx.71.1590767527890; Fri, 29 May 2020 08:52:07 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id z23sm7074614pga.86.2020.05.29.08.52.07 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 May 2020 08:52:07 -0700 (PDT) Date: Fri, 29 May 2020 08:52:06 -0700 From: Guenter Roeck 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, Emmanuel Grumbach , Heiko Stuebner , "Rafael J . Wysocki" , Vishal Kulkarni , Luca Coelho , Miquel Raynal , kernel@collabora.com, Fabio Estevam , Amit Kucheria , Chunyan Zhang , Daniel Lezcano , Allison Randal , NXP Linux Team , Darren Hart , Zhang Rui , Gayatri Kammela , Len Brown , Johannes Berg , Intel Linux Wireless , Sascha Hauer , Ido Schimmel , Baolin Wang , Jiri Pirko , Orson Zhai , Thomas Gleixner , Kalle Valo , Support Opensource , Enrico Weigelt , Peter Kaestle , Sebastian Reichel , Bartlomiej Zolnierkiewicz , Pengutronix Kernel Team , Niklas =?iso-8859-1?Q?S=F6derlund?= , Shawn Guo , "David S . Miller" , Andy Shevchenko Subject: Re: [PATCH v4 06/11] thermal: Add mode helpers Message-ID: <20200529155206.GA158553@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Thu, May 28, 2020 at 09:20:46PM +0200, Andrzej Pietrasiewicz wrote: > Prepare for making the drivers not access tzd's private members. > > 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..f2a5c5ee3455 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); > + Nit: unnecessary empty line. > + 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(thermal_zone_device_enable); Other exports in thermal/ use EXPORT_SYMBOL_GPL. > + > +int thermal_zone_device_disable(struct thermal_zone_device *tz) > +{ > + return thermal_zone_device_set_mode(tz, THERMAL_DEVICE_DISABLED); > +} > +EXPORT_SYMBOL(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(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__ */