From patchwork Tue May 3 09:33:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 9001311 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 35F68BF29F for ; Tue, 3 May 2016 09:34:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4BC68200FE for ; Tue, 3 May 2016 09:34:51 +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 6211D20253 for ; Tue, 3 May 2016 09:34:50 +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 1axWjC-0000GP-3c; Tue, 03 May 2016 09:34:50 +0000 Received: from mail-pf0-f195.google.com ([209.85.192.195]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1axWjA-0000BM-Sj for linux-rockchip@lists.infradead.org; Tue, 03 May 2016 09:34:49 +0000 Received: by mail-pf0-f195.google.com with SMTP id p185so1247362pfb.3 for ; Tue, 03 May 2016 02:34: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=V5UJlZBsd3ECMKw8SurZNbzIrUZjuTtTsQSkCed6OpM=; b=CsodTpAwyRHN14XljQ/8pDT0WtBn7EQjFXgm6O4FlZulW6bhzz8HhY5EgQ9ut2eqOt pf3weXfPAmGdjeNU5Mksdd7L2N3o2ztjUYkaM7e5bNd+JFLUP5kGWuadgHKByZK3R1ZL l4eK5ebZYWngZTOvVSIZ2GcEWXz8Gvr/LpKK8a1LroyzjswaMn62mfHTkMXmb4xvKzwt nBMPK2PvspGR0tTemqTr0u95kNkC4I4JHV3IttHKHqb3e8Pt64f96flY6aZWYY2TzteD laKQdqtmrJum7Hup9ufOayuD9r4wUuMiLTlWXY/j89n5uPpnS02e9C+tFQl1FdCa/CRD 7N0w== X-Gm-Message-State: AOPr4FUtrtqkwg9w+uWJ07+TcRWoWXS730b8L4Sis7vVV/Y4TnHeOzoFAb0GGg+2SjUNMw== X-Received: by 10.98.67.143 with SMTP id l15mr1921747pfi.114.1462268068097; Tue, 03 May 2016 02:34:28 -0700 (PDT) Received: from localhost.localdomain ([104.37.5.210]) by smtp.gmail.com with ESMTPSA id f16sm4201829pfj.71.2016.05.03.02.34.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 May 2016 02:34:26 -0700 (PDT) From: Caesar Wang To: edubezval@gmail.com Subject: [PATCH v2 2/5] thermal: of: implement .set_trips for device tree thermal zones Date: Tue, 3 May 2016 17:33:30 +0800 Message-Id: <1462268013-14992-3-git-send-email-wxt@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1462268013-14992-1-git-send-email-wxt@rock-chips.com> References: <1462268013-14992-1-git-send-email-wxt@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160503_023448_967494_C3C7D437 X-CRM114-Status: GOOD ( 13.90 ) X-Spam-Score: -2.4 (--) 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, smbarber@google.com, cf@rock-chips.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=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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: Sascha Hauer This patch implemnets .set_trips for device tree thermal zones. As the hardware-tracked trip points is supported by thermal core patch[0]. patch[0] "thermal: Add support for hardware-tracked trip points". Signed-off-by: Sascha Hauer Signed-off-by: Caesar Wang Cc: Zhang Rui Cc: Eduardo Valentin Cc: linux-pm@vger.kernel.org --- Changes in v2: - add the commit in patch[v2 2/5]. 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..09053eb 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); };