From patchwork Wed Jan 16 20:42:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dirk.brandewie@gmail.com X-Patchwork-Id: 1993371 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 1A6873FC85 for ; Wed, 16 Jan 2013 20:43:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756322Ab3APUnA (ORCPT ); Wed, 16 Jan 2013 15:43:00 -0500 Received: from mail-pb0-f50.google.com ([209.85.160.50]:47374 "EHLO mail-pb0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754115Ab3APUm7 (ORCPT ); Wed, 16 Jan 2013 15:42:59 -0500 Received: by mail-pb0-f50.google.com with SMTP id wz7so932387pbc.37 for ; Wed, 16 Jan 2013 12:42:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=d1rIbEBQ0Iosb2d1hnVMcxNrzZvIJaJcNMn0jfGy2vQ=; b=yKrIkhYPG1DvkyzeiKpIKFvg9PkAq0pFmRCxT3YQ3zECjnCLxVXpbun6yXsqXe7fcz /bf7gXs3xLpZYqdBN8GKTEClkSE4VKUpxSJH3DrJR1RpBS76jxFfuMN2RIgIE1Cj6QF0 6hwVInwLnYEbfmUE+rBOI9e1CoNTlnTsJOXjE3dQgyM+L2UJ9PuV3crXMfVqe5EuUyXL ifF0VXzFD7B6VM/3CjRKalGJl9xhe3PX3/FllCK3ft6qUpIxw2o5YXgVuwg0Dmdus0kn DPI2DFIELEadXVcL6sj4QqIH1hlfek8LVjbZqMiV7nkwV5IIolsjxAmtgRNW6JN+VPEV DD3Q== X-Received: by 10.66.79.202 with SMTP id l10mr6894520pax.36.1358368979066; Wed, 16 Jan 2013 12:42:59 -0800 (PST) Received: from echolake.localdomain (static-50-43-39-32.bvtn.or.frontiernet.net. [50.43.39.32]) by mx.google.com with ESMTPS id oj5sm12862232pbb.47.2013.01.16.12.42.56 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 16 Jan 2013 12:42:57 -0800 (PST) From: dirk.brandewie@gmail.com To: linux-pm@vger.kernel.org, cpufreq@vger.kernel.org Cc: rjw@sisk.pl, Dirk Brandewie Subject: [PATCH] cpufreq: handle cpufreq being disabled for all exported function. Date: Wed, 16 Jan 2013 12:42:47 -0800 Message-Id: <1358368967-16294-1-git-send-email-dirk.brandewie@gmail.com> X-Mailer: git-send-email 1.7.7.6 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Dirk Brandewie When disable_cpufreq() is called some exported functions are still being used that do not have a check for cpufreq being disabled. Add a disabled check into cpufreq_cpu_get() to return NULL if cpufreq is disabled this covers most of the exported functions. For the exported functions that do not call cpufreq_cpu_get() add an explicit check. Signed-off-by: Dirk Brandewie --- drivers/cpufreq/cpufreq.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 1f93dbd..b7663f7 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -180,6 +180,9 @@ err_out: struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu) { + if (cpufreq_disabled()) + return NULL; + return __cpufreq_cpu_get(cpu, false); } EXPORT_SYMBOL_GPL(cpufreq_cpu_get); @@ -198,6 +201,9 @@ static void __cpufreq_cpu_put(struct cpufreq_policy *data, bool sysfs) void cpufreq_cpu_put(struct cpufreq_policy *data) { + if (cpufreq_disabled()) + return; + __cpufreq_cpu_put(data, false); } EXPORT_SYMBOL_GPL(cpufreq_cpu_put); @@ -264,6 +270,9 @@ void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state) BUG_ON(irqs_disabled()); + if (cpufreq_disabled()) + return; + freqs->flags = cpufreq_driver->flags; pr_debug("notification %u of frequency transition to %u kHz\n", state, freqs->new); @@ -1408,6 +1417,9 @@ int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list) { int ret; + if (cpufreq_disabled()) + return -EINVAL; + WARN_ON(!init_cpufreq_transition_notifier_list_called); switch (list) { @@ -1442,6 +1454,9 @@ int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list) { int ret; + if (cpufreq_disabled()) + return -EINVAL; + switch (list) { case CPUFREQ_TRANSITION_NOTIFIER: ret = srcu_notifier_chain_unregister( @@ -1522,6 +1537,9 @@ int __cpufreq_driver_getavg(struct cpufreq_policy *policy, unsigned int cpu) { int ret = 0; + if (cpufreq_disabled()) + return ret; + if (!(cpu_online(cpu) && cpufreq_driver->getavg)) return 0;