From patchwork Thu Oct 9 16:38:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 5059751 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6E41CC11AC for ; Thu, 9 Oct 2014 16:42:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DA7B120200 for ; Thu, 9 Oct 2014 16:42:45 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 021FC201FE for ; Thu, 9 Oct 2014 16:42:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XcGkx-00030V-IZ; Thu, 09 Oct 2014 16:39:59 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XcGkY-0002ki-Vp for linux-arm-kernel@lists.infradead.org; Thu, 09 Oct 2014 16:39:35 +0000 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 <0ND6009PRRLOJN20@mailout3.samsung.com> for linux-arm-kernel@lists.infradead.org; Fri, 10 Oct 2014 01:39:24 +0900 (KST) X-AuditID: cbfee61a-f79c06d000004e71-31-5436ba3ca259 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 44.CD.20081.C3AB6345; Fri, 10 Oct 2014 01:39:24 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0ND600M6SRKZPK30@mmp2.samsung.com>; Fri, 10 Oct 2014 01:39:24 +0900 (KST) From: Lukasz Majewski To: Eduardo Valentin , Zhang Rui Subject: [PATCH 04/21] thermal: of: Extend current of-thermal.c code to allow setting emulated temp Date: Thu, 09 Oct 2014 18:38:40 +0200 Message-id: <1412872737-624-5-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-reply-to: <1412872737-624-1-git-send-email-l.majewski@samsung.com> References: <1412872737-624-1-git-send-email-l.majewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrHLMWRmVeSWpSXmKPExsVy+t9jQV2bXWYhBh/eClk0XA2x2DhjPavF 9S/PWS3mX7nGatG74CqbxdmmN+wWbx5xW7x5uJnRYtNjoPjn3iOMFjPO72OyePKwj82Bx2Pn rLvsHov3vGTy2Lyk3mPdtLfMHn1bVjF6fN4kF8AWxWWTkpqTWZZapG+XwJUx6etV5oJuhYrv Rw4wNjC+lOxi5OSQEDCRWPt8GyOELSZx4d56ti5GLg4hgemMEtvOvWYCSQgJdDFJbF4lCGKz CehJfL77FCwuIuAt8XrfdEaQBmaBq8wSl3evZAVJCAukSlxZsx/I5uBgEVCVWLBKAiTMK+Ai MWVWHwvEMkWJ7mcT2EBsTgFXiaePVzND7HKRuP3oJfsERt4FjAyrGEVTC5ILipPScw31ihNz i0vz0vWS83M3MYJD8ZnUDsaVDRaHGAU4GJV4eB/8Mw0RYk0sK67MPcQowcGsJMK7faZZiBBv SmJlVWpRfnxRaU5q8SFGaQ4WJXHeA63WgUIC6YklqdmpqQWpRTBZJg5OqQbG9gusFpc9wuSf Cn3puVop2qyz8u7Vlgtix3WF7u3SXBEUVlb88NCfC+vXX16yWHjN5E1T4xr/HFoZteKdVaT/ z4Bfjz/tvZ9wXLr5/7135Q7nO1yYZ3b1av81YVd/MvXe4slmZp6u+VnGcu3b3iQvntZzVXJK xD27UscL/8rXxE1pKc4vLzEXV2Ipzkg01GIuKk4EABPdK8ZBAgAA X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141009_093935_217720_93C1B287 X-CRM114-Status: GOOD ( 12.91 ) X-Spam-Score: -5.0 (-----) Cc: Lukasz Majewski , Kukjin Kim , Bartlomiej Zolnierkiewicz , Lukasz Majewski , Linux PM list , Kyungmin Park , Chanwoo Choi , Amit Daniel Kachhap , "linux-samsung-soc@vger.kernel.org" , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 Before this change it was only possible to set get_temp() and get_trend() methods to be used in the common code handling passing parameters via device tree to "cpu-thermal" CPU thermal zone device. Now it is possible to also set emulated value of temperature for debug purposes. Signed-off-by: Lukasz Majewski --- drivers/thermal/of-thermal.c | 25 ++++++++++++++++++++++--- include/linux/thermal.h | 6 ++++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index cd74e64..f206375 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -98,10 +98,22 @@ struct __thermal_zone { void *sensor_data; int (*get_temp)(void *, long *); int (*get_trend)(void *, long *); + int (*set_emul_temp)(void *, unsigned long); }; /*** DT thermal zone device callbacks ***/ +static int of_thermal_set_emul_temp(struct thermal_zone_device *tz, + unsigned long temp) +{ + struct __thermal_zone *data = tz->devdata; + + if (!data->set_emul_temp) + return -EINVAL; + + return data->set_emul_temp(data->sensor_data, temp); +} + static int of_thermal_get_temp(struct thermal_zone_device *tz, unsigned long *temp) { @@ -352,7 +364,8 @@ static struct thermal_zone_device * thermal_zone_of_add_sensor(struct device_node *zone, struct device_node *sensor, void *data, int (*get_temp)(void *, long *), - int (*get_trend)(void *, long *)) + int (*get_trend)(void *, long *), + int (*set_emul_temp)(void *, unsigned long)) { struct thermal_zone_device *tzd; struct __thermal_zone *tz; @@ -366,10 +379,12 @@ thermal_zone_of_add_sensor(struct device_node *zone, mutex_lock(&tzd->lock); tz->get_temp = get_temp; tz->get_trend = get_trend; + tz->set_emul_temp = set_emul_temp; tz->sensor_data = data; tzd->ops->get_temp = of_thermal_get_temp; tzd->ops->get_trend = of_thermal_get_trend; + tzd->ops->set_emul_temp = of_thermal_set_emul_temp; mutex_unlock(&tzd->lock); return tzd; @@ -411,7 +426,8 @@ thermal_zone_of_add_sensor(struct device_node *zone, struct thermal_zone_device * thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data, int (*get_temp)(void *, long *), - int (*get_trend)(void *, long *)) + int (*get_trend)(void *, long *), + int (*set_emul_temp)(void *, unsigned long)) { struct device_node *np, *child, *sensor_np; @@ -453,7 +469,8 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id, return thermal_zone_of_add_sensor(child, sensor_np, data, get_temp, - get_trend); + get_trend, + set_emul_temp); } } of_node_put(np); @@ -494,9 +511,11 @@ void thermal_zone_of_sensor_unregister(struct device *dev, mutex_lock(&tzd->lock); tzd->ops->get_temp = NULL; tzd->ops->get_trend = NULL; + tzd->ops->set_emul_temp = NULL; tz->get_temp = NULL; tz->get_trend = NULL; + tz->set_emul_temp = NULL; tz->sensor_data = NULL; mutex_unlock(&tzd->lock); } diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 0305cde..36010e9 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -290,14 +290,16 @@ struct thermal_genl_event { struct thermal_zone_device * thermal_zone_of_sensor_register(struct device *dev, int id, void *data, int (*get_temp)(void *, long *), - int (*get_trend)(void *, long *)); + int (*get_trend)(void *, long *), + int (*set_emul_temp)(void *, unsigned long)); void thermal_zone_of_sensor_unregister(struct device *dev, struct thermal_zone_device *tz); #else static inline struct thermal_zone_device * thermal_zone_of_sensor_register(struct device *dev, int id, void *data, int (*get_temp)(void *, long *), - int (*get_trend)(void *, long *)) + int (*get_trend)(void *, long *), + int (*set_emul_temp)(void *, unsigned long)) { return NULL; }