Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1563696imu; Tue, 6 Nov 2018 00:12:35 -0800 (PST) X-Google-Smtp-Source: AJdET5cZYYka1zevda+kauRof2K5fxJctVcpVzgHzKf5ENWIHUhPxC+8IYOAXef1IeckKoP3/x/J X-Received: by 2002:a62:8a0d:: with SMTP id y13-v6mr25409154pfd.142.1541491955158; Tue, 06 Nov 2018 00:12:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541491955; cv=none; d=google.com; s=arc-20160816; b=T14ip+aDI1Qu3rAU/I4hpmOwqoGbPqRp/euJlOBHloJPkTDC0V9ScFb2JZ52nol2er d2gkrIQyeO3sxhcW6gnvERK0N0xuC+5/Dxxz5lklC+/lRSbxiJ/QOZmQtd0fu3DXkSs2 JE9ivOCEFnqKouqZkaNlq58LkQ+veS1RVs8MyMsqcZ512TGEQ4YT8eiCslLYZJqMCTrS jX3Sv1p4rCtLbPg/aPJCSvcQpAFYNrNbpRXJPFnQl1OmQB4l1IL1nDPhhG3GnJqwZNhL VsSw4hx8+8rjaxWAxY82px4NnShkTouFwKSxWqRpMbMH2gO6sn7QtZvb91N+UqeHEz9n ZqIQ== 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:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=Gb668rOIsmhWuryXE0gAkPke3Fe0FFS2Z/JCwHmmIwM=; b=YNT6EkYUgl1LR+OEcPmyjMTNjZ5comDRJN+qGU9qcEOd0AYvr05L6ggRkWRRdXLdMU EUeWXpIWA/QvqSwEHTyMP+/4ZI5KuIzTAwGW9n/sle1mIAkVbbBhin/bIvB6jHZPAy7c O69CPHrQgh/ErWX8OKmmf5nh0RN5ncZ9cHvNP2zU7juk0sMCslJQT6+qbBuZvISMZK2a IFls8Jw5hE5rQD7J3Y3c9OjgQNGScBEBL0DouuHjXCM/bAOEq8zNF7LoioaVQ6IvuxKq Eb33p0wsLuq46DQVs1nruhespbr5fm0YJKP1ZBqh5VM8qXmAx8ju/5MC+F22nwEED7wx Ar1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r18-v6si38709449pfc.253.2018.11.06.00.12.19; Tue, 06 Nov 2018 00:12:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387399AbeKFRf7 (ORCPT + 99 others); Tue, 6 Nov 2018 12:35:59 -0500 Received: from mga07.intel.com ([134.134.136.100]:13183 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729021AbeKFRf7 (ORCPT ); Tue, 6 Nov 2018 12:35:59 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Nov 2018 00:11:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,471,1534834800"; d="scan'208";a="101887378" Received: from dgao1-mobl1.ccr.corp.intel.com ([10.255.30.243]) by fmsmga002.fm.intel.com with ESMTP; 06 Nov 2018 00:11:54 -0800 Message-ID: <1541491911.2124.91.camel@intel.com> Subject: Re: [PATCH v2 01/17] thermal: add thermal_zone_set_mode() helper From: Zhang Rui To: Bartlomiej Zolnierkiewicz , Eduardo Valentin Cc: Amit kucheria , Eric Anholt , Stefan Wahren , Markus Mayer , bcm-kernel-feedback-list@broadcom.com, Heiko Stuebner , Thierry Reding , Jonathan Hunter , Keerthy , Masahiro Yamada , Jun Nie , Baoyou Xie , Shawn Guo , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 06 Nov 2018 16:11:51 +0800 In-Reply-To: <1539791563-5959-2-git-send-email-b.zolnierkie@samsung.com> References: <1539791563-5959-1-git-send-email-b.zolnierkie@samsung.com> <1539791563-5959-2-git-send-email-b.zolnierkie@samsung.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 三, 2018-10-17 at 17:52 +0200, Bartlomiej Zolnierkiewicz wrote: > In order to remove the code duplication and prepare for further > changes: > > * Add thermal_zone_set_mode() helper. Then update core code and >   drivers to use it. > > There should be no functional changes caused by this patch. > > Signed-off-by: Bartlomiej Zolnierkiewicz > --- >  drivers/thermal/hisi_thermal.c     | 14 ++------------ >  drivers/thermal/of-thermal.c       |  3 ++- >  drivers/thermal/rockchip_thermal.c | 26 +++++++++----------------- >  drivers/thermal/thermal_helpers.c  | 14 ++++++++++++++ >  drivers/thermal/thermal_sysfs.c    |  8 +++++--- >  include/linux/thermal.h            |  5 +++++ >  6 files changed, 37 insertions(+), 33 deletions(-) > >  >   > diff --git a/drivers/thermal/thermal_helpers.c > b/drivers/thermal/thermal_helpers.c > index 2ba756a..b18cee2 100644 > --- a/drivers/thermal/thermal_helpers.c > +++ b/drivers/thermal/thermal_helpers.c > @@ -224,3 +224,17 @@ int thermal_zone_get_offset(struct > thermal_zone_device *tz) >   return 0; >  } >  EXPORT_SYMBOL_GPL(thermal_zone_get_offset); > + > +/** > + * thermal_zone_set_mode() - sets mode of thermal zone device > + * @tz: a valid pointer to a struct thermal_zone_device > + * @mode: mode to be set > + * > + * Return: On success returns 0, an error code otherwise. > + */ > +int thermal_zone_set_mode(struct thermal_zone_device *tz, > +   enum thermal_device_mode mode) > +{ > + return tz->ops->set_mode(tz, mode); better to check tz->ops->set_mode first. thanks, rui > +} > +EXPORT_SYMBOL_GPL(thermal_zone_set_mode); > diff --git a/drivers/thermal/thermal_sysfs.c > b/drivers/thermal/thermal_sysfs.c > index 2241cea..2e9e762 100644 > --- a/drivers/thermal/thermal_sysfs.c > +++ b/drivers/thermal/thermal_sysfs.c > @@ -69,17 +69,19 @@ >  { >   struct thermal_zone_device *tz = to_thermal_zone(dev); >   int result; > + enum thermal_device_mode mode; >   >   if (!tz->ops->set_mode) >   return -EPERM; >   >   if (!strncmp(buf, "enabled", sizeof("enabled") - 1)) > - result = tz->ops->set_mode(tz, > THERMAL_DEVICE_ENABLED); > + mode = THERMAL_DEVICE_ENABLED; >   else if (!strncmp(buf, "disabled", sizeof("disabled") - 1)) > - result = tz->ops->set_mode(tz, > THERMAL_DEVICE_DISABLED); > + mode = THERMAL_DEVICE_DISABLED; >   else > - result = -EINVAL; > + return -EINVAL; >   > + result = thermal_zone_set_mode(tz, mode); >   if (result) >   return result; >   > diff --git a/include/linux/thermal.h b/include/linux/thermal.h > index 5f4705f..9d21fd1 100644 > --- a/include/linux/thermal.h > +++ b/include/linux/thermal.h > @@ -452,6 +452,8 @@ struct thermal_cooling_device * >  int thermal_zone_get_temp(struct thermal_zone_device *tz, int > *temp); >  int thermal_zone_get_slope(struct thermal_zone_device *tz); >  int thermal_zone_get_offset(struct thermal_zone_device *tz); > +int thermal_zone_set_mode(struct thermal_zone_device *tz, > +   enum thermal_device_mode mode); >   >  int get_tz_trend(struct thermal_zone_device *, int); >  struct thermal_instance *get_thermal_instance(struct > thermal_zone_device *, > @@ -518,6 +520,9 @@ static inline int thermal_zone_get_slope( >  static inline int thermal_zone_get_offset( >   struct thermal_zone_device *tz) >  { return -ENODEV; } > +static inline int thermal_zone_set_mode( > + struct thermal_zone_device *tz, enum > thermal_device_mode mode) > +{ return -ENODEV; } >  static inline int get_tz_trend(struct thermal_zone_device *tz, int > trip) >  { return -ENODEV; } >  static inline struct thermal_instance *