From patchwork Thu Feb 11 13:03:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darren Jenkins X-Patchwork-Id: 78702 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 o1BD45l8015453 for ; Thu, 11 Feb 2010 13:04:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753213Ab0BKNEC (ORCPT ); Thu, 11 Feb 2010 08:04:02 -0500 Received: from mail-gx0-f224.google.com ([209.85.217.224]:43397 "EHLO mail-gx0-f224.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752286Ab0BKNEB (ORCPT ); Thu, 11 Feb 2010 08:04:01 -0500 Received: by gxk24 with SMTP id 24so1061847gxk.1 for ; Thu, 11 Feb 2010 05:04:00 -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=I4oEtnJ2VKN2Oj5mo4yX+QmqWzON1dpoQ3lkKaMb+UE=; b=AelDjliqLjKvrSS/Y6sCJS6kkkulIe8Qq+4pff7Ryp3ShHWkW0GWPprnjNYYYbfoN8 C/c/A/LSkynSVctkjxuFSjeo/FdmM8EaEW1a7v/vUdDtQuN1bk7VuEJqkgHZGA4DQ9NB feSLVsR2Pu79rUQVD74GzuOeQm0Zykwy5Lvhk= 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=kUFyLkoXfZWcilXpfVe0QdYXWUpSTl4dZqUP3y+/w8JE/dlFJ1+Z/RV38/Z+cGjtIm 1NAbt6ae3w3NV6NVmyox8ZMCoDkHePdETXrlpWdwKGbR5GFc34/Wvdfs+wjTqO/leDyK kXnVUpjMHvb1CltOG1eJAUndUN2OuoEfV9ZMQ= Received: by 10.101.14.16 with SMTP id r16mr2442539ani.23.1265893440224; Thu, 11 Feb 2010 05:04:00 -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 39sm882024yxd.9.2010.02.11.05.03.54 (version=SSLv3 cipher=RC4-MD5); Thu, 11 Feb 2010 05:03:59 -0800 (PST) Subject: Re: [PATCH] drivers/acpi/processor_thermal.c From: Darren Jenkins To: Thomas Renninger Cc: Julia Lawall , Len Brown , Zhang Rui , H Hartley Sweeten , Andrew Morton , Alexey Dobriyan , Matthew Garrett , linux ACPI , Linux Kernel Mailing List , Kernel Janitors Date: Fri, 12 Feb 2010 00:03:52 +1100 Message-ID: <1265893432.27789.14.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 13:04:14 +0000 (UTC) diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index 1290c25..278cebd 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c @@ -298,9 +298,14 @@ static int acpi_fan_add(struct acpi_device *device) static int acpi_fan_remove(struct acpi_device *device, int type) { - struct thermal_cooling_device *cdev = device->driver_data; + struct thermal_cooling_device *cdev; + + if (!device) + return -EINVAL; + + cdev = device->driver_data; - if (!device || !cdev) + if (!cdev) return -EINVAL; acpi_fan_remove_fs(device); diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c index cd18c98..3c9f8ac 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 = device->driver_data; + struct acpi_processor *pr; - if (!device || !pr) + if (!device) + return -EINVAL; + + pr = device->driver_data; + + 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 = device->driver_data; + struct acpi_processor *pr; + + if (!device) + return -EINVAL; - if (!device || !pr) + pr = device->driver_data; + + 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 = device->driver_data; + 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 = device->driver_data; - 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);