From patchwork Thu Feb 11 09:56:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darren Jenkins X-Patchwork-Id: 78668 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1B9vMMv015294 for ; Thu, 11 Feb 2010 09:57:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753365Ab0BKJ5B (ORCPT ); Thu, 11 Feb 2010 04:57:01 -0500 Received: from mail-yx0-f193.google.com ([209.85.210.193]:63529 "EHLO mail-yx0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752972Ab0BKJ46 (ORCPT ); Thu, 11 Feb 2010 04:56:58 -0500 Received: by mail-yx0-f193.google.com with SMTP id 31so946342yxe.21 for ; Thu, 11 Feb 2010 01:56:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; bh=KZ1nGUrw8iB2/oSZr3CrYKco9lH9vGO4bhsMHyMcUqc=; b=vs3QDSAn8Vf2RN2MR5K/iH/nkiBz5eDNkA6mEqNgve6T6oRi4p/Rnz5gleBnkvbSAO cOz+2mQuPg3R2Eix/XSp/C+ipVZiQTo1TQwxV1ky80ElLH4GvcBlT7VUzRxzmMbOIaPU LjAcZ2Y+6mNNMQPRD/R7rTgN/RTC8VRWGPqnI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; b=txGRgo63oigDM+hKj+MAvrvpfjI7I3ioxvOGMWdp4/VhXXYyIPVFU2HczRNDs0W0FB /NvYitcIXgrurmSGb+q3CkEHz+sXVC03kw0OpvvEJUx2TujHkT5tHmLcjXK5fH+tsoeP x/wtNDcMpKMlkHYbmBNTrm6+eCkd/5NqJ8TQE= Received: by 10.101.27.3 with SMTP id e3mr2091409anj.115.1265882218090; Thu, 11 Feb 2010 01:56:58 -0800 (PST) Received: from ?192.168.2.3? (C-59-101-225-152.bur.connect.net.au [59.101.225.152]) by mx.google.com with ESMTPS id 7sm834666yxd.62.2010.02.11.01.56.53 (version=SSLv3 cipher=RC4-MD5); Thu, 11 Feb 2010 01:56:57 -0800 (PST) Subject: [PATCH] drivers/acpi/processor_thermal.c From: Darren Jenkins To: Len Brown Cc: Zhang Rui , H Hartley Sweeten , Andrew Morton , Thomas Renninger , linux ACPI , Linux Kernel Mailing List , Kernel Janitors Date: Thu, 11 Feb 2010 20:56:51 +1100 Message-ID: <1265882211.27789.1.camel@ICE-BOX> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 11 Feb 2010 09:57:22 +0000 (UTC) diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c index 6deafb4..ec33554 100644 --- a/drivers/acpi/processor_thermal.c +++ b/drivers/acpi/processor_thermal.c @@ -379,9 +379,14 @@ processor_get_max_state(struct thermal_cooling_device *cdev, unsigned long *state) { struct acpi_device *device = cdev->devdata; - struct acpi_processor *pr = acpi_driver_data(device); + struct acpi_processor *pr; - if (!device || !pr) + if (!device) + return -EINVAL; + + pr = acpi_driver_data(device); + + if (!pr) return -EINVAL; *state = acpi_processor_max_state(pr); @@ -393,9 +398,14 @@ processor_get_cur_state(struct thermal_cooling_device *cdev, unsigned long *cur_state) { struct acpi_device *device = cdev->devdata; - struct acpi_processor *pr = acpi_driver_data(device); + struct acpi_processor *pr; + + if (!device) + return -EINVAL; - if (!device || !pr) + pr = acpi_driver_data(device); + + if (!pr) return -EINVAL; *cur_state = cpufreq_get_cur_state(pr->id); @@ -409,18 +419,20 @@ processor_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state) { struct acpi_device *device = cdev->devdata; - struct acpi_processor *pr = acpi_driver_data(device); + struct acpi_processor *pr; int result = 0; int max_pstate; - if (!device || !pr) + if (!device) return -EINVAL; - max_pstate = cpufreq_get_max_state(pr->id); + pr = acpi_driver_data(device); - if (state > acpi_processor_max_state(pr)) + if (!pr || state > acpi_processor_max_state(pr)) return -EINVAL; + max_pstate = cpufreq_get_max_state(pr->id); + if (state <= max_pstate) { if (pr->flags.throttling && pr->throttling.state) result = acpi_processor_set_throttling(pr, 0, false);