aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/ac.c1
-rw-r--r--drivers/acpi/battery.c1
-rw-r--r--drivers/acpi/button.c3
-rw-r--r--drivers/acpi/fan.c2
-rw-r--r--drivers/acpi/processor_core.c2
-rw-r--r--drivers/acpi/sbs.c1
-rw-r--r--drivers/acpi/thermal.c2
-rw-r--r--drivers/acpi/video.c5
-rw-r--r--drivers/base/cpu.c2
-rw-r--r--drivers/base/power/main.c20
-rw-r--r--drivers/base/sys.c8
-rw-r--r--drivers/block/ps3vram.c2
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c12
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c6
-rw-r--r--drivers/firmware/dmi_scan.c18
-rw-r--r--drivers/hwmon/Kconfig27
-rw-r--r--drivers/hwmon/Makefile1
-rw-r--r--drivers/hwmon/ds1621.c172
-rw-r--r--drivers/hwmon/fschmd.c229
-rw-r--r--drivers/hwmon/hdaps.c66
-rw-r--r--drivers/hwmon/pcf8591.c (renamed from drivers/i2c/chips/pcf8591.c)24
-rw-r--r--drivers/hwmon/w83627ehf.c170
-rw-r--r--drivers/i2c/busses/i2c-i801.c77
-rw-r--r--drivers/i2c/chips/Kconfig13
-rw-r--r--drivers/i2c/chips/Makefile1
-rw-r--r--drivers/input/input.c2
-rw-r--r--drivers/isdn/hardware/eicon/divasi.c1
-rw-r--r--drivers/lguest/core.c4
-rw-r--r--drivers/lguest/interrupts_and_traps.c28
-rw-r--r--drivers/lguest/lg.h8
-rw-r--r--drivers/lguest/lguest_device.c4
-rw-r--r--drivers/lguest/page_tables.c22
-rw-r--r--drivers/lguest/segments.c2
-rw-r--r--drivers/lguest/x86/core.c62
-rw-r--r--drivers/media/video/cpia.c4
-rw-r--r--drivers/message/i2o/i2o_proc.c2
-rw-r--r--drivers/net/bonding/bond_main.c35
-rw-r--r--drivers/net/gianfar.c2
-rw-r--r--drivers/net/hamradio/dmascc.c2
-rw-r--r--drivers/net/irda/vlsi_ir.c7
-rw-r--r--drivers/net/netconsole.c10
-rw-r--r--drivers/net/ni5010.c18
-rw-r--r--drivers/net/niu.c12
-rw-r--r--drivers/net/tg3.c4
-rw-r--r--drivers/net/ucc_geth.c11
-rw-r--r--drivers/net/wireless/airo.c3
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2200.c1
-rw-r--r--drivers/net/wireless/prism54/islpci_dev.c1
-rw-r--r--drivers/net/wireless/zd1201.c1
-rw-r--r--drivers/pci/pci-driver.c177
-rw-r--r--drivers/pci/pci.c142
-rw-r--r--drivers/pci/pci.h1
-rw-r--r--drivers/platform/x86/asus_acpi.c3
-rw-r--r--drivers/platform/x86/dell-laptop.c4
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c2
-rw-r--r--drivers/platform/x86/toshiba_acpi.c3
-rw-r--r--drivers/rtc/rtc-proc.c10
-rw-r--r--drivers/s390/block/dasd_proc.c2
-rw-r--r--drivers/scsi/scsi_devinfo.c2
-rw-r--r--drivers/scsi/scsi_proc.c3
-rw-r--r--drivers/video/aty/radeon_pm.c2
-rw-r--r--drivers/video/via/viafbdev.c5
-rw-r--r--drivers/virtio/virtio_ring.c22
-rw-r--r--drivers/watchdog/hpwdt.c4
-rw-r--r--drivers/xen/manage.c16
65 files changed, 902 insertions, 607 deletions
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 9b917dac7732..88e42abf5d88 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -191,7 +191,6 @@ static int acpi_ac_add_fs(struct acpi_device *device)
191 acpi_ac_dir); 191 acpi_ac_dir);
192 if (!acpi_device_dir(device)) 192 if (!acpi_device_dir(device))
193 return -ENODEV; 193 return -ENODEV;
194 acpi_device_dir(device)->owner = THIS_MODULE;
195 } 194 }
196 195
197 /* 'state' [R] */ 196 /* 'state' [R] */
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 69cbc57c2d1c..3bcb5bfc45d3 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -760,7 +760,6 @@ static int acpi_battery_add_fs(struct acpi_device *device)
760 acpi_battery_dir); 760 acpi_battery_dir);
761 if (!acpi_device_dir(device)) 761 if (!acpi_device_dir(device))
762 return -ENODEV; 762 return -ENODEV;
763 acpi_device_dir(device)->owner = THIS_MODULE;
764 } 763 }
765 764
766 for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) { 765 for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) {
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 171fd914f435..c2f06069dcd4 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -200,12 +200,10 @@ static int acpi_button_add_fs(struct acpi_device *device)
200 200
201 if (!entry) 201 if (!entry)
202 return -ENODEV; 202 return -ENODEV;
203 entry->owner = THIS_MODULE;
204 203
205 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry); 204 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry);
206 if (!acpi_device_dir(device)) 205 if (!acpi_device_dir(device))
207 return -ENODEV; 206 return -ENODEV;
208 acpi_device_dir(device)->owner = THIS_MODULE;
209 207
210 /* 'info' [R] */ 208 /* 'info' [R] */
211 entry = proc_create_data(ACPI_BUTTON_FILE_INFO, 209 entry = proc_create_data(ACPI_BUTTON_FILE_INFO,
@@ -522,7 +520,6 @@ static int __init acpi_button_init(void)
522 acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir); 520 acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir);
523 if (!acpi_button_dir) 521 if (!acpi_button_dir)
524 return -ENODEV; 522 return -ENODEV;
525 acpi_button_dir->owner = THIS_MODULE;
526 result = acpi_bus_register_driver(&acpi_button_driver); 523 result = acpi_bus_register_driver(&acpi_button_driver);
527 if (result < 0) { 524 if (result < 0) {
528 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); 525 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index eaaee1660bdf..8a02944bf92d 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -193,7 +193,6 @@ static int acpi_fan_add_fs(struct acpi_device *device)
193 acpi_fan_dir); 193 acpi_fan_dir);
194 if (!acpi_device_dir(device)) 194 if (!acpi_device_dir(device))
195 return -ENODEV; 195 return -ENODEV;
196 acpi_device_dir(device)->owner = THIS_MODULE;
197 } 196 }
198 197
199 /* 'status' [R/W] */ 198 /* 'status' [R/W] */
@@ -347,7 +346,6 @@ static int __init acpi_fan_init(void)
347 acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir); 346 acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir);
348 if (!acpi_fan_dir) 347 if (!acpi_fan_dir)
349 return -ENODEV; 348 return -ENODEV;
350 acpi_fan_dir->owner = THIS_MODULE;
351#endif 349#endif
352 350
353 result = acpi_bus_register_driver(&acpi_fan_driver); 351 result = acpi_bus_register_driver(&acpi_fan_driver);
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 0cc2fd31e376..fa2f7422d23d 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -359,7 +359,6 @@ static int acpi_processor_add_fs(struct acpi_device *device)
359 if (!acpi_device_dir(device)) 359 if (!acpi_device_dir(device))
360 return -ENODEV; 360 return -ENODEV;
361 } 361 }
362 acpi_device_dir(device)->owner = THIS_MODULE;
363 362
364 /* 'info' [R] */ 363 /* 'info' [R] */
365 entry = proc_create_data(ACPI_PROCESSOR_FILE_INFO, 364 entry = proc_create_data(ACPI_PROCESSOR_FILE_INFO,
@@ -1137,7 +1136,6 @@ static int __init acpi_processor_init(void)
1137 acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); 1136 acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir);
1138 if (!acpi_processor_dir) 1137 if (!acpi_processor_dir)
1139 return -ENOMEM; 1138 return -ENOMEM;
1140 acpi_processor_dir->owner = THIS_MODULE;
1141 1139
1142 /* 1140 /*
1143 * Check whether the system is DMI table. If yes, OSPM 1141 * Check whether the system is DMI table. If yes, OSPM
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index 6050ce481873..59afd52ccc12 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -488,7 +488,6 @@ acpi_sbs_add_fs(struct proc_dir_entry **dir,
488 if (!*dir) { 488 if (!*dir) {
489 return -ENODEV; 489 return -ENODEV;
490 } 490 }
491 (*dir)->owner = THIS_MODULE;
492 } 491 }
493 492
494 /* 'info' [R] */ 493 /* 'info' [R] */
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 99e6f1f8ea45..c11f9aeca706 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -1506,7 +1506,6 @@ static int acpi_thermal_add_fs(struct acpi_device *device)
1506 acpi_thermal_dir); 1506 acpi_thermal_dir);
1507 if (!acpi_device_dir(device)) 1507 if (!acpi_device_dir(device))
1508 return -ENODEV; 1508 return -ENODEV;
1509 acpi_device_dir(device)->owner = THIS_MODULE;
1510 } 1509 }
1511 1510
1512 /* 'state' [R] */ 1511 /* 'state' [R] */
@@ -1875,7 +1874,6 @@ static int __init acpi_thermal_init(void)
1875 acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir); 1874 acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir);
1876 if (!acpi_thermal_dir) 1875 if (!acpi_thermal_dir)
1877 return -ENODEV; 1876 return -ENODEV;
1878 acpi_thermal_dir->owner = THIS_MODULE;
1879 1877
1880 result = acpi_bus_register_driver(&acpi_thermal_driver); 1878 result = acpi_bus_register_driver(&acpi_thermal_driver);
1881 if (result < 0) { 1879 if (result < 0) {
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index bb5ed059114a..67cc36dc9b82 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -1125,8 +1125,6 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
1125 if (!device_dir) 1125 if (!device_dir)
1126 return -ENOMEM; 1126 return -ENOMEM;
1127 1127
1128 device_dir->owner = THIS_MODULE;
1129
1130 /* 'info' [R] */ 1128 /* 'info' [R] */
1131 entry = proc_create_data("info", S_IRUGO, device_dir, 1129 entry = proc_create_data("info", S_IRUGO, device_dir,
1132 &acpi_video_device_info_fops, acpi_driver_data(device)); 1130 &acpi_video_device_info_fops, acpi_driver_data(device));
@@ -1403,8 +1401,6 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1403 if (!device_dir) 1401 if (!device_dir)
1404 return -ENOMEM; 1402 return -ENOMEM;
1405 1403
1406 device_dir->owner = THIS_MODULE;
1407
1408 /* 'info' [R] */ 1404 /* 'info' [R] */
1409 entry = proc_create_data("info", S_IRUGO, device_dir, 1405 entry = proc_create_data("info", S_IRUGO, device_dir,
1410 &acpi_video_bus_info_fops, 1406 &acpi_video_bus_info_fops,
@@ -2131,7 +2127,6 @@ static int __init acpi_video_init(void)
2131 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir); 2127 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir);
2132 if (!acpi_video_dir) 2128 if (!acpi_video_dir)
2133 return -ENODEV; 2129 return -ENODEV;
2134 acpi_video_dir->owner = THIS_MODULE;
2135 2130
2136 result = acpi_bus_register_driver(&acpi_video_bus); 2131 result = acpi_bus_register_driver(&acpi_video_bus);
2137 if (result < 0) { 2132 if (result < 0) {
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 5b257a57bc57..e62a4ccea54d 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -119,7 +119,7 @@ static ssize_t print_cpus_map(char *buf, const struct cpumask *map)
119#define print_cpus_func(type) \ 119#define print_cpus_func(type) \
120static ssize_t print_cpus_##type(struct sysdev_class *class, char *buf) \ 120static ssize_t print_cpus_##type(struct sysdev_class *class, char *buf) \
121{ \ 121{ \
122 return print_cpus_map(buf, &cpu_##type##_map); \ 122 return print_cpus_map(buf, cpu_##type##_mask); \
123} \ 123} \
124static struct sysdev_class_attribute attr_##type##_map = \ 124static struct sysdev_class_attribute attr_##type##_map = \
125 _SYSDEV_CLASS_ATTR(type, 0444, print_cpus_##type, NULL) 125 _SYSDEV_CLASS_ATTR(type, 0444, print_cpus_##type, NULL)
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index e255341682c8..69b4ddb7de3b 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -23,6 +23,7 @@
23#include <linux/pm.h> 23#include <linux/pm.h>
24#include <linux/resume-trace.h> 24#include <linux/resume-trace.h>
25#include <linux/rwsem.h> 25#include <linux/rwsem.h>
26#include <linux/interrupt.h>
26 27
27#include "../base.h" 28#include "../base.h"
28#include "power.h" 29#include "power.h"
@@ -349,7 +350,8 @@ static int resume_device_noirq(struct device *dev, pm_message_t state)
349 * Execute the appropriate "noirq resume" callback for all devices marked 350 * Execute the appropriate "noirq resume" callback for all devices marked
350 * as DPM_OFF_IRQ. 351 * as DPM_OFF_IRQ.
351 * 352 *
352 * Must be called with interrupts disabled and only one CPU running. 353 * Must be called under dpm_list_mtx. Device drivers should not receive
354 * interrupts while it's being executed.
353 */ 355 */
354static void dpm_power_up(pm_message_t state) 356static void dpm_power_up(pm_message_t state)
355{ 357{
@@ -370,14 +372,13 @@ static void dpm_power_up(pm_message_t state)
370 * device_power_up - Turn on all devices that need special attention. 372 * device_power_up - Turn on all devices that need special attention.
371 * @state: PM transition of the system being carried out. 373 * @state: PM transition of the system being carried out.
372 * 374 *
373 * Power on system devices, then devices that required we shut them down 375 * Call the "early" resume handlers and enable device drivers to receive
374 * with interrupts disabled. 376 * interrupts.
375 *
376 * Must be called with interrupts disabled.
377 */ 377 */
378void device_power_up(pm_message_t state) 378void device_power_up(pm_message_t state)
379{ 379{
380 dpm_power_up(state); 380 dpm_power_up(state);
381 resume_device_irqs();
381} 382}
382EXPORT_SYMBOL_GPL(device_power_up); 383EXPORT_SYMBOL_GPL(device_power_up);
383 384
@@ -602,16 +603,17 @@ static int suspend_device_noirq(struct device *dev, pm_message_t state)
602 * device_power_down - Shut down special devices. 603 * device_power_down - Shut down special devices.
603 * @state: PM transition of the system being carried out. 604 * @state: PM transition of the system being carried out.
604 * 605 *
605 * Power down devices that require interrupts to be disabled. 606 * Prevent device drivers from receiving interrupts and call the "late"
606 * Then power down system devices. 607 * suspend handlers.
607 * 608 *
608 * Must be called with interrupts disabled and only one CPU running. 609 * Must be called under dpm_list_mtx.
609 */ 610 */
610int device_power_down(pm_message_t state) 611int device_power_down(pm_message_t state)
611{ 612{
612 struct device *dev; 613 struct device *dev;
613 int error = 0; 614 int error = 0;
614 615
616 suspend_device_irqs();
615 list_for_each_entry_reverse(dev, &dpm_list, power.entry) { 617 list_for_each_entry_reverse(dev, &dpm_list, power.entry) {
616 error = suspend_device_noirq(dev, state); 618 error = suspend_device_noirq(dev, state);
617 if (error) { 619 if (error) {
@@ -621,7 +623,7 @@ int device_power_down(pm_message_t state)
621 dev->power.status = DPM_OFF_IRQ; 623 dev->power.status = DPM_OFF_IRQ;
622 } 624 }
623 if (error) 625 if (error)
624 dpm_power_up(resume_event(state)); 626 device_power_up(resume_event(state));
625 return error; 627 return error;
626} 628}
627EXPORT_SYMBOL_GPL(device_power_down); 629EXPORT_SYMBOL_GPL(device_power_down);
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index cbd36cf59a0f..76ce75bad91e 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -22,6 +22,7 @@
22#include <linux/pm.h> 22#include <linux/pm.h>
23#include <linux/device.h> 23#include <linux/device.h>
24#include <linux/mutex.h> 24#include <linux/mutex.h>
25#include <linux/interrupt.h>
25 26
26#include "base.h" 27#include "base.h"
27 28
@@ -369,6 +370,13 @@ int sysdev_suspend(pm_message_t state)
369 struct sysdev_driver *drv, *err_drv; 370 struct sysdev_driver *drv, *err_drv;
370 int ret; 371 int ret;
371 372
373 pr_debug("Checking wake-up interrupts\n");
374
375 /* Return error code if there are any wake-up interrupts pending */
376 ret = check_wakeup_irqs();
377 if (ret)
378 return ret;
379
372 pr_debug("Suspending System Devices\n"); 380 pr_debug("Suspending System Devices\n");
373 381
374 list_for_each_entry_reverse(cls, &system_kset->list, kset.kobj.entry) { 382 list_for_each_entry_reverse(cls, &system_kset->list, kset.kobj.entry) {
diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c
index 393ed6760d78..8eddef373a91 100644
--- a/drivers/block/ps3vram.c
+++ b/drivers/block/ps3vram.c
@@ -551,8 +551,6 @@ static void __devinit ps3vram_proc_init(struct ps3_system_bus_device *dev)
551 dev_warn(&dev->core, "failed to create /proc entry\n"); 551 dev_warn(&dev->core, "failed to create /proc entry\n");
552 return; 552 return;
553 } 553 }
554
555 pde->owner = THIS_MODULE;
556 pde->data = priv; 554 pde->data = priv;
557} 555}
558 556
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 7a88dfd4427b..e93fc8d22fb2 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -1944,7 +1944,7 @@ static int stat_file_read_proc(char *page, char **start, off_t off,
1944 1944
1945int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, 1945int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
1946 read_proc_t *read_proc, 1946 read_proc_t *read_proc,
1947 void *data, struct module *owner) 1947 void *data)
1948{ 1948{
1949 int rv = 0; 1949 int rv = 0;
1950#ifdef CONFIG_PROC_FS 1950#ifdef CONFIG_PROC_FS
@@ -1970,7 +1970,6 @@ int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
1970 } else { 1970 } else {
1971 file->data = data; 1971 file->data = data;
1972 file->read_proc = read_proc; 1972 file->read_proc = read_proc;
1973 file->owner = owner;
1974 1973
1975 mutex_lock(&smi->proc_entry_lock); 1974 mutex_lock(&smi->proc_entry_lock);
1976 /* Stick it on the list. */ 1975 /* Stick it on the list. */
@@ -1993,23 +1992,21 @@ static int add_proc_entries(ipmi_smi_t smi, int num)
1993 smi->proc_dir = proc_mkdir(smi->proc_dir_name, proc_ipmi_root); 1992 smi->proc_dir = proc_mkdir(smi->proc_dir_name, proc_ipmi_root);
1994 if (!smi->proc_dir) 1993 if (!smi->proc_dir)
1995 rv = -ENOMEM; 1994 rv = -ENOMEM;
1996 else
1997 smi->proc_dir->owner = THIS_MODULE;
1998 1995
1999 if (rv == 0) 1996 if (rv == 0)
2000 rv = ipmi_smi_add_proc_entry(smi, "stats", 1997 rv = ipmi_smi_add_proc_entry(smi, "stats",
2001 stat_file_read_proc, 1998 stat_file_read_proc,
2002 smi, THIS_MODULE); 1999 smi);
2003 2000
2004 if (rv == 0) 2001 if (rv == 0)
2005 rv = ipmi_smi_add_proc_entry(smi, "ipmb", 2002 rv = ipmi_smi_add_proc_entry(smi, "ipmb",
2006 ipmb_file_read_proc, 2003 ipmb_file_read_proc,
2007 smi, THIS_MODULE); 2004 smi);
2008 2005
2009 if (rv == 0) 2006 if (rv == 0)
2010 rv = ipmi_smi_add_proc_entry(smi, "version", 2007 rv = ipmi_smi_add_proc_entry(smi, "version",
2011 version_file_read_proc, 2008 version_file_read_proc,
2012 smi, THIS_MODULE); 2009 smi);
2013#endif /* CONFIG_PROC_FS */ 2010#endif /* CONFIG_PROC_FS */
2014 2011
2015 return rv; 2012 return rv;
@@ -4265,7 +4262,6 @@ static int ipmi_init_msghandler(void)
4265 return -ENOMEM; 4262 return -ENOMEM;
4266 } 4263 }
4267 4264
4268 proc_ipmi_root->owner = THIS_MODULE;
4269#endif /* CONFIG_PROC_FS */ 4265#endif /* CONFIG_PROC_FS */
4270 4266
4271 setup_timer(&ipmi_timer, ipmi_timeout, 0); 4267 setup_timer(&ipmi_timer, ipmi_timeout, 0);
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 3000135f2ead..e58ea4cd55ce 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -2899,7 +2899,7 @@ static int try_smi_init(struct smi_info *new_smi)
2899 2899
2900 rv = ipmi_smi_add_proc_entry(new_smi->intf, "type", 2900 rv = ipmi_smi_add_proc_entry(new_smi->intf, "type",
2901 type_file_read_proc, 2901 type_file_read_proc,
2902 new_smi, THIS_MODULE); 2902 new_smi);
2903 if (rv) { 2903 if (rv) {
2904 printk(KERN_ERR 2904 printk(KERN_ERR
2905 "ipmi_si: Unable to create proc entry: %d\n", 2905 "ipmi_si: Unable to create proc entry: %d\n",
@@ -2909,7 +2909,7 @@ static int try_smi_init(struct smi_info *new_smi)
2909 2909
2910 rv = ipmi_smi_add_proc_entry(new_smi->intf, "si_stats", 2910 rv = ipmi_smi_add_proc_entry(new_smi->intf, "si_stats",
2911 stat_file_read_proc, 2911 stat_file_read_proc,
2912 new_smi, THIS_MODULE); 2912 new_smi);
2913 if (rv) { 2913 if (rv) {
2914 printk(KERN_ERR 2914 printk(KERN_ERR
2915 "ipmi_si: Unable to create proc entry: %d\n", 2915 "ipmi_si: Unable to create proc entry: %d\n",
@@ -2919,7 +2919,7 @@ static int try_smi_init(struct smi_info *new_smi)
2919 2919
2920 rv = ipmi_smi_add_proc_entry(new_smi->intf, "params", 2920 rv = ipmi_smi_add_proc_entry(new_smi->intf, "params",
2921 param_read_proc, 2921 param_read_proc,
2922 new_smi, THIS_MODULE); 2922 new_smi);
2923 if (rv) { 2923 if (rv) {
2924 printk(KERN_ERR 2924 printk(KERN_ERR
2925 "ipmi_si: Unable to create proc entry: %d\n", 2925 "ipmi_si: Unable to create proc entry: %d\n",
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 8f0f7c449305..5f1b5400d96a 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -68,7 +68,8 @@ static char * __init dmi_string(const struct dmi_header *dm, u8 s)
68 * pointing to completely the wrong place for example 68 * pointing to completely the wrong place for example
69 */ 69 */
70static void dmi_table(u8 *buf, int len, int num, 70static void dmi_table(u8 *buf, int len, int num,
71 void (*decode)(const struct dmi_header *)) 71 void (*decode)(const struct dmi_header *, void *),
72 void *private_data)
72{ 73{
73 u8 *data = buf; 74 u8 *data = buf;
74 int i = 0; 75 int i = 0;
@@ -89,7 +90,7 @@ static void dmi_table(u8 *buf, int len, int num,
89 while ((data - buf < len - 1) && (data[0] || data[1])) 90 while ((data - buf < len - 1) && (data[0] || data[1]))
90 data++; 91 data++;
91 if (data - buf < len - 1) 92 if (data - buf < len - 1)
92 decode(dm); 93 decode(dm, private_data);
93 data += 2; 94 data += 2;
94 i++; 95 i++;
95 } 96 }
@@ -99,7 +100,8 @@ static u32 dmi_base;
99static u16 dmi_len; 100static u16 dmi_len;
100static u16 dmi_num; 101static u16 dmi_num;
101 102
102static int __init dmi_walk_early(void (*decode)(const struct dmi_header *)) 103static int __init dmi_walk_early(void (*decode)(const struct dmi_header *,
104 void *))
103{ 105{
104 u8 *buf; 106 u8 *buf;
105 107
@@ -107,7 +109,7 @@ static int __init dmi_walk_early(void (*decode)(const struct dmi_header *))
107 if (buf == NULL) 109 if (buf == NULL)
108 return -1; 110 return -1;
109 111
110 dmi_table(buf, dmi_len, dmi_num, decode); 112 dmi_table(buf, dmi_len, dmi_num, decode, NULL);
111 113
112 dmi_iounmap(buf, dmi_len); 114 dmi_iounmap(buf, dmi_len);
113 return 0; 115 return 0;
@@ -295,7 +297,7 @@ static void __init dmi_save_extended_devices(const struct dmi_header *dm)
295 * and machine entries. For 2.5 we should pull the smbus controller info 297 * and machine entries. For 2.5 we should pull the smbus controller info
296 * out of here. 298 * out of here.
297 */ 299 */
298static void __init dmi_decode(const struct dmi_header *dm) 300static void __init dmi_decode(const struct dmi_header *dm, void *dummy)
299{ 301{
300 switch(dm->type) { 302 switch(dm->type) {
301 case 0: /* BIOS Information */ 303 case 0: /* BIOS Information */
@@ -598,10 +600,12 @@ int dmi_get_year(int field)
598/** 600/**
599 * dmi_walk - Walk the DMI table and get called back for every record 601 * dmi_walk - Walk the DMI table and get called back for every record
600 * @decode: Callback function 602 * @decode: Callback function
603 * @private_data: Private data to be passed to the callback function
601 * 604 *
602 * Returns -1 when the DMI table can't be reached, 0 on success. 605 * Returns -1 when the DMI table can't be reached, 0 on success.
603 */ 606 */
604int dmi_walk(void (*decode)(const struct dmi_header *)) 607int dmi_walk(void (*decode)(const struct dmi_header *, void *),
608 void *private_data)
605{ 609{
606 u8 *buf; 610 u8 *buf;
607 611
@@ -612,7 +616,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *))
612 if (buf == NULL) 616 if (buf == NULL)
613 return -1; 617 return -1;
614 618
615 dmi_table(buf, dmi_len, dmi_num, decode); 619 dmi_table(buf, dmi_len, dmi_num, decode, private_data);
616 620
617 iounmap(buf); 621 iounmap(buf);
618 return 0; 622 return 0;
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index b4eea0292c1a..51ff9b3d7ea2 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -343,12 +343,13 @@ config SENSORS_FSCPOS
343 will be called fscpos. 343 will be called fscpos.
344 344
345config SENSORS_FSCHMD 345config SENSORS_FSCHMD
346 tristate "FSC Poseidon, Scylla, Hermes, Heimdall and Heracles" 346 tristate "Fujitsu Siemens Computers sensor chips"
347 depends on X86 && I2C 347 depends on X86 && I2C
348 help 348 help
349 If you say yes here you get support for various Fujitsu Siemens 349 If you say yes here you get support for the following Fujitsu
350 Computers sensor chips, including support for the integrated 350 Siemens Computers (FSC) sensor chips: Poseidon, Scylla, Hermes,
351 watchdog. 351 Heimdall, Heracles, Hades and Syleus including support for the
352 integrated watchdog.
352 353
353 This is a merged driver for FSC sensor chips replacing the fscpos, 354 This is a merged driver for FSC sensor chips replacing the fscpos,
354 fscscy and fscher drivers and adding support for several other FSC 355 fscscy and fscher drivers and adding support for several other FSC
@@ -635,6 +636,20 @@ config SENSORS_PC87427
635 This driver can also be built as a module. If so, the module 636 This driver can also be built as a module. If so, the module
636 will be called pc87427. 637 will be called pc87427.
637 638
639config SENSORS_PCF8591
640 tristate "Philips PCF8591 ADC/DAC"
641 depends on I2C
642 default n
643 help
644 If you say yes here you get support for Philips PCF8591 4-channel
645 ADC, 1-channel DAC chips.
646
647 This driver can also be built as a module. If so, the module
648 will be called pcf8591.
649
650 These devices are hard to detect and rarely found on mainstream
651 hardware. If unsure, say N.
652
638config SENSORS_SIS5595 653config SENSORS_SIS5595
639 tristate "Silicon Integrated Systems Corp. SiS5595" 654 tristate "Silicon Integrated Systems Corp. SiS5595"
640 depends on PCI 655 depends on PCI
@@ -827,7 +842,7 @@ config SENSORS_W83627HF
827 will be called w83627hf. 842 will be called w83627hf.
828 843
829config SENSORS_W83627EHF 844config SENSORS_W83627EHF
830 tristate "Winbond W83627EHF/DHG" 845 tristate "Winbond W83627EHF/EHG/DHG, W83667HG"
831 select HWMON_VID 846 select HWMON_VID
832 help 847 help
833 If you say yes here you get support for the hardware 848 If you say yes here you get support for the hardware
@@ -838,6 +853,8 @@ config SENSORS_W83627EHF
838 chip suited for specific Intel processors that use PECI such as 853 chip suited for specific Intel processors that use PECI such as
839 the Core 2 Duo. 854 the Core 2 Duo.
840 855
856 This driver also supports the W83667HG chip.
857
841 This driver can also be built as a module. If so, the module 858 This driver can also be built as a module. If so, the module
842 will be called w83627ehf. 859 will be called w83627ehf.
843 860
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 2e80f37f39eb..e332d6267920 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -70,6 +70,7 @@ obj-$(CONFIG_SENSORS_MAX1619) += max1619.o
70obj-$(CONFIG_SENSORS_MAX6650) += max6650.o 70obj-$(CONFIG_SENSORS_MAX6650) += max6650.o
71obj-$(CONFIG_SENSORS_PC87360) += pc87360.o 71obj-$(CONFIG_SENSORS_PC87360) += pc87360.o
72obj-$(CONFIG_SENSORS_PC87427) += pc87427.o 72obj-$(CONFIG_SENSORS_PC87427) += pc87427.o
73obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
73obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o 74obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o
74obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o 75obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o
75obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o 76obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c
index 7415381601c3..53f88f511816 100644
--- a/drivers/hwmon/ds1621.c
+++ b/drivers/hwmon/ds1621.c
@@ -81,71 +81,84 @@ struct ds1621_data {
81 u8 conf; /* Register encoding, combined */ 81 u8 conf; /* Register encoding, combined */
82}; 82};
83 83
84static int ds1621_probe(struct i2c_client *client, 84/* Temperature registers are word-sized.
85 const struct i2c_device_id *id);
86static int ds1621_detect(struct i2c_client *client, int kind,
87 struct i2c_board_info *info);
88static void ds1621_init_client(struct i2c_client *client);
89static int ds1621_remove(struct i2c_client *client);
90static struct ds1621_data *ds1621_update_client(struct device *dev);
91
92static const struct i2c_device_id ds1621_id[] = {
93 { "ds1621", ds1621 },
94 { "ds1625", ds1621 },
95 { }
96};
97MODULE_DEVICE_TABLE(i2c, ds1621_id);
98
99/* This is the driver that will be inserted */
100static struct i2c_driver ds1621_driver = {
101 .class = I2C_CLASS_HWMON,
102 .driver = {
103 .name = "ds1621",
104 },
105 .probe = ds1621_probe,
106 .remove = ds1621_remove,
107 .id_table = ds1621_id,
108 .detect = ds1621_detect,
109 .address_data = &addr_data,
110};
111
112/* All registers are word-sized, except for the configuration register.
113 DS1621 uses a high-byte first convention, which is exactly opposite to 85 DS1621 uses a high-byte first convention, which is exactly opposite to
114 the SMBus standard. */ 86 the SMBus standard. */
115static int ds1621_read_value(struct i2c_client *client, u8 reg) 87static int ds1621_read_temp(struct i2c_client *client, u8 reg)
116{ 88{
117 if (reg == DS1621_REG_CONF) 89 int ret;
118 return i2c_smbus_read_byte_data(client, reg); 90
119 else 91 ret = i2c_smbus_read_word_data(client, reg);
120 return swab16(i2c_smbus_read_word_data(client, reg)); 92 if (ret < 0)
93 return ret;
94 return swab16(ret);
121} 95}
122 96
123static int ds1621_write_value(struct i2c_client *client, u8 reg, u16 value) 97static int ds1621_write_temp(struct i2c_client *client, u8 reg, u16 value)
124{ 98{
125 if (reg == DS1621_REG_CONF) 99 return i2c_smbus_write_word_data(client, reg, swab16(value));
126 return i2c_smbus_write_byte_data(client, reg, value);
127 else
128 return i2c_smbus_write_word_data(client, reg, swab16(value));
129} 100}
130 101
131static void ds1621_init_client(struct i2c_client *client) 102static void ds1621_init_client(struct i2c_client *client)
132{ 103{
133 int reg = ds1621_read_value(client, DS1621_REG_CONF); 104 u8 conf, new_conf;
105
106 new_conf = conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF);
134 /* switch to continuous conversion mode */ 107 /* switch to continuous conversion mode */
135 reg &= ~ DS1621_REG_CONFIG_1SHOT; 108 new_conf &= ~DS1621_REG_CONFIG_1SHOT;
136 109
137 /* setup output polarity */ 110 /* setup output polarity */
138 if (polarity == 0) 111 if (polarity == 0)
139 reg &= ~DS1621_REG_CONFIG_POLARITY; 112 new_conf &= ~DS1621_REG_CONFIG_POLARITY;
140 else if (polarity == 1) 113 else if (polarity == 1)
141 reg |= DS1621_REG_CONFIG_POLARITY; 114 new_conf |= DS1621_REG_CONFIG_POLARITY;
142 115
143 ds1621_write_value(client, DS1621_REG_CONF, reg); 116 if (conf != new_conf)
117 i2c_smbus_write_byte_data(client, DS1621_REG_CONF, new_conf);
144 118
145 /* start conversion */ 119 /* start conversion */
146 i2c_smbus_write_byte(client, DS1621_COM_START); 120 i2c_smbus_write_byte(client, DS1621_COM_START);
147} 121}
148 122
123static struct ds1621_data *ds1621_update_client(struct device *dev)
124{
125 struct i2c_client *client = to_i2c_client(dev);
126 struct ds1621_data *data = i2c_get_clientdata(client);
127 u8 new_conf;
128
129 mutex_lock(&data->update_lock);
130
131 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
132 || !data->valid) {
133 int i;
134
135 dev_dbg(&client->dev, "Starting ds1621 update\n");
136
137 data->conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF);
138
139 for (i = 0; i < ARRAY_SIZE(data->temp); i++)
140 data->temp[i] = ds1621_read_temp(client,
141 DS1621_REG_TEMP[i]);
142
143 /* reset alarms if necessary */
144 new_conf = data->conf;
145 if (data->temp[0] > data->temp[1]) /* input > min */
146 new_conf &= ~DS1621_ALARM_TEMP_LOW;
147 if (data->temp[0] < data->temp[2]) /* input < max */
148 new_conf &= ~DS1621_ALARM_TEMP_HIGH;
149 if (data->conf != new_conf)
150 i2c_smbus_write_byte_data(client, DS1621_REG_CONF,
151 new_conf);
152
153 data->last_updated = jiffies;
154 data->valid = 1;
155 }
156
157 mutex_unlock(&data->update_lock);
158
159 return data;
160}
161
149static ssize_t show_temp(struct device *dev, struct device_attribute *da, 162static ssize_t show_temp(struct device *dev, struct device_attribute *da,
150 char *buf) 163 char *buf)
151{ 164{
@@ -160,13 +173,13 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
160{ 173{
161 struct sensor_device_attribute *attr = to_sensor_dev_attr(da); 174 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
162 struct i2c_client *client = to_i2c_client(dev); 175 struct i2c_client *client = to_i2c_client(dev);
163 struct ds1621_data *data = ds1621_update_client(dev); 176 struct ds1621_data *data = i2c_get_clientdata(client);
164 u16 val = LM75_TEMP_TO_REG(simple_strtol(buf, NULL, 10)); 177 u16 val = LM75_TEMP_TO_REG(simple_strtol(buf, NULL, 10));
165 178
166 mutex_lock(&data->update_lock); 179 mutex_lock(&data->update_lock);
167 data->temp[attr->index] = val; 180 data->temp[attr->index] = val;
168 ds1621_write_value(client, DS1621_REG_TEMP[attr->index], 181 ds1621_write_temp(client, DS1621_REG_TEMP[attr->index],
169 data->temp[attr->index]); 182 data->temp[attr->index]);
170 mutex_unlock(&data->update_lock); 183 mutex_unlock(&data->update_lock);
171 return count; 184 return count;
172} 185}
@@ -228,13 +241,14 @@ static int ds1621_detect(struct i2c_client *client, int kind,
228 /* The NVB bit should be low if no EEPROM write has been 241 /* The NVB bit should be low if no EEPROM write has been
229 requested during the latest 10ms, which is highly 242 requested during the latest 10ms, which is highly
230 improbable in our case. */ 243 improbable in our case. */
231 conf = ds1621_read_value(client, DS1621_REG_CONF); 244 conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF);
232 if (conf & DS1621_REG_CONFIG_NVB) 245 if (conf < 0 || conf & DS1621_REG_CONFIG_NVB)
233 return -ENODEV; 246 return -ENODEV;
234 /* The 7 lowest bits of a temperature should always be 0. */ 247 /* The 7 lowest bits of a temperature should always be 0. */
235 for (i = 0; i < ARRAY_SIZE(DS1621_REG_TEMP); i++) { 248 for (i = 0; i < ARRAY_SIZE(DS1621_REG_TEMP); i++) {
236 temp = ds1621_read_value(client, DS1621_REG_TEMP[i]); 249 temp = i2c_smbus_read_word_data(client,
237 if (temp & 0x007f) 250 DS1621_REG_TEMP[i]);
251 if (temp < 0 || (temp & 0x7f00))
238 return -ENODEV; 252 return -ENODEV;
239 } 253 }
240 } 254 }
@@ -294,45 +308,25 @@ static int ds1621_remove(struct i2c_client *client)
294 return 0; 308 return 0;
295} 309}
296 310
311static const struct i2c_device_id ds1621_id[] = {
312 { "ds1621", ds1621 },
313 { "ds1625", ds1621 },
314 { }
315};
316MODULE_DEVICE_TABLE(i2c, ds1621_id);
297 317
298static struct ds1621_data *ds1621_update_client(struct device *dev) 318/* This is the driver that will be inserted */
299{ 319static struct i2c_driver ds1621_driver = {
300 struct i2c_client *client = to_i2c_client(dev); 320 .class = I2C_CLASS_HWMON,
301 struct ds1621_data *data = i2c_get_clientdata(client); 321 .driver = {
302 u8 new_conf; 322 .name = "ds1621",
303 323 },
304 mutex_lock(&data->update_lock); 324 .probe = ds1621_probe,
305 325 .remove = ds1621_remove,
306 if (time_after(jiffies, data->last_updated + HZ + HZ / 2) 326 .id_table = ds1621_id,
307 || !data->valid) { 327 .detect = ds1621_detect,
308 int i; 328 .address_data = &addr_data,
309 329};
310 dev_dbg(&client->dev, "Starting ds1621 update\n");
311
312 data->conf = ds1621_read_value(client, DS1621_REG_CONF);
313
314 for (i = 0; i < ARRAY_SIZE(data->temp); i++)
315 data->temp[i] = ds1621_read_value(client,
316 DS1621_REG_TEMP[i]);
317
318 /* reset alarms if necessary */
319 new_conf = data->conf;
320 if (data->temp[0] > data->temp[1]) /* input > min */
321 new_conf &= ~DS1621_ALARM_TEMP_LOW;
322 if (data->temp[0] < data->temp[2]) /* input < max */
323 new_conf &= ~DS1621_ALARM_TEMP_HIGH;
324 if (data->conf != new_conf)
325 ds1621_write_value(client, DS1621_REG_CONF,
326 new_conf);
327
328 data->last_updated = jiffies;
329 data->valid = 1;
330 }
331
332 mutex_unlock(&data->update_lock);
333
334 return data;
335}
336 330
337static int __init ds1621_init(void) 331static int __init ds1621_init(void)
338{ 332{
diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c
index d07f4ef75092..ea955edde87e 100644
--- a/drivers/hwmon/fschmd.c
+++ b/drivers/hwmon/fschmd.c
@@ -1,6 +1,6 @@
1/* fschmd.c 1/* fschmd.c
2 * 2 *
3 * Copyright (C) 2007,2008 Hans de Goede <hdegoede@redhat.com> 3 * Copyright (C) 2007 - 2009 Hans de Goede <hdegoede@redhat.com>
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
19 19
20/* 20/*
21 * Merged Fujitsu Siemens hwmon driver, supporting the Poseidon, Hermes, 21 * Merged Fujitsu Siemens hwmon driver, supporting the Poseidon, Hermes,
22 * Scylla, Heracles and Heimdall chips 22 * Scylla, Heracles, Heimdall, Hades and Syleus chips
23 * 23 *
24 * Based on the original 2.4 fscscy, 2.6 fscpos, 2.6 fscher and 2.6 24 * Based on the original 2.4 fscscy, 2.6 fscpos, 2.6 fscher and 2.6
25 * (candidate) fschmd drivers: 25 * (candidate) fschmd drivers:
@@ -56,7 +56,7 @@ static int nowayout = WATCHDOG_NOWAYOUT;
56module_param(nowayout, int, 0); 56module_param(nowayout, int, 0);
57MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" 57MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
58 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 58 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
59I2C_CLIENT_INSMOD_5(fscpos, fscher, fscscy, fschrc, fschmd); 59I2C_CLIENT_INSMOD_7(fscpos, fscher, fscscy, fschrc, fschmd, fschds, fscsyl);
60 60
61/* 61/*
62 * The FSCHMD registers and other defines 62 * The FSCHMD registers and other defines
@@ -75,9 +75,12 @@ I2C_CLIENT_INSMOD_5(fscpos, fscher, fscscy, fschrc, fschmd);
75#define FSCHMD_CONTROL_ALERT_LED 0x01 75#define FSCHMD_CONTROL_ALERT_LED 0x01
76 76
77/* watchdog */ 77/* watchdog */
78#define FSCHMD_REG_WDOG_PRESET 0x28 78static const u8 FSCHMD_REG_WDOG_CONTROL[7] =
79#define FSCHMD_REG_WDOG_STATE 0x23 79 { 0x21, 0x21, 0x21, 0x21, 0x21, 0x28, 0x28 };
80#define FSCHMD_REG_WDOG_CONTROL 0x21 80static const u8 FSCHMD_REG_WDOG_STATE[7] =
81 { 0x23, 0x23, 0x23, 0x23, 0x23, 0x29, 0x29 };
82static const u8 FSCHMD_REG_WDOG_PRESET[7] =
83 { 0x28, 0x28, 0x28, 0x28, 0x28, 0x2a, 0x2a };
81 84
82#define FSCHMD_WDOG_CONTROL_TRIGGER 0x10 85#define FSCHMD_WDOG_CONTROL_TRIGGER 0x10
83#define FSCHMD_WDOG_CONTROL_STARTED 0x10 /* the same as trigger */ 86#define FSCHMD_WDOG_CONTROL_STARTED 0x10 /* the same as trigger */
@@ -87,70 +90,95 @@ I2C_CLIENT_INSMOD_5(fscpos, fscher, fscscy, fschrc, fschmd);
87#define FSCHMD_WDOG_STATE_CARDRESET 0x02 90#define FSCHMD_WDOG_STATE_CARDRESET 0x02
88 91
89/* voltages, weird order is to keep the same order as the old drivers */ 92/* voltages, weird order is to keep the same order as the old drivers */
90static const u8 FSCHMD_REG_VOLT[3] = { 0x45, 0x42, 0x48 }; 93static const u8 FSCHMD_REG_VOLT[7][6] = {
94 { 0x45, 0x42, 0x48 }, /* pos */
95 { 0x45, 0x42, 0x48 }, /* her */
96 { 0x45, 0x42, 0x48 }, /* scy */
97 { 0x45, 0x42, 0x48 }, /* hrc */
98 { 0x45, 0x42, 0x48 }, /* hmd */
99 { 0x21, 0x20, 0x22 }, /* hds */
100 { 0x21, 0x20, 0x22, 0x23, 0x24, 0x25 }, /* syl */
101};
102
103static const int FSCHMD_NO_VOLT_SENSORS[7] = { 3, 3, 3, 3, 3, 3, 6 };
91 104
92/* minimum pwm at which the fan is driven (pwm can by increased depending on 105/* minimum pwm at which the fan is driven (pwm can by increased depending on
93 the temp. Notice that for the scy some fans share there minimum speed. 106 the temp. Notice that for the scy some fans share there minimum speed.
94 Also notice that with the scy the sensor order is different than with the 107 Also notice that with the scy the sensor order is different than with the
95 other chips, this order was in the 2.4 driver and kept for consistency. */ 108 other chips, this order was in the 2.4 driver and kept for consistency. */
96static const u8 FSCHMD_REG_FAN_MIN[5][6] = { 109static const u8 FSCHMD_REG_FAN_MIN[7][7] = {
97 { 0x55, 0x65 }, /* pos */ 110 { 0x55, 0x65 }, /* pos */
98 { 0x55, 0x65, 0xb5 }, /* her */ 111 { 0x55, 0x65, 0xb5 }, /* her */
99 { 0x65, 0x65, 0x55, 0xa5, 0x55, 0xa5 }, /* scy */ 112 { 0x65, 0x65, 0x55, 0xa5, 0x55, 0xa5 }, /* scy */
100 { 0x55, 0x65, 0xa5, 0xb5 }, /* hrc */ 113 { 0x55, 0x65, 0xa5, 0xb5 }, /* hrc */
101 { 0x55, 0x65, 0xa5, 0xb5, 0xc5 }, /* hmd */ 114 { 0x55, 0x65, 0xa5, 0xb5, 0xc5 }, /* hmd */
115 { 0x55, 0x65, 0xa5, 0xb5, 0xc5 }, /* hds */
116 { 0x54, 0x64, 0x74, 0x84, 0x94, 0xa4, 0xb4 }, /* syl */
102}; 117};
103 118
104/* actual fan speed */ 119/* actual fan speed */
105static const u8 FSCHMD_REG_FAN_ACT[5][6] = { 120static const u8 FSCHMD_REG_FAN_ACT[7][7] = {
106 { 0x0e, 0x6b, 0xab }, /* pos */ 121 { 0x0e, 0x6b, 0xab }, /* pos */
107 { 0x0e, 0x6b, 0xbb }, /* her */ 122 { 0x0e, 0x6b, 0xbb }, /* her */
108 { 0x6b, 0x6c, 0x0e, 0xab, 0x5c, 0xbb }, /* scy */ 123 { 0x6b, 0x6c, 0x0e, 0xab, 0x5c, 0xbb }, /* scy */
109 { 0x0e, 0x6b, 0xab, 0xbb }, /* hrc */ 124 { 0x0e, 0x6b, 0xab, 0xbb }, /* hrc */
110 { 0x5b, 0x6b, 0xab, 0xbb, 0xcb }, /* hmd */ 125 { 0x5b, 0x6b, 0xab, 0xbb, 0xcb }, /* hmd */
126 { 0x5b, 0x6b, 0xab, 0xbb, 0xcb }, /* hds */
127 { 0x57, 0x67, 0x77, 0x87, 0x97, 0xa7, 0xb7 }, /* syl */
111}; 128};
112 129
113/* fan status registers */ 130/* fan status registers */
114static const u8 FSCHMD_REG_FAN_STATE[5][6] = { 131static const u8 FSCHMD_REG_FAN_STATE[7][7] = {
115 { 0x0d, 0x62, 0xa2 }, /* pos */ 132 { 0x0d, 0x62, 0xa2 }, /* pos */
116 { 0x0d, 0x62, 0xb2 }, /* her */ 133 { 0x0d, 0x62, 0xb2 }, /* her */
117 { 0x62, 0x61, 0x0d, 0xa2, 0x52, 0xb2 }, /* scy */ 134 { 0x62, 0x61, 0x0d, 0xa2, 0x52, 0xb2 }, /* scy */
118 { 0x0d, 0x62, 0xa2, 0xb2 }, /* hrc */ 135 { 0x0d, 0x62, 0xa2, 0xb2 }, /* hrc */
119 { 0x52, 0x62, 0xa2, 0xb2, 0xc2 }, /* hmd */ 136 { 0x52, 0x62, 0xa2, 0xb2, 0xc2 }, /* hmd */
137 { 0x52, 0x62, 0xa2, 0xb2, 0xc2 }, /* hds */
138 { 0x50, 0x60, 0x70, 0x80, 0x90, 0xa0, 0xb0 }, /* syl */
120}; 139};
121 140
122/* fan ripple / divider registers */ 141/* fan ripple / divider registers */
123static const u8 FSCHMD_REG_FAN_RIPPLE[5][6] = { 142static const u8 FSCHMD_REG_FAN_RIPPLE[7][7] = {
124 { 0x0f, 0x6f, 0xaf }, /* pos */ 143 { 0x0f, 0x6f, 0xaf }, /* pos */
125 { 0x0f, 0x6f, 0xbf }, /* her */ 144 { 0x0f, 0x6f, 0xbf }, /* her */
126 { 0x6f, 0x6f, 0x0f, 0xaf, 0x0f, 0xbf }, /* scy */ 145 { 0x6f, 0x6f, 0x0f, 0xaf, 0x0f, 0xbf }, /* scy */
127 { 0x0f, 0x6f, 0xaf, 0xbf }, /* hrc */ 146 { 0x0f, 0x6f, 0xaf, 0xbf }, /* hrc */
128 { 0x5f, 0x6f, 0xaf, 0xbf, 0xcf }, /* hmd */ 147 { 0x5f, 0x6f, 0xaf, 0xbf, 0xcf }, /* hmd */
148 { 0x5f, 0x6f, 0xaf, 0xbf, 0xcf }, /* hds */
149 { 0x56, 0x66, 0x76, 0x86, 0x96, 0xa6, 0xb6 }, /* syl */
129}; 150};
130 151
131static const int FSCHMD_NO_FAN_SENSORS[5] = { 3, 3, 6, 4, 5 }; 152static const int FSCHMD_NO_FAN_SENSORS[7] = { 3, 3, 6, 4, 5, 5, 7 };
132 153
133/* Fan status register bitmasks */ 154/* Fan status register bitmasks */
134#define FSCHMD_FAN_ALARM 0x04 /* called fault by FSC! */ 155#define FSCHMD_FAN_ALARM 0x04 /* called fault by FSC! */
135#define FSCHMD_FAN_NOT_PRESENT 0x08 /* not documented */ 156#define FSCHMD_FAN_NOT_PRESENT 0x08
157#define FSCHMD_FAN_DISABLED 0x80
136 158
137 159
138/* actual temperature registers */ 160/* actual temperature registers */
139static const u8 FSCHMD_REG_TEMP_ACT[5][5] = { 161static const u8 FSCHMD_REG_TEMP_ACT[7][11] = {
140 { 0x64, 0x32, 0x35 }, /* pos */ 162 { 0x64, 0x32, 0x35 }, /* pos */
141 { 0x64, 0x32, 0x35 }, /* her */ 163 { 0x64, 0x32, 0x35 }, /* her */
142 { 0x64, 0xD0, 0x32, 0x35 }, /* scy */ 164 { 0x64, 0xD0, 0x32, 0x35 }, /* scy */
143 { 0x64, 0x32, 0x35 }, /* hrc */ 165 { 0x64, 0x32, 0x35 }, /* hrc */
144 { 0x70, 0x80, 0x90, 0xd0, 0xe0 }, /* hmd */ 166 { 0x70, 0x80, 0x90, 0xd0, 0xe0 }, /* hmd */
167 { 0x70, 0x80, 0x90, 0xd0, 0xe0 }, /* hds */
168 { 0x58, 0x68, 0x78, 0x88, 0x98, 0xa8, /* syl */
169 0xb8, 0xc8, 0xd8, 0xe8, 0xf8 },
145}; 170};
146 171
147/* temperature state registers */ 172/* temperature state registers */
148static const u8 FSCHMD_REG_TEMP_STATE[5][5] = { 173static const u8 FSCHMD_REG_TEMP_STATE[7][11] = {
149 { 0x71, 0x81, 0x91 }, /* pos */ 174 { 0x71, 0x81, 0x91 }, /* pos */
150 { 0x71, 0x81, 0x91 }, /* her */ 175 { 0x71, 0x81, 0x91 }, /* her */
151 { 0x71, 0xd1, 0x81, 0x91 }, /* scy */ 176 { 0x71, 0xd1, 0x81, 0x91 }, /* scy */
152 { 0x71, 0x81, 0x91 }, /* hrc */ 177 { 0x71, 0x81, 0x91 }, /* hrc */
153 { 0x71, 0x81, 0x91, 0xd1, 0xe1 }, /* hmd */ 178 { 0x71, 0x81, 0x91, 0xd1, 0xe1 }, /* hmd */
179 { 0x71, 0x81, 0x91, 0xd1, 0xe1 }, /* hds */
180 { 0x59, 0x69, 0x79, 0x89, 0x99, 0xa9, /* syl */
181 0xb9, 0xc9, 0xd9, 0xe9, 0xf9 },
154}; 182};
155 183
156/* temperature high limit registers, FSC does not document these. Proven to be 184/* temperature high limit registers, FSC does not document these. Proven to be
@@ -158,24 +186,31 @@ static const u8 FSCHMD_REG_TEMP_STATE[5][5] = {
158 in the fscscy 2.4 driver. FSC has confirmed that the fschmd has registers 186 in the fscscy 2.4 driver. FSC has confirmed that the fschmd has registers
159 at these addresses, but doesn't want to confirm they are the same as with 187 at these addresses, but doesn't want to confirm they are the same as with
160 the fscher?? */ 188 the fscher?? */
161static const u8 FSCHMD_REG_TEMP_LIMIT[5][5] = { 189static const u8 FSCHMD_REG_TEMP_LIMIT[7][11] = {
162 { 0, 0, 0 }, /* pos */ 190 { 0, 0, 0 }, /* pos */
163 { 0x76, 0x86, 0x96 }, /* her */ 191 { 0x76, 0x86, 0x96 }, /* her */
164 { 0x76, 0xd6, 0x86, 0x96 }, /* scy */ 192 { 0x76, 0xd6, 0x86, 0x96 }, /* scy */
165 { 0x76, 0x86, 0x96 }, /* hrc */ 193 { 0x76, 0x86, 0x96 }, /* hrc */
166 { 0x76, 0x86, 0x96, 0xd6, 0xe6 }, /* hmd */ 194 { 0x76, 0x86, 0x96, 0xd6, 0xe6 }, /* hmd */
195 { 0x76, 0x86, 0x96, 0xd6, 0xe6 }, /* hds */
196 { 0x5a, 0x6a, 0x7a, 0x8a, 0x9a, 0xaa, /* syl */
197 0xba, 0xca, 0xda, 0xea, 0xfa },
167}; 198};
168 199
169/* These were found through experimenting with an fscher, currently they are 200/* These were found through experimenting with an fscher, currently they are
170 not used, but we keep them around for future reference. 201 not used, but we keep them around for future reference.
202 On the fscsyl AUTOP1 lives at 0x#c (so 0x5c for fan1, 0x6c for fan2, etc),
203 AUTOP2 lives at 0x#e, and 0x#1 is a bitmask defining which temps influence
204 the fan speed.
171static const u8 FSCHER_REG_TEMP_AUTOP1[] = { 0x73, 0x83, 0x93 }; 205static const u8 FSCHER_REG_TEMP_AUTOP1[] = { 0x73, 0x83, 0x93 };
172static const u8 FSCHER_REG_TEMP_AUTOP2[] = { 0x75, 0x85, 0x95 }; */ 206static const u8 FSCHER_REG_TEMP_AUTOP2[] = { 0x75, 0x85, 0x95 }; */
173 207
174static const int FSCHMD_NO_TEMP_SENSORS[5] = { 3, 3, 4, 3, 5 }; 208static const int FSCHMD_NO_TEMP_SENSORS[7] = { 3, 3, 4, 3, 5, 5, 11 };
175 209
176/* temp status register bitmasks */ 210/* temp status register bitmasks */
177#define FSCHMD_TEMP_WORKING 0x01 211#define FSCHMD_TEMP_WORKING 0x01
178#define FSCHMD_TEMP_ALERT 0x02 212#define FSCHMD_TEMP_ALERT 0x02
213#define FSCHMD_TEMP_DISABLED 0x80
179/* there only really is an alarm if the sensor is working and alert == 1 */ 214/* there only really is an alarm if the sensor is working and alert == 1 */
180#define FSCHMD_TEMP_ALARM_MASK \ 215#define FSCHMD_TEMP_ALARM_MASK \
181 (FSCHMD_TEMP_WORKING | FSCHMD_TEMP_ALERT) 216 (FSCHMD_TEMP_WORKING | FSCHMD_TEMP_ALERT)
@@ -201,6 +236,8 @@ static const struct i2c_device_id fschmd_id[] = {
201 { "fscscy", fscscy }, 236 { "fscscy", fscscy },
202 { "fschrc", fschrc }, 237 { "fschrc", fschrc },
203 { "fschmd", fschmd }, 238 { "fschmd", fschmd },
239 { "fschds", fschds },
240 { "fscsyl", fscsyl },
204 { } 241 { }
205}; 242};
206MODULE_DEVICE_TABLE(i2c, fschmd_id); 243MODULE_DEVICE_TABLE(i2c, fschmd_id);
@@ -242,14 +279,14 @@ struct fschmd_data {
242 u8 watchdog_control; /* watchdog control register */ 279 u8 watchdog_control; /* watchdog control register */
243 u8 watchdog_state; /* watchdog status register */ 280 u8 watchdog_state; /* watchdog status register */
244 u8 watchdog_preset; /* watchdog counter preset on trigger val */ 281 u8 watchdog_preset; /* watchdog counter preset on trigger val */
245 u8 volt[3]; /* 12, 5, battery voltage */ 282 u8 volt[6]; /* voltage */
246 u8 temp_act[5]; /* temperature */ 283 u8 temp_act[11]; /* temperature */
247 u8 temp_status[5]; /* status of sensor */ 284 u8 temp_status[11]; /* status of sensor */
248 u8 temp_max[5]; /* high temp limit, notice: undocumented! */ 285 u8 temp_max[11]; /* high temp limit, notice: undocumented! */
249 u8 fan_act[6]; /* fans revolutions per second */ 286 u8 fan_act[7]; /* fans revolutions per second */
250 u8 fan_status[6]; /* fan status */ 287 u8 fan_status[7]; /* fan status */
251 u8 fan_min[6]; /* fan min value for rps */ 288 u8 fan_min[7]; /* fan min value for rps */
252 u8 fan_ripple[6]; /* divider for rps */ 289 u8 fan_ripple[7]; /* divider for rps */
253}; 290};
254 291
255/* Global variables to hold information read from special DMI tables, which are 292/* Global variables to hold information read from special DMI tables, which are
@@ -257,8 +294,8 @@ struct fschmd_data {
257 protect these with a lock as they are only modified from our attach function 294 protect these with a lock as they are only modified from our attach function
258 which always gets called with the i2c-core lock held and never accessed 295 which always gets called with the i2c-core lock held and never accessed
259 before the attach function is done with them. */ 296 before the attach function is done with them. */
260static int dmi_mult[3] = { 490, 200, 100 }; 297static int dmi_mult[6] = { 490, 200, 100, 100, 200, 100 };
261static int dmi_offset[3] = { 0, 0, 0 }; 298static int dmi_offset[6] = { 0, 0, 0, 0, 0, 0 };
262static int dmi_vref = -1; 299static int dmi_vref = -1;
263 300
264/* Somewhat ugly :( global data pointer list with all fschmd devices, so that 301/* Somewhat ugly :( global data pointer list with all fschmd devices, so that
@@ -450,10 +487,11 @@ static ssize_t show_pwm_auto_point1_pwm(struct device *dev,
450 struct device_attribute *devattr, char *buf) 487 struct device_attribute *devattr, char *buf)
451{ 488{
452 int index = to_sensor_dev_attr(devattr)->index; 489 int index = to_sensor_dev_attr(devattr)->index;
453 int val = fschmd_update_device(dev)->fan_min[index]; 490 struct fschmd_data *data = fschmd_update_device(dev);
491 int val = data->fan_min[index];
454 492
455 /* 0 = allow turning off, 1-255 = 50-100% */ 493 /* 0 = allow turning off (except on the syl), 1-255 = 50-100% */
456 if (val) 494 if (val || data->kind == fscsyl - 1)
457 val = val / 2 + 128; 495 val = val / 2 + 128;
458 496
459 return sprintf(buf, "%d\n", val); 497 return sprintf(buf, "%d\n", val);
@@ -466,8 +504,8 @@ static ssize_t store_pwm_auto_point1_pwm(struct device *dev,
466 struct fschmd_data *data = dev_get_drvdata(dev); 504 struct fschmd_data *data = dev_get_drvdata(dev);
467 unsigned long v = simple_strtoul(buf, NULL, 10); 505 unsigned long v = simple_strtoul(buf, NULL, 10);
468 506
469 /* register: 0 = allow turning off, 1-255 = 50-100% */ 507 /* reg: 0 = allow turning off (except on the syl), 1-255 = 50-100% */
470 if (v) { 508 if (v || data->kind == fscsyl - 1) {
471 v = SENSORS_LIMIT(v, 128, 255); 509 v = SENSORS_LIMIT(v, 128, 255);
472 v = (v - 128) * 2 + 1; 510 v = (v - 128) * 2 + 1;
473 } 511 }
@@ -522,11 +560,15 @@ static ssize_t store_alert_led(struct device *dev,
522 return count; 560 return count;
523} 561}
524 562
563static DEVICE_ATTR(alert_led, 0644, show_alert_led, store_alert_led);
564
525static struct sensor_device_attribute fschmd_attr[] = { 565static struct sensor_device_attribute fschmd_attr[] = {
526 SENSOR_ATTR(in0_input, 0444, show_in_value, NULL, 0), 566 SENSOR_ATTR(in0_input, 0444, show_in_value, NULL, 0),
527 SENSOR_ATTR(in1_input, 0444, show_in_value, NULL, 1), 567 SENSOR_ATTR(in1_input, 0444, show_in_value, NULL, 1),
528 SENSOR_ATTR(in2_input, 0444, show_in_value, NULL, 2), 568 SENSOR_ATTR(in2_input, 0444, show_in_value, NULL, 2),
529 SENSOR_ATTR(alert_led, 0644, show_alert_led, store_alert_led, 0), 569 SENSOR_ATTR(in3_input, 0444, show_in_value, NULL, 3),
570 SENSOR_ATTR(in4_input, 0444, show_in_value, NULL, 4),
571 SENSOR_ATTR(in5_input, 0444, show_in_value, NULL, 5),
530}; 572};
531 573
532static struct sensor_device_attribute fschmd_temp_attr[] = { 574static struct sensor_device_attribute fschmd_temp_attr[] = {
@@ -550,6 +592,30 @@ static struct sensor_device_attribute fschmd_temp_attr[] = {
550 SENSOR_ATTR(temp5_max, 0644, show_temp_max, store_temp_max, 4), 592 SENSOR_ATTR(temp5_max, 0644, show_temp_max, store_temp_max, 4),
551 SENSOR_ATTR(temp5_fault, 0444, show_temp_fault, NULL, 4), 593 SENSOR_ATTR(temp5_fault, 0444, show_temp_fault, NULL, 4),
552 SENSOR_ATTR(temp5_alarm, 0444, show_temp_alarm, NULL, 4), 594 SENSOR_ATTR(temp5_alarm, 0444, show_temp_alarm, NULL, 4),
595 SENSOR_ATTR(temp6_input, 0444, show_temp_value, NULL, 5),
596 SENSOR_ATTR(temp6_max, 0644, show_temp_max, store_temp_max, 5),
597 SENSOR_ATTR(temp6_fault, 0444, show_temp_fault, NULL, 5),
598 SENSOR_ATTR(temp6_alarm, 0444, show_temp_alarm, NULL, 5),
599 SENSOR_ATTR(temp7_input, 0444, show_temp_value, NULL, 6),
600 SENSOR_ATTR(temp7_max, 0644, show_temp_max, store_temp_max, 6),
601 SENSOR_ATTR(temp7_fault, 0444, show_temp_fault, NULL, 6),
602 SENSOR_ATTR(temp7_alarm, 0444, show_temp_alarm, NULL, 6),
603 SENSOR_ATTR(temp8_input, 0444, show_temp_value, NULL, 7),
604 SENSOR_ATTR(temp8_max, 0644, show_temp_max, store_temp_max, 7),
605 SENSOR_ATTR(temp8_fault, 0444, show_temp_fault, NULL, 7),
606 SENSOR_ATTR(temp8_alarm, 0444, show_temp_alarm, NULL, 7),
607 SENSOR_ATTR(temp9_input, 0444, show_temp_value, NULL, 8),
608 SENSOR_ATTR(temp9_max, 0644, show_temp_max, store_temp_max, 8),
609 SENSOR_ATTR(temp9_fault, 0444, show_temp_fault, NULL, 8),
610 SENSOR_ATTR(temp9_alarm, 0444, show_temp_alarm, NULL, 8),
611 SENSOR_ATTR(temp10_input, 0444, show_temp_value, NULL, 9),
612 SENSOR_ATTR(temp10_max, 0644, show_temp_max, store_temp_max, 9),
613 SENSOR_ATTR(temp10_fault, 0444, show_temp_fault, NULL, 9),
614 SENSOR_ATTR(temp10_alarm, 0444, show_temp_alarm, NULL, 9),
615 SENSOR_ATTR(temp11_input, 0444, show_temp_value, NULL, 10),
616 SENSOR_ATTR(temp11_max, 0644, show_temp_max, store_temp_max, 10),
617 SENSOR_ATTR(temp11_fault, 0444, show_temp_fault, NULL, 10),
618 SENSOR_ATTR(temp11_alarm, 0444, show_temp_alarm, NULL, 10),
553}; 619};
554 620
555static struct sensor_device_attribute fschmd_fan_attr[] = { 621static struct sensor_device_attribute fschmd_fan_attr[] = {
@@ -589,6 +655,12 @@ static struct sensor_device_attribute fschmd_fan_attr[] = {
589 SENSOR_ATTR(fan6_fault, 0444, show_fan_fault, NULL, 5), 655 SENSOR_ATTR(fan6_fault, 0444, show_fan_fault, NULL, 5),
590 SENSOR_ATTR(pwm6_auto_point1_pwm, 0644, show_pwm_auto_point1_pwm, 656 SENSOR_ATTR(pwm6_auto_point1_pwm, 0644, show_pwm_auto_point1_pwm,
591 store_pwm_auto_point1_pwm, 5), 657 store_pwm_auto_point1_pwm, 5),
658 SENSOR_ATTR(fan7_input, 0444, show_fan_value, NULL, 6),
659 SENSOR_ATTR(fan7_div, 0644, show_fan_div, store_fan_div, 6),
660 SENSOR_ATTR(fan7_alarm, 0444, show_fan_alarm, NULL, 6),
661 SENSOR_ATTR(fan7_fault, 0444, show_fan_fault, NULL, 6),
662 SENSOR_ATTR(pwm7_auto_point1_pwm, 0644, show_pwm_auto_point1_pwm,
663 store_pwm_auto_point1_pwm, 6),
592}; 664};
593 665
594 666
@@ -624,10 +696,11 @@ static int watchdog_set_timeout(struct fschmd_data *data, int timeout)
624 data->watchdog_preset = DIV_ROUND_UP(timeout, resolution); 696 data->watchdog_preset = DIV_ROUND_UP(timeout, resolution);
625 697
626 /* Write new timeout value */ 698 /* Write new timeout value */
627 i2c_smbus_write_byte_data(data->client, FSCHMD_REG_WDOG_PRESET, 699 i2c_smbus_write_byte_data(data->client,
628 data->watchdog_preset); 700 FSCHMD_REG_WDOG_PRESET[data->kind], data->watchdog_preset);
629 /* Write new control register, do not trigger! */ 701 /* Write new control register, do not trigger! */
630 i2c_smbus_write_byte_data(data->client, FSCHMD_REG_WDOG_CONTROL, 702 i2c_smbus_write_byte_data(data->client,
703 FSCHMD_REG_WDOG_CONTROL[data->kind],
631 data->watchdog_control & ~FSCHMD_WDOG_CONTROL_TRIGGER); 704 data->watchdog_control & ~FSCHMD_WDOG_CONTROL_TRIGGER);
632 705
633 ret = data->watchdog_preset * resolution; 706 ret = data->watchdog_preset * resolution;
@@ -662,8 +735,9 @@ static int watchdog_trigger(struct fschmd_data *data)
662 } 735 }
663 736
664 data->watchdog_control |= FSCHMD_WDOG_CONTROL_TRIGGER; 737 data->watchdog_control |= FSCHMD_WDOG_CONTROL_TRIGGER;
665 i2c_smbus_write_byte_data(data->client, FSCHMD_REG_WDOG_CONTROL, 738 i2c_smbus_write_byte_data(data->client,
666 data->watchdog_control); 739 FSCHMD_REG_WDOG_CONTROL[data->kind],
740 data->watchdog_control);
667leave: 741leave:
668 mutex_unlock(&data->watchdog_lock); 742 mutex_unlock(&data->watchdog_lock);
669 return ret; 743 return ret;
@@ -682,7 +756,8 @@ static int watchdog_stop(struct fschmd_data *data)
682 data->watchdog_control &= ~FSCHMD_WDOG_CONTROL_STARTED; 756 data->watchdog_control &= ~FSCHMD_WDOG_CONTROL_STARTED;
683 /* Don't store the stop flag in our watchdog control register copy, as 757 /* Don't store the stop flag in our watchdog control register copy, as
684 its a write only bit (read always returns 0) */ 758 its a write only bit (read always returns 0) */
685 i2c_smbus_write_byte_data(data->client, FSCHMD_REG_WDOG_CONTROL, 759 i2c_smbus_write_byte_data(data->client,
760 FSCHMD_REG_WDOG_CONTROL[data->kind],
686 data->watchdog_control | FSCHMD_WDOG_CONTROL_STOP); 761 data->watchdog_control | FSCHMD_WDOG_CONTROL_STOP);
687leave: 762leave:
688 mutex_unlock(&data->watchdog_lock); 763 mutex_unlock(&data->watchdog_lock);
@@ -856,7 +931,7 @@ static struct file_operations watchdog_fops = {
856 931
857/* DMI decode routine to read voltage scaling factors from special DMI tables, 932/* DMI decode routine to read voltage scaling factors from special DMI tables,
858 which are available on FSC machines with an fscher or later chip. */ 933 which are available on FSC machines with an fscher or later chip. */
859static void fschmd_dmi_decode(const struct dmi_header *header) 934static void fschmd_dmi_decode(const struct dmi_header *header, void *dummy)
860{ 935{
861 int i, mult[3] = { 0 }, offset[3] = { 0 }, vref = 0, found = 0; 936 int i, mult[3] = { 0 }, offset[3] = { 0 }, vref = 0, found = 0;
862 937
@@ -912,6 +987,15 @@ static void fschmd_dmi_decode(const struct dmi_header *header)
912 dmi_mult[i] = mult[i] * 10; 987 dmi_mult[i] = mult[i] * 10;
913 dmi_offset[i] = offset[i] * 10; 988 dmi_offset[i] = offset[i] * 10;
914 } 989 }
990 /* According to the docs there should be separate dmi entries
991 for the mult's and offsets of in3-5 of the syl, but on
992 my test machine these are not present */
993 dmi_mult[3] = dmi_mult[2];
994 dmi_mult[4] = dmi_mult[1];
995 dmi_mult[5] = dmi_mult[2];
996 dmi_offset[3] = dmi_offset[2];
997 dmi_offset[4] = dmi_offset[1];
998 dmi_offset[5] = dmi_offset[2];
915 dmi_vref = vref; 999 dmi_vref = vref;
916 } 1000 }
917} 1001}
@@ -920,8 +1004,6 @@ static int fschmd_detect(struct i2c_client *client, int kind,
920 struct i2c_board_info *info) 1004 struct i2c_board_info *info)
921{ 1005{
922 struct i2c_adapter *adapter = client->adapter; 1006 struct i2c_adapter *adapter = client->adapter;
923 const char * const client_names[5] = { "fscpos", "fscher", "fscscy",
924 "fschrc", "fschmd" };
925 1007
926 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 1008 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
927 return -ENODEV; 1009 return -ENODEV;
@@ -948,11 +1030,15 @@ static int fschmd_detect(struct i2c_client *client, int kind,
948 kind = fschrc; 1030 kind = fschrc;
949 else if (!strcmp(id, "HMD")) 1031 else if (!strcmp(id, "HMD"))
950 kind = fschmd; 1032 kind = fschmd;
1033 else if (!strcmp(id, "HDS"))
1034 kind = fschds;
1035 else if (!strcmp(id, "SYL"))
1036 kind = fscsyl;
951 else 1037 else
952 return -ENODEV; 1038 return -ENODEV;
953 } 1039 }
954 1040
955 strlcpy(info->type, client_names[kind - 1], I2C_NAME_SIZE); 1041 strlcpy(info->type, fschmd_id[kind - 1].name, I2C_NAME_SIZE);
956 1042
957 return 0; 1043 return 0;
958} 1044}
@@ -961,8 +1047,8 @@ static int fschmd_probe(struct i2c_client *client,
961 const struct i2c_device_id *id) 1047 const struct i2c_device_id *id)
962{ 1048{
963 struct fschmd_data *data; 1049 struct fschmd_data *data;
964 const char * const names[5] = { "Poseidon", "Hermes", "Scylla", 1050 const char * const names[7] = { "Poseidon", "Hermes", "Scylla",
965 "Heracles", "Heimdall" }; 1051 "Heracles", "Heimdall", "Hades", "Syleus" };
966 const int watchdog_minors[] = { WATCHDOG_MINOR, 212, 213, 214, 215 }; 1052 const int watchdog_minors[] = { WATCHDOG_MINOR, 212, 213, 214, 215 };
967 int i, err; 1053 int i, err;
968 enum chips kind = id->driver_data; 1054 enum chips kind = id->driver_data;
@@ -991,7 +1077,7 @@ static int fschmd_probe(struct i2c_client *client,
991 1077
992 /* Read the special DMI table for fscher and newer chips */ 1078 /* Read the special DMI table for fscher and newer chips */
993 if ((kind == fscher || kind >= fschrc) && dmi_vref == -1) { 1079 if ((kind == fscher || kind >= fschrc) && dmi_vref == -1) {
994 dmi_walk(fschmd_dmi_decode); 1080 dmi_walk(fschmd_dmi_decode, NULL);
995 if (dmi_vref == -1) { 1081 if (dmi_vref == -1) {
996 dev_warn(&client->dev, 1082 dev_warn(&client->dev,
997 "Couldn't get voltage scaling factors from " 1083 "Couldn't get voltage scaling factors from "
@@ -1000,21 +1086,25 @@ static int fschmd_probe(struct i2c_client *client,
1000 } 1086 }
1001 } 1087 }
1002 1088
1089 /* i2c kind goes from 1-6, we want from 0-5 to address arrays */
1090 data->kind = kind - 1;
1091
1003 /* Read in some never changing registers */ 1092 /* Read in some never changing registers */
1004 data->revision = i2c_smbus_read_byte_data(client, FSCHMD_REG_REVISION); 1093 data->revision = i2c_smbus_read_byte_data(client, FSCHMD_REG_REVISION);
1005 data->global_control = i2c_smbus_read_byte_data(client, 1094 data->global_control = i2c_smbus_read_byte_data(client,
1006 FSCHMD_REG_CONTROL); 1095 FSCHMD_REG_CONTROL);
1007 data->watchdog_control = i2c_smbus_read_byte_data(client, 1096 data->watchdog_control = i2c_smbus_read_byte_data(client,
1008 FSCHMD_REG_WDOG_CONTROL); 1097 FSCHMD_REG_WDOG_CONTROL[data->kind]);
1009 data->watchdog_state = i2c_smbus_read_byte_data(client, 1098 data->watchdog_state = i2c_smbus_read_byte_data(client,
1010 FSCHMD_REG_WDOG_STATE); 1099 FSCHMD_REG_WDOG_STATE[data->kind]);
1011 data->watchdog_preset = i2c_smbus_read_byte_data(client, 1100 data->watchdog_preset = i2c_smbus_read_byte_data(client,
1012 FSCHMD_REG_WDOG_PRESET); 1101 FSCHMD_REG_WDOG_PRESET[data->kind]);
1013 1102
1014 /* i2c kind goes from 1-5, we want from 0-4 to address arrays */ 1103 err = device_create_file(&client->dev, &dev_attr_alert_led);
1015 data->kind = kind - 1; 1104 if (err)
1105 goto exit_detach;
1016 1106
1017 for (i = 0; i < ARRAY_SIZE(fschmd_attr); i++) { 1107 for (i = 0; i < FSCHMD_NO_VOLT_SENSORS[data->kind]; i++) {
1018 err = device_create_file(&client->dev, 1108 err = device_create_file(&client->dev,
1019 &fschmd_attr[i].dev_attr); 1109 &fschmd_attr[i].dev_attr);
1020 if (err) 1110 if (err)
@@ -1027,6 +1117,16 @@ static int fschmd_probe(struct i2c_client *client,
1027 show_temp_max) 1117 show_temp_max)
1028 continue; 1118 continue;
1029 1119
1120 if (kind == fscsyl) {
1121 if (i % 4 == 0)
1122 data->temp_status[i / 4] =
1123 i2c_smbus_read_byte_data(client,
1124 FSCHMD_REG_TEMP_STATE
1125 [data->kind][i / 4]);
1126 if (data->temp_status[i / 4] & FSCHMD_TEMP_DISABLED)
1127 continue;
1128 }
1129
1030 err = device_create_file(&client->dev, 1130 err = device_create_file(&client->dev,
1031 &fschmd_temp_attr[i].dev_attr); 1131 &fschmd_temp_attr[i].dev_attr);
1032 if (err) 1132 if (err)
@@ -1040,6 +1140,16 @@ static int fschmd_probe(struct i2c_client *client,
1040 "pwm3_auto_point1_pwm")) 1140 "pwm3_auto_point1_pwm"))
1041 continue; 1141 continue;
1042 1142
1143 if (kind == fscsyl) {
1144 if (i % 5 == 0)
1145 data->fan_status[i / 5] =
1146 i2c_smbus_read_byte_data(client,
1147 FSCHMD_REG_FAN_STATE
1148 [data->kind][i / 5]);
1149 if (data->fan_status[i / 5] & FSCHMD_FAN_DISABLED)
1150 continue;
1151 }
1152
1043 err = device_create_file(&client->dev, 1153 err = device_create_file(&client->dev,
1044 &fschmd_fan_attr[i].dev_attr); 1154 &fschmd_fan_attr[i].dev_attr);
1045 if (err) 1155 if (err)
@@ -1126,7 +1236,8 @@ static int fschmd_remove(struct i2c_client *client)
1126 if (data->hwmon_dev) 1236 if (data->hwmon_dev)
1127 hwmon_device_unregister(data->hwmon_dev); 1237 hwmon_device_unregister(data->hwmon_dev);
1128 1238
1129 for (i = 0; i < ARRAY_SIZE(fschmd_attr); i++) 1239 device_remove_file(&client->dev, &dev_attr_alert_led);
1240 for (i = 0; i < (FSCHMD_NO_VOLT_SENSORS[data->kind]); i++)
1130 device_remove_file(&client->dev, &fschmd_attr[i].dev_attr); 1241 device_remove_file(&client->dev, &fschmd_attr[i].dev_attr);
1131 for (i = 0; i < (FSCHMD_NO_TEMP_SENSORS[data->kind] * 4); i++) 1242 for (i = 0; i < (FSCHMD_NO_TEMP_SENSORS[data->kind] * 4); i++)
1132 device_remove_file(&client->dev, 1243 device_remove_file(&client->dev,
@@ -1171,7 +1282,7 @@ static struct fschmd_data *fschmd_update_device(struct device *dev)
1171 data->temp_act[i] < data->temp_max[i]) 1282 data->temp_act[i] < data->temp_max[i])
1172 i2c_smbus_write_byte_data(client, 1283 i2c_smbus_write_byte_data(client,
1173 FSCHMD_REG_TEMP_STATE[data->kind][i], 1284 FSCHMD_REG_TEMP_STATE[data->kind][i],
1174 FSCHMD_TEMP_ALERT); 1285 data->temp_status[i]);
1175 } 1286 }
1176 1287
1177 for (i = 0; i < FSCHMD_NO_FAN_SENSORS[data->kind]; i++) { 1288 for (i = 0; i < FSCHMD_NO_FAN_SENSORS[data->kind]; i++) {
@@ -1193,12 +1304,12 @@ static struct fschmd_data *fschmd_update_device(struct device *dev)
1193 data->fan_act[i]) 1304 data->fan_act[i])
1194 i2c_smbus_write_byte_data(client, 1305 i2c_smbus_write_byte_data(client,
1195 FSCHMD_REG_FAN_STATE[data->kind][i], 1306 FSCHMD_REG_FAN_STATE[data->kind][i],
1196 FSCHMD_FAN_ALARM); 1307 data->fan_status[i]);
1197 } 1308 }
1198 1309
1199 for (i = 0; i < 3; i++) 1310 for (i = 0; i < FSCHMD_NO_VOLT_SENSORS[data->kind]; i++)
1200 data->volt[i] = i2c_smbus_read_byte_data(client, 1311 data->volt[i] = i2c_smbus_read_byte_data(client,
1201 FSCHMD_REG_VOLT[i]); 1312 FSCHMD_REG_VOLT[data->kind][i]);
1202 1313
1203 data->last_updated = jiffies; 1314 data->last_updated = jiffies;
1204 data->valid = 1; 1315 data->valid = 1;
@@ -1220,8 +1331,8 @@ static void __exit fschmd_exit(void)
1220} 1331}
1221 1332
1222MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>"); 1333MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
1223MODULE_DESCRIPTION("FSC Poseidon, Hermes, Scylla, Heracles and " 1334MODULE_DESCRIPTION("FSC Poseidon, Hermes, Scylla, Heracles, Heimdall, Hades "
1224 "Heimdall driver"); 1335 "and Syleus driver");
1225MODULE_LICENSE("GPL"); 1336MODULE_LICENSE("GPL");
1226 1337
1227module_init(fschmd_init); 1338module_init(fschmd_init);
diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c
index a4d92d246d52..d3612a1f1981 100644
--- a/drivers/hwmon/hdaps.c
+++ b/drivers/hwmon/hdaps.c
@@ -65,6 +65,10 @@
65#define HDAPS_INPUT_FUZZ 4 /* input event threshold */ 65#define HDAPS_INPUT_FUZZ 4 /* input event threshold */
66#define HDAPS_INPUT_FLAT 4 66#define HDAPS_INPUT_FLAT 4
67 67
68#define HDAPS_X_AXIS (1 << 0)
69#define HDAPS_Y_AXIS (1 << 1)
70#define HDAPS_BOTH_AXES (HDAPS_X_AXIS | HDAPS_Y_AXIS)
71
68static struct platform_device *pdev; 72static struct platform_device *pdev;
69static struct input_polled_dev *hdaps_idev; 73static struct input_polled_dev *hdaps_idev;
70static unsigned int hdaps_invert; 74static unsigned int hdaps_invert;
@@ -182,11 +186,11 @@ static int __hdaps_read_pair(unsigned int port1, unsigned int port2,
182 km_activity = inb(HDAPS_PORT_KMACT); 186 km_activity = inb(HDAPS_PORT_KMACT);
183 __device_complete(); 187 __device_complete();
184 188
185 /* if hdaps_invert is set, negate the two values */ 189 /* hdaps_invert is a bitvector to negate the axes */
186 if (hdaps_invert) { 190 if (hdaps_invert & HDAPS_X_AXIS)
187 *x = -*x; 191 *x = -*x;
192 if (hdaps_invert & HDAPS_Y_AXIS)
188 *y = -*y; 193 *y = -*y;
189 }
190 194
191 return 0; 195 return 0;
192} 196}
@@ -436,7 +440,8 @@ static ssize_t hdaps_invert_store(struct device *dev,
436{ 440{
437 int invert; 441 int invert;
438 442
439 if (sscanf(buf, "%d", &invert) != 1 || (invert != 1 && invert != 0)) 443 if (sscanf(buf, "%d", &invert) != 1 ||
444 invert < 0 || invert > HDAPS_BOTH_AXES)
440 return -EINVAL; 445 return -EINVAL;
441 446
442 hdaps_invert = invert; 447 hdaps_invert = invert;
@@ -483,56 +488,52 @@ static int __init hdaps_dmi_match(const struct dmi_system_id *id)
483/* hdaps_dmi_match_invert - found an inverted match. */ 488/* hdaps_dmi_match_invert - found an inverted match. */
484static int __init hdaps_dmi_match_invert(const struct dmi_system_id *id) 489static int __init hdaps_dmi_match_invert(const struct dmi_system_id *id)
485{ 490{
486 hdaps_invert = 1; 491 hdaps_invert = (unsigned long)id->driver_data;
487 printk(KERN_INFO "hdaps: inverting axis readings.\n"); 492 printk(KERN_INFO "hdaps: inverting axis (%u) readings.\n",
493 hdaps_invert);
488 return hdaps_dmi_match(id); 494 return hdaps_dmi_match(id);
489} 495}
490 496
491#define HDAPS_DMI_MATCH_NORMAL(vendor, model) { \ 497#define HDAPS_DMI_MATCH_INVERT(vendor, model, axes) { \
492 .ident = vendor " " model, \
493 .callback = hdaps_dmi_match, \
494 .matches = { \
495 DMI_MATCH(DMI_BOARD_VENDOR, vendor), \
496 DMI_MATCH(DMI_PRODUCT_VERSION, model) \
497 } \
498}
499
500#define HDAPS_DMI_MATCH_INVERT(vendor, model) { \
501 .ident = vendor " " model, \ 498 .ident = vendor " " model, \
502 .callback = hdaps_dmi_match_invert, \ 499 .callback = hdaps_dmi_match_invert, \
500 .driver_data = (void *)axes, \
503 .matches = { \ 501 .matches = { \
504 DMI_MATCH(DMI_BOARD_VENDOR, vendor), \ 502 DMI_MATCH(DMI_BOARD_VENDOR, vendor), \
505 DMI_MATCH(DMI_PRODUCT_VERSION, model) \ 503 DMI_MATCH(DMI_PRODUCT_VERSION, model) \
506 } \ 504 } \
507} 505}
508 506
507#define HDAPS_DMI_MATCH_NORMAL(vendor, model) \
508 HDAPS_DMI_MATCH_INVERT(vendor, model, 0)
509
509/* Note that HDAPS_DMI_MATCH_NORMAL("ThinkPad T42") would match 510/* Note that HDAPS_DMI_MATCH_NORMAL("ThinkPad T42") would match
510 "ThinkPad T42p", so the order of the entries matters. 511 "ThinkPad T42p", so the order of the entries matters.
511 If your ThinkPad is not recognized, please update to latest 512 If your ThinkPad is not recognized, please update to latest
512 BIOS. This is especially the case for some R52 ThinkPads. */ 513 BIOS. This is especially the case for some R52 ThinkPads. */
513static struct dmi_system_id __initdata hdaps_whitelist[] = { 514static struct dmi_system_id __initdata hdaps_whitelist[] = {
514 HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad R50p"), 515 HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad R50p", HDAPS_BOTH_AXES),
515 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R50"), 516 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R50"),
516 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R51"), 517 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R51"),
517 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R52"), 518 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad R52"),
518 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad R61i"), 519 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad R61i", HDAPS_BOTH_AXES),
519 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad R61"), 520 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad R61", HDAPS_BOTH_AXES),
520 HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad T41p"), 521 HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad T41p", HDAPS_BOTH_AXES),
521 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T41"), 522 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T41"),
522 HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad T42p"), 523 HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad T42p", HDAPS_BOTH_AXES),
523 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T42"), 524 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T42"),
524 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T43"), 525 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad T43"),
525 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad T60"), 526 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad T60", HDAPS_BOTH_AXES),
526 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad T61p"), 527 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad T61p", HDAPS_BOTH_AXES),
527 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad T61"), 528 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad T61", HDAPS_BOTH_AXES),
528 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad X40"), 529 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad X40"),
529 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad X41"), 530 HDAPS_DMI_MATCH_INVERT("IBM", "ThinkPad X41", HDAPS_Y_AXIS),
530 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad X60"), 531 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad X60", HDAPS_BOTH_AXES),
531 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad X61s"), 532 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad X61s", HDAPS_BOTH_AXES),
532 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad X61"), 533 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad X61", HDAPS_BOTH_AXES),
533 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad Z60m"), 534 HDAPS_DMI_MATCH_NORMAL("IBM", "ThinkPad Z60m"),
534 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad Z61m"), 535 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad Z61m", HDAPS_BOTH_AXES),
535 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad Z61p"), 536 HDAPS_DMI_MATCH_INVERT("LENOVO", "ThinkPad Z61p", HDAPS_BOTH_AXES),
536 { .ident = NULL } 537 { .ident = NULL }
537}; 538};
538 539
@@ -627,8 +628,9 @@ static void __exit hdaps_exit(void)
627module_init(hdaps_init); 628module_init(hdaps_init);
628module_exit(hdaps_exit); 629module_exit(hdaps_exit);
629 630
630module_param_named(invert, hdaps_invert, bool, 0); 631module_param_named(invert, hdaps_invert, int, 0);
631MODULE_PARM_DESC(invert, "invert data along each axis"); 632MODULE_PARM_DESC(invert, "invert data along each axis. 1 invert x-axis, "
633 "2 invert y-axis, 3 invert both axes.");
632 634
633MODULE_AUTHOR("Robert Love"); 635MODULE_AUTHOR("Robert Love");
634MODULE_DESCRIPTION("IBM Hard Drive Active Protection System (HDAPS) driver"); 636MODULE_DESCRIPTION("IBM Hard Drive Active Protection System (HDAPS) driver");
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/hwmon/pcf8591.c
index 16ce3e193776..1d7ffebd679d 100644
--- a/drivers/i2c/chips/pcf8591.c
+++ b/drivers/hwmon/pcf8591.c
@@ -1,6 +1,6 @@
1/* 1/*
2 Copyright (C) 2001-2004 Aurelien Jarno <aurelien@aurel32.net> 2 Copyright (C) 2001-2004 Aurelien Jarno <aurelien@aurel32.net>
3 Ported to Linux 2.6 by Aurelien Jarno <aurelien@aurel32.net> with 3 Ported to Linux 2.6 by Aurelien Jarno <aurelien@aurel32.net> with
4 the help of Jean Delvare <khali@linux-fr.org> 4 the help of Jean Delvare <khali@linux-fr.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
@@ -41,13 +41,13 @@ MODULE_PARM_DESC(input_mode,
41 " 3 = two differential inputs\n"); 41 " 3 = two differential inputs\n");
42 42
43/* The PCF8591 control byte 43/* The PCF8591 control byte
44 7 6 5 4 3 2 1 0 44 7 6 5 4 3 2 1 0
45 | 0 |AOEF| AIP | 0 |AINC| AICH | */ 45 | 0 |AOEF| AIP | 0 |AINC| AICH | */
46 46
47/* Analog Output Enable Flag (analog output active if 1) */ 47/* Analog Output Enable Flag (analog output active if 1) */
48#define PCF8591_CONTROL_AOEF 0x40 48#define PCF8591_CONTROL_AOEF 0x40
49 49
50/* Analog Input Programming 50/* Analog Input Programming
51 0x00 = four single ended inputs 51 0x00 = four single ended inputs
52 0x10 = three differential inputs 52 0x10 = three differential inputs
53 0x20 = single ended and differential mixed 53 0x20 = single ended and differential mixed
@@ -58,7 +58,7 @@ MODULE_PARM_DESC(input_mode,
58#define PCF8591_CONTROL_AINC 0x04 58#define PCF8591_CONTROL_AINC 0x04
59 59
60/* Channel selection 60/* Channel selection
61 0x00 = channel 0 61 0x00 = channel 0
62 0x01 = channel 1 62 0x01 = channel 1
63 0x02 = channel 2 63 0x02 = channel 2
64 0x03 = channel 3 */ 64 0x03 = channel 3 */
@@ -114,7 +114,7 @@ static ssize_t set_out0_output(struct device *dev, struct device_attribute *attr
114 return -EINVAL; 114 return -EINVAL;
115} 115}
116 116
117static DEVICE_ATTR(out0_output, S_IWUSR | S_IRUGO, 117static DEVICE_ATTR(out0_output, S_IWUSR | S_IRUGO,
118 show_out0_ouput, set_out0_output); 118 show_out0_ouput, set_out0_output);
119 119
120static ssize_t show_out0_enable(struct device *dev, struct device_attribute *attr, char *buf) 120static ssize_t show_out0_enable(struct device *dev, struct device_attribute *attr, char *buf)
@@ -139,7 +139,7 @@ static ssize_t set_out0_enable(struct device *dev, struct device_attribute *attr
139 return count; 139 return count;
140} 140}
141 141
142static DEVICE_ATTR(out0_enable, S_IWUSR | S_IRUGO, 142static DEVICE_ATTR(out0_enable, S_IWUSR | S_IRUGO,
143 show_out0_enable, set_out0_enable); 143 show_out0_enable, set_out0_enable);
144 144
145static struct attribute *pcf8591_attributes[] = { 145static struct attribute *pcf8591_attributes[] = {
@@ -196,7 +196,7 @@ static int pcf8591_probe(struct i2c_client *client,
196 err = -ENOMEM; 196 err = -ENOMEM;
197 goto exit; 197 goto exit;
198 } 198 }
199 199
200 i2c_set_clientdata(client, data); 200 i2c_set_clientdata(client, data);
201 mutex_init(&data->update_lock); 201 mutex_init(&data->update_lock);
202 202
@@ -249,8 +249,8 @@ static void pcf8591_init_client(struct i2c_client *client)
249 data->aout = PCF8591_INIT_AOUT; 249 data->aout = PCF8591_INIT_AOUT;
250 250
251 i2c_smbus_write_byte_data(client, data->control, data->aout); 251 i2c_smbus_write_byte_data(client, data->control, data->aout);
252 252
253 /* The first byte transmitted contains the conversion code of the 253 /* The first byte transmitted contains the conversion code of the
254 previous read cycle. FLUSH IT! */ 254 previous read cycle. FLUSH IT! */
255 i2c_smbus_read_byte(client); 255 i2c_smbus_read_byte(client);
256} 256}
@@ -267,8 +267,8 @@ static int pcf8591_read_channel(struct device *dev, int channel)
267 data->control = (data->control & ~PCF8591_CONTROL_AICH_MASK) 267 data->control = (data->control & ~PCF8591_CONTROL_AICH_MASK)
268 | channel; 268 | channel;
269 i2c_smbus_write_byte(client, data->control); 269 i2c_smbus_write_byte(client, data->control);
270 270
271 /* The first byte transmitted contains the conversion code of 271 /* The first byte transmitted contains the conversion code of
272 the previous read cycle. FLUSH IT! */ 272 the previous read cycle. FLUSH IT! */
273 i2c_smbus_read_byte(client); 273 i2c_smbus_read_byte(client);
274 } 274 }
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index feae743ba991..e64b42058b21 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -36,6 +36,7 @@
36 w83627ehf 10 5 4 3 0x8850 0x88 0x5ca3 36 w83627ehf 10 5 4 3 0x8850 0x88 0x5ca3
37 0x8860 0xa1 37 0x8860 0xa1
38 w83627dhg 9 5 4 3 0xa020 0xc1 0x5ca3 38 w83627dhg 9 5 4 3 0xa020 0xc1 0x5ca3
39 w83667hg 9 5 3 3 0xa510 0xc1 0x5ca3
39*/ 40*/
40 41
41#include <linux/module.h> 42#include <linux/module.h>
@@ -52,12 +53,13 @@
52#include <asm/io.h> 53#include <asm/io.h>
53#include "lm75.h" 54#include "lm75.h"
54 55
55enum kinds { w83627ehf, w83627dhg }; 56enum kinds { w83627ehf, w83627dhg, w83667hg };
56 57
57/* used to set data->name = w83627ehf_device_names[data->sio_kind] */ 58/* used to set data->name = w83627ehf_device_names[data->sio_kind] */
58static const char * w83627ehf_device_names[] = { 59static const char * w83627ehf_device_names[] = {
59 "w83627ehf", 60 "w83627ehf",
60 "w83627dhg", 61 "w83627dhg",
62 "w83667hg",
61}; 63};
62 64
63static unsigned short force_id; 65static unsigned short force_id;
@@ -71,6 +73,7 @@ MODULE_PARM_DESC(force_id, "Override the detected device ID");
71 */ 73 */
72 74
73#define W83627EHF_LD_HWM 0x0b 75#define W83627EHF_LD_HWM 0x0b
76#define W83667HG_LD_VID 0x0d
74 77
75#define SIO_REG_LDSEL 0x07 /* Logical device select */ 78#define SIO_REG_LDSEL 0x07 /* Logical device select */
76#define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */ 79#define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */
@@ -83,6 +86,7 @@ MODULE_PARM_DESC(force_id, "Override the detected device ID");
83#define SIO_W83627EHF_ID 0x8850 86#define SIO_W83627EHF_ID 0x8850
84#define SIO_W83627EHG_ID 0x8860 87#define SIO_W83627EHG_ID 0x8860
85#define SIO_W83627DHG_ID 0xa020 88#define SIO_W83627DHG_ID 0xa020
89#define SIO_W83667HG_ID 0xa510
86#define SIO_ID_MASK 0xFFF0 90#define SIO_ID_MASK 0xFFF0
87 91
88static inline void 92static inline void
@@ -289,6 +293,7 @@ struct w83627ehf_data {
289 u8 pwm_mode[4]; /* 0->DC variable voltage, 1->PWM variable duty cycle */ 293 u8 pwm_mode[4]; /* 0->DC variable voltage, 1->PWM variable duty cycle */
290 u8 pwm_enable[4]; /* 1->manual 294 u8 pwm_enable[4]; /* 1->manual
291 2->thermal cruise (also called SmartFan I) */ 295 2->thermal cruise (also called SmartFan I) */
296 u8 pwm_num; /* number of pwm */
292 u8 pwm[4]; 297 u8 pwm[4];
293 u8 target_temp[4]; 298 u8 target_temp[4];
294 u8 tolerance[4]; 299 u8 tolerance[4];
@@ -298,6 +303,9 @@ struct w83627ehf_data {
298 303
299 u8 vid; 304 u8 vid;
300 u8 vrm; 305 u8 vrm;
306
307 u8 temp3_disable;
308 u8 in6_skip;
301}; 309};
302 310
303struct w83627ehf_sio_data { 311struct w83627ehf_sio_data {
@@ -866,25 +874,37 @@ show_temp_type(struct device *dev, struct device_attribute *attr, char *buf)
866 return sprintf(buf, "%d\n", (int)data->temp_type[nr]); 874 return sprintf(buf, "%d\n", (int)data->temp_type[nr]);
867} 875}
868 876
869static struct sensor_device_attribute sda_temp[] = { 877static struct sensor_device_attribute sda_temp_input[] = {
870 SENSOR_ATTR(temp1_input, S_IRUGO, show_temp1, NULL, 0), 878 SENSOR_ATTR(temp1_input, S_IRUGO, show_temp1, NULL, 0),
871 SENSOR_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 0), 879 SENSOR_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 0),
872 SENSOR_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 1), 880 SENSOR_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 1),
881};
882
883static struct sensor_device_attribute sda_temp_max[] = {
873 SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp1_max, 884 SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp1_max,
874 store_temp1_max, 0), 885 store_temp1_max, 0),
875 SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR, show_temp_max, 886 SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR, show_temp_max,
876 store_temp_max, 0), 887 store_temp_max, 0),
877 SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR, show_temp_max, 888 SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR, show_temp_max,
878 store_temp_max, 1), 889 store_temp_max, 1),
890};
891
892static struct sensor_device_attribute sda_temp_max_hyst[] = {
879 SENSOR_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1_max_hyst, 893 SENSOR_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1_max_hyst,
880 store_temp1_max_hyst, 0), 894 store_temp1_max_hyst, 0),
881 SENSOR_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR, show_temp_max_hyst, 895 SENSOR_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR, show_temp_max_hyst,
882 store_temp_max_hyst, 0), 896 store_temp_max_hyst, 0),
883 SENSOR_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR, show_temp_max_hyst, 897 SENSOR_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR, show_temp_max_hyst,
884 store_temp_max_hyst, 1), 898 store_temp_max_hyst, 1),
899};
900
901static struct sensor_device_attribute sda_temp_alarm[] = {
885 SENSOR_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4), 902 SENSOR_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4),
886 SENSOR_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5), 903 SENSOR_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5),
887 SENSOR_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13), 904 SENSOR_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13),
905};
906
907static struct sensor_device_attribute sda_temp_type[] = {
888 SENSOR_ATTR(temp1_type, S_IRUGO, show_temp_type, NULL, 0), 908 SENSOR_ATTR(temp1_type, S_IRUGO, show_temp_type, NULL, 0),
889 SENSOR_ATTR(temp2_type, S_IRUGO, show_temp_type, NULL, 1), 909 SENSOR_ATTR(temp2_type, S_IRUGO, show_temp_type, NULL, 1),
890 SENSOR_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2), 910 SENSOR_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2),
@@ -1181,6 +1201,8 @@ static void w83627ehf_device_remove_files(struct device *dev)
1181 for (i = 0; i < ARRAY_SIZE(sda_sf3_arrays_fan4); i++) 1201 for (i = 0; i < ARRAY_SIZE(sda_sf3_arrays_fan4); i++)
1182 device_remove_file(dev, &sda_sf3_arrays_fan4[i].dev_attr); 1202 device_remove_file(dev, &sda_sf3_arrays_fan4[i].dev_attr);
1183 for (i = 0; i < data->in_num; i++) { 1203 for (i = 0; i < data->in_num; i++) {
1204 if ((i == 6) && data->in6_skip)
1205 continue;
1184 device_remove_file(dev, &sda_in_input[i].dev_attr); 1206 device_remove_file(dev, &sda_in_input[i].dev_attr);
1185 device_remove_file(dev, &sda_in_alarm[i].dev_attr); 1207 device_remove_file(dev, &sda_in_alarm[i].dev_attr);
1186 device_remove_file(dev, &sda_in_min[i].dev_attr); 1208 device_remove_file(dev, &sda_in_min[i].dev_attr);
@@ -1192,15 +1214,22 @@ static void w83627ehf_device_remove_files(struct device *dev)
1192 device_remove_file(dev, &sda_fan_div[i].dev_attr); 1214 device_remove_file(dev, &sda_fan_div[i].dev_attr);
1193 device_remove_file(dev, &sda_fan_min[i].dev_attr); 1215 device_remove_file(dev, &sda_fan_min[i].dev_attr);
1194 } 1216 }
1195 for (i = 0; i < 4; i++) { 1217 for (i = 0; i < data->pwm_num; i++) {
1196 device_remove_file(dev, &sda_pwm[i].dev_attr); 1218 device_remove_file(dev, &sda_pwm[i].dev_attr);
1197 device_remove_file(dev, &sda_pwm_mode[i].dev_attr); 1219 device_remove_file(dev, &sda_pwm_mode[i].dev_attr);
1198 device_remove_file(dev, &sda_pwm_enable[i].dev_attr); 1220 device_remove_file(dev, &sda_pwm_enable[i].dev_attr);
1199 device_remove_file(dev, &sda_target_temp[i].dev_attr); 1221 device_remove_file(dev, &sda_target_temp[i].dev_attr);
1200 device_remove_file(dev, &sda_tolerance[i].dev_attr); 1222 device_remove_file(dev, &sda_tolerance[i].dev_attr);
1201 } 1223 }
1202 for (i = 0; i < ARRAY_SIZE(sda_temp); i++) 1224 for (i = 0; i < 3; i++) {
1203 device_remove_file(dev, &sda_temp[i].dev_attr); 1225 if ((i == 2) && data->temp3_disable)
1226 continue;
1227 device_remove_file(dev, &sda_temp_input[i].dev_attr);
1228 device_remove_file(dev, &sda_temp_max[i].dev_attr);
1229 device_remove_file(dev, &sda_temp_max_hyst[i].dev_attr);
1230 device_remove_file(dev, &sda_temp_alarm[i].dev_attr);
1231 device_remove_file(dev, &sda_temp_type[i].dev_attr);
1232 }
1204 1233
1205 device_remove_file(dev, &dev_attr_name); 1234 device_remove_file(dev, &dev_attr_name);
1206 device_remove_file(dev, &dev_attr_cpu0_vid); 1235 device_remove_file(dev, &dev_attr_cpu0_vid);
@@ -1222,6 +1251,8 @@ static inline void __devinit w83627ehf_init_device(struct w83627ehf_data *data)
1222 for (i = 0; i < 2; i++) { 1251 for (i = 0; i < 2; i++) {
1223 tmp = w83627ehf_read_value(data, 1252 tmp = w83627ehf_read_value(data,
1224 W83627EHF_REG_TEMP_CONFIG[i]); 1253 W83627EHF_REG_TEMP_CONFIG[i]);
1254 if ((i == 1) && data->temp3_disable)
1255 continue;
1225 if (tmp & 0x01) 1256 if (tmp & 0x01)
1226 w83627ehf_write_value(data, 1257 w83627ehf_write_value(data,
1227 W83627EHF_REG_TEMP_CONFIG[i], 1258 W83627EHF_REG_TEMP_CONFIG[i],
@@ -1272,8 +1303,17 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
1272 data->name = w83627ehf_device_names[sio_data->kind]; 1303 data->name = w83627ehf_device_names[sio_data->kind];
1273 platform_set_drvdata(pdev, data); 1304 platform_set_drvdata(pdev, data);
1274 1305
1275 /* 627EHG and 627EHF have 10 voltage inputs; DHG has 9 */ 1306 /* 627EHG and 627EHF have 10 voltage inputs; 627DHG and 667HG have 9 */
1276 data->in_num = (sio_data->kind == w83627dhg) ? 9 : 10; 1307 data->in_num = (sio_data->kind == w83627ehf) ? 10 : 9;
1308 /* 667HG has 3 pwms */
1309 data->pwm_num = (sio_data->kind == w83667hg) ? 3 : 4;
1310
1311 /* Check temp3 configuration bit for 667HG */
1312 if (sio_data->kind == w83667hg) {
1313 data->temp3_disable = w83627ehf_read_value(data,
1314 W83627EHF_REG_TEMP_CONFIG[1]) & 0x01;
1315 data->in6_skip = !data->temp3_disable;
1316 }
1277 1317
1278 /* Initialize the chip */ 1318 /* Initialize the chip */
1279 w83627ehf_init_device(data); 1319 w83627ehf_init_device(data);
@@ -1281,44 +1321,64 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
1281 data->vrm = vid_which_vrm(); 1321 data->vrm = vid_which_vrm();
1282 superio_enter(sio_data->sioreg); 1322 superio_enter(sio_data->sioreg);
1283 /* Read VID value */ 1323 /* Read VID value */
1284 superio_select(sio_data->sioreg, W83627EHF_LD_HWM); 1324 if (sio_data->kind == w83667hg) {
1285 if (superio_inb(sio_data->sioreg, SIO_REG_VID_CTRL) & 0x80) { 1325 /* W83667HG has different pins for VID input and output, so
1286 /* Set VID input sensibility if needed. In theory the BIOS 1326 we can get the VID input values directly at logical device D
1287 should have set it, but in practice it's not always the 1327 0xe3. */
1288 case. We only do it for the W83627EHF/EHG because the 1328 superio_select(sio_data->sioreg, W83667HG_LD_VID);
1289 W83627DHG is more complex in this respect. */ 1329 data->vid = superio_inb(sio_data->sioreg, 0xe3);
1290 if (sio_data->kind == w83627ehf) {
1291 en_vrm10 = superio_inb(sio_data->sioreg,
1292 SIO_REG_EN_VRM10);
1293 if ((en_vrm10 & 0x08) && data->vrm == 90) {
1294 dev_warn(dev, "Setting VID input voltage to "
1295 "TTL\n");
1296 superio_outb(sio_data->sioreg, SIO_REG_EN_VRM10,
1297 en_vrm10 & ~0x08);
1298 } else if (!(en_vrm10 & 0x08) && data->vrm == 100) {
1299 dev_warn(dev, "Setting VID input voltage to "
1300 "VRM10\n");
1301 superio_outb(sio_data->sioreg, SIO_REG_EN_VRM10,
1302 en_vrm10 | 0x08);
1303 }
1304 }
1305
1306 data->vid = superio_inb(sio_data->sioreg, SIO_REG_VID_DATA);
1307 if (sio_data->kind == w83627ehf) /* 6 VID pins only */
1308 data->vid &= 0x3f;
1309
1310 err = device_create_file(dev, &dev_attr_cpu0_vid); 1330 err = device_create_file(dev, &dev_attr_cpu0_vid);
1311 if (err) 1331 if (err)
1312 goto exit_release; 1332 goto exit_release;
1313 } else { 1333 } else {
1314 dev_info(dev, "VID pins in output mode, CPU VID not " 1334 superio_select(sio_data->sioreg, W83627EHF_LD_HWM);
1315 "available\n"); 1335 if (superio_inb(sio_data->sioreg, SIO_REG_VID_CTRL) & 0x80) {
1336 /* Set VID input sensibility if needed. In theory the
1337 BIOS should have set it, but in practice it's not
1338 always the case. We only do it for the W83627EHF/EHG
1339 because the W83627DHG is more complex in this
1340 respect. */
1341 if (sio_data->kind == w83627ehf) {
1342 en_vrm10 = superio_inb(sio_data->sioreg,
1343 SIO_REG_EN_VRM10);
1344 if ((en_vrm10 & 0x08) && data->vrm == 90) {
1345 dev_warn(dev, "Setting VID input "
1346 "voltage to TTL\n");
1347 superio_outb(sio_data->sioreg,
1348 SIO_REG_EN_VRM10,
1349 en_vrm10 & ~0x08);
1350 } else if (!(en_vrm10 & 0x08)
1351 && data->vrm == 100) {
1352 dev_warn(dev, "Setting VID input "
1353 "voltage to VRM10\n");
1354 superio_outb(sio_data->sioreg,
1355 SIO_REG_EN_VRM10,
1356 en_vrm10 | 0x08);
1357 }
1358 }
1359
1360 data->vid = superio_inb(sio_data->sioreg,
1361 SIO_REG_VID_DATA);
1362 if (sio_data->kind == w83627ehf) /* 6 VID pins only */
1363 data->vid &= 0x3f;
1364
1365 err = device_create_file(dev, &dev_attr_cpu0_vid);
1366 if (err)
1367 goto exit_release;
1368 } else {
1369 dev_info(dev, "VID pins in output mode, CPU VID not "
1370 "available\n");
1371 }
1316 } 1372 }
1317 1373
1318 /* fan4 and fan5 share some pins with the GPIO and serial flash */ 1374 /* fan4 and fan5 share some pins with the GPIO and serial flash */
1319 1375 if (sio_data->kind == w83667hg) {
1320 fan5pin = superio_inb(sio_data->sioreg, 0x24) & 0x2; 1376 fan5pin = superio_inb(sio_data->sioreg, 0x27) & 0x20;
1321 fan4pin = superio_inb(sio_data->sioreg, 0x29) & 0x6; 1377 fan4pin = superio_inb(sio_data->sioreg, 0x27) & 0x40;
1378 } else {
1379 fan5pin = !(superio_inb(sio_data->sioreg, 0x24) & 0x02);
1380 fan4pin = !(superio_inb(sio_data->sioreg, 0x29) & 0x06);
1381 }
1322 superio_exit(sio_data->sioreg); 1382 superio_exit(sio_data->sioreg);
1323 1383
1324 /* It looks like fan4 and fan5 pins can be alternatively used 1384 /* It looks like fan4 and fan5 pins can be alternatively used
@@ -1329,9 +1389,9 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
1329 1389
1330 data->has_fan = 0x07; /* fan1, fan2 and fan3 */ 1390 data->has_fan = 0x07; /* fan1, fan2 and fan3 */
1331 i = w83627ehf_read_value(data, W83627EHF_REG_FANDIV1); 1391 i = w83627ehf_read_value(data, W83627EHF_REG_FANDIV1);
1332 if ((i & (1 << 2)) && (!fan4pin)) 1392 if ((i & (1 << 2)) && fan4pin)
1333 data->has_fan |= (1 << 3); 1393 data->has_fan |= (1 << 3);
1334 if (!(i & (1 << 1)) && (!fan5pin)) 1394 if (!(i & (1 << 1)) && fan5pin)
1335 data->has_fan |= (1 << 4); 1395 data->has_fan |= (1 << 4);
1336 1396
1337 /* Read fan clock dividers immediately */ 1397 /* Read fan clock dividers immediately */
@@ -1344,14 +1404,16 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
1344 goto exit_remove; 1404 goto exit_remove;
1345 1405
1346 /* if fan4 is enabled create the sf3 files for it */ 1406 /* if fan4 is enabled create the sf3 files for it */
1347 if (data->has_fan & (1 << 3)) 1407 if ((data->has_fan & (1 << 3)) && data->pwm_num >= 4)
1348 for (i = 0; i < ARRAY_SIZE(sda_sf3_arrays_fan4); i++) { 1408 for (i = 0; i < ARRAY_SIZE(sda_sf3_arrays_fan4); i++) {
1349 if ((err = device_create_file(dev, 1409 if ((err = device_create_file(dev,
1350 &sda_sf3_arrays_fan4[i].dev_attr))) 1410 &sda_sf3_arrays_fan4[i].dev_attr)))
1351 goto exit_remove; 1411 goto exit_remove;
1352 } 1412 }
1353 1413
1354 for (i = 0; i < data->in_num; i++) 1414 for (i = 0; i < data->in_num; i++) {
1415 if ((i == 6) && data->in6_skip)
1416 continue;
1355 if ((err = device_create_file(dev, &sda_in_input[i].dev_attr)) 1417 if ((err = device_create_file(dev, &sda_in_input[i].dev_attr))
1356 || (err = device_create_file(dev, 1418 || (err = device_create_file(dev,
1357 &sda_in_alarm[i].dev_attr)) 1419 &sda_in_alarm[i].dev_attr))
@@ -1360,6 +1422,7 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
1360 || (err = device_create_file(dev, 1422 || (err = device_create_file(dev,
1361 &sda_in_max[i].dev_attr))) 1423 &sda_in_max[i].dev_attr)))
1362 goto exit_remove; 1424 goto exit_remove;
1425 }
1363 1426
1364 for (i = 0; i < 5; i++) { 1427 for (i = 0; i < 5; i++) {
1365 if (data->has_fan & (1 << i)) { 1428 if (data->has_fan & (1 << i)) {
@@ -1372,7 +1435,7 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
1372 || (err = device_create_file(dev, 1435 || (err = device_create_file(dev,
1373 &sda_fan_min[i].dev_attr))) 1436 &sda_fan_min[i].dev_attr)))
1374 goto exit_remove; 1437 goto exit_remove;
1375 if (i < 4 && /* w83627ehf only has 4 pwm */ 1438 if (i < data->pwm_num &&
1376 ((err = device_create_file(dev, 1439 ((err = device_create_file(dev,
1377 &sda_pwm[i].dev_attr)) 1440 &sda_pwm[i].dev_attr))
1378 || (err = device_create_file(dev, 1441 || (err = device_create_file(dev,
@@ -1387,9 +1450,21 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
1387 } 1450 }
1388 } 1451 }
1389 1452
1390 for (i = 0; i < ARRAY_SIZE(sda_temp); i++) 1453 for (i = 0; i < 3; i++) {
1391 if ((err = device_create_file(dev, &sda_temp[i].dev_attr))) 1454 if ((i == 2) && data->temp3_disable)
1455 continue;
1456 if ((err = device_create_file(dev,
1457 &sda_temp_input[i].dev_attr))
1458 || (err = device_create_file(dev,
1459 &sda_temp_max[i].dev_attr))
1460 || (err = device_create_file(dev,
1461 &sda_temp_max_hyst[i].dev_attr))
1462 || (err = device_create_file(dev,
1463 &sda_temp_alarm[i].dev_attr))
1464 || (err = device_create_file(dev,
1465 &sda_temp_type[i].dev_attr)))
1392 goto exit_remove; 1466 goto exit_remove;
1467 }
1393 1468
1394 err = device_create_file(dev, &dev_attr_name); 1469 err = device_create_file(dev, &dev_attr_name);
1395 if (err) 1470 if (err)
@@ -1442,6 +1517,7 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr,
1442 static const char __initdata sio_name_W83627EHF[] = "W83627EHF"; 1517 static const char __initdata sio_name_W83627EHF[] = "W83627EHF";
1443 static const char __initdata sio_name_W83627EHG[] = "W83627EHG"; 1518 static const char __initdata sio_name_W83627EHG[] = "W83627EHG";
1444 static const char __initdata sio_name_W83627DHG[] = "W83627DHG"; 1519 static const char __initdata sio_name_W83627DHG[] = "W83627DHG";
1520 static const char __initdata sio_name_W83667HG[] = "W83667HG";
1445 1521
1446 u16 val; 1522 u16 val;
1447 const char *sio_name; 1523 const char *sio_name;
@@ -1466,6 +1542,10 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr,
1466 sio_data->kind = w83627dhg; 1542 sio_data->kind = w83627dhg;
1467 sio_name = sio_name_W83627DHG; 1543 sio_name = sio_name_W83627DHG;
1468 break; 1544 break;
1545 case SIO_W83667HG_ID:
1546 sio_data->kind = w83667hg;
1547 sio_name = sio_name_W83667HG;
1548 break;
1469 default: 1549 default:
1470 if (val != 0xffff) 1550 if (val != 0xffff)
1471 pr_debug(DRVNAME ": unsupported chip ID: 0x%04x\n", 1551 pr_debug(DRVNAME ": unsupported chip ID: 0x%04x\n",
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 230238df56c4..10411848fd70 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -65,6 +65,7 @@
65#include <linux/i2c.h> 65#include <linux/i2c.h>
66#include <linux/acpi.h> 66#include <linux/acpi.h>
67#include <linux/io.h> 67#include <linux/io.h>
68#include <linux/dmi.h>
68 69
69/* I801 SMBus address offsets */ 70/* I801 SMBus address offsets */
70#define SMBHSTSTS (0 + i801_smba) 71#define SMBHSTSTS (0 + i801_smba)
@@ -616,10 +617,81 @@ static void __init input_apanel_init(void)
616static void __init input_apanel_init(void) {} 617static void __init input_apanel_init(void) {}
617#endif 618#endif
618 619
620#if defined CONFIG_SENSORS_FSCHMD || defined CONFIG_SENSORS_FSCHMD_MODULE
621struct dmi_onboard_device_info {
622 const char *name;
623 u8 type;
624 unsigned short i2c_addr;
625 const char *i2c_type;
626};
627
628static struct dmi_onboard_device_info __devinitdata dmi_devices[] = {
629 { "Syleus", DMI_DEV_TYPE_OTHER, 0x73, "fscsyl" },
630 { "Hermes", DMI_DEV_TYPE_OTHER, 0x73, "fscher" },
631 { "Hades", DMI_DEV_TYPE_OTHER, 0x73, "fschds" },
632};
633
634static void __devinit dmi_check_onboard_device(u8 type, const char *name,
635 struct i2c_adapter *adap)
636{
637 int i;
638 struct i2c_board_info info;
639
640 for (i = 0; i < ARRAY_SIZE(dmi_devices); i++) {
641 /* & ~0x80, ignore enabled/disabled bit */
642 if ((type & ~0x80) != dmi_devices[i].type)
643 continue;
644 if (strcmp(name, dmi_devices[i].name))
645 continue;
646
647 memset(&info, 0, sizeof(struct i2c_board_info));
648 info.addr = dmi_devices[i].i2c_addr;
649 strlcpy(info.type, dmi_devices[i].i2c_type, I2C_NAME_SIZE);
650 i2c_new_device(adap, &info);
651 break;
652 }
653}
654
655/* We use our own function to check for onboard devices instead of
656 dmi_find_device() as some buggy BIOS's have the devices we are interested
657 in marked as disabled */
658static void __devinit dmi_check_onboard_devices(const struct dmi_header *dm,
659 void *adap)
660{
661 int i, count;
662
663 if (dm->type != 10)
664 return;
665
666 count = (dm->length - sizeof(struct dmi_header)) / 2;
667 for (i = 0; i < count; i++) {
668 const u8 *d = (char *)(dm + 1) + (i * 2);
669 const char *name = ((char *) dm) + dm->length;
670 u8 type = d[0];
671 u8 s = d[1];
672
673 if (!s)
674 continue;
675 s--;
676 while (s > 0 && name[0]) {
677 name += strlen(name) + 1;
678 s--;
679 }
680 if (name[0] == 0) /* Bogus string reference */
681 continue;
682
683 dmi_check_onboard_device(type, name, adap);
684 }
685}
686#endif
687
619static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id *id) 688static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
620{ 689{
621 unsigned char temp; 690 unsigned char temp;
622 int err; 691 int err;
692#if defined CONFIG_SENSORS_FSCHMD || defined CONFIG_SENSORS_FSCHMD_MODULE
693 const char *vendor;
694#endif
623 695
624 I801_dev = dev; 696 I801_dev = dev;
625 i801_features = 0; 697 i801_features = 0;
@@ -712,6 +784,11 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id
712 i2c_new_device(&i801_adapter, &info); 784 i2c_new_device(&i801_adapter, &info);
713 } 785 }
714#endif 786#endif
787#if defined CONFIG_SENSORS_FSCHMD || defined CONFIG_SENSORS_FSCHMD_MODULE
788 vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
789 if (vendor && !strcmp(vendor, "FUJITSU SIEMENS"))
790 dmi_walk(dmi_check_onboard_devices, &i801_adapter);
791#endif
715 792
716 return 0; 793 return 0;
717 794
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index c80312c1f382..8f8c81eb0aee 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -64,19 +64,6 @@ config SENSORS_PCA9539
64 This driver is deprecated and will be dropped soon. Use 64 This driver is deprecated and will be dropped soon. Use
65 drivers/gpio/pca953x.c instead. 65 drivers/gpio/pca953x.c instead.
66 66
67config SENSORS_PCF8591
68 tristate "Philips PCF8591"
69 depends on EXPERIMENTAL
70 default n
71 help
72 If you say yes here you get support for Philips PCF8591 chips.
73
74 This driver can also be built as a module. If so, the module
75 will be called pcf8591.
76
77 These devices are hard to detect and rarely found on mainstream
78 hardware. If unsure, say N.
79
80config SENSORS_MAX6875 67config SENSORS_MAX6875
81 tristate "Maxim MAX6875 Power supply supervisor" 68 tristate "Maxim MAX6875 Power supply supervisor"
82 depends on EXPERIMENTAL 69 depends on EXPERIMENTAL
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
index d142f238a2de..55a376037183 100644
--- a/drivers/i2c/chips/Makefile
+++ b/drivers/i2c/chips/Makefile
@@ -15,7 +15,6 @@ obj-$(CONFIG_SENSORS_MAX6875) += max6875.o
15obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o 15obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o
16obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o 16obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o
17obj-$(CONFIG_PCF8575) += pcf8575.o 17obj-$(CONFIG_PCF8575) += pcf8575.o
18obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
19obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o 18obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o
20 19
21ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) 20ifeq ($(CONFIG_I2C_DEBUG_CHIP),y)
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 1730d7331a5d..ec3db3ade118 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -903,8 +903,6 @@ static int __init input_proc_init(void)
903 if (!proc_bus_input_dir) 903 if (!proc_bus_input_dir)
904 return -ENOMEM; 904 return -ENOMEM;
905 905
906 proc_bus_input_dir->owner = THIS_MODULE;
907
908 entry = proc_create("devices", 0, proc_bus_input_dir, 906 entry = proc_create("devices", 0, proc_bus_input_dir,
909 &input_devices_fileops); 907 &input_devices_fileops);
910 if (!entry) 908 if (!entry)
diff --git a/drivers/isdn/hardware/eicon/divasi.c b/drivers/isdn/hardware/eicon/divasi.c
index f4969fe0a055..69e71ebe7841 100644
--- a/drivers/isdn/hardware/eicon/divasi.c
+++ b/drivers/isdn/hardware/eicon/divasi.c
@@ -118,7 +118,6 @@ static int DIVA_INIT_FUNCTION create_um_idi_proc(void)
118 return (0); 118 return (0);
119 119
120 um_idi_proc_entry->read_proc = um_idi_proc_read; 120 um_idi_proc_entry->read_proc = um_idi_proc_read;
121 um_idi_proc_entry->owner = THIS_MODULE;
122 121
123 return (1); 122 return (1);
124} 123}
diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
index 60156dfdc608..4845fb3cf74b 100644
--- a/drivers/lguest/core.c
+++ b/drivers/lguest/core.c
@@ -152,8 +152,8 @@ static void unmap_switcher(void)
152 * code. We have to check that the range is below the pfn_limit the Launcher 152 * code. We have to check that the range is below the pfn_limit the Launcher
153 * gave us. We have to make sure that addr + len doesn't give us a false 153 * gave us. We have to make sure that addr + len doesn't give us a false
154 * positive by overflowing, too. */ 154 * positive by overflowing, too. */
155int lguest_address_ok(const struct lguest *lg, 155bool lguest_address_ok(const struct lguest *lg,
156 unsigned long addr, unsigned long len) 156 unsigned long addr, unsigned long len)
157{ 157{
158 return (addr+len) / PAGE_SIZE < lg->pfn_limit && (addr+len >= addr); 158 return (addr+len) / PAGE_SIZE < lg->pfn_limit && (addr+len >= addr);
159} 159}
diff --git a/drivers/lguest/interrupts_and_traps.c b/drivers/lguest/interrupts_and_traps.c
index 415fab0125ac..6e99adbe1946 100644
--- a/drivers/lguest/interrupts_and_traps.c
+++ b/drivers/lguest/interrupts_and_traps.c
@@ -34,7 +34,7 @@ static int idt_type(u32 lo, u32 hi)
34} 34}
35 35
36/* An IDT entry can't be used unless the "present" bit is set. */ 36/* An IDT entry can't be used unless the "present" bit is set. */
37static int idt_present(u32 lo, u32 hi) 37static bool idt_present(u32 lo, u32 hi)
38{ 38{
39 return (hi & 0x8000); 39 return (hi & 0x8000);
40} 40}
@@ -60,7 +60,8 @@ static void push_guest_stack(struct lg_cpu *cpu, unsigned long *gstack, u32 val)
60 * We set up the stack just like the CPU does for a real interrupt, so it's 60 * We set up the stack just like the CPU does for a real interrupt, so it's
61 * identical for the Guest (and the standard "iret" instruction will undo 61 * identical for the Guest (and the standard "iret" instruction will undo
62 * it). */ 62 * it). */
63static void set_guest_interrupt(struct lg_cpu *cpu, u32 lo, u32 hi, int has_err) 63static void set_guest_interrupt(struct lg_cpu *cpu, u32 lo, u32 hi,
64 bool has_err)
64{ 65{
65 unsigned long gstack, origstack; 66 unsigned long gstack, origstack;
66 u32 eflags, ss, irq_enable; 67 u32 eflags, ss, irq_enable;
@@ -184,7 +185,7 @@ void maybe_do_interrupt(struct lg_cpu *cpu)
184 /* set_guest_interrupt() takes the interrupt descriptor and a 185 /* set_guest_interrupt() takes the interrupt descriptor and a
185 * flag to say whether this interrupt pushes an error code onto 186 * flag to say whether this interrupt pushes an error code onto
186 * the stack as well: virtual interrupts never do. */ 187 * the stack as well: virtual interrupts never do. */
187 set_guest_interrupt(cpu, idt->a, idt->b, 0); 188 set_guest_interrupt(cpu, idt->a, idt->b, false);
188 } 189 }
189 190
190 /* Every time we deliver an interrupt, we update the timestamp in the 191 /* Every time we deliver an interrupt, we update the timestamp in the
@@ -244,26 +245,26 @@ void free_interrupts(void)
244/*H:220 Now we've got the routines to deliver interrupts, delivering traps like 245/*H:220 Now we've got the routines to deliver interrupts, delivering traps like
245 * page fault is easy. The only trick is that Intel decided that some traps 246 * page fault is easy. The only trick is that Intel decided that some traps
246 * should have error codes: */ 247 * should have error codes: */
247static int has_err(unsigned int trap) 248static bool has_err(unsigned int trap)
248{ 249{
249 return (trap == 8 || (trap >= 10 && trap <= 14) || trap == 17); 250 return (trap == 8 || (trap >= 10 && trap <= 14) || trap == 17);
250} 251}
251 252
252/* deliver_trap() returns true if it could deliver the trap. */ 253/* deliver_trap() returns true if it could deliver the trap. */
253int deliver_trap(struct lg_cpu *cpu, unsigned int num) 254bool deliver_trap(struct lg_cpu *cpu, unsigned int num)
254{ 255{
255 /* Trap numbers are always 8 bit, but we set an impossible trap number 256 /* Trap numbers are always 8 bit, but we set an impossible trap number
256 * for traps inside the Switcher, so check that here. */ 257 * for traps inside the Switcher, so check that here. */
257 if (num >= ARRAY_SIZE(cpu->arch.idt)) 258 if (num >= ARRAY_SIZE(cpu->arch.idt))
258 return 0; 259 return false;
259 260
260 /* Early on the Guest hasn't set the IDT entries (or maybe it put a 261 /* Early on the Guest hasn't set the IDT entries (or maybe it put a
261 * bogus one in): if we fail here, the Guest will be killed. */ 262 * bogus one in): if we fail here, the Guest will be killed. */
262 if (!idt_present(cpu->arch.idt[num].a, cpu->arch.idt[num].b)) 263 if (!idt_present(cpu->arch.idt[num].a, cpu->arch.idt[num].b))
263 return 0; 264 return false;
264 set_guest_interrupt(cpu, cpu->arch.idt[num].a, 265 set_guest_interrupt(cpu, cpu->arch.idt[num].a,
265 cpu->arch.idt[num].b, has_err(num)); 266 cpu->arch.idt[num].b, has_err(num));
266 return 1; 267 return true;
267} 268}
268 269
269/*H:250 Here's the hard part: returning to the Host every time a trap happens 270/*H:250 Here's the hard part: returning to the Host every time a trap happens
@@ -279,18 +280,19 @@ int deliver_trap(struct lg_cpu *cpu, unsigned int num)
279 * 280 *
280 * This routine indicates if a particular trap number could be delivered 281 * This routine indicates if a particular trap number could be delivered
281 * directly. */ 282 * directly. */
282static int direct_trap(unsigned int num) 283static bool direct_trap(unsigned int num)
283{ 284{
284 /* Hardware interrupts don't go to the Guest at all (except system 285 /* Hardware interrupts don't go to the Guest at all (except system
285 * call). */ 286 * call). */
286 if (num >= FIRST_EXTERNAL_VECTOR && !could_be_syscall(num)) 287 if (num >= FIRST_EXTERNAL_VECTOR && !could_be_syscall(num))
287 return 0; 288 return false;
288 289
289 /* The Host needs to see page faults (for shadow paging and to save the 290 /* The Host needs to see page faults (for shadow paging and to save the
290 * fault address), general protection faults (in/out emulation) and 291 * fault address), general protection faults (in/out emulation) and
291 * device not available (TS handling), and of course, the hypercall 292 * device not available (TS handling), invalid opcode fault (kvm hcall),
292 * trap. */ 293 * and of course, the hypercall trap. */
293 return num != 14 && num != 13 && num != 7 && num != LGUEST_TRAP_ENTRY; 294 return num != 14 && num != 13 && num != 7 &&
295 num != 6 && num != LGUEST_TRAP_ENTRY;
294} 296}
295/*:*/ 297/*:*/
296 298
diff --git a/drivers/lguest/lg.h b/drivers/lguest/lg.h
index f2c641e0bdde..ac8a4a3741b8 100644
--- a/drivers/lguest/lg.h
+++ b/drivers/lguest/lg.h
@@ -109,8 +109,8 @@ struct lguest
109extern struct mutex lguest_lock; 109extern struct mutex lguest_lock;
110 110
111/* core.c: */ 111/* core.c: */
112int lguest_address_ok(const struct lguest *lg, 112bool lguest_address_ok(const struct lguest *lg,
113 unsigned long addr, unsigned long len); 113 unsigned long addr, unsigned long len);
114void __lgread(struct lg_cpu *, void *, unsigned long, unsigned); 114void __lgread(struct lg_cpu *, void *, unsigned long, unsigned);
115void __lgwrite(struct lg_cpu *, unsigned long, const void *, unsigned); 115void __lgwrite(struct lg_cpu *, unsigned long, const void *, unsigned);
116 116
@@ -140,7 +140,7 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user);
140 140
141/* interrupts_and_traps.c: */ 141/* interrupts_and_traps.c: */
142void maybe_do_interrupt(struct lg_cpu *cpu); 142void maybe_do_interrupt(struct lg_cpu *cpu);
143int deliver_trap(struct lg_cpu *cpu, unsigned int num); 143bool deliver_trap(struct lg_cpu *cpu, unsigned int num);
144void load_guest_idt_entry(struct lg_cpu *cpu, unsigned int i, 144void load_guest_idt_entry(struct lg_cpu *cpu, unsigned int i,
145 u32 low, u32 hi); 145 u32 low, u32 hi);
146void guest_set_stack(struct lg_cpu *cpu, u32 seg, u32 esp, unsigned int pages); 146void guest_set_stack(struct lg_cpu *cpu, u32 seg, u32 esp, unsigned int pages);
@@ -173,7 +173,7 @@ void guest_pagetable_flush_user(struct lg_cpu *cpu);
173void guest_set_pte(struct lg_cpu *cpu, unsigned long gpgdir, 173void guest_set_pte(struct lg_cpu *cpu, unsigned long gpgdir,
174 unsigned long vaddr, pte_t val); 174 unsigned long vaddr, pte_t val);
175void map_switcher_in_guest(struct lg_cpu *cpu, struct lguest_pages *pages); 175void map_switcher_in_guest(struct lg_cpu *cpu, struct lguest_pages *pages);
176int demand_page(struct lg_cpu *cpu, unsigned long cr2, int errcode); 176bool demand_page(struct lg_cpu *cpu, unsigned long cr2, int errcode);
177void pin_page(struct lg_cpu *cpu, unsigned long vaddr); 177void pin_page(struct lg_cpu *cpu, unsigned long vaddr);
178unsigned long guest_pa(struct lg_cpu *cpu, unsigned long vaddr); 178unsigned long guest_pa(struct lg_cpu *cpu, unsigned long vaddr);
179void page_table_guest_data_init(struct lg_cpu *cpu); 179void page_table_guest_data_init(struct lg_cpu *cpu);
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c
index 8132533d71f9..df44d962626d 100644
--- a/drivers/lguest/lguest_device.c
+++ b/drivers/lguest/lguest_device.c
@@ -161,7 +161,7 @@ static void set_status(struct virtio_device *vdev, u8 status)
161 161
162 /* We set the status. */ 162 /* We set the status. */
163 to_lgdev(vdev)->desc->status = status; 163 to_lgdev(vdev)->desc->status = status;
164 hcall(LHCALL_NOTIFY, (max_pfn<<PAGE_SHIFT) + offset, 0, 0); 164 kvm_hypercall1(LHCALL_NOTIFY, (max_pfn << PAGE_SHIFT) + offset);
165} 165}
166 166
167static void lg_set_status(struct virtio_device *vdev, u8 status) 167static void lg_set_status(struct virtio_device *vdev, u8 status)
@@ -209,7 +209,7 @@ static void lg_notify(struct virtqueue *vq)
209 * virtqueue structure. */ 209 * virtqueue structure. */
210 struct lguest_vq_info *lvq = vq->priv; 210 struct lguest_vq_info *lvq = vq->priv;
211 211
212 hcall(LHCALL_NOTIFY, lvq->config.pfn << PAGE_SHIFT, 0, 0); 212 kvm_hypercall1(LHCALL_NOTIFY, lvq->config.pfn << PAGE_SHIFT);
213} 213}
214 214
215/* An extern declaration inside a C file is bad form. Don't do it. */ 215/* An extern declaration inside a C file is bad form. Don't do it. */
diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
index 576a8318221c..a059cf9980f7 100644
--- a/drivers/lguest/page_tables.c
+++ b/drivers/lguest/page_tables.c
@@ -199,7 +199,7 @@ static void check_gpgd(struct lg_cpu *cpu, pgd_t gpgd)
199 * 199 *
200 * If we fixed up the fault (ie. we mapped the address), this routine returns 200 * If we fixed up the fault (ie. we mapped the address), this routine returns
201 * true. Otherwise, it was a real fault and we need to tell the Guest. */ 201 * true. Otherwise, it was a real fault and we need to tell the Guest. */
202int demand_page(struct lg_cpu *cpu, unsigned long vaddr, int errcode) 202bool demand_page(struct lg_cpu *cpu, unsigned long vaddr, int errcode)
203{ 203{
204 pgd_t gpgd; 204 pgd_t gpgd;
205 pgd_t *spgd; 205 pgd_t *spgd;
@@ -211,7 +211,7 @@ int demand_page(struct lg_cpu *cpu, unsigned long vaddr, int errcode)
211 gpgd = lgread(cpu, gpgd_addr(cpu, vaddr), pgd_t); 211 gpgd = lgread(cpu, gpgd_addr(cpu, vaddr), pgd_t);
212 /* Toplevel not present? We can't map it in. */ 212 /* Toplevel not present? We can't map it in. */
213 if (!(pgd_flags(gpgd) & _PAGE_PRESENT)) 213 if (!(pgd_flags(gpgd) & _PAGE_PRESENT))
214 return 0; 214 return false;
215 215
216 /* Now look at the matching shadow entry. */ 216 /* Now look at the matching shadow entry. */
217 spgd = spgd_addr(cpu, cpu->cpu_pgd, vaddr); 217 spgd = spgd_addr(cpu, cpu->cpu_pgd, vaddr);
@@ -222,7 +222,7 @@ int demand_page(struct lg_cpu *cpu, unsigned long vaddr, int errcode)
222 * simple for this corner case. */ 222 * simple for this corner case. */
223 if (!ptepage) { 223 if (!ptepage) {
224 kill_guest(cpu, "out of memory allocating pte page"); 224 kill_guest(cpu, "out of memory allocating pte page");
225 return 0; 225 return false;
226 } 226 }
227 /* We check that the Guest pgd is OK. */ 227 /* We check that the Guest pgd is OK. */
228 check_gpgd(cpu, gpgd); 228 check_gpgd(cpu, gpgd);
@@ -238,16 +238,16 @@ int demand_page(struct lg_cpu *cpu, unsigned long vaddr, int errcode)
238 238
239 /* If this page isn't in the Guest page tables, we can't page it in. */ 239 /* If this page isn't in the Guest page tables, we can't page it in. */
240 if (!(pte_flags(gpte) & _PAGE_PRESENT)) 240 if (!(pte_flags(gpte) & _PAGE_PRESENT))
241 return 0; 241 return false;
242 242
243 /* Check they're not trying to write to a page the Guest wants 243 /* Check they're not trying to write to a page the Guest wants
244 * read-only (bit 2 of errcode == write). */ 244 * read-only (bit 2 of errcode == write). */
245 if ((errcode & 2) && !(pte_flags(gpte) & _PAGE_RW)) 245 if ((errcode & 2) && !(pte_flags(gpte) & _PAGE_RW))
246 return 0; 246 return false;
247 247
248 /* User access to a kernel-only page? (bit 3 == user access) */ 248 /* User access to a kernel-only page? (bit 3 == user access) */
249 if ((errcode & 4) && !(pte_flags(gpte) & _PAGE_USER)) 249 if ((errcode & 4) && !(pte_flags(gpte) & _PAGE_USER))
250 return 0; 250 return false;
251 251
252 /* Check that the Guest PTE flags are OK, and the page number is below 252 /* Check that the Guest PTE flags are OK, and the page number is below
253 * the pfn_limit (ie. not mapping the Launcher binary). */ 253 * the pfn_limit (ie. not mapping the Launcher binary). */
@@ -283,7 +283,7 @@ int demand_page(struct lg_cpu *cpu, unsigned long vaddr, int errcode)
283 * manipulated, the result returned and the code complete. A small 283 * manipulated, the result returned and the code complete. A small
284 * delay and a trace of alliteration are the only indications the Guest 284 * delay and a trace of alliteration are the only indications the Guest
285 * has that a page fault occurred at all. */ 285 * has that a page fault occurred at all. */
286 return 1; 286 return true;
287} 287}
288 288
289/*H:360 289/*H:360
@@ -296,7 +296,7 @@ int demand_page(struct lg_cpu *cpu, unsigned long vaddr, int errcode)
296 * 296 *
297 * This is a quick version which answers the question: is this virtual address 297 * This is a quick version which answers the question: is this virtual address
298 * mapped by the shadow page tables, and is it writable? */ 298 * mapped by the shadow page tables, and is it writable? */
299static int page_writable(struct lg_cpu *cpu, unsigned long vaddr) 299static bool page_writable(struct lg_cpu *cpu, unsigned long vaddr)
300{ 300{
301 pgd_t *spgd; 301 pgd_t *spgd;
302 unsigned long flags; 302 unsigned long flags;
@@ -304,7 +304,7 @@ static int page_writable(struct lg_cpu *cpu, unsigned long vaddr)
304 /* Look at the current top level entry: is it present? */ 304 /* Look at the current top level entry: is it present? */
305 spgd = spgd_addr(cpu, cpu->cpu_pgd, vaddr); 305 spgd = spgd_addr(cpu, cpu->cpu_pgd, vaddr);
306 if (!(pgd_flags(*spgd) & _PAGE_PRESENT)) 306 if (!(pgd_flags(*spgd) & _PAGE_PRESENT))
307 return 0; 307 return false;
308 308
309 /* Check the flags on the pte entry itself: it must be present and 309 /* Check the flags on the pte entry itself: it must be present and
310 * writable. */ 310 * writable. */
@@ -373,8 +373,10 @@ unsigned long guest_pa(struct lg_cpu *cpu, unsigned long vaddr)
373 /* First step: get the top-level Guest page table entry. */ 373 /* First step: get the top-level Guest page table entry. */
374 gpgd = lgread(cpu, gpgd_addr(cpu, vaddr), pgd_t); 374 gpgd = lgread(cpu, gpgd_addr(cpu, vaddr), pgd_t);
375 /* Toplevel not present? We can't map it in. */ 375 /* Toplevel not present? We can't map it in. */
376 if (!(pgd_flags(gpgd) & _PAGE_PRESENT)) 376 if (!(pgd_flags(gpgd) & _PAGE_PRESENT)) {
377 kill_guest(cpu, "Bad address %#lx", vaddr); 377 kill_guest(cpu, "Bad address %#lx", vaddr);
378 return -1UL;
379 }
378 380
379 gpte = lgread(cpu, gpte_addr(gpgd, vaddr), pte_t); 381 gpte = lgread(cpu, gpte_addr(gpgd, vaddr), pte_t);
380 if (!(pte_flags(gpte) & _PAGE_PRESENT)) 382 if (!(pte_flags(gpte) & _PAGE_PRESENT))
diff --git a/drivers/lguest/segments.c b/drivers/lguest/segments.c
index ec6aa3f1c36b..4f15439b7f12 100644
--- a/drivers/lguest/segments.c
+++ b/drivers/lguest/segments.c
@@ -45,7 +45,7 @@
45 * "Task State Segment" which controls all kinds of delicate things. The 45 * "Task State Segment" which controls all kinds of delicate things. The
46 * LGUEST_CS and LGUEST_DS entries are reserved for the Switcher, and the 46 * LGUEST_CS and LGUEST_DS entries are reserved for the Switcher, and the
47 * the Guest can't be trusted to deal with double faults. */ 47 * the Guest can't be trusted to deal with double faults. */
48static int ignored_gdt(unsigned int num) 48static bool ignored_gdt(unsigned int num)
49{ 49{
50 return (num == GDT_ENTRY_TSS 50 return (num == GDT_ENTRY_TSS
51 || num == GDT_ENTRY_LGUEST_CS 51 || num == GDT_ENTRY_LGUEST_CS
diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
index bf7942327bda..a6b717644be0 100644
--- a/drivers/lguest/x86/core.c
+++ b/drivers/lguest/x86/core.c
@@ -290,6 +290,57 @@ static int emulate_insn(struct lg_cpu *cpu)
290 return 1; 290 return 1;
291} 291}
292 292
293/* Our hypercalls mechanism used to be based on direct software interrupts.
294 * After Anthony's "Refactor hypercall infrastructure" kvm patch, we decided to
295 * change over to using kvm hypercalls.
296 *
297 * KVM_HYPERCALL is actually a "vmcall" instruction, which generates an invalid
298 * opcode fault (fault 6) on non-VT cpus, so the easiest solution seemed to be
299 * an *emulation approach*: if the fault was really produced by an hypercall
300 * (is_hypercall() does exactly this check), we can just call the corresponding
301 * hypercall host implementation function.
302 *
303 * But these invalid opcode faults are notably slower than software interrupts.
304 * So we implemented the *patching (or rewriting) approach*: every time we hit
305 * the KVM_HYPERCALL opcode in Guest code, we patch it to the old "int 0x1f"
306 * opcode, so next time the Guest calls this hypercall it will use the
307 * faster trap mechanism.
308 *
309 * Matias even benchmarked it to convince you: this shows the average cycle
310 * cost of a hypercall. For each alternative solution mentioned above we've
311 * made 5 runs of the benchmark:
312 *
313 * 1) direct software interrupt: 2915, 2789, 2764, 2721, 2898
314 * 2) emulation technique: 3410, 3681, 3466, 3392, 3780
315 * 3) patching (rewrite) technique: 2977, 2975, 2891, 2637, 2884
316 *
317 * One two-line function is worth a 20% hypercall speed boost!
318 */
319static void rewrite_hypercall(struct lg_cpu *cpu)
320{
321 /* This are the opcodes we use to patch the Guest. The opcode for "int
322 * $0x1f" is "0xcd 0x1f" but vmcall instruction is 3 bytes long, so we
323 * complete the sequence with a NOP (0x90). */
324 u8 insn[3] = {0xcd, 0x1f, 0x90};
325
326 __lgwrite(cpu, guest_pa(cpu, cpu->regs->eip), insn, sizeof(insn));
327}
328
329static bool is_hypercall(struct lg_cpu *cpu)
330{
331 u8 insn[3];
332
333 /* This must be the Guest kernel trying to do something.
334 * The bottom two bits of the CS segment register are the privilege
335 * level. */
336 if ((cpu->regs->cs & 3) != GUEST_PL)
337 return false;
338
339 /* Is it a vmcall? */
340 __lgread(cpu, insn, guest_pa(cpu, cpu->regs->eip), sizeof(insn));
341 return insn[0] == 0x0f && insn[1] == 0x01 && insn[2] == 0xc1;
342}
343
293/*H:050 Once we've re-enabled interrupts, we look at why the Guest exited. */ 344/*H:050 Once we've re-enabled interrupts, we look at why the Guest exited. */
294void lguest_arch_handle_trap(struct lg_cpu *cpu) 345void lguest_arch_handle_trap(struct lg_cpu *cpu)
295{ 346{
@@ -337,7 +388,7 @@ void lguest_arch_handle_trap(struct lg_cpu *cpu)
337 break; 388 break;
338 case 32 ... 255: 389 case 32 ... 255:
339 /* These values mean a real interrupt occurred, in which case 390 /* These values mean a real interrupt occurred, in which case
340 * the Host handler has already been run. We just do a 391 * the Host handler has already been run. We just do a
341 * friendly check if another process should now be run, then 392 * friendly check if another process should now be run, then
342 * return to run the Guest again */ 393 * return to run the Guest again */
343 cond_resched(); 394 cond_resched();
@@ -347,6 +398,15 @@ void lguest_arch_handle_trap(struct lg_cpu *cpu)
347 * up the pointer now to indicate a hypercall is pending. */ 398 * up the pointer now to indicate a hypercall is pending. */
348 cpu->hcall = (struct hcall_args *)cpu->regs; 399 cpu->hcall = (struct hcall_args *)cpu->regs;
349 return; 400 return;
401 case 6:
402 /* kvm hypercalls trigger an invalid opcode fault (6).
403 * We need to check if ring == GUEST_PL and
404 * faulting instruction == vmcall. */
405 if (is_hypercall(cpu)) {
406 rewrite_hypercall(cpu);
407 return;
408 }
409 break;
350 } 410 }
351 411
352 /* We didn't handle the trap, so it needs to go to the Guest. */ 412 /* We didn't handle the trap, so it needs to go to the Guest. */
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c
index c3b0c8c63c76..43ab0adf3b61 100644
--- a/drivers/media/video/cpia.c
+++ b/drivers/media/video/cpia.c
@@ -1381,9 +1381,7 @@ static void proc_cpia_create(void)
1381{ 1381{
1382 cpia_proc_root = proc_mkdir("cpia", NULL); 1382 cpia_proc_root = proc_mkdir("cpia", NULL);
1383 1383
1384 if (cpia_proc_root) 1384 if (!cpia_proc_root)
1385 cpia_proc_root->owner = THIS_MODULE;
1386 else
1387 LOG("Unable to initialise /proc/cpia\n"); 1385 LOG("Unable to initialise /proc/cpia\n");
1388} 1386}
1389 1387
diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
index 9a36b5a7de57..7045c45da9b1 100644
--- a/drivers/message/i2o/i2o_proc.c
+++ b/drivers/message/i2o/i2o_proc.c
@@ -2037,8 +2037,6 @@ static int __init i2o_proc_fs_create(void)
2037 if (!i2o_proc_dir_root) 2037 if (!i2o_proc_dir_root)
2038 return -1; 2038 return -1;
2039 2039
2040 i2o_proc_dir_root->owner = THIS_MODULE;
2041
2042 list_for_each_entry(c, &i2o_controllers, list) 2040 list_for_each_entry(c, &i2o_controllers, list)
2043 i2o_proc_iop_add(i2o_proc_dir_root, c); 2041 i2o_proc_iop_add(i2o_proc_dir_root, c);
2044 2042
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 9c326a50a3ee..99610f358c40 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3444,25 +3444,12 @@ static void bond_remove_proc_entry(struct bonding *bond)
3444 */ 3444 */
3445static void bond_create_proc_dir(void) 3445static void bond_create_proc_dir(void)
3446{ 3446{
3447 int len = strlen(DRV_NAME);
3448
3449 for (bond_proc_dir = init_net.proc_net->subdir; bond_proc_dir;
3450 bond_proc_dir = bond_proc_dir->next) {
3451 if ((bond_proc_dir->namelen == len) &&
3452 !memcmp(bond_proc_dir->name, DRV_NAME, len)) {
3453 break;
3454 }
3455 }
3456
3457 if (!bond_proc_dir) { 3447 if (!bond_proc_dir) {
3458 bond_proc_dir = proc_mkdir(DRV_NAME, init_net.proc_net); 3448 bond_proc_dir = proc_mkdir(DRV_NAME, init_net.proc_net);
3459 if (bond_proc_dir) { 3449 if (!bond_proc_dir)
3460 bond_proc_dir->owner = THIS_MODULE;
3461 } else {
3462 printk(KERN_WARNING DRV_NAME 3450 printk(KERN_WARNING DRV_NAME
3463 ": Warning: cannot create /proc/net/%s\n", 3451 ": Warning: cannot create /proc/net/%s\n",
3464 DRV_NAME); 3452 DRV_NAME);
3465 }
3466 } 3453 }
3467} 3454}
3468 3455
@@ -3471,25 +3458,7 @@ static void bond_create_proc_dir(void)
3471 */ 3458 */
3472static void bond_destroy_proc_dir(void) 3459static void bond_destroy_proc_dir(void)
3473{ 3460{
3474 struct proc_dir_entry *de; 3461 if (bond_proc_dir) {
3475
3476 if (!bond_proc_dir) {
3477 return;
3478 }
3479
3480 /* verify that the /proc dir is empty */
3481 for (de = bond_proc_dir->subdir; de; de = de->next) {
3482 /* ignore . and .. */
3483 if (*(de->name) != '.') {
3484 break;
3485 }
3486 }
3487
3488 if (de) {
3489 if (bond_proc_dir->owner == THIS_MODULE) {
3490 bond_proc_dir->owner = NULL;
3491 }
3492 } else {
3493 remove_proc_entry(DRV_NAME, init_net.proc_net); 3462 remove_proc_entry(DRV_NAME, init_net.proc_net);
3494 bond_proc_dir = NULL; 3463 bond_proc_dir = NULL;
3495 } 3464 }
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 6a38800be3f1..65f55877be95 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -289,9 +289,9 @@ static int gfar_of_init(struct net_device *dev)
289 id = of_get_property(phy, "reg", NULL); 289 id = of_get_property(phy, "reg", NULL);
290 290
291 of_node_put(phy); 291 of_node_put(phy);
292 of_node_put(mdio);
293 292
294 fsl_pq_mdio_bus_name(bus_name, mdio); 293 fsl_pq_mdio_bus_name(bus_name, mdio);
294 of_node_put(mdio);
295 snprintf(priv->phy_bus_id, sizeof(priv->phy_bus_id), "%s:%02x", 295 snprintf(priv->phy_bus_id, sizeof(priv->phy_bus_id), "%s:%02x",
296 bus_name, *id); 296 bus_name, *id);
297 } 297 }
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c
index 881bf818bb48..7459b3ac77a9 100644
--- a/drivers/net/hamradio/dmascc.c
+++ b/drivers/net/hamradio/dmascc.c
@@ -445,6 +445,7 @@ static const struct net_device_ops scc_netdev_ops = {
445 .ndo_stop = scc_close, 445 .ndo_stop = scc_close,
446 .ndo_start_xmit = scc_send_packet, 446 .ndo_start_xmit = scc_send_packet,
447 .ndo_do_ioctl = scc_ioctl, 447 .ndo_do_ioctl = scc_ioctl,
448 .ndo_set_mac_address = scc_set_mac_address,
448}; 449};
449 450
450static int __init setup_adapter(int card_base, int type, int n) 451static int __init setup_adapter(int card_base, int type, int n)
@@ -584,7 +585,6 @@ static int __init setup_adapter(int card_base, int type, int n)
584 dev->irq = irq; 585 dev->irq = irq;
585 dev->netdev_ops = &scc_netdev_ops; 586 dev->netdev_ops = &scc_netdev_ops;
586 dev->header_ops = &ax25_header_ops; 587 dev->header_ops = &ax25_header_ops;
587 dev->set_mac_address = scc_set_mac_address;
588 } 588 }
589 if (register_netdev(info->dev[0])) { 589 if (register_netdev(info->dev[0])) {
590 printk(KERN_ERR "dmascc: could not register %s\n", 590 printk(KERN_ERR "dmascc: could not register %s\n",
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
index 1243bc8e0035..ac0e4b6b6b66 100644
--- a/drivers/net/irda/vlsi_ir.c
+++ b/drivers/net/irda/vlsi_ir.c
@@ -1871,13 +1871,6 @@ static int __init vlsi_mod_init(void)
1871 * without procfs - it's not required for the driver to work. 1871 * without procfs - it's not required for the driver to work.
1872 */ 1872 */
1873 vlsi_proc_root = proc_mkdir(PROC_DIR, NULL); 1873 vlsi_proc_root = proc_mkdir(PROC_DIR, NULL);
1874 if (vlsi_proc_root) {
1875 /* protect registered procdir against module removal.
1876 * Because we are in the module init path there's no race
1877 * window after create_proc_entry (and no barrier needed).
1878 */
1879 vlsi_proc_root->owner = THIS_MODULE;
1880 }
1881 1874
1882 ret = pci_register_driver(&vlsi_irda_driver); 1875 ret = pci_register_driver(&vlsi_irda_driver);
1883 1876
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index d304d38cd5d1..eceadf787a67 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -294,14 +294,12 @@ static ssize_t show_remote_port(struct netconsole_target *nt, char *buf)
294 294
295static ssize_t show_local_ip(struct netconsole_target *nt, char *buf) 295static ssize_t show_local_ip(struct netconsole_target *nt, char *buf)
296{ 296{
297 return snprintf(buf, PAGE_SIZE, "%d.%d.%d.%d\n", 297 return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.local_ip);
298 HIPQUAD(nt->np.local_ip));
299} 298}
300 299
301static ssize_t show_remote_ip(struct netconsole_target *nt, char *buf) 300static ssize_t show_remote_ip(struct netconsole_target *nt, char *buf)
302{ 301{
303 return snprintf(buf, PAGE_SIZE, "%d.%d.%d.%d\n", 302 return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.remote_ip);
304 HIPQUAD(nt->np.remote_ip));
305} 303}
306 304
307static ssize_t show_local_mac(struct netconsole_target *nt, char *buf) 305static ssize_t show_local_mac(struct netconsole_target *nt, char *buf)
@@ -438,7 +436,7 @@ static ssize_t store_local_ip(struct netconsole_target *nt,
438 return -EINVAL; 436 return -EINVAL;
439 } 437 }
440 438
441 nt->np.local_ip = ntohl(in_aton(buf)); 439 nt->np.local_ip = in_aton(buf);
442 440
443 return strnlen(buf, count); 441 return strnlen(buf, count);
444} 442}
@@ -454,7 +452,7 @@ static ssize_t store_remote_ip(struct netconsole_target *nt,
454 return -EINVAL; 452 return -EINVAL;
455 } 453 }
456 454
457 nt->np.remote_ip = ntohl(in_aton(buf)); 455 nt->np.remote_ip = in_aton(buf);
458 456
459 return strnlen(buf, count); 457 return strnlen(buf, count);
460} 458}
diff --git a/drivers/net/ni5010.c b/drivers/net/ni5010.c
index 539e18ab485c..2a8da476ab3d 100644
--- a/drivers/net/ni5010.c
+++ b/drivers/net/ni5010.c
@@ -189,6 +189,17 @@ static void __init trigger_irq(int ioaddr)
189 outb(MM_EN_XMT|MM_MUX, IE_MMODE); /* Start transmission */ 189 outb(MM_EN_XMT|MM_MUX, IE_MMODE); /* Start transmission */
190} 190}
191 191
192static const struct net_device_ops ni5010_netdev_ops = {
193 .ndo_open = ni5010_open,
194 .ndo_stop = ni5010_close,
195 .ndo_start_xmit = ni5010_send_packet,
196 .ndo_set_multicast_list = ni5010_set_multicast_list,
197 .ndo_tx_timeout = ni5010_timeout,
198 .ndo_validate_addr = eth_validate_addr,
199 .ndo_set_mac_address = eth_mac_addr,
200 .ndo_change_mtu = eth_change_mtu,
201};
202
192/* 203/*
193 * This is the real probe routine. Linux has a history of friendly device 204 * This is the real probe routine. Linux has a history of friendly device
194 * probes on the ISA bus. A good device probes avoids doing writes, and 205 * probes on the ISA bus. A good device probes avoids doing writes, and
@@ -328,13 +339,8 @@ static int __init ni5010_probe1(struct net_device *dev, int ioaddr)
328 outb(0, IE_RBUF); /* set buffer byte 0 to 0 again */ 339 outb(0, IE_RBUF); /* set buffer byte 0 to 0 again */
329 } 340 }
330 printk("-> bufsize rcv/xmt=%d/%d\n", bufsize_rcv, NI5010_BUFSIZE); 341 printk("-> bufsize rcv/xmt=%d/%d\n", bufsize_rcv, NI5010_BUFSIZE);
331 memset(netdev_priv(dev), 0, sizeof(struct ni5010_local));
332 342
333 dev->open = ni5010_open; 343 dev->netdev_ops = &ni5010_netdev_ops;
334 dev->stop = ni5010_close;
335 dev->hard_start_xmit = ni5010_send_packet;
336 dev->set_multicast_list = ni5010_set_multicast_list;
337 dev->tx_timeout = ni5010_timeout;
338 dev->watchdog_timeo = HZ/20; 344 dev->watchdog_timeo = HZ/20;
339 345
340 dev->flags &= ~IFF_MULTICAST; /* Multicast doesn't work */ 346 dev->flags &= ~IFF_MULTICAST; /* Multicast doesn't work */
diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index 50c11126a3db..02c37e2f08a9 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -3441,7 +3441,8 @@ static int niu_rx_pkt_ignore(struct niu *np, struct rx_ring_info *rp)
3441 return num_rcr; 3441 return num_rcr;
3442} 3442}
3443 3443
3444static int niu_process_rx_pkt(struct niu *np, struct rx_ring_info *rp) 3444static int niu_process_rx_pkt(struct napi_struct *napi, struct niu *np,
3445 struct rx_ring_info *rp)
3445{ 3446{
3446 unsigned int index = rp->rcr_index; 3447 unsigned int index = rp->rcr_index;
3447 struct sk_buff *skb; 3448 struct sk_buff *skb;
@@ -3518,7 +3519,7 @@ static int niu_process_rx_pkt(struct niu *np, struct rx_ring_info *rp)
3518 3519
3519 skb->protocol = eth_type_trans(skb, np->dev); 3520 skb->protocol = eth_type_trans(skb, np->dev);
3520 skb_record_rx_queue(skb, rp->rx_channel); 3521 skb_record_rx_queue(skb, rp->rx_channel);
3521 netif_receive_skb(skb); 3522 napi_gro_receive(napi, skb);
3522 3523
3523 return num_rcr; 3524 return num_rcr;
3524} 3525}
@@ -3706,7 +3707,8 @@ static inline void niu_sync_rx_discard_stats(struct niu *np,
3706 } 3707 }
3707} 3708}
3708 3709
3709static int niu_rx_work(struct niu *np, struct rx_ring_info *rp, int budget) 3710static int niu_rx_work(struct napi_struct *napi, struct niu *np,
3711 struct rx_ring_info *rp, int budget)
3710{ 3712{
3711 int qlen, rcr_done = 0, work_done = 0; 3713 int qlen, rcr_done = 0, work_done = 0;
3712 struct rxdma_mailbox *mbox = rp->mbox; 3714 struct rxdma_mailbox *mbox = rp->mbox;
@@ -3728,7 +3730,7 @@ static int niu_rx_work(struct niu *np, struct rx_ring_info *rp, int budget)
3728 rcr_done = work_done = 0; 3730 rcr_done = work_done = 0;
3729 qlen = min(qlen, budget); 3731 qlen = min(qlen, budget);
3730 while (work_done < qlen) { 3732 while (work_done < qlen) {
3731 rcr_done += niu_process_rx_pkt(np, rp); 3733 rcr_done += niu_process_rx_pkt(napi, np, rp);
3732 work_done++; 3734 work_done++;
3733 } 3735 }
3734 3736
@@ -3776,7 +3778,7 @@ static int niu_poll_core(struct niu *np, struct niu_ldg *lp, int budget)
3776 if (rx_vec & (1 << rp->rx_channel)) { 3778 if (rx_vec & (1 << rp->rx_channel)) {
3777 int this_work_done; 3779 int this_work_done;
3778 3780
3779 this_work_done = niu_rx_work(np, rp, 3781 this_work_done = niu_rx_work(&lp->napi, np, rp,
3780 budget); 3782 budget);
3781 3783
3782 budget -= this_work_done; 3784 budget -= this_work_done;
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index f7efcecc4108..1205c2a22657 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -4392,7 +4392,7 @@ static void tg3_recycle_rx(struct tg3 *tp, u32 opaque_key,
4392#if TG3_VLAN_TAG_USED 4392#if TG3_VLAN_TAG_USED
4393static int tg3_vlan_rx(struct tg3 *tp, struct sk_buff *skb, u16 vlan_tag) 4393static int tg3_vlan_rx(struct tg3 *tp, struct sk_buff *skb, u16 vlan_tag)
4394{ 4394{
4395 return vlan_hwaccel_receive_skb(skb, tp->vlgrp, vlan_tag); 4395 return vlan_gro_receive(&tp->napi, tp->vlgrp, vlan_tag, skb);
4396} 4396}
4397#endif 4397#endif
4398 4398
@@ -4539,7 +4539,7 @@ static int tg3_rx(struct tg3 *tp, int budget)
4539 desc->err_vlan & RXD_VLAN_MASK); 4539 desc->err_vlan & RXD_VLAN_MASK);
4540 } else 4540 } else
4541#endif 4541#endif
4542 netif_receive_skb(skb); 4542 napi_gro_receive(&tp->napi, skb);
4543 4543
4544 received++; 4544 received++;
4545 budget--; 4545 budget--;
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index 86a479f61c0c..933fcfbf35e1 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -3648,15 +3648,16 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
3648 mdio = of_get_parent(phy); 3648 mdio = of_get_parent(phy);
3649 3649
3650 if (mdio == NULL) 3650 if (mdio == NULL)
3651 return -1; 3651 return -ENODEV;
3652 3652
3653 err = of_address_to_resource(mdio, 0, &res); 3653 err = of_address_to_resource(mdio, 0, &res);
3654 of_node_put(mdio);
3655
3656 if (err)
3657 return -1;
3658 3654
3655 if (err) {
3656 of_node_put(mdio);
3657 return err;
3658 }
3659 fsl_pq_mdio_bus_name(bus_name, mdio); 3659 fsl_pq_mdio_bus_name(bus_name, mdio);
3660 of_node_put(mdio);
3660 snprintf(ug_info->phy_bus_id, sizeof(ug_info->phy_bus_id), 3661 snprintf(ug_info->phy_bus_id, sizeof(ug_info->phy_bus_id),
3661 "%s:%02x", bus_name, *prop); 3662 "%s:%02x", bus_name, *prop);
3662 } 3663 }
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 7e80aba8a148..f21a6171c691 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -2752,7 +2752,6 @@ static const struct net_device_ops airo_netdev_ops = {
2752 .ndo_set_mac_address = airo_set_mac_address, 2752 .ndo_set_mac_address = airo_set_mac_address,
2753 .ndo_do_ioctl = airo_ioctl, 2753 .ndo_do_ioctl = airo_ioctl,
2754 .ndo_change_mtu = airo_change_mtu, 2754 .ndo_change_mtu = airo_change_mtu,
2755 .ndo_set_mac_address = eth_mac_addr,
2756 .ndo_validate_addr = eth_validate_addr, 2755 .ndo_validate_addr = eth_validate_addr,
2757}; 2756};
2758 2757
@@ -2765,7 +2764,6 @@ static const struct net_device_ops mpi_netdev_ops = {
2765 .ndo_set_mac_address = airo_set_mac_address, 2764 .ndo_set_mac_address = airo_set_mac_address,
2766 .ndo_do_ioctl = airo_ioctl, 2765 .ndo_do_ioctl = airo_ioctl,
2767 .ndo_change_mtu = airo_change_mtu, 2766 .ndo_change_mtu = airo_change_mtu,
2768 .ndo_set_mac_address = eth_mac_addr,
2769 .ndo_validate_addr = eth_validate_addr, 2767 .ndo_validate_addr = eth_validate_addr,
2770}; 2768};
2771 2769
@@ -4494,7 +4492,6 @@ static int setup_proc_entry( struct net_device *dev,
4494 goto fail; 4492 goto fail;
4495 apriv->proc_entry->uid = proc_uid; 4493 apriv->proc_entry->uid = proc_uid;
4496 apriv->proc_entry->gid = proc_gid; 4494 apriv->proc_entry->gid = proc_gid;
4497 apriv->proc_entry->owner = THIS_MODULE;
4498 4495
4499 /* Setup the StatsDelta */ 4496 /* Setup the StatsDelta */
4500 entry = proc_create_data("StatsDelta", 4497 entry = proc_create_data("StatsDelta",
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
index b3449948a25a..4a92af1d7877 100644
--- a/drivers/net/wireless/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/ipw2x00/ipw2200.c
@@ -11593,7 +11593,6 @@ static const struct net_device_ops ipw_netdev_ops = {
11593 .ndo_set_mac_address = ipw_net_set_mac_address, 11593 .ndo_set_mac_address = ipw_net_set_mac_address,
11594 .ndo_start_xmit = ieee80211_xmit, 11594 .ndo_start_xmit = ieee80211_xmit,
11595 .ndo_change_mtu = ieee80211_change_mtu, 11595 .ndo_change_mtu = ieee80211_change_mtu,
11596 .ndo_set_mac_address = eth_mac_addr,
11597 .ndo_validate_addr = eth_validate_addr, 11596 .ndo_validate_addr = eth_validate_addr,
11598}; 11597};
11599 11598
diff --git a/drivers/net/wireless/prism54/islpci_dev.c b/drivers/net/wireless/prism54/islpci_dev.c
index 166ed9584601..e26d7b3ceab5 100644
--- a/drivers/net/wireless/prism54/islpci_dev.c
+++ b/drivers/net/wireless/prism54/islpci_dev.c
@@ -803,7 +803,6 @@ static const struct net_device_ops islpci_netdev_ops = {
803 .ndo_tx_timeout = islpci_eth_tx_timeout, 803 .ndo_tx_timeout = islpci_eth_tx_timeout,
804 .ndo_set_mac_address = prism54_set_mac_address, 804 .ndo_set_mac_address = prism54_set_mac_address,
805 .ndo_change_mtu = eth_change_mtu, 805 .ndo_change_mtu = eth_change_mtu,
806 .ndo_set_mac_address = eth_mac_addr,
807 .ndo_validate_addr = eth_validate_addr, 806 .ndo_validate_addr = eth_validate_addr,
808}; 807};
809 808
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c
index 9b244c96b221..5fabd9c0f07a 100644
--- a/drivers/net/wireless/zd1201.c
+++ b/drivers/net/wireless/zd1201.c
@@ -1725,7 +1725,6 @@ static const struct net_device_ops zd1201_netdev_ops = {
1725 .ndo_set_multicast_list = zd1201_set_multicast, 1725 .ndo_set_multicast_list = zd1201_set_multicast,
1726 .ndo_set_mac_address = zd1201_set_mac_address, 1726 .ndo_set_mac_address = zd1201_set_mac_address,
1727 .ndo_change_mtu = eth_change_mtu, 1727 .ndo_change_mtu = eth_change_mtu,
1728 .ndo_set_mac_address = eth_mac_addr,
1729 .ndo_validate_addr = eth_validate_addr, 1728 .ndo_validate_addr = eth_validate_addr,
1730}; 1729};
1731 1730
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index b522f883d674..16240390bcde 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -351,53 +351,60 @@ static int pci_legacy_suspend(struct device *dev, pm_message_t state)
351{ 351{
352 struct pci_dev * pci_dev = to_pci_dev(dev); 352 struct pci_dev * pci_dev = to_pci_dev(dev);
353 struct pci_driver * drv = pci_dev->driver; 353 struct pci_driver * drv = pci_dev->driver;
354 int i = 0; 354
355 pci_dev->state_saved = false;
355 356
356 if (drv && drv->suspend) { 357 if (drv && drv->suspend) {
357 pci_power_t prev = pci_dev->current_state; 358 pci_power_t prev = pci_dev->current_state;
359 int error;
358 360
359 pci_dev->state_saved = false; 361 error = drv->suspend(pci_dev, state);
360 362 suspend_report_result(drv->suspend, error);
361 i = drv->suspend(pci_dev, state); 363 if (error)
362 suspend_report_result(drv->suspend, i); 364 return error;
363 if (i)
364 return i;
365
366 if (pci_dev->state_saved)
367 goto Fixup;
368 365
369 if (pci_dev->current_state != PCI_D0 366 if (!pci_dev->state_saved && pci_dev->current_state != PCI_D0
370 && pci_dev->current_state != PCI_UNKNOWN) { 367 && pci_dev->current_state != PCI_UNKNOWN) {
371 WARN_ONCE(pci_dev->current_state != prev, 368 WARN_ONCE(pci_dev->current_state != prev,
372 "PCI PM: Device state not saved by %pF\n", 369 "PCI PM: Device state not saved by %pF\n",
373 drv->suspend); 370 drv->suspend);
374 goto Fixup;
375 } 371 }
376 } 372 }
377 373
378 pci_save_state(pci_dev);
379 /*
380 * This is for compatibility with existing code with legacy PM support.
381 */
382 pci_pm_set_unknown_state(pci_dev);
383
384 Fixup:
385 pci_fixup_device(pci_fixup_suspend, pci_dev); 374 pci_fixup_device(pci_fixup_suspend, pci_dev);
386 375
387 return i; 376 return 0;
388} 377}
389 378
390static int pci_legacy_suspend_late(struct device *dev, pm_message_t state) 379static int pci_legacy_suspend_late(struct device *dev, pm_message_t state)
391{ 380{
392 struct pci_dev * pci_dev = to_pci_dev(dev); 381 struct pci_dev * pci_dev = to_pci_dev(dev);
393 struct pci_driver * drv = pci_dev->driver; 382 struct pci_driver * drv = pci_dev->driver;
394 int i = 0;
395 383
396 if (drv && drv->suspend_late) { 384 if (drv && drv->suspend_late) {
397 i = drv->suspend_late(pci_dev, state); 385 pci_power_t prev = pci_dev->current_state;
398 suspend_report_result(drv->suspend_late, i); 386 int error;
387
388 error = drv->suspend_late(pci_dev, state);
389 suspend_report_result(drv->suspend_late, error);
390 if (error)
391 return error;
392
393 if (!pci_dev->state_saved && pci_dev->current_state != PCI_D0
394 && pci_dev->current_state != PCI_UNKNOWN) {
395 WARN_ONCE(pci_dev->current_state != prev,
396 "PCI PM: Device state not saved by %pF\n",
397 drv->suspend_late);
398 return 0;
399 }
399 } 400 }
400 return i; 401
402 if (!pci_dev->state_saved)
403 pci_save_state(pci_dev);
404
405 pci_pm_set_unknown_state(pci_dev);
406
407 return 0;
401} 408}
402 409
403static int pci_legacy_resume_early(struct device *dev) 410static int pci_legacy_resume_early(struct device *dev)
@@ -422,6 +429,23 @@ static int pci_legacy_resume(struct device *dev)
422 429
423/* Auxiliary functions used by the new power management framework */ 430/* Auxiliary functions used by the new power management framework */
424 431
432/**
433 * pci_restore_standard_config - restore standard config registers of PCI device
434 * @pci_dev: PCI device to handle
435 */
436static int pci_restore_standard_config(struct pci_dev *pci_dev)
437{
438 pci_update_current_state(pci_dev, PCI_UNKNOWN);
439
440 if (pci_dev->current_state != PCI_D0) {
441 int error = pci_set_power_state(pci_dev, PCI_D0);
442 if (error)
443 return error;
444 }
445
446 return pci_dev->state_saved ? pci_restore_state(pci_dev) : 0;
447}
448
425static void pci_pm_default_resume_noirq(struct pci_dev *pci_dev) 449static void pci_pm_default_resume_noirq(struct pci_dev *pci_dev)
426{ 450{
427 pci_restore_standard_config(pci_dev); 451 pci_restore_standard_config(pci_dev);
@@ -442,7 +466,6 @@ static void pci_pm_default_suspend(struct pci_dev *pci_dev)
442 /* Disable non-bridge devices without PM support */ 466 /* Disable non-bridge devices without PM support */
443 if (!pci_is_bridge(pci_dev)) 467 if (!pci_is_bridge(pci_dev))
444 pci_disable_enabled_device(pci_dev); 468 pci_disable_enabled_device(pci_dev);
445 pci_save_state(pci_dev);
446} 469}
447 470
448static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev) 471static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev)
@@ -492,13 +515,13 @@ static int pci_pm_suspend(struct device *dev)
492 if (pci_has_legacy_pm_support(pci_dev)) 515 if (pci_has_legacy_pm_support(pci_dev))
493 return pci_legacy_suspend(dev, PMSG_SUSPEND); 516 return pci_legacy_suspend(dev, PMSG_SUSPEND);
494 517
518 pci_dev->state_saved = false;
519
495 if (!pm) { 520 if (!pm) {
496 pci_pm_default_suspend(pci_dev); 521 pci_pm_default_suspend(pci_dev);
497 goto Fixup; 522 goto Fixup;
498 } 523 }
499 524
500 pci_dev->state_saved = false;
501
502 if (pm->suspend) { 525 if (pm->suspend) {
503 pci_power_t prev = pci_dev->current_state; 526 pci_power_t prev = pci_dev->current_state;
504 int error; 527 int error;
@@ -508,24 +531,14 @@ static int pci_pm_suspend(struct device *dev)
508 if (error) 531 if (error)
509 return error; 532 return error;
510 533
511 if (pci_dev->state_saved) 534 if (!pci_dev->state_saved && pci_dev->current_state != PCI_D0
512 goto Fixup;
513
514 if (pci_dev->current_state != PCI_D0
515 && pci_dev->current_state != PCI_UNKNOWN) { 535 && pci_dev->current_state != PCI_UNKNOWN) {
516 WARN_ONCE(pci_dev->current_state != prev, 536 WARN_ONCE(pci_dev->current_state != prev,
517 "PCI PM: State of device not saved by %pF\n", 537 "PCI PM: State of device not saved by %pF\n",
518 pm->suspend); 538 pm->suspend);
519 goto Fixup;
520 } 539 }
521 } 540 }
522 541
523 if (!pci_dev->state_saved) {
524 pci_save_state(pci_dev);
525 if (!pci_is_bridge(pci_dev))
526 pci_prepare_to_sleep(pci_dev);
527 }
528
529 Fixup: 542 Fixup:
530 pci_fixup_device(pci_fixup_suspend, pci_dev); 543 pci_fixup_device(pci_fixup_suspend, pci_dev);
531 544
@@ -535,21 +548,43 @@ static int pci_pm_suspend(struct device *dev)
535static int pci_pm_suspend_noirq(struct device *dev) 548static int pci_pm_suspend_noirq(struct device *dev)
536{ 549{
537 struct pci_dev *pci_dev = to_pci_dev(dev); 550 struct pci_dev *pci_dev = to_pci_dev(dev);
538 struct device_driver *drv = dev->driver; 551 struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
539 int error = 0;
540 552
541 if (pci_has_legacy_pm_support(pci_dev)) 553 if (pci_has_legacy_pm_support(pci_dev))
542 return pci_legacy_suspend_late(dev, PMSG_SUSPEND); 554 return pci_legacy_suspend_late(dev, PMSG_SUSPEND);
543 555
544 if (drv && drv->pm && drv->pm->suspend_noirq) { 556 if (!pm) {
545 error = drv->pm->suspend_noirq(dev); 557 pci_save_state(pci_dev);
546 suspend_report_result(drv->pm->suspend_noirq, error); 558 return 0;
547 } 559 }
548 560
549 if (!error) 561 if (pm->suspend_noirq) {
550 pci_pm_set_unknown_state(pci_dev); 562 pci_power_t prev = pci_dev->current_state;
563 int error;
551 564
552 return error; 565 error = pm->suspend_noirq(dev);
566 suspend_report_result(pm->suspend_noirq, error);
567 if (error)
568 return error;
569
570 if (!pci_dev->state_saved && pci_dev->current_state != PCI_D0
571 && pci_dev->current_state != PCI_UNKNOWN) {
572 WARN_ONCE(pci_dev->current_state != prev,
573 "PCI PM: State of device not saved by %pF\n",
574 pm->suspend_noirq);
575 return 0;
576 }
577 }
578
579 if (!pci_dev->state_saved) {
580 pci_save_state(pci_dev);
581 if (!pci_is_bridge(pci_dev))
582 pci_prepare_to_sleep(pci_dev);
583 }
584
585 pci_pm_set_unknown_state(pci_dev);
586
587 return 0;
553} 588}
554 589
555static int pci_pm_resume_noirq(struct device *dev) 590static int pci_pm_resume_noirq(struct device *dev)
@@ -616,13 +651,13 @@ static int pci_pm_freeze(struct device *dev)
616 if (pci_has_legacy_pm_support(pci_dev)) 651 if (pci_has_legacy_pm_support(pci_dev))
617 return pci_legacy_suspend(dev, PMSG_FREEZE); 652 return pci_legacy_suspend(dev, PMSG_FREEZE);
618 653
654 pci_dev->state_saved = false;
655
619 if (!pm) { 656 if (!pm) {
620 pci_pm_default_suspend(pci_dev); 657 pci_pm_default_suspend(pci_dev);
621 return 0; 658 return 0;
622 } 659 }
623 660
624 pci_dev->state_saved = false;
625
626 if (pm->freeze) { 661 if (pm->freeze) {
627 int error; 662 int error;
628 663
@@ -632,9 +667,6 @@ static int pci_pm_freeze(struct device *dev)
632 return error; 667 return error;
633 } 668 }
634 669
635 if (!pci_dev->state_saved)
636 pci_save_state(pci_dev);
637
638 return 0; 670 return 0;
639} 671}
640 672
@@ -642,20 +674,25 @@ static int pci_pm_freeze_noirq(struct device *dev)
642{ 674{
643 struct pci_dev *pci_dev = to_pci_dev(dev); 675 struct pci_dev *pci_dev = to_pci_dev(dev);
644 struct device_driver *drv = dev->driver; 676 struct device_driver *drv = dev->driver;
645 int error = 0;
646 677
647 if (pci_has_legacy_pm_support(pci_dev)) 678 if (pci_has_legacy_pm_support(pci_dev))
648 return pci_legacy_suspend_late(dev, PMSG_FREEZE); 679 return pci_legacy_suspend_late(dev, PMSG_FREEZE);
649 680
650 if (drv && drv->pm && drv->pm->freeze_noirq) { 681 if (drv && drv->pm && drv->pm->freeze_noirq) {
682 int error;
683
651 error = drv->pm->freeze_noirq(dev); 684 error = drv->pm->freeze_noirq(dev);
652 suspend_report_result(drv->pm->freeze_noirq, error); 685 suspend_report_result(drv->pm->freeze_noirq, error);
686 if (error)
687 return error;
653 } 688 }
654 689
655 if (!error) 690 if (!pci_dev->state_saved)
656 pci_pm_set_unknown_state(pci_dev); 691 pci_save_state(pci_dev);
657 692
658 return error; 693 pci_pm_set_unknown_state(pci_dev);
694
695 return 0;
659} 696}
660 697
661static int pci_pm_thaw_noirq(struct device *dev) 698static int pci_pm_thaw_noirq(struct device *dev)
@@ -698,46 +735,56 @@ static int pci_pm_poweroff(struct device *dev)
698{ 735{
699 struct pci_dev *pci_dev = to_pci_dev(dev); 736 struct pci_dev *pci_dev = to_pci_dev(dev);
700 struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; 737 struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
701 int error = 0;
702 738
703 if (pci_has_legacy_pm_support(pci_dev)) 739 if (pci_has_legacy_pm_support(pci_dev))
704 return pci_legacy_suspend(dev, PMSG_HIBERNATE); 740 return pci_legacy_suspend(dev, PMSG_HIBERNATE);
705 741
742 pci_dev->state_saved = false;
743
706 if (!pm) { 744 if (!pm) {
707 pci_pm_default_suspend(pci_dev); 745 pci_pm_default_suspend(pci_dev);
708 goto Fixup; 746 goto Fixup;
709 } 747 }
710 748
711 pci_dev->state_saved = false;
712
713 if (pm->poweroff) { 749 if (pm->poweroff) {
750 int error;
751
714 error = pm->poweroff(dev); 752 error = pm->poweroff(dev);
715 suspend_report_result(pm->poweroff, error); 753 suspend_report_result(pm->poweroff, error);
754 if (error)
755 return error;
716 } 756 }
717 757
718 if (!pci_dev->state_saved && !pci_is_bridge(pci_dev))
719 pci_prepare_to_sleep(pci_dev);
720
721 Fixup: 758 Fixup:
722 pci_fixup_device(pci_fixup_suspend, pci_dev); 759 pci_fixup_device(pci_fixup_suspend, pci_dev);
723 760
724 return error; 761 return 0;
725} 762}
726 763
727static int pci_pm_poweroff_noirq(struct device *dev) 764static int pci_pm_poweroff_noirq(struct device *dev)
728{ 765{
766 struct pci_dev *pci_dev = to_pci_dev(dev);
729 struct device_driver *drv = dev->driver; 767 struct device_driver *drv = dev->driver;
730 int error = 0;
731 768
732 if (pci_has_legacy_pm_support(to_pci_dev(dev))) 769 if (pci_has_legacy_pm_support(to_pci_dev(dev)))
733 return pci_legacy_suspend_late(dev, PMSG_HIBERNATE); 770 return pci_legacy_suspend_late(dev, PMSG_HIBERNATE);
734 771
735 if (drv && drv->pm && drv->pm->poweroff_noirq) { 772 if (!drv || !drv->pm)
773 return 0;
774
775 if (drv->pm->poweroff_noirq) {
776 int error;
777
736 error = drv->pm->poweroff_noirq(dev); 778 error = drv->pm->poweroff_noirq(dev);
737 suspend_report_result(drv->pm->poweroff_noirq, error); 779 suspend_report_result(drv->pm->poweroff_noirq, error);
780 if (error)
781 return error;
738 } 782 }
739 783
740 return error; 784 if (!pci_dev->state_saved && !pci_is_bridge(pci_dev))
785 pci_prepare_to_sleep(pci_dev);
786
787 return 0;
741} 788}
742 789
743static int pci_pm_restore_noirq(struct device *dev) 790static int pci_pm_restore_noirq(struct device *dev)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 6d6120007af4..0195066251e5 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -426,7 +426,6 @@ static inline int platform_pci_sleep_wake(struct pci_dev *dev, bool enable)
426 * given PCI device 426 * given PCI device
427 * @dev: PCI device to handle. 427 * @dev: PCI device to handle.
428 * @state: PCI power state (D0, D1, D2, D3hot) to put the device into. 428 * @state: PCI power state (D0, D1, D2, D3hot) to put the device into.
429 * @wait: If 'true', wait for the device to change its power state
430 * 429 *
431 * RETURN VALUE: 430 * RETURN VALUE:
432 * -EINVAL if the requested state is invalid. 431 * -EINVAL if the requested state is invalid.
@@ -435,12 +434,15 @@ static inline int platform_pci_sleep_wake(struct pci_dev *dev, bool enable)
435 * 0 if device already is in the requested state. 434 * 0 if device already is in the requested state.
436 * 0 if device's power state has been successfully changed. 435 * 0 if device's power state has been successfully changed.
437 */ 436 */
438static int 437static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state)
439pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state, bool wait)
440{ 438{
441 u16 pmcsr; 439 u16 pmcsr;
442 bool need_restore = false; 440 bool need_restore = false;
443 441
442 /* Check if we're already there */
443 if (dev->current_state == state)
444 return 0;
445
444 if (!dev->pm_cap) 446 if (!dev->pm_cap)
445 return -EIO; 447 return -EIO;
446 448
@@ -451,10 +453,7 @@ pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state, bool wait)
451 * Can enter D0 from any state, but if we can only go deeper 453 * Can enter D0 from any state, but if we can only go deeper
452 * to sleep if we're already in a low power state 454 * to sleep if we're already in a low power state
453 */ 455 */
454 if (dev->current_state == state) { 456 if (state != PCI_D0 && dev->current_state <= PCI_D3cold
455 /* we're already there */
456 return 0;
457 } else if (state != PCI_D0 && dev->current_state <= PCI_D3cold
458 && dev->current_state > state) { 457 && dev->current_state > state) {
459 dev_err(&dev->dev, "invalid power transition " 458 dev_err(&dev->dev, "invalid power transition "
460 "(from state %d to %d)\n", dev->current_state, state); 459 "(from state %d to %d)\n", dev->current_state, state);
@@ -481,10 +480,8 @@ pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state, bool wait)
481 break; 480 break;
482 case PCI_UNKNOWN: /* Boot-up */ 481 case PCI_UNKNOWN: /* Boot-up */
483 if ((pmcsr & PCI_PM_CTRL_STATE_MASK) == PCI_D3hot 482 if ((pmcsr & PCI_PM_CTRL_STATE_MASK) == PCI_D3hot
484 && !(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET)) { 483 && !(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET))
485 need_restore = true; 484 need_restore = true;
486 wait = true;
487 }
488 /* Fall-through: force to D0 */ 485 /* Fall-through: force to D0 */
489 default: 486 default:
490 pmcsr = 0; 487 pmcsr = 0;
@@ -494,9 +491,6 @@ pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state, bool wait)
494 /* enter specified state */ 491 /* enter specified state */
495 pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pmcsr); 492 pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pmcsr);
496 493
497 if (!wait)
498 return 0;
499
500 /* Mandatory power management transition delays */ 494 /* Mandatory power management transition delays */
501 /* see PCI PM 1.1 5.6.1 table 18 */ 495 /* see PCI PM 1.1 5.6.1 table 18 */
502 if (state == PCI_D3hot || dev->current_state == PCI_D3hot) 496 if (state == PCI_D3hot || dev->current_state == PCI_D3hot)
@@ -521,7 +515,7 @@ pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state, bool wait)
521 if (need_restore) 515 if (need_restore)
522 pci_restore_bars(dev); 516 pci_restore_bars(dev);
523 517
524 if (wait && dev->bus->self) 518 if (dev->bus->self)
525 pcie_aspm_pm_state_change(dev->bus->self); 519 pcie_aspm_pm_state_change(dev->bus->self);
526 520
527 return 0; 521 return 0;
@@ -546,6 +540,53 @@ void pci_update_current_state(struct pci_dev *dev, pci_power_t state)
546} 540}
547 541
548/** 542/**
543 * pci_platform_power_transition - Use platform to change device power state
544 * @dev: PCI device to handle.
545 * @state: State to put the device into.
546 */
547static int pci_platform_power_transition(struct pci_dev *dev, pci_power_t state)
548{
549 int error;
550
551 if (platform_pci_power_manageable(dev)) {
552 error = platform_pci_set_power_state(dev, state);
553 if (!error)
554 pci_update_current_state(dev, state);
555 } else {
556 error = -ENODEV;
557 /* Fall back to PCI_D0 if native PM is not supported */
558 pci_update_current_state(dev, PCI_D0);
559 }
560
561 return error;
562}
563
564/**
565 * __pci_start_power_transition - Start power transition of a PCI device
566 * @dev: PCI device to handle.
567 * @state: State to put the device into.
568 */
569static void __pci_start_power_transition(struct pci_dev *dev, pci_power_t state)
570{
571 if (state == PCI_D0)
572 pci_platform_power_transition(dev, PCI_D0);
573}
574
575/**
576 * __pci_complete_power_transition - Complete power transition of a PCI device
577 * @dev: PCI device to handle.
578 * @state: State to put the device into.
579 *
580 * This function should not be called directly by device drivers.
581 */
582int __pci_complete_power_transition(struct pci_dev *dev, pci_power_t state)
583{
584 return state > PCI_D0 ?
585 pci_platform_power_transition(dev, state) : -EINVAL;
586}
587EXPORT_SYMBOL_GPL(__pci_complete_power_transition);
588
589/**
549 * pci_set_power_state - Set the power state of a PCI device 590 * pci_set_power_state - Set the power state of a PCI device
550 * @dev: PCI device to handle. 591 * @dev: PCI device to handle.
551 * @state: PCI power state (D0, D1, D2, D3hot) to put the device into. 592 * @state: PCI power state (D0, D1, D2, D3hot) to put the device into.
@@ -577,30 +618,21 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
577 */ 618 */
578 return 0; 619 return 0;
579 620
580 if (state == PCI_D0 && platform_pci_power_manageable(dev)) { 621 /* Check if we're already there */
581 /* 622 if (dev->current_state == state)
582 * Allow the platform to change the state, for example via ACPI 623 return 0;
583 * _PR0, _PS0 and some such, but do not trust it. 624
584 */ 625 __pci_start_power_transition(dev, state);
585 int ret = platform_pci_set_power_state(dev, PCI_D0); 626
586 if (!ret)
587 pci_update_current_state(dev, PCI_D0);
588 }
589 /* This device is quirked not to be put into D3, so 627 /* This device is quirked not to be put into D3, so
590 don't put it in D3 */ 628 don't put it in D3 */
591 if (state == PCI_D3hot && (dev->dev_flags & PCI_DEV_FLAGS_NO_D3)) 629 if (state == PCI_D3hot && (dev->dev_flags & PCI_DEV_FLAGS_NO_D3))
592 return 0; 630 return 0;
593 631
594 error = pci_raw_set_power_state(dev, state, true); 632 error = pci_raw_set_power_state(dev, state);
595 633
596 if (state > PCI_D0 && platform_pci_power_manageable(dev)) { 634 if (!__pci_complete_power_transition(dev, state))
597 /* Allow the platform to finalize the transition */ 635 error = 0;
598 int ret = platform_pci_set_power_state(dev, state);
599 if (!ret) {
600 pci_update_current_state(dev, state);
601 error = 0;
602 }
603 }
604 636
605 return error; 637 return error;
606} 638}
@@ -1231,7 +1263,7 @@ int pci_prepare_to_sleep(struct pci_dev *dev)
1231 if (target_state == PCI_POWER_ERROR) 1263 if (target_state == PCI_POWER_ERROR)
1232 return -EIO; 1264 return -EIO;
1233 1265
1234 pci_enable_wake(dev, target_state, true); 1266 pci_enable_wake(dev, target_state, device_may_wakeup(&dev->dev));
1235 1267
1236 error = pci_set_power_state(dev, target_state); 1268 error = pci_set_power_state(dev, target_state);
1237 1269
@@ -1381,50 +1413,6 @@ void pci_allocate_cap_save_buffers(struct pci_dev *dev)
1381} 1413}
1382 1414
1383/** 1415/**
1384 * pci_restore_standard_config - restore standard config registers of PCI device
1385 * @dev: PCI device to handle
1386 *
1387 * This function assumes that the device's configuration space is accessible.
1388 * If the device needs to be powered up, the function will wait for it to
1389 * change the state.
1390 */
1391int pci_restore_standard_config(struct pci_dev *dev)
1392{
1393 pci_power_t prev_state;
1394 int error;
1395
1396 pci_update_current_state(dev, PCI_D0);
1397
1398 prev_state = dev->current_state;
1399 if (prev_state == PCI_D0)
1400 goto Restore;
1401
1402 error = pci_raw_set_power_state(dev, PCI_D0, false);
1403 if (error)
1404 return error;
1405
1406 /*
1407 * This assumes that we won't get a bus in B2 or B3 from the BIOS, but
1408 * we've made this assumption forever and it appears to be universally
1409 * satisfied.
1410 */
1411 switch(prev_state) {
1412 case PCI_D3cold:
1413 case PCI_D3hot:
1414 mdelay(pci_pm_d3_delay);
1415 break;
1416 case PCI_D2:
1417 udelay(PCI_PM_D2_DELAY);
1418 break;
1419 }
1420
1421 pci_update_current_state(dev, PCI_D0);
1422
1423 Restore:
1424 return dev->state_saved ? pci_restore_state(dev) : 0;
1425}
1426
1427/**
1428 * pci_enable_ari - enable ARI forwarding if hardware support it 1416 * pci_enable_ari - enable ARI forwarding if hardware support it
1429 * @dev: the PCI device 1417 * @dev: the PCI device
1430 */ 1418 */
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 07c0aa5275e6..149fff65891f 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -49,7 +49,6 @@ extern void pci_disable_enabled_device(struct pci_dev *dev);
49extern void pci_pm_init(struct pci_dev *dev); 49extern void pci_pm_init(struct pci_dev *dev);
50extern void platform_pci_wakeup_init(struct pci_dev *dev); 50extern void platform_pci_wakeup_init(struct pci_dev *dev);
51extern void pci_allocate_cap_save_buffers(struct pci_dev *dev); 51extern void pci_allocate_cap_save_buffers(struct pci_dev *dev);
52extern int pci_restore_standard_config(struct pci_dev *dev);
53 52
54static inline bool pci_is_bridge(struct pci_dev *pci_dev) 53static inline bool pci_is_bridge(struct pci_dev *pci_dev)
55{ 54{
diff --git a/drivers/platform/x86/asus_acpi.c b/drivers/platform/x86/asus_acpi.c
index d63f26e666a4..ba1f7497e4b9 100644
--- a/drivers/platform/x86/asus_acpi.c
+++ b/drivers/platform/x86/asus_acpi.c
@@ -987,7 +987,6 @@ asus_proc_add(char *name, proc_writefunc *writefunc,
987 proc->write_proc = writefunc; 987 proc->write_proc = writefunc;
988 proc->read_proc = readfunc; 988 proc->read_proc = readfunc;
989 proc->data = acpi_driver_data(device); 989 proc->data = acpi_driver_data(device);
990 proc->owner = THIS_MODULE;
991 proc->uid = asus_uid; 990 proc->uid = asus_uid;
992 proc->gid = asus_gid; 991 proc->gid = asus_gid;
993 return 0; 992 return 0;
@@ -1020,7 +1019,6 @@ static int asus_hotk_add_fs(struct acpi_device *device)
1020 if (proc) { 1019 if (proc) {
1021 proc->read_proc = proc_read_info; 1020 proc->read_proc = proc_read_info;
1022 proc->data = acpi_driver_data(device); 1021 proc->data = acpi_driver_data(device);
1023 proc->owner = THIS_MODULE;
1024 proc->uid = asus_uid; 1022 proc->uid = asus_uid;
1025 proc->gid = asus_gid; 1023 proc->gid = asus_gid;
1026 } else { 1024 } else {
@@ -1436,7 +1434,6 @@ static int __init asus_acpi_init(void)
1436 printk(KERN_ERR "Asus ACPI: Unable to create /proc entry\n"); 1434 printk(KERN_ERR "Asus ACPI: Unable to create /proc entry\n");
1437 return -ENODEV; 1435 return -ENODEV;
1438 } 1436 }
1439 asus_proc_dir->owner = THIS_MODULE;
1440 1437
1441 result = acpi_bus_register_driver(&asus_hotk_driver); 1438 result = acpi_bus_register_driver(&asus_hotk_driver);
1442 if (result < 0) { 1439 if (result < 0) {
diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
index 16e11c2ee19a..af9f43021172 100644
--- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -103,7 +103,7 @@ static void parse_da_table(const struct dmi_header *dm)
103 da_num_tokens += tokens; 103 da_num_tokens += tokens;
104} 104}
105 105
106static void find_tokens(const struct dmi_header *dm) 106static void find_tokens(const struct dmi_header *dm, void *dummy)
107{ 107{
108 switch (dm->type) { 108 switch (dm->type) {
109 case 0xd4: /* Indexed IO */ 109 case 0xd4: /* Indexed IO */
@@ -356,7 +356,7 @@ static int __init dell_init(void)
356 if (!dmi_check_system(dell_device_table)) 356 if (!dmi_check_system(dell_device_table))
357 return -ENODEV; 357 return -ENODEV;
358 358
359 dmi_walk(find_tokens); 359 dmi_walk(find_tokens, NULL);
360 360
361 if (!da_tokens) { 361 if (!da_tokens) {
362 printk(KERN_INFO "dell-laptop: Unable to find dmi tokens\n"); 362 printk(KERN_INFO "dell-laptop: Unable to find dmi tokens\n");
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index d2433204a40c..3dad27a385d3 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -6992,7 +6992,6 @@ static int __init ibm_init(struct ibm_init_struct *iibm)
6992 ret = -ENODEV; 6992 ret = -ENODEV;
6993 goto err_out; 6993 goto err_out;
6994 } 6994 }
6995 entry->owner = THIS_MODULE;
6996 entry->data = ibm; 6995 entry->data = ibm;
6997 entry->read_proc = &dispatch_procfs_read; 6996 entry->read_proc = &dispatch_procfs_read;
6998 if (ibm->write) 6997 if (ibm->write)
@@ -7405,7 +7404,6 @@ static int __init thinkpad_acpi_module_init(void)
7405 thinkpad_acpi_module_exit(); 7404 thinkpad_acpi_module_exit();
7406 return -ENODEV; 7405 return -ENODEV;
7407 } 7406 }
7408 proc_dir->owner = THIS_MODULE;
7409 7407
7410 ret = platform_driver_register(&tpacpi_pdriver); 7408 ret = platform_driver_register(&tpacpi_pdriver);
7411 if (ret) { 7409 if (ret) {
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 40e60fc2e596..9f187265db8e 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -679,8 +679,6 @@ static acpi_status __init add_device(void)
679 toshiba_proc_dir, 679 toshiba_proc_dir,
680 (read_proc_t *) dispatch_read, 680 (read_proc_t *) dispatch_read,
681 item); 681 item);
682 if (proc)
683 proc->owner = THIS_MODULE;
684 if (proc && item->write_func) 682 if (proc && item->write_func)
685 proc->write_proc = (write_proc_t *) dispatch_write; 683 proc->write_proc = (write_proc_t *) dispatch_write;
686 } 684 }
@@ -772,7 +770,6 @@ static int __init toshiba_acpi_init(void)
772 toshiba_acpi_exit(); 770 toshiba_acpi_exit();
773 return -ENODEV; 771 return -ENODEV;
774 } else { 772 } else {
775 toshiba_proc_dir->owner = THIS_MODULE;
776 status = add_device(); 773 status = add_device();
777 if (ACPI_FAILURE(status)) { 774 if (ACPI_FAILURE(status)) {
778 toshiba_acpi_exit(); 775 toshiba_acpi_exit();
diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c
index 0c6257a034ff..c086fc30a84c 100644
--- a/drivers/rtc/rtc-proc.c
+++ b/drivers/rtc/rtc-proc.c
@@ -105,14 +105,8 @@ static const struct file_operations rtc_proc_fops = {
105 105
106void rtc_proc_add_device(struct rtc_device *rtc) 106void rtc_proc_add_device(struct rtc_device *rtc)
107{ 107{
108 if (rtc->id == 0) { 108 if (rtc->id == 0)
109 struct proc_dir_entry *ent; 109 proc_create_data("driver/rtc", 0, NULL, &rtc_proc_fops, rtc);
110
111 ent = proc_create_data("driver/rtc", 0, NULL,
112 &rtc_proc_fops, rtc);
113 if (ent)
114 ent->owner = rtc->owner;
115 }
116} 110}
117 111
118void rtc_proc_del_device(struct rtc_device *rtc) 112void rtc_proc_del_device(struct rtc_device *rtc)
diff --git a/drivers/s390/block/dasd_proc.c b/drivers/s390/block/dasd_proc.c
index 2080ba6a69b0..654daa3cdfda 100644
--- a/drivers/s390/block/dasd_proc.c
+++ b/drivers/s390/block/dasd_proc.c
@@ -320,7 +320,6 @@ dasd_proc_init(void)
320 dasd_proc_root_entry = proc_mkdir("dasd", NULL); 320 dasd_proc_root_entry = proc_mkdir("dasd", NULL);
321 if (!dasd_proc_root_entry) 321 if (!dasd_proc_root_entry)
322 goto out_nodasd; 322 goto out_nodasd;
323 dasd_proc_root_entry->owner = THIS_MODULE;
324 dasd_devices_entry = proc_create("devices", 323 dasd_devices_entry = proc_create("devices",
325 S_IFREG | S_IRUGO | S_IWUSR, 324 S_IFREG | S_IRUGO | S_IWUSR,
326 dasd_proc_root_entry, 325 dasd_proc_root_entry,
@@ -334,7 +333,6 @@ dasd_proc_init(void)
334 goto out_nostatistics; 333 goto out_nostatistics;
335 dasd_statistics_entry->read_proc = dasd_statistics_read; 334 dasd_statistics_entry->read_proc = dasd_statistics_read;
336 dasd_statistics_entry->write_proc = dasd_statistics_write; 335 dasd_statistics_entry->write_proc = dasd_statistics_write;
337 dasd_statistics_entry->owner = THIS_MODULE;
338 return 0; 336 return 0;
339 337
340 out_nostatistics: 338 out_nostatistics:
diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index 099b5455bbce..b13481369642 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -596,8 +596,6 @@ int __init scsi_init_devinfo(void)
596 error = -ENOMEM; 596 error = -ENOMEM;
597 goto out; 597 goto out;
598 } 598 }
599
600 p->owner = THIS_MODULE;
601#endif /* CONFIG_SCSI_PROC_FS */ 599#endif /* CONFIG_SCSI_PROC_FS */
602 600
603 out: 601 out:
diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c
index 82f7b2dd08a2..77fbddb507fd 100644
--- a/drivers/scsi/scsi_proc.c
+++ b/drivers/scsi/scsi_proc.c
@@ -115,8 +115,6 @@ void scsi_proc_hostdir_add(struct scsi_host_template *sht)
115 if (!sht->proc_dir) 115 if (!sht->proc_dir)
116 printk(KERN_ERR "%s: proc_mkdir failed for %s\n", 116 printk(KERN_ERR "%s: proc_mkdir failed for %s\n",
117 __func__, sht->proc_name); 117 __func__, sht->proc_name);
118 else
119 sht->proc_dir->owner = sht->module;
120 } 118 }
121 mutex_unlock(&global_host_template_mutex); 119 mutex_unlock(&global_host_template_mutex);
122} 120}
@@ -163,7 +161,6 @@ void scsi_proc_host_add(struct Scsi_Host *shost)
163 } 161 }
164 162
165 p->write_proc = proc_scsi_write_proc; 163 p->write_proc = proc_scsi_write_proc;
166 p->owner = sht->module;
167} 164}
168 165
169/** 166/**
diff --git a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c
index c6d7cc76516f..1de0c0032468 100644
--- a/drivers/video/aty/radeon_pm.c
+++ b/drivers/video/aty/radeon_pm.c
@@ -2582,7 +2582,7 @@ static void radeon_set_suspend(struct radeonfb_info *rinfo, int suspend)
2582 * calling pci_set_power_state() 2582 * calling pci_set_power_state()
2583 */ 2583 */
2584 radeonfb_whack_power_state(rinfo, PCI_D2); 2584 radeonfb_whack_power_state(rinfo, PCI_D2);
2585 pci_set_power_state(rinfo->pdev, PCI_D2); 2585 __pci_complete_power_transition(rinfo->pdev, PCI_D2);
2586 } else { 2586 } else {
2587 printk(KERN_DEBUG "radeonfb (%s): switching to D0 state...\n", 2587 printk(KERN_DEBUG "radeonfb (%s): switching to D0 state...\n",
2588 pci_name(rinfo->pdev)); 2588 pci_name(rinfo->pdev));
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 37b433a08ce8..e327b84820d2 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -2059,25 +2059,21 @@ static void viafb_init_proc(struct proc_dir_entry **viafb_entry)
2059 if (viafb_entry) { 2059 if (viafb_entry) {
2060 entry = create_proc_entry("dvp0", 0, *viafb_entry); 2060 entry = create_proc_entry("dvp0", 0, *viafb_entry);
2061 if (entry) { 2061 if (entry) {
2062 entry->owner = THIS_MODULE;
2063 entry->read_proc = viafb_dvp0_proc_read; 2062 entry->read_proc = viafb_dvp0_proc_read;
2064 entry->write_proc = viafb_dvp0_proc_write; 2063 entry->write_proc = viafb_dvp0_proc_write;
2065 } 2064 }
2066 entry = create_proc_entry("dvp1", 0, *viafb_entry); 2065 entry = create_proc_entry("dvp1", 0, *viafb_entry);
2067 if (entry) { 2066 if (entry) {
2068 entry->owner = THIS_MODULE;
2069 entry->read_proc = viafb_dvp1_proc_read; 2067 entry->read_proc = viafb_dvp1_proc_read;
2070 entry->write_proc = viafb_dvp1_proc_write; 2068 entry->write_proc = viafb_dvp1_proc_write;
2071 } 2069 }
2072 entry = create_proc_entry("dfph", 0, *viafb_entry); 2070 entry = create_proc_entry("dfph", 0, *viafb_entry);
2073 if (entry) { 2071 if (entry) {
2074 entry->owner = THIS_MODULE;
2075 entry->read_proc = viafb_dfph_proc_read; 2072 entry->read_proc = viafb_dfph_proc_read;
2076 entry->write_proc = viafb_dfph_proc_write; 2073 entry->write_proc = viafb_dfph_proc_write;
2077 } 2074 }
2078 entry = create_proc_entry("dfpl", 0, *viafb_entry); 2075 entry = create_proc_entry("dfpl", 0, *viafb_entry);
2079 if (entry) { 2076 if (entry) {
2080 entry->owner = THIS_MODULE;
2081 entry->read_proc = viafb_dfpl_proc_read; 2077 entry->read_proc = viafb_dfpl_proc_read;
2082 entry->write_proc = viafb_dfpl_proc_write; 2078 entry->write_proc = viafb_dfpl_proc_write;
2083 } 2079 }
@@ -2086,7 +2082,6 @@ static void viafb_init_proc(struct proc_dir_entry **viafb_entry)
2086 viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) { 2082 viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
2087 entry = create_proc_entry("vt1636", 0, *viafb_entry); 2083 entry = create_proc_entry("vt1636", 0, *viafb_entry);
2088 if (entry) { 2084 if (entry) {
2089 entry->owner = THIS_MODULE;
2090 entry->read_proc = viafb_vt1636_proc_read; 2085 entry->read_proc = viafb_vt1636_proc_read;
2091 entry->write_proc = viafb_vt1636_proc_write; 2086 entry->write_proc = viafb_vt1636_proc_write;
2092 } 2087 }
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 5777196bf6c9..5c52369ab9bb 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -23,15 +23,21 @@
23 23
24#ifdef DEBUG 24#ifdef DEBUG
25/* For development, we want to crash whenever the ring is screwed. */ 25/* For development, we want to crash whenever the ring is screwed. */
26#define BAD_RING(vq, fmt...) \ 26#define BAD_RING(_vq, fmt...) \
27 do { dev_err(&vq->vq.vdev->dev, fmt); BUG(); } while(0) 27 do { dev_err(&(_vq)->vq.vdev->dev, fmt); BUG(); } while(0)
28#define START_USE(vq) \ 28/* Caller is supposed to guarantee no reentry. */
29 do { if ((vq)->in_use) panic("in_use = %i\n", (vq)->in_use); (vq)->in_use = __LINE__; mb(); } while(0) 29#define START_USE(_vq) \
30#define END_USE(vq) \ 30 do { \
31 do { BUG_ON(!(vq)->in_use); (vq)->in_use = 0; mb(); } while(0) 31 if ((_vq)->in_use) \
32 panic("in_use = %i\n", (_vq)->in_use); \
33 (_vq)->in_use = __LINE__; \
34 mb(); \
35 } while(0)
36#define END_USE(_vq) \
37 do { BUG_ON(!(_vq)->in_use); (_vq)->in_use = 0; mb(); } while(0)
32#else 38#else
33#define BAD_RING(vq, fmt...) \ 39#define BAD_RING(_vq, fmt...) \
34 do { dev_err(&vq->vq.vdev->dev, fmt); (vq)->broken = true; } while(0) 40 do { dev_err(&_vq->vq.vdev->dev, fmt); (_vq)->broken = true; } while(0)
35#define START_USE(vq) 41#define START_USE(vq)
36#define END_USE(vq) 42#define END_USE(vq)
37#endif 43#endif
diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
index 6cf155d6b350..3137361ccbfe 100644
--- a/drivers/watchdog/hpwdt.c
+++ b/drivers/watchdog/hpwdt.c
@@ -380,7 +380,7 @@ asm(".text \n\t"
380 * This function checks whether or not a SMBIOS/DMI record is 380 * This function checks whether or not a SMBIOS/DMI record is
381 * the 64bit CRU info or not 381 * the 64bit CRU info or not
382 */ 382 */
383static void __devinit dmi_find_cru(const struct dmi_header *dm) 383static void __devinit dmi_find_cru(const struct dmi_header *dm, void *dummy)
384{ 384{
385 struct smbios_cru64_info *smbios_cru64_ptr; 385 struct smbios_cru64_info *smbios_cru64_ptr;
386 unsigned long cru_physical_address; 386 unsigned long cru_physical_address;
@@ -403,7 +403,7 @@ static int __devinit detect_cru_service(void)
403{ 403{
404 cru_rom_addr = NULL; 404 cru_rom_addr = NULL;
405 405
406 dmi_walk(dmi_find_cru); 406 dmi_walk(dmi_find_cru, NULL);
407 407
408 /* if cru_rom_addr has been set then we found a CRU service */ 408 /* if cru_rom_addr has been set then we found a CRU service */
409 return ((cru_rom_addr != NULL) ? 0 : -ENODEV); 409 return ((cru_rom_addr != NULL) ? 0 : -ENODEV);
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index 3ccd348d112d..0d61db1e7b49 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -39,12 +39,6 @@ static int xen_suspend(void *data)
39 39
40 BUG_ON(!irqs_disabled()); 40 BUG_ON(!irqs_disabled());
41 41
42 err = device_power_down(PMSG_SUSPEND);
43 if (err) {
44 printk(KERN_ERR "xen_suspend: device_power_down failed: %d\n",
45 err);
46 return err;
47 }
48 err = sysdev_suspend(PMSG_SUSPEND); 42 err = sysdev_suspend(PMSG_SUSPEND);
49 if (err) { 43 if (err) {
50 printk(KERN_ERR "xen_suspend: sysdev_suspend failed: %d\n", 44 printk(KERN_ERR "xen_suspend: sysdev_suspend failed: %d\n",
@@ -69,7 +63,6 @@ static int xen_suspend(void *data)
69 xen_mm_unpin_all(); 63 xen_mm_unpin_all();
70 64
71 sysdev_resume(); 65 sysdev_resume();
72 device_power_up(PMSG_RESUME);
73 66
74 if (!*cancelled) { 67 if (!*cancelled) {
75 xen_irq_resume(); 68 xen_irq_resume();
@@ -108,6 +101,12 @@ static void do_suspend(void)
108 /* XXX use normal device tree? */ 101 /* XXX use normal device tree? */
109 xenbus_suspend(); 102 xenbus_suspend();
110 103
104 err = device_power_down(PMSG_SUSPEND);
105 if (err) {
106 printk(KERN_ERR "device_power_down failed: %d\n", err);
107 goto resume_devices;
108 }
109
111 err = stop_machine(xen_suspend, &cancelled, cpumask_of(0)); 110 err = stop_machine(xen_suspend, &cancelled, cpumask_of(0));
112 if (err) { 111 if (err) {
113 printk(KERN_ERR "failed to start xen_suspend: %d\n", err); 112 printk(KERN_ERR "failed to start xen_suspend: %d\n", err);
@@ -120,6 +119,9 @@ static void do_suspend(void)
120 } else 119 } else
121 xenbus_suspend_cancel(); 120 xenbus_suspend_cancel();
122 121
122 device_power_up(PMSG_RESUME);
123
124resume_devices:
123 device_resume(PMSG_RESUME); 125 device_resume(PMSG_RESUME);
124 126
125 /* Make sure timer events get retriggered on all CPUs */ 127 /* Make sure timer events get retriggered on all CPUs */