x86: cpa, micro-optimization
[safe/jmp/linux-2.6] / drivers / hwmon / coretemp.c
index 0328382..3ee60d2 100644 (file)
@@ -47,7 +47,7 @@ typedef enum { SHOW_TEMP, SHOW_TJMAX, SHOW_LABEL, SHOW_NAME } SHOW;
 static struct coretemp_data *coretemp_update_device(struct device *dev);
 
 struct coretemp_data {
-       struct class_device *class_dev;
+       struct device *hwmon_dev;
        struct mutex update_lock;
        const char *name;
        u32 id;
@@ -58,8 +58,6 @@ struct coretemp_data {
        u8 alarm;
 };
 
-static struct coretemp_data *coretemp_update_device(struct device *dev);
-
 /*
  * Sysfs stuff
  */
@@ -152,7 +150,7 @@ static struct coretemp_data *coretemp_update_device(struct device *dev)
 static int __devinit coretemp_probe(struct platform_device *pdev)
 {
        struct coretemp_data *data;
-       struct cpuinfo_x86 *c = &(cpu_data)[pdev->id];
+       struct cpuinfo_x86 *c = &cpu_data(pdev->id);
        int err;
        u32 eax, edx;
 
@@ -185,6 +183,7 @@ static int __devinit coretemp_probe(struct platform_device *pdev)
                /* check for microcode update */
                rdmsr_on_cpu(data->id, MSR_IA32_UCODE_REV, &eax, &edx);
                if (edx < 0x39) {
+                       err = -ENODEV;
                        dev_err(&pdev->dev,
                                "Errata AE18 not fixed, update BIOS or "
                                "microcode of the CPU!\n");
@@ -227,9 +226,9 @@ static int __devinit coretemp_probe(struct platform_device *pdev)
        if ((err = sysfs_create_group(&pdev->dev.kobj, &coretemp_group)))
                goto exit_free;
 
-       data->class_dev = hwmon_device_register(&pdev->dev);
-       if (IS_ERR(data->class_dev)) {
-               err = PTR_ERR(data->class_dev);
+       data->hwmon_dev = hwmon_device_register(&pdev->dev);
+       if (IS_ERR(data->hwmon_dev)) {
+               err = PTR_ERR(data->hwmon_dev);
                dev_err(&pdev->dev, "Class registration failed (%d)\n",
                        err);
                goto exit_class;
@@ -249,7 +248,7 @@ static int __devexit coretemp_remove(struct platform_device *pdev)
 {
        struct coretemp_data *data = platform_get_drvdata(pdev);
 
-       hwmon_device_unregister(data->class_dev);
+       hwmon_device_unregister(data->hwmon_dev);
        sysfs_remove_group(&pdev->dev.kobj, &coretemp_group);
        platform_set_drvdata(pdev, NULL);
        kfree(data);
@@ -317,7 +316,7 @@ exit:
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
-void coretemp_device_remove(unsigned int cpu)
+static void coretemp_device_remove(unsigned int cpu)
 {
        struct pdev_entry *p, *n;
        mutex_lock(&pdev_list_mutex);
@@ -338,18 +337,17 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
 
        switch (action) {
        case CPU_ONLINE:
-       case CPU_ONLINE_FROZEN:
+       case CPU_DOWN_FAILED:
                coretemp_device_add(cpu);
                break;
-       case CPU_DEAD:
-       case CPU_DEAD_FROZEN:
+       case CPU_DOWN_PREPARE:
                coretemp_device_remove(cpu);
                break;
        }
        return NOTIFY_OK;
 }
 
-static struct notifier_block __cpuinitdata coretemp_cpu_notifier = {
+static struct notifier_block coretemp_cpu_notifier = {
        .notifier_call = coretemp_cpu_callback,
 };
 #endif                         /* !CONFIG_HOTPLUG_CPU */
@@ -360,7 +358,7 @@ static int __init coretemp_init(void)
        struct pdev_entry *p, *n;
 
        /* quick check if we run Intel */
-       if (cpu_data[0].x86_vendor != X86_VENDOR_INTEL)
+       if (cpu_data(0).x86_vendor != X86_VENDOR_INTEL)
                goto exit;
 
        err = platform_driver_register(&coretemp_driver);
@@ -368,11 +366,12 @@ static int __init coretemp_init(void)
                goto exit;
 
        for_each_online_cpu(i) {
-               struct cpuinfo_x86 *c = &(cpu_data)[i];
+               struct cpuinfo_x86 *c = &cpu_data(i);
 
-               /* check if family 6, models e, f */
+               /* check if family 6, models e, f, 16 */
                if ((c->cpuid_level < 0) || (c->x86 != 0x6) ||
-                   !((c->x86_model == 0xe) || (c->x86_model == 0xf))) {
+                   !((c->x86_model == 0xe) || (c->x86_model == 0xf) ||
+                       (c->x86_model == 0x16))) {
 
                        /* supported CPU not found, but report the unknown
                           family 6 CPU */