From patchwork Mon Feb 18 11:30:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Ni X-Patchwork-Id: 2156861 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 44B073FCFC for ; Mon, 18 Feb 2013 11:31:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751149Ab3BRLb2 (ORCPT ); Mon, 18 Feb 2013 06:31:28 -0500 Received: from hqemgate03.nvidia.com ([216.228.121.140]:2564 "EHLO hqemgate03.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751282Ab3BRLbZ (ORCPT ); Mon, 18 Feb 2013 06:31:25 -0500 Received: from hqnvupgp05.nvidia.com (Not Verified[216.228.121.13]) by hqemgate03.nvidia.com id ; Mon, 18 Feb 2013 03:36:00 -0800 Received: from hqemhub01.nvidia.com ([172.20.150.30]) by hqnvupgp05.nvidia.com (PGP Universal service); Mon, 18 Feb 2013 03:31:14 -0800 X-PGP-Universal: processed; by hqnvupgp05.nvidia.com on Mon, 18 Feb 2013 03:31:14 -0800 Received: from hkemhub02.nvidia.com (10.18.67.13) by hqemhub01.nvidia.com (172.20.150.30) with Microsoft SMTP Server (TLS) id 8.3.297.1; Mon, 18 Feb 2013 03:31:13 -0800 Received: from niwei-ubuntu.nvidia.com (10.18.67.5) by hkemhub02.nvidia.com (10.18.67.13) with Microsoft SMTP Server id 8.3.297.1; Mon, 18 Feb 2013 19:31:09 +0800 From: Wei Ni To: , , , CC: , , , , , , Wei Ni Subject: [RFC PATCH 5/9] Thermal: Support using dt node to get sensor Date: Mon, 18 Feb 2013 19:30:27 +0800 Message-ID: <1361187031-3679-6-git-send-email-wni@nvidia.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1361187031-3679-1-git-send-email-wni@nvidia.com> References: <1361187031-3679-1-git-send-email-wni@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add functions to support using dt node with args to get sensor. Signed-off-by: Wei Ni --- drivers/thermal/thermal_sys.c | 30 ++++++++++++++++++++++++++++++ include/linux/thermal.h | 9 +++++++++ 2 files changed, 39 insertions(+) diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index e284b67..b5bedab 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c @@ -2183,6 +2183,28 @@ struct thermal_sensor *get_sensor_by_name(const char *name) } EXPORT_SYMBOL(get_sensor_by_name); +struct thermal_sensor *get_sensor_by_node(struct node_args *np_args) +{ + struct thermal_sensor *pos; + struct thermal_sensor *ts = NULL; + struct node_args *args; + + mutex_lock(&sensor_list_lock); + for_each_thermal_sensor(pos) { + args = &pos->np_args; + if (args->np) { + if ((args->np == np_args->np) && + (args->index == np_args->index)) { + ts = pos; + break; + } + } + } + mutex_unlock(&sensor_list_lock); + return ts; +} +EXPORT_SYMBOL(get_sensor_by_node); + static int create_map_attrs(struct thermal_zone *tz, int indx) { int ret, i; @@ -2368,6 +2390,7 @@ EXPORT_SYMBOL(add_sensor_trip_info); * @devdata: private device data */ struct thermal_sensor *thermal_sensor_register(const char *name, int count, + struct node_args *np_args, struct thermal_sensor_ops *ops, void *devdata) { struct thermal_sensor *ts; @@ -2412,6 +2435,13 @@ struct thermal_sensor *thermal_sensor_register(const char *name, int count, goto exit_temp; } + if (np_args) { + ts->np_args.np = np_args->np; + ts->np_args.index = np_args->index; + } else { + ts->np_args.np = NULL; + } + /* Add this sensor to the global list of sensors */ mutex_lock(&sensor_list_lock); list_add_tail(&ts->node, &thermal_sensor_list); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 4389599..b560ffa 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -113,6 +113,12 @@ enum { }; #define THERMAL_GENL_CMD_MAX (__THERMAL_GENL_CMD_MAX - 1) +/* support to parse node with args to get sensor or cooling device */ +struct node_args { + struct device_node *np; + int index; +}; + struct thermal_zone_device_ops { int (*bind) (struct thermal_zone_device *, struct thermal_cooling_device *); @@ -223,6 +229,7 @@ struct thermal_sensor { void *devdata; struct idr idr; struct device device; + struct node_args np_args; struct list_head node; struct thermal_sensor_ops *ops; struct thermal_attr *thresh_attrs; @@ -350,6 +357,7 @@ int thermal_register_governor(struct thermal_governor *); void thermal_unregister_governor(struct thermal_governor *); struct thermal_sensor *thermal_sensor_register(const char *, int, + struct node_args *, struct thermal_sensor_ops *, void *); void thermal_sensor_unregister(struct thermal_sensor *); @@ -357,6 +365,7 @@ struct thermal_zone *create_thermal_zone(const char *, void *); void remove_thermal_zone(struct thermal_zone *); int add_sensor_to_zone(struct thermal_zone *, struct thermal_sensor *); struct thermal_sensor *get_sensor_by_name(const char *); +struct thermal_sensor *get_sensor_by_node(struct node_args *); int add_cdev_to_zone(struct thermal_zone *, struct thermal_cooling_device *); struct thermal_cooling_device *get_cdev_by_name(const char *);