From patchwork Thu Nov 27 01:16:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: navneet kumar X-Patchwork-Id: 5390981 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 C07B9C11AC for ; Thu, 27 Nov 2014 01:17:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CEACB201EC for ; Thu, 27 Nov 2014 01:17:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 04420201C8 for ; Thu, 27 Nov 2014 01:17:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753480AbaK0BRS (ORCPT ); Wed, 26 Nov 2014 20:17:18 -0500 Received: from hqemgate16.nvidia.com ([216.228.121.65]:7981 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753356AbaK0BRG (ORCPT ); Wed, 26 Nov 2014 20:17:06 -0500 Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com id ; Wed, 26 Nov 2014 17:17:10 -0800 Received: from hqemhub03.nvidia.com ([172.20.12.94]) by hqnvupgp07.nvidia.com (PGP Universal service); Wed, 26 Nov 2014 17:15:41 -0800 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Wed, 26 Nov 2014 17:15:41 -0800 Received: from navneetk-ASUS.nvidia.com (172.20.144.16) by hqemhub03.nvidia.com (172.20.150.15) with Microsoft SMTP Server (TLS) id 8.3.342.0; Wed, 26 Nov 2014 17:17:05 -0800 From: Navneet Kumar To: , CC: , , navneet kumar Subject: [PATCH 3/3] thermal: of: notify sensor driver on trip updates Date: Wed, 26 Nov 2014 17:16:29 -0800 Message-ID: <1417050989-25405-3-git-send-email-navneetk@nvidia.com> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1417050989-25405-1-git-send-email-navneetk@nvidia.com> References: <1417050989-25405-1-git-send-email-navneetk@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 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 From: navneet kumar some thermal sensor hardwares include logic which can raise interrupts at certain programmed temperature thresholds. Drivers for such sensors should be able to learn the appropriate threshold temperatures for interrupts by querying the thermal framework. This change provides a mechanism to allow a sensor driver to update it's thresholds when userspace changes a trip point temperature. While this behavior may not make sense in thermal zones with more than one sensor, no such examples exist in the kernel. Signed-off-by: navneet kumar --- drivers/thermal/of-thermal.c | 7 +++++++ include/linux/thermal.h | 1 + 2 files changed, 8 insertions(+) diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index 3d47a0cf3825..3568e4a586dc 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -258,6 +258,9 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip, /* thermal framework should take care of data->mask & (1 << trip) */ data->trips[trip].temperature = temp; + if (data->sops.trip_update) + data->sops.trip_update(data->sensor_data, trip); + return 0; } @@ -285,6 +288,9 @@ static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int trip, /* thermal framework should take care of data->mask & (1 << trip) */ data->trips[trip].hysteresis = hyst; + if (data->sops.trip_update) + data->sops.trip_update(data->sensor_data, trip); + return 0; } @@ -500,6 +506,7 @@ void thermal_zone_of_sensor_unregister(struct device *dev, tz->sops.get_temp = NULL; tz->sops.get_trend = NULL; + tz->sops.trip_update = NULL; tz->sensor_data = NULL; mutex_unlock(&tzd->lock); } diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 58341c56a01f..b93e65815175 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -292,6 +292,7 @@ struct thermal_genl_event { struct thermal_of_sensor_ops { int (*get_temp)(void *, long *); int (*get_trend)(void *, long *); + int (*trip_update)(void *, int); }; /* Function declarations */