aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/Kconfig2
-rw-r--r--drivers/acpi/ac.c40
-rw-r--r--drivers/acpi/battery.c10
-rw-r--r--drivers/acpi/toshiba_acpi.c3
-rw-r--r--drivers/ata/ata_piix.c7
-rw-r--r--drivers/ata/libata-acpi.c10
-rw-r--r--drivers/ata/libata-core.c78
-rw-r--r--drivers/ata/pata_platform.c35
-rw-r--r--drivers/ata/sata_nv.c2
-rw-r--r--drivers/ata/sata_qstor.c114
-rw-r--r--drivers/block/nbd.c3
-rw-r--r--drivers/block/paride/pf.c25
-rw-r--r--drivers/block/pktcdvd.c9
-rw-r--r--drivers/block/rd.c13
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c2
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c2
-rw-r--r--drivers/char/random.c6
-rw-r--r--drivers/char/rtc.c52
-rw-r--r--drivers/char/tty_ioctl.c170
-rw-r--r--drivers/crypto/geode-aes.c3
-rw-r--r--drivers/dma/dmaengine.c17
-rw-r--r--drivers/dma/ioat.c11
-rw-r--r--drivers/dma/ioat_dca.c164
-rw-r--r--drivers/dma/ioat_dma.c578
-rw-r--r--drivers/dma/ioatdma.h32
-rw-r--r--drivers/dma/ioatdma_hw.h33
-rw-r--r--drivers/dma/ioatdma_registers.h106
-rw-r--r--drivers/edac/i5000_edac.c2
-rw-r--r--drivers/firewire/fw-sbp2.c11
-rw-r--r--drivers/hwmon/Kconfig10
-rw-r--r--drivers/hwmon/Makefile1
-rw-r--r--drivers/hwmon/abituguru3.c56
-rw-r--r--drivers/hwmon/applesmc.c107
-rw-r--r--drivers/hwmon/f75375s.c170
-rw-r--r--drivers/hwmon/i5k_amb.c552
-rw-r--r--drivers/hwmon/ibmpex.c48
-rw-r--r--drivers/hwmon/lm70.c11
-rw-r--r--drivers/hwmon/sis5595.c59
-rw-r--r--drivers/hwmon/w83627hf.c155
-rw-r--r--drivers/hwmon/w83781d.c3
-rw-r--r--drivers/ide/Kconfig4
-rw-r--r--drivers/ide/cris/ide-cris.c3
-rw-r--r--drivers/ide/ide-io.c6
-rw-r--r--drivers/ide/ide-lib.c1
-rw-r--r--drivers/ide/pci/cmd64x.c5
-rw-r--r--drivers/ide/pci/cs5530.c3
-rw-r--r--drivers/ide/pci/it821x.c3
-rw-r--r--drivers/ide/pci/jmicron.c3
-rw-r--r--drivers/ide/pci/sc1200.c3
-rw-r--r--drivers/ide/pci/sis5513.c1
-rw-r--r--drivers/ide/ppc/pmac.c1
-rw-r--r--drivers/ide/setup-pci.c5
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_provider.c1
-rw-r--r--drivers/infiniband/hw/ehca/ehca_av.c48
-rw-r--r--drivers/infiniband/hw/ehca/ehca_classes.h1
-rw-r--r--drivers/infiniband/hw/ehca/ehca_hca.c20
-rw-r--r--drivers/infiniband/hw/ehca/ehca_iverbs.h3
-rw-r--r--drivers/infiniband/hw/ehca/ehca_main.c3
-rw-r--r--drivers/infiniband/hw/ehca/ehca_qp.c29
-rw-r--r--drivers/infiniband/hw/ehca/hipz_hw.h6
-rw-r--r--drivers/infiniband/hw/ipath/ipath_cq.c11
-rw-r--r--drivers/infiniband/hw/ipath/ipath_rc.c5
-rw-r--r--drivers/isdn/sc/card.h2
-rw-r--r--drivers/isdn/sc/packet.c2
-rw-r--r--drivers/isdn/sc/shmem.c2
-rw-r--r--drivers/kvm/svm.c18
-rw-r--r--drivers/kvm/x86_emulate.c26
-rw-r--r--drivers/lguest/lguest_device.c3
-rw-r--r--drivers/lguest/lguest_user.c2
-rw-r--r--drivers/macintosh/windfarm_core.c10
-rw-r--r--drivers/md/bitmap.c3
-rw-r--r--drivers/md/dm-table.c3
-rw-r--r--drivers/md/linear.c3
-rw-r--r--drivers/md/md.c4
-rw-r--r--drivers/md/multipath.c3
-rw-r--r--drivers/md/raid0.c3
-rw-r--r--drivers/md/raid1.c3
-rw-r--r--drivers/md/raid10.c3
-rw-r--r--drivers/md/raid5.c19
-rw-r--r--drivers/misc/ioc4.c10
-rw-r--r--drivers/mmc/card/queue.c2
-rw-r--r--drivers/mmc/host/sdhci.c2
-rw-r--r--drivers/net/Kconfig208
-rw-r--r--drivers/net/arcnet/Kconfig15
-rw-r--r--drivers/net/arm/ep93xx_eth.c2
-rw-r--r--drivers/net/bonding/bond_main.c5
-rw-r--r--drivers/net/bonding/bond_sysfs.c4
-rw-r--r--drivers/net/cris/eth_v10.c440
-rw-r--r--drivers/net/e1000/e1000_main.c13
-rw-r--r--drivers/net/fs_enet/Kconfig11
-rw-r--r--drivers/net/fs_enet/Makefile15
-rw-r--r--drivers/net/hamradio/6pack.c26
-rw-r--r--drivers/net/irda/irtty-sir.c7
-rw-r--r--drivers/net/loopback.c2
-rw-r--r--drivers/net/mlx4/alloc.c7
-rw-r--r--drivers/net/mlx4/qp.c2
-rw-r--r--drivers/net/myri_sbus.c2
-rw-r--r--drivers/net/netx-eth.c6
-rw-r--r--drivers/net/pasemi_mac.c18
-rw-r--r--drivers/net/ppp_async.c44
-rw-r--r--drivers/net/ppp_generic.c126
-rw-r--r--drivers/net/ppp_synctty.c37
-rw-r--r--drivers/net/pppol2tp.c25
-rw-r--r--drivers/net/qla3xxx.c42
-rw-r--r--drivers/net/qla3xxx.h1
-rw-r--r--drivers/net/r8169.c26
-rw-r--r--drivers/net/rrunner.c18
-rw-r--r--drivers/net/s2io.c110
-rw-r--r--drivers/net/sky2.c116
-rw-r--r--drivers/net/sky2.h3
-rw-r--r--drivers/net/slip.c8
-rw-r--r--drivers/net/smc91x.h15
-rw-r--r--drivers/net/sungem.c11
-rw-r--r--drivers/net/tehuti.c8
-rw-r--r--drivers/net/tg3.c186
-rw-r--r--drivers/net/tg3.h44
-rw-r--r--drivers/net/tulip/Kconfig21
-rw-r--r--drivers/net/usb/Kconfig9
-rw-r--r--drivers/net/usb/usbnet.c7
-rw-r--r--drivers/net/virtio_net.c3
-rw-r--r--drivers/net/wan/x25_asy.c6
-rw-r--r--drivers/net/wireless/Kconfig2
-rw-r--r--drivers/net/wireless/b43/Kconfig10
-rw-r--r--drivers/net/wireless/b43/debugfs.c2
-rw-r--r--drivers/net/wireless/b43/main.c19
-rw-r--r--drivers/net/wireless/b43/pcmcia.c52
-rw-r--r--drivers/net/wireless/b43/rfkill.c115
-rw-r--r--drivers/net/wireless/b43/rfkill.h14
-rw-r--r--drivers/net/wireless/b43legacy/debugfs.c2
-rw-r--r--drivers/net/wireless/b43legacy/main.c21
-rw-r--r--drivers/net/wireless/hostap/hostap_pci.c6
-rw-r--r--drivers/net/wireless/ipw2100.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl4965-base.c2
-rw-r--r--drivers/net/wireless/libertas/cmd.c10
-rw-r--r--drivers/net/wireless/libertas/if_cs.c7
-rw-r--r--drivers/net/wireless/libertas/if_sdio.c4
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c8
-rw-r--r--drivers/net/wireless/strip.c10
-rw-r--r--drivers/oprofile/cpu_buffer.c7
-rw-r--r--drivers/oprofile/cpu_buffer.h1
-rw-r--r--drivers/oprofile/oprofile_stats.c4
-rw-r--r--drivers/rtc/Kconfig8
-rw-r--r--drivers/rtc/hctosys.c4
-rw-r--r--drivers/rtc/rtc-ds1307.c93
-rw-r--r--drivers/rtc/rtc-ds1553.c2
-rw-r--r--drivers/rtc/rtc-ds1742.c5
-rw-r--r--drivers/rtc/rtc-m48t59.c3
-rw-r--r--drivers/rtc/rtc-sh.c6
-rw-r--r--drivers/rtc/rtc-stk17ta8.c2
-rw-r--r--drivers/scsi/aic94xx/aic94xx_sds.c4
-rw-r--r--drivers/serial/8250_pnp.c10
-rw-r--r--drivers/serial/atmel_serial.c9
-rw-r--r--drivers/serial/crisv10.c1293
-rw-r--r--drivers/serial/crisv10.h146
-rw-r--r--drivers/serial/sh-sci.h19
-rw-r--r--drivers/serial/uartlite.c10
-rw-r--r--drivers/sh/superhyway/superhyway.c7
-rw-r--r--drivers/spi/spi.c8
-rw-r--r--drivers/spi/spi_txx9.c40
-rw-r--r--drivers/spi/tle62x0.c5
-rw-r--r--drivers/ssb/main.c6
-rw-r--r--drivers/ssb/pcmcia.c56
-rw-r--r--drivers/usb/serial/keyspan.c38
-rw-r--r--drivers/video/Kconfig2
-rw-r--r--drivers/video/cyber2000fb.c2
-rw-r--r--drivers/video/gbefb.c4
-rw-r--r--drivers/video/geode/lxfb.h2
-rw-r--r--drivers/video/ps3fb.c2
-rw-r--r--drivers/video/s1d13xxxfb.c5
-rw-r--r--drivers/video/sis/sis_main.c3
-rw-r--r--drivers/video/uvesafb.c6
-rw-r--r--drivers/virtio/virtio_ring.c10
-rw-r--r--drivers/w1/masters/ds2490.c2
174 files changed, 4238 insertions, 2528 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index da3a08fa9e4f..087a7028ae84 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -50,6 +50,7 @@ config ACPI_SLEEP
50config ACPI_PROCFS 50config ACPI_PROCFS
51 bool "Deprecated /proc/acpi files" 51 bool "Deprecated /proc/acpi files"
52 depends on PROC_FS 52 depends on PROC_FS
53 default y
53 ---help--- 54 ---help---
54 For backwards compatibility, this option allows 55 For backwards compatibility, this option allows
55 deprecated /proc/acpi/ files to exist, even when 56 deprecated /proc/acpi/ files to exist, even when
@@ -60,6 +61,7 @@ config ACPI_PROCFS
60 /proc/acpi/info (/sys/modules/acpi/parameters/acpica_version) 61 /proc/acpi/info (/sys/modules/acpi/parameters/acpica_version)
61 /proc/acpi/dsdt (/sys/firmware/acpi/tables/DSDT) 62 /proc/acpi/dsdt (/sys/firmware/acpi/tables/DSDT)
62 /proc/acpi/fadt (/sys/firmware/acpi/tables/FACP) 63 /proc/acpi/fadt (/sys/firmware/acpi/tables/FACP)
64 /proc/acpi/battery (/sys/class/power_supply)
63 /proc/acpi/debug_layer (/sys/module/acpi/parameters/debug_layer) 65 /proc/acpi/debug_layer (/sys/module/acpi/parameters/debug_layer)
64 /proc/acpi/debug_level (/sys/module/acpi/parameters/debug_level) 66 /proc/acpi/debug_level (/sys/module/acpi/parameters/debug_level)
65 67
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index e03de37a750d..30238f6ff232 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -27,8 +27,10 @@
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/types.h> 29#include <linux/types.h>
30#ifdef CONFIG_ACPI_PROCFS
30#include <linux/proc_fs.h> 31#include <linux/proc_fs.h>
31#include <linux/seq_file.h> 32#include <linux/seq_file.h>
33#endif
32#include <linux/power_supply.h> 34#include <linux/power_supply.h>
33#include <acpi/acpi_bus.h> 35#include <acpi/acpi_bus.h>
34#include <acpi/acpi_drivers.h> 36#include <acpi/acpi_drivers.h>
@@ -49,12 +51,15 @@ MODULE_AUTHOR("Paul Diefenbaugh");
49MODULE_DESCRIPTION("ACPI AC Adapter Driver"); 51MODULE_DESCRIPTION("ACPI AC Adapter Driver");
50MODULE_LICENSE("GPL"); 52MODULE_LICENSE("GPL");
51 53
54#ifdef CONFIG_ACPI_PROCFS
52extern struct proc_dir_entry *acpi_lock_ac_dir(void); 55extern struct proc_dir_entry *acpi_lock_ac_dir(void);
53extern void *acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir); 56extern void *acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir);
57static int acpi_ac_open_fs(struct inode *inode, struct file *file);
58#endif
54 59
55static int acpi_ac_add(struct acpi_device *device); 60static int acpi_ac_add(struct acpi_device *device);
56static int acpi_ac_remove(struct acpi_device *device, int type); 61static int acpi_ac_remove(struct acpi_device *device, int type);
57static int acpi_ac_open_fs(struct inode *inode, struct file *file); 62static int acpi_ac_resume(struct acpi_device *device);
58 63
59const static struct acpi_device_id ac_device_ids[] = { 64const static struct acpi_device_id ac_device_ids[] = {
60 {"ACPI0003", 0}, 65 {"ACPI0003", 0},
@@ -69,6 +74,7 @@ static struct acpi_driver acpi_ac_driver = {
69 .ops = { 74 .ops = {
70 .add = acpi_ac_add, 75 .add = acpi_ac_add,
71 .remove = acpi_ac_remove, 76 .remove = acpi_ac_remove,
77 .resume = acpi_ac_resume,
72 }, 78 },
73}; 79};
74 80
@@ -80,12 +86,15 @@ struct acpi_ac {
80 86
81#define to_acpi_ac(x) container_of(x, struct acpi_ac, charger); 87#define to_acpi_ac(x) container_of(x, struct acpi_ac, charger);
82 88
89#ifdef CONFIG_ACPI_PROCFS
83static const struct file_operations acpi_ac_fops = { 90static const struct file_operations acpi_ac_fops = {
84 .open = acpi_ac_open_fs, 91 .open = acpi_ac_open_fs,
85 .read = seq_read, 92 .read = seq_read,
86 .llseek = seq_lseek, 93 .llseek = seq_lseek,
87 .release = single_release, 94 .release = single_release,
88}; 95};
96#endif
97
89static int get_ac_property(struct power_supply *psy, 98static int get_ac_property(struct power_supply *psy,
90 enum power_supply_property psp, 99 enum power_supply_property psp,
91 union power_supply_propval *val) 100 union power_supply_propval *val)
@@ -127,6 +136,7 @@ static int acpi_ac_get_state(struct acpi_ac *ac)
127 return 0; 136 return 0;
128} 137}
129 138
139#ifdef CONFIG_ACPI_PROCFS
130/* -------------------------------------------------------------------------- 140/* --------------------------------------------------------------------------
131 FS Interface (/proc) 141 FS Interface (/proc)
132 -------------------------------------------------------------------------- */ 142 -------------------------------------------------------------------------- */
@@ -206,6 +216,7 @@ static int acpi_ac_remove_fs(struct acpi_device *device)
206 216
207 return 0; 217 return 0;
208} 218}
219#endif
209 220
210/* -------------------------------------------------------------------------- 221/* --------------------------------------------------------------------------
211 Driver Model 222 Driver Model
@@ -264,7 +275,9 @@ static int acpi_ac_add(struct acpi_device *device)
264 if (result) 275 if (result)
265 goto end; 276 goto end;
266 277
278#ifdef CONFIG_ACPI_PROCFS
267 result = acpi_ac_add_fs(device); 279 result = acpi_ac_add_fs(device);
280#endif
268 if (result) 281 if (result)
269 goto end; 282 goto end;
270 ac->charger.name = acpi_device_bid(device); 283 ac->charger.name = acpi_device_bid(device);
@@ -287,13 +300,30 @@ static int acpi_ac_add(struct acpi_device *device)
287 300
288 end: 301 end:
289 if (result) { 302 if (result) {
303#ifdef CONFIG_ACPI_PROCFS
290 acpi_ac_remove_fs(device); 304 acpi_ac_remove_fs(device);
305#endif
291 kfree(ac); 306 kfree(ac);
292 } 307 }
293 308
294 return result; 309 return result;
295} 310}
296 311
312static int acpi_ac_resume(struct acpi_device *device)
313{
314 struct acpi_ac *ac;
315 unsigned old_state;
316 if (!device || !acpi_driver_data(device))
317 return -EINVAL;
318 ac = acpi_driver_data(device);
319 old_state = ac->state;
320 if (acpi_ac_get_state(ac))
321 return 0;
322 if (old_state != ac->state)
323 kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE);
324 return 0;
325}
326
297static int acpi_ac_remove(struct acpi_device *device, int type) 327static int acpi_ac_remove(struct acpi_device *device, int type)
298{ 328{
299 acpi_status status = AE_OK; 329 acpi_status status = AE_OK;
@@ -309,7 +339,9 @@ static int acpi_ac_remove(struct acpi_device *device, int type)
309 ACPI_ALL_NOTIFY, acpi_ac_notify); 339 ACPI_ALL_NOTIFY, acpi_ac_notify);
310 if (ac->charger.dev) 340 if (ac->charger.dev)
311 power_supply_unregister(&ac->charger); 341 power_supply_unregister(&ac->charger);
342#ifdef CONFIG_ACPI_PROCFS
312 acpi_ac_remove_fs(device); 343 acpi_ac_remove_fs(device);
344#endif
313 345
314 kfree(ac); 346 kfree(ac);
315 347
@@ -323,13 +355,17 @@ static int __init acpi_ac_init(void)
323 if (acpi_disabled) 355 if (acpi_disabled)
324 return -ENODEV; 356 return -ENODEV;
325 357
358#ifdef CONFIG_ACPI_PROCFS
326 acpi_ac_dir = acpi_lock_ac_dir(); 359 acpi_ac_dir = acpi_lock_ac_dir();
327 if (!acpi_ac_dir) 360 if (!acpi_ac_dir)
328 return -ENODEV; 361 return -ENODEV;
362#endif
329 363
330 result = acpi_bus_register_driver(&acpi_ac_driver); 364 result = acpi_bus_register_driver(&acpi_ac_driver);
331 if (result < 0) { 365 if (result < 0) {
366#ifdef CONFIG_ACPI_PROCFS
332 acpi_unlock_ac_dir(acpi_ac_dir); 367 acpi_unlock_ac_dir(acpi_ac_dir);
368#endif
333 return -ENODEV; 369 return -ENODEV;
334 } 370 }
335 371
@@ -341,7 +377,9 @@ static void __exit acpi_ac_exit(void)
341 377
342 acpi_bus_unregister_driver(&acpi_ac_driver); 378 acpi_bus_unregister_driver(&acpi_ac_driver);
343 379
380#ifdef CONFIG_ACPI_PROCFS
344 acpi_unlock_ac_dir(acpi_ac_dir); 381 acpi_unlock_ac_dir(acpi_ac_dir);
382#endif
345 383
346 return; 384 return;
347} 385}
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index c2ce0ad21693..192c244f6190 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -132,7 +132,7 @@ static int acpi_battery_technology(struct acpi_battery *battery)
132 return POWER_SUPPLY_TECHNOLOGY_UNKNOWN; 132 return POWER_SUPPLY_TECHNOLOGY_UNKNOWN;
133} 133}
134 134
135static int acpi_battery_update(struct acpi_battery *battery); 135static int acpi_battery_get_state(struct acpi_battery *battery);
136 136
137static int acpi_battery_get_property(struct power_supply *psy, 137static int acpi_battery_get_property(struct power_supply *psy,
138 enum power_supply_property psp, 138 enum power_supply_property psp,
@@ -140,10 +140,11 @@ static int acpi_battery_get_property(struct power_supply *psy,
140{ 140{
141 struct acpi_battery *battery = to_acpi_battery(psy); 141 struct acpi_battery *battery = to_acpi_battery(psy);
142 142
143 if ((!acpi_battery_present(battery)) && 143 if (acpi_battery_present(battery)) {
144 psp != POWER_SUPPLY_PROP_PRESENT) 144 /* run battery update only if it is present */
145 acpi_battery_get_state(battery);
146 } else if (psp != POWER_SUPPLY_PROP_PRESENT)
145 return -ENODEV; 147 return -ENODEV;
146 acpi_battery_update(battery);
147 switch (psp) { 148 switch (psp) {
148 case POWER_SUPPLY_PROP_STATUS: 149 case POWER_SUPPLY_PROP_STATUS:
149 if (battery->state & 0x01) 150 if (battery->state & 0x01)
@@ -457,6 +458,7 @@ static void sysfs_remove_battery(struct acpi_battery *battery)
457 return; 458 return;
458 device_remove_file(battery->bat.dev, &alarm_attr); 459 device_remove_file(battery->bat.dev, &alarm_attr);
459 power_supply_unregister(&battery->bat); 460 power_supply_unregister(&battery->bat);
461 battery->bat.dev = NULL;
460} 462}
461 463
462static int acpi_battery_update(struct acpi_battery *battery) 464static int acpi_battery_update(struct acpi_battery *battery)
diff --git a/drivers/acpi/toshiba_acpi.c b/drivers/acpi/toshiba_acpi.c
index a736ef7bdee4..9e8c20c6a0b7 100644
--- a/drivers/acpi/toshiba_acpi.c
+++ b/drivers/acpi/toshiba_acpi.c
@@ -591,9 +591,12 @@ static int __init toshiba_acpi_init(void)
591 NULL, 591 NULL,
592 &toshiba_backlight_data); 592 &toshiba_backlight_data);
593 if (IS_ERR(toshiba_backlight_device)) { 593 if (IS_ERR(toshiba_backlight_device)) {
594 int ret = PTR_ERR(toshiba_backlight_device);
595
594 printk(KERN_ERR "Could not register toshiba backlight device\n"); 596 printk(KERN_ERR "Could not register toshiba backlight device\n");
595 toshiba_backlight_device = NULL; 597 toshiba_backlight_device = NULL;
596 toshiba_acpi_exit(); 598 toshiba_acpi_exit();
599 return ret;
597 } 600 }
598 toshiba_backlight_device->props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1; 601 toshiba_backlight_device->props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1;
599 602
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index f08cca21702c..328ce8a08426 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -960,6 +960,13 @@ static int piix_broken_suspend(void)
960 }, 960 },
961 }, 961 },
962 { 962 {
963 .ident = "Satellite Pro U200",
964 .matches = {
965 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
966 DMI_MATCH(DMI_PRODUCT_NAME, "SATELLITE PRO U200"),
967 },
968 },
969 {
963 .ident = "Satellite U205", 970 .ident = "Satellite U205",
964 .matches = { 971 .matches = {
965 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 972 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 08a52dd45fb6..545ea865ceb5 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -312,7 +312,7 @@ EXPORT_SYMBOL_GPL(ata_acpi_stm);
312 * 312 *
313 * RETURNS: 313 * RETURNS:
314 * Number of taskfiles on success, 0 if _GTF doesn't exist or doesn't 314 * Number of taskfiles on success, 0 if _GTF doesn't exist or doesn't
315 * contain valid data. -errno on other errors. 315 * contain valid data.
316 */ 316 */
317static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf, 317static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf,
318 void **ptr_to_free) 318 void **ptr_to_free)
@@ -339,7 +339,6 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf,
339 ata_dev_printk(dev, KERN_WARNING, 339 ata_dev_printk(dev, KERN_WARNING,
340 "_GTF evaluation failed (AE 0x%x)\n", 340 "_GTF evaluation failed (AE 0x%x)\n",
341 status); 341 status);
342 rc = -EIO;
343 } 342 }
344 goto out_free; 343 goto out_free;
345 } 344 }
@@ -359,7 +358,6 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf,
359 ata_dev_printk(dev, KERN_WARNING, 358 ata_dev_printk(dev, KERN_WARNING,
360 "_GTF unexpected object type 0x%x\n", 359 "_GTF unexpected object type 0x%x\n",
361 out_obj->type); 360 out_obj->type);
362 rc = -EINVAL;
363 goto out_free; 361 goto out_free;
364 } 362 }
365 363
@@ -367,7 +365,6 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf,
367 ata_dev_printk(dev, KERN_WARNING, 365 ata_dev_printk(dev, KERN_WARNING,
368 "unexpected _GTF length (%d)\n", 366 "unexpected _GTF length (%d)\n",
369 out_obj->buffer.length); 367 out_obj->buffer.length);
370 rc = -EINVAL;
371 goto out_free; 368 goto out_free;
372 } 369 }
373 370
@@ -511,10 +508,7 @@ static int ata_acpi_exec_tfs(struct ata_device *dev)
511 int gtf_count, i, rc; 508 int gtf_count, i, rc;
512 509
513 /* get taskfiles */ 510 /* get taskfiles */
514 rc = ata_dev_get_GTF(dev, &gtf, &ptr_to_free); 511 gtf_count = ata_dev_get_GTF(dev, &gtf, &ptr_to_free);
515 if (rc < 0)
516 return rc;
517 gtf_count = rc;
518 512
519 /* execute them */ 513 /* execute them */
520 for (i = 0, rc = 0; i < gtf_count; i++) { 514 for (i = 0, rc = 0; i < gtf_count; i++) {
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index ec3ce120a517..81898036dbca 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -3373,14 +3373,20 @@ void ata_wait_after_reset(struct ata_port *ap, unsigned long deadline)
3373 * to clear 0xff after reset. For example, HHD424020F7SV00 3373 * to clear 0xff after reset. For example, HHD424020F7SV00
3374 * iVDR needs >= 800ms while. Quantum GoVault needs even more 3374 * iVDR needs >= 800ms while. Quantum GoVault needs even more
3375 * than that. 3375 * than that.
3376 *
3377 * Note that some PATA controllers (pata_ali) explode if
3378 * status register is read more than once when there's no
3379 * device attached.
3376 */ 3380 */
3377 while (1) { 3381 if (ap->flags & ATA_FLAG_SATA) {
3378 u8 status = ata_chk_status(ap); 3382 while (1) {
3383 u8 status = ata_chk_status(ap);
3379 3384
3380 if (status != 0xff || time_after(jiffies, deadline)) 3385 if (status != 0xff || time_after(jiffies, deadline))
3381 return; 3386 return;
3382 3387
3383 msleep(50); 3388 msleep(50);
3389 }
3384 } 3390 }
3385} 3391}
3386 3392
@@ -6821,19 +6827,6 @@ static void ata_host_release(struct device *gendev, void *res)
6821 if (!ap) 6827 if (!ap)
6822 continue; 6828 continue;
6823 6829
6824 if ((host->flags & ATA_HOST_STARTED) && ap->ops->port_stop)
6825 ap->ops->port_stop(ap);
6826 }
6827
6828 if ((host->flags & ATA_HOST_STARTED) && host->ops->host_stop)
6829 host->ops->host_stop(host);
6830
6831 for (i = 0; i < host->n_ports; i++) {
6832 struct ata_port *ap = host->ports[i];
6833
6834 if (!ap)
6835 continue;
6836
6837 if (ap->scsi_host) 6830 if (ap->scsi_host)
6838 scsi_host_put(ap->scsi_host); 6831 scsi_host_put(ap->scsi_host);
6839 6832
@@ -6960,6 +6953,24 @@ struct ata_host *ata_host_alloc_pinfo(struct device *dev,
6960 return host; 6953 return host;
6961} 6954}
6962 6955
6956static void ata_host_stop(struct device *gendev, void *res)
6957{
6958 struct ata_host *host = dev_get_drvdata(gendev);
6959 int i;
6960
6961 WARN_ON(!(host->flags & ATA_HOST_STARTED));
6962
6963 for (i = 0; i < host->n_ports; i++) {
6964 struct ata_port *ap = host->ports[i];
6965
6966 if (ap->ops->port_stop)
6967 ap->ops->port_stop(ap);
6968 }
6969
6970 if (host->ops->host_stop)
6971 host->ops->host_stop(host);
6972}
6973
6963/** 6974/**
6964 * ata_host_start - start and freeze ports of an ATA host 6975 * ata_host_start - start and freeze ports of an ATA host
6965 * @host: ATA host to start ports for 6976 * @host: ATA host to start ports for
@@ -6978,6 +6989,8 @@ struct ata_host *ata_host_alloc_pinfo(struct device *dev,
6978 */ 6989 */
6979int ata_host_start(struct ata_host *host) 6990int ata_host_start(struct ata_host *host)
6980{ 6991{
6992 int have_stop = 0;
6993 void *start_dr = NULL;
6981 int i, rc; 6994 int i, rc;
6982 6995
6983 if (host->flags & ATA_HOST_STARTED) 6996 if (host->flags & ATA_HOST_STARTED)
@@ -6989,6 +7002,22 @@ int ata_host_start(struct ata_host *host)
6989 if (!host->ops && !ata_port_is_dummy(ap)) 7002 if (!host->ops && !ata_port_is_dummy(ap))
6990 host->ops = ap->ops; 7003 host->ops = ap->ops;
6991 7004
7005 if (ap->ops->port_stop)
7006 have_stop = 1;
7007 }
7008
7009 if (host->ops->host_stop)
7010 have_stop = 1;
7011
7012 if (have_stop) {
7013 start_dr = devres_alloc(ata_host_stop, 0, GFP_KERNEL);
7014 if (!start_dr)
7015 return -ENOMEM;
7016 }
7017
7018 for (i = 0; i < host->n_ports; i++) {
7019 struct ata_port *ap = host->ports[i];
7020
6992 if (ap->ops->port_start) { 7021 if (ap->ops->port_start) {
6993 rc = ap->ops->port_start(ap); 7022 rc = ap->ops->port_start(ap);
6994 if (rc) { 7023 if (rc) {
@@ -7001,6 +7030,8 @@ int ata_host_start(struct ata_host *host)
7001 ata_eh_freeze_port(ap); 7030 ata_eh_freeze_port(ap);
7002 } 7031 }
7003 7032
7033 if (start_dr)
7034 devres_add(host->dev, start_dr);
7004 host->flags |= ATA_HOST_STARTED; 7035 host->flags |= ATA_HOST_STARTED;
7005 return 0; 7036 return 0;
7006 7037
@@ -7011,6 +7042,7 @@ int ata_host_start(struct ata_host *host)
7011 if (ap->ops->port_stop) 7042 if (ap->ops->port_stop)
7012 ap->ops->port_stop(ap); 7043 ap->ops->port_stop(ap);
7013 } 7044 }
7045 devres_free(start_dr);
7014 return rc; 7046 return rc;
7015} 7047}
7016 7048
@@ -7178,6 +7210,10 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
7178 * request IRQ and register it. This helper takes necessasry 7210 * request IRQ and register it. This helper takes necessasry
7179 * arguments and performs the three steps in one go. 7211 * arguments and performs the three steps in one go.
7180 * 7212 *
7213 * An invalid IRQ skips the IRQ registration and expects the host to
7214 * have set polling mode on the port. In this case, @irq_handler
7215 * should be NULL.
7216 *
7181 * LOCKING: 7217 * LOCKING:
7182 * Inherited from calling layer (may sleep). 7218 * Inherited from calling layer (may sleep).
7183 * 7219 *
@@ -7194,6 +7230,12 @@ int ata_host_activate(struct ata_host *host, int irq,
7194 if (rc) 7230 if (rc)
7195 return rc; 7231 return rc;
7196 7232
7233 /* Special case for polling mode */
7234 if (!irq) {
7235 WARN_ON(irq_handler);
7236 return ata_host_register(host, sht);
7237 }
7238
7197 rc = devm_request_irq(host->dev, irq, irq_handler, irq_flags, 7239 rc = devm_request_irq(host->dev, irq, irq_handler, irq_flags,
7198 dev_driver_string(host->dev), host); 7240 dev_driver_string(host->dev), host);
7199 if (rc) 7241 if (rc)
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
index fc72a965643d..ac03a90a6168 100644
--- a/drivers/ata/pata_platform.c
+++ b/drivers/ata/pata_platform.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Generic platform device PATA driver 2 * Generic platform device PATA driver
3 * 3 *
4 * Copyright (C) 2006 Paul Mundt 4 * Copyright (C) 2006 - 2007 Paul Mundt
5 * 5 *
6 * Based on pata_pcmcia: 6 * Based on pata_pcmcia:
7 * 7 *
@@ -22,7 +22,7 @@
22#include <linux/pata_platform.h> 22#include <linux/pata_platform.h>
23 23
24#define DRV_NAME "pata_platform" 24#define DRV_NAME "pata_platform"
25#define DRV_VERSION "1.1" 25#define DRV_VERSION "1.2"
26 26
27static int pio_mask = 1; 27static int pio_mask = 1;
28 28
@@ -120,15 +120,20 @@ static void pata_platform_setup_port(struct ata_ioports *ioaddr,
120 * Register a platform bus IDE interface. Such interfaces are PIO and we 120 * Register a platform bus IDE interface. Such interfaces are PIO and we
121 * assume do not support IRQ sharing. 121 * assume do not support IRQ sharing.
122 * 122 *
123 * Platform devices are expected to contain 3 resources per port: 123 * Platform devices are expected to contain at least 2 resources per port:
124 * 124 *
125 * - I/O Base (IORESOURCE_IO or IORESOURCE_MEM) 125 * - I/O Base (IORESOURCE_IO or IORESOURCE_MEM)
126 * - CTL Base (IORESOURCE_IO or IORESOURCE_MEM) 126 * - CTL Base (IORESOURCE_IO or IORESOURCE_MEM)
127 *
128 * and optionally:
129 *
127 * - IRQ (IORESOURCE_IRQ) 130 * - IRQ (IORESOURCE_IRQ)
128 * 131 *
129 * If the base resources are both mem types, the ioremap() is handled 132 * If the base resources are both mem types, the ioremap() is handled
130 * here. For IORESOURCE_IO, it's assumed that there's no remapping 133 * here. For IORESOURCE_IO, it's assumed that there's no remapping
131 * necessary. 134 * necessary.
135 *
136 * If no IRQ resource is present, PIO polling mode is used instead.
132 */ 137 */
133static int __devinit pata_platform_probe(struct platform_device *pdev) 138static int __devinit pata_platform_probe(struct platform_device *pdev)
134{ 139{
@@ -137,11 +142,12 @@ static int __devinit pata_platform_probe(struct platform_device *pdev)
137 struct ata_port *ap; 142 struct ata_port *ap;
138 struct pata_platform_info *pp_info; 143 struct pata_platform_info *pp_info;
139 unsigned int mmio; 144 unsigned int mmio;
145 int irq;
140 146
141 /* 147 /*
142 * Simple resource validation .. 148 * Simple resource validation ..
143 */ 149 */
144 if (unlikely(pdev->num_resources != 3)) { 150 if ((pdev->num_resources != 3) && (pdev->num_resources != 2)) {
145 dev_err(&pdev->dev, "invalid number of resources\n"); 151 dev_err(&pdev->dev, "invalid number of resources\n");
146 return -EINVAL; 152 return -EINVAL;
147 } 153 }
@@ -173,6 +179,13 @@ static int __devinit pata_platform_probe(struct platform_device *pdev)
173 (ctl_res->flags == IORESOURCE_MEM)); 179 (ctl_res->flags == IORESOURCE_MEM));
174 180
175 /* 181 /*
182 * And the IRQ
183 */
184 irq = platform_get_irq(pdev, 0);
185 if (irq < 0)
186 irq = 0; /* no irq */
187
188 /*
176 * Now that that's out of the way, wire up the port.. 189 * Now that that's out of the way, wire up the port..
177 */ 190 */
178 host = ata_host_alloc(&pdev->dev, 1); 191 host = ata_host_alloc(&pdev->dev, 1);
@@ -185,6 +198,14 @@ static int __devinit pata_platform_probe(struct platform_device *pdev)
185 ap->flags |= ATA_FLAG_SLAVE_POSS; 198 ap->flags |= ATA_FLAG_SLAVE_POSS;
186 199
187 /* 200 /*
201 * Use polling mode if there's no IRQ
202 */
203 if (!irq) {
204 ap->flags |= ATA_FLAG_PIO_POLLING;
205 ata_port_desc(ap, "no IRQ, using PIO polling");
206 }
207
208 /*
188 * Handle the MMIO case 209 * Handle the MMIO case
189 */ 210 */
190 if (mmio) { 211 if (mmio) {
@@ -213,9 +234,9 @@ static int __devinit pata_platform_probe(struct platform_device *pdev)
213 (unsigned long long)ctl_res->start); 234 (unsigned long long)ctl_res->start);
214 235
215 /* activate */ 236 /* activate */
216 return ata_host_activate(host, platform_get_irq(pdev, 0), 237 return ata_host_activate(host, irq, irq ? ata_interrupt : NULL,
217 ata_interrupt, pp_info ? pp_info->irq_flags 238 pp_info ? pp_info->irq_flags : 0,
218 : 0, &pata_platform_sht); 239 &pata_platform_sht);
219} 240}
220 241
221/** 242/**
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index 35b2df297527..44f9e5d9e362 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -1629,7 +1629,7 @@ static int nv_hardreset(struct ata_link *link, unsigned int *class,
1629 1629
1630 /* SATA hardreset fails to retrieve proper device signature on 1630 /* SATA hardreset fails to retrieve proper device signature on
1631 * some controllers. Don't classify on hardreset. For more 1631 * some controllers. Don't classify on hardreset. For more
1632 * info, see http://bugme.osdl.org/show_bug.cgi?id=3352 1632 * info, see http://bugzilla.kernel.org/show_bug.cgi?id=3352
1633 */ 1633 */
1634 return sata_std_hardreset(link, &dummy, deadline); 1634 return sata_std_hardreset(link, &dummy, deadline);
1635} 1635}
diff --git a/drivers/ata/sata_qstor.c b/drivers/ata/sata_qstor.c
index 6d43ba79e154..2f1de6ec044c 100644
--- a/drivers/ata/sata_qstor.c
+++ b/drivers/ata/sata_qstor.c
@@ -103,7 +103,7 @@ enum {
103 QS_DMA_BOUNDARY = ~0UL 103 QS_DMA_BOUNDARY = ~0UL
104}; 104};
105 105
106typedef enum { qs_state_idle, qs_state_pkt, qs_state_mmio } qs_state_t; 106typedef enum { qs_state_mmio, qs_state_pkt } qs_state_t;
107 107
108struct qs_port_priv { 108struct qs_port_priv {
109 u8 *pkt; 109 u8 *pkt;
@@ -116,14 +116,15 @@ static int qs_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val);
116static int qs_ata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); 116static int qs_ata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
117static int qs_port_start(struct ata_port *ap); 117static int qs_port_start(struct ata_port *ap);
118static void qs_host_stop(struct ata_host *host); 118static void qs_host_stop(struct ata_host *host);
119static void qs_phy_reset(struct ata_port *ap);
120static void qs_qc_prep(struct ata_queued_cmd *qc); 119static void qs_qc_prep(struct ata_queued_cmd *qc);
121static unsigned int qs_qc_issue(struct ata_queued_cmd *qc); 120static unsigned int qs_qc_issue(struct ata_queued_cmd *qc);
122static int qs_check_atapi_dma(struct ata_queued_cmd *qc); 121static int qs_check_atapi_dma(struct ata_queued_cmd *qc);
123static void qs_bmdma_stop(struct ata_queued_cmd *qc); 122static void qs_bmdma_stop(struct ata_queued_cmd *qc);
124static u8 qs_bmdma_status(struct ata_port *ap); 123static u8 qs_bmdma_status(struct ata_port *ap);
125static void qs_irq_clear(struct ata_port *ap); 124static void qs_irq_clear(struct ata_port *ap);
126static void qs_eng_timeout(struct ata_port *ap); 125static void qs_freeze(struct ata_port *ap);
126static void qs_thaw(struct ata_port *ap);
127static void qs_error_handler(struct ata_port *ap);
127 128
128static struct scsi_host_template qs_ata_sht = { 129static struct scsi_host_template qs_ata_sht = {
129 .module = THIS_MODULE, 130 .module = THIS_MODULE,
@@ -150,11 +151,12 @@ static const struct ata_port_operations qs_ata_ops = {
150 .check_atapi_dma = qs_check_atapi_dma, 151 .check_atapi_dma = qs_check_atapi_dma,
151 .exec_command = ata_exec_command, 152 .exec_command = ata_exec_command,
152 .dev_select = ata_std_dev_select, 153 .dev_select = ata_std_dev_select,
153 .phy_reset = qs_phy_reset,
154 .qc_prep = qs_qc_prep, 154 .qc_prep = qs_qc_prep,
155 .qc_issue = qs_qc_issue, 155 .qc_issue = qs_qc_issue,
156 .data_xfer = ata_data_xfer, 156 .data_xfer = ata_data_xfer,
157 .eng_timeout = qs_eng_timeout, 157 .freeze = qs_freeze,
158 .thaw = qs_thaw,
159 .error_handler = qs_error_handler,
158 .irq_clear = qs_irq_clear, 160 .irq_clear = qs_irq_clear,
159 .irq_on = ata_irq_on, 161 .irq_on = ata_irq_on,
160 .scr_read = qs_scr_read, 162 .scr_read = qs_scr_read,
@@ -169,8 +171,6 @@ static const struct ata_port_info qs_port_info[] = {
169 /* board_2068_idx */ 171 /* board_2068_idx */
170 { 172 {
171 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 173 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
172 ATA_FLAG_SATA_RESET |
173 //FIXME ATA_FLAG_SRST |
174 ATA_FLAG_MMIO | ATA_FLAG_PIO_POLLING, 174 ATA_FLAG_MMIO | ATA_FLAG_PIO_POLLING,
175 .pio_mask = 0x10, /* pio4 */ 175 .pio_mask = 0x10, /* pio4 */
176 .udma_mask = ATA_UDMA6, 176 .udma_mask = ATA_UDMA6,
@@ -219,7 +219,9 @@ static void qs_irq_clear(struct ata_port *ap)
219static inline void qs_enter_reg_mode(struct ata_port *ap) 219static inline void qs_enter_reg_mode(struct ata_port *ap)
220{ 220{
221 u8 __iomem *chan = qs_mmio_base(ap->host) + (ap->port_no * 0x4000); 221 u8 __iomem *chan = qs_mmio_base(ap->host) + (ap->port_no * 0x4000);
222 struct qs_port_priv *pp = ap->private_data;
222 223
224 pp->state = qs_state_mmio;
223 writeb(QS_CTR0_REG, chan + QS_CCT_CTR0); 225 writeb(QS_CTR0_REG, chan + QS_CCT_CTR0);
224 readb(chan + QS_CCT_CTR0); /* flush */ 226 readb(chan + QS_CCT_CTR0); /* flush */
225} 227}
@@ -233,23 +235,28 @@ static inline void qs_reset_channel_logic(struct ata_port *ap)
233 qs_enter_reg_mode(ap); 235 qs_enter_reg_mode(ap);
234} 236}
235 237
236static void qs_phy_reset(struct ata_port *ap) 238static void qs_freeze(struct ata_port *ap)
237{ 239{
238 struct qs_port_priv *pp = ap->private_data; 240 u8 __iomem *mmio_base = qs_mmio_base(ap->host);
239 241
240 pp->state = qs_state_idle; 242 writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */
241 qs_reset_channel_logic(ap); 243 qs_enter_reg_mode(ap);
242 sata_phy_reset(ap);
243} 244}
244 245
245static void qs_eng_timeout(struct ata_port *ap) 246static void qs_thaw(struct ata_port *ap)
246{ 247{
247 struct qs_port_priv *pp = ap->private_data; 248 u8 __iomem *mmio_base = qs_mmio_base(ap->host);
249
250 qs_enter_reg_mode(ap);
251 writeb(1, mmio_base + QS_HCT_CTRL); /* enable host interrupts */
252}
253
254static int qs_prereset(struct ata_link *link, unsigned long deadline)
255{
256 struct ata_port *ap = link->ap;
248 257
249 if (pp->state != qs_state_idle) /* healthy paranoia */
250 pp->state = qs_state_mmio;
251 qs_reset_channel_logic(ap); 258 qs_reset_channel_logic(ap);
252 ata_eng_timeout(ap); 259 return ata_std_prereset(link, deadline);
253} 260}
254 261
255static int qs_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) 262static int qs_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val)
@@ -260,6 +267,13 @@ static int qs_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val)
260 return 0; 267 return 0;
261} 268}
262 269
270static void qs_error_handler(struct ata_port *ap)
271{
272 qs_enter_reg_mode(ap);
273 ata_do_eh(ap, qs_prereset, ata_std_softreset, NULL,
274 ata_std_postreset);
275}
276
263static int qs_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val) 277static int qs_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val)
264{ 278{
265 if (sc_reg > SCR_CONTROL) 279 if (sc_reg > SCR_CONTROL)
@@ -358,7 +372,6 @@ static unsigned int qs_qc_issue(struct ata_queued_cmd *qc)
358 372
359 switch (qc->tf.protocol) { 373 switch (qc->tf.protocol) {
360 case ATA_PROT_DMA: 374 case ATA_PROT_DMA:
361
362 pp->state = qs_state_pkt; 375 pp->state = qs_state_pkt;
363 qs_packet_start(qc); 376 qs_packet_start(qc);
364 return 0; 377 return 0;
@@ -375,6 +388,26 @@ static unsigned int qs_qc_issue(struct ata_queued_cmd *qc)
375 return ata_qc_issue_prot(qc); 388 return ata_qc_issue_prot(qc);
376} 389}
377 390
391static void qs_do_or_die(struct ata_queued_cmd *qc, u8 status)
392{
393 qc->err_mask |= ac_err_mask(status);
394
395 if (!qc->err_mask) {
396 ata_qc_complete(qc);
397 } else {
398 struct ata_port *ap = qc->ap;
399 struct ata_eh_info *ehi = &ap->link.eh_info;
400
401 ata_ehi_clear_desc(ehi);
402 ata_ehi_push_desc(ehi, "status 0x%02X", status);
403
404 if (qc->err_mask == AC_ERR_DEV)
405 ata_port_abort(ap);
406 else
407 ata_port_freeze(ap);
408 }
409}
410
378static inline unsigned int qs_intr_pkt(struct ata_host *host) 411static inline unsigned int qs_intr_pkt(struct ata_host *host)
379{ 412{
380 unsigned int handled = 0; 413 unsigned int handled = 0;
@@ -406,10 +439,8 @@ static inline unsigned int qs_intr_pkt(struct ata_host *host)
406 switch (sHST) { 439 switch (sHST) {
407 case 0: /* successful CPB */ 440 case 0: /* successful CPB */
408 case 3: /* device error */ 441 case 3: /* device error */
409 pp->state = qs_state_idle;
410 qs_enter_reg_mode(qc->ap); 442 qs_enter_reg_mode(qc->ap);
411 qc->err_mask |= ac_err_mask(sDST); 443 qs_do_or_die(qc, sDST);
412 ata_qc_complete(qc);
413 break; 444 break;
414 default: 445 default:
415 break; 446 break;
@@ -431,25 +462,27 @@ static inline unsigned int qs_intr_mmio(struct ata_host *host)
431 if (ap && 462 if (ap &&
432 !(ap->flags & ATA_FLAG_DISABLED)) { 463 !(ap->flags & ATA_FLAG_DISABLED)) {
433 struct ata_queued_cmd *qc; 464 struct ata_queued_cmd *qc;
434 struct qs_port_priv *pp = ap->private_data; 465 struct qs_port_priv *pp;
435 if (!pp || pp->state != qs_state_mmio)
436 continue;
437 qc = ata_qc_from_tag(ap, ap->link.active_tag); 466 qc = ata_qc_from_tag(ap, ap->link.active_tag);
438 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) { 467 if (!qc || !(qc->flags & ATA_QCFLAG_ACTIVE)) {
439 468 /*
440 /* check main status, clearing INTRQ */ 469 * The qstor hardware generates spurious
441 u8 status = ata_check_status(ap); 470 * interrupts from time to time when switching
442 if ((status & ATA_BUSY)) 471 * in and out of packet mode.
443 continue; 472 * There's no obvious way to know if we're
444 DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n", 473 * here now due to that, so just ack the irq
445 ap->print_id, qc->tf.protocol, status); 474 * and pretend we knew it was ours.. (ugh).
446 475 * This does not affect packet mode.
447 /* complete taskfile transaction */ 476 */
448 pp->state = qs_state_idle; 477 ata_check_status(ap);
449 qc->err_mask |= ac_err_mask(status);
450 ata_qc_complete(qc);
451 handled = 1; 478 handled = 1;
479 continue;
452 } 480 }
481 pp = ap->private_data;
482 if (!pp || pp->state != qs_state_mmio)
483 continue;
484 if (!(qc->tf.flags & ATA_TFLAG_POLLING))
485 handled |= ata_host_intr(ap, qc);
453 } 486 }
454 } 487 }
455 return handled; 488 return handled;
@@ -459,12 +492,13 @@ static irqreturn_t qs_intr(int irq, void *dev_instance)
459{ 492{
460 struct ata_host *host = dev_instance; 493 struct ata_host *host = dev_instance;
461 unsigned int handled = 0; 494 unsigned int handled = 0;
495 unsigned long flags;
462 496
463 VPRINTK("ENTER\n"); 497 VPRINTK("ENTER\n");
464 498
465 spin_lock(&host->lock); 499 spin_lock_irqsave(&host->lock, flags);
466 handled = qs_intr_pkt(host) | qs_intr_mmio(host); 500 handled = qs_intr_pkt(host) | qs_intr_mmio(host);
467 spin_unlock(&host->lock); 501 spin_unlock_irqrestore(&host->lock, flags);
468 502
469 VPRINTK("EXIT\n"); 503 VPRINTK("EXIT\n");
470 504
@@ -501,7 +535,6 @@ static int qs_port_start(struct ata_port *ap)
501 rc = ata_port_start(ap); 535 rc = ata_port_start(ap);
502 if (rc) 536 if (rc)
503 return rc; 537 return rc;
504 qs_enter_reg_mode(ap);
505 pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); 538 pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
506 if (!pp) 539 if (!pp)
507 return -ENOMEM; 540 return -ENOMEM;
@@ -512,6 +545,7 @@ static int qs_port_start(struct ata_port *ap)
512 memset(pp->pkt, 0, QS_PKT_BYTES); 545 memset(pp->pkt, 0, QS_PKT_BYTES);
513 ap->private_data = pp; 546 ap->private_data = pp;
514 547
548 qs_enter_reg_mode(ap);
515 addr = (u64)pp->pkt_dma; 549 addr = (u64)pp->pkt_dma;
516 writel((u32) addr, chan + QS_CCF_CPBA); 550 writel((u32) addr, chan + QS_CCF_CPBA);
517 writel((u32)(addr >> 32), chan + QS_CCF_CPBA + 4); 551 writel((u32)(addr >> 32), chan + QS_CCF_CPBA + 4);
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 6332acad078c..b4c0888aedc3 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -28,6 +28,7 @@
28#include <linux/err.h> 28#include <linux/err.h>
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <net/sock.h> 30#include <net/sock.h>
31#include <linux/net.h>
31 32
32#include <asm/uaccess.h> 33#include <asm/uaccess.h>
33#include <asm/system.h> 34#include <asm/system.h>
@@ -126,7 +127,7 @@ static void sock_shutdown(struct nbd_device *lo, int lock)
126 if (lo->sock) { 127 if (lo->sock) {
127 printk(KERN_WARNING "%s: shutting down socket\n", 128 printk(KERN_WARNING "%s: shutting down socket\n",
128 lo->disk->disk_name); 129 lo->disk->disk_name);
129 lo->sock->ops->shutdown(lo->sock, SEND_SHUTDOWN|RCV_SHUTDOWN); 130 kernel_sock_shutdown(lo->sock, SHUT_RDWR);
130 lo->sock = NULL; 131 lo->sock = NULL;
131 } 132 }
132 if (lock) 133 if (lock)
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index ceffa6034e20..e7fe6ca97dd8 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -488,13 +488,11 @@ static int pf_atapi(struct pf_unit *pf, char *cmd, int dlen, char *buf, char *fu
488 return r; 488 return r;
489} 489}
490 490
491#define DBMSG(msg) ((verbose>1)?(msg):NULL)
492
493static void pf_lock(struct pf_unit *pf, int func) 491static void pf_lock(struct pf_unit *pf, int func)
494{ 492{
495 char lo_cmd[12] = { ATAPI_LOCK, pf->lun << 5, 0, 0, func, 0, 0, 0, 0, 0, 0, 0 }; 493 char lo_cmd[12] = { ATAPI_LOCK, pf->lun << 5, 0, 0, func, 0, 0, 0, 0, 0, 0, 0 };
496 494
497 pf_atapi(pf, lo_cmd, 0, pf_scratch, func ? "unlock" : "lock"); 495 pf_atapi(pf, lo_cmd, 0, pf_scratch, func ? "lock" : "unlock");
498} 496}
499 497
500static void pf_eject(struct pf_unit *pf) 498static void pf_eject(struct pf_unit *pf)
@@ -555,7 +553,7 @@ static void pf_mode_sense(struct pf_unit *pf)
555 { ATAPI_MODE_SENSE, pf->lun << 5, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0 }; 553 { ATAPI_MODE_SENSE, pf->lun << 5, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0 };
556 char buf[8]; 554 char buf[8];
557 555
558 pf_atapi(pf, ms_cmd, 8, buf, DBMSG("mode sense")); 556 pf_atapi(pf, ms_cmd, 8, buf, "mode sense");
559 pf->media_status = PF_RW; 557 pf->media_status = PF_RW;
560 if (buf[3] & 0x80) 558 if (buf[3] & 0x80)
561 pf->media_status = PF_RO; 559 pf->media_status = PF_RO;
@@ -591,7 +589,7 @@ static void pf_get_capacity(struct pf_unit *pf)
591 char buf[8]; 589 char buf[8];
592 int bs; 590 int bs;
593 591
594 if (pf_atapi(pf, rc_cmd, 8, buf, DBMSG("get capacity"))) { 592 if (pf_atapi(pf, rc_cmd, 8, buf, "get capacity")) {
595 pf->media_status = PF_NM; 593 pf->media_status = PF_NM;
596 return; 594 return;
597 } 595 }
@@ -804,13 +802,18 @@ static int pf_next_buf(void)
804 pf_buf += 512; 802 pf_buf += 512;
805 pf_block++; 803 pf_block++;
806 if (!pf_run) 804 if (!pf_run)
807 return 0;
808 if (!pf_count)
809 return 1; 805 return 1;
810 spin_lock_irqsave(&pf_spin_lock, saved_flags); 806 if (!pf_count) {
811 pf_end_request(1); 807 spin_lock_irqsave(&pf_spin_lock, saved_flags);
812 spin_unlock_irqrestore(&pf_spin_lock, saved_flags); 808 pf_end_request(1);
813 return 1; 809 pf_req = elv_next_request(pf_queue);
810 spin_unlock_irqrestore(&pf_spin_lock, saved_flags);
811 if (!pf_req)
812 return 1;
813 pf_count = pf_req->current_nr_sectors;
814 pf_buf = pf_req->buffer;
815 }
816 return 0;
814} 817}
815 818
816static inline void next_request(int success) 819static inline void next_request(int success)
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index a8130a4ad6d4..a5ee21319d37 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -358,10 +358,19 @@ static ssize_t class_pktcdvd_store_add(struct class *c, const char *buf,
358 size_t count) 358 size_t count)
359{ 359{
360 unsigned int major, minor; 360 unsigned int major, minor;
361
361 if (sscanf(buf, "%u:%u", &major, &minor) == 2) { 362 if (sscanf(buf, "%u:%u", &major, &minor) == 2) {
363 /* pkt_setup_dev() expects caller to hold reference to self */
364 if (!try_module_get(THIS_MODULE))
365 return -ENODEV;
366
362 pkt_setup_dev(MKDEV(major, minor), NULL); 367 pkt_setup_dev(MKDEV(major, minor), NULL);
368
369 module_put(THIS_MODULE);
370
363 return count; 371 return count;
364 } 372 }
373
365 return -EINVAL; 374 return -EINVAL;
366} 375}
367 376
diff --git a/drivers/block/rd.c b/drivers/block/rd.c
index 47f8ac6cce57..82f4eecc8699 100644
--- a/drivers/block/rd.c
+++ b/drivers/block/rd.c
@@ -189,6 +189,18 @@ static int ramdisk_set_page_dirty(struct page *page)
189 return 0; 189 return 0;
190} 190}
191 191
192/*
193 * releasepage is called by pagevec_strip/try_to_release_page if
194 * buffers_heads_over_limit is true. Without a releasepage function
195 * try_to_free_buffers is called instead. That can unset the dirty
196 * bit of our ram disk pages, which will be eventually freed, even
197 * if the page is still in use.
198 */
199static int ramdisk_releasepage(struct page *page, gfp_t dummy)
200{
201 return 0;
202}
203
192static const struct address_space_operations ramdisk_aops = { 204static const struct address_space_operations ramdisk_aops = {
193 .readpage = ramdisk_readpage, 205 .readpage = ramdisk_readpage,
194 .prepare_write = ramdisk_prepare_write, 206 .prepare_write = ramdisk_prepare_write,
@@ -196,6 +208,7 @@ static const struct address_space_operations ramdisk_aops = {
196 .writepage = ramdisk_writepage, 208 .writepage = ramdisk_writepage,
197 .set_page_dirty = ramdisk_set_page_dirty, 209 .set_page_dirty = ramdisk_set_page_dirty,
198 .writepages = ramdisk_writepages, 210 .writepages = ramdisk_writepages,
211 .releasepage = ramdisk_releasepage,
199}; 212};
200 213
201static int rd_blkdev_pagecache_IO(int rw, struct bio_vec *vec, sector_t sector, 214static int rd_blkdev_pagecache_IO(int rw, struct bio_vec *vec, sector_t sector,
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index cc5d77797def..02518da6a386 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -47,7 +47,7 @@
47/* #define ATR_CSUM */ 47/* #define ATR_CSUM */
48 48
49#ifdef PCMCIA_DEBUG 49#ifdef PCMCIA_DEBUG
50#define reader_to_dev(x) (&handle_to_dev(x->p_dev->handle)) 50#define reader_to_dev(x) (&handle_to_dev(x->p_dev))
51static int pc_debug = PCMCIA_DEBUG; 51static int pc_debug = PCMCIA_DEBUG;
52module_param(pc_debug, int, 0600); 52module_param(pc_debug, int, 0600);
53#define DEBUGP(n, rdr, x, args...) do { \ 53#define DEBUGP(n, rdr, x, args...) do { \
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index a0b9c8728d56..5f291bf739a6 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -41,7 +41,7 @@
41 41
42 42
43#ifdef PCMCIA_DEBUG 43#ifdef PCMCIA_DEBUG
44#define reader_to_dev(x) (&handle_to_dev(x->p_dev->handle)) 44#define reader_to_dev(x) (&handle_to_dev(x->p_dev))
45static int pc_debug = PCMCIA_DEBUG; 45static int pc_debug = PCMCIA_DEBUG;
46module_param(pc_debug, int, 0600); 46module_param(pc_debug, int, 0600);
47#define DEBUGP(n, rdr, x, args...) do { \ 47#define DEBUGP(n, rdr, x, args...) do { \
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 1756b1f7cb72..5fee05661823 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1494,7 +1494,7 @@ __u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr,
1494 seq = twothirdsMD4Transform((const __u32 *)daddr, hash) & HASH_MASK; 1494 seq = twothirdsMD4Transform((const __u32 *)daddr, hash) & HASH_MASK;
1495 seq += keyptr->count; 1495 seq += keyptr->count;
1496 1496
1497 seq += ktime_get_real().tv64; 1497 seq += ktime_to_ns(ktime_get_real());
1498 1498
1499 return seq; 1499 return seq;
1500} 1500}
@@ -1556,7 +1556,7 @@ __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr,
1556 * overlaps less than one time per MSL (2 minutes). 1556 * overlaps less than one time per MSL (2 minutes).
1557 * Choosing a clock of 64 ns period is OK. (period of 274 s) 1557 * Choosing a clock of 64 ns period is OK. (period of 274 s)
1558 */ 1558 */
1559 seq += ktime_get_real().tv64 >> 6; 1559 seq += ktime_to_ns(ktime_get_real()) >> 6;
1560#if 0 1560#if 0
1561 printk("init_seq(%lx, %lx, %d, %d) = %d\n", 1561 printk("init_seq(%lx, %lx, %d, %d) = %d\n",
1562 saddr, daddr, sport, dport, seq); 1562 saddr, daddr, sport, dport, seq);
@@ -1616,7 +1616,7 @@ u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr,
1616 seq = half_md4_transform(hash, keyptr->secret); 1616 seq = half_md4_transform(hash, keyptr->secret);
1617 seq |= ((u64)keyptr->count) << (32 - HASH_BITS); 1617 seq |= ((u64)keyptr->count) << (32 - HASH_BITS);
1618 1618
1619 seq += ktime_get_real().tv64; 1619 seq += ktime_to_ns(ktime_get_real());
1620 seq &= (1ull << 48) - 1; 1620 seq &= (1ull << 48) - 1;
1621#if 0 1621#if 0
1622 printk("dccp init_seq(%lx, %lx, %d, %d) = %d\n", 1622 printk("dccp init_seq(%lx, %lx, %d, %d) = %d\n",
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index ec6b65ec69ea..0c66b802736a 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -918,6 +918,31 @@ static const struct file_operations rtc_proc_fops = {
918}; 918};
919#endif 919#endif
920 920
921static resource_size_t rtc_size;
922
923static struct resource * __init rtc_request_region(resource_size_t size)
924{
925 struct resource *r;
926
927 if (RTC_IOMAPPED)
928 r = request_region(RTC_PORT(0), size, "rtc");
929 else
930 r = request_mem_region(RTC_PORT(0), size, "rtc");
931
932 if (r)
933 rtc_size = size;
934
935 return r;
936}
937
938static void rtc_release_region(void)
939{
940 if (RTC_IOMAPPED)
941 release_region(RTC_PORT(0), rtc_size);
942 else
943 release_mem_region(RTC_PORT(0), rtc_size);
944}
945
921static int __init rtc_init(void) 946static int __init rtc_init(void)
922{ 947{
923#ifdef CONFIG_PROC_FS 948#ifdef CONFIG_PROC_FS
@@ -968,10 +993,17 @@ found:
968 } 993 }
969no_irq: 994no_irq:
970#else 995#else
971 if (RTC_IOMAPPED) 996 r = rtc_request_region(RTC_IO_EXTENT);
972 r = request_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc"); 997
973 else 998 /*
974 r = request_mem_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc"); 999 * If we've already requested a smaller range (for example, because
1000 * PNPBIOS or ACPI told us how the device is configured), the request
1001 * above might fail because it's too big.
1002 *
1003 * If so, request just the range we actually use.
1004 */
1005 if (!r)
1006 r = rtc_request_region(RTC_IO_EXTENT_USED);
975 if (!r) { 1007 if (!r) {
976#ifdef RTC_IRQ 1008#ifdef RTC_IRQ
977 rtc_has_irq = 0; 1009 rtc_has_irq = 0;
@@ -992,10 +1024,7 @@ no_irq:
992 /* Yeah right, seeing as irq 8 doesn't even hit the bus. */ 1024 /* Yeah right, seeing as irq 8 doesn't even hit the bus. */
993 rtc_has_irq = 0; 1025 rtc_has_irq = 0;
994 printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ); 1026 printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ);
995 if (RTC_IOMAPPED) 1027 rtc_release_region();
996 release_region(RTC_PORT(0), RTC_IO_EXTENT);
997 else
998 release_mem_region(RTC_PORT(0), RTC_IO_EXTENT);
999 return -EIO; 1028 return -EIO;
1000 } 1029 }
1001 hpet_rtc_timer_init(); 1030 hpet_rtc_timer_init();
@@ -1009,7 +1038,7 @@ no_irq:
1009 free_irq(RTC_IRQ, NULL); 1038 free_irq(RTC_IRQ, NULL);
1010 rtc_has_irq = 0; 1039 rtc_has_irq = 0;
1011#endif 1040#endif
1012 release_region(RTC_PORT(0), RTC_IO_EXTENT); 1041 rtc_release_region();
1013 return -ENODEV; 1042 return -ENODEV;
1014 } 1043 }
1015 1044
@@ -1091,10 +1120,7 @@ static void __exit rtc_exit (void)
1091 if (rtc_has_irq) 1120 if (rtc_has_irq)
1092 free_irq (rtc_irq, &rtc_port); 1121 free_irq (rtc_irq, &rtc_port);
1093#else 1122#else
1094 if (RTC_IOMAPPED) 1123 rtc_release_region();
1095 release_region(RTC_PORT(0), RTC_IO_EXTENT);
1096 else
1097 release_mem_region(RTC_PORT(0), RTC_IO_EXTENT);
1098#ifdef RTC_IRQ 1124#ifdef RTC_IRQ
1099 if (rtc_has_irq) 1125 if (rtc_has_irq)
1100 free_irq (RTC_IRQ, NULL); 1126 free_irq (RTC_IRQ, NULL);
diff --git a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c
index 7a003504c265..1bdd2bf4f37d 100644
--- a/drivers/char/tty_ioctl.c
+++ b/drivers/char/tty_ioctl.c
@@ -730,13 +730,23 @@ static int send_prio_char(struct tty_struct *tty, char ch)
730 return 0; 730 return 0;
731} 731}
732 732
733int n_tty_ioctl(struct tty_struct * tty, struct file * file, 733/**
734 unsigned int cmd, unsigned long arg) 734 * tty_mode_ioctl - mode related ioctls
735 * @tty: tty for the ioctl
736 * @file: file pointer for the tty
737 * @cmd: command
738 * @arg: ioctl argument
739 *
740 * Perform non line discipline specific mode control ioctls. This
741 * is designed to be called by line disciplines to ensure they provide
742 * consistent mode setting.
743 */
744
745int tty_mode_ioctl(struct tty_struct * tty, struct file *file,
746 unsigned int cmd, unsigned long arg)
735{ 747{
736 struct tty_struct * real_tty; 748 struct tty_struct * real_tty;
737 void __user *p = (void __user *)arg; 749 void __user *p = (void __user *)arg;
738 int retval;
739 struct tty_ldisc *ld;
740 750
741 if (tty->driver->type == TTY_DRIVER_TYPE_PTY && 751 if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
742 tty->driver->subtype == PTY_TYPE_MASTER) 752 tty->driver->subtype == PTY_TYPE_MASTER)
@@ -799,6 +809,93 @@ int n_tty_ioctl(struct tty_struct * tty, struct file * file,
799 return set_termios(real_tty, p, TERMIOS_WAIT | TERMIOS_TERMIO); 809 return set_termios(real_tty, p, TERMIOS_WAIT | TERMIOS_TERMIO);
800 case TCSETA: 810 case TCSETA:
801 return set_termios(real_tty, p, TERMIOS_TERMIO); 811 return set_termios(real_tty, p, TERMIOS_TERMIO);
812#ifndef TCGETS2
813 case TIOCGLCKTRMIOS:
814 if (kernel_termios_to_user_termios((struct termios __user *)arg, real_tty->termios_locked))
815 return -EFAULT;
816 return 0;
817
818 case TIOCSLCKTRMIOS:
819 if (!capable(CAP_SYS_ADMIN))
820 return -EPERM;
821 if (user_termios_to_kernel_termios(real_tty->termios_locked, (struct termios __user *) arg))
822 return -EFAULT;
823 return 0;
824#else
825 case TIOCGLCKTRMIOS:
826 if (kernel_termios_to_user_termios_1((struct termios __user *)arg, real_tty->termios_locked))
827 return -EFAULT;
828 return 0;
829
830 case TIOCSLCKTRMIOS:
831 if (!capable(CAP_SYS_ADMIN))
832 return -EPERM;
833 if (user_termios_to_kernel_termios_1(real_tty->termios_locked, (struct termios __user *) arg))
834 return -EFAULT;
835 return 0;
836#endif
837 case TIOCGSOFTCAR:
838 return put_user(C_CLOCAL(tty) ? 1 : 0, (int __user *)arg);
839 case TIOCSSOFTCAR:
840 if (get_user(arg, (unsigned int __user *) arg))
841 return -EFAULT;
842 mutex_lock(&tty->termios_mutex);
843 tty->termios->c_cflag =
844 ((tty->termios->c_cflag & ~CLOCAL) |
845 (arg ? CLOCAL : 0));
846 mutex_unlock(&tty->termios_mutex);
847 return 0;
848 default:
849 return -ENOIOCTLCMD;
850 }
851}
852
853EXPORT_SYMBOL_GPL(tty_mode_ioctl);
854
855int tty_perform_flush(struct tty_struct *tty, unsigned long arg)
856{
857 struct tty_ldisc *ld;
858 int retval = tty_check_change(tty);
859 if (retval)
860 return retval;
861
862 ld = tty_ldisc_ref(tty);
863 switch (arg) {
864 case TCIFLUSH:
865 if (ld && ld->flush_buffer)
866 ld->flush_buffer(tty);
867 break;
868 case TCIOFLUSH:
869 if (ld && ld->flush_buffer)
870 ld->flush_buffer(tty);
871 /* fall through */
872 case TCOFLUSH:
873 if (tty->driver->flush_buffer)
874 tty->driver->flush_buffer(tty);
875 break;
876 default:
877 tty_ldisc_deref(ld);
878 return -EINVAL;
879 }
880 tty_ldisc_deref(ld);
881 return 0;
882}
883
884EXPORT_SYMBOL_GPL(tty_perform_flush);
885
886int n_tty_ioctl(struct tty_struct * tty, struct file * file,
887 unsigned int cmd, unsigned long arg)
888{
889 struct tty_struct * real_tty;
890 int retval;
891
892 if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
893 tty->driver->subtype == PTY_TYPE_MASTER)
894 real_tty = tty->link;
895 else
896 real_tty = tty;
897
898 switch (cmd) {
802 case TCXONC: 899 case TCXONC:
803 retval = tty_check_change(tty); 900 retval = tty_check_change(tty);
804 if (retval) 901 if (retval)
@@ -829,30 +926,7 @@ int n_tty_ioctl(struct tty_struct * tty, struct file * file,
829 } 926 }
830 return 0; 927 return 0;
831 case TCFLSH: 928 case TCFLSH:
832 retval = tty_check_change(tty); 929 return tty_perform_flush(tty, arg);
833 if (retval)
834 return retval;
835
836 ld = tty_ldisc_ref(tty);
837 switch (arg) {
838 case TCIFLUSH:
839 if (ld && ld->flush_buffer)
840 ld->flush_buffer(tty);
841 break;
842 case TCIOFLUSH:
843 if (ld && ld->flush_buffer)
844 ld->flush_buffer(tty);
845 /* fall through */
846 case TCOFLUSH:
847 if (tty->driver->flush_buffer)
848 tty->driver->flush_buffer(tty);
849 break;
850 default:
851 tty_ldisc_deref(ld);
852 return -EINVAL;
853 }
854 tty_ldisc_deref(ld);
855 return 0;
856 case TIOCOUTQ: 930 case TIOCOUTQ:
857 return put_user(tty->driver->chars_in_buffer ? 931 return put_user(tty->driver->chars_in_buffer ?
858 tty->driver->chars_in_buffer(tty) : 0, 932 tty->driver->chars_in_buffer(tty) : 0,
@@ -862,32 +936,6 @@ int n_tty_ioctl(struct tty_struct * tty, struct file * file,
862 if (L_ICANON(tty)) 936 if (L_ICANON(tty))
863 retval = inq_canon(tty); 937 retval = inq_canon(tty);
864 return put_user(retval, (unsigned int __user *) arg); 938 return put_user(retval, (unsigned int __user *) arg);
865#ifndef TCGETS2
866 case TIOCGLCKTRMIOS:
867 if (kernel_termios_to_user_termios((struct termios __user *)arg, real_tty->termios_locked))
868 return -EFAULT;
869 return 0;
870
871 case TIOCSLCKTRMIOS:
872 if (!capable(CAP_SYS_ADMIN))
873 return -EPERM;
874 if (user_termios_to_kernel_termios(real_tty->termios_locked, (struct termios __user *) arg))
875 return -EFAULT;
876 return 0;
877#else
878 case TIOCGLCKTRMIOS:
879 if (kernel_termios_to_user_termios_1((struct termios __user *)arg, real_tty->termios_locked))
880 return -EFAULT;
881 return 0;
882
883 case TIOCSLCKTRMIOS:
884 if (!capable(CAP_SYS_ADMIN))
885 return -EPERM;
886 if (user_termios_to_kernel_termios_1(real_tty->termios_locked, (struct termios __user *) arg))
887 return -EFAULT;
888 return 0;
889#endif
890
891 case TIOCPKT: 939 case TIOCPKT:
892 { 940 {
893 int pktmode; 941 int pktmode;
@@ -906,19 +954,9 @@ int n_tty_ioctl(struct tty_struct * tty, struct file * file,
906 tty->packet = 0; 954 tty->packet = 0;
907 return 0; 955 return 0;
908 } 956 }
909 case TIOCGSOFTCAR:
910 return put_user(C_CLOCAL(tty) ? 1 : 0, (int __user *)arg);
911 case TIOCSSOFTCAR:
912 if (get_user(arg, (unsigned int __user *) arg))
913 return -EFAULT;
914 mutex_lock(&tty->termios_mutex);
915 tty->termios->c_cflag =
916 ((tty->termios->c_cflag & ~CLOCAL) |
917 (arg ? CLOCAL : 0));
918 mutex_unlock(&tty->termios_mutex);
919 return 0;
920 default: 957 default:
921 return -ENOIOCTLCMD; 958 /* Try the mode commands */
959 return tty_mode_ioctl(tty, file, cmd, arg);
922 } 960 }
923} 961}
924 962
diff --git a/drivers/crypto/geode-aes.c b/drivers/crypto/geode-aes.c
index f9a34abbf4fa..711e246e1ef0 100644
--- a/drivers/crypto/geode-aes.c
+++ b/drivers/crypto/geode-aes.c
@@ -110,8 +110,7 @@ geode_aes_crypt(struct geode_aes_op *op)
110 * we don't need to worry 110 * we don't need to worry
111 */ 111 */
112 112
113 if (op->src == op->dst) 113 flags |= (AES_CTRL_DCA | AES_CTRL_SCA);
114 flags |= (AES_CTRL_DCA | AES_CTRL_SCA);
115 114
116 if (op->dir == AES_DIR_ENCRYPT) 115 if (op->dir == AES_DIR_ENCRYPT)
117 flags |= AES_CTRL_ENCRYPT; 116 flags |= AES_CTRL_ENCRYPT;
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 82489923af09..d59b2f417306 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -182,10 +182,9 @@ static void dma_client_chan_alloc(struct dma_client *client)
182 /* we are done once this client rejects 182 /* we are done once this client rejects
183 * an available resource 183 * an available resource
184 */ 184 */
185 if (ack == DMA_ACK) { 185 if (ack == DMA_ACK)
186 dma_chan_get(chan); 186 dma_chan_get(chan);
187 kref_get(&device->refcount); 187 else if (ack == DMA_NAK)
188 } else if (ack == DMA_NAK)
189 return; 188 return;
190 } 189 }
191 } 190 }
@@ -272,11 +271,8 @@ static void dma_clients_notify_removed(struct dma_chan *chan)
272 /* client was holding resources for this channel so 271 /* client was holding resources for this channel so
273 * free it 272 * free it
274 */ 273 */
275 if (ack == DMA_ACK) { 274 if (ack == DMA_ACK)
276 dma_chan_put(chan); 275 dma_chan_put(chan);
277 kref_put(&chan->device->refcount,
278 dma_async_device_cleanup);
279 }
280 } 276 }
281 277
282 mutex_unlock(&dma_list_mutex); 278 mutex_unlock(&dma_list_mutex);
@@ -316,11 +312,8 @@ void dma_async_client_unregister(struct dma_client *client)
316 ack = client->event_callback(client, chan, 312 ack = client->event_callback(client, chan,
317 DMA_RESOURCE_REMOVED); 313 DMA_RESOURCE_REMOVED);
318 314
319 if (ack == DMA_ACK) { 315 if (ack == DMA_ACK)
320 dma_chan_put(chan); 316 dma_chan_put(chan);
321 kref_put(&chan->device->refcount,
322 dma_async_device_cleanup);
323 }
324 } 317 }
325 318
326 list_del(&client->global_node); 319 list_del(&client->global_node);
@@ -397,6 +390,8 @@ int dma_async_device_register(struct dma_device *device)
397 goto err_out; 390 goto err_out;
398 } 391 }
399 392
393 /* One for the channel, one of the class device */
394 kref_get(&device->refcount);
400 kref_get(&device->refcount); 395 kref_get(&device->refcount);
401 kref_init(&chan->refcount); 396 kref_init(&chan->refcount);
402 chan->slow_ref = 0; 397 chan->slow_ref = 0;
diff --git a/drivers/dma/ioat.c b/drivers/dma/ioat.c
index f204c39fb412..16e0fd8facfb 100644
--- a/drivers/dma/ioat.c
+++ b/drivers/dma/ioat.c
@@ -39,10 +39,14 @@ MODULE_LICENSE("GPL");
39MODULE_AUTHOR("Intel Corporation"); 39MODULE_AUTHOR("Intel Corporation");
40 40
41static struct pci_device_id ioat_pci_tbl[] = { 41static struct pci_device_id ioat_pci_tbl[] = {
42 /* I/OAT v1 platforms */
42 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IOAT) }, 43 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IOAT) },
43 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IOAT_CNB) }, 44 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IOAT_CNB) },
44 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IOAT_SCNB) }, 45 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IOAT_SCNB) },
45 { PCI_DEVICE(PCI_VENDOR_ID_UNISYS, PCI_DEVICE_ID_UNISYS_DMA_DIRECTOR) }, 46 { PCI_DEVICE(PCI_VENDOR_ID_UNISYS, PCI_DEVICE_ID_UNISYS_DMA_DIRECTOR) },
47
48 /* I/OAT v2 platforms */
49 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IOAT_SNB) },
46 { 0, } 50 { 0, }
47}; 51};
48 52
@@ -74,10 +78,17 @@ static int ioat_setup_functionality(struct pci_dev *pdev, void __iomem *iobase)
74 if (device->dma && ioat_dca_enabled) 78 if (device->dma && ioat_dca_enabled)
75 device->dca = ioat_dca_init(pdev, iobase); 79 device->dca = ioat_dca_init(pdev, iobase);
76 break; 80 break;
81 case IOAT_VER_2_0:
82 device->dma = ioat_dma_probe(pdev, iobase);
83 if (device->dma && ioat_dca_enabled)
84 device->dca = ioat2_dca_init(pdev, iobase);
85 break;
77 default: 86 default:
78 err = -ENODEV; 87 err = -ENODEV;
79 break; 88 break;
80 } 89 }
90 if (!device->dma)
91 err = -ENODEV;
81 return err; 92 return err;
82} 93}
83 94
diff --git a/drivers/dma/ioat_dca.c b/drivers/dma/ioat_dca.c
index ba985715b803..0fa8a98051a8 100644
--- a/drivers/dma/ioat_dca.c
+++ b/drivers/dma/ioat_dca.c
@@ -261,3 +261,167 @@ struct dca_provider *ioat_dca_init(struct pci_dev *pdev, void __iomem *iobase)
261 return dca; 261 return dca;
262} 262}
263 263
264
265static int ioat2_dca_add_requester(struct dca_provider *dca, struct device *dev)
266{
267 struct ioat_dca_priv *ioatdca = dca_priv(dca);
268 struct pci_dev *pdev;
269 int i;
270 u16 id;
271 u16 global_req_table;
272
273 /* This implementation only supports PCI-Express */
274 if (dev->bus != &pci_bus_type)
275 return -ENODEV;
276 pdev = to_pci_dev(dev);
277 id = dcaid_from_pcidev(pdev);
278
279 if (ioatdca->requester_count == ioatdca->max_requesters)
280 return -ENODEV;
281
282 for (i = 0; i < ioatdca->max_requesters; i++) {
283 if (ioatdca->req_slots[i].pdev == NULL) {
284 /* found an empty slot */
285 ioatdca->requester_count++;
286 ioatdca->req_slots[i].pdev = pdev;
287 ioatdca->req_slots[i].rid = id;
288 global_req_table =
289 readw(ioatdca->dca_base + IOAT_DCA_GREQID_OFFSET);
290 writel(id | IOAT_DCA_GREQID_VALID,
291 ioatdca->iobase + global_req_table + (i * 4));
292 return i;
293 }
294 }
295 /* Error, ioatdma->requester_count is out of whack */
296 return -EFAULT;
297}
298
299static int ioat2_dca_remove_requester(struct dca_provider *dca,
300 struct device *dev)
301{
302 struct ioat_dca_priv *ioatdca = dca_priv(dca);
303 struct pci_dev *pdev;
304 int i;
305 u16 global_req_table;
306
307 /* This implementation only supports PCI-Express */
308 if (dev->bus != &pci_bus_type)
309 return -ENODEV;
310 pdev = to_pci_dev(dev);
311
312 for (i = 0; i < ioatdca->max_requesters; i++) {
313 if (ioatdca->req_slots[i].pdev == pdev) {
314 global_req_table =
315 readw(ioatdca->dca_base + IOAT_DCA_GREQID_OFFSET);
316 writel(0, ioatdca->iobase + global_req_table + (i * 4));
317 ioatdca->req_slots[i].pdev = NULL;
318 ioatdca->req_slots[i].rid = 0;
319 ioatdca->requester_count--;
320 return i;
321 }
322 }
323 return -ENODEV;
324}
325
326static u8 ioat2_dca_get_tag(struct dca_provider *dca, int cpu)
327{
328 u8 tag;
329
330 tag = ioat_dca_get_tag(dca, cpu);
331 tag = (~tag) & 0x1F;
332 return tag;
333}
334
335static struct dca_ops ioat2_dca_ops = {
336 .add_requester = ioat2_dca_add_requester,
337 .remove_requester = ioat2_dca_remove_requester,
338 .get_tag = ioat2_dca_get_tag,
339};
340
341static int ioat2_dca_count_dca_slots(void *iobase, u16 dca_offset)
342{
343 int slots = 0;
344 u32 req;
345 u16 global_req_table;
346
347 global_req_table = readw(iobase + dca_offset + IOAT_DCA_GREQID_OFFSET);
348 if (global_req_table == 0)
349 return 0;
350 do {
351 req = readl(iobase + global_req_table + (slots * sizeof(u32)));
352 slots++;
353 } while ((req & IOAT_DCA_GREQID_LASTID) == 0);
354
355 return slots;
356}
357
358struct dca_provider *ioat2_dca_init(struct pci_dev *pdev, void __iomem *iobase)
359{
360 struct dca_provider *dca;
361 struct ioat_dca_priv *ioatdca;
362 int slots;
363 int i;
364 int err;
365 u32 tag_map;
366 u16 dca_offset;
367 u16 csi_fsb_control;
368 u16 pcie_control;
369 u8 bit;
370
371 if (!system_has_dca_enabled(pdev))
372 return NULL;
373
374 dca_offset = readw(iobase + IOAT_DCAOFFSET_OFFSET);
375 if (dca_offset == 0)
376 return NULL;
377
378 slots = ioat2_dca_count_dca_slots(iobase, dca_offset);
379 if (slots == 0)
380 return NULL;
381
382 dca = alloc_dca_provider(&ioat2_dca_ops,
383 sizeof(*ioatdca)
384 + (sizeof(struct ioat_dca_slot) * slots));
385 if (!dca)
386 return NULL;
387
388 ioatdca = dca_priv(dca);
389 ioatdca->iobase = iobase;
390 ioatdca->dca_base = iobase + dca_offset;
391 ioatdca->max_requesters = slots;
392
393 /* some bios might not know to turn these on */
394 csi_fsb_control = readw(ioatdca->dca_base + IOAT_FSB_CAP_ENABLE_OFFSET);
395 if ((csi_fsb_control & IOAT_FSB_CAP_ENABLE_PREFETCH) == 0) {
396 csi_fsb_control |= IOAT_FSB_CAP_ENABLE_PREFETCH;
397 writew(csi_fsb_control,
398 ioatdca->dca_base + IOAT_FSB_CAP_ENABLE_OFFSET);
399 }
400 pcie_control = readw(ioatdca->dca_base + IOAT_PCI_CAP_ENABLE_OFFSET);
401 if ((pcie_control & IOAT_PCI_CAP_ENABLE_MEMWR) == 0) {
402 pcie_control |= IOAT_PCI_CAP_ENABLE_MEMWR;
403 writew(pcie_control,
404 ioatdca->dca_base + IOAT_PCI_CAP_ENABLE_OFFSET);
405 }
406
407
408 /* TODO version, compatibility and configuration checks */
409
410 /* copy out the APIC to DCA tag map */
411 tag_map = readl(ioatdca->dca_base + IOAT_APICID_TAG_MAP_OFFSET);
412 for (i = 0; i < 5; i++) {
413 bit = (tag_map >> (4 * i)) & 0x0f;
414 if (bit < 8)
415 ioatdca->tag_map[i] = bit | DCA_TAG_MAP_VALID;
416 else
417 ioatdca->tag_map[i] = 0;
418 }
419
420 err = register_dca_provider(dca, &pdev->dev);
421 if (err) {
422 free_dca_provider(dca);
423 return NULL;
424 }
425
426 return dca;
427}
diff --git a/drivers/dma/ioat_dma.c b/drivers/dma/ioat_dma.c
index 7e4a785c2dff..c1c2dcc6fc2e 100644
--- a/drivers/dma/ioat_dma.c
+++ b/drivers/dma/ioat_dma.c
@@ -36,18 +36,24 @@
36#include "ioatdma_registers.h" 36#include "ioatdma_registers.h"
37#include "ioatdma_hw.h" 37#include "ioatdma_hw.h"
38 38
39#define INITIAL_IOAT_DESC_COUNT 128
40
41#define to_ioat_chan(chan) container_of(chan, struct ioat_dma_chan, common) 39#define to_ioat_chan(chan) container_of(chan, struct ioat_dma_chan, common)
42#define to_ioatdma_device(dev) container_of(dev, struct ioatdma_device, common) 40#define to_ioatdma_device(dev) container_of(dev, struct ioatdma_device, common)
43#define to_ioat_desc(lh) container_of(lh, struct ioat_desc_sw, node) 41#define to_ioat_desc(lh) container_of(lh, struct ioat_desc_sw, node)
44#define tx_to_ioat_desc(tx) container_of(tx, struct ioat_desc_sw, async_tx) 42#define tx_to_ioat_desc(tx) container_of(tx, struct ioat_desc_sw, async_tx)
45 43
44static int ioat_pending_level = 4;
45module_param(ioat_pending_level, int, 0644);
46MODULE_PARM_DESC(ioat_pending_level,
47 "high-water mark for pushing ioat descriptors (default: 4)");
48
46/* internal functions */ 49/* internal functions */
47static void ioat_dma_start_null_desc(struct ioat_dma_chan *ioat_chan); 50static void ioat_dma_start_null_desc(struct ioat_dma_chan *ioat_chan);
48static void ioat_dma_memcpy_cleanup(struct ioat_dma_chan *ioat_chan); 51static void ioat_dma_memcpy_cleanup(struct ioat_dma_chan *ioat_chan);
52
53static struct ioat_desc_sw *
54ioat1_dma_get_next_descriptor(struct ioat_dma_chan *ioat_chan);
49static struct ioat_desc_sw * 55static struct ioat_desc_sw *
50ioat_dma_get_next_descriptor(struct ioat_dma_chan *ioat_chan); 56ioat2_dma_get_next_descriptor(struct ioat_dma_chan *ioat_chan);
51 57
52static inline struct ioat_dma_chan *ioat_lookup_chan_by_index( 58static inline struct ioat_dma_chan *ioat_lookup_chan_by_index(
53 struct ioatdma_device *device, 59 struct ioatdma_device *device,
@@ -130,6 +136,12 @@ static int ioat_dma_enumerate_channels(struct ioatdma_device *device)
130 ioat_chan->device = device; 136 ioat_chan->device = device;
131 ioat_chan->reg_base = device->reg_base + (0x80 * (i + 1)); 137 ioat_chan->reg_base = device->reg_base + (0x80 * (i + 1));
132 ioat_chan->xfercap = xfercap; 138 ioat_chan->xfercap = xfercap;
139 ioat_chan->desccount = 0;
140 if (ioat_chan->device->version != IOAT_VER_1_2) {
141 writel(IOAT_DCACTRL_CMPL_WRITE_ENABLE
142 | IOAT_DMA_DCA_ANY_CPU,
143 ioat_chan->reg_base + IOAT_DCACTRL_OFFSET);
144 }
133 spin_lock_init(&ioat_chan->cleanup_lock); 145 spin_lock_init(&ioat_chan->cleanup_lock);
134 spin_lock_init(&ioat_chan->desc_lock); 146 spin_lock_init(&ioat_chan->desc_lock);
135 INIT_LIST_HEAD(&ioat_chan->free_desc); 147 INIT_LIST_HEAD(&ioat_chan->free_desc);
@@ -161,13 +173,17 @@ static void ioat_set_dest(dma_addr_t addr,
161 tx_to_ioat_desc(tx)->dst = addr; 173 tx_to_ioat_desc(tx)->dst = addr;
162} 174}
163 175
164static dma_cookie_t ioat_tx_submit(struct dma_async_tx_descriptor *tx) 176static inline void __ioat1_dma_memcpy_issue_pending(
177 struct ioat_dma_chan *ioat_chan);
178static inline void __ioat2_dma_memcpy_issue_pending(
179 struct ioat_dma_chan *ioat_chan);
180
181static dma_cookie_t ioat1_tx_submit(struct dma_async_tx_descriptor *tx)
165{ 182{
166 struct ioat_dma_chan *ioat_chan = to_ioat_chan(tx->chan); 183 struct ioat_dma_chan *ioat_chan = to_ioat_chan(tx->chan);
167 struct ioat_desc_sw *first = tx_to_ioat_desc(tx); 184 struct ioat_desc_sw *first = tx_to_ioat_desc(tx);
168 struct ioat_desc_sw *prev, *new; 185 struct ioat_desc_sw *prev, *new;
169 struct ioat_dma_descriptor *hw; 186 struct ioat_dma_descriptor *hw;
170 int append = 0;
171 dma_cookie_t cookie; 187 dma_cookie_t cookie;
172 LIST_HEAD(new_chain); 188 LIST_HEAD(new_chain);
173 u32 copy; 189 u32 copy;
@@ -209,7 +225,7 @@ static dma_cookie_t ioat_tx_submit(struct dma_async_tx_descriptor *tx)
209 list_add_tail(&new->node, &new_chain); 225 list_add_tail(&new->node, &new_chain);
210 desc_count++; 226 desc_count++;
211 prev = new; 227 prev = new;
212 } while (len && (new = ioat_dma_get_next_descriptor(ioat_chan))); 228 } while (len && (new = ioat1_dma_get_next_descriptor(ioat_chan)));
213 229
214 hw->ctl = IOAT_DMA_DESCRIPTOR_CTL_CP_STS; 230 hw->ctl = IOAT_DMA_DESCRIPTOR_CTL_CP_STS;
215 if (new->async_tx.callback) { 231 if (new->async_tx.callback) {
@@ -246,20 +262,98 @@ static dma_cookie_t ioat_tx_submit(struct dma_async_tx_descriptor *tx)
246 first->async_tx.phys; 262 first->async_tx.phys;
247 __list_splice(&new_chain, ioat_chan->used_desc.prev); 263 __list_splice(&new_chain, ioat_chan->used_desc.prev);
248 264
265 ioat_chan->dmacount += desc_count;
249 ioat_chan->pending += desc_count; 266 ioat_chan->pending += desc_count;
250 if (ioat_chan->pending >= 4) { 267 if (ioat_chan->pending >= ioat_pending_level)
251 append = 1; 268 __ioat1_dma_memcpy_issue_pending(ioat_chan);
252 ioat_chan->pending = 0;
253 }
254 spin_unlock_bh(&ioat_chan->desc_lock); 269 spin_unlock_bh(&ioat_chan->desc_lock);
255 270
256 if (append) 271 return cookie;
257 writeb(IOAT_CHANCMD_APPEND, 272}
258 ioat_chan->reg_base + IOAT_CHANCMD_OFFSET); 273
274static dma_cookie_t ioat2_tx_submit(struct dma_async_tx_descriptor *tx)
275{
276 struct ioat_dma_chan *ioat_chan = to_ioat_chan(tx->chan);
277 struct ioat_desc_sw *first = tx_to_ioat_desc(tx);
278 struct ioat_desc_sw *new;
279 struct ioat_dma_descriptor *hw;
280 dma_cookie_t cookie;
281 u32 copy;
282 size_t len;
283 dma_addr_t src, dst;
284 int orig_ack;
285 unsigned int desc_count = 0;
286
287 /* src and dest and len are stored in the initial descriptor */
288 len = first->len;
289 src = first->src;
290 dst = first->dst;
291 orig_ack = first->async_tx.ack;
292 new = first;
293
294 /* ioat_chan->desc_lock is still in force in version 2 path */
295
296 do {
297 copy = min((u32) len, ioat_chan->xfercap);
298
299 new->async_tx.ack = 1;
300
301 hw = new->hw;
302 hw->size = copy;
303 hw->ctl = 0;
304 hw->src_addr = src;
305 hw->dst_addr = dst;
306
307 len -= copy;
308 dst += copy;
309 src += copy;
310 desc_count++;
311 } while (len && (new = ioat2_dma_get_next_descriptor(ioat_chan)));
312
313 hw->ctl = IOAT_DMA_DESCRIPTOR_CTL_CP_STS;
314 if (new->async_tx.callback) {
315 hw->ctl |= IOAT_DMA_DESCRIPTOR_CTL_INT_GN;
316 if (first != new) {
317 /* move callback into to last desc */
318 new->async_tx.callback = first->async_tx.callback;
319 new->async_tx.callback_param
320 = first->async_tx.callback_param;
321 first->async_tx.callback = NULL;
322 first->async_tx.callback_param = NULL;
323 }
324 }
325
326 new->tx_cnt = desc_count;
327 new->async_tx.ack = orig_ack; /* client is in control of this ack */
328
329 /* store the original values for use in later cleanup */
330 if (new != first) {
331 new->src = first->src;
332 new->dst = first->dst;
333 new->len = first->len;
334 }
335
336 /* cookie incr and addition to used_list must be atomic */
337 cookie = ioat_chan->common.cookie;
338 cookie++;
339 if (cookie < 0)
340 cookie = 1;
341 ioat_chan->common.cookie = new->async_tx.cookie = cookie;
342
343 ioat_chan->dmacount += desc_count;
344 ioat_chan->pending += desc_count;
345 if (ioat_chan->pending >= ioat_pending_level)
346 __ioat2_dma_memcpy_issue_pending(ioat_chan);
347 spin_unlock_bh(&ioat_chan->desc_lock);
259 348
260 return cookie; 349 return cookie;
261} 350}
262 351
352/**
353 * ioat_dma_alloc_descriptor - allocate and return a sw and hw descriptor pair
354 * @ioat_chan: the channel supplying the memory pool for the descriptors
355 * @flags: allocation flags
356 */
263static struct ioat_desc_sw *ioat_dma_alloc_descriptor( 357static struct ioat_desc_sw *ioat_dma_alloc_descriptor(
264 struct ioat_dma_chan *ioat_chan, 358 struct ioat_dma_chan *ioat_chan,
265 gfp_t flags) 359 gfp_t flags)
@@ -284,15 +378,57 @@ static struct ioat_desc_sw *ioat_dma_alloc_descriptor(
284 dma_async_tx_descriptor_init(&desc_sw->async_tx, &ioat_chan->common); 378 dma_async_tx_descriptor_init(&desc_sw->async_tx, &ioat_chan->common);
285 desc_sw->async_tx.tx_set_src = ioat_set_src; 379 desc_sw->async_tx.tx_set_src = ioat_set_src;
286 desc_sw->async_tx.tx_set_dest = ioat_set_dest; 380 desc_sw->async_tx.tx_set_dest = ioat_set_dest;
287 desc_sw->async_tx.tx_submit = ioat_tx_submit; 381 switch (ioat_chan->device->version) {
382 case IOAT_VER_1_2:
383 desc_sw->async_tx.tx_submit = ioat1_tx_submit;
384 break;
385 case IOAT_VER_2_0:
386 desc_sw->async_tx.tx_submit = ioat2_tx_submit;
387 break;
388 }
288 INIT_LIST_HEAD(&desc_sw->async_tx.tx_list); 389 INIT_LIST_HEAD(&desc_sw->async_tx.tx_list);
390
289 desc_sw->hw = desc; 391 desc_sw->hw = desc;
290 desc_sw->async_tx.phys = phys; 392 desc_sw->async_tx.phys = phys;
291 393
292 return desc_sw; 394 return desc_sw;
293} 395}
294 396
295/* returns the actual number of allocated descriptors */ 397static int ioat_initial_desc_count = 256;
398module_param(ioat_initial_desc_count, int, 0644);
399MODULE_PARM_DESC(ioat_initial_desc_count,
400 "initial descriptors per channel (default: 256)");
401
402/**
403 * ioat2_dma_massage_chan_desc - link the descriptors into a circle
404 * @ioat_chan: the channel to be massaged
405 */
406static void ioat2_dma_massage_chan_desc(struct ioat_dma_chan *ioat_chan)
407{
408 struct ioat_desc_sw *desc, *_desc;
409
410 /* setup used_desc */
411 ioat_chan->used_desc.next = ioat_chan->free_desc.next;
412 ioat_chan->used_desc.prev = NULL;
413
414 /* pull free_desc out of the circle so that every node is a hw
415 * descriptor, but leave it pointing to the list
416 */
417 ioat_chan->free_desc.prev->next = ioat_chan->free_desc.next;
418 ioat_chan->free_desc.next->prev = ioat_chan->free_desc.prev;
419
420 /* circle link the hw descriptors */
421 desc = to_ioat_desc(ioat_chan->free_desc.next);
422 desc->hw->next = to_ioat_desc(desc->node.next)->async_tx.phys;
423 list_for_each_entry_safe(desc, _desc, ioat_chan->free_desc.next, node) {
424 desc->hw->next = to_ioat_desc(desc->node.next)->async_tx.phys;
425 }
426}
427
428/**
429 * ioat_dma_alloc_chan_resources - returns the number of allocated descriptors
430 * @chan: the channel to be filled out
431 */
296static int ioat_dma_alloc_chan_resources(struct dma_chan *chan) 432static int ioat_dma_alloc_chan_resources(struct dma_chan *chan)
297{ 433{
298 struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan); 434 struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan);
@@ -304,7 +440,7 @@ static int ioat_dma_alloc_chan_resources(struct dma_chan *chan)
304 440
305 /* have we already been set up? */ 441 /* have we already been set up? */
306 if (!list_empty(&ioat_chan->free_desc)) 442 if (!list_empty(&ioat_chan->free_desc))
307 return INITIAL_IOAT_DESC_COUNT; 443 return ioat_chan->desccount;
308 444
309 /* Setup register to interrupt and write completion status on error */ 445 /* Setup register to interrupt and write completion status on error */
310 chanctrl = IOAT_CHANCTRL_ERR_INT_EN | 446 chanctrl = IOAT_CHANCTRL_ERR_INT_EN |
@@ -320,7 +456,7 @@ static int ioat_dma_alloc_chan_resources(struct dma_chan *chan)
320 } 456 }
321 457
322 /* Allocate descriptors */ 458 /* Allocate descriptors */
323 for (i = 0; i < INITIAL_IOAT_DESC_COUNT; i++) { 459 for (i = 0; i < ioat_initial_desc_count; i++) {
324 desc = ioat_dma_alloc_descriptor(ioat_chan, GFP_KERNEL); 460 desc = ioat_dma_alloc_descriptor(ioat_chan, GFP_KERNEL);
325 if (!desc) { 461 if (!desc) {
326 dev_err(&ioat_chan->device->pdev->dev, 462 dev_err(&ioat_chan->device->pdev->dev,
@@ -330,7 +466,10 @@ static int ioat_dma_alloc_chan_resources(struct dma_chan *chan)
330 list_add_tail(&desc->node, &tmp_list); 466 list_add_tail(&desc->node, &tmp_list);
331 } 467 }
332 spin_lock_bh(&ioat_chan->desc_lock); 468 spin_lock_bh(&ioat_chan->desc_lock);
469 ioat_chan->desccount = i;
333 list_splice(&tmp_list, &ioat_chan->free_desc); 470 list_splice(&tmp_list, &ioat_chan->free_desc);
471 if (ioat_chan->device->version != IOAT_VER_1_2)
472 ioat2_dma_massage_chan_desc(ioat_chan);
334 spin_unlock_bh(&ioat_chan->desc_lock); 473 spin_unlock_bh(&ioat_chan->desc_lock);
335 474
336 /* allocate a completion writeback area */ 475 /* allocate a completion writeback area */
@@ -347,10 +486,14 @@ static int ioat_dma_alloc_chan_resources(struct dma_chan *chan)
347 ioat_chan->reg_base + IOAT_CHANCMP_OFFSET_HIGH); 486 ioat_chan->reg_base + IOAT_CHANCMP_OFFSET_HIGH);
348 487
349 tasklet_enable(&ioat_chan->cleanup_task); 488 tasklet_enable(&ioat_chan->cleanup_task);
350 ioat_dma_start_null_desc(ioat_chan); 489 ioat_dma_start_null_desc(ioat_chan); /* give chain to dma device */
351 return i; 490 return ioat_chan->desccount;
352} 491}
353 492
493/**
494 * ioat_dma_free_chan_resources - release all the descriptors
495 * @chan: the channel to be cleaned
496 */
354static void ioat_dma_free_chan_resources(struct dma_chan *chan) 497static void ioat_dma_free_chan_resources(struct dma_chan *chan)
355{ 498{
356 struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan); 499 struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan);
@@ -364,22 +507,45 @@ static void ioat_dma_free_chan_resources(struct dma_chan *chan)
364 /* Delay 100ms after reset to allow internal DMA logic to quiesce 507 /* Delay 100ms after reset to allow internal DMA logic to quiesce
365 * before removing DMA descriptor resources. 508 * before removing DMA descriptor resources.
366 */ 509 */
367 writeb(IOAT_CHANCMD_RESET, ioat_chan->reg_base + IOAT_CHANCMD_OFFSET); 510 writeb(IOAT_CHANCMD_RESET,
511 ioat_chan->reg_base
512 + IOAT_CHANCMD_OFFSET(ioat_chan->device->version));
368 mdelay(100); 513 mdelay(100);
369 514
370 spin_lock_bh(&ioat_chan->desc_lock); 515 spin_lock_bh(&ioat_chan->desc_lock);
371 list_for_each_entry_safe(desc, _desc, &ioat_chan->used_desc, node) { 516 switch (ioat_chan->device->version) {
372 in_use_descs++; 517 case IOAT_VER_1_2:
373 list_del(&desc->node); 518 list_for_each_entry_safe(desc, _desc,
374 pci_pool_free(ioatdma_device->dma_pool, desc->hw, 519 &ioat_chan->used_desc, node) {
375 desc->async_tx.phys); 520 in_use_descs++;
376 kfree(desc); 521 list_del(&desc->node);
377 } 522 pci_pool_free(ioatdma_device->dma_pool, desc->hw,
378 list_for_each_entry_safe(desc, _desc, &ioat_chan->free_desc, node) { 523 desc->async_tx.phys);
379 list_del(&desc->node); 524 kfree(desc);
525 }
526 list_for_each_entry_safe(desc, _desc,
527 &ioat_chan->free_desc, node) {
528 list_del(&desc->node);
529 pci_pool_free(ioatdma_device->dma_pool, desc->hw,
530 desc->async_tx.phys);
531 kfree(desc);
532 }
533 break;
534 case IOAT_VER_2_0:
535 list_for_each_entry_safe(desc, _desc,
536 ioat_chan->free_desc.next, node) {
537 list_del(&desc->node);
538 pci_pool_free(ioatdma_device->dma_pool, desc->hw,
539 desc->async_tx.phys);
540 kfree(desc);
541 }
542 desc = to_ioat_desc(ioat_chan->free_desc.next);
380 pci_pool_free(ioatdma_device->dma_pool, desc->hw, 543 pci_pool_free(ioatdma_device->dma_pool, desc->hw,
381 desc->async_tx.phys); 544 desc->async_tx.phys);
382 kfree(desc); 545 kfree(desc);
546 INIT_LIST_HEAD(&ioat_chan->free_desc);
547 INIT_LIST_HEAD(&ioat_chan->used_desc);
548 break;
383 } 549 }
384 spin_unlock_bh(&ioat_chan->desc_lock); 550 spin_unlock_bh(&ioat_chan->desc_lock);
385 551
@@ -395,6 +561,7 @@ static void ioat_dma_free_chan_resources(struct dma_chan *chan)
395 561
396 ioat_chan->last_completion = ioat_chan->completion_addr = 0; 562 ioat_chan->last_completion = ioat_chan->completion_addr = 0;
397 ioat_chan->pending = 0; 563 ioat_chan->pending = 0;
564 ioat_chan->dmacount = 0;
398} 565}
399 566
400/** 567/**
@@ -406,7 +573,7 @@ static void ioat_dma_free_chan_resources(struct dma_chan *chan)
406 * has run out. 573 * has run out.
407 */ 574 */
408static struct ioat_desc_sw * 575static struct ioat_desc_sw *
409ioat_dma_get_next_descriptor(struct ioat_dma_chan *ioat_chan) 576ioat1_dma_get_next_descriptor(struct ioat_dma_chan *ioat_chan)
410{ 577{
411 struct ioat_desc_sw *new = NULL; 578 struct ioat_desc_sw *new = NULL;
412 579
@@ -425,7 +592,82 @@ ioat_dma_get_next_descriptor(struct ioat_dma_chan *ioat_chan)
425 return new; 592 return new;
426} 593}
427 594
428static struct dma_async_tx_descriptor *ioat_dma_prep_memcpy( 595static struct ioat_desc_sw *
596ioat2_dma_get_next_descriptor(struct ioat_dma_chan *ioat_chan)
597{
598 struct ioat_desc_sw *new = NULL;
599
600 /*
601 * used.prev points to where to start processing
602 * used.next points to next free descriptor
603 * if used.prev == NULL, there are none waiting to be processed
604 * if used.next == used.prev.prev, there is only one free descriptor,
605 * and we need to use it to as a noop descriptor before
606 * linking in a new set of descriptors, since the device
607 * has probably already read the pointer to it
608 */
609 if (ioat_chan->used_desc.prev &&
610 ioat_chan->used_desc.next == ioat_chan->used_desc.prev->prev) {
611
612 struct ioat_desc_sw *desc = NULL;
613 struct ioat_desc_sw *noop_desc = NULL;
614 int i;
615
616 /* set up the noop descriptor */
617 noop_desc = to_ioat_desc(ioat_chan->used_desc.next);
618 noop_desc->hw->size = 0;
619 noop_desc->hw->ctl = IOAT_DMA_DESCRIPTOR_NUL;
620 noop_desc->hw->src_addr = 0;
621 noop_desc->hw->dst_addr = 0;
622
623 ioat_chan->used_desc.next = ioat_chan->used_desc.next->next;
624 ioat_chan->pending++;
625 ioat_chan->dmacount++;
626
627 /* get a few more descriptors */
628 for (i = 16; i; i--) {
629 desc = ioat_dma_alloc_descriptor(ioat_chan, GFP_ATOMIC);
630 BUG_ON(!desc);
631 list_add_tail(&desc->node, ioat_chan->used_desc.next);
632
633 desc->hw->next
634 = to_ioat_desc(desc->node.next)->async_tx.phys;
635 to_ioat_desc(desc->node.prev)->hw->next
636 = desc->async_tx.phys;
637 ioat_chan->desccount++;
638 }
639
640 ioat_chan->used_desc.next = noop_desc->node.next;
641 }
642 new = to_ioat_desc(ioat_chan->used_desc.next);
643 prefetch(new);
644 ioat_chan->used_desc.next = new->node.next;
645
646 if (ioat_chan->used_desc.prev == NULL)
647 ioat_chan->used_desc.prev = &new->node;
648
649 prefetch(new->hw);
650 return new;
651}
652
653static struct ioat_desc_sw *ioat_dma_get_next_descriptor(
654 struct ioat_dma_chan *ioat_chan)
655{
656 if (!ioat_chan)
657 return NULL;
658
659 switch (ioat_chan->device->version) {
660 case IOAT_VER_1_2:
661 return ioat1_dma_get_next_descriptor(ioat_chan);
662 break;
663 case IOAT_VER_2_0:
664 return ioat2_dma_get_next_descriptor(ioat_chan);
665 break;
666 }
667 return NULL;
668}
669
670static struct dma_async_tx_descriptor *ioat1_dma_prep_memcpy(
429 struct dma_chan *chan, 671 struct dma_chan *chan,
430 size_t len, 672 size_t len,
431 int int_en) 673 int int_en)
@@ -441,19 +683,62 @@ static struct dma_async_tx_descriptor *ioat_dma_prep_memcpy(
441 return new ? &new->async_tx : NULL; 683 return new ? &new->async_tx : NULL;
442} 684}
443 685
686static struct dma_async_tx_descriptor *ioat2_dma_prep_memcpy(
687 struct dma_chan *chan,
688 size_t len,
689 int int_en)
690{
691 struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan);
692 struct ioat_desc_sw *new;
693
694 spin_lock_bh(&ioat_chan->desc_lock);
695 new = ioat2_dma_get_next_descriptor(ioat_chan);
696 new->len = len;
697
698 /* leave ioat_chan->desc_lock set in version 2 path */
699 return new ? &new->async_tx : NULL;
700}
701
702
444/** 703/**
445 * ioat_dma_memcpy_issue_pending - push potentially unrecognized appended 704 * ioat_dma_memcpy_issue_pending - push potentially unrecognized appended
446 * descriptors to hw 705 * descriptors to hw
447 * @chan: DMA channel handle 706 * @chan: DMA channel handle
448 */ 707 */
449static void ioat_dma_memcpy_issue_pending(struct dma_chan *chan) 708static inline void __ioat1_dma_memcpy_issue_pending(
709 struct ioat_dma_chan *ioat_chan)
710{
711 ioat_chan->pending = 0;
712 writeb(IOAT_CHANCMD_APPEND, ioat_chan->reg_base + IOAT1_CHANCMD_OFFSET);
713}
714
715static void ioat1_dma_memcpy_issue_pending(struct dma_chan *chan)
450{ 716{
451 struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan); 717 struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan);
452 718
453 if (ioat_chan->pending != 0) { 719 if (ioat_chan->pending != 0) {
454 ioat_chan->pending = 0; 720 spin_lock_bh(&ioat_chan->desc_lock);
455 writeb(IOAT_CHANCMD_APPEND, 721 __ioat1_dma_memcpy_issue_pending(ioat_chan);
456 ioat_chan->reg_base + IOAT_CHANCMD_OFFSET); 722 spin_unlock_bh(&ioat_chan->desc_lock);
723 }
724}
725
726static inline void __ioat2_dma_memcpy_issue_pending(
727 struct ioat_dma_chan *ioat_chan)
728{
729 ioat_chan->pending = 0;
730 writew(ioat_chan->dmacount,
731 ioat_chan->reg_base + IOAT_CHAN_DMACOUNT_OFFSET);
732}
733
734static void ioat2_dma_memcpy_issue_pending(struct dma_chan *chan)
735{
736 struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan);
737
738 if (ioat_chan->pending != 0) {
739 spin_lock_bh(&ioat_chan->desc_lock);
740 __ioat2_dma_memcpy_issue_pending(ioat_chan);
741 spin_unlock_bh(&ioat_chan->desc_lock);
457 } 742 }
458} 743}
459 744
@@ -465,11 +750,17 @@ static void ioat_dma_cleanup_tasklet(unsigned long data)
465 chan->reg_base + IOAT_CHANCTRL_OFFSET); 750 chan->reg_base + IOAT_CHANCTRL_OFFSET);
466} 751}
467 752
753/**
754 * ioat_dma_memcpy_cleanup - cleanup up finished descriptors
755 * @chan: ioat channel to be cleaned up
756 */
468static void ioat_dma_memcpy_cleanup(struct ioat_dma_chan *ioat_chan) 757static void ioat_dma_memcpy_cleanup(struct ioat_dma_chan *ioat_chan)
469{ 758{
470 unsigned long phys_complete; 759 unsigned long phys_complete;
471 struct ioat_desc_sw *desc, *_desc; 760 struct ioat_desc_sw *desc, *_desc;
472 dma_cookie_t cookie = 0; 761 dma_cookie_t cookie = 0;
762 unsigned long desc_phys;
763 struct ioat_desc_sw *latest_desc;
473 764
474 prefetch(ioat_chan->completion_virt); 765 prefetch(ioat_chan->completion_virt);
475 766
@@ -507,56 +798,115 @@ static void ioat_dma_memcpy_cleanup(struct ioat_dma_chan *ioat_chan)
507 798
508 cookie = 0; 799 cookie = 0;
509 spin_lock_bh(&ioat_chan->desc_lock); 800 spin_lock_bh(&ioat_chan->desc_lock);
510 list_for_each_entry_safe(desc, _desc, &ioat_chan->used_desc, node) { 801 switch (ioat_chan->device->version) {
511 802 case IOAT_VER_1_2:
512 /* 803 list_for_each_entry_safe(desc, _desc,
513 * Incoming DMA requests may use multiple descriptors, due to 804 &ioat_chan->used_desc, node) {
514 * exceeding xfercap, perhaps. If so, only the last one will
515 * have a cookie, and require unmapping.
516 */
517 if (desc->async_tx.cookie) {
518 cookie = desc->async_tx.cookie;
519 805
520 /* 806 /*
521 * yes we are unmapping both _page and _single alloc'd 807 * Incoming DMA requests may use multiple descriptors,
522 * regions with unmap_page. Is this *really* that bad? 808 * due to exceeding xfercap, perhaps. If so, only the
809 * last one will have a cookie, and require unmapping.
523 */ 810 */
524 pci_unmap_page(ioat_chan->device->pdev, 811 if (desc->async_tx.cookie) {
525 pci_unmap_addr(desc, dst), 812 cookie = desc->async_tx.cookie;
526 pci_unmap_len(desc, len), 813
527 PCI_DMA_FROMDEVICE); 814 /*
528 pci_unmap_page(ioat_chan->device->pdev, 815 * yes we are unmapping both _page and _single
529 pci_unmap_addr(desc, src), 816 * alloc'd regions with unmap_page. Is this
530 pci_unmap_len(desc, len), 817 * *really* that bad?
531 PCI_DMA_TODEVICE); 818 */
532 if (desc->async_tx.callback) { 819 pci_unmap_page(ioat_chan->device->pdev,
533 desc->async_tx.callback( 820 pci_unmap_addr(desc, dst),
534 desc->async_tx.callback_param); 821 pci_unmap_len(desc, len),
535 desc->async_tx.callback = NULL; 822 PCI_DMA_FROMDEVICE);
823 pci_unmap_page(ioat_chan->device->pdev,
824 pci_unmap_addr(desc, src),
825 pci_unmap_len(desc, len),
826 PCI_DMA_TODEVICE);
827
828 if (desc->async_tx.callback) {
829 desc->async_tx.callback(desc->async_tx.callback_param);
830 desc->async_tx.callback = NULL;
831 }
536 } 832 }
537 }
538 833
539 if (desc->async_tx.phys != phys_complete) { 834 if (desc->async_tx.phys != phys_complete) {
540 /* 835 /*
541 * a completed entry, but not the last, so cleanup 836 * a completed entry, but not the last, so clean
542 * if the client is done with the descriptor 837 * up if the client is done with the descriptor
543 */ 838 */
544 if (desc->async_tx.ack) { 839 if (desc->async_tx.ack) {
545 list_del(&desc->node); 840 list_del(&desc->node);
546 list_add_tail(&desc->node, 841 list_add_tail(&desc->node,
547 &ioat_chan->free_desc); 842 &ioat_chan->free_desc);
548 } else 843 } else
844 desc->async_tx.cookie = 0;
845 } else {
846 /*
847 * last used desc. Do not remove, so we can
848 * append from it, but don't look at it next
849 * time, either
850 */
549 desc->async_tx.cookie = 0; 851 desc->async_tx.cookie = 0;
550 } else {
551 /*
552 * last used desc. Do not remove, so we can append from
553 * it, but don't look at it next time, either
554 */
555 desc->async_tx.cookie = 0;
556 852
557 /* TODO check status bits? */ 853 /* TODO check status bits? */
854 break;
855 }
856 }
857 break;
858 case IOAT_VER_2_0:
859 /* has some other thread has already cleaned up? */
860 if (ioat_chan->used_desc.prev == NULL)
558 break; 861 break;
862
863 /* work backwards to find latest finished desc */
864 desc = to_ioat_desc(ioat_chan->used_desc.next);
865 latest_desc = NULL;
866 do {
867 desc = to_ioat_desc(desc->node.prev);
868 desc_phys = (unsigned long)desc->async_tx.phys
869 & IOAT_CHANSTS_COMPLETED_DESCRIPTOR_ADDR;
870 if (desc_phys == phys_complete) {
871 latest_desc = desc;
872 break;
873 }
874 } while (&desc->node != ioat_chan->used_desc.prev);
875
876 if (latest_desc != NULL) {
877
878 /* work forwards to clear finished descriptors */
879 for (desc = to_ioat_desc(ioat_chan->used_desc.prev);
880 &desc->node != latest_desc->node.next &&
881 &desc->node != ioat_chan->used_desc.next;
882 desc = to_ioat_desc(desc->node.next)) {
883 if (desc->async_tx.cookie) {
884 cookie = desc->async_tx.cookie;
885 desc->async_tx.cookie = 0;
886
887 pci_unmap_page(ioat_chan->device->pdev,
888 pci_unmap_addr(desc, dst),
889 pci_unmap_len(desc, len),
890 PCI_DMA_FROMDEVICE);
891 pci_unmap_page(ioat_chan->device->pdev,
892 pci_unmap_addr(desc, src),
893 pci_unmap_len(desc, len),
894 PCI_DMA_TODEVICE);
895
896 if (desc->async_tx.callback) {
897 desc->async_tx.callback(desc->async_tx.callback_param);
898 desc->async_tx.callback = NULL;
899 }
900 }
901 }
902
903 /* move used.prev up beyond those that are finished */
904 if (&desc->node == ioat_chan->used_desc.next)
905 ioat_chan->used_desc.prev = NULL;
906 else
907 ioat_chan->used_desc.prev = &desc->node;
559 } 908 }
909 break;
560 } 910 }
561 911
562 spin_unlock_bh(&ioat_chan->desc_lock); 912 spin_unlock_bh(&ioat_chan->desc_lock);
@@ -621,8 +971,6 @@ static enum dma_status ioat_dma_is_complete(struct dma_chan *chan,
621 return dma_async_is_complete(cookie, last_complete, last_used); 971 return dma_async_is_complete(cookie, last_complete, last_used);
622} 972}
623 973
624/* PCI API */
625
626static void ioat_dma_start_null_desc(struct ioat_dma_chan *ioat_chan) 974static void ioat_dma_start_null_desc(struct ioat_dma_chan *ioat_chan)
627{ 975{
628 struct ioat_desc_sw *desc; 976 struct ioat_desc_sw *desc;
@@ -633,21 +981,34 @@ static void ioat_dma_start_null_desc(struct ioat_dma_chan *ioat_chan)
633 desc->hw->ctl = IOAT_DMA_DESCRIPTOR_NUL 981 desc->hw->ctl = IOAT_DMA_DESCRIPTOR_NUL
634 | IOAT_DMA_DESCRIPTOR_CTL_INT_GN 982 | IOAT_DMA_DESCRIPTOR_CTL_INT_GN
635 | IOAT_DMA_DESCRIPTOR_CTL_CP_STS; 983 | IOAT_DMA_DESCRIPTOR_CTL_CP_STS;
636 desc->hw->next = 0;
637 desc->hw->size = 0; 984 desc->hw->size = 0;
638 desc->hw->src_addr = 0; 985 desc->hw->src_addr = 0;
639 desc->hw->dst_addr = 0; 986 desc->hw->dst_addr = 0;
640 desc->async_tx.ack = 1; 987 desc->async_tx.ack = 1;
641 988 switch (ioat_chan->device->version) {
642 list_add_tail(&desc->node, &ioat_chan->used_desc); 989 case IOAT_VER_1_2:
990 desc->hw->next = 0;
991 list_add_tail(&desc->node, &ioat_chan->used_desc);
992
993 writel(((u64) desc->async_tx.phys) & 0x00000000FFFFFFFF,
994 ioat_chan->reg_base + IOAT1_CHAINADDR_OFFSET_LOW);
995 writel(((u64) desc->async_tx.phys) >> 32,
996 ioat_chan->reg_base + IOAT1_CHAINADDR_OFFSET_HIGH);
997
998 writeb(IOAT_CHANCMD_START, ioat_chan->reg_base
999 + IOAT_CHANCMD_OFFSET(ioat_chan->device->version));
1000 break;
1001 case IOAT_VER_2_0:
1002 writel(((u64) desc->async_tx.phys) & 0x00000000FFFFFFFF,
1003 ioat_chan->reg_base + IOAT2_CHAINADDR_OFFSET_LOW);
1004 writel(((u64) desc->async_tx.phys) >> 32,
1005 ioat_chan->reg_base + IOAT2_CHAINADDR_OFFSET_HIGH);
1006
1007 ioat_chan->dmacount++;
1008 __ioat2_dma_memcpy_issue_pending(ioat_chan);
1009 break;
1010 }
643 spin_unlock_bh(&ioat_chan->desc_lock); 1011 spin_unlock_bh(&ioat_chan->desc_lock);
644
645 writel(((u64) desc->async_tx.phys) & 0x00000000FFFFFFFF,
646 ioat_chan->reg_base + IOAT_CHAINADDR_OFFSET_LOW);
647 writel(((u64) desc->async_tx.phys) >> 32,
648 ioat_chan->reg_base + IOAT_CHAINADDR_OFFSET_HIGH);
649
650 writeb(IOAT_CHANCMD_START, ioat_chan->reg_base + IOAT_CHANCMD_OFFSET);
651} 1012}
652 1013
653/* 1014/*
@@ -693,14 +1054,14 @@ static int ioat_dma_self_test(struct ioatdma_device *device)
693 dma_chan = container_of(device->common.channels.next, 1054 dma_chan = container_of(device->common.channels.next,
694 struct dma_chan, 1055 struct dma_chan,
695 device_node); 1056 device_node);
696 if (ioat_dma_alloc_chan_resources(dma_chan) < 1) { 1057 if (device->common.device_alloc_chan_resources(dma_chan) < 1) {
697 dev_err(&device->pdev->dev, 1058 dev_err(&device->pdev->dev,
698 "selftest cannot allocate chan resource\n"); 1059 "selftest cannot allocate chan resource\n");
699 err = -ENODEV; 1060 err = -ENODEV;
700 goto out; 1061 goto out;
701 } 1062 }
702 1063
703 tx = ioat_dma_prep_memcpy(dma_chan, IOAT_TEST_SIZE, 0); 1064 tx = device->common.device_prep_dma_memcpy(dma_chan, IOAT_TEST_SIZE, 0);
704 if (!tx) { 1065 if (!tx) {
705 dev_err(&device->pdev->dev, 1066 dev_err(&device->pdev->dev,
706 "Self-test prep failed, disabling\n"); 1067 "Self-test prep failed, disabling\n");
@@ -710,24 +1071,25 @@ static int ioat_dma_self_test(struct ioatdma_device *device)
710 1071
711 async_tx_ack(tx); 1072 async_tx_ack(tx);
712 addr = dma_map_single(dma_chan->device->dev, src, IOAT_TEST_SIZE, 1073 addr = dma_map_single(dma_chan->device->dev, src, IOAT_TEST_SIZE,
713 DMA_TO_DEVICE); 1074 DMA_TO_DEVICE);
714 ioat_set_src(addr, tx, 0); 1075 tx->tx_set_src(addr, tx, 0);
715 addr = dma_map_single(dma_chan->device->dev, dest, IOAT_TEST_SIZE, 1076 addr = dma_map_single(dma_chan->device->dev, dest, IOAT_TEST_SIZE,
716 DMA_FROM_DEVICE); 1077 DMA_FROM_DEVICE);
717 ioat_set_dest(addr, tx, 0); 1078 tx->tx_set_dest(addr, tx, 0);
718 tx->callback = ioat_dma_test_callback; 1079 tx->callback = ioat_dma_test_callback;
719 tx->callback_param = (void *)0x8086; 1080 tx->callback_param = (void *)0x8086;
720 cookie = ioat_tx_submit(tx); 1081 cookie = tx->tx_submit(tx);
721 if (cookie < 0) { 1082 if (cookie < 0) {
722 dev_err(&device->pdev->dev, 1083 dev_err(&device->pdev->dev,
723 "Self-test setup failed, disabling\n"); 1084 "Self-test setup failed, disabling\n");
724 err = -ENODEV; 1085 err = -ENODEV;
725 goto free_resources; 1086 goto free_resources;
726 } 1087 }
727 ioat_dma_memcpy_issue_pending(dma_chan); 1088 device->common.device_issue_pending(dma_chan);
728 msleep(1); 1089 msleep(1);
729 1090
730 if (ioat_dma_is_complete(dma_chan, cookie, NULL, NULL) != DMA_SUCCESS) { 1091 if (device->common.device_is_tx_complete(dma_chan, cookie, NULL, NULL)
1092 != DMA_SUCCESS) {
731 dev_err(&device->pdev->dev, 1093 dev_err(&device->pdev->dev,
732 "Self-test copy timed out, disabling\n"); 1094 "Self-test copy timed out, disabling\n");
733 err = -ENODEV; 1095 err = -ENODEV;
@@ -741,7 +1103,7 @@ static int ioat_dma_self_test(struct ioatdma_device *device)
741 } 1103 }
742 1104
743free_resources: 1105free_resources:
744 ioat_dma_free_chan_resources(dma_chan); 1106 device->common.device_free_chan_resources(dma_chan);
745out: 1107out:
746 kfree(src); 1108 kfree(src);
747 kfree(dest); 1109 kfree(dest);
@@ -941,16 +1303,28 @@ struct ioatdma_device *ioat_dma_probe(struct pci_dev *pdev,
941 INIT_LIST_HEAD(&device->common.channels); 1303 INIT_LIST_HEAD(&device->common.channels);
942 ioat_dma_enumerate_channels(device); 1304 ioat_dma_enumerate_channels(device);
943 1305
944 dma_cap_set(DMA_MEMCPY, device->common.cap_mask);
945 device->common.device_alloc_chan_resources = 1306 device->common.device_alloc_chan_resources =
946 ioat_dma_alloc_chan_resources; 1307 ioat_dma_alloc_chan_resources;
947 device->common.device_free_chan_resources = 1308 device->common.device_free_chan_resources =
948 ioat_dma_free_chan_resources; 1309 ioat_dma_free_chan_resources;
949 device->common.device_prep_dma_memcpy = ioat_dma_prep_memcpy; 1310 device->common.dev = &pdev->dev;
1311
1312 dma_cap_set(DMA_MEMCPY, device->common.cap_mask);
950 device->common.device_is_tx_complete = ioat_dma_is_complete; 1313 device->common.device_is_tx_complete = ioat_dma_is_complete;
951 device->common.device_issue_pending = ioat_dma_memcpy_issue_pending;
952 device->common.device_dependency_added = ioat_dma_dependency_added; 1314 device->common.device_dependency_added = ioat_dma_dependency_added;
953 device->common.dev = &pdev->dev; 1315 switch (device->version) {
1316 case IOAT_VER_1_2:
1317 device->common.device_prep_dma_memcpy = ioat1_dma_prep_memcpy;
1318 device->common.device_issue_pending =
1319 ioat1_dma_memcpy_issue_pending;
1320 break;
1321 case IOAT_VER_2_0:
1322 device->common.device_prep_dma_memcpy = ioat2_dma_prep_memcpy;
1323 device->common.device_issue_pending =
1324 ioat2_dma_memcpy_issue_pending;
1325 break;
1326 }
1327
954 dev_err(&device->pdev->dev, 1328 dev_err(&device->pdev->dev,
955 "Intel(R) I/OAT DMA Engine found," 1329 "Intel(R) I/OAT DMA Engine found,"
956 " %d channels, device version 0x%02x, driver version %s\n", 1330 " %d channels, device version 0x%02x, driver version %s\n",
diff --git a/drivers/dma/ioatdma.h b/drivers/dma/ioatdma.h
index 5f9881e7b0ed..b668234ef654 100644
--- a/drivers/dma/ioatdma.h
+++ b/drivers/dma/ioatdma.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright(c) 2004 - 2006 Intel Corporation. All rights reserved. 2 * Copyright(c) 2004 - 2007 Intel Corporation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free 5 * under the terms of the GNU General Public License as published by the Free
@@ -28,7 +28,7 @@
28#include <linux/cache.h> 28#include <linux/cache.h>
29#include <linux/pci_ids.h> 29#include <linux/pci_ids.h>
30 30
31#define IOAT_DMA_VERSION "1.26" 31#define IOAT_DMA_VERSION "2.04"
32 32
33enum ioat_interrupt { 33enum ioat_interrupt {
34 none = 0, 34 none = 0,
@@ -39,6 +39,8 @@ enum ioat_interrupt {
39}; 39};
40 40
41#define IOAT_LOW_COMPLETION_MASK 0xffffffc0 41#define IOAT_LOW_COMPLETION_MASK 0xffffffc0
42#define IOAT_DMA_DCA_ANY_CPU ~0
43
42 44
43/** 45/**
44 * struct ioatdma_device - internal representation of a IOAT device 46 * struct ioatdma_device - internal representation of a IOAT device
@@ -47,6 +49,9 @@ enum ioat_interrupt {
47 * @dma_pool: for allocating DMA descriptors 49 * @dma_pool: for allocating DMA descriptors
48 * @common: embedded struct dma_device 50 * @common: embedded struct dma_device
49 * @version: version of ioatdma device 51 * @version: version of ioatdma device
52 * @irq_mode: which style irq to use
53 * @msix_entries: irq handlers
54 * @idx: per channel data
50 */ 55 */
51 56
52struct ioatdma_device { 57struct ioatdma_device {
@@ -63,23 +68,7 @@ struct ioatdma_device {
63 68
64/** 69/**
65 * struct ioat_dma_chan - internal representation of a DMA channel 70 * struct ioat_dma_chan - internal representation of a DMA channel
66 * @device:
67 * @reg_base:
68 * @sw_in_use:
69 * @completion:
70 * @completion_low:
71 * @completion_high:
72 * @completed_cookie: last cookie seen completed on cleanup
73 * @cookie: value of last cookie given to client
74 * @last_completion:
75 * @xfercap:
76 * @desc_lock:
77 * @free_desc:
78 * @used_desc:
79 * @resource:
80 * @device_node:
81 */ 71 */
82
83struct ioat_dma_chan { 72struct ioat_dma_chan {
84 73
85 void __iomem *reg_base; 74 void __iomem *reg_base;
@@ -95,6 +84,8 @@ struct ioat_dma_chan {
95 struct list_head used_desc; 84 struct list_head used_desc;
96 85
97 int pending; 86 int pending;
87 int dmacount;
88 int desccount;
98 89
99 struct ioatdma_device *device; 90 struct ioatdma_device *device;
100 struct dma_chan common; 91 struct dma_chan common;
@@ -134,12 +125,13 @@ struct ioat_desc_sw {
134struct ioatdma_device *ioat_dma_probe(struct pci_dev *pdev, 125struct ioatdma_device *ioat_dma_probe(struct pci_dev *pdev,
135 void __iomem *iobase); 126 void __iomem *iobase);
136void ioat_dma_remove(struct ioatdma_device *device); 127void ioat_dma_remove(struct ioatdma_device *device);
137struct dca_provider *ioat_dca_init(struct pci_dev *pdev, 128struct dca_provider *ioat_dca_init(struct pci_dev *pdev, void __iomem *iobase);
138 void __iomem *iobase); 129struct dca_provider *ioat2_dca_init(struct pci_dev *pdev, void __iomem *iobase);
139#else 130#else
140#define ioat_dma_probe(pdev, iobase) NULL 131#define ioat_dma_probe(pdev, iobase) NULL
141#define ioat_dma_remove(device) do { } while (0) 132#define ioat_dma_remove(device) do { } while (0)
142#define ioat_dca_init(pdev, iobase) NULL 133#define ioat_dca_init(pdev, iobase) NULL
134#define ioat2_dca_init(pdev, iobase) NULL
143#endif 135#endif
144 136
145#endif /* IOATDMA_H */ 137#endif /* IOATDMA_H */
diff --git a/drivers/dma/ioatdma_hw.h b/drivers/dma/ioatdma_hw.h
index 9e7434e1551f..dd470fa91d86 100644
--- a/drivers/dma/ioatdma_hw.h
+++ b/drivers/dma/ioatdma_hw.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright(c) 2004 - 2006 Intel Corporation. All rights reserved. 2 * Copyright(c) 2004 - 2007 Intel Corporation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free 5 * under the terms of the GNU General Public License as published by the Free
@@ -22,12 +22,19 @@
22#define _IOAT_HW_H_ 22#define _IOAT_HW_H_
23 23
24/* PCI Configuration Space Values */ 24/* PCI Configuration Space Values */
25#define IOAT_PCI_VID 0x8086 25#define IOAT_PCI_VID 0x8086
26#define IOAT_PCI_DID 0x1A38 26
27#define IOAT_PCI_RID 0x00 27/* CB device ID's */
28#define IOAT_PCI_SVID 0x8086 28#define IOAT_PCI_DID_5000 0x1A38
29#define IOAT_PCI_SID 0x8086 29#define IOAT_PCI_DID_CNB 0x360B
30#define IOAT_VER_1_2 0x12 /* Version 1.2 */ 30#define IOAT_PCI_DID_SCNB 0x65FF
31#define IOAT_PCI_DID_SNB 0x402F
32
33#define IOAT_PCI_RID 0x00
34#define IOAT_PCI_SVID 0x8086
35#define IOAT_PCI_SID 0x8086
36#define IOAT_VER_1_2 0x12 /* Version 1.2 */
37#define IOAT_VER_2_0 0x20 /* Version 2.0 */
31 38
32struct ioat_dma_descriptor { 39struct ioat_dma_descriptor {
33 uint32_t size; 40 uint32_t size;
@@ -47,6 +54,16 @@ struct ioat_dma_descriptor {
47#define IOAT_DMA_DESCRIPTOR_CTL_CP_STS 0x00000008 54#define IOAT_DMA_DESCRIPTOR_CTL_CP_STS 0x00000008
48#define IOAT_DMA_DESCRIPTOR_CTL_FRAME 0x00000010 55#define IOAT_DMA_DESCRIPTOR_CTL_FRAME 0x00000010
49#define IOAT_DMA_DESCRIPTOR_NUL 0x00000020 56#define IOAT_DMA_DESCRIPTOR_NUL 0x00000020
50#define IOAT_DMA_DESCRIPTOR_OPCODE 0xFF000000 57#define IOAT_DMA_DESCRIPTOR_CTL_SP_BRK 0x00000040
58#define IOAT_DMA_DESCRIPTOR_CTL_DP_BRK 0x00000080
59#define IOAT_DMA_DESCRIPTOR_CTL_BNDL 0x00000100
60#define IOAT_DMA_DESCRIPTOR_CTL_DCA 0x00000200
61#define IOAT_DMA_DESCRIPTOR_CTL_BUFHINT 0x00000400
62
63#define IOAT_DMA_DESCRIPTOR_CTL_OPCODE_CONTEXT 0xFF000000
64#define IOAT_DMA_DESCRIPTOR_CTL_OPCODE_DMA 0x00000000
65
66#define IOAT_DMA_DESCRIPTOR_CTL_CONTEXT_DCA 0x00000001
67#define IOAT_DMA_DESCRIPTOR_CTL_OPCODE_MASK 0xFF000000
51 68
52#endif 69#endif
diff --git a/drivers/dma/ioatdma_registers.h b/drivers/dma/ioatdma_registers.h
index baaab5ea146a..9832d7ebd931 100644
--- a/drivers/dma/ioatdma_registers.h
+++ b/drivers/dma/ioatdma_registers.h
@@ -42,26 +42,25 @@
42#define IOAT_INTRCTRL_MASTER_INT_EN 0x01 /* Master Interrupt Enable */ 42#define IOAT_INTRCTRL_MASTER_INT_EN 0x01 /* Master Interrupt Enable */
43#define IOAT_INTRCTRL_INT_STATUS 0x02 /* ATTNSTATUS -or- Channel Int */ 43#define IOAT_INTRCTRL_INT_STATUS 0x02 /* ATTNSTATUS -or- Channel Int */
44#define IOAT_INTRCTRL_INT 0x04 /* INT_STATUS -and- MASTER_INT_EN */ 44#define IOAT_INTRCTRL_INT 0x04 /* INT_STATUS -and- MASTER_INT_EN */
45#define IOAT_INTRCTRL_MSIX_VECTOR_CONTROL 0x08 /* Enable all MSI-X vectors */ 45#define IOAT_INTRCTRL_MSIX_VECTOR_CONTROL 0x08 /* Enable all MSI-X vectors */
46 46
47#define IOAT_ATTNSTATUS_OFFSET 0x04 /* Each bit is a channel */ 47#define IOAT_ATTNSTATUS_OFFSET 0x04 /* Each bit is a channel */
48 48
49#define IOAT_VER_OFFSET 0x08 /* 8-bit */ 49#define IOAT_VER_OFFSET 0x08 /* 8-bit */
50#define IOAT_VER_MAJOR_MASK 0xF0 50#define IOAT_VER_MAJOR_MASK 0xF0
51#define IOAT_VER_MINOR_MASK 0x0F 51#define IOAT_VER_MINOR_MASK 0x0F
52#define GET_IOAT_VER_MAJOR(x) ((x) & IOAT_VER_MAJOR_MASK) 52#define GET_IOAT_VER_MAJOR(x) (((x) & IOAT_VER_MAJOR_MASK) >> 4)
53#define GET_IOAT_VER_MINOR(x) ((x) & IOAT_VER_MINOR_MASK) 53#define GET_IOAT_VER_MINOR(x) ((x) & IOAT_VER_MINOR_MASK)
54 54
55#define IOAT_PERPORTOFFSET_OFFSET 0x0A /* 16-bit */ 55#define IOAT_PERPORTOFFSET_OFFSET 0x0A /* 16-bit */
56 56
57#define IOAT_INTRDELAY_OFFSET 0x0C /* 16-bit */ 57#define IOAT_INTRDELAY_OFFSET 0x0C /* 16-bit */
58#define IOAT_INTRDELAY_INT_DELAY_MASK 0x3FFF /* Interrupt Delay Time */ 58#define IOAT_INTRDELAY_INT_DELAY_MASK 0x3FFF /* Interrupt Delay Time */
59#define IOAT_INTRDELAY_COALESE_SUPPORT 0x8000 /* Interrupt Coalesing Supported */ 59#define IOAT_INTRDELAY_COALESE_SUPPORT 0x8000 /* Interrupt Coalescing Supported */
60 60
61#define IOAT_DEVICE_STATUS_OFFSET 0x0E /* 16-bit */ 61#define IOAT_DEVICE_STATUS_OFFSET 0x0E /* 16-bit */
62#define IOAT_DEVICE_STATUS_DEGRADED_MODE 0x0001 62#define IOAT_DEVICE_STATUS_DEGRADED_MODE 0x0001
63 63
64
65#define IOAT_CHANNEL_MMIO_SIZE 0x80 /* Each Channel MMIO space is this size */ 64#define IOAT_CHANNEL_MMIO_SIZE 0x80 /* Each Channel MMIO space is this size */
66 65
67/* DMA Channel Registers */ 66/* DMA Channel Registers */
@@ -74,25 +73,101 @@
74#define IOAT_CHANCTRL_ERR_COMPLETION_EN 0x0004 73#define IOAT_CHANCTRL_ERR_COMPLETION_EN 0x0004
75#define IOAT_CHANCTRL_INT_DISABLE 0x0001 74#define IOAT_CHANCTRL_INT_DISABLE 0x0001
76 75
77#define IOAT_DMA_COMP_OFFSET 0x02 /* 16-bit DMA channel compatability */ 76#define IOAT_DMA_COMP_OFFSET 0x02 /* 16-bit DMA channel compatibility */
78#define IOAT_DMA_COMP_V1 0x0001 /* Compatability with DMA version 1 */ 77#define IOAT_DMA_COMP_V1 0x0001 /* Compatibility with DMA version 1 */
79 78#define IOAT_DMA_COMP_V2 0x0002 /* Compatibility with DMA version 2 */
80#define IOAT_CHANSTS_OFFSET 0x04 /* 64-bit Channel Status Register */ 79
81#define IOAT_CHANSTS_OFFSET_LOW 0x04 80
82#define IOAT_CHANSTS_OFFSET_HIGH 0x08 81#define IOAT1_CHANSTS_OFFSET 0x04 /* 64-bit Channel Status Register */
83#define IOAT_CHANSTS_COMPLETED_DESCRIPTOR_ADDR 0xFFFFFFFFFFFFFFC0UL 82#define IOAT2_CHANSTS_OFFSET 0x08 /* 64-bit Channel Status Register */
83#define IOAT_CHANSTS_OFFSET(ver) ((ver) < IOAT_VER_2_0 \
84 ? IOAT1_CHANSTS_OFFSET : IOAT2_CHANSTS_OFFSET)
85#define IOAT1_CHANSTS_OFFSET_LOW 0x04
86#define IOAT2_CHANSTS_OFFSET_LOW 0x08
87#define IOAT_CHANSTS_OFFSET_LOW(ver) ((ver) < IOAT_VER_2_0 \
88 ? IOAT1_CHANSTS_OFFSET_LOW : IOAT2_CHANSTS_OFFSET_LOW)
89#define IOAT1_CHANSTS_OFFSET_HIGH 0x08
90#define IOAT2_CHANSTS_OFFSET_HIGH 0x0C
91#define IOAT_CHANSTS_OFFSET_HIGH(ver) ((ver) < IOAT_VER_2_0 \
92 ? IOAT1_CHANSTS_OFFSET_HIGH : IOAT2_CHANSTS_OFFSET_HIGH)
93#define IOAT_CHANSTS_COMPLETED_DESCRIPTOR_ADDR ~0x3F
84#define IOAT_CHANSTS_SOFT_ERR 0x0000000000000010 94#define IOAT_CHANSTS_SOFT_ERR 0x0000000000000010
95#define IOAT_CHANSTS_UNAFFILIATED_ERR 0x0000000000000008
85#define IOAT_CHANSTS_DMA_TRANSFER_STATUS 0x0000000000000007 96#define IOAT_CHANSTS_DMA_TRANSFER_STATUS 0x0000000000000007
86#define IOAT_CHANSTS_DMA_TRANSFER_STATUS_ACTIVE 0x0 97#define IOAT_CHANSTS_DMA_TRANSFER_STATUS_ACTIVE 0x0
87#define IOAT_CHANSTS_DMA_TRANSFER_STATUS_DONE 0x1 98#define IOAT_CHANSTS_DMA_TRANSFER_STATUS_DONE 0x1
88#define IOAT_CHANSTS_DMA_TRANSFER_STATUS_SUSPENDED 0x2 99#define IOAT_CHANSTS_DMA_TRANSFER_STATUS_SUSPENDED 0x2
89#define IOAT_CHANSTS_DMA_TRANSFER_STATUS_HALTED 0x3 100#define IOAT_CHANSTS_DMA_TRANSFER_STATUS_HALTED 0x3
90 101
91#define IOAT_CHAINADDR_OFFSET 0x0C /* 64-bit Descriptor Chain Address Register */
92#define IOAT_CHAINADDR_OFFSET_LOW 0x0C
93#define IOAT_CHAINADDR_OFFSET_HIGH 0x10
94 102
95#define IOAT_CHANCMD_OFFSET 0x14 /* 8-bit DMA Channel Command Register */ 103
104#define IOAT_CHAN_DMACOUNT_OFFSET 0x06 /* 16-bit DMA Count register */
105
106#define IOAT_DCACTRL_OFFSET 0x30 /* 32 bit Direct Cache Access Control Register */
107#define IOAT_DCACTRL_CMPL_WRITE_ENABLE 0x10000
108#define IOAT_DCACTRL_TARGET_CPU_MASK 0xFFFF /* APIC ID */
109
110/* CB DCA Memory Space Registers */
111#define IOAT_DCAOFFSET_OFFSET 0x14
112/* CB_BAR + IOAT_DCAOFFSET value */
113#define IOAT_DCA_VER_OFFSET 0x00
114#define IOAT_DCA_VER_MAJOR_MASK 0xF0
115#define IOAT_DCA_VER_MINOR_MASK 0x0F
116
117#define IOAT_DCA_COMP_OFFSET 0x02
118#define IOAT_DCA_COMP_V1 0x1
119
120#define IOAT_FSB_CAPABILITY_OFFSET 0x04
121#define IOAT_FSB_CAPABILITY_PREFETCH 0x1
122
123#define IOAT_PCI_CAPABILITY_OFFSET 0x06
124#define IOAT_PCI_CAPABILITY_MEMWR 0x1
125
126#define IOAT_FSB_CAP_ENABLE_OFFSET 0x08
127#define IOAT_FSB_CAP_ENABLE_PREFETCH 0x1
128
129#define IOAT_PCI_CAP_ENABLE_OFFSET 0x0A
130#define IOAT_PCI_CAP_ENABLE_MEMWR 0x1
131
132#define IOAT_APICID_TAG_MAP_OFFSET 0x0C
133#define IOAT_APICID_TAG_MAP_TAG0 0x0000000F
134#define IOAT_APICID_TAG_MAP_TAG0_SHIFT 0
135#define IOAT_APICID_TAG_MAP_TAG1 0x000000F0
136#define IOAT_APICID_TAG_MAP_TAG1_SHIFT 4
137#define IOAT_APICID_TAG_MAP_TAG2 0x00000F00
138#define IOAT_APICID_TAG_MAP_TAG2_SHIFT 8
139#define IOAT_APICID_TAG_MAP_TAG3 0x0000F000
140#define IOAT_APICID_TAG_MAP_TAG3_SHIFT 12
141#define IOAT_APICID_TAG_MAP_TAG4 0x000F0000
142#define IOAT_APICID_TAG_MAP_TAG4_SHIFT 16
143#define IOAT_APICID_TAG_CB2_VALID 0x8080808080
144
145#define IOAT_DCA_GREQID_OFFSET 0x10
146#define IOAT_DCA_GREQID_SIZE 0x04
147#define IOAT_DCA_GREQID_MASK 0xFFFF
148#define IOAT_DCA_GREQID_IGNOREFUN 0x10000000
149#define IOAT_DCA_GREQID_VALID 0x20000000
150#define IOAT_DCA_GREQID_LASTID 0x80000000
151
152
153
154#define IOAT1_CHAINADDR_OFFSET 0x0C /* 64-bit Descriptor Chain Address Register */
155#define IOAT2_CHAINADDR_OFFSET 0x10 /* 64-bit Descriptor Chain Address Register */
156#define IOAT_CHAINADDR_OFFSET(ver) ((ver) < IOAT_VER_2_0 \
157 ? IOAT1_CHAINADDR_OFFSET : IOAT2_CHAINADDR_OFFSET)
158#define IOAT1_CHAINADDR_OFFSET_LOW 0x0C
159#define IOAT2_CHAINADDR_OFFSET_LOW 0x10
160#define IOAT_CHAINADDR_OFFSET_LOW(ver) ((ver) < IOAT_VER_2_0 \
161 ? IOAT1_CHAINADDR_OFFSET_LOW : IOAT2_CHAINADDR_OFFSET_LOW)
162#define IOAT1_CHAINADDR_OFFSET_HIGH 0x10
163#define IOAT2_CHAINADDR_OFFSET_HIGH 0x14
164#define IOAT_CHAINADDR_OFFSET_HIGH(ver) ((ver) < IOAT_VER_2_0 \
165 ? IOAT1_CHAINADDR_OFFSET_HIGH : IOAT2_CHAINADDR_OFFSET_HIGH)
166
167#define IOAT1_CHANCMD_OFFSET 0x14 /* 8-bit DMA Channel Command Register */
168#define IOAT2_CHANCMD_OFFSET 0x04 /* 8-bit DMA Channel Command Register */
169#define IOAT_CHANCMD_OFFSET(ver) ((ver) < IOAT_VER_2_0 \
170 ? IOAT1_CHANCMD_OFFSET : IOAT2_CHANCMD_OFFSET)
96#define IOAT_CHANCMD_RESET 0x20 171#define IOAT_CHANCMD_RESET 0x20
97#define IOAT_CHANCMD_RESUME 0x10 172#define IOAT_CHANCMD_RESUME 0x10
98#define IOAT_CHANCMD_ABORT 0x08 173#define IOAT_CHANCMD_ABORT 0x08
@@ -124,6 +199,7 @@
124#define IOAT_CHANERR_COMPLETION_ADDR_ERR 0x1000 199#define IOAT_CHANERR_COMPLETION_ADDR_ERR 0x1000
125#define IOAT_CHANERR_INT_CONFIGURATION_ERR 0x2000 200#define IOAT_CHANERR_INT_CONFIGURATION_ERR 0x2000
126#define IOAT_CHANERR_SOFT_ERR 0x4000 201#define IOAT_CHANERR_SOFT_ERR 0x4000
202#define IOAT_CHANERR_UNAFFILIATED_ERR 0x8000
127 203
128#define IOAT_CHANERR_MASK_OFFSET 0x2C /* 32-bit Channel Error Register */ 204#define IOAT_CHANERR_MASK_OFFSET 0x2C /* 32-bit Channel Error Register */
129 205
diff --git a/drivers/edac/i5000_edac.c b/drivers/edac/i5000_edac.c
index 96f7e63e3996..a1f24c42d5ff 100644
--- a/drivers/edac/i5000_edac.c
+++ b/drivers/edac/i5000_edac.c
@@ -1462,7 +1462,7 @@ MODULE_DEVICE_TABLE(pci, i5000_pci_tbl);
1462 * 1462 *
1463 */ 1463 */
1464static struct pci_driver i5000_driver = { 1464static struct pci_driver i5000_driver = {
1465 .name = __stringify(KBUILD_BASENAME), 1465 .name = KBUILD_BASENAME,
1466 .probe = i5000_init_one, 1466 .probe = i5000_init_one,
1467 .remove = __devexit_p(i5000_remove_one), 1467 .remove = __devexit_p(i5000_remove_one),
1468 .id_table = i5000_pci_tbl, 1468 .id_table = i5000_pci_tbl,
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index 5596df65c8ed..624ff3e082f6 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -650,13 +650,14 @@ static void sbp2_login(struct work_struct *work)
650 if (sbp2_send_management_orb(lu, node_id, generation, 650 if (sbp2_send_management_orb(lu, node_id, generation,
651 SBP2_LOGIN_REQUEST, lu->lun, &response) < 0) { 651 SBP2_LOGIN_REQUEST, lu->lun, &response) < 0) {
652 if (lu->retries++ < 5) { 652 if (lu->retries++ < 5) {
653 queue_delayed_work(sbp2_wq, &lu->work, 653 if (queue_delayed_work(sbp2_wq, &lu->work,
654 DIV_ROUND_UP(HZ, 5)); 654 DIV_ROUND_UP(HZ, 5)))
655 kref_get(&lu->tgt->kref);
655 } else { 656 } else {
656 fw_error("failed to login to %s LUN %04x\n", 657 fw_error("failed to login to %s LUN %04x\n",
657 unit->device.bus_id, lu->lun); 658 unit->device.bus_id, lu->lun);
658 kref_put(&lu->tgt->kref, sbp2_release_target);
659 } 659 }
660 kref_put(&lu->tgt->kref, sbp2_release_target);
660 return; 661 return;
661 } 662 }
662 663
@@ -914,7 +915,9 @@ static void sbp2_reconnect(struct work_struct *work)
914 lu->retries = 0; 915 lu->retries = 0;
915 PREPARE_DELAYED_WORK(&lu->work, sbp2_login); 916 PREPARE_DELAYED_WORK(&lu->work, sbp2_login);
916 } 917 }
917 queue_delayed_work(sbp2_wq, &lu->work, DIV_ROUND_UP(HZ, 5)); 918 if (queue_delayed_work(sbp2_wq, &lu->work, DIV_ROUND_UP(HZ, 5)))
919 kref_get(&lu->tgt->kref);
920 kref_put(&lu->tgt->kref, sbp2_release_target);
918 return; 921 return;
919 } 922 }
920 923
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 700a1657554f..a0445bea9f75 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -216,6 +216,16 @@ config SENSORS_DS1621
216 This driver can also be built as a module. If so, the module 216 This driver can also be built as a module. If so, the module
217 will be called ds1621. 217 will be called ds1621.
218 218
219config SENSORS_I5K_AMB
220 tristate "FB-DIMM AMB temperature sensor on Intel 5000 series chipsets"
221 depends on PCI && EXPERIMENTAL
222 help
223 If you say yes here you get support for FB-DIMM AMB temperature
224 monitoring chips on systems with the Intel 5000 series chipset.
225
226 This driver can also be built as a module. If so, the module
227 will be called i5k_amb.
228
219config SENSORS_F71805F 229config SENSORS_F71805F
220 tristate "Fintek F71805F/FG, F71806F/FG and F71872F/FG" 230 tristate "Fintek F71805F/FG, F71806F/FG and F71872F/FG"
221 depends on EXPERIMENTAL 231 depends on EXPERIMENTAL
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 6da3eef94306..55595f6e1aa6 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_SENSORS_FSCPOS) += fscpos.o
38obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o 38obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o
39obj-$(CONFIG_SENSORS_GL520SM) += gl520sm.o 39obj-$(CONFIG_SENSORS_GL520SM) += gl520sm.o
40obj-$(CONFIG_SENSORS_HDAPS) += hdaps.o 40obj-$(CONFIG_SENSORS_HDAPS) += hdaps.o
41obj-$(CONFIG_SENSORS_I5K_AMB) += i5k_amb.o
41obj-$(CONFIG_SENSORS_IBMPEX) += ibmpex.o 42obj-$(CONFIG_SENSORS_IBMPEX) += ibmpex.o
42obj-$(CONFIG_SENSORS_IT87) += it87.o 43obj-$(CONFIG_SENSORS_IT87) += it87.o
43obj-$(CONFIG_SENSORS_K8TEMP) += k8temp.o 44obj-$(CONFIG_SENSORS_K8TEMP) += k8temp.o
diff --git a/drivers/hwmon/abituguru3.c b/drivers/hwmon/abituguru3.c
index cb2331bfd9d5..d9f04ce90327 100644
--- a/drivers/hwmon/abituguru3.c
+++ b/drivers/hwmon/abituguru3.c
@@ -503,7 +503,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = {
503 { "AUX3 FAN", 36, 2, 60, 1, 0 }, 503 { "AUX3 FAN", 36, 2, 60, 1, 0 },
504 { NULL, 0, 0, 0, 0, 0 } } 504 { NULL, 0, 0, 0, 0, 0 } }
505 }, 505 },
506 { 0x001A, "unknown", { 506 { 0x001A, "Abit IP35 Pro", {
507 { "CPU Core", 0, 0, 10, 1, 0 }, 507 { "CPU Core", 0, 0, 10, 1, 0 },
508 { "DDR2", 1, 0, 20, 1, 0 }, 508 { "DDR2", 1, 0, 20, 1, 0 },
509 { "DDR2 VTT", 2, 0, 10, 1, 0 }, 509 { "DDR2 VTT", 2, 0, 10, 1, 0 },
@@ -530,6 +530,60 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = {
530 { "AUX3 Fan", 36, 2, 60, 1, 0 }, 530 { "AUX3 Fan", 36, 2, 60, 1, 0 },
531 { NULL, 0, 0, 0, 0, 0 } } 531 { NULL, 0, 0, 0, 0, 0 } }
532 }, 532 },
533 { 0x001B, "unknown", {
534 { "CPU Core", 0, 0, 10, 1, 0 },
535 { "DDR3", 1, 0, 20, 1, 0 },
536 { "DDR3 VTT", 2, 0, 10, 1, 0 },
537 { "CPU VTT", 3, 0, 10, 1, 0 },
538 { "MCH 1.25V", 4, 0, 10, 1, 0 },
539 { "ICHIO 1.5V", 5, 0, 10, 1, 0 },
540 { "ICH 1.05V", 6, 0, 10, 1, 0 },
541 { "ATX +12V (24-Pin)", 7, 0, 60, 1, 0 },
542 { "ATX +12V (8-pin)", 8, 0, 60, 1, 0 },
543 { "ATX +5V", 9, 0, 30, 1, 0 },
544 { "+3.3V", 10, 0, 20, 1, 0 },
545 { "5VSB", 11, 0, 30, 1, 0 },
546 { "CPU", 24, 1, 1, 1, 0 },
547 { "System", 25, 1, 1, 1, 0 },
548 { "PWM Phase1", 26, 1, 1, 1, 0 },
549 { "PWM Phase2", 27, 1, 1, 1, 0 },
550 { "PWM Phase3", 28, 1, 1, 1, 0 },
551 { "PWM Phase4", 29, 1, 1, 1, 0 },
552 { "PWM Phase5", 30, 1, 1, 1, 0 },
553 { "CPU Fan", 32, 2, 60, 1, 0 },
554 { "SYS Fan", 34, 2, 60, 1, 0 },
555 { "AUX1 Fan", 33, 2, 60, 1, 0 },
556 { "AUX2 Fan", 35, 2, 60, 1, 0 },
557 { "AUX3 Fan", 36, 2, 60, 1, 0 },
558 { NULL, 0, 0, 0, 0, 0 } }
559 },
560 { 0x001C, "unknown", {
561 { "CPU Core", 0, 0, 10, 1, 0 },
562 { "DDR2", 1, 0, 20, 1, 0 },
563 { "DDR2 VTT", 2, 0, 10, 1, 0 },
564 { "CPU VTT", 3, 0, 10, 1, 0 },
565 { "MCH 1.25V", 4, 0, 10, 1, 0 },
566 { "ICHIO 1.5V", 5, 0, 10, 1, 0 },
567 { "ICH 1.05V", 6, 0, 10, 1, 0 },
568 { "ATX +12V (24-Pin)", 7, 0, 60, 1, 0 },
569 { "ATX +12V (8-pin)", 8, 0, 60, 1, 0 },
570 { "ATX +5V", 9, 0, 30, 1, 0 },
571 { "+3.3V", 10, 0, 20, 1, 0 },
572 { "5VSB", 11, 0, 30, 1, 0 },
573 { "CPU", 24, 1, 1, 1, 0 },
574 { "System", 25, 1, 1, 1, 0 },
575 { "PWM Phase1", 26, 1, 1, 1, 0 },
576 { "PWM Phase2", 27, 1, 1, 1, 0 },
577 { "PWM Phase3", 28, 1, 1, 1, 0 },
578 { "PWM Phase4", 29, 1, 1, 1, 0 },
579 { "PWM Phase5", 30, 1, 1, 1, 0 },
580 { "CPU Fan", 32, 2, 60, 1, 0 },
581 { "SYS Fan", 34, 2, 60, 1, 0 },
582 { "AUX1 Fan", 33, 2, 60, 1, 0 },
583 { "AUX2 Fan", 35, 2, 60, 1, 0 },
584 { "AUX3 Fan", 36, 2, 60, 1, 0 },
585 { NULL, 0, 0, 0, 0, 0 } }
586 },
533 { 0x0000, NULL, { { NULL, 0, 0, 0, 0, 0 } } } 587 { 0x0000, NULL, { { NULL, 0, 0, 0, 0, 0 } } }
534}; 588};
535 589
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 1001d2e122a2..86c66c345f8b 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -80,7 +80,7 @@
80/* 80/*
81 * Temperature sensors keys (sp78 - 2 bytes). 81 * Temperature sensors keys (sp78 - 2 bytes).
82 */ 82 */
83static const char* temperature_sensors_sets[][13] = { 83static const char* temperature_sensors_sets[][36] = {
84/* Set 0: Macbook Pro */ 84/* Set 0: Macbook Pro */
85 { "TA0P", "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "Th0H", 85 { "TA0P", "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "Th0H",
86 "Th1H", "Tm0P", "Ts0P", "Ts1P", NULL }, 86 "Th1H", "Tm0P", "Ts0P", "Ts1P", NULL },
@@ -88,7 +88,13 @@ static const char* temperature_sensors_sets[][13] = {
88 { "TB0T", "TC0D", "TC0P", "TM0P", "TN0P", "TN1P", "Th0H", "Th0S", 88 { "TB0T", "TC0D", "TC0P", "TM0P", "TN0P", "TN1P", "Th0H", "Th0S",
89 "Th1H", "Ts0P", NULL }, 89 "Th1H", "Ts0P", NULL },
90/* Set 2: Macmini set */ 90/* Set 2: Macmini set */
91 { "TC0D", "TC0P", NULL } 91 { "TC0D", "TC0P", NULL },
92/* Set 3: Mac Pro (2 x Quad-Core) */
93 { "TA0P", "TCAG", "TCAH", "TCBG", "TCBH", "TC0C", "TC0D", "TC0P",
94 "TC1C", "TC1D", "TC2C", "TC2D", "TC3C", "TC3D", "THTG", "TH0P",
95 "TH1P", "TH2P", "TH3P", "TMAP", "TMAS", "TMBS", "TM0P", "TM0S",
96 "TM1P", "TM1S", "TM2P", "TM2S", "TM3S", "TM8P", "TM8S", "TM9P",
97 "TM9S", "TN0H", "TS0C", NULL },
92}; 98};
93 99
94/* List of keys used to read/write fan speeds */ 100/* List of keys used to read/write fan speeds */
@@ -990,14 +996,18 @@ static struct attribute *fan##offset##_attributes[] = { \
990 996
991/* 997/*
992 * Create the needed functions for each fan using the macro defined above 998 * Create the needed functions for each fan using the macro defined above
993 * (2 fans are supported) 999 * (4 fans are supported)
994 */ 1000 */
995sysfs_fan_speeds_offset(1); 1001sysfs_fan_speeds_offset(1);
996sysfs_fan_speeds_offset(2); 1002sysfs_fan_speeds_offset(2);
1003sysfs_fan_speeds_offset(3);
1004sysfs_fan_speeds_offset(4);
997 1005
998static const struct attribute_group fan_attribute_groups[] = { 1006static const struct attribute_group fan_attribute_groups[] = {
999 { .attrs = fan1_attributes }, 1007 { .attrs = fan1_attributes },
1000 { .attrs = fan2_attributes } 1008 { .attrs = fan2_attributes },
1009 { .attrs = fan3_attributes },
1010 { .attrs = fan4_attributes },
1001}; 1011};
1002 1012
1003/* 1013/*
@@ -1027,6 +1037,52 @@ static SENSOR_DEVICE_ATTR(temp11_input, S_IRUGO,
1027 applesmc_show_temperature, NULL, 10); 1037 applesmc_show_temperature, NULL, 10);
1028static SENSOR_DEVICE_ATTR(temp12_input, S_IRUGO, 1038static SENSOR_DEVICE_ATTR(temp12_input, S_IRUGO,
1029 applesmc_show_temperature, NULL, 11); 1039 applesmc_show_temperature, NULL, 11);
1040static SENSOR_DEVICE_ATTR(temp13_input, S_IRUGO,
1041 applesmc_show_temperature, NULL, 12);
1042static SENSOR_DEVICE_ATTR(temp14_input, S_IRUGO,
1043 applesmc_show_temperature, NULL, 13);
1044static SENSOR_DEVICE_ATTR(temp15_input, S_IRUGO,
1045 applesmc_show_temperature, NULL, 14);
1046static SENSOR_DEVICE_ATTR(temp16_input, S_IRUGO,
1047 applesmc_show_temperature, NULL, 15);
1048static SENSOR_DEVICE_ATTR(temp17_input, S_IRUGO,
1049 applesmc_show_temperature, NULL, 16);
1050static SENSOR_DEVICE_ATTR(temp18_input, S_IRUGO,
1051 applesmc_show_temperature, NULL, 17);
1052static SENSOR_DEVICE_ATTR(temp19_input, S_IRUGO,
1053 applesmc_show_temperature, NULL, 18);
1054static SENSOR_DEVICE_ATTR(temp20_input, S_IRUGO,
1055 applesmc_show_temperature, NULL, 19);
1056static SENSOR_DEVICE_ATTR(temp21_input, S_IRUGO,
1057 applesmc_show_temperature, NULL, 20);
1058static SENSOR_DEVICE_ATTR(temp22_input, S_IRUGO,
1059 applesmc_show_temperature, NULL, 21);
1060static SENSOR_DEVICE_ATTR(temp23_input, S_IRUGO,
1061 applesmc_show_temperature, NULL, 22);
1062static SENSOR_DEVICE_ATTR(temp24_input, S_IRUGO,
1063 applesmc_show_temperature, NULL, 23);
1064static SENSOR_DEVICE_ATTR(temp25_input, S_IRUGO,
1065 applesmc_show_temperature, NULL, 24);
1066static SENSOR_DEVICE_ATTR(temp26_input, S_IRUGO,
1067 applesmc_show_temperature, NULL, 25);
1068static SENSOR_DEVICE_ATTR(temp27_input, S_IRUGO,
1069 applesmc_show_temperature, NULL, 26);
1070static SENSOR_DEVICE_ATTR(temp28_input, S_IRUGO,
1071 applesmc_show_temperature, NULL, 27);
1072static SENSOR_DEVICE_ATTR(temp29_input, S_IRUGO,
1073 applesmc_show_temperature, NULL, 28);
1074static SENSOR_DEVICE_ATTR(temp30_input, S_IRUGO,
1075 applesmc_show_temperature, NULL, 29);
1076static SENSOR_DEVICE_ATTR(temp31_input, S_IRUGO,
1077 applesmc_show_temperature, NULL, 30);
1078static SENSOR_DEVICE_ATTR(temp32_input, S_IRUGO,
1079 applesmc_show_temperature, NULL, 31);
1080static SENSOR_DEVICE_ATTR(temp33_input, S_IRUGO,
1081 applesmc_show_temperature, NULL, 32);
1082static SENSOR_DEVICE_ATTR(temp34_input, S_IRUGO,
1083 applesmc_show_temperature, NULL, 33);
1084static SENSOR_DEVICE_ATTR(temp35_input, S_IRUGO,
1085 applesmc_show_temperature, NULL, 34);
1030 1086
1031static struct attribute *temperature_attributes[] = { 1087static struct attribute *temperature_attributes[] = {
1032 &sensor_dev_attr_temp1_input.dev_attr.attr, 1088 &sensor_dev_attr_temp1_input.dev_attr.attr,
@@ -1041,6 +1097,29 @@ static struct attribute *temperature_attributes[] = {
1041 &sensor_dev_attr_temp10_input.dev_attr.attr, 1097 &sensor_dev_attr_temp10_input.dev_attr.attr,
1042 &sensor_dev_attr_temp11_input.dev_attr.attr, 1098 &sensor_dev_attr_temp11_input.dev_attr.attr,
1043 &sensor_dev_attr_temp12_input.dev_attr.attr, 1099 &sensor_dev_attr_temp12_input.dev_attr.attr,
1100 &sensor_dev_attr_temp13_input.dev_attr.attr,
1101 &sensor_dev_attr_temp14_input.dev_attr.attr,
1102 &sensor_dev_attr_temp15_input.dev_attr.attr,
1103 &sensor_dev_attr_temp16_input.dev_attr.attr,
1104 &sensor_dev_attr_temp17_input.dev_attr.attr,
1105 &sensor_dev_attr_temp18_input.dev_attr.attr,
1106 &sensor_dev_attr_temp19_input.dev_attr.attr,
1107 &sensor_dev_attr_temp20_input.dev_attr.attr,
1108 &sensor_dev_attr_temp21_input.dev_attr.attr,
1109 &sensor_dev_attr_temp22_input.dev_attr.attr,
1110 &sensor_dev_attr_temp23_input.dev_attr.attr,
1111 &sensor_dev_attr_temp24_input.dev_attr.attr,
1112 &sensor_dev_attr_temp25_input.dev_attr.attr,
1113 &sensor_dev_attr_temp26_input.dev_attr.attr,
1114 &sensor_dev_attr_temp27_input.dev_attr.attr,
1115 &sensor_dev_attr_temp28_input.dev_attr.attr,
1116 &sensor_dev_attr_temp29_input.dev_attr.attr,
1117 &sensor_dev_attr_temp30_input.dev_attr.attr,
1118 &sensor_dev_attr_temp31_input.dev_attr.attr,
1119 &sensor_dev_attr_temp32_input.dev_attr.attr,
1120 &sensor_dev_attr_temp33_input.dev_attr.attr,
1121 &sensor_dev_attr_temp34_input.dev_attr.attr,
1122 &sensor_dev_attr_temp35_input.dev_attr.attr,
1044 NULL 1123 NULL
1045}; 1124};
1046 1125
@@ -1137,6 +1216,8 @@ static __initdata struct dmi_match_data applesmc_dmi_data[] = {
1137 { .accelerometer = 1, .light = 0, .temperature_set = 1 }, 1216 { .accelerometer = 1, .light = 0, .temperature_set = 1 },
1138/* MacMini: temperature set 2 */ 1217/* MacMini: temperature set 2 */
1139 { .accelerometer = 0, .light = 0, .temperature_set = 2 }, 1218 { .accelerometer = 0, .light = 0, .temperature_set = 2 },
1219/* MacPro: temperature set 3 */
1220 { .accelerometer = 0, .light = 0, .temperature_set = 3 },
1140}; 1221};
1141 1222
1142/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1". 1223/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1".
@@ -1154,6 +1235,10 @@ static __initdata struct dmi_system_id applesmc_whitelist[] = {
1154 DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), 1235 DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
1155 DMI_MATCH(DMI_PRODUCT_NAME,"Macmini") }, 1236 DMI_MATCH(DMI_PRODUCT_NAME,"Macmini") },
1156 (void*)&applesmc_dmi_data[2]}, 1237 (void*)&applesmc_dmi_data[2]},
1238 { applesmc_dmi_match, "Apple MacPro2", {
1239 DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
1240 DMI_MATCH(DMI_PRODUCT_NAME,"MacPro2") },
1241 (void*)&applesmc_dmi_data[3]},
1157 { .ident = NULL } 1242 { .ident = NULL }
1158}; 1243};
1159 1244
@@ -1204,9 +1289,19 @@ static int __init applesmc_init(void)
1204 1289
1205 switch (count) { 1290 switch (count) {
1206 default: 1291 default:
1207 printk(KERN_WARNING "applesmc: More than 2 fans found," 1292 printk(KERN_WARNING "applesmc: More than 4 fans found,"
1208 " but at most 2 fans are supported" 1293 " but at most 4 fans are supported"
1209 " by the driver.\n"); 1294 " by the driver.\n");
1295 case 4:
1296 ret = sysfs_create_group(&pdev->dev.kobj,
1297 &fan_attribute_groups[3]);
1298 if (ret)
1299 goto out_key_enumeration;
1300 case 3:
1301 ret = sysfs_create_group(&pdev->dev.kobj,
1302 &fan_attribute_groups[2]);
1303 if (ret)
1304 goto out_key_enumeration;
1210 case 2: 1305 case 2:
1211 ret = sysfs_create_group(&pdev->dev.kobj, 1306 ret = sysfs_create_group(&pdev->dev.kobj,
1212 &fan_attribute_groups[1]); 1307 &fan_attribute_groups[1]);
diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c
index 13a041326a04..6892f76fc18a 100644
--- a/drivers/hwmon/f75375s.c
+++ b/drivers/hwmon/f75375s.c
@@ -34,6 +34,7 @@
34#include <linux/i2c.h> 34#include <linux/i2c.h>
35#include <linux/err.h> 35#include <linux/err.h>
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37#include <linux/f75375s.h>
37 38
38/* Addresses to scan */ 39/* Addresses to scan */
39static unsigned short normal_i2c[] = { 0x2d, 0x2e, I2C_CLIENT_END }; 40static unsigned short normal_i2c[] = { 0x2d, 0x2e, I2C_CLIENT_END };
@@ -86,7 +87,7 @@ I2C_CLIENT_INSMOD_2(f75373, f75375);
86 87
87struct f75375_data { 88struct f75375_data {
88 unsigned short addr; 89 unsigned short addr;
89 struct i2c_client client; 90 struct i2c_client *client;
90 struct device *hwmon_dev; 91 struct device *hwmon_dev;
91 92
92 const char *name; 93 const char *name;
@@ -116,15 +117,25 @@ struct f75375_data {
116static int f75375_attach_adapter(struct i2c_adapter *adapter); 117static int f75375_attach_adapter(struct i2c_adapter *adapter);
117static int f75375_detect(struct i2c_adapter *adapter, int address, int kind); 118static int f75375_detect(struct i2c_adapter *adapter, int address, int kind);
118static int f75375_detach_client(struct i2c_client *client); 119static int f75375_detach_client(struct i2c_client *client);
120static int f75375_probe(struct i2c_client *client);
121static int f75375_remove(struct i2c_client *client);
119 122
120static struct i2c_driver f75375_driver = { 123static struct i2c_driver f75375_legacy_driver = {
121 .driver = { 124 .driver = {
122 .name = "f75375", 125 .name = "f75375_legacy",
123 }, 126 },
124 .attach_adapter = f75375_attach_adapter, 127 .attach_adapter = f75375_attach_adapter,
125 .detach_client = f75375_detach_client, 128 .detach_client = f75375_detach_client,
126}; 129};
127 130
131static struct i2c_driver f75375_driver = {
132 .driver = {
133 .name = "f75375",
134 },
135 .probe = f75375_probe,
136 .remove = f75375_remove,
137};
138
128static inline int f75375_read8(struct i2c_client *client, u8 reg) 139static inline int f75375_read8(struct i2c_client *client, u8 reg)
129{ 140{
130 return i2c_smbus_read_byte_data(client, reg); 141 return i2c_smbus_read_byte_data(client, reg);
@@ -276,19 +287,14 @@ static ssize_t show_pwm_enable(struct device *dev, struct device_attribute
276 return sprintf(buf, "%d\n", data->pwm_enable[nr]); 287 return sprintf(buf, "%d\n", data->pwm_enable[nr]);
277} 288}
278 289
279static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, 290static int set_pwm_enable_direct(struct i2c_client *client, int nr, int val)
280 const char *buf, size_t count)
281{ 291{
282 int nr = to_sensor_dev_attr(attr)->index;
283 struct i2c_client *client = to_i2c_client(dev);
284 struct f75375_data *data = i2c_get_clientdata(client); 292 struct f75375_data *data = i2c_get_clientdata(client);
285 int val = simple_strtoul(buf, NULL, 10);
286 u8 fanmode; 293 u8 fanmode;
287 294
288 if (val < 0 || val > 4) 295 if (val < 0 || val > 4)
289 return -EINVAL; 296 return -EINVAL;
290 297
291 mutex_lock(&data->update_lock);
292 fanmode = f75375_read8(client, F75375_REG_FAN_TIMER); 298 fanmode = f75375_read8(client, F75375_REG_FAN_TIMER);
293 fanmode = ~(3 << FAN_CTRL_MODE(nr)); 299 fanmode = ~(3 << FAN_CTRL_MODE(nr));
294 300
@@ -310,8 +316,22 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr,
310 } 316 }
311 f75375_write8(client, F75375_REG_FAN_TIMER, fanmode); 317 f75375_write8(client, F75375_REG_FAN_TIMER, fanmode);
312 data->pwm_enable[nr] = val; 318 data->pwm_enable[nr] = val;
319 return 0;
320}
321
322static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr,
323 const char *buf, size_t count)
324{
325 int nr = to_sensor_dev_attr(attr)->index;
326 struct i2c_client *client = to_i2c_client(dev);
327 struct f75375_data *data = i2c_get_clientdata(client);
328 int val = simple_strtoul(buf, NULL, 10);
329 int err = 0;
330
331 mutex_lock(&data->update_lock);
332 err = set_pwm_enable_direct(client, nr, val);
313 mutex_unlock(&data->update_lock); 333 mutex_unlock(&data->update_lock);
314 return count; 334 return err ? err : count;
315} 335}
316 336
317static ssize_t set_pwm_mode(struct device *dev, struct device_attribute *attr, 337static ssize_t set_pwm_mode(struct device *dev, struct device_attribute *attr,
@@ -323,7 +343,7 @@ static ssize_t set_pwm_mode(struct device *dev, struct device_attribute *attr,
323 int val = simple_strtoul(buf, NULL, 10); 343 int val = simple_strtoul(buf, NULL, 10);
324 u8 conf = 0; 344 u8 conf = 0;
325 345
326 if (val != 0 || val != 1 || data->kind == f75373) 346 if (!(val == 0 || val == 1))
327 return -EINVAL; 347 return -EINVAL;
328 348
329 mutex_lock(&data->update_lock); 349 mutex_lock(&data->update_lock);
@@ -529,13 +549,13 @@ static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO|S_IWUSR,
529 show_pwm, set_pwm, 0); 549 show_pwm, set_pwm, 0);
530static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO|S_IWUSR, 550static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO|S_IWUSR,
531 show_pwm_enable, set_pwm_enable, 0); 551 show_pwm_enable, set_pwm_enable, 0);
532static SENSOR_DEVICE_ATTR(pwm1_mode, S_IRUGO|S_IWUSR, 552static SENSOR_DEVICE_ATTR(pwm1_mode, S_IRUGO,
533 show_pwm_mode, set_pwm_mode, 0); 553 show_pwm_mode, set_pwm_mode, 0);
534static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, 554static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR,
535 show_pwm, set_pwm, 1); 555 show_pwm, set_pwm, 1);
536static SENSOR_DEVICE_ATTR(pwm2_enable, S_IRUGO|S_IWUSR, 556static SENSOR_DEVICE_ATTR(pwm2_enable, S_IRUGO|S_IWUSR,
537 show_pwm_enable, set_pwm_enable, 1); 557 show_pwm_enable, set_pwm_enable, 1);
538static SENSOR_DEVICE_ATTR(pwm2_mode, S_IRUGO|S_IWUSR, 558static SENSOR_DEVICE_ATTR(pwm2_mode, S_IRUGO,
539 show_pwm_mode, set_pwm_mode, 1); 559 show_pwm_mode, set_pwm_mode, 1);
540 560
541static struct attribute *f75375_attributes[] = { 561static struct attribute *f75375_attributes[] = {
@@ -580,12 +600,9 @@ static const struct attribute_group f75375_group = {
580 600
581static int f75375_detach_client(struct i2c_client *client) 601static int f75375_detach_client(struct i2c_client *client)
582{ 602{
583 struct f75375_data *data = i2c_get_clientdata(client);
584 int err; 603 int err;
585 604
586 hwmon_device_unregister(data->hwmon_dev); 605 f75375_remove(client);
587 sysfs_remove_group(&client->dev.kobj, &f75375_group);
588
589 err = i2c_detach_client(client); 606 err = i2c_detach_client(client);
590 if (err) { 607 if (err) {
591 dev_err(&client->dev, 608 dev_err(&client->dev,
@@ -593,7 +610,91 @@ static int f75375_detach_client(struct i2c_client *client)
593 "client not detached.\n"); 610 "client not detached.\n");
594 return err; 611 return err;
595 } 612 }
613 kfree(client);
614 return 0;
615}
616
617static void f75375_init(struct i2c_client *client, struct f75375_data *data,
618 struct f75375s_platform_data *f75375s_pdata)
619{
620 int nr;
621 set_pwm_enable_direct(client, 0, f75375s_pdata->pwm_enable[0]);
622 set_pwm_enable_direct(client, 1, f75375s_pdata->pwm_enable[1]);
623 for (nr = 0; nr < 2; nr++) {
624 data->pwm[nr] = SENSORS_LIMIT(f75375s_pdata->pwm[nr], 0, 255);
625 f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr),
626 data->pwm[nr]);
627 }
628
629}
630
631static int f75375_probe(struct i2c_client *client)
632{
633 struct f75375_data *data = i2c_get_clientdata(client);
634 struct f75375s_platform_data *f75375s_pdata = client->dev.platform_data;
635 int err;
636
637 if (!i2c_check_functionality(client->adapter,
638 I2C_FUNC_SMBUS_BYTE_DATA))
639 return -EIO;
640 if (!(data = kzalloc(sizeof(struct f75375_data), GFP_KERNEL)))
641 return -ENOMEM;
642
643 i2c_set_clientdata(client, data);
644 data->client = client;
645 mutex_init(&data->update_lock);
646
647 if (strcmp(client->name, "f75375") == 0)
648 data->kind = f75375;
649 else if (strcmp(client->name, "f75373") == 0)
650 data->kind = f75373;
651 else {
652 dev_err(&client->dev, "Unsupported device: %s\n", client->name);
653 return -ENODEV;
654 }
655
656 if ((err = sysfs_create_group(&client->dev.kobj, &f75375_group)))
657 goto exit_free;
658
659 if (data->kind == f75375) {
660 err = sysfs_chmod_file(&client->dev.kobj,
661 &sensor_dev_attr_pwm1_mode.dev_attr.attr,
662 S_IRUGO | S_IWUSR);
663 if (err)
664 goto exit_remove;
665 err = sysfs_chmod_file(&client->dev.kobj,
666 &sensor_dev_attr_pwm2_mode.dev_attr.attr,
667 S_IRUGO | S_IWUSR);
668 if (err)
669 goto exit_remove;
670 }
671
672 data->hwmon_dev = hwmon_device_register(&client->dev);
673 if (IS_ERR(data->hwmon_dev)) {
674 err = PTR_ERR(data->hwmon_dev);
675 goto exit_remove;
676 }
677
678 if (f75375s_pdata != NULL)
679 f75375_init(client, data, f75375s_pdata);
680
681 return 0;
682
683exit_remove:
684 sysfs_remove_group(&client->dev.kobj, &f75375_group);
685exit_free:
596 kfree(data); 686 kfree(data);
687 i2c_set_clientdata(client, NULL);
688 return err;
689}
690
691static int f75375_remove(struct i2c_client *client)
692{
693 struct f75375_data *data = i2c_get_clientdata(client);
694 hwmon_device_unregister(data->hwmon_dev);
695 sysfs_remove_group(&client->dev.kobj, &f75375_group);
696 kfree(data);
697 i2c_set_clientdata(client, NULL);
597 return 0; 698 return 0;
598} 699}
599 700
@@ -608,20 +709,17 @@ static int f75375_attach_adapter(struct i2c_adapter *adapter)
608static int f75375_detect(struct i2c_adapter *adapter, int address, int kind) 709static int f75375_detect(struct i2c_adapter *adapter, int address, int kind)
609{ 710{
610 struct i2c_client *client; 711 struct i2c_client *client;
611 struct f75375_data *data;
612 u8 version = 0; 712 u8 version = 0;
613 int err = 0; 713 int err = 0;
614 const char *name = ""; 714 const char *name = "";
615 715
616 if (!(data = kzalloc(sizeof(struct f75375_data), GFP_KERNEL))) { 716 if (!(client = kzalloc(sizeof(*client), GFP_KERNEL))) {
617 err = -ENOMEM; 717 err = -ENOMEM;
618 goto exit; 718 goto exit;
619 } 719 }
620 client = &data->client;
621 i2c_set_clientdata(client, data);
622 client->addr = address; 720 client->addr = address;
623 client->adapter = adapter; 721 client->adapter = adapter;
624 client->driver = &f75375_driver; 722 client->driver = &f75375_legacy_driver;
625 723
626 if (kind < 0) { 724 if (kind < 0) {
627 u16 vendid = f75375_read16(client, F75375_REG_VENDOR); 725 u16 vendid = f75375_read16(client, F75375_REG_VENDOR);
@@ -644,42 +742,42 @@ static int f75375_detect(struct i2c_adapter *adapter, int address, int kind)
644 } else if (kind == f75373) { 742 } else if (kind == f75373) {
645 name = "f75373"; 743 name = "f75373";
646 } 744 }
647
648 dev_info(&adapter->dev, "found %s version: %02X\n", name, version); 745 dev_info(&adapter->dev, "found %s version: %02X\n", name, version);
649 strlcpy(client->name, name, I2C_NAME_SIZE); 746 strlcpy(client->name, name, I2C_NAME_SIZE);
650 data->kind = kind; 747
651 mutex_init(&data->update_lock);
652 if ((err = i2c_attach_client(client))) 748 if ((err = i2c_attach_client(client)))
653 goto exit_free; 749 goto exit_free;
654 750
655 if ((err = sysfs_create_group(&client->dev.kobj, &f75375_group))) 751 if ((err = f75375_probe(client)) < 0)
656 goto exit_detach; 752 goto exit_detach;
657 753
658 data->hwmon_dev = hwmon_device_register(&client->dev);
659 if (IS_ERR(data->hwmon_dev)) {
660 err = PTR_ERR(data->hwmon_dev);
661 goto exit_remove;
662 }
663
664 return 0; 754 return 0;
665 755
666exit_remove:
667 sysfs_remove_group(&client->dev.kobj, &f75375_group);
668exit_detach: 756exit_detach:
669 i2c_detach_client(client); 757 i2c_detach_client(client);
670exit_free: 758exit_free:
671 kfree(data); 759 kfree(client);
672exit: 760exit:
673 return err; 761 return err;
674} 762}
675 763
676static int __init sensors_f75375_init(void) 764static int __init sensors_f75375_init(void)
677{ 765{
678 return i2c_add_driver(&f75375_driver); 766 int status;
767 status = i2c_add_driver(&f75375_driver);
768 if (status)
769 return status;
770
771 status = i2c_add_driver(&f75375_legacy_driver);
772 if (status)
773 i2c_del_driver(&f75375_driver);
774
775 return status;
679} 776}
680 777
681static void __exit sensors_f75375_exit(void) 778static void __exit sensors_f75375_exit(void)
682{ 779{
780 i2c_del_driver(&f75375_legacy_driver);
683 i2c_del_driver(&f75375_driver); 781 i2c_del_driver(&f75375_driver);
684} 782}
685 783
diff --git a/drivers/hwmon/i5k_amb.c b/drivers/hwmon/i5k_amb.c
new file mode 100644
index 000000000000..6ac5c6f53585
--- /dev/null
+++ b/drivers/hwmon/i5k_amb.c
@@ -0,0 +1,552 @@
1/*
2 * A hwmon driver for the Intel 5000 series chipset FB-DIMM AMB
3 * temperature sensors
4 * Copyright (C) 2007 IBM
5 *
6 * Author: Darrick J. Wong <djwong@us.ibm.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#include <linux/module.h>
24#include <linux/jiffies.h>
25#include <linux/hwmon.h>
26#include <linux/hwmon-sysfs.h>
27#include <linux/err.h>
28#include <linux/mutex.h>
29#include <linux/delay.h>
30#include <linux/log2.h>
31#include <linux/pci.h>
32#include <linux/platform_device.h>
33
34#define DRVNAME "i5k_amb"
35
36#define I5K_REG_AMB_BASE_ADDR 0x48
37#define I5K_REG_AMB_LEN_ADDR 0x50
38#define I5K_REG_CHAN0_PRESENCE_ADDR 0x64
39#define I5K_REG_CHAN1_PRESENCE_ADDR 0x66
40
41#define AMB_REG_TEMP_MIN_ADDR 0x80
42#define AMB_REG_TEMP_MID_ADDR 0x81
43#define AMB_REG_TEMP_MAX_ADDR 0x82
44#define AMB_REG_TEMP_STATUS_ADDR 0x84
45#define AMB_REG_TEMP_ADDR 0x85
46
47#define AMB_CONFIG_SIZE 2048
48#define AMB_FUNC_3_OFFSET 768
49
50static unsigned long amb_reg_temp_status(unsigned int amb)
51{
52 return AMB_FUNC_3_OFFSET + AMB_REG_TEMP_STATUS_ADDR +
53 AMB_CONFIG_SIZE * amb;
54}
55
56static unsigned long amb_reg_temp_min(unsigned int amb)
57{
58 return AMB_FUNC_3_OFFSET + AMB_REG_TEMP_MIN_ADDR +
59 AMB_CONFIG_SIZE * amb;
60}
61
62static unsigned long amb_reg_temp_mid(unsigned int amb)
63{
64 return AMB_FUNC_3_OFFSET + AMB_REG_TEMP_MID_ADDR +
65 AMB_CONFIG_SIZE * amb;
66}
67
68static unsigned long amb_reg_temp_max(unsigned int amb)
69{
70 return AMB_FUNC_3_OFFSET + AMB_REG_TEMP_MAX_ADDR +
71 AMB_CONFIG_SIZE * amb;
72}
73
74static unsigned long amb_reg_temp(unsigned int amb)
75{
76 return AMB_FUNC_3_OFFSET + AMB_REG_TEMP_ADDR +
77 AMB_CONFIG_SIZE * amb;
78}
79
80#define MAX_MEM_CHANNELS 4
81#define MAX_AMBS_PER_CHANNEL 16
82#define MAX_AMBS (MAX_MEM_CHANNELS * \
83 MAX_AMBS_PER_CHANNEL)
84/*
85 * Ugly hack: For some reason the highest bit is set if there
86 * are _any_ DIMMs in the channel. Attempting to read from
87 * this "high-order" AMB results in a memory bus error, so
88 * for now we'll just ignore that top bit, even though that
89 * might prevent us from seeing the 16th DIMM in the channel.
90 */
91#define REAL_MAX_AMBS_PER_CHANNEL 15
92#define KNOBS_PER_AMB 5
93
94static unsigned long amb_num_from_reg(unsigned int byte_num, unsigned int bit)
95{
96 return byte_num * MAX_AMBS_PER_CHANNEL + bit;
97}
98
99#define AMB_SYSFS_NAME_LEN 16
100struct i5k_device_attribute {
101 struct sensor_device_attribute s_attr;
102 char name[AMB_SYSFS_NAME_LEN];
103};
104
105struct i5k_amb_data {
106 struct device *hwmon_dev;
107
108 unsigned long amb_base;
109 unsigned long amb_len;
110 u16 amb_present[MAX_MEM_CHANNELS];
111 void __iomem *amb_mmio;
112 struct i5k_device_attribute *attrs;
113 unsigned int num_attrs;
114};
115
116static ssize_t show_name(struct device *dev, struct device_attribute *devattr,
117 char *buf)
118{
119 return sprintf(buf, "%s\n", DRVNAME);
120}
121
122
123static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
124
125static struct platform_device *amb_pdev;
126
127static u8 amb_read_byte(struct i5k_amb_data *data, unsigned long offset)
128{
129 return ioread8(data->amb_mmio + offset);
130}
131
132static void amb_write_byte(struct i5k_amb_data *data, unsigned long offset,
133 u8 val)
134{
135 iowrite8(val, data->amb_mmio + offset);
136}
137
138static ssize_t show_amb_alarm(struct device *dev,
139 struct device_attribute *devattr,
140 char *buf)
141{
142 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
143 struct i5k_amb_data *data = dev_get_drvdata(dev);
144
145 if (!(amb_read_byte(data, amb_reg_temp_status(attr->index)) & 0x20) &&
146 (amb_read_byte(data, amb_reg_temp_status(attr->index)) & 0x8))
147 return sprintf(buf, "1\n");
148 else
149 return sprintf(buf, "0\n");
150}
151
152static ssize_t store_amb_min(struct device *dev,
153 struct device_attribute *devattr,
154 const char *buf,
155 size_t count)
156{
157 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
158 struct i5k_amb_data *data = dev_get_drvdata(dev);
159 unsigned long temp = simple_strtoul(buf, NULL, 10) / 500;
160
161 if (temp > 255)
162 temp = 255;
163
164 amb_write_byte(data, amb_reg_temp_min(attr->index), temp);
165 return count;
166}
167
168static ssize_t store_amb_mid(struct device *dev,
169 struct device_attribute *devattr,
170 const char *buf,
171 size_t count)
172{
173 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
174 struct i5k_amb_data *data = dev_get_drvdata(dev);
175 unsigned long temp = simple_strtoul(buf, NULL, 10) / 500;
176
177 if (temp > 255)
178 temp = 255;
179
180 amb_write_byte(data, amb_reg_temp_mid(attr->index), temp);
181 return count;
182}
183
184static ssize_t store_amb_max(struct device *dev,
185 struct device_attribute *devattr,
186 const char *buf,
187 size_t count)
188{
189 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
190 struct i5k_amb_data *data = dev_get_drvdata(dev);
191 unsigned long temp = simple_strtoul(buf, NULL, 10) / 500;
192
193 if (temp > 255)
194 temp = 255;
195
196 amb_write_byte(data, amb_reg_temp_max(attr->index), temp);
197 return count;
198}
199
200static ssize_t show_amb_min(struct device *dev,
201 struct device_attribute *devattr,
202 char *buf)
203{
204 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
205 struct i5k_amb_data *data = dev_get_drvdata(dev);
206 return sprintf(buf, "%d\n",
207 500 * amb_read_byte(data, amb_reg_temp_min(attr->index)));
208}
209
210static ssize_t show_amb_mid(struct device *dev,
211 struct device_attribute *devattr,
212 char *buf)
213{
214 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
215 struct i5k_amb_data *data = dev_get_drvdata(dev);
216 return sprintf(buf, "%d\n",
217 500 * amb_read_byte(data, amb_reg_temp_mid(attr->index)));
218}
219
220static ssize_t show_amb_max(struct device *dev,
221 struct device_attribute *devattr,
222 char *buf)
223{
224 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
225 struct i5k_amb_data *data = dev_get_drvdata(dev);
226 return sprintf(buf, "%d\n",
227 500 * amb_read_byte(data, amb_reg_temp_max(attr->index)));
228}
229
230static ssize_t show_amb_temp(struct device *dev,
231 struct device_attribute *devattr,
232 char *buf)
233{
234 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
235 struct i5k_amb_data *data = dev_get_drvdata(dev);
236 return sprintf(buf, "%d\n",
237 500 * amb_read_byte(data, amb_reg_temp(attr->index)));
238}
239
240static int __devinit i5k_amb_hwmon_init(struct platform_device *pdev)
241{
242 int i, j, k, d = 0;
243 u16 c;
244 int res = 0;
245 int num_ambs = 0;
246 struct i5k_amb_data *data = platform_get_drvdata(pdev);
247
248 /* Count the number of AMBs found */
249 /* ignore the high-order bit, see "Ugly hack" comment above */
250 for (i = 0; i < MAX_MEM_CHANNELS; i++)
251 num_ambs += hweight16(data->amb_present[i] & 0x7fff);
252
253 /* Set up sysfs stuff */
254 data->attrs = kzalloc(sizeof(*data->attrs) * num_ambs * KNOBS_PER_AMB,
255 GFP_KERNEL);
256 if (!data->attrs)
257 return -ENOMEM;
258 data->num_attrs = 0;
259
260 for (i = 0; i < MAX_MEM_CHANNELS; i++) {
261 c = data->amb_present[i];
262 for (j = 0; j < REAL_MAX_AMBS_PER_CHANNEL; j++, c >>= 1) {
263 struct i5k_device_attribute *iattr;
264
265 k = amb_num_from_reg(i, j);
266 if (!(c & 0x1))
267 continue;
268 d++;
269
270 /* Temperature sysfs knob */
271 iattr = data->attrs + data->num_attrs;
272 snprintf(iattr->name, AMB_SYSFS_NAME_LEN,
273 "temp%d_input", d);
274 iattr->s_attr.dev_attr.attr.name = iattr->name;
275 iattr->s_attr.dev_attr.attr.mode = S_IRUGO;
276 iattr->s_attr.dev_attr.show = show_amb_temp;
277 iattr->s_attr.index = k;
278 res = device_create_file(&pdev->dev,
279 &iattr->s_attr.dev_attr);
280 if (res)
281 goto exit_remove;
282 data->num_attrs++;
283
284 /* Temperature min sysfs knob */
285 iattr = data->attrs + data->num_attrs;
286 snprintf(iattr->name, AMB_SYSFS_NAME_LEN,
287 "temp%d_min", d);
288 iattr->s_attr.dev_attr.attr.name = iattr->name;
289 iattr->s_attr.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
290 iattr->s_attr.dev_attr.show = show_amb_min;
291 iattr->s_attr.dev_attr.store = store_amb_min;
292 iattr->s_attr.index = k;
293 res = device_create_file(&pdev->dev,
294 &iattr->s_attr.dev_attr);
295 if (res)
296 goto exit_remove;
297 data->num_attrs++;
298
299 /* Temperature mid sysfs knob */
300 iattr = data->attrs + data->num_attrs;
301 snprintf(iattr->name, AMB_SYSFS_NAME_LEN,
302 "temp%d_mid", d);
303 iattr->s_attr.dev_attr.attr.name = iattr->name;
304 iattr->s_attr.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
305 iattr->s_attr.dev_attr.show = show_amb_mid;
306 iattr->s_attr.dev_attr.store = store_amb_mid;
307 iattr->s_attr.index = k;
308 res = device_create_file(&pdev->dev,
309 &iattr->s_attr.dev_attr);
310 if (res)
311 goto exit_remove;
312 data->num_attrs++;
313
314 /* Temperature max sysfs knob */
315 iattr = data->attrs + data->num_attrs;
316 snprintf(iattr->name, AMB_SYSFS_NAME_LEN,
317 "temp%d_max", d);
318 iattr->s_attr.dev_attr.attr.name = iattr->name;
319 iattr->s_attr.dev_attr.attr.mode = S_IWUSR | S_IRUGO;
320 iattr->s_attr.dev_attr.show = show_amb_max;
321 iattr->s_attr.dev_attr.store = store_amb_max;
322 iattr->s_attr.index = k;
323 res = device_create_file(&pdev->dev,
324 &iattr->s_attr.dev_attr);
325 if (res)
326 goto exit_remove;
327 data->num_attrs++;
328
329 /* Temperature alarm sysfs knob */
330 iattr = data->attrs + data->num_attrs;
331 snprintf(iattr->name, AMB_SYSFS_NAME_LEN,
332 "temp%d_alarm", d);
333 iattr->s_attr.dev_attr.attr.name = iattr->name;
334 iattr->s_attr.dev_attr.attr.mode = S_IRUGO;
335 iattr->s_attr.dev_attr.show = show_amb_alarm;
336 iattr->s_attr.index = k;
337 res = device_create_file(&pdev->dev,
338 &iattr->s_attr.dev_attr);
339 if (res)
340 goto exit_remove;
341 data->num_attrs++;
342 }
343 }
344
345 res = device_create_file(&pdev->dev, &dev_attr_name);
346 if (res)
347 goto exit_remove;
348
349 data->hwmon_dev = hwmon_device_register(&pdev->dev);
350 if (IS_ERR(data->hwmon_dev)) {
351 res = PTR_ERR(data->hwmon_dev);
352 goto exit_remove;
353 }
354
355 return res;
356
357exit_remove:
358 device_remove_file(&pdev->dev, &dev_attr_name);
359 for (i = 0; i < data->num_attrs; i++)
360 device_remove_file(&pdev->dev, &data->attrs[i].s_attr.dev_attr);
361 kfree(data->attrs);
362
363 return res;
364}
365
366static int __devinit i5k_amb_add(void)
367{
368 int res = -ENODEV;
369
370 /* only ever going to be one of these */
371 amb_pdev = platform_device_alloc(DRVNAME, 0);
372 if (!amb_pdev)
373 return -ENOMEM;
374
375 res = platform_device_add(amb_pdev);
376 if (res)
377 goto err;
378 return 0;
379
380err:
381 platform_device_put(amb_pdev);
382 return res;
383}
384
385static int __devinit i5k_find_amb_registers(struct i5k_amb_data *data)
386{
387 struct pci_dev *pcidev;
388 u32 val32;
389 int res = -ENODEV;
390
391 /* Find AMB register memory space */
392 pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
393 PCI_DEVICE_ID_INTEL_5000_ERR,
394 NULL);
395 if (!pcidev)
396 return -ENODEV;
397
398 if (pci_read_config_dword(pcidev, I5K_REG_AMB_BASE_ADDR, &val32))
399 goto out;
400 data->amb_base = val32;
401
402 if (pci_read_config_dword(pcidev, I5K_REG_AMB_LEN_ADDR, &val32))
403 goto out;
404 data->amb_len = val32;
405
406 /* Is it big enough? */
407 if (data->amb_len < AMB_CONFIG_SIZE * MAX_AMBS) {
408 dev_err(&pcidev->dev, "AMB region too small!\n");
409 goto out;
410 }
411
412 res = 0;
413out:
414 pci_dev_put(pcidev);
415 return res;
416}
417
418static int __devinit i5k_channel_probe(u16 *amb_present, unsigned long dev_id)
419{
420 struct pci_dev *pcidev;
421 u16 val16;
422 int res = -ENODEV;
423
424 /* Copy the DIMM presence map for these two channels */
425 pcidev = pci_get_device(PCI_VENDOR_ID_INTEL, dev_id, NULL);
426 if (!pcidev)
427 return -ENODEV;
428
429 if (pci_read_config_word(pcidev, I5K_REG_CHAN0_PRESENCE_ADDR, &val16))
430 goto out;
431 amb_present[0] = val16;
432
433 if (pci_read_config_word(pcidev, I5K_REG_CHAN1_PRESENCE_ADDR, &val16))
434 goto out;
435 amb_present[1] = val16;
436
437 res = 0;
438
439out:
440 pci_dev_put(pcidev);
441 return res;
442}
443
444static int __devinit i5k_amb_probe(struct platform_device *pdev)
445{
446 struct i5k_amb_data *data;
447 struct resource *reso;
448 int res = -ENODEV;
449
450 data = kzalloc(sizeof(*data), GFP_KERNEL);
451 if (!data)
452 return -ENOMEM;
453
454 /* Figure out where the AMB registers live */
455 res = i5k_find_amb_registers(data);
456 if (res)
457 goto err;
458
459 /* Copy the DIMM presence map for the first two channels */
460 res = i5k_channel_probe(&data->amb_present[0],
461 PCI_DEVICE_ID_INTEL_5000_FBD0);
462 if (res)
463 goto err;
464
465 /* Copy the DIMM presence map for the optional second two channels */
466 i5k_channel_probe(&data->amb_present[2],
467 PCI_DEVICE_ID_INTEL_5000_FBD1);
468
469 /* Set up resource regions */
470 reso = request_mem_region(data->amb_base, data->amb_len, DRVNAME);
471 if (!reso) {
472 res = -EBUSY;
473 goto err;
474 }
475
476 data->amb_mmio = ioremap_nocache(data->amb_base, data->amb_len);
477 if (!data->amb_mmio) {
478 res = -EBUSY;
479 goto err_map_failed;
480 }
481
482 platform_set_drvdata(pdev, data);
483
484 res = i5k_amb_hwmon_init(pdev);
485 if (res)
486 goto err_init_failed;
487
488 return res;
489
490err_init_failed:
491 iounmap(data->amb_mmio);
492 platform_set_drvdata(pdev, NULL);
493err_map_failed:
494 release_mem_region(data->amb_base, data->amb_len);
495err:
496 kfree(data);
497 return res;
498}
499
500static int __devexit i5k_amb_remove(struct platform_device *pdev)
501{
502 int i;
503 struct i5k_amb_data *data = platform_get_drvdata(pdev);
504
505 hwmon_device_unregister(data->hwmon_dev);
506 device_remove_file(&pdev->dev, &dev_attr_name);
507 for (i = 0; i < data->num_attrs; i++)
508 device_remove_file(&pdev->dev, &data->attrs[i].s_attr.dev_attr);
509 kfree(data->attrs);
510 iounmap(data->amb_mmio);
511 release_mem_region(data->amb_base, data->amb_len);
512 platform_set_drvdata(pdev, NULL);
513 kfree(data);
514 return 0;
515}
516
517static struct platform_driver i5k_amb_driver = {
518 .driver = {
519 .owner = THIS_MODULE,
520 .name = DRVNAME,
521 },
522 .probe = i5k_amb_probe,
523 .remove = __devexit_p(i5k_amb_remove),
524};
525
526static int __init i5k_amb_init(void)
527{
528 int res;
529
530 res = platform_driver_register(&i5k_amb_driver);
531 if (res)
532 return res;
533
534 res = i5k_amb_add();
535 if (res)
536 platform_driver_unregister(&i5k_amb_driver);
537
538 return res;
539}
540
541static void __exit i5k_amb_exit(void)
542{
543 platform_device_unregister(amb_pdev);
544 platform_driver_unregister(&i5k_amb_driver);
545}
546
547MODULE_AUTHOR("Darrick J. Wong <djwong@us.ibm.com>");
548MODULE_DESCRIPTION("Intel 5000 chipset FB-DIMM AMB temperature sensor");
549MODULE_LICENSE("GPL");
550
551module_init(i5k_amb_init);
552module_exit(i5k_amb_exit);
diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c
index c462824ffccf..9c9cdb0685e4 100644
--- a/drivers/hwmon/ibmpex.c
+++ b/drivers/hwmon/ibmpex.c
@@ -140,10 +140,10 @@ static int ibmpex_send_message(struct ibmpex_bmc_data *data)
140 140
141 return 0; 141 return 0;
142out1: 142out1:
143 printk(KERN_ERR "%s: request_settime=%x\n", __FUNCTION__, err); 143 dev_err(data->bmc_device, "request_settime=%x\n", err);
144 return err; 144 return err;
145out: 145out:
146 printk(KERN_ERR "%s: validate_addr=%x\n", __FUNCTION__, err); 146 dev_err(data->bmc_device, "validate_addr=%x\n", err);
147 return err; 147 return err;
148} 148}
149 149
@@ -161,14 +161,14 @@ static int ibmpex_ver_check(struct ibmpex_bmc_data *data)
161 data->sensor_major = data->rx_msg_data[0]; 161 data->sensor_major = data->rx_msg_data[0];
162 data->sensor_minor = data->rx_msg_data[1]; 162 data->sensor_minor = data->rx_msg_data[1];
163 163
164 printk(KERN_INFO DRVNAME ": Found BMC with sensor interface " 164 dev_info(data->bmc_device, "Found BMC with sensor interface "
165 "v%d.%d %d-%02d-%02d on interface %d\n", 165 "v%d.%d %d-%02d-%02d on interface %d\n",
166 data->sensor_major, 166 data->sensor_major,
167 data->sensor_minor, 167 data->sensor_minor,
168 extract_value(data->rx_msg_data, 2), 168 extract_value(data->rx_msg_data, 2),
169 data->rx_msg_data[4], 169 data->rx_msg_data[4],
170 data->rx_msg_data[5], 170 data->rx_msg_data[5],
171 data->interface); 171 data->interface);
172 172
173 return 0; 173 return 0;
174} 174}
@@ -212,8 +212,8 @@ static int ibmpex_query_sensor_data(struct ibmpex_bmc_data *data, int sensor)
212 wait_for_completion(&data->read_complete); 212 wait_for_completion(&data->read_complete);
213 213
214 if (data->rx_result || data->rx_msg_len < 26) { 214 if (data->rx_result || data->rx_msg_len < 26) {
215 printk(KERN_ERR "Error reading sensor %d, please check.\n", 215 dev_err(data->bmc_device, "Error reading sensor %d.\n",
216 sensor); 216 sensor);
217 return -ENOENT; 217 return -ENOENT;
218 } 218 }
219 219
@@ -456,8 +456,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
456 456
457 data = kzalloc(sizeof(*data), GFP_KERNEL); 457 data = kzalloc(sizeof(*data), GFP_KERNEL);
458 if (!data) { 458 if (!data) {
459 printk(KERN_ERR DRVNAME ": Insufficient memory for BMC " 459 dev_err(dev, "Insufficient memory for BMC interface.\n");
460 "interface %d.\n", data->interface);
461 return; 460 return;
462 } 461 }
463 462
@@ -471,9 +470,8 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
471 err = ipmi_create_user(data->interface, &driver_data.ipmi_hndlrs, 470 err = ipmi_create_user(data->interface, &driver_data.ipmi_hndlrs,
472 data, &data->user); 471 data, &data->user);
473 if (err < 0) { 472 if (err < 0) {
474 printk(KERN_ERR DRVNAME ": Error, unable to register user with " 473 dev_err(dev, "Unable to register user with IPMI "
475 "ipmi interface %d\n", 474 "interface %d\n", data->interface);
476 data->interface);
477 goto out; 475 goto out;
478 } 476 }
479 477
@@ -495,9 +493,9 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
495 data->hwmon_dev = hwmon_device_register(data->bmc_device); 493 data->hwmon_dev = hwmon_device_register(data->bmc_device);
496 494
497 if (IS_ERR(data->hwmon_dev)) { 495 if (IS_ERR(data->hwmon_dev)) {
498 printk(KERN_ERR DRVNAME ": Error, unable to register hwmon " 496 dev_err(data->bmc_device, "Unable to register hwmon "
499 "class device for interface %d\n", 497 "device for IPMI interface %d\n",
500 data->interface); 498 data->interface);
501 goto out_user; 499 goto out_user;
502 } 500 }
503 501
@@ -508,7 +506,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
508 /* Now go find all the sensors */ 506 /* Now go find all the sensors */
509 err = ibmpex_find_sensors(data); 507 err = ibmpex_find_sensors(data);
510 if (err) { 508 if (err) {
511 printk(KERN_ERR "Error %d allocating memory\n", err); 509 dev_err(data->bmc_device, "Error %d finding sensors\n", err);
512 goto out_register; 510 goto out_register;
513 } 511 }
514 512
@@ -561,10 +559,10 @@ static void ibmpex_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data)
561 struct ibmpex_bmc_data *data = (struct ibmpex_bmc_data *)user_msg_data; 559 struct ibmpex_bmc_data *data = (struct ibmpex_bmc_data *)user_msg_data;
562 560
563 if (msg->msgid != data->tx_msgid) { 561 if (msg->msgid != data->tx_msgid) {
564 printk(KERN_ERR "Received msgid (%02x) and transmitted " 562 dev_err(data->bmc_device, "Mismatch between received msgid "
565 "msgid (%02x) mismatch!\n", 563 "(%02x) and transmitted msgid (%02x)!\n",
566 (int)msg->msgid, 564 (int)msg->msgid,
567 (int)data->tx_msgid); 565 (int)data->tx_msgid);
568 ipmi_free_recv_msg(msg); 566 ipmi_free_recv_msg(msg);
569 return; 567 return;
570 } 568 }
diff --git a/drivers/hwmon/lm70.c b/drivers/hwmon/lm70.c
index dd366889ce9b..d435f003292d 100644
--- a/drivers/hwmon/lm70.c
+++ b/drivers/hwmon/lm70.c
@@ -31,14 +31,15 @@
31#include <linux/err.h> 31#include <linux/err.h>
32#include <linux/sysfs.h> 32#include <linux/sysfs.h>
33#include <linux/hwmon.h> 33#include <linux/hwmon.h>
34#include <linux/mutex.h>
34#include <linux/spi/spi.h> 35#include <linux/spi/spi.h>
35#include <asm/semaphore.h> 36
36 37
37#define DRVNAME "lm70" 38#define DRVNAME "lm70"
38 39
39struct lm70 { 40struct lm70 {
40 struct device *hwmon_dev; 41 struct device *hwmon_dev;
41 struct semaphore sem; 42 struct mutex lock;
42}; 43};
43 44
44/* sysfs hook function */ 45/* sysfs hook function */
@@ -51,7 +52,7 @@ static ssize_t lm70_sense_temp(struct device *dev,
51 s16 raw=0; 52 s16 raw=0;
52 struct lm70 *p_lm70 = dev_get_drvdata(&spi->dev); 53 struct lm70 *p_lm70 = dev_get_drvdata(&spi->dev);
53 54
54 if (down_interruptible(&p_lm70->sem)) 55 if (mutex_lock_interruptible(&p_lm70->lock))
55 return -ERESTARTSYS; 56 return -ERESTARTSYS;
56 57
57 /* 58 /*
@@ -83,7 +84,7 @@ static ssize_t lm70_sense_temp(struct device *dev,
83 val = ((int)raw/32) * 250; 84 val = ((int)raw/32) * 250;
84 status = sprintf(buf, "%d\n", val); /* millidegrees Celsius */ 85 status = sprintf(buf, "%d\n", val); /* millidegrees Celsius */
85out: 86out:
86 up(&p_lm70->sem); 87 mutex_unlock(&p_lm70->lock);
87 return status; 88 return status;
88} 89}
89 90
@@ -112,7 +113,7 @@ static int __devinit lm70_probe(struct spi_device *spi)
112 if (!p_lm70) 113 if (!p_lm70)
113 return -ENOMEM; 114 return -ENOMEM;
114 115
115 init_MUTEX(&p_lm70->sem); 116 mutex_init(&p_lm70->lock);
116 117
117 /* sysfs hook */ 118 /* sysfs hook */
118 p_lm70->hwmon_dev = hwmon_device_register(&spi->dev); 119 p_lm70->hwmon_dev = hwmon_device_register(&spi->dev);
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
index 7e2d9787babc..a276806f3d53 100644
--- a/drivers/hwmon/sis5595.c
+++ b/drivers/hwmon/sis5595.c
@@ -435,6 +435,22 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, ch
435} 435}
436static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 436static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
437 437
438static ssize_t show_alarm(struct device *dev, struct device_attribute *da,
439 char *buf)
440{
441 struct sis5595_data *data = sis5595_update_device(dev);
442 int nr = to_sensor_dev_attr(da)->index;
443 return sprintf(buf, "%u\n", (data->alarms >> nr) & 1);
444}
445static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0);
446static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1);
447static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2);
448static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3);
449static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 15);
450static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6);
451static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7);
452static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 15);
453
438static ssize_t show_name(struct device *dev, struct device_attribute *attr, 454static ssize_t show_name(struct device *dev, struct device_attribute *attr,
439 char *buf) 455 char *buf)
440{ 456{
@@ -447,22 +463,28 @@ static struct attribute *sis5595_attributes[] = {
447 &sensor_dev_attr_in0_input.dev_attr.attr, 463 &sensor_dev_attr_in0_input.dev_attr.attr,
448 &sensor_dev_attr_in0_min.dev_attr.attr, 464 &sensor_dev_attr_in0_min.dev_attr.attr,
449 &sensor_dev_attr_in0_max.dev_attr.attr, 465 &sensor_dev_attr_in0_max.dev_attr.attr,
466 &sensor_dev_attr_in0_alarm.dev_attr.attr,
450 &sensor_dev_attr_in1_input.dev_attr.attr, 467 &sensor_dev_attr_in1_input.dev_attr.attr,
451 &sensor_dev_attr_in1_min.dev_attr.attr, 468 &sensor_dev_attr_in1_min.dev_attr.attr,
452 &sensor_dev_attr_in1_max.dev_attr.attr, 469 &sensor_dev_attr_in1_max.dev_attr.attr,
470 &sensor_dev_attr_in1_alarm.dev_attr.attr,
453 &sensor_dev_attr_in2_input.dev_attr.attr, 471 &sensor_dev_attr_in2_input.dev_attr.attr,
454 &sensor_dev_attr_in2_min.dev_attr.attr, 472 &sensor_dev_attr_in2_min.dev_attr.attr,
455 &sensor_dev_attr_in2_max.dev_attr.attr, 473 &sensor_dev_attr_in2_max.dev_attr.attr,
474 &sensor_dev_attr_in2_alarm.dev_attr.attr,
456 &sensor_dev_attr_in3_input.dev_attr.attr, 475 &sensor_dev_attr_in3_input.dev_attr.attr,
457 &sensor_dev_attr_in3_min.dev_attr.attr, 476 &sensor_dev_attr_in3_min.dev_attr.attr,
458 &sensor_dev_attr_in3_max.dev_attr.attr, 477 &sensor_dev_attr_in3_max.dev_attr.attr,
478 &sensor_dev_attr_in3_alarm.dev_attr.attr,
459 479
460 &sensor_dev_attr_fan1_input.dev_attr.attr, 480 &sensor_dev_attr_fan1_input.dev_attr.attr,
461 &sensor_dev_attr_fan1_min.dev_attr.attr, 481 &sensor_dev_attr_fan1_min.dev_attr.attr,
462 &sensor_dev_attr_fan1_div.dev_attr.attr, 482 &sensor_dev_attr_fan1_div.dev_attr.attr,
483 &sensor_dev_attr_fan1_alarm.dev_attr.attr,
463 &sensor_dev_attr_fan2_input.dev_attr.attr, 484 &sensor_dev_attr_fan2_input.dev_attr.attr,
464 &sensor_dev_attr_fan2_min.dev_attr.attr, 485 &sensor_dev_attr_fan2_min.dev_attr.attr,
465 &sensor_dev_attr_fan2_div.dev_attr.attr, 486 &sensor_dev_attr_fan2_div.dev_attr.attr,
487 &sensor_dev_attr_fan2_alarm.dev_attr.attr,
466 488
467 &dev_attr_alarms.attr, 489 &dev_attr_alarms.attr,
468 &dev_attr_name.attr, 490 &dev_attr_name.attr,
@@ -473,19 +495,28 @@ static const struct attribute_group sis5595_group = {
473 .attrs = sis5595_attributes, 495 .attrs = sis5595_attributes,
474}; 496};
475 497
476static struct attribute *sis5595_attributes_opt[] = { 498static struct attribute *sis5595_attributes_in4[] = {
477 &sensor_dev_attr_in4_input.dev_attr.attr, 499 &sensor_dev_attr_in4_input.dev_attr.attr,
478 &sensor_dev_attr_in4_min.dev_attr.attr, 500 &sensor_dev_attr_in4_min.dev_attr.attr,
479 &sensor_dev_attr_in4_max.dev_attr.attr, 501 &sensor_dev_attr_in4_max.dev_attr.attr,
502 &sensor_dev_attr_in4_alarm.dev_attr.attr,
503 NULL
504};
505
506static const struct attribute_group sis5595_group_in4 = {
507 .attrs = sis5595_attributes_in4,
508};
480 509
510static struct attribute *sis5595_attributes_temp1[] = {
481 &dev_attr_temp1_input.attr, 511 &dev_attr_temp1_input.attr,
482 &dev_attr_temp1_max.attr, 512 &dev_attr_temp1_max.attr,
483 &dev_attr_temp1_max_hyst.attr, 513 &dev_attr_temp1_max_hyst.attr,
514 &sensor_dev_attr_temp1_alarm.dev_attr.attr,
484 NULL 515 NULL
485}; 516};
486 517
487static const struct attribute_group sis5595_group_opt = { 518static const struct attribute_group sis5595_group_temp1 = {
488 .attrs = sis5595_attributes_opt, 519 .attrs = sis5595_attributes_temp1,
489}; 520};
490 521
491/* This is called when the module is loaded */ 522/* This is called when the module is loaded */
@@ -540,20 +571,12 @@ static int __devinit sis5595_probe(struct platform_device *pdev)
540 if ((err = sysfs_create_group(&pdev->dev.kobj, &sis5595_group))) 571 if ((err = sysfs_create_group(&pdev->dev.kobj, &sis5595_group)))
541 goto exit_free; 572 goto exit_free;
542 if (data->maxins == 4) { 573 if (data->maxins == 4) {
543 if ((err = device_create_file(&pdev->dev, 574 if ((err = sysfs_create_group(&pdev->dev.kobj,
544 &sensor_dev_attr_in4_input.dev_attr)) 575 &sis5595_group_in4)))
545 || (err = device_create_file(&pdev->dev,
546 &sensor_dev_attr_in4_min.dev_attr))
547 || (err = device_create_file(&pdev->dev,
548 &sensor_dev_attr_in4_max.dev_attr)))
549 goto exit_remove_files; 576 goto exit_remove_files;
550 } else { 577 } else {
551 if ((err = device_create_file(&pdev->dev, 578 if ((err = sysfs_create_group(&pdev->dev.kobj,
552 &dev_attr_temp1_input)) 579 &sis5595_group_temp1)))
553 || (err = device_create_file(&pdev->dev,
554 &dev_attr_temp1_max))
555 || (err = device_create_file(&pdev->dev,
556 &dev_attr_temp1_max_hyst)))
557 goto exit_remove_files; 580 goto exit_remove_files;
558 } 581 }
559 582
@@ -567,7 +590,8 @@ static int __devinit sis5595_probe(struct platform_device *pdev)
567 590
568exit_remove_files: 591exit_remove_files:
569 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group); 592 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group);
570 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_opt); 593 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_in4);
594 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_temp1);
571exit_free: 595exit_free:
572 kfree(data); 596 kfree(data);
573exit_release: 597exit_release:
@@ -582,7 +606,8 @@ static int __devexit sis5595_remove(struct platform_device *pdev)
582 606
583 hwmon_device_unregister(data->hwmon_dev); 607 hwmon_device_unregister(data->hwmon_dev);
584 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group); 608 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group);
585 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_opt); 609 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_in4);
610 sysfs_remove_group(&pdev->dev.kobj, &sis5595_group_temp1);
586 611
587 release_region(data->addr, SIS5595_EXTENT); 612 release_region(data->addr, SIS5595_EXTENT);
588 platform_set_drvdata(pdev, NULL); 613 platform_set_drvdata(pdev, NULL);
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index 20ae425a1980..879d0a6544cc 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -170,20 +170,16 @@ superio_exit(void)
170#define W83781D_REG_IN(nr) ((nr < 7) ? (0x20 + (nr)) : \ 170#define W83781D_REG_IN(nr) ((nr < 7) ? (0x20 + (nr)) : \
171 (0x550 + (nr) - 7)) 171 (0x550 + (nr) - 7))
172 172
173#define W83781D_REG_FAN_MIN(nr) (0x3a + (nr)) 173/* nr:0-2 for fans:1-3 */
174#define W83781D_REG_FAN(nr) (0x27 + (nr)) 174#define W83627HF_REG_FAN_MIN(nr) (0x3b + (nr))
175 175#define W83627HF_REG_FAN(nr) (0x28 + (nr))
176#define W83781D_REG_TEMP2_CONFIG 0x152 176
177#define W83781D_REG_TEMP3_CONFIG 0x252 177#define W83627HF_REG_TEMP2_CONFIG 0x152
178#define W83781D_REG_TEMP(nr) ((nr == 3) ? (0x0250) : \ 178#define W83627HF_REG_TEMP3_CONFIG 0x252
179 ((nr == 2) ? (0x0150) : \ 179/* these are zero-based, unlike config constants above */
180 (0x27))) 180static const u16 w83627hf_reg_temp[] = { 0x27, 0x150, 0x250 };
181#define W83781D_REG_TEMP_HYST(nr) ((nr == 3) ? (0x253) : \ 181static const u16 w83627hf_reg_temp_hyst[] = { 0x3A, 0x153, 0x253 };
182 ((nr == 2) ? (0x153) : \ 182static const u16 w83627hf_reg_temp_over[] = { 0x39, 0x155, 0x255 };
183 (0x3A)))
184#define W83781D_REG_TEMP_OVER(nr) ((nr == 3) ? (0x255) : \
185 ((nr == 2) ? (0x155) : \
186 (0x39)))
187 183
188#define W83781D_REG_BANK 0x4E 184#define W83781D_REG_BANK 0x4E
189 185
@@ -360,12 +356,9 @@ struct w83627hf_data {
360 u8 in_min[9]; /* Register value */ 356 u8 in_min[9]; /* Register value */
361 u8 fan[3]; /* Register value */ 357 u8 fan[3]; /* Register value */
362 u8 fan_min[3]; /* Register value */ 358 u8 fan_min[3]; /* Register value */
363 u8 temp; 359 u16 temp[3]; /* Register value */
364 u8 temp_max; /* Register value */ 360 u16 temp_max[3]; /* Register value */
365 u8 temp_max_hyst; /* Register value */ 361 u16 temp_max_hyst[3]; /* Register value */
366 u16 temp_add[2]; /* Register value */
367 u16 temp_max_add[2]; /* Register value */
368 u16 temp_max_hyst_add[2]; /* Register value */
369 u8 fan_div[3]; /* Register encoding, shifted right */ 362 u8 fan_div[3]; /* Register encoding, shifted right */
370 u8 vid; /* Register encoding, combined */ 363 u8 vid; /* Register encoding, combined */
371 u32 alarms; /* Register encoding, combined */ 364 u32 alarms; /* Register encoding, combined */
@@ -590,7 +583,7 @@ store_fan_min(struct device *dev, struct device_attribute *devattr,
590 583
591 mutex_lock(&data->update_lock); 584 mutex_lock(&data->update_lock);
592 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); 585 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
593 w83627hf_write_value(data, W83781D_REG_FAN_MIN(nr+1), 586 w83627hf_write_value(data, W83627HF_REG_FAN_MIN(nr),
594 data->fan_min[nr]); 587 data->fan_min[nr]);
595 588
596 mutex_unlock(&data->update_lock); 589 mutex_unlock(&data->update_lock);
@@ -611,12 +604,10 @@ show_temp(struct device *dev, struct device_attribute *devattr, char *buf)
611{ 604{
612 int nr = to_sensor_dev_attr(devattr)->index; 605 int nr = to_sensor_dev_attr(devattr)->index;
613 struct w83627hf_data *data = w83627hf_update_device(dev); 606 struct w83627hf_data *data = w83627hf_update_device(dev);
614 if (nr >= 2) { /* TEMP2 and TEMP3 */ 607
615 return sprintf(buf, "%ld\n", 608 u16 tmp = data->temp[nr];
616 (long)LM75_TEMP_FROM_REG(data->temp_add[nr-2])); 609 return sprintf(buf, "%ld\n", (nr) ? (long) LM75_TEMP_FROM_REG(tmp)
617 } else { /* TEMP1 */ 610 : (long) TEMP_FROM_REG(tmp));
618 return sprintf(buf, "%ld\n", (long)TEMP_FROM_REG(data->temp));
619 }
620} 611}
621 612
622static ssize_t 613static ssize_t
@@ -625,13 +616,10 @@ show_temp_max(struct device *dev, struct device_attribute *devattr,
625{ 616{
626 int nr = to_sensor_dev_attr(devattr)->index; 617 int nr = to_sensor_dev_attr(devattr)->index;
627 struct w83627hf_data *data = w83627hf_update_device(dev); 618 struct w83627hf_data *data = w83627hf_update_device(dev);
628 if (nr >= 2) { /* TEMP2 and TEMP3 */ 619
629 return sprintf(buf, "%ld\n", 620 u16 tmp = data->temp_max[nr];
630 (long)LM75_TEMP_FROM_REG(data->temp_max_add[nr-2])); 621 return sprintf(buf, "%ld\n", (nr) ? (long) LM75_TEMP_FROM_REG(tmp)
631 } else { /* TEMP1 */ 622 : (long) TEMP_FROM_REG(tmp));
632 return sprintf(buf, "%ld\n",
633 (long)TEMP_FROM_REG(data->temp_max));
634 }
635} 623}
636 624
637static ssize_t 625static ssize_t
@@ -640,13 +628,10 @@ show_temp_max_hyst(struct device *dev, struct device_attribute *devattr,
640{ 628{
641 int nr = to_sensor_dev_attr(devattr)->index; 629 int nr = to_sensor_dev_attr(devattr)->index;
642 struct w83627hf_data *data = w83627hf_update_device(dev); 630 struct w83627hf_data *data = w83627hf_update_device(dev);
643 if (nr >= 2) { /* TEMP2 and TEMP3 */ 631
644 return sprintf(buf, "%ld\n", 632 u16 tmp = data->temp_max_hyst[nr];
645 (long)LM75_TEMP_FROM_REG(data->temp_max_hyst_add[nr-2])); 633 return sprintf(buf, "%ld\n", (nr) ? (long) LM75_TEMP_FROM_REG(tmp)
646 } else { /* TEMP1 */ 634 : (long) TEMP_FROM_REG(tmp));
647 return sprintf(buf, "%ld\n",
648 (long)TEMP_FROM_REG(data->temp_max_hyst));
649 }
650} 635}
651 636
652static ssize_t 637static ssize_t
@@ -656,18 +641,11 @@ store_temp_max(struct device *dev, struct device_attribute *devattr,
656 int nr = to_sensor_dev_attr(devattr)->index; 641 int nr = to_sensor_dev_attr(devattr)->index;
657 struct w83627hf_data *data = dev_get_drvdata(dev); 642 struct w83627hf_data *data = dev_get_drvdata(dev);
658 long val = simple_strtol(buf, NULL, 10); 643 long val = simple_strtol(buf, NULL, 10);
644 u16 tmp = (nr) ? LM75_TEMP_TO_REG(val) : TEMP_TO_REG(val);
659 645
660 mutex_lock(&data->update_lock); 646 mutex_lock(&data->update_lock);
661 647 data->temp_max[nr] = tmp;
662 if (nr >= 2) { /* TEMP2 and TEMP3 */ 648 w83627hf_write_value(data, w83627hf_reg_temp_over[nr], tmp);
663 data->temp_max_add[nr-2] = LM75_TEMP_TO_REG(val);
664 w83627hf_write_value(data, W83781D_REG_TEMP_OVER(nr),
665 data->temp_max_add[nr-2]);
666 } else { /* TEMP1 */
667 data->temp_max = TEMP_TO_REG(val);
668 w83627hf_write_value(data, W83781D_REG_TEMP_OVER(nr),
669 data->temp_max);
670 }
671 mutex_unlock(&data->update_lock); 649 mutex_unlock(&data->update_lock);
672 return count; 650 return count;
673} 651}
@@ -679,29 +657,22 @@ store_temp_max_hyst(struct device *dev, struct device_attribute *devattr,
679 int nr = to_sensor_dev_attr(devattr)->index; 657 int nr = to_sensor_dev_attr(devattr)->index;
680 struct w83627hf_data *data = dev_get_drvdata(dev); 658 struct w83627hf_data *data = dev_get_drvdata(dev);
681 long val = simple_strtol(buf, NULL, 10); 659 long val = simple_strtol(buf, NULL, 10);
660 u16 tmp = (nr) ? LM75_TEMP_TO_REG(val) : TEMP_TO_REG(val);
682 661
683 mutex_lock(&data->update_lock); 662 mutex_lock(&data->update_lock);
684 663 data->temp_max_hyst[nr] = tmp;
685 if (nr >= 2) { /* TEMP2 and TEMP3 */ 664 w83627hf_write_value(data, w83627hf_reg_temp_hyst[nr], tmp);
686 data->temp_max_hyst_add[nr-2] = LM75_TEMP_TO_REG(val);
687 w83627hf_write_value(data, W83781D_REG_TEMP_HYST(nr),
688 data->temp_max_hyst_add[nr-2]);
689 } else { /* TEMP1 */
690 data->temp_max_hyst = TEMP_TO_REG(val);
691 w83627hf_write_value(data, W83781D_REG_TEMP_HYST(nr),
692 data->temp_max_hyst);
693 }
694 mutex_unlock(&data->update_lock); 665 mutex_unlock(&data->update_lock);
695 return count; 666 return count;
696} 667}
697 668
698#define sysfs_temp_decl(offset) \ 669#define sysfs_temp_decl(offset) \
699static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ 670static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
700 show_temp, NULL, offset); \ 671 show_temp, NULL, offset - 1); \
701static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO|S_IWUSR, \ 672static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO|S_IWUSR, \
702 show_temp_max, store_temp_max, offset); \ 673 show_temp_max, store_temp_max, offset - 1); \
703static SENSOR_DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO|S_IWUSR, \ 674static SENSOR_DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO|S_IWUSR, \
704 show_temp_max_hyst, store_temp_max_hyst, offset); 675 show_temp_max_hyst, store_temp_max_hyst, offset - 1);
705 676
706sysfs_temp_decl(1); 677sysfs_temp_decl(1);
707sysfs_temp_decl(2); 678sysfs_temp_decl(2);
@@ -844,7 +815,7 @@ store_fan_div(struct device *dev, struct device_attribute *devattr,
844 815
845 /* Restore fan_min */ 816 /* Restore fan_min */
846 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); 817 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
847 w83627hf_write_value(data, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]); 818 w83627hf_write_value(data, W83627HF_REG_FAN_MIN(nr), data->fan_min[nr]);
848 819
849 mutex_unlock(&data->update_lock); 820 mutex_unlock(&data->update_lock);
850 return count; 821 return count;
@@ -1170,7 +1141,7 @@ static int __devinit w83627hf_probe(struct platform_device *pdev)
1170 struct w83627hf_sio_data *sio_data = dev->platform_data; 1141 struct w83627hf_sio_data *sio_data = dev->platform_data;
1171 struct w83627hf_data *data; 1142 struct w83627hf_data *data;
1172 struct resource *res; 1143 struct resource *res;
1173 int err; 1144 int err, i;
1174 1145
1175 static const char *names[] = { 1146 static const char *names[] = {
1176 "w83627hf", 1147 "w83627hf",
@@ -1204,9 +1175,9 @@ static int __devinit w83627hf_probe(struct platform_device *pdev)
1204 w83627hf_init_device(pdev); 1175 w83627hf_init_device(pdev);
1205 1176
1206 /* A few vars need to be filled upon startup */ 1177 /* A few vars need to be filled upon startup */
1207 data->fan_min[0] = w83627hf_read_value(data, W83781D_REG_FAN_MIN(1)); 1178 for (i = 0; i <= 2; i++)
1208 data->fan_min[1] = w83627hf_read_value(data, W83781D_REG_FAN_MIN(2)); 1179 data->fan_min[i] = w83627hf_read_value(
1209 data->fan_min[2] = w83627hf_read_value(data, W83781D_REG_FAN_MIN(3)); 1180 data, W83627HF_REG_FAN_MIN(i));
1210 w83627hf_update_fan_div(data); 1181 w83627hf_update_fan_div(data);
1211 1182
1212 /* Register common device attributes */ 1183 /* Register common device attributes */
@@ -1514,23 +1485,23 @@ static void __devinit w83627hf_init_device(struct platform_device *pdev)
1514 1485
1515 if(init) { 1486 if(init) {
1516 /* Enable temp2 */ 1487 /* Enable temp2 */
1517 tmp = w83627hf_read_value(data, W83781D_REG_TEMP2_CONFIG); 1488 tmp = w83627hf_read_value(data, W83627HF_REG_TEMP2_CONFIG);
1518 if (tmp & 0x01) { 1489 if (tmp & 0x01) {
1519 dev_warn(&pdev->dev, "Enabling temp2, readings " 1490 dev_warn(&pdev->dev, "Enabling temp2, readings "
1520 "might not make sense\n"); 1491 "might not make sense\n");
1521 w83627hf_write_value(data, W83781D_REG_TEMP2_CONFIG, 1492 w83627hf_write_value(data, W83627HF_REG_TEMP2_CONFIG,
1522 tmp & 0xfe); 1493 tmp & 0xfe);
1523 } 1494 }
1524 1495
1525 /* Enable temp3 */ 1496 /* Enable temp3 */
1526 if (type != w83697hf) { 1497 if (type != w83697hf) {
1527 tmp = w83627hf_read_value(data, 1498 tmp = w83627hf_read_value(data,
1528 W83781D_REG_TEMP3_CONFIG); 1499 W83627HF_REG_TEMP3_CONFIG);
1529 if (tmp & 0x01) { 1500 if (tmp & 0x01) {
1530 dev_warn(&pdev->dev, "Enabling temp3, " 1501 dev_warn(&pdev->dev, "Enabling temp3, "
1531 "readings might not make sense\n"); 1502 "readings might not make sense\n");
1532 w83627hf_write_value(data, 1503 w83627hf_write_value(data,
1533 W83781D_REG_TEMP3_CONFIG, tmp & 0xfe); 1504 W83627HF_REG_TEMP3_CONFIG, tmp & 0xfe);
1534 } 1505 }
1535 } 1506 }
1536 } 1507 }
@@ -1563,7 +1534,7 @@ static void w83627hf_update_fan_div(struct w83627hf_data *data)
1563static struct w83627hf_data *w83627hf_update_device(struct device *dev) 1534static struct w83627hf_data *w83627hf_update_device(struct device *dev)
1564{ 1535{
1565 struct w83627hf_data *data = dev_get_drvdata(dev); 1536 struct w83627hf_data *data = dev_get_drvdata(dev);
1566 int i; 1537 int i, num_temps = (data->type == w83697hf) ? 2 : 3;
1567 1538
1568 mutex_lock(&data->update_lock); 1539 mutex_lock(&data->update_lock);
1569 1540
@@ -1584,12 +1555,12 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev)
1584 w83627hf_read_value(data, 1555 w83627hf_read_value(data,
1585 W83781D_REG_IN_MAX(i)); 1556 W83781D_REG_IN_MAX(i));
1586 } 1557 }
1587 for (i = 1; i <= 3; i++) { 1558 for (i = 0; i <= 2; i++) {
1588 data->fan[i - 1] = 1559 data->fan[i] =
1589 w83627hf_read_value(data, W83781D_REG_FAN(i)); 1560 w83627hf_read_value(data, W83627HF_REG_FAN(i));
1590 data->fan_min[i - 1] = 1561 data->fan_min[i] =
1591 w83627hf_read_value(data, 1562 w83627hf_read_value(data,
1592 W83781D_REG_FAN_MIN(i)); 1563 W83627HF_REG_FAN_MIN(i));
1593 } 1564 }
1594 for (i = 0; i <= 2; i++) { 1565 for (i = 0; i <= 2; i++) {
1595 u8 tmp = w83627hf_read_value(data, 1566 u8 tmp = w83627hf_read_value(data,
@@ -1616,25 +1587,13 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev)
1616 break; 1587 break;
1617 } 1588 }
1618 } 1589 }
1619 1590 for (i = 0; i < num_temps; i++) {
1620 data->temp = w83627hf_read_value(data, W83781D_REG_TEMP(1)); 1591 data->temp[i] = w83627hf_read_value(
1621 data->temp_max = 1592 data, w83627hf_reg_temp[i]);
1622 w83627hf_read_value(data, W83781D_REG_TEMP_OVER(1)); 1593 data->temp_max[i] = w83627hf_read_value(
1623 data->temp_max_hyst = 1594 data, w83627hf_reg_temp_over[i]);
1624 w83627hf_read_value(data, W83781D_REG_TEMP_HYST(1)); 1595 data->temp_max_hyst[i] = w83627hf_read_value(
1625 data->temp_add[0] = 1596 data, w83627hf_reg_temp_hyst[i]);
1626 w83627hf_read_value(data, W83781D_REG_TEMP(2));
1627 data->temp_max_add[0] =
1628 w83627hf_read_value(data, W83781D_REG_TEMP_OVER(2));
1629 data->temp_max_hyst_add[0] =
1630 w83627hf_read_value(data, W83781D_REG_TEMP_HYST(2));
1631 if (data->type != w83697hf) {
1632 data->temp_add[1] =
1633 w83627hf_read_value(data, W83781D_REG_TEMP(3));
1634 data->temp_max_add[1] =
1635 w83627hf_read_value(data, W83781D_REG_TEMP_OVER(3));
1636 data->temp_max_hyst_add[1] =
1637 w83627hf_read_value(data, W83781D_REG_TEMP_HYST(3));
1638 } 1597 }
1639 1598
1640 w83627hf_update_fan_div(data); 1599 w83627hf_update_fan_div(data);
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index a6a1edfe7614..e0fa7520400d 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -1122,12 +1122,13 @@ w83781d_create_files(struct device *dev, int kind, int is_isa)
1122 &sensor_dev_attr_temp3_beep.dev_attr))) 1122 &sensor_dev_attr_temp3_beep.dev_attr)))
1123 return err; 1123 return err;
1124 1124
1125 if (kind != w83781d) 1125 if (kind != w83781d) {
1126 err = sysfs_chmod_file(&dev->kobj, 1126 err = sysfs_chmod_file(&dev->kobj,
1127 &sensor_dev_attr_temp3_alarm.dev_attr.attr, 1127 &sensor_dev_attr_temp3_alarm.dev_attr.attr,
1128 S_IRUGO | S_IWUSR); 1128 S_IRUGO | S_IWUSR);
1129 if (err) 1129 if (err)
1130 return err; 1130 return err;
1131 }
1131 } 1132 }
1132 1133
1133 if (kind != w83781d && kind != as99127f) { 1134 if (kind != w83781d && kind != as99127f) {
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index d1e8df187222..e445fe6e4ba9 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -203,10 +203,6 @@ config BLK_DEV_IDECD
203 CD-ROM drive, you can say N to all other CD-ROM options, but be sure 203 CD-ROM drive, you can say N to all other CD-ROM options, but be sure
204 to say Y or M to "ISO 9660 CD-ROM file system support". 204 to say Y or M to "ISO 9660 CD-ROM file system support".
205 205
206 Note that older versions of LILO (LInux LOader) cannot properly deal
207 with IDE/ATAPI CD-ROMs, so install LILO 16 or higher, available from
208 <http://lilo.go.dyndns.org/>.
209
210 To compile this driver as a module, choose M here: the 206 To compile this driver as a module, choose M here: the
211 module will be called ide-cd. 207 module will be called ide-cd.
212 208
diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c
index e196aefa2070..7f5bc2ee6c7e 100644
--- a/drivers/ide/cris/ide-cris.c
+++ b/drivers/ide/cris/ide-cris.c
@@ -748,8 +748,7 @@ static void cris_set_dma_mode(ide_drive_t *drive, const u8 speed)
748 hold = ATA_DMA2_HOLD; 748 hold = ATA_DMA2_HOLD;
749 break; 749 break;
750 default: 750 default:
751 BUG(); 751 return;
752 break;
753 } 752 }
754 753
755 if (speed >= XFER_UDMA_0) 754 if (speed >= XFER_UDMA_0)
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 755011827afa..db22d1ff4e55 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -885,7 +885,6 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive,
885 return do_rw_taskfile(drive, args); 885 return do_rw_taskfile(drive, args);
886 } else if (rq->cmd_type == REQ_TYPE_ATA_TASK) { 886 } else if (rq->cmd_type == REQ_TYPE_ATA_TASK) {
887 u8 *args = rq->buffer; 887 u8 *args = rq->buffer;
888 u8 sel;
889 888
890 if (!args) 889 if (!args)
891 goto done; 890 goto done;
@@ -903,10 +902,7 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive,
903 hwif->OUTB(args[3], IDE_SECTOR_REG); 902 hwif->OUTB(args[3], IDE_SECTOR_REG);
904 hwif->OUTB(args[4], IDE_LCYL_REG); 903 hwif->OUTB(args[4], IDE_LCYL_REG);
905 hwif->OUTB(args[5], IDE_HCYL_REG); 904 hwif->OUTB(args[5], IDE_HCYL_REG);
906 sel = (args[6] & ~0x10); 905 hwif->OUTB((args[6] & 0xEF)|drive->select.all, IDE_SELECT_REG);
907 if (drive->select.b.unit)
908 sel |= 0x10;
909 hwif->OUTB(sel, IDE_SELECT_REG);
910 ide_cmd(drive, args[0], args[2], &drive_cmd_intr); 906 ide_cmd(drive, args[0], args[2], &drive_cmd_intr);
911 return ide_started; 907 return ide_started;
912 } else if (rq->cmd_type == REQ_TYPE_ATA_CMD) { 908 } else if (rq->cmd_type == REQ_TYPE_ATA_CMD) {
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index af86433baede..1609b8604f56 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -514,6 +514,7 @@ static u8 ide_dump_ata_status(ide_drive_t *drive, const char *msg, u8 stat)
514 if (drive->addressing == 1) { 514 if (drive->addressing == 1) {
515 __u64 sectors = 0; 515 __u64 sectors = 0;
516 u32 low = 0, high = 0; 516 u32 low = 0, high = 0;
517 hwif->OUTB(drive->ctl&~0x80, IDE_CONTROL_REG);
517 low = ide_read_24(drive); 518 low = ide_read_24(drive);
518 hwif->OUTB(drive->ctl|0x80, IDE_CONTROL_REG); 519 hwif->OUTB(drive->ctl|0x80, IDE_CONTROL_REG);
519 high = ide_read_24(drive); 520 high = ide_read_24(drive);
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c
index ea0143ef5fe5..51fca441c294 100644
--- a/drivers/ide/pci/cmd64x.c
+++ b/drivers/ide/pci/cmd64x.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/cmd64x.c Version 1.50 May 10, 2007 2 * linux/drivers/ide/pci/cmd64x.c Version 1.51 Nov 8, 2007
3 * 3 *
4 * cmd64x.c: Enable interrupts at initialization time on Ultra/PCI machines. 4 * cmd64x.c: Enable interrupts at initialization time on Ultra/PCI machines.
5 * Due to massive hardware bugs, UltraDMA is only supported 5 * Due to massive hardware bugs, UltraDMA is only supported
@@ -339,7 +339,8 @@ static int cmd648_ide_dma_end (ide_drive_t *drive)
339 u8 mrdmode = inb(hwif->dma_master + 0x01); 339 u8 mrdmode = inb(hwif->dma_master + 0x01);
340 340
341 /* clear the interrupt bit */ 341 /* clear the interrupt bit */
342 outb(mrdmode | irq_mask, hwif->dma_master + 0x01); 342 outb((mrdmode & ~(MRDMODE_INTR_CH0 | MRDMODE_INTR_CH1)) | irq_mask,
343 hwif->dma_master + 0x01);
343 344
344 return err; 345 return err;
345} 346}
diff --git a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c
index 599408952bd4..547690395eee 100644
--- a/drivers/ide/pci/cs5530.c
+++ b/drivers/ide/pci/cs5530.c
@@ -117,8 +117,7 @@ static void cs5530_set_dma_mode(ide_drive_t *drive, const u8 mode)
117 case XFER_MW_DMA_1: timings = 0x00012121; break; 117 case XFER_MW_DMA_1: timings = 0x00012121; break;
118 case XFER_MW_DMA_2: timings = 0x00002020; break; 118 case XFER_MW_DMA_2: timings = 0x00002020; break;
119 default: 119 default:
120 BUG(); 120 return;
121 break;
122 } 121 }
123 basereg = CS5530_BASEREG(drive->hwif); 122 basereg = CS5530_BASEREG(drive->hwif);
124 reg = inl(basereg + 4); /* get drive0 config register */ 123 reg = inl(basereg + 4); /* get drive0 config register */
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index 5c9975435319..99b7d763b6c7 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -653,8 +653,7 @@ static const struct ide_port_info it821x_chipsets[] __devinitdata = {
653 653
654static int __devinit it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id) 654static int __devinit it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
655{ 655{
656 ide_setup_pci_device(dev, &it821x_chipsets[id->driver_data]); 656 return ide_setup_pci_device(dev, &it821x_chipsets[id->driver_data]);
657 return 0;
658} 657}
659 658
660static const struct pci_device_id it821x_pci_tbl[] = { 659static const struct pci_device_id it821x_pci_tbl[] = {
diff --git a/drivers/ide/pci/jmicron.c b/drivers/ide/pci/jmicron.c
index bdf64d997708..0083eaf89c77 100644
--- a/drivers/ide/pci/jmicron.c
+++ b/drivers/ide/pci/jmicron.c
@@ -139,8 +139,7 @@ static const struct ide_port_info jmicron_chipset __devinitdata = {
139 139
140static int __devinit jmicron_init_one(struct pci_dev *dev, const struct pci_device_id *id) 140static int __devinit jmicron_init_one(struct pci_dev *dev, const struct pci_device_id *id)
141{ 141{
142 ide_setup_pci_device(dev, &jmicron_chipset); 142 return ide_setup_pci_device(dev, &jmicron_chipset);
143 return 0;
144} 143}
145 144
146/* All JMB PATA controllers have and will continue to have the same 145/* All JMB PATA controllers have and will continue to have the same
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c
index 0a7b3202066d..707d5ff66b03 100644
--- a/drivers/ide/pci/sc1200.c
+++ b/drivers/ide/pci/sc1200.c
@@ -186,8 +186,7 @@ static void sc1200_set_dma_mode(ide_drive_t *drive, const u8 mode)
186 } 186 }
187 break; 187 break;
188 default: 188 default:
189 BUG(); 189 return;
190 break;
191 } 190 }
192 191
193 if (unit == 0) { /* are we configuring drive0? */ 192 if (unit == 0) { /* are we configuring drive0? */
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c
index 6b7bb53acefd..f6e2ab3dd166 100644
--- a/drivers/ide/pci/sis5513.c
+++ b/drivers/ide/pci/sis5513.c
@@ -356,7 +356,6 @@ static void sis_set_dma_mode(ide_drive_t *drive, const u8 speed)
356 sis_program_timings(drive, speed); 356 sis_program_timings(drive, speed);
357 break; 357 break;
358 default: 358 default:
359 BUG();
360 break; 359 break;
361 } 360 }
362} 361}
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 816b5311dad6..5afdfef7264c 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1138,6 +1138,7 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
1138 hwif->drives[0].autotune = IDE_TUNE_AUTO; 1138 hwif->drives[0].autotune = IDE_TUNE_AUTO;
1139 hwif->drives[1].autotune = IDE_TUNE_AUTO; 1139 hwif->drives[1].autotune = IDE_TUNE_AUTO;
1140 hwif->host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA | 1140 hwif->host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA |
1141 IDE_HFLAG_PIO_NO_DOWNGRADE |
1141 IDE_HFLAG_POST_SET_MODE; 1142 IDE_HFLAG_POST_SET_MODE;
1142 hwif->pio_mask = ATA_PIO4; 1143 hwif->pio_mask = ATA_PIO4;
1143 hwif->set_pio_mode = pmac_ide_set_pio_mode; 1144 hwif->set_pio_mode = pmac_ide_set_pio_mode;
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index 02d14bf85ab2..25fd09053220 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -7,11 +7,6 @@
7 * May be copied or modified under the terms of the GNU General Public License 7 * May be copied or modified under the terms of the GNU General Public License
8 */ 8 */
9 9
10/*
11 * This module provides support for automatic detection and
12 * configuration of all PCI IDE interfaces present in a system.
13 */
14
15#include <linux/module.h> 10#include <linux/module.h>
16#include <linux/types.h> 11#include <linux/types.h>
17#include <linux/kernel.h> 12#include <linux/kernel.h>
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c
index f0c777589374..b5436ca92e68 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_provider.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c
@@ -1000,6 +1000,7 @@ static int iwch_query_device(struct ib_device *ibdev,
1000 props->max_sge = dev->attr.max_sge_per_wr; 1000 props->max_sge = dev->attr.max_sge_per_wr;
1001 props->max_sge_rd = 1; 1001 props->max_sge_rd = 1;
1002 props->max_qp_rd_atom = dev->attr.max_rdma_reads_per_qp; 1002 props->max_qp_rd_atom = dev->attr.max_rdma_reads_per_qp;
1003 props->max_qp_init_rd_atom = dev->attr.max_rdma_reads_per_qp;
1003 props->max_cq = dev->attr.max_cqs; 1004 props->max_cq = dev->attr.max_cqs;
1004 props->max_cqe = dev->attr.max_cqes_per_cq; 1005 props->max_cqe = dev->attr.max_cqes_per_cq;
1005 props->max_mr = dev->attr.max_mem_regs; 1006 props->max_mr = dev->attr.max_mem_regs;
diff --git a/drivers/infiniband/hw/ehca/ehca_av.c b/drivers/infiniband/hw/ehca/ehca_av.c
index 97d108634c58..453eb995c1d4 100644
--- a/drivers/infiniband/hw/ehca/ehca_av.c
+++ b/drivers/infiniband/hw/ehca/ehca_av.c
@@ -50,6 +50,38 @@
50 50
51static struct kmem_cache *av_cache; 51static struct kmem_cache *av_cache;
52 52
53int ehca_calc_ipd(struct ehca_shca *shca, int port,
54 enum ib_rate path_rate, u32 *ipd)
55{
56 int path = ib_rate_to_mult(path_rate);
57 int link, ret;
58 struct ib_port_attr pa;
59
60 if (path_rate == IB_RATE_PORT_CURRENT) {
61 *ipd = 0;
62 return 0;
63 }
64
65 if (unlikely(path < 0)) {
66 ehca_err(&shca->ib_device, "Invalid static rate! path_rate=%x",
67 path_rate);
68 return -EINVAL;
69 }
70
71 ret = ehca_query_port(&shca->ib_device, port, &pa);
72 if (unlikely(ret < 0)) {
73 ehca_err(&shca->ib_device, "Failed to query port ret=%i", ret);
74 return ret;
75 }
76
77 link = ib_width_enum_to_int(pa.active_width) * pa.active_speed;
78
79 /* IPD = round((link / path) - 1) */
80 *ipd = ((link + (path >> 1)) / path) - 1;
81
82 return 0;
83}
84
53struct ib_ah *ehca_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr) 85struct ib_ah *ehca_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
54{ 86{
55 int ret; 87 int ret;
@@ -69,15 +101,13 @@ struct ib_ah *ehca_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
69 av->av.slid_path_bits = ah_attr->src_path_bits; 101 av->av.slid_path_bits = ah_attr->src_path_bits;
70 102
71 if (ehca_static_rate < 0) { 103 if (ehca_static_rate < 0) {
72 int ah_mult = ib_rate_to_mult(ah_attr->static_rate); 104 u32 ipd;
73 int ehca_mult = 105 if (ehca_calc_ipd(shca, ah_attr->port_num,
74 ib_rate_to_mult(shca->sport[ah_attr->port_num].rate ); 106 ah_attr->static_rate, &ipd)) {
75 107 ret = -EINVAL;
76 if (ah_mult >= ehca_mult) 108 goto create_ah_exit1;
77 av->av.ipd = 0; 109 }
78 else 110 av->av.ipd = ipd;
79 av->av.ipd = (ah_mult > 0) ?
80 ((ehca_mult - 1) / ah_mult) : 0;
81 } else 111 } else
82 av->av.ipd = ehca_static_rate; 112 av->av.ipd = ehca_static_rate;
83 113
diff --git a/drivers/infiniband/hw/ehca/ehca_classes.h b/drivers/infiniband/hw/ehca/ehca_classes.h
index 2d660ae189e5..87f12d4312a7 100644
--- a/drivers/infiniband/hw/ehca/ehca_classes.h
+++ b/drivers/infiniband/hw/ehca/ehca_classes.h
@@ -95,7 +95,6 @@ struct ehca_sma_attr {
95struct ehca_sport { 95struct ehca_sport {
96 struct ib_cq *ibcq_aqp1; 96 struct ib_cq *ibcq_aqp1;
97 struct ib_qp *ibqp_aqp1; 97 struct ib_qp *ibqp_aqp1;
98 enum ib_rate rate;
99 enum ib_port_state port_state; 98 enum ib_port_state port_state;
100 struct ehca_sma_attr saved_attr; 99 struct ehca_sma_attr saved_attr;
101}; 100};
diff --git a/drivers/infiniband/hw/ehca/ehca_hca.c b/drivers/infiniband/hw/ehca/ehca_hca.c
index 15806d140461..5bd7b591987e 100644
--- a/drivers/infiniband/hw/ehca/ehca_hca.c
+++ b/drivers/infiniband/hw/ehca/ehca_hca.c
@@ -151,7 +151,6 @@ int ehca_query_port(struct ib_device *ibdev,
151 } 151 }
152 152
153 memset(props, 0, sizeof(struct ib_port_attr)); 153 memset(props, 0, sizeof(struct ib_port_attr));
154 props->state = rblock->state;
155 154
156 switch (rblock->max_mtu) { 155 switch (rblock->max_mtu) {
157 case 0x1: 156 case 0x1:
@@ -188,11 +187,20 @@ int ehca_query_port(struct ib_device *ibdev,
188 props->subnet_timeout = rblock->subnet_timeout; 187 props->subnet_timeout = rblock->subnet_timeout;
189 props->init_type_reply = rblock->init_type_reply; 188 props->init_type_reply = rblock->init_type_reply;
190 189
191 props->active_width = IB_WIDTH_12X; 190 if (rblock->state && rblock->phys_width) {
192 props->active_speed = 0x1; 191 props->phys_state = rblock->phys_pstate;
193 192 props->state = rblock->phys_state;
194 /* at the moment (logical) link state is always LINK_UP */ 193 props->active_width = rblock->phys_width;
195 props->phys_state = 0x5; 194 props->active_speed = rblock->phys_speed;
195 } else {
196 /* old firmware releases don't report physical
197 * port info, so use default values
198 */
199 props->phys_state = 5;
200 props->state = rblock->state;
201 props->active_width = IB_WIDTH_12X;
202 props->active_speed = 0x1;
203 }
196 204
197query_port1: 205query_port1:
198 ehca_free_fw_ctrlblock(rblock); 206 ehca_free_fw_ctrlblock(rblock);
diff --git a/drivers/infiniband/hw/ehca/ehca_iverbs.h b/drivers/infiniband/hw/ehca/ehca_iverbs.h
index dce503bb7d6b..5485799cdc8d 100644
--- a/drivers/infiniband/hw/ehca/ehca_iverbs.h
+++ b/drivers/infiniband/hw/ehca/ehca_iverbs.h
@@ -189,6 +189,9 @@ int ehca_mmap(struct ib_ucontext *context, struct vm_area_struct *vma);
189 189
190void ehca_poll_eqs(unsigned long data); 190void ehca_poll_eqs(unsigned long data);
191 191
192int ehca_calc_ipd(struct ehca_shca *shca, int port,
193 enum ib_rate path_rate, u32 *ipd);
194
192#ifdef CONFIG_PPC_64K_PAGES 195#ifdef CONFIG_PPC_64K_PAGES
193void *ehca_alloc_fw_ctrlblock(gfp_t flags); 196void *ehca_alloc_fw_ctrlblock(gfp_t flags);
194void ehca_free_fw_ctrlblock(void *ptr); 197void ehca_free_fw_ctrlblock(void *ptr);
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
index c6cd38c5321f..90d4334179bf 100644
--- a/drivers/infiniband/hw/ehca/ehca_main.c
+++ b/drivers/infiniband/hw/ehca/ehca_main.c
@@ -327,9 +327,6 @@ static int ehca_sense_attributes(struct ehca_shca *shca)
327 shca->hw_level = ehca_hw_level; 327 shca->hw_level = ehca_hw_level;
328 ehca_gen_dbg(" ... hardware level=%x", shca->hw_level); 328 ehca_gen_dbg(" ... hardware level=%x", shca->hw_level);
329 329
330 shca->sport[0].rate = IB_RATE_30_GBPS;
331 shca->sport[1].rate = IB_RATE_30_GBPS;
332
333 shca->hca_cap = rblock->hca_cap_indicators; 330 shca->hca_cap = rblock->hca_cap_indicators;
334 ehca_gen_dbg(" ... HCA capabilities:"); 331 ehca_gen_dbg(" ... HCA capabilities:");
335 for (i = 0; i < ARRAY_SIZE(hca_cap_descr); i++) 332 for (i = 0; i < ARRAY_SIZE(hca_cap_descr); i++)
diff --git a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c
index de182648b282..2e3e6547cb78 100644
--- a/drivers/infiniband/hw/ehca/ehca_qp.c
+++ b/drivers/infiniband/hw/ehca/ehca_qp.c
@@ -1196,10 +1196,6 @@ static int internal_modify_qp(struct ib_qp *ibqp,
1196 update_mask |= EHCA_BMASK_SET(MQPCB_MASK_QKEY, 1); 1196 update_mask |= EHCA_BMASK_SET(MQPCB_MASK_QKEY, 1);
1197 } 1197 }
1198 if (attr_mask & IB_QP_AV) { 1198 if (attr_mask & IB_QP_AV) {
1199 int ah_mult = ib_rate_to_mult(attr->ah_attr.static_rate);
1200 int ehca_mult = ib_rate_to_mult(shca->sport[my_qp->
1201 init_attr.port_num].rate);
1202
1203 mqpcb->dlid = attr->ah_attr.dlid; 1199 mqpcb->dlid = attr->ah_attr.dlid;
1204 update_mask |= EHCA_BMASK_SET(MQPCB_MASK_DLID, 1); 1200 update_mask |= EHCA_BMASK_SET(MQPCB_MASK_DLID, 1);
1205 mqpcb->source_path_bits = attr->ah_attr.src_path_bits; 1201 mqpcb->source_path_bits = attr->ah_attr.src_path_bits;
@@ -1207,11 +1203,12 @@ static int internal_modify_qp(struct ib_qp *ibqp,
1207 mqpcb->service_level = attr->ah_attr.sl; 1203 mqpcb->service_level = attr->ah_attr.sl;
1208 update_mask |= EHCA_BMASK_SET(MQPCB_MASK_SERVICE_LEVEL, 1); 1204 update_mask |= EHCA_BMASK_SET(MQPCB_MASK_SERVICE_LEVEL, 1);
1209 1205
1210 if (ah_mult < ehca_mult) 1206 if (ehca_calc_ipd(shca, my_qp->init_attr.port_num,
1211 mqpcb->max_static_rate = (ah_mult > 0) ? 1207 attr->ah_attr.static_rate,
1212 ((ehca_mult - 1) / ah_mult) : 0; 1208 &mqpcb->max_static_rate)) {
1213 else 1209 ret = -EINVAL;
1214 mqpcb->max_static_rate = 0; 1210 goto modify_qp_exit2;
1211 }
1215 update_mask |= EHCA_BMASK_SET(MQPCB_MASK_MAX_STATIC_RATE, 1); 1212 update_mask |= EHCA_BMASK_SET(MQPCB_MASK_MAX_STATIC_RATE, 1);
1216 1213
1217 /* 1214 /*
@@ -1280,10 +1277,6 @@ static int internal_modify_qp(struct ib_qp *ibqp,
1280 (MQPCB_MASK_RDMA_ATOMIC_OUTST_DEST_QP, 1); 1277 (MQPCB_MASK_RDMA_ATOMIC_OUTST_DEST_QP, 1);
1281 } 1278 }
1282 if (attr_mask & IB_QP_ALT_PATH) { 1279 if (attr_mask & IB_QP_ALT_PATH) {
1283 int ah_mult = ib_rate_to_mult(attr->alt_ah_attr.static_rate);
1284 int ehca_mult = ib_rate_to_mult(
1285 shca->sport[my_qp->init_attr.port_num].rate);
1286
1287 if (attr->alt_port_num < 1 1280 if (attr->alt_port_num < 1
1288 || attr->alt_port_num > shca->num_ports) { 1281 || attr->alt_port_num > shca->num_ports) {
1289 ret = -EINVAL; 1282 ret = -EINVAL;
@@ -1309,10 +1302,12 @@ static int internal_modify_qp(struct ib_qp *ibqp,
1309 mqpcb->source_path_bits_al = attr->alt_ah_attr.src_path_bits; 1302 mqpcb->source_path_bits_al = attr->alt_ah_attr.src_path_bits;
1310 mqpcb->service_level_al = attr->alt_ah_attr.sl; 1303 mqpcb->service_level_al = attr->alt_ah_attr.sl;
1311 1304
1312 if (ah_mult > 0 && ah_mult < ehca_mult) 1305 if (ehca_calc_ipd(shca, my_qp->init_attr.port_num,
1313 mqpcb->max_static_rate_al = (ehca_mult - 1) / ah_mult; 1306 attr->alt_ah_attr.static_rate,
1314 else 1307 &mqpcb->max_static_rate_al)) {
1315 mqpcb->max_static_rate_al = 0; 1308 ret = -EINVAL;
1309 goto modify_qp_exit2;
1310 }
1316 1311
1317 /* OpenIB doesn't support alternate retry counts - copy them */ 1312 /* OpenIB doesn't support alternate retry counts - copy them */
1318 mqpcb->retry_count_al = mqpcb->retry_count; 1313 mqpcb->retry_count_al = mqpcb->retry_count;
diff --git a/drivers/infiniband/hw/ehca/hipz_hw.h b/drivers/infiniband/hw/ehca/hipz_hw.h
index d9739e554515..485b8400359e 100644
--- a/drivers/infiniband/hw/ehca/hipz_hw.h
+++ b/drivers/infiniband/hw/ehca/hipz_hw.h
@@ -402,7 +402,11 @@ struct hipz_query_port {
402 u64 max_msg_sz; 402 u64 max_msg_sz;
403 u32 max_mtu; 403 u32 max_mtu;
404 u32 vl_cap; 404 u32 vl_cap;
405 u8 reserved2[1900]; 405 u32 phys_pstate;
406 u32 phys_state;
407 u32 phys_speed;
408 u32 phys_width;
409 u8 reserved2[1884];
406 u64 guid_entries[255]; 410 u64 guid_entries[255];
407} __attribute__ ((packed)); 411} __attribute__ ((packed));
408 412
diff --git a/drivers/infiniband/hw/ipath/ipath_cq.c b/drivers/infiniband/hw/ipath/ipath_cq.c
index 645ed71fd797..08d8ae148cd0 100644
--- a/drivers/infiniband/hw/ipath/ipath_cq.c
+++ b/drivers/infiniband/hw/ipath/ipath_cq.c
@@ -404,7 +404,7 @@ int ipath_resize_cq(struct ib_cq *ibcq, int cqe, struct ib_udata *udata)
404 404
405 ret = ib_copy_to_udata(udata, &offset, sizeof(offset)); 405 ret = ib_copy_to_udata(udata, &offset, sizeof(offset));
406 if (ret) 406 if (ret)
407 goto bail; 407 goto bail_free;
408 } 408 }
409 409
410 spin_lock_irq(&cq->lock); 410 spin_lock_irq(&cq->lock);
@@ -424,10 +424,8 @@ int ipath_resize_cq(struct ib_cq *ibcq, int cqe, struct ib_udata *udata)
424 else 424 else
425 n = head - tail; 425 n = head - tail;
426 if (unlikely((u32)cqe < n)) { 426 if (unlikely((u32)cqe < n)) {
427 spin_unlock_irq(&cq->lock);
428 vfree(wc);
429 ret = -EOVERFLOW; 427 ret = -EOVERFLOW;
430 goto bail; 428 goto bail_unlock;
431 } 429 }
432 for (n = 0; tail != head; n++) { 430 for (n = 0; tail != head; n++) {
433 if (cq->ip) 431 if (cq->ip)
@@ -459,7 +457,12 @@ int ipath_resize_cq(struct ib_cq *ibcq, int cqe, struct ib_udata *udata)
459 } 457 }
460 458
461 ret = 0; 459 ret = 0;
460 goto bail;
462 461
462bail_unlock:
463 spin_unlock_irq(&cq->lock);
464bail_free:
465 vfree(wc);
463bail: 466bail:
464 return ret; 467 return ret;
465} 468}
diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
index 5c29b2bfea17..120a61b03bc4 100644
--- a/drivers/infiniband/hw/ipath/ipath_rc.c
+++ b/drivers/infiniband/hw/ipath/ipath_rc.c
@@ -959,8 +959,9 @@ static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode,
959 /* If this is a partial ACK, reset the retransmit timer. */ 959 /* If this is a partial ACK, reset the retransmit timer. */
960 if (qp->s_last != qp->s_tail) { 960 if (qp->s_last != qp->s_tail) {
961 spin_lock(&dev->pending_lock); 961 spin_lock(&dev->pending_lock);
962 list_add_tail(&qp->timerwait, 962 if (list_empty(&qp->timerwait))
963 &dev->pending[dev->pending_index]); 963 list_add_tail(&qp->timerwait,
964 &dev->pending[dev->pending_index]);
964 spin_unlock(&dev->pending_lock); 965 spin_unlock(&dev->pending_lock);
965 /* 966 /*
966 * If we get a partial ACK for a resent operation, 967 * If we get a partial ACK for a resent operation,
diff --git a/drivers/isdn/sc/card.h b/drivers/isdn/sc/card.h
index 5992f63c383e..0120bcf88311 100644
--- a/drivers/isdn/sc/card.h
+++ b/drivers/isdn/sc/card.h
@@ -109,7 +109,7 @@ void memcpy_fromshmem(int card, void *dest, const void *src, size_t n);
109int get_card_from_id(int driver); 109int get_card_from_id(int driver);
110int indicate_status(int card, int event, ulong Channel, char *Data); 110int indicate_status(int card, int event, ulong Channel, char *Data);
111irqreturn_t interrupt_handler(int interrupt, void *cardptr); 111irqreturn_t interrupt_handler(int interrupt, void *cardptr);
112int sndpkt(int devId, int channel, struct sk_buff *data); 112int sndpkt(int devId, int channel, int ack, struct sk_buff *data);
113void rcvpkt(int card, RspMessage *rcvmsg); 113void rcvpkt(int card, RspMessage *rcvmsg);
114int command(isdn_ctrl *cmd); 114int command(isdn_ctrl *cmd);
115int reset(int card); 115int reset(int card);
diff --git a/drivers/isdn/sc/packet.c b/drivers/isdn/sc/packet.c
index 92016a2608e9..5ff6ae868440 100644
--- a/drivers/isdn/sc/packet.c
+++ b/drivers/isdn/sc/packet.c
@@ -20,7 +20,7 @@
20#include "message.h" 20#include "message.h"
21#include "card.h" 21#include "card.h"
22 22
23int sndpkt(int devId, int channel, struct sk_buff *data) 23int sndpkt(int devId, int channel, int ack, struct sk_buff *data)
24{ 24{
25 LLData ReqLnkWrite; 25 LLData ReqLnkWrite;
26 int status; 26 int status;
diff --git a/drivers/isdn/sc/shmem.c b/drivers/isdn/sc/shmem.c
index e0331e0094f1..712220cef139 100644
--- a/drivers/isdn/sc/shmem.c
+++ b/drivers/isdn/sc/shmem.c
@@ -50,7 +50,7 @@ void memcpy_toshmem(int card, void *dest, const void *src, size_t n)
50 50
51 outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80, 51 outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80,
52 sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); 52 sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]);
53 memcpy_toio(sc_adapter[card]->rambase + dest_rem, src, n); 53 memcpy_toio((void __iomem *)(sc_adapter[card]->rambase + dest_rem), src, n);
54 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); 54 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags);
55 pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename, 55 pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename,
56 ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80); 56 ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80);
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index 729f1cd93606..7a6eead63a6b 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -494,6 +494,7 @@ static void init_vmcb(struct vmcb *vmcb)
494 */ 494 */
495 /* (1ULL << INTERCEPT_SELECTIVE_CR0) | */ 495 /* (1ULL << INTERCEPT_SELECTIVE_CR0) | */
496 (1ULL << INTERCEPT_CPUID) | 496 (1ULL << INTERCEPT_CPUID) |
497 (1ULL << INTERCEPT_INVD) |
497 (1ULL << INTERCEPT_HLT) | 498 (1ULL << INTERCEPT_HLT) |
498 (1ULL << INTERCEPT_INVLPGA) | 499 (1ULL << INTERCEPT_INVLPGA) |
499 (1ULL << INTERCEPT_IOIO_PROT) | 500 (1ULL << INTERCEPT_IOIO_PROT) |
@@ -507,6 +508,7 @@ static void init_vmcb(struct vmcb *vmcb)
507 (1ULL << INTERCEPT_STGI) | 508 (1ULL << INTERCEPT_STGI) |
508 (1ULL << INTERCEPT_CLGI) | 509 (1ULL << INTERCEPT_CLGI) |
509 (1ULL << INTERCEPT_SKINIT) | 510 (1ULL << INTERCEPT_SKINIT) |
511 (1ULL << INTERCEPT_WBINVD) |
510 (1ULL << INTERCEPT_MONITOR) | 512 (1ULL << INTERCEPT_MONITOR) |
511 (1ULL << INTERCEPT_MWAIT); 513 (1ULL << INTERCEPT_MWAIT);
512 514
@@ -561,6 +563,12 @@ static void svm_vcpu_reset(struct kvm_vcpu *vcpu)
561 struct vcpu_svm *svm = to_svm(vcpu); 563 struct vcpu_svm *svm = to_svm(vcpu);
562 564
563 init_vmcb(svm->vmcb); 565 init_vmcb(svm->vmcb);
566
567 if (vcpu->vcpu_id != 0) {
568 svm->vmcb->save.rip = 0;
569 svm->vmcb->save.cs.base = svm->vcpu.sipi_vector << 12;
570 svm->vmcb->save.cs.selector = svm->vcpu.sipi_vector << 8;
571 }
564} 572}
565 573
566static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, unsigned int id) 574static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, unsigned int id)
@@ -1241,6 +1249,7 @@ static int (*svm_exit_handlers[])(struct vcpu_svm *svm,
1241 [SVM_EXIT_VINTR] = interrupt_window_interception, 1249 [SVM_EXIT_VINTR] = interrupt_window_interception,
1242 /* [SVM_EXIT_CR0_SEL_WRITE] = emulate_on_interception, */ 1250 /* [SVM_EXIT_CR0_SEL_WRITE] = emulate_on_interception, */
1243 [SVM_EXIT_CPUID] = cpuid_interception, 1251 [SVM_EXIT_CPUID] = cpuid_interception,
1252 [SVM_EXIT_INVD] = emulate_on_interception,
1244 [SVM_EXIT_HLT] = halt_interception, 1253 [SVM_EXIT_HLT] = halt_interception,
1245 [SVM_EXIT_INVLPG] = emulate_on_interception, 1254 [SVM_EXIT_INVLPG] = emulate_on_interception,
1246 [SVM_EXIT_INVLPGA] = invalid_op_interception, 1255 [SVM_EXIT_INVLPGA] = invalid_op_interception,
@@ -1255,6 +1264,7 @@ static int (*svm_exit_handlers[])(struct vcpu_svm *svm,
1255 [SVM_EXIT_STGI] = invalid_op_interception, 1264 [SVM_EXIT_STGI] = invalid_op_interception,
1256 [SVM_EXIT_CLGI] = invalid_op_interception, 1265 [SVM_EXIT_CLGI] = invalid_op_interception,
1257 [SVM_EXIT_SKINIT] = invalid_op_interception, 1266 [SVM_EXIT_SKINIT] = invalid_op_interception,
1267 [SVM_EXIT_WBINVD] = emulate_on_interception,
1258 [SVM_EXIT_MONITOR] = invalid_op_interception, 1268 [SVM_EXIT_MONITOR] = invalid_op_interception,
1259 [SVM_EXIT_MWAIT] = invalid_op_interception, 1269 [SVM_EXIT_MWAIT] = invalid_op_interception,
1260}; 1270};
@@ -1579,10 +1589,6 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1579#endif 1589#endif
1580 : "cc", "memory" ); 1590 : "cc", "memory" );
1581 1591
1582 local_irq_disable();
1583
1584 stgi();
1585
1586 if ((svm->vmcb->save.dr7 & 0xff)) 1592 if ((svm->vmcb->save.dr7 & 0xff))
1587 load_db_regs(svm->host_db_regs); 1593 load_db_regs(svm->host_db_regs);
1588 1594
@@ -1599,6 +1605,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1599 1605
1600 reload_tss(vcpu); 1606 reload_tss(vcpu);
1601 1607
1608 local_irq_disable();
1609
1610 stgi();
1611
1602 svm->next_rip = 0; 1612 svm->next_rip = 0;
1603} 1613}
1604 1614
diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c
index a6ace302e0cd..33b181451557 100644
--- a/drivers/kvm/x86_emulate.c
+++ b/drivers/kvm/x86_emulate.c
@@ -167,7 +167,7 @@ static u8 opcode_table[256] = {
167static u16 twobyte_table[256] = { 167static u16 twobyte_table[256] = {
168 /* 0x00 - 0x0F */ 168 /* 0x00 - 0x0F */
169 0, SrcMem | ModRM | DstReg, 0, 0, 0, 0, ImplicitOps, 0, 169 0, SrcMem | ModRM | DstReg, 0, 0, 0, 0, ImplicitOps, 0,
170 0, ImplicitOps, 0, 0, 0, ImplicitOps | ModRM, 0, 0, 170 ImplicitOps, ImplicitOps, 0, 0, 0, ImplicitOps | ModRM, 0, 0,
171 /* 0x10 - 0x1F */ 171 /* 0x10 - 0x1F */
172 0, 0, 0, 0, 0, 0, 0, 0, ImplicitOps | ModRM, 0, 0, 0, 0, 0, 0, 0, 172 0, 0, 0, 0, 0, 0, 0, 0, ImplicitOps | ModRM, 0, 0, 0, 0, 0, 0, 0,
173 /* 0x20 - 0x2F */ 173 /* 0x20 - 0x2F */
@@ -980,17 +980,6 @@ done_prefixes:
980 goto cannot_emulate; 980 goto cannot_emulate;
981 dst.val = (s32) src.val; 981 dst.val = (s32) src.val;
982 break; 982 break;
983 case 0x6a: /* push imm8 */
984 src.val = 0L;
985 src.val = insn_fetch(s8, 1, _eip);
986push:
987 dst.type = OP_MEM;
988 dst.bytes = op_bytes;
989 dst.val = src.val;
990 register_address_increment(_regs[VCPU_REGS_RSP], -op_bytes);
991 dst.ptr = (void *) register_address(ctxt->ss_base,
992 _regs[VCPU_REGS_RSP]);
993 break;
994 case 0x80 ... 0x83: /* Grp1 */ 983 case 0x80 ... 0x83: /* Grp1 */
995 switch (modrm_reg) { 984 switch (modrm_reg) {
996 case 0: 985 case 0:
@@ -1243,6 +1232,17 @@ special_insn:
1243 register_address_increment(_regs[VCPU_REGS_RSP], op_bytes); 1232 register_address_increment(_regs[VCPU_REGS_RSP], op_bytes);
1244 no_wb = 1; /* Disable writeback. */ 1233 no_wb = 1; /* Disable writeback. */
1245 break; 1234 break;
1235 case 0x6a: /* push imm8 */
1236 src.val = 0L;
1237 src.val = insn_fetch(s8, 1, _eip);
1238 push:
1239 dst.type = OP_MEM;
1240 dst.bytes = op_bytes;
1241 dst.val = src.val;
1242 register_address_increment(_regs[VCPU_REGS_RSP], -op_bytes);
1243 dst.ptr = (void *) register_address(ctxt->ss_base,
1244 _regs[VCPU_REGS_RSP]);
1245 break;
1246 case 0x6c: /* insb */ 1246 case 0x6c: /* insb */
1247 case 0x6d: /* insw/insd */ 1247 case 0x6d: /* insw/insd */
1248 if (kvm_emulate_pio_string(ctxt->vcpu, NULL, 1248 if (kvm_emulate_pio_string(ctxt->vcpu, NULL,
@@ -1532,6 +1532,8 @@ twobyte_special_insn:
1532 case 0x06: 1532 case 0x06:
1533 emulate_clts(ctxt->vcpu); 1533 emulate_clts(ctxt->vcpu);
1534 break; 1534 break;
1535 case 0x08: /* invd */
1536 break;
1535 case 0x09: /* wbinvd */ 1537 case 0x09: /* wbinvd */
1536 break; 1538 break;
1537 case 0x0d: /* GrpP (prefetch) */ 1539 case 0x0d: /* GrpP (prefetch) */
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c
index 8904f72f97c6..66f38722253a 100644
--- a/drivers/lguest/lguest_device.c
+++ b/drivers/lguest/lguest_device.c
@@ -200,7 +200,8 @@ static struct virtqueue *lg_find_vq(struct virtio_device *vdev,
200 200
201 /* Figure out how many pages the ring will take, and map that memory */ 201 /* Figure out how many pages the ring will take, and map that memory */
202 lvq->pages = lguest_map((unsigned long)lvq->config.pfn << PAGE_SHIFT, 202 lvq->pages = lguest_map((unsigned long)lvq->config.pfn << PAGE_SHIFT,
203 DIV_ROUND_UP(vring_size(lvq->config.num), 203 DIV_ROUND_UP(vring_size(lvq->config.num,
204 PAGE_SIZE),
204 PAGE_SIZE)); 205 PAGE_SIZE));
205 if (!lvq->pages) { 206 if (!lvq->pages) {
206 err = -ENOMEM; 207 err = -ENOMEM;
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index 9d716fa42cad..3b92a61ba8d2 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -184,7 +184,7 @@ static int initialize(struct file *file, const unsigned long __user *input)
184free_regs: 184free_regs:
185 free_page(lg->regs_page); 185 free_page(lg->regs_page);
186release_guest: 186release_guest:
187 memset(lg, 0, sizeof(*lg)); 187 kfree(lg);
188unlock: 188unlock:
189 mutex_unlock(&lguest_lock); 189 mutex_unlock(&lguest_lock);
190 return err; 190 return err;
diff --git a/drivers/macintosh/windfarm_core.c b/drivers/macintosh/windfarm_core.c
index 516d943227e2..075b4d99e354 100644
--- a/drivers/macintosh/windfarm_core.c
+++ b/drivers/macintosh/windfarm_core.c
@@ -94,7 +94,9 @@ static int wf_thread_func(void *data)
94 DBG("wf: thread started\n"); 94 DBG("wf: thread started\n");
95 95
96 set_freezable(); 96 set_freezable();
97 while(!kthread_should_stop()) { 97 while (!kthread_should_stop()) {
98 try_to_freeze();
99
98 if (time_after_eq(jiffies, next)) { 100 if (time_after_eq(jiffies, next)) {
99 wf_notify(WF_EVENT_TICK, NULL); 101 wf_notify(WF_EVENT_TICK, NULL);
100 if (wf_overtemp) { 102 if (wf_overtemp) {
@@ -116,12 +118,6 @@ static int wf_thread_func(void *data)
116 delay = next - jiffies; 118 delay = next - jiffies;
117 if (delay <= HZ) 119 if (delay <= HZ)
118 schedule_timeout_interruptible(delay); 120 schedule_timeout_interruptible(delay);
119
120 /* there should be no non-suspend signal, but oh well */
121 if (signal_pending(current) && !try_to_freeze()) {
122 printk(KERN_WARNING "windfarm: thread got sigl !\n");
123 break;
124 }
125 } 121 }
126 122
127 DBG("wf: thread stopped\n"); 123 DBG("wf: thread stopped\n");
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 7c426d07a555..1b1ef3130e6e 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1207,8 +1207,7 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect
1207 prepare_to_wait(&bitmap->overflow_wait, &__wait, 1207 prepare_to_wait(&bitmap->overflow_wait, &__wait,
1208 TASK_UNINTERRUPTIBLE); 1208 TASK_UNINTERRUPTIBLE);
1209 spin_unlock_irq(&bitmap->lock); 1209 spin_unlock_irq(&bitmap->lock);
1210 bitmap->mddev->queue 1210 blk_unplug(bitmap->mddev->queue);
1211 ->unplug_fn(bitmap->mddev->queue);
1212 schedule(); 1211 schedule();
1213 finish_wait(&bitmap->overflow_wait, &__wait); 1212 finish_wait(&bitmap->overflow_wait, &__wait);
1214 continue; 1213 continue;
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 5a7eb650181e..e298d8d11f24 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1000,8 +1000,7 @@ void dm_table_unplug_all(struct dm_table *t)
1000 struct dm_dev *dd = list_entry(d, struct dm_dev, list); 1000 struct dm_dev *dd = list_entry(d, struct dm_dev, list);
1001 struct request_queue *q = bdev_get_queue(dd->bdev); 1001 struct request_queue *q = bdev_get_queue(dd->bdev);
1002 1002
1003 if (q->unplug_fn) 1003 blk_unplug(q);
1004 q->unplug_fn(q);
1005 } 1004 }
1006} 1005}
1007 1006
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 56a11f6c127b..3dac1cfb8189 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -87,8 +87,7 @@ static void linear_unplug(struct request_queue *q)
87 87
88 for (i=0; i < mddev->raid_disks; i++) { 88 for (i=0; i < mddev->raid_disks; i++) {
89 struct request_queue *r_queue = bdev_get_queue(conf->disks[i].rdev->bdev); 89 struct request_queue *r_queue = bdev_get_queue(conf->disks[i].rdev->bdev);
90 if (r_queue->unplug_fn) 90 blk_unplug(r_queue);
91 r_queue->unplug_fn(r_queue);
92 } 91 }
93} 92}
94 93
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 808cd9549456..cef9ebd5a046 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5445,7 +5445,7 @@ void md_do_sync(mddev_t *mddev)
5445 * about not overloading the IO subsystem. (things like an 5445 * about not overloading the IO subsystem. (things like an
5446 * e2fsck being done on the RAID array should execute fast) 5446 * e2fsck being done on the RAID array should execute fast)
5447 */ 5447 */
5448 mddev->queue->unplug_fn(mddev->queue); 5448 blk_unplug(mddev->queue);
5449 cond_resched(); 5449 cond_resched();
5450 5450
5451 currspeed = ((unsigned long)(io_sectors-mddev->resync_mark_cnt))/2 5451 currspeed = ((unsigned long)(io_sectors-mddev->resync_mark_cnt))/2
@@ -5464,7 +5464,7 @@ void md_do_sync(mddev_t *mddev)
5464 * this also signals 'finished resyncing' to md_stop 5464 * this also signals 'finished resyncing' to md_stop
5465 */ 5465 */
5466 out: 5466 out:
5467 mddev->queue->unplug_fn(mddev->queue); 5467 blk_unplug(mddev->queue);
5468 5468
5469 wait_event(mddev->recovery_wait, !atomic_read(&mddev->recovery_active)); 5469 wait_event(mddev->recovery_wait, !atomic_read(&mddev->recovery_active));
5470 5470
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index b35731cceac6..eb631ebed686 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -125,8 +125,7 @@ static void unplug_slaves(mddev_t *mddev)
125 atomic_inc(&rdev->nr_pending); 125 atomic_inc(&rdev->nr_pending);
126 rcu_read_unlock(); 126 rcu_read_unlock();
127 127
128 if (r_queue->unplug_fn) 128 blk_unplug(r_queue);
129 r_queue->unplug_fn(r_queue);
130 129
131 rdev_dec_pending(rdev, mddev); 130 rdev_dec_pending(rdev, mddev);
132 rcu_read_lock(); 131 rcu_read_lock();
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index c111105fc2dc..f8e591708d1f 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -35,8 +35,7 @@ static void raid0_unplug(struct request_queue *q)
35 for (i=0; i<mddev->raid_disks; i++) { 35 for (i=0; i<mddev->raid_disks; i++) {
36 struct request_queue *r_queue = bdev_get_queue(devlist[i]->bdev); 36 struct request_queue *r_queue = bdev_get_queue(devlist[i]->bdev);
37 37
38 if (r_queue->unplug_fn) 38 blk_unplug(r_queue);
39 r_queue->unplug_fn(r_queue);
40 } 39 }
41} 40}
42 41
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 85478d6a9c1a..4a69c416e045 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -549,8 +549,7 @@ static void unplug_slaves(mddev_t *mddev)
549 atomic_inc(&rdev->nr_pending); 549 atomic_inc(&rdev->nr_pending);
550 rcu_read_unlock(); 550 rcu_read_unlock();
551 551
552 if (r_queue->unplug_fn) 552 blk_unplug(r_queue);
553 r_queue->unplug_fn(r_queue);
554 553
555 rdev_dec_pending(rdev, mddev); 554 rdev_dec_pending(rdev, mddev);
556 rcu_read_lock(); 555 rcu_read_lock();
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index fc6607acb6e4..5cdcc9386200 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -593,8 +593,7 @@ static void unplug_slaves(mddev_t *mddev)
593 atomic_inc(&rdev->nr_pending); 593 atomic_inc(&rdev->nr_pending);
594 rcu_read_unlock(); 594 rcu_read_unlock();
595 595
596 if (r_queue->unplug_fn) 596 blk_unplug(r_queue);
597 r_queue->unplug_fn(r_queue);
598 597
599 rdev_dec_pending(rdev, mddev); 598 rdev_dec_pending(rdev, mddev);
600 rcu_read_lock(); 599 rcu_read_lock();
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 82af3465a900..a5aad8cad843 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -688,7 +688,8 @@ ops_run_prexor(struct stripe_head *sh, struct dma_async_tx_descriptor *tx)
688} 688}
689 689
690static struct dma_async_tx_descriptor * 690static struct dma_async_tx_descriptor *
691ops_run_biodrain(struct stripe_head *sh, struct dma_async_tx_descriptor *tx) 691ops_run_biodrain(struct stripe_head *sh, struct dma_async_tx_descriptor *tx,
692 unsigned long pending)
692{ 693{
693 int disks = sh->disks; 694 int disks = sh->disks;
694 int pd_idx = sh->pd_idx, i; 695 int pd_idx = sh->pd_idx, i;
@@ -696,7 +697,7 @@ ops_run_biodrain(struct stripe_head *sh, struct dma_async_tx_descriptor *tx)
696 /* check if prexor is active which means only process blocks 697 /* check if prexor is active which means only process blocks
697 * that are part of a read-modify-write (Wantprexor) 698 * that are part of a read-modify-write (Wantprexor)
698 */ 699 */
699 int prexor = test_bit(STRIPE_OP_PREXOR, &sh->ops.pending); 700 int prexor = test_bit(STRIPE_OP_PREXOR, &pending);
700 701
701 pr_debug("%s: stripe %llu\n", __FUNCTION__, 702 pr_debug("%s: stripe %llu\n", __FUNCTION__,
702 (unsigned long long)sh->sector); 703 (unsigned long long)sh->sector);
@@ -773,7 +774,8 @@ static void ops_complete_write(void *stripe_head_ref)
773} 774}
774 775
775static void 776static void
776ops_run_postxor(struct stripe_head *sh, struct dma_async_tx_descriptor *tx) 777ops_run_postxor(struct stripe_head *sh, struct dma_async_tx_descriptor *tx,
778 unsigned long pending)
777{ 779{
778 /* kernel stack size limits the total number of disks */ 780 /* kernel stack size limits the total number of disks */
779 int disks = sh->disks; 781 int disks = sh->disks;
@@ -781,7 +783,7 @@ ops_run_postxor(struct stripe_head *sh, struct dma_async_tx_descriptor *tx)
781 783
782 int count = 0, pd_idx = sh->pd_idx, i; 784 int count = 0, pd_idx = sh->pd_idx, i;
783 struct page *xor_dest; 785 struct page *xor_dest;
784 int prexor = test_bit(STRIPE_OP_PREXOR, &sh->ops.pending); 786 int prexor = test_bit(STRIPE_OP_PREXOR, &pending);
785 unsigned long flags; 787 unsigned long flags;
786 dma_async_tx_callback callback; 788 dma_async_tx_callback callback;
787 789
@@ -808,7 +810,7 @@ ops_run_postxor(struct stripe_head *sh, struct dma_async_tx_descriptor *tx)
808 } 810 }
809 811
810 /* check whether this postxor is part of a write */ 812 /* check whether this postxor is part of a write */
811 callback = test_bit(STRIPE_OP_BIODRAIN, &sh->ops.pending) ? 813 callback = test_bit(STRIPE_OP_BIODRAIN, &pending) ?
812 ops_complete_write : ops_complete_postxor; 814 ops_complete_write : ops_complete_postxor;
813 815
814 /* 1/ if we prexor'd then the dest is reused as a source 816 /* 1/ if we prexor'd then the dest is reused as a source
@@ -896,12 +898,12 @@ static void raid5_run_ops(struct stripe_head *sh, unsigned long pending)
896 tx = ops_run_prexor(sh, tx); 898 tx = ops_run_prexor(sh, tx);
897 899
898 if (test_bit(STRIPE_OP_BIODRAIN, &pending)) { 900 if (test_bit(STRIPE_OP_BIODRAIN, &pending)) {
899 tx = ops_run_biodrain(sh, tx); 901 tx = ops_run_biodrain(sh, tx, pending);
900 overlap_clear++; 902 overlap_clear++;
901 } 903 }
902 904
903 if (test_bit(STRIPE_OP_POSTXOR, &pending)) 905 if (test_bit(STRIPE_OP_POSTXOR, &pending))
904 ops_run_postxor(sh, tx); 906 ops_run_postxor(sh, tx, pending);
905 907
906 if (test_bit(STRIPE_OP_CHECK, &pending)) 908 if (test_bit(STRIPE_OP_CHECK, &pending))
907 ops_run_check(sh); 909 ops_run_check(sh);
@@ -3186,8 +3188,7 @@ static void unplug_slaves(mddev_t *mddev)
3186 atomic_inc(&rdev->nr_pending); 3188 atomic_inc(&rdev->nr_pending);
3187 rcu_read_unlock(); 3189 rcu_read_unlock();
3188 3190
3189 if (r_queue->unplug_fn) 3191 blk_unplug(r_queue);
3190 r_queue->unplug_fn(r_queue);
3191 3192
3192 rdev_dec_pending(rdev, mddev); 3193 rdev_dec_pending(rdev, mddev);
3193 rcu_read_lock(); 3194 rcu_read_lock();
diff --git a/drivers/misc/ioc4.c b/drivers/misc/ioc4.c
index 6a5a05d1f392..05172d2613d6 100644
--- a/drivers/misc/ioc4.c
+++ b/drivers/misc/ioc4.c
@@ -244,10 +244,11 @@ ioc4_variant(struct ioc4_driver_data *idd)
244 idd->idd_pdev->bus->number == pdev->bus->number && 244 idd->idd_pdev->bus->number == pdev->bus->number &&
245 3 == PCI_SLOT(pdev->devfn)) 245 3 == PCI_SLOT(pdev->devfn))
246 found = 1; 246 found = 1;
247 pci_dev_put(pdev);
248 } while (pdev && !found); 247 } while (pdev && !found);
249 if (NULL != pdev) 248 if (NULL != pdev) {
249 pci_dev_put(pdev);
250 return IOC4_VARIANT_IO9; 250 return IOC4_VARIANT_IO9;
251 }
251 252
252 /* IO10: Look for a Vitesse VSC 7174 at the same bus and slot 3. */ 253 /* IO10: Look for a Vitesse VSC 7174 at the same bus and slot 3. */
253 pdev = NULL; 254 pdev = NULL;
@@ -258,10 +259,11 @@ ioc4_variant(struct ioc4_driver_data *idd)
258 idd->idd_pdev->bus->number == pdev->bus->number && 259 idd->idd_pdev->bus->number == pdev->bus->number &&
259 3 == PCI_SLOT(pdev->devfn)) 260 3 == PCI_SLOT(pdev->devfn))
260 found = 1; 261 found = 1;
261 pci_dev_put(pdev);
262 } while (pdev && !found); 262 } while (pdev && !found);
263 if (NULL != pdev) 263 if (NULL != pdev) {
264 pci_dev_put(pdev);
264 return IOC4_VARIANT_IO10; 265 return IOC4_VARIANT_IO10;
266 }
265 267
266 /* PCI-RT: No SCSI/SATA controller will be present */ 268 /* PCI-RT: No SCSI/SATA controller will be present */
267 return IOC4_VARIANT_PCI_RT; 269 return IOC4_VARIANT_PCI_RT;
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
index 9203a0b221b3..1b9c9b6da5b7 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -310,7 +310,7 @@ static void copy_sg(struct scatterlist *dst, unsigned int dst_len,
310 } 310 }
311 311
312 if (src_size == 0) { 312 if (src_size == 0) {
313 src_buf = sg_virt(dst); 313 src_buf = sg_virt(src);
314 src_size = src->length; 314 src_size = src->length;
315 } 315 }
316 316
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 6b80bf77a4ef..ff59d2e0475b 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1301,7 +1301,7 @@ static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot)
1301 1301
1302 if ((chip->quirks & SDHCI_QUIRK_BROKEN_DMA) && 1302 if ((chip->quirks & SDHCI_QUIRK_BROKEN_DMA) &&
1303 (host->flags & SDHCI_USE_DMA)) { 1303 (host->flags & SDHCI_USE_DMA)) {
1304 DBG("Disabling DMA as it is marked broken"); 1304 DBG("Disabling DMA as it is marked broken\n");
1305 host->flags &= ~SDHCI_USE_DMA; 1305 host->flags &= ~SDHCI_USE_DMA;
1306 } 1306 }
1307 1307
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 5f800a6dd978..e8d69b0adf90 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -136,10 +136,11 @@ config TUN
136 If you don't know what to use this for, you don't need it. 136 If you don't know what to use this for, you don't need it.
137 137
138config VETH 138config VETH
139 tristate "Virtual ethernet device" 139 tristate "Virtual ethernet pair device"
140 ---help--- 140 ---help---
141 The device is an ethernet tunnel. Devices are created in pairs. When 141 This device is a local ethernet tunnel. Devices are created in pairs.
142 one end receives the packet it appears on its pair and vice versa. 142 When one end receives the packet it appears on its pair and vice
143 versa.
143 144
144config NET_SB1000 145config NET_SB1000
145 tristate "General Instruments Surfboard 1000" 146 tristate "General Instruments Surfboard 1000"
@@ -234,7 +235,7 @@ source "drivers/net/arm/Kconfig"
234 235
235config AX88796 236config AX88796
236 tristate "ASIX AX88796 NE2000 clone support" 237 tristate "ASIX AX88796 NE2000 clone support"
237 depends on ARM || MIPS 238 depends on ARM || MIPS || SUPERH
238 select CRC32 239 select CRC32
239 select MII 240 select MII
240 help 241 help
@@ -365,8 +366,7 @@ config MAC89x0
365 read the Ethernet-HOWTO, available from 366 read the Ethernet-HOWTO, available from
366 <http://www.tldp.org/docs.html#howto>. 367 <http://www.tldp.org/docs.html#howto>.
367 368
368 To compile this driver as a module, choose M here and read 369 To compile this driver as a module, choose M here. This module will
369 <file:Documentation/networking/net-modules.txt>. This module will
370 be called mac89x0. 370 be called mac89x0.
371 371
372config MACSONIC 372config MACSONIC
@@ -379,8 +379,7 @@ config MACSONIC
379 one of these say Y and read the Ethernet-HOWTO, available from 379 one of these say Y and read the Ethernet-HOWTO, available from
380 <http://www.tldp.org/docs.html#howto>. 380 <http://www.tldp.org/docs.html#howto>.
381 381
382 To compile this driver as a module, choose M here and read 382 To compile this driver as a module, choose M here. This module will
383 <file:Documentation/networking/net-modules.txt>. This module will
384 be called macsonic. 383 be called macsonic.
385 384
386config MACMACE 385config MACMACE
@@ -618,8 +617,7 @@ config EL1
618 have problems. Some people suggest to ping ("man ping") a nearby 617 have problems. Some people suggest to ping ("man ping") a nearby
619 machine every minute ("man cron") when using this card. 618 machine every minute ("man cron") when using this card.
620 619
621 To compile this driver as a module, choose M here and read 620 To compile this driver as a module, choose M here. The module
622 <file:Documentation/networking/net-modules.txt>. The module
623 will be called 3c501. 621 will be called 3c501.
624 622
625config EL2 623config EL2
@@ -631,8 +629,7 @@ config EL2
631 the Ethernet-HOWTO, available from 629 the Ethernet-HOWTO, available from
632 <http://www.tldp.org/docs.html#howto>. 630 <http://www.tldp.org/docs.html#howto>.
633 631
634 To compile this driver as a module, choose M here and read 632 To compile this driver as a module, choose M here. The module
635 <file:Documentation/networking/net-modules.txt>. The module
636 will be called 3c503. 633 will be called 3c503.
637 634
638config ELPLUS 635config ELPLUS
@@ -644,8 +641,7 @@ config ELPLUS
644 this type, say Y and read the Ethernet-HOWTO, available from 641 this type, say Y and read the Ethernet-HOWTO, available from
645 <http://www.tldp.org/docs.html#howto>. 642 <http://www.tldp.org/docs.html#howto>.
646 643
647 To compile this driver as a module, choose M here and read 644 To compile this driver as a module, choose M here. The module
648 <file:Documentation/networking/net-modules.txt>. The module
649 will be called 3c505. 645 will be called 3c505.
650 646
651config EL16 647config EL16
@@ -656,8 +652,7 @@ config EL16
656 the Ethernet-HOWTO, available from 652 the Ethernet-HOWTO, available from
657 <http://www.tldp.org/docs.html#howto>. 653 <http://www.tldp.org/docs.html#howto>.
658 654
659 To compile this driver as a module, choose M here and read 655 To compile this driver as a module, choose M here. The module
660 <file:Documentation/networking/net-modules.txt>. The module
661 will be called 3c507. 656 will be called 3c507.
662 657
663config EL3 658config EL3
@@ -672,8 +667,7 @@ config EL3
672 setup disk to disable Plug & Play mode, and to select the default 667 setup disk to disable Plug & Play mode, and to select the default
673 media type. 668 media type.
674 669
675 To compile this driver as a module, choose M here and read 670 To compile this driver as a module, choose M here. The module
676 <file:Documentation/networking/net-modules.txt>. The module
677 will be called 3c509. 671 will be called 3c509.
678 672
679config 3C515 673config 3C515
@@ -684,8 +678,7 @@ config 3C515
684 network card, say Y and read the Ethernet-HOWTO, available from 678 network card, say Y and read the Ethernet-HOWTO, available from
685 <http://www.tldp.org/docs.html#howto>. 679 <http://www.tldp.org/docs.html#howto>.
686 680
687 To compile this driver as a module, choose M here and read 681 To compile this driver as a module, choose M here. The module
688 <file:Documentation/networking/net-modules.txt>. The module
689 will be called 3c515. 682 will be called 3c515.
690 683
691config ELMC 684config ELMC
@@ -696,8 +689,7 @@ config ELMC
696 the Ethernet-HOWTO, available from 689 the Ethernet-HOWTO, available from
697 <http://www.tldp.org/docs.html#howto>. 690 <http://www.tldp.org/docs.html#howto>.
698 691
699 To compile this driver as a module, choose M here and read 692 To compile this driver as a module, choose M here. The module
700 <file:Documentation/networking/net-modules.txt>. The module
701 will be called 3c523. 693 will be called 3c523.
702 694
703config ELMC_II 695config ELMC_II
@@ -708,8 +700,7 @@ config ELMC_II
708 the Ethernet-HOWTO, available from 700 the Ethernet-HOWTO, available from
709 <http://www.tldp.org/docs.html#howto>. 701 <http://www.tldp.org/docs.html#howto>.
710 702
711 To compile this driver as a module, choose M here and read 703 To compile this driver as a module, choose M here. The module
712 <file:Documentation/networking/net-modules.txt>. The module
713 will be called 3c527. 704 will be called 3c527.
714 705
715config VORTEX 706config VORTEX
@@ -732,8 +723,7 @@ config VORTEX
732 <file:Documentation/networking/vortex.txt> and in the comments at 723 <file:Documentation/networking/vortex.txt> and in the comments at
733 the beginning of <file:drivers/net/3c59x.c>. 724 the beginning of <file:drivers/net/3c59x.c>.
734 725
735 To compile this support as a module, choose M here and read 726 To compile this support as a module, choose M here.
736 <file:Documentation/networking/net-modules.txt>.
737 727
738config TYPHOON 728config TYPHOON
739 tristate "3cr990 series \"Typhoon\" support" 729 tristate "3cr990 series \"Typhoon\" support"
@@ -750,8 +740,7 @@ config TYPHOON
750 the Ethernet-HOWTO, available from 740 the Ethernet-HOWTO, available from
751 <http://www.tldp.org/docs.html#howto>. 741 <http://www.tldp.org/docs.html#howto>.
752 742
753 To compile this driver as a module, choose M here and read 743 To compile this driver as a module, choose M here. The module
754 <file:Documentation/networking/net-modules.txt>. The module
755 will be called typhoon. 744 will be called typhoon.
756 745
757config LANCE 746config LANCE
@@ -788,8 +777,7 @@ config WD80x3
788 the Ethernet-HOWTO, available from 777 the Ethernet-HOWTO, available from
789 <http://www.tldp.org/docs.html#howto>. 778 <http://www.tldp.org/docs.html#howto>.
790 779
791 To compile this driver as a module, choose M here and read 780 To compile this driver as a module, choose M here. The module
792 <file:Documentation/networking/net-modules.txt>. The module
793 will be called wd. 781 will be called wd.
794 782
795config ULTRAMCA 783config ULTRAMCA
@@ -801,8 +789,7 @@ config ULTRAMCA
801 an MCA based system (PS/2), say Y and read the Ethernet-HOWTO, 789 an MCA based system (PS/2), say Y and read the Ethernet-HOWTO,
802 available from <http://www.tldp.org/docs.html#howto>. 790 available from <http://www.tldp.org/docs.html#howto>.
803 791
804 To compile this driver as a module, choose M here and read 792 To compile this driver as a module, choose M here. The module
805 <file:Documentation/networking/net-modules.txt>. The module
806 will be called smc-mca. 793 will be called smc-mca.
807 794
808config ULTRA 795config ULTRA
@@ -821,8 +808,7 @@ config ULTRA
821 this but keep it in mind if you have such a SCSI card and have 808 this but keep it in mind if you have such a SCSI card and have
822 problems. 809 problems.
823 810
824 To compile this driver as a module, choose M here and read 811 To compile this driver as a module, choose M here. The module
825 <file:Documentation/networking/net-modules.txt>. The module
826 will be called smc-ultra. 812 will be called smc-ultra.
827 813
828config ULTRA32 814config ULTRA32
@@ -834,8 +820,7 @@ config ULTRA32
834 the Ethernet-HOWTO, available from 820 the Ethernet-HOWTO, available from
835 <http://www.tldp.org/docs.html#howto>. 821 <http://www.tldp.org/docs.html#howto>.
836 822
837 To compile this driver as a module, choose M here and read 823 To compile this driver as a module, choose M here. The module
838 <file:Documentation/networking/net-modules.txt>. The module
839 will be called smc-ultra32. 824 will be called smc-ultra32.
840 825
841config BFIN_MAC 826config BFIN_MAC
@@ -896,8 +881,7 @@ config SMC9194
896 <file:Documentation/networking/smc9.txt> and the Ethernet-HOWTO, 881 <file:Documentation/networking/smc9.txt> and the Ethernet-HOWTO,
897 available from <http://www.tldp.org/docs.html#howto>. 882 available from <http://www.tldp.org/docs.html#howto>.
898 883
899 To compile this driver as a module, choose M here and read 884 To compile this driver as a module, choose M here. The module
900 <file:Documentation/networking/net-modules.txt>. The module
901 will be called smc9194. 885 will be called smc9194.
902 886
903config SMC91X 887config SMC91X
@@ -915,8 +899,7 @@ config SMC91X
915 This driver is also available as a module ( = code which can be 899 This driver is also available as a module ( = code which can be
916 inserted in and removed from the running kernel whenever you want). 900 inserted in and removed from the running kernel whenever you want).
917 The module will be called smc91x. If you want to compile it as a 901 The module will be called smc91x. If you want to compile it as a
918 module, say M here and read <file:Documentation/kbuild/modules.txt> 902 module, say M here and read <file:Documentation/kbuild/modules.txt>.
919 as well as <file:Documentation/networking/net-modules.txt>.
920 903
921config NET_NETX 904config NET_NETX
922 tristate "NetX Ethernet support" 905 tristate "NetX Ethernet support"
@@ -925,8 +908,7 @@ config NET_NETX
925 help 908 help
926 This is support for the Hilscher netX builtin Ethernet ports 909 This is support for the Hilscher netX builtin Ethernet ports
927 910
928 To compile this driver as a module, choose M here and read 911 To compile this driver as a module, choose M here. The module
929 <file:Documentation/networking/net-modules.txt>. The module
930 will be called netx-eth. 912 will be called netx-eth.
931 913
932config DM9000 914config DM9000
@@ -937,9 +919,8 @@ config DM9000
937 ---help--- 919 ---help---
938 Support for DM9000 chipset. 920 Support for DM9000 chipset.
939 921
940 To compile this driver as a module, choose M here and read 922 To compile this driver as a module, choose M here. The module
941 <file:Documentation/networking/net-modules.txt>. The module will be 923 will be called dm9000.
942 called dm9000.
943 924
944config SMC911X 925config SMC911X
945 tristate "SMSC LAN911[5678] support" 926 tristate "SMSC LAN911[5678] support"
@@ -979,8 +960,7 @@ config NI5010
979 <http://www.tldp.org/docs.html#howto>. Note that this is still 960 <http://www.tldp.org/docs.html#howto>. Note that this is still
980 experimental code. 961 experimental code.
981 962
982 To compile this driver as a module, choose M here and read 963 To compile this driver as a module, choose M here. The module
983 <file:Documentation/networking/net-modules.txt>. The module
984 will be called ni5010. 964 will be called ni5010.
985 965
986config NI52 966config NI52
@@ -991,8 +971,7 @@ config NI52
991 the Ethernet-HOWTO, available from 971 the Ethernet-HOWTO, available from
992 <http://www.tldp.org/docs.html#howto>. 972 <http://www.tldp.org/docs.html#howto>.
993 973
994 To compile this driver as a module, choose M here and read 974 To compile this driver as a module, choose M here. The module
995 <file:Documentation/networking/net-modules.txt>. The module
996 will be called ni52. 975 will be called ni52.
997 976
998config NI65 977config NI65
@@ -1003,8 +982,7 @@ config NI65
1003 the Ethernet-HOWTO, available from 982 the Ethernet-HOWTO, available from
1004 <http://www.tldp.org/docs.html#howto>. 983 <http://www.tldp.org/docs.html#howto>.
1005 984
1006 To compile this driver as a module, choose M here and read 985 To compile this driver as a module, choose M here. The module
1007 <file:Documentation/networking/net-modules.txt>. The module
1008 will be called ni65. 986 will be called ni65.
1009 987
1010source "drivers/net/tulip/Kconfig" 988source "drivers/net/tulip/Kconfig"
@@ -1018,8 +996,7 @@ config AT1700
1018 the Ethernet-HOWTO, available from 996 the Ethernet-HOWTO, available from
1019 <http://www.tldp.org/docs.html#howto>. 997 <http://www.tldp.org/docs.html#howto>.
1020 998
1021 To compile this driver as a module, choose M here and read 999 To compile this driver as a module, choose M here. The module
1022 <file:Documentation/networking/net-modules.txt>. The module
1023 will be called at1700. 1000 will be called at1700.
1024 1001
1025config DEPCA 1002config DEPCA
@@ -1032,8 +1009,7 @@ config DEPCA
1032 <http://www.tldp.org/docs.html#howto> as well as 1009 <http://www.tldp.org/docs.html#howto> as well as
1033 <file:drivers/net/depca.c>. 1010 <file:drivers/net/depca.c>.
1034 1011
1035 To compile this driver as a module, choose M here and read 1012 To compile this driver as a module, choose M here. The module
1036 <file:Documentation/networking/net-modules.txt>. The module
1037 will be called depca. 1013 will be called depca.
1038 1014
1039config HP100 1015config HP100
@@ -1044,8 +1020,7 @@ config HP100
1044 the Ethernet-HOWTO, available from 1020 the Ethernet-HOWTO, available from
1045 <http://www.tldp.org/docs.html#howto>. 1021 <http://www.tldp.org/docs.html#howto>.
1046 1022
1047 To compile this driver as a module, choose M here and read 1023 To compile this driver as a module, choose M here. The module
1048 <file:Documentation/networking/net-modules.txt>. The module
1049 will be called hp100. 1024 will be called hp100.
1050 1025
1051config NET_ISA 1026config NET_ISA
@@ -1074,8 +1049,7 @@ config E2100
1074 the Ethernet-HOWTO, available from 1049 the Ethernet-HOWTO, available from
1075 <http://www.tldp.org/docs.html#howto>. 1050 <http://www.tldp.org/docs.html#howto>.
1076 1051
1077 To compile this driver as a module, choose M here and read 1052 To compile this driver as a module, choose M here. The module
1078 <file:Documentation/networking/net-modules.txt>. The module
1079 will be called e2100. 1053 will be called e2100.
1080 1054
1081config EWRK3 1055config EWRK3
@@ -1089,8 +1063,7 @@ config EWRK3
1089 well as the Ethernet-HOWTO, available from 1063 well as the Ethernet-HOWTO, available from
1090 <http://www.tldp.org/docs.html#howto>. 1064 <http://www.tldp.org/docs.html#howto>.
1091 1065
1092 To compile this driver as a module, choose M here and read 1066 To compile this driver as a module, choose M here. The module
1093 <file:Documentation/networking/net-modules.txt>. The module
1094 will be called ewrk3. 1067 will be called ewrk3.
1095 1068
1096config EEXPRESS 1069config EEXPRESS
@@ -1104,8 +1077,7 @@ config EEXPRESS
1104 because the driver was very unreliable. We now have a new driver 1077 because the driver was very unreliable. We now have a new driver
1105 that should do better. 1078 that should do better.
1106 1079
1107 To compile this driver as a module, choose M here and read 1080 To compile this driver as a module, choose M here. The module
1108 <file:Documentation/networking/net-modules.txt>. The module
1109 will be called eexpress. 1081 will be called eexpress.
1110 1082
1111config EEXPRESS_PRO 1083config EEXPRESS_PRO
@@ -1118,8 +1090,7 @@ config EEXPRESS_PRO
1118 driver. Please read the Ethernet-HOWTO, available from 1090 driver. Please read the Ethernet-HOWTO, available from
1119 <http://www.tldp.org/docs.html#howto>. 1091 <http://www.tldp.org/docs.html#howto>.
1120 1092
1121 To compile this driver as a module, choose M here and read 1093 To compile this driver as a module, choose M here. The module
1122 <file:Documentation/networking/net-modules.txt>. The module
1123 will be called eepro. 1094 will be called eepro.
1124 1095
1125config HPLAN_PLUS 1096config HPLAN_PLUS
@@ -1131,8 +1102,7 @@ config HPLAN_PLUS
1131 the Ethernet-HOWTO, available from 1102 the Ethernet-HOWTO, available from
1132 <http://www.tldp.org/docs.html#howto>. 1103 <http://www.tldp.org/docs.html#howto>.
1133 1104
1134 To compile this driver as a module, choose M here and read 1105 To compile this driver as a module, choose M here. The module
1135 <file:Documentation/networking/net-modules.txt>. The module
1136 will be called hp-plus. 1106 will be called hp-plus.
1137 1107
1138config HPLAN 1108config HPLAN
@@ -1144,8 +1114,7 @@ config HPLAN
1144 the Ethernet-HOWTO, available from 1114 the Ethernet-HOWTO, available from
1145 <http://www.tldp.org/docs.html#howto>. 1115 <http://www.tldp.org/docs.html#howto>.
1146 1116
1147 To compile this driver as a module, choose M here and read 1117 To compile this driver as a module, choose M here. The module
1148 <file:Documentation/networking/net-modules.txt>. The module
1149 will be called hp. 1118 will be called hp.
1150 1119
1151config LP486E 1120config LP486E
@@ -1164,8 +1133,7 @@ config ETH16I
1164 the Ethernet-HOWTO, available from 1133 the Ethernet-HOWTO, available from
1165 <http://www.tldp.org/docs.html#howto>. 1134 <http://www.tldp.org/docs.html#howto>.
1166 1135
1167 To compile this driver as a module, choose M here and read 1136 To compile this driver as a module, choose M here. The module
1168 <file:Documentation/networking/net-modules.txt>. The module
1169 will be called eth16i. 1137 will be called eth16i.
1170 1138
1171config NE2000 1139config NE2000
@@ -1185,8 +1153,7 @@ config NE2000
1185 laptops), say N here and Y to "NE/2 (ne2000 MCA version) support", 1153 laptops), say N here and Y to "NE/2 (ne2000 MCA version) support",
1186 below. 1154 below.
1187 1155
1188 To compile this driver as a module, choose M here and read 1156 To compile this driver as a module, choose M here. The module
1189 <file:Documentation/networking/net-modules.txt>. The module
1190 will be called ne. 1157 will be called ne.
1191 1158
1192config ZNET 1159config ZNET
@@ -1207,8 +1174,7 @@ config SEEQ8005
1207 is for you, read the Ethernet-HOWTO, available from 1174 is for you, read the Ethernet-HOWTO, available from
1208 <http://www.tldp.org/docs.html#howto>. 1175 <http://www.tldp.org/docs.html#howto>.
1209 1176
1210 To compile this driver as a module, choose M here and read 1177 To compile this driver as a module, choose M here. The module
1211 <file:Documentation/networking/net-modules.txt>. The module
1212 will be called seeq8005. 1178 will be called seeq8005.
1213 1179
1214config NE2_MCA 1180config NE2_MCA
@@ -1220,8 +1186,7 @@ config NE2_MCA
1220 the Ethernet-HOWTO, available from 1186 the Ethernet-HOWTO, available from
1221 <http://www.tldp.org/docs.html#howto>. 1187 <http://www.tldp.org/docs.html#howto>.
1222 1188
1223 To compile this driver as a module, choose M here and read 1189 To compile this driver as a module, choose M here. The module
1224 <file:Documentation/networking/net-modules.txt>. The module
1225 will be called ne2. 1190 will be called ne2.
1226 1191
1227config IBMLANA 1192config IBMLANA
@@ -1232,8 +1197,7 @@ config IBMLANA
1232 CONFIG_MCA to use this driver. It is both available as an in-kernel 1197 CONFIG_MCA to use this driver. It is both available as an in-kernel
1233 driver and as a module. 1198 driver and as a module.
1234 1199
1235 To compile this driver as a module, choose M here and read 1200 To compile this driver as a module, choose M here. The only
1236 <file:Documentation/networking/net-modules.txt>. The only
1237 currently supported card is the IBM LAN Adapter/A for Ethernet. It 1201 currently supported card is the IBM LAN Adapter/A for Ethernet. It
1238 will both support 16K and 32K memory windows, however a 32K window 1202 will both support 16K and 32K memory windows, however a 32K window
1239 gives a better security against packet losses. Usage of multiple 1203 gives a better security against packet losses. Usage of multiple
@@ -1247,8 +1211,7 @@ config IBMVETH
1247 This driver supports virtual ethernet adapters on newer IBM iSeries 1211 This driver supports virtual ethernet adapters on newer IBM iSeries
1248 and pSeries systems. 1212 and pSeries systems.
1249 1213
1250 To compile this driver as a module, choose M here and read 1214 To compile this driver as a module, choose M here. The module will
1251 <file:Documentation/networking/net-modules.txt>. The module will
1252 be called ibmveth. 1215 be called ibmveth.
1253 1216
1254source "drivers/net/ibm_emac/Kconfig" 1217source "drivers/net/ibm_emac/Kconfig"
@@ -1278,8 +1241,7 @@ config PCNET32
1278 answer Y here and read the Ethernet-HOWTO, available from 1241 answer Y here and read the Ethernet-HOWTO, available from
1279 <http://www.tldp.org/docs.html#howto>. 1242 <http://www.tldp.org/docs.html#howto>.
1280 1243
1281 To compile this driver as a module, choose M here and read 1244 To compile this driver as a module, choose M here. The module
1282 <file:Documentation/networking/net-modules.txt>. The module
1283 will be called pcnet32. 1245 will be called pcnet32.
1284 1246
1285config PCNET32_NAPI 1247config PCNET32_NAPI
@@ -1306,8 +1268,7 @@ config AMD8111_ETH
1306 answer Y here and read the Ethernet-HOWTO, available from 1268 answer Y here and read the Ethernet-HOWTO, available from
1307 <http://www.tldp.org/docs.html#howto>. 1269 <http://www.tldp.org/docs.html#howto>.
1308 1270
1309 To compile this driver as a module, choose M here and read 1271 To compile this driver as a module, choose M here. The module
1310 <file:Documentation/networking/net-modules.txt>. The module
1311 will be called amd8111e. 1272 will be called amd8111e.
1312 1273
1313config AMD8111E_NAPI 1274config AMD8111E_NAPI
@@ -1361,8 +1322,7 @@ config AC3200
1361 the Ethernet-HOWTO, available from 1322 the Ethernet-HOWTO, available from
1362 <http://www.tldp.org/docs.html#howto>. 1323 <http://www.tldp.org/docs.html#howto>.
1363 1324
1364 To compile this driver as a module, choose M here and read 1325 To compile this driver as a module, choose M here. The module
1365 <file:Documentation/networking/net-modules.txt>. The module
1366 will be called ac3200. 1326 will be called ac3200.
1367 1327
1368config APRICOT 1328config APRICOT
@@ -1373,9 +1333,8 @@ config APRICOT
1373 read the Ethernet-HOWTO, available from 1333 read the Ethernet-HOWTO, available from
1374 <http://www.tldp.org/docs.html#howto>. 1334 <http://www.tldp.org/docs.html#howto>.
1375 1335
1376 To compile this driver as a module, choose M here and read 1336 To compile this driver as a module, choose M here. The module
1377 <file:Documentation/networking/net-modules.txt>. The module will be 1337 will be called apricot.
1378 called apricot.
1379 1338
1380config B44 1339config B44
1381 tristate "Broadcom 440x/47xx ethernet support" 1340 tristate "Broadcom 440x/47xx ethernet support"
@@ -1387,9 +1346,8 @@ config B44
1387 or M and read the Ethernet-HOWTO, available from 1346 or M and read the Ethernet-HOWTO, available from
1388 <http://www.tldp.org/docs.html#howto>. 1347 <http://www.tldp.org/docs.html#howto>.
1389 1348
1390 To compile this driver as a module, choose M here and read 1349 To compile this driver as a module, choose M here. The module
1391 <file:Documentation/networking/net-modules.txt>. The module will be 1350 will be called b44.
1392 called b44.
1393 1351
1394# Auto-select SSB PCI-HOST support, if possible 1352# Auto-select SSB PCI-HOST support, if possible
1395config B44_PCI_AUTOSELECT 1353config B44_PCI_AUTOSELECT
@@ -1418,9 +1376,8 @@ config FORCEDETH
1418 read the Ethernet-HOWTO, available from 1376 read the Ethernet-HOWTO, available from
1419 <http://www.tldp.org/docs.html#howto>. 1377 <http://www.tldp.org/docs.html#howto>.
1420 1378
1421 To compile this driver as a module, choose M here and read 1379 To compile this driver as a module, choose M here. The module
1422 <file:Documentation/networking/net-modules.txt>. The module will be 1380 will be called forcedeth.
1423 called forcedeth.
1424 1381
1425config FORCEDETH_NAPI 1382config FORCEDETH_NAPI
1426 bool "Use Rx Polling (NAPI) (EXPERIMENTAL)" 1383 bool "Use Rx Polling (NAPI) (EXPERIMENTAL)"
@@ -1446,9 +1403,8 @@ config CS89x0
1446 <http://www.tldp.org/docs.html#howto> as well as 1403 <http://www.tldp.org/docs.html#howto> as well as
1447 <file:Documentation/networking/cs89x0.txt>. 1404 <file:Documentation/networking/cs89x0.txt>.
1448 1405
1449 To compile this driver as a module, choose M here and read 1406 To compile this driver as a module, choose M here. The module
1450 <file:Documentation/networking/net-modules.txt>. The module will be 1407 will be called cs89x0.
1451 called cs89x0.
1452 1408
1453config TC35815 1409config TC35815
1454 tristate "TOSHIBA TC35815 Ethernet support" 1410 tristate "TOSHIBA TC35815 Ethernet support"
@@ -1464,8 +1420,7 @@ config EEPRO100
1464 card, say Y and read the Ethernet-HOWTO, available from 1420 card, say Y and read the Ethernet-HOWTO, available from
1465 <http://www.tldp.org/docs.html#howto>. 1421 <http://www.tldp.org/docs.html#howto>.
1466 1422
1467 To compile this driver as a module, choose M here and read 1423 To compile this driver as a module, choose M here. The module
1468 <file:Documentation/networking/net-modules.txt>. The module
1469 will be called eepro100. 1424 will be called eepro100.
1470 1425
1471 1426
@@ -1492,8 +1447,7 @@ config E100
1492 More specific information on configuring the driver is in 1447 More specific information on configuring the driver is in
1493 <file:Documentation/networking/e100.txt>. 1448 <file:Documentation/networking/e100.txt>.
1494 1449
1495 To compile this driver as a module, choose M here and read 1450 To compile this driver as a module, choose M here. The module
1496 <file:Documentation/networking/net-modules.txt>. The module
1497 will be called e100. 1451 will be called e100.
1498 1452
1499config LNE390 1453config LNE390
@@ -1505,8 +1459,7 @@ config LNE390
1505 the Ethernet-HOWTO, available from 1459 the Ethernet-HOWTO, available from
1506 <http://www.tldp.org/docs.html#howto>. 1460 <http://www.tldp.org/docs.html#howto>.
1507 1461
1508 To compile this driver as a module, choose M here and read 1462 To compile this driver as a module, choose M here. The module
1509 <file:Documentation/networking/net-modules.txt>. The module
1510 will be called lne390. 1463 will be called lne390.
1511 1464
1512config FEALNX 1465config FEALNX
@@ -1546,8 +1499,7 @@ config NE2K_PCI
1546 NetVin NV5000SC Via 86C926 SureCom NE34 Winbond 1499 NetVin NV5000SC Via 86C926 SureCom NE34 Winbond
1547 Holtek HT80232 Holtek HT80229 1500 Holtek HT80232 Holtek HT80229
1548 1501
1549 To compile this driver as a module, choose M here and read 1502 To compile this driver as a module, choose M here. The module
1550 <file:Documentation/networking/net-modules.txt>. The module
1551 will be called ne2k-pci. 1503 will be called ne2k-pci.
1552 1504
1553config NE3210 1505config NE3210
@@ -1560,8 +1512,7 @@ config NE3210
1560 <http://www.tldp.org/docs.html#howto>. Note that this driver 1512 <http://www.tldp.org/docs.html#howto>. Note that this driver
1561 will NOT WORK for NE3200 cards as they are completely different. 1513 will NOT WORK for NE3200 cards as they are completely different.
1562 1514
1563 To compile this driver as a module, choose M here and read 1515 To compile this driver as a module, choose M here. The module
1564 <file:Documentation/networking/net-modules.txt>. The module
1565 will be called ne3210. 1516 will be called ne3210.
1566 1517
1567config ES3210 1518config ES3210
@@ -1573,8 +1524,7 @@ config ES3210
1573 the Ethernet-HOWTO, available from 1524 the Ethernet-HOWTO, available from
1574 <http://www.tldp.org/docs.html#howto>. 1525 <http://www.tldp.org/docs.html#howto>.
1575 1526
1576 To compile this driver as a module, choose M here and read 1527 To compile this driver as a module, choose M here. The module
1577 <file:Documentation/networking/net-modules.txt>. The module
1578 will be called es3210. 1528 will be called es3210.
1579 1529
1580config 8139CP 1530config 8139CP
@@ -1704,8 +1654,7 @@ config TLAN
1704 Compaq NetFlex and Olicom cards. Please read the file 1654 Compaq NetFlex and Olicom cards. Please read the file
1705 <file:Documentation/networking/tlan.txt> for more details. 1655 <file:Documentation/networking/tlan.txt> for more details.
1706 1656
1707 To compile this driver as a module, choose M here and read 1657 To compile this driver as a module, choose M here. The module
1708 <file:Documentation/networking/net-modules.txt>. The module
1709 will be called tlan. 1658 will be called tlan.
1710 1659
1711 Please email feedback to <torben.mathiasen@compaq.com>. 1660 Please email feedback to <torben.mathiasen@compaq.com>.
@@ -1995,8 +1944,7 @@ config E1000
1995 More specific information on configuring the driver is in 1944 More specific information on configuring the driver is in
1996 <file:Documentation/networking/e1000.txt>. 1945 <file:Documentation/networking/e1000.txt>.
1997 1946
1998 To compile this driver as a module, choose M here and read 1947 To compile this driver as a module, choose M here. The module
1999 <file:Documentation/networking/net-modules.txt>. The module
2000 will be called e1000. 1948 will be called e1000.
2001 1949
2002config E1000_NAPI 1950config E1000_NAPI
@@ -2041,8 +1989,7 @@ config E1000E
2041 More specific information on configuring the driver is in 1989 More specific information on configuring the driver is in
2042 <file:Documentation/networking/e1000e.txt>. 1990 <file:Documentation/networking/e1000e.txt>.
2043 1991
2044 To compile this driver as a module, choose M here and read 1992 To compile this driver as a module, choose M here. The module
2045 <file:Documentation/networking/net-modules.txt>. The module
2046 will be called e1000e. 1993 will be called e1000e.
2047 1994
2048source "drivers/net/ixp2000/Kconfig" 1995source "drivers/net/ixp2000/Kconfig"
@@ -2075,8 +2022,7 @@ config HAMACHI
2075 the Ethernet-HOWTO, available from 2022 the Ethernet-HOWTO, available from
2076 <http://www.tldp.org/docs.html#howto>. 2023 <http://www.tldp.org/docs.html#howto>.
2077 2024
2078 To compile this driver as a module, choose M here and read 2025 To compile this driver as a module, choose M here. The module will be
2079 <file:Documentation/networking/net-modules.txt>. The module will be
2080 called hamachi. 2026 called hamachi.
2081 2027
2082config YELLOWFIN 2028config YELLOWFIN
@@ -2525,8 +2471,7 @@ config IXGBE
2525 More specific information on configuring the driver is in 2471 More specific information on configuring the driver is in
2526 <file:Documentation/networking/ixgbe.txt>. 2472 <file:Documentation/networking/ixgbe.txt>.
2527 2473
2528 To compile this driver as a module, choose M here and read 2474 To compile this driver as a module, choose M here. The module
2529 <file:Documentation/networking/net-modules.txt>. The module
2530 will be called ixgbe. 2475 will be called ixgbe.
2531 2476
2532config IXGB 2477config IXGB
@@ -2548,8 +2493,7 @@ config IXGB
2548 More specific information on configuring the driver is in 2493 More specific information on configuring the driver is in
2549 <file:Documentation/networking/ixgb.txt>. 2494 <file:Documentation/networking/ixgb.txt>.
2550 2495
2551 To compile this driver as a module, choose M here and read 2496 To compile this driver as a module, choose M here. The module
2552 <file:Documentation/networking/net-modules.txt>. The module
2553 will be called ixgb. 2497 will be called ixgb.
2554 2498
2555config IXGB_NAPI 2499config IXGB_NAPI
@@ -2602,8 +2546,7 @@ config MYRI10GE
2602 2546
2603 <http://www.myri.com/scs/download-Myri10GE.html> 2547 <http://www.myri.com/scs/download-Myri10GE.html>
2604 2548
2605 To compile this driver as a module, choose M here and read 2549 To compile this driver as a module, choose M here. The module
2606 <file:Documentation/networking/net-modules.txt>. The module
2607 will be called myri10ge. 2550 will be called myri10ge.
2608 2551
2609config NETXEN_NIC 2552config NETXEN_NIC
@@ -2827,10 +2770,9 @@ config PLIP
2827 with the PLIP support in Linux versions 1.0.x. This option enlarges 2770 with the PLIP support in Linux versions 1.0.x. This option enlarges
2828 your kernel by about 8 KB. 2771 your kernel by about 8 KB.
2829 2772
2830 To compile this driver as a module, choose M here and read 2773 To compile this driver as a module, choose M here. The module
2831 <file:Documentation/networking/net-modules.txt>. The module will be 2774 will be called plip. If unsure, say Y or M, in case you buy
2832 called plip. If unsure, say Y or M, in case you buy a laptop 2775 a laptop later.
2833 later.
2834 2776
2835config PPP 2777config PPP
2836 tristate "PPP (point-to-point protocol) support" 2778 tristate "PPP (point-to-point protocol) support"
@@ -2860,8 +2802,7 @@ config PPP
2860 If you said Y to "Version information on all symbols" above, then 2802 If you said Y to "Version information on all symbols" above, then
2861 you cannot compile the PPP driver into the kernel; you can then only 2803 you cannot compile the PPP driver into the kernel; you can then only
2862 compile it as a module. To compile this driver as a module, choose M 2804 compile it as a module. To compile this driver as a module, choose M
2863 here and read <file:Documentation/networking/net-modules.txt>. 2805 here. The module will be called ppp_generic.
2864 The module will be called ppp_generic.
2865 2806
2866config PPP_MULTILINK 2807config PPP_MULTILINK
2867 bool "PPP multilink support (EXPERIMENTAL)" 2808 bool "PPP multilink support (EXPERIMENTAL)"
@@ -3022,9 +2963,8 @@ config SLIP
3022 <http://www.bart.nl/~patrickr/term-howto/Term-HOWTO.html>). SLIP 2963 <http://www.bart.nl/~patrickr/term-howto/Term-HOWTO.html>). SLIP
3023 support will enlarge your kernel by about 4 KB. If unsure, say N. 2964 support will enlarge your kernel by about 4 KB. If unsure, say N.
3024 2965
3025 To compile this driver as a module, choose M here and read 2966 To compile this driver as a module, choose M here. The module
3026 <file:Documentation/networking/net-modules.txt>. The module will be 2967 will be called slip.
3027 called slip.
3028 2968
3029config SLIP_COMPRESSED 2969config SLIP_COMPRESSED
3030 bool "CSLIP compressed headers" 2970 bool "CSLIP compressed headers"
diff --git a/drivers/net/arcnet/Kconfig b/drivers/net/arcnet/Kconfig
index 4030274fe788..3b2f7f115464 100644
--- a/drivers/net/arcnet/Kconfig
+++ b/drivers/net/arcnet/Kconfig
@@ -19,8 +19,7 @@ menuconfig ARCNET
19 from <http://www.tldp.org/docs.html#howto>(even though ARCnet 19 from <http://www.tldp.org/docs.html#howto>(even though ARCnet
20 is not really Ethernet). 20 is not really Ethernet).
21 21
22 To compile this driver as a module, choose M here and read 22 To compile this driver as a module, choose M here. The module will
23 <file:Documentation/networking/net-modules.txt>. The module will
24 be called arcnet. 23 be called arcnet.
25 24
26if ARCNET 25if ARCNET
@@ -81,8 +80,7 @@ config ARCNET_COM90xx
81 have always used the old ARCnet driver without knowing what type of 80 have always used the old ARCnet driver without knowing what type of
82 card you had, this is probably the one for you. 81 card you had, this is probably the one for you.
83 82
84 To compile this driver as a module, choose M here and read 83 To compile this driver as a module, choose M here. The module will
85 <file:Documentation/networking/net-modules.txt>. The module will
86 be called com90xx. 84 be called com90xx.
87 85
88config ARCNET_COM90xxIO 86config ARCNET_COM90xxIO
@@ -93,8 +91,7 @@ config ARCNET_COM90xxIO
93 the normal driver. Only use it if your card doesn't support shared 91 the normal driver. Only use it if your card doesn't support shared
94 memory. 92 memory.
95 93
96 To compile this driver as a module, choose M here and read 94 To compile this driver as a module, choose M here. The module will
97 <file:Documentation/networking/net-modules.txt>. The module will
98 be called com90io. 95 be called com90io.
99 96
100config ARCNET_RIM_I 97config ARCNET_RIM_I
@@ -105,8 +102,7 @@ config ARCNET_RIM_I
105 driver is completely untested, so if you have one of these cards, 102 driver is completely untested, so if you have one of these cards,
106 please mail <dwmw2@infradead.org>, especially if it works! 103 please mail <dwmw2@infradead.org>, especially if it works!
107 104
108 To compile this driver as a module, choose M here and read 105 To compile this driver as a module, choose M here. The module will
109 <file:Documentation/networking/net-modules.txt>. The module will
110 be called arc-rimi. 106 be called arc-rimi.
111 107
112config ARCNET_COM20020 108config ARCNET_COM20020
@@ -116,8 +112,7 @@ config ARCNET_COM20020
116 things as promiscuous mode, so packet sniffing is possible, and 112 things as promiscuous mode, so packet sniffing is possible, and
117 extra diagnostic information. 113 extra diagnostic information.
118 114
119 To compile this driver as a module, choose M here and read 115 To compile this driver as a module, choose M here. The module will
120 <file:Documentation/networking/net-modules.txt>. The module will
121 be called com20020. 116 be called com20020.
122 117
123config ARCNET_COM20020_ISA 118config ARCNET_COM20020_ISA
diff --git a/drivers/net/arm/ep93xx_eth.c b/drivers/net/arm/ep93xx_eth.c
index 7f016f3d5bf0..91a6590d107b 100644
--- a/drivers/net/arm/ep93xx_eth.c
+++ b/drivers/net/arm/ep93xx_eth.c
@@ -417,7 +417,7 @@ static irqreturn_t ep93xx_irq(int irq, void *dev_id)
417 417
418 if (status & REG_INTSTS_RX) { 418 if (status & REG_INTSTS_RX) {
419 spin_lock(&ep->rx_lock); 419 spin_lock(&ep->rx_lock);
420 if (likely(__netif_rx_schedule_prep(dev, &ep->napi))) { 420 if (likely(netif_rx_schedule_prep(dev, &ep->napi))) {
421 wrl(ep, REG_INTEN, REG_INTEN_TX); 421 wrl(ep, REG_INTEN, REG_INTEN_TX);
422 __netif_rx_schedule(dev, &ep->napi); 422 __netif_rx_schedule(dev, &ep->napi);
423 } 423 }
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 6937ef0e7275..423298c84a1d 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1847,9 +1847,9 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1847*/ 1847*/
1848void bond_destroy(struct bonding *bond) 1848void bond_destroy(struct bonding *bond)
1849{ 1849{
1850 unregister_netdevice(bond->dev);
1851 bond_deinit(bond->dev); 1850 bond_deinit(bond->dev);
1852 bond_destroy_sysfs_entry(bond); 1851 bond_destroy_sysfs_entry(bond);
1852 unregister_netdevice(bond->dev);
1853} 1853}
1854 1854
1855/* 1855/*
@@ -4405,6 +4405,7 @@ static int bond_init(struct net_device *bond_dev, struct bond_params *params)
4405 bond_dev->set_multicast_list = bond_set_multicast_list; 4405 bond_dev->set_multicast_list = bond_set_multicast_list;
4406 bond_dev->change_mtu = bond_change_mtu; 4406 bond_dev->change_mtu = bond_change_mtu;
4407 bond_dev->set_mac_address = bond_set_mac_address; 4407 bond_dev->set_mac_address = bond_set_mac_address;
4408 bond_dev->validate_addr = NULL;
4408 4409
4409 bond_set_mode_ops(bond, bond->params.mode); 4410 bond_set_mode_ops(bond, bond->params.mode);
4410 4411
@@ -4474,8 +4475,8 @@ static void bond_free_all(void)
4474 bond_mc_list_destroy(bond); 4475 bond_mc_list_destroy(bond);
4475 /* Release the bonded slaves */ 4476 /* Release the bonded slaves */
4476 bond_release_all(bond_dev); 4477 bond_release_all(bond_dev);
4477 unregister_netdevice(bond_dev);
4478 bond_deinit(bond_dev); 4478 bond_deinit(bond_dev);
4479 unregister_netdevice(bond_dev);
4479 } 4480 }
4480 4481
4481#ifdef CONFIG_PROC_FS 4482#ifdef CONFIG_PROC_FS
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 7a06ade85b02..b29330d8e309 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -1193,8 +1193,6 @@ static ssize_t bonding_show_active_slave(struct device *d,
1193 struct bonding *bond = to_bond(d); 1193 struct bonding *bond = to_bond(d);
1194 int count; 1194 int count;
1195 1195
1196 rtnl_lock();
1197
1198 read_lock(&bond->curr_slave_lock); 1196 read_lock(&bond->curr_slave_lock);
1199 curr = bond->curr_active_slave; 1197 curr = bond->curr_active_slave;
1200 read_unlock(&bond->curr_slave_lock); 1198 read_unlock(&bond->curr_slave_lock);
@@ -1216,7 +1214,9 @@ static ssize_t bonding_store_active_slave(struct device *d,
1216 struct slave *new_active = NULL; 1214 struct slave *new_active = NULL;
1217 struct bonding *bond = to_bond(d); 1215 struct bonding *bond = to_bond(d);
1218 1216
1217 rtnl_lock();
1219 write_lock_bh(&bond->lock); 1218 write_lock_bh(&bond->lock);
1219
1220 if (!USES_PRIMARY(bond->params.mode)) { 1220 if (!USES_PRIMARY(bond->params.mode)) {
1221 printk(KERN_INFO DRV_NAME 1221 printk(KERN_INFO DRV_NAME
1222 ": %s: Unable to change active slave; %s is in mode %d\n", 1222 ": %s: Unable to change active slave; %s is in mode %d\n",
diff --git a/drivers/net/cris/eth_v10.c b/drivers/net/cris/eth_v10.c
index edd6828f0a78..917b7b46f1a7 100644
--- a/drivers/net/cris/eth_v10.c
+++ b/drivers/net/cris/eth_v10.c
@@ -250,6 +250,7 @@
250#include <asm/system.h> 250#include <asm/system.h>
251#include <asm/ethernet.h> 251#include <asm/ethernet.h>
252#include <asm/cache.h> 252#include <asm/cache.h>
253#include <asm/arch/io_interface_mux.h>
253 254
254//#define ETHDEBUG 255//#define ETHDEBUG
255#define D(x) 256#define D(x)
@@ -279,6 +280,9 @@ struct net_local {
279 * by this lock as well. 280 * by this lock as well.
280 */ 281 */
281 spinlock_t lock; 282 spinlock_t lock;
283
284 spinlock_t led_lock; /* Protect LED state */
285 spinlock_t transceiver_lock; /* Protect transceiver state. */
282}; 286};
283 287
284typedef struct etrax_eth_descr 288typedef struct etrax_eth_descr
@@ -295,8 +299,6 @@ struct transceiver_ops
295 void (*check_duplex)(struct net_device* dev); 299 void (*check_duplex)(struct net_device* dev);
296}; 300};
297 301
298struct transceiver_ops* transceiver;
299
300/* Duplex settings */ 302/* Duplex settings */
301enum duplex 303enum duplex
302{ 304{
@@ -307,7 +309,7 @@ enum duplex
307 309
308/* Dma descriptors etc. */ 310/* Dma descriptors etc. */
309 311
310#define MAX_MEDIA_DATA_SIZE 1518 312#define MAX_MEDIA_DATA_SIZE 1522
311 313
312#define MIN_PACKET_LEN 46 314#define MIN_PACKET_LEN 46
313#define ETHER_HEAD_LEN 14 315#define ETHER_HEAD_LEN 14
@@ -332,8 +334,8 @@ enum duplex
332 334
333/*Intel LXT972A specific*/ 335/*Intel LXT972A specific*/
334#define MDIO_INT_STATUS_REG_2 0x0011 336#define MDIO_INT_STATUS_REG_2 0x0011
335#define MDIO_INT_FULL_DUPLEX_IND ( 1 << 9 ) 337#define MDIO_INT_FULL_DUPLEX_IND (1 << 9)
336#define MDIO_INT_SPEED ( 1 << 14 ) 338#define MDIO_INT_SPEED (1 << 14)
337 339
338/* Network flash constants */ 340/* Network flash constants */
339#define NET_FLASH_TIME (HZ/50) /* 20 ms */ 341#define NET_FLASH_TIME (HZ/50) /* 20 ms */
@@ -344,8 +346,8 @@ enum duplex
344#define NO_NETWORK_ACTIVITY 0 346#define NO_NETWORK_ACTIVITY 0
345#define NETWORK_ACTIVITY 1 347#define NETWORK_ACTIVITY 1
346 348
347#define NBR_OF_RX_DESC 64 349#define NBR_OF_RX_DESC 32
348#define NBR_OF_TX_DESC 256 350#define NBR_OF_TX_DESC 16
349 351
350/* Large packets are sent directly to upper layers while small packets are */ 352/* Large packets are sent directly to upper layers while small packets are */
351/* copied (to reduce memory waste). The following constant decides the breakpoint */ 353/* copied (to reduce memory waste). The following constant decides the breakpoint */
@@ -367,7 +369,6 @@ enum duplex
367static etrax_eth_descr *myNextRxDesc; /* Points to the next descriptor to 369static etrax_eth_descr *myNextRxDesc; /* Points to the next descriptor to
368 to be processed */ 370 to be processed */
369static etrax_eth_descr *myLastRxDesc; /* The last processed descriptor */ 371static etrax_eth_descr *myLastRxDesc; /* The last processed descriptor */
370static etrax_eth_descr *myPrevRxDesc; /* The descriptor right before myNextRxDesc */
371 372
372static etrax_eth_descr RxDescList[NBR_OF_RX_DESC] __attribute__ ((aligned(32))); 373static etrax_eth_descr RxDescList[NBR_OF_RX_DESC] __attribute__ ((aligned(32)));
373 374
@@ -377,7 +378,6 @@ static etrax_eth_descr* myNextTxDesc; /* Next descriptor to use */
377static etrax_eth_descr TxDescList[NBR_OF_TX_DESC] __attribute__ ((aligned(32))); 378static etrax_eth_descr TxDescList[NBR_OF_TX_DESC] __attribute__ ((aligned(32)));
378 379
379static unsigned int network_rec_config_shadow = 0; 380static unsigned int network_rec_config_shadow = 0;
380static unsigned int mdio_phy_addr; /* Transciever address */
381 381
382static unsigned int network_tr_ctrl_shadow = 0; 382static unsigned int network_tr_ctrl_shadow = 0;
383 383
@@ -411,7 +411,7 @@ static int e100_set_config(struct net_device* dev, struct ifmap* map);
411static void e100_tx_timeout(struct net_device *dev); 411static void e100_tx_timeout(struct net_device *dev);
412static struct net_device_stats *e100_get_stats(struct net_device *dev); 412static struct net_device_stats *e100_get_stats(struct net_device *dev);
413static void set_multicast_list(struct net_device *dev); 413static void set_multicast_list(struct net_device *dev);
414static void e100_hardware_send_packet(char *buf, int length); 414static void e100_hardware_send_packet(struct net_local* np, char *buf, int length);
415static void update_rx_stats(struct net_device_stats *); 415static void update_rx_stats(struct net_device_stats *);
416static void update_tx_stats(struct net_device_stats *); 416static void update_tx_stats(struct net_device_stats *);
417static int e100_probe_transceiver(struct net_device* dev); 417static int e100_probe_transceiver(struct net_device* dev);
@@ -434,7 +434,10 @@ static void e100_clear_network_leds(unsigned long dummy);
434static void e100_set_network_leds(int active); 434static void e100_set_network_leds(int active);
435 435
436static const struct ethtool_ops e100_ethtool_ops; 436static const struct ethtool_ops e100_ethtool_ops;
437 437#if defined(CONFIG_ETRAX_NO_PHY)
438static void dummy_check_speed(struct net_device* dev);
439static void dummy_check_duplex(struct net_device* dev);
440#else
438static void broadcom_check_speed(struct net_device* dev); 441static void broadcom_check_speed(struct net_device* dev);
439static void broadcom_check_duplex(struct net_device* dev); 442static void broadcom_check_duplex(struct net_device* dev);
440static void tdk_check_speed(struct net_device* dev); 443static void tdk_check_speed(struct net_device* dev);
@@ -443,16 +446,28 @@ static void intel_check_speed(struct net_device* dev);
443static void intel_check_duplex(struct net_device* dev); 446static void intel_check_duplex(struct net_device* dev);
444static void generic_check_speed(struct net_device* dev); 447static void generic_check_speed(struct net_device* dev);
445static void generic_check_duplex(struct net_device* dev); 448static void generic_check_duplex(struct net_device* dev);
449#endif
450#ifdef CONFIG_NET_POLL_CONTROLLER
451static void e100_netpoll(struct net_device* dev);
452#endif
453
454static int autoneg_normal = 1;
446 455
447struct transceiver_ops transceivers[] = 456struct transceiver_ops transceivers[] =
448{ 457{
458#if defined(CONFIG_ETRAX_NO_PHY)
459 {0x0000, dummy_check_speed, dummy_check_duplex} /* Dummy */
460#else
449 {0x1018, broadcom_check_speed, broadcom_check_duplex}, /* Broadcom */ 461 {0x1018, broadcom_check_speed, broadcom_check_duplex}, /* Broadcom */
450 {0xC039, tdk_check_speed, tdk_check_duplex}, /* TDK 2120 */ 462 {0xC039, tdk_check_speed, tdk_check_duplex}, /* TDK 2120 */
451 {0x039C, tdk_check_speed, tdk_check_duplex}, /* TDK 2120C */ 463 {0x039C, tdk_check_speed, tdk_check_duplex}, /* TDK 2120C */
452 {0x04de, intel_check_speed, intel_check_duplex}, /* Intel LXT972A*/ 464 {0x04de, intel_check_speed, intel_check_duplex}, /* Intel LXT972A*/
453 {0x0000, generic_check_speed, generic_check_duplex} /* Generic, must be last */ 465 {0x0000, generic_check_speed, generic_check_duplex} /* Generic, must be last */
466#endif
454}; 467};
455 468
469struct transceiver_ops* transceiver = &transceivers[0];
470
456#define tx_done(dev) (*R_DMA_CH0_CMD == 0) 471#define tx_done(dev) (*R_DMA_CH0_CMD == 0)
457 472
458/* 473/*
@@ -471,14 +486,22 @@ etrax_ethernet_init(void)
471 int i, err; 486 int i, err;
472 487
473 printk(KERN_INFO 488 printk(KERN_INFO
474 "ETRAX 100LX 10/100MBit ethernet v2.0 (c) 2000-2003 Axis Communications AB\n"); 489 "ETRAX 100LX 10/100MBit ethernet v2.0 (c) 1998-2007 Axis Communications AB\n");
475 490
476 dev = alloc_etherdev(sizeof(struct net_local)); 491 if (cris_request_io_interface(if_eth, cardname)) {
477 np = dev->priv; 492 printk(KERN_CRIT "etrax_ethernet_init failed to get IO interface\n");
493 return -EBUSY;
494 }
478 495
496 dev = alloc_etherdev(sizeof(struct net_local));
479 if (!dev) 497 if (!dev)
480 return -ENOMEM; 498 return -ENOMEM;
481 499
500 np = netdev_priv(dev);
501
502 /* we do our own locking */
503 dev->features |= NETIF_F_LLTX;
504
482 dev->base_addr = (unsigned int)R_NETWORK_SA_0; /* just to have something to show */ 505 dev->base_addr = (unsigned int)R_NETWORK_SA_0; /* just to have something to show */
483 506
484 /* now setup our etrax specific stuff */ 507 /* now setup our etrax specific stuff */
@@ -498,14 +521,22 @@ etrax_ethernet_init(void)
498 dev->do_ioctl = e100_ioctl; 521 dev->do_ioctl = e100_ioctl;
499 dev->set_config = e100_set_config; 522 dev->set_config = e100_set_config;
500 dev->tx_timeout = e100_tx_timeout; 523 dev->tx_timeout = e100_tx_timeout;
524#ifdef CONFIG_NET_POLL_CONTROLLER
525 dev->poll_controller = e100_netpoll;
526#endif
527
528 spin_lock_init(&np->lock);
529 spin_lock_init(&np->led_lock);
530 spin_lock_init(&np->transceiver_lock);
501 531
502 /* Initialise the list of Etrax DMA-descriptors */ 532 /* Initialise the list of Etrax DMA-descriptors */
503 533
504 /* Initialise receive descriptors */ 534 /* Initialise receive descriptors */
505 535
506 for (i = 0; i < NBR_OF_RX_DESC; i++) { 536 for (i = 0; i < NBR_OF_RX_DESC; i++) {
507 /* Allocate two extra cachelines to make sure that buffer used by DMA 537 /* Allocate two extra cachelines to make sure that buffer used
508 * does not share cacheline with any other data (to avoid cache bug) 538 * by DMA does not share cacheline with any other data (to
539 * avoid cache bug)
509 */ 540 */
510 RxDescList[i].skb = dev_alloc_skb(MAX_MEDIA_DATA_SIZE + 2 * L1_CACHE_BYTES); 541 RxDescList[i].skb = dev_alloc_skb(MAX_MEDIA_DATA_SIZE + 2 * L1_CACHE_BYTES);
511 if (!RxDescList[i].skb) 542 if (!RxDescList[i].skb)
@@ -541,7 +572,6 @@ etrax_ethernet_init(void)
541 572
542 myNextRxDesc = &RxDescList[0]; 573 myNextRxDesc = &RxDescList[0];
543 myLastRxDesc = &RxDescList[NBR_OF_RX_DESC - 1]; 574 myLastRxDesc = &RxDescList[NBR_OF_RX_DESC - 1];
544 myPrevRxDesc = &RxDescList[NBR_OF_RX_DESC - 1];
545 myFirstTxDesc = &TxDescList[0]; 575 myFirstTxDesc = &TxDescList[0];
546 myNextTxDesc = &TxDescList[0]; 576 myNextTxDesc = &TxDescList[0];
547 myLastTxDesc = &TxDescList[NBR_OF_TX_DESC - 1]; 577 myLastTxDesc = &TxDescList[NBR_OF_TX_DESC - 1];
@@ -562,10 +592,11 @@ etrax_ethernet_init(void)
562 current_speed = 10; 592 current_speed = 10;
563 current_speed_selection = 0; /* Auto */ 593 current_speed_selection = 0; /* Auto */
564 speed_timer.expires = jiffies + NET_LINK_UP_CHECK_INTERVAL; 594 speed_timer.expires = jiffies + NET_LINK_UP_CHECK_INTERVAL;
565 duplex_timer.data = (unsigned long)dev; 595 speed_timer.data = (unsigned long)dev;
566 speed_timer.function = e100_check_speed; 596 speed_timer.function = e100_check_speed;
567 597
568 clear_led_timer.function = e100_clear_network_leds; 598 clear_led_timer.function = e100_clear_network_leds;
599 clear_led_timer.data = (unsigned long)dev;
569 600
570 full_duplex = 0; 601 full_duplex = 0;
571 current_duplex = autoneg; 602 current_duplex = autoneg;
@@ -574,7 +605,6 @@ etrax_ethernet_init(void)
574 duplex_timer.function = e100_check_duplex; 605 duplex_timer.function = e100_check_duplex;
575 606
576 /* Initialize mii interface */ 607 /* Initialize mii interface */
577 np->mii_if.phy_id = mdio_phy_addr;
578 np->mii_if.phy_id_mask = 0x1f; 608 np->mii_if.phy_id_mask = 0x1f;
579 np->mii_if.reg_num_mask = 0x1f; 609 np->mii_if.reg_num_mask = 0x1f;
580 np->mii_if.dev = dev; 610 np->mii_if.dev = dev;
@@ -585,6 +615,9 @@ etrax_ethernet_init(void)
585 /* unwanted addresses are matched */ 615 /* unwanted addresses are matched */
586 *R_NETWORK_GA_0 = 0x00000000; 616 *R_NETWORK_GA_0 = 0x00000000;
587 *R_NETWORK_GA_1 = 0x00000000; 617 *R_NETWORK_GA_1 = 0x00000000;
618
619 /* Initialize next time the led can flash */
620 led_next_time = jiffies;
588 return 0; 621 return 0;
589} 622}
590 623
@@ -595,9 +628,9 @@ etrax_ethernet_init(void)
595static int 628static int
596e100_set_mac_address(struct net_device *dev, void *p) 629e100_set_mac_address(struct net_device *dev, void *p)
597{ 630{
598 struct net_local *np = (struct net_local *)dev->priv; 631 struct net_local *np = netdev_priv(dev);
599 struct sockaddr *addr = p; 632 struct sockaddr *addr = p;
600 int i; 633 DECLARE_MAC_BUF(mac);
601 634
602 spin_lock(&np->lock); /* preemption protection */ 635 spin_lock(&np->lock); /* preemption protection */
603 636
@@ -686,6 +719,25 @@ e100_open(struct net_device *dev)
686 goto grace_exit2; 719 goto grace_exit2;
687 } 720 }
688 721
722 /*
723 * Always allocate the DMA channels after the IRQ,
724 * and clean up on failure.
725 */
726
727 if (cris_request_dma(NETWORK_TX_DMA_NBR,
728 cardname,
729 DMA_VERBOSE_ON_ERROR,
730 dma_eth)) {
731 goto grace_exit3;
732 }
733
734 if (cris_request_dma(NETWORK_RX_DMA_NBR,
735 cardname,
736 DMA_VERBOSE_ON_ERROR,
737 dma_eth)) {
738 goto grace_exit4;
739 }
740
689 /* give the HW an idea of what MAC address we want */ 741 /* give the HW an idea of what MAC address we want */
690 742
691 *R_NETWORK_SA_0 = dev->dev_addr[0] | (dev->dev_addr[1] << 8) | 743 *R_NETWORK_SA_0 = dev->dev_addr[0] | (dev->dev_addr[1] << 8) |
@@ -700,6 +752,7 @@ e100_open(struct net_device *dev)
700 752
701 *R_NETWORK_REC_CONFIG = 0xd; /* broadcast rec, individ. rec, ma0 enabled */ 753 *R_NETWORK_REC_CONFIG = 0xd; /* broadcast rec, individ. rec, ma0 enabled */
702#else 754#else
755 SETS(network_rec_config_shadow, R_NETWORK_REC_CONFIG, max_size, size1522);
703 SETS(network_rec_config_shadow, R_NETWORK_REC_CONFIG, broadcast, receive); 756 SETS(network_rec_config_shadow, R_NETWORK_REC_CONFIG, broadcast, receive);
704 SETS(network_rec_config_shadow, R_NETWORK_REC_CONFIG, ma0, enable); 757 SETS(network_rec_config_shadow, R_NETWORK_REC_CONFIG, ma0, enable);
705 SETF(network_rec_config_shadow, R_NETWORK_REC_CONFIG, duplex, full_duplex); 758 SETF(network_rec_config_shadow, R_NETWORK_REC_CONFIG, duplex, full_duplex);
@@ -719,8 +772,7 @@ e100_open(struct net_device *dev)
719 SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, crc, enable); 772 SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, crc, enable);
720 *R_NETWORK_TR_CTRL = network_tr_ctrl_shadow; 773 *R_NETWORK_TR_CTRL = network_tr_ctrl_shadow;
721 774
722 save_flags(flags); 775 local_irq_save(flags);
723 cli();
724 776
725 /* enable the irq's for ethernet DMA */ 777 /* enable the irq's for ethernet DMA */
726 778
@@ -752,12 +804,13 @@ e100_open(struct net_device *dev)
752 804
753 *R_DMA_CH0_FIRST = 0; 805 *R_DMA_CH0_FIRST = 0;
754 *R_DMA_CH0_DESCR = virt_to_phys(myLastTxDesc); 806 *R_DMA_CH0_DESCR = virt_to_phys(myLastTxDesc);
807 netif_start_queue(dev);
755 808
756 restore_flags(flags); 809 local_irq_restore(flags);
757 810
758 /* Probe for transceiver */ 811 /* Probe for transceiver */
759 if (e100_probe_transceiver(dev)) 812 if (e100_probe_transceiver(dev))
760 goto grace_exit3; 813 goto grace_exit5;
761 814
762 /* Start duplex/speed timers */ 815 /* Start duplex/speed timers */
763 add_timer(&speed_timer); 816 add_timer(&speed_timer);
@@ -766,10 +819,14 @@ e100_open(struct net_device *dev)
766 /* We are now ready to accept transmit requeusts from 819 /* We are now ready to accept transmit requeusts from
767 * the queueing layer of the networking. 820 * the queueing layer of the networking.
768 */ 821 */
769 netif_start_queue(dev); 822 netif_carrier_on(dev);
770 823
771 return 0; 824 return 0;
772 825
826grace_exit5:
827 cris_free_dma(NETWORK_RX_DMA_NBR, cardname);
828grace_exit4:
829 cris_free_dma(NETWORK_TX_DMA_NBR, cardname);
773grace_exit3: 830grace_exit3:
774 free_irq(NETWORK_STATUS_IRQ_NBR, (void *)dev); 831 free_irq(NETWORK_STATUS_IRQ_NBR, (void *)dev);
775grace_exit2: 832grace_exit2:
@@ -780,12 +837,20 @@ grace_exit0:
780 return -EAGAIN; 837 return -EAGAIN;
781} 838}
782 839
783 840#if defined(CONFIG_ETRAX_NO_PHY)
841static void
842dummy_check_speed(struct net_device* dev)
843{
844 current_speed = 100;
845}
846#else
784static void 847static void
785generic_check_speed(struct net_device* dev) 848generic_check_speed(struct net_device* dev)
786{ 849{
787 unsigned long data; 850 unsigned long data;
788 data = e100_get_mdio_reg(dev, mdio_phy_addr, MII_ADVERTISE); 851 struct net_local *np = netdev_priv(dev);
852
853 data = e100_get_mdio_reg(dev, np->mii_if.phy_id, MII_ADVERTISE);
789 if ((data & ADVERTISE_100FULL) || 854 if ((data & ADVERTISE_100FULL) ||
790 (data & ADVERTISE_100HALF)) 855 (data & ADVERTISE_100HALF))
791 current_speed = 100; 856 current_speed = 100;
@@ -797,7 +862,10 @@ static void
797tdk_check_speed(struct net_device* dev) 862tdk_check_speed(struct net_device* dev)
798{ 863{
799 unsigned long data; 864 unsigned long data;
800 data = e100_get_mdio_reg(dev, mdio_phy_addr, MDIO_TDK_DIAGNOSTIC_REG); 865 struct net_local *np = netdev_priv(dev);
866
867 data = e100_get_mdio_reg(dev, np->mii_if.phy_id,
868 MDIO_TDK_DIAGNOSTIC_REG);
801 current_speed = (data & MDIO_TDK_DIAGNOSTIC_RATE ? 100 : 10); 869 current_speed = (data & MDIO_TDK_DIAGNOSTIC_RATE ? 100 : 10);
802} 870}
803 871
@@ -805,7 +873,10 @@ static void
805broadcom_check_speed(struct net_device* dev) 873broadcom_check_speed(struct net_device* dev)
806{ 874{
807 unsigned long data; 875 unsigned long data;
808 data = e100_get_mdio_reg(dev, mdio_phy_addr, MDIO_AUX_CTRL_STATUS_REG); 876 struct net_local *np = netdev_priv(dev);
877
878 data = e100_get_mdio_reg(dev, np->mii_if.phy_id,
879 MDIO_AUX_CTRL_STATUS_REG);
809 current_speed = (data & MDIO_BC_SPEED ? 100 : 10); 880 current_speed = (data & MDIO_BC_SPEED ? 100 : 10);
810} 881}
811 882
@@ -813,46 +884,62 @@ static void
813intel_check_speed(struct net_device* dev) 884intel_check_speed(struct net_device* dev)
814{ 885{
815 unsigned long data; 886 unsigned long data;
816 data = e100_get_mdio_reg(dev, mdio_phy_addr, MDIO_INT_STATUS_REG_2); 887 struct net_local *np = netdev_priv(dev);
888
889 data = e100_get_mdio_reg(dev, np->mii_if.phy_id,
890 MDIO_INT_STATUS_REG_2);
817 current_speed = (data & MDIO_INT_SPEED ? 100 : 10); 891 current_speed = (data & MDIO_INT_SPEED ? 100 : 10);
818} 892}
819 893#endif
820static void 894static void
821e100_check_speed(unsigned long priv) 895e100_check_speed(unsigned long priv)
822{ 896{
823 struct net_device* dev = (struct net_device*)priv; 897 struct net_device* dev = (struct net_device*)priv;
898 struct net_local *np = netdev_priv(dev);
824 static int led_initiated = 0; 899 static int led_initiated = 0;
825 unsigned long data; 900 unsigned long data;
826 int old_speed = current_speed; 901 int old_speed = current_speed;
827 902
828 data = e100_get_mdio_reg(dev, mdio_phy_addr, MII_BMSR); 903 spin_lock(&np->transceiver_lock);
904
905 data = e100_get_mdio_reg(dev, np->mii_if.phy_id, MII_BMSR);
829 if (!(data & BMSR_LSTATUS)) { 906 if (!(data & BMSR_LSTATUS)) {
830 current_speed = 0; 907 current_speed = 0;
831 } else { 908 } else {
832 transceiver->check_speed(dev); 909 transceiver->check_speed(dev);
833 } 910 }
834 911
912 spin_lock(&np->led_lock);
835 if ((old_speed != current_speed) || !led_initiated) { 913 if ((old_speed != current_speed) || !led_initiated) {
836 led_initiated = 1; 914 led_initiated = 1;
837 e100_set_network_leds(NO_NETWORK_ACTIVITY); 915 e100_set_network_leds(NO_NETWORK_ACTIVITY);
916 if (current_speed)
917 netif_carrier_on(dev);
918 else
919 netif_carrier_off(dev);
838 } 920 }
921 spin_unlock(&np->led_lock);
839 922
840 /* Reinitialize the timer. */ 923 /* Reinitialize the timer. */
841 speed_timer.expires = jiffies + NET_LINK_UP_CHECK_INTERVAL; 924 speed_timer.expires = jiffies + NET_LINK_UP_CHECK_INTERVAL;
842 add_timer(&speed_timer); 925 add_timer(&speed_timer);
926
927 spin_unlock(&np->transceiver_lock);
843} 928}
844 929
845static void 930static void
846e100_negotiate(struct net_device* dev) 931e100_negotiate(struct net_device* dev)
847{ 932{
848 unsigned short data = e100_get_mdio_reg(dev, mdio_phy_addr, MII_ADVERTISE); 933 struct net_local *np = netdev_priv(dev);
934 unsigned short data = e100_get_mdio_reg(dev, np->mii_if.phy_id,
935 MII_ADVERTISE);
849 936
850 /* Discard old speed and duplex settings */ 937 /* Discard old speed and duplex settings */
851 data &= ~(ADVERTISE_100HALF | ADVERTISE_100FULL | 938 data &= ~(ADVERTISE_100HALF | ADVERTISE_100FULL |
852 ADVERTISE_10HALF | ADVERTISE_10FULL); 939 ADVERTISE_10HALF | ADVERTISE_10FULL);
853 940
854 switch (current_speed_selection) { 941 switch (current_speed_selection) {
855 case 10 : 942 case 10:
856 if (current_duplex == full) 943 if (current_duplex == full)
857 data |= ADVERTISE_10FULL; 944 data |= ADVERTISE_10FULL;
858 else if (current_duplex == half) 945 else if (current_duplex == half)
@@ -861,7 +948,7 @@ e100_negotiate(struct net_device* dev)
861 data |= ADVERTISE_10HALF | ADVERTISE_10FULL; 948 data |= ADVERTISE_10HALF | ADVERTISE_10FULL;
862 break; 949 break;
863 950
864 case 100 : 951 case 100:
865 if (current_duplex == full) 952 if (current_duplex == full)
866 data |= ADVERTISE_100FULL; 953 data |= ADVERTISE_100FULL;
867 else if (current_duplex == half) 954 else if (current_duplex == half)
@@ -870,7 +957,7 @@ e100_negotiate(struct net_device* dev)
870 data |= ADVERTISE_100HALF | ADVERTISE_100FULL; 957 data |= ADVERTISE_100HALF | ADVERTISE_100FULL;
871 break; 958 break;
872 959
873 case 0 : /* Auto */ 960 case 0: /* Auto */
874 if (current_duplex == full) 961 if (current_duplex == full)
875 data |= ADVERTISE_100FULL | ADVERTISE_10FULL; 962 data |= ADVERTISE_100FULL | ADVERTISE_10FULL;
876 else if (current_duplex == half) 963 else if (current_duplex == half)
@@ -880,35 +967,44 @@ e100_negotiate(struct net_device* dev)
880 ADVERTISE_100HALF | ADVERTISE_100FULL; 967 ADVERTISE_100HALF | ADVERTISE_100FULL;
881 break; 968 break;
882 969
883 default : /* assume autoneg speed and duplex */ 970 default: /* assume autoneg speed and duplex */
884 data |= ADVERTISE_10HALF | ADVERTISE_10FULL | 971 data |= ADVERTISE_10HALF | ADVERTISE_10FULL |
885 ADVERTISE_100HALF | ADVERTISE_100FULL; 972 ADVERTISE_100HALF | ADVERTISE_100FULL;
973 break;
886 } 974 }
887 975
888 e100_set_mdio_reg(dev, mdio_phy_addr, MII_ADVERTISE, data); 976 e100_set_mdio_reg(dev, np->mii_if.phy_id, MII_ADVERTISE, data);
889 977
890 /* Renegotiate with link partner */ 978 /* Renegotiate with link partner */
891 data = e100_get_mdio_reg(dev, mdio_phy_addr, MII_BMCR); 979 if (autoneg_normal) {
980 data = e100_get_mdio_reg(dev, np->mii_if.phy_id, MII_BMCR);
892 data |= BMCR_ANENABLE | BMCR_ANRESTART; 981 data |= BMCR_ANENABLE | BMCR_ANRESTART;
893 982 }
894 e100_set_mdio_reg(dev, mdio_phy_addr, MII_BMCR, data); 983 e100_set_mdio_reg(dev, np->mii_if.phy_id, MII_BMCR, data);
895} 984}
896 985
897static void 986static void
898e100_set_speed(struct net_device* dev, unsigned long speed) 987e100_set_speed(struct net_device* dev, unsigned long speed)
899{ 988{
989 struct net_local *np = netdev_priv(dev);
990
991 spin_lock(&np->transceiver_lock);
900 if (speed != current_speed_selection) { 992 if (speed != current_speed_selection) {
901 current_speed_selection = speed; 993 current_speed_selection = speed;
902 e100_negotiate(dev); 994 e100_negotiate(dev);
903 } 995 }
996 spin_unlock(&np->transceiver_lock);
904} 997}
905 998
906static void 999static void
907e100_check_duplex(unsigned long priv) 1000e100_check_duplex(unsigned long priv)
908{ 1001{
909 struct net_device *dev = (struct net_device *)priv; 1002 struct net_device *dev = (struct net_device *)priv;
910 struct net_local *np = (struct net_local *)dev->priv; 1003 struct net_local *np = netdev_priv(dev);
911 int old_duplex = full_duplex; 1004 int old_duplex;
1005
1006 spin_lock(&np->transceiver_lock);
1007 old_duplex = full_duplex;
912 transceiver->check_duplex(dev); 1008 transceiver->check_duplex(dev);
913 if (old_duplex != full_duplex) { 1009 if (old_duplex != full_duplex) {
914 /* Duplex changed */ 1010 /* Duplex changed */
@@ -920,13 +1016,22 @@ e100_check_duplex(unsigned long priv)
920 duplex_timer.expires = jiffies + NET_DUPLEX_CHECK_INTERVAL; 1016 duplex_timer.expires = jiffies + NET_DUPLEX_CHECK_INTERVAL;
921 add_timer(&duplex_timer); 1017 add_timer(&duplex_timer);
922 np->mii_if.full_duplex = full_duplex; 1018 np->mii_if.full_duplex = full_duplex;
1019 spin_unlock(&np->transceiver_lock);
923} 1020}
924 1021#if defined(CONFIG_ETRAX_NO_PHY)
1022static void
1023dummy_check_duplex(struct net_device* dev)
1024{
1025 full_duplex = 1;
1026}
1027#else
925static void 1028static void
926generic_check_duplex(struct net_device* dev) 1029generic_check_duplex(struct net_device* dev)
927{ 1030{
928 unsigned long data; 1031 unsigned long data;
929 data = e100_get_mdio_reg(dev, mdio_phy_addr, MII_ADVERTISE); 1032 struct net_local *np = netdev_priv(dev);
1033
1034 data = e100_get_mdio_reg(dev, np->mii_if.phy_id, MII_ADVERTISE);
930 if ((data & ADVERTISE_10FULL) || 1035 if ((data & ADVERTISE_10FULL) ||
931 (data & ADVERTISE_100FULL)) 1036 (data & ADVERTISE_100FULL))
932 full_duplex = 1; 1037 full_duplex = 1;
@@ -938,7 +1043,10 @@ static void
938tdk_check_duplex(struct net_device* dev) 1043tdk_check_duplex(struct net_device* dev)
939{ 1044{
940 unsigned long data; 1045 unsigned long data;
941 data = e100_get_mdio_reg(dev, mdio_phy_addr, MDIO_TDK_DIAGNOSTIC_REG); 1046 struct net_local *np = netdev_priv(dev);
1047
1048 data = e100_get_mdio_reg(dev, np->mii_if.phy_id,
1049 MDIO_TDK_DIAGNOSTIC_REG);
942 full_duplex = (data & MDIO_TDK_DIAGNOSTIC_DPLX) ? 1 : 0; 1050 full_duplex = (data & MDIO_TDK_DIAGNOSTIC_DPLX) ? 1 : 0;
943} 1051}
944 1052
@@ -946,7 +1054,10 @@ static void
946broadcom_check_duplex(struct net_device* dev) 1054broadcom_check_duplex(struct net_device* dev)
947{ 1055{
948 unsigned long data; 1056 unsigned long data;
949 data = e100_get_mdio_reg(dev, mdio_phy_addr, MDIO_AUX_CTRL_STATUS_REG); 1057 struct net_local *np = netdev_priv(dev);
1058
1059 data = e100_get_mdio_reg(dev, np->mii_if.phy_id,
1060 MDIO_AUX_CTRL_STATUS_REG);
950 full_duplex = (data & MDIO_BC_FULL_DUPLEX_IND) ? 1 : 0; 1061 full_duplex = (data & MDIO_BC_FULL_DUPLEX_IND) ? 1 : 0;
951} 1062}
952 1063
@@ -954,38 +1065,55 @@ static void
954intel_check_duplex(struct net_device* dev) 1065intel_check_duplex(struct net_device* dev)
955{ 1066{
956 unsigned long data; 1067 unsigned long data;
957 data = e100_get_mdio_reg(dev, mdio_phy_addr, MDIO_INT_STATUS_REG_2); 1068 struct net_local *np = netdev_priv(dev);
1069
1070 data = e100_get_mdio_reg(dev, np->mii_if.phy_id,
1071 MDIO_INT_STATUS_REG_2);
958 full_duplex = (data & MDIO_INT_FULL_DUPLEX_IND) ? 1 : 0; 1072 full_duplex = (data & MDIO_INT_FULL_DUPLEX_IND) ? 1 : 0;
959} 1073}
960 1074#endif
961static void 1075static void
962e100_set_duplex(struct net_device* dev, enum duplex new_duplex) 1076e100_set_duplex(struct net_device* dev, enum duplex new_duplex)
963{ 1077{
1078 struct net_local *np = netdev_priv(dev);
1079
1080 spin_lock(&np->transceiver_lock);
964 if (new_duplex != current_duplex) { 1081 if (new_duplex != current_duplex) {
965 current_duplex = new_duplex; 1082 current_duplex = new_duplex;
966 e100_negotiate(dev); 1083 e100_negotiate(dev);
967 } 1084 }
1085 spin_unlock(&np->transceiver_lock);
968} 1086}
969 1087
970static int 1088static int
971e100_probe_transceiver(struct net_device* dev) 1089e100_probe_transceiver(struct net_device* dev)
972{ 1090{
1091 int ret = 0;
1092
1093#if !defined(CONFIG_ETRAX_NO_PHY)
973 unsigned int phyid_high; 1094 unsigned int phyid_high;
974 unsigned int phyid_low; 1095 unsigned int phyid_low;
975 unsigned int oui; 1096 unsigned int oui;
976 struct transceiver_ops* ops = NULL; 1097 struct transceiver_ops* ops = NULL;
1098 struct net_local *np = netdev_priv(dev);
1099
1100 spin_lock(&np->transceiver_lock);
977 1101
978 /* Probe MDIO physical address */ 1102 /* Probe MDIO physical address */
979 for (mdio_phy_addr = 0; mdio_phy_addr <= 31; mdio_phy_addr++) { 1103 for (np->mii_if.phy_id = 0; np->mii_if.phy_id <= 31;
980 if (e100_get_mdio_reg(dev, mdio_phy_addr, MII_BMSR) != 0xffff) 1104 np->mii_if.phy_id++) {
1105 if (e100_get_mdio_reg(dev,
1106 np->mii_if.phy_id, MII_BMSR) != 0xffff)
981 break; 1107 break;
982 } 1108 }
983 if (mdio_phy_addr == 32) 1109 if (np->mii_if.phy_id == 32) {
984 return -ENODEV; 1110 ret = -ENODEV;
1111 goto out;
1112 }
985 1113
986 /* Get manufacturer */ 1114 /* Get manufacturer */
987 phyid_high = e100_get_mdio_reg(dev, mdio_phy_addr, MII_PHYSID1); 1115 phyid_high = e100_get_mdio_reg(dev, np->mii_if.phy_id, MII_PHYSID1);
988 phyid_low = e100_get_mdio_reg(dev, mdio_phy_addr, MII_PHYSID2); 1116 phyid_low = e100_get_mdio_reg(dev, np->mii_if.phy_id, MII_PHYSID2);
989 oui = (phyid_high << 6) | (phyid_low >> 10); 1117 oui = (phyid_high << 6) | (phyid_low >> 10);
990 1118
991 for (ops = &transceivers[0]; ops->oui; ops++) { 1119 for (ops = &transceivers[0]; ops->oui; ops++) {
@@ -993,8 +1121,10 @@ e100_probe_transceiver(struct net_device* dev)
993 break; 1121 break;
994 } 1122 }
995 transceiver = ops; 1123 transceiver = ops;
996 1124out:
997 return 0; 1125 spin_unlock(&np->transceiver_lock);
1126#endif
1127 return ret;
998} 1128}
999 1129
1000static int 1130static int
@@ -1088,13 +1218,14 @@ e100_receive_mdio_bit()
1088static void 1218static void
1089e100_reset_transceiver(struct net_device* dev) 1219e100_reset_transceiver(struct net_device* dev)
1090{ 1220{
1221 struct net_local *np = netdev_priv(dev);
1091 unsigned short cmd; 1222 unsigned short cmd;
1092 unsigned short data; 1223 unsigned short data;
1093 int bitCounter; 1224 int bitCounter;
1094 1225
1095 data = e100_get_mdio_reg(dev, mdio_phy_addr, MII_BMCR); 1226 data = e100_get_mdio_reg(dev, np->mii_if.phy_id, MII_BMCR);
1096 1227
1097 cmd = (MDIO_START << 14) | (MDIO_WRITE << 12) | (mdio_phy_addr << 7) | (MII_BMCR << 2); 1228 cmd = (MDIO_START << 14) | (MDIO_WRITE << 12) | (np->mii_if.phy_id << 7) | (MII_BMCR << 2);
1098 1229
1099 e100_send_mdio_cmd(cmd, 1); 1230 e100_send_mdio_cmd(cmd, 1);
1100 1231
@@ -1112,7 +1243,7 @@ e100_reset_transceiver(struct net_device* dev)
1112static void 1243static void
1113e100_tx_timeout(struct net_device *dev) 1244e100_tx_timeout(struct net_device *dev)
1114{ 1245{
1115 struct net_local *np = (struct net_local *)dev->priv; 1246 struct net_local *np = netdev_priv(dev);
1116 unsigned long flags; 1247 unsigned long flags;
1117 1248
1118 spin_lock_irqsave(&np->lock, flags); 1249 spin_lock_irqsave(&np->lock, flags);
@@ -1134,8 +1265,7 @@ e100_tx_timeout(struct net_device *dev)
1134 e100_reset_transceiver(dev); 1265 e100_reset_transceiver(dev);
1135 1266
1136 /* and get rid of the packets that never got an interrupt */ 1267 /* and get rid of the packets that never got an interrupt */
1137 while (myFirstTxDesc != myNextTxDesc) 1268 while (myFirstTxDesc != myNextTxDesc) {
1138 {
1139 dev_kfree_skb(myFirstTxDesc->skb); 1269 dev_kfree_skb(myFirstTxDesc->skb);
1140 myFirstTxDesc->skb = 0; 1270 myFirstTxDesc->skb = 0;
1141 myFirstTxDesc = phys_to_virt(myFirstTxDesc->descr.next); 1271 myFirstTxDesc = phys_to_virt(myFirstTxDesc->descr.next);
@@ -1161,7 +1291,7 @@ e100_tx_timeout(struct net_device *dev)
1161static int 1291static int
1162e100_send_packet(struct sk_buff *skb, struct net_device *dev) 1292e100_send_packet(struct sk_buff *skb, struct net_device *dev)
1163{ 1293{
1164 struct net_local *np = (struct net_local *)dev->priv; 1294 struct net_local *np = netdev_priv(dev);
1165 unsigned char *buf = skb->data; 1295 unsigned char *buf = skb->data;
1166 unsigned long flags; 1296 unsigned long flags;
1167 1297
@@ -1174,7 +1304,7 @@ e100_send_packet(struct sk_buff *skb, struct net_device *dev)
1174 1304
1175 dev->trans_start = jiffies; 1305 dev->trans_start = jiffies;
1176 1306
1177 e100_hardware_send_packet(buf, skb->len); 1307 e100_hardware_send_packet(np, buf, skb->len);
1178 1308
1179 myNextTxDesc = phys_to_virt(myNextTxDesc->descr.next); 1309 myNextTxDesc = phys_to_virt(myNextTxDesc->descr.next);
1180 1310
@@ -1197,13 +1327,15 @@ static irqreturn_t
1197e100rxtx_interrupt(int irq, void *dev_id) 1327e100rxtx_interrupt(int irq, void *dev_id)
1198{ 1328{
1199 struct net_device *dev = (struct net_device *)dev_id; 1329 struct net_device *dev = (struct net_device *)dev_id;
1200 struct net_local *np = (struct net_local *)dev->priv; 1330 struct net_local *np = netdev_priv(dev);
1201 unsigned long irqbits = *R_IRQ_MASK2_RD; 1331 unsigned long irqbits;
1202 1332
1203 /* Disable RX/TX IRQs to avoid reentrancy */ 1333 /*
1204 *R_IRQ_MASK2_CLR = 1334 * Note that both rx and tx interrupts are blocked at this point,
1205 IO_STATE(R_IRQ_MASK2_CLR, dma0_eop, clr) | 1335 * regardless of which got us here.
1206 IO_STATE(R_IRQ_MASK2_CLR, dma1_eop, clr); 1336 */
1337
1338 irqbits = *R_IRQ_MASK2_RD;
1207 1339
1208 /* Handle received packets */ 1340 /* Handle received packets */
1209 if (irqbits & IO_STATE(R_IRQ_MASK2_RD, dma1_eop, active)) { 1341 if (irqbits & IO_STATE(R_IRQ_MASK2_RD, dma1_eop, active)) {
@@ -1219,7 +1351,7 @@ e100rxtx_interrupt(int irq, void *dev_id)
1219 * allocate a new buffer to put a packet in. 1351 * allocate a new buffer to put a packet in.
1220 */ 1352 */
1221 e100_rx(dev); 1353 e100_rx(dev);
1222 ((struct net_local *)dev->priv)->stats.rx_packets++; 1354 np->stats.rx_packets++;
1223 /* restart/continue on the channel, for safety */ 1355 /* restart/continue on the channel, for safety */
1224 *R_DMA_CH1_CMD = IO_STATE(R_DMA_CH1_CMD, cmd, restart); 1356 *R_DMA_CH1_CMD = IO_STATE(R_DMA_CH1_CMD, cmd, restart);
1225 /* clear dma channel 1 eop/descr irq bits */ 1357 /* clear dma channel 1 eop/descr irq bits */
@@ -1233,9 +1365,8 @@ e100rxtx_interrupt(int irq, void *dev_id)
1233 } 1365 }
1234 1366
1235 /* Report any packets that have been sent */ 1367 /* Report any packets that have been sent */
1236 while (myFirstTxDesc != phys_to_virt(*R_DMA_CH0_FIRST) && 1368 while (virt_to_phys(myFirstTxDesc) != *R_DMA_CH0_FIRST &&
1237 myFirstTxDesc != myNextTxDesc) 1369 (netif_queue_stopped(dev) || myFirstTxDesc != myNextTxDesc)) {
1238 {
1239 np->stats.tx_bytes += myFirstTxDesc->skb->len; 1370 np->stats.tx_bytes += myFirstTxDesc->skb->len;
1240 np->stats.tx_packets++; 1371 np->stats.tx_packets++;
1241 1372
@@ -1244,19 +1375,15 @@ e100rxtx_interrupt(int irq, void *dev_id)
1244 dev_kfree_skb_irq(myFirstTxDesc->skb); 1375 dev_kfree_skb_irq(myFirstTxDesc->skb);
1245 myFirstTxDesc->skb = 0; 1376 myFirstTxDesc->skb = 0;
1246 myFirstTxDesc = phys_to_virt(myFirstTxDesc->descr.next); 1377 myFirstTxDesc = phys_to_virt(myFirstTxDesc->descr.next);
1378 /* Wake up queue. */
1379 netif_wake_queue(dev);
1247 } 1380 }
1248 1381
1249 if (irqbits & IO_STATE(R_IRQ_MASK2_RD, dma0_eop, active)) { 1382 if (irqbits & IO_STATE(R_IRQ_MASK2_RD, dma0_eop, active)) {
1250 /* acknowledge the eop interrupt and wake up queue */ 1383 /* acknowledge the eop interrupt. */
1251 *R_DMA_CH0_CLR_INTR = IO_STATE(R_DMA_CH0_CLR_INTR, clr_eop, do); 1384 *R_DMA_CH0_CLR_INTR = IO_STATE(R_DMA_CH0_CLR_INTR, clr_eop, do);
1252 netif_wake_queue(dev);
1253 } 1385 }
1254 1386
1255 /* Enable RX/TX IRQs again */
1256 *R_IRQ_MASK2_SET =
1257 IO_STATE(R_IRQ_MASK2_SET, dma0_eop, set) |
1258 IO_STATE(R_IRQ_MASK2_SET, dma1_eop, set);
1259
1260 return IRQ_HANDLED; 1387 return IRQ_HANDLED;
1261} 1388}
1262 1389
@@ -1264,7 +1391,7 @@ static irqreturn_t
1264e100nw_interrupt(int irq, void *dev_id) 1391e100nw_interrupt(int irq, void *dev_id)
1265{ 1392{
1266 struct net_device *dev = (struct net_device *)dev_id; 1393 struct net_device *dev = (struct net_device *)dev_id;
1267 struct net_local *np = (struct net_local *)dev->priv; 1394 struct net_local *np = netdev_priv(dev);
1268 unsigned long irqbits = *R_IRQ_MASK0_RD; 1395 unsigned long irqbits = *R_IRQ_MASK0_RD;
1269 1396
1270 /* check for underrun irq */ 1397 /* check for underrun irq */
@@ -1286,7 +1413,6 @@ e100nw_interrupt(int irq, void *dev_id)
1286 SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, clr_error, clr); 1413 SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, clr_error, clr);
1287 *R_NETWORK_TR_CTRL = network_tr_ctrl_shadow; 1414 *R_NETWORK_TR_CTRL = network_tr_ctrl_shadow;
1288 SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, clr_error, nop); 1415 SETS(network_tr_ctrl_shadow, R_NETWORK_TR_CTRL, clr_error, nop);
1289 *R_NETWORK_TR_CTRL = IO_STATE(R_NETWORK_TR_CTRL, clr_error, clr);
1290 np->stats.tx_errors++; 1416 np->stats.tx_errors++;
1291 D(printk("ethernet excessive collisions!\n")); 1417 D(printk("ethernet excessive collisions!\n"));
1292 } 1418 }
@@ -1299,12 +1425,13 @@ e100_rx(struct net_device *dev)
1299{ 1425{
1300 struct sk_buff *skb; 1426 struct sk_buff *skb;
1301 int length = 0; 1427 int length = 0;
1302 struct net_local *np = (struct net_local *)dev->priv; 1428 struct net_local *np = netdev_priv(dev);
1303 unsigned char *skb_data_ptr; 1429 unsigned char *skb_data_ptr;
1304#ifdef ETHDEBUG 1430#ifdef ETHDEBUG
1305 int i; 1431 int i;
1306#endif 1432#endif
1307 1433 etrax_eth_descr *prevRxDesc; /* The descriptor right before myNextRxDesc */
1434 spin_lock(&np->led_lock);
1308 if (!led_active && time_after(jiffies, led_next_time)) { 1435 if (!led_active && time_after(jiffies, led_next_time)) {
1309 /* light the network leds depending on the current speed. */ 1436 /* light the network leds depending on the current speed. */
1310 e100_set_network_leds(NETWORK_ACTIVITY); 1437 e100_set_network_leds(NETWORK_ACTIVITY);
@@ -1314,9 +1441,10 @@ e100_rx(struct net_device *dev)
1314 led_active = 1; 1441 led_active = 1;
1315 mod_timer(&clear_led_timer, jiffies + HZ/10); 1442 mod_timer(&clear_led_timer, jiffies + HZ/10);
1316 } 1443 }
1444 spin_unlock(&np->led_lock);
1317 1445
1318 length = myNextRxDesc->descr.hw_len - 4; 1446 length = myNextRxDesc->descr.hw_len - 4;
1319 ((struct net_local *)dev->priv)->stats.rx_bytes += length; 1447 np->stats.rx_bytes += length;
1320 1448
1321#ifdef ETHDEBUG 1449#ifdef ETHDEBUG
1322 printk("Got a packet of length %d:\n", length); 1450 printk("Got a packet of length %d:\n", length);
@@ -1336,7 +1464,7 @@ e100_rx(struct net_device *dev)
1336 if (!skb) { 1464 if (!skb) {
1337 np->stats.rx_errors++; 1465 np->stats.rx_errors++;
1338 printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name); 1466 printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name);
1339 return; 1467 goto update_nextrxdesc;
1340 } 1468 }
1341 1469
1342 skb_put(skb, length - ETHER_HEAD_LEN); /* allocate room for the packet body */ 1470 skb_put(skb, length - ETHER_HEAD_LEN); /* allocate room for the packet body */
@@ -1354,15 +1482,15 @@ e100_rx(struct net_device *dev)
1354 else { 1482 else {
1355 /* Large packet, send directly to upper layers and allocate new 1483 /* Large packet, send directly to upper layers and allocate new
1356 * memory (aligned to cache line boundary to avoid bug). 1484 * memory (aligned to cache line boundary to avoid bug).
1357 * Before sending the skb to upper layers we must make sure that 1485 * Before sending the skb to upper layers we must make sure
1358 * skb->data points to the aligned start of the packet. 1486 * that skb->data points to the aligned start of the packet.
1359 */ 1487 */
1360 int align; 1488 int align;
1361 struct sk_buff *new_skb = dev_alloc_skb(MAX_MEDIA_DATA_SIZE + 2 * L1_CACHE_BYTES); 1489 struct sk_buff *new_skb = dev_alloc_skb(MAX_MEDIA_DATA_SIZE + 2 * L1_CACHE_BYTES);
1362 if (!new_skb) { 1490 if (!new_skb) {
1363 np->stats.rx_errors++; 1491 np->stats.rx_errors++;
1364 printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name); 1492 printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name);
1365 return; 1493 goto update_nextrxdesc;
1366 } 1494 }
1367 skb = myNextRxDesc->skb; 1495 skb = myNextRxDesc->skb;
1368 align = (int)phys_to_virt(myNextRxDesc->descr.buf) - (int)skb->data; 1496 align = (int)phys_to_virt(myNextRxDesc->descr.buf) - (int)skb->data;
@@ -1377,9 +1505,10 @@ e100_rx(struct net_device *dev)
1377 /* Send the packet to the upper layers */ 1505 /* Send the packet to the upper layers */
1378 netif_rx(skb); 1506 netif_rx(skb);
1379 1507
1508 update_nextrxdesc:
1380 /* Prepare for next packet */ 1509 /* Prepare for next packet */
1381 myNextRxDesc->descr.status = 0; 1510 myNextRxDesc->descr.status = 0;
1382 myPrevRxDesc = myNextRxDesc; 1511 prevRxDesc = myNextRxDesc;
1383 myNextRxDesc = phys_to_virt(myNextRxDesc->descr.next); 1512 myNextRxDesc = phys_to_virt(myNextRxDesc->descr.next);
1384 1513
1385 rx_queue_len++; 1514 rx_queue_len++;
@@ -1387,9 +1516,9 @@ e100_rx(struct net_device *dev)
1387 /* Check if descriptors should be returned */ 1516 /* Check if descriptors should be returned */
1388 if (rx_queue_len == RX_QUEUE_THRESHOLD) { 1517 if (rx_queue_len == RX_QUEUE_THRESHOLD) {
1389 flush_etrax_cache(); 1518 flush_etrax_cache();
1390 myPrevRxDesc->descr.ctrl |= d_eol; 1519 prevRxDesc->descr.ctrl |= d_eol;
1391 myLastRxDesc->descr.ctrl &= ~d_eol; 1520 myLastRxDesc->descr.ctrl &= ~d_eol;
1392 myLastRxDesc = myPrevRxDesc; 1521 myLastRxDesc = prevRxDesc;
1393 rx_queue_len = 0; 1522 rx_queue_len = 0;
1394 } 1523 }
1395} 1524}
@@ -1398,7 +1527,7 @@ e100_rx(struct net_device *dev)
1398static int 1527static int
1399e100_close(struct net_device *dev) 1528e100_close(struct net_device *dev)
1400{ 1529{
1401 struct net_local *np = (struct net_local *)dev->priv; 1530 struct net_local *np = netdev_priv(dev);
1402 1531
1403 printk(KERN_INFO "Closing %s.\n", dev->name); 1532 printk(KERN_INFO "Closing %s.\n", dev->name);
1404 1533
@@ -1426,6 +1555,9 @@ e100_close(struct net_device *dev)
1426 free_irq(NETWORK_DMA_TX_IRQ_NBR, (void *)dev); 1555 free_irq(NETWORK_DMA_TX_IRQ_NBR, (void *)dev);
1427 free_irq(NETWORK_STATUS_IRQ_NBR, (void *)dev); 1556 free_irq(NETWORK_STATUS_IRQ_NBR, (void *)dev);
1428 1557
1558 cris_free_dma(NETWORK_TX_DMA_NBR, cardname);
1559 cris_free_dma(NETWORK_RX_DMA_NBR, cardname);
1560
1429 /* Update the statistics here. */ 1561 /* Update the statistics here. */
1430 1562
1431 update_rx_stats(&np->stats); 1563 update_rx_stats(&np->stats);
@@ -1443,18 +1575,11 @@ e100_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1443{ 1575{
1444 struct mii_ioctl_data *data = if_mii(ifr); 1576 struct mii_ioctl_data *data = if_mii(ifr);
1445 struct net_local *np = netdev_priv(dev); 1577 struct net_local *np = netdev_priv(dev);
1578 int rc = 0;
1579 int old_autoneg;
1446 1580
1447 spin_lock(&np->lock); /* Preempt protection */ 1581 spin_lock(&np->lock); /* Preempt protection */
1448 switch (cmd) { 1582 switch (cmd) {
1449 case SIOCGMIIPHY: /* Get PHY address */
1450 data->phy_id = mdio_phy_addr;
1451 break;
1452 case SIOCGMIIREG: /* Read MII register */
1453 data->val_out = e100_get_mdio_reg(dev, mdio_phy_addr, data->reg_num);
1454 break;
1455 case SIOCSMIIREG: /* Write MII register */
1456 e100_set_mdio_reg(dev, mdio_phy_addr, data->reg_num, data->val_in);
1457 break;
1458 /* The ioctls below should be considered obsolete but are */ 1583 /* The ioctls below should be considered obsolete but are */
1459 /* still present for compatability with old scripts/apps */ 1584 /* still present for compatability with old scripts/apps */
1460 case SET_ETH_SPEED_10: /* 10 Mbps */ 1585 case SET_ETH_SPEED_10: /* 10 Mbps */
@@ -1463,60 +1588,47 @@ e100_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1463 case SET_ETH_SPEED_100: /* 100 Mbps */ 1588 case SET_ETH_SPEED_100: /* 100 Mbps */
1464 e100_set_speed(dev, 100); 1589 e100_set_speed(dev, 100);
1465 break; 1590 break;
1466 case SET_ETH_SPEED_AUTO: /* Auto negotiate speed */ 1591 case SET_ETH_SPEED_AUTO: /* Auto-negotiate speed */
1467 e100_set_speed(dev, 0); 1592 e100_set_speed(dev, 0);
1468 break; 1593 break;
1469 case SET_ETH_DUPLEX_HALF: /* Half duplex. */ 1594 case SET_ETH_DUPLEX_HALF: /* Half duplex */
1470 e100_set_duplex(dev, half); 1595 e100_set_duplex(dev, half);
1471 break; 1596 break;
1472 case SET_ETH_DUPLEX_FULL: /* Full duplex. */ 1597 case SET_ETH_DUPLEX_FULL: /* Full duplex */
1473 e100_set_duplex(dev, full); 1598 e100_set_duplex(dev, full);
1474 break; 1599 break;
1475 case SET_ETH_DUPLEX_AUTO: /* Autonegotiate duplex*/ 1600 case SET_ETH_DUPLEX_AUTO: /* Auto-negotiate duplex */
1476 e100_set_duplex(dev, autoneg); 1601 e100_set_duplex(dev, autoneg);
1477 break; 1602 break;
1603 case SET_ETH_AUTONEG:
1604 old_autoneg = autoneg_normal;
1605 autoneg_normal = *(int*)data;
1606 if (autoneg_normal != old_autoneg)
1607 e100_negotiate(dev);
1608 break;
1478 default: 1609 default:
1479 return -EINVAL; 1610 rc = generic_mii_ioctl(&np->mii_if, if_mii(ifr),
1611 cmd, NULL);
1612 break;
1480 } 1613 }
1481 spin_unlock(&np->lock); 1614 spin_unlock(&np->lock);
1482 return 0; 1615 return rc;
1483} 1616}
1484 1617
1485static int e100_set_settings(struct net_device *dev, 1618static int e100_get_settings(struct net_device *dev,
1486 struct ethtool_cmd *ecmd) 1619 struct ethtool_cmd *cmd)
1487{ 1620{
1488 ecmd->supported = SUPPORTED_Autoneg | SUPPORTED_TP | SUPPORTED_MII | 1621 struct net_local *np = netdev_priv(dev);
1489 SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | 1622 int err;
1490 SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full;
1491 ecmd->port = PORT_TP;
1492 ecmd->transceiver = XCVR_EXTERNAL;
1493 ecmd->phy_address = mdio_phy_addr;
1494 ecmd->speed = current_speed;
1495 ecmd->duplex = full_duplex ? DUPLEX_FULL : DUPLEX_HALF;
1496 ecmd->advertising = ADVERTISED_TP;
1497 1623
1498 if (current_duplex == autoneg && current_speed_selection == 0) 1624 spin_lock_irq(&np->lock);
1499 ecmd->advertising |= ADVERTISED_Autoneg; 1625 err = mii_ethtool_gset(&np->mii_if, cmd);
1500 else { 1626 spin_unlock_irq(&np->lock);
1501 ecmd->advertising |=
1502 ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
1503 ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full;
1504 if (current_speed_selection == 10)
1505 ecmd->advertising &= ~(ADVERTISED_100baseT_Half |
1506 ADVERTISED_100baseT_Full);
1507 else if (current_speed_selection == 100)
1508 ecmd->advertising &= ~(ADVERTISED_10baseT_Half |
1509 ADVERTISED_10baseT_Full);
1510 if (current_duplex == half)
1511 ecmd->advertising &= ~(ADVERTISED_10baseT_Full |
1512 ADVERTISED_100baseT_Full);
1513 else if (current_duplex == full)
1514 ecmd->advertising &= ~(ADVERTISED_10baseT_Half |
1515 ADVERTISED_100baseT_Half);
1516 }
1517 1627
1518 ecmd->autoneg = AUTONEG_ENABLE; 1628 /* The PHY may support 1000baseT, but the Etrax100 does not. */
1519 return 0; 1629 cmd->supported &= ~(SUPPORTED_1000baseT_Half
1630 | SUPPORTED_1000baseT_Full);
1631 return err;
1520} 1632}
1521 1633
1522static int e100_set_settings(struct net_device *dev, 1634static int e100_set_settings(struct net_device *dev,
@@ -1560,7 +1672,8 @@ static const struct ethtool_ops e100_ethtool_ops = {
1560static int 1672static int
1561e100_set_config(struct net_device *dev, struct ifmap *map) 1673e100_set_config(struct net_device *dev, struct ifmap *map)
1562{ 1674{
1563 struct net_local *np = (struct net_local *)dev->priv; 1675 struct net_local *np = netdev_priv(dev);
1676
1564 spin_lock(&np->lock); /* Preempt protection */ 1677 spin_lock(&np->lock); /* Preempt protection */
1565 1678
1566 switch(map->port) { 1679 switch(map->port) {
@@ -1612,7 +1725,6 @@ update_tx_stats(struct net_device_stats *es)
1612 es->collisions += 1725 es->collisions +=
1613 IO_EXTRACT(R_TR_COUNTERS, single_col, r) + 1726 IO_EXTRACT(R_TR_COUNTERS, single_col, r) +
1614 IO_EXTRACT(R_TR_COUNTERS, multiple_col, r); 1727 IO_EXTRACT(R_TR_COUNTERS, multiple_col, r);
1615 es->tx_errors += IO_EXTRACT(R_TR_COUNTERS, deferred, r);
1616} 1728}
1617 1729
1618/* 1730/*
@@ -1622,8 +1734,9 @@ update_tx_stats(struct net_device_stats *es)
1622static struct net_device_stats * 1734static struct net_device_stats *
1623e100_get_stats(struct net_device *dev) 1735e100_get_stats(struct net_device *dev)
1624{ 1736{
1625 struct net_local *lp = (struct net_local *)dev->priv; 1737 struct net_local *lp = netdev_priv(dev);
1626 unsigned long flags; 1738 unsigned long flags;
1739
1627 spin_lock_irqsave(&lp->lock, flags); 1740 spin_lock_irqsave(&lp->lock, flags);
1628 1741
1629 update_rx_stats(&lp->stats); 1742 update_rx_stats(&lp->stats);
@@ -1643,13 +1756,13 @@ e100_get_stats(struct net_device *dev)
1643static void 1756static void
1644set_multicast_list(struct net_device *dev) 1757set_multicast_list(struct net_device *dev)
1645{ 1758{
1646 struct net_local *lp = (struct net_local *)dev->priv; 1759 struct net_local *lp = netdev_priv(dev);
1647 int num_addr = dev->mc_count; 1760 int num_addr = dev->mc_count;
1648 unsigned long int lo_bits; 1761 unsigned long int lo_bits;
1649 unsigned long int hi_bits; 1762 unsigned long int hi_bits;
1763
1650 spin_lock(&lp->lock); 1764 spin_lock(&lp->lock);
1651 if (dev->flags & IFF_PROMISC) 1765 if (dev->flags & IFF_PROMISC) {
1652 {
1653 /* promiscuous mode */ 1766 /* promiscuous mode */
1654 lo_bits = 0xfffffffful; 1767 lo_bits = 0xfffffffful;
1655 hi_bits = 0xfffffffful; 1768 hi_bits = 0xfffffffful;
@@ -1679,9 +1792,10 @@ set_multicast_list(struct net_device *dev)
1679 struct dev_mc_list *dmi = dev->mc_list; 1792 struct dev_mc_list *dmi = dev->mc_list;
1680 int i; 1793 int i;
1681 char *baddr; 1794 char *baddr;
1795
1682 lo_bits = 0x00000000ul; 1796 lo_bits = 0x00000000ul;
1683 hi_bits = 0x00000000ul; 1797 hi_bits = 0x00000000ul;
1684 for (i=0; i<num_addr; i++) { 1798 for (i = 0; i < num_addr; i++) {
1685 /* Calculate the hash index for the GA registers */ 1799 /* Calculate the hash index for the GA registers */
1686 1800
1687 hash_ix = 0; 1801 hash_ix = 0;
@@ -1708,8 +1822,7 @@ set_multicast_list(struct net_device *dev)
1708 1822
1709 if (hash_ix >= 32) { 1823 if (hash_ix >= 32) {
1710 hi_bits |= (1 << (hash_ix-32)); 1824 hi_bits |= (1 << (hash_ix-32));
1711 } 1825 } else {
1712 else {
1713 lo_bits |= (1 << hash_ix); 1826 lo_bits |= (1 << hash_ix);
1714 } 1827 }
1715 dmi = dmi->next; 1828 dmi = dmi->next;
@@ -1724,10 +1837,11 @@ set_multicast_list(struct net_device *dev)
1724} 1837}
1725 1838
1726void 1839void
1727e100_hardware_send_packet(char *buf, int length) 1840e100_hardware_send_packet(struct net_local *np, char *buf, int length)
1728{ 1841{
1729 D(printk("e100 send pack, buf 0x%x len %d\n", buf, length)); 1842 D(printk("e100 send pack, buf 0x%x len %d\n", buf, length));
1730 1843
1844 spin_lock(&np->led_lock);
1731 if (!led_active && time_after(jiffies, led_next_time)) { 1845 if (!led_active && time_after(jiffies, led_next_time)) {
1732 /* light the network leds depending on the current speed. */ 1846 /* light the network leds depending on the current speed. */
1733 e100_set_network_leds(NETWORK_ACTIVITY); 1847 e100_set_network_leds(NETWORK_ACTIVITY);
@@ -1737,6 +1851,7 @@ e100_hardware_send_packet(char *buf, int length)
1737 led_active = 1; 1851 led_active = 1;
1738 mod_timer(&clear_led_timer, jiffies + HZ/10); 1852 mod_timer(&clear_led_timer, jiffies + HZ/10);
1739 } 1853 }
1854 spin_unlock(&np->led_lock);
1740 1855
1741 /* configure the tx dma descriptor */ 1856 /* configure the tx dma descriptor */
1742 myNextTxDesc->descr.sw_len = length; 1857 myNextTxDesc->descr.sw_len = length;
@@ -1754,6 +1869,11 @@ e100_hardware_send_packet(char *buf, int length)
1754static void 1869static void
1755e100_clear_network_leds(unsigned long dummy) 1870e100_clear_network_leds(unsigned long dummy)
1756{ 1871{
1872 struct net_device *dev = (struct net_device *)dummy;
1873 struct net_local *np = netdev_priv(dev);
1874
1875 spin_lock(&np->led_lock);
1876
1757 if (led_active && time_after(jiffies, led_next_time)) { 1877 if (led_active && time_after(jiffies, led_next_time)) {
1758 e100_set_network_leds(NO_NETWORK_ACTIVITY); 1878 e100_set_network_leds(NO_NETWORK_ACTIVITY);
1759 1879
@@ -1761,6 +1881,8 @@ e100_clear_network_leds(unsigned long dummy)
1761 led_next_time = jiffies + NET_FLASH_PAUSE; 1881 led_next_time = jiffies + NET_FLASH_PAUSE;
1762 led_active = 0; 1882 led_active = 0;
1763 } 1883 }
1884
1885 spin_unlock(&np->led_lock);
1764} 1886}
1765 1887
1766static void 1888static void
@@ -1781,19 +1903,25 @@ e100_set_network_leds(int active)
1781#else 1903#else
1782 LED_NETWORK_SET(LED_OFF); 1904 LED_NETWORK_SET(LED_OFF);
1783#endif 1905#endif
1784 } 1906 } else if (light_leds) {
1785 else if (light_leds) {
1786 if (current_speed == 10) { 1907 if (current_speed == 10) {
1787 LED_NETWORK_SET(LED_ORANGE); 1908 LED_NETWORK_SET(LED_ORANGE);
1788 } else { 1909 } else {
1789 LED_NETWORK_SET(LED_GREEN); 1910 LED_NETWORK_SET(LED_GREEN);
1790 } 1911 }
1791 } 1912 } else {
1792 else {
1793 LED_NETWORK_SET(LED_OFF); 1913 LED_NETWORK_SET(LED_OFF);
1794 } 1914 }
1795} 1915}
1796 1916
1917#ifdef CONFIG_NET_POLL_CONTROLLER
1918static void
1919e100_netpoll(struct net_device* netdev)
1920{
1921 e100rxtx_interrupt(NETWORK_DMA_TX_IRQ_NBR, netdev, NULL);
1922}
1923#endif
1924
1797static int 1925static int
1798etrax_init_module(void) 1926etrax_init_module(void)
1799{ 1927{
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 72deff0d4d90..cf39473ef90a 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -4804,6 +4804,7 @@ e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
4804 spin_unlock_irqrestore(&adapter->stats_lock, flags); 4804 spin_unlock_irqrestore(&adapter->stats_lock, flags);
4805 return -EIO; 4805 return -EIO;
4806 } 4806 }
4807 spin_unlock_irqrestore(&adapter->stats_lock, flags);
4807 if (adapter->hw.media_type == e1000_media_type_copper) { 4808 if (adapter->hw.media_type == e1000_media_type_copper) {
4808 switch (data->reg_num) { 4809 switch (data->reg_num) {
4809 case PHY_CTRL: 4810 case PHY_CTRL:
@@ -4824,12 +4825,8 @@ e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
4824 DUPLEX_HALF; 4825 DUPLEX_HALF;
4825 retval = e1000_set_spd_dplx(adapter, 4826 retval = e1000_set_spd_dplx(adapter,
4826 spddplx); 4827 spddplx);
4827 if (retval) { 4828 if (retval)
4828 spin_unlock_irqrestore(
4829 &adapter->stats_lock,
4830 flags);
4831 return retval; 4829 return retval;
4832 }
4833 } 4830 }
4834 if (netif_running(adapter->netdev)) 4831 if (netif_running(adapter->netdev))
4835 e1000_reinit_locked(adapter); 4832 e1000_reinit_locked(adapter);
@@ -4838,11 +4835,8 @@ e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
4838 break; 4835 break;
4839 case M88E1000_PHY_SPEC_CTRL: 4836 case M88E1000_PHY_SPEC_CTRL:
4840 case M88E1000_EXT_PHY_SPEC_CTRL: 4837 case M88E1000_EXT_PHY_SPEC_CTRL:
4841 if (e1000_phy_reset(&adapter->hw)) { 4838 if (e1000_phy_reset(&adapter->hw))
4842 spin_unlock_irqrestore(
4843 &adapter->stats_lock, flags);
4844 return -EIO; 4839 return -EIO;
4845 }
4846 break; 4840 break;
4847 } 4841 }
4848 } else { 4842 } else {
@@ -4857,7 +4851,6 @@ e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
4857 break; 4851 break;
4858 } 4852 }
4859 } 4853 }
4860 spin_unlock_irqrestore(&adapter->stats_lock, flags);
4861 break; 4854 break;
4862 default: 4855 default:
4863 return -EOPNOTSUPP; 4856 return -EOPNOTSUPP;
diff --git a/drivers/net/fs_enet/Kconfig b/drivers/net/fs_enet/Kconfig
index 2765e49e07df..562ea68ed99b 100644
--- a/drivers/net/fs_enet/Kconfig
+++ b/drivers/net/fs_enet/Kconfig
@@ -2,6 +2,7 @@ config FS_ENET
2 tristate "Freescale Ethernet Driver" 2 tristate "Freescale Ethernet Driver"
3 depends on CPM1 || CPM2 3 depends on CPM1 || CPM2
4 select MII 4 select MII
5 select PHYLIB
5 6
6config FS_ENET_HAS_SCC 7config FS_ENET_HAS_SCC
7 bool "Chip has an SCC usable for ethernet" 8 bool "Chip has an SCC usable for ethernet"
@@ -11,11 +12,19 @@ config FS_ENET_HAS_SCC
11config FS_ENET_HAS_FCC 12config FS_ENET_HAS_FCC
12 bool "Chip has an FCC usable for ethernet" 13 bool "Chip has an FCC usable for ethernet"
13 depends on FS_ENET && CPM2 14 depends on FS_ENET && CPM2
14 select MDIO_BITBANG
15 default y 15 default y
16 16
17config FS_ENET_HAS_FEC 17config FS_ENET_HAS_FEC
18 bool "Chip has an FEC usable for ethernet" 18 bool "Chip has an FEC usable for ethernet"
19 depends on FS_ENET && CPM1 19 depends on FS_ENET && CPM1
20 select FS_ENET_MDIO_FEC
20 default y 21 default y
21 22
23config FS_ENET_MDIO_FEC
24 tristate "MDIO driver for FEC"
25 depends on FS_ENET && CPM1
26
27config FS_ENET_MDIO_FCC
28 tristate "MDIO driver for FCC"
29 depends on FS_ENET && CPM2
30 select MDIO_BITBANG
diff --git a/drivers/net/fs_enet/Makefile b/drivers/net/fs_enet/Makefile
index 02d4dc18ba69..1ffbe0756a0c 100644
--- a/drivers/net/fs_enet/Makefile
+++ b/drivers/net/fs_enet/Makefile
@@ -4,7 +4,16 @@
4 4
5obj-$(CONFIG_FS_ENET) += fs_enet.o 5obj-$(CONFIG_FS_ENET) += fs_enet.o
6 6
7obj-$(CONFIG_8xx) += mac-fec.o mac-scc.o mii-fec.o 7fs_enet-$(CONFIG_FS_ENET_HAS_SCC) += mac-scc.o
8obj-$(CONFIG_CPM2) += mac-fcc.o mii-bitbang.o 8fs_enet-$(CONFIG_FS_ENET_HAS_FEC) += mac-fec.o
9fs_enet-$(CONFIG_FS_ENET_HAS_FCC) += mac-fcc.o
9 10
10fs_enet-objs := fs_enet-main.o 11ifeq ($(CONFIG_PPC_CPM_NEW_BINDING),y)
12obj-$(CONFIG_FS_ENET_MDIO_FEC) += mii-fec.o
13obj-$(CONFIG_FS_ENET_MDIO_FCC) += mii-bitbang.o
14else
15fs_enet-$(CONFIG_FS_ENET_MDIO_FEC) += mii-fec.o
16fs_enet-$(CONFIG_FS_ENET_MDIO_FCC) += mii-bitbang.o
17endif
18
19fs_enet-objs := fs_enet-main.o $(fs_enet-m)
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index e0119f6a3319..580cb4ab2af1 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -762,26 +762,20 @@ static int sixpack_ioctl(struct tty_struct *tty, struct file *file,
762 762
763 if (copy_from_user(&addr, 763 if (copy_from_user(&addr,
764 (void __user *) arg, AX25_ADDR_LEN)) { 764 (void __user *) arg, AX25_ADDR_LEN)) {
765 err = -EFAULT; 765 err = -EFAULT;
766 break; 766 break;
767 } 767 }
768 768
769 netif_tx_lock_bh(dev); 769 netif_tx_lock_bh(dev);
770 memcpy(dev->dev_addr, &addr, AX25_ADDR_LEN); 770 memcpy(dev->dev_addr, &addr, AX25_ADDR_LEN);
771 netif_tx_unlock_bh(dev); 771 netif_tx_unlock_bh(dev);
772 772
773 err = 0; 773 err = 0;
774 break; 774 break;
775 } 775 }
776
777 /* Allow stty to read, but not set, the serial port */
778 case TCGETS:
779 case TCGETA:
780 err = n_tty_ioctl(tty, (struct file *) file, cmd, arg);
781 break;
782 776
783 default: 777 default:
784 err = -ENOIOCTLCMD; 778 err = tty_mode_ioctl(tty, file, cmd, arg);
785 } 779 }
786 780
787 sp_put(sp); 781 sp_put(sp);
diff --git a/drivers/net/irda/irtty-sir.c b/drivers/net/irda/irtty-sir.c
index 2c6f7be36e8a..fc753d7f674e 100644
--- a/drivers/net/irda/irtty-sir.c
+++ b/drivers/net/irda/irtty-sir.c
@@ -434,11 +434,6 @@ static int irtty_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
434 IRDA_ASSERT(dev != NULL, return -1;); 434 IRDA_ASSERT(dev != NULL, return -1;);
435 435
436 switch (cmd) { 436 switch (cmd) {
437 case TCGETS:
438 case TCGETA:
439 err = n_tty_ioctl(tty, file, cmd, arg);
440 break;
441
442 case IRTTY_IOCTDONGLE: 437 case IRTTY_IOCTDONGLE:
443 /* this call blocks for completion */ 438 /* this call blocks for completion */
444 err = sirdev_set_dongle(dev, (IRDA_DONGLE) arg); 439 err = sirdev_set_dongle(dev, (IRDA_DONGLE) arg);
@@ -454,7 +449,7 @@ static int irtty_ioctl(struct tty_struct *tty, struct file *file, unsigned int c
454 err = -EFAULT; 449 err = -EFAULT;
455 break; 450 break;
456 default: 451 default:
457 err = -ENOIOCTLCMD; 452 err = tty_mode_ioctl(tty, file, cmd, arg);
458 break; 453 break;
459 } 454 }
460 return err; 455 return err;
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 45f30a2974b8..662b8d16803c 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -284,7 +284,7 @@ static __net_exit void loopback_net_exit(struct net *net)
284 unregister_netdev(dev); 284 unregister_netdev(dev);
285} 285}
286 286
287static struct pernet_operations loopback_net_ops = { 287static struct pernet_operations __net_initdata loopback_net_ops = {
288 .init = loopback_net_init, 288 .init = loopback_net_init,
289 .exit = loopback_net_exit, 289 .exit = loopback_net_exit,
290}; 290};
diff --git a/drivers/net/mlx4/alloc.c b/drivers/net/mlx4/alloc.c
index f8d63d39f592..b226e019bc8b 100644
--- a/drivers/net/mlx4/alloc.c
+++ b/drivers/net/mlx4/alloc.c
@@ -171,9 +171,10 @@ void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf)
171 buf->u.direct.map); 171 buf->u.direct.map);
172 else { 172 else {
173 for (i = 0; i < buf->nbufs; ++i) 173 for (i = 0; i < buf->nbufs; ++i)
174 dma_free_coherent(&dev->pdev->dev, PAGE_SIZE, 174 if (buf->u.page_list[i].buf)
175 buf->u.page_list[i].buf, 175 dma_free_coherent(&dev->pdev->dev, PAGE_SIZE,
176 buf->u.page_list[i].map); 176 buf->u.page_list[i].buf,
177 buf->u.page_list[i].map);
177 kfree(buf->u.page_list); 178 kfree(buf->u.page_list);
178 } 179 }
179} 180}
diff --git a/drivers/net/mlx4/qp.c b/drivers/net/mlx4/qp.c
index cc4b1be18219..42b47639c81c 100644
--- a/drivers/net/mlx4/qp.c
+++ b/drivers/net/mlx4/qp.c
@@ -240,7 +240,7 @@ void mlx4_qp_free(struct mlx4_dev *dev, struct mlx4_qp *qp)
240 mlx4_table_put(dev, &qp_table->auxc_table, qp->qpn); 240 mlx4_table_put(dev, &qp_table->auxc_table, qp->qpn);
241 mlx4_table_put(dev, &qp_table->qp_table, qp->qpn); 241 mlx4_table_put(dev, &qp_table->qp_table, qp->qpn);
242 242
243 if (qp->qpn < dev->caps.sqp_start + 8) 243 if (qp->qpn >= dev->caps.sqp_start + 8)
244 mlx4_bitmap_free(&qp_table->bitmap, qp->qpn); 244 mlx4_bitmap_free(&qp_table->bitmap, qp->qpn);
245} 245}
246EXPORT_SYMBOL_GPL(mlx4_qp_free); 246EXPORT_SYMBOL_GPL(mlx4_qp_free);
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c
index 8d29319cc5cb..656a260fc956 100644
--- a/drivers/net/myri_sbus.c
+++ b/drivers/net/myri_sbus.c
@@ -134,7 +134,7 @@ static int myri_do_handshake(struct myri_eth *mp)
134 134
135 myri_disable_irq(mp->lregs, cregs); 135 myri_disable_irq(mp->lregs, cregs);
136 136
137 while (tick++ <= 25) { 137 while (tick++ < 25) {
138 u32 softstate; 138 u32 softstate;
139 139
140 /* Wake it up. */ 140 /* Wake it up. */
diff --git a/drivers/net/netx-eth.c b/drivers/net/netx-eth.c
index eb0aff787dfd..5267e031daa0 100644
--- a/drivers/net/netx-eth.c
+++ b/drivers/net/netx-eth.c
@@ -128,8 +128,8 @@ netx_eth_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
128 FIFO_PTR_FRAMELEN(len)); 128 FIFO_PTR_FRAMELEN(len));
129 129
130 ndev->trans_start = jiffies; 130 ndev->trans_start = jiffies;
131 dev->stats.tx_packets++; 131 ndev->stats.tx_packets++;
132 dev->stats.tx_bytes += skb->len; 132 ndev->stats.tx_bytes += skb->len;
133 133
134 netif_stop_queue(ndev); 134 netif_stop_queue(ndev);
135 spin_unlock_irq(&priv->lock); 135 spin_unlock_irq(&priv->lock);
@@ -155,7 +155,7 @@ static void netx_eth_receive(struct net_device *ndev)
155 if (unlikely(skb == NULL)) { 155 if (unlikely(skb == NULL)) {
156 printk(KERN_NOTICE "%s: Low memory, packet dropped.\n", 156 printk(KERN_NOTICE "%s: Low memory, packet dropped.\n",
157 ndev->name); 157 ndev->name);
158 dev->stats.rx_dropped++; 158 ndev->stats.rx_dropped++;
159 return; 159 return;
160 } 160 }
161 161
diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c
index ab4d309a858f..09b4fde8d924 100644
--- a/drivers/net/pasemi_mac.c
+++ b/drivers/net/pasemi_mac.c
@@ -580,6 +580,16 @@ static int pasemi_mac_clean_rx(struct pasemi_mac *mac, int limit)
580 580
581 len = (macrx & XCT_MACRX_LLEN_M) >> XCT_MACRX_LLEN_S; 581 len = (macrx & XCT_MACRX_LLEN_M) >> XCT_MACRX_LLEN_S;
582 582
583 pci_unmap_single(mac->dma_pdev, dma, len, PCI_DMA_FROMDEVICE);
584
585 if (macrx & XCT_MACRX_CRC) {
586 /* CRC error flagged */
587 mac->netdev->stats.rx_errors++;
588 mac->netdev->stats.rx_crc_errors++;
589 dev_kfree_skb_irq(skb);
590 goto next;
591 }
592
583 if (len < 256) { 593 if (len < 256) {
584 struct sk_buff *new_skb; 594 struct sk_buff *new_skb;
585 595
@@ -595,11 +605,10 @@ static int pasemi_mac_clean_rx(struct pasemi_mac *mac, int limit)
595 } else 605 } else
596 info->skb = NULL; 606 info->skb = NULL;
597 607
598 pci_unmap_single(mac->dma_pdev, dma, len, PCI_DMA_FROMDEVICE);
599
600 info->dma = 0; 608 info->dma = 0;
601 609
602 skb_put(skb, len); 610 /* Don't include CRC */
611 skb_put(skb, len-4);
603 612
604 if (likely((macrx & XCT_MACRX_HTY_M) == XCT_MACRX_HTY_IPV4_OK)) { 613 if (likely((macrx & XCT_MACRX_HTY_M) == XCT_MACRX_HTY_IPV4_OK)) {
605 skb->ip_summed = CHECKSUM_UNNECESSARY; 614 skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -614,6 +623,7 @@ static int pasemi_mac_clean_rx(struct pasemi_mac *mac, int limit)
614 skb->protocol = eth_type_trans(skb, mac->netdev); 623 skb->protocol = eth_type_trans(skb, mac->netdev);
615 netif_receive_skb(skb); 624 netif_receive_skb(skb);
616 625
626next:
617 RX_RING(mac, n) = 0; 627 RX_RING(mac, n) = 0;
618 RX_RING(mac, n+1) = 0; 628 RX_RING(mac, n+1) = 0;
619 629
@@ -1126,7 +1136,7 @@ static int pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev)
1126 unsigned long flags; 1136 unsigned long flags;
1127 int i, nfrags; 1137 int i, nfrags;
1128 1138
1129 dflags = XCT_MACTX_O | XCT_MACTX_ST | XCT_MACTX_SS | XCT_MACTX_CRC_PAD; 1139 dflags = XCT_MACTX_O | XCT_MACTX_ST | XCT_MACTX_CRC_PAD;
1130 1140
1131 if (skb->ip_summed == CHECKSUM_PARTIAL) { 1141 if (skb->ip_summed == CHECKSUM_PARTIAL) {
1132 const unsigned char *nh = skb_network_header(skb); 1142 const unsigned char *nh = skb_network_header(skb);
diff --git a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c
index 27f5b904f48e..f023d5b67e6e 100644
--- a/drivers/net/ppp_async.c
+++ b/drivers/net/ppp_async.c
@@ -160,7 +160,7 @@ ppp_asynctty_open(struct tty_struct *tty)
160 160
161 err = -ENOMEM; 161 err = -ENOMEM;
162 ap = kzalloc(sizeof(*ap), GFP_KERNEL); 162 ap = kzalloc(sizeof(*ap), GFP_KERNEL);
163 if (ap == 0) 163 if (!ap)
164 goto out; 164 goto out;
165 165
166 /* initialize the asyncppp structure */ 166 /* initialize the asyncppp structure */
@@ -215,7 +215,7 @@ ppp_asynctty_close(struct tty_struct *tty)
215 ap = tty->disc_data; 215 ap = tty->disc_data;
216 tty->disc_data = NULL; 216 tty->disc_data = NULL;
217 write_unlock_irq(&disc_data_lock); 217 write_unlock_irq(&disc_data_lock);
218 if (ap == 0) 218 if (!ap)
219 return; 219 return;
220 220
221 /* 221 /*
@@ -230,10 +230,10 @@ ppp_asynctty_close(struct tty_struct *tty)
230 tasklet_kill(&ap->tsk); 230 tasklet_kill(&ap->tsk);
231 231
232 ppp_unregister_channel(&ap->chan); 232 ppp_unregister_channel(&ap->chan);
233 if (ap->rpkt != 0) 233 if (ap->rpkt)
234 kfree_skb(ap->rpkt); 234 kfree_skb(ap->rpkt);
235 skb_queue_purge(&ap->rqueue); 235 skb_queue_purge(&ap->rqueue);
236 if (ap->tpkt != 0) 236 if (ap->tpkt)
237 kfree_skb(ap->tpkt); 237 kfree_skb(ap->tpkt);
238 kfree(ap); 238 kfree(ap);
239} 239}
@@ -285,13 +285,13 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file,
285 int err, val; 285 int err, val;
286 int __user *p = (int __user *)arg; 286 int __user *p = (int __user *)arg;
287 287
288 if (ap == 0) 288 if (!ap)
289 return -ENXIO; 289 return -ENXIO;
290 err = -EFAULT; 290 err = -EFAULT;
291 switch (cmd) { 291 switch (cmd) {
292 case PPPIOCGCHAN: 292 case PPPIOCGCHAN:
293 err = -ENXIO; 293 err = -ENXIO;
294 if (ap == 0) 294 if (!ap)
295 break; 295 break;
296 err = -EFAULT; 296 err = -EFAULT;
297 if (put_user(ppp_channel_index(&ap->chan), p)) 297 if (put_user(ppp_channel_index(&ap->chan), p))
@@ -301,7 +301,7 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file,
301 301
302 case PPPIOCGUNIT: 302 case PPPIOCGUNIT:
303 err = -ENXIO; 303 err = -ENXIO;
304 if (ap == 0) 304 if (!ap)
305 break; 305 break;
306 err = -EFAULT; 306 err = -EFAULT;
307 if (put_user(ppp_unit_number(&ap->chan), p)) 307 if (put_user(ppp_unit_number(&ap->chan), p))
@@ -309,16 +309,11 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file,
309 err = 0; 309 err = 0;
310 break; 310 break;
311 311
312 case TCGETS:
313 case TCGETA:
314 err = n_tty_ioctl(tty, file, cmd, arg);
315 break;
316
317 case TCFLSH: 312 case TCFLSH:
318 /* flush our buffers and the serial port's buffer */ 313 /* flush our buffers and the serial port's buffer */
319 if (arg == TCIOFLUSH || arg == TCOFLUSH) 314 if (arg == TCIOFLUSH || arg == TCOFLUSH)
320 ppp_async_flush_output(ap); 315 ppp_async_flush_output(ap);
321 err = n_tty_ioctl(tty, file, cmd, arg); 316 err = tty_perform_flush(tty, arg);
322 break; 317 break;
323 318
324 case FIONREAD: 319 case FIONREAD:
@@ -329,7 +324,8 @@ ppp_asynctty_ioctl(struct tty_struct *tty, struct file *file,
329 break; 324 break;
330 325
331 default: 326 default:
332 err = -ENOIOCTLCMD; 327 /* Try the various mode ioctls */
328 err = tty_mode_ioctl(tty, file, cmd, arg);
333 } 329 }
334 330
335 ap_put(ap); 331 ap_put(ap);
@@ -354,7 +350,7 @@ ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf,
354 struct asyncppp *ap = ap_get(tty); 350 struct asyncppp *ap = ap_get(tty);
355 unsigned long flags; 351 unsigned long flags;
356 352
357 if (ap == 0) 353 if (!ap)
358 return; 354 return;
359 spin_lock_irqsave(&ap->recv_lock, flags); 355 spin_lock_irqsave(&ap->recv_lock, flags);
360 ppp_async_input(ap, buf, cflags, count); 356 ppp_async_input(ap, buf, cflags, count);
@@ -373,7 +369,7 @@ ppp_asynctty_wakeup(struct tty_struct *tty)
373 struct asyncppp *ap = ap_get(tty); 369 struct asyncppp *ap = ap_get(tty);
374 370
375 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); 371 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
376 if (ap == 0) 372 if (!ap)
377 return; 373 return;
378 set_bit(XMIT_WAKEUP, &ap->xmit_flags); 374 set_bit(XMIT_WAKEUP, &ap->xmit_flags);
379 tasklet_schedule(&ap->tsk); 375 tasklet_schedule(&ap->tsk);
@@ -688,7 +684,7 @@ ppp_async_push(struct asyncppp *ap)
688 tty_stuffed = 1; 684 tty_stuffed = 1;
689 continue; 685 continue;
690 } 686 }
691 if (ap->optr >= ap->olim && ap->tpkt != 0) { 687 if (ap->optr >= ap->olim && ap->tpkt) {
692 if (ppp_async_encode(ap)) { 688 if (ppp_async_encode(ap)) {
693 /* finished processing ap->tpkt */ 689 /* finished processing ap->tpkt */
694 clear_bit(XMIT_FULL, &ap->xmit_flags); 690 clear_bit(XMIT_FULL, &ap->xmit_flags);
@@ -708,7 +704,7 @@ ppp_async_push(struct asyncppp *ap)
708 clear_bit(XMIT_BUSY, &ap->xmit_flags); 704 clear_bit(XMIT_BUSY, &ap->xmit_flags);
709 /* any more work to do? if not, exit the loop */ 705 /* any more work to do? if not, exit the loop */
710 if (!(test_bit(XMIT_WAKEUP, &ap->xmit_flags) 706 if (!(test_bit(XMIT_WAKEUP, &ap->xmit_flags)
711 || (!tty_stuffed && ap->tpkt != 0))) 707 || (!tty_stuffed && ap->tpkt)))
712 break; 708 break;
713 /* more work to do, see if we can do it now */ 709 /* more work to do, see if we can do it now */
714 if (test_and_set_bit(XMIT_BUSY, &ap->xmit_flags)) 710 if (test_and_set_bit(XMIT_BUSY, &ap->xmit_flags))
@@ -719,7 +715,7 @@ ppp_async_push(struct asyncppp *ap)
719 715
720flush: 716flush:
721 clear_bit(XMIT_BUSY, &ap->xmit_flags); 717 clear_bit(XMIT_BUSY, &ap->xmit_flags);
722 if (ap->tpkt != 0) { 718 if (ap->tpkt) {
723 kfree_skb(ap->tpkt); 719 kfree_skb(ap->tpkt);
724 ap->tpkt = NULL; 720 ap->tpkt = NULL;
725 clear_bit(XMIT_FULL, &ap->xmit_flags); 721 clear_bit(XMIT_FULL, &ap->xmit_flags);
@@ -852,7 +848,7 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf,
852 s = 0; 848 s = 0;
853 for (i = 0; i < count; ++i) { 849 for (i = 0; i < count; ++i) {
854 c = buf[i]; 850 c = buf[i];
855 if (flags != 0 && flags[i] != 0) 851 if (flags && flags[i] != 0)
856 continue; 852 continue;
857 s |= (c & 0x80)? SC_RCV_B7_1: SC_RCV_B7_0; 853 s |= (c & 0x80)? SC_RCV_B7_1: SC_RCV_B7_0;
858 c = ((c >> 4) ^ c) & 0xf; 854 c = ((c >> 4) ^ c) & 0xf;
@@ -869,7 +865,7 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf,
869 n = scan_ordinary(ap, buf, count); 865 n = scan_ordinary(ap, buf, count);
870 866
871 f = 0; 867 f = 0;
872 if (flags != 0 && (ap->state & SC_TOSS) == 0) { 868 if (flags && (ap->state & SC_TOSS) == 0) {
873 /* check the flags to see if any char had an error */ 869 /* check the flags to see if any char had an error */
874 for (j = 0; j < n; ++j) 870 for (j = 0; j < n; ++j)
875 if ((f = flags[j]) != 0) 871 if ((f = flags[j]) != 0)
@@ -882,9 +878,9 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf,
882 } else if (n > 0 && (ap->state & SC_TOSS) == 0) { 878 } else if (n > 0 && (ap->state & SC_TOSS) == 0) {
883 /* stuff the chars in the skb */ 879 /* stuff the chars in the skb */
884 skb = ap->rpkt; 880 skb = ap->rpkt;
885 if (skb == 0) { 881 if (!skb) {
886 skb = dev_alloc_skb(ap->mru + PPP_HDRLEN + 2); 882 skb = dev_alloc_skb(ap->mru + PPP_HDRLEN + 2);
887 if (skb == 0) 883 if (!skb)
888 goto nomem; 884 goto nomem;
889 ap->rpkt = skb; 885 ap->rpkt = skb;
890 } 886 }
@@ -931,7 +927,7 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf,
931 ++n; 927 ++n;
932 928
933 buf += n; 929 buf += n;
934 if (flags != 0) 930 if (flags)
935 flags += n; 931 flags += n;
936 count -= n; 932 count -= n;
937 } 933 }
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 4b49d0e8c7eb..4f690378bb77 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -367,7 +367,7 @@ static int ppp_release(struct inode *inode, struct file *file)
367 struct ppp_file *pf = file->private_data; 367 struct ppp_file *pf = file->private_data;
368 struct ppp *ppp; 368 struct ppp *ppp;
369 369
370 if (pf != 0) { 370 if (pf) {
371 file->private_data = NULL; 371 file->private_data = NULL;
372 if (pf->kind == INTERFACE) { 372 if (pf->kind == INTERFACE) {
373 ppp = PF_TO_PPP(pf); 373 ppp = PF_TO_PPP(pf);
@@ -398,7 +398,7 @@ static ssize_t ppp_read(struct file *file, char __user *buf,
398 398
399 ret = count; 399 ret = count;
400 400
401 if (pf == 0) 401 if (!pf)
402 return -ENXIO; 402 return -ENXIO;
403 add_wait_queue(&pf->rwait, &wait); 403 add_wait_queue(&pf->rwait, &wait);
404 for (;;) { 404 for (;;) {
@@ -431,7 +431,7 @@ static ssize_t ppp_read(struct file *file, char __user *buf,
431 set_current_state(TASK_RUNNING); 431 set_current_state(TASK_RUNNING);
432 remove_wait_queue(&pf->rwait, &wait); 432 remove_wait_queue(&pf->rwait, &wait);
433 433
434 if (skb == 0) 434 if (!skb)
435 goto out; 435 goto out;
436 436
437 ret = -EOVERFLOW; 437 ret = -EOVERFLOW;
@@ -455,11 +455,11 @@ static ssize_t ppp_write(struct file *file, const char __user *buf,
455 struct sk_buff *skb; 455 struct sk_buff *skb;
456 ssize_t ret; 456 ssize_t ret;
457 457
458 if (pf == 0) 458 if (!pf)
459 return -ENXIO; 459 return -ENXIO;
460 ret = -ENOMEM; 460 ret = -ENOMEM;
461 skb = alloc_skb(count + pf->hdrlen, GFP_KERNEL); 461 skb = alloc_skb(count + pf->hdrlen, GFP_KERNEL);
462 if (skb == 0) 462 if (!skb)
463 goto out; 463 goto out;
464 skb_reserve(skb, pf->hdrlen); 464 skb_reserve(skb, pf->hdrlen);
465 ret = -EFAULT; 465 ret = -EFAULT;
@@ -491,11 +491,11 @@ static unsigned int ppp_poll(struct file *file, poll_table *wait)
491 struct ppp_file *pf = file->private_data; 491 struct ppp_file *pf = file->private_data;
492 unsigned int mask; 492 unsigned int mask;
493 493
494 if (pf == 0) 494 if (!pf)
495 return 0; 495 return 0;
496 poll_wait(file, &pf->rwait, wait); 496 poll_wait(file, &pf->rwait, wait);
497 mask = POLLOUT | POLLWRNORM; 497 mask = POLLOUT | POLLWRNORM;
498 if (skb_peek(&pf->rq) != 0) 498 if (skb_peek(&pf->rq))
499 mask |= POLLIN | POLLRDNORM; 499 mask |= POLLIN | POLLRDNORM;
500 if (pf->dead) 500 if (pf->dead)
501 mask |= POLLHUP; 501 mask |= POLLHUP;
@@ -559,7 +559,7 @@ static int ppp_ioctl(struct inode *inode, struct file *file,
559 void __user *argp = (void __user *)arg; 559 void __user *argp = (void __user *)arg;
560 int __user *p = argp; 560 int __user *p = argp;
561 561
562 if (pf == 0) 562 if (!pf)
563 return ppp_unattached_ioctl(pf, file, cmd, arg); 563 return ppp_unattached_ioctl(pf, file, cmd, arg);
564 564
565 if (cmd == PPPIOCDETACH) { 565 if (cmd == PPPIOCDETACH) {
@@ -689,13 +689,13 @@ static int ppp_ioctl(struct inode *inode, struct file *file,
689 val &= 0xffff; 689 val &= 0xffff;
690 } 690 }
691 vj = slhc_init(val2+1, val+1); 691 vj = slhc_init(val2+1, val+1);
692 if (vj == 0) { 692 if (!vj) {
693 printk(KERN_ERR "PPP: no memory (VJ compressor)\n"); 693 printk(KERN_ERR "PPP: no memory (VJ compressor)\n");
694 err = -ENOMEM; 694 err = -ENOMEM;
695 break; 695 break;
696 } 696 }
697 ppp_lock(ppp); 697 ppp_lock(ppp);
698 if (ppp->vj != 0) 698 if (ppp->vj)
699 slhc_free(ppp->vj); 699 slhc_free(ppp->vj);
700 ppp->vj = vj; 700 ppp->vj = vj;
701 ppp_unlock(ppp); 701 ppp_unlock(ppp);
@@ -786,7 +786,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file,
786 if (get_user(unit, p)) 786 if (get_user(unit, p))
787 break; 787 break;
788 ppp = ppp_create_interface(unit, &err); 788 ppp = ppp_create_interface(unit, &err);
789 if (ppp == 0) 789 if (!ppp)
790 break; 790 break;
791 file->private_data = &ppp->file; 791 file->private_data = &ppp->file;
792 ppp->owner = file; 792 ppp->owner = file;
@@ -803,7 +803,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file,
803 mutex_lock(&all_ppp_mutex); 803 mutex_lock(&all_ppp_mutex);
804 err = -ENXIO; 804 err = -ENXIO;
805 ppp = ppp_find_unit(unit); 805 ppp = ppp_find_unit(unit);
806 if (ppp != 0) { 806 if (ppp) {
807 atomic_inc(&ppp->file.refcnt); 807 atomic_inc(&ppp->file.refcnt);
808 file->private_data = &ppp->file; 808 file->private_data = &ppp->file;
809 err = 0; 809 err = 0;
@@ -817,7 +817,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file,
817 spin_lock_bh(&all_channels_lock); 817 spin_lock_bh(&all_channels_lock);
818 err = -ENXIO; 818 err = -ENXIO;
819 chan = ppp_find_channel(unit); 819 chan = ppp_find_channel(unit);
820 if (chan != 0) { 820 if (chan) {
821 atomic_inc(&chan->file.refcnt); 821 atomic_inc(&chan->file.refcnt);
822 file->private_data = &chan->file; 822 file->private_data = &chan->file;
823 err = 0; 823 err = 0;
@@ -946,9 +946,9 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
946 946
947 case SIOCGPPPCSTATS: 947 case SIOCGPPPCSTATS:
948 memset(&cstats, 0, sizeof(cstats)); 948 memset(&cstats, 0, sizeof(cstats));
949 if (ppp->xc_state != 0) 949 if (ppp->xc_state)
950 ppp->xcomp->comp_stat(ppp->xc_state, &cstats.c); 950 ppp->xcomp->comp_stat(ppp->xc_state, &cstats.c);
951 if (ppp->rc_state != 0) 951 if (ppp->rc_state)
952 ppp->rcomp->decomp_stat(ppp->rc_state, &cstats.d); 952 ppp->rcomp->decomp_stat(ppp->rc_state, &cstats.d);
953 if (copy_to_user(addr, &cstats, sizeof(cstats))) 953 if (copy_to_user(addr, &cstats, sizeof(cstats)))
954 break; 954 break;
@@ -993,14 +993,14 @@ ppp_xmit_process(struct ppp *ppp)
993 struct sk_buff *skb; 993 struct sk_buff *skb;
994 994
995 ppp_xmit_lock(ppp); 995 ppp_xmit_lock(ppp);
996 if (ppp->dev != 0) { 996 if (ppp->dev) {
997 ppp_push(ppp); 997 ppp_push(ppp);
998 while (ppp->xmit_pending == 0 998 while (!ppp->xmit_pending
999 && (skb = skb_dequeue(&ppp->file.xq)) != 0) 999 && (skb = skb_dequeue(&ppp->file.xq)))
1000 ppp_send_frame(ppp, skb); 1000 ppp_send_frame(ppp, skb);
1001 /* If there's no work left to do, tell the core net 1001 /* If there's no work left to do, tell the core net
1002 code that we can accept some more. */ 1002 code that we can accept some more. */
1003 if (ppp->xmit_pending == 0 && skb_peek(&ppp->file.xq) == 0) 1003 if (!ppp->xmit_pending && !skb_peek(&ppp->file.xq))
1004 netif_wake_queue(ppp->dev); 1004 netif_wake_queue(ppp->dev);
1005 } 1005 }
1006 ppp_xmit_unlock(ppp); 1006 ppp_xmit_unlock(ppp);
@@ -1100,12 +1100,12 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
1100 1100
1101 switch (proto) { 1101 switch (proto) {
1102 case PPP_IP: 1102 case PPP_IP:
1103 if (ppp->vj == 0 || (ppp->flags & SC_COMP_TCP) == 0) 1103 if (!ppp->vj || (ppp->flags & SC_COMP_TCP) == 0)
1104 break; 1104 break;
1105 /* try to do VJ TCP header compression */ 1105 /* try to do VJ TCP header compression */
1106 new_skb = alloc_skb(skb->len + ppp->dev->hard_header_len - 2, 1106 new_skb = alloc_skb(skb->len + ppp->dev->hard_header_len - 2,
1107 GFP_ATOMIC); 1107 GFP_ATOMIC);
1108 if (new_skb == 0) { 1108 if (!new_skb) {
1109 printk(KERN_ERR "PPP: no memory (VJ comp pkt)\n"); 1109 printk(KERN_ERR "PPP: no memory (VJ comp pkt)\n");
1110 goto drop; 1110 goto drop;
1111 } 1111 }
@@ -1140,7 +1140,7 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
1140 } 1140 }
1141 1141
1142 /* try to do packet compression */ 1142 /* try to do packet compression */
1143 if ((ppp->xstate & SC_COMP_RUN) && ppp->xc_state != 0 1143 if ((ppp->xstate & SC_COMP_RUN) && ppp->xc_state
1144 && proto != PPP_LCP && proto != PPP_CCP) { 1144 && proto != PPP_LCP && proto != PPP_CCP) {
1145 if (!(ppp->flags & SC_CCP_UP) && (ppp->flags & SC_MUST_COMP)) { 1145 if (!(ppp->flags & SC_CCP_UP) && (ppp->flags & SC_MUST_COMP)) {
1146 if (net_ratelimit()) 1146 if (net_ratelimit())
@@ -1185,7 +1185,7 @@ ppp_push(struct ppp *ppp)
1185 struct channel *pch; 1185 struct channel *pch;
1186 struct sk_buff *skb = ppp->xmit_pending; 1186 struct sk_buff *skb = ppp->xmit_pending;
1187 1187
1188 if (skb == 0) 1188 if (!skb)
1189 return; 1189 return;
1190 1190
1191 list = &ppp->channels; 1191 list = &ppp->channels;
@@ -1355,7 +1355,7 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
1355 if (flen == len && nfree == 0) 1355 if (flen == len && nfree == 0)
1356 bits |= E; 1356 bits |= E;
1357 frag = alloc_skb(flen + hdrlen + (flen == 0), GFP_ATOMIC); 1357 frag = alloc_skb(flen + hdrlen + (flen == 0), GFP_ATOMIC);
1358 if (frag == 0) 1358 if (!frag)
1359 goto noskb; 1359 goto noskb;
1360 q = skb_put(frag, flen + hdrlen); 1360 q = skb_put(frag, flen + hdrlen);
1361 1361
@@ -1425,7 +1425,7 @@ ppp_channel_push(struct channel *pch)
1425 struct ppp *ppp; 1425 struct ppp *ppp;
1426 1426
1427 spin_lock_bh(&pch->downl); 1427 spin_lock_bh(&pch->downl);
1428 if (pch->chan != 0) { 1428 if (pch->chan) {
1429 while (!skb_queue_empty(&pch->file.xq)) { 1429 while (!skb_queue_empty(&pch->file.xq)) {
1430 skb = skb_dequeue(&pch->file.xq); 1430 skb = skb_dequeue(&pch->file.xq);
1431 if (!pch->chan->ops->start_xmit(pch->chan, skb)) { 1431 if (!pch->chan->ops->start_xmit(pch->chan, skb)) {
@@ -1443,7 +1443,7 @@ ppp_channel_push(struct channel *pch)
1443 if (skb_queue_empty(&pch->file.xq)) { 1443 if (skb_queue_empty(&pch->file.xq)) {
1444 read_lock_bh(&pch->upl); 1444 read_lock_bh(&pch->upl);
1445 ppp = pch->ppp; 1445 ppp = pch->ppp;
1446 if (ppp != 0) 1446 if (ppp)
1447 ppp_xmit_process(ppp); 1447 ppp_xmit_process(ppp);
1448 read_unlock_bh(&pch->upl); 1448 read_unlock_bh(&pch->upl);
1449 } 1449 }
@@ -1462,7 +1462,7 @@ ppp_do_recv(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
1462{ 1462{
1463 ppp_recv_lock(ppp); 1463 ppp_recv_lock(ppp);
1464 /* ppp->dev == 0 means interface is closing down */ 1464 /* ppp->dev == 0 means interface is closing down */
1465 if (ppp->dev != 0) 1465 if (ppp->dev)
1466 ppp_receive_frame(ppp, skb, pch); 1466 ppp_receive_frame(ppp, skb, pch);
1467 else 1467 else
1468 kfree_skb(skb); 1468 kfree_skb(skb);
@@ -1475,19 +1475,19 @@ ppp_input(struct ppp_channel *chan, struct sk_buff *skb)
1475 struct channel *pch = chan->ppp; 1475 struct channel *pch = chan->ppp;
1476 int proto; 1476 int proto;
1477 1477
1478 if (pch == 0 || skb->len == 0) { 1478 if (!pch || skb->len == 0) {
1479 kfree_skb(skb); 1479 kfree_skb(skb);
1480 return; 1480 return;
1481 } 1481 }
1482 1482
1483 proto = PPP_PROTO(skb); 1483 proto = PPP_PROTO(skb);
1484 read_lock_bh(&pch->upl); 1484 read_lock_bh(&pch->upl);
1485 if (pch->ppp == 0 || proto >= 0xc000 || proto == PPP_CCPFRAG) { 1485 if (!pch->ppp || proto >= 0xc000 || proto == PPP_CCPFRAG) {
1486 /* put it on the channel queue */ 1486 /* put it on the channel queue */
1487 skb_queue_tail(&pch->file.rq, skb); 1487 skb_queue_tail(&pch->file.rq, skb);
1488 /* drop old frames if queue too long */ 1488 /* drop old frames if queue too long */
1489 while (pch->file.rq.qlen > PPP_MAX_RQLEN 1489 while (pch->file.rq.qlen > PPP_MAX_RQLEN
1490 && (skb = skb_dequeue(&pch->file.rq)) != 0) 1490 && (skb = skb_dequeue(&pch->file.rq)))
1491 kfree_skb(skb); 1491 kfree_skb(skb);
1492 wake_up_interruptible(&pch->file.rwait); 1492 wake_up_interruptible(&pch->file.rwait);
1493 } else { 1493 } else {
@@ -1503,13 +1503,13 @@ ppp_input_error(struct ppp_channel *chan, int code)
1503 struct channel *pch = chan->ppp; 1503 struct channel *pch = chan->ppp;
1504 struct sk_buff *skb; 1504 struct sk_buff *skb;
1505 1505
1506 if (pch == 0) 1506 if (!pch)
1507 return; 1507 return;
1508 1508
1509 read_lock_bh(&pch->upl); 1509 read_lock_bh(&pch->upl);
1510 if (pch->ppp != 0) { 1510 if (pch->ppp) {
1511 skb = alloc_skb(0, GFP_ATOMIC); 1511 skb = alloc_skb(0, GFP_ATOMIC);
1512 if (skb != 0) { 1512 if (skb) {
1513 skb->len = 0; /* probably unnecessary */ 1513 skb->len = 0; /* probably unnecessary */
1514 skb->cb[0] = code; 1514 skb->cb[0] = code;
1515 ppp_do_recv(pch->ppp, skb, pch); 1515 ppp_do_recv(pch->ppp, skb, pch);
@@ -1548,7 +1548,7 @@ static void
1548ppp_receive_error(struct ppp *ppp) 1548ppp_receive_error(struct ppp *ppp)
1549{ 1549{
1550 ++ppp->stats.rx_errors; 1550 ++ppp->stats.rx_errors;
1551 if (ppp->vj != 0) 1551 if (ppp->vj)
1552 slhc_toss(ppp->vj); 1552 slhc_toss(ppp->vj);
1553} 1553}
1554 1554
@@ -1563,7 +1563,7 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
1563 * Note that some decompressors need to see uncompressed frames 1563 * Note that some decompressors need to see uncompressed frames
1564 * that come in as well as compressed frames. 1564 * that come in as well as compressed frames.
1565 */ 1565 */
1566 if (ppp->rc_state != 0 && (ppp->rstate & SC_DECOMP_RUN) 1566 if (ppp->rc_state && (ppp->rstate & SC_DECOMP_RUN)
1567 && (ppp->rstate & (SC_DC_FERROR | SC_DC_ERROR)) == 0) 1567 && (ppp->rstate & (SC_DC_FERROR | SC_DC_ERROR)) == 0)
1568 skb = ppp_decompress_frame(ppp, skb); 1568 skb = ppp_decompress_frame(ppp, skb);
1569 1569
@@ -1574,13 +1574,13 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
1574 switch (proto) { 1574 switch (proto) {
1575 case PPP_VJC_COMP: 1575 case PPP_VJC_COMP:
1576 /* decompress VJ compressed packets */ 1576 /* decompress VJ compressed packets */
1577 if (ppp->vj == 0 || (ppp->flags & SC_REJ_COMP_TCP)) 1577 if (!ppp->vj || (ppp->flags & SC_REJ_COMP_TCP))
1578 goto err; 1578 goto err;
1579 1579
1580 if (skb_tailroom(skb) < 124 || skb_cloned(skb)) { 1580 if (skb_tailroom(skb) < 124 || skb_cloned(skb)) {
1581 /* copy to a new sk_buff with more tailroom */ 1581 /* copy to a new sk_buff with more tailroom */
1582 ns = dev_alloc_skb(skb->len + 128); 1582 ns = dev_alloc_skb(skb->len + 128);
1583 if (ns == 0) { 1583 if (!ns) {
1584 printk(KERN_ERR"PPP: no memory (VJ decomp)\n"); 1584 printk(KERN_ERR"PPP: no memory (VJ decomp)\n");
1585 goto err; 1585 goto err;
1586 } 1586 }
@@ -1606,7 +1606,7 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
1606 break; 1606 break;
1607 1607
1608 case PPP_VJC_UNCOMP: 1608 case PPP_VJC_UNCOMP:
1609 if (ppp->vj == 0 || (ppp->flags & SC_REJ_COMP_TCP)) 1609 if (!ppp->vj || (ppp->flags & SC_REJ_COMP_TCP))
1610 goto err; 1610 goto err;
1611 1611
1612 /* Until we fix the decompressor need to make sure 1612 /* Until we fix the decompressor need to make sure
@@ -1636,7 +1636,7 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
1636 skb_queue_tail(&ppp->file.rq, skb); 1636 skb_queue_tail(&ppp->file.rq, skb);
1637 /* limit queue length by dropping old frames */ 1637 /* limit queue length by dropping old frames */
1638 while (ppp->file.rq.qlen > PPP_MAX_RQLEN 1638 while (ppp->file.rq.qlen > PPP_MAX_RQLEN
1639 && (skb = skb_dequeue(&ppp->file.rq)) != 0) 1639 && (skb = skb_dequeue(&ppp->file.rq)))
1640 kfree_skb(skb); 1640 kfree_skb(skb);
1641 /* wake up any process polling or blocking on read */ 1641 /* wake up any process polling or blocking on read */
1642 wake_up_interruptible(&ppp->file.rwait); 1642 wake_up_interruptible(&ppp->file.rwait);
@@ -1718,7 +1718,7 @@ ppp_decompress_frame(struct ppp *ppp, struct sk_buff *skb)
1718 } 1718 }
1719 1719
1720 ns = dev_alloc_skb(obuff_size); 1720 ns = dev_alloc_skb(obuff_size);
1721 if (ns == 0) { 1721 if (!ns) {
1722 printk(KERN_ERR "ppp_decompress_frame: no memory\n"); 1722 printk(KERN_ERR "ppp_decompress_frame: no memory\n");
1723 goto err; 1723 goto err;
1724 } 1724 }
@@ -1836,7 +1836,7 @@ ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
1836 ppp->minseq = ppp->mrq.next->sequence; 1836 ppp->minseq = ppp->mrq.next->sequence;
1837 1837
1838 /* Pull completed packets off the queue and receive them. */ 1838 /* Pull completed packets off the queue and receive them. */
1839 while ((skb = ppp_mp_reconstruct(ppp)) != 0) 1839 while ((skb = ppp_mp_reconstruct(ppp)))
1840 ppp_receive_nonmp_frame(ppp, skb); 1840 ppp_receive_nonmp_frame(ppp, skb);
1841 1841
1842 return; 1842 return;
@@ -2002,7 +2002,7 @@ ppp_register_channel(struct ppp_channel *chan)
2002 struct channel *pch; 2002 struct channel *pch;
2003 2003
2004 pch = kzalloc(sizeof(struct channel), GFP_KERNEL); 2004 pch = kzalloc(sizeof(struct channel), GFP_KERNEL);
2005 if (pch == 0) 2005 if (!pch)
2006 return -ENOMEM; 2006 return -ENOMEM;
2007 pch->ppp = NULL; 2007 pch->ppp = NULL;
2008 pch->chan = chan; 2008 pch->chan = chan;
@@ -2030,7 +2030,7 @@ int ppp_channel_index(struct ppp_channel *chan)
2030{ 2030{
2031 struct channel *pch = chan->ppp; 2031 struct channel *pch = chan->ppp;
2032 2032
2033 if (pch != 0) 2033 if (pch)
2034 return pch->file.index; 2034 return pch->file.index;
2035 return -1; 2035 return -1;
2036} 2036}
@@ -2043,9 +2043,9 @@ int ppp_unit_number(struct ppp_channel *chan)
2043 struct channel *pch = chan->ppp; 2043 struct channel *pch = chan->ppp;
2044 int unit = -1; 2044 int unit = -1;
2045 2045
2046 if (pch != 0) { 2046 if (pch) {
2047 read_lock_bh(&pch->upl); 2047 read_lock_bh(&pch->upl);
2048 if (pch->ppp != 0) 2048 if (pch->ppp)
2049 unit = pch->ppp->file.index; 2049 unit = pch->ppp->file.index;
2050 read_unlock_bh(&pch->upl); 2050 read_unlock_bh(&pch->upl);
2051 } 2051 }
@@ -2061,7 +2061,7 @@ ppp_unregister_channel(struct ppp_channel *chan)
2061{ 2061{
2062 struct channel *pch = chan->ppp; 2062 struct channel *pch = chan->ppp;
2063 2063
2064 if (pch == 0) 2064 if (!pch)
2065 return; /* should never happen */ 2065 return; /* should never happen */
2066 chan->ppp = NULL; 2066 chan->ppp = NULL;
2067 2067
@@ -2093,7 +2093,7 @@ ppp_output_wakeup(struct ppp_channel *chan)
2093{ 2093{
2094 struct channel *pch = chan->ppp; 2094 struct channel *pch = chan->ppp;
2095 2095
2096 if (pch == 0) 2096 if (!pch)
2097 return; 2097 return;
2098 ppp_channel_push(pch); 2098 ppp_channel_push(pch);
2099} 2099}
@@ -2124,18 +2124,18 @@ ppp_set_compress(struct ppp *ppp, unsigned long arg)
2124 2124
2125 cp = find_compressor(ccp_option[0]); 2125 cp = find_compressor(ccp_option[0]);
2126#ifdef CONFIG_KMOD 2126#ifdef CONFIG_KMOD
2127 if (cp == 0) { 2127 if (!cp) {
2128 request_module("ppp-compress-%d", ccp_option[0]); 2128 request_module("ppp-compress-%d", ccp_option[0]);
2129 cp = find_compressor(ccp_option[0]); 2129 cp = find_compressor(ccp_option[0]);
2130 } 2130 }
2131#endif /* CONFIG_KMOD */ 2131#endif /* CONFIG_KMOD */
2132 if (cp == 0) 2132 if (!cp)
2133 goto out; 2133 goto out;
2134 2134
2135 err = -ENOBUFS; 2135 err = -ENOBUFS;
2136 if (data.transmit) { 2136 if (data.transmit) {
2137 state = cp->comp_alloc(ccp_option, data.length); 2137 state = cp->comp_alloc(ccp_option, data.length);
2138 if (state != 0) { 2138 if (state) {
2139 ppp_xmit_lock(ppp); 2139 ppp_xmit_lock(ppp);
2140 ppp->xstate &= ~SC_COMP_RUN; 2140 ppp->xstate &= ~SC_COMP_RUN;
2141 ocomp = ppp->xcomp; 2141 ocomp = ppp->xcomp;
@@ -2143,7 +2143,7 @@ ppp_set_compress(struct ppp *ppp, unsigned long arg)
2143 ppp->xcomp = cp; 2143 ppp->xcomp = cp;
2144 ppp->xc_state = state; 2144 ppp->xc_state = state;
2145 ppp_xmit_unlock(ppp); 2145 ppp_xmit_unlock(ppp);
2146 if (ostate != 0) { 2146 if (ostate) {
2147 ocomp->comp_free(ostate); 2147 ocomp->comp_free(ostate);
2148 module_put(ocomp->owner); 2148 module_put(ocomp->owner);
2149 } 2149 }
@@ -2153,7 +2153,7 @@ ppp_set_compress(struct ppp *ppp, unsigned long arg)
2153 2153
2154 } else { 2154 } else {
2155 state = cp->decomp_alloc(ccp_option, data.length); 2155 state = cp->decomp_alloc(ccp_option, data.length);
2156 if (state != 0) { 2156 if (state) {
2157 ppp_recv_lock(ppp); 2157 ppp_recv_lock(ppp);
2158 ppp->rstate &= ~SC_DECOMP_RUN; 2158 ppp->rstate &= ~SC_DECOMP_RUN;
2159 ocomp = ppp->rcomp; 2159 ocomp = ppp->rcomp;
@@ -2161,7 +2161,7 @@ ppp_set_compress(struct ppp *ppp, unsigned long arg)
2161 ppp->rcomp = cp; 2161 ppp->rcomp = cp;
2162 ppp->rc_state = state; 2162 ppp->rc_state = state;
2163 ppp_recv_unlock(ppp); 2163 ppp_recv_unlock(ppp);
2164 if (ostate != 0) { 2164 if (ostate) {
2165 ocomp->decomp_free(ostate); 2165 ocomp->decomp_free(ostate);
2166 module_put(ocomp->owner); 2166 module_put(ocomp->owner);
2167 } 2167 }
@@ -2228,7 +2228,7 @@ ppp_ccp_peek(struct ppp *ppp, struct sk_buff *skb, int inbound)
2228 break; 2228 break;
2229 if (inbound) { 2229 if (inbound) {
2230 /* we will start receiving compressed packets */ 2230 /* we will start receiving compressed packets */
2231 if (ppp->rc_state == 0) 2231 if (!ppp->rc_state)
2232 break; 2232 break;
2233 if (ppp->rcomp->decomp_init(ppp->rc_state, dp, len, 2233 if (ppp->rcomp->decomp_init(ppp->rc_state, dp, len,
2234 ppp->file.index, 0, ppp->mru, ppp->debug)) { 2234 ppp->file.index, 0, ppp->mru, ppp->debug)) {
@@ -2237,7 +2237,7 @@ ppp_ccp_peek(struct ppp *ppp, struct sk_buff *skb, int inbound)
2237 } 2237 }
2238 } else { 2238 } else {
2239 /* we will soon start sending compressed packets */ 2239 /* we will soon start sending compressed packets */
2240 if (ppp->xc_state == 0) 2240 if (!ppp->xc_state)
2241 break; 2241 break;
2242 if (ppp->xcomp->comp_init(ppp->xc_state, dp, len, 2242 if (ppp->xcomp->comp_init(ppp->xc_state, dp, len,
2243 ppp->file.index, 0, ppp->debug)) 2243 ppp->file.index, 0, ppp->debug))
@@ -2320,11 +2320,11 @@ ppp_register_compressor(struct compressor *cp)
2320 int ret; 2320 int ret;
2321 spin_lock(&compressor_list_lock); 2321 spin_lock(&compressor_list_lock);
2322 ret = -EEXIST; 2322 ret = -EEXIST;
2323 if (find_comp_entry(cp->compress_proto) != 0) 2323 if (find_comp_entry(cp->compress_proto))
2324 goto out; 2324 goto out;
2325 ret = -ENOMEM; 2325 ret = -ENOMEM;
2326 ce = kmalloc(sizeof(struct compressor_entry), GFP_ATOMIC); 2326 ce = kmalloc(sizeof(struct compressor_entry), GFP_ATOMIC);
2327 if (ce == 0) 2327 if (!ce)
2328 goto out; 2328 goto out;
2329 ret = 0; 2329 ret = 0;
2330 ce->comp = cp; 2330 ce->comp = cp;
@@ -2342,7 +2342,7 @@ ppp_unregister_compressor(struct compressor *cp)
2342 2342
2343 spin_lock(&compressor_list_lock); 2343 spin_lock(&compressor_list_lock);
2344 ce = find_comp_entry(cp->compress_proto); 2344 ce = find_comp_entry(cp->compress_proto);
2345 if (ce != 0 && ce->comp == cp) { 2345 if (ce && ce->comp == cp) {
2346 list_del(&ce->list); 2346 list_del(&ce->list);
2347 kfree(ce); 2347 kfree(ce);
2348 } 2348 }
@@ -2358,7 +2358,7 @@ find_compressor(int type)
2358 2358
2359 spin_lock(&compressor_list_lock); 2359 spin_lock(&compressor_list_lock);
2360 ce = find_comp_entry(type); 2360 ce = find_comp_entry(type);
2361 if (ce != 0) { 2361 if (ce) {
2362 cp = ce->comp; 2362 cp = ce->comp;
2363 if (!try_module_get(cp->owner)) 2363 if (!try_module_get(cp->owner))
2364 cp = NULL; 2364 cp = NULL;
@@ -2383,7 +2383,7 @@ ppp_get_stats(struct ppp *ppp, struct ppp_stats *st)
2383 st->p.ppp_opackets = ppp->stats.tx_packets; 2383 st->p.ppp_opackets = ppp->stats.tx_packets;
2384 st->p.ppp_oerrors = ppp->stats.tx_errors; 2384 st->p.ppp_oerrors = ppp->stats.tx_errors;
2385 st->p.ppp_obytes = ppp->stats.tx_bytes; 2385 st->p.ppp_obytes = ppp->stats.tx_bytes;
2386 if (vj == 0) 2386 if (!vj)
2387 return; 2387 return;
2388 st->vj.vjs_packets = vj->sls_o_compressed + vj->sls_o_uncompressed; 2388 st->vj.vjs_packets = vj->sls_o_compressed + vj->sls_o_uncompressed;
2389 st->vj.vjs_compressed = vj->sls_o_compressed; 2389 st->vj.vjs_compressed = vj->sls_o_compressed;
@@ -2604,11 +2604,11 @@ ppp_connect_channel(struct channel *pch, int unit)
2604 2604
2605 mutex_lock(&all_ppp_mutex); 2605 mutex_lock(&all_ppp_mutex);
2606 ppp = ppp_find_unit(unit); 2606 ppp = ppp_find_unit(unit);
2607 if (ppp == 0) 2607 if (!ppp)
2608 goto out; 2608 goto out;
2609 write_lock_bh(&pch->upl); 2609 write_lock_bh(&pch->upl);
2610 ret = -EINVAL; 2610 ret = -EINVAL;
2611 if (pch->ppp != 0) 2611 if (pch->ppp)
2612 goto outl; 2612 goto outl;
2613 2613
2614 ppp_lock(ppp); 2614 ppp_lock(ppp);
@@ -2644,7 +2644,7 @@ ppp_disconnect_channel(struct channel *pch)
2644 ppp = pch->ppp; 2644 ppp = pch->ppp;
2645 pch->ppp = NULL; 2645 pch->ppp = NULL;
2646 write_unlock_bh(&pch->upl); 2646 write_unlock_bh(&pch->upl);
2647 if (ppp != 0) { 2647 if (ppp) {
2648 /* remove it from the ppp unit's list */ 2648 /* remove it from the ppp unit's list */
2649 ppp_lock(ppp); 2649 ppp_lock(ppp);
2650 list_del(&pch->clist); 2650 list_del(&pch->clist);
diff --git a/drivers/net/ppp_synctty.c b/drivers/net/ppp_synctty.c
index ce64032a465a..f0c6a1926a02 100644
--- a/drivers/net/ppp_synctty.c
+++ b/drivers/net/ppp_synctty.c
@@ -209,7 +209,7 @@ ppp_sync_open(struct tty_struct *tty)
209 209
210 ap = kzalloc(sizeof(*ap), GFP_KERNEL); 210 ap = kzalloc(sizeof(*ap), GFP_KERNEL);
211 err = -ENOMEM; 211 err = -ENOMEM;
212 if (ap == 0) 212 if (!ap)
213 goto out; 213 goto out;
214 214
215 /* initialize the syncppp structure */ 215 /* initialize the syncppp structure */
@@ -262,7 +262,7 @@ ppp_sync_close(struct tty_struct *tty)
262 ap = tty->disc_data; 262 ap = tty->disc_data;
263 tty->disc_data = NULL; 263 tty->disc_data = NULL;
264 write_unlock_irq(&disc_data_lock); 264 write_unlock_irq(&disc_data_lock);
265 if (ap == 0) 265 if (!ap)
266 return; 266 return;
267 267
268 /* 268 /*
@@ -278,7 +278,7 @@ ppp_sync_close(struct tty_struct *tty)
278 278
279 ppp_unregister_channel(&ap->chan); 279 ppp_unregister_channel(&ap->chan);
280 skb_queue_purge(&ap->rqueue); 280 skb_queue_purge(&ap->rqueue);
281 if (ap->tpkt != 0) 281 if (ap->tpkt)
282 kfree_skb(ap->tpkt); 282 kfree_skb(ap->tpkt);
283 kfree(ap); 283 kfree(ap);
284} 284}
@@ -325,13 +325,13 @@ ppp_synctty_ioctl(struct tty_struct *tty, struct file *file,
325 int __user *p = (int __user *)arg; 325 int __user *p = (int __user *)arg;
326 int err, val; 326 int err, val;
327 327
328 if (ap == 0) 328 if (!ap)
329 return -ENXIO; 329 return -ENXIO;
330 err = -EFAULT; 330 err = -EFAULT;
331 switch (cmd) { 331 switch (cmd) {
332 case PPPIOCGCHAN: 332 case PPPIOCGCHAN:
333 err = -ENXIO; 333 err = -ENXIO;
334 if (ap == 0) 334 if (!ap)
335 break; 335 break;
336 err = -EFAULT; 336 err = -EFAULT;
337 if (put_user(ppp_channel_index(&ap->chan), p)) 337 if (put_user(ppp_channel_index(&ap->chan), p))
@@ -341,7 +341,7 @@ ppp_synctty_ioctl(struct tty_struct *tty, struct file *file,
341 341
342 case PPPIOCGUNIT: 342 case PPPIOCGUNIT:
343 err = -ENXIO; 343 err = -ENXIO;
344 if (ap == 0) 344 if (!ap)
345 break; 345 break;
346 err = -EFAULT; 346 err = -EFAULT;
347 if (put_user(ppp_unit_number(&ap->chan), p)) 347 if (put_user(ppp_unit_number(&ap->chan), p))
@@ -349,16 +349,11 @@ ppp_synctty_ioctl(struct tty_struct *tty, struct file *file,
349 err = 0; 349 err = 0;
350 break; 350 break;
351 351
352 case TCGETS:
353 case TCGETA:
354 err = n_tty_ioctl(tty, file, cmd, arg);
355 break;
356
357 case TCFLSH: 352 case TCFLSH:
358 /* flush our buffers and the serial port's buffer */ 353 /* flush our buffers and the serial port's buffer */
359 if (arg == TCIOFLUSH || arg == TCOFLUSH) 354 if (arg == TCIOFLUSH || arg == TCOFLUSH)
360 ppp_sync_flush_output(ap); 355 ppp_sync_flush_output(ap);
361 err = n_tty_ioctl(tty, file, cmd, arg); 356 err = tty_perform_flush(tty, arg);
362 break; 357 break;
363 358
364 case FIONREAD: 359 case FIONREAD:
@@ -369,7 +364,8 @@ ppp_synctty_ioctl(struct tty_struct *tty, struct file *file,
369 break; 364 break;
370 365
371 default: 366 default:
372 err = -ENOIOCTLCMD; 367 err = tty_mode_ioctl(tty, file, cmd, arg);
368 break;
373 } 369 }
374 370
375 sp_put(ap); 371 sp_put(ap);
@@ -394,7 +390,7 @@ ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf,
394 struct syncppp *ap = sp_get(tty); 390 struct syncppp *ap = sp_get(tty);
395 unsigned long flags; 391 unsigned long flags;
396 392
397 if (ap == 0) 393 if (!ap)
398 return; 394 return;
399 spin_lock_irqsave(&ap->recv_lock, flags); 395 spin_lock_irqsave(&ap->recv_lock, flags);
400 ppp_sync_input(ap, buf, cflags, count); 396 ppp_sync_input(ap, buf, cflags, count);
@@ -413,7 +409,7 @@ ppp_sync_wakeup(struct tty_struct *tty)
413 struct syncppp *ap = sp_get(tty); 409 struct syncppp *ap = sp_get(tty);
414 410
415 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); 411 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
416 if (ap == 0) 412 if (!ap)
417 return; 413 return;
418 set_bit(XMIT_WAKEUP, &ap->xmit_flags); 414 set_bit(XMIT_WAKEUP, &ap->xmit_flags);
419 tasklet_schedule(&ap->tsk); 415 tasklet_schedule(&ap->tsk);
@@ -655,7 +651,7 @@ ppp_sync_push(struct syncppp *ap)
655 for (;;) { 651 for (;;) {
656 if (test_and_clear_bit(XMIT_WAKEUP, &ap->xmit_flags)) 652 if (test_and_clear_bit(XMIT_WAKEUP, &ap->xmit_flags))
657 tty_stuffed = 0; 653 tty_stuffed = 0;
658 if (!tty_stuffed && ap->tpkt != 0) { 654 if (!tty_stuffed && ap->tpkt) {
659 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); 655 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
660 sent = tty->driver->write(tty, ap->tpkt->data, ap->tpkt->len); 656 sent = tty->driver->write(tty, ap->tpkt->data, ap->tpkt->len);
661 if (sent < 0) 657 if (sent < 0)
@@ -673,7 +669,7 @@ ppp_sync_push(struct syncppp *ap)
673 /* haven't made any progress */ 669 /* haven't made any progress */
674 spin_unlock_bh(&ap->xmit_lock); 670 spin_unlock_bh(&ap->xmit_lock);
675 if (!(test_bit(XMIT_WAKEUP, &ap->xmit_flags) 671 if (!(test_bit(XMIT_WAKEUP, &ap->xmit_flags)
676 || (!tty_stuffed && ap->tpkt != 0))) 672 || (!tty_stuffed && ap->tpkt)))
677 break; 673 break;
678 if (!spin_trylock_bh(&ap->xmit_lock)) 674 if (!spin_trylock_bh(&ap->xmit_lock))
679 break; 675 break;
@@ -681,7 +677,7 @@ ppp_sync_push(struct syncppp *ap)
681 return done; 677 return done;
682 678
683flush: 679flush:
684 if (ap->tpkt != 0) { 680 if (ap->tpkt) {
685 kfree_skb(ap->tpkt); 681 kfree_skb(ap->tpkt);
686 ap->tpkt = NULL; 682 ap->tpkt = NULL;
687 clear_bit(XMIT_FULL, &ap->xmit_flags); 683 clear_bit(XMIT_FULL, &ap->xmit_flags);
@@ -736,7 +732,8 @@ ppp_sync_input(struct syncppp *ap, const unsigned char *buf,
736 ppp_print_buffer ("receive buffer", buf, count); 732 ppp_print_buffer ("receive buffer", buf, count);
737 733
738 /* stuff the chars in the skb */ 734 /* stuff the chars in the skb */
739 if ((skb = dev_alloc_skb(ap->mru + PPP_HDRLEN + 2)) == 0) { 735 skb = dev_alloc_skb(ap->mru + PPP_HDRLEN + 2);
736 if (!skb) {
740 printk(KERN_ERR "PPPsync: no memory (input pkt)\n"); 737 printk(KERN_ERR "PPPsync: no memory (input pkt)\n");
741 goto err; 738 goto err;
742 } 739 }
@@ -744,7 +741,7 @@ ppp_sync_input(struct syncppp *ap, const unsigned char *buf,
744 if (buf[0] != PPP_ALLSTATIONS) 741 if (buf[0] != PPP_ALLSTATIONS)
745 skb_reserve(skb, 2 + (buf[0] & 1)); 742 skb_reserve(skb, 2 + (buf[0] & 1));
746 743
747 if (flags != 0 && *flags) { 744 if (flags && *flags) {
748 /* error flag set, ignore frame */ 745 /* error flag set, ignore frame */
749 goto err; 746 goto err;
750 } else if (count > skb_tailroom(skb)) { 747 } else if (count > skb_tailroom(skb)) {
diff --git a/drivers/net/pppol2tp.c b/drivers/net/pppol2tp.c
index f8904fd92369..a7556cd2df79 100644
--- a/drivers/net/pppol2tp.c
+++ b/drivers/net/pppol2tp.c
@@ -488,7 +488,7 @@ static int pppol2tp_recv_core(struct sock *sock, struct sk_buff *skb)
488{ 488{
489 struct pppol2tp_session *session = NULL; 489 struct pppol2tp_session *session = NULL;
490 struct pppol2tp_tunnel *tunnel; 490 struct pppol2tp_tunnel *tunnel;
491 unsigned char *ptr; 491 unsigned char *ptr, *optr;
492 u16 hdrflags; 492 u16 hdrflags;
493 u16 tunnel_id, session_id; 493 u16 tunnel_id, session_id;
494 int length; 494 int length;
@@ -496,7 +496,7 @@ static int pppol2tp_recv_core(struct sock *sock, struct sk_buff *skb)
496 496
497 tunnel = pppol2tp_sock_to_tunnel(sock); 497 tunnel = pppol2tp_sock_to_tunnel(sock);
498 if (tunnel == NULL) 498 if (tunnel == NULL)
499 goto error; 499 goto no_tunnel;
500 500
501 /* UDP always verifies the packet length. */ 501 /* UDP always verifies the packet length. */
502 __skb_pull(skb, sizeof(struct udphdr)); 502 __skb_pull(skb, sizeof(struct udphdr));
@@ -509,7 +509,7 @@ static int pppol2tp_recv_core(struct sock *sock, struct sk_buff *skb)
509 } 509 }
510 510
511 /* Point to L2TP header */ 511 /* Point to L2TP header */
512 ptr = skb->data; 512 optr = ptr = skb->data;
513 513
514 /* Get L2TP header flags */ 514 /* Get L2TP header flags */
515 hdrflags = ntohs(*(__be16*)ptr); 515 hdrflags = ntohs(*(__be16*)ptr);
@@ -637,12 +637,14 @@ static int pppol2tp_recv_core(struct sock *sock, struct sk_buff *skb)
637 /* If offset bit set, skip it. */ 637 /* If offset bit set, skip it. */
638 if (hdrflags & L2TP_HDRFLAG_O) { 638 if (hdrflags & L2TP_HDRFLAG_O) {
639 offset = ntohs(*(__be16 *)ptr); 639 offset = ntohs(*(__be16 *)ptr);
640 skb->transport_header += 2 + offset; 640 ptr += 2 + offset;
641 if (!pskb_may_pull(skb, skb_transport_offset(skb) + 2))
642 goto discard;
643 } 641 }
644 642
645 __skb_pull(skb, skb_transport_offset(skb)); 643 offset = ptr - optr;
644 if (!pskb_may_pull(skb, offset))
645 goto discard;
646
647 __skb_pull(skb, offset);
646 648
647 /* Skip PPP header, if present. In testing, Microsoft L2TP clients 649 /* Skip PPP header, if present. In testing, Microsoft L2TP clients
648 * don't send the PPP header (PPP header compression enabled), but 650 * don't send the PPP header (PPP header compression enabled), but
@@ -652,6 +654,9 @@ static int pppol2tp_recv_core(struct sock *sock, struct sk_buff *skb)
652 * Note that skb->data[] isn't dereferenced from a u16 ptr here since 654 * Note that skb->data[] isn't dereferenced from a u16 ptr here since
653 * the field may be unaligned. 655 * the field may be unaligned.
654 */ 656 */
657 if (!pskb_may_pull(skb, 2))
658 goto discard;
659
655 if ((skb->data[0] == 0xff) && (skb->data[1] == 0x03)) 660 if ((skb->data[0] == 0xff) && (skb->data[1] == 0x03))
656 skb_pull(skb, 2); 661 skb_pull(skb, 2);
657 662
@@ -709,6 +714,10 @@ discard:
709 return 0; 714 return 0;
710 715
711error: 716error:
717 /* Put UDP header back */
718 __skb_push(skb, sizeof(struct udphdr));
719
720no_tunnel:
712 return 1; 721 return 1;
713} 722}
714 723
@@ -1050,6 +1059,8 @@ static int pppol2tp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
1050 /* Get routing info from the tunnel socket */ 1059 /* Get routing info from the tunnel socket */
1051 dst_release(skb->dst); 1060 dst_release(skb->dst);
1052 skb->dst = sk_dst_get(sk_tun); 1061 skb->dst = sk_dst_get(sk_tun);
1062 skb_orphan(skb);
1063 skb->sk = sk_tun;
1053 1064
1054 /* Queue the packet to IP for output */ 1065 /* Queue the packet to IP for output */
1055 len = skb->len; 1066 len = skb->len;
diff --git a/drivers/net/qla3xxx.c b/drivers/net/qla3xxx.c
index 30adf726743c..a5791114b7bd 100644
--- a/drivers/net/qla3xxx.c
+++ b/drivers/net/qla3xxx.c
@@ -1456,16 +1456,11 @@ static void ql_phy_start_neg_ex(struct ql3_adapter *qdev)
1456 PHYAddr[qdev->mac_index]); 1456 PHYAddr[qdev->mac_index]);
1457 reg &= ~PHY_GIG_ALL_PARAMS; 1457 reg &= ~PHY_GIG_ALL_PARAMS;
1458 1458
1459 if(portConfiguration & 1459 if(portConfiguration & PORT_CONFIG_1000MB_SPEED) {
1460 PORT_CONFIG_FULL_DUPLEX_ENABLED & 1460 if(portConfiguration & PORT_CONFIG_FULL_DUPLEX_ENABLED)
1461 PORT_CONFIG_1000MB_SPEED) { 1461 reg |= PHY_GIG_ADV_1000F;
1462 reg |= PHY_GIG_ADV_1000F; 1462 else
1463 } 1463 reg |= PHY_GIG_ADV_1000H;
1464
1465 if(portConfiguration &
1466 PORT_CONFIG_HALF_DUPLEX_ENABLED &
1467 PORT_CONFIG_1000MB_SPEED) {
1468 reg |= PHY_GIG_ADV_1000H;
1469 } 1464 }
1470 1465
1471 ql_mii_write_reg_ex(qdev, PHY_GIG_CONTROL, reg, 1466 ql_mii_write_reg_ex(qdev, PHY_GIG_CONTROL, reg,
@@ -1645,8 +1640,11 @@ static int ql_finish_auto_neg(struct ql3_adapter *qdev)
1645 return 0; 1640 return 0;
1646} 1641}
1647 1642
1648static void ql_link_state_machine(struct ql3_adapter *qdev) 1643static void ql_link_state_machine_work(struct work_struct *work)
1649{ 1644{
1645 struct ql3_adapter *qdev =
1646 container_of(work, struct ql3_adapter, link_state_work.work);
1647
1650 u32 curr_link_state; 1648 u32 curr_link_state;
1651 unsigned long hw_flags; 1649 unsigned long hw_flags;
1652 1650
@@ -1661,6 +1659,10 @@ static void ql_link_state_machine(struct ql3_adapter *qdev)
1661 "state.\n", qdev->ndev->name); 1659 "state.\n", qdev->ndev->name);
1662 1660
1663 spin_unlock_irqrestore(&qdev->hw_lock, hw_flags); 1661 spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
1662
1663 /* Restart timer on 2 second interval. */
1664 mod_timer(&qdev->adapter_timer, jiffies + HZ * 1);\
1665
1664 return; 1666 return;
1665 } 1667 }
1666 1668
@@ -1705,6 +1707,9 @@ static void ql_link_state_machine(struct ql3_adapter *qdev)
1705 break; 1707 break;
1706 } 1708 }
1707 spin_unlock_irqrestore(&qdev->hw_lock, hw_flags); 1709 spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
1710
1711 /* Restart timer on 2 second interval. */
1712 mod_timer(&qdev->adapter_timer, jiffies + HZ * 1);
1708} 1713}
1709 1714
1710/* 1715/*
@@ -3941,19 +3946,7 @@ static void ql_get_board_info(struct ql3_adapter *qdev)
3941static void ql3xxx_timer(unsigned long ptr) 3946static void ql3xxx_timer(unsigned long ptr)
3942{ 3947{
3943 struct ql3_adapter *qdev = (struct ql3_adapter *)ptr; 3948 struct ql3_adapter *qdev = (struct ql3_adapter *)ptr;
3944 3949 queue_delayed_work(qdev->workqueue, &qdev->link_state_work, 0);
3945 if (test_bit(QL_RESET_ACTIVE,&qdev->flags)) {
3946 printk(KERN_DEBUG PFX
3947 "%s: Reset in progress.\n",
3948 qdev->ndev->name);
3949 goto end;
3950 }
3951
3952 ql_link_state_machine(qdev);
3953
3954 /* Restart timer on 2 second interval. */
3955end:
3956 mod_timer(&qdev->adapter_timer, jiffies + HZ * 1);
3957} 3950}
3958 3951
3959static int __devinit ql3xxx_probe(struct pci_dev *pdev, 3952static int __devinit ql3xxx_probe(struct pci_dev *pdev,
@@ -4103,6 +4096,7 @@ static int __devinit ql3xxx_probe(struct pci_dev *pdev,
4103 qdev->workqueue = create_singlethread_workqueue(ndev->name); 4096 qdev->workqueue = create_singlethread_workqueue(ndev->name);
4104 INIT_DELAYED_WORK(&qdev->reset_work, ql_reset_work); 4097 INIT_DELAYED_WORK(&qdev->reset_work, ql_reset_work);
4105 INIT_DELAYED_WORK(&qdev->tx_timeout_work, ql_tx_timeout_work); 4098 INIT_DELAYED_WORK(&qdev->tx_timeout_work, ql_tx_timeout_work);
4099 INIT_DELAYED_WORK(&qdev->link_state_work, ql_link_state_machine_work);
4106 4100
4107 init_timer(&qdev->adapter_timer); 4101 init_timer(&qdev->adapter_timer);
4108 qdev->adapter_timer.function = ql3xxx_timer; 4102 qdev->adapter_timer.function = ql3xxx_timer;
diff --git a/drivers/net/qla3xxx.h b/drivers/net/qla3xxx.h
index fbcb0b949639..d0ffb30ef371 100644
--- a/drivers/net/qla3xxx.h
+++ b/drivers/net/qla3xxx.h
@@ -1286,6 +1286,7 @@ struct ql3_adapter {
1286 struct workqueue_struct *workqueue; 1286 struct workqueue_struct *workqueue;
1287 struct delayed_work reset_work; 1287 struct delayed_work reset_work;
1288 struct delayed_work tx_timeout_work; 1288 struct delayed_work tx_timeout_work;
1289 struct delayed_work link_state_work;
1289 u32 max_frame_size; 1290 u32 max_frame_size;
1290 u32 device_id; 1291 u32 device_id;
1291 u16 phyType; 1292 u16 phyType;
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index b94fa7ef1955..1f647b9ce352 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -171,6 +171,8 @@ static struct pci_device_id rtl8169_pci_tbl[] = {
171 { PCI_DEVICE(0x16ec, 0x0116), 0, 0, RTL_CFG_0 }, 171 { PCI_DEVICE(0x16ec, 0x0116), 0, 0, RTL_CFG_0 },
172 { PCI_VENDOR_ID_LINKSYS, 0x1032, 172 { PCI_VENDOR_ID_LINKSYS, 0x1032,
173 PCI_ANY_ID, 0x0024, 0, 0, RTL_CFG_0 }, 173 PCI_ANY_ID, 0x0024, 0, 0, RTL_CFG_0 },
174 { 0x0001, 0x8168,
175 PCI_ANY_ID, 0x2410, 0, 0, RTL_CFG_2 },
174 {0,}, 176 {0,},
175}; 177};
176 178
@@ -468,7 +470,7 @@ static void mdio_write(void __iomem *ioaddr, int reg_addr, int value)
468{ 470{
469 int i; 471 int i;
470 472
471 RTL_W32(PHYAR, 0x80000000 | (reg_addr & 0xFF) << 16 | value); 473 RTL_W32(PHYAR, 0x80000000 | (reg_addr & 0x1f) << 16 | (value & 0xffff));
472 474
473 for (i = 20; i > 0; i--) { 475 for (i = 20; i > 0; i--) {
474 /* 476 /*
@@ -485,7 +487,7 @@ static int mdio_read(void __iomem *ioaddr, int reg_addr)
485{ 487{
486 int i, value = -1; 488 int i, value = -1;
487 489
488 RTL_W32(PHYAR, 0x0 | (reg_addr & 0xFF) << 16); 490 RTL_W32(PHYAR, 0x0 | (reg_addr & 0x1f) << 16);
489 491
490 for (i = 20; i > 0; i--) { 492 for (i = 20; i > 0; i--) {
491 /* 493 /*
@@ -493,7 +495,7 @@ static int mdio_read(void __iomem *ioaddr, int reg_addr)
493 * the specified MII register. 495 * the specified MII register.
494 */ 496 */
495 if (RTL_R32(PHYAR) & 0x80000000) { 497 if (RTL_R32(PHYAR) & 0x80000000) {
496 value = (int) (RTL_R32(PHYAR) & 0xFFFF); 498 value = RTL_R32(PHYAR) & 0xffff;
497 break; 499 break;
498 } 500 }
499 udelay(25); 501 udelay(25);
@@ -1245,16 +1247,6 @@ static void rtl8169sb_hw_phy_config(void __iomem *ioaddr)
1245 1247
1246 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init)); 1248 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init));
1247} 1249}
1248static void rtl8168b_hw_phy_config(void __iomem *ioaddr)
1249{
1250 struct phy_reg phy_reg_init[] = {
1251 { 0x1f, 0x0000 },
1252 { 0x10, 0xf41b },
1253 { 0x1f, 0x0000 }
1254 };
1255
1256 rtl_phy_write(ioaddr, phy_reg_init, ARRAY_SIZE(phy_reg_init));
1257}
1258 1250
1259static void rtl8168cp_hw_phy_config(void __iomem *ioaddr) 1251static void rtl8168cp_hw_phy_config(void __iomem *ioaddr)
1260{ 1252{
@@ -1324,11 +1316,6 @@ static void rtl_hw_phy_config(struct net_device *dev)
1324 case RTL_GIGA_MAC_VER_04: 1316 case RTL_GIGA_MAC_VER_04:
1325 rtl8169sb_hw_phy_config(ioaddr); 1317 rtl8169sb_hw_phy_config(ioaddr);
1326 break; 1318 break;
1327 case RTL_GIGA_MAC_VER_11:
1328 case RTL_GIGA_MAC_VER_12:
1329 case RTL_GIGA_MAC_VER_17:
1330 rtl8168b_hw_phy_config(ioaddr);
1331 break;
1332 case RTL_GIGA_MAC_VER_18: 1319 case RTL_GIGA_MAC_VER_18:
1333 rtl8168cp_hw_phy_config(ioaddr); 1320 rtl8168cp_hw_phy_config(ioaddr);
1334 break; 1321 break;
@@ -1739,7 +1726,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1739 tp->features |= rtl_try_msi(pdev, ioaddr, cfg); 1726 tp->features |= rtl_try_msi(pdev, ioaddr, cfg);
1740 RTL_W8(Cfg9346, Cfg9346_Lock); 1727 RTL_W8(Cfg9346, Cfg9346_Lock);
1741 1728
1742 if (RTL_R8(PHYstatus) & TBI_Enable) { 1729 if ((tp->mac_version <= RTL_GIGA_MAC_VER_06) &&
1730 (RTL_R8(PHYstatus) & TBI_Enable)) {
1743 tp->set_speed = rtl8169_set_speed_tbi; 1731 tp->set_speed = rtl8169_set_speed_tbi;
1744 tp->get_settings = rtl8169_gset_tbi; 1732 tp->get_settings = rtl8169_gset_tbi;
1745 tp->phy_reset_enable = rtl8169_tbi_reset_enable; 1733 tp->phy_reset_enable = rtl8169_tbi_reset_enable;
diff --git a/drivers/net/rrunner.c b/drivers/net/rrunner.c
index b822859c8de3..73a7e6529ee0 100644
--- a/drivers/net/rrunner.c
+++ b/drivers/net/rrunner.c
@@ -78,12 +78,6 @@ static char version[] __devinitdata = "rrunner.c: v0.50 11/11/2002 Jes Sorensen
78 * stack will need to know about I/O vectors or something similar. 78 * stack will need to know about I/O vectors or something similar.
79 */ 79 */
80 80
81/*
82 * sysctl_[wr]mem_max are checked at init time to see if they are at
83 * least 256KB and increased to 256KB if they are not. This is done to
84 * avoid ending up with socket buffers smaller than the MTU size,
85 */
86
87static int __devinit rr_init_one(struct pci_dev *pdev, 81static int __devinit rr_init_one(struct pci_dev *pdev,
88 const struct pci_device_id *ent) 82 const struct pci_device_id *ent)
89{ 83{
@@ -561,18 +555,6 @@ static int __devinit rr_init(struct net_device *dev)
561 sram_size = rr_read_eeprom_word(rrpriv, (void *)8); 555 sram_size = rr_read_eeprom_word(rrpriv, (void *)8);
562 printk(" SRAM size 0x%06x\n", sram_size); 556 printk(" SRAM size 0x%06x\n", sram_size);
563 557
564 if (sysctl_rmem_max < 262144){
565 printk(" Receive socket buffer limit too low (%i), "
566 "setting to 262144\n", sysctl_rmem_max);
567 sysctl_rmem_max = 262144;
568 }
569
570 if (sysctl_wmem_max < 262144){
571 printk(" Transmit socket buffer limit too low (%i), "
572 "setting to 262144\n", sysctl_wmem_max);
573 sysctl_wmem_max = 262144;
574 }
575
576 return 0; 558 return 0;
577} 559}
578 560
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index b8c0e7b4ca1c..632666706247 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -84,7 +84,7 @@
84#include "s2io.h" 84#include "s2io.h"
85#include "s2io-regs.h" 85#include "s2io-regs.h"
86 86
87#define DRV_VERSION "2.0.26.5" 87#define DRV_VERSION "2.0.26.6"
88 88
89/* S2io Driver name & version. */ 89/* S2io Driver name & version. */
90static char s2io_driver_name[] = "Neterion"; 90static char s2io_driver_name[] = "Neterion";
@@ -3775,6 +3775,40 @@ static int __devinit s2io_test_msi(struct s2io_nic *sp)
3775 3775
3776 return err; 3776 return err;
3777} 3777}
3778
3779static void remove_msix_isr(struct s2io_nic *sp)
3780{
3781 int i;
3782 u16 msi_control;
3783
3784 for (i = 0; i < MAX_REQUESTED_MSI_X; i++) {
3785 if (sp->s2io_entries[i].in_use ==
3786 MSIX_REGISTERED_SUCCESS) {
3787 int vector = sp->entries[i].vector;
3788 void *arg = sp->s2io_entries[i].arg;
3789 free_irq(vector, arg);
3790 }
3791 }
3792
3793 kfree(sp->entries);
3794 kfree(sp->s2io_entries);
3795 sp->entries = NULL;
3796 sp->s2io_entries = NULL;
3797
3798 pci_read_config_word(sp->pdev, 0x42, &msi_control);
3799 msi_control &= 0xFFFE; /* Disable MSI */
3800 pci_write_config_word(sp->pdev, 0x42, msi_control);
3801
3802 pci_disable_msix(sp->pdev);
3803}
3804
3805static void remove_inta_isr(struct s2io_nic *sp)
3806{
3807 struct net_device *dev = sp->dev;
3808
3809 free_irq(sp->pdev->irq, dev);
3810}
3811
3778/* ********************************************************* * 3812/* ********************************************************* *
3779 * Functions defined below concern the OS part of the driver * 3813 * Functions defined below concern the OS part of the driver *
3780 * ********************************************************* */ 3814 * ********************************************************* */
@@ -3809,28 +3843,9 @@ static int s2io_open(struct net_device *dev)
3809 int ret = s2io_enable_msi_x(sp); 3843 int ret = s2io_enable_msi_x(sp);
3810 3844
3811 if (!ret) { 3845 if (!ret) {
3812 u16 msi_control;
3813
3814 ret = s2io_test_msi(sp); 3846 ret = s2io_test_msi(sp);
3815
3816 /* rollback MSI-X, will re-enable during add_isr() */ 3847 /* rollback MSI-X, will re-enable during add_isr() */
3817 kfree(sp->entries); 3848 remove_msix_isr(sp);
3818 sp->mac_control.stats_info->sw_stat.mem_freed +=
3819 (MAX_REQUESTED_MSI_X *
3820 sizeof(struct msix_entry));
3821 kfree(sp->s2io_entries);
3822 sp->mac_control.stats_info->sw_stat.mem_freed +=
3823 (MAX_REQUESTED_MSI_X *
3824 sizeof(struct s2io_msix_entry));
3825 sp->entries = NULL;
3826 sp->s2io_entries = NULL;
3827
3828 pci_read_config_word(sp->pdev, 0x42, &msi_control);
3829 msi_control &= 0xFFFE; /* Disable MSI */
3830 pci_write_config_word(sp->pdev, 0x42, msi_control);
3831
3832 pci_disable_msix(sp->pdev);
3833
3834 } 3849 }
3835 if (ret) { 3850 if (ret) {
3836 3851
@@ -6719,15 +6734,22 @@ static int s2io_add_isr(struct s2io_nic * sp)
6719 } 6734 }
6720 } 6735 }
6721 if (err) { 6736 if (err) {
6737 remove_msix_isr(sp);
6722 DBG_PRINT(ERR_DBG,"%s:MSI-X-%d registration " 6738 DBG_PRINT(ERR_DBG,"%s:MSI-X-%d registration "
6723 "failed\n", dev->name, i); 6739 "failed\n", dev->name, i);
6724 DBG_PRINT(ERR_DBG, "Returned: %d\n", err); 6740 DBG_PRINT(ERR_DBG, "%s: defaulting to INTA\n",
6725 return -1; 6741 dev->name);
6742 sp->config.intr_type = INTA;
6743 break;
6726 } 6744 }
6727 sp->s2io_entries[i].in_use = MSIX_REGISTERED_SUCCESS; 6745 sp->s2io_entries[i].in_use = MSIX_REGISTERED_SUCCESS;
6728 } 6746 }
6729 printk("MSI-X-TX %d entries enabled\n",msix_tx_cnt); 6747 if (!err) {
6730 printk("MSI-X-RX %d entries enabled\n",msix_rx_cnt); 6748 printk(KERN_INFO "MSI-X-TX %d entries enabled\n",
6749 msix_tx_cnt);
6750 printk(KERN_INFO "MSI-X-RX %d entries enabled\n",
6751 msix_rx_cnt);
6752 }
6731 } 6753 }
6732 if (sp->config.intr_type == INTA) { 6754 if (sp->config.intr_type == INTA) {
6733 err = request_irq((int) sp->pdev->irq, s2io_isr, IRQF_SHARED, 6755 err = request_irq((int) sp->pdev->irq, s2io_isr, IRQF_SHARED,
@@ -6742,40 +6764,10 @@ static int s2io_add_isr(struct s2io_nic * sp)
6742} 6764}
6743static void s2io_rem_isr(struct s2io_nic * sp) 6765static void s2io_rem_isr(struct s2io_nic * sp)
6744{ 6766{
6745 struct net_device *dev = sp->dev; 6767 if (sp->config.intr_type == MSI_X)
6746 struct swStat *stats = &sp->mac_control.stats_info->sw_stat; 6768 remove_msix_isr(sp);
6747 6769 else
6748 if (sp->config.intr_type == MSI_X) { 6770 remove_inta_isr(sp);
6749 int i;
6750 u16 msi_control;
6751
6752 for (i=1; (sp->s2io_entries[i].in_use ==
6753 MSIX_REGISTERED_SUCCESS); i++) {
6754 int vector = sp->entries[i].vector;
6755 void *arg = sp->s2io_entries[i].arg;
6756
6757 synchronize_irq(vector);
6758 free_irq(vector, arg);
6759 }
6760
6761 kfree(sp->entries);
6762 stats->mem_freed +=
6763 (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry));
6764 kfree(sp->s2io_entries);
6765 stats->mem_freed +=
6766 (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry));
6767 sp->entries = NULL;
6768 sp->s2io_entries = NULL;
6769
6770 pci_read_config_word(sp->pdev, 0x42, &msi_control);
6771 msi_control &= 0xFFFE; /* Disable MSI */
6772 pci_write_config_word(sp->pdev, 0x42, msi_control);
6773
6774 pci_disable_msix(sp->pdev);
6775 } else {
6776 synchronize_irq(sp->pdev->irq);
6777 free_irq(sp->pdev->irq, dev);
6778 }
6779} 6771}
6780 6772
6781static void do_s2io_card_down(struct s2io_nic * sp, int do_io) 6773static void do_s2io_card_down(struct s2io_nic * sp, int do_io)
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index c27c7d63b6a5..a2070db725c9 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -52,7 +52,7 @@
52#include "sky2.h" 52#include "sky2.h"
53 53
54#define DRV_NAME "sky2" 54#define DRV_NAME "sky2"
55#define DRV_VERSION "1.19" 55#define DRV_VERSION "1.20"
56#define PFX DRV_NAME " " 56#define PFX DRV_NAME " "
57 57
58/* 58/*
@@ -121,6 +121,7 @@ static const struct pci_device_id sky2_id_table[] = {
121 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4353) }, /* 88E8039 */ 121 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4353) }, /* 88E8039 */
122 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4354) }, /* 88E8040 */ 122 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4354) }, /* 88E8040 */
123 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4356) }, /* 88EC033 */ 123 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4356) }, /* 88EC033 */
124 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4357) }, /* 88E8042 */
124 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x435A) }, /* 88E8048 */ 125 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x435A) }, /* 88E8048 */
125 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4360) }, /* 88E8052 */ 126 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4360) }, /* 88E8052 */
126 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4361) }, /* 88E8050 */ 127 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4361) }, /* 88E8050 */
@@ -134,6 +135,7 @@ static const struct pci_device_id sky2_id_table[] = {
134 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4369) }, /* 88EC042 */ 135 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4369) }, /* 88EC042 */
135 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436A) }, /* 88E8058 */ 136 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436A) }, /* 88E8058 */
136 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436B) }, /* 88E8071 */ 137 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436B) }, /* 88E8071 */
138 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436C) }, /* 88E8072 */
137 { 0 } 139 { 0 }
138}; 140};
139 141
@@ -156,7 +158,7 @@ static const char *yukon2_name[] = {
156 158
157static void sky2_set_multicast(struct net_device *dev); 159static void sky2_set_multicast(struct net_device *dev);
158 160
159/* Access to external PHY */ 161/* Access to PHY via serial interconnect */
160static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val) 162static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val)
161{ 163{
162 int i; 164 int i;
@@ -166,13 +168,22 @@ static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val)
166 GM_SMI_CT_PHY_AD(PHY_ADDR_MARV) | GM_SMI_CT_REG_AD(reg)); 168 GM_SMI_CT_PHY_AD(PHY_ADDR_MARV) | GM_SMI_CT_REG_AD(reg));
167 169
168 for (i = 0; i < PHY_RETRIES; i++) { 170 for (i = 0; i < PHY_RETRIES; i++) {
169 if (!(gma_read16(hw, port, GM_SMI_CTRL) & GM_SMI_CT_BUSY)) 171 u16 ctrl = gma_read16(hw, port, GM_SMI_CTRL);
172 if (ctrl == 0xffff)
173 goto io_error;
174
175 if (!(ctrl & GM_SMI_CT_BUSY))
170 return 0; 176 return 0;
171 udelay(1); 177
178 udelay(10);
172 } 179 }
173 180
174 printk(KERN_WARNING PFX "%s: phy write timeout\n", hw->dev[port]->name); 181 dev_warn(&hw->pdev->dev,"%s: phy write timeout\n", hw->dev[port]->name);
175 return -ETIMEDOUT; 182 return -ETIMEDOUT;
183
184io_error:
185 dev_err(&hw->pdev->dev, "%s: phy I/O error\n", hw->dev[port]->name);
186 return -EIO;
176} 187}
177 188
178static int __gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg, u16 *val) 189static int __gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg, u16 *val)
@@ -183,23 +194,29 @@ static int __gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg, u16 *val)
183 | GM_SMI_CT_REG_AD(reg) | GM_SMI_CT_OP_RD); 194 | GM_SMI_CT_REG_AD(reg) | GM_SMI_CT_OP_RD);
184 195
185 for (i = 0; i < PHY_RETRIES; i++) { 196 for (i = 0; i < PHY_RETRIES; i++) {
186 if (gma_read16(hw, port, GM_SMI_CTRL) & GM_SMI_CT_RD_VAL) { 197 u16 ctrl = gma_read16(hw, port, GM_SMI_CTRL);
198 if (ctrl == 0xffff)
199 goto io_error;
200
201 if (ctrl & GM_SMI_CT_RD_VAL) {
187 *val = gma_read16(hw, port, GM_SMI_DATA); 202 *val = gma_read16(hw, port, GM_SMI_DATA);
188 return 0; 203 return 0;
189 } 204 }
190 205
191 udelay(1); 206 udelay(10);
192 } 207 }
193 208
209 dev_warn(&hw->pdev->dev, "%s: phy read timeout\n", hw->dev[port]->name);
194 return -ETIMEDOUT; 210 return -ETIMEDOUT;
211io_error:
212 dev_err(&hw->pdev->dev, "%s: phy I/O error\n", hw->dev[port]->name);
213 return -EIO;
195} 214}
196 215
197static u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg) 216static inline u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg)
198{ 217{
199 u16 v; 218 u16 v;
200 219 __gm_phy_read(hw, port, reg, &v);
201 if (__gm_phy_read(hw, port, reg, &v) != 0)
202 printk(KERN_WARNING PFX "%s: phy read timeout\n", hw->dev[port]->name);
203 return v; 220 return v;
204} 221}
205 222
@@ -273,8 +290,6 @@ static void sky2_gmac_reset(struct sky2_hw *hw, unsigned port)
273 290
274 /* disable all GMAC IRQ's */ 291 /* disable all GMAC IRQ's */
275 sky2_write8(hw, SK_REG(port, GMAC_IRQ_MSK), 0); 292 sky2_write8(hw, SK_REG(port, GMAC_IRQ_MSK), 0);
276 /* disable PHY IRQs */
277 gm_phy_write(hw, port, PHY_MARV_INT_MASK, 0);
278 293
279 gma_write16(hw, port, GM_MC_ADDR_H1, 0); /* clear MC hash */ 294 gma_write16(hw, port, GM_MC_ADDR_H1, 0); /* clear MC hash */
280 gma_write16(hw, port, GM_MC_ADDR_H2, 0); 295 gma_write16(hw, port, GM_MC_ADDR_H2, 0);
@@ -1805,29 +1820,6 @@ static void sky2_link_up(struct sky2_port *sky2)
1805 sky2_write8(hw, SK_REG(port, LNK_LED_REG), 1820 sky2_write8(hw, SK_REG(port, LNK_LED_REG),
1806 LINKLED_ON | LINKLED_BLINK_OFF | LINKLED_LINKSYNC_OFF); 1821 LINKLED_ON | LINKLED_BLINK_OFF | LINKLED_LINKSYNC_OFF);
1807 1822
1808 if (hw->flags & SKY2_HW_NEWER_PHY) {
1809 u16 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR);
1810 u16 led = PHY_M_LEDC_LOS_CTRL(1); /* link active */
1811
1812 switch(sky2->speed) {
1813 case SPEED_10:
1814 led |= PHY_M_LEDC_INIT_CTRL(7);
1815 break;
1816
1817 case SPEED_100:
1818 led |= PHY_M_LEDC_STA1_CTRL(7);
1819 break;
1820
1821 case SPEED_1000:
1822 led |= PHY_M_LEDC_STA0_CTRL(7);
1823 break;
1824 }
1825
1826 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3);
1827 gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, led);
1828 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg);
1829 }
1830
1831 if (netif_msg_link(sky2)) 1823 if (netif_msg_link(sky2))
1832 printk(KERN_INFO PFX 1824 printk(KERN_INFO PFX
1833 "%s: Link is up at %d Mbps, %s duplex, flow control %s\n", 1825 "%s: Link is up at %d Mbps, %s duplex, flow control %s\n",
@@ -2247,20 +2239,26 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do, u16 idx)
2247 do { 2239 do {
2248 struct sky2_port *sky2; 2240 struct sky2_port *sky2;
2249 struct sky2_status_le *le = hw->st_le + hw->st_idx; 2241 struct sky2_status_le *le = hw->st_le + hw->st_idx;
2250 unsigned port = le->css & CSS_LINK_BIT; 2242 unsigned port;
2251 struct net_device *dev; 2243 struct net_device *dev;
2252 struct sk_buff *skb; 2244 struct sk_buff *skb;
2253 u32 status; 2245 u32 status;
2254 u16 length; 2246 u16 length;
2247 u8 opcode = le->opcode;
2248
2249 if (!(opcode & HW_OWNER))
2250 break;
2255 2251
2256 hw->st_idx = RING_NEXT(hw->st_idx, STATUS_RING_SIZE); 2252 hw->st_idx = RING_NEXT(hw->st_idx, STATUS_RING_SIZE);
2257 2253
2254 port = le->css & CSS_LINK_BIT;
2258 dev = hw->dev[port]; 2255 dev = hw->dev[port];
2259 sky2 = netdev_priv(dev); 2256 sky2 = netdev_priv(dev);
2260 length = le16_to_cpu(le->length); 2257 length = le16_to_cpu(le->length);
2261 status = le32_to_cpu(le->status); 2258 status = le32_to_cpu(le->status);
2262 2259
2263 switch (le->opcode & ~HW_OWNER) { 2260 le->opcode = 0;
2261 switch (opcode & ~HW_OWNER) {
2264 case OP_RXSTAT: 2262 case OP_RXSTAT:
2265 ++rx[port]; 2263 ++rx[port];
2266 skb = sky2_receive(dev, length, status); 2264 skb = sky2_receive(dev, length, status);
@@ -2353,7 +2351,7 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do, u16 idx)
2353 default: 2351 default:
2354 if (net_ratelimit()) 2352 if (net_ratelimit())
2355 printk(KERN_WARNING PFX 2353 printk(KERN_WARNING PFX
2356 "unknown status opcode 0x%x\n", le->opcode); 2354 "unknown status opcode 0x%x\n", opcode);
2357 } 2355 }
2358 } while (hw->st_idx != idx); 2356 } while (hw->st_idx != idx);
2359 2357
@@ -2439,13 +2437,26 @@ static void sky2_hw_intr(struct sky2_hw *hw)
2439 2437
2440 if (status & Y2_IS_PCI_EXP) { 2438 if (status & Y2_IS_PCI_EXP) {
2441 /* PCI-Express uncorrectable Error occurred */ 2439 /* PCI-Express uncorrectable Error occurred */
2442 int pos = pci_find_aer_capability(hw->pdev); 2440 int aer = pci_find_aer_capability(hw->pdev);
2443 u32 err; 2441 u32 err;
2444 2442
2445 pci_read_config_dword(pdev, pos + PCI_ERR_UNCOR_STATUS, &err); 2443 if (aer) {
2444 pci_read_config_dword(pdev, aer + PCI_ERR_UNCOR_STATUS,
2445 &err);
2446 pci_cleanup_aer_uncorrect_error_status(pdev);
2447 } else {
2448 /* Either AER not configured, or not working
2449 * because of bad MMCONFIG, so just do recover
2450 * manually.
2451 */
2452 err = sky2_read32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS);
2453 sky2_write32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS,
2454 0xfffffffful);
2455 }
2456
2446 if (net_ratelimit()) 2457 if (net_ratelimit())
2447 dev_err(&pdev->dev, "PCI Express error (0x%x)\n", err); 2458 dev_err(&pdev->dev, "PCI Express error (0x%x)\n", err);
2448 pci_cleanup_aer_uncorrect_error_status(pdev); 2459
2449 } 2460 }
2450 2461
2451 if (status & Y2_HWE_L1_MASK) 2462 if (status & Y2_HWE_L1_MASK)
@@ -2791,6 +2802,9 @@ static void sky2_reset(struct sky2_hw *hw)
2791 sky2_write8(hw, B0_CTST, CS_RST_SET); 2802 sky2_write8(hw, B0_CTST, CS_RST_SET);
2792 sky2_write8(hw, B0_CTST, CS_RST_CLR); 2803 sky2_write8(hw, B0_CTST, CS_RST_CLR);
2793 2804
2805 /* allow writes to PCI config */
2806 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2807
2794 /* clear PCI errors, if any */ 2808 /* clear PCI errors, if any */
2795 pci_read_config_word(pdev, PCI_STATUS, &status); 2809 pci_read_config_word(pdev, PCI_STATUS, &status);
2796 status |= PCI_STATUS_ERROR_BITS; 2810 status |= PCI_STATUS_ERROR_BITS;
@@ -2800,9 +2814,18 @@ static void sky2_reset(struct sky2_hw *hw)
2800 2814
2801 cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); 2815 cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
2802 if (cap) { 2816 if (cap) {
2803 /* Check for advanced error reporting */ 2817 if (pci_find_aer_capability(pdev)) {
2804 pci_cleanup_aer_uncorrect_error_status(pdev); 2818 /* Check for advanced error reporting */
2805 pci_cleanup_aer_correct_error_status(pdev); 2819 pci_cleanup_aer_uncorrect_error_status(pdev);
2820 pci_cleanup_aer_correct_error_status(pdev);
2821 } else {
2822 dev_warn(&pdev->dev,
2823 "PCI Express Advanced Error Reporting"
2824 " not configured or MMCONFIG problem?\n");
2825
2826 sky2_write32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS,
2827 0xfffffffful);
2828 }
2806 2829
2807 /* If error bit is stuck on ignore it */ 2830 /* If error bit is stuck on ignore it */
2808 if (sky2_read32(hw, B0_HWE_ISRC) & Y2_IS_PCI_EXP) 2831 if (sky2_read32(hw, B0_HWE_ISRC) & Y2_IS_PCI_EXP)
@@ -3974,7 +3997,8 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
3974 dev->tx_timeout = sky2_tx_timeout; 3997 dev->tx_timeout = sky2_tx_timeout;
3975 dev->watchdog_timeo = TX_WATCHDOG; 3998 dev->watchdog_timeo = TX_WATCHDOG;
3976#ifdef CONFIG_NET_POLL_CONTROLLER 3999#ifdef CONFIG_NET_POLL_CONTROLLER
3977 dev->poll_controller = sky2_netpoll; 4000 if (port == 0)
4001 dev->poll_controller = sky2_netpoll;
3978#endif 4002#endif
3979 4003
3980 sky2 = netdev_priv(dev); 4004 sky2 = netdev_priv(dev);
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index 49ee264064ab..69525fd7908d 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -247,7 +247,8 @@ enum csr_regs {
247 B3_PA_CTRL = 0x01f0, 247 B3_PA_CTRL = 0x01f0,
248 B3_PA_TEST = 0x01f2, 248 B3_PA_TEST = 0x01f2,
249 249
250 Y2_CFG_SPC = 0x1c00, 250 Y2_CFG_SPC = 0x1c00, /* PCI config space region */
251 Y2_CFG_AER = 0x1d00, /* PCI Advanced Error Report region */
251}; 252};
252 253
253/* B0_CTST 16 bit Control/Status register */ 254/* B0_CTST 16 bit Control/Status register */
diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index 335b7cc80eba..251a3ce376ac 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -1218,14 +1218,8 @@ static int slip_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
1218 return 0; 1218 return 0;
1219 /* VSV changes end */ 1219 /* VSV changes end */
1220#endif 1220#endif
1221
1222 /* Allow stty to read, but not set, the serial port */
1223 case TCGETS:
1224 case TCGETA:
1225 return n_tty_ioctl(tty, file, cmd, arg);
1226
1227 default: 1221 default:
1228 return -ENOIOCTLCMD; 1222 return tty_mode_ioctl(tty, file, cmd, arg);
1229 } 1223 }
1230} 1224}
1231 1225
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index 729fd28c08b5..db34e1eb67e9 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -224,6 +224,21 @@ SMC_outw(u16 val, void __iomem *ioaddr, int reg)
224 } 224 }
225} 225}
226 226
227#elif defined(CONFIG_MACH_ZYLONITE)
228
229#define SMC_CAN_USE_8BIT 1
230#define SMC_CAN_USE_16BIT 1
231#define SMC_CAN_USE_32BIT 0
232#define SMC_IO_SHIFT 0
233#define SMC_NOWAIT 1
234#define SMC_USE_PXA_DMA 1
235#define SMC_inb(a, r) readb((a) + (r))
236#define SMC_inw(a, r) readw((a) + (r))
237#define SMC_insw(a, r, p, l) insw((a) + (r), p, l)
238#define SMC_outsw(a, r, p, l) outsw((a) + (r), p, l)
239#define SMC_outb(v, a, r) writeb(v, (a) + (r))
240#define SMC_outw(v, a, r) writew(v, (a) + (r))
241
227#elif defined(CONFIG_ARCH_OMAP) 242#elif defined(CONFIG_ARCH_OMAP)
228 243
229/* We can only do 16-bit reads and writes in the static memory space. */ 244/* We can only do 16-bit reads and writes in the static memory space. */
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index 53b8344a68ef..f6fedcc32de1 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -2333,10 +2333,10 @@ static int gem_close(struct net_device *dev)
2333{ 2333{
2334 struct gem *gp = dev->priv; 2334 struct gem *gp = dev->priv;
2335 2335
2336 napi_disable(&gp->napi);
2337
2338 mutex_lock(&gp->pm_mutex); 2336 mutex_lock(&gp->pm_mutex);
2339 2337
2338 napi_disable(&gp->napi);
2339
2340 gp->opened = 0; 2340 gp->opened = 0;
2341 if (!gp->asleep) 2341 if (!gp->asleep)
2342 gem_do_stop(dev, 0); 2342 gem_do_stop(dev, 0);
@@ -2355,8 +2355,6 @@ static int gem_suspend(struct pci_dev *pdev, pm_message_t state)
2355 2355
2356 mutex_lock(&gp->pm_mutex); 2356 mutex_lock(&gp->pm_mutex);
2357 2357
2358 napi_disable(&gp->napi);
2359
2360 printk(KERN_INFO "%s: suspending, WakeOnLan %s\n", 2358 printk(KERN_INFO "%s: suspending, WakeOnLan %s\n",
2361 dev->name, 2359 dev->name,
2362 (gp->wake_on_lan && gp->opened) ? "enabled" : "disabled"); 2360 (gp->wake_on_lan && gp->opened) ? "enabled" : "disabled");
@@ -2370,6 +2368,8 @@ static int gem_suspend(struct pci_dev *pdev, pm_message_t state)
2370 2368
2371 /* If the driver is opened, we stop the MAC */ 2369 /* If the driver is opened, we stop the MAC */
2372 if (gp->opened) { 2370 if (gp->opened) {
2371 napi_disable(&gp->napi);
2372
2373 /* Stop traffic, mark us closed */ 2373 /* Stop traffic, mark us closed */
2374 netif_device_detach(dev); 2374 netif_device_detach(dev);
2375 2375
@@ -2460,6 +2460,7 @@ static int gem_resume(struct pci_dev *pdev)
2460 /* Re-attach net device */ 2460 /* Re-attach net device */
2461 netif_device_attach(dev); 2461 netif_device_attach(dev);
2462 2462
2463 napi_enable(&gp->napi);
2463 } 2464 }
2464 2465
2465 spin_lock_irqsave(&gp->lock, flags); 2466 spin_lock_irqsave(&gp->lock, flags);
@@ -2479,8 +2480,6 @@ static int gem_resume(struct pci_dev *pdev)
2479 spin_unlock(&gp->tx_lock); 2480 spin_unlock(&gp->tx_lock);
2480 spin_unlock_irqrestore(&gp->lock, flags); 2481 spin_unlock_irqrestore(&gp->lock, flags);
2481 2482
2482 napi_enable(&gp->napi);
2483
2484 mutex_unlock(&gp->pm_mutex); 2483 mutex_unlock(&gp->pm_mutex);
2485 2484
2486 return 0; 2485 return 0;
diff --git a/drivers/net/tehuti.c b/drivers/net/tehuti.c
index 4e1b84e6d66a..21230c97b2a0 100644
--- a/drivers/net/tehuti.c
+++ b/drivers/net/tehuti.c
@@ -2168,10 +2168,10 @@ bdx_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
2168{ 2168{
2169 struct bdx_priv *priv = netdev->priv; 2169 struct bdx_priv *priv = netdev->priv;
2170 2170
2171 strncat(drvinfo->driver, BDX_DRV_NAME, sizeof(drvinfo->driver)); 2171 strlcat(drvinfo->driver, BDX_DRV_NAME, sizeof(drvinfo->driver));
2172 strncat(drvinfo->version, BDX_DRV_VERSION, sizeof(drvinfo->version)); 2172 strlcat(drvinfo->version, BDX_DRV_VERSION, sizeof(drvinfo->version));
2173 strncat(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); 2173 strlcat(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version));
2174 strncat(drvinfo->bus_info, pci_name(priv->pdev), 2174 strlcat(drvinfo->bus_info, pci_name(priv->pdev),
2175 sizeof(drvinfo->bus_info)); 2175 sizeof(drvinfo->bus_info));
2176 2176
2177 drvinfo->n_stats = ((priv->stats_flag) ? 2177 drvinfo->n_stats = ((priv->stats_flag) ?
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index cad519910767..4942f7d18937 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -64,8 +64,8 @@
64 64
65#define DRV_MODULE_NAME "tg3" 65#define DRV_MODULE_NAME "tg3"
66#define PFX DRV_MODULE_NAME ": " 66#define PFX DRV_MODULE_NAME ": "
67#define DRV_MODULE_VERSION "3.85" 67#define DRV_MODULE_VERSION "3.86"
68#define DRV_MODULE_RELDATE "October 18, 2007" 68#define DRV_MODULE_RELDATE "November 9, 2007"
69 69
70#define TG3_DEF_MAC_MODE 0 70#define TG3_DEF_MAC_MODE 0
71#define TG3_DEF_RX_MODE 0 71#define TG3_DEF_RX_MODE 0
@@ -1106,6 +1106,24 @@ static int tg3_phy_reset(struct tg3 *tp)
1106 if (err) 1106 if (err)
1107 return err; 1107 return err;
1108 1108
1109 if (tp->tg3_flags3 & TG3_FLG3_5761_5784_AX_FIXES) {
1110 u32 val;
1111
1112 val = tr32(TG3_CPMU_LSPD_1000MB_CLK);
1113 if ((val & CPMU_LSPD_1000MB_MACCLK_MASK) ==
1114 CPMU_LSPD_1000MB_MACCLK_12_5) {
1115 val &= ~CPMU_LSPD_1000MB_MACCLK_MASK;
1116 udelay(40);
1117 tw32_f(TG3_CPMU_LSPD_1000MB_CLK, val);
1118 }
1119
1120 /* Disable GPHY autopowerdown. */
1121 tg3_writephy(tp, MII_TG3_MISC_SHDW,
1122 MII_TG3_MISC_SHDW_WREN |
1123 MII_TG3_MISC_SHDW_APD_SEL |
1124 MII_TG3_MISC_SHDW_APD_WKTM_84MS);
1125 }
1126
1109out: 1127out:
1110 if (tp->tg3_flags2 & TG3_FLG2_PHY_ADC_BUG) { 1128 if (tp->tg3_flags2 & TG3_FLG2_PHY_ADC_BUG) {
1111 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00); 1129 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00);
@@ -1297,6 +1315,8 @@ static void tg3_nvram_unlock(struct tg3 *);
1297 1315
1298static void tg3_power_down_phy(struct tg3 *tp) 1316static void tg3_power_down_phy(struct tg3 *tp)
1299{ 1317{
1318 u32 val;
1319
1300 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) { 1320 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) {
1301 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) { 1321 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) {
1302 u32 sg_dig_ctrl = tr32(SG_DIG_CTRL); 1322 u32 sg_dig_ctrl = tr32(SG_DIG_CTRL);
@@ -1311,8 +1331,6 @@ static void tg3_power_down_phy(struct tg3 *tp)
1311 } 1331 }
1312 1332
1313 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { 1333 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
1314 u32 val;
1315
1316 tg3_bmcr_reset(tp); 1334 tg3_bmcr_reset(tp);
1317 val = tr32(GRC_MISC_CFG); 1335 val = tr32(GRC_MISC_CFG);
1318 tw32_f(GRC_MISC_CFG, val | GRC_MISC_CFG_EPHY_IDDQ); 1336 tw32_f(GRC_MISC_CFG, val | GRC_MISC_CFG_EPHY_IDDQ);
@@ -1332,6 +1350,14 @@ static void tg3_power_down_phy(struct tg3 *tp)
1332 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780 && 1350 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5780 &&
1333 (tp->tg3_flags2 & TG3_FLG2_MII_SERDES))) 1351 (tp->tg3_flags2 & TG3_FLG2_MII_SERDES)))
1334 return; 1352 return;
1353
1354 if (tp->tg3_flags3 & TG3_FLG3_5761_5784_AX_FIXES) {
1355 val = tr32(TG3_CPMU_LSPD_1000MB_CLK);
1356 val &= ~CPMU_LSPD_1000MB_MACCLK_MASK;
1357 val |= CPMU_LSPD_1000MB_MACCLK_12_5;
1358 tw32_f(TG3_CPMU_LSPD_1000MB_CLK, val);
1359 }
1360
1335 tg3_writephy(tp, MII_BMCR, BMCR_PDOWN); 1361 tg3_writephy(tp, MII_BMCR, BMCR_PDOWN);
1336} 1362}
1337 1363
@@ -3126,6 +3152,23 @@ static int tg3_setup_phy(struct tg3 *tp, int force_reset)
3126 err = tg3_setup_copper_phy(tp, force_reset); 3152 err = tg3_setup_copper_phy(tp, force_reset);
3127 } 3153 }
3128 3154
3155 if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 ||
3156 tp->pci_chip_rev_id == CHIPREV_ID_5784_A1) {
3157 u32 val, scale;
3158
3159 val = tr32(TG3_CPMU_CLCK_STAT) & CPMU_CLCK_STAT_MAC_CLCK_MASK;
3160 if (val == CPMU_CLCK_STAT_MAC_CLCK_62_5)
3161 scale = 65;
3162 else if (val == CPMU_CLCK_STAT_MAC_CLCK_6_25)
3163 scale = 6;
3164 else
3165 scale = 12;
3166
3167 val = tr32(GRC_MISC_CFG) & ~GRC_MISC_CFG_PRESCALAR_MASK;
3168 val |= (scale << GRC_MISC_CFG_PRESCALAR_SHIFT);
3169 tw32(GRC_MISC_CFG, val);
3170 }
3171
3129 if (tp->link_config.active_speed == SPEED_1000 && 3172 if (tp->link_config.active_speed == SPEED_1000 &&
3130 tp->link_config.active_duplex == DUPLEX_HALF) 3173 tp->link_config.active_duplex == DUPLEX_HALF)
3131 tw32(MAC_TX_LENGTHS, 3174 tw32(MAC_TX_LENGTHS,
@@ -5054,12 +5097,15 @@ static void tg3_restore_pci_state(struct tg3 *tp)
5054 5097
5055 pci_write_config_word(tp->pdev, PCI_COMMAND, tp->pci_cmd); 5098 pci_write_config_word(tp->pdev, PCI_COMMAND, tp->pci_cmd);
5056 5099
5057 if (!(tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS)) { 5100 if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS)
5101 pcie_set_readrq(tp->pdev, 4096);
5102 else {
5058 pci_write_config_byte(tp->pdev, PCI_CACHE_LINE_SIZE, 5103 pci_write_config_byte(tp->pdev, PCI_CACHE_LINE_SIZE,
5059 tp->pci_cacheline_sz); 5104 tp->pci_cacheline_sz);
5060 pci_write_config_byte(tp->pdev, PCI_LATENCY_TIMER, 5105 pci_write_config_byte(tp->pdev, PCI_LATENCY_TIMER,
5061 tp->pci_lat_timer); 5106 tp->pci_lat_timer);
5062 } 5107 }
5108
5063 /* Make sure PCI-X relaxed ordering bit is clear. */ 5109 /* Make sure PCI-X relaxed ordering bit is clear. */
5064 if (tp->pcix_cap) { 5110 if (tp->pcix_cap) {
5065 u16 pcix_cmd; 5111 u16 pcix_cmd;
@@ -6343,10 +6389,26 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6343 6389
6344 tg3_write_sig_legacy(tp, RESET_KIND_INIT); 6390 tg3_write_sig_legacy(tp, RESET_KIND_INIT);
6345 6391
6346 if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0) { 6392 if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 ||
6393 tp->pci_chip_rev_id == CHIPREV_ID_5784_A1) {
6347 val = tr32(TG3_CPMU_CTRL); 6394 val = tr32(TG3_CPMU_CTRL);
6348 val &= ~(CPMU_CTRL_LINK_AWARE_MODE | CPMU_CTRL_LINK_IDLE_MODE); 6395 val &= ~(CPMU_CTRL_LINK_AWARE_MODE | CPMU_CTRL_LINK_IDLE_MODE);
6349 tw32(TG3_CPMU_CTRL, val); 6396 tw32(TG3_CPMU_CTRL, val);
6397
6398 val = tr32(TG3_CPMU_LSPD_10MB_CLK);
6399 val &= ~CPMU_LSPD_10MB_MACCLK_MASK;
6400 val |= CPMU_LSPD_10MB_MACCLK_6_25;
6401 tw32(TG3_CPMU_LSPD_10MB_CLK, val);
6402
6403 val = tr32(TG3_CPMU_LNK_AWARE_PWRMD);
6404 val &= ~CPMU_LNK_AWARE_MACCLK_MASK;
6405 val |= CPMU_LNK_AWARE_MACCLK_6_25;
6406 tw32(TG3_CPMU_LNK_AWARE_PWRMD, val);
6407
6408 val = tr32(TG3_CPMU_HST_ACC);
6409 val &= ~CPMU_HST_ACC_MACCLK_MASK;
6410 val |= CPMU_HST_ACC_MACCLK_6_25;
6411 tw32(TG3_CPMU_HST_ACC, val);
6350 } 6412 }
6351 6413
6352 /* This works around an issue with Athlon chipsets on 6414 /* This works around an issue with Athlon chipsets on
@@ -8267,7 +8329,7 @@ static int tg3_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
8267 SUPPORTED_100baseT_Full | 8329 SUPPORTED_100baseT_Full |
8268 SUPPORTED_10baseT_Half | 8330 SUPPORTED_10baseT_Half |
8269 SUPPORTED_10baseT_Full | 8331 SUPPORTED_10baseT_Full |
8270 SUPPORTED_MII); 8332 SUPPORTED_TP);
8271 cmd->port = PORT_TP; 8333 cmd->port = PORT_TP;
8272 } else { 8334 } else {
8273 cmd->supported |= SUPPORTED_FIBRE; 8335 cmd->supported |= SUPPORTED_FIBRE;
@@ -8664,7 +8726,9 @@ static void tg3_get_ethtool_stats (struct net_device *dev,
8664} 8726}
8665 8727
8666#define NVRAM_TEST_SIZE 0x100 8728#define NVRAM_TEST_SIZE 0x100
8667#define NVRAM_SELFBOOT_FORMAT1_SIZE 0x14 8729#define NVRAM_SELFBOOT_FORMAT1_0_SIZE 0x14
8730#define NVRAM_SELFBOOT_FORMAT1_2_SIZE 0x18
8731#define NVRAM_SELFBOOT_FORMAT1_3_SIZE 0x1c
8668#define NVRAM_SELFBOOT_HW_SIZE 0x20 8732#define NVRAM_SELFBOOT_HW_SIZE 0x20
8669#define NVRAM_SELFBOOT_DATA_SIZE 0x1c 8733#define NVRAM_SELFBOOT_DATA_SIZE 0x1c
8670 8734
@@ -8679,9 +8743,22 @@ static int tg3_test_nvram(struct tg3 *tp)
8679 if (magic == TG3_EEPROM_MAGIC) 8743 if (magic == TG3_EEPROM_MAGIC)
8680 size = NVRAM_TEST_SIZE; 8744 size = NVRAM_TEST_SIZE;
8681 else if ((magic & TG3_EEPROM_MAGIC_FW_MSK) == TG3_EEPROM_MAGIC_FW) { 8745 else if ((magic & TG3_EEPROM_MAGIC_FW_MSK) == TG3_EEPROM_MAGIC_FW) {
8682 if ((magic & 0xe00000) == 0x200000) 8746 if ((magic & TG3_EEPROM_SB_FORMAT_MASK) ==
8683 size = NVRAM_SELFBOOT_FORMAT1_SIZE; 8747 TG3_EEPROM_SB_FORMAT_1) {
8684 else 8748 switch (magic & TG3_EEPROM_SB_REVISION_MASK) {
8749 case TG3_EEPROM_SB_REVISION_0:
8750 size = NVRAM_SELFBOOT_FORMAT1_0_SIZE;
8751 break;
8752 case TG3_EEPROM_SB_REVISION_2:
8753 size = NVRAM_SELFBOOT_FORMAT1_2_SIZE;
8754 break;
8755 case TG3_EEPROM_SB_REVISION_3:
8756 size = NVRAM_SELFBOOT_FORMAT1_3_SIZE;
8757 break;
8758 default:
8759 return 0;
8760 }
8761 } else
8685 return 0; 8762 return 0;
8686 } else if ((magic & TG3_EEPROM_MAGIC_HW_MSK) == TG3_EEPROM_MAGIC_HW) 8763 } else if ((magic & TG3_EEPROM_MAGIC_HW_MSK) == TG3_EEPROM_MAGIC_HW)
8687 size = NVRAM_SELFBOOT_HW_SIZE; 8764 size = NVRAM_SELFBOOT_HW_SIZE;
@@ -8708,8 +8785,17 @@ static int tg3_test_nvram(struct tg3 *tp)
8708 TG3_EEPROM_MAGIC_FW) { 8785 TG3_EEPROM_MAGIC_FW) {
8709 u8 *buf8 = (u8 *) buf, csum8 = 0; 8786 u8 *buf8 = (u8 *) buf, csum8 = 0;
8710 8787
8711 for (i = 0; i < size; i++) 8788 if ((cpu_to_be32(buf[0]) & TG3_EEPROM_SB_REVISION_MASK) ==
8712 csum8 += buf8[i]; 8789 TG3_EEPROM_SB_REVISION_2) {
8790 /* For rev 2, the csum doesn't include the MBA. */
8791 for (i = 0; i < TG3_EEPROM_SB_F1R2_MBA_OFF; i++)
8792 csum8 += buf8[i];
8793 for (i = TG3_EEPROM_SB_F1R2_MBA_OFF + 4; i < size; i++)
8794 csum8 += buf8[i];
8795 } else {
8796 for (i = 0; i < size; i++)
8797 csum8 += buf8[i];
8798 }
8713 8799
8714 if (csum8 == 0) { 8800 if (csum8 == 0) {
8715 err = 0; 8801 err = 0;
@@ -9293,7 +9379,7 @@ static int tg3_test_loopback(struct tg3 *tp)
9293 if (err) 9379 if (err)
9294 return TG3_LOOPBACK_FAILED; 9380 return TG3_LOOPBACK_FAILED;
9295 9381
9296 if (tp->tg3_flags & TG3_FLAG_CPMU_PRESENT) { 9382 if (tp->tg3_flags3 & TG3_FLG3_5761_5784_AX_FIXES) {
9297 int i; 9383 int i;
9298 u32 status; 9384 u32 status;
9299 9385
@@ -9310,17 +9396,17 @@ static int tg3_test_loopback(struct tg3 *tp)
9310 if (status != CPMU_MUTEX_GNT_DRIVER) 9396 if (status != CPMU_MUTEX_GNT_DRIVER)
9311 return TG3_LOOPBACK_FAILED; 9397 return TG3_LOOPBACK_FAILED;
9312 9398
9313 cpmuctrl = tr32(TG3_CPMU_CTRL);
9314
9315 /* Turn off power management based on link speed. */ 9399 /* Turn off power management based on link speed. */
9400 cpmuctrl = tr32(TG3_CPMU_CTRL);
9316 tw32(TG3_CPMU_CTRL, 9401 tw32(TG3_CPMU_CTRL,
9317 cpmuctrl & ~CPMU_CTRL_LINK_SPEED_MODE); 9402 cpmuctrl & ~(CPMU_CTRL_LINK_SPEED_MODE |
9403 CPMU_CTRL_LINK_AWARE_MODE));
9318 } 9404 }
9319 9405
9320 if (tg3_run_loopback(tp, TG3_MAC_LOOPBACK)) 9406 if (tg3_run_loopback(tp, TG3_MAC_LOOPBACK))
9321 err |= TG3_MAC_LOOPBACK_FAILED; 9407 err |= TG3_MAC_LOOPBACK_FAILED;
9322 9408
9323 if (tp->tg3_flags & TG3_FLAG_CPMU_PRESENT) { 9409 if (tp->tg3_flags3 & TG3_FLG3_5761_5784_AX_FIXES) {
9324 tw32(TG3_CPMU_CTRL, cpmuctrl); 9410 tw32(TG3_CPMU_CTRL, cpmuctrl);
9325 9411
9326 /* Release the mutex */ 9412 /* Release the mutex */
@@ -10541,6 +10627,10 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
10541 tp->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL) 10627 tp->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL)
10542 tp->led_ctrl = LED_CTRL_MODE_PHY_2; 10628 tp->led_ctrl = LED_CTRL_MODE_PHY_2;
10543 10629
10630 if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 ||
10631 tp->pci_chip_rev_id == CHIPREV_ID_5784_A1)
10632 tp->led_ctrl = LED_CTRL_MODE_MAC;
10633
10544 if (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP) { 10634 if (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP) {
10545 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT; 10635 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
10546 if ((tp->pdev->subsystem_vendor == 10636 if ((tp->pdev->subsystem_vendor ==
@@ -10859,7 +10949,7 @@ static void __devinit tg3_read_fw_ver(struct tg3 *tp)
10859 } 10949 }
10860 10950
10861 if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF) || 10951 if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF) ||
10862 (tp->tg3_flags & TG3_FLG3_ENABLE_APE)) 10952 (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE))
10863 return; 10953 return;
10864 10954
10865 for (offset = TG3_NVM_DIR_START; 10955 for (offset = TG3_NVM_DIR_START;
@@ -11127,6 +11217,9 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
11127 pcie_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_EXP); 11217 pcie_cap = pci_find_capability(tp->pdev, PCI_CAP_ID_EXP);
11128 if (pcie_cap != 0) { 11218 if (pcie_cap != 0) {
11129 tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS; 11219 tp->tg3_flags2 |= TG3_FLG2_PCI_EXPRESS;
11220
11221 pcie_set_readrq(tp->pdev, 4096);
11222
11130 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { 11223 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
11131 u16 lnkctl; 11224 u16 lnkctl;
11132 11225
@@ -11307,9 +11400,16 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
11307 } 11400 }
11308 11401
11309 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 || 11402 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 ||
11310 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5761) 11403 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5761) {
11311 tp->tg3_flags |= TG3_FLAG_CPMU_PRESENT; 11404 tp->tg3_flags |= TG3_FLAG_CPMU_PRESENT;
11312 11405
11406 if (tp->pci_chip_rev_id == CHIPREV_ID_5784_A0 ||
11407 tp->pci_chip_rev_id == CHIPREV_ID_5784_A1 ||
11408 tp->pci_chip_rev_id == CHIPREV_ID_5761_A0 ||
11409 tp->pci_chip_rev_id == CHIPREV_ID_5761_A1)
11410 tp->tg3_flags3 |= TG3_FLG3_5761_5784_AX_FIXES;
11411 }
11412
11313 /* Set up tp->grc_local_ctrl before calling tg3_set_power_state(). 11413 /* Set up tp->grc_local_ctrl before calling tg3_set_power_state().
11314 * GPIO1 driven high will bring 5700's external PHY out of reset. 11414 * GPIO1 driven high will bring 5700's external PHY out of reset.
11315 * It is also used as eeprom write protect on LOMs. 11415 * It is also used as eeprom write protect on LOMs.
@@ -12464,6 +12564,28 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
12464 goto err_out_iounmap; 12564 goto err_out_iounmap;
12465 } 12565 }
12466 12566
12567 if (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) {
12568 if (!(pci_resource_flags(pdev, 2) & IORESOURCE_MEM)) {
12569 printk(KERN_ERR PFX "Cannot find proper PCI device "
12570 "base address for APE, aborting.\n");
12571 err = -ENODEV;
12572 goto err_out_iounmap;
12573 }
12574
12575 tg3reg_base = pci_resource_start(pdev, 2);
12576 tg3reg_len = pci_resource_len(pdev, 2);
12577
12578 tp->aperegs = ioremap_nocache(tg3reg_base, tg3reg_len);
12579 if (tp->aperegs == 0UL) {
12580 printk(KERN_ERR PFX "Cannot map APE registers, "
12581 "aborting.\n");
12582 err = -ENOMEM;
12583 goto err_out_iounmap;
12584 }
12585
12586 tg3_ape_lock_init(tp);
12587 }
12588
12467 /* 12589 /*
12468 * Reset chip in case UNDI or EFI driver did not shutdown 12590 * Reset chip in case UNDI or EFI driver did not shutdown
12469 * DMA self test will enable WDMAC and we'll see (spurious) 12591 * DMA self test will enable WDMAC and we'll see (spurious)
@@ -12478,7 +12600,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
12478 err = tg3_test_dma(tp); 12600 err = tg3_test_dma(tp);
12479 if (err) { 12601 if (err) {
12480 printk(KERN_ERR PFX "DMA engine test failed, aborting.\n"); 12602 printk(KERN_ERR PFX "DMA engine test failed, aborting.\n");
12481 goto err_out_iounmap; 12603 goto err_out_apeunmap;
12482 } 12604 }
12483 12605
12484 /* Tigon3 can do ipv4 only... and some chips have buggy 12606 /* Tigon3 can do ipv4 only... and some chips have buggy
@@ -12501,28 +12623,6 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
12501 12623
12502 tg3_init_coal(tp); 12624 tg3_init_coal(tp);
12503 12625
12504 if (tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) {
12505 if (!(pci_resource_flags(pdev, 2) & IORESOURCE_MEM)) {
12506 printk(KERN_ERR PFX "Cannot find proper PCI device "
12507 "base address for APE, aborting.\n");
12508 err = -ENODEV;
12509 goto err_out_iounmap;
12510 }
12511
12512 tg3reg_base = pci_resource_start(pdev, 2);
12513 tg3reg_len = pci_resource_len(pdev, 2);
12514
12515 tp->aperegs = ioremap_nocache(tg3reg_base, tg3reg_len);
12516 if (tp->aperegs == 0UL) {
12517 printk(KERN_ERR PFX "Cannot map APE registers, "
12518 "aborting.\n");
12519 err = -ENOMEM;
12520 goto err_out_iounmap;
12521 }
12522
12523 tg3_ape_lock_init(tp);
12524 }
12525
12526 pci_set_drvdata(pdev, dev); 12626 pci_set_drvdata(pdev, dev);
12527 12627
12528 err = register_netdev(dev); 12628 err = register_netdev(dev);
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index 1d5b2a3dd29d..da18fb220712 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -109,6 +109,9 @@
109#define CHIPREV_ID_5714_A2 0x9002 109#define CHIPREV_ID_5714_A2 0x9002
110#define CHIPREV_ID_5906_A1 0xc001 110#define CHIPREV_ID_5906_A1 0xc001
111#define CHIPREV_ID_5784_A0 0x5784000 111#define CHIPREV_ID_5784_A0 0x5784000
112#define CHIPREV_ID_5784_A1 0x5784001
113#define CHIPREV_ID_5761_A0 0x5761000
114#define CHIPREV_ID_5761_A1 0x5761001
112#define GET_ASIC_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 12) 115#define GET_ASIC_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 12)
113#define ASIC_REV_5700 0x07 116#define ASIC_REV_5700 0x07
114#define ASIC_REV_5701 0x00 117#define ASIC_REV_5701 0x00
@@ -856,7 +859,31 @@
856#define CPMU_CTRL_LINK_IDLE_MODE 0x00000200 859#define CPMU_CTRL_LINK_IDLE_MODE 0x00000200
857#define CPMU_CTRL_LINK_AWARE_MODE 0x00000400 860#define CPMU_CTRL_LINK_AWARE_MODE 0x00000400
858#define CPMU_CTRL_LINK_SPEED_MODE 0x00004000 861#define CPMU_CTRL_LINK_SPEED_MODE 0x00004000
859/* 0x3604 --> 0x365c unused */ 862#define TG3_CPMU_LSPD_10MB_CLK 0x00003604
863#define CPMU_LSPD_10MB_MACCLK_MASK 0x001f0000
864#define CPMU_LSPD_10MB_MACCLK_6_25 0x00130000
865/* 0x3608 --> 0x360c unused */
866
867#define TG3_CPMU_LSPD_1000MB_CLK 0x0000360c
868#define CPMU_LSPD_1000MB_MACCLK_62_5 0x00000000
869#define CPMU_LSPD_1000MB_MACCLK_12_5 0x00110000
870#define CPMU_LSPD_1000MB_MACCLK_MASK 0x001f0000
871#define TG3_CPMU_LNK_AWARE_PWRMD 0x00003610
872#define CPMU_LNK_AWARE_MACCLK_MASK 0x001f0000
873#define CPMU_LNK_AWARE_MACCLK_6_25 0x00130000
874/* 0x3614 --> 0x361c unused */
875
876#define TG3_CPMU_HST_ACC 0x0000361c
877#define CPMU_HST_ACC_MACCLK_MASK 0x001f0000
878#define CPMU_HST_ACC_MACCLK_6_25 0x00130000
879/* 0x3620 --> 0x3630 unused */
880
881#define TG3_CPMU_CLCK_STAT 0x00003630
882#define CPMU_CLCK_STAT_MAC_CLCK_MASK 0x001f0000
883#define CPMU_CLCK_STAT_MAC_CLCK_62_5 0x00000000
884#define CPMU_CLCK_STAT_MAC_CLCK_12_5 0x00110000
885#define CPMU_CLCK_STAT_MAC_CLCK_6_25 0x00130000
886/* 0x3634 --> 0x365c unused */
860 887
861#define TG3_CPMU_MUTEX_REQ 0x0000365c 888#define TG3_CPMU_MUTEX_REQ 0x0000365c
862#define CPMU_MUTEX_REQ_DRIVER 0x00001000 889#define CPMU_MUTEX_REQ_DRIVER 0x00001000
@@ -1537,6 +1564,12 @@
1537#define TG3_EEPROM_MAGIC 0x669955aa 1564#define TG3_EEPROM_MAGIC 0x669955aa
1538#define TG3_EEPROM_MAGIC_FW 0xa5000000 1565#define TG3_EEPROM_MAGIC_FW 0xa5000000
1539#define TG3_EEPROM_MAGIC_FW_MSK 0xff000000 1566#define TG3_EEPROM_MAGIC_FW_MSK 0xff000000
1567#define TG3_EEPROM_SB_FORMAT_MASK 0x00e00000
1568#define TG3_EEPROM_SB_FORMAT_1 0x00200000
1569#define TG3_EEPROM_SB_REVISION_MASK 0x001f0000
1570#define TG3_EEPROM_SB_REVISION_0 0x00000000
1571#define TG3_EEPROM_SB_REVISION_2 0x00020000
1572#define TG3_EEPROM_SB_REVISION_3 0x00030000
1540#define TG3_EEPROM_MAGIC_HW 0xabcd 1573#define TG3_EEPROM_MAGIC_HW 0xabcd
1541#define TG3_EEPROM_MAGIC_HW_MSK 0xffff 1574#define TG3_EEPROM_MAGIC_HW_MSK 0xffff
1542 1575
@@ -1691,6 +1724,12 @@
1691#define MII_TG3_ISTAT 0x1a /* IRQ status register */ 1724#define MII_TG3_ISTAT 0x1a /* IRQ status register */
1692#define MII_TG3_IMASK 0x1b /* IRQ mask register */ 1725#define MII_TG3_IMASK 0x1b /* IRQ mask register */
1693 1726
1727#define MII_TG3_MISC_SHDW 0x1c
1728#define MII_TG3_MISC_SHDW_WREN 0x8000
1729#define MII_TG3_MISC_SHDW_APD_SEL 0x2800
1730
1731#define MII_TG3_MISC_SHDW_APD_WKTM_84MS 0x0001
1732
1694/* ISTAT/IMASK event bits */ 1733/* ISTAT/IMASK event bits */
1695#define MII_TG3_INT_LINKCHG 0x0002 1734#define MII_TG3_INT_LINKCHG 0x0002
1696#define MII_TG3_INT_SPEEDCHG 0x0004 1735#define MII_TG3_INT_SPEEDCHG 0x0004
@@ -1747,6 +1786,8 @@
1747/* APE convenience enumerations. */ 1786/* APE convenience enumerations. */
1748#define TG3_APE_LOCK_MEM 4 1787#define TG3_APE_LOCK_MEM 4
1749 1788
1789#define TG3_EEPROM_SB_F1R2_MBA_OFF 0x10
1790
1750 1791
1751/* There are two ways to manage the TX descriptors on the tigon3. 1792/* There are two ways to manage the TX descriptors on the tigon3.
1752 * Either the descriptors are in host DMA'able memory, or they 1793 * Either the descriptors are in host DMA'able memory, or they
@@ -2352,6 +2393,7 @@ struct tg3 {
2352 u32 tg3_flags3; 2393 u32 tg3_flags3;
2353#define TG3_FLG3_NO_NVRAM_ADDR_TRANS 0x00000001 2394#define TG3_FLG3_NO_NVRAM_ADDR_TRANS 0x00000001
2354#define TG3_FLG3_ENABLE_APE 0x00000002 2395#define TG3_FLG3_ENABLE_APE 0x00000002
2396#define TG3_FLG3_5761_5784_AX_FIXES 0x00000004
2355 2397
2356 struct timer_list timer; 2398 struct timer_list timer;
2357 u16 timer_counter; 2399 u16 timer_counter;
diff --git a/drivers/net/tulip/Kconfig b/drivers/net/tulip/Kconfig
index 49d7a290dbbc..20ac1503021e 100644
--- a/drivers/net/tulip/Kconfig
+++ b/drivers/net/tulip/Kconfig
@@ -24,8 +24,7 @@ config DE2104X
24 will say Y here.) Do read the Ethernet-HOWTO, available from 24 will say Y here.) Do read the Ethernet-HOWTO, available from
25 <http://www.tldp.org/docs.html#howto>. 25 <http://www.tldp.org/docs.html#howto>.
26 26
27 To compile this driver as a module, choose M here and read 27 To compile this driver as a module, choose M here. The module will
28 <file:Documentation/networking/net-modules.txt>. The module will
29 be called de2104x. 28 be called de2104x.
30 29
31config TULIP 30config TULIP
@@ -42,8 +41,7 @@ config TULIP
42 will say Y here.) Do read the Ethernet-HOWTO, available from 41 will say Y here.) Do read the Ethernet-HOWTO, available from
43 <http://www.tldp.org/docs.html#howto>. 42 <http://www.tldp.org/docs.html#howto>.
44 43
45 To compile this driver as a module, choose M here and read 44 To compile this driver as a module, choose M here. The module will
46 <file:Documentation/networking/net-modules.txt>. The module will
47 be called tulip. 45 be called tulip.
48 46
49config TULIP_MWI 47config TULIP_MWI
@@ -104,8 +102,7 @@ config DE4X5
104 information is contained in 102 information is contained in
105 <file:Documentation/networking/de4x5.txt>. 103 <file:Documentation/networking/de4x5.txt>.
106 104
107 To compile this driver as a module, choose M here and read 105 To compile this driver as a module, choose M here. The module will
108 <file:Documentation/networking/net-modules.txt>. The module will
109 be called de4x5. 106 be called de4x5.
110 107
111config WINBOND_840 108config WINBOND_840
@@ -129,8 +126,7 @@ config DM9102
129 (Ethernet) card, say Y. Some information is contained in the file 126 (Ethernet) card, say Y. Some information is contained in the file
130 <file:Documentation/networking/dmfe.txt>. 127 <file:Documentation/networking/dmfe.txt>.
131 128
132 To compile this driver as a module, choose M here and read 129 To compile this driver as a module, choose M here. The module will
133 <file:Documentation/networking/net-modules.txt>. The module will
134 be called dmfe. 130 be called dmfe.
135 131
136config ULI526X 132config ULI526X
@@ -141,8 +137,7 @@ config ULI526X
141 This driver is for ULi M5261/M5263 10/100M Ethernet Controller 137 This driver is for ULi M5261/M5263 10/100M Ethernet Controller
142 (<http://www.uli.com.tw/>). 138 (<http://www.uli.com.tw/>).
143 139
144 To compile this driver as a module, choose M here and read 140 To compile this driver as a module, choose M here. The module will
145 <file:Documentation/networking/net-modules.txt>. The module will
146 be called uli526x. 141 be called uli526x.
147 142
148config PCMCIA_XIRCOM 143config PCMCIA_XIRCOM
@@ -154,8 +149,7 @@ config PCMCIA_XIRCOM
154 as with work-alike chips from Lite-On (PNIC) and Macronix (MXIC) and 149 as with work-alike chips from Lite-On (PNIC) and Macronix (MXIC) and
155 ASIX. 150 ASIX.
156 151
157 To compile this driver as a module, choose M here and read 152 To compile this driver as a module, choose M here. The module will
158 <file:Documentation/networking/net-modules.txt>. The module will
159 be called xircom_cb. If unsure, say N. 153 be called xircom_cb. If unsure, say N.
160 154
161config PCMCIA_XIRTULIP 155config PCMCIA_XIRTULIP
@@ -168,8 +162,7 @@ config PCMCIA_XIRTULIP
168 as with work-alike chips from Lite-On (PNIC) and Macronix (MXIC) and 162 as with work-alike chips from Lite-On (PNIC) and Macronix (MXIC) and
169 ASIX. 163 ASIX.
170 164
171 To compile this driver as a module, choose M here and read 165 To compile this driver as a module, choose M here. The module will
172 <file:Documentation/networking/net-modules.txt>. The module will
173 be called xircom_tulip_cb. If unsure, say N. 166 be called xircom_tulip_cb. If unsure, say N.
174 167
175endif # NET_TULIP 168endif # NET_TULIP
diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index 5a96d74e4ce8..a12c9c41b217 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -93,13 +93,9 @@ config USB_RTL8150
93 To compile this driver as a module, choose M here: the 93 To compile this driver as a module, choose M here: the
94 module will be called rtl8150. 94 module will be called rtl8150.
95 95
96config USB_USBNET_MII
97 tristate
98 default n
99
100config USB_USBNET 96config USB_USBNET
101 tristate "Multi-purpose USB Networking Framework" 97 tristate "Multi-purpose USB Networking Framework"
102 select MII if USB_USBNET_MII != n 98 select MII
103 ---help--- 99 ---help---
104 This driver supports several kinds of network links over USB, 100 This driver supports several kinds of network links over USB,
105 with "minidrivers" built around a common network driver core 101 with "minidrivers" built around a common network driver core
@@ -135,7 +131,6 @@ config USB_NET_AX8817X
135 tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters" 131 tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters"
136 depends on USB_USBNET && NET_ETHERNET 132 depends on USB_USBNET && NET_ETHERNET
137 select CRC32 133 select CRC32
138 select USB_USBNET_MII
139 default y 134 default y
140 help 135 help
141 This option adds support for ASIX AX88xxx based USB 2.0 136 This option adds support for ASIX AX88xxx based USB 2.0
@@ -190,7 +185,6 @@ config USB_NET_DM9601
190 tristate "Davicom DM9601 based USB 1.1 10/100 ethernet devices" 185 tristate "Davicom DM9601 based USB 1.1 10/100 ethernet devices"
191 depends on USB_USBNET 186 depends on USB_USBNET
192 select CRC32 187 select CRC32
193 select USB_USBNET_MII
194 help 188 help
195 This option adds support for Davicom DM9601 based USB 1.1 189 This option adds support for Davicom DM9601 based USB 1.1
196 10/100 Ethernet adapters. 190 10/100 Ethernet adapters.
@@ -225,7 +219,6 @@ config USB_NET_PLUSB
225config USB_NET_MCS7830 219config USB_NET_MCS7830
226 tristate "MosChip MCS7830 based Ethernet adapters" 220 tristate "MosChip MCS7830 based Ethernet adapters"
227 depends on USB_USBNET 221 depends on USB_USBNET
228 select USB_USBNET_MII
229 help 222 help
230 Choose this option if you're using a 10/100 Ethernet USB2 223 Choose this option if you're using a 10/100 Ethernet USB2
231 adapter based on the MosChip 7830 controller. This includes 224 adapter based on the MosChip 7830 controller. This includes
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index acd5f1c0e63a..8ed1fc5cbc70 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -683,9 +683,6 @@ done_nopm:
683 * they'll probably want to use this base set. 683 * they'll probably want to use this base set.
684 */ 684 */
685 685
686#if defined(CONFIG_MII) || defined(CONFIG_MII_MODULE)
687#define HAVE_MII
688
689int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd) 686int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd)
690{ 687{
691 struct usbnet *dev = netdev_priv(net); 688 struct usbnet *dev = netdev_priv(net);
@@ -744,8 +741,6 @@ int usbnet_nway_reset(struct net_device *net)
744} 741}
745EXPORT_SYMBOL_GPL(usbnet_nway_reset); 742EXPORT_SYMBOL_GPL(usbnet_nway_reset);
746 743
747#endif /* HAVE_MII */
748
749void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info) 744void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info)
750{ 745{
751 struct usbnet *dev = netdev_priv(net); 746 struct usbnet *dev = netdev_priv(net);
@@ -776,12 +771,10 @@ EXPORT_SYMBOL_GPL(usbnet_set_msglevel);
776 771
777/* drivers may override default ethtool_ops in their bind() routine */ 772/* drivers may override default ethtool_ops in their bind() routine */
778static struct ethtool_ops usbnet_ethtool_ops = { 773static struct ethtool_ops usbnet_ethtool_ops = {
779#ifdef HAVE_MII
780 .get_settings = usbnet_get_settings, 774 .get_settings = usbnet_get_settings,
781 .set_settings = usbnet_set_settings, 775 .set_settings = usbnet_set_settings,
782 .get_link = usbnet_get_link, 776 .get_link = usbnet_get_link,
783 .nway_reset = usbnet_nway_reset, 777 .nway_reset = usbnet_nway_reset,
784#endif
785 .get_drvinfo = usbnet_get_drvinfo, 778 .get_drvinfo = usbnet_get_drvinfo,
786 .get_msglevel = usbnet_get_msglevel, 779 .get_msglevel = usbnet_get_msglevel,
787 .set_msglevel = usbnet_set_msglevel, 780 .set_msglevel = usbnet_set_msglevel,
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index e396c9d2af8d..a75be57fb209 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -146,6 +146,7 @@ static void try_fill_recv(struct virtnet_info *vi)
146 struct scatterlist sg[1+MAX_SKB_FRAGS]; 146 struct scatterlist sg[1+MAX_SKB_FRAGS];
147 int num, err; 147 int num, err;
148 148
149 sg_init_table(sg, 1+MAX_SKB_FRAGS);
149 for (;;) { 150 for (;;) {
150 skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN); 151 skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN);
151 if (unlikely(!skb)) 152 if (unlikely(!skb))
@@ -231,6 +232,8 @@ static int start_xmit(struct sk_buff *skb, struct net_device *dev)
231 const unsigned char *dest = ((struct ethhdr *)skb->data)->h_dest; 232 const unsigned char *dest = ((struct ethhdr *)skb->data)->h_dest;
232 DECLARE_MAC_BUF(mac); 233 DECLARE_MAC_BUF(mac);
233 234
235 sg_init_table(sg, 1+MAX_SKB_FRAGS);
236
234 pr_debug("%s: xmit %p %s\n", dev->name, skb, print_mac(mac, dest)); 237 pr_debug("%s: xmit %p %s\n", dev->name, skb, print_mac(mac, dest));
235 238
236 free_old_xmit_skbs(vi); 239 free_old_xmit_skbs(vi);
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index c48b1cc63fd5..1e89d4de1bb7 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -719,12 +719,8 @@ static int x25_asy_ioctl(struct tty_struct *tty, struct file *file,
719 return 0; 719 return 0;
720 case SIOCSIFHWADDR: 720 case SIOCSIFHWADDR:
721 return -EINVAL; 721 return -EINVAL;
722 /* Allow stty to read, but not set, the serial port */
723 case TCGETS:
724 case TCGETA:
725 return n_tty_ioctl(tty, file, cmd, arg);
726 default: 722 default:
727 return -ENOIOCTLCMD; 723 return tty_mode_ioctl(tty, file, cmd, arg);
728 } 724 }
729} 725}
730 726
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index dae5c8d5a318..2b733c582915 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -325,7 +325,7 @@ config HERMES
325 Cabletron/EnteraSys Roamabout, ELSA AirLancer, MELCO Buffalo, Avaya, 325 Cabletron/EnteraSys Roamabout, ELSA AirLancer, MELCO Buffalo, Avaya,
326 IBM High Rate Wireless, Farralon Syyline, Samsung MagicLAN, Netgear 326 IBM High Rate Wireless, Farralon Syyline, Samsung MagicLAN, Netgear
327 MA401, LinkSys WPC-11, D-Link DWL-650, 3Com AirConnect, Intel 327 MA401, LinkSys WPC-11, D-Link DWL-650, 3Com AirConnect, Intel
328 PRO/Wireless, and Symbol Spectrum24 High Rate amongst others. 328 IPW2011, and Symbol Spectrum24 High Rate amongst others.
329 329
330 This option includes the guts of the driver, but in order to 330 This option includes the guts of the driver, but in order to
331 actually use a card you will also need to enable support for PCMCIA 331 actually use a card you will also need to enable support for PCMCIA
diff --git a/drivers/net/wireless/b43/Kconfig b/drivers/net/wireless/b43/Kconfig
index e3c573e56b63..fdbc351ac333 100644
--- a/drivers/net/wireless/b43/Kconfig
+++ b/drivers/net/wireless/b43/Kconfig
@@ -61,16 +61,18 @@ config B43_PCMCIA
61 61
62 If unsure, say N. 62 If unsure, say N.
63 63
64# LED support 64# This config option automatically enables b43 LEDS support,
65# if it's possible.
65config B43_LEDS 66config B43_LEDS
66 bool 67 bool
67 depends on B43 && MAC80211_LEDS 68 depends on B43 && MAC80211_LEDS && (LEDS_CLASS = y || LEDS_CLASS = B43)
68 default y 69 default y
69 70
70# RFKILL support 71# This config option automatically enables b43 RFKILL support,
72# if it's possible.
71config B43_RFKILL 73config B43_RFKILL
72 bool 74 bool
73 depends on B43 && RFKILL && RFKILL_INPUT && INPUT_POLLDEV 75 depends on B43 && (RFKILL = y || RFKILL = B43) && RFKILL_INPUT && (INPUT_POLLDEV = y || INPUT_POLLDEV = B43)
74 default y 76 default y
75 77
76config B43_DEBUG 78config B43_DEBUG
diff --git a/drivers/net/wireless/b43/debugfs.c b/drivers/net/wireless/b43/debugfs.c
index 734e70e1a06d..ef0075d9f9cb 100644
--- a/drivers/net/wireless/b43/debugfs.c
+++ b/drivers/net/wireless/b43/debugfs.c
@@ -128,7 +128,7 @@ static ssize_t shm_read_file(struct b43_wldev *dev,
128 __le16 *le16buf = (__le16 *)buf; 128 __le16 *le16buf = (__le16 *)buf;
129 129
130 for (i = 0; i < 0x1000; i++) { 130 for (i = 0; i < 0x1000; i++) {
131 if (bufsize <= 0) 131 if (bufsize < sizeof(tmp))
132 break; 132 break;
133 tmp = b43_shm_read16(dev, B43_SHM_SHARED, 2 * i); 133 tmp = b43_shm_read16(dev, B43_SHM_SHARED, 2 * i);
134 le16buf[i] = cpu_to_le16(tmp); 134 le16buf[i] = cpu_to_le16(tmp);
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 5058e60e5703..2b17c1dc46f1 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -2985,6 +2985,16 @@ static void b43_wireless_core_stop(struct b43_wldev *dev)
2985 2985
2986 if (b43_status(dev) < B43_STAT_STARTED) 2986 if (b43_status(dev) < B43_STAT_STARTED)
2987 return; 2987 return;
2988
2989 /* Disable and sync interrupts. We must do this before than
2990 * setting the status to INITIALIZED, as the interrupt handler
2991 * won't care about IRQs then. */
2992 spin_lock_irqsave(&wl->irq_lock, flags);
2993 dev->irq_savedstate = b43_interrupt_disable(dev, B43_IRQ_ALL);
2994 b43_read32(dev, B43_MMIO_GEN_IRQ_MASK); /* flush */
2995 spin_unlock_irqrestore(&wl->irq_lock, flags);
2996 b43_synchronize_irq(dev);
2997
2988 b43_set_status(dev, B43_STAT_INITIALIZED); 2998 b43_set_status(dev, B43_STAT_INITIALIZED);
2989 2999
2990 mutex_unlock(&wl->mutex); 3000 mutex_unlock(&wl->mutex);
@@ -2995,13 +3005,6 @@ static void b43_wireless_core_stop(struct b43_wldev *dev)
2995 3005
2996 ieee80211_stop_queues(wl->hw); //FIXME this could cause a deadlock, as mac80211 seems buggy. 3006 ieee80211_stop_queues(wl->hw); //FIXME this could cause a deadlock, as mac80211 seems buggy.
2997 3007
2998 /* Disable and sync interrupts. */
2999 spin_lock_irqsave(&wl->irq_lock, flags);
3000 dev->irq_savedstate = b43_interrupt_disable(dev, B43_IRQ_ALL);
3001 b43_read32(dev, B43_MMIO_GEN_IRQ_MASK); /* flush */
3002 spin_unlock_irqrestore(&wl->irq_lock, flags);
3003 b43_synchronize_irq(dev);
3004
3005 b43_mac_suspend(dev); 3008 b43_mac_suspend(dev);
3006 free_irq(dev->dev->irq, dev); 3009 free_irq(dev->dev->irq, dev);
3007 b43dbg(wl, "Wireless interface stopped\n"); 3010 b43dbg(wl, "Wireless interface stopped\n");
@@ -3661,7 +3664,6 @@ static int b43_setup_modes(struct b43_wldev *dev,
3661 3664
3662static void b43_wireless_core_detach(struct b43_wldev *dev) 3665static void b43_wireless_core_detach(struct b43_wldev *dev)
3663{ 3666{
3664 b43_rfkill_free(dev);
3665 /* We release firmware that late to not be required to re-request 3667 /* We release firmware that late to not be required to re-request
3666 * is all the time when we reinit the core. */ 3668 * is all the time when we reinit the core. */
3667 b43_release_firmware(dev); 3669 b43_release_firmware(dev);
@@ -3747,7 +3749,6 @@ static int b43_wireless_core_attach(struct b43_wldev *dev)
3747 if (!wl->current_dev) 3749 if (!wl->current_dev)
3748 wl->current_dev = dev; 3750 wl->current_dev = dev;
3749 INIT_WORK(&dev->restart_work, b43_chip_reset); 3751 INIT_WORK(&dev->restart_work, b43_chip_reset);
3750 b43_rfkill_alloc(dev);
3751 3752
3752 b43_radio_turn_off(dev, 1); 3753 b43_radio_turn_off(dev, 1);
3753 b43_switch_analog(dev, 0); 3754 b43_switch_analog(dev, 0);
diff --git a/drivers/net/wireless/b43/pcmcia.c b/drivers/net/wireless/b43/pcmcia.c
index b242a9a90dd2..b79a6bd5396d 100644
--- a/drivers/net/wireless/b43/pcmcia.c
+++ b/drivers/net/wireless/b43/pcmcia.c
@@ -65,12 +65,12 @@ static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev)
65 tuple_t tuple; 65 tuple_t tuple;
66 cisparse_t parse; 66 cisparse_t parse;
67 int err = -ENOMEM; 67 int err = -ENOMEM;
68 int res; 68 int res = 0;
69 unsigned char buf[64]; 69 unsigned char buf[64];
70 70
71 ssb = kzalloc(sizeof(*ssb), GFP_KERNEL); 71 ssb = kzalloc(sizeof(*ssb), GFP_KERNEL);
72 if (!ssb) 72 if (!ssb)
73 goto out; 73 goto out_error;
74 74
75 err = -ENODEV; 75 err = -ENODEV;
76 tuple.DesiredTuple = CISTPL_CONFIG; 76 tuple.DesiredTuple = CISTPL_CONFIG;
@@ -96,10 +96,12 @@ static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev)
96 dev->io.NumPorts2 = 0; 96 dev->io.NumPorts2 = 0;
97 dev->io.Attributes2 = 0; 97 dev->io.Attributes2 = 0;
98 98
99 win.Attributes = WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT; 99 win.Attributes = WIN_ADDR_SPACE_MEM | WIN_MEMORY_TYPE_CM |
100 WIN_ENABLE | WIN_DATA_WIDTH_16 |
101 WIN_USE_WAIT;
100 win.Base = 0; 102 win.Base = 0;
101 win.Size = SSB_CORE_SIZE; 103 win.Size = SSB_CORE_SIZE;
102 win.AccessSpeed = 1000; 104 win.AccessSpeed = 250;
103 res = pcmcia_request_window(&dev, &win, &dev->win); 105 res = pcmcia_request_window(&dev, &win, &dev->win);
104 if (res != CS_SUCCESS) 106 if (res != CS_SUCCESS)
105 goto err_kfree_ssb; 107 goto err_kfree_ssb;
@@ -108,21 +110,34 @@ static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev)
108 mem.Page = 0; 110 mem.Page = 0;
109 res = pcmcia_map_mem_page(dev->win, &mem); 111 res = pcmcia_map_mem_page(dev->win, &mem);
110 if (res != CS_SUCCESS) 112 if (res != CS_SUCCESS)
111 goto err_kfree_ssb; 113 goto err_disable;
114
115 dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_FIRST_SHARED;
116 dev->irq.IRQInfo1 = IRQ_LEVEL_ID | IRQ_SHARE_ID;
117 dev->irq.Handler = NULL; /* The handler is registered later. */
118 dev->irq.Instance = NULL;
119 res = pcmcia_request_irq(dev, &dev->irq);
120 if (res != CS_SUCCESS)
121 goto err_disable;
112 122
113 res = pcmcia_request_configuration(dev, &dev->conf); 123 res = pcmcia_request_configuration(dev, &dev->conf);
114 if (res != CS_SUCCESS) 124 if (res != CS_SUCCESS)
115 goto err_disable; 125 goto err_disable;
116 126
117 err = ssb_bus_pcmciabus_register(ssb, dev, win.Base); 127 err = ssb_bus_pcmciabus_register(ssb, dev, win.Base);
128 if (err)
129 goto err_disable;
118 dev->priv = ssb; 130 dev->priv = ssb;
119 131
120 out: 132 return 0;
121 return err; 133
122 err_disable: 134err_disable:
123 pcmcia_disable_device(dev); 135 pcmcia_disable_device(dev);
124 err_kfree_ssb: 136err_kfree_ssb:
125 kfree(ssb); 137 kfree(ssb);
138out_error:
139 printk(KERN_ERR "b43-pcmcia: Initialization failed (%d, %d)\n",
140 res, err);
126 return err; 141 return err;
127} 142}
128 143
@@ -131,22 +146,21 @@ static void __devexit b43_pcmcia_remove(struct pcmcia_device *dev)
131 struct ssb_bus *ssb = dev->priv; 146 struct ssb_bus *ssb = dev->priv;
132 147
133 ssb_bus_unregister(ssb); 148 ssb_bus_unregister(ssb);
134 pcmcia_release_window(dev->win);
135 pcmcia_disable_device(dev); 149 pcmcia_disable_device(dev);
136 kfree(ssb); 150 kfree(ssb);
137 dev->priv = NULL; 151 dev->priv = NULL;
138} 152}
139 153
140static struct pcmcia_driver b43_pcmcia_driver = { 154static struct pcmcia_driver b43_pcmcia_driver = {
141 .owner = THIS_MODULE, 155 .owner = THIS_MODULE,
142 .drv = { 156 .drv = {
143 .name = "b43-pcmcia", 157 .name = "b43-pcmcia",
144 }, 158 },
145 .id_table = b43_pcmcia_tbl, 159 .id_table = b43_pcmcia_tbl,
146 .probe = b43_pcmcia_probe, 160 .probe = b43_pcmcia_probe,
147 .remove = b43_pcmcia_remove, 161 .remove = __devexit_p(b43_pcmcia_remove),
148 .suspend = b43_pcmcia_suspend, 162 .suspend = b43_pcmcia_suspend,
149 .resume = b43_pcmcia_resume, 163 .resume = b43_pcmcia_resume,
150}; 164};
151 165
152int b43_pcmcia_init(void) 166int b43_pcmcia_init(void)
diff --git a/drivers/net/wireless/b43/rfkill.c b/drivers/net/wireless/b43/rfkill.c
index 800e0a61a7f5..9b1f905ffbf4 100644
--- a/drivers/net/wireless/b43/rfkill.c
+++ b/drivers/net/wireless/b43/rfkill.c
@@ -47,32 +47,35 @@ static void b43_rfkill_poll(struct input_polled_dev *poll_dev)
47 struct b43_wldev *dev = poll_dev->private; 47 struct b43_wldev *dev = poll_dev->private;
48 struct b43_wl *wl = dev->wl; 48 struct b43_wl *wl = dev->wl;
49 bool enabled; 49 bool enabled;
50 bool report_change = 0;
50 51
51 mutex_lock(&wl->mutex); 52 mutex_lock(&wl->mutex);
52 B43_WARN_ON(b43_status(dev) < B43_STAT_INITIALIZED); 53 B43_WARN_ON(b43_status(dev) < B43_STAT_INITIALIZED);
53 enabled = b43_is_hw_radio_enabled(dev); 54 enabled = b43_is_hw_radio_enabled(dev);
54 if (unlikely(enabled != dev->radio_hw_enable)) { 55 if (unlikely(enabled != dev->radio_hw_enable)) {
55 dev->radio_hw_enable = enabled; 56 dev->radio_hw_enable = enabled;
57 report_change = 1;
56 b43info(wl, "Radio hardware status changed to %s\n", 58 b43info(wl, "Radio hardware status changed to %s\n",
57 enabled ? "ENABLED" : "DISABLED"); 59 enabled ? "ENABLED" : "DISABLED");
58 mutex_unlock(&wl->mutex); 60 }
61 mutex_unlock(&wl->mutex);
62
63 if (unlikely(report_change))
59 input_report_key(poll_dev->input, KEY_WLAN, enabled); 64 input_report_key(poll_dev->input, KEY_WLAN, enabled);
60 } else
61 mutex_unlock(&wl->mutex);
62} 65}
63 66
64/* Called when the RFKILL toggled in software. 67/* Called when the RFKILL toggled in software. */
65 * This is called without locking. */
66static int b43_rfkill_soft_toggle(void *data, enum rfkill_state state) 68static int b43_rfkill_soft_toggle(void *data, enum rfkill_state state)
67{ 69{
68 struct b43_wldev *dev = data; 70 struct b43_wldev *dev = data;
69 struct b43_wl *wl = dev->wl; 71 struct b43_wl *wl = dev->wl;
70 int err = 0; 72 int err = 0;
71 73
72 mutex_lock(&wl->mutex); 74 if (!wl->rfkill.registered)
73 if (b43_status(dev) < B43_STAT_INITIALIZED) 75 return 0;
74 goto out_unlock;
75 76
77 mutex_lock(&wl->mutex);
78 B43_WARN_ON(b43_status(dev) < B43_STAT_INITIALIZED);
76 switch (state) { 79 switch (state) {
77 case RFKILL_STATE_ON: 80 case RFKILL_STATE_ON:
78 if (!dev->radio_hw_enable) { 81 if (!dev->radio_hw_enable) {
@@ -89,7 +92,6 @@ static int b43_rfkill_soft_toggle(void *data, enum rfkill_state state)
89 b43_radio_turn_off(dev, 0); 92 b43_radio_turn_off(dev, 0);
90 break; 93 break;
91 } 94 }
92
93out_unlock: 95out_unlock:
94 mutex_unlock(&wl->mutex); 96 mutex_unlock(&wl->mutex);
95 97
@@ -98,11 +100,11 @@ out_unlock:
98 100
99char * b43_rfkill_led_name(struct b43_wldev *dev) 101char * b43_rfkill_led_name(struct b43_wldev *dev)
100{ 102{
101 struct b43_wl *wl = dev->wl; 103 struct b43_rfkill *rfk = &(dev->wl->rfkill);
102 104
103 if (!wl->rfkill.rfkill) 105 if (!rfk->registered)
104 return NULL; 106 return NULL;
105 return rfkill_get_led_name(wl->rfkill.rfkill); 107 return rfkill_get_led_name(rfk->rfkill);
106} 108}
107 109
108void b43_rfkill_init(struct b43_wldev *dev) 110void b43_rfkill_init(struct b43_wldev *dev)
@@ -111,53 +113,13 @@ void b43_rfkill_init(struct b43_wldev *dev)
111 struct b43_rfkill *rfk = &(wl->rfkill); 113 struct b43_rfkill *rfk = &(wl->rfkill);
112 int err; 114 int err;
113 115
114 if (rfk->rfkill) { 116 rfk->registered = 0;
115 err = rfkill_register(rfk->rfkill);
116 if (err) {
117 b43warn(wl, "Failed to register RF-kill button\n");
118 goto err_free_rfk;
119 }
120 }
121 if (rfk->poll_dev) {
122 err = input_register_polled_device(rfk->poll_dev);
123 if (err) {
124 b43warn(wl, "Failed to register RF-kill polldev\n");
125 goto err_free_polldev;
126 }
127 }
128
129 return;
130err_free_rfk:
131 rfkill_free(rfk->rfkill);
132 rfk->rfkill = NULL;
133err_free_polldev:
134 input_free_polled_device(rfk->poll_dev);
135 rfk->poll_dev = NULL;
136}
137
138void b43_rfkill_exit(struct b43_wldev *dev)
139{
140 struct b43_rfkill *rfk = &(dev->wl->rfkill);
141
142 if (rfk->poll_dev)
143 input_unregister_polled_device(rfk->poll_dev);
144 if (rfk->rfkill)
145 rfkill_unregister(rfk->rfkill);
146}
147
148void b43_rfkill_alloc(struct b43_wldev *dev)
149{
150 struct b43_wl *wl = dev->wl;
151 struct b43_rfkill *rfk = &(wl->rfkill);
152 117
118 rfk->rfkill = rfkill_allocate(dev->dev->dev, RFKILL_TYPE_WLAN);
119 if (!rfk->rfkill)
120 goto out_error;
153 snprintf(rfk->name, sizeof(rfk->name), 121 snprintf(rfk->name, sizeof(rfk->name),
154 "b43-%s", wiphy_name(wl->hw->wiphy)); 122 "b43-%s", wiphy_name(wl->hw->wiphy));
155
156 rfk->rfkill = rfkill_allocate(dev->dev->dev, RFKILL_TYPE_WLAN);
157 if (!rfk->rfkill) {
158 b43warn(wl, "Failed to allocate RF-kill button\n");
159 return;
160 }
161 rfk->rfkill->name = rfk->name; 123 rfk->rfkill->name = rfk->name;
162 rfk->rfkill->state = RFKILL_STATE_ON; 124 rfk->rfkill->state = RFKILL_STATE_ON;
163 rfk->rfkill->data = dev; 125 rfk->rfkill->data = dev;
@@ -165,18 +127,45 @@ void b43_rfkill_alloc(struct b43_wldev *dev)
165 rfk->rfkill->user_claim_unsupported = 1; 127 rfk->rfkill->user_claim_unsupported = 1;
166 128
167 rfk->poll_dev = input_allocate_polled_device(); 129 rfk->poll_dev = input_allocate_polled_device();
168 if (rfk->poll_dev) { 130 if (!rfk->poll_dev)
169 rfk->poll_dev->private = dev; 131 goto err_free_rfk;
170 rfk->poll_dev->poll = b43_rfkill_poll; 132 rfk->poll_dev->private = dev;
171 rfk->poll_dev->poll_interval = 1000; /* msecs */ 133 rfk->poll_dev->poll = b43_rfkill_poll;
172 } else 134 rfk->poll_dev->poll_interval = 1000; /* msecs */
173 b43warn(wl, "Failed to allocate RF-kill polldev\n"); 135
136 err = rfkill_register(rfk->rfkill);
137 if (err)
138 goto err_free_polldev;
139 err = input_register_polled_device(rfk->poll_dev);
140 if (err)
141 goto err_unreg_rfk;
142
143 rfk->registered = 1;
144
145 return;
146err_unreg_rfk:
147 rfkill_unregister(rfk->rfkill);
148err_free_polldev:
149 input_free_polled_device(rfk->poll_dev);
150 rfk->poll_dev = NULL;
151err_free_rfk:
152 rfkill_free(rfk->rfkill);
153 rfk->rfkill = NULL;
154out_error:
155 rfk->registered = 0;
156 b43warn(wl, "RF-kill button init failed\n");
174} 157}
175 158
176void b43_rfkill_free(struct b43_wldev *dev) 159void b43_rfkill_exit(struct b43_wldev *dev)
177{ 160{
178 struct b43_rfkill *rfk = &(dev->wl->rfkill); 161 struct b43_rfkill *rfk = &(dev->wl->rfkill);
179 162
163 if (!rfk->registered)
164 return;
165 rfk->registered = 0;
166
167 input_unregister_polled_device(rfk->poll_dev);
168 rfkill_unregister(rfk->rfkill);
180 input_free_polled_device(rfk->poll_dev); 169 input_free_polled_device(rfk->poll_dev);
181 rfk->poll_dev = NULL; 170 rfk->poll_dev = NULL;
182 rfkill_free(rfk->rfkill); 171 rfkill_free(rfk->rfkill);
diff --git a/drivers/net/wireless/b43/rfkill.h b/drivers/net/wireless/b43/rfkill.h
index 29544e8c9e5f..adacf936d815 100644
--- a/drivers/net/wireless/b43/rfkill.h
+++ b/drivers/net/wireless/b43/rfkill.h
@@ -15,14 +15,14 @@ struct b43_rfkill {
15 struct rfkill *rfkill; 15 struct rfkill *rfkill;
16 /* The poll device for the RFKILL input button */ 16 /* The poll device for the RFKILL input button */
17 struct input_polled_dev *poll_dev; 17 struct input_polled_dev *poll_dev;
18 /* Did initialization succeed? Used for freeing. */
19 bool registered;
18 /* The unique name of this rfkill switch */ 20 /* The unique name of this rfkill switch */
19 char name[32]; 21 char name[sizeof("b43-phy4294967295")];
20}; 22};
21 23
22/* All the init functions return void, because we are not interested 24/* The init function returns void, because we are not interested
23 * in failing the b43 init process when rfkill init failed. */ 25 * in failing the b43 init process when rfkill init failed. */
24void b43_rfkill_alloc(struct b43_wldev *dev);
25void b43_rfkill_free(struct b43_wldev *dev);
26void b43_rfkill_init(struct b43_wldev *dev); 26void b43_rfkill_init(struct b43_wldev *dev);
27void b43_rfkill_exit(struct b43_wldev *dev); 27void b43_rfkill_exit(struct b43_wldev *dev);
28 28
@@ -36,12 +36,6 @@ struct b43_rfkill {
36 /* empty */ 36 /* empty */
37}; 37};
38 38
39static inline void b43_rfkill_alloc(struct b43_wldev *dev)
40{
41}
42static inline void b43_rfkill_free(struct b43_wldev *dev)
43{
44}
45static inline void b43_rfkill_init(struct b43_wldev *dev) 39static inline void b43_rfkill_init(struct b43_wldev *dev)
46{ 40{
47} 41}
diff --git a/drivers/net/wireless/b43legacy/debugfs.c b/drivers/net/wireless/b43legacy/debugfs.c
index eefa6fb79685..619b4534ef09 100644
--- a/drivers/net/wireless/b43legacy/debugfs.c
+++ b/drivers/net/wireless/b43legacy/debugfs.c
@@ -124,7 +124,7 @@ static ssize_t shm_read_file(struct b43legacy_wldev *dev, char *buf, size_t bufs
124 __le16 *le16buf = (__le16 *)buf; 124 __le16 *le16buf = (__le16 *)buf;
125 125
126 for (i = 0; i < 0x1000; i++) { 126 for (i = 0; i < 0x1000; i++) {
127 if (bufsize <= 0) 127 if (bufsize < sizeof(tmp))
128 break; 128 break;
129 tmp = b43legacy_shm_read16(dev, B43legacy_SHM_SHARED, 2 * i); 129 tmp = b43legacy_shm_read16(dev, B43legacy_SHM_SHARED, 2 * i);
130 le16buf[i] = cpu_to_le16(tmp); 130 le16buf[i] = cpu_to_le16(tmp);
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
index f0e56dfc9ecf..3bde1e9ab428 100644
--- a/drivers/net/wireless/b43legacy/main.c
+++ b/drivers/net/wireless/b43legacy/main.c
@@ -2781,6 +2781,17 @@ static void b43legacy_wireless_core_stop(struct b43legacy_wldev *dev)
2781 2781
2782 if (b43legacy_status(dev) < B43legacy_STAT_STARTED) 2782 if (b43legacy_status(dev) < B43legacy_STAT_STARTED)
2783 return; 2783 return;
2784
2785 /* Disable and sync interrupts. We must do this before than
2786 * setting the status to INITIALIZED, as the interrupt handler
2787 * won't care about IRQs then. */
2788 spin_lock_irqsave(&wl->irq_lock, flags);
2789 dev->irq_savedstate = b43legacy_interrupt_disable(dev,
2790 B43legacy_IRQ_ALL);
2791 b43legacy_read32(dev, B43legacy_MMIO_GEN_IRQ_MASK); /* flush */
2792 spin_unlock_irqrestore(&wl->irq_lock, flags);
2793 b43legacy_synchronize_irq(dev);
2794
2784 b43legacy_set_status(dev, B43legacy_STAT_INITIALIZED); 2795 b43legacy_set_status(dev, B43legacy_STAT_INITIALIZED);
2785 2796
2786 mutex_unlock(&wl->mutex); 2797 mutex_unlock(&wl->mutex);
@@ -2791,14 +2802,6 @@ static void b43legacy_wireless_core_stop(struct b43legacy_wldev *dev)
2791 2802
2792 ieee80211_stop_queues(wl->hw); /* FIXME this could cause a deadlock */ 2803 ieee80211_stop_queues(wl->hw); /* FIXME this could cause a deadlock */
2793 2804
2794 /* Disable and sync interrupts. */
2795 spin_lock_irqsave(&wl->irq_lock, flags);
2796 dev->irq_savedstate = b43legacy_interrupt_disable(dev,
2797 B43legacy_IRQ_ALL);
2798 b43legacy_read32(dev, B43legacy_MMIO_GEN_IRQ_MASK); /* flush */
2799 spin_unlock_irqrestore(&wl->irq_lock, flags);
2800 b43legacy_synchronize_irq(dev);
2801
2802 b43legacy_mac_suspend(dev); 2805 b43legacy_mac_suspend(dev);
2803 free_irq(dev->dev->irq, dev); 2806 free_irq(dev->dev->irq, dev);
2804 b43legacydbg(wl, "Wireless interface stopped\n"); 2807 b43legacydbg(wl, "Wireless interface stopped\n");
@@ -3332,7 +3335,7 @@ out_mutex_unlock:
3332 return err; 3335 return err;
3333} 3336}
3334 3337
3335void b43legacy_stop(struct ieee80211_hw *hw) 3338static void b43legacy_stop(struct ieee80211_hw *hw)
3336{ 3339{
3337 struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw); 3340 struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
3338 struct b43legacy_wldev *dev = wl->current_dev; 3341 struct b43legacy_wldev *dev = wl->current_dev;
diff --git a/drivers/net/wireless/hostap/hostap_pci.c b/drivers/net/wireless/hostap/hostap_pci.c
index 7da3664b8515..fc876ba18572 100644
--- a/drivers/net/wireless/hostap/hostap_pci.c
+++ b/drivers/net/wireless/hostap/hostap_pci.c
@@ -444,7 +444,7 @@ static int prism2_pci_resume(struct pci_dev *pdev)
444 444
445MODULE_DEVICE_TABLE(pci, prism2_pci_id_table); 445MODULE_DEVICE_TABLE(pci, prism2_pci_id_table);
446 446
447static struct pci_driver prism2_pci_drv_id = { 447static struct pci_driver prism2_pci_driver = {
448 .name = "hostap_pci", 448 .name = "hostap_pci",
449 .id_table = prism2_pci_id_table, 449 .id_table = prism2_pci_id_table,
450 .probe = prism2_pci_probe, 450 .probe = prism2_pci_probe,
@@ -458,13 +458,13 @@ static struct pci_driver prism2_pci_drv_id = {
458 458
459static int __init init_prism2_pci(void) 459static int __init init_prism2_pci(void)
460{ 460{
461 return pci_register_driver(&prism2_pci_drv_id); 461 return pci_register_driver(&prism2_pci_driver);
462} 462}
463 463
464 464
465static void __exit exit_prism2_pci(void) 465static void __exit exit_prism2_pci(void)
466{ 466{
467 pci_unregister_driver(&prism2_pci_drv_id); 467 pci_unregister_driver(&prism2_pci_driver);
468} 468}
469 469
470 470
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index 8d53d08b9691..fc6cdd8086c1 100644
--- a/drivers/net/wireless/ipw2100.c
+++ b/drivers/net/wireless/ipw2100.c
@@ -1267,7 +1267,7 @@ static int ipw2100_start_adapter(struct ipw2100_priv *priv)
1267 IPW2100_INTA_FATAL_ERROR | 1267 IPW2100_INTA_FATAL_ERROR |
1268 IPW2100_INTA_PARITY_ERROR); 1268 IPW2100_INTA_PARITY_ERROR);
1269 } 1269 }
1270 } while (i--); 1270 } while (--i);
1271 1271
1272 /* Clear out any pending INTAs since we aren't supposed to have 1272 /* Clear out any pending INTAs since we aren't supposed to have
1273 * interrupts enabled at this point... */ 1273 * interrupts enabled at this point... */
@@ -1339,7 +1339,7 @@ static int ipw2100_power_cycle_adapter(struct ipw2100_priv *priv)
1339 1339
1340 if (reg & IPW_AUX_HOST_RESET_REG_MASTER_DISABLED) 1340 if (reg & IPW_AUX_HOST_RESET_REG_MASTER_DISABLED)
1341 break; 1341 break;
1342 } while (i--); 1342 } while (--i);
1343 1343
1344 priv->status &= ~STATUS_RESET_PENDING; 1344 priv->status &= ~STATUS_RESET_PENDING;
1345 1345
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index e4ddbc9ac243..465da4f67ce7 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -4850,7 +4850,7 @@ static irqreturn_t iwl_isr(int irq, void *data)
4850 if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) { 4850 if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) {
4851 /* Hardware disappeared */ 4851 /* Hardware disappeared */
4852 IWL_WARNING("HARDWARE GONE?? INTA == 0x%080x\n", inta); 4852 IWL_WARNING("HARDWARE GONE?? INTA == 0x%080x\n", inta);
4853 goto none; 4853 goto unplugged;
4854 } 4854 }
4855 4855
4856 IWL_DEBUG_ISR("ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", 4856 IWL_DEBUG_ISR("ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n",
@@ -4858,6 +4858,7 @@ static irqreturn_t iwl_isr(int irq, void *data)
4858 4858
4859 /* iwl_irq_tasklet() will service interrupts and re-enable them */ 4859 /* iwl_irq_tasklet() will service interrupts and re-enable them */
4860 tasklet_schedule(&priv->irq_tasklet); 4860 tasklet_schedule(&priv->irq_tasklet);
4861unplugged:
4861 spin_unlock(&priv->lock); 4862 spin_unlock(&priv->lock);
4862 4863
4863 return IRQ_HANDLED; 4864 return IRQ_HANDLED;
@@ -8354,6 +8355,8 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8354 } 8355 }
8355 SET_IEEE80211_DEV(hw, &pdev->dev); 8356 SET_IEEE80211_DEV(hw, &pdev->dev);
8356 8357
8358 hw->rate_control_algorithm = "iwl-3945-rs";
8359
8357 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n"); 8360 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n");
8358 priv = hw->priv; 8361 priv = hw->priv;
8359 priv->hw = hw; 8362 priv->hw = hw;
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index d5107bb413cd..9918780f5e86 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -8957,6 +8957,8 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8957 } 8957 }
8958 SET_IEEE80211_DEV(hw, &pdev->dev); 8958 SET_IEEE80211_DEV(hw, &pdev->dev);
8959 8959
8960 hw->rate_control_algorithm = "iwl-4965-rs";
8961
8960 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n"); 8962 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n");
8961 priv = hw->priv; 8963 priv = hw->priv;
8962 priv->hw = hw; 8964 priv->hw = hw;
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index 1cbbd96fdbde..be5cfd8402c7 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -912,6 +912,10 @@ static int wlan_cmd_set_boot2_ver(wlan_private * priv,
912 return 0; 912 return 0;
913} 913}
914 914
915/*
916 * Note: NEVER use libertas_queue_cmd() with addtail==0 other than for
917 * the command timer, because it does not account for queued commands.
918 */
915void libertas_queue_cmd(wlan_adapter * adapter, struct cmd_ctrl_node *cmdnode, u8 addtail) 919void libertas_queue_cmd(wlan_adapter * adapter, struct cmd_ctrl_node *cmdnode, u8 addtail)
916{ 920{
917 unsigned long flags; 921 unsigned long flags;
@@ -941,10 +945,11 @@ void libertas_queue_cmd(wlan_adapter * adapter, struct cmd_ctrl_node *cmdnode, u
941 945
942 spin_lock_irqsave(&adapter->driver_lock, flags); 946 spin_lock_irqsave(&adapter->driver_lock, flags);
943 947
944 if (addtail) 948 if (addtail) {
945 list_add_tail((struct list_head *)cmdnode, 949 list_add_tail((struct list_head *)cmdnode,
946 &adapter->cmdpendingq); 950 &adapter->cmdpendingq);
947 else 951 adapter->nr_cmd_pending++;
952 } else
948 list_add((struct list_head *)cmdnode, &adapter->cmdpendingq); 953 list_add((struct list_head *)cmdnode, &adapter->cmdpendingq);
949 954
950 spin_unlock_irqrestore(&adapter->driver_lock, flags); 955 spin_unlock_irqrestore(&adapter->driver_lock, flags);
@@ -1412,7 +1417,6 @@ int libertas_prepare_and_send_command(wlan_private * priv,
1412 cmdnode->cmdwaitqwoken = 0; 1417 cmdnode->cmdwaitqwoken = 0;
1413 1418
1414 libertas_queue_cmd(adapter, cmdnode, 1); 1419 libertas_queue_cmd(adapter, cmdnode, 1);
1415 adapter->nr_cmd_pending++;
1416 wake_up_interruptible(&priv->waitq); 1420 wake_up_interruptible(&priv->waitq);
1417 1421
1418 if (wait_option & CMD_OPTION_WAITFORRSP) { 1422 if (wait_option & CMD_OPTION_WAITFORRSP) {
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c
index 0360cad363a8..ec89dabc412c 100644
--- a/drivers/net/wireless/libertas/if_cs.c
+++ b/drivers/net/wireless/libertas/if_cs.c
@@ -148,11 +148,11 @@ static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 r
148{ 148{
149 int i; 149 int i;
150 150
151 for (i = 0; i < 500; i++) { 151 for (i = 0; i < 1000; i++) {
152 u8 val = if_cs_read8(card, addr); 152 u8 val = if_cs_read8(card, addr);
153 if (val == reg) 153 if (val == reg)
154 return i; 154 return i;
155 udelay(100); 155 udelay(500);
156 } 156 }
157 return -ETIME; 157 return -ETIME;
158} 158}
@@ -878,6 +878,9 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
878 goto out3; 878 goto out3;
879 } 879 }
880 880
881 /* Clear any interrupt cause that happend while sending
882 * firmware/initializing card */
883 if_cs_write16(card, IF_CS_C_INT_CAUSE, IF_CS_C_IC_MASK);
881 if_cs_enable_ints(card); 884 if_cs_enable_ints(card);
882 885
883 /* And finally bring the card up */ 886 /* And finally bring the card up */
diff --git a/drivers/net/wireless/libertas/if_sdio.c b/drivers/net/wireless/libertas/if_sdio.c
index a8e17076e7de..b24425f74883 100644
--- a/drivers/net/wireless/libertas/if_sdio.c
+++ b/drivers/net/wireless/libertas/if_sdio.c
@@ -182,12 +182,14 @@ static int if_sdio_handle_data(struct if_sdio_card *card,
182 goto out; 182 goto out;
183 } 183 }
184 184
185 skb = dev_alloc_skb(MRVDRV_ETH_RX_PACKET_BUFFER_SIZE); 185 skb = dev_alloc_skb(MRVDRV_ETH_RX_PACKET_BUFFER_SIZE + NET_IP_ALIGN);
186 if (!skb) { 186 if (!skb) {
187 ret = -ENOMEM; 187 ret = -ENOMEM;
188 goto out; 188 goto out;
189 } 189 }
190 190
191 skb_reserve(skb, NET_IP_ALIGN);
192
191 data = skb_put(skb, size); 193 data = skb_put(skb, size);
192 194
193 memcpy(data, buffer, size); 195 memcpy(data, buffer, size);
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index 4a6a0bd01ff1..85ea8a8e658e 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -196,6 +196,14 @@ int rt2x00mac_add_interface(struct ieee80211_hw *hw,
196 struct rt2x00_dev *rt2x00dev = hw->priv; 196 struct rt2x00_dev *rt2x00dev = hw->priv;
197 struct interface *intf = &rt2x00dev->interface; 197 struct interface *intf = &rt2x00dev->interface;
198 198
199 /* FIXME: Beaconing is broken in rt2x00. */
200 if (conf->type == IEEE80211_IF_TYPE_IBSS ||
201 conf->type == IEEE80211_IF_TYPE_AP) {
202 ERROR(rt2x00dev,
203 "rt2x00 does not support Adhoc or Master mode");
204 return -EOPNOTSUPP;
205 }
206
199 /* 207 /*
200 * Don't allow interfaces to be added while 208 * Don't allow interfaces to be added while
201 * either the device has disappeared or when 209 * either the device has disappeared or when
diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c
index 4bd14b331862..88efe1bae58f 100644
--- a/drivers/net/wireless/strip.c
+++ b/drivers/net/wireless/strip.c
@@ -2735,16 +2735,8 @@ static int strip_ioctl(struct tty_struct *tty, struct file *file,
2735 return -EFAULT; 2735 return -EFAULT;
2736 return set_mac_address(strip_info, &addr); 2736 return set_mac_address(strip_info, &addr);
2737 } 2737 }
2738 /*
2739 * Allow stty to read, but not set, the serial port
2740 */
2741
2742 case TCGETS:
2743 case TCGETA:
2744 return n_tty_ioctl(tty, file, cmd, arg);
2745 break;
2746 default: 2738 default:
2747 return -ENOIOCTLCMD; 2739 return tty_mode_ioctl(tty, file, cmd, arg);
2748 break; 2740 break;
2749 } 2741 }
2750 return 0; 2742 return 0;
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
index a83c3db7d18f..c93d3d2640ab 100644
--- a/drivers/oprofile/cpu_buffer.c
+++ b/drivers/oprofile/cpu_buffer.c
@@ -64,6 +64,8 @@ int alloc_cpu_buffers(void)
64 b->head_pos = 0; 64 b->head_pos = 0;
65 b->sample_received = 0; 65 b->sample_received = 0;
66 b->sample_lost_overflow = 0; 66 b->sample_lost_overflow = 0;
67 b->backtrace_aborted = 0;
68 b->sample_invalid_eip = 0;
67 b->cpu = i; 69 b->cpu = i;
68 INIT_DELAYED_WORK(&b->work, wq_sync_buffer); 70 INIT_DELAYED_WORK(&b->work, wq_sync_buffer);
69 } 71 }
@@ -175,6 +177,11 @@ static int log_sample(struct oprofile_cpu_buffer * cpu_buf, unsigned long pc,
175 177
176 cpu_buf->sample_received++; 178 cpu_buf->sample_received++;
177 179
180 if (pc == ESCAPE_CODE) {
181 cpu_buf->sample_invalid_eip++;
182 return 0;
183 }
184
178 if (nr_available_slots(cpu_buf) < 3) { 185 if (nr_available_slots(cpu_buf) < 3) {
179 cpu_buf->sample_lost_overflow++; 186 cpu_buf->sample_lost_overflow++;
180 return 0; 187 return 0;
diff --git a/drivers/oprofile/cpu_buffer.h b/drivers/oprofile/cpu_buffer.h
index 49900d9e3235..c66c025abe75 100644
--- a/drivers/oprofile/cpu_buffer.h
+++ b/drivers/oprofile/cpu_buffer.h
@@ -42,6 +42,7 @@ struct oprofile_cpu_buffer {
42 unsigned long sample_received; 42 unsigned long sample_received;
43 unsigned long sample_lost_overflow; 43 unsigned long sample_lost_overflow;
44 unsigned long backtrace_aborted; 44 unsigned long backtrace_aborted;
45 unsigned long sample_invalid_eip;
45 int cpu; 46 int cpu;
46 struct delayed_work work; 47 struct delayed_work work;
47} ____cacheline_aligned; 48} ____cacheline_aligned;
diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
index f0acb661c253..d1f6d776e9e4 100644
--- a/drivers/oprofile/oprofile_stats.c
+++ b/drivers/oprofile/oprofile_stats.c
@@ -26,6 +26,8 @@ void oprofile_reset_stats(void)
26 cpu_buf = &cpu_buffer[i]; 26 cpu_buf = &cpu_buffer[i];
27 cpu_buf->sample_received = 0; 27 cpu_buf->sample_received = 0;
28 cpu_buf->sample_lost_overflow = 0; 28 cpu_buf->sample_lost_overflow = 0;
29 cpu_buf->backtrace_aborted = 0;
30 cpu_buf->sample_invalid_eip = 0;
29 } 31 }
30 32
31 atomic_set(&oprofile_stats.sample_lost_no_mm, 0); 33 atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
@@ -61,6 +63,8 @@ void oprofile_create_stats_files(struct super_block * sb, struct dentry * root)
61 &cpu_buf->sample_lost_overflow); 63 &cpu_buf->sample_lost_overflow);
62 oprofilefs_create_ro_ulong(sb, cpudir, "backtrace_aborted", 64 oprofilefs_create_ro_ulong(sb, cpudir, "backtrace_aborted",
63 &cpu_buf->backtrace_aborted); 65 &cpu_buf->backtrace_aborted);
66 oprofilefs_create_ro_ulong(sb, cpudir, "sample_invalid_eip",
67 &cpu_buf->sample_invalid_eip);
64 } 68 }
65 69
66 oprofilefs_create_ro_atomic(sb, dir, "sample_lost_no_mm", 70 oprofilefs_create_ro_atomic(sb, dir, "sample_lost_no_mm",
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index cbde770eb121..e5cdc0294aaa 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -36,7 +36,9 @@ config RTC_HCTOSYS_DEVICE
36 help 36 help
37 The RTC device that will be used to (re)initialize the system 37 The RTC device that will be used to (re)initialize the system
38 clock, usually rtc0. Initialization is done when the system 38 clock, usually rtc0. Initialization is done when the system
39 starts up, and when it resumes from a low power state. 39 starts up, and when it resumes from a low power state. This
40 device should record time in UTC, since the kernel won't do
41 timezone correction.
40 42
41 The driver for this RTC device must be loaded before late_initcall 43 The driver for this RTC device must be loaded before late_initcall
42 functions run, so it must usually be statically linked. 44 functions run, so it must usually be statically linked.
@@ -133,8 +135,8 @@ config RTC_DRV_DS1307
133 135
134 The first seven registers on these chips hold an RTC, and other 136 The first seven registers on these chips hold an RTC, and other
135 registers may add features such as NVRAM, a trickle charger for 137 registers may add features such as NVRAM, a trickle charger for
136 the RTC/NVRAM backup power, and alarms. This driver may not 138 the RTC/NVRAM backup power, and alarms. NVRAM is visible in
137 expose all those available chip features. 139 sysfs, but other chip features may not be available.
138 140
139 This driver can also be built as a module. If so, the module 141 This driver can also be built as a module. If so, the module
140 will be called rtc-ds1307. 142 will be called rtc-ds1307.
diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c
index 178527252c6a..33c0e98243ee 100644
--- a/drivers/rtc/hctosys.c
+++ b/drivers/rtc/hctosys.c
@@ -47,8 +47,8 @@ static int __init rtc_hctosys(void)
47 do_settimeofday(&tv); 47 do_settimeofday(&tv);
48 48
49 dev_info(rtc->dev.parent, 49 dev_info(rtc->dev.parent,
50 "setting the system clock to " 50 "setting system clock to "
51 "%d-%02d-%02d %02d:%02d:%02d (%u)\n", 51 "%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n",
52 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, 52 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
53 tm.tm_hour, tm.tm_min, tm.tm_sec, 53 tm.tm_hour, tm.tm_min, tm.tm_sec,
54 (unsigned int) tv.tv_sec); 54 (unsigned int) tv.tv_sec);
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index db6f3f0d8982..bc1c7fe94ad3 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -89,6 +89,7 @@ enum ds_type {
89 89
90struct ds1307 { 90struct ds1307 {
91 u8 reg_addr; 91 u8 reg_addr;
92 bool has_nvram;
92 u8 regs[8]; 93 u8 regs[8];
93 enum ds_type type; 94 enum ds_type type;
94 struct i2c_msg msg[2]; 95 struct i2c_msg msg[2];
@@ -242,6 +243,87 @@ static const struct rtc_class_ops ds13xx_rtc_ops = {
242 .set_time = ds1307_set_time, 243 .set_time = ds1307_set_time,
243}; 244};
244 245
246/*----------------------------------------------------------------------*/
247
248#define NVRAM_SIZE 56
249
250static ssize_t
251ds1307_nvram_read(struct kobject *kobj, struct bin_attribute *attr,
252 char *buf, loff_t off, size_t count)
253{
254 struct i2c_client *client;
255 struct ds1307 *ds1307;
256 struct i2c_msg msg[2];
257 int result;
258
259 client = to_i2c_client(container_of(kobj, struct device, kobj));
260 ds1307 = i2c_get_clientdata(client);
261
262 if (unlikely(off >= NVRAM_SIZE))
263 return 0;
264 if ((off + count) > NVRAM_SIZE)
265 count = NVRAM_SIZE - off;
266 if (unlikely(!count))
267 return count;
268
269 msg[0].addr = client->addr;
270 msg[0].flags = 0;
271 msg[0].len = 1;
272 msg[0].buf = buf;
273
274 buf[0] = 8 + off;
275
276 msg[1].addr = client->addr;
277 msg[1].flags = I2C_M_RD;
278 msg[1].len = count;
279 msg[1].buf = buf;
280
281 result = i2c_transfer(to_i2c_adapter(client->dev.parent), msg, 2);
282 if (result != 2) {
283 dev_err(&client->dev, "%s error %d\n", "nvram read", result);
284 return -EIO;
285 }
286 return count;
287}
288
289static ssize_t
290ds1307_nvram_write(struct kobject *kobj, struct bin_attribute *attr,
291 char *buf, loff_t off, size_t count)
292{
293 struct i2c_client *client;
294 u8 buffer[NVRAM_SIZE + 1];
295 int ret;
296
297 client = to_i2c_client(container_of(kobj, struct device, kobj));
298
299 if (unlikely(off >= NVRAM_SIZE))
300 return -EFBIG;
301 if ((off + count) > NVRAM_SIZE)
302 count = NVRAM_SIZE - off;
303 if (unlikely(!count))
304 return count;
305
306 buffer[0] = 8 + off;
307 memcpy(buffer + 1, buf, count);
308
309 ret = i2c_master_send(client, buffer, count + 1);
310 return (ret < 0) ? ret : (ret - 1);
311}
312
313static struct bin_attribute nvram = {
314 .attr = {
315 .name = "nvram",
316 .mode = S_IRUGO | S_IWUSR,
317 .owner = THIS_MODULE,
318 },
319
320 .read = ds1307_nvram_read,
321 .write = ds1307_nvram_write,
322 .size = NVRAM_SIZE,
323};
324
325/*----------------------------------------------------------------------*/
326
245static struct i2c_driver ds1307_driver; 327static struct i2c_driver ds1307_driver;
246 328
247static int __devinit ds1307_probe(struct i2c_client *client) 329static int __devinit ds1307_probe(struct i2c_client *client)
@@ -413,6 +495,14 @@ read_rtc:
413 goto exit_free; 495 goto exit_free;
414 } 496 }
415 497
498 if (chip->nvram56) {
499 err = sysfs_create_bin_file(&client->dev.kobj, &nvram);
500 if (err == 0) {
501 ds1307->has_nvram = true;
502 dev_info(&client->dev, "56 bytes nvram\n");
503 }
504 }
505
416 return 0; 506 return 0;
417 507
418exit_bad: 508exit_bad:
@@ -432,6 +522,9 @@ static int __devexit ds1307_remove(struct i2c_client *client)
432{ 522{
433 struct ds1307 *ds1307 = i2c_get_clientdata(client); 523 struct ds1307 *ds1307 = i2c_get_clientdata(client);
434 524
525 if (ds1307->has_nvram)
526 sysfs_remove_bin_file(&client->dev.kobj, &nvram);
527
435 rtc_device_unregister(ds1307->rtc); 528 rtc_device_unregister(ds1307->rtc);
436 kfree(ds1307); 529 kfree(ds1307);
437 return 0; 530 return 0;
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c
index bb53c09bad16..d9e848dcd450 100644
--- a/drivers/rtc/rtc-ds1553.c
+++ b/drivers/rtc/rtc-ds1553.c
@@ -291,7 +291,7 @@ static ssize_t ds1553_nvram_write(struct kobject *kobj,
291static struct bin_attribute ds1553_nvram_attr = { 291static struct bin_attribute ds1553_nvram_attr = {
292 .attr = { 292 .attr = {
293 .name = "nvram", 293 .name = "nvram",
294 .mode = S_IRUGO | S_IWUGO, 294 .mode = S_IRUGO | S_IWUSR,
295 }, 295 },
296 .size = RTC_OFFSET, 296 .size = RTC_OFFSET,
297 .read = ds1553_nvram_read, 297 .read = ds1553_nvram_read,
diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c
index c535b78698e2..2e73f0b183b2 100644
--- a/drivers/rtc/rtc-ds1742.c
+++ b/drivers/rtc/rtc-ds1742.c
@@ -160,10 +160,13 @@ static ssize_t ds1742_nvram_write(struct kobject *kobj,
160static struct bin_attribute ds1742_nvram_attr = { 160static struct bin_attribute ds1742_nvram_attr = {
161 .attr = { 161 .attr = {
162 .name = "nvram", 162 .name = "nvram",
163 .mode = S_IRUGO | S_IWUGO, 163 .mode = S_IRUGO | S_IWUSR,
164 }, 164 },
165 .read = ds1742_nvram_read, 165 .read = ds1742_nvram_read,
166 .write = ds1742_nvram_write, 166 .write = ds1742_nvram_write,
167 /* REVISIT: size in sysfs won't match actual size... if it's
168 * not a constant, each RTC should have its own attribute.
169 */
167}; 170};
168 171
169static int __devinit ds1742_rtc_probe(struct platform_device *pdev) 172static int __devinit ds1742_rtc_probe(struct platform_device *pdev)
diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
index 2bad1637330a..cd0bbc0e8038 100644
--- a/drivers/rtc/rtc-m48t59.c
+++ b/drivers/rtc/rtc-m48t59.c
@@ -353,11 +353,12 @@ static ssize_t m48t59_nvram_write(struct kobject *kobj,
353static struct bin_attribute m48t59_nvram_attr = { 353static struct bin_attribute m48t59_nvram_attr = {
354 .attr = { 354 .attr = {
355 .name = "nvram", 355 .name = "nvram",
356 .mode = S_IRUGO | S_IWUGO, 356 .mode = S_IRUGO | S_IWUSR,
357 .owner = THIS_MODULE, 357 .owner = THIS_MODULE,
358 }, 358 },
359 .read = m48t59_nvram_read, 359 .read = m48t59_nvram_read,
360 .write = m48t59_nvram_write, 360 .write = m48t59_nvram_write,
361 .size = M48T59_NVRAM_SIZE,
361}; 362};
362 363
363static int __devinit m48t59_rtc_probe(struct platform_device *pdev) 364static int __devinit m48t59_rtc_probe(struct platform_device *pdev)
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index 78277a118b67..8e8c8b8e81ee 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -351,8 +351,10 @@ static int sh_rtc_read_time(struct device *dev, struct rtc_time *tm)
351 tm->tm_sec, tm->tm_min, tm->tm_hour, 351 tm->tm_sec, tm->tm_min, tm->tm_hour,
352 tm->tm_mday, tm->tm_mon + 1, tm->tm_year, tm->tm_wday); 352 tm->tm_mday, tm->tm_mon + 1, tm->tm_year, tm->tm_wday);
353 353
354 if (rtc_valid_tm(tm) < 0) 354 if (rtc_valid_tm(tm) < 0) {
355 dev_err(dev, "invalid date\n"); 355 dev_err(dev, "invalid date\n");
356 rtc_time_to_tm(0, tm);
357 }
356 358
357 return 0; 359 return 0;
358} 360}
@@ -588,7 +590,7 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev)
588 590
589 rtc->rtc_dev = rtc_device_register("sh", &pdev->dev, 591 rtc->rtc_dev = rtc_device_register("sh", &pdev->dev,
590 &sh_rtc_ops, THIS_MODULE); 592 &sh_rtc_ops, THIS_MODULE);
591 if (IS_ERR(rtc)) { 593 if (IS_ERR(rtc->rtc_dev)) {
592 ret = PTR_ERR(rtc->rtc_dev); 594 ret = PTR_ERR(rtc->rtc_dev);
593 goto err_badmap; 595 goto err_badmap;
594 } 596 }
diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c
index 8288b6b2bf2b..a265da7c6ff8 100644
--- a/drivers/rtc/rtc-stk17ta8.c
+++ b/drivers/rtc/rtc-stk17ta8.c
@@ -291,7 +291,7 @@ static ssize_t stk17ta8_nvram_write(struct kobject *kobj,
291static struct bin_attribute stk17ta8_nvram_attr = { 291static struct bin_attribute stk17ta8_nvram_attr = {
292 .attr = { 292 .attr = {
293 .name = "nvram", 293 .name = "nvram",
294 .mode = S_IRUGO | S_IWUGO, 294 .mode = S_IRUGO | S_IWUSR,
295 .owner = THIS_MODULE, 295 .owner = THIS_MODULE,
296 }, 296 },
297 .size = RTC_OFFSET, 297 .size = RTC_OFFSET,
diff --git a/drivers/scsi/aic94xx/aic94xx_sds.c b/drivers/scsi/aic94xx/aic94xx_sds.c
index 5b0932f61473..06509bff71f7 100644
--- a/drivers/scsi/aic94xx/aic94xx_sds.c
+++ b/drivers/scsi/aic94xx/aic94xx_sds.c
@@ -377,7 +377,7 @@ out:
377 377
378#define FLASH_RESET 0xF0 378#define FLASH_RESET 0xF0
379 379
380#define FLASH_SIZE 0x200000 380#define ASD_FLASH_SIZE 0x200000
381#define FLASH_DIR_COOKIE "*** ADAPTEC FLASH DIRECTORY *** " 381#define FLASH_DIR_COOKIE "*** ADAPTEC FLASH DIRECTORY *** "
382#define FLASH_NEXT_ENTRY_OFFS 0x2000 382#define FLASH_NEXT_ENTRY_OFFS 0x2000
383#define FLASH_MAX_DIR_ENTRIES 32 383#define FLASH_MAX_DIR_ENTRIES 32
@@ -609,7 +609,7 @@ static int asd_find_flash_dir(struct asd_ha_struct *asd_ha,
609 struct asd_flash_dir *flash_dir) 609 struct asd_flash_dir *flash_dir)
610{ 610{
611 u32 v; 611 u32 v;
612 for (v = 0; v < FLASH_SIZE; v += FLASH_NEXT_ENTRY_OFFS) { 612 for (v = 0; v < ASD_FLASH_SIZE; v += FLASH_NEXT_ENTRY_OFFS) {
613 asd_read_flash_seg(asd_ha, flash_dir, v, 613 asd_read_flash_seg(asd_ha, flash_dir, v,
614 sizeof(FLASH_DIR_COOKIE)-1); 614 sizeof(FLASH_DIR_COOKIE)-1);
615 if (memcmp(flash_dir->cookie, FLASH_DIR_COOKIE, 615 if (memcmp(flash_dir->cookie, FLASH_DIR_COOKIE,
diff --git a/drivers/serial/8250_pnp.c b/drivers/serial/8250_pnp.c
index 926f58a674a1..1de098e75497 100644
--- a/drivers/serial/8250_pnp.c
+++ b/drivers/serial/8250_pnp.c
@@ -69,6 +69,8 @@ static const struct pnp_device_id pnp_dev_table[] = {
69 { "CTL3001", 0 }, 69 { "CTL3001", 0 },
70 /* Creative Labs Modem Blaster 28.8 DSVD PnP Voice */ 70 /* Creative Labs Modem Blaster 28.8 DSVD PnP Voice */
71 { "CTL3011", 0 }, 71 { "CTL3011", 0 },
72 /* Davicom ISA 33.6K Modem */
73 { "DAV0336", 0 },
72 /* Creative */ 74 /* Creative */
73 /* Creative Modem Blaster Flash56 DI5601-1 */ 75 /* Creative Modem Blaster Flash56 DI5601-1 */
74 { "DMB1032", 0 }, 76 { "DMB1032", 0 },
@@ -345,6 +347,11 @@ static const struct pnp_device_id pnp_dev_table[] = {
345 /* Fujitsu Wacom Tablet PC devices */ 347 /* Fujitsu Wacom Tablet PC devices */
346 { "FUJ02E5", 0 }, 348 { "FUJ02E5", 0 },
347 { "FUJ02E6", 0 }, 349 { "FUJ02E6", 0 },
350 /*
351 * LG C1 EXPRESS DUAL (C1-PB11A3) touch screen (actually a FUJ02E6 in
352 * disguise)
353 */
354 { "LTS0001", 0 },
348 /* Rockwell's (PORALiNK) 33600 INT PNP */ 355 /* Rockwell's (PORALiNK) 33600 INT PNP */
349 { "WCI0003", 0 }, 356 { "WCI0003", 0 },
350 /* Unkown PnP modems */ 357 /* Unkown PnP modems */
@@ -432,7 +439,8 @@ serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
432 } 439 }
433 440
434 memset(&port, 0, sizeof(struct uart_port)); 441 memset(&port, 0, sizeof(struct uart_port));
435 port.irq = pnp_irq(dev, 0); 442 if (pnp_irq_valid(dev, 0))
443 port.irq = pnp_irq(dev, 0);
436 if (pnp_port_valid(dev, 0)) { 444 if (pnp_port_valid(dev, 0)) {
437 port.iobase = pnp_port_start(dev, 0); 445 port.iobase = pnp_port_start(dev, 0);
438 port.iotype = UPIO_PORT; 446 port.iotype = UPIO_PORT;
diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c
index 4d6b3c56d20e..111da57f5334 100644
--- a/drivers/serial/atmel_serial.c
+++ b/drivers/serial/atmel_serial.c
@@ -204,8 +204,6 @@ static u_int atmel_get_mctrl(struct uart_port *port)
204 */ 204 */
205static void atmel_stop_tx(struct uart_port *port) 205static void atmel_stop_tx(struct uart_port *port)
206{ 206{
207 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *) port;
208
209 UART_PUT_IDR(port, ATMEL_US_TXRDY); 207 UART_PUT_IDR(port, ATMEL_US_TXRDY);
210} 208}
211 209
@@ -214,8 +212,6 @@ static void atmel_stop_tx(struct uart_port *port)
214 */ 212 */
215static void atmel_start_tx(struct uart_port *port) 213static void atmel_start_tx(struct uart_port *port)
216{ 214{
217 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *) port;
218
219 UART_PUT_IER(port, ATMEL_US_TXRDY); 215 UART_PUT_IER(port, ATMEL_US_TXRDY);
220} 216}
221 217
@@ -224,8 +220,6 @@ static void atmel_start_tx(struct uart_port *port)
224 */ 220 */
225static void atmel_stop_rx(struct uart_port *port) 221static void atmel_stop_rx(struct uart_port *port)
226{ 222{
227 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *) port;
228
229 UART_PUT_IDR(port, ATMEL_US_RXRDY); 223 UART_PUT_IDR(port, ATMEL_US_RXRDY);
230} 224}
231 225
@@ -409,7 +403,6 @@ static irqreturn_t atmel_interrupt(int irq, void *dev_id)
409 */ 403 */
410static int atmel_startup(struct uart_port *port) 404static int atmel_startup(struct uart_port *port)
411{ 405{
412 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *) port;
413 int retval; 406 int retval;
414 407
415 /* 408 /*
@@ -456,8 +449,6 @@ static int atmel_startup(struct uart_port *port)
456 */ 449 */
457static void atmel_shutdown(struct uart_port *port) 450static void atmel_shutdown(struct uart_port *port)
458{ 451{
459 struct atmel_uart_port *atmel_port = (struct atmel_uart_port *) port;
460
461 /* 452 /*
462 * Disable all interrupts, port and break condition. 453 * Disable all interrupts, port and break condition.
463 */ 454 */
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c
index f523cdf4b02b..a4e23cf47906 100644
--- a/drivers/serial/crisv10.c
+++ b/drivers/serial/crisv10.c
@@ -1,426 +1,10 @@
1/* $Id: serial.c,v 1.25 2004/09/29 10:33:49 starvik Exp $ 1/*
2 *
3 * Serial port driver for the ETRAX 100LX chip 2 * Serial port driver for the ETRAX 100LX chip
4 * 3 *
5 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Axis Communications AB 4 * Copyright (C) 1998-2007 Axis Communications AB
6 * 5 *
7 * Many, many authors. Based once upon a time on serial.c for 16x50. 6 * Many, many authors. Based once upon a time on serial.c for 16x50.
8 * 7 *
9 * $Log: serial.c,v $
10 * Revision 1.25 2004/09/29 10:33:49 starvik
11 * Resolved a dealock when printing debug from kernel.
12 *
13 * Revision 1.24 2004/08/27 23:25:59 johana
14 * rs_set_termios() must call change_speed() if c_iflag has changed or
15 * automatic XOFF handling will be enabled and transmitter will stop
16 * if 0x13 is received.
17 *
18 * Revision 1.23 2004/08/24 06:57:13 starvik
19 * More whitespace cleanup
20 *
21 * Revision 1.22 2004/08/24 06:12:20 starvik
22 * Whitespace cleanup
23 *
24 * Revision 1.20 2004/05/24 12:00:20 starvik
25 * Big merge of stuff from Linux 2.4 (e.g. manual mode for the serial port).
26 *
27 * Revision 1.19 2004/05/17 13:12:15 starvik
28 * Kernel console hook
29 * Big merge from Linux 2.4 still pending.
30 *
31 * Revision 1.18 2003/10/28 07:18:30 starvik
32 * Compiles with debug info
33 *
34 * Revision 1.17 2003/07/04 08:27:37 starvik
35 * Merge of Linux 2.5.74
36 *
37 * Revision 1.16 2003/06/13 10:05:19 johana
38 * Help the user to avoid trouble by:
39 * Forcing mixed mode for status/control lines if not all pins are used.
40 *
41 * Revision 1.15 2003/06/13 09:43:01 johana
42 * Merged in the following changes from os/linux/arch/cris/drivers/serial.c
43 * + some minor changes to reduce diff.
44 *
45 * Revision 1.49 2003/05/30 11:31:54 johana
46 * Merged in change-branch--serial9bit that adds CMSPAR support for sticky
47 * parity (mark/space)
48 *
49 * Revision 1.48 2003/05/30 11:03:57 johana
50 * Implemented rs_send_xchar() by disabling the DMA and writing manually.
51 * Added e100_disable_txdma_channel() and e100_enable_txdma_channel().
52 * Fixed rs_throttle() and rs_unthrottle() to properly call rs_send_xchar
53 * instead of setting info->x_char and check the CRTSCTS flag before
54 * controlling the rts pin.
55 *
56 * Revision 1.14 2003/04/09 08:12:44 pkj
57 * Corrected typo changes made upstream.
58 *
59 * Revision 1.13 2003/04/09 05:20:47 starvik
60 * Merge of Linux 2.5.67
61 *
62 * Revision 1.11 2003/01/22 06:48:37 starvik
63 * Fixed warnings issued by GCC 3.2.1
64 *
65 * Revision 1.9 2002/12/13 09:07:47 starvik
66 * Alert user that RX_TIMEOUT_TICKS==0 doesn't work
67 *
68 * Revision 1.8 2002/12/11 13:13:57 starvik
69 * Added arch/ to v10 specific includes
70 * Added fix from Linux 2.4 in serial.c (flush_to_flip_buffer)
71 *
72 * Revision 1.7 2002/12/06 07:13:57 starvik
73 * Corrected work queue stuff
74 * Removed CONFIG_ETRAX_SERIAL_FLUSH_DMA_FAST
75 *
76 * Revision 1.6 2002/11/21 07:17:46 starvik
77 * Change static inline to extern inline where otherwise outlined with gcc-3.2
78 *
79 * Revision 1.5 2002/11/14 15:59:49 starvik
80 * Linux 2.5 port of the latest serial driver from 2.4. The work queue stuff
81 * probably doesn't work yet.
82 *
83 * Revision 1.42 2002/11/05 09:08:47 johana
84 * Better implementation of rs_stop() and rs_start() that uses the XOFF
85 * register to start/stop transmission.
86 * change_speed() also initilises XOFF register correctly so that
87 * auto_xoff is enabled when IXON flag is set by user.
88 * This gives fast XOFF response times.
89 *
90 * Revision 1.41 2002/11/04 18:40:57 johana
91 * Implemented rs_stop() and rs_start().
92 * Simple tests using hwtestserial indicates that this should be enough
93 * to make it work.
94 *
95 * Revision 1.40 2002/10/14 05:33:18 starvik
96 * RS-485 uses fast timers even if SERIAL_FAST_TIMER is disabled
97 *
98 * Revision 1.39 2002/09/30 21:00:57 johana
99 * Support for CONFIG_ETRAX_SERx_DTR_RI_DSR_CD_MIXED where the status and
100 * control pins can be mixed between PA and PB.
101 * If no serial port uses MIXED old solution is used
102 * (saves a few bytes and cycles).
103 * control_pins struct uses masks instead of bit numbers.
104 * Corrected dummy values and polarity in line_info() so
105 * /proc/tty/driver/serial is now correct.
106 * (the E100_xxx_GET() macros is really active low - perhaps not obvious)
107 *
108 * Revision 1.38 2002/08/23 11:01:36 starvik
109 * Check that serial port is enabled in all interrupt handlers to avoid
110 * restarts of DMA channels not assigned to serial ports
111 *
112 * Revision 1.37 2002/08/13 13:02:37 bjornw
113 * Removed some warnings because of unused code
114 *
115 * Revision 1.36 2002/08/08 12:50:01 starvik
116 * Serial interrupt is shared with synchronous serial port driver
117 *
118 * Revision 1.35 2002/06/03 10:40:49 starvik
119 * Increased RS-485 RTS toggle timer to 2 characters
120 *
121 * Revision 1.34 2002/05/28 18:59:36 johana
122 * Whitespace and comment fixing to be more like etrax100ser.c 1.71.
123 *
124 * Revision 1.33 2002/05/28 17:55:43 johana
125 * RS-485 uses FAST_TIMER if enabled, and starts a short (one char time)
126 * timer from tranismit_chars (interrupt context).
127 * The timer toggles RTS in interrupt context when expired giving minimum
128 * latencies.
129 *
130 * Revision 1.32 2002/05/22 13:58:00 johana
131 * Renamed rs_write() to raw_write() and made it inline.
132 * New rs_write() handles RS-485 if configured and enabled
133 * (moved code from e100_write_rs485()).
134 * RS-485 ioctl's uses copy_from_user() instead of verify_area().
135 *
136 * Revision 1.31 2002/04/22 11:20:03 johana
137 * Updated copyright years.
138 *
139 * Revision 1.30 2002/04/22 09:39:12 johana
140 * RS-485 support compiles.
141 *
142 * Revision 1.29 2002/01/14 16:10:01 pkj
143 * Allocate the receive buffers dynamically. The static 4kB buffer was
144 * too small for the peaks. This means that we can get rid of the extra
145 * buffer and the copying to it. It also means we require less memory
146 * under normal operations, but can use more when needed (there is a
147 * cap at 64kB for safety reasons). If there is no memory available
148 * we panic(), and die a horrible death...
149 *
150 * Revision 1.28 2001/12/18 15:04:53 johana
151 * Cleaned up write_rs485() - now it works correctly without padding extra
152 * char.
153 * Added sane default initialisation of rs485.
154 * Added #ifdef around dummy variables.
155 *
156 * Revision 1.27 2001/11/29 17:00:41 pkj
157 * 2kB seems to be too small a buffer when using 921600 bps,
158 * so increase it to 4kB (this was already done for the elinux
159 * version of the serial driver).
160 *
161 * Revision 1.26 2001/11/19 14:20:41 pkj
162 * Minor changes to comments and unused code.
163 *
164 * Revision 1.25 2001/11/12 20:03:43 pkj
165 * Fixed compiler warnings.
166 *
167 * Revision 1.24 2001/11/12 15:10:05 pkj
168 * Total redesign of the receiving part of the serial driver.
169 * Uses eight chained descriptors to write to a 4kB buffer.
170 * This data is then serialised into a 2kB buffer. From there it
171 * is copied into the TTY's flip buffers when they become available.
172 * A lot of copying, and the sizes of the buffers might need to be
173 * tweaked, but all in all it should work better than the previous
174 * version, without the need to modify the TTY code in any way.
175 * Also note that erroneous bytes are now correctly marked in the
176 * flag buffers (instead of always marking the first byte).
177 *
178 * Revision 1.23 2001/10/30 17:53:26 pkj
179 * * Set info->uses_dma to 0 when a port is closed.
180 * * Mark the timer1 interrupt as a fast one (SA_INTERRUPT).
181 * * Call start_flush_timer() in start_receive() if
182 * CONFIG_ETRAX_SERIAL_FLUSH_DMA_FAST is defined.
183 *
184 * Revision 1.22 2001/10/30 17:44:03 pkj
185 * Use %lu for received and transmitted counters in line_info().
186 *
187 * Revision 1.21 2001/10/30 17:40:34 pkj
188 * Clean-up. The only change to functionality is that
189 * CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS(=5) is used instead of
190 * MAX_FLUSH_TIME(=8).
191 *
192 * Revision 1.20 2001/10/30 15:24:49 johana
193 * Added char_time stuff from 2.0 driver.
194 *
195 * Revision 1.19 2001/10/30 15:23:03 johana
196 * Merged with 1.13.2 branch + fixed indentation
197 * and changed CONFIG_ETRAX100_XYS to CONFIG_ETRAX_XYZ
198 *
199 * Revision 1.18 2001/09/24 09:27:22 pkj
200 * Completed ext_baud_table[] in cflag_to_baud() and cflag_to_etrax_baud().
201 *
202 * Revision 1.17 2001/08/24 11:32:49 ronny
203 * More fixes for the CONFIG_ETRAX_SERIAL_PORT0 define.
204 *
205 * Revision 1.16 2001/08/24 07:56:22 ronny
206 * Added config ifdefs around ser0 irq requests.
207 *
208 * Revision 1.15 2001/08/16 09:10:31 bjarne
209 * serial.c - corrected the initialization of rs_table, the wrong defines
210 * where used.
211 * Corrected a test in timed_flush_handler.
212 * Changed configured to enabled.
213 * serial.h - Changed configured to enabled.
214 *
215 * Revision 1.14 2001/08/15 07:31:23 bjarne
216 * Introduced two new members to the e100_serial struct.
217 * configured - Will be set to 1 if the port has been configured in .config
218 * uses_dma - Should be set to 1 if the port uses DMA. Currently it is set
219 * to 1
220 * when a port is opened. This is used to limit the DMA interrupt
221 * routines to only manipulate DMA channels actually used by the
222 * serial driver.
223 *
224 * Revision 1.13.2.2 2001/10/17 13:57:13 starvik
225 * Receiver was broken by the break fixes
226 *
227 * Revision 1.13.2.1 2001/07/20 13:57:39 ronny
228 * Merge with new stuff from etrax100ser.c. Works but haven't checked stuff
229 * like break handling.
230 *
231 * Revision 1.13 2001/05/09 12:40:31 johana
232 * Use DMA_NBR and IRQ_NBR defines from dma.h and irq.h
233 *
234 * Revision 1.12 2001/04/19 12:23:07 bjornw
235 * CONFIG_RS485 -> CONFIG_ETRAX_RS485
236 *
237 * Revision 1.11 2001/04/05 14:29:48 markusl
238 * Updated according to review remarks i.e.
239 * -Use correct types in port structure to avoid compiler warnings
240 * -Try to use IO_* macros whenever possible
241 * -Open should never return -EBUSY
242 *
243 * Revision 1.10 2001/03/05 13:14:07 bjornw
244 * Another spelling fix
245 *
246 * Revision 1.9 2001/02/23 13:46:38 bjornw
247 * Spellling check
248 *
249 * Revision 1.8 2001/01/23 14:56:35 markusl
250 * Made use of ser1 optional
251 * Needed by USB
252 *
253 * Revision 1.7 2001/01/19 16:14:48 perf
254 * Added kernel options for serial ports 234.
255 * Changed option names from CONFIG_ETRAX100_XYZ to CONFIG_ETRAX_XYZ.
256 *
257 * Revision 1.6 2000/11/22 16:36:09 bjornw
258 * Please marketing by using the correct case when spelling Etrax.
259 *
260 * Revision 1.5 2000/11/21 16:43:37 bjornw
261 * Fixed so it compiles under CONFIG_SVINTO_SIM
262 *
263 * Revision 1.4 2000/11/15 17:34:12 bjornw
264 * Added a timeout timer for flushing input channels. The interrupt-based
265 * fast flush system should be easy to merge with this later (works the same
266 * way, only with an irq instead of a system timer_list)
267 *
268 * Revision 1.3 2000/11/13 17:19:57 bjornw
269 * * Incredibly, this almost complete rewrite of serial.c worked (at least
270 * for output) the first time.
271 *
272 * Items worth noticing:
273 *
274 * No Etrax100 port 1 workarounds (does only compile on 2.4 anyway now)
275 * RS485 is not ported (why can't it be done in userspace as on x86 ?)
276 * Statistics done through async_icount - if any more stats are needed,
277 * that's the place to put them or in an arch-dep version of it.
278 * timeout_interrupt and the other fast timeout stuff not ported yet
279 * There be dragons in this 3k+ line driver
280 *
281 * Revision 1.2 2000/11/10 16:50:28 bjornw
282 * First shot at a 2.4 port, does not compile totally yet
283 *
284 * Revision 1.1 2000/11/10 16:47:32 bjornw
285 * Added verbatim copy of rev 1.49 etrax100ser.c from elinux
286 *
287 * Revision 1.49 2000/10/30 15:47:14 tobiasa
288 * Changed version number.
289 *
290 * Revision 1.48 2000/10/25 11:02:43 johana
291 * Changed %ul to %lu in printf's
292 *
293 * Revision 1.47 2000/10/18 15:06:53 pkj
294 * Compile correctly with CONFIG_ETRAX_SERIAL_FLUSH_DMA_FAST and
295 * CONFIG_ETRAX_SERIAL_PROC_ENTRY together.
296 * Some clean-up of the /proc/serial file.
297 *
298 * Revision 1.46 2000/10/16 12:59:40 johana
299 * Added CONFIG_ETRAX_SERIAL_PROC_ENTRY for statistics and debug info.
300 *
301 * Revision 1.45 2000/10/13 17:10:59 pkj
302 * Do not flush DMAs while flipping TTY buffers.
303 *
304 * Revision 1.44 2000/10/13 16:34:29 pkj
305 * Added a delay in ser_interrupt() for 2.3ms when an error is detected.
306 * We do not know why this delay is required yet, but without it the
307 * irmaflash program does not work (this was the program that needed
308 * the ser_interrupt() to be needed in the first place). This should not
309 * affect normal use of the serial ports.
310 *
311 * Revision 1.43 2000/10/13 16:30:44 pkj
312 * New version of the fast flush of serial buffers code. This time
313 * it is localized to the serial driver and uses a fast timer to
314 * do the work.
315 *
316 * Revision 1.42 2000/10/13 14:54:26 bennyo
317 * Fix for switching RTS when using rs485
318 *
319 * Revision 1.41 2000/10/12 11:43:44 pkj
320 * Cleaned up a number of comments.
321 *
322 * Revision 1.40 2000/10/10 11:58:39 johana
323 * Made RS485 support generic for all ports.
324 * Toggle rts in interrupt if no delay wanted.
325 * WARNING: No true transmitter empty check??
326 * Set d_wait bit when sending data so interrupt is delayed until
327 * fifo flushed. (Fix tcdrain() problem)
328 *
329 * Revision 1.39 2000/10/04 16:08:02 bjornw
330 * * Use virt_to_phys etc. for DMA addresses
331 * * Removed CONFIG_FLUSH_DMA_FAST hacks
332 * * Indentation fix
333 *
334 * Revision 1.38 2000/10/02 12:27:10 mattias
335 * * added variable used when using fast flush on serial dma.
336 * (CONFIG_FLUSH_DMA_FAST)
337 *
338 * Revision 1.37 2000/09/27 09:44:24 pkj
339 * Uncomment definition of SERIAL_HANDLE_EARLY_ERRORS.
340 *
341 * Revision 1.36 2000/09/20 13:12:52 johana
342 * Support for CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS:
343 * Number of timer ticks between flush of receive fifo (1 tick = 10ms).
344 * Try 0-3 for low latency applications. Approx 5 for high load
345 * applications (e.g. PPP). Maybe this should be more adaptive some day...
346 *
347 * Revision 1.35 2000/09/20 10:36:08 johana
348 * Typo in get_lsr_info()
349 *
350 * Revision 1.34 2000/09/20 10:29:59 johana
351 * Let rs_chars_in_buffer() check fifo content as well.
352 * get_lsr_info() might work now (not tested).
353 * Easier to change the port to debug.
354 *
355 * Revision 1.33 2000/09/13 07:52:11 torbjore
356 * Support RS485
357 *
358 * Revision 1.32 2000/08/31 14:45:37 bjornw
359 * After sending a break we need to reset the transmit DMA channel
360 *
361 * Revision 1.31 2000/06/21 12:13:29 johana
362 * Fixed wait for all chars sent when closing port.
363 * (Used to always take 1 second!)
364 * Added shadows for directions of status/ctrl signals.
365 *
366 * Revision 1.30 2000/05/29 16:27:55 bjornw
367 * Simulator ifdef moved a bit
368 *
369 * Revision 1.29 2000/05/09 09:40:30 mattias
370 * * Added description of dma registers used in timeout_interrupt
371 * * Removed old code
372 *
373 * Revision 1.28 2000/05/08 16:38:58 mattias
374 * * Bugfix for flushing fifo in timeout_interrupt
375 * Problem occurs when bluetooth stack waits for a small number of bytes
376 * containing an event acknowledging free buffers in bluetooth HW
377 * As before, data was stuck in fifo until more data came on uart and
378 * flushed it up to the stack.
379 *
380 * Revision 1.27 2000/05/02 09:52:28 jonasd
381 * Added fix for peculiar etrax behaviour when eop is forced on an empty
382 * fifo. This is used when flashing the IRMA chip. Disabled by default.
383 *
384 * Revision 1.26 2000/03/29 15:32:02 bjornw
385 * 2.0.34 updates
386 *
387 * Revision 1.25 2000/02/16 16:59:36 bjornw
388 * * Receive DMA directly into the flip-buffer, eliminating an intermediary
389 * receive buffer and a memcpy. Will avoid some overruns.
390 * * Error message on debug port if an overrun or flip buffer overrun occurs.
391 * * Just use the first byte in the flag flip buffer for errors.
392 * * Check for timeout on the serial ports only each 5/100 s, not 1/100.
393 *
394 * Revision 1.24 2000/02/09 18:02:28 bjornw
395 * * Clear serial errors (overrun, framing, parity) correctly. Before, the
396 * receiver would get stuck if an error occurred and we did not restart
397 * the input DMA.
398 * * Cosmetics (indentation, some code made into inlines)
399 * * Some more debug options
400 * * Actually shut down the serial port (DMA irq, DMA reset, receiver stop)
401 * when the last open is closed. Corresponding fixes in startup().
402 * * rs_close() "tx FIFO wait" code moved into right place, bug & -> && fixed
403 * and make a special case out of port 1 (R_DMA_CHx_STATUS is broken for that)
404 * * e100_disable_rx/enable_rx just disables/enables the receiver, not RTS
405 *
406 * Revision 1.23 2000/01/24 17:46:19 johana
407 * Wait for flush of DMA/FIFO when closing port.
408 *
409 * Revision 1.22 2000/01/20 18:10:23 johana
410 * Added TIOCMGET ioctl to return modem status.
411 * Implemented modem status/control that works with the extra signals
412 * (DTR, DSR, RI,CD) as well.
413 * 3 different modes supported:
414 * ser0 on PB (Bundy), ser1 on PB (Lisa) and ser2 on PA (Bundy)
415 * Fixed DEF_TX value that caused the serial transmitter pin (txd) to go to 0 when
416 * closing the last filehandle, NASTY!.
417 * Added break generation, not tested though!
418 * Use IRQF_SHARED when request_irq() for ser2 and ser3 (shared with) par0 and par1.
419 * You can't use them at the same time (yet..), but you can hopefully switch
420 * between ser2/par0, ser3/par1 with the same kernel config.
421 * Replaced some magic constants with defines
422 *
423 *
424 */ 8 */
425 9
426static char *serial_version = "$Revision: 1.25 $"; 10static char *serial_version = "$Revision: 1.25 $";
@@ -446,6 +30,7 @@ static char *serial_version = "$Revision: 1.25 $";
446 30
447#include <asm/io.h> 31#include <asm/io.h>
448#include <asm/irq.h> 32#include <asm/irq.h>
33#include <asm/dma.h>
449#include <asm/system.h> 34#include <asm/system.h>
450#include <linux/delay.h> 35#include <linux/delay.h>
451 36
@@ -454,8 +39,9 @@ static char *serial_version = "$Revision: 1.25 $";
454/* non-arch dependent serial structures are in linux/serial.h */ 39/* non-arch dependent serial structures are in linux/serial.h */
455#include <linux/serial.h> 40#include <linux/serial.h>
456/* while we keep our own stuff (struct e100_serial) in a local .h file */ 41/* while we keep our own stuff (struct e100_serial) in a local .h file */
457#include "serial.h" 42#include "crisv10.h"
458#include <asm/fasttimer.h> 43#include <asm/fasttimer.h>
44#include <asm/arch/io_interface_mux.h>
459 45
460#ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER 46#ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER
461#ifndef CONFIG_ETRAX_FAST_TIMER 47#ifndef CONFIG_ETRAX_FAST_TIMER
@@ -504,18 +90,6 @@ struct tty_driver *serial_driver;
504 from eLinux */ 90 from eLinux */
505#define SERIAL_HANDLE_EARLY_ERRORS 91#define SERIAL_HANDLE_EARLY_ERRORS
506 92
507/* Defined and used in n_tty.c, but we need it here as well */
508#define TTY_THRESHOLD_THROTTLE 128
509
510/* Due to buffersizes and threshold values, our SERIAL_DESCR_BUF_SIZE
511 * must not be to high or flow control won't work if we leave it to the tty
512 * layer so we have our own throttling in flush_to_flip
513 * TTY_FLIPBUF_SIZE=512,
514 * TTY_THRESHOLD_THROTTLE/UNTHROTTLE=128
515 * BUF_SIZE can't be > 128
516 */
517#define CRIS_BUF_SIZE 512
518
519/* Currently 16 descriptors x 128 bytes = 2048 bytes */ 93/* Currently 16 descriptors x 128 bytes = 2048 bytes */
520#define SERIAL_DESCR_BUF_SIZE 256 94#define SERIAL_DESCR_BUF_SIZE 256
521 95
@@ -588,13 +162,13 @@ unsigned long timer_data_to_ns(unsigned long timer_data);
588static void change_speed(struct e100_serial *info); 162static void change_speed(struct e100_serial *info);
589static void rs_throttle(struct tty_struct * tty); 163static void rs_throttle(struct tty_struct * tty);
590static void rs_wait_until_sent(struct tty_struct *tty, int timeout); 164static void rs_wait_until_sent(struct tty_struct *tty, int timeout);
591static int rs_write(struct tty_struct * tty, int from_user, 165static int rs_write(struct tty_struct *tty,
592 const unsigned char *buf, int count); 166 const unsigned char *buf, int count);
593#ifdef CONFIG_ETRAX_RS485 167#ifdef CONFIG_ETRAX_RS485
594static int e100_write_rs485(struct tty_struct * tty, int from_user, 168static int e100_write_rs485(struct tty_struct *tty,
595 const unsigned char *buf, int count); 169 const unsigned char *buf, int count);
596#endif 170#endif
597static int get_lsr_info(struct e100_serial * info, unsigned int *value); 171static int get_lsr_info(struct e100_serial *info, unsigned int *value);
598 172
599 173
600#define DEF_BAUD 115200 /* 115.2 kbit/s */ 174#define DEF_BAUD 115200 /* 115.2 kbit/s */
@@ -679,20 +253,39 @@ static struct e100_serial rs_table[] = {
679 .rx_ctrl = DEF_RX, 253 .rx_ctrl = DEF_RX,
680 .tx_ctrl = DEF_TX, 254 .tx_ctrl = DEF_TX,
681 .iseteop = 2, 255 .iseteop = 2,
256 .dma_owner = dma_ser0,
257 .io_if = if_serial_0,
682#ifdef CONFIG_ETRAX_SERIAL_PORT0 258#ifdef CONFIG_ETRAX_SERIAL_PORT0
683 .enabled = 1, 259 .enabled = 1,
684#ifdef CONFIG_ETRAX_SERIAL_PORT0_DMA6_OUT 260#ifdef CONFIG_ETRAX_SERIAL_PORT0_DMA6_OUT
685 .dma_out_enabled = 1, 261 .dma_out_enabled = 1,
262 .dma_out_nbr = SER0_TX_DMA_NBR,
263 .dma_out_irq_nbr = SER0_DMA_TX_IRQ_NBR,
264 .dma_out_irq_flags = IRQF_DISABLED,
265 .dma_out_irq_description = "serial 0 dma tr",
686#else 266#else
687 .dma_out_enabled = 0, 267 .dma_out_enabled = 0,
268 .dma_out_nbr = UINT_MAX,
269 .dma_out_irq_nbr = 0,
270 .dma_out_irq_flags = 0,
271 .dma_out_irq_description = NULL,
688#endif 272#endif
689#ifdef CONFIG_ETRAX_SERIAL_PORT0_DMA7_IN 273#ifdef CONFIG_ETRAX_SERIAL_PORT0_DMA7_IN
690 .dma_in_enabled = 1, 274 .dma_in_enabled = 1,
275 .dma_in_nbr = SER0_RX_DMA_NBR,
276 .dma_in_irq_nbr = SER0_DMA_RX_IRQ_NBR,
277 .dma_in_irq_flags = IRQF_DISABLED,
278 .dma_in_irq_description = "serial 0 dma rec",
691#else 279#else
692 .dma_in_enabled = 0 280 .dma_in_enabled = 0,
281 .dma_in_nbr = UINT_MAX,
282 .dma_in_irq_nbr = 0,
283 .dma_in_irq_flags = 0,
284 .dma_in_irq_description = NULL,
693#endif 285#endif
694#else 286#else
695 .enabled = 0, 287 .enabled = 0,
288 .io_if_description = NULL,
696 .dma_out_enabled = 0, 289 .dma_out_enabled = 0,
697 .dma_in_enabled = 0 290 .dma_in_enabled = 0
698#endif 291#endif
@@ -714,20 +307,42 @@ static struct e100_serial rs_table[] = {
714 .rx_ctrl = DEF_RX, 307 .rx_ctrl = DEF_RX,
715 .tx_ctrl = DEF_TX, 308 .tx_ctrl = DEF_TX,
716 .iseteop = 3, 309 .iseteop = 3,
310 .dma_owner = dma_ser1,
311 .io_if = if_serial_1,
717#ifdef CONFIG_ETRAX_SERIAL_PORT1 312#ifdef CONFIG_ETRAX_SERIAL_PORT1
718 .enabled = 1, 313 .enabled = 1,
314 .io_if_description = "ser1",
719#ifdef CONFIG_ETRAX_SERIAL_PORT1_DMA8_OUT 315#ifdef CONFIG_ETRAX_SERIAL_PORT1_DMA8_OUT
720 .dma_out_enabled = 1, 316 .dma_out_enabled = 1,
317 .dma_out_nbr = SER1_TX_DMA_NBR,
318 .dma_out_irq_nbr = SER1_DMA_TX_IRQ_NBR,
319 .dma_out_irq_flags = IRQF_DISABLED,
320 .dma_out_irq_description = "serial 1 dma tr",
721#else 321#else
722 .dma_out_enabled = 0, 322 .dma_out_enabled = 0,
323 .dma_out_nbr = UINT_MAX,
324 .dma_out_irq_nbr = 0,
325 .dma_out_irq_flags = 0,
326 .dma_out_irq_description = NULL,
723#endif 327#endif
724#ifdef CONFIG_ETRAX_SERIAL_PORT1_DMA9_IN 328#ifdef CONFIG_ETRAX_SERIAL_PORT1_DMA9_IN
725 .dma_in_enabled = 1, 329 .dma_in_enabled = 1,
330 .dma_in_nbr = SER1_RX_DMA_NBR,
331 .dma_in_irq_nbr = SER1_DMA_RX_IRQ_NBR,
332 .dma_in_irq_flags = IRQF_DISABLED,
333 .dma_in_irq_description = "serial 1 dma rec",
726#else 334#else
727 .dma_in_enabled = 0 335 .dma_in_enabled = 0,
336 .dma_in_enabled = 0,
337 .dma_in_nbr = UINT_MAX,
338 .dma_in_irq_nbr = 0,
339 .dma_in_irq_flags = 0,
340 .dma_in_irq_description = NULL,
728#endif 341#endif
729#else 342#else
730 .enabled = 0, 343 .enabled = 0,
344 .io_if_description = NULL,
345 .dma_in_irq_nbr = 0,
731 .dma_out_enabled = 0, 346 .dma_out_enabled = 0,
732 .dma_in_enabled = 0 347 .dma_in_enabled = 0
733#endif 348#endif
@@ -748,20 +363,40 @@ static struct e100_serial rs_table[] = {
748 .rx_ctrl = DEF_RX, 363 .rx_ctrl = DEF_RX,
749 .tx_ctrl = DEF_TX, 364 .tx_ctrl = DEF_TX,
750 .iseteop = 0, 365 .iseteop = 0,
366 .dma_owner = dma_ser2,
367 .io_if = if_serial_2,
751#ifdef CONFIG_ETRAX_SERIAL_PORT2 368#ifdef CONFIG_ETRAX_SERIAL_PORT2
752 .enabled = 1, 369 .enabled = 1,
370 .io_if_description = "ser2",
753#ifdef CONFIG_ETRAX_SERIAL_PORT2_DMA2_OUT 371#ifdef CONFIG_ETRAX_SERIAL_PORT2_DMA2_OUT
754 .dma_out_enabled = 1, 372 .dma_out_enabled = 1,
373 .dma_out_nbr = SER2_TX_DMA_NBR,
374 .dma_out_irq_nbr = SER2_DMA_TX_IRQ_NBR,
375 .dma_out_irq_flags = IRQF_DISABLED,
376 .dma_out_irq_description = "serial 2 dma tr",
755#else 377#else
756 .dma_out_enabled = 0, 378 .dma_out_enabled = 0,
379 .dma_out_nbr = UINT_MAX,
380 .dma_out_irq_nbr = 0,
381 .dma_out_irq_flags = 0,
382 .dma_out_irq_description = NULL,
757#endif 383#endif
758#ifdef CONFIG_ETRAX_SERIAL_PORT2_DMA3_IN 384#ifdef CONFIG_ETRAX_SERIAL_PORT2_DMA3_IN
759 .dma_in_enabled = 1, 385 .dma_in_enabled = 1,
386 .dma_in_nbr = SER2_RX_DMA_NBR,
387 .dma_in_irq_nbr = SER2_DMA_RX_IRQ_NBR,
388 .dma_in_irq_flags = IRQF_DISABLED,
389 .dma_in_irq_description = "serial 2 dma rec",
760#else 390#else
761 .dma_in_enabled = 0 391 .dma_in_enabled = 0,
392 .dma_in_nbr = UINT_MAX,
393 .dma_in_irq_nbr = 0,
394 .dma_in_irq_flags = 0,
395 .dma_in_irq_description = NULL,
762#endif 396#endif
763#else 397#else
764 .enabled = 0, 398 .enabled = 0,
399 .io_if_description = NULL,
765 .dma_out_enabled = 0, 400 .dma_out_enabled = 0,
766 .dma_in_enabled = 0 401 .dma_in_enabled = 0
767#endif 402#endif
@@ -782,20 +417,40 @@ static struct e100_serial rs_table[] = {
782 .rx_ctrl = DEF_RX, 417 .rx_ctrl = DEF_RX,
783 .tx_ctrl = DEF_TX, 418 .tx_ctrl = DEF_TX,
784 .iseteop = 1, 419 .iseteop = 1,
420 .dma_owner = dma_ser3,
421 .io_if = if_serial_3,
785#ifdef CONFIG_ETRAX_SERIAL_PORT3 422#ifdef CONFIG_ETRAX_SERIAL_PORT3
786 .enabled = 1, 423 .enabled = 1,
424 .io_if_description = "ser3",
787#ifdef CONFIG_ETRAX_SERIAL_PORT3_DMA4_OUT 425#ifdef CONFIG_ETRAX_SERIAL_PORT3_DMA4_OUT
788 .dma_out_enabled = 1, 426 .dma_out_enabled = 1,
427 .dma_out_nbr = SER3_TX_DMA_NBR,
428 .dma_out_irq_nbr = SER3_DMA_TX_IRQ_NBR,
429 .dma_out_irq_flags = IRQF_DISABLED,
430 .dma_out_irq_description = "serial 3 dma tr",
789#else 431#else
790 .dma_out_enabled = 0, 432 .dma_out_enabled = 0,
433 .dma_out_nbr = UINT_MAX,
434 .dma_out_irq_nbr = 0,
435 .dma_out_irq_flags = 0,
436 .dma_out_irq_description = NULL,
791#endif 437#endif
792#ifdef CONFIG_ETRAX_SERIAL_PORT3_DMA5_IN 438#ifdef CONFIG_ETRAX_SERIAL_PORT3_DMA5_IN
793 .dma_in_enabled = 1, 439 .dma_in_enabled = 1,
440 .dma_in_nbr = SER3_RX_DMA_NBR,
441 .dma_in_irq_nbr = SER3_DMA_RX_IRQ_NBR,
442 .dma_in_irq_flags = IRQF_DISABLED,
443 .dma_in_irq_description = "serial 3 dma rec",
794#else 444#else
795 .dma_in_enabled = 0 445 .dma_in_enabled = 0,
446 .dma_in_nbr = UINT_MAX,
447 .dma_in_irq_nbr = 0,
448 .dma_in_irq_flags = 0,
449 .dma_in_irq_description = NULL
796#endif 450#endif
797#else 451#else
798 .enabled = 0, 452 .enabled = 0,
453 .io_if_description = NULL,
799 .dma_out_enabled = 0, 454 .dma_out_enabled = 0,
800 .dma_in_enabled = 0 455 .dma_in_enabled = 0
801#endif 456#endif
@@ -1416,12 +1071,11 @@ e100_dtr(struct e100_serial *info, int set)
1416 { 1071 {
1417 unsigned long flags; 1072 unsigned long flags;
1418 1073
1419 save_flags(flags); 1074 local_irq_save(flags);
1420 cli();
1421 *e100_modem_pins[info->line].dtr_shadow &= ~mask; 1075 *e100_modem_pins[info->line].dtr_shadow &= ~mask;
1422 *e100_modem_pins[info->line].dtr_shadow |= (set ? 0 : mask); 1076 *e100_modem_pins[info->line].dtr_shadow |= (set ? 0 : mask);
1423 *e100_modem_pins[info->line].dtr_port = *e100_modem_pins[info->line].dtr_shadow; 1077 *e100_modem_pins[info->line].dtr_port = *e100_modem_pins[info->line].dtr_shadow;
1424 restore_flags(flags); 1078 local_irq_restore(flags);
1425 } 1079 }
1426 1080
1427#ifdef SERIAL_DEBUG_IO 1081#ifdef SERIAL_DEBUG_IO
@@ -1440,12 +1094,11 @@ e100_rts(struct e100_serial *info, int set)
1440{ 1094{
1441#ifndef CONFIG_SVINTO_SIM 1095#ifndef CONFIG_SVINTO_SIM
1442 unsigned long flags; 1096 unsigned long flags;
1443 save_flags(flags); 1097 local_irq_save(flags);
1444 cli();
1445 info->rx_ctrl &= ~E100_RTS_MASK; 1098 info->rx_ctrl &= ~E100_RTS_MASK;
1446 info->rx_ctrl |= (set ? 0 : E100_RTS_MASK); /* RTS is active low */ 1099 info->rx_ctrl |= (set ? 0 : E100_RTS_MASK); /* RTS is active low */
1447 info->port[REG_REC_CTRL] = info->rx_ctrl; 1100 info->port[REG_REC_CTRL] = info->rx_ctrl;
1448 restore_flags(flags); 1101 local_irq_restore(flags);
1449#ifdef SERIAL_DEBUG_IO 1102#ifdef SERIAL_DEBUG_IO
1450 printk("ser%i rts %i\n", info->line, set); 1103 printk("ser%i rts %i\n", info->line, set);
1451#endif 1104#endif
@@ -1463,12 +1116,11 @@ e100_ri_out(struct e100_serial *info, int set)
1463 unsigned char mask = e100_modem_pins[info->line].ri_mask; 1116 unsigned char mask = e100_modem_pins[info->line].ri_mask;
1464 unsigned long flags; 1117 unsigned long flags;
1465 1118
1466 save_flags(flags); 1119 local_irq_save(flags);
1467 cli();
1468 *e100_modem_pins[info->line].ri_shadow &= ~mask; 1120 *e100_modem_pins[info->line].ri_shadow &= ~mask;
1469 *e100_modem_pins[info->line].ri_shadow |= (set ? 0 : mask); 1121 *e100_modem_pins[info->line].ri_shadow |= (set ? 0 : mask);
1470 *e100_modem_pins[info->line].ri_port = *e100_modem_pins[info->line].ri_shadow; 1122 *e100_modem_pins[info->line].ri_port = *e100_modem_pins[info->line].ri_shadow;
1471 restore_flags(flags); 1123 local_irq_restore(flags);
1472 } 1124 }
1473#endif 1125#endif
1474} 1126}
@@ -1481,12 +1133,11 @@ e100_cd_out(struct e100_serial *info, int set)
1481 unsigned char mask = e100_modem_pins[info->line].cd_mask; 1133 unsigned char mask = e100_modem_pins[info->line].cd_mask;
1482 unsigned long flags; 1134 unsigned long flags;
1483 1135
1484 save_flags(flags); 1136 local_irq_save(flags);
1485 cli();
1486 *e100_modem_pins[info->line].cd_shadow &= ~mask; 1137 *e100_modem_pins[info->line].cd_shadow &= ~mask;
1487 *e100_modem_pins[info->line].cd_shadow |= (set ? 0 : mask); 1138 *e100_modem_pins[info->line].cd_shadow |= (set ? 0 : mask);
1488 *e100_modem_pins[info->line].cd_port = *e100_modem_pins[info->line].cd_shadow; 1139 *e100_modem_pins[info->line].cd_port = *e100_modem_pins[info->line].cd_shadow;
1489 restore_flags(flags); 1140 local_irq_restore(flags);
1490 } 1141 }
1491#endif 1142#endif
1492} 1143}
@@ -1560,8 +1211,7 @@ static void e100_disable_txdma_channel(struct e100_serial *info)
1560 /* Disable output DMA channel for the serial port in question 1211 /* Disable output DMA channel for the serial port in question
1561 * ( set to something other then serialX) 1212 * ( set to something other then serialX)
1562 */ 1213 */
1563 save_flags(flags); 1214 local_irq_save(flags);
1564 cli();
1565 DFLOW(DEBUG_LOG(info->line, "disable_txdma_channel %i\n", info->line)); 1215 DFLOW(DEBUG_LOG(info->line, "disable_txdma_channel %i\n", info->line));
1566 if (info->line == 0) { 1216 if (info->line == 0) {
1567 if ((genconfig_shadow & IO_MASK(R_GEN_CONFIG, dma6)) == 1217 if ((genconfig_shadow & IO_MASK(R_GEN_CONFIG, dma6)) ==
@@ -1589,7 +1239,7 @@ static void e100_disable_txdma_channel(struct e100_serial *info)
1589 } 1239 }
1590 } 1240 }
1591 *R_GEN_CONFIG = genconfig_shadow; 1241 *R_GEN_CONFIG = genconfig_shadow;
1592 restore_flags(flags); 1242 local_irq_restore(flags);
1593} 1243}
1594 1244
1595 1245
@@ -1597,8 +1247,7 @@ static void e100_enable_txdma_channel(struct e100_serial *info)
1597{ 1247{
1598 unsigned long flags; 1248 unsigned long flags;
1599 1249
1600 save_flags(flags); 1250 local_irq_save(flags);
1601 cli();
1602 DFLOW(DEBUG_LOG(info->line, "enable_txdma_channel %i\n", info->line)); 1251 DFLOW(DEBUG_LOG(info->line, "enable_txdma_channel %i\n", info->line));
1603 /* Enable output DMA channel for the serial port in question */ 1252 /* Enable output DMA channel for the serial port in question */
1604 if (info->line == 0) { 1253 if (info->line == 0) {
@@ -1615,7 +1264,7 @@ static void e100_enable_txdma_channel(struct e100_serial *info)
1615 genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma4, serial3); 1264 genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma4, serial3);
1616 } 1265 }
1617 *R_GEN_CONFIG = genconfig_shadow; 1266 *R_GEN_CONFIG = genconfig_shadow;
1618 restore_flags(flags); 1267 local_irq_restore(flags);
1619} 1268}
1620 1269
1621static void e100_disable_rxdma_channel(struct e100_serial *info) 1270static void e100_disable_rxdma_channel(struct e100_serial *info)
@@ -1625,8 +1274,7 @@ static void e100_disable_rxdma_channel(struct e100_serial *info)
1625 /* Disable input DMA channel for the serial port in question 1274 /* Disable input DMA channel for the serial port in question
1626 * ( set to something other then serialX) 1275 * ( set to something other then serialX)
1627 */ 1276 */
1628 save_flags(flags); 1277 local_irq_save(flags);
1629 cli();
1630 if (info->line == 0) { 1278 if (info->line == 0) {
1631 if ((genconfig_shadow & IO_MASK(R_GEN_CONFIG, dma7)) == 1279 if ((genconfig_shadow & IO_MASK(R_GEN_CONFIG, dma7)) ==
1632 IO_STATE(R_GEN_CONFIG, dma7, serial0)) { 1280 IO_STATE(R_GEN_CONFIG, dma7, serial0)) {
@@ -1653,7 +1301,7 @@ static void e100_disable_rxdma_channel(struct e100_serial *info)
1653 } 1301 }
1654 } 1302 }
1655 *R_GEN_CONFIG = genconfig_shadow; 1303 *R_GEN_CONFIG = genconfig_shadow;
1656 restore_flags(flags); 1304 local_irq_restore(flags);
1657} 1305}
1658 1306
1659 1307
@@ -1661,8 +1309,7 @@ static void e100_enable_rxdma_channel(struct e100_serial *info)
1661{ 1309{
1662 unsigned long flags; 1310 unsigned long flags;
1663 1311
1664 save_flags(flags); 1312 local_irq_save(flags);
1665 cli();
1666 /* Enable input DMA channel for the serial port in question */ 1313 /* Enable input DMA channel for the serial port in question */
1667 if (info->line == 0) { 1314 if (info->line == 0) {
1668 genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG, dma7); 1315 genconfig_shadow &= ~IO_MASK(R_GEN_CONFIG, dma7);
@@ -1678,7 +1325,7 @@ static void e100_enable_rxdma_channel(struct e100_serial *info)
1678 genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma5, serial3); 1325 genconfig_shadow |= IO_STATE(R_GEN_CONFIG, dma5, serial3);
1679 } 1326 }
1680 *R_GEN_CONFIG = genconfig_shadow; 1327 *R_GEN_CONFIG = genconfig_shadow;
1681 restore_flags(flags); 1328 local_irq_restore(flags);
1682} 1329}
1683 1330
1684#ifdef SERIAL_HANDLE_EARLY_ERRORS 1331#ifdef SERIAL_HANDLE_EARLY_ERRORS
@@ -1785,7 +1432,7 @@ e100_enable_rs485(struct tty_struct *tty,struct rs485_control *r)
1785} 1432}
1786 1433
1787static int 1434static int
1788e100_write_rs485(struct tty_struct *tty, int from_user, 1435e100_write_rs485(struct tty_struct *tty,
1789 const unsigned char *buf, int count) 1436 const unsigned char *buf, int count)
1790{ 1437{
1791 struct e100_serial * info = (struct e100_serial *)tty->driver_data; 1438 struct e100_serial * info = (struct e100_serial *)tty->driver_data;
@@ -1798,7 +1445,7 @@ e100_write_rs485(struct tty_struct *tty, int from_user,
1798 */ 1445 */
1799 info->rs485.enabled = 1; 1446 info->rs485.enabled = 1;
1800 /* rs_write now deals with RS485 if enabled */ 1447 /* rs_write now deals with RS485 if enabled */
1801 count = rs_write(tty, from_user, buf, count); 1448 count = rs_write(tty, buf, count);
1802 info->rs485.enabled = old_enabled; 1449 info->rs485.enabled = old_enabled;
1803 return count; 1450 return count;
1804} 1451}
@@ -1836,7 +1483,7 @@ rs_stop(struct tty_struct *tty)
1836 unsigned long flags; 1483 unsigned long flags;
1837 unsigned long xoff; 1484 unsigned long xoff;
1838 1485
1839 save_flags(flags); cli(); 1486 local_irq_save(flags);
1840 DFLOW(DEBUG_LOG(info->line, "XOFF rs_stop xmit %i\n", 1487 DFLOW(DEBUG_LOG(info->line, "XOFF rs_stop xmit %i\n",
1841 CIRC_CNT(info->xmit.head, 1488 CIRC_CNT(info->xmit.head,
1842 info->xmit.tail,SERIAL_XMIT_SIZE))); 1489 info->xmit.tail,SERIAL_XMIT_SIZE)));
@@ -1848,7 +1495,7 @@ rs_stop(struct tty_struct *tty)
1848 } 1495 }
1849 1496
1850 *((unsigned long *)&info->port[REG_XOFF]) = xoff; 1497 *((unsigned long *)&info->port[REG_XOFF]) = xoff;
1851 restore_flags(flags); 1498 local_irq_restore(flags);
1852 } 1499 }
1853} 1500}
1854 1501
@@ -1860,7 +1507,7 @@ rs_start(struct tty_struct *tty)
1860 unsigned long flags; 1507 unsigned long flags;
1861 unsigned long xoff; 1508 unsigned long xoff;
1862 1509
1863 save_flags(flags); cli(); 1510 local_irq_save(flags);
1864 DFLOW(DEBUG_LOG(info->line, "XOFF rs_start xmit %i\n", 1511 DFLOW(DEBUG_LOG(info->line, "XOFF rs_start xmit %i\n",
1865 CIRC_CNT(info->xmit.head, 1512 CIRC_CNT(info->xmit.head,
1866 info->xmit.tail,SERIAL_XMIT_SIZE))); 1513 info->xmit.tail,SERIAL_XMIT_SIZE)));
@@ -1875,7 +1522,7 @@ rs_start(struct tty_struct *tty)
1875 info->xmit.head != info->xmit.tail && info->xmit.buf) 1522 info->xmit.head != info->xmit.tail && info->xmit.buf)
1876 e100_enable_serial_tx_ready_irq(info); 1523 e100_enable_serial_tx_ready_irq(info);
1877 1524
1878 restore_flags(flags); 1525 local_irq_restore(flags);
1879 } 1526 }
1880} 1527}
1881 1528
@@ -2055,8 +1702,7 @@ static int serial_fast_timer_expired = 0;
2055static void flush_timeout_function(unsigned long data); 1702static void flush_timeout_function(unsigned long data);
2056#define START_FLUSH_FAST_TIMER_TIME(info, string, usec) {\ 1703#define START_FLUSH_FAST_TIMER_TIME(info, string, usec) {\
2057 unsigned long timer_flags; \ 1704 unsigned long timer_flags; \
2058 save_flags(timer_flags); \ 1705 local_irq_save(timer_flags); \
2059 cli(); \
2060 if (fast_timers[info->line].function == NULL) { \ 1706 if (fast_timers[info->line].function == NULL) { \
2061 serial_fast_timer_started++; \ 1707 serial_fast_timer_started++; \
2062 TIMERD(DEBUG_LOG(info->line, "start_timer %i ", info->line)); \ 1708 TIMERD(DEBUG_LOG(info->line, "start_timer %i ", info->line)); \
@@ -2070,7 +1716,7 @@ static void flush_timeout_function(unsigned long data);
2070 else { \ 1716 else { \
2071 TIMERD(DEBUG_LOG(info->line, "timer %i already running\n", info->line)); \ 1717 TIMERD(DEBUG_LOG(info->line, "timer %i already running\n", info->line)); \
2072 } \ 1718 } \
2073 restore_flags(timer_flags); \ 1719 local_irq_restore(timer_flags); \
2074} 1720}
2075#define START_FLUSH_FAST_TIMER(info, string) START_FLUSH_FAST_TIMER_TIME(info, string, info->flush_time_usec) 1721#define START_FLUSH_FAST_TIMER(info, string) START_FLUSH_FAST_TIMER_TIME(info, string, info->flush_time_usec)
2076 1722
@@ -2099,8 +1745,7 @@ append_recv_buffer(struct e100_serial *info, struct etrax_recv_buffer *buffer)
2099{ 1745{
2100 unsigned long flags; 1746 unsigned long flags;
2101 1747
2102 save_flags(flags); 1748 local_irq_save(flags);
2103 cli();
2104 1749
2105 if (!info->first_recv_buffer) 1750 if (!info->first_recv_buffer)
2106 info->first_recv_buffer = buffer; 1751 info->first_recv_buffer = buffer;
@@ -2113,7 +1758,7 @@ append_recv_buffer(struct e100_serial *info, struct etrax_recv_buffer *buffer)
2113 if (info->recv_cnt > info->max_recv_cnt) 1758 if (info->recv_cnt > info->max_recv_cnt)
2114 info->max_recv_cnt = info->recv_cnt; 1759 info->max_recv_cnt = info->recv_cnt;
2115 1760
2116 restore_flags(flags); 1761 local_irq_restore(flags);
2117} 1762}
2118 1763
2119static int 1764static int
@@ -2133,11 +1778,7 @@ add_char_and_flag(struct e100_serial *info, unsigned char data, unsigned char fl
2133 info->icount.rx++; 1778 info->icount.rx++;
2134 } else { 1779 } else {
2135 struct tty_struct *tty = info->tty; 1780 struct tty_struct *tty = info->tty;
2136 *tty->flip.char_buf_ptr = data; 1781 tty_insert_flip_char(tty, data, flag);
2137 *tty->flip.flag_buf_ptr = flag;
2138 tty->flip.flag_buf_ptr++;
2139 tty->flip.char_buf_ptr++;
2140 tty->flip.count++;
2141 info->icount.rx++; 1782 info->icount.rx++;
2142 } 1783 }
2143 1784
@@ -2322,7 +1963,6 @@ start_receive(struct e100_serial *info)
2322 */ 1963 */
2323 return; 1964 return;
2324#endif 1965#endif
2325 info->tty->flip.count = 0;
2326 if (info->uses_dma_in) { 1966 if (info->uses_dma_in) {
2327 /* reset the input dma channel to be sure it works */ 1967 /* reset the input dma channel to be sure it works */
2328 1968
@@ -2484,32 +2124,20 @@ static void flush_to_flip_buffer(struct e100_serial *info)
2484{ 2124{
2485 struct tty_struct *tty; 2125 struct tty_struct *tty;
2486 struct etrax_recv_buffer *buffer; 2126 struct etrax_recv_buffer *buffer;
2487 unsigned int length;
2488 unsigned long flags; 2127 unsigned long flags;
2489 int max_flip_size;
2490
2491 if (!info->first_recv_buffer)
2492 return;
2493 2128
2494 save_flags(flags); 2129 local_irq_save(flags);
2495 cli(); 2130 tty = info->tty;
2496 2131
2497 if (!(tty = info->tty)) { 2132 if (!tty) {
2498 restore_flags(flags); 2133 local_irq_restore(flags);
2499 return; 2134 return;
2500 } 2135 }
2501 2136
2502 while ((buffer = info->first_recv_buffer) != NULL) { 2137 while ((buffer = info->first_recv_buffer) != NULL) {
2503 unsigned int count = buffer->length; 2138 unsigned int count = buffer->length;
2504 2139
2505 count = tty_buffer_request_room(tty, count); 2140 tty_insert_flip_string(tty, buffer->buffer, count);
2506 if (count == 0) /* Throttle ?? */
2507 break;
2508
2509 if (count > 1)
2510 tty_insert_flip_strings(tty, buffer->buffer, count - 1);
2511 tty_insert_flip_char(tty, buffer->buffer[count-1], buffer->error);
2512
2513 info->recv_cnt -= count; 2141 info->recv_cnt -= count;
2514 2142
2515 if (count == buffer->length) { 2143 if (count == buffer->length) {
@@ -2525,18 +2153,9 @@ static void flush_to_flip_buffer(struct e100_serial *info)
2525 if (!info->first_recv_buffer) 2153 if (!info->first_recv_buffer)
2526 info->last_recv_buffer = NULL; 2154 info->last_recv_buffer = NULL;
2527 2155
2528 restore_flags(flags); 2156 local_irq_restore(flags);
2529
2530 DFLIP(
2531 if (1) {
2532 DEBUG_LOG(info->line, "*** rxtot %i\n", info->icount.rx);
2533 DEBUG_LOG(info->line, "ldisc %lu\n", tty->ldisc.chars_in_buffer(tty));
2534 DEBUG_LOG(info->line, "room %lu\n", tty->ldisc.receive_room(tty));
2535 }
2536 2157
2537 ); 2158 /* This includes a check for low-latency */
2538
2539 /* this includes a check for low-latency */
2540 tty_flip_buffer_push(tty); 2159 tty_flip_buffer_push(tty);
2541} 2160}
2542 2161
@@ -2679,21 +2298,7 @@ struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info)
2679 printk("!NO TTY!\n"); 2298 printk("!NO TTY!\n");
2680 return info; 2299 return info;
2681 } 2300 }
2682 if (tty->flip.count >= CRIS_BUF_SIZE - TTY_THRESHOLD_THROTTLE) { 2301
2683 /* check TTY_THROTTLED first so it indicates our state */
2684 if (!test_and_set_bit(TTY_THROTTLED, &tty->flags)) {
2685 DFLOW(DEBUG_LOG(info->line, "rs_throttle flip.count: %i\n", tty->flip.count));
2686 rs_throttle(tty);
2687 }
2688 }
2689 if (tty->flip.count >= CRIS_BUF_SIZE) {
2690 DEBUG_LOG(info->line, "force FLIP! %i\n", tty->flip.count);
2691 tty->flip.work.func((void *) tty);
2692 if (tty->flip.count >= CRIS_BUF_SIZE) {
2693 DEBUG_LOG(info->line, "FLIP FULL! %i\n", tty->flip.count);
2694 return info; /* if TTY_DONT_FLIP is set */
2695 }
2696 }
2697 /* Read data and status at the same time */ 2302 /* Read data and status at the same time */
2698 data_read = *((unsigned long *)&info->port[REG_DATA_STATUS32]); 2303 data_read = *((unsigned long *)&info->port[REG_DATA_STATUS32]);
2699more_data: 2304more_data:
@@ -2746,27 +2351,26 @@ more_data:
2746 DEBUG_LOG(info->line, "EBRK %i\n", info->break_detected_cnt); 2351 DEBUG_LOG(info->line, "EBRK %i\n", info->break_detected_cnt);
2747 info->errorcode = ERRCODE_INSERT_BREAK; 2352 info->errorcode = ERRCODE_INSERT_BREAK;
2748 } else { 2353 } else {
2354 unsigned char data = IO_EXTRACT(R_SERIAL0_READ,
2355 data_in, data_read);
2356 char flag = TTY_NORMAL;
2749 if (info->errorcode == ERRCODE_INSERT_BREAK) { 2357 if (info->errorcode == ERRCODE_INSERT_BREAK) {
2750 info->icount.brk++; 2358 struct tty_struct *tty = info->tty;
2751 *tty->flip.char_buf_ptr = 0; 2359 tty_insert_flip_char(tty, 0, flag);
2752 *tty->flip.flag_buf_ptr = TTY_BREAK;
2753 tty->flip.flag_buf_ptr++;
2754 tty->flip.char_buf_ptr++;
2755 tty->flip.count++;
2756 info->icount.rx++; 2360 info->icount.rx++;
2757 } 2361 }
2758 *tty->flip.char_buf_ptr = IO_EXTRACT(R_SERIAL0_READ, data_in, data_read);
2759 2362
2760 if (data_read & IO_MASK(R_SERIAL0_READ, par_err)) { 2363 if (data_read & IO_MASK(R_SERIAL0_READ, par_err)) {
2761 info->icount.parity++; 2364 info->icount.parity++;
2762 *tty->flip.flag_buf_ptr = TTY_PARITY; 2365 flag = TTY_PARITY;
2763 } else if (data_read & IO_MASK(R_SERIAL0_READ, overrun)) { 2366 } else if (data_read & IO_MASK(R_SERIAL0_READ, overrun)) {
2764 info->icount.overrun++; 2367 info->icount.overrun++;
2765 *tty->flip.flag_buf_ptr = TTY_OVERRUN; 2368 flag = TTY_OVERRUN;
2766 } else if (data_read & IO_MASK(R_SERIAL0_READ, framing_err)) { 2369 } else if (data_read & IO_MASK(R_SERIAL0_READ, framing_err)) {
2767 info->icount.frame++; 2370 info->icount.frame++;
2768 *tty->flip.flag_buf_ptr = TTY_FRAME; 2371 flag = TTY_FRAME;
2769 } 2372 }
2373 tty_insert_flip_char(tty, data, flag);
2770 info->errorcode = 0; 2374 info->errorcode = 0;
2771 } 2375 }
2772 info->break_detected_cnt = 0; 2376 info->break_detected_cnt = 0;
@@ -2782,16 +2386,14 @@ more_data:
2782 log_int(rdpc(), 0, 0); 2386 log_int(rdpc(), 0, 0);
2783 } 2387 }
2784 ); 2388 );
2785 *tty->flip.char_buf_ptr = IO_EXTRACT(R_SERIAL0_READ, data_in, data_read); 2389 tty_insert_flip_char(tty,
2786 *tty->flip.flag_buf_ptr = 0; 2390 IO_EXTRACT(R_SERIAL0_READ, data_in, data_read),
2391 TTY_NORMAL);
2787 } else { 2392 } else {
2788 DEBUG_LOG(info->line, "ser_rx int but no data_avail %08lX\n", data_read); 2393 DEBUG_LOG(info->line, "ser_rx int but no data_avail %08lX\n", data_read);
2789 } 2394 }
2790 2395
2791 2396
2792 tty->flip.flag_buf_ptr++;
2793 tty->flip.char_buf_ptr++;
2794 tty->flip.count++;
2795 info->icount.rx++; 2397 info->icount.rx++;
2796 data_read = *((unsigned long *)&info->port[REG_DATA_STATUS32]); 2398 data_read = *((unsigned long *)&info->port[REG_DATA_STATUS32]);
2797 if (data_read & IO_MASK(R_SERIAL0_READ, data_avail)) { 2399 if (data_read & IO_MASK(R_SERIAL0_READ, data_avail)) {
@@ -2929,7 +2531,7 @@ static void handle_ser_tx_interrupt(struct e100_serial *info)
2929 if (info->x_char) { 2531 if (info->x_char) {
2930 unsigned char rstat; 2532 unsigned char rstat;
2931 DFLOW(DEBUG_LOG(info->line, "tx_int: xchar 0x%02X\n", info->x_char)); 2533 DFLOW(DEBUG_LOG(info->line, "tx_int: xchar 0x%02X\n", info->x_char));
2932 save_flags(flags); cli(); 2534 local_irq_save(flags);
2933 rstat = info->port[REG_STATUS]; 2535 rstat = info->port[REG_STATUS];
2934 DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat)); 2536 DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat));
2935 2537
@@ -2938,7 +2540,7 @@ static void handle_ser_tx_interrupt(struct e100_serial *info)
2938 info->x_char = 0; 2540 info->x_char = 0;
2939 /* We must enable since it is disabled in ser_interrupt */ 2541 /* We must enable since it is disabled in ser_interrupt */
2940 e100_enable_serial_tx_ready_irq(info); 2542 e100_enable_serial_tx_ready_irq(info);
2941 restore_flags(flags); 2543 local_irq_restore(flags);
2942 return; 2544 return;
2943 } 2545 }
2944 if (info->uses_dma_out) { 2546 if (info->uses_dma_out) {
@@ -2946,7 +2548,7 @@ static void handle_ser_tx_interrupt(struct e100_serial *info)
2946 int i; 2548 int i;
2947 /* We only use normal tx interrupt when sending x_char */ 2549 /* We only use normal tx interrupt when sending x_char */
2948 DFLOW(DEBUG_LOG(info->line, "tx_int: xchar sent\n", 0)); 2550 DFLOW(DEBUG_LOG(info->line, "tx_int: xchar sent\n", 0));
2949 save_flags(flags); cli(); 2551 local_irq_save(flags);
2950 rstat = info->port[REG_STATUS]; 2552 rstat = info->port[REG_STATUS];
2951 DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat)); 2553 DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat));
2952 e100_disable_serial_tx_ready_irq(info); 2554 e100_disable_serial_tx_ready_irq(info);
@@ -2959,7 +2561,7 @@ static void handle_ser_tx_interrupt(struct e100_serial *info)
2959 nop(); 2561 nop();
2960 2562
2961 *info->ocmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, continue); 2563 *info->ocmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, continue);
2962 restore_flags(flags); 2564 local_irq_restore(flags);
2963 return; 2565 return;
2964 } 2566 }
2965 /* Normal char-by-char interrupt */ 2567 /* Normal char-by-char interrupt */
@@ -2973,7 +2575,7 @@ static void handle_ser_tx_interrupt(struct e100_serial *info)
2973 } 2575 }
2974 DINTR2(DEBUG_LOG(info->line, "tx_int %c\n", info->xmit.buf[info->xmit.tail])); 2576 DINTR2(DEBUG_LOG(info->line, "tx_int %c\n", info->xmit.buf[info->xmit.tail]));
2975 /* Send a byte, rs485 timing is critical so turn of ints */ 2577 /* Send a byte, rs485 timing is critical so turn of ints */
2976 save_flags(flags); cli(); 2578 local_irq_save(flags);
2977 info->port[REG_TR_DATA] = info->xmit.buf[info->xmit.tail]; 2579 info->port[REG_TR_DATA] = info->xmit.buf[info->xmit.tail];
2978 info->xmit.tail = (info->xmit.tail + 1) & (SERIAL_XMIT_SIZE-1); 2580 info->xmit.tail = (info->xmit.tail + 1) & (SERIAL_XMIT_SIZE-1);
2979 info->icount.tx++; 2581 info->icount.tx++;
@@ -2997,7 +2599,7 @@ static void handle_ser_tx_interrupt(struct e100_serial *info)
2997 /* We must enable since it is disabled in ser_interrupt */ 2599 /* We must enable since it is disabled in ser_interrupt */
2998 e100_enable_serial_tx_ready_irq(info); 2600 e100_enable_serial_tx_ready_irq(info);
2999 } 2601 }
3000 restore_flags(flags); 2602 local_irq_restore(flags);
3001 2603
3002 if (CIRC_CNT(info->xmit.head, 2604 if (CIRC_CNT(info->xmit.head,
3003 info->xmit.tail, 2605 info->xmit.tail,
@@ -3022,7 +2624,7 @@ ser_interrupt(int irq, void *dev_id)
3022 int handled = 0; 2624 int handled = 0;
3023 static volatile unsigned long reentered_ready_mask = 0; 2625 static volatile unsigned long reentered_ready_mask = 0;
3024 2626
3025 save_flags(flags); cli(); 2627 local_irq_save(flags);
3026 irq_mask1_rd = *R_IRQ_MASK1_RD; 2628 irq_mask1_rd = *R_IRQ_MASK1_RD;
3027 /* First handle all rx interrupts with ints disabled */ 2629 /* First handle all rx interrupts with ints disabled */
3028 info = rs_table; 2630 info = rs_table;
@@ -3067,7 +2669,7 @@ ser_interrupt(int irq, void *dev_id)
3067 /* Unblock the serial interrupt */ 2669 /* Unblock the serial interrupt */
3068 *R_VECT_MASK_SET = IO_STATE(R_VECT_MASK_SET, serial, set); 2670 *R_VECT_MASK_SET = IO_STATE(R_VECT_MASK_SET, serial, set);
3069 2671
3070 sti(); 2672 local_irq_enable();
3071 ready_mask = (1 << (8+1+2*0)); /* ser0 tr_ready */ 2673 ready_mask = (1 << (8+1+2*0)); /* ser0 tr_ready */
3072 info = rs_table; 2674 info = rs_table;
3073 for (i = 0; i < NR_PORTS; i++) { 2675 for (i = 0; i < NR_PORTS; i++) {
@@ -3080,11 +2682,11 @@ ser_interrupt(int irq, void *dev_id)
3080 ready_mask <<= 2; 2682 ready_mask <<= 2;
3081 } 2683 }
3082 /* handle_ser_tx_interrupt enables tr_ready interrupts */ 2684 /* handle_ser_tx_interrupt enables tr_ready interrupts */
3083 cli(); 2685 local_irq_disable();
3084 /* Handle reentered TX interrupt */ 2686 /* Handle reentered TX interrupt */
3085 irq_mask1_rd = reentered_ready_mask; 2687 irq_mask1_rd = reentered_ready_mask;
3086 } 2688 }
3087 cli(); 2689 local_irq_disable();
3088 tx_started = 0; 2690 tx_started = 0;
3089 } else { 2691 } else {
3090 unsigned long ready_mask; 2692 unsigned long ready_mask;
@@ -3100,7 +2702,7 @@ ser_interrupt(int irq, void *dev_id)
3100 } 2702 }
3101 } 2703 }
3102 2704
3103 restore_flags(flags); 2705 local_irq_restore(flags);
3104 return IRQ_RETVAL(handled); 2706 return IRQ_RETVAL(handled);
3105} /* ser_interrupt */ 2707} /* ser_interrupt */
3106#endif 2708#endif
@@ -3121,11 +2723,13 @@ ser_interrupt(int irq, void *dev_id)
3121 * them using rs_sched_event(), and they get done here. 2723 * them using rs_sched_event(), and they get done here.
3122 */ 2724 */
3123static void 2725static void
3124do_softint(void *private_) 2726do_softint(struct work_struct *work)
3125{ 2727{
3126 struct e100_serial *info = (struct e100_serial *) private_; 2728 struct e100_serial *info;
3127 struct tty_struct *tty; 2729 struct tty_struct *tty;
3128 2730
2731 info = container_of(work, struct e100_serial, work);
2732
3129 tty = info->tty; 2733 tty = info->tty;
3130 if (!tty) 2734 if (!tty)
3131 return; 2735 return;
@@ -3145,13 +2749,12 @@ startup(struct e100_serial * info)
3145 if (!xmit_page) 2749 if (!xmit_page)
3146 return -ENOMEM; 2750 return -ENOMEM;
3147 2751
3148 save_flags(flags); 2752 local_irq_save(flags);
3149 cli();
3150 2753
3151 /* if it was already initialized, skip this */ 2754 /* if it was already initialized, skip this */
3152 2755
3153 if (info->flags & ASYNC_INITIALIZED) { 2756 if (info->flags & ASYNC_INITIALIZED) {
3154 restore_flags(flags); 2757 local_irq_restore(flags);
3155 free_page(xmit_page); 2758 free_page(xmit_page);
3156 return 0; 2759 return 0;
3157 } 2760 }
@@ -3277,7 +2880,7 @@ startup(struct e100_serial * info)
3277 2880
3278 info->flags |= ASYNC_INITIALIZED; 2881 info->flags |= ASYNC_INITIALIZED;
3279 2882
3280 restore_flags(flags); 2883 local_irq_restore(flags);
3281 return 0; 2884 return 0;
3282} 2885}
3283 2886
@@ -3328,8 +2931,7 @@ shutdown(struct e100_serial * info)
3328 info->irq); 2931 info->irq);
3329#endif 2932#endif
3330 2933
3331 save_flags(flags); 2934 local_irq_save(flags);
3332 cli(); /* Disable interrupts */
3333 2935
3334 if (info->xmit.buf) { 2936 if (info->xmit.buf) {
3335 free_page((unsigned long)info->xmit.buf); 2937 free_page((unsigned long)info->xmit.buf);
@@ -3353,7 +2955,7 @@ shutdown(struct e100_serial * info)
3353 set_bit(TTY_IO_ERROR, &info->tty->flags); 2955 set_bit(TTY_IO_ERROR, &info->tty->flags);
3354 2956
3355 info->flags &= ~ASYNC_INITIALIZED; 2957 info->flags &= ~ASYNC_INITIALIZED;
3356 restore_flags(flags); 2958 local_irq_restore(flags);
3357} 2959}
3358 2960
3359 2961
@@ -3411,7 +3013,6 @@ change_speed(struct e100_serial *info)
3411 DBAUD(printk("using external baudrate: %lu\n", CONFIG_ETRAX_EXTERN_PB6CLK_FREQ/8)); 3013 DBAUD(printk("using external baudrate: %lu\n", CONFIG_ETRAX_EXTERN_PB6CLK_FREQ/8));
3412 info->baud = CONFIG_ETRAX_EXTERN_PB6CLK_FREQ/8; 3014 info->baud = CONFIG_ETRAX_EXTERN_PB6CLK_FREQ/8;
3413 } 3015 }
3414 }
3415#endif 3016#endif
3416 else 3017 else
3417 { 3018 {
@@ -3445,8 +3046,7 @@ change_speed(struct e100_serial *info)
3445 3046
3446#ifndef CONFIG_SVINTO_SIM 3047#ifndef CONFIG_SVINTO_SIM
3447 /* start with default settings and then fill in changes */ 3048 /* start with default settings and then fill in changes */
3448 save_flags(flags); 3049 local_irq_save(flags);
3449 cli();
3450 /* 8 bit, no/even parity */ 3050 /* 8 bit, no/even parity */
3451 info->rx_ctrl &= ~(IO_MASK(R_SERIAL0_REC_CTRL, rec_bitnr) | 3051 info->rx_ctrl &= ~(IO_MASK(R_SERIAL0_REC_CTRL, rec_bitnr) |
3452 IO_MASK(R_SERIAL0_REC_CTRL, rec_par_en) | 3052 IO_MASK(R_SERIAL0_REC_CTRL, rec_par_en) |
@@ -3510,7 +3110,7 @@ change_speed(struct e100_serial *info)
3510 } 3110 }
3511 3111
3512 *((unsigned long *)&info->port[REG_XOFF]) = xoff; 3112 *((unsigned long *)&info->port[REG_XOFF]) = xoff;
3513 restore_flags(flags); 3113 local_irq_restore(flags);
3514#endif /* !CONFIG_SVINTO_SIM */ 3114#endif /* !CONFIG_SVINTO_SIM */
3515 3115
3516 update_char_time(info); 3116 update_char_time(info);
@@ -3538,13 +3138,12 @@ rs_flush_chars(struct tty_struct *tty)
3538 3138
3539 /* this protection might not exactly be necessary here */ 3139 /* this protection might not exactly be necessary here */
3540 3140
3541 save_flags(flags); 3141 local_irq_save(flags);
3542 cli();
3543 start_transmit(info); 3142 start_transmit(info);
3544 restore_flags(flags); 3143 local_irq_restore(flags);
3545} 3144}
3546 3145
3547static int rs_raw_write(struct tty_struct * tty, int from_user, 3146static int rs_raw_write(struct tty_struct *tty,
3548 const unsigned char *buf, int count) 3147 const unsigned char *buf, int count)
3549{ 3148{
3550 int c, ret = 0; 3149 int c, ret = 0;
@@ -3567,53 +3166,19 @@ static int rs_raw_write(struct tty_struct * tty, int from_user,
3567 SIMCOUT(buf, count); 3166 SIMCOUT(buf, count);
3568 return count; 3167 return count;
3569#endif 3168#endif
3570 save_flags(flags); 3169 local_save_flags(flags);
3571 DFLOW(DEBUG_LOG(info->line, "write count %i ", count)); 3170 DFLOW(DEBUG_LOG(info->line, "write count %i ", count));
3572 DFLOW(DEBUG_LOG(info->line, "ldisc %i\n", tty->ldisc.chars_in_buffer(tty))); 3171 DFLOW(DEBUG_LOG(info->line, "ldisc %i\n", tty->ldisc.chars_in_buffer(tty)));
3573 3172
3574 3173
3575 /* the cli/restore_flags pairs below are needed because the 3174 /* The local_irq_disable/restore_flags pairs below are needed
3576 * DMA interrupt handler moves the info->xmit values. the memcpy 3175 * because the DMA interrupt handler moves the info->xmit values.
3577 * needs to be in the critical region unfortunately, because we 3176 * the memcpy needs to be in the critical region unfortunately,
3578 * need to read xmit values, memcpy, write xmit values in one 3177 * because we need to read xmit values, memcpy, write xmit values
3579 * atomic operation... this could perhaps be avoided by more clever 3178 * in one atomic operation... this could perhaps be avoided by
3580 * design. 3179 * more clever design.
3581 */ 3180 */
3582 if (from_user) { 3181 local_irq_disable();
3583 mutex_lock(&tmp_buf_mutex);
3584 while (1) {
3585 int c1;
3586 c = CIRC_SPACE_TO_END(info->xmit.head,
3587 info->xmit.tail,
3588 SERIAL_XMIT_SIZE);
3589 if (count < c)
3590 c = count;
3591 if (c <= 0)
3592 break;
3593
3594 c -= copy_from_user(tmp_buf, buf, c);
3595 if (!c) {
3596 if (!ret)
3597 ret = -EFAULT;
3598 break;
3599 }
3600 cli();
3601 c1 = CIRC_SPACE_TO_END(info->xmit.head,
3602 info->xmit.tail,
3603 SERIAL_XMIT_SIZE);
3604 if (c1 < c)
3605 c = c1;
3606 memcpy(info->xmit.buf + info->xmit.head, tmp_buf, c);
3607 info->xmit.head = ((info->xmit.head + c) &
3608 (SERIAL_XMIT_SIZE-1));
3609 restore_flags(flags);
3610 buf += c;
3611 count -= c;
3612 ret += c;
3613 }
3614 mutex_unlock(&tmp_buf_mutex);
3615 } else {
3616 cli();
3617 while (count) { 3182 while (count) {
3618 c = CIRC_SPACE_TO_END(info->xmit.head, 3183 c = CIRC_SPACE_TO_END(info->xmit.head,
3619 info->xmit.tail, 3184 info->xmit.tail,
@@ -3631,8 +3196,7 @@ static int rs_raw_write(struct tty_struct * tty, int from_user,
3631 count -= c; 3196 count -= c;
3632 ret += c; 3197 ret += c;
3633 } 3198 }
3634 restore_flags(flags); 3199 local_irq_restore(flags);
3635 }
3636 3200
3637 /* enable transmitter if not running, unless the tty is stopped 3201 /* enable transmitter if not running, unless the tty is stopped
3638 * this does not need IRQ protection since if tr_running == 0 3202 * this does not need IRQ protection since if tr_running == 0
@@ -3651,7 +3215,7 @@ static int rs_raw_write(struct tty_struct * tty, int from_user,
3651} /* raw_raw_write() */ 3215} /* raw_raw_write() */
3652 3216
3653static int 3217static int
3654rs_write(struct tty_struct * tty, int from_user, 3218rs_write(struct tty_struct *tty,
3655 const unsigned char *buf, int count) 3219 const unsigned char *buf, int count)
3656{ 3220{
3657#if defined(CONFIG_ETRAX_RS485) 3221#if defined(CONFIG_ETRAX_RS485)
@@ -3678,7 +3242,7 @@ rs_write(struct tty_struct * tty, int from_user,
3678 } 3242 }
3679#endif /* CONFIG_ETRAX_RS485 */ 3243#endif /* CONFIG_ETRAX_RS485 */
3680 3244
3681 count = rs_raw_write(tty, from_user, buf, count); 3245 count = rs_raw_write(tty, buf, count);
3682 3246
3683#if defined(CONFIG_ETRAX_RS485) 3247#if defined(CONFIG_ETRAX_RS485)
3684 if (info->rs485.enabled) 3248 if (info->rs485.enabled)
@@ -3746,10 +3310,9 @@ rs_flush_buffer(struct tty_struct *tty)
3746 struct e100_serial *info = (struct e100_serial *)tty->driver_data; 3310 struct e100_serial *info = (struct e100_serial *)tty->driver_data;
3747 unsigned long flags; 3311 unsigned long flags;
3748 3312
3749 save_flags(flags); 3313 local_irq_save(flags);
3750 cli();
3751 info->xmit.head = info->xmit.tail = 0; 3314 info->xmit.head = info->xmit.tail = 0;
3752 restore_flags(flags); 3315 local_irq_restore(flags);
3753 3316
3754 tty_wakeup(tty); 3317 tty_wakeup(tty);
3755} 3318}
@@ -3767,7 +3330,7 @@ static void rs_send_xchar(struct tty_struct *tty, char ch)
3767{ 3330{
3768 struct e100_serial *info = (struct e100_serial *)tty->driver_data; 3331 struct e100_serial *info = (struct e100_serial *)tty->driver_data;
3769 unsigned long flags; 3332 unsigned long flags;
3770 save_flags(flags); cli(); 3333 local_irq_save(flags);
3771 if (info->uses_dma_out) { 3334 if (info->uses_dma_out) {
3772 /* Put the DMA on hold and disable the channel */ 3335 /* Put the DMA on hold and disable the channel */
3773 *info->ocmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, hold); 3336 *info->ocmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, hold);
@@ -3784,7 +3347,7 @@ static void rs_send_xchar(struct tty_struct *tty, char ch)
3784 DFLOW(DEBUG_LOG(info->line, "rs_send_xchar 0x%02X\n", ch)); 3347 DFLOW(DEBUG_LOG(info->line, "rs_send_xchar 0x%02X\n", ch));
3785 info->x_char = ch; 3348 info->x_char = ch;
3786 e100_enable_serial_tx_ready_irq(info); 3349 e100_enable_serial_tx_ready_irq(info);
3787 restore_flags(flags); 3350 local_irq_restore(flags);
3788} 3351}
3789 3352
3790/* 3353/*
@@ -3996,21 +3559,61 @@ char *get_control_state_str(int MLines, char *s)
3996} 3559}
3997#endif 3560#endif
3998 3561
3562static void
3563rs_break(struct tty_struct *tty, int break_state)
3564{
3565 struct e100_serial *info = (struct e100_serial *)tty->driver_data;
3566 unsigned long flags;
3567
3568 if (!info->port)
3569 return;
3570
3571 local_irq_save(flags);
3572 if (break_state == -1) {
3573 /* Go to manual mode and set the txd pin to 0 */
3574 /* Clear bit 7 (txd) and 6 (tr_enable) */
3575 info->tx_ctrl &= 0x3F;
3576 } else {
3577 /* Set bit 7 (txd) and 6 (tr_enable) */
3578 info->tx_ctrl |= (0x80 | 0x40);
3579 }
3580 info->port[REG_TR_CTRL] = info->tx_ctrl;
3581 local_irq_restore(flags);
3582}
3583
3999static int 3584static int
4000get_modem_info(struct e100_serial * info, unsigned int *value) 3585rs_tiocmset(struct tty_struct *tty, struct file *file,
3586 unsigned int set, unsigned int clear)
4001{ 3587{
4002 unsigned int result; 3588 struct e100_serial *info = (struct e100_serial *)tty->driver_data;
4003 /* Polarity isn't verified */
4004#if 0 /*def SERIAL_DEBUG_IO */
4005 3589
4006 printk("get_modem_info: RTS: %i DTR: %i CD: %i RI: %i DSR: %i CTS: %i\n", 3590 if (clear & TIOCM_RTS)
4007 E100_RTS_GET(info), 3591 e100_rts(info, 0);
4008 E100_DTR_GET(info), 3592 if (clear & TIOCM_DTR)
4009 E100_CD_GET(info), 3593 e100_dtr(info, 0);
4010 E100_RI_GET(info), 3594 /* Handle FEMALE behaviour */
4011 E100_DSR_GET(info), 3595 if (clear & TIOCM_RI)
4012 E100_CTS_GET(info)); 3596 e100_ri_out(info, 0);
4013#endif 3597 if (clear & TIOCM_CD)
3598 e100_cd_out(info, 0);
3599
3600 if (set & TIOCM_RTS)
3601 e100_rts(info, 1);
3602 if (set & TIOCM_DTR)
3603 e100_dtr(info, 1);
3604 /* Handle FEMALE behaviour */
3605 if (set & TIOCM_RI)
3606 e100_ri_out(info, 1);
3607 if (set & TIOCM_CD)
3608 e100_cd_out(info, 1);
3609 return 0;
3610}
3611
3612static int
3613rs_tiocmget(struct tty_struct *tty, struct file *file)
3614{
3615 struct e100_serial *info = (struct e100_serial *)tty->driver_data;
3616 unsigned int result;
4014 3617
4015 result = 3618 result =
4016 (!E100_RTS_GET(info) ? TIOCM_RTS : 0) 3619 (!E100_RTS_GET(info) ? TIOCM_RTS : 0)
@@ -4021,95 +3624,20 @@ get_modem_info(struct e100_serial * info, unsigned int *value)
4021 | (!E100_CTS_GET(info) ? TIOCM_CTS : 0); 3624 | (!E100_CTS_GET(info) ? TIOCM_CTS : 0);
4022 3625
4023#ifdef SERIAL_DEBUG_IO 3626#ifdef SERIAL_DEBUG_IO
4024 printk("e100ser: modem state: %i 0x%08X\n", result, result); 3627 printk(KERN_DEBUG "ser%i: modem state: %i 0x%08X\n",
3628 info->line, result, result);
4025 { 3629 {
4026 char s[100]; 3630 char s[100];
4027 3631
4028 get_control_state_str(result, s); 3632 get_control_state_str(result, s);
4029 printk("state: %s\n", s); 3633 printk(KERN_DEBUG "state: %s\n", s);
4030 } 3634 }
4031#endif 3635#endif
4032 if (copy_to_user(value, &result, sizeof(int))) 3636 return result;
4033 return -EFAULT;
4034 return 0;
4035}
4036 3637
4037
4038static int
4039set_modem_info(struct e100_serial * info, unsigned int cmd,
4040 unsigned int *value)
4041{
4042 unsigned int arg;
4043
4044 if (copy_from_user(&arg, value, sizeof(int)))
4045 return -EFAULT;
4046
4047 switch (cmd) {
4048 case TIOCMBIS:
4049 if (arg & TIOCM_RTS) {
4050 e100_rts(info, 1);
4051 }
4052 if (arg & TIOCM_DTR) {
4053 e100_dtr(info, 1);
4054 }
4055 /* Handle FEMALE behaviour */
4056 if (arg & TIOCM_RI) {
4057 e100_ri_out(info, 1);
4058 }
4059 if (arg & TIOCM_CD) {
4060 e100_cd_out(info, 1);
4061 }
4062 break;
4063 case TIOCMBIC:
4064 if (arg & TIOCM_RTS) {
4065 e100_rts(info, 0);
4066 }
4067 if (arg & TIOCM_DTR) {
4068 e100_dtr(info, 0);
4069 }
4070 /* Handle FEMALE behaviour */
4071 if (arg & TIOCM_RI) {
4072 e100_ri_out(info, 0);
4073 }
4074 if (arg & TIOCM_CD) {
4075 e100_cd_out(info, 0);
4076 }
4077 break;
4078 case TIOCMSET:
4079 e100_rts(info, arg & TIOCM_RTS);
4080 e100_dtr(info, arg & TIOCM_DTR);
4081 /* Handle FEMALE behaviour */
4082 e100_ri_out(info, arg & TIOCM_RI);
4083 e100_cd_out(info, arg & TIOCM_CD);
4084 break;
4085 default:
4086 return -EINVAL;
4087 }
4088 return 0;
4089} 3638}
4090 3639
4091 3640
4092static void
4093rs_break(struct tty_struct *tty, int break_state)
4094{
4095 struct e100_serial * info = (struct e100_serial *)tty->driver_data;
4096 unsigned long flags;
4097
4098 if (!info->port)
4099 return;
4100
4101 save_flags(flags);
4102 cli();
4103 if (break_state == -1) {
4104 /* Go to manual mode and set the txd pin to 0 */
4105 info->tx_ctrl &= 0x3F; /* Clear bit 7 (txd) and 6 (tr_enable) */
4106 } else {
4107 info->tx_ctrl |= (0x80 | 0x40); /* Set bit 7 (txd) and 6 (tr_enable) */
4108 }
4109 info->port[REG_TR_CTRL] = info->tx_ctrl;
4110 restore_flags(flags);
4111}
4112
4113static int 3641static int
4114rs_ioctl(struct tty_struct *tty, struct file * file, 3642rs_ioctl(struct tty_struct *tty, struct file * file,
4115 unsigned int cmd, unsigned long arg) 3643 unsigned int cmd, unsigned long arg)
@@ -4124,49 +3652,45 @@ rs_ioctl(struct tty_struct *tty, struct file * file,
4124 } 3652 }
4125 3653
4126 switch (cmd) { 3654 switch (cmd) {
4127 case TIOCMGET: 3655 case TIOCGSERIAL:
4128 return get_modem_info(info, (unsigned int *) arg); 3656 return get_serial_info(info,
4129 case TIOCMBIS: 3657 (struct serial_struct *) arg);
4130 case TIOCMBIC: 3658 case TIOCSSERIAL:
4131 case TIOCMSET: 3659 return set_serial_info(info,
4132 return set_modem_info(info, cmd, (unsigned int *) arg); 3660 (struct serial_struct *) arg);
4133 case TIOCGSERIAL: 3661 case TIOCSERGETLSR: /* Get line status register */
4134 return get_serial_info(info, 3662 return get_lsr_info(info, (unsigned int *) arg);
4135 (struct serial_struct *) arg); 3663
4136 case TIOCSSERIAL: 3664 case TIOCSERGSTRUCT:
4137 return set_serial_info(info, 3665 if (copy_to_user((struct e100_serial *) arg,
4138 (struct serial_struct *) arg); 3666 info, sizeof(struct e100_serial)))
4139 case TIOCSERGETLSR: /* Get line status register */ 3667 return -EFAULT;
4140 return get_lsr_info(info, (unsigned int *) arg); 3668 return 0;
4141
4142 case TIOCSERGSTRUCT:
4143 if (copy_to_user((struct e100_serial *) arg,
4144 info, sizeof(struct e100_serial)))
4145 return -EFAULT;
4146 return 0;
4147 3669
4148#if defined(CONFIG_ETRAX_RS485) 3670#if defined(CONFIG_ETRAX_RS485)
4149 case TIOCSERSETRS485: 3671 case TIOCSERSETRS485:
4150 { 3672 {
4151 struct rs485_control rs485ctrl; 3673 struct rs485_control rs485ctrl;
4152 if (copy_from_user(&rs485ctrl, (struct rs485_control*)arg, sizeof(rs485ctrl))) 3674 if (copy_from_user(&rs485ctrl, (struct rs485_control *)arg,
4153 return -EFAULT; 3675 sizeof(rs485ctrl)))
3676 return -EFAULT;
4154 3677
4155 return e100_enable_rs485(tty, &rs485ctrl); 3678 return e100_enable_rs485(tty, &rs485ctrl);
4156 } 3679 }
4157 3680
4158 case TIOCSERWRRS485: 3681 case TIOCSERWRRS485:
4159 { 3682 {
4160 struct rs485_write rs485wr; 3683 struct rs485_write rs485wr;
4161 if (copy_from_user(&rs485wr, (struct rs485_write*)arg, sizeof(rs485wr))) 3684 if (copy_from_user(&rs485wr, (struct rs485_write *)arg,
4162 return -EFAULT; 3685 sizeof(rs485wr)))
3686 return -EFAULT;
4163 3687
4164 return e100_write_rs485(tty, 1, rs485wr.outc, rs485wr.outc_size); 3688 return e100_write_rs485(tty, rs485wr.outc, rs485wr.outc_size);
4165 } 3689 }
4166#endif 3690#endif
4167 3691
4168 default: 3692 default:
4169 return -ENOIOCTLCMD; 3693 return -ENOIOCTLCMD;
4170 } 3694 }
4171 return 0; 3695 return 0;
4172} 3696}
@@ -4191,46 +3715,6 @@ rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
4191 3715
4192} 3716}
4193 3717
4194/* In debugport.c - register a console write function that uses the normal
4195 * serial driver
4196 */
4197typedef int (*debugport_write_function)(int i, const char *buf, unsigned int len);
4198
4199extern debugport_write_function debug_write_function;
4200
4201static int rs_debug_write_function(int i, const char *buf, unsigned int len)
4202{
4203 int cnt;
4204 int written = 0;
4205 struct tty_struct *tty;
4206 static int recurse_cnt = 0;
4207
4208 tty = rs_table[i].tty;
4209 if (tty) {
4210 unsigned long flags;
4211 if (recurse_cnt > 5) /* We skip this debug output */
4212 return 1;
4213
4214 local_irq_save(flags);
4215 recurse_cnt++;
4216 local_irq_restore(flags);
4217 do {
4218 cnt = rs_write(tty, 0, buf + written, len);
4219 if (cnt >= 0) {
4220 written += cnt;
4221 buf += cnt;
4222 len -= cnt;
4223 } else
4224 len = cnt;
4225 } while(len > 0);
4226 local_irq_save(flags);
4227 recurse_cnt--;
4228 local_irq_restore(flags);
4229 return 1;
4230 }
4231 return 0;
4232}
4233
4234/* 3718/*
4235 * ------------------------------------------------------------ 3719 * ------------------------------------------------------------
4236 * rs_close() 3720 * rs_close()
@@ -4252,11 +3736,10 @@ rs_close(struct tty_struct *tty, struct file * filp)
4252 3736
4253 /* interrupts are disabled for this entire function */ 3737 /* interrupts are disabled for this entire function */
4254 3738
4255 save_flags(flags); 3739 local_irq_save(flags);
4256 cli();
4257 3740
4258 if (tty_hung_up_p(filp)) { 3741 if (tty_hung_up_p(filp)) {
4259 restore_flags(flags); 3742 local_irq_restore(flags);
4260 return; 3743 return;
4261 } 3744 }
4262 3745
@@ -4283,7 +3766,7 @@ rs_close(struct tty_struct *tty, struct file * filp)
4283 info->count = 0; 3766 info->count = 0;
4284 } 3767 }
4285 if (info->count) { 3768 if (info->count) {
4286 restore_flags(flags); 3769 local_irq_restore(flags);
4287 return; 3770 return;
4288 } 3771 }
4289 info->flags |= ASYNC_CLOSING; 3772 info->flags |= ASYNC_CLOSING;
@@ -4337,7 +3820,7 @@ rs_close(struct tty_struct *tty, struct file * filp)
4337 } 3820 }
4338 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 3821 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
4339 wake_up_interruptible(&info->close_wait); 3822 wake_up_interruptible(&info->close_wait);
4340 restore_flags(flags); 3823 local_irq_restore(flags);
4341 3824
4342 /* port closed */ 3825 /* port closed */
4343 3826
@@ -4359,6 +3842,28 @@ rs_close(struct tty_struct *tty, struct file * filp)
4359#endif 3842#endif
4360 } 3843 }
4361#endif 3844#endif
3845
3846 /*
3847 * Release any allocated DMA irq's.
3848 */
3849 if (info->dma_in_enabled) {
3850 free_irq(info->dma_in_irq_nbr, info);
3851 cris_free_dma(info->dma_in_nbr, info->dma_in_irq_description);
3852 info->uses_dma_in = 0;
3853#ifdef SERIAL_DEBUG_OPEN
3854 printk(KERN_DEBUG "DMA irq '%s' freed\n",
3855 info->dma_in_irq_description);
3856#endif
3857 }
3858 if (info->dma_out_enabled) {
3859 free_irq(info->dma_out_irq_nbr, info);
3860 cris_free_dma(info->dma_out_nbr, info->dma_out_irq_description);
3861 info->uses_dma_out = 0;
3862#ifdef SERIAL_DEBUG_OPEN
3863 printk(KERN_DEBUG "DMA irq '%s' freed\n",
3864 info->dma_out_irq_description);
3865#endif
3866 }
4362} 3867}
4363 3868
4364/* 3869/*
@@ -4433,8 +3938,8 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
4433 */ 3938 */
4434 if (tty_hung_up_p(filp) || 3939 if (tty_hung_up_p(filp) ||
4435 (info->flags & ASYNC_CLOSING)) { 3940 (info->flags & ASYNC_CLOSING)) {
4436 if (info->flags & ASYNC_CLOSING) 3941 wait_event_interruptible(info->close_wait,
4437 interruptible_sleep_on(&info->close_wait); 3942 !(info->flags & ASYNC_CLOSING));
4438#ifdef SERIAL_DO_RESTART 3943#ifdef SERIAL_DO_RESTART
4439 if (info->flags & ASYNC_HUP_NOTIFY) 3944 if (info->flags & ASYNC_HUP_NOTIFY)
4440 return -EAGAIN; 3945 return -EAGAIN;
@@ -4472,21 +3977,19 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
4472 printk("block_til_ready before block: ttyS%d, count = %d\n", 3977 printk("block_til_ready before block: ttyS%d, count = %d\n",
4473 info->line, info->count); 3978 info->line, info->count);
4474#endif 3979#endif
4475 save_flags(flags); 3980 local_irq_save(flags);
4476 cli();
4477 if (!tty_hung_up_p(filp)) { 3981 if (!tty_hung_up_p(filp)) {
4478 extra_count++; 3982 extra_count++;
4479 info->count--; 3983 info->count--;
4480 } 3984 }
4481 restore_flags(flags); 3985 local_irq_restore(flags);
4482 info->blocked_open++; 3986 info->blocked_open++;
4483 while (1) { 3987 while (1) {
4484 save_flags(flags); 3988 local_irq_save(flags);
4485 cli();
4486 /* assert RTS and DTR */ 3989 /* assert RTS and DTR */
4487 e100_rts(info, 1); 3990 e100_rts(info, 1);
4488 e100_dtr(info, 1); 3991 e100_dtr(info, 1);
4489 restore_flags(flags); 3992 local_irq_restore(flags);
4490 set_current_state(TASK_INTERRUPTIBLE); 3993 set_current_state(TASK_INTERRUPTIBLE);
4491 if (tty_hung_up_p(filp) || 3994 if (tty_hung_up_p(filp) ||
4492 !(info->flags & ASYNC_INITIALIZED)) { 3995 !(info->flags & ASYNC_INITIALIZED)) {
@@ -4528,6 +4031,19 @@ block_til_ready(struct tty_struct *tty, struct file * filp,
4528 return 0; 4031 return 0;
4529} 4032}
4530 4033
4034static void
4035deinit_port(struct e100_serial *info)
4036{
4037 if (info->dma_out_enabled) {
4038 cris_free_dma(info->dma_out_nbr, info->dma_out_irq_description);
4039 free_irq(info->dma_out_irq_nbr, info);
4040 }
4041 if (info->dma_in_enabled) {
4042 cris_free_dma(info->dma_in_nbr, info->dma_in_irq_description);
4043 free_irq(info->dma_in_irq_nbr, info);
4044 }
4045}
4046
4531/* 4047/*
4532 * This routine is called whenever a serial port is opened. 4048 * This routine is called whenever a serial port is opened.
4533 * It performs the serial-specific initialization for the tty structure. 4049 * It performs the serial-specific initialization for the tty structure.
@@ -4538,9 +4054,9 @@ rs_open(struct tty_struct *tty, struct file * filp)
4538 struct e100_serial *info; 4054 struct e100_serial *info;
4539 int retval, line; 4055 int retval, line;
4540 unsigned long page; 4056 unsigned long page;
4057 int allocated_resources = 0;
4541 4058
4542 /* find which port we want to open */ 4059 /* find which port we want to open */
4543
4544 line = tty->index; 4060 line = tty->index;
4545 4061
4546 if (line < 0 || line >= NR_PORTS) 4062 if (line < 0 || line >= NR_PORTS)
@@ -4580,8 +4096,8 @@ rs_open(struct tty_struct *tty, struct file * filp)
4580 */ 4096 */
4581 if (tty_hung_up_p(filp) || 4097 if (tty_hung_up_p(filp) ||
4582 (info->flags & ASYNC_CLOSING)) { 4098 (info->flags & ASYNC_CLOSING)) {
4583 if (info->flags & ASYNC_CLOSING) 4099 wait_event_interruptible(info->close_wait,
4584 interruptible_sleep_on(&info->close_wait); 4100 !(info->flags & ASYNC_CLOSING));
4585#ifdef SERIAL_DO_RESTART 4101#ifdef SERIAL_DO_RESTART
4586 return ((info->flags & ASYNC_HUP_NOTIFY) ? 4102 return ((info->flags & ASYNC_HUP_NOTIFY) ?
4587 -EAGAIN : -ERESTARTSYS); 4103 -EAGAIN : -ERESTARTSYS);
@@ -4591,12 +4107,85 @@ rs_open(struct tty_struct *tty, struct file * filp)
4591 } 4107 }
4592 4108
4593 /* 4109 /*
4110 * If DMA is enabled try to allocate the irq's.
4111 */
4112 if (info->count == 1) {
4113 allocated_resources = 1;
4114 if (info->dma_in_enabled) {
4115 if (request_irq(info->dma_in_irq_nbr,
4116 rec_interrupt,
4117 info->dma_in_irq_flags,
4118 info->dma_in_irq_description,
4119 info)) {
4120 printk(KERN_WARNING "DMA irq '%s' busy; "
4121 "falling back to non-DMA mode\n",
4122 info->dma_in_irq_description);
4123 /* Make sure we never try to use DMA in */
4124 /* for the port again. */
4125 info->dma_in_enabled = 0;
4126 } else if (cris_request_dma(info->dma_in_nbr,
4127 info->dma_in_irq_description,
4128 DMA_VERBOSE_ON_ERROR,
4129 info->dma_owner)) {
4130 free_irq(info->dma_in_irq_nbr, info);
4131 printk(KERN_WARNING "DMA '%s' busy; "
4132 "falling back to non-DMA mode\n",
4133 info->dma_in_irq_description);
4134 /* Make sure we never try to use DMA in */
4135 /* for the port again. */
4136 info->dma_in_enabled = 0;
4137 }
4138#ifdef SERIAL_DEBUG_OPEN
4139 else
4140 printk(KERN_DEBUG "DMA irq '%s' allocated\n",
4141 info->dma_in_irq_description);
4142#endif
4143 }
4144 if (info->dma_out_enabled) {
4145 if (request_irq(info->dma_out_irq_nbr,
4146 tr_interrupt,
4147 info->dma_out_irq_flags,
4148 info->dma_out_irq_description,
4149 info)) {
4150 printk(KERN_WARNING "DMA irq '%s' busy; "
4151 "falling back to non-DMA mode\n",
4152 info->dma_out_irq_description);
4153 /* Make sure we never try to use DMA out */
4154 /* for the port again. */
4155 info->dma_out_enabled = 0;
4156 } else if (cris_request_dma(info->dma_out_nbr,
4157 info->dma_out_irq_description,
4158 DMA_VERBOSE_ON_ERROR,
4159 info->dma_owner)) {
4160 free_irq(info->dma_out_irq_nbr, info);
4161 printk(KERN_WARNING "DMA '%s' busy; "
4162 "falling back to non-DMA mode\n",
4163 info->dma_out_irq_description);
4164 /* Make sure we never try to use DMA out */
4165 /* for the port again. */
4166 info->dma_out_enabled = 0;
4167 }
4168#ifdef SERIAL_DEBUG_OPEN
4169 else
4170 printk(KERN_DEBUG "DMA irq '%s' allocated\n",
4171 info->dma_out_irq_description);
4172#endif
4173 }
4174 }
4175
4176 /*
4594 * Start up the serial port 4177 * Start up the serial port
4595 */ 4178 */
4596 4179
4597 retval = startup(info); 4180 retval = startup(info);
4598 if (retval) 4181 if (retval) {
4182 if (allocated_resources)
4183 deinit_port(info);
4184
4185 /* FIXME Decrease count info->count here too? */
4599 return retval; 4186 return retval;
4187 }
4188
4600 4189
4601 retval = block_til_ready(tty, filp, info); 4190 retval = block_til_ready(tty, filp, info);
4602 if (retval) { 4191 if (retval) {
@@ -4604,6 +4193,9 @@ rs_open(struct tty_struct *tty, struct file * filp)
4604 printk("rs_open returning after block_til_ready with %d\n", 4193 printk("rs_open returning after block_til_ready with %d\n",
4605 retval); 4194 retval);
4606#endif 4195#endif
4196 if (allocated_resources)
4197 deinit_port(info);
4198
4607 return retval; 4199 return retval;
4608 } 4200 }
4609 4201
@@ -4793,6 +4385,8 @@ static const struct tty_operations rs_ops = {
4793 .send_xchar = rs_send_xchar, 4385 .send_xchar = rs_send_xchar,
4794 .wait_until_sent = rs_wait_until_sent, 4386 .wait_until_sent = rs_wait_until_sent,
4795 .read_proc = rs_read_proc, 4387 .read_proc = rs_read_proc,
4388 .tiocmget = rs_tiocmget,
4389 .tiocmset = rs_tiocmset
4796}; 4390};
4797 4391
4798static int __init 4392static int __init
@@ -4810,9 +4404,27 @@ rs_init(void)
4810 /* Setup the timed flush handler system */ 4404 /* Setup the timed flush handler system */
4811 4405
4812#if !defined(CONFIG_ETRAX_SERIAL_FAST_TIMER) 4406#if !defined(CONFIG_ETRAX_SERIAL_FAST_TIMER)
4813 init_timer(&flush_timer); 4407 setup_timer(&flush_timer, timed_flush_handler, 0);
4814 flush_timer.function = timed_flush_handler; 4408 mod_timer(&flush_timer, jiffies + 5);
4815 mod_timer(&flush_timer, jiffies + CONFIG_ETRAX_SERIAL_RX_TIMEOUT_TICKS); 4409#endif
4410
4411#if defined(CONFIG_ETRAX_RS485)
4412#if defined(CONFIG_ETRAX_RS485_ON_PA)
4413 if (cris_io_interface_allocate_pins(if_ser0, 'a', rs485_pa_bit,
4414 rs485_pa_bit)) {
4415 printk(KERN_CRIT "ETRAX100LX serial: Could not allocate "
4416 "RS485 pin\n");
4417 return -EBUSY;
4418 }
4419#endif
4420#if defined(CONFIG_ETRAX_RS485_ON_PORT_G)
4421 if (cris_io_interface_allocate_pins(if_ser0, 'g', rs485_pa_bit,
4422 rs485_port_g_bit)) {
4423 printk(KERN_CRIT "ETRAX100LX serial: Could not allocate "
4424 "RS485 pin\n");
4425 return -EBUSY;
4426 }
4427#endif
4816#endif 4428#endif
4817 4429
4818 /* Initialize the tty_driver structure */ 4430 /* Initialize the tty_driver structure */
@@ -4839,6 +4451,16 @@ rs_init(void)
4839 /* do some initializing for the separate ports */ 4451 /* do some initializing for the separate ports */
4840 4452
4841 for (i = 0, info = rs_table; i < NR_PORTS; i++,info++) { 4453 for (i = 0, info = rs_table; i < NR_PORTS; i++,info++) {
4454 if (info->enabled) {
4455 if (cris_request_io_interface(info->io_if,
4456 info->io_if_description)) {
4457 printk(KERN_CRIT "ETRAX100LX async serial: "
4458 "Could not allocate IO pins for "
4459 "%s, port %d\n",
4460 info->io_if_description, i);
4461 info->enabled = 0;
4462 }
4463 }
4842 info->uses_dma_in = 0; 4464 info->uses_dma_in = 0;
4843 info->uses_dma_out = 0; 4465 info->uses_dma_out = 0;
4844 info->line = i; 4466 info->line = i;
@@ -4872,7 +4494,7 @@ rs_init(void)
4872 info->rs485.delay_rts_before_send = 0; 4494 info->rs485.delay_rts_before_send = 0;
4873 info->rs485.enabled = 0; 4495 info->rs485.enabled = 0;
4874#endif 4496#endif
4875 INIT_WORK(&info->work, do_softint, info); 4497 INIT_WORK(&info->work, do_softint);
4876 4498
4877 if (info->enabled) { 4499 if (info->enabled) {
4878 printk(KERN_INFO "%s%d at 0x%x is a builtin UART with DMA\n", 4500 printk(KERN_INFO "%s%d at 0x%x is a builtin UART with DMA\n",
@@ -4890,64 +4512,17 @@ rs_init(void)
4890#endif 4512#endif
4891 4513
4892#ifndef CONFIG_SVINTO_SIM 4514#ifndef CONFIG_SVINTO_SIM
4515#ifndef CONFIG_ETRAX_KGDB
4893 /* Not needed in simulator. May only complicate stuff. */ 4516 /* Not needed in simulator. May only complicate stuff. */
4894 /* hook the irq's for DMA channel 6 and 7, serial output and input, and some more... */ 4517 /* hook the irq's for DMA channel 6 and 7, serial output and input, and some more... */
4895 4518
4896 if (request_irq(SERIAL_IRQ_NBR, ser_interrupt, IRQF_SHARED | IRQF_DISABLED, "serial ", NULL)) 4519 if (request_irq(SERIAL_IRQ_NBR, ser_interrupt,
4897 panic("irq8"); 4520 IRQF_SHARED | IRQF_DISABLED, "serial ", driver))
4898 4521 panic("%s: Failed to request irq8", __FUNCTION__);
4899#ifdef CONFIG_ETRAX_SERIAL_PORT0
4900#ifdef CONFIG_ETRAX_SERIAL_PORT0_DMA6_OUT
4901 if (request_irq(SER0_DMA_TX_IRQ_NBR, tr_interrupt, IRQF_DISABLED, "serial 0 dma tr", NULL))
4902 panic("irq22");
4903#endif
4904#ifdef CONFIG_ETRAX_SERIAL_PORT0_DMA7_IN
4905 if (request_irq(SER0_DMA_RX_IRQ_NBR, rec_interrupt, IRQF_DISABLED, "serial 0 dma rec", NULL))
4906 panic("irq23");
4907#endif
4908#endif
4909
4910#ifdef CONFIG_ETRAX_SERIAL_PORT1
4911#ifdef CONFIG_ETRAX_SERIAL_PORT1_DMA8_OUT
4912 if (request_irq(SER1_DMA_TX_IRQ_NBR, tr_interrupt, IRQF_DISABLED, "serial 1 dma tr", NULL))
4913 panic("irq24");
4914#endif
4915#ifdef CONFIG_ETRAX_SERIAL_PORT1_DMA9_IN
4916 if (request_irq(SER1_DMA_RX_IRQ_NBR, rec_interrupt, IRQF_DISABLED, "serial 1 dma rec", NULL))
4917 panic("irq25");
4918#endif
4919#endif
4920#ifdef CONFIG_ETRAX_SERIAL_PORT2
4921 /* DMA Shared with par0 (and SCSI0 and ATA) */
4922#ifdef CONFIG_ETRAX_SERIAL_PORT2_DMA2_OUT
4923 if (request_irq(SER2_DMA_TX_IRQ_NBR, tr_interrupt, IRQF_SHARED | IRQF_DISABLED, "serial 2 dma tr", NULL))
4924 panic("irq18");
4925#endif
4926#ifdef CONFIG_ETRAX_SERIAL_PORT2_DMA3_IN
4927 if (request_irq(SER2_DMA_RX_IRQ_NBR, rec_interrupt, IRQF_SHARED | IRQF_DISABLED, "serial 2 dma rec", NULL))
4928 panic("irq19");
4929#endif
4930#endif
4931#ifdef CONFIG_ETRAX_SERIAL_PORT3
4932 /* DMA Shared with par1 (and SCSI1 and Extern DMA 0) */
4933#ifdef CONFIG_ETRAX_SERIAL_PORT3_DMA4_OUT
4934 if (request_irq(SER3_DMA_TX_IRQ_NBR, tr_interrupt, IRQF_SHARED | IRQF_DISABLED, "serial 3 dma tr", NULL))
4935 panic("irq20");
4936#endif
4937#ifdef CONFIG_ETRAX_SERIAL_PORT3_DMA5_IN
4938 if (request_irq(SER3_DMA_RX_IRQ_NBR, rec_interrupt, IRQF_SHARED | IRQF_DISABLED, "serial 3 dma rec", NULL))
4939 panic("irq21");
4940#endif
4941#endif
4942 4522
4943#ifdef CONFIG_ETRAX_SERIAL_FLUSH_DMA_FAST
4944 if (request_irq(TIMER1_IRQ_NBR, timeout_interrupt, IRQF_SHARED | IRQF_DISABLED,
4945 "fast serial dma timeout", NULL)) {
4946 printk(KERN_CRIT "err: timer1 irq\n");
4947 }
4948#endif 4523#endif
4949#endif /* CONFIG_SVINTO_SIM */ 4524#endif /* CONFIG_SVINTO_SIM */
4950 debug_write_function = rs_debug_write_function; 4525
4951 return 0; 4526 return 0;
4952} 4527}
4953 4528
diff --git a/drivers/serial/crisv10.h b/drivers/serial/crisv10.h
new file mode 100644
index 000000000000..ccd0f32b7372
--- /dev/null
+++ b/drivers/serial/crisv10.h
@@ -0,0 +1,146 @@
1/*
2 * serial.h: Arch-dep definitions for the Etrax100 serial driver.
3 *
4 * Copyright (C) 1998-2007 Axis Communications AB
5 */
6
7#ifndef _ETRAX_SERIAL_H
8#define _ETRAX_SERIAL_H
9
10#include <linux/circ_buf.h>
11#include <asm/termios.h>
12#include <asm/dma.h>
13#include <asm/arch/io_interface_mux.h>
14
15/* Software state per channel */
16
17#ifdef __KERNEL__
18/*
19 * This is our internal structure for each serial port's state.
20 *
21 * Many fields are paralleled by the structure used by the serial_struct
22 * structure.
23 *
24 * For definitions of the flags field, see tty.h
25 */
26
27#define SERIAL_RECV_DESCRIPTORS 8
28
29struct etrax_recv_buffer {
30 struct etrax_recv_buffer *next;
31 unsigned short length;
32 unsigned char error;
33 unsigned char pad;
34
35 unsigned char buffer[0];
36};
37
38struct e100_serial {
39 int baud;
40 volatile u8 *port; /* R_SERIALx_CTRL */
41 u32 irq; /* bitnr in R_IRQ_MASK2 for dmaX_descr */
42
43 /* Output registers */
44 volatile u8 *oclrintradr; /* adr to R_DMA_CHx_CLR_INTR */
45 volatile u32 *ofirstadr; /* adr to R_DMA_CHx_FIRST */
46 volatile u8 *ocmdadr; /* adr to R_DMA_CHx_CMD */
47 const volatile u8 *ostatusadr; /* adr to R_DMA_CHx_STATUS */
48
49 /* Input registers */
50 volatile u8 *iclrintradr; /* adr to R_DMA_CHx_CLR_INTR */
51 volatile u32 *ifirstadr; /* adr to R_DMA_CHx_FIRST */
52 volatile u8 *icmdadr; /* adr to R_DMA_CHx_CMD */
53 volatile u32 *idescradr; /* adr to R_DMA_CHx_DESCR */
54
55 int flags; /* defined in tty.h */
56
57 u8 rx_ctrl; /* shadow for R_SERIALx_REC_CTRL */
58 u8 tx_ctrl; /* shadow for R_SERIALx_TR_CTRL */
59 u8 iseteop; /* bit number for R_SET_EOP for the input dma */
60 int enabled; /* Set to 1 if the port is enabled in HW config */
61
62 u8 dma_out_enabled; /* Set to 1 if DMA should be used */
63 u8 dma_in_enabled; /* Set to 1 if DMA should be used */
64
65 /* end of fields defined in rs_table[] in .c-file */
66 int dma_owner;
67 unsigned int dma_in_nbr;
68 unsigned int dma_out_nbr;
69 unsigned int dma_in_irq_nbr;
70 unsigned int dma_out_irq_nbr;
71 unsigned long dma_in_irq_flags;
72 unsigned long dma_out_irq_flags;
73 char *dma_in_irq_description;
74 char *dma_out_irq_description;
75
76 enum cris_io_interface io_if;
77 char *io_if_description;
78
79 u8 uses_dma_in; /* Set to 1 if DMA is used */
80 u8 uses_dma_out; /* Set to 1 if DMA is used */
81 u8 forced_eop; /* a fifo eop has been forced */
82 int baud_base; /* For special baudrates */
83 int custom_divisor; /* For special baudrates */
84 struct etrax_dma_descr tr_descr;
85 struct etrax_dma_descr rec_descr[SERIAL_RECV_DESCRIPTORS];
86 int cur_rec_descr;
87
88 volatile int tr_running; /* 1 if output is running */
89
90 struct tty_struct *tty;
91 int read_status_mask;
92 int ignore_status_mask;
93 int x_char; /* xon/xoff character */
94 int close_delay;
95 unsigned short closing_wait;
96 unsigned short closing_wait2;
97 unsigned long event;
98 unsigned long last_active;
99 int line;
100 int type; /* PORT_ETRAX */
101 int count; /* # of fd on device */
102 int blocked_open; /* # of blocked opens */
103 struct circ_buf xmit;
104 struct etrax_recv_buffer *first_recv_buffer;
105 struct etrax_recv_buffer *last_recv_buffer;
106 unsigned int recv_cnt;
107 unsigned int max_recv_cnt;
108
109 struct work_struct work;
110 struct async_icount icount; /* error-statistics etc.*/
111 struct ktermios normal_termios;
112 struct ktermios callout_termios;
113 wait_queue_head_t open_wait;
114 wait_queue_head_t close_wait;
115
116 unsigned long char_time_usec; /* The time for 1 char, in usecs */
117 unsigned long flush_time_usec; /* How often we should flush */
118 unsigned long last_tx_active_usec; /* Last tx usec in the jiffies */
119 unsigned long last_tx_active; /* Last tx time in jiffies */
120 unsigned long last_rx_active_usec; /* Last rx usec in the jiffies */
121 unsigned long last_rx_active; /* Last rx time in jiffies */
122
123 int break_detected_cnt;
124 int errorcode;
125
126#ifdef CONFIG_ETRAX_RS485
127 struct rs485_control rs485; /* RS-485 support */
128#endif
129};
130
131/* this PORT is not in the standard serial.h. it's not actually used for
132 * anything since we only have one type of async serial-port anyway in this
133 * system.
134 */
135
136#define PORT_ETRAX 1
137
138/*
139 * Events are used to schedule things to happen at timer-interrupt
140 * time, instead of at rs interrupt time.
141 */
142#define RS_EVENT_WRITE_WAKEUP 0
143
144#endif /* __KERNEL__ */
145
146#endif /* !_ETRAX_SERIAL_H */
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index e89ae29645d6..d24621ce799a 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -77,7 +77,6 @@
77# define SCIF_ONLY 77# define SCIF_ONLY
78#elif defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712) 78#elif defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
79# define SCSPTR0 0xA4400000 /* 16 bit SCIF */ 79# define SCSPTR0 0xA4400000 /* 16 bit SCIF */
80# define SCI_NPORTS 2
81# define SCIF_ORER 0x0001 /* overrun error bit */ 80# define SCIF_ORER 0x0001 /* overrun error bit */
82# define PACR 0xa4050100 81# define PACR 0xa4050100
83# define PBCR 0xa4050102 82# define PBCR 0xa4050102
@@ -102,12 +101,6 @@
102# define SCIF_ORER 0x0001 /* overrun error bit */ 101# define SCIF_ORER 0x0001 /* overrun error bit */
103# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 102# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
104# define SCIF_ONLY 103# define SCIF_ONLY
105#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
106# define SCSPTR1 0xffe00020 /* 16 bit SCIF */
107# define SCSPTR2 0xffe80020 /* 16 bit SCIF */
108# define SCIF_ORER 0x0001 /* overrun error bit */
109# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
110# define SCIF_ONLY
111#elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103) 104#elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103)
112# include <asm/hardware.h> 105# include <asm/hardware.h>
113# define SCIF_BASE_ADDR 0x01030000 106# define SCIF_BASE_ADDR 0x01030000
@@ -116,8 +109,7 @@
116# define SCIF_LSR2_OFFS 0x0000024 109# define SCIF_LSR2_OFFS 0x0000024
117# define SCSPTR2 ((port->mapbase)+SCIF_PTR2_OFFS) /* 16 bit SCIF */ 110# define SCSPTR2 ((port->mapbase)+SCIF_PTR2_OFFS) /* 16 bit SCIF */
118# define SCLSR2 ((port->mapbase)+SCIF_LSR2_OFFS) /* 16 bit SCIF */ 111# define SCLSR2 ((port->mapbase)+SCIF_LSR2_OFFS) /* 16 bit SCIF */
119# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0, 112# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0, TE=1,RE=1,REIE=1 */
120 TE=1,RE=1,REIE=1 */
121# define SCIF_ONLY 113# define SCIF_ONLY
122#elif defined(CONFIG_H83007) || defined(CONFIG_H83068) 114#elif defined(CONFIG_H83007) || defined(CONFIG_H83068)
123# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ 115# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
@@ -577,15 +569,6 @@ static inline int sci_rxd_in(struct uart_port *port)
577 return ctrl_inb(SCPDR0) & 0x0001 ? 1 : 0; /* SCIF0 */ 569 return ctrl_inb(SCPDR0) & 0x0001 ? 1 : 0; /* SCIF0 */
578 return 1; 570 return 1;
579} 571}
580#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
581static inline int sci_rxd_in(struct uart_port *port)
582{
583 if (port->mapbase == 0xffe00000)
584 return ctrl_inw(SCSPTR1)&0x0001 ? 1 : 0; /* SCIF */
585 else
586 return ctrl_inw(SCSPTR2)&0x0001 ? 1 : 0; /* SCIF */
587
588}
589#elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103) 572#elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103)
590static inline int sci_rxd_in(struct uart_port *port) 573static inline int sci_rxd_in(struct uart_port *port)
591{ 574{
diff --git a/drivers/serial/uartlite.c b/drivers/serial/uartlite.c
index dfef83f14960..a85f2d31a686 100644
--- a/drivers/serial/uartlite.c
+++ b/drivers/serial/uartlite.c
@@ -329,12 +329,14 @@ static struct uart_ops ulite_ops = {
329static void ulite_console_wait_tx(struct uart_port *port) 329static void ulite_console_wait_tx(struct uart_port *port)
330{ 330{
331 int i; 331 int i;
332 u8 val;
332 333
333 /* wait up to 10ms for the character(s) to be sent */ 334 /* Spin waiting for TX fifo to have space available */
334 for (i = 0; i < 10000; i++) { 335 for (i = 0; i < 100000; i++) {
335 if (readb(port->membase + ULITE_STATUS) & ULITE_STATUS_TXEMPTY) 336 val = readb(port->membase + ULITE_STATUS);
337 if ((val & ULITE_STATUS_TXFULL) == 0)
336 break; 338 break;
337 udelay(1); 339 cpu_relax();
338 } 340 }
339} 341}
340 342
diff --git a/drivers/sh/superhyway/superhyway.c b/drivers/sh/superhyway/superhyway.c
index 7d873b3b0513..4d0282b821b5 100644
--- a/drivers/sh/superhyway/superhyway.c
+++ b/drivers/sh/superhyway/superhyway.c
@@ -107,16 +107,17 @@ int superhyway_add_devices(struct superhyway_bus *bus,
107static int __init superhyway_init(void) 107static int __init superhyway_init(void)
108{ 108{
109 struct superhyway_bus *bus; 109 struct superhyway_bus *bus;
110 int ret = 0; 110 int ret;
111 111
112 device_register(&superhyway_bus_device); 112 ret = device_register(&superhyway_bus_device);
113 if (unlikely(ret))
114 return ret;
113 115
114 for (bus = superhyway_channels; bus->ops; bus++) 116 for (bus = superhyway_channels; bus->ops; bus++)
115 ret |= superhyway_scan_bus(bus); 117 ret |= superhyway_scan_bus(bus);
116 118
117 return ret; 119 return ret;
118} 120}
119
120postcore_initcall(superhyway_init); 121postcore_initcall(superhyway_init);
121 122
122static const struct superhyway_device_id * 123static const struct superhyway_device_id *
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 89769ce16f88..b31f4431849b 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -457,10 +457,11 @@ done:
457EXPORT_SYMBOL_GPL(spi_register_master); 457EXPORT_SYMBOL_GPL(spi_register_master);
458 458
459 459
460static int __unregister(struct device *dev, void *unused) 460static int __unregister(struct device *dev, void *master_dev)
461{ 461{
462 /* note: before about 2.6.14-rc1 this would corrupt memory: */ 462 /* note: before about 2.6.14-rc1 this would corrupt memory: */
463 spi_unregister_device(to_spi_device(dev)); 463 if (dev != master_dev)
464 spi_unregister_device(to_spi_device(dev));
464 return 0; 465 return 0;
465} 466}
466 467
@@ -478,7 +479,8 @@ void spi_unregister_master(struct spi_master *master)
478{ 479{
479 int dummy; 480 int dummy;
480 481
481 dummy = device_for_each_child(master->dev.parent, NULL, __unregister); 482 dummy = device_for_each_child(master->dev.parent, &master->dev,
483 __unregister);
482 device_unregister(&master->dev); 484 device_unregister(&master->dev);
483} 485}
484EXPORT_SYMBOL_GPL(spi_unregister_master); 486EXPORT_SYMBOL_GPL(spi_unregister_master);
diff --git a/drivers/spi/spi_txx9.c b/drivers/spi/spi_txx9.c
index cc5094f37dd3..363ac8e68821 100644
--- a/drivers/spi/spi_txx9.c
+++ b/drivers/spi/spi_txx9.c
@@ -24,6 +24,7 @@
24#include <linux/spi/spi.h> 24#include <linux/spi/spi.h>
25#include <linux/err.h> 25#include <linux/err.h>
26#include <linux/clk.h> 26#include <linux/clk.h>
27#include <linux/io.h>
27#include <asm/gpio.h> 28#include <asm/gpio.h>
28 29
29 30
@@ -74,7 +75,6 @@ struct txx9spi {
74 struct list_head queue; 75 struct list_head queue;
75 wait_queue_head_t waitq; 76 wait_queue_head_t waitq;
76 void __iomem *membase; 77 void __iomem *membase;
77 int irq;
78 int baseclk; 78 int baseclk;
79 struct clk *clk; 79 struct clk *clk;
80 u32 max_speed_hz, min_speed_hz; 80 u32 max_speed_hz, min_speed_hz;
@@ -350,12 +350,12 @@ static int __init txx9spi_probe(struct platform_device *dev)
350 struct resource *res; 350 struct resource *res;
351 int ret = -ENODEV; 351 int ret = -ENODEV;
352 u32 mcr; 352 u32 mcr;
353 int irq;
353 354
354 master = spi_alloc_master(&dev->dev, sizeof(*c)); 355 master = spi_alloc_master(&dev->dev, sizeof(*c));
355 if (!master) 356 if (!master)
356 return ret; 357 return ret;
357 c = spi_master_get_devdata(master); 358 c = spi_master_get_devdata(master);
358 c->irq = -1;
359 platform_set_drvdata(dev, master); 359 platform_set_drvdata(dev, master);
360 360
361 INIT_WORK(&c->work, txx9spi_work); 361 INIT_WORK(&c->work, txx9spi_work);
@@ -381,32 +381,36 @@ static int __init txx9spi_probe(struct platform_device *dev)
381 381
382 res = platform_get_resource(dev, IORESOURCE_MEM, 0); 382 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
383 if (!res) 383 if (!res)
384 goto exit; 384 goto exit_busy;
385 c->membase = ioremap(res->start, res->end - res->start + 1); 385 if (!devm_request_mem_region(&dev->dev,
386 res->start, res->end - res->start + 1,
387 "spi_txx9"))
388 goto exit_busy;
389 c->membase = devm_ioremap(&dev->dev,
390 res->start, res->end - res->start + 1);
386 if (!c->membase) 391 if (!c->membase)
387 goto exit; 392 goto exit_busy;
388 393
389 /* enter config mode */ 394 /* enter config mode */
390 mcr = txx9spi_rd(c, TXx9_SPMCR); 395 mcr = txx9spi_rd(c, TXx9_SPMCR);
391 mcr &= ~(TXx9_SPMCR_OPMODE | TXx9_SPMCR_SPSTP | TXx9_SPMCR_BCLR); 396 mcr &= ~(TXx9_SPMCR_OPMODE | TXx9_SPMCR_SPSTP | TXx9_SPMCR_BCLR);
392 txx9spi_wr(c, mcr | TXx9_SPMCR_CONFIG | TXx9_SPMCR_BCLR, TXx9_SPMCR); 397 txx9spi_wr(c, mcr | TXx9_SPMCR_CONFIG | TXx9_SPMCR_BCLR, TXx9_SPMCR);
393 398
394 c->irq = platform_get_irq(dev, 0); 399 irq = platform_get_irq(dev, 0);
395 if (c->irq < 0) 400 if (irq < 0)
396 goto exit; 401 goto exit_busy;
397 ret = request_irq(c->irq, txx9spi_interrupt, 0, dev->name, c); 402 ret = devm_request_irq(&dev->dev, irq, txx9spi_interrupt, 0,
398 if (ret) { 403 "spi_txx9", c);
399 c->irq = -1; 404 if (ret)
400 goto exit; 405 goto exit;
401 }
402 406
403 c->workqueue = create_singlethread_workqueue(master->dev.parent->bus_id); 407 c->workqueue = create_singlethread_workqueue(master->dev.parent->bus_id);
404 if (!c->workqueue) 408 if (!c->workqueue)
405 goto exit; 409 goto exit_busy;
406 c->last_chipselect = -1; 410 c->last_chipselect = -1;
407 411
408 dev_info(&dev->dev, "at %#llx, irq %d, %dMHz\n", 412 dev_info(&dev->dev, "at %#llx, irq %d, %dMHz\n",
409 (unsigned long long)res->start, c->irq, 413 (unsigned long long)res->start, irq,
410 (c->baseclk + 500000) / 1000000); 414 (c->baseclk + 500000) / 1000000);
411 415
412 master->bus_num = dev->id; 416 master->bus_num = dev->id;
@@ -418,13 +422,11 @@ static int __init txx9spi_probe(struct platform_device *dev)
418 if (ret) 422 if (ret)
419 goto exit; 423 goto exit;
420 return 0; 424 return 0;
425exit_busy:
426 ret = -EBUSY;
421exit: 427exit:
422 if (c->workqueue) 428 if (c->workqueue)
423 destroy_workqueue(c->workqueue); 429 destroy_workqueue(c->workqueue);
424 if (c->irq >= 0)
425 free_irq(c->irq, c);
426 if (c->membase)
427 iounmap(c->membase);
428 if (c->clk) { 430 if (c->clk) {
429 clk_disable(c->clk); 431 clk_disable(c->clk);
430 clk_put(c->clk); 432 clk_put(c->clk);
@@ -442,8 +444,6 @@ static int __exit txx9spi_remove(struct platform_device *dev)
442 spi_unregister_master(master); 444 spi_unregister_master(master);
443 platform_set_drvdata(dev, NULL); 445 platform_set_drvdata(dev, NULL);
444 destroy_workqueue(c->workqueue); 446 destroy_workqueue(c->workqueue);
445 free_irq(c->irq, c);
446 iounmap(c->membase);
447 clk_disable(c->clk); 447 clk_disable(c->clk);
448 clk_put(c->clk); 448 clk_put(c->clk);
449 spi_master_put(master); 449 spi_master_put(master);
diff --git a/drivers/spi/tle62x0.c b/drivers/spi/tle62x0.c
index 6da58ca48b33..455991fbe28f 100644
--- a/drivers/spi/tle62x0.c
+++ b/drivers/spi/tle62x0.c
@@ -107,8 +107,11 @@ static ssize_t tle62x0_status_show(struct device *dev,
107 107
108 mutex_lock(&st->lock); 108 mutex_lock(&st->lock);
109 ret = tle62x0_read(st); 109 ret = tle62x0_read(st);
110
111 dev_dbg(dev, "tle62x0_read() returned %d\n", ret); 110 dev_dbg(dev, "tle62x0_read() returned %d\n", ret);
111 if (ret < 0) {
112 mutex_unlock(&st->lock);
113 return ret;
114 }
112 115
113 for (ptr = 0; ptr < (st->nr_gpio * 2)/8; ptr += 1) { 116 for (ptr = 0; ptr < (st->nr_gpio * 2)/8; ptr += 1) {
114 fault <<= 8; 117 fault <<= 8;
diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c
index c12a741b5574..85a20546e827 100644
--- a/drivers/ssb/main.c
+++ b/drivers/ssb/main.c
@@ -440,6 +440,7 @@ static int ssb_devices_register(struct ssb_bus *bus)
440 break; 440 break;
441 case SSB_BUSTYPE_PCMCIA: 441 case SSB_BUSTYPE_PCMCIA:
442#ifdef CONFIG_SSB_PCMCIAHOST 442#ifdef CONFIG_SSB_PCMCIAHOST
443 sdev->irq = bus->host_pcmcia->irq.AssignedIRQ;
443 dev->parent = &bus->host_pcmcia->dev; 444 dev->parent = &bus->host_pcmcia->dev;
444#endif 445#endif
445 break; 446 break;
@@ -1147,7 +1148,10 @@ static int __init ssb_modinit(void)
1147 1148
1148 return err; 1149 return err;
1149} 1150}
1150subsys_initcall(ssb_modinit); 1151/* ssb must be initialized after PCI but before the ssb drivers.
1152 * That means we must use some initcall between subsys_initcall
1153 * and device_initcall. */
1154fs_initcall(ssb_modinit);
1151 1155
1152static void __exit ssb_modexit(void) 1156static void __exit ssb_modexit(void)
1153{ 1157{
diff --git a/drivers/ssb/pcmcia.c b/drivers/ssb/pcmcia.c
index b6abee846f02..bb44a76b3eb5 100644
--- a/drivers/ssb/pcmcia.c
+++ b/drivers/ssb/pcmcia.c
@@ -63,17 +63,17 @@ int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus,
63 err = pcmcia_access_configuration_register(pdev, &reg); 63 err = pcmcia_access_configuration_register(pdev, &reg);
64 if (err != CS_SUCCESS) 64 if (err != CS_SUCCESS)
65 goto error; 65 goto error;
66 read_addr |= (reg.Value & 0xF) << 12; 66 read_addr |= ((u32)(reg.Value & 0x0F)) << 12;
67 reg.Offset = 0x30; 67 reg.Offset = 0x30;
68 err = pcmcia_access_configuration_register(pdev, &reg); 68 err = pcmcia_access_configuration_register(pdev, &reg);
69 if (err != CS_SUCCESS) 69 if (err != CS_SUCCESS)
70 goto error; 70 goto error;
71 read_addr |= reg.Value << 16; 71 read_addr |= ((u32)reg.Value) << 16;
72 reg.Offset = 0x32; 72 reg.Offset = 0x32;
73 err = pcmcia_access_configuration_register(pdev, &reg); 73 err = pcmcia_access_configuration_register(pdev, &reg);
74 if (err != CS_SUCCESS) 74 if (err != CS_SUCCESS)
75 goto error; 75 goto error;
76 read_addr |= reg.Value << 24; 76 read_addr |= ((u32)reg.Value) << 24;
77 77
78 cur_core = (read_addr - SSB_ENUM_BASE) / SSB_CORE_SIZE; 78 cur_core = (read_addr - SSB_ENUM_BASE) / SSB_CORE_SIZE;
79 if (cur_core == coreidx) 79 if (cur_core == coreidx)
@@ -152,28 +152,29 @@ error:
152 goto out_unlock; 152 goto out_unlock;
153} 153}
154 154
155/* These are the main device register access functions. 155static int select_core_and_segment(struct ssb_device *dev,
156 * do_select_core is inline to have the likely hotpath inline. 156 u16 *offset)
157 * All unlikely codepaths are out-of-line. */
158static inline int do_select_core(struct ssb_bus *bus,
159 struct ssb_device *dev,
160 u16 *offset)
161{ 157{
158 struct ssb_bus *bus = dev->bus;
162 int err; 159 int err;
163 u8 need_seg = (*offset >= 0x800) ? 1 : 0; 160 u8 need_segment;
161
162 if (*offset >= 0x800) {
163 *offset -= 0x800;
164 need_segment = 1;
165 } else
166 need_segment = 0;
164 167
165 if (unlikely(dev != bus->mapped_device)) { 168 if (unlikely(dev != bus->mapped_device)) {
166 err = ssb_pcmcia_switch_core(bus, dev); 169 err = ssb_pcmcia_switch_core(bus, dev);
167 if (unlikely(err)) 170 if (unlikely(err))
168 return err; 171 return err;
169 } 172 }
170 if (unlikely(need_seg != bus->mapped_pcmcia_seg)) { 173 if (unlikely(need_segment != bus->mapped_pcmcia_seg)) {
171 err = ssb_pcmcia_switch_segment(bus, need_seg); 174 err = ssb_pcmcia_switch_segment(bus, need_segment);
172 if (unlikely(err)) 175 if (unlikely(err))
173 return err; 176 return err;
174 } 177 }
175 if (need_seg == 1)
176 *offset -= 0x800;
177 178
178 return 0; 179 return 0;
179} 180}
@@ -181,32 +182,31 @@ static inline int do_select_core(struct ssb_bus *bus,
181static u16 ssb_pcmcia_read16(struct ssb_device *dev, u16 offset) 182static u16 ssb_pcmcia_read16(struct ssb_device *dev, u16 offset)
182{ 183{
183 struct ssb_bus *bus = dev->bus; 184 struct ssb_bus *bus = dev->bus;
184 u16 x;
185 185
186 if (unlikely(do_select_core(bus, dev, &offset))) 186 if (unlikely(select_core_and_segment(dev, &offset)))
187 return 0xFFFF; 187 return 0xFFFF;
188 x = readw(bus->mmio + offset);
189 188
190 return x; 189 return readw(bus->mmio + offset);
191} 190}
192 191
193static u32 ssb_pcmcia_read32(struct ssb_device *dev, u16 offset) 192static u32 ssb_pcmcia_read32(struct ssb_device *dev, u16 offset)
194{ 193{
195 struct ssb_bus *bus = dev->bus; 194 struct ssb_bus *bus = dev->bus;
196 u32 x; 195 u32 lo, hi;
197 196
198 if (unlikely(do_select_core(bus, dev, &offset))) 197 if (unlikely(select_core_and_segment(dev, &offset)))
199 return 0xFFFFFFFF; 198 return 0xFFFFFFFF;
200 x = readl(bus->mmio + offset); 199 lo = readw(bus->mmio + offset);
200 hi = readw(bus->mmio + offset + 2);
201 201
202 return x; 202 return (lo | (hi << 16));
203} 203}
204 204
205static void ssb_pcmcia_write16(struct ssb_device *dev, u16 offset, u16 value) 205static void ssb_pcmcia_write16(struct ssb_device *dev, u16 offset, u16 value)
206{ 206{
207 struct ssb_bus *bus = dev->bus; 207 struct ssb_bus *bus = dev->bus;
208 208
209 if (unlikely(do_select_core(bus, dev, &offset))) 209 if (unlikely(select_core_and_segment(dev, &offset)))
210 return; 210 return;
211 writew(value, bus->mmio + offset); 211 writew(value, bus->mmio + offset);
212} 212}
@@ -215,12 +215,12 @@ static void ssb_pcmcia_write32(struct ssb_device *dev, u16 offset, u32 value)
215{ 215{
216 struct ssb_bus *bus = dev->bus; 216 struct ssb_bus *bus = dev->bus;
217 217
218 if (unlikely(do_select_core(bus, dev, &offset))) 218 if (unlikely(select_core_and_segment(dev, &offset)))
219 return; 219 return;
220 readw(bus->mmio + offset); 220 writeb((value & 0xFF000000) >> 24, bus->mmio + offset + 3);
221 writew(value >> 16, bus->mmio + offset + 2); 221 writeb((value & 0x00FF0000) >> 16, bus->mmio + offset + 2);
222 readw(bus->mmio + offset); 222 writeb((value & 0x0000FF00) >> 8, bus->mmio + offset + 1);
223 writew(value, bus->mmio + offset); 223 writeb((value & 0x000000FF) >> 0, bus->mmio + offset + 0);
224} 224}
225 225
226/* Not "static", as it's used in main.c */ 226/* Not "static", as it's used in main.c */
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 6bfdba6a213f..1f7ab15df36d 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -1215,20 +1215,18 @@ static int keyspan_chars_in_buffer (struct usb_serial_port *port)
1215 1215
1216static int keyspan_open (struct usb_serial_port *port, struct file *filp) 1216static int keyspan_open (struct usb_serial_port *port, struct file *filp)
1217{ 1217{
1218 struct keyspan_port_private *p_priv; 1218 struct keyspan_port_private *p_priv;
1219 struct keyspan_serial_private *s_priv; 1219 struct keyspan_serial_private *s_priv;
1220 struct usb_serial *serial = port->serial; 1220 struct usb_serial *serial = port->serial;
1221 const struct keyspan_device_details *d_details; 1221 const struct keyspan_device_details *d_details;
1222 int i, err; 1222 int i, err;
1223 int baud_rate, device_port;
1224 struct urb *urb; 1223 struct urb *urb;
1225 unsigned int cflag;
1226 1224
1227 s_priv = usb_get_serial_data(serial); 1225 s_priv = usb_get_serial_data(serial);
1228 p_priv = usb_get_serial_port_data(port); 1226 p_priv = usb_get_serial_port_data(port);
1229 d_details = p_priv->device_details; 1227 d_details = p_priv->device_details;
1230 1228
1231 dbg("%s - port%d.", __FUNCTION__, port->number); 1229 dbg("%s - port%d.", __FUNCTION__, port->number);
1232 1230
1233 /* Set some sane defaults */ 1231 /* Set some sane defaults */
1234 p_priv->rts_state = 1; 1232 p_priv->rts_state = 1;
@@ -1249,7 +1247,7 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp)
1249 urb->dev = serial->dev; 1247 urb->dev = serial->dev;
1250 1248
1251 /* make sure endpoint data toggle is synchronized with the device */ 1249 /* make sure endpoint data toggle is synchronized with the device */
1252 1250
1253 usb_clear_halt(urb->dev, urb->pipe); 1251 usb_clear_halt(urb->dev, urb->pipe);
1254 1252
1255 if ((err = usb_submit_urb(urb, GFP_KERNEL)) != 0) { 1253 if ((err = usb_submit_urb(urb, GFP_KERNEL)) != 0) {
@@ -1265,30 +1263,6 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp)
1265 /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe), 0); */ 1263 /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe), 0); */
1266 } 1264 }
1267 1265
1268 /* get the terminal config for the setup message now so we don't
1269 * need to send 2 of them */
1270
1271 cflag = port->tty->termios->c_cflag;
1272 device_port = port->number - port->serial->minor;
1273
1274 /* Baud rate calculation takes baud rate as an integer
1275 so other rates can be generated if desired. */
1276 baud_rate = tty_get_baud_rate(port->tty);
1277 /* If no match or invalid, leave as default */
1278 if (baud_rate >= 0
1279 && d_details->calculate_baud_rate(baud_rate, d_details->baudclk,
1280 NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) {
1281 p_priv->baud = baud_rate;
1282 }
1283
1284 /* set CTS/RTS handshake etc. */
1285 p_priv->cflag = cflag;
1286 p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none;
1287
1288 keyspan_send_setup(port, 1);
1289 //mdelay(100);
1290 //keyspan_set_termios(port, NULL);
1291
1292 return (0); 1266 return (0);
1293} 1267}
1294 1268
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index cc4b60f899ca..7d86e9eae915 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -503,7 +503,7 @@ config FB_VALKYRIE
503 503
504config FB_CT65550 504config FB_CT65550
505 bool "Chips 65550 display support" 505 bool "Chips 65550 display support"
506 depends on (FB = y) && PPC32 506 depends on (FB = y) && PPC32 && PCI
507 select FB_CFB_FILLRECT 507 select FB_CFB_FILLRECT
508 select FB_CFB_COPYAREA 508 select FB_CFB_COPYAREA
509 select FB_CFB_IMAGEBLIT 509 select FB_CFB_IMAGEBLIT
diff --git a/drivers/video/cyber2000fb.c b/drivers/video/cyber2000fb.c
index 5fb8675e0d6b..d0e4cb618269 100644
--- a/drivers/video/cyber2000fb.c
+++ b/drivers/video/cyber2000fb.c
@@ -874,6 +874,8 @@ static int cyber2000fb_set_par(struct fb_info *info)
874 default: 874 default:
875 BUG(); 875 BUG();
876 } 876 }
877 break;
878
877 case 24:/* TRUECOLOUR, 16m */ 879 case 24:/* TRUECOLOUR, 16m */
878 hw.co_pixfmt = CO_PIXFMT_24BPP; 880 hw.co_pixfmt = CO_PIXFMT_24BPP;
879 hw.width *= 3; 881 hw.width *= 3;
diff --git a/drivers/video/gbefb.c b/drivers/video/gbefb.c
index b9b572b293d4..2e552d5bbb5d 100644
--- a/drivers/video/gbefb.c
+++ b/drivers/video/gbefb.c
@@ -183,8 +183,8 @@ static struct fb_videomode default_mode_LCD __initdata = {
183 .vmode = FB_VMODE_NONINTERLACED, 183 .vmode = FB_VMODE_NONINTERLACED,
184}; 184};
185 185
186struct fb_videomode *default_mode = &default_mode_CRT; 186struct fb_videomode *default_mode __initdata = &default_mode_CRT;
187struct fb_var_screeninfo *default_var = &default_var_CRT; 187struct fb_var_screeninfo *default_var __initdata = &default_var_CRT;
188 188
189static int flat_panel_enabled = 0; 189static int flat_panel_enabled = 0;
190 190
diff --git a/drivers/video/geode/lxfb.h b/drivers/video/geode/lxfb.h
index 6c227f9592a5..ca13c48d19b0 100644
--- a/drivers/video/geode/lxfb.h
+++ b/drivers/video/geode/lxfb.h
@@ -33,7 +33,7 @@ void lx_set_palette_reg(struct fb_info *, unsigned int, unsigned int,
33 33
34#define MSR_LX_GLD_CONFIG 0x48002001 34#define MSR_LX_GLD_CONFIG 0x48002001
35#define MSR_LX_GLCP_DOTPLL 0x4c000015 35#define MSR_LX_GLCP_DOTPLL 0x4c000015
36#define MSR_LX_DF_PADSEL 0x48000011 36#define MSR_LX_DF_PADSEL 0x48002011
37#define MSR_LX_DC_SPARE 0x80000011 37#define MSR_LX_DC_SPARE 0x80000011
38#define MSR_LX_DF_GLCONFIG 0x48002001 38#define MSR_LX_DF_GLCONFIG 0x48002001
39 39
diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c
index b3463ddcfd60..75836aa83191 100644
--- a/drivers/video/ps3fb.c
+++ b/drivers/video/ps3fb.c
@@ -727,7 +727,7 @@ static int ps3fb_blank(int blank, struct fb_info *info)
727 727
728static int ps3fb_get_vblank(struct fb_vblank *vblank) 728static int ps3fb_get_vblank(struct fb_vblank *vblank)
729{ 729{
730 memset(vblank, 0, sizeof(&vblank)); 730 memset(vblank, 0, sizeof(*vblank));
731 vblank->flags = FB_VBLANK_HAVE_VSYNC; 731 vblank->flags = FB_VBLANK_HAVE_VSYNC;
732 return 0; 732 return 0;
733} 733}
diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
index a5333c190789..b829dc7c5edf 100644
--- a/drivers/video/s1d13xxxfb.c
+++ b/drivers/video/s1d13xxxfb.c
@@ -540,7 +540,7 @@ s1d13xxxfb_probe(struct platform_device *pdev)
540 int ret = 0; 540 int ret = 0;
541 u8 revision; 541 u8 revision;
542 542
543 dbg("probe called: device is %p\n", dev); 543 dbg("probe called: device is %p\n", pdev);
544 544
545 printk(KERN_INFO "Epson S1D13XXX FB Driver\n"); 545 printk(KERN_INFO "Epson S1D13XXX FB Driver\n");
546 546
@@ -753,8 +753,11 @@ static struct platform_driver s1d13xxxfb_driver = {
753static int __init 753static int __init
754s1d13xxxfb_init(void) 754s1d13xxxfb_init(void)
755{ 755{
756
757#ifndef MODULE
756 if (fb_get_options("s1d13xxxfb", NULL)) 758 if (fb_get_options("s1d13xxxfb", NULL))
757 return -ENODEV; 759 return -ENODEV;
760#endif
758 761
759 return platform_driver_register(&s1d13xxxfb_driver); 762 return platform_driver_register(&s1d13xxxfb_driver);
760} 763}
diff --git a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c
index bc7d23683735..37bd24b8d83b 100644
--- a/drivers/video/sis/sis_main.c
+++ b/drivers/video/sis/sis_main.c
@@ -1248,7 +1248,6 @@ sisfb_do_set_var(struct fb_var_screeninfo *var, int isactive, struct fb_info *in
1248 if(found_mode) { 1248 if(found_mode) {
1249 ivideo->sisfb_mode_idx = sisfb_validate_mode(ivideo, 1249 ivideo->sisfb_mode_idx = sisfb_validate_mode(ivideo,
1250 ivideo->sisfb_mode_idx, ivideo->currentvbflags); 1250 ivideo->sisfb_mode_idx, ivideo->currentvbflags);
1251 ivideo->mode_no = sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni];
1252 } else { 1251 } else {
1253 ivideo->sisfb_mode_idx = -1; 1252 ivideo->sisfb_mode_idx = -1;
1254 } 1253 }
@@ -1260,6 +1259,8 @@ sisfb_do_set_var(struct fb_var_screeninfo *var, int isactive, struct fb_info *in
1260 return -EINVAL; 1259 return -EINVAL;
1261 } 1260 }
1262 1261
1262 ivideo->mode_no = sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni];
1263
1263 if(sisfb_search_refresh_rate(ivideo, ivideo->refresh_rate, ivideo->sisfb_mode_idx) == 0) { 1264 if(sisfb_search_refresh_rate(ivideo, ivideo->refresh_rate, ivideo->sisfb_mode_idx) == 0) {
1264 ivideo->rate_idx = sisbios_mode[ivideo->sisfb_mode_idx].rate_idx; 1265 ivideo->rate_idx = sisbios_mode[ivideo->sisfb_mode_idx].rate_idx;
1265 ivideo->refresh_rate = 60; 1266 ivideo->refresh_rate = 60;
diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
index b983d262ab78..d1d6c0facd54 100644
--- a/drivers/video/uvesafb.c
+++ b/drivers/video/uvesafb.c
@@ -926,8 +926,10 @@ static int uvesafb_setpalette(struct uvesafb_pal_entry *entries, int count,
926 int start, struct fb_info *info) 926 int start, struct fb_info *info)
927{ 927{
928 struct uvesafb_ktask *task; 928 struct uvesafb_ktask *task;
929#ifdef CONFIG_X86
929 struct uvesafb_par *par = info->par; 930 struct uvesafb_par *par = info->par;
930 int i = par->mode_idx; 931 int i = par->mode_idx;
932#endif
931 int err = 0; 933 int err = 0;
932 934
933 /* 935 /*
@@ -1103,11 +1105,11 @@ static int uvesafb_pan_display(struct fb_var_screeninfo *var,
1103 1105
1104static int uvesafb_blank(int blank, struct fb_info *info) 1106static int uvesafb_blank(int blank, struct fb_info *info)
1105{ 1107{
1106 struct uvesafb_par *par = info->par;
1107 struct uvesafb_ktask *task; 1108 struct uvesafb_ktask *task;
1108 int err = 1; 1109 int err = 1;
1109
1110#ifdef CONFIG_X86 1110#ifdef CONFIG_X86
1111 struct uvesafb_par *par = info->par;
1112
1111 if (par->vbe_ib.capabilities & VBE_CAP_VGACOMPAT) { 1113 if (par->vbe_ib.capabilities & VBE_CAP_VGACOMPAT) {
1112 int loop = 10000; 1114 int loop = 10000;
1113 u8 seq = 0, crtc17 = 0; 1115 u8 seq = 0, crtc17 = 0;
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 0e4baca21b8f..1dc04b6684e6 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -53,7 +53,7 @@ struct vring_virtqueue
53 unsigned int num_added; 53 unsigned int num_added;
54 54
55 /* Last used index we've seen. */ 55 /* Last used index we've seen. */
56 unsigned int last_used_idx; 56 u16 last_used_idx;
57 57
58 /* How to notify other side. FIXME: commonalize hcalls! */ 58 /* How to notify other side. FIXME: commonalize hcalls! */
59 void (*notify)(struct virtqueue *vq); 59 void (*notify)(struct virtqueue *vq);
@@ -277,11 +277,17 @@ struct virtqueue *vring_new_virtqueue(unsigned int num,
277 struct vring_virtqueue *vq; 277 struct vring_virtqueue *vq;
278 unsigned int i; 278 unsigned int i;
279 279
280 /* We assume num is a power of 2. */
281 if (num & (num - 1)) {
282 dev_warn(&vdev->dev, "Bad virtqueue length %u\n", num);
283 return NULL;
284 }
285
280 vq = kmalloc(sizeof(*vq) + sizeof(void *)*num, GFP_KERNEL); 286 vq = kmalloc(sizeof(*vq) + sizeof(void *)*num, GFP_KERNEL);
281 if (!vq) 287 if (!vq)
282 return NULL; 288 return NULL;
283 289
284 vring_init(&vq->vring, num, pages); 290 vring_init(&vq->vring, num, pages, PAGE_SIZE);
285 vq->vq.callback = callback; 291 vq->vq.callback = callback;
286 vq->vq.vdev = vdev; 292 vq->vq.vdev = vdev;
287 vq->vq.vq_ops = &vring_vq_ops; 293 vq->vq.vq_ops = &vring_vq_ops;
diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
index 299e274d241a..b63b5e044a4c 100644
--- a/drivers/w1/masters/ds2490.c
+++ b/drivers/w1/masters/ds2490.c
@@ -233,7 +233,7 @@ static int ds_recv_status_nodump(struct ds_device *dev, struct ds_status *st,
233{ 233{
234 int count, err; 234 int count, err;
235 235
236 memset(st, 0, sizeof(st)); 236 memset(st, 0, sizeof(*st));
237 237
238 count = 0; 238 count = 0;
239 err = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_STATUS]), buf, size, &count, 100); 239 err = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_STATUS]), buf, size, &count, 100);