Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2042455imu; Tue, 6 Nov 2018 08:12:48 -0800 (PST) X-Google-Smtp-Source: AJdET5eH6QByRcuO2NfFXexl8OREfdsVL7yE28tpOqAZGAlCmC8gJgt8d0vOraq2kraQSvROTlN3 X-Received: by 2002:a63:8f45:: with SMTP id r5mr4711604pgn.222.1541520768126; Tue, 06 Nov 2018 08:12:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541520768; cv=none; d=google.com; s=arc-20160816; b=rjDk1WaznL6BQB9in2J83amvu6RaWdr6H39O0mDmPaGi+AeZc6vErgmxn4g+kM5wYJ C3m6E9roJsmbx86ytHUu7wUu2qanh+u1rN469fyUujp0zTxz4JqcXGAljUJZCwicERlc totYjBXzDwlt49ZSjc2z0GeRZXP6Dv42nFhDO9An2XcO5fmb9XzsX1wvWXZnp+uRCPVp 5l6+9+7fWOqfmmZm0WWowfE4gQ+lS1aITHTtq6zae0AozSIwwnskQzEJaD6U223W/Mos iBoJMnhmkOflAFRz0MsNhBfJIVXF5ok8hzzpNMXcwdlQs6uJfYYKqUmjlnybMOiD9oBl oZQA== 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:in-reply-to:mime-version:user-agent:date :message-id:from:cc:to:subject:dkim-signature:dkim-filter; bh=hjPQ4cW2Mdsigk4ROsD6Qnmni/Fhuh35zTnxNIHe1zo=; b=xru0Ss0X8sXvUDOyE/1IElQUBiHtaQeaWx2/mpGeVDE0Hh4aurpV1PxdMtEzshJ9Lo UYIsTu2in+Mha76ZVd7JdBxrH7BvH/OGKKzlZFt0tpeQdYVay6aBy5dPpMYf57cbuiAf NEMLopWqA4HFx/twPMnH8KR+a2pyBx5V8hyC/A1wgXuyPNzY7ym8SONamkGrv+354bUK wVcX7+RQRhbKiIpUaaS109vaRojs0m+SeAGGyOXbDx9hwiaH+gfUDT94qwBkA0Ov/Tv1 bx8k8NgSreIV0XVGWBHJWxww01bNdt4AZtGVdjSOIJ7vdB+EFZsEOzGYd8Dx96J0bar0 hrGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=rucFVYYc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e62-v6si49026904pfe.31.2018.11.06.08.12.21; Tue, 06 Nov 2018 08:12:47 -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; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=rucFVYYc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389178AbeKGBhX (ORCPT + 99 others); Tue, 6 Nov 2018 20:37:23 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:54332 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389146AbeKGBhW (ORCPT ); Tue, 6 Nov 2018 20:37:22 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20181106161127euoutp019d0859e18b0311243c27fe79b9cba0db~klOXFjszx3198431984euoutp01I for ; Tue, 6 Nov 2018 16:11:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20181106161127euoutp019d0859e18b0311243c27fe79b9cba0db~klOXFjszx3198431984euoutp01I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1541520687; bh=hjPQ4cW2Mdsigk4ROsD6Qnmni/Fhuh35zTnxNIHe1zo=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=rucFVYYcvhgQwp/QGOMQTmxtwrVSnruQZ0v9MZLpdOWWaidhOo69V0wW/6Syo0tv/ Qe75ND7JXPCQPkyru+0/oO8vAsu+uuYP2ZMrVL4zgC21cln9ez+dYmO16svD3nu1fB QjS99gvlCmzwKFweHlAIm945869ug3Qpt0vdrr5k= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181106161125eucas1p13cf70f550c5e38afdd32522f92aab8b2~klOV70Nce2666226662eucas1p1g; Tue, 6 Nov 2018 16:11:25 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id C5.E7.04806.D2DB1EB5; Tue, 6 Nov 2018 16:11:25 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20181106161124eucas1p25b9be654095bc0628d301164553bc631~klOVC8u-v2861428614eucas1p2V; Tue, 6 Nov 2018 16:11:24 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20181106161124eusmtrp20e357d9efc635af92dd870512abe9588~klOUxlpcb1300813008eusmtrp2X; Tue, 6 Nov 2018 16:11:24 +0000 (GMT) X-AuditID: cbfec7f5-367ff700000012c6-e0-5be1bd2df575 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 4C.CE.04284.C2DB1EB5; Tue, 6 Nov 2018 16:11:24 +0000 (GMT) Received: from [106.120.53.102] (unknown [106.120.53.102]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20181106161123eusmtip2e1304ffcc17c9d9820687d1842be2efb~klOUD3u110665406654eusmtip2T; Tue, 6 Nov 2018 16:11:23 +0000 (GMT) Subject: Re: [PATCH v2 01/17] thermal: add thermal_zone_set_mode() helper To: Zhang Rui , 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 From: Bartlomiej Zolnierkiewicz Message-ID: Date: Tue, 6 Nov 2018 17:11:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <1541491911.2124.91.camel@intel.com> Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA02Se1BMcRTH++29e7vt2ObXig5FY8cw3hqM33iNR39cw4w0TI3+YHEnRqXZ 2yLMSFmybJ4zsRpJocci2WqLaJIWPUgPEWrNMsojunlsmtLureG/c77nc875npnDUqpu+Vh2 e0wcr43RRKkZBV1U5aybMaPMHjH7jjiGJCVkysgH0YbIdeNDmqQ3NstJ+cEGRAbefZKTJ8WJ MnLIdJkmWQ67J2koTWOIaKxEJO1rqydx2FMY8tHiRwqyWxjiLL1Ik7K3IlrqwyV2VTGcqa2W 4UpMbzy5wlfzuMy7HTKuIPcow71uvstwxqSvDFfcfJHiHqX+ojlbS7GMEwvGh4zYoFi0lY/a vovXzlqySbHtmvGNLNYyYU9aVxGdgCr8DciLBTwX8g+mMwakYFU4G4He8oyWkh4E3fldQxUR gTXznudwS7u5E0mFawi+GeuGqC4ENxJfIBc1Eq+Eh3Xf5QbEsr54FVjMrIuhcA4NZ9vK3JMY vABOHcl180q8BFob02hXTOOJkHGszN07CofDiZrJEuIDj8873IgXDgKDo94dUz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uYTMJtTwFCi68lFMJtZQF3iz7xLzBC2vETz 1tnMExgFZyFpmYWkbBaSsgWMzKsYRVJLi3PTc4sN9YoTc4tL89L1kvNzNzECY33bsZ+bdzBe 2hh8iFGAg1GJh1djx8NoIdbEsuLK3EOMEhzMSiK8p1cDhXhTEiurUovy44tKc1KLDzGaAj0x kVlKNDkfmIbySuINTQ3NLSwNzY3Njc0slMR5zxtURgkJpCeWpGanphakFsH0MXFwSjUwMn/n FahLdzxSd/RF/yQ+1uDjPPm/H3985vT1upHXd63SgnlRfyZV/dot269Rznct1O500+rV7Psy vUT37Gvp2cnwrDLtusxEvbL6+Njgj7nMMl+OXdHgbFg4u8Ml6HfjSe0pZcHZ10/nfFM2kvl7 V0iZc9ExRY1ARsn8xKZPdxfOXXC7Z1qAEktxRqKhFnNRcSIAOhFc0AsDAAA= X-CMS-MailID: 20181106161124eucas1p25b9be654095bc0628d301164553bc631 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20181017155320epcas2p439b713149d94aa485b3c2ffba063ea03 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181017155320epcas2p439b713149d94aa485b3c2ffba063ea03 References: <1539791563-5959-1-git-send-email-b.zolnierkie@samsung.com> <1539791563-5959-2-git-send-email-b.zolnierkie@samsung.com> <1541491911.2124.91.camel@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/06/2018 09:11 AM, Zhang Rui wrote: > 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. I think that it should be added incrementally later when needed. We don't do 'defensive coding' in the kernel and in this patchset thermal_zone_set_mode() is not used in any place which has not used ->set_mode directly previously (actually patches #1-4 should not cause any functionality changes as noted in patch descriptions). > 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 * Best regards, -- Bartlomiej Zolnierkiewicz Samsung R&D Institute Poland Samsung Electronics