From patchwork Wed Aug 26 16:17:23 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frans Pop X-Patchwork-Id: 44070 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7QGK8xq025977 for ; Wed, 26 Aug 2009 16:20:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751858AbZHZQSI (ORCPT ); Wed, 26 Aug 2009 12:18:08 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751796AbZHZQR1 (ORCPT ); Wed, 26 Aug 2009 12:17:27 -0400 Received: from Cpsmtpm-eml108.kpnxchange.com ([195.121.3.12]:51592 "EHLO CPSMTPM-EML108.kpnxchange.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751539AbZHZQRZ (ORCPT ); Wed, 26 Aug 2009 12:17:25 -0400 Received: from elrond.fjphome.nl ([77.166.180.99]) by CPSMTPM-EML108.kpnxchange.com with Microsoft SMTPSVC(7.0.6001.18000); Wed, 26 Aug 2009 18:17:25 +0200 Received: from aragorn.fjphome.nl ([10.19.66.13]) by elrond.fjphome.nl with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1MgLBd-0001D6-HC; Wed, 26 Aug 2009 18:17:25 +0200 Received: from fjp by aragorn.fjphome.nl with local (Exim 4.69) (envelope-from ) id 1MgLBd-0007N4-8d; Wed, 26 Aug 2009 18:17:25 +0200 From: Frans Pop To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Frans Pop , Matthew Garrett , Zhang Rui Subject: [PATCH 4/6] thermal: add sanity check for the passive attribute Date: Wed, 26 Aug 2009 18:17:23 +0200 Message-Id: <1251303445-25317-5-git-send-email-elendil@planet.nl> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1251303445-25317-1-git-send-email-elendil@planet.nl> References: <1251303445-25317-1-git-send-email-elendil@planet.nl> X-OriginalArrivalTime: 26 Aug 2009 16:17:25.0990 (UTC) FILETIME=[B349E860:01CA2668] Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Values below 40000 milli-celsius (limit is somewhat arbitrary) don't make sense and can cause the system to go into a thermal heart attack: the actual temperature will always be lower and thus the system will be throttled down to its lowest setting. For values below 1000 an additional problem is that they would show as 0 in /proc/acpi/thermal/TZx/trip_points:passive. cat passive 0 echo -n 90000 >passive cat passive 90000 echo -n 30000 >passive bash: echo: write error: Invalid argument Signed-off-by: Frans Pop Cc: Matthew Garrett Cc: Zhang Rui --- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/thermal/sysfs-api.txt b/Documentation/thermal/sysfs-api.txt index 2a036eb..09d5c88 100644 --- a/Documentation/thermal/sysfs-api.txt +++ b/Documentation/thermal/sysfs-api.txt @@ -206,6 +206,7 @@ passive point for the zone. Activation is done by polling with an interval of 1 second. Unit: millidegrees Celsius + Minimum value: 40000 RW, Optional ***************************** diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index 0a69672..2d13d0d 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c @@ -225,6 +225,12 @@ passive_store(struct device *dev, struct device_attribute *attr, if (!sscanf(buf, "%d\n", &state)) return -EINVAL; + /* sanity check: values below 40000 millicelcius don't make sense + * and can cause the system to go into a thermal heart attack + */ + if (state && state < 40000) + return -EINVAL; + if (state && !tz->forced_passive) { mutex_lock(&thermal_list_lock); list_for_each_entry(cdev, &thermal_cdev_list, node) {