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: 5059351 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: X-Original-To: patchwork-linux-pm@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 09F9AC11AC for ; Thu, 9 Oct 2014 16:39:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1D4E820204 for ; Thu, 9 Oct 2014 16:39:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 55E4A2020E for ; Thu, 9 Oct 2014 16:39:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755646AbaJIQj0 (ORCPT ); Thu, 9 Oct 2014 12:39:26 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:65347 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757508AbaJIQjZ (ORCPT ); Thu, 9 Oct 2014 12:39:25 -0400 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>; 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 Cc: "linux-samsung-soc@vger.kernel.org" , linux-arm-kernel@lists.infradead.org, Linux PM list , Kukjin Kim , Bartlomiej Zolnierkiewicz , Lukasz Majewski , Amit Daniel Kachhap , Kyungmin Park , Chanwoo Choi , Lukasz Majewski 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 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 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; }