From patchwork Tue Mar 25 10:49:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 27035 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 060A420539 for ; Tue, 25 Mar 2014 10:53:42 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id i7sf1099530oag.4 for ; Tue, 25 Mar 2014 03:53:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=khoNO7c4+drY0PL0Df7XH7Gb0gWmK5WgaWTohLmA9O8=; b=Khf0of5au15eh6Gp/IbowM+NpLsc4JV6j09Gxlw1ROPHH3eqwuzcHkWTDvw2hoBlIq RaYN0G/FDNLAm80Roo3QLKJjJB9KAah5Cj0RfBCRVDDzH0IgQ6gM4Myw0vh4GOlfY8v+ 1EEKwg++D8N04avCsgK+S8sRlfsDhbDIc+SyGrY0Ffod2aXDcXLZCyz1Qzr0lUxFIV55 2CGgmfYjI/1RAHvaIcrbs/disach5BSw4E7NS8+GOFpu7NMDsGoI6A3bffK/CQP8q3Oz cKL1FQYaziY0aXQURvkEwOXYVMJEcVyBzu45nQXlxklXbb2Xjzrl68xGIF6sJa7H1oTj VQrw== X-Gm-Message-State: ALoCoQm50vzCpGbAvlbPyQlotepBZ8I2Z1NptKlF9UuONLWvi51eTkOS8lXwrSNqEIGu6iCjqLeQ X-Received: by 10.182.125.134 with SMTP id mq6mr21252788obb.1.1395744822480; Tue, 25 Mar 2014 03:53:42 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.24.110 with SMTP id 101ls185322qgq.88.gmail; Tue, 25 Mar 2014 03:53:42 -0700 (PDT) X-Received: by 10.220.106.84 with SMTP id w20mr55095147vco.18.1395744822335; Tue, 25 Mar 2014 03:53:42 -0700 (PDT) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by mx.google.com with ESMTPS id sh5si3725551vdc.104.2014.03.25.03.53.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 03:53:42 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.180; Received: by mail-ve0-f180.google.com with SMTP id jz11so301958veb.11 for ; Tue, 25 Mar 2014 03:53:42 -0700 (PDT) X-Received: by 10.58.207.74 with SMTP id lu10mr54150242vec.15.1395744822261; Tue, 25 Mar 2014 03:53:42 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp293963vck; Tue, 25 Mar 2014 03:53:41 -0700 (PDT) X-Received: by 10.68.106.130 with SMTP id gu2mr77955962pbb.59.1395744821306; Tue, 25 Mar 2014 03:53:41 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xn1si11134553pbc.395.2014.03.25.03.53.40; Tue, 25 Mar 2014 03:53:40 -0700 (PDT) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754109AbaCYKxd (ORCPT + 26 others); Tue, 25 Mar 2014 06:53:33 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:38234 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753650AbaCYKuQ (ORCPT ); Tue, 25 Mar 2014 06:50:16 -0400 Received: by mail-pa0-f42.google.com with SMTP id fb1so274286pad.15 for ; Tue, 25 Mar 2014 03:50:15 -0700 (PDT) X-Received: by 10.68.52.132 with SMTP id t4mr77574151pbo.102.1395744615878; Tue, 25 Mar 2014 03:50:15 -0700 (PDT) Received: from localhost.localdomain ([162.243.130.63]) by mx.google.com with ESMTPSA id db3sm42987987pbb.10.2014.03.25.03.50.10 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 03:50:15 -0700 (PDT) From: Alex Shi To: mark.hambleton@broadcom.com, mark.brown@linaro.org, eduardo.valentin@ti.com, mporter@linaro.org, lsk-interest@linaro.org, linaro-kernel@linaro.org Cc: Zhang Rui , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Alex Shi Subject: [PATCH 05/19] thermal: core: introduce thermal_of_cooling_device_register Date: Tue, 25 Mar 2014 18:49:18 +0800 Message-Id: <1395744572-20014-6-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1395744572-20014-1-git-send-email-alex.shi@linaro.org> References: <1395744572-20014-1-git-send-email-alex.shi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alex.shi@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Eduardo Valentin This patch adds a new API to allow registering cooling devices in the thermal framework derived from device tree nodes. This API links the cooling device with the device tree node so that binding with thermal zones is possible, given that thermal zones are pointing to cooling device device tree nodes. Cc: Zhang Rui Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin (cherry picked from commit a116b5d44f144586ef03a93f14ddc63f4a85e906) Signed-off-by: Alex Shi Conflicts: drivers/thermal/thermal_core.c --- drivers/thermal/thermal_core.c | 59 +++++++++++++++++++++++++++++++++++++++--- include/linux/thermal.h | 4 +++ 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index ed5f765..916bde1 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include #include @@ -1037,7 +1039,8 @@ static struct class thermal_class = { }; /** - * thermal_cooling_device_register() - register a new thermal cooling device + * __thermal_cooling_device_register() - register a new thermal cooling device + * @np: a pointer to a device tree node. * @type: the thermal cooling device type. * @devdata: device private data. * @ops: standard thermal cooling devices callbacks. @@ -1045,13 +1048,16 @@ static struct class thermal_class = { * This interface function adds a new thermal cooling device (fan/processor/...) * to /sys/class/thermal/ folder as cooling_device[0-*]. It tries to bind itself * to all the thermal zone devices registered at the same time. + * It also gives the opportunity to link the cooling device to a device tree + * node, so that it can be bound to a thermal zone created out of device tree. * * Return: a pointer to the created struct thermal_cooling_device or an * ERR_PTR. Caller must check return value with IS_ERR*() helpers. */ -struct thermal_cooling_device * -thermal_cooling_device_register(char *type, void *devdata, - const struct thermal_cooling_device_ops *ops) +static struct thermal_cooling_device * +__thermal_cooling_device_register(struct device_node *np, + char *type, void *devdata, + const struct thermal_cooling_device_ops *ops) { struct thermal_cooling_device *cdev; int result; @@ -1076,6 +1082,7 @@ thermal_cooling_device_register(char *type, void *devdata, strlcpy(cdev->type, type ? : "", sizeof(cdev->type)); mutex_init(&cdev->lock); INIT_LIST_HEAD(&cdev->thermal_instances); + cdev->np = np; cdev->ops = ops; cdev->updated = true; cdev->device.class = &thermal_class; @@ -1118,9 +1125,53 @@ unregister: device_unregister(&cdev->device); return ERR_PTR(result); } + +/** + * thermal_cooling_device_register() - register a new thermal cooling device + * @type: the thermal cooling device type. + * @devdata: device private data. + * @ops: standard thermal cooling devices callbacks. + * + * This interface function adds a new thermal cooling device (fan/processor/...) + * to /sys/class/thermal/ folder as cooling_device[0-*]. It tries to bind itself + * to all the thermal zone devices registered at the same time. + * + * Return: a pointer to the created struct thermal_cooling_device or an + * ERR_PTR. Caller must check return value with IS_ERR*() helpers. + */ +struct thermal_cooling_device * +thermal_cooling_device_register(char *type, void *devdata, + const struct thermal_cooling_device_ops *ops) +{ + return __thermal_cooling_device_register(NULL, type, devdata, ops); +} EXPORT_SYMBOL_GPL(thermal_cooling_device_register); /** + * thermal_of_cooling_device_register() - register an OF thermal cooling device + * @np: a pointer to a device tree node. + * @type: the thermal cooling device type. + * @devdata: device private data. + * @ops: standard thermal cooling devices callbacks. + * + * This function will register a cooling device with device tree node reference. + * This interface function adds a new thermal cooling device (fan/processor/...) + * to /sys/class/thermal/ folder as cooling_device[0-*]. It tries to bind itself + * to all the thermal zone devices registered at the same time. + * + * Return: a pointer to the created struct thermal_cooling_device or an + * ERR_PTR. Caller must check return value with IS_ERR*() helpers. + */ +struct thermal_cooling_device * +thermal_of_cooling_device_register(struct device_node *np, + char *type, void *devdata, + const struct thermal_cooling_device_ops *ops) +{ + return __thermal_cooling_device_register(np, type, devdata, ops); +} +EXPORT_SYMBOL_GPL(thermal_of_cooling_device_register); + +/** * thermal_cooling_device_unregister - removes the registered thermal cooling device * @cdev: the thermal cooling device to remove. * diff --git a/include/linux/thermal.h b/include/linux/thermal.h index bd2533b..55fce47 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -25,6 +25,7 @@ #ifndef __THERMAL_H__ #define __THERMAL_H__ +#include #include #include #include @@ -270,6 +271,9 @@ void thermal_zone_device_update(struct thermal_zone_device *); struct thermal_cooling_device *thermal_cooling_device_register(char *, void *, const struct thermal_cooling_device_ops *); +struct thermal_cooling_device * +thermal_of_cooling_device_register(struct device_node *np, char *, void *, + const struct thermal_cooling_device_ops *); void thermal_cooling_device_unregister(struct thermal_cooling_device *); struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name); int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);