From patchwork Mon Dec 8 17:04:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 5457671 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9B5AC9F1C5 for ; Mon, 8 Dec 2014 17:07:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B977A2017E for ; Mon, 8 Dec 2014 17:06:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0053720160 for ; Mon, 8 Dec 2014 17:06:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752334AbaLHRG5 (ORCPT ); Mon, 8 Dec 2014 12:06:57 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:42916 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750908AbaLHRG4 (ORCPT ); Mon, 8 Dec 2014 12:06:56 -0500 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NG900KOVWVIRF40@mailout3.samsung.com>; Tue, 09 Dec 2014 02:06:54 +0900 (KST) X-AuditID: cbfee61a-f79c06d000004e71-9e-5485daae8a34 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 07.13.20081.EAAD5845; Tue, 09 Dec 2014 02:06:54 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NG900HU3WRB5450@mmp1.samsung.com>; Tue, 09 Dec 2014 02:06:54 +0900 (KST) From: Lukasz Majewski To: Eduardo Valentin , Zhang Rui Cc: Linux PM list , Thierry Reding , Bartlomiej Zolnierkiewicz , Lukasz Majewski , Mikko Perttunen , Stephen Warren , Abhilash Kesavan , Abhilash Kesavan , Guenter Roeck , linux-kernel@vger.kernel.org, Caesar Wang , navneet kumar , Lukasz Majewski Subject: [PATCH v3 2/5] thermal: of: Extend of-thermal.c to provide check if trip point is valid Date: Mon, 08 Dec 2014 18:04:18 +0100 Message-id: <1418058261-25251-3-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-reply-to: <1418058261-25251-1-git-send-email-l.majewski@samsung.com> References: <1416500488-7232-1-git-send-email-l.majewski@samsung.com> <1418058261-25251-1-git-send-email-l.majewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrPLMWRmVeSWpSXmKPExsVy+t9jAd11t1pDDLofC1k8XrOYyWLjjPWs Fl8+97FZzL9yjdVizV8lizePuC3ePNzMaHF51xw2i8+9Rxgtniw8w2Tx4Oo0Not9a5YyWTx5 CFT/6mAbi8XPXfNYHPg9ds66y+6xeM9LJo91094ye/Q2v2Pz+DtrP4vHzu8N7B59W1Yxenze JOexcW5oAGcUl01Kak5mWWqRvl0CV8b5Y3eYC14LV3R+WcrewHhUoIuRk0NCwETi+/u1jBC2 mMSFe+vZuhi5OIQEFjFK7F79ghnC6WKSuDKtkwWkik1AT+Lz3adMILaIgLfE633TGUGKmAXW sEh8uHqXDSQhLJAksejjSjCbRUBVYuuaPWA2r4CbxPrD+6HWKUp0P5sAFucUcJc4f+86K8S2 JkaJyzt2skxg5F3AyLCKUTS1ILmgOCk911CvODG3uDQvXS85P3cTIziYn0ntYFzZYHGIUYCD UYmHd8GDlhAh1sSy4srcQ4wSHMxKIrzLd7aGCPGmJFZWpRblxxeV5qQWH2KU5mBREue9cTM3 REggPbEkNTs1tSC1CCbLxMEp1cBYsqMwUbdGWPtFTLrK3qKXDfyByueWpLskydyc57IgOuh1 y6IFLx1qpv3LerU30TVj2/+Qz8/0BW1ShIo3fJl4L/CSlk5X0tP5R6ZuV8rL/KF5wH/9nDTm G22n/XtmbcucGHkwZs23a2Yt2huu/7d1XuY2c++uS/vkRETmHs7jvqNd8jDcKfa4EktxRqKh FnNRcSIAm5oWQGICAAA= Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch extends the of-thermal.c to provide check if trip point is valid. Signed-off-by: Lukasz Majewski --- Changes for v3: - Rename of_thermal_is_trip_en() to of_thermal_is_trip_valid() - Export of_thermal_is_trip_valid symbol as GPL - Fix the build error when CONFIG_THERMAL_OF is not defined Changes for v2: - Replace int with bool - Replace 1/0 with true/false - Add check if data pointer is not NULL - Add missing doxygen style comment for the function --- drivers/thermal/of-thermal.c | 21 +++++++++++++++++++++ drivers/thermal/thermal_core.h | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index 7facd23..87b9cfe 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -133,6 +133,27 @@ int of_thermal_get_ntrips(struct thermal_zone_device *tz) } EXPORT_SYMBOL_GPL(of_thermal_get_ntrips); +/** + * of_thermal_is_trip_valid - function to check if trip point is valid + * + * @tz: pointer to a thermal zone + * @trip: trip point to evaluate + * + * This function is responsible for checking if passed trip point is valid + * + * Return: true if trip point is valid, false otherwise + */ +bool of_thermal_is_trip_valid(struct thermal_zone_device *tz, int trip) +{ + struct __thermal_zone *data = tz->devdata; + + if (!data || trip >= data->ntrips || trip < 0) + return false; + + return true; +} +EXPORT_SYMBOL_GPL(of_thermal_is_trip_valid); + static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip, enum thermal_trend *trend) { diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 1cc5041..58a0dfa 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -90,6 +90,7 @@ static inline void thermal_gov_user_space_unregister(void) {} int of_parse_thermal_zones(void); void of_thermal_destroy_zones(void); int of_thermal_get_ntrips(struct thermal_zone_device *); +bool of_thermal_is_trip_valid(struct thermal_zone_device *, int); #else static inline int of_parse_thermal_zones(void) { return 0; } static inline void of_thermal_destroy_zones(void) { } @@ -97,6 +98,11 @@ static inline int of_thermal_get_ntrips(struct thermal_zone_device *tz) { return 0; } +static inline bool of_thermal_is_trip_valid(struct thermal_zone_device *tz, + int trip) +{ + return 0; +} #endif #endif /* __THERMAL_CORE_H__ */