Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3044516ybt; Mon, 29 Jun 2020 13:47:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYGoX3GoTQMURg4lg+TICqdrlYsCMwfHKTX9frg7HpNWsLaDMss0WOREJBdX2EZdKlwPzT X-Received: by 2002:a17:906:d057:: with SMTP id bo23mr1893007ejb.210.1593463641783; Mon, 29 Jun 2020 13:47:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593463641; cv=none; d=google.com; s=arc-20160816; b=EwXwX9ldmSMoBNP1e6c7XLk+gg6cvLscbTiCeFHs0PxwQtued9FKVyqjFol/q8t0Mp AIBzDw5UjezX3oie0+hQ6So+agRrsS6v05QJB8mNKRGeo0UYf2T00xB00s1mkbOT47MM t1PPVgWIVT7REECABkPsW9xefqjKeBYayQrcO0v377wNizmZFw1nUGcMgjZmbsGASPHX 1ANbSLrF1SK6FXbd/H7uxSF0Mdk7bnSR3+jX3MYvbXY1jLZdfTel7FL3EFmPTlo7yGW1 vZQ4M4SYgZbs1BzAIr6bYCn9xGjq3TIrFZCrZ+X/na2T+vIetGTLu/gbTM9nLM8XdWOY FIrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=O4CL5jT1tY8QD8FjAFdyHeuWe+dWBhI6iRrYPmWg+K0=; b=SnG1a0K3qIpAOY3ep80FrrQL/K0WTWUc3kgFRKw08MsDGse29GLz9omUvrw/jfZjA3 cJN/2/RwXG+ZUaTMWTuCLe4Q7POYnWRFgPwdp59ntnfKO+HD4FrS94tPVnXyezGCupKv zPc3y0dd3EjwW9/vJICZjDTXEkONIDbyErO8CBCwMsjdZvPpCa9hUXpMnpyXRx9PZyjf dzv9U+zrAOfamKdPK8nL+J8jCnhtpMgplKC90Sil3DiTqls+GBvxoRYvzhnKyMyowb58 qhA+igUul+Pac//3oDnUQznFG/jutxYu4vSAeCSIyP+YZfzMb14KdLqrXjKhWZCny6Gz KUzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@verdurent-com.20150623.gappssmtp.com header.s=20150623 header.b=ufgK5aOt; 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 b30si377142edj.204.2020.06.29.13.46.58; Mon, 29 Jun 2020 13:47:21 -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=@verdurent-com.20150623.gappssmtp.com header.s=20150623 header.b=ufgK5aOt; 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 S2388189AbgF2Upi (ORCPT + 99 others); Mon, 29 Jun 2020 16:45:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731573AbgF2TN5 (ORCPT ); Mon, 29 Jun 2020 15:13:57 -0400 Received: from mail-vs1-xe41.google.com (mail-vs1-xe41.google.com [IPv6:2607:f8b0:4864:20::e41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 746C9C08ED8B for ; Mon, 29 Jun 2020 00:05:02 -0700 (PDT) Received: by mail-vs1-xe41.google.com with SMTP id s18so8680809vsi.6 for ; Mon, 29 Jun 2020 00:05:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verdurent-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=O4CL5jT1tY8QD8FjAFdyHeuWe+dWBhI6iRrYPmWg+K0=; b=ufgK5aOt+VEkKCf7cfv7S4ZtNXtnnmklYABTUv1VaPxOyVYlRF0W+WWMz74ZV08AGE 1s1vKmMq4KVk+MBoFIT07TOKURsUNbRQdevHqaQ1aWm8cwm+U1Imt2LTLVn76ZfauBCL Jn8YnNOHw3ZvLP+IWIJlri1ht33n4/CzEON0vrJSMjbdw8TJtfW8X1tddfpQMfXgkCZi BtT26G9ckLhBaXLHozdLJ9i2lXgOWfKOEveukc+nllrmwg/ZQ4vjc16Owk1GMoom+Uhd EtZSUhps1bb5xV0fHsgJxXJI4qzTSeRxyn0KdrZYD00xOxK3NemGIoaULhoM5HjdHhpi jOmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=O4CL5jT1tY8QD8FjAFdyHeuWe+dWBhI6iRrYPmWg+K0=; b=HiRRhyzBsIFtK5mfsEYvNgvo1WyMIu9+av9fK+2twRTV4xRmXop83pIn/K3HQFcdKn jO++W+2DZNvKbdENPYlT6hYEhdHE3fTZc/+ovuMEkfeOQQV05jeo0b4DA6qybC878KM+ 09GYYKP9ALDIl++jzQZKNT+fwboKT1dFbKI8ebuY3H33WjApdNnUSwNv6Bcj+ERvUATg nvwWsEE5piTyq0tko/ble38rK4bh0qOMRrozaistEFwroTo3yFsyuAHyM14AAh94Plq/ +/BWVC68k4+/Xy2Wq8QnUcSyAWpuMHt6W3zAmeVU7g7HzquFvBbn/UNL0LvcwwmCtuTA Cnmw== X-Gm-Message-State: AOAM531WFWVtiwba0HkFYzCc5pKVgKg9hg0SmxEFLflHlCFP+rkCu1Xs VbzjuVd7HnoEY0OfeZrW95LkWA27BmIwGyeK7asj9A== X-Received: by 2002:a05:6102:203:: with SMTP id z3mr2837721vsp.182.1593414301322; Mon, 29 Jun 2020 00:05:01 -0700 (PDT) MIME-Version: 1.0 References: <9cbffad6-69e4-0b33-4640-fde7c4f6a6e7@linaro.org> <20200626173755.26379-1-andrzej.p@collabora.com> <20200626173755.26379-7-andrzej.p@collabora.com> In-Reply-To: <20200626173755.26379-7-andrzej.p@collabora.com> From: Amit Kucheria Date: Mon, 29 Jun 2020 12:34:50 +0530 Message-ID: Subject: Re: [PATCH v5 06/11] thermal: Add mode helpers To: Andrzej Pietrasiewicz Cc: Linux PM list , linux-acpi@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, platform-driver-x86@vger.kernel.org, lakml , 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 , 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 , Bartlomiej Zolnierkiewicz , kernel@collabora.com Content-Type: text/plain; charset="UTF-8" Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Fri, Jun 26, 2020 at 11:08 PM Andrzej Pietrasiewicz wrote: > > 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) Should this be static? > +{ > + 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 >