Browse Source

Merge branch 'hwmon-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6

* 'hwmon-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6:
  hwmon/applesmc: Handle name file creation error and deletion
  hwmon/applesmc: Simplify dependencies
  hwmon-vid: Don't spam the logs when VRM version is missing
  hwmon/w83627hf: Be quiet when no chip is found
  hwmon/coretemp: Add more safety checks
  hwmon/ds1621: Fix swapped temperature limits
Linus Torvalds 18 years ago
parent
commit
358a9afc35

+ 1 - 1
drivers/hwmon/Kconfig

@@ -620,7 +620,7 @@ config SENSORS_HDAPS
 
 
 config SENSORS_APPLESMC
 config SENSORS_APPLESMC
 	tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)"
 	tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)"
-	depends on HWMON && INPUT && X86
+	depends on INPUT && X86
 	select NEW_LEDS
 	select NEW_LEDS
 	select LEDS_CLASS
 	select LEDS_CLASS
 	default n
 	default n

+ 6 - 1
drivers/hwmon/applesmc.c

@@ -1206,11 +1206,13 @@ static int __init applesmc_init(void)
 	}
 	}
 
 
 	ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_name.attr);
 	ret = sysfs_create_file(&pdev->dev.kobj, &dev_attr_name.attr);
+	if (ret)
+		goto out_device;
 
 
 	/* Create key enumeration sysfs files */
 	/* Create key enumeration sysfs files */
 	ret = sysfs_create_group(&pdev->dev.kobj, &key_enumeration_group);
 	ret = sysfs_create_group(&pdev->dev.kobj, &key_enumeration_group);
 	if (ret)
 	if (ret)
-		goto out_device;
+		goto out_name;
 
 
 	/* create fan files */
 	/* create fan files */
 	count = applesmc_get_fan_count();
 	count = applesmc_get_fan_count();
@@ -1310,6 +1312,8 @@ out_fan_1:
 	sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[1]);
 	sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[1]);
 out_key_enumeration:
 out_key_enumeration:
 	sysfs_remove_group(&pdev->dev.kobj, &key_enumeration_group);
 	sysfs_remove_group(&pdev->dev.kobj, &key_enumeration_group);
+out_name:
+	sysfs_remove_file(&pdev->dev.kobj, &dev_attr_name.attr);
 out_device:
 out_device:
 	platform_device_unregister(pdev);
 	platform_device_unregister(pdev);
 out_driver:
 out_driver:
@@ -1335,6 +1339,7 @@ static void __exit applesmc_exit(void)
 	sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[0]);
 	sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[0]);
 	sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[1]);
 	sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[1]);
 	sysfs_remove_group(&pdev->dev.kobj, &key_enumeration_group);
 	sysfs_remove_group(&pdev->dev.kobj, &key_enumeration_group);
+	sysfs_remove_file(&pdev->dev.kobj, &dev_attr_name.attr);
 	platform_device_unregister(pdev);
 	platform_device_unregister(pdev);
 	platform_driver_unregister(&applesmc_driver);
 	platform_driver_unregister(&applesmc_driver);
 	release_region(APPLESMC_DATA_PORT, APPLESMC_NR_PORTS);
 	release_region(APPLESMC_DATA_PORT, APPLESMC_NR_PORTS);

+ 29 - 3
drivers/hwmon/coretemp.c

@@ -176,6 +176,22 @@ static int __devinit coretemp_probe(struct platform_device *pdev)
 		goto exit_free;
 		goto exit_free;
 	}
 	}
 
 
+	/* Check if we have problem with errata AE18 of Core processors:
+	   Readings might stop update when processor visited too deep sleep,
+	   fixed for stepping D0 (6EC).
+	*/
+
+	if ((c->x86_model == 0xe) && (c->x86_mask < 0xc)) {
+		/* check for microcode update */
+		rdmsr_on_cpu(data->id, MSR_IA32_UCODE_REV, &eax, &edx);
+		if (edx < 0x39) {
+			dev_err(&pdev->dev,
+				"Errata AE18 not fixed, update BIOS or "
+				"microcode of the CPU!\n");
+			goto exit_free;
+		}
+	}
+
 	/* Some processors have Tjmax 85 following magic should detect it
 	/* Some processors have Tjmax 85 following magic should detect it
 	   Intel won't disclose the information without signed NDA, but
 	   Intel won't disclose the information without signed NDA, but
 	   individuals cannot sign it. Catch(ed) 22.
 	   individuals cannot sign it. Catch(ed) 22.
@@ -193,6 +209,19 @@ static int __devinit coretemp_probe(struct platform_device *pdev)
 		}
 		}
 	}
 	}
 
 
+	/* Intel says that above should not work for desktop Core2 processors,
+	   but it seems to work. There is no other way how get the absolute
+	   readings. Warn the user about this. First check if are desktop,
+	   bit 50 of MSR_IA32_PLATFORM_ID should be 0.
+	*/
+
+	rdmsr_safe_on_cpu(data->id, MSR_IA32_PLATFORM_ID, &eax, &edx);
+
+	if ((c->x86_model == 0xf) && (!(edx & 0x00040000))) {
+		dev_warn(&pdev->dev, "Using undocumented features, absolute "
+			 "temperature might be wrong!\n");
+	}
+
 	platform_set_drvdata(pdev, data);
 	platform_set_drvdata(pdev, data);
 
 
 	if ((err = sysfs_create_group(&pdev->dev.kobj, &coretemp_group)))
 	if ((err = sysfs_create_group(&pdev->dev.kobj, &coretemp_group)))
@@ -330,9 +359,6 @@ static int __init coretemp_init(void)
 	int i, err = -ENODEV;
 	int i, err = -ENODEV;
 	struct pdev_entry *p, *n;
 	struct pdev_entry *p, *n;
 
 
-	printk(KERN_NOTICE DRVNAME ": This driver uses undocumented features "
-		"of Core CPU. Temperature might be wrong!\n");
-
 	/* quick check if we run Intel */
 	/* 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;
 		goto exit;

+ 4 - 4
drivers/hwmon/ds1621.c

@@ -53,8 +53,8 @@ MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low")
 
 
 /* The DS1621 registers */
 /* The DS1621 registers */
 #define DS1621_REG_TEMP			0xAA /* word, RO */
 #define DS1621_REG_TEMP			0xAA /* word, RO */
-#define DS1621_REG_TEMP_MIN		0xA1 /* word, RW */
-#define DS1621_REG_TEMP_MAX		0xA2 /* word, RW */
+#define DS1621_REG_TEMP_MIN		0xA2 /* word, RW */
+#define DS1621_REG_TEMP_MAX		0xA1 /* word, RW */
 #define DS1621_REG_CONF			0xAC /* byte, RW */
 #define DS1621_REG_CONF			0xAC /* byte, RW */
 #define DS1621_COM_START		0xEE /* no data */
 #define DS1621_COM_START		0xEE /* no data */
 #define DS1621_COM_STOP			0x22 /* no data */
 #define DS1621_COM_STOP			0x22 /* no data */
@@ -328,9 +328,9 @@ static struct ds1621_data *ds1621_update_client(struct device *dev)
 
 
 		/* reset alarms if necessary */
 		/* reset alarms if necessary */
 		new_conf = data->conf;
 		new_conf = data->conf;
-		if (data->temp < data->temp_min)
+		if (data->temp > data->temp_min)
 			new_conf &= ~DS1621_ALARM_TEMP_LOW;
 			new_conf &= ~DS1621_ALARM_TEMP_LOW;
-		if (data->temp > data->temp_max)
+		if (data->temp < data->temp_max)
 			new_conf &= ~DS1621_ALARM_TEMP_HIGH;
 			new_conf &= ~DS1621_ALARM_TEMP_HIGH;
 		if (data->conf != new_conf)
 		if (data->conf != new_conf)
 			ds1621_write_value(client, DS1621_REG_CONF,
 			ds1621_write_value(client, DS1621_REG_CONF,

+ 3 - 1
drivers/hwmon/hwmon-vid.c

@@ -132,7 +132,9 @@ int vid_from_reg(int val, u8 vrm)
 		val &= 0x7f;
 		val &= 0x7f;
 		return(val > 0x77 ? 0 : (1500000 - (val * 12500) + 500) / 1000);
 		return(val > 0x77 ? 0 : (1500000 - (val * 12500) + 500) / 1000);
 	default:		/* report 0 for unknown */
 	default:		/* report 0 for unknown */
-		printk(KERN_INFO "hwmon-vid: requested unknown VRM version\n");
+		if (vrm)
+			printk(KERN_WARNING "hwmon-vid: Requested unsupported "
+			       "VRM version (%u)\n", (unsigned int)vrm);
 		return 0;
 		return 0;
 	}
 	}
 }
 }

+ 3 - 1
drivers/hwmon/w83627hf.c

@@ -965,8 +965,10 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr,
 	case W687THF_DEVID:
 	case W687THF_DEVID:
 		sio_data->type = w83687thf;
 		sio_data->type = w83687thf;
 		break;
 		break;
+	case 0xff:	/* No device at all */
+		goto exit;
 	default:
 	default:
-		pr_debug(DRVNAME ": Unsupported chip (DEVID=0x%x)\n", val);
+		pr_debug(DRVNAME ": Unsupported chip (DEVID=0x%02x)\n", val);
 		goto exit;
 		goto exit;
 	}
 	}