From patchwork Tue Mar 3 10:43:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 5921181 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 21FFDBF440 for ; Tue, 3 Mar 2015 10:43:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3D21E202B4 for ; Tue, 3 Mar 2015 10:43:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 502152026C for ; Tue, 3 Mar 2015 10:43:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756071AbbCCKnA (ORCPT ); Tue, 3 Mar 2015 05:43:00 -0500 Received: from fw-tnat.cambridge.arm.com ([217.140.96.140]:34417 "EHLO cam-smtp0.cambridge.arm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754819AbbCCKnA (ORCPT ); Tue, 3 Mar 2015 05:43:00 -0500 Received: from e105922-lin.cambridge.arm.com (e105922-lin.cambridge.arm.com [10.2.131.206]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with SMTP id t23AgtMd007877; Tue, 3 Mar 2015 10:42:55 GMT Received: by e105922-lin.cambridge.arm.com (sSMTP sendmail emulation); Tue, 03 Mar 2015 10:43:36 +0000 From: Punit Agrawal To: edubezval@gmail.com Cc: linux-pm@vger.kernel.org, rui.zhang@intel.com, Punit Agrawal Subject: [PATCH 1/2] thermal: core: Add Kconfig option to enable writable trips Date: Tue, 3 Mar 2015 10:43:03 +0000 Message-Id: <1425379384-17000-2-git-send-email-punit.agrawal@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1425379384-17000-1-git-send-email-punit.agrawal@arm.com> References: <1425379384-17000-1-git-send-email-punit.agrawal@arm.com> 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=ham 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 Add a Kconfig option to allow system integrators to control whether userspace tools can change trip temperatures. This option overrides the thermal zone setup in the driver code and must be enabled for platform specified writable trips to come into effect. The original behaviour of requiring root privileges to change trip temperatures remains unchanged. Cc: Eduardo Valentin Cc: Zhang Rui Signed-off-by: Punit Agrawal --- drivers/thermal/Kconfig | 11 +++++++++++ drivers/thermal/thermal_core.c | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index af40db0..5d2d39b 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -42,6 +42,17 @@ config THERMAL_OF Say 'Y' here if you need to build thermal infrastructure based on device tree. +config THERMAL_WRITABLE_TRIPS + bool "Enable writable trip points" + help + This option allows the system integrator to choose whether + trip temperatures can be changed from userspace. The + writable trips need to be specified when setting up the + thermal zone but the choice here takes precedence. + + Say 'Y' here if you would like to allow userspace tools to + change trip temperatures. + choice prompt "Default Thermal governor" default THERMAL_DEFAULT_GOV_STEP_WISE diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 48491d1..15111c1 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1378,7 +1378,8 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) tz->trip_temp_attrs[indx].name; tz->trip_temp_attrs[indx].attr.attr.mode = S_IRUGO; tz->trip_temp_attrs[indx].attr.show = trip_point_temp_show; - if (mask & (1 << indx)) { + if (IS_ENABLED(CONFIG_THERMAL_WRITABLE_TRIPS) && + mask & (1 << indx)) { tz->trip_temp_attrs[indx].attr.attr.mode |= S_IWUSR; tz->trip_temp_attrs[indx].attr.store = trip_point_temp_store;