aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/Kconfig1
-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/pktcdvd.c9
-rw-r--r--drivers/char/tty_ioctl.c170
-rw-r--r--drivers/firewire/fw-sbp2.c11
-rw-r--r--drivers/lguest/lguest_device.c3
-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.c3
-rw-r--r--drivers/mmc/card/queue.c2
-rw-r--r--drivers/mmc/host/sdhci.c2
-rw-r--r--drivers/net/Kconfig9
-rw-r--r--drivers/net/bonding/bond_main.c1
-rw-r--r--drivers/net/bonding/bond_sysfs.c4
-rw-r--r--drivers/net/hamradio/6pack.c26
-rw-r--r--drivers/net/irda/irtty-sir.c7
-rw-r--r--drivers/net/pasemi_mac.c18
-rw-r--r--drivers/net/ppp_async.c10
-rw-r--r--drivers/net/ppp_synctty.c10
-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/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/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.c2
-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/rtc/rtc-sh.c6
-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/ssb/main.c6
-rw-r--r--drivers/ssb/pcmcia.c56
-rw-r--r--drivers/video/cyber2000fb.c2
-rw-r--r--drivers/virtio/virtio_ring.c10
70 files changed, 697 insertions, 555 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index da3a08fa9e4f..ce9dead0f499 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -60,6 +60,7 @@ config ACPI_PROCFS
60 /proc/acpi/info (/sys/modules/acpi/parameters/acpica_version) 60 /proc/acpi/info (/sys/modules/acpi/parameters/acpica_version)
61 /proc/acpi/dsdt (/sys/firmware/acpi/tables/DSDT) 61 /proc/acpi/dsdt (/sys/firmware/acpi/tables/DSDT)
62 /proc/acpi/fadt (/sys/firmware/acpi/tables/FACP) 62 /proc/acpi/fadt (/sys/firmware/acpi/tables/FACP)
63 /proc/acpi/battery (/sys/class/power_supply)
63 /proc/acpi/debug_layer (/sys/module/acpi/parameters/debug_layer) 64 /proc/acpi/debug_layer (/sys/module/acpi/parameters/debug_layer)
64 /proc/acpi/debug_level (/sys/module/acpi/parameters/debug_level) 65 /proc/acpi/debug_level (/sys/module/acpi/parameters/debug_level)
65 66
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/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/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/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/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/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..1cfc984cc7b7 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3186,8 +3186,7 @@ static void unplug_slaves(mddev_t *mddev)
3186 atomic_inc(&rdev->nr_pending); 3186 atomic_inc(&rdev->nr_pending);
3187 rcu_read_unlock(); 3187 rcu_read_unlock();
3188 3188
3189 if (r_queue->unplug_fn) 3189 blk_unplug(r_queue);
3190 r_queue->unplug_fn(r_queue);
3191 3190
3192 rdev_dec_pending(rdev, mddev); 3191 rdev_dec_pending(rdev, mddev);
3193 rcu_read_lock(); 3192 rcu_read_lock();
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..bf8890ebbc4c 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
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 6937ef0e7275..a198404a3e36 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -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
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/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/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..8d278c87ba48 100644
--- a/drivers/net/ppp_async.c
+++ b/drivers/net/ppp_async.c
@@ -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);
diff --git a/drivers/net/ppp_synctty.c b/drivers/net/ppp_synctty.c
index ce64032a465a..00e2fb48b4ae 100644
--- a/drivers/net/ppp_synctty.c
+++ b/drivers/net/ppp_synctty.c
@@ -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);
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/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/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 4f22a7174caf..be7c9f42a340 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -8354,6 +8354,8 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8354 } 8354 }
8355 SET_IEEE80211_DEV(hw, &pdev->dev); 8355 SET_IEEE80211_DEV(hw, &pdev->dev);
8356 8356
8357 hw->rate_control_algorithm = "iwl-3945-rs";
8358
8357 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n"); 8359 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n");
8358 priv = hw->priv; 8360 priv = hw->priv;
8359 priv->hw = hw; 8361 priv->hw = hw;
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index d60adcb9bd4a..6757c6c1b25a 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -8955,6 +8955,8 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
8955 } 8955 }
8956 SET_IEEE80211_DEV(hw, &pdev->dev); 8956 SET_IEEE80211_DEV(hw, &pdev->dev);
8957 8957
8958 hw->rate_control_algorithm = "iwl-4965-rs";
8959
8958 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n"); 8960 IWL_DEBUG_INFO("*** LOAD DRIVER ***\n");
8959 priv = hw->priv; 8961 priv = hw->priv;
8960 priv->hw = hw; 8962 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/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/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/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/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/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;