From patchwork Mon Apr 25 03:02:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 8922551 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DB992BF29F for ; Mon, 25 Apr 2016 03:03:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D160C20155 for ; Mon, 25 Apr 2016 03:03:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EB0542014A for ; Mon, 25 Apr 2016 03:03:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1auWoL-0005eO-NY; Mon, 25 Apr 2016 03:03:45 +0000 Received: from mail-pa0-f68.google.com ([209.85.220.68]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1auWoK-0005Xb-Pw for linux-rockchip@lists.infradead.org; Mon, 25 Apr 2016 03:03:45 +0000 Received: by mail-pa0-f68.google.com with SMTP id zy2so16677123pac.2 for ; Sun, 24 Apr 2016 20:03:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8iY6vdwuMIziEHPika7q+BJK3bEP66/BxjmsSIq3xnc=; b=Fef6wqNVdgw97LJAN2Y1Wz3vgj80UrJkXdFrlNRzqjaYfuYS8spG8/48ME220jJfFy Vkf9INAE0vlbiMdYSBL4Y1E5dJNPqbB//X7sGFUKmQ5FlZzaN65PaT9DUwSWCw1bi/lL FzPdaDBxTOPJv3/UmKvlHh56JnyRlkDMkRWaL5ua6EV7XJt05K+11mEwxa7Oo5clNztL nRij2EClUFhh3l9wdWtdqwxtrWPsdzjJ5L9+RJgugZ7zB3/wNLoHRYP37suWfnjTG9ob 60jtyP7SfGqIXwOQjOTz6wlc51L5aI77MHkWbtaBxRimC5AkYEdFmq3Suc/rezKk0IbL CLpA== X-Gm-Message-State: AOPr4FVxZEj4zQdE1Dc/xk7AEWcrRm8+Vbemsxrma4fOzXFctysbeYeaRNf1fxDST1Kbxw== X-Received: by 10.66.153.174 with SMTP id vh14mr46054452pab.131.1461553408136; Sun, 24 Apr 2016 20:03:28 -0700 (PDT) Received: from localhost.localdomain ([104.37.5.142]) by smtp.gmail.com with ESMTPSA id i7sm23964173pfc.47.2016.04.24.20.03.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Apr 2016 20:03:27 -0700 (PDT) From: Caesar Wang To: edubezval@gmail.com Subject: [PATCH 2/4] thermal: of: implement .set_trips for device tree thermal zones Date: Mon, 25 Apr 2016 11:02:45 +0800 Message-Id: <1461553367-24744-3-git-send-email-wxt@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461553367-24744-1-git-send-email-wxt@rock-chips.com> References: <1461553367-24744-1-git-send-email-wxt@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160424_200344_873627_0835821B X-CRM114-Status: GOOD ( 11.90 ) X-Spam-Score: -0.7 (/) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: huangtao@rock-chips.com, Heiko Stuebner , linux-pm@vger.kernel.org, Sascha Hauer , dmitry.torokhov@gmail.com, dianders@chromium.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, eddie.cai@rock-chips.com, smbarber@google.com, briannorris@google.com, Zhang Rui , Caesar Wang MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD,UNPARSEABLE_RELAY,URIBL_BLACK 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: Sascha Hauer Signed-off-by: Sascha Hauer Signed-off-by: Caesar Wang Cc: Zhang Rui Cc: Eduardo Valentin Cc: linux-pm@vger.kernel.org --- drivers/thermal/of-thermal.c | 12 ++++++++++++ include/linux/thermal.h | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index b8e509c..8722e63 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -101,6 +101,17 @@ static int of_thermal_get_temp(struct thermal_zone_device *tz, return data->ops->get_temp(data->sensor_data, temp); } +static int of_thermal_set_trips(struct thermal_zone_device *tz, + int low, int high) +{ + struct __thermal_zone *data = tz->devdata; + + if (!data->ops || !data->ops->set_trips) + return -EINVAL; + + return data->ops->set_trips(data->sensor_data, low, high); +} + /** * of_thermal_get_ntrips - function to export number of available trip * points. @@ -427,6 +438,7 @@ thermal_zone_of_add_sensor(struct device_node *zone, tzd->ops->get_temp = of_thermal_get_temp; tzd->ops->get_trend = of_thermal_get_trend; + tzd->ops->set_trips = of_thermal_set_trips; tzd->ops->set_emul_temp = of_thermal_set_emul_temp; mutex_unlock(&tzd->lock); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index e258359..cb64866 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -336,12 +336,16 @@ struct thermal_genl_event { * * Optional: * @get_trend: a pointer to a function that reads the sensor temperature trend. + * @@set_trips: a pointer to a function that sets a temperature window. When + * this window is left the driver must inform the thermal core via + * thermal_zone_device_update. * @set_emul_temp: a pointer to a function that sets sensor emulated * temperature. */ struct thermal_zone_of_device_ops { int (*get_temp)(void *, int *); int (*get_trend)(void *, long *); + int (*set_trips)(void *, int, int); int (*set_emul_temp)(void *, int); int (*set_trip_temp)(void *, int, int); };