From 7574d7e937f81754dfd82deac24aea5880107e2d Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 27 May 2007 22:17:43 +0200 Subject: [PATCH 1/6] hwmon/ds1621: Fix swapped temperature limits The low temperature limit and the high temperature limit registers have been accidentally swapped, causing alarms to trigger when they shouldn't. Signed-off-by: Jean Delvare Acked-by: Aurelien Jarno --- drivers/hwmon/ds1621.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index c849c0c6ee9c..d5ac422d73b2 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c @@ -53,8 +53,8 @@ MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low") /* The DS1621 registers */ #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_COM_START 0xEE /* 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 */ new_conf = data->conf; - if (data->temp < data->temp_min) + if (data->temp > data->temp_min) new_conf &= ~DS1621_ALARM_TEMP_LOW; - if (data->temp > data->temp_max) + if (data->temp < data->temp_max) new_conf &= ~DS1621_ALARM_TEMP_HIGH; if (data->conf != new_conf) ds1621_write_value(client, DS1621_REG_CONF, From 67f363b1f6a31cf5027a97372f64bcced4f05ba6 Mon Sep 17 00:00:00 2001 From: Rudolf Marek Date: Sun, 27 May 2007 22:17:43 +0200 Subject: [PATCH 2/6] hwmon/coretemp: Add more safety checks Add detection of AE18 Errata of Core processor and warns users that the absolute readings might be wrong for Core2 processor. Signed-off-by: Rudolf Marek Signed-off-by: Jean Delvare --- drivers/hwmon/coretemp.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c index 75e3911810a3..0328382df8fa 100644 --- a/drivers/hwmon/coretemp.c +++ b/drivers/hwmon/coretemp.c @@ -176,6 +176,22 @@ static int __devinit coretemp_probe(struct platform_device *pdev) 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 Intel won't disclose the information without signed NDA, but 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); if ((err = sysfs_create_group(&pdev->dev.kobj, &coretemp_group))) @@ -330,9 +359,6 @@ static int __init coretemp_init(void) int i, err = -ENODEV; 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 */ if (cpu_data[0].x86_vendor != X86_VENDOR_INTEL) goto exit; From e142e2a30787e9fa1bf0f66aa1d01727ce718cc7 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 27 May 2007 22:17:43 +0200 Subject: [PATCH 3/6] hwmon/w83627hf: Be quiet when no chip is found Signed-off-by: Jean Delvare --- drivers/hwmon/w83627hf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index a5b774b07cbd..12cb40a975de 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c @@ -965,8 +965,10 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr, case W687THF_DEVID: sio_data->type = w83687thf; break; + case 0xff: /* No device at all */ + goto exit; default: - pr_debug(DRVNAME ": Unsupported chip (DEVID=0x%x)\n", val); + pr_debug(DRVNAME ": Unsupported chip (DEVID=0x%02x)\n", val); goto exit; } From 45f2acc484b31d429eb1359c48ea5cd3acb869cd Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 27 May 2007 22:17:43 +0200 Subject: [PATCH 4/6] hwmon-vid: Don't spam the logs when VRM version is missing If we cannot guess which VRM version the CPU uses, we set it to 0 and log it. So we shouldn't spam the log each time vid_from_reg() is later called with vrm 0. Signed-off-by: Jean Delvare Acked-by: Rudolf Marek --- drivers/hwmon/hwmon-vid.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/hwmon-vid.c b/drivers/hwmon/hwmon-vid.c index 5aab23b93e24..f17e771e42f8 100644 --- a/drivers/hwmon/hwmon-vid.c +++ b/drivers/hwmon/hwmon-vid.c @@ -132,7 +132,9 @@ int vid_from_reg(int val, u8 vrm) val &= 0x7f; return(val > 0x77 ? 0 : (1500000 - (val * 12500) + 500) / 1000); 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; } } From 548c343b2ff03488b913440799e83d66d7db8fad Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 27 May 2007 22:17:43 +0200 Subject: [PATCH 5/6] hwmon/applesmc: Simplify dependencies The dependency upon HWMON is now handled at menu level. Signed-off-by: Jean Delvare Cc: Nicolas Boichat --- drivers/hwmon/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 4d1cb5b855d1..13eea47dceb3 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -620,7 +620,7 @@ config SENSORS_HDAPS config SENSORS_APPLESMC tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)" - depends on HWMON && INPUT && X86 + depends on INPUT && X86 select NEW_LEDS select LEDS_CLASS default n From 6996abf0962bb86b6285987a4698f6d275ff531f Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Sun, 27 May 2007 22:17:43 +0200 Subject: [PATCH 6/6] hwmon/applesmc: Handle name file creation error and deletion The previous patch was incomplete. Signed-off-by: Nicolas Boichat Signed-off-by: Jean Delvare --- drivers/hwmon/applesmc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c index 366f4a1a2cb8..fd1281f42209 100644 --- a/drivers/hwmon/applesmc.c +++ b/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); + if (ret) + goto out_device; /* Create key enumeration sysfs files */ ret = sysfs_create_group(&pdev->dev.kobj, &key_enumeration_group); if (ret) - goto out_device; + goto out_name; /* create fan files */ count = applesmc_get_fan_count(); @@ -1310,6 +1312,8 @@ out_fan_1: sysfs_remove_group(&pdev->dev.kobj, &fan_attribute_groups[1]); out_key_enumeration: sysfs_remove_group(&pdev->dev.kobj, &key_enumeration_group); +out_name: + sysfs_remove_file(&pdev->dev.kobj, &dev_attr_name.attr); out_device: platform_device_unregister(pdev); 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[1]); sysfs_remove_group(&pdev->dev.kobj, &key_enumeration_group); + sysfs_remove_file(&pdev->dev.kobj, &dev_attr_name.attr); platform_device_unregister(pdev); platform_driver_unregister(&applesmc_driver); release_region(APPLESMC_DATA_PORT, APPLESMC_NR_PORTS);