Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/davej/cpufreq
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 21 Jul 2008 22:10:37 +0000 (15:10 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 21 Jul 2008 22:10:37 +0000 (15:10 -0700)
* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/davej/cpufreq:
  [CPUFREQ] cpufreq: remove CVS keywords
  [CPUFREQ] change cpu freq arrays to per_cpu variables

1  2 
drivers/cpufreq/cpufreq.c
drivers/cpufreq/freq_table.c

index 1d41496ed2f83b648e1311ee8fecccbd56ad741d,6b73d163fa83d0e252fb732f5b27437e7af5163c..ee1df0d45e8189ca4eb92d4b1c2a352235b369db
   * also protects the cpufreq_cpu_data array.
   */
  static struct cpufreq_driver *cpufreq_driver;
- static struct cpufreq_policy *cpufreq_cpu_data[NR_CPUS];
+ static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data);
  #ifdef CONFIG_HOTPLUG_CPU
  /* This one keeps track of the previously set governor of a removed CPU */
- static struct cpufreq_governor *cpufreq_cpu_governor[NR_CPUS];
+ static DEFINE_PER_CPU(struct cpufreq_governor *, cpufreq_cpu_governor);
  #endif
  static DEFINE_SPINLOCK(cpufreq_driver_lock);
  
@@@ -135,7 -135,7 +135,7 @@@ struct cpufreq_policy *cpufreq_cpu_get(
        struct cpufreq_policy *data;
        unsigned long flags;
  
-       if (cpu >= NR_CPUS)
+       if (cpu >= nr_cpu_ids)
                goto err_out;
  
        /* get the cpufreq driver */
  
  
        /* get the CPU */
-       data = cpufreq_cpu_data[cpu];
+       data = per_cpu(cpufreq_cpu_data, cpu);
  
        if (!data)
                goto err_out_put_module;
@@@ -327,7 -327,7 +327,7 @@@ void cpufreq_notify_transition(struct c
        dprintk("notification %u of frequency transition to %u kHz\n",
                state, freqs->new);
  
-       policy = cpufreq_cpu_data[freqs->cpu];
+       policy = per_cpu(cpufreq_cpu_data, freqs->cpu);
        switch (state) {
  
        case CPUFREQ_PRECHANGE:
@@@ -412,7 -412,7 +412,7 @@@ static int cpufreq_parse_governor(char 
                                int ret;
  
                                mutex_unlock(&cpufreq_governor_mutex);
 -                              ret = request_module(name);
 +                              ret = request_module("%s", name);
                                mutex_lock(&cpufreq_governor_mutex);
  
                                if (ret == 0)
@@@ -625,7 -625,7 +625,7 @@@ static ssize_t store_scaling_setspeed(s
        unsigned int freq = 0;
        unsigned int ret;
  
 -      if (!policy->governor->store_setspeed)
 +      if (!policy->governor || !policy->governor->store_setspeed)
                return -EINVAL;
  
        ret = sscanf(buf, "%u", &freq);
  
  static ssize_t show_scaling_setspeed(struct cpufreq_policy *policy, char *buf)
  {
 -      if (!policy->governor->show_setspeed)
 +      if (!policy->governor || !policy->governor->show_setspeed)
                return sprintf(buf, "<unsupported>\n");
  
        return policy->governor->show_setspeed(policy, buf);
@@@ -828,8 -828,8 +828,8 @@@ static int cpufreq_add_dev(struct sys_d
  #ifdef CONFIG_SMP
  
  #ifdef CONFIG_HOTPLUG_CPU
-       if (cpufreq_cpu_governor[cpu]){
-               policy->governor = cpufreq_cpu_governor[cpu];
+       if (per_cpu(cpufreq_cpu_governor, cpu)) {
+               policy->governor = per_cpu(cpufreq_cpu_governor, cpu);
                dprintk("Restoring governor %s for cpu %d\n",
                       policy->governor->name, cpu);
        }
  
                        spin_lock_irqsave(&cpufreq_driver_lock, flags);
                        managed_policy->cpus = policy->cpus;
-                       cpufreq_cpu_data[cpu] = managed_policy;
+                       per_cpu(cpufreq_cpu_data, cpu) = managed_policy;
                        spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
  
                        dprintk("CPU already managed, adding link\n");
  
        spin_lock_irqsave(&cpufreq_driver_lock, flags);
        for_each_cpu_mask(j, policy->cpus) {
-               cpufreq_cpu_data[j] = policy;
+               per_cpu(cpufreq_cpu_data, j) = policy;
                per_cpu(policy_cpu, j) = policy->cpu;
        }
        spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
        policy->user_policy.policy = policy->policy;
        policy->user_policy.governor = policy->governor;
  
 -      unlock_policy_rwsem_write(cpu);
 -
        if (ret) {
                dprintk("setting policy failed\n");
                goto err_out_unregister;
        }
  
 +      unlock_policy_rwsem_write(cpu);
 +
        kobject_uevent(&policy->kobj, KOBJ_ADD);
        module_put(cpufreq_driver->owner);
        dprintk("initialization complete\n");
  err_out_unregister:
        spin_lock_irqsave(&cpufreq_driver_lock, flags);
        for_each_cpu_mask(j, policy->cpus)
-               cpufreq_cpu_data[j] = NULL;
+               per_cpu(cpufreq_cpu_data, j) = NULL;
        spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
  
        kobject_put(&policy->kobj);
@@@ -989,7 -989,7 +989,7 @@@ static int __cpufreq_remove_dev(struct 
        dprintk("unregistering CPU %u\n", cpu);
  
        spin_lock_irqsave(&cpufreq_driver_lock, flags);
-       data = cpufreq_cpu_data[cpu];
+       data = per_cpu(cpufreq_cpu_data, cpu);
  
        if (!data) {
                spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
                unlock_policy_rwsem_write(cpu);
                return -EINVAL;
        }
-       cpufreq_cpu_data[cpu] = NULL;
+       per_cpu(cpufreq_cpu_data, cpu) = NULL;
  
  
  #ifdef CONFIG_SMP
  #ifdef CONFIG_SMP
  
  #ifdef CONFIG_HOTPLUG_CPU
-       cpufreq_cpu_governor[cpu] = data->governor;
+       per_cpu(cpufreq_cpu_governor, cpu) = data->governor;
  #endif
  
        /* if we have other CPUs still registered, we need to unlink them,
         * or else wait_for_completion below will lock up. Clean the
-        * cpufreq_cpu_data[] while holding the lock, and remove the sysfs
-        * links afterwards.
+        * per_cpu(cpufreq_cpu_data) while holding the lock, and remove
+        * the sysfs links afterwards.
         */
        if (unlikely(cpus_weight(data->cpus) > 1)) {
                for_each_cpu_mask(j, data->cpus) {
                        if (j == cpu)
                                continue;
-                       cpufreq_cpu_data[j] = NULL;
+                       per_cpu(cpufreq_cpu_data, j) = NULL;
                }
        }
  
                                continue;
                        dprintk("removing link for cpu %u\n", j);
  #ifdef CONFIG_HOTPLUG_CPU
-                       cpufreq_cpu_governor[j] = data->governor;
+                       per_cpu(cpufreq_cpu_governor, j) = data->governor;
  #endif
                        cpu_sys_dev = get_cpu_sysdev(j);
                        sysfs_remove_link(&cpu_sys_dev->kobj, "cpufreq");
@@@ -1153,7 -1153,7 +1153,7 @@@ EXPORT_SYMBOL(cpufreq_quick_get)
  
  static unsigned int __cpufreq_get(unsigned int cpu)
  {
-       struct cpufreq_policy *policy = cpufreq_cpu_data[cpu];
+       struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu);
        unsigned int ret_freq = 0;
  
        if (!cpufreq_driver->get)
@@@ -1822,16 -1822,19 +1822,19 @@@ int cpufreq_register_driver(struct cpuf
        cpufreq_driver = driver_data;
        spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
  
-       ret = sysdev_driver_register(&cpu_sysdev_class,&cpufreq_sysdev_driver);
+       ret = sysdev_driver_register(&cpu_sysdev_class,
+                                       &cpufreq_sysdev_driver);
  
        if ((!ret) && !(cpufreq_driver->flags & CPUFREQ_STICKY)) {
                int i;
                ret = -ENODEV;
  
                /* check for at least one working CPU */
-               for (i=0; i<NR_CPUS; i++)
-                       if (cpufreq_cpu_data[i])
+               for (i = 0; i < nr_cpu_ids; i++)
+                       if (cpu_possible(i) && per_cpu(cpufreq_cpu_data, i)) {
                                ret = 0;
+                               break;
+                       }
  
                /* if all ->init() calls failed, unregister */
                if (ret) {
index b64c6bc445e31580074fe7cc437fdfdf3e880cb9,fe485c9515d1cb7a9bf00abbca5f28ba76d78343..9071d80fbba2427d6b29c911832e169bf201466a
@@@ -2,11 -2,6 +2,11 @@@
   * linux/drivers/cpufreq/freq_table.c
   *
   * Copyright (C) 2002 - 2003 Dominik Brodowski
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + *
   */
  
  #include <linux/kernel.h>
@@@ -174,7 -169,7 +174,7 @@@ int cpufreq_frequency_table_target(stru
  }
  EXPORT_SYMBOL_GPL(cpufreq_frequency_table_target);
  
- static struct cpufreq_frequency_table *show_table[NR_CPUS];
+ static DEFINE_PER_CPU(struct cpufreq_frequency_table *, show_table);
  /**
   * show_available_freqs - show available frequencies for the specified CPU
   */
@@@ -185,10 -180,10 +185,10 @@@ static ssize_t show_available_freqs (st
        ssize_t count = 0;
        struct cpufreq_frequency_table *table;
  
-       if (!show_table[cpu])
+       if (!per_cpu(show_table, cpu))
                return -ENODEV;
  
-       table = show_table[cpu];
+       table = per_cpu(show_table, cpu);
  
        for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
                if (table[i].frequency == CPUFREQ_ENTRY_INVALID)
@@@ -217,20 -212,20 +217,20 @@@ void cpufreq_frequency_table_get_attr(s
                                      unsigned int cpu)
  {
        dprintk("setting show_table for cpu %u to %p\n", cpu, table);
-       show_table[cpu] = table;
+       per_cpu(show_table, cpu) = table;
  }
  EXPORT_SYMBOL_GPL(cpufreq_frequency_table_get_attr);
  
  void cpufreq_frequency_table_put_attr(unsigned int cpu)
  {
        dprintk("clearing show_table for cpu %u\n", cpu);
-       show_table[cpu] = NULL;
+       per_cpu(show_table, cpu) = NULL;
  }
  EXPORT_SYMBOL_GPL(cpufreq_frequency_table_put_attr);
  
  struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu)
  {
-       return show_table[cpu];
+       return per_cpu(show_table, cpu);
  }
  EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table);