All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Jones <davej@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Alexander Beregalov <a.beregalov@gmail.com>,
	linux-kernel@vger.kernel.org, mathieu.desnoyers@polymtl.ca
Subject: Re: [PATCH] cpufreq: fix UP build
Date: Wed, 8 Jul 2009 16:17:38 -0400	[thread overview]
Message-ID: <20090708201738.GA22900@redhat.com> (raw)
In-Reply-To: <alpine.LFD.2.01.0907081103560.3352@localhost.localdomain>

On Wed, Jul 08, 2009 at 11:08:12AM -0700, Linus Torvalds wrote:
 > 
 > 
 > On Wed, 8 Jul 2009, Alexander Beregalov wrote:
 > >
 > > From: Alexander Beregalov <a.beregalov@gmail.com> 
 > > 
 > > Fix this build error when CONFIG_SMP is not set:
 > > drivers/cpufreq/cpufreq.c:941: 'managed_policy' undeclared
 > 
 > Grr. DaveJ?
 > 
 > That said, I'd much prefer the fix that does _not_ have this crap in it 
 > (not new to your diff - it's pre-existing crap):
 > 
 > 	>  #ifdef CONFIG_SMP
 > 	>       struct cpufreq_policy *managed_policy;
 > 	> +     struct sys_device *cpu_sys_dev;
 > 	>  #endif
 > 
 > and instead those variables should be declared inside the blocks where 
 > they are used, not at the top.
 > 
 > The rule should always be: make the scope of a variable as small as 
 > possible. Don't declare it at the top and try to "save" a declaration when 
 > it can be used inside multiple blocks as multiple different variables.
 > 
 > Also, that whole function could damn well be split into smaller pieces, 
 > which would make it much more readable than that horrible 250+ line piece 
 > of crap monster-function with #ifdef's inside the code.
 > 
 > Please, somebody?

This seems to be a minimal step in the direction of declaring it locally..
Not boot-tested, but should do the right thing.

I'll take a stab at chopping that function up further separately.

	Dave


commit 2381f2a2d3b329313b375bc0bf5df34802b9b4ba
Author: Dave Jones <davej@redhat.com>
Date:   Wed Jul 8 16:14:23 2009 -0400

    [CPUFREQ] Fix compile failure in cpufreq.c
    
    managed_policy is out of scope for the non-smp case.
    Declare it locally where used (twice)
    
    Signed-off-by: Dave Jones <davej@redhat.com>

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index c668ac8..b90eda8 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -776,9 +776,6 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
 	struct sys_device *cpu_sys_dev;
 	unsigned long flags;
 	unsigned int j;
-#ifdef CONFIG_SMP
-	struct cpufreq_policy *managed_policy;
-#endif
 
 	if (cpu_is_offline(cpu))
 		return 0;
@@ -854,6 +851,8 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
 #endif
 
 	for_each_cpu(j, policy->cpus) {
+		struct cpufreq_policy *managed_policy;
+
 		if (cpu == j)
 			continue;
 
@@ -932,6 +931,8 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
 
 	/* symlink affected CPUs */
 	for_each_cpu(j, policy->cpus) {
+		struct cpufreq_policy *managed_policy;
+
 		if (j == cpu)
 			continue;
 		if (!cpu_online(j))


  parent reply	other threads:[~2009-07-08 20:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-08 17:57 [PATCH] cpufreq: fix UP build Alexander Beregalov
2009-07-08 18:08 ` Linus Torvalds
2009-07-08 18:17   ` Dave Jones
2009-07-08 20:17   ` Dave Jones [this message]
2009-07-08 18:15 ` Dave Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090708201738.GA22900@redhat.com \
    --to=davej@redhat.com \
    --cc=a.beregalov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@polymtl.ca \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.