From patchwork Tue Mar 25 10:49:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 27033 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f198.google.com (mail-ve0-f198.google.com [209.85.128.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5918420539 for ; Tue, 25 Mar 2014 10:52:52 +0000 (UTC) Received: by mail-ve0-f198.google.com with SMTP id oz11sf641564veb.9 for ; Tue, 25 Mar 2014 03:52:52 -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=9aeHGDsxaDCnqe/95kkwNsAPmOL5KfbGRK0ZA0EL8Qk=; b=BO50F2uQC3DZNAYR/WWDNxhyvoDKoDgM0b8QBCkWzic7D1pcShEifnOhPBrmyK5vV0 RAHkZLsfFwwXTpOkF+lLDduJfWogdz2CbQxdyNkE8ZfOutGRFW/NkH6hO4i72RSuVcTo NLuvM2B6ro4AzB64+9l4gAG8LK/8izkk7JezAQPY0CCQ+TUDBRVjsT06wzfdsozjLXYq AT/xvNLHv2GwaLPPP6IUbp9HgtUzjI4ZCOHsdCK8mt6eKSLpASaZVXMlQIVAVRn0+l60 2fjPf8fJyUacLsTLJUR66qDhOiF2mKVIKKNVYnZBqZjLuTGY6hhuffGUim+6Se+xnVE/ wdXA== X-Gm-Message-State: ALoCoQnatOhZweBcSuHL+ZhUaEkxvKySx8uGAXVniau/foMMQg3xPp/3NvyaiJON6RLh7DB+5gg/ X-Received: by 10.236.197.39 with SMTP id s27mr17729903yhn.36.1395744772017; Tue, 25 Mar 2014 03:52:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.18.175 with SMTP id 44ls172624qgf.24.gmail; Tue, 25 Mar 2014 03:52:51 -0700 (PDT) X-Received: by 10.58.229.167 with SMTP id sr7mr53172821vec.7.1395744771918; Tue, 25 Mar 2014 03:52:51 -0700 (PDT) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id sn5si3725106vdc.155.2014.03.25.03.52.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 03:52:51 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.177 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.177; Received: by mail-ve0-f177.google.com with SMTP id sa20so292502veb.8 for ; Tue, 25 Mar 2014 03:52:51 -0700 (PDT) X-Received: by 10.52.99.168 with SMTP id er8mr4806496vdb.26.1395744771826; Tue, 25 Mar 2014 03:52:51 -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 i9csp293915vck; Tue, 25 Mar 2014 03:52:51 -0700 (PDT) X-Received: by 10.66.146.229 with SMTP id tf5mr78585671pab.50.1395744766834; Tue, 25 Mar 2014 03:52:46 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j1si11145456pbr.257.2014.03.25.03.52.46; Tue, 25 Mar 2014 03:52:46 -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 S1753791AbaCYKuq (ORCPT + 26 others); Tue, 25 Mar 2014 06:50:46 -0400 Received: from mail-pb0-f43.google.com ([209.85.160.43]:52493 "EHLO mail-pb0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753754AbaCYKui (ORCPT ); Tue, 25 Mar 2014 06:50:38 -0400 Received: by mail-pb0-f43.google.com with SMTP id um1so278696pbc.16 for ; Tue, 25 Mar 2014 03:50:38 -0700 (PDT) X-Received: by 10.68.137.136 with SMTP id qi8mr77591441pbb.79.1395744638149; Tue, 25 Mar 2014 03:50:38 -0700 (PDT) Received: from localhost.localdomain ([162.243.130.63]) by mx.google.com with ESMTPSA id db3sm42987987pbb.10.2014.03.25.03.50.32 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 03:50:37 -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: Jean Delvare , lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org, Alex Shi Subject: [PATCH 08/19] hwmon: tmp102: expose to thermal fw via DT nodes Date: Tue, 25 Mar 2014 18:49:21 +0800 Message-Id: <1395744572-20014-9-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.177 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 to tmp102 temperature sensor the possibility to expose itself as thermal zone device, registered on the thermal framework. The thermal zone is built only if a device tree node describing a thermal zone for this sensor is present inside the tmp102 DT node. Otherwise, the driver behavior will be the same. Note: This patch has also been reviewed by Jean D. He has requested to perform a wider inspection of possible users of thermal and hwmon interaction API. On the other hand, the change on this patch is acceptable on first step of overall code change. Cc: Jean Delvare Cc: lm-sensors@lm-sensors.org Cc: linux-kernel@vger.kernel.org Acked-by: Guenter Roeck Signed-off-by: Eduardo Valentin (cherry picked from commit 6a027523f30f1cc90037686e6a682d15c6a555d6) Signed-off-by: Alex Shi --- drivers/hwmon/tmp102.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c index d7b47ab..6748b45 100644 --- a/drivers/hwmon/tmp102.c +++ b/drivers/hwmon/tmp102.c @@ -27,6 +27,8 @@ #include #include #include +#include +#include #define DRIVER_NAME "tmp102" @@ -50,6 +52,7 @@ struct tmp102 { struct device *hwmon_dev; + struct thermal_zone_device *tz; struct mutex lock; u16 config_orig; unsigned long last_update; @@ -93,6 +96,15 @@ static struct tmp102 *tmp102_update_device(struct i2c_client *client) return tmp102; } +static int tmp102_read_temp(void *dev, long *temp) +{ + struct tmp102 *tmp102 = tmp102_update_device(to_i2c_client(dev)); + + *temp = tmp102->temp[0]; + + return 0; +} + static ssize_t tmp102_show_temp(struct device *dev, struct device_attribute *attr, char *buf) @@ -204,6 +216,12 @@ static int tmp102_probe(struct i2c_client *client, goto fail_remove_sysfs; } + tmp102->tz = thermal_zone_of_sensor_register(&client->dev, 0, + &client->dev, + tmp102_read_temp, NULL); + if (IS_ERR(tmp102->tz)) + tmp102->tz = NULL; + dev_info(&client->dev, "initialized\n"); return 0; @@ -220,6 +238,7 @@ static int tmp102_remove(struct i2c_client *client) { struct tmp102 *tmp102 = i2c_get_clientdata(client); + thermal_zone_of_sensor_unregister(&client->dev, tmp102->tz); hwmon_device_unregister(tmp102->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &tmp102_attr_group);