aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2009-05-23 18:18:40 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-05-23 18:18:40 -0400
commitfc05505b77f7900a1bb74fb3f3a4343dee4265a4 (patch)
tree6517919cb60bd9465078512cacbefd8c77f94b76 /drivers
parenta2ab67fae1ab9226679495a8d260f4e6555efc5f (diff)
parent11c79740d3c03cb81f84e98cf2e2dbd8d9bb53cd (diff)
Merge branch 'ixp4xx' of git://git.kernel.org/pub/scm/linux/kernel/git/chris/linux-2.6 into devel
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ata/ata_piix.c18
-rw-r--r--drivers/ata/libata-core.c4
-rw-r--r--drivers/ata/libata-eh.c34
-rw-r--r--drivers/ata/libata-scsi.c38
-rw-r--r--drivers/ata/pata_pdc202xx_old.c6
-rw-r--r--drivers/ata/sata_fsl.c15
-rw-r--r--drivers/ata/sata_mv.c69
-rw-r--r--drivers/ata/sata_sx4.c180
-rw-r--r--drivers/base/iommu.c2
-rw-r--r--drivers/base/platform.c22
-rw-r--r--drivers/char/random.c19
-rw-r--r--drivers/char/sysrq.c4
-rw-r--r--drivers/char/vt_ioctl.c6
-rw-r--r--drivers/dma/dmaengine.c17
-rw-r--r--drivers/dma/dmatest.c4
-rw-r--r--drivers/dma/ioat_dma.c45
-rw-r--r--drivers/dma/ipu/ipu_idmac.c7
-rw-r--r--drivers/gpu/drm/Kconfig1
-rw-r--r--drivers/gpu/drm/drm_crtc_helper.c19
-rw-r--r--drivers/gpu/drm/drm_drv.c3
-rw-r--r--drivers/gpu/drm/drm_stub.c15
-rw-r--r--drivers/gpu/drm/drm_sysfs.c2
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c13
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h11
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c9
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h1
-rw-r--r--drivers/gpu/drm/i915/i915_suspend.c24
-rw-r--r--drivers/gpu/drm/i915/intel_crt.c2
-rw-r--r--drivers/gpu/drm/i915/intel_display.c31
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h4
-rw-r--r--drivers/gpu/drm/i915/intel_fb.c4
-rw-r--r--drivers/gpu/drm/i915/intel_hdmi.c17
-rw-r--r--drivers/gpu/drm/i915/intel_i2c.c17
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c54
-rw-r--r--drivers/gpu/drm/i915/intel_modes.c6
-rw-r--r--drivers/gpu/drm/r128/r128_cce.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_drv.h3
-rw-r--r--drivers/hid/hid-ids.h5
-rw-r--r--drivers/hid/usbhid/hid-core.c2
-rw-r--r--drivers/hid/usbhid/hid-quirks.c3
-rw-r--r--drivers/hwmon/asus_atk0110.c2
-rw-r--r--drivers/hwmon/w83781d.c3
-rw-r--r--drivers/i2c/algos/i2c-algo-bit.c2
-rw-r--r--drivers/i2c/algos/i2c-algo-pca.c11
-rw-r--r--drivers/i2c/busses/Kconfig2
-rw-r--r--drivers/i2c/busses/i2c-ali1535.c2
-rw-r--r--drivers/i2c/busses/i2c-ali15x3.c2
-rw-r--r--drivers/i2c/busses/i2c-amd756.c4
-rw-r--r--drivers/i2c/busses/i2c-cpm.c16
-rw-r--r--drivers/i2c/busses/i2c-i801.c8
-rw-r--r--drivers/i2c/busses/i2c-isch.c2
-rw-r--r--drivers/i2c/busses/i2c-mpc.c34
-rw-r--r--drivers/i2c/busses/i2c-nforce2.c2
-rw-r--r--drivers/i2c/busses/i2c-pxa.c6
-rw-r--r--drivers/i2c/busses/i2c-sis5595.c2
-rw-r--r--drivers/i2c/busses/i2c-sis630.c2
-rw-r--r--drivers/i2c/busses/i2c-sis96x.c2
-rw-r--r--drivers/infiniband/hw/cxgb3/cxio_hal.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_fs.c2
-rw-r--r--drivers/infiniband/hw/mlx4/mlx4_ib.h1
-rw-r--r--drivers/infiniband/hw/mlx4/mr.c10
-rw-r--r--drivers/infiniband/hw/mlx4/qp.c2
-rw-r--r--drivers/input/ff-memless.c2
-rw-r--r--drivers/input/joydev.c8
-rw-r--r--drivers/input/keyboard/atkbd.c16
-rw-r--r--drivers/input/touchscreen/tsc2007.c5
-rw-r--r--drivers/isdn/capi/capifs.c11
-rw-r--r--drivers/md/bitmap.c29
-rw-r--r--drivers/md/md.c70
-rw-r--r--drivers/md/raid10.c12
-rw-r--r--drivers/media/radio/radio-sf16fmi.c2
-rw-r--r--drivers/media/radio/radio-sf16fmr2.c2
-rw-r--r--drivers/media/video/cafe_ccic.c1
-rw-r--r--drivers/media/video/cx23885/cx23885-dvb.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.c9
-rw-r--r--drivers/media/video/ivtv/ivtv-gpio.c4
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c5
-rw-r--r--drivers/media/video/ivtv/ivtv-irq.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-yuv.c3
-rw-r--r--drivers/media/video/ivtv/ivtvfb.c3
-rw-r--r--drivers/media/video/uvc/uvc_driver.c9
-rw-r--r--drivers/media/video/uvc/uvc_video.c2
-rw-r--r--drivers/media/video/v4l2-ioctl.c45
-rw-r--r--drivers/media/video/zoran/zoran_driver.c28
-rw-r--r--drivers/misc/isl29003.c9
-rw-r--r--drivers/mmc/card/block.c8
-rw-r--r--drivers/mmc/core/core.c4
-rw-r--r--drivers/mmc/host/mmci.c2
-rw-r--r--drivers/mmc/host/mvsdio.c11
-rw-r--r--drivers/mmc/host/sdhci-pci.c8
-rw-r--r--drivers/mmc/host/sdhci.h2
-rw-r--r--drivers/mtd/devices/m25p80.c26
-rw-r--r--drivers/mtd/mtdcore.c18
-rw-r--r--drivers/mtd/mtdsuper.c3
-rw-r--r--drivers/net/arm/ixp4xx_eth.c56
-rw-r--r--drivers/net/bnx2.c6
-rw-r--r--drivers/net/bonding/bond_alb.c12
-rw-r--r--drivers/net/bonding/bond_main.c44
-rw-r--r--drivers/net/cxgb3/t3_hw.c2
-rw-r--r--drivers/net/e1000/e1000_main.c2
-rw-r--r--drivers/net/ehea/ehea.h2
-rw-r--r--drivers/net/ehea/ehea_main.c31
-rw-r--r--drivers/net/igb/igb_main.c12
-rw-r--r--drivers/net/mlx4/en_rx.c1
-rw-r--r--drivers/net/mv643xx_eth.c24
-rw-r--r--drivers/net/ne2k-pci.c7
-rw-r--r--drivers/net/netconsole.c11
-rw-r--r--drivers/net/usb/Kconfig14
-rw-r--r--drivers/net/usb/Makefile1
-rw-r--r--drivers/net/usb/cdc_eem.c381
-rw-r--r--drivers/net/usb/smsc95xx.c15
-rw-r--r--drivers/net/usb/smsc95xx.h3
-rw-r--r--drivers/net/virtio_net.c24
-rw-r--r--drivers/net/wan/ixp4xx_hss.c14
-rw-r--r--drivers/net/wireless/airo.c10
-rw-r--r--drivers/net/wireless/ath5k/base.c22
-rw-r--r--drivers/net/wireless/ath5k/debug.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c21
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c2
-rw-r--r--drivers/net/wireless/rndis_wlan.c14
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187.h57
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_dev.c13
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_rtl8225.c8
-rw-r--r--drivers/pci/intel-iommu.c13
-rw-r--r--drivers/pci/msi.c8
-rw-r--r--drivers/pci/pcie/aer/aerdrv.h3
-rw-r--r--drivers/pci/pcie/portdrv_pci.c2
-rw-r--r--drivers/rtc/rtc-twl4030.c4
-rw-r--r--drivers/scsi/osd/osd_uld.c20
-rw-r--r--drivers/serial/jsm/jsm.h2
-rw-r--r--drivers/serial/jsm/jsm_driver.c1
-rw-r--r--drivers/serial/nwpserial.c4
-rw-r--r--drivers/serial/s3c6400.c1
-rw-r--r--drivers/serial/samsung.c61
-rw-r--r--drivers/serial/samsung.h4
-rw-r--r--drivers/spi/pxa2xx_spi.c3
-rw-r--r--drivers/staging/comedi/TODO1
-rw-r--r--drivers/staging/rt2870/rt2870.h1
-rw-r--r--drivers/staging/rtl8187se/r8180.h2
-rw-r--r--drivers/staging/rtl8187se/r8180_core.c46
-rw-r--r--drivers/staging/winbond/wbusb.c9
-rw-r--r--drivers/usb/Makefile2
-rw-r--r--drivers/usb/atm/cxacru.c10
-rw-r--r--drivers/usb/gadget/usbstring.c6
-rw-r--r--drivers/usb/serial/ftdi_sio.c20
-rw-r--r--drivers/usb/serial/ftdi_sio.h6
-rw-r--r--drivers/usb/storage/unusual_devs.h5
-rw-r--r--drivers/video/Kconfig23
-rw-r--r--drivers/video/Makefile1
-rw-r--r--drivers/video/cfbfillrect.c36
-rw-r--r--drivers/video/fb_draw.h21
-rw-r--r--drivers/video/gbefb.c14
-rw-r--r--drivers/video/sysfillrect.c30
-rw-r--r--drivers/video/via/viafbdev.c6
-rw-r--r--drivers/xen/balloon.c3
158 files changed, 1717 insertions, 697 deletions
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 942d14ac8792..d51a17c0f59b 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -72,6 +72,7 @@
72 * ICH2 spec c #20 - IDE PRD must not cross a 64K boundary 72 * ICH2 spec c #20 - IDE PRD must not cross a 64K boundary
73 * and must be dword aligned 73 * and must be dword aligned
74 * ICH2 spec c #24 - UDMA mode 4,5 t85/86 should be 6ns not 3.3 74 * ICH2 spec c #24 - UDMA mode 4,5 t85/86 should be 6ns not 3.3
75 * ICH7 errata #16 - MWDMA1 timings are incorrect
75 * 76 *
76 * Should have been BIOS fixed: 77 * Should have been BIOS fixed:
77 * 450NX: errata #19 - DMA hangs on old 450NX 78 * 450NX: errata #19 - DMA hangs on old 450NX
@@ -94,7 +95,7 @@
94#include <linux/dmi.h> 95#include <linux/dmi.h>
95 96
96#define DRV_NAME "ata_piix" 97#define DRV_NAME "ata_piix"
97#define DRV_VERSION "2.12" 98#define DRV_VERSION "2.13"
98 99
99enum { 100enum {
100 PIIX_IOCFG = 0x54, /* IDE I/O configuration register */ 101 PIIX_IOCFG = 0x54, /* IDE I/O configuration register */
@@ -136,6 +137,7 @@ enum piix_controller_ids {
136 ich_pata_33, /* ICH up to UDMA 33 only */ 137 ich_pata_33, /* ICH up to UDMA 33 only */
137 ich_pata_66, /* ICH up to 66 Mhz */ 138 ich_pata_66, /* ICH up to 66 Mhz */
138 ich_pata_100, /* ICH up to UDMA 100 */ 139 ich_pata_100, /* ICH up to UDMA 100 */
140 ich_pata_100_nomwdma1, /* ICH up to UDMA 100 but with no MWDMA1*/
139 ich5_sata, 141 ich5_sata,
140 ich6_sata, 142 ich6_sata,
141 ich6m_sata, 143 ich6m_sata,
@@ -216,8 +218,8 @@ static const struct pci_device_id piix_pci_tbl[] = {
216 /* ICH6 (and 6) (i915) UDMA 100 */ 218 /* ICH6 (and 6) (i915) UDMA 100 */
217 { 0x8086, 0x266F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 }, 219 { 0x8086, 0x266F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
218 /* ICH7/7-R (i945, i975) UDMA 100*/ 220 /* ICH7/7-R (i945, i975) UDMA 100*/
219 { 0x8086, 0x27DF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 }, 221 { 0x8086, 0x27DF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100_nomwdma1 },
220 { 0x8086, 0x269E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 }, 222 { 0x8086, 0x269E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100_nomwdma1 },
221 /* ICH8 Mobile PATA Controller */ 223 /* ICH8 Mobile PATA Controller */
222 { 0x8086, 0x2850, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 }, 224 { 0x8086, 0x2850, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
223 225
@@ -487,6 +489,15 @@ static struct ata_port_info piix_port_info[] = {
487 .port_ops = &ich_pata_ops, 489 .port_ops = &ich_pata_ops,
488 }, 490 },
489 491
492 [ich_pata_100_nomwdma1] =
493 {
494 .flags = PIIX_PATA_FLAGS | PIIX_FLAG_CHECKINTR,
495 .pio_mask = ATA_PIO4,
496 .mwdma_mask = ATA_MWDMA2_ONLY,
497 .udma_mask = ATA_UDMA5,
498 .port_ops = &ich_pata_ops,
499 },
500
490 [ich5_sata] = 501 [ich5_sata] =
491 { 502 {
492 .flags = PIIX_SATA_FLAGS, 503 .flags = PIIX_SATA_FLAGS,
@@ -594,6 +605,7 @@ static const struct ich_laptop ich_laptop[] = {
594 { 0x24CA, 0x1025, 0x003d }, /* ICH4 on ACER TM290 */ 605 { 0x24CA, 0x1025, 0x003d }, /* ICH4 on ACER TM290 */
595 { 0x266F, 0x1025, 0x0066 }, /* ICH6 on ACER Aspire 1694WLMi */ 606 { 0x266F, 0x1025, 0x0066 }, /* ICH6 on ACER Aspire 1694WLMi */
596 { 0x2653, 0x1043, 0x82D8 }, /* ICH6M on Asus Eee 701 */ 607 { 0x2653, 0x1043, 0x82D8 }, /* ICH6M on Asus Eee 701 */
608 { 0x27df, 0x104d, 0x900e }, /* ICH7 on Sony TZ-90 */
597 /* end marker */ 609 /* end marker */
598 { 0, } 610 { 0, }
599}; 611};
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 17c5d48a75d2..c9242301cfa1 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4091,7 +4091,9 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,
4091 4091
4092 /* fail early if !ATA && !ATAPI to avoid issuing [P]IDENTIFY to PMP */ 4092 /* fail early if !ATA && !ATAPI to avoid issuing [P]IDENTIFY to PMP */
4093 if (ata_class_enabled(new_class) && 4093 if (ata_class_enabled(new_class) &&
4094 new_class != ATA_DEV_ATA && new_class != ATA_DEV_ATAPI) { 4094 new_class != ATA_DEV_ATA &&
4095 new_class != ATA_DEV_ATAPI &&
4096 new_class != ATA_DEV_SEMB) {
4095 ata_dev_printk(dev, KERN_INFO, "class mismatch %u != %u\n", 4097 ata_dev_printk(dev, KERN_INFO, "class mismatch %u != %u\n",
4096 dev->class, new_class); 4098 dev->class, new_class);
4097 rc = -ENODEV; 4099 rc = -ENODEV;
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 01831312c360..94919ad03df1 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -2783,6 +2783,12 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
2783 } else if (dev->class == ATA_DEV_UNKNOWN && 2783 } else if (dev->class == ATA_DEV_UNKNOWN &&
2784 ehc->tries[dev->devno] && 2784 ehc->tries[dev->devno] &&
2785 ata_class_enabled(ehc->classes[dev->devno])) { 2785 ata_class_enabled(ehc->classes[dev->devno])) {
2786 /* Temporarily set dev->class, it will be
2787 * permanently set once all configurations are
2788 * complete. This is necessary because new
2789 * device configuration is done in two
2790 * separate loops.
2791 */
2786 dev->class = ehc->classes[dev->devno]; 2792 dev->class = ehc->classes[dev->devno];
2787 2793
2788 if (dev->class == ATA_DEV_PMP) 2794 if (dev->class == ATA_DEV_PMP)
@@ -2790,6 +2796,11 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
2790 else 2796 else
2791 rc = ata_dev_read_id(dev, &dev->class, 2797 rc = ata_dev_read_id(dev, &dev->class,
2792 readid_flags, dev->id); 2798 readid_flags, dev->id);
2799
2800 /* read_id might have changed class, store and reset */
2801 ehc->classes[dev->devno] = dev->class;
2802 dev->class = ATA_DEV_UNKNOWN;
2803
2793 switch (rc) { 2804 switch (rc) {
2794 case 0: 2805 case 0:
2795 /* clear error info accumulated during probe */ 2806 /* clear error info accumulated during probe */
@@ -2799,13 +2810,11 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
2799 case -ENOENT: 2810 case -ENOENT:
2800 /* IDENTIFY was issued to non-existent 2811 /* IDENTIFY was issued to non-existent
2801 * device. No need to reset. Just 2812 * device. No need to reset. Just
2802 * thaw and kill the device. 2813 * thaw and ignore the device.
2803 */ 2814 */
2804 ata_eh_thaw_port(ap); 2815 ata_eh_thaw_port(ap);
2805 dev->class = ATA_DEV_UNKNOWN;
2806 break; 2816 break;
2807 default: 2817 default:
2808 dev->class = ATA_DEV_UNKNOWN;
2809 goto err; 2818 goto err;
2810 } 2819 }
2811 } 2820 }
@@ -2826,11 +2835,15 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
2826 dev->class == ATA_DEV_PMP) 2835 dev->class == ATA_DEV_PMP)
2827 continue; 2836 continue;
2828 2837
2838 dev->class = ehc->classes[dev->devno];
2839
2829 ehc->i.flags |= ATA_EHI_PRINTINFO; 2840 ehc->i.flags |= ATA_EHI_PRINTINFO;
2830 rc = ata_dev_configure(dev); 2841 rc = ata_dev_configure(dev);
2831 ehc->i.flags &= ~ATA_EHI_PRINTINFO; 2842 ehc->i.flags &= ~ATA_EHI_PRINTINFO;
2832 if (rc) 2843 if (rc) {
2844 dev->class = ATA_DEV_UNKNOWN;
2833 goto err; 2845 goto err;
2846 }
2834 2847
2835 spin_lock_irqsave(ap->lock, flags); 2848 spin_lock_irqsave(ap->lock, flags);
2836 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; 2849 ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG;
@@ -3494,6 +3507,8 @@ static void ata_eh_handle_port_suspend(struct ata_port *ap)
3494 */ 3507 */
3495static void ata_eh_handle_port_resume(struct ata_port *ap) 3508static void ata_eh_handle_port_resume(struct ata_port *ap)
3496{ 3509{
3510 struct ata_link *link;
3511 struct ata_device *dev;
3497 unsigned long flags; 3512 unsigned long flags;
3498 int rc = 0; 3513 int rc = 0;
3499 3514
@@ -3508,6 +3523,17 @@ static void ata_eh_handle_port_resume(struct ata_port *ap)
3508 3523
3509 WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED)); 3524 WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED));
3510 3525
3526 /*
3527 * Error timestamps are in jiffies which doesn't run while
3528 * suspended and PHY events during resume isn't too uncommon.
3529 * When the two are combined, it can lead to unnecessary speed
3530 * downs if the machine is suspended and resumed repeatedly.
3531 * Clear error history.
3532 */
3533 ata_for_each_link(link, ap, HOST_FIRST)
3534 ata_for_each_dev(dev, link, ALL)
3535 ata_ering_clear(&dev->ering);
3536
3511 ata_acpi_set_state(ap, PMSG_ON); 3537 ata_acpi_set_state(ap, PMSG_ON);
3512 3538
3513 if (ap->ops->port_resume) 3539 if (ap->ops->port_resume)
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 2733b0c90b75..342316064e9f 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -313,7 +313,7 @@ ata_scsi_em_message_show(struct device *dev, struct device_attribute *attr,
313 return ap->ops->em_show(ap, buf); 313 return ap->ops->em_show(ap, buf);
314 return -EINVAL; 314 return -EINVAL;
315} 315}
316DEVICE_ATTR(em_message, S_IRUGO | S_IWUGO, 316DEVICE_ATTR(em_message, S_IRUGO | S_IWUSR,
317 ata_scsi_em_message_show, ata_scsi_em_message_store); 317 ata_scsi_em_message_show, ata_scsi_em_message_store);
318EXPORT_SYMBOL_GPL(dev_attr_em_message); 318EXPORT_SYMBOL_GPL(dev_attr_em_message);
319 319
@@ -366,7 +366,7 @@ ata_scsi_activity_store(struct device *dev, struct device_attribute *attr,
366 } 366 }
367 return -EINVAL; 367 return -EINVAL;
368} 368}
369DEVICE_ATTR(sw_activity, S_IWUGO | S_IRUGO, ata_scsi_activity_show, 369DEVICE_ATTR(sw_activity, S_IWUSR | S_IRUGO, ata_scsi_activity_show,
370 ata_scsi_activity_store); 370 ata_scsi_activity_store);
371EXPORT_SYMBOL_GPL(dev_attr_sw_activity); 371EXPORT_SYMBOL_GPL(dev_attr_sw_activity);
372 372
@@ -2142,13 +2142,14 @@ static unsigned int ata_scsiop_inq_89(struct ata_scsi_args *args, u8 *rbuf)
2142 2142
2143static unsigned int ata_scsiop_inq_b1(struct ata_scsi_args *args, u8 *rbuf) 2143static unsigned int ata_scsiop_inq_b1(struct ata_scsi_args *args, u8 *rbuf)
2144{ 2144{
2145 int form_factor = ata_id_form_factor(args->id);
2146 int media_rotation_rate = ata_id_rotation_rate(args->id);
2147
2145 rbuf[1] = 0xb1; 2148 rbuf[1] = 0xb1;
2146 rbuf[3] = 0x3c; 2149 rbuf[3] = 0x3c;
2147 if (ata_id_major_version(args->id) > 7) { 2150 rbuf[4] = media_rotation_rate >> 8;
2148 rbuf[4] = args->id[217] >> 8; 2151 rbuf[5] = media_rotation_rate;
2149 rbuf[5] = args->id[217]; 2152 rbuf[7] = form_factor;
2150 rbuf[7] = args->id[168] & 0xf;
2151 }
2152 2153
2153 return 0; 2154 return 0;
2154} 2155}
@@ -2376,7 +2377,23 @@ saving_not_supp:
2376 */ 2377 */
2377static unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf) 2378static unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf)
2378{ 2379{
2379 u64 last_lba = args->dev->n_sectors - 1; /* LBA of the last block */ 2380 struct ata_device *dev = args->dev;
2381 u64 last_lba = dev->n_sectors - 1; /* LBA of the last block */
2382 u8 log_per_phys = 0;
2383 u16 lowest_aligned = 0;
2384 u16 word_106 = dev->id[106];
2385 u16 word_209 = dev->id[209];
2386
2387 if ((word_106 & 0xc000) == 0x4000) {
2388 /* Number and offset of logical sectors per physical sector */
2389 if (word_106 & (1 << 13))
2390 log_per_phys = word_106 & 0xf;
2391 if ((word_209 & 0xc000) == 0x4000) {
2392 u16 first = dev->id[209] & 0x3fff;
2393 if (first > 0)
2394 lowest_aligned = (1 << log_per_phys) - first;
2395 }
2396 }
2380 2397
2381 VPRINTK("ENTER\n"); 2398 VPRINTK("ENTER\n");
2382 2399
@@ -2407,6 +2424,11 @@ static unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf)
2407 /* sector size */ 2424 /* sector size */
2408 rbuf[10] = ATA_SECT_SIZE >> 8; 2425 rbuf[10] = ATA_SECT_SIZE >> 8;
2409 rbuf[11] = ATA_SECT_SIZE & 0xff; 2426 rbuf[11] = ATA_SECT_SIZE & 0xff;
2427
2428 rbuf[12] = 0;
2429 rbuf[13] = log_per_phys;
2430 rbuf[14] = (lowest_aligned >> 8) & 0x3f;
2431 rbuf[15] = lowest_aligned;
2410 } 2432 }
2411 2433
2412 return 0; 2434 return 0;
diff --git a/drivers/ata/pata_pdc202xx_old.c b/drivers/ata/pata_pdc202xx_old.c
index 5fedb3d4032b..2f3c9bed63d9 100644
--- a/drivers/ata/pata_pdc202xx_old.c
+++ b/drivers/ata/pata_pdc202xx_old.c
@@ -2,7 +2,7 @@
2 * pata_pdc202xx_old.c - Promise PDC202xx PATA for new ATA layer 2 * pata_pdc202xx_old.c - Promise PDC202xx PATA for new ATA layer
3 * (C) 2005 Red Hat Inc 3 * (C) 2005 Red Hat Inc
4 * Alan Cox <alan@lxorguk.ukuu.org.uk> 4 * Alan Cox <alan@lxorguk.ukuu.org.uk>
5 * (C) 2007 Bartlomiej Zolnierkiewicz 5 * (C) 2007,2009 Bartlomiej Zolnierkiewicz
6 * 6 *
7 * Based in part on linux/drivers/ide/pci/pdc202xx_old.c 7 * Based in part on linux/drivers/ide/pci/pdc202xx_old.c
8 * 8 *
@@ -158,7 +158,7 @@ static void pdc2026x_bmdma_start(struct ata_queued_cmd *qc)
158 u32 len; 158 u32 len;
159 159
160 /* Check we keep host level locking here */ 160 /* Check we keep host level locking here */
161 if (adev->dma_mode >= XFER_UDMA_2) 161 if (adev->dma_mode > XFER_UDMA_2)
162 iowrite8(ioread8(clock) | sel66, clock); 162 iowrite8(ioread8(clock) | sel66, clock);
163 else 163 else
164 iowrite8(ioread8(clock) & ~sel66, clock); 164 iowrite8(ioread8(clock) & ~sel66, clock);
@@ -212,7 +212,7 @@ static void pdc2026x_bmdma_stop(struct ata_queued_cmd *qc)
212 iowrite8(ioread8(clock) & ~sel66, clock); 212 iowrite8(ioread8(clock) & ~sel66, clock);
213 } 213 }
214 /* Flip back to 33Mhz for PIO */ 214 /* Flip back to 33Mhz for PIO */
215 if (adev->dma_mode >= XFER_UDMA_2) 215 if (adev->dma_mode > XFER_UDMA_2)
216 iowrite8(ioread8(clock) & ~sel66, clock); 216 iowrite8(ioread8(clock) & ~sel66, clock);
217 ata_bmdma_stop(qc); 217 ata_bmdma_stop(qc);
218 pdc202xx_set_piomode(ap, adev); 218 pdc202xx_set_piomode(ap, adev);
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
index c2e90e1fece0..36b8629203be 100644
--- a/drivers/ata/sata_fsl.c
+++ b/drivers/ata/sata_fsl.c
@@ -205,6 +205,7 @@ struct cmdhdr_tbl_entry {
205 * Description information bitdefs 205 * Description information bitdefs
206 */ 206 */
207enum { 207enum {
208 CMD_DESC_RES = (1 << 11),
208 VENDOR_SPECIFIC_BIST = (1 << 10), 209 VENDOR_SPECIFIC_BIST = (1 << 10),
209 CMD_DESC_SNOOP_ENABLE = (1 << 9), 210 CMD_DESC_SNOOP_ENABLE = (1 << 9),
210 FPDMA_QUEUED_CMD = (1 << 8), 211 FPDMA_QUEUED_CMD = (1 << 8),
@@ -332,13 +333,14 @@ static unsigned int sata_fsl_fill_sg(struct ata_queued_cmd *qc, void *cmd_desc,
332 dma_addr_t sg_addr = sg_dma_address(sg); 333 dma_addr_t sg_addr = sg_dma_address(sg);
333 u32 sg_len = sg_dma_len(sg); 334 u32 sg_len = sg_dma_len(sg);
334 335
335 VPRINTK("SATA FSL : fill_sg, sg_addr = 0x%x, sg_len = %d\n", 336 VPRINTK("SATA FSL : fill_sg, sg_addr = 0x%llx, sg_len = %d\n",
336 sg_addr, sg_len); 337 (unsigned long long)sg_addr, sg_len);
337 338
338 /* warn if each s/g element is not dword aligned */ 339 /* warn if each s/g element is not dword aligned */
339 if (sg_addr & 0x03) 340 if (sg_addr & 0x03)
340 ata_port_printk(qc->ap, KERN_ERR, 341 ata_port_printk(qc->ap, KERN_ERR,
341 "s/g addr unaligned : 0x%x\n", sg_addr); 342 "s/g addr unaligned : 0x%llx\n",
343 (unsigned long long)sg_addr);
342 if (sg_len & 0x03) 344 if (sg_len & 0x03)
343 ata_port_printk(qc->ap, KERN_ERR, 345 ata_port_printk(qc->ap, KERN_ERR,
344 "s/g len unaligned : 0x%x\n", sg_len); 346 "s/g len unaligned : 0x%x\n", sg_len);
@@ -387,7 +389,7 @@ static void sata_fsl_qc_prep(struct ata_queued_cmd *qc)
387 void __iomem *hcr_base = host_priv->hcr_base; 389 void __iomem *hcr_base = host_priv->hcr_base;
388 unsigned int tag = sata_fsl_tag(qc->tag, hcr_base); 390 unsigned int tag = sata_fsl_tag(qc->tag, hcr_base);
389 struct command_desc *cd; 391 struct command_desc *cd;
390 u32 desc_info = CMD_DESC_SNOOP_ENABLE; 392 u32 desc_info = CMD_DESC_RES | CMD_DESC_SNOOP_ENABLE;
391 u32 num_prde = 0; 393 u32 num_prde = 0;
392 u32 ttl_dwords = 0; 394 u32 ttl_dwords = 0;
393 dma_addr_t cd_paddr; 395 dma_addr_t cd_paddr;
@@ -840,7 +842,7 @@ issue_srst:
840 842
841 /* device reset/SRST is a control register update FIS, uses tag0 */ 843 /* device reset/SRST is a control register update FIS, uses tag0 */
842 sata_fsl_setup_cmd_hdr_entry(pp, 0, 844 sata_fsl_setup_cmd_hdr_entry(pp, 0,
843 SRST_CMD | CMD_DESC_SNOOP_ENABLE, 0, 0, 5); 845 SRST_CMD | CMD_DESC_RES | CMD_DESC_SNOOP_ENABLE, 0, 0, 5);
844 846
845 tf.ctl |= ATA_SRST; /* setup SRST bit in taskfile control reg */ 847 tf.ctl |= ATA_SRST; /* setup SRST bit in taskfile control reg */
846 ata_tf_to_fis(&tf, pmp, 0, cfis); 848 ata_tf_to_fis(&tf, pmp, 0, cfis);
@@ -886,7 +888,8 @@ issue_srst:
886 * using ATA signature D2H register FIS to the host controller. 888 * using ATA signature D2H register FIS to the host controller.
887 */ 889 */
888 890
889 sata_fsl_setup_cmd_hdr_entry(pp, 0, CMD_DESC_SNOOP_ENABLE, 0, 0, 5); 891 sata_fsl_setup_cmd_hdr_entry(pp, 0, CMD_DESC_RES | CMD_DESC_SNOOP_ENABLE,
892 0, 0, 5);
890 893
891 tf.ctl &= ~ATA_SRST; /* 2nd H2D Ctl. register FIS */ 894 tf.ctl &= ~ATA_SRST; /* 2nd H2D Ctl. register FIS */
892 ata_tf_to_fis(&tf, pmp, 0, cfis); 895 ata_tf_to_fis(&tf, pmp, 0, cfis);
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 870dcfd82357..23714aefb825 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -293,6 +293,10 @@ enum {
293 FISCFG_WAIT_DEV_ERR = (1 << 8), /* wait for host on DevErr */ 293 FISCFG_WAIT_DEV_ERR = (1 << 8), /* wait for host on DevErr */
294 FISCFG_SINGLE_SYNC = (1 << 16), /* SYNC on DMA activation */ 294 FISCFG_SINGLE_SYNC = (1 << 16), /* SYNC on DMA activation */
295 295
296 PHY_MODE9_GEN2 = 0x398,
297 PHY_MODE9_GEN1 = 0x39c,
298 PHYCFG_OFS = 0x3a0, /* only in 65n devices */
299
296 MV5_PHY_MODE = 0x74, 300 MV5_PHY_MODE = 0x74,
297 MV5_LTMODE = 0x30, 301 MV5_LTMODE = 0x30,
298 MV5_PHY_CTL = 0x0C, 302 MV5_PHY_CTL = 0x0C,
@@ -609,6 +613,8 @@ static int mv_soc_reset_hc(struct mv_host_priv *hpriv,
609static void mv_soc_reset_flash(struct mv_host_priv *hpriv, 613static void mv_soc_reset_flash(struct mv_host_priv *hpriv,
610 void __iomem *mmio); 614 void __iomem *mmio);
611static void mv_soc_reset_bus(struct ata_host *host, void __iomem *mmio); 615static void mv_soc_reset_bus(struct ata_host *host, void __iomem *mmio);
616static void mv_soc_65n_phy_errata(struct mv_host_priv *hpriv,
617 void __iomem *mmio, unsigned int port);
612static void mv_reset_pci_bus(struct ata_host *host, void __iomem *mmio); 618static void mv_reset_pci_bus(struct ata_host *host, void __iomem *mmio);
613static void mv_reset_channel(struct mv_host_priv *hpriv, void __iomem *mmio, 619static void mv_reset_channel(struct mv_host_priv *hpriv, void __iomem *mmio,
614 unsigned int port_no); 620 unsigned int port_no);
@@ -807,6 +813,14 @@ static const struct mv_hw_ops mv_soc_ops = {
807 .reset_bus = mv_soc_reset_bus, 813 .reset_bus = mv_soc_reset_bus,
808}; 814};
809 815
816static const struct mv_hw_ops mv_soc_65n_ops = {
817 .phy_errata = mv_soc_65n_phy_errata,
818 .enable_leds = mv_soc_enable_leds,
819 .reset_hc = mv_soc_reset_hc,
820 .reset_flash = mv_soc_reset_flash,
821 .reset_bus = mv_soc_reset_bus,
822};
823
810/* 824/*
811 * Functions 825 * Functions
812 */ 826 */
@@ -3397,6 +3411,53 @@ static void mv_soc_reset_bus(struct ata_host *host, void __iomem *mmio)
3397 return; 3411 return;
3398} 3412}
3399 3413
3414static void mv_soc_65n_phy_errata(struct mv_host_priv *hpriv,
3415 void __iomem *mmio, unsigned int port)
3416{
3417 void __iomem *port_mmio = mv_port_base(mmio, port);
3418 u32 reg;
3419
3420 reg = readl(port_mmio + PHY_MODE3);
3421 reg &= ~(0x3 << 27); /* SELMUPF (bits 28:27) to 1 */
3422 reg |= (0x1 << 27);
3423 reg &= ~(0x3 << 29); /* SELMUPI (bits 30:29) to 1 */
3424 reg |= (0x1 << 29);
3425 writel(reg, port_mmio + PHY_MODE3);
3426
3427 reg = readl(port_mmio + PHY_MODE4);
3428 reg &= ~0x1; /* SATU_OD8 (bit 0) to 0, reserved bit 16 must be set */
3429 reg |= (0x1 << 16);
3430 writel(reg, port_mmio + PHY_MODE4);
3431
3432 reg = readl(port_mmio + PHY_MODE9_GEN2);
3433 reg &= ~0xf; /* TXAMP[3:0] (bits 3:0) to 8 */
3434 reg |= 0x8;
3435 reg &= ~(0x1 << 14); /* TXAMP[4] (bit 14) to 0 */
3436 writel(reg, port_mmio + PHY_MODE9_GEN2);
3437
3438 reg = readl(port_mmio + PHY_MODE9_GEN1);
3439 reg &= ~0xf; /* TXAMP[3:0] (bits 3:0) to 8 */
3440 reg |= 0x8;
3441 reg &= ~(0x1 << 14); /* TXAMP[4] (bit 14) to 0 */
3442 writel(reg, port_mmio + PHY_MODE9_GEN1);
3443}
3444
3445/**
3446 * soc_is_65 - check if the soc is 65 nano device
3447 *
3448 * Detect the type of the SoC, this is done by reading the PHYCFG_OFS
3449 * register, this register should contain non-zero value and it exists only
3450 * in the 65 nano devices, when reading it from older devices we get 0.
3451 */
3452static bool soc_is_65n(struct mv_host_priv *hpriv)
3453{
3454 void __iomem *port0_mmio = mv_port_base(hpriv->base, 0);
3455
3456 if (readl(port0_mmio + PHYCFG_OFS))
3457 return true;
3458 return false;
3459}
3460
3400static void mv_setup_ifcfg(void __iomem *port_mmio, int want_gen2i) 3461static void mv_setup_ifcfg(void __iomem *port_mmio, int want_gen2i)
3401{ 3462{
3402 u32 ifcfg = readl(port_mmio + SATA_IFCFG); 3463 u32 ifcfg = readl(port_mmio + SATA_IFCFG);
@@ -3737,7 +3798,10 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)
3737 } 3798 }
3738 break; 3799 break;
3739 case chip_soc: 3800 case chip_soc:
3740 hpriv->ops = &mv_soc_ops; 3801 if (soc_is_65n(hpriv))
3802 hpriv->ops = &mv_soc_65n_ops;
3803 else
3804 hpriv->ops = &mv_soc_ops;
3741 hp_flags |= MV_HP_FLAG_SOC | MV_HP_GEN_IIE | 3805 hp_flags |= MV_HP_FLAG_SOC | MV_HP_GEN_IIE |
3742 MV_HP_ERRATA_60X1C0; 3806 MV_HP_ERRATA_60X1C0;
3743 break; 3807 break;
@@ -3800,7 +3864,8 @@ static int mv_init_host(struct ata_host *host, unsigned int board_idx)
3800 n_hc = mv_get_hc_count(host->ports[0]->flags); 3864 n_hc = mv_get_hc_count(host->ports[0]->flags);
3801 3865
3802 for (port = 0; port < host->n_ports; port++) 3866 for (port = 0; port < host->n_ports; port++)
3803 hpriv->ops->read_preamp(hpriv, port, mmio); 3867 if (hpriv->ops->read_preamp)
3868 hpriv->ops->read_preamp(hpriv, port, mmio);
3804 3869
3805 rc = hpriv->ops->reset_hc(hpriv, mmio, n_hc); 3870 rc = hpriv->ops->reset_hc(hpriv, mmio, n_hc);
3806 if (rc) 3871 if (rc)
diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c
index dce3dccced3f..eb05a3c82a9e 100644
--- a/drivers/ata/sata_sx4.c
+++ b/drivers/ata/sata_sx4.c
@@ -213,8 +213,9 @@ struct pdc_host_priv {
213 213
214 214
215static int pdc_sata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); 215static int pdc_sata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
216static void pdc_eng_timeout(struct ata_port *ap); 216static void pdc_error_handler(struct ata_port *ap);
217static void pdc_20621_phy_reset(struct ata_port *ap); 217static void pdc_freeze(struct ata_port *ap);
218static void pdc_thaw(struct ata_port *ap);
218static int pdc_port_start(struct ata_port *ap); 219static int pdc_port_start(struct ata_port *ap);
219static void pdc20621_qc_prep(struct ata_queued_cmd *qc); 220static void pdc20621_qc_prep(struct ata_queued_cmd *qc);
220static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); 221static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
@@ -233,6 +234,10 @@ static void pdc20621_put_to_dimm(struct ata_host *host,
233 void *psource, u32 offset, u32 size); 234 void *psource, u32 offset, u32 size);
234static void pdc20621_irq_clear(struct ata_port *ap); 235static void pdc20621_irq_clear(struct ata_port *ap);
235static unsigned int pdc20621_qc_issue(struct ata_queued_cmd *qc); 236static unsigned int pdc20621_qc_issue(struct ata_queued_cmd *qc);
237static int pdc_softreset(struct ata_link *link, unsigned int *class,
238 unsigned long deadline);
239static void pdc_post_internal_cmd(struct ata_queued_cmd *qc);
240static int pdc_check_atapi_dma(struct ata_queued_cmd *qc);
236 241
237 242
238static struct scsi_host_template pdc_sata_sht = { 243static struct scsi_host_template pdc_sata_sht = {
@@ -243,20 +248,24 @@ static struct scsi_host_template pdc_sata_sht = {
243 248
244/* TODO: inherit from base port_ops after converting to new EH */ 249/* TODO: inherit from base port_ops after converting to new EH */
245static struct ata_port_operations pdc_20621_ops = { 250static struct ata_port_operations pdc_20621_ops = {
246 .sff_tf_load = pdc_tf_load_mmio, 251 .inherits = &ata_sff_port_ops,
247 .sff_tf_read = ata_sff_tf_read, 252
248 .sff_check_status = ata_sff_check_status, 253 .check_atapi_dma = pdc_check_atapi_dma,
249 .sff_exec_command = pdc_exec_command_mmio,
250 .sff_dev_select = ata_sff_dev_select,
251 .phy_reset = pdc_20621_phy_reset,
252 .qc_prep = pdc20621_qc_prep, 254 .qc_prep = pdc20621_qc_prep,
253 .qc_issue = pdc20621_qc_issue, 255 .qc_issue = pdc20621_qc_issue,
254 .qc_fill_rtf = ata_sff_qc_fill_rtf, 256
255 .sff_data_xfer = ata_sff_data_xfer, 257 .freeze = pdc_freeze,
256 .eng_timeout = pdc_eng_timeout, 258 .thaw = pdc_thaw,
257 .sff_irq_clear = pdc20621_irq_clear, 259 .softreset = pdc_softreset,
258 .sff_irq_on = ata_sff_irq_on, 260 .error_handler = pdc_error_handler,
261 .lost_interrupt = ATA_OP_NULL,
262 .post_internal_cmd = pdc_post_internal_cmd,
263
259 .port_start = pdc_port_start, 264 .port_start = pdc_port_start,
265
266 .sff_tf_load = pdc_tf_load_mmio,
267 .sff_exec_command = pdc_exec_command_mmio,
268 .sff_irq_clear = pdc20621_irq_clear,
260}; 269};
261 270
262static const struct ata_port_info pdc_port_info[] = { 271static const struct ata_port_info pdc_port_info[] = {
@@ -310,14 +319,6 @@ static int pdc_port_start(struct ata_port *ap)
310 return 0; 319 return 0;
311} 320}
312 321
313static void pdc_20621_phy_reset(struct ata_port *ap)
314{
315 VPRINTK("ENTER\n");
316 ap->cbl = ATA_CBL_SATA;
317 ata_port_probe(ap);
318 ata_bus_reset(ap);
319}
320
321static inline void pdc20621_ata_sg(struct ata_taskfile *tf, u8 *buf, 322static inline void pdc20621_ata_sg(struct ata_taskfile *tf, u8 *buf,
322 unsigned int portno, 323 unsigned int portno,
323 unsigned int total_len) 324 unsigned int total_len)
@@ -686,8 +687,11 @@ static void pdc20621_packet_start(struct ata_queued_cmd *qc)
686static unsigned int pdc20621_qc_issue(struct ata_queued_cmd *qc) 687static unsigned int pdc20621_qc_issue(struct ata_queued_cmd *qc)
687{ 688{
688 switch (qc->tf.protocol) { 689 switch (qc->tf.protocol) {
689 case ATA_PROT_DMA:
690 case ATA_PROT_NODATA: 690 case ATA_PROT_NODATA:
691 if (qc->tf.flags & ATA_TFLAG_POLLING)
692 break;
693 /*FALLTHROUGH*/
694 case ATA_PROT_DMA:
691 pdc20621_packet_start(qc); 695 pdc20621_packet_start(qc);
692 return 0; 696 return 0;
693 697
@@ -786,12 +790,7 @@ static inline unsigned int pdc20621_host_intr(struct ata_port *ap,
786 790
787static void pdc20621_irq_clear(struct ata_port *ap) 791static void pdc20621_irq_clear(struct ata_port *ap)
788{ 792{
789 struct ata_host *host = ap->host; 793 ioread8(ap->ioaddr.status_addr);
790 void __iomem *mmio = host->iomap[PDC_MMIO_BAR];
791
792 mmio += PDC_CHIP0_OFS;
793
794 readl(mmio + PDC_20621_SEQMASK);
795} 794}
796 795
797static irqreturn_t pdc20621_interrupt(int irq, void *dev_instance) 796static irqreturn_t pdc20621_interrupt(int irq, void *dev_instance)
@@ -859,46 +858,119 @@ static irqreturn_t pdc20621_interrupt(int irq, void *dev_instance)
859 return IRQ_RETVAL(handled); 858 return IRQ_RETVAL(handled);
860} 859}
861 860
862static void pdc_eng_timeout(struct ata_port *ap) 861static void pdc_freeze(struct ata_port *ap)
863{ 862{
864 u8 drv_stat; 863 void __iomem *mmio = ap->ioaddr.cmd_addr;
865 struct ata_host *host = ap->host; 864 u32 tmp;
866 struct ata_queued_cmd *qc;
867 unsigned long flags;
868 865
869 DPRINTK("ENTER\n"); 866 /* FIXME: if all 4 ATA engines are stopped, also stop HDMA engine */
870 867
871 spin_lock_irqsave(&host->lock, flags); 868 tmp = readl(mmio + PDC_CTLSTAT);
869 tmp |= PDC_MASK_INT;
870 tmp &= ~PDC_DMA_ENABLE;
871 writel(tmp, mmio + PDC_CTLSTAT);
872 readl(mmio + PDC_CTLSTAT); /* flush */
873}
872 874
873 qc = ata_qc_from_tag(ap, ap->link.active_tag); 875static void pdc_thaw(struct ata_port *ap)
876{
877 void __iomem *mmio = ap->ioaddr.cmd_addr;
878 u32 tmp;
874 879
875 switch (qc->tf.protocol) { 880 /* FIXME: start HDMA engine, if zero ATA engines running */
876 case ATA_PROT_DMA:
877 case ATA_PROT_NODATA:
878 ata_port_printk(ap, KERN_ERR, "command timeout\n");
879 qc->err_mask |= __ac_err_mask(ata_wait_idle(ap));
880 break;
881 881
882 default: 882 /* clear IRQ */
883 drv_stat = ata_sff_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); 883 ioread8(ap->ioaddr.status_addr);
884 884
885 ata_port_printk(ap, KERN_ERR, 885 /* turn IRQ back on */
886 "unknown timeout, cmd 0x%x stat 0x%x\n", 886 tmp = readl(mmio + PDC_CTLSTAT);
887 qc->tf.command, drv_stat); 887 tmp &= ~PDC_MASK_INT;
888 writel(tmp, mmio + PDC_CTLSTAT);
889 readl(mmio + PDC_CTLSTAT); /* flush */
890}
888 891
889 qc->err_mask |= ac_err_mask(drv_stat); 892static void pdc_reset_port(struct ata_port *ap)
890 break; 893{
894 void __iomem *mmio = ap->ioaddr.cmd_addr + PDC_CTLSTAT;
895 unsigned int i;
896 u32 tmp;
897
898 /* FIXME: handle HDMA copy engine */
899
900 for (i = 11; i > 0; i--) {
901 tmp = readl(mmio);
902 if (tmp & PDC_RESET)
903 break;
904
905 udelay(100);
906
907 tmp |= PDC_RESET;
908 writel(tmp, mmio);
891 } 909 }
892 910
893 spin_unlock_irqrestore(&host->lock, flags); 911 tmp &= ~PDC_RESET;
894 ata_eh_qc_complete(qc); 912 writel(tmp, mmio);
895 DPRINTK("EXIT\n"); 913 readl(mmio); /* flush */
914}
915
916static int pdc_softreset(struct ata_link *link, unsigned int *class,
917 unsigned long deadline)
918{
919 pdc_reset_port(link->ap);
920 return ata_sff_softreset(link, class, deadline);
921}
922
923static void pdc_error_handler(struct ata_port *ap)
924{
925 if (!(ap->pflags & ATA_PFLAG_FROZEN))
926 pdc_reset_port(ap);
927
928 ata_std_error_handler(ap);
929}
930
931static void pdc_post_internal_cmd(struct ata_queued_cmd *qc)
932{
933 struct ata_port *ap = qc->ap;
934
935 /* make DMA engine forget about the failed command */
936 if (qc->flags & ATA_QCFLAG_FAILED)
937 pdc_reset_port(ap);
938}
939
940static int pdc_check_atapi_dma(struct ata_queued_cmd *qc)
941{
942 u8 *scsicmd = qc->scsicmd->cmnd;
943 int pio = 1; /* atapi dma off by default */
944
945 /* Whitelist commands that may use DMA. */
946 switch (scsicmd[0]) {
947 case WRITE_12:
948 case WRITE_10:
949 case WRITE_6:
950 case READ_12:
951 case READ_10:
952 case READ_6:
953 case 0xad: /* READ_DVD_STRUCTURE */
954 case 0xbe: /* READ_CD */
955 pio = 0;
956 }
957 /* -45150 (FFFF4FA2) to -1 (FFFFFFFF) shall use PIO mode */
958 if (scsicmd[0] == WRITE_10) {
959 unsigned int lba =
960 (scsicmd[2] << 24) |
961 (scsicmd[3] << 16) |
962 (scsicmd[4] << 8) |
963 scsicmd[5];
964 if (lba >= 0xFFFF4FA2)
965 pio = 1;
966 }
967 return pio;
896} 968}
897 969
898static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf) 970static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
899{ 971{
900 WARN_ON(tf->protocol == ATA_PROT_DMA || 972 WARN_ON(tf->protocol == ATA_PROT_DMA ||
901 tf->protocol == ATA_PROT_NODATA); 973 tf->protocol == ATAPI_PROT_DMA);
902 ata_sff_tf_load(ap, tf); 974 ata_sff_tf_load(ap, tf);
903} 975}
904 976
@@ -906,7 +978,7 @@ static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
906static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf) 978static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
907{ 979{
908 WARN_ON(tf->protocol == ATA_PROT_DMA || 980 WARN_ON(tf->protocol == ATA_PROT_DMA ||
909 tf->protocol == ATA_PROT_NODATA); 981 tf->protocol == ATAPI_PROT_DMA);
910 ata_sff_exec_command(ap, tf); 982 ata_sff_exec_command(ap, tf);
911} 983}
912 984
diff --git a/drivers/base/iommu.c b/drivers/base/iommu.c
index 9f0e672f4be8..8ad4ffea6920 100644
--- a/drivers/base/iommu.c
+++ b/drivers/base/iommu.c
@@ -18,6 +18,8 @@
18 18
19#include <linux/bug.h> 19#include <linux/bug.h>
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/module.h>
22#include <linux/slab.h>
21#include <linux/errno.h> 23#include <linux/errno.h>
22#include <linux/iommu.h> 24#include <linux/iommu.h>
23 25
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index b5b6c973a2e0..8b4708e06244 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -217,7 +217,6 @@ int platform_device_add_data(struct platform_device *pdev, const void *data,
217 if (d) { 217 if (d) {
218 memcpy(d, data, size); 218 memcpy(d, data, size);
219 pdev->dev.platform_data = d; 219 pdev->dev.platform_data = d;
220 pdev->platform_data = d;
221 } 220 }
222 return d ? 0 : -ENOMEM; 221 return d ? 0 : -ENOMEM;
223} 222}
@@ -247,21 +246,6 @@ int platform_device_add(struct platform_device *pdev)
247 else 246 else
248 dev_set_name(&pdev->dev, pdev->name); 247 dev_set_name(&pdev->dev, pdev->name);
249 248
250 /* We will remove platform_data field from struct device
251 * if all platform devices pass its platform specific data
252 * from platform_device. The conversion is going to be a
253 * long time, so we allow the two cases coexist to make
254 * this kind of fix more easily*/
255 if (pdev->platform_data && pdev->dev.platform_data) {
256 printk(KERN_ERR
257 "%s: use which platform_data?\n",
258 dev_name(&pdev->dev));
259 } else if (pdev->platform_data) {
260 pdev->dev.platform_data = pdev->platform_data;
261 } else if (pdev->dev.platform_data) {
262 pdev->platform_data = pdev->dev.platform_data;
263 }
264
265 for (i = 0; i < pdev->num_resources; i++) { 249 for (i = 0; i < pdev->num_resources; i++) {
266 struct resource *p, *r = &pdev->resource[i]; 250 struct resource *p, *r = &pdev->resource[i];
267 251
@@ -1028,7 +1012,7 @@ static __initdata LIST_HEAD(early_platform_device_list);
1028 1012
1029/** 1013/**
1030 * early_platform_driver_register 1014 * early_platform_driver_register
1031 * @edrv: early_platform driver structure 1015 * @epdrv: early_platform driver structure
1032 * @buf: string passed from early_param() 1016 * @buf: string passed from early_param()
1033 */ 1017 */
1034int __init early_platform_driver_register(struct early_platform_driver *epdrv, 1018int __init early_platform_driver_register(struct early_platform_driver *epdrv,
@@ -1112,7 +1096,7 @@ void __init early_platform_driver_register_all(char *class_str)
1112 1096
1113/** 1097/**
1114 * early_platform_match 1098 * early_platform_match
1115 * @edrv: early platform driver structure 1099 * @epdrv: early platform driver structure
1116 * @id: id to match against 1100 * @id: id to match against
1117 */ 1101 */
1118static __init struct platform_device * 1102static __init struct platform_device *
@@ -1130,7 +1114,7 @@ early_platform_match(struct early_platform_driver *epdrv, int id)
1130 1114
1131/** 1115/**
1132 * early_platform_left 1116 * early_platform_left
1133 * @edrv: early platform driver structure 1117 * @epdrv: early platform driver structure
1134 * @id: return true if id or above exists 1118 * @id: return true if id or above exists
1135 */ 1119 */
1136static __init int early_platform_left(struct early_platform_driver *epdrv, 1120static __init int early_platform_left(struct early_platform_driver *epdrv,
diff --git a/drivers/char/random.c b/drivers/char/random.c
index f824ef8a9273..b2ced39d76b2 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1665,15 +1665,20 @@ EXPORT_SYMBOL(secure_dccp_sequence_number);
1665 * value is not cryptographically secure but for several uses the cost of 1665 * value is not cryptographically secure but for several uses the cost of
1666 * depleting entropy is too high 1666 * depleting entropy is too high
1667 */ 1667 */
1668DEFINE_PER_CPU(__u32 [4], get_random_int_hash);
1668unsigned int get_random_int(void) 1669unsigned int get_random_int(void)
1669{ 1670{
1670 /* 1671 struct keydata *keyptr;
1671 * Use IP's RNG. It suits our purpose perfectly: it re-keys itself 1672 __u32 *hash = get_cpu_var(get_random_int_hash);
1672 * every second, from the entropy pool (and thus creates a limited 1673 int ret;
1673 * drain on it), and uses halfMD4Transform within the second. We 1674
1674 * also mix it with jiffies and the PID: 1675 keyptr = get_keyptr();
1675 */ 1676 hash[0] += current->pid + jiffies + get_cycles() + (int)(long)&ret;
1676 return secure_ip_id((__force __be32)(current->pid + jiffies)); 1677
1678 ret = half_md4_transform(hash, keyptr->secret);
1679 put_cpu_var(get_random_int_hash);
1680
1681 return ret;
1677} 1682}
1678 1683
1679/* 1684/*
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index b0a6a3e51924..d6a807f4077d 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -406,7 +406,7 @@ static struct sysrq_key_op *sysrq_key_table[36] = {
406 &sysrq_showlocks_op, /* d */ 406 &sysrq_showlocks_op, /* d */
407 &sysrq_term_op, /* e */ 407 &sysrq_term_op, /* e */
408 &sysrq_moom_op, /* f */ 408 &sysrq_moom_op, /* f */
409 /* g: May be registered by ppc for kgdb */ 409 /* g: May be registered for the kernel debugger */
410 NULL, /* g */ 410 NULL, /* g */
411 NULL, /* h - reserved for help */ 411 NULL, /* h - reserved for help */
412 &sysrq_kill_op, /* i */ 412 &sysrq_kill_op, /* i */
@@ -431,7 +431,7 @@ static struct sysrq_key_op *sysrq_key_table[36] = {
431 &sysrq_sync_op, /* s */ 431 &sysrq_sync_op, /* s */
432 &sysrq_showstate_op, /* t */ 432 &sysrq_showstate_op, /* t */
433 &sysrq_mountro_op, /* u */ 433 &sysrq_mountro_op, /* u */
434 /* v: May be registered at init time by SMP VOYAGER */ 434 /* v: May be registered for frame buffer console restore */
435 NULL, /* v */ 435 NULL, /* v */
436 &sysrq_showstate_blocked_op, /* w */ 436 &sysrq_showstate_blocked_op, /* w */
437 /* x: May be registered on ppc/powerpc for xmon */ 437 /* x: May be registered on ppc/powerpc for xmon */
diff --git a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c
index a2dee0eb6dad..e6ce632a393e 100644
--- a/drivers/char/vt_ioctl.c
+++ b/drivers/char/vt_ioctl.c
@@ -400,6 +400,9 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
400 case KIOCSOUND: 400 case KIOCSOUND:
401 if (!perm) 401 if (!perm)
402 goto eperm; 402 goto eperm;
403 /* FIXME: This is an old broken API but we need to keep it
404 supported and somehow separate the historic advertised
405 tick rate from any real one */
403 if (arg) 406 if (arg)
404 arg = CLOCK_TICK_RATE / arg; 407 arg = CLOCK_TICK_RATE / arg;
405 kd_mksound(arg, 0); 408 kd_mksound(arg, 0);
@@ -417,6 +420,9 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
417 */ 420 */
418 ticks = HZ * ((arg >> 16) & 0xffff) / 1000; 421 ticks = HZ * ((arg >> 16) & 0xffff) / 1000;
419 count = ticks ? (arg & 0xffff) : 0; 422 count = ticks ? (arg & 0xffff) : 0;
423 /* FIXME: This is an old broken API but we need to keep it
424 supported and somehow separate the historic advertised
425 tick rate from any real one */
420 if (count) 426 if (count)
421 count = CLOCK_TICK_RATE / count; 427 count = CLOCK_TICK_RATE / count;
422 kd_mksound(count, ticks); 428 kd_mksound(count, ticks);
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 92438e9dacc3..5a87384ea4ff 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -804,11 +804,14 @@ dma_async_memcpy_buf_to_buf(struct dma_chan *chan, void *dest,
804 dma_addr_t dma_dest, dma_src; 804 dma_addr_t dma_dest, dma_src;
805 dma_cookie_t cookie; 805 dma_cookie_t cookie;
806 int cpu; 806 int cpu;
807 unsigned long flags;
807 808
808 dma_src = dma_map_single(dev->dev, src, len, DMA_TO_DEVICE); 809 dma_src = dma_map_single(dev->dev, src, len, DMA_TO_DEVICE);
809 dma_dest = dma_map_single(dev->dev, dest, len, DMA_FROM_DEVICE); 810 dma_dest = dma_map_single(dev->dev, dest, len, DMA_FROM_DEVICE);
810 tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, 811 flags = DMA_CTRL_ACK |
811 DMA_CTRL_ACK); 812 DMA_COMPL_SRC_UNMAP_SINGLE |
813 DMA_COMPL_DEST_UNMAP_SINGLE;
814 tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, flags);
812 815
813 if (!tx) { 816 if (!tx) {
814 dma_unmap_single(dev->dev, dma_src, len, DMA_TO_DEVICE); 817 dma_unmap_single(dev->dev, dma_src, len, DMA_TO_DEVICE);
@@ -850,11 +853,12 @@ dma_async_memcpy_buf_to_pg(struct dma_chan *chan, struct page *page,
850 dma_addr_t dma_dest, dma_src; 853 dma_addr_t dma_dest, dma_src;
851 dma_cookie_t cookie; 854 dma_cookie_t cookie;
852 int cpu; 855 int cpu;
856 unsigned long flags;
853 857
854 dma_src = dma_map_single(dev->dev, kdata, len, DMA_TO_DEVICE); 858 dma_src = dma_map_single(dev->dev, kdata, len, DMA_TO_DEVICE);
855 dma_dest = dma_map_page(dev->dev, page, offset, len, DMA_FROM_DEVICE); 859 dma_dest = dma_map_page(dev->dev, page, offset, len, DMA_FROM_DEVICE);
856 tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, 860 flags = DMA_CTRL_ACK | DMA_COMPL_SRC_UNMAP_SINGLE;
857 DMA_CTRL_ACK); 861 tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, flags);
858 862
859 if (!tx) { 863 if (!tx) {
860 dma_unmap_single(dev->dev, dma_src, len, DMA_TO_DEVICE); 864 dma_unmap_single(dev->dev, dma_src, len, DMA_TO_DEVICE);
@@ -898,12 +902,13 @@ dma_async_memcpy_pg_to_pg(struct dma_chan *chan, struct page *dest_pg,
898 dma_addr_t dma_dest, dma_src; 902 dma_addr_t dma_dest, dma_src;
899 dma_cookie_t cookie; 903 dma_cookie_t cookie;
900 int cpu; 904 int cpu;
905 unsigned long flags;
901 906
902 dma_src = dma_map_page(dev->dev, src_pg, src_off, len, DMA_TO_DEVICE); 907 dma_src = dma_map_page(dev->dev, src_pg, src_off, len, DMA_TO_DEVICE);
903 dma_dest = dma_map_page(dev->dev, dest_pg, dest_off, len, 908 dma_dest = dma_map_page(dev->dev, dest_pg, dest_off, len,
904 DMA_FROM_DEVICE); 909 DMA_FROM_DEVICE);
905 tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, 910 flags = DMA_CTRL_ACK;
906 DMA_CTRL_ACK); 911 tx = dev->device_prep_dma_memcpy(chan, dma_dest, dma_src, len, flags);
907 912
908 if (!tx) { 913 if (!tx) {
909 dma_unmap_page(dev->dev, dma_src, len, DMA_TO_DEVICE); 914 dma_unmap_page(dev->dev, dma_src, len, DMA_TO_DEVICE);
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index a27c0fb1bc11..fb7da5141e96 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -531,9 +531,7 @@ static int __init dmatest_init(void)
531 chan = dma_request_channel(mask, filter, NULL); 531 chan = dma_request_channel(mask, filter, NULL);
532 if (chan) { 532 if (chan) {
533 err = dmatest_add_channel(chan); 533 err = dmatest_add_channel(chan);
534 if (err == 0) 534 if (err) {
535 continue;
536 else {
537 dma_release_channel(chan); 535 dma_release_channel(chan);
538 break; /* add_channel failed, punt */ 536 break; /* add_channel failed, punt */
539 } 537 }
diff --git a/drivers/dma/ioat_dma.c b/drivers/dma/ioat_dma.c
index e4fc33c1c32f..1955ee8d6d20 100644
--- a/drivers/dma/ioat_dma.c
+++ b/drivers/dma/ioat_dma.c
@@ -1063,22 +1063,31 @@ static void ioat_dma_cleanup_tasklet(unsigned long data)
1063static void 1063static void
1064ioat_dma_unmap(struct ioat_dma_chan *ioat_chan, struct ioat_desc_sw *desc) 1064ioat_dma_unmap(struct ioat_dma_chan *ioat_chan, struct ioat_desc_sw *desc)
1065{ 1065{
1066 /* 1066 if (!(desc->async_tx.flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
1067 * yes we are unmapping both _page and _single 1067 if (desc->async_tx.flags & DMA_COMPL_DEST_UNMAP_SINGLE)
1068 * alloc'd regions with unmap_page. Is this 1068 pci_unmap_single(ioat_chan->device->pdev,
1069 * *really* that bad? 1069 pci_unmap_addr(desc, dst),
1070 */ 1070 pci_unmap_len(desc, len),
1071 if (!(desc->async_tx.flags & DMA_COMPL_SKIP_DEST_UNMAP)) 1071 PCI_DMA_FROMDEVICE);
1072 pci_unmap_page(ioat_chan->device->pdev, 1072 else
1073 pci_unmap_addr(desc, dst), 1073 pci_unmap_page(ioat_chan->device->pdev,
1074 pci_unmap_len(desc, len), 1074 pci_unmap_addr(desc, dst),
1075 PCI_DMA_FROMDEVICE); 1075 pci_unmap_len(desc, len),
1076 1076 PCI_DMA_FROMDEVICE);
1077 if (!(desc->async_tx.flags & DMA_COMPL_SKIP_SRC_UNMAP)) 1077 }
1078 pci_unmap_page(ioat_chan->device->pdev, 1078
1079 pci_unmap_addr(desc, src), 1079 if (!(desc->async_tx.flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
1080 pci_unmap_len(desc, len), 1080 if (desc->async_tx.flags & DMA_COMPL_SRC_UNMAP_SINGLE)
1081 PCI_DMA_TODEVICE); 1081 pci_unmap_single(ioat_chan->device->pdev,
1082 pci_unmap_addr(desc, src),
1083 pci_unmap_len(desc, len),
1084 PCI_DMA_TODEVICE);
1085 else
1086 pci_unmap_page(ioat_chan->device->pdev,
1087 pci_unmap_addr(desc, src),
1088 pci_unmap_len(desc, len),
1089 PCI_DMA_TODEVICE);
1090 }
1082} 1091}
1083 1092
1084/** 1093/**
@@ -1363,6 +1372,7 @@ static int ioat_dma_self_test(struct ioatdma_device *device)
1363 int err = 0; 1372 int err = 0;
1364 struct completion cmp; 1373 struct completion cmp;
1365 unsigned long tmo; 1374 unsigned long tmo;
1375 unsigned long flags;
1366 1376
1367 src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL); 1377 src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL);
1368 if (!src) 1378 if (!src)
@@ -1392,8 +1402,9 @@ static int ioat_dma_self_test(struct ioatdma_device *device)
1392 DMA_TO_DEVICE); 1402 DMA_TO_DEVICE);
1393 dma_dest = dma_map_single(dma_chan->device->dev, dest, IOAT_TEST_SIZE, 1403 dma_dest = dma_map_single(dma_chan->device->dev, dest, IOAT_TEST_SIZE,
1394 DMA_FROM_DEVICE); 1404 DMA_FROM_DEVICE);
1405 flags = DMA_COMPL_SRC_UNMAP_SINGLE | DMA_COMPL_DEST_UNMAP_SINGLE;
1395 tx = device->common.device_prep_dma_memcpy(dma_chan, dma_dest, dma_src, 1406 tx = device->common.device_prep_dma_memcpy(dma_chan, dma_dest, dma_src,
1396 IOAT_TEST_SIZE, 0); 1407 IOAT_TEST_SIZE, flags);
1397 if (!tx) { 1408 if (!tx) {
1398 dev_err(&device->pdev->dev, 1409 dev_err(&device->pdev->dev,
1399 "Self-test prep failed, disabling\n"); 1410 "Self-test prep failed, disabling\n");
diff --git a/drivers/dma/ipu/ipu_idmac.c b/drivers/dma/ipu/ipu_idmac.c
index e202a6ce5573..9a5bc1a7389e 100644
--- a/drivers/dma/ipu/ipu_idmac.c
+++ b/drivers/dma/ipu/ipu_idmac.c
@@ -1272,7 +1272,8 @@ static irqreturn_t idmac_interrupt(int irq, void *dev_id)
1272 /* Other interrupts do not interfere with this channel */ 1272 /* Other interrupts do not interfere with this channel */
1273 spin_lock(&ichan->lock); 1273 spin_lock(&ichan->lock);
1274 if (unlikely(chan_id != IDMAC_SDC_0 && chan_id != IDMAC_SDC_1 && 1274 if (unlikely(chan_id != IDMAC_SDC_0 && chan_id != IDMAC_SDC_1 &&
1275 ((curbuf >> chan_id) & 1) == ichan->active_buffer)) { 1275 ((curbuf >> chan_id) & 1) == ichan->active_buffer &&
1276 !list_is_last(ichan->queue.next, &ichan->queue))) {
1276 int i = 100; 1277 int i = 100;
1277 1278
1278 /* This doesn't help. See comment in ipu_disable_channel() */ 1279 /* This doesn't help. See comment in ipu_disable_channel() */
@@ -1547,7 +1548,7 @@ static irqreturn_t ic_sof_irq(int irq, void *dev_id)
1547 struct idmac_channel *ichan = dev_id; 1548 struct idmac_channel *ichan = dev_id;
1548 printk(KERN_DEBUG "Got SOF IRQ %d on Channel %d\n", 1549 printk(KERN_DEBUG "Got SOF IRQ %d on Channel %d\n",
1549 irq, ichan->dma_chan.chan_id); 1550 irq, ichan->dma_chan.chan_id);
1550 disable_irq(irq); 1551 disable_irq_nosync(irq);
1551 return IRQ_HANDLED; 1552 return IRQ_HANDLED;
1552} 1553}
1553 1554
@@ -1556,7 +1557,7 @@ static irqreturn_t ic_eof_irq(int irq, void *dev_id)
1556 struct idmac_channel *ichan = dev_id; 1557 struct idmac_channel *ichan = dev_id;
1557 printk(KERN_DEBUG "Got EOF IRQ %d on Channel %d\n", 1558 printk(KERN_DEBUG "Got EOF IRQ %d on Channel %d\n",
1558 irq, ichan->dma_chan.chan_id); 1559 irq, ichan->dma_chan.chan_id);
1559 disable_irq(irq); 1560 disable_irq_nosync(irq);
1560 return IRQ_HANDLED; 1561 return IRQ_HANDLED;
1561} 1562}
1562 1563
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 3a22eb9be378..17b24c580c09 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -71,6 +71,7 @@ config DRM_I915
71 select FB_CFB_COPYAREA 71 select FB_CFB_COPYAREA
72 select FB_CFB_IMAGEBLIT 72 select FB_CFB_IMAGEBLIT
73 select FB 73 select FB
74 select FRAMEBUFFER_CONSOLE if !EMBEDDED
74 tristate "i915 driver" 75 tristate "i915 driver"
75 help 76 help
76 Choose this option if you have a system that has Intel 830M, 845G, 77 Choose this option if you have a system that has Intel 830M, 845G,
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index a04639dc633d..45890447feec 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -561,7 +561,6 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
561 int saved_x, saved_y; 561 int saved_x, saved_y;
562 struct drm_encoder *encoder; 562 struct drm_encoder *encoder;
563 bool ret = true; 563 bool ret = true;
564 bool depth_changed, bpp_changed;
565 564
566 adjusted_mode = drm_mode_duplicate(dev, mode); 565 adjusted_mode = drm_mode_duplicate(dev, mode);
567 566
@@ -570,15 +569,6 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
570 if (!crtc->enabled) 569 if (!crtc->enabled)
571 return true; 570 return true;
572 571
573 if (old_fb && crtc->fb) {
574 depth_changed = (old_fb->depth != crtc->fb->depth);
575 bpp_changed = (old_fb->bits_per_pixel !=
576 crtc->fb->bits_per_pixel);
577 } else {
578 depth_changed = true;
579 bpp_changed = true;
580 }
581
582 saved_mode = crtc->mode; 572 saved_mode = crtc->mode;
583 saved_x = crtc->x; 573 saved_x = crtc->x;
584 saved_y = crtc->y; 574 saved_y = crtc->y;
@@ -590,15 +580,6 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
590 crtc->x = x; 580 crtc->x = x;
591 crtc->y = y; 581 crtc->y = y;
592 582
593 if (drm_mode_equal(&saved_mode, &crtc->mode)) {
594 if (saved_x != crtc->x || saved_y != crtc->y ||
595 depth_changed || bpp_changed) {
596 ret = !crtc_funcs->mode_set_base(crtc, crtc->x, crtc->y,
597 old_fb);
598 goto done;
599 }
600 }
601
602 /* Pass our mode to the connectors and the CRTC to give them a chance to 583 /* Pass our mode to the connectors and the CRTC to give them a chance to
603 * adjust it according to limitations or connector properties, and also 584 * adjust it according to limitations or connector properties, and also
604 * a chance to reject the mode entirely. 585 * a chance to reject the mode entirely.
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index c4ada8b6295b..f01def16a669 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -456,7 +456,8 @@ int drm_ioctl(struct inode *inode, struct file *filp,
456 retcode = -EINVAL; 456 retcode = -EINVAL;
457 } else if (((ioctl->flags & DRM_ROOT_ONLY) && !capable(CAP_SYS_ADMIN)) || 457 } else if (((ioctl->flags & DRM_ROOT_ONLY) && !capable(CAP_SYS_ADMIN)) ||
458 ((ioctl->flags & DRM_AUTH) && !file_priv->authenticated) || 458 ((ioctl->flags & DRM_AUTH) && !file_priv->authenticated) ||
459 ((ioctl->flags & DRM_MASTER) && !file_priv->is_master)) { 459 ((ioctl->flags & DRM_MASTER) && !file_priv->is_master) ||
460 (!(ioctl->flags & DRM_CONTROL_ALLOW) && (file_priv->minor->type == DRM_MINOR_CONTROL))) {
460 retcode = -EACCES; 461 retcode = -EACCES;
461 } else { 462 } else {
462 if (cmd & (IOC_IN | IOC_OUT)) { 463 if (cmd & (IOC_IN | IOC_OUT)) {
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index ef878615c49f..b9631e3a1ea6 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -402,14 +402,14 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
402 if (dev->driver->load) { 402 if (dev->driver->load) {
403 ret = dev->driver->load(dev, ent->driver_data); 403 ret = dev->driver->load(dev, ent->driver_data);
404 if (ret) 404 if (ret)
405 goto err_g3; 405 goto err_g4;
406 } 406 }
407 407
408 /* setup the grouping for the legacy output */ 408 /* setup the grouping for the legacy output */
409 if (drm_core_check_feature(dev, DRIVER_MODESET)) { 409 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
410 ret = drm_mode_group_init_legacy_group(dev, &dev->primary->mode_group); 410 ret = drm_mode_group_init_legacy_group(dev, &dev->primary->mode_group);
411 if (ret) 411 if (ret)
412 goto err_g3; 412 goto err_g4;
413 } 413 }
414 414
415 list_add_tail(&dev->driver_item, &driver->device_list); 415 list_add_tail(&dev->driver_item, &driver->device_list);
@@ -420,8 +420,11 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
420 420
421 return 0; 421 return 0;
422 422
423err_g3: 423err_g4:
424 drm_put_minor(&dev->primary); 424 drm_put_minor(&dev->primary);
425err_g3:
426 if (drm_core_check_feature(dev, DRIVER_MODESET))
427 drm_put_minor(&dev->control);
425err_g2: 428err_g2:
426 pci_disable_device(pdev); 429 pci_disable_device(pdev);
427err_g1: 430err_g1:
@@ -502,11 +505,11 @@ void drm_put_dev(struct drm_device *dev)
502 dev->agp = NULL; 505 dev->agp = NULL;
503 } 506 }
504 507
505 drm_ht_remove(&dev->map_hash);
506 drm_ctxbitmap_cleanup(dev);
507
508 list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) 508 list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head)
509 drm_rmmap(dev, r_list->map); 509 drm_rmmap(dev, r_list->map);
510 drm_ht_remove(&dev->map_hash);
511
512 drm_ctxbitmap_cleanup(dev);
510 513
511 if (drm_core_check_feature(dev, DRIVER_MODESET)) 514 if (drm_core_check_feature(dev, DRIVER_MODESET))
512 drm_put_minor(&dev->control); 515 drm_put_minor(&dev->control);
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 022876ae34f0..8f9372921f82 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -489,9 +489,7 @@ int drm_sysfs_device_add(struct drm_minor *minor)
489 489
490 return 0; 490 return 0;
491 491
492 device_unregister(&minor->kdev);
493err_out: 492err_out:
494
495 return err; 493 return err;
496} 494}
497 495
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 051134c56aef..53d544552625 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1011,8 +1011,16 @@ static int i915_load_modeset_init(struct drm_device *dev)
1011 /* Basic memrange allocator for stolen space (aka vram) */ 1011 /* Basic memrange allocator for stolen space (aka vram) */
1012 drm_mm_init(&dev_priv->vram, 0, prealloc_size); 1012 drm_mm_init(&dev_priv->vram, 0, prealloc_size);
1013 1013
1014 /* Let GEM Manage from end of prealloc space to end of aperture */ 1014 /* Let GEM Manage from end of prealloc space to end of aperture.
1015 i915_gem_do_init(dev, prealloc_size, agp_size); 1015 *
1016 * However, leave one page at the end still bound to the scratch page.
1017 * There are a number of places where the hardware apparently
1018 * prefetches past the end of the object, and we've seen multiple
1019 * hangs with the GPU head pointer stuck in a batchbuffer bound
1020 * at the last page of the aperture. One page should be enough to
1021 * keep any prefetching inside of the aperture.
1022 */
1023 i915_gem_do_init(dev, prealloc_size, agp_size - 4096);
1016 1024
1017 ret = i915_gem_init_ringbuffer(dev); 1025 ret = i915_gem_init_ringbuffer(dev);
1018 if (ret) 1026 if (ret)
@@ -1350,6 +1358,7 @@ struct drm_ioctl_desc i915_ioctls[] = {
1350 DRM_IOCTL_DEF(DRM_I915_GEM_SET_TILING, i915_gem_set_tiling, 0), 1358 DRM_IOCTL_DEF(DRM_I915_GEM_SET_TILING, i915_gem_set_tiling, 0),
1351 DRM_IOCTL_DEF(DRM_I915_GEM_GET_TILING, i915_gem_get_tiling, 0), 1359 DRM_IOCTL_DEF(DRM_I915_GEM_GET_TILING, i915_gem_get_tiling, 0),
1352 DRM_IOCTL_DEF(DRM_I915_GEM_GET_APERTURE, i915_gem_get_aperture_ioctl, 0), 1360 DRM_IOCTL_DEF(DRM_I915_GEM_GET_APERTURE, i915_gem_get_aperture_ioctl, 0),
1361 DRM_IOCTL_DEF(DRM_I915_GET_PIPE_FROM_CRTC_ID, intel_get_pipe_from_crtc_id, 0),
1353}; 1362};
1354 1363
1355int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); 1364int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 25065923b8a8..9b149fe824c3 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -283,6 +283,7 @@ typedef struct drm_i915_private {
283 u8 saveAR[21]; 283 u8 saveAR[21];
284 u8 saveDACMASK; 284 u8 saveDACMASK;
285 u8 saveCR[37]; 285 u8 saveCR[37];
286 uint64_t saveFENCE[16];
286 287
287 struct { 288 struct {
288 struct drm_mm gtt_space; 289 struct drm_mm gtt_space;
@@ -705,13 +706,8 @@ extern void intel_modeset_cleanup(struct drm_device *dev);
705#define I915_WRITE16(reg, val) writel(val, dev_priv->regs + (reg)) 706#define I915_WRITE16(reg, val) writel(val, dev_priv->regs + (reg))
706#define I915_READ8(reg) readb(dev_priv->regs + (reg)) 707#define I915_READ8(reg) readb(dev_priv->regs + (reg))
707#define I915_WRITE8(reg, val) writeb(val, dev_priv->regs + (reg)) 708#define I915_WRITE8(reg, val) writeb(val, dev_priv->regs + (reg))
708#ifdef writeq
709#define I915_WRITE64(reg, val) writeq(val, dev_priv->regs + (reg)) 709#define I915_WRITE64(reg, val) writeq(val, dev_priv->regs + (reg))
710#else 710#define I915_READ64(reg) readq(dev_priv->regs + (reg))
711#define I915_WRITE64(reg, val) (writel(val, dev_priv->regs + (reg)), \
712 writel(upper_32_bits(val), dev_priv->regs + \
713 (reg) + 4))
714#endif
715#define POSTING_READ(reg) (void)I915_READ(reg) 711#define POSTING_READ(reg) (void)I915_READ(reg)
716 712
717#define I915_VERBOSE 0 713#define I915_VERBOSE 0
@@ -790,7 +786,8 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
790 (dev)->pci_device == 0x2E22 || \ 786 (dev)->pci_device == 0x2E22 || \
791 (dev)->pci_device == 0x2E32) 787 (dev)->pci_device == 0x2E32)
792 788
793#define IS_I965GM(dev) ((dev)->pci_device == 0x2A02) 789#define IS_I965GM(dev) ((dev)->pci_device == 0x2A02 || \
790 (dev)->pci_device == 0x2A12)
794 791
795#define IS_GM45(dev) ((dev)->pci_device == 0x2A42) 792#define IS_GM45(dev) ((dev)->pci_device == 0x2A42)
796 793
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index ee896d91c5bc..b189b49c7602 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1691,11 +1691,20 @@ static int
1691i915_wait_request(struct drm_device *dev, uint32_t seqno) 1691i915_wait_request(struct drm_device *dev, uint32_t seqno)
1692{ 1692{
1693 drm_i915_private_t *dev_priv = dev->dev_private; 1693 drm_i915_private_t *dev_priv = dev->dev_private;
1694 u32 ier;
1694 int ret = 0; 1695 int ret = 0;
1695 1696
1696 BUG_ON(seqno == 0); 1697 BUG_ON(seqno == 0);
1697 1698
1698 if (!i915_seqno_passed(i915_get_gem_seqno(dev), seqno)) { 1699 if (!i915_seqno_passed(i915_get_gem_seqno(dev), seqno)) {
1700 ier = I915_READ(IER);
1701 if (!ier) {
1702 DRM_ERROR("something (likely vbetool) disabled "
1703 "interrupts, re-enabling\n");
1704 i915_driver_irq_preinstall(dev);
1705 i915_driver_irq_postinstall(dev);
1706 }
1707
1699 dev_priv->mm.waiting_gem_seqno = seqno; 1708 dev_priv->mm.waiting_gem_seqno = seqno;
1700 i915_user_irq_get(dev); 1709 i915_user_irq_get(dev);
1701 ret = wait_event_interruptible(dev_priv->irq_queue, 1710 ret = wait_event_interruptible(dev_priv->irq_queue,
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 521194732266..15da44cf21b1 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -526,6 +526,7 @@
526#define DPLLA_INPUT_BUFFER_ENABLE (1 << 0) 526#define DPLLA_INPUT_BUFFER_ENABLE (1 << 0)
527#define D_STATE 0x6104 527#define D_STATE 0x6104
528#define CG_2D_DIS 0x6200 528#define CG_2D_DIS 0x6200
529#define DPCUNIT_CLOCK_GATE_DISABLE (1 << 24)
529#define CG_3D_DIS 0x6204 530#define CG_3D_DIS 0x6204
530 531
531/* 532/*
diff --git a/drivers/gpu/drm/i915/i915_suspend.c b/drivers/gpu/drm/i915/i915_suspend.c
index d669cc2b42c0..ce8a21344a71 100644
--- a/drivers/gpu/drm/i915/i915_suspend.c
+++ b/drivers/gpu/drm/i915/i915_suspend.c
@@ -349,6 +349,18 @@ int i915_save_state(struct drm_device *dev)
349 for (i = 0; i < 3; i++) 349 for (i = 0; i < 3; i++)
350 dev_priv->saveSWF2[i] = I915_READ(SWF30 + (i << 2)); 350 dev_priv->saveSWF2[i] = I915_READ(SWF30 + (i << 2));
351 351
352 /* Fences */
353 if (IS_I965G(dev)) {
354 for (i = 0; i < 16; i++)
355 dev_priv->saveFENCE[i] = I915_READ64(FENCE_REG_965_0 + (i * 8));
356 } else {
357 for (i = 0; i < 8; i++)
358 dev_priv->saveFENCE[i] = I915_READ(FENCE_REG_830_0 + (i * 4));
359
360 if (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev))
361 for (i = 0; i < 8; i++)
362 dev_priv->saveFENCE[i+8] = I915_READ(FENCE_REG_945_8 + (i * 4));
363 }
352 i915_save_vga(dev); 364 i915_save_vga(dev);
353 365
354 return 0; 366 return 0;
@@ -371,6 +383,18 @@ int i915_restore_state(struct drm_device *dev)
371 /* Display arbitration */ 383 /* Display arbitration */
372 I915_WRITE(DSPARB, dev_priv->saveDSPARB); 384 I915_WRITE(DSPARB, dev_priv->saveDSPARB);
373 385
386 /* Fences */
387 if (IS_I965G(dev)) {
388 for (i = 0; i < 16; i++)
389 I915_WRITE64(FENCE_REG_965_0 + (i * 8), dev_priv->saveFENCE[i]);
390 } else {
391 for (i = 0; i < 8; i++)
392 I915_WRITE(FENCE_REG_830_0 + (i * 4), dev_priv->saveFENCE[i]);
393 if (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev))
394 for (i = 0; i < 8; i++)
395 I915_WRITE(FENCE_REG_945_8 + (i * 4), dev_priv->saveFENCE[i+8]);
396 }
397
374 /* Pipe & plane A info */ 398 /* Pipe & plane A info */
375 /* Prime the clock */ 399 /* Prime the clock */
376 if (dev_priv->saveDPLL_A & DPLL_VCO_ENABLE) { 400 if (dev_priv->saveDPLL_A & DPLL_VCO_ENABLE) {
diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index 9bdd959260a5..19148c3df637 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -161,7 +161,7 @@ static bool intel_crt_detect_hotplug(struct drm_connector *connector)
161 hotplug_en &= CRT_FORCE_HOTPLUG_MASK; 161 hotplug_en &= CRT_FORCE_HOTPLUG_MASK;
162 hotplug_en |= CRT_HOTPLUG_FORCE_DETECT; 162 hotplug_en |= CRT_HOTPLUG_FORCE_DETECT;
163 163
164 if (IS_GM45(dev)) 164 if (IS_G4X(dev))
165 hotplug_en |= CRT_HOTPLUG_ACTIVATION_PERIOD_64; 165 hotplug_en |= CRT_HOTPLUG_ACTIVATION_PERIOD_64;
166 166
167 hotplug_en |= CRT_HOTPLUG_VOLTAGE_COMPARE_50; 167 hotplug_en |= CRT_HOTPLUG_VOLTAGE_COMPARE_50;
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index bdcda36953b0..3387cf32f385 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -1804,6 +1804,37 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)
1804 } 1804 }
1805} 1805}
1806 1806
1807int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
1808 struct drm_file *file_priv)
1809{
1810 drm_i915_private_t *dev_priv = dev->dev_private;
1811 struct drm_i915_get_pipe_from_crtc_id *pipe_from_crtc_id = data;
1812 struct drm_crtc *crtc = NULL;
1813 int pipe = -1;
1814
1815 if (!dev_priv) {
1816 DRM_ERROR("called with no initialization\n");
1817 return -EINVAL;
1818 }
1819
1820 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
1821 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
1822 if (crtc->base.id == pipe_from_crtc_id->crtc_id) {
1823 pipe = intel_crtc->pipe;
1824 break;
1825 }
1826 }
1827
1828 if (pipe == -1) {
1829 DRM_ERROR("no such CRTC id\n");
1830 return -EINVAL;
1831 }
1832
1833 pipe_from_crtc_id->pipe = pipe;
1834
1835 return 0;
1836}
1837
1807struct drm_crtc *intel_get_crtc_from_pipe(struct drm_device *dev, int pipe) 1838struct drm_crtc *intel_get_crtc_from_pipe(struct drm_device *dev, int pipe)
1808{ 1839{
1809 struct drm_crtc *crtc = NULL; 1840 struct drm_crtc *crtc = NULL;
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 957daef8edff..cd4b9c5f715e 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -109,7 +109,7 @@ struct intel_i2c_chan *intel_i2c_create(struct drm_device *dev, const u32 reg,
109void intel_i2c_destroy(struct intel_i2c_chan *chan); 109void intel_i2c_destroy(struct intel_i2c_chan *chan);
110int intel_ddc_get_modes(struct intel_output *intel_output); 110int intel_ddc_get_modes(struct intel_output *intel_output);
111extern bool intel_ddc_probe(struct intel_output *intel_output); 111extern bool intel_ddc_probe(struct intel_output *intel_output);
112 112void intel_i2c_quirk_set(struct drm_device *dev, bool enable);
113extern void intel_crt_init(struct drm_device *dev); 113extern void intel_crt_init(struct drm_device *dev);
114extern void intel_hdmi_init(struct drm_device *dev, int sdvox_reg); 114extern void intel_hdmi_init(struct drm_device *dev, int sdvox_reg);
115extern bool intel_sdvo_init(struct drm_device *dev, int output_device); 115extern bool intel_sdvo_init(struct drm_device *dev, int output_device);
@@ -125,6 +125,8 @@ extern struct drm_encoder *intel_best_encoder(struct drm_connector *connector);
125 125
126extern struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev, 126extern struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
127 struct drm_crtc *crtc); 127 struct drm_crtc *crtc);
128int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
129 struct drm_file *file_priv);
128extern void intel_wait_for_vblank(struct drm_device *dev); 130extern void intel_wait_for_vblank(struct drm_device *dev);
129extern struct drm_crtc *intel_get_crtc_from_pipe(struct drm_device *dev, int pipe); 131extern struct drm_crtc *intel_get_crtc_from_pipe(struct drm_device *dev, int pipe);
130extern struct drm_crtc *intel_get_load_detect_pipe(struct intel_output *intel_output, 132extern struct drm_crtc *intel_get_load_detect_pipe(struct intel_output *intel_output,
diff --git a/drivers/gpu/drm/i915/intel_fb.c b/drivers/gpu/drm/i915/intel_fb.c
index 3e094beecb99..e4652dcdd9bb 100644
--- a/drivers/gpu/drm/i915/intel_fb.c
+++ b/drivers/gpu/drm/i915/intel_fb.c
@@ -864,7 +864,7 @@ static void intelfb_sysrq(int dummy1, struct tty_struct *dummy3)
864 864
865static struct sysrq_key_op sysrq_intelfb_restore_op = { 865static struct sysrq_key_op sysrq_intelfb_restore_op = {
866 .handler = intelfb_sysrq, 866 .handler = intelfb_sysrq,
867 .help_msg = "force-fb(G)", 867 .help_msg = "force-fb(V)",
868 .action_msg = "Restore framebuffer console", 868 .action_msg = "Restore framebuffer console",
869}; 869};
870 870
@@ -898,7 +898,7 @@ int intelfb_probe(struct drm_device *dev)
898 ret = intelfb_single_fb_probe(dev); 898 ret = intelfb_single_fb_probe(dev);
899 } 899 }
900 900
901 register_sysrq_key('g', &sysrq_intelfb_restore_op); 901 register_sysrq_key('v', &sysrq_intelfb_restore_op);
902 902
903 return ret; 903 return ret;
904} 904}
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index 550374225388..d0983bb93a18 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -155,11 +155,18 @@ intel_hdmi_detect(struct drm_connector *connector)
155 155
156 temp = I915_READ(PORT_HOTPLUG_EN); 156 temp = I915_READ(PORT_HOTPLUG_EN);
157 157
158 I915_WRITE(PORT_HOTPLUG_EN, 158 switch (hdmi_priv->sdvox_reg) {
159 temp | 159 case SDVOB:
160 HDMIB_HOTPLUG_INT_EN | 160 temp |= HDMIB_HOTPLUG_INT_EN;
161 HDMIC_HOTPLUG_INT_EN | 161 break;
162 HDMID_HOTPLUG_INT_EN); 162 case SDVOC:
163 temp |= HDMIC_HOTPLUG_INT_EN;
164 break;
165 default:
166 return connector_status_unknown;
167 }
168
169 I915_WRITE(PORT_HOTPLUG_EN, temp);
163 170
164 POSTING_READ(PORT_HOTPLUG_EN); 171 POSTING_READ(PORT_HOTPLUG_EN);
165 172
diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c
index 5ee9d4c25753..f7061f68d050 100644
--- a/drivers/gpu/drm/i915/intel_i2c.c
+++ b/drivers/gpu/drm/i915/intel_i2c.c
@@ -34,6 +34,21 @@
34#include "i915_drm.h" 34#include "i915_drm.h"
35#include "i915_drv.h" 35#include "i915_drv.h"
36 36
37void intel_i2c_quirk_set(struct drm_device *dev, bool enable)
38{
39 struct drm_i915_private *dev_priv = dev->dev_private;
40
41 /* When using bit bashing for I2C, this bit needs to be set to 1 */
42 if (!IS_IGD(dev))
43 return;
44 if (enable)
45 I915_WRITE(CG_2D_DIS,
46 I915_READ(CG_2D_DIS) | DPCUNIT_CLOCK_GATE_DISABLE);
47 else
48 I915_WRITE(CG_2D_DIS,
49 I915_READ(CG_2D_DIS) & (~DPCUNIT_CLOCK_GATE_DISABLE));
50}
51
37/* 52/*
38 * Intel GPIO access functions 53 * Intel GPIO access functions
39 */ 54 */
@@ -153,8 +168,10 @@ struct intel_i2c_chan *intel_i2c_create(struct drm_device *dev, const u32 reg,
153 goto out_free; 168 goto out_free;
154 169
155 /* JJJ: raise SCL and SDA? */ 170 /* JJJ: raise SCL and SDA? */
171 intel_i2c_quirk_set(dev, true);
156 set_data(chan, 1); 172 set_data(chan, 1);
157 set_clock(chan, 1); 173 set_clock(chan, 1);
174 intel_i2c_quirk_set(dev, false);
158 udelay(20); 175 udelay(20);
159 176
160 return chan; 177 return chan;
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index 6619f26e46a5..439a86514993 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -384,7 +384,51 @@ static const struct drm_encoder_funcs intel_lvds_enc_funcs = {
384 .destroy = intel_lvds_enc_destroy, 384 .destroy = intel_lvds_enc_destroy,
385}; 385};
386 386
387static int __init intel_no_lvds_dmi_callback(const struct dmi_system_id *id)
388{
389 DRM_DEBUG("Skipping LVDS initialization for %s\n", id->ident);
390 return 1;
391}
387 392
393/* These systems claim to have LVDS, but really don't */
394static const struct dmi_system_id __initdata intel_no_lvds[] = {
395 {
396 .callback = intel_no_lvds_dmi_callback,
397 .ident = "Apple Mac Mini (Core series)",
398 .matches = {
399 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
400 DMI_MATCH(DMI_PRODUCT_NAME, "Macmini1,1"),
401 },
402 },
403 {
404 .callback = intel_no_lvds_dmi_callback,
405 .ident = "Apple Mac Mini (Core 2 series)",
406 .matches = {
407 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
408 DMI_MATCH(DMI_PRODUCT_NAME, "Macmini2,1"),
409 },
410 },
411 {
412 .callback = intel_no_lvds_dmi_callback,
413 .ident = "MSI IM-945GSE-A",
414 .matches = {
415 DMI_MATCH(DMI_SYS_VENDOR, "MSI"),
416 DMI_MATCH(DMI_PRODUCT_NAME, "A9830IMS"),
417 },
418 },
419 {
420 .callback = intel_no_lvds_dmi_callback,
421 .ident = "Dell Studio Hybrid",
422 .matches = {
423 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
424 DMI_MATCH(DMI_PRODUCT_NAME, "Studio Hybrid 140g"),
425 },
426 },
427
428 /* FIXME: add a check for the Aopen Mini PC */
429
430 { } /* terminating entry */
431};
388 432
389/** 433/**
390 * intel_lvds_init - setup LVDS connectors on this device 434 * intel_lvds_init - setup LVDS connectors on this device
@@ -404,15 +448,9 @@ void intel_lvds_init(struct drm_device *dev)
404 u32 lvds; 448 u32 lvds;
405 int pipe; 449 int pipe;
406 450
407 /* Blacklist machines that we know falsely report LVDS. */ 451 /* Skip init on machines we know falsely report LVDS */
408 /* FIXME: add a check for the Aopen Mini PC */ 452 if (dmi_check_system(intel_no_lvds))
409
410 /* Apple Mac Mini Core Duo and Mac Mini Core 2 Duo */
411 if(dmi_match(DMI_PRODUCT_NAME, "Macmini1,1") ||
412 dmi_match(DMI_PRODUCT_NAME, "Macmini2,1")) {
413 DRM_DEBUG("Skipping LVDS initialization for Apple Mac Mini\n");
414 return; 453 return;
415 }
416 454
417 intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL); 455 intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL);
418 if (!intel_output) { 456 if (!intel_output) {
diff --git a/drivers/gpu/drm/i915/intel_modes.c b/drivers/gpu/drm/i915/intel_modes.c
index 07d7ec976168..e0910fefce87 100644
--- a/drivers/gpu/drm/i915/intel_modes.c
+++ b/drivers/gpu/drm/i915/intel_modes.c
@@ -27,6 +27,7 @@
27#include <linux/fb.h> 27#include <linux/fb.h>
28#include "drmP.h" 28#include "drmP.h"
29#include "intel_drv.h" 29#include "intel_drv.h"
30#include "i915_drv.h"
30 31
31/** 32/**
32 * intel_ddc_probe 33 * intel_ddc_probe
@@ -52,7 +53,10 @@ bool intel_ddc_probe(struct intel_output *intel_output)
52 } 53 }
53 }; 54 };
54 55
56 intel_i2c_quirk_set(intel_output->ddc_bus->drm_dev, true);
55 ret = i2c_transfer(&intel_output->ddc_bus->adapter, msgs, 2); 57 ret = i2c_transfer(&intel_output->ddc_bus->adapter, msgs, 2);
58 intel_i2c_quirk_set(intel_output->ddc_bus->drm_dev, false);
59
56 if (ret == 2) 60 if (ret == 2)
57 return true; 61 return true;
58 62
@@ -70,8 +74,10 @@ int intel_ddc_get_modes(struct intel_output *intel_output)
70 struct edid *edid; 74 struct edid *edid;
71 int ret = 0; 75 int ret = 0;
72 76
77 intel_i2c_quirk_set(intel_output->ddc_bus->drm_dev, true);
73 edid = drm_get_edid(&intel_output->base, 78 edid = drm_get_edid(&intel_output->base,
74 &intel_output->ddc_bus->adapter); 79 &intel_output->ddc_bus->adapter);
80 intel_i2c_quirk_set(intel_output->ddc_bus->drm_dev, false);
75 if (edid) { 81 if (edid) {
76 drm_mode_connector_update_edid_property(&intel_output->base, 82 drm_mode_connector_update_edid_property(&intel_output->base,
77 edid); 83 edid);
diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
index 32de4cedc363..077c0455a6b9 100644
--- a/drivers/gpu/drm/r128/r128_cce.c
+++ b/drivers/gpu/drm/r128/r128_cce.c
@@ -511,9 +511,9 @@ static int r128_do_init_cce(struct drm_device * dev, drm_r128_init_t * init)
511 511
512#if __OS_HAS_AGP 512#if __OS_HAS_AGP
513 if (!dev_priv->is_pci) { 513 if (!dev_priv->is_pci) {
514 drm_core_ioremap(dev_priv->cce_ring, dev); 514 drm_core_ioremap_wc(dev_priv->cce_ring, dev);
515 drm_core_ioremap(dev_priv->ring_rptr, dev); 515 drm_core_ioremap_wc(dev_priv->ring_rptr, dev);
516 drm_core_ioremap(dev->agp_buffer_map, dev); 516 drm_core_ioremap_wc(dev->agp_buffer_map, dev);
517 if (!dev_priv->cce_ring->handle || 517 if (!dev_priv->cce_ring->handle ||
518 !dev_priv->ring_rptr->handle || 518 !dev_priv->ring_rptr->handle ||
519 !dev->agp_buffer_map->handle) { 519 !dev->agp_buffer_map->handle) {
diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
index ed4d27e6ee6f..8071d965f142 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.h
+++ b/drivers/gpu/drm/radeon/radeon_drv.h
@@ -99,9 +99,10 @@
99 * 1.27- Add support for IGP GART 99 * 1.27- Add support for IGP GART
100 * 1.28- Add support for VBL on CRTC2 100 * 1.28- Add support for VBL on CRTC2
101 * 1.29- R500 3D cmd buffer support 101 * 1.29- R500 3D cmd buffer support
102 * 1.30- Add support for occlusion queries
102 */ 103 */
103#define DRIVER_MAJOR 1 104#define DRIVER_MAJOR 1
104#define DRIVER_MINOR 29 105#define DRIVER_MINOR 30
105#define DRIVER_PATCHLEVEL 0 106#define DRIVER_PATCHLEVEL 0
106 107
107/* 108/*
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index aa1b995dd033..4d5ee2bbc62b 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -113,6 +113,11 @@
113#define USB_VENDOR_ID_BERKSHIRE 0x0c98 113#define USB_VENDOR_ID_BERKSHIRE 0x0c98
114#define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140 114#define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140
115 115
116#define USB_VENDOR_ID_CH 0x068e
117#define USB_DEVICE_ID_CH_PRO_PEDALS 0x00f2
118#define USB_DEVICE_ID_CH_COMBATSTICK 0x00f4
119#define USB_DEVICE_ID_CH_FLIGHT_SIM_YOKE 0x00ff
120
116#define USB_VENDOR_ID_CHERRY 0x046a 121#define USB_VENDOR_ID_CHERRY 0x046a
117#define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023 122#define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023
118 123
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 900ce18dd549..ac8049b5f1e9 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -898,7 +898,7 @@ static int usbhid_parse(struct hid_device *hid)
898 goto err; 898 goto err;
899 } 899 }
900 900
901 hid->quirks = quirks; 901 hid->quirks |= quirks;
902 902
903 return 0; 903 return 0;
904err: 904err:
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index 4391717d2519..d8f7423f363e 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -50,6 +50,9 @@ static const struct hid_blacklist {
50 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET }, 50 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET },
51 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET }, 51 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET },
52 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, 52 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET },
53 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_COMBATSTICK, HID_QUIRK_NOGET },
54 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_FLIGHT_SIM_YOKE, HID_QUIRK_NOGET },
55 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_PRO_PEDALS, HID_QUIRK_NOGET },
53 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, 56 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET },
54 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, 57 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET },
55 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, 58 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET },
diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
index 0897edef2574..bff0103610c1 100644
--- a/drivers/hwmon/asus_atk0110.c
+++ b/drivers/hwmon/asus_atk0110.c
@@ -348,6 +348,7 @@ static int validate_hwmon_pack(struct atk_data *data, union acpi_object *obj)
348 return 0; 348 return 0;
349} 349}
350 350
351#ifdef DEBUG
351static char const *atk_sensor_type(union acpi_object *flags) 352static char const *atk_sensor_type(union acpi_object *flags)
352{ 353{
353 u64 type = flags->integer.value & ATK_TYPE_MASK; 354 u64 type = flags->integer.value & ATK_TYPE_MASK;
@@ -370,6 +371,7 @@ static char const *atk_sensor_type(union acpi_object *flags)
370 371
371 return what; 372 return what;
372} 373}
374#endif
373 375
374static void atk_print_sensor(struct atk_data *data, union acpi_object *obj) 376static void atk_print_sensor(struct atk_data *data, union acpi_object *obj)
375{ 377{
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index dbfb30c588d8..0bdab959b736 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -1462,7 +1462,8 @@ static struct w83781d_data *w83781d_update_device(struct device *dev)
1462 data->pwm[i] = 1462 data->pwm[i] =
1463 w83781d_read_value(data, 1463 w83781d_read_value(data,
1464 W83781D_REG_PWM[i]); 1464 W83781D_REG_PWM[i]);
1465 if ((data->type != w83782d || !client->driver) 1465 /* Only W83782D on SMBus has PWM3 and PWM4 */
1466 if ((data->type != w83782d || !client)
1466 && i == 1) 1467 && i == 1)
1467 break; 1468 break;
1468 } 1469 }
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
index d420cc5f5633..e25e13980af3 100644
--- a/drivers/i2c/algos/i2c-algo-bit.c
+++ b/drivers/i2c/algos/i2c-algo-bit.c
@@ -104,7 +104,7 @@ static int sclhi(struct i2c_algo_bit_data *adap)
104 * chips may hold it low ("clock stretching") while they 104 * chips may hold it low ("clock stretching") while they
105 * are processing data internally. 105 * are processing data internally.
106 */ 106 */
107 if (time_after_eq(jiffies, start + adap->timeout)) 107 if (time_after(jiffies, start + adap->timeout))
108 return -ETIMEDOUT; 108 return -ETIMEDOUT;
109 cond_resched(); 109 cond_resched();
110 } 110 }
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c
index 6318f7ddc1d4..78d42aae0089 100644
--- a/drivers/i2c/algos/i2c-algo-pca.c
+++ b/drivers/i2c/algos/i2c-algo-pca.c
@@ -287,10 +287,21 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
287 287
288 case 0x30: /* Data byte in I2CDAT has been transmitted; NOT ACK has been received */ 288 case 0x30: /* Data byte in I2CDAT has been transmitted; NOT ACK has been received */
289 DEB2("NOT ACK received after data byte\n"); 289 DEB2("NOT ACK received after data byte\n");
290 pca_stop(adap);
290 goto out; 291 goto out;
291 292
292 case 0x38: /* Arbitration lost during SLA+W, SLA+R or data bytes */ 293 case 0x38: /* Arbitration lost during SLA+W, SLA+R or data bytes */
293 DEB2("Arbitration lost\n"); 294 DEB2("Arbitration lost\n");
295 /*
296 * The PCA9564 data sheet (2006-09-01) says "A
297 * START condition will be transmitted when the
298 * bus becomes free (STOP or SCL and SDA high)"
299 * when the STA bit is set (p. 11).
300 *
301 * In case this won't work, try pca_reset()
302 * instead.
303 */
304 pca_start(adap);
294 goto out; 305 goto out;
295 306
296 case 0x58: /* Data byte has been received; NOT ACK has been returned */ 307 case 0x58: /* Data byte has been received; NOT ACK has been returned */
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index a48c8aee0218..f1c6ca7e2852 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -467,7 +467,7 @@ config I2C_PXA_SLAVE
467 467
468config I2C_S3C2410 468config I2C_S3C2410
469 tristate "S3C2410 I2C Driver" 469 tristate "S3C2410 I2C Driver"
470 depends on ARCH_S3C2410 470 depends on ARCH_S3C2410 || ARCH_S3C64XX
471 help 471 help
472 Say Y here to include support for I2C controller in the 472 Say Y here to include support for I2C controller in the
473 Samsung S3C2410 based System-on-Chip devices. 473 Samsung S3C2410 based System-on-Chip devices.
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c
index 981e080b32ae..d108450df064 100644
--- a/drivers/i2c/busses/i2c-ali1535.c
+++ b/drivers/i2c/busses/i2c-ali1535.c
@@ -284,7 +284,7 @@ static int ali1535_transaction(struct i2c_adapter *adap)
284 && (timeout++ < MAX_TIMEOUT)); 284 && (timeout++ < MAX_TIMEOUT));
285 285
286 /* If the SMBus is still busy, we give up */ 286 /* If the SMBus is still busy, we give up */
287 if (timeout >= MAX_TIMEOUT) { 287 if (timeout > MAX_TIMEOUT) {
288 result = -ETIMEDOUT; 288 result = -ETIMEDOUT;
289 dev_err(&adap->dev, "SMBus Timeout!\n"); 289 dev_err(&adap->dev, "SMBus Timeout!\n");
290 } 290 }
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c
index 39066dee46e3..d627fceb790b 100644
--- a/drivers/i2c/busses/i2c-ali15x3.c
+++ b/drivers/i2c/busses/i2c-ali15x3.c
@@ -306,7 +306,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
306 && (timeout++ < MAX_TIMEOUT)); 306 && (timeout++ < MAX_TIMEOUT));
307 307
308 /* If the SMBus is still busy, we give up */ 308 /* If the SMBus is still busy, we give up */
309 if (timeout >= MAX_TIMEOUT) { 309 if (timeout > MAX_TIMEOUT) {
310 result = -ETIMEDOUT; 310 result = -ETIMEDOUT;
311 dev_err(&adap->dev, "SMBus Timeout!\n"); 311 dev_err(&adap->dev, "SMBus Timeout!\n");
312 } 312 }
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c
index 220f4a1eee1d..f7d6fe9c49ba 100644
--- a/drivers/i2c/busses/i2c-amd756.c
+++ b/drivers/i2c/busses/i2c-amd756.c
@@ -126,7 +126,7 @@ static int amd756_transaction(struct i2c_adapter *adap)
126 } while ((temp & (GS_HST_STS | GS_SMB_STS)) && 126 } while ((temp & (GS_HST_STS | GS_SMB_STS)) &&
127 (timeout++ < MAX_TIMEOUT)); 127 (timeout++ < MAX_TIMEOUT));
128 /* If the SMBus is still busy, we give up */ 128 /* If the SMBus is still busy, we give up */
129 if (timeout >= MAX_TIMEOUT) { 129 if (timeout > MAX_TIMEOUT) {
130 dev_dbg(&adap->dev, "Busy wait timeout (%04x)\n", temp); 130 dev_dbg(&adap->dev, "Busy wait timeout (%04x)\n", temp);
131 goto abort; 131 goto abort;
132 } 132 }
@@ -143,7 +143,7 @@ static int amd756_transaction(struct i2c_adapter *adap)
143 } while ((temp & GS_HST_STS) && (timeout++ < MAX_TIMEOUT)); 143 } while ((temp & GS_HST_STS) && (timeout++ < MAX_TIMEOUT));
144 144
145 /* If the SMBus is still busy, we give up */ 145 /* If the SMBus is still busy, we give up */
146 if (timeout >= MAX_TIMEOUT) { 146 if (timeout > MAX_TIMEOUT) {
147 dev_dbg(&adap->dev, "Completion timeout!\n"); 147 dev_dbg(&adap->dev, "Completion timeout!\n");
148 goto abort; 148 goto abort;
149 } 149 }
diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
index 3fcf78e906db..b5db8b883615 100644
--- a/drivers/i2c/busses/i2c-cpm.c
+++ b/drivers/i2c/busses/i2c-cpm.c
@@ -531,16 +531,16 @@ static int __devinit cpm_i2c_setup(struct cpm_i2c *cpm)
531 rbdf = cpm->rbase; 531 rbdf = cpm->rbase;
532 532
533 for (i = 0; i < CPM_MAXBD; i++) { 533 for (i = 0; i < CPM_MAXBD; i++) {
534 cpm->rxbuf[i] = dma_alloc_coherent( 534 cpm->rxbuf[i] = dma_alloc_coherent(&cpm->ofdev->dev,
535 NULL, CPM_MAX_READ + 1, &cpm->rxdma[i], GFP_KERNEL); 535 CPM_MAX_READ + 1,
536 &cpm->rxdma[i], GFP_KERNEL);
536 if (!cpm->rxbuf[i]) { 537 if (!cpm->rxbuf[i]) {
537 ret = -ENOMEM; 538 ret = -ENOMEM;
538 goto out_muram; 539 goto out_muram;
539 } 540 }
540 out_be32(&rbdf[i].cbd_bufaddr, ((cpm->rxdma[i] + 1) & ~1)); 541 out_be32(&rbdf[i].cbd_bufaddr, ((cpm->rxdma[i] + 1) & ~1));
541 542
542 cpm->txbuf[i] = (unsigned char *)dma_alloc_coherent( 543 cpm->txbuf[i] = (unsigned char *)dma_alloc_coherent(&cpm->ofdev->dev, CPM_MAX_READ + 1, &cpm->txdma[i], GFP_KERNEL);
543 NULL, CPM_MAX_READ + 1, &cpm->txdma[i], GFP_KERNEL);
544 if (!cpm->txbuf[i]) { 544 if (!cpm->txbuf[i]) {
545 ret = -ENOMEM; 545 ret = -ENOMEM;
546 goto out_muram; 546 goto out_muram;
@@ -585,10 +585,10 @@ static int __devinit cpm_i2c_setup(struct cpm_i2c *cpm)
585out_muram: 585out_muram:
586 for (i = 0; i < CPM_MAXBD; i++) { 586 for (i = 0; i < CPM_MAXBD; i++) {
587 if (cpm->rxbuf[i]) 587 if (cpm->rxbuf[i])
588 dma_free_coherent(NULL, CPM_MAX_READ + 1, 588 dma_free_coherent(&cpm->ofdev->dev, CPM_MAX_READ + 1,
589 cpm->rxbuf[i], cpm->rxdma[i]); 589 cpm->rxbuf[i], cpm->rxdma[i]);
590 if (cpm->txbuf[i]) 590 if (cpm->txbuf[i])
591 dma_free_coherent(NULL, CPM_MAX_READ + 1, 591 dma_free_coherent(&cpm->ofdev->dev, CPM_MAX_READ + 1,
592 cpm->txbuf[i], cpm->txdma[i]); 592 cpm->txbuf[i], cpm->txdma[i]);
593 } 593 }
594 cpm_muram_free(cpm->dp_addr); 594 cpm_muram_free(cpm->dp_addr);
@@ -619,9 +619,9 @@ static void cpm_i2c_shutdown(struct cpm_i2c *cpm)
619 619
620 /* Free all memory */ 620 /* Free all memory */
621 for (i = 0; i < CPM_MAXBD; i++) { 621 for (i = 0; i < CPM_MAXBD; i++) {
622 dma_free_coherent(NULL, CPM_MAX_READ + 1, 622 dma_free_coherent(&cpm->ofdev->dev, CPM_MAX_READ + 1,
623 cpm->rxbuf[i], cpm->rxdma[i]); 623 cpm->rxbuf[i], cpm->rxdma[i]);
624 dma_free_coherent(NULL, CPM_MAX_READ + 1, 624 dma_free_coherent(&cpm->ofdev->dev, CPM_MAX_READ + 1,
625 cpm->txbuf[i], cpm->txdma[i]); 625 cpm->txbuf[i], cpm->txdma[i]);
626 } 626 }
627 627
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 10411848fd70..9d2c5adf5d4f 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -237,7 +237,7 @@ static int i801_transaction(int xact)
237 status = inb_p(SMBHSTSTS); 237 status = inb_p(SMBHSTSTS);
238 } while ((status & SMBHSTSTS_HOST_BUSY) && (timeout++ < MAX_TIMEOUT)); 238 } while ((status & SMBHSTSTS_HOST_BUSY) && (timeout++ < MAX_TIMEOUT));
239 239
240 result = i801_check_post(status, timeout >= MAX_TIMEOUT); 240 result = i801_check_post(status, timeout > MAX_TIMEOUT);
241 if (result < 0) 241 if (result < 0)
242 return result; 242 return result;
243 243
@@ -257,9 +257,9 @@ static void i801_wait_hwpec(void)
257 } while ((!(status & SMBHSTSTS_INTR)) 257 } while ((!(status & SMBHSTSTS_INTR))
258 && (timeout++ < MAX_TIMEOUT)); 258 && (timeout++ < MAX_TIMEOUT));
259 259
260 if (timeout >= MAX_TIMEOUT) { 260 if (timeout > MAX_TIMEOUT)
261 dev_dbg(&I801_dev->dev, "PEC Timeout!\n"); 261 dev_dbg(&I801_dev->dev, "PEC Timeout!\n");
262 } 262
263 outb_p(status, SMBHSTSTS); 263 outb_p(status, SMBHSTSTS);
264} 264}
265 265
@@ -344,7 +344,7 @@ static int i801_block_transaction_byte_by_byte(union i2c_smbus_data *data,
344 while ((!(status & SMBHSTSTS_BYTE_DONE)) 344 while ((!(status & SMBHSTSTS_BYTE_DONE))
345 && (timeout++ < MAX_TIMEOUT)); 345 && (timeout++ < MAX_TIMEOUT));
346 346
347 result = i801_check_post(status, timeout >= MAX_TIMEOUT); 347 result = i801_check_post(status, timeout > MAX_TIMEOUT);
348 if (result < 0) 348 if (result < 0)
349 return result; 349 return result;
350 350
diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c
index b9c01aa90036..9f6b8e0f8632 100644
--- a/drivers/i2c/busses/i2c-isch.c
+++ b/drivers/i2c/busses/i2c-isch.c
@@ -112,7 +112,7 @@ static int sch_transaction(void)
112 } while ((temp & 0x08) && (timeout++ < MAX_TIMEOUT)); 112 } while ((temp & 0x08) && (timeout++ < MAX_TIMEOUT));
113 113
114 /* If the SMBus is still busy, we give up */ 114 /* If the SMBus is still busy, we give up */
115 if (timeout >= MAX_TIMEOUT) { 115 if (timeout > MAX_TIMEOUT) {
116 dev_err(&sch_adapter.dev, "SMBus Timeout!\n"); 116 dev_err(&sch_adapter.dev, "SMBus Timeout!\n");
117 result = -ETIMEDOUT; 117 result = -ETIMEDOUT;
118 } 118 }
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 4af5c09f0e8f..dd778d7ae047 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -164,7 +164,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
164 return 0; 164 return 0;
165} 165}
166 166
167#ifdef CONFIG_PPC_52xx 167#ifdef CONFIG_PPC_MPC52xx
168static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = { 168static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
169 {20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23}, 169 {20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23},
170 {28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02}, 170 {28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02},
@@ -188,7 +188,7 @@ static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
188 188
189int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, int prescaler) 189int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, int prescaler)
190{ 190{
191 const struct mpc52xx_i2c_divider *div = NULL; 191 const struct mpc_i2c_divider *div = NULL;
192 unsigned int pvr = mfspr(SPRN_PVR); 192 unsigned int pvr = mfspr(SPRN_PVR);
193 u32 divider; 193 u32 divider;
194 int i; 194 int i;
@@ -203,7 +203,7 @@ int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, int prescaler)
203 * We want to choose an FDR/DFSR that generates an I2C bus speed that 203 * We want to choose an FDR/DFSR that generates an I2C bus speed that
204 * is equal to or lower than the requested speed. 204 * is equal to or lower than the requested speed.
205 */ 205 */
206 for (i = 0; i < ARRAY_SIZE(mpc52xx_i2c_dividers); i++) { 206 for (i = 0; i < ARRAY_SIZE(mpc_i2c_dividers_52xx); i++) {
207 div = &mpc_i2c_dividers_52xx[i]; 207 div = &mpc_i2c_dividers_52xx[i];
208 /* Old MPC5200 rev A CPUs do not support the high bits */ 208 /* Old MPC5200 rev A CPUs do not support the high bits */
209 if (div->fdr & 0xc0 && pvr == 0x80822011) 209 if (div->fdr & 0xc0 && pvr == 0x80822011)
@@ -219,20 +219,23 @@ static void mpc_i2c_setclock_52xx(struct device_node *node,
219 struct mpc_i2c *i2c, 219 struct mpc_i2c *i2c,
220 u32 clock, u32 prescaler) 220 u32 clock, u32 prescaler)
221{ 221{
222 int fdr = mpc52xx_i2c_get_fdr(node, clock, prescaler); 222 int ret, fdr;
223
224 ret = mpc_i2c_get_fdr_52xx(node, clock, prescaler);
225 fdr = (ret >= 0) ? ret : 0x3f; /* backward compatibility */
223 226
224 if (fdr < 0)
225 fdr = 0x3f; /* backward compatibility */
226 writeb(fdr & 0xff, i2c->base + MPC_I2C_FDR); 227 writeb(fdr & 0xff, i2c->base + MPC_I2C_FDR);
227 dev_info(i2c->dev, "clock %d Hz (fdr=%d)\n", clock, fdr); 228
229 if (ret >= 0)
230 dev_info(i2c->dev, "clock %d Hz (fdr=%d)\n", clock, fdr);
228} 231}
229#else /* !CONFIG_PPC_52xx */ 232#else /* !CONFIG_PPC_MPC52xx */
230static void mpc_i2c_setclock_52xx(struct device_node *node, 233static void mpc_i2c_setclock_52xx(struct device_node *node,
231 struct mpc_i2c *i2c, 234 struct mpc_i2c *i2c,
232 u32 clock, u32 prescaler) 235 u32 clock, u32 prescaler)
233{ 236{
234} 237}
235#endif /* CONFIG_PPC_52xx*/ 238#endif /* CONFIG_PPC_MPC52xx*/
236 239
237#ifdef CONFIG_FSL_SOC 240#ifdef CONFIG_FSL_SOC
238static const struct mpc_i2c_divider mpc_i2c_dividers_8xxx[] = { 241static const struct mpc_i2c_divider mpc_i2c_dividers_8xxx[] = {
@@ -321,14 +324,17 @@ static void mpc_i2c_setclock_8xxx(struct device_node *node,
321 struct mpc_i2c *i2c, 324 struct mpc_i2c *i2c,
322 u32 clock, u32 prescaler) 325 u32 clock, u32 prescaler)
323{ 326{
324 int fdr = mpc_i2c_get_fdr_8xxx(node, clock, prescaler); 327 int ret, fdr;
328
329 ret = mpc_i2c_get_fdr_8xxx(node, clock, prescaler);
330 fdr = (ret >= 0) ? ret : 0x1031; /* backward compatibility */
325 331
326 if (fdr < 0)
327 fdr = 0x1031; /* backward compatibility */
328 writeb(fdr & 0xff, i2c->base + MPC_I2C_FDR); 332 writeb(fdr & 0xff, i2c->base + MPC_I2C_FDR);
329 writeb((fdr >> 8) & 0xff, i2c->base + MPC_I2C_DFSRR); 333 writeb((fdr >> 8) & 0xff, i2c->base + MPC_I2C_DFSRR);
330 dev_info(i2c->dev, "clock %d Hz (dfsrr=%d fdr=%d)\n", 334
331 clock, fdr >> 8, fdr & 0xff); 335 if (ret >= 0)
336 dev_info(i2c->dev, "clock %d Hz (dfsrr=%d fdr=%d)\n",
337 clock, fdr >> 8, fdr & 0xff);
332} 338}
333 339
334#else /* !CONFIG_FSL_SOC */ 340#else /* !CONFIG_FSL_SOC */
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index 2ff4683703a8..ec11d1c4e77b 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -173,7 +173,7 @@ static int nforce2_check_status(struct i2c_adapter *adap)
173 temp = inb_p(NVIDIA_SMB_STS); 173 temp = inb_p(NVIDIA_SMB_STS);
174 } while ((!temp) && (timeout++ < MAX_TIMEOUT)); 174 } while ((!temp) && (timeout++ < MAX_TIMEOUT));
175 175
176 if (timeout >= MAX_TIMEOUT) { 176 if (timeout > MAX_TIMEOUT) {
177 dev_dbg(&adap->dev, "SMBus Timeout!\n"); 177 dev_dbg(&adap->dev, "SMBus Timeout!\n");
178 if (smbus->can_abort) 178 if (smbus->can_abort)
179 nforce2_abort(adap); 179 nforce2_abort(adap);
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index c1405c8f6ba5..acc7143d9655 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -265,10 +265,10 @@ static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
265 show_state(i2c); 265 show_state(i2c);
266 } 266 }
267 267
268 if (timeout <= 0) 268 if (timeout < 0)
269 show_state(i2c); 269 show_state(i2c);
270 270
271 return timeout <= 0 ? I2C_RETRY : 0; 271 return timeout < 0 ? I2C_RETRY : 0;
272} 272}
273 273
274static int i2c_pxa_wait_master(struct pxa_i2c *i2c) 274static int i2c_pxa_wait_master(struct pxa_i2c *i2c)
@@ -612,7 +612,7 @@ static int i2c_pxa_pio_set_master(struct pxa_i2c *i2c)
612 show_state(i2c); 612 show_state(i2c);
613 } 613 }
614 614
615 if (timeout <= 0) { 615 if (timeout < 0) {
616 show_state(i2c); 616 show_state(i2c);
617 dev_err(&i2c->adap.dev, 617 dev_err(&i2c->adap.dev,
618 "i2c_pxa: timeout waiting for bus free\n"); 618 "i2c_pxa: timeout waiting for bus free\n");
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c
index f320ab27da46..139f0c7f12a4 100644
--- a/drivers/i2c/busses/i2c-sis5595.c
+++ b/drivers/i2c/busses/i2c-sis5595.c
@@ -256,7 +256,7 @@ static int sis5595_transaction(struct i2c_adapter *adap)
256 } while (!(temp & 0x40) && (timeout++ < MAX_TIMEOUT)); 256 } while (!(temp & 0x40) && (timeout++ < MAX_TIMEOUT));
257 257
258 /* If the SMBus is still busy, we give up */ 258 /* If the SMBus is still busy, we give up */
259 if (timeout >= MAX_TIMEOUT) { 259 if (timeout > MAX_TIMEOUT) {
260 dev_dbg(&adap->dev, "SMBus Timeout!\n"); 260 dev_dbg(&adap->dev, "SMBus Timeout!\n");
261 result = -ETIMEDOUT; 261 result = -ETIMEDOUT;
262 } 262 }
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c
index 50c3610e6028..70ca41e90e58 100644
--- a/drivers/i2c/busses/i2c-sis630.c
+++ b/drivers/i2c/busses/i2c-sis630.c
@@ -173,7 +173,7 @@ static int sis630_transaction_wait(struct i2c_adapter *adap, int size)
173 } while (!(temp & 0x0e) && (timeout++ < MAX_TIMEOUT)); 173 } while (!(temp & 0x0e) && (timeout++ < MAX_TIMEOUT));
174 174
175 /* If the SMBus is still busy, we give up */ 175 /* If the SMBus is still busy, we give up */
176 if (timeout >= MAX_TIMEOUT) { 176 if (timeout > MAX_TIMEOUT) {
177 dev_dbg(&adap->dev, "SMBus Timeout!\n"); 177 dev_dbg(&adap->dev, "SMBus Timeout!\n");
178 result = -ETIMEDOUT; 178 result = -ETIMEDOUT;
179 } 179 }
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c
index 7e1594b40579..8295885b2fdb 100644
--- a/drivers/i2c/busses/i2c-sis96x.c
+++ b/drivers/i2c/busses/i2c-sis96x.c
@@ -132,7 +132,7 @@ static int sis96x_transaction(int size)
132 } while (!(temp & 0x0e) && (timeout++ < MAX_TIMEOUT)); 132 } while (!(temp & 0x0e) && (timeout++ < MAX_TIMEOUT));
133 133
134 /* If the SMBus is still busy, we give up */ 134 /* If the SMBus is still busy, we give up */
135 if (timeout >= MAX_TIMEOUT) { 135 if (timeout > MAX_TIMEOUT) {
136 dev_dbg(&sis96x_adapter.dev, "SMBus Timeout! (0x%02x)\n", temp); 136 dev_dbg(&sis96x_adapter.dev, "SMBus Timeout! (0x%02x)\n", temp);
137 result = -ETIMEDOUT; 137 result = -ETIMEDOUT;
138 } 138 }
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.c b/drivers/infiniband/hw/cxgb3/cxio_hal.c
index 8d71086f5a1c..62f9cf2f94ec 100644
--- a/drivers/infiniband/hw/cxgb3/cxio_hal.c
+++ b/drivers/infiniband/hw/cxgb3/cxio_hal.c
@@ -410,6 +410,7 @@ int cxio_flush_sq(struct t3_wq *wq, struct t3_cq *cq, int count)
410 ptr = wq->sq_rptr + count; 410 ptr = wq->sq_rptr + count;
411 sqp = wq->sq + Q_PTR2IDX(ptr, wq->sq_size_log2); 411 sqp = wq->sq + Q_PTR2IDX(ptr, wq->sq_size_log2);
412 while (ptr != wq->sq_wptr) { 412 while (ptr != wq->sq_wptr) {
413 sqp->signaled = 0;
413 insert_sq_cqe(wq, cq, sqp); 414 insert_sq_cqe(wq, cq, sqp);
414 ptr++; 415 ptr++;
415 sqp = wq->sq + Q_PTR2IDX(ptr, wq->sq_size_log2); 416 sqp = wq->sq + Q_PTR2IDX(ptr, wq->sq_size_log2);
diff --git a/drivers/infiniband/hw/ipath/ipath_fs.c b/drivers/infiniband/hw/ipath/ipath_fs.c
index 8dc2bb781605..b3684060465e 100644
--- a/drivers/infiniband/hw/ipath/ipath_fs.c
+++ b/drivers/infiniband/hw/ipath/ipath_fs.c
@@ -347,7 +347,7 @@ static int ipathfs_fill_super(struct super_block *sb, void *data,
347 spin_unlock_irqrestore(&ipath_devs_lock, flags); 347 spin_unlock_irqrestore(&ipath_devs_lock, flags);
348 ret = create_device_files(sb, dd); 348 ret = create_device_files(sb, dd);
349 if (ret) { 349 if (ret) {
350 deactivate_super(sb); 350 deactivate_locked_super(sb);
351 goto bail; 351 goto bail;
352 } 352 }
353 spin_lock_irqsave(&ipath_devs_lock, flags); 353 spin_lock_irqsave(&ipath_devs_lock, flags);
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index 9974e886b8de..8a7dd6795fa0 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -86,6 +86,7 @@ struct mlx4_ib_mr {
86 86
87struct mlx4_ib_fast_reg_page_list { 87struct mlx4_ib_fast_reg_page_list {
88 struct ib_fast_reg_page_list ibfrpl; 88 struct ib_fast_reg_page_list ibfrpl;
89 __be64 *mapped_page_list;
89 dma_addr_t map; 90 dma_addr_t map;
90}; 91};
91 92
diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c
index 8e4d26d56a95..8f3666b20ea4 100644
--- a/drivers/infiniband/hw/mlx4/mr.c
+++ b/drivers/infiniband/hw/mlx4/mr.c
@@ -231,7 +231,11 @@ struct ib_fast_reg_page_list *mlx4_ib_alloc_fast_reg_page_list(struct ib_device
231 if (!mfrpl) 231 if (!mfrpl)
232 return ERR_PTR(-ENOMEM); 232 return ERR_PTR(-ENOMEM);
233 233
234 mfrpl->ibfrpl.page_list = dma_alloc_coherent(&dev->dev->pdev->dev, 234 mfrpl->ibfrpl.page_list = kmalloc(size, GFP_KERNEL);
235 if (!mfrpl->ibfrpl.page_list)
236 goto err_free;
237
238 mfrpl->mapped_page_list = dma_alloc_coherent(&dev->dev->pdev->dev,
235 size, &mfrpl->map, 239 size, &mfrpl->map,
236 GFP_KERNEL); 240 GFP_KERNEL);
237 if (!mfrpl->ibfrpl.page_list) 241 if (!mfrpl->ibfrpl.page_list)
@@ -242,6 +246,7 @@ struct ib_fast_reg_page_list *mlx4_ib_alloc_fast_reg_page_list(struct ib_device
242 return &mfrpl->ibfrpl; 246 return &mfrpl->ibfrpl;
243 247
244err_free: 248err_free:
249 kfree(mfrpl->ibfrpl.page_list);
245 kfree(mfrpl); 250 kfree(mfrpl);
246 return ERR_PTR(-ENOMEM); 251 return ERR_PTR(-ENOMEM);
247} 252}
@@ -252,8 +257,9 @@ void mlx4_ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list)
252 struct mlx4_ib_fast_reg_page_list *mfrpl = to_mfrpl(page_list); 257 struct mlx4_ib_fast_reg_page_list *mfrpl = to_mfrpl(page_list);
253 int size = page_list->max_page_list_len * sizeof (u64); 258 int size = page_list->max_page_list_len * sizeof (u64);
254 259
255 dma_free_coherent(&dev->dev->pdev->dev, size, page_list->page_list, 260 dma_free_coherent(&dev->dev->pdev->dev, size, mfrpl->mapped_page_list,
256 mfrpl->map); 261 mfrpl->map);
262 kfree(mfrpl->ibfrpl.page_list);
257 kfree(mfrpl); 263 kfree(mfrpl);
258} 264}
259 265
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index f385a24d31d2..20724aee76f4 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -1365,7 +1365,7 @@ static void set_fmr_seg(struct mlx4_wqe_fmr_seg *fseg, struct ib_send_wr *wr)
1365 int i; 1365 int i;
1366 1366
1367 for (i = 0; i < wr->wr.fast_reg.page_list_len; ++i) 1367 for (i = 0; i < wr->wr.fast_reg.page_list_len; ++i)
1368 wr->wr.fast_reg.page_list->page_list[i] = 1368 mfrpl->mapped_page_list[i] =
1369 cpu_to_be64(wr->wr.fast_reg.page_list->page_list[i] | 1369 cpu_to_be64(wr->wr.fast_reg.page_list->page_list[i] |
1370 MLX4_MTT_FLAG_PRESENT); 1370 MLX4_MTT_FLAG_PRESENT);
1371 1371
diff --git a/drivers/input/ff-memless.c b/drivers/input/ff-memless.c
index bc4e40f3ede7..2d1415e16834 100644
--- a/drivers/input/ff-memless.c
+++ b/drivers/input/ff-memless.c
@@ -226,7 +226,7 @@ static int get_compatible_type(struct ff_device *ff, int effect_type)
226 */ 226 */
227static void ml_combine_effects(struct ff_effect *effect, 227static void ml_combine_effects(struct ff_effect *effect,
228 struct ml_effect_state *state, 228 struct ml_effect_state *state,
229 int gain) 229 unsigned int gain)
230{ 230{
231 struct ff_effect *new = state->effect; 231 struct ff_effect *new = state->effect;
232 unsigned int strong, weak, i; 232 unsigned int strong, weak, i;
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 4224f0112849..012a5e753991 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -843,7 +843,13 @@ static const struct input_device_id joydev_blacklist[] = {
843 INPUT_DEVICE_ID_MATCH_KEYBIT, 843 INPUT_DEVICE_ID_MATCH_KEYBIT,
844 .evbit = { BIT_MASK(EV_KEY) }, 844 .evbit = { BIT_MASK(EV_KEY) },
845 .keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) }, 845 .keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) },
846 }, /* Avoid itouchpads, touchscreens and tablets */ 846 }, /* Avoid itouchpads and touchscreens */
847 {
848 .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
849 INPUT_DEVICE_ID_MATCH_KEYBIT,
850 .evbit = { BIT_MASK(EV_KEY) },
851 .keybit = { [BIT_WORD(BTN_DIGI)] = BIT_MASK(BTN_DIGI) },
852 }, /* Avoid tablets, digitisers and similar devices */
847 { } /* Terminating entry */ 853 { } /* Terminating entry */
848}; 854};
849 855
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 444dec07e5d8..df3f8aa68115 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -895,6 +895,13 @@ static unsigned int atkbd_amilo_pa1510_forced_release_keys[] = {
895}; 895};
896 896
897/* 897/*
898 * Amilo Xi 3650 key release for light touch bar not working
899 */
900static unsigned int atkbd_amilo_xi3650_forced_release_keys[] = {
901 0x67, 0xed, 0x90, 0xa2, 0x99, 0xa4, 0xae, 0xb0, -1U
902};
903
904/*
898 * atkbd_set_keycode_table() initializes keyboard's keycode table 905 * atkbd_set_keycode_table() initializes keyboard's keycode table
899 * according to the selected scancode set 906 * according to the selected scancode set
900 */ 907 */
@@ -1560,6 +1567,15 @@ static struct dmi_system_id atkbd_dmi_quirk_table[] __initdata = {
1560 .callback = atkbd_setup_forced_release, 1567 .callback = atkbd_setup_forced_release,
1561 .driver_data = atkbd_amilo_pa1510_forced_release_keys, 1568 .driver_data = atkbd_amilo_pa1510_forced_release_keys,
1562 }, 1569 },
1570 {
1571 .ident = "Fujitsu Amilo Xi 3650",
1572 .matches = {
1573 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
1574 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Xi 3650"),
1575 },
1576 .callback = atkbd_setup_forced_release,
1577 .driver_data = atkbd_amilo_xi3650_forced_release_keys,
1578 },
1563 { } 1579 { }
1564}; 1580};
1565 1581
diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
index 536668fbda22..948e167557f1 100644
--- a/drivers/input/touchscreen/tsc2007.c
+++ b/drivers/input/touchscreen/tsc2007.c
@@ -200,8 +200,9 @@ static int tsc2007_read_values(struct tsc2007 *tsc)
200static enum hrtimer_restart tsc2007_timer(struct hrtimer *handle) 200static enum hrtimer_restart tsc2007_timer(struct hrtimer *handle)
201{ 201{
202 struct tsc2007 *ts = container_of(handle, struct tsc2007, timer); 202 struct tsc2007 *ts = container_of(handle, struct tsc2007, timer);
203 unsigned long flags;
203 204
204 spin_lock_irq(&ts->lock); 205 spin_lock_irqsave(&ts->lock, flags);
205 206
206 if (unlikely(!ts->get_pendown_state() && ts->pendown)) { 207 if (unlikely(!ts->get_pendown_state() && ts->pendown)) {
207 struct input_dev *input = ts->input; 208 struct input_dev *input = ts->input;
@@ -222,7 +223,7 @@ static enum hrtimer_restart tsc2007_timer(struct hrtimer *handle)
222 tsc2007_send_event(ts); 223 tsc2007_send_event(ts);
223 } 224 }
224 225
225 spin_unlock_irq(&ts->lock); 226 spin_unlock_irqrestore(&ts->lock, flags);
226 227
227 return HRTIMER_NORESTART; 228 return HRTIMER_NORESTART;
228} 229}
diff --git a/drivers/isdn/capi/capifs.c b/drivers/isdn/capi/capifs.c
index b129409925af..bff72d81f263 100644
--- a/drivers/isdn/capi/capifs.c
+++ b/drivers/isdn/capi/capifs.c
@@ -75,15 +75,17 @@ static int capifs_remount(struct super_block *s, int *flags, char *data)
75 } 75 }
76 } 76 }
77 77
78 kfree(s->s_options); 78 mutex_lock(&s->s_root->d_inode->i_mutex);
79 s->s_options = new_opt;
80 79
80 replace_mount_options(s, new_opt);
81 config.setuid = setuid; 81 config.setuid = setuid;
82 config.setgid = setgid; 82 config.setgid = setgid;
83 config.uid = uid; 83 config.uid = uid;
84 config.gid = gid; 84 config.gid = gid;
85 config.mode = mode; 85 config.mode = mode;
86 86
87 mutex_unlock(&s->s_root->d_inode->i_mutex);
88
87 return 0; 89 return 0;
88} 90}
89 91
@@ -154,13 +156,16 @@ void capifs_new_ncci(unsigned int number, dev_t device)
154 if (!inode) 156 if (!inode)
155 return; 157 return;
156 inode->i_ino = number+2; 158 inode->i_ino = number+2;
159
160 dentry = get_node(number);
161
162 /* config contents is protected by root's i_mutex */
157 inode->i_uid = config.setuid ? config.uid : current_fsuid(); 163 inode->i_uid = config.setuid ? config.uid : current_fsuid();
158 inode->i_gid = config.setgid ? config.gid : current_fsgid(); 164 inode->i_gid = config.setgid ? config.gid : current_fsgid();
159 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 165 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
160 init_special_inode(inode, S_IFCHR|config.mode, device); 166 init_special_inode(inode, S_IFCHR|config.mode, device);
161 //inode->i_op = &capifs_file_inode_operations; 167 //inode->i_op = &capifs_file_inode_operations;
162 168
163 dentry = get_node(number);
164 if (!IS_ERR(dentry) && !dentry->d_inode) 169 if (!IS_ERR(dentry) && !dentry->d_inode)
165 d_instantiate(dentry, inode); 170 d_instantiate(dentry, inode);
166 mutex_unlock(&capifs_root->d_inode->i_mutex); 171 mutex_unlock(&capifs_root->d_inode->i_mutex);
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 1fb91edc7de2..47c68bc75a17 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -986,6 +986,9 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
986 oldindex = index; 986 oldindex = index;
987 oldpage = page; 987 oldpage = page;
988 988
989 bitmap->filemap[bitmap->file_pages++] = page;
990 bitmap->last_page_size = count;
991
989 if (outofdate) { 992 if (outofdate) {
990 /* 993 /*
991 * if bitmap is out of date, dirty the 994 * if bitmap is out of date, dirty the
@@ -998,15 +1001,9 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
998 write_page(bitmap, page, 1); 1001 write_page(bitmap, page, 1);
999 1002
1000 ret = -EIO; 1003 ret = -EIO;
1001 if (bitmap->flags & BITMAP_WRITE_ERROR) { 1004 if (bitmap->flags & BITMAP_WRITE_ERROR)
1002 /* release, page not in filemap yet */
1003 put_page(page);
1004 goto err; 1005 goto err;
1005 }
1006 } 1006 }
1007
1008 bitmap->filemap[bitmap->file_pages++] = page;
1009 bitmap->last_page_size = count;
1010 } 1007 }
1011 paddr = kmap_atomic(page, KM_USER0); 1008 paddr = kmap_atomic(page, KM_USER0);
1012 if (bitmap->flags & BITMAP_HOSTENDIAN) 1009 if (bitmap->flags & BITMAP_HOSTENDIAN)
@@ -1016,9 +1013,11 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
1016 kunmap_atomic(paddr, KM_USER0); 1013 kunmap_atomic(paddr, KM_USER0);
1017 if (b) { 1014 if (b) {
1018 /* if the disk bit is set, set the memory bit */ 1015 /* if the disk bit is set, set the memory bit */
1019 bitmap_set_memory_bits(bitmap, i << CHUNK_BLOCK_SHIFT(bitmap), 1016 int needed = ((sector_t)(i+1) << (CHUNK_BLOCK_SHIFT(bitmap))
1020 ((i+1) << (CHUNK_BLOCK_SHIFT(bitmap)) >= start) 1017 >= start);
1021 ); 1018 bitmap_set_memory_bits(bitmap,
1019 (sector_t)i << CHUNK_BLOCK_SHIFT(bitmap),
1020 needed);
1022 bit_cnt++; 1021 bit_cnt++;
1023 set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN); 1022 set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
1024 } 1023 }
@@ -1154,8 +1153,9 @@ void bitmap_daemon_work(struct bitmap *bitmap)
1154 spin_lock_irqsave(&bitmap->lock, flags); 1153 spin_lock_irqsave(&bitmap->lock, flags);
1155 clear_page_attr(bitmap, page, BITMAP_PAGE_CLEAN); 1154 clear_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
1156 } 1155 }
1157 bmc = bitmap_get_counter(bitmap, j << CHUNK_BLOCK_SHIFT(bitmap), 1156 bmc = bitmap_get_counter(bitmap,
1158 &blocks, 0); 1157 (sector_t)j << CHUNK_BLOCK_SHIFT(bitmap),
1158 &blocks, 0);
1159 if (bmc) { 1159 if (bmc) {
1160/* 1160/*
1161 if (j < 100) printk("bitmap: j=%lu, *bmc = 0x%x\n", j, *bmc); 1161 if (j < 100) printk("bitmap: j=%lu, *bmc = 0x%x\n", j, *bmc);
@@ -1169,7 +1169,8 @@ void bitmap_daemon_work(struct bitmap *bitmap)
1169 } else if (*bmc == 1) { 1169 } else if (*bmc == 1) {
1170 /* we can clear the bit */ 1170 /* we can clear the bit */
1171 *bmc = 0; 1171 *bmc = 0;
1172 bitmap_count_page(bitmap, j << CHUNK_BLOCK_SHIFT(bitmap), 1172 bitmap_count_page(bitmap,
1173 (sector_t)j << CHUNK_BLOCK_SHIFT(bitmap),
1173 -1); 1174 -1);
1174 1175
1175 /* clear the bit */ 1176 /* clear the bit */
@@ -1514,7 +1515,7 @@ void bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e)
1514 unsigned long chunk; 1515 unsigned long chunk;
1515 1516
1516 for (chunk = s; chunk <= e; chunk++) { 1517 for (chunk = s; chunk <= e; chunk++) {
1517 sector_t sec = chunk << CHUNK_BLOCK_SHIFT(bitmap); 1518 sector_t sec = (sector_t)chunk << CHUNK_BLOCK_SHIFT(bitmap);
1518 bitmap_set_memory_bits(bitmap, sec, 1); 1519 bitmap_set_memory_bits(bitmap, sec, 1);
1519 bitmap_file_set_bit(bitmap, sec); 1520 bitmap_file_set_bit(bitmap, sec);
1520 } 1521 }
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 612343fdde94..fccc8343a250 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -3066,11 +3066,8 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len)
3066 } else 3066 } else
3067 err = -EBUSY; 3067 err = -EBUSY;
3068 spin_unlock_irq(&mddev->write_lock); 3068 spin_unlock_irq(&mddev->write_lock);
3069 } else { 3069 } else
3070 mddev->ro = 0; 3070 err = -EINVAL;
3071 mddev->recovery_cp = MaxSector;
3072 err = do_md_run(mddev);
3073 }
3074 break; 3071 break;
3075 case active: 3072 case active:
3076 if (mddev->pers) { 3073 if (mddev->pers) {
@@ -4297,6 +4294,7 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
4297{ 4294{
4298 int err = 0; 4295 int err = 0;
4299 struct gendisk *disk = mddev->gendisk; 4296 struct gendisk *disk = mddev->gendisk;
4297 mdk_rdev_t *rdev;
4300 4298
4301 if (atomic_read(&mddev->openers) > is_open) { 4299 if (atomic_read(&mddev->openers) > is_open) {
4302 printk("md: %s still in use.\n",mdname(mddev)); 4300 printk("md: %s still in use.\n",mdname(mddev));
@@ -4339,6 +4337,13 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
4339 /* tell userspace to handle 'inactive' */ 4337 /* tell userspace to handle 'inactive' */
4340 sysfs_notify_dirent(mddev->sysfs_state); 4338 sysfs_notify_dirent(mddev->sysfs_state);
4341 4339
4340 list_for_each_entry(rdev, &mddev->disks, same_set)
4341 if (rdev->raid_disk >= 0) {
4342 char nm[20];
4343 sprintf(nm, "rd%d", rdev->raid_disk);
4344 sysfs_remove_link(&mddev->kobj, nm);
4345 }
4346
4342 set_capacity(disk, 0); 4347 set_capacity(disk, 0);
4343 mddev->changed = 1; 4348 mddev->changed = 1;
4344 4349
@@ -4359,7 +4364,6 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
4359 * Free resources if final stop 4364 * Free resources if final stop
4360 */ 4365 */
4361 if (mode == 0) { 4366 if (mode == 0) {
4362 mdk_rdev_t *rdev;
4363 4367
4364 printk(KERN_INFO "md: %s stopped.\n", mdname(mddev)); 4368 printk(KERN_INFO "md: %s stopped.\n", mdname(mddev));
4365 4369
@@ -4371,13 +4375,6 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
4371 } 4375 }
4372 mddev->bitmap_offset = 0; 4376 mddev->bitmap_offset = 0;
4373 4377
4374 list_for_each_entry(rdev, &mddev->disks, same_set)
4375 if (rdev->raid_disk >= 0) {
4376 char nm[20];
4377 sprintf(nm, "rd%d", rdev->raid_disk);
4378 sysfs_remove_link(&mddev->kobj, nm);
4379 }
4380
4381 /* make sure all md_delayed_delete calls have finished */ 4378 /* make sure all md_delayed_delete calls have finished */
4382 flush_scheduled_work(); 4379 flush_scheduled_work();
4383 4380
@@ -5705,37 +5702,38 @@ static void status_unused(struct seq_file *seq)
5705 5702
5706static void status_resync(struct seq_file *seq, mddev_t * mddev) 5703static void status_resync(struct seq_file *seq, mddev_t * mddev)
5707{ 5704{
5708 sector_t max_blocks, resync, res; 5705 sector_t max_sectors, resync, res;
5709 unsigned long dt, db, rt; 5706 unsigned long dt, db;
5707 sector_t rt;
5710 int scale; 5708 int scale;
5711 unsigned int per_milli; 5709 unsigned int per_milli;
5712 5710
5713 resync = (mddev->curr_resync - atomic_read(&mddev->recovery_active))/2; 5711 resync = mddev->curr_resync - atomic_read(&mddev->recovery_active);
5714 5712
5715 if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) 5713 if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery))
5716 max_blocks = mddev->resync_max_sectors >> 1; 5714 max_sectors = mddev->resync_max_sectors;
5717 else 5715 else
5718 max_blocks = mddev->dev_sectors / 2; 5716 max_sectors = mddev->dev_sectors;
5719 5717
5720 /* 5718 /*
5721 * Should not happen. 5719 * Should not happen.
5722 */ 5720 */
5723 if (!max_blocks) { 5721 if (!max_sectors) {
5724 MD_BUG(); 5722 MD_BUG();
5725 return; 5723 return;
5726 } 5724 }
5727 /* Pick 'scale' such that (resync>>scale)*1000 will fit 5725 /* Pick 'scale' such that (resync>>scale)*1000 will fit
5728 * in a sector_t, and (max_blocks>>scale) will fit in a 5726 * in a sector_t, and (max_sectors>>scale) will fit in a
5729 * u32, as those are the requirements for sector_div. 5727 * u32, as those are the requirements for sector_div.
5730 * Thus 'scale' must be at least 10 5728 * Thus 'scale' must be at least 10
5731 */ 5729 */
5732 scale = 10; 5730 scale = 10;
5733 if (sizeof(sector_t) > sizeof(unsigned long)) { 5731 if (sizeof(sector_t) > sizeof(unsigned long)) {
5734 while ( max_blocks/2 > (1ULL<<(scale+32))) 5732 while ( max_sectors/2 > (1ULL<<(scale+32)))
5735 scale++; 5733 scale++;
5736 } 5734 }
5737 res = (resync>>scale)*1000; 5735 res = (resync>>scale)*1000;
5738 sector_div(res, (u32)((max_blocks>>scale)+1)); 5736 sector_div(res, (u32)((max_sectors>>scale)+1));
5739 5737
5740 per_milli = res; 5738 per_milli = res;
5741 { 5739 {
@@ -5756,25 +5754,35 @@ static void status_resync(struct seq_file *seq, mddev_t * mddev)
5756 (test_bit(MD_RECOVERY_SYNC, &mddev->recovery) ? 5754 (test_bit(MD_RECOVERY_SYNC, &mddev->recovery) ?
5757 "resync" : "recovery"))), 5755 "resync" : "recovery"))),
5758 per_milli/10, per_milli % 10, 5756 per_milli/10, per_milli % 10,
5759 (unsigned long long) resync, 5757 (unsigned long long) resync/2,
5760 (unsigned long long) max_blocks); 5758 (unsigned long long) max_sectors/2);
5761 5759
5762 /* 5760 /*
5763 * We do not want to overflow, so the order of operands and
5764 * the * 100 / 100 trick are important. We do a +1 to be
5765 * safe against division by zero. We only estimate anyway.
5766 *
5767 * dt: time from mark until now 5761 * dt: time from mark until now
5768 * db: blocks written from mark until now 5762 * db: blocks written from mark until now
5769 * rt: remaining time 5763 * rt: remaining time
5764 *
5765 * rt is a sector_t, so could be 32bit or 64bit.
5766 * So we divide before multiply in case it is 32bit and close
5767 * to the limit.
5768 * We scale the divisor (db) by 32 to avoid loosing precision
5769 * near the end of resync when the number of remaining sectors
5770 * is close to 'db'.
5771 * We then divide rt by 32 after multiplying by db to compensate.
5772 * The '+1' avoids division by zero if db is very small.
5770 */ 5773 */
5771 dt = ((jiffies - mddev->resync_mark) / HZ); 5774 dt = ((jiffies - mddev->resync_mark) / HZ);
5772 if (!dt) dt++; 5775 if (!dt) dt++;
5773 db = (mddev->curr_mark_cnt - atomic_read(&mddev->recovery_active)) 5776 db = (mddev->curr_mark_cnt - atomic_read(&mddev->recovery_active))
5774 - mddev->resync_mark_cnt; 5777 - mddev->resync_mark_cnt;
5775 rt = (dt * ((unsigned long)(max_blocks-resync) / (db/2/100+1)))/100;
5776 5778
5777 seq_printf(seq, " finish=%lu.%lumin", rt / 60, (rt % 60)/6); 5779 rt = max_sectors - resync; /* number of remaining sectors */
5780 sector_div(rt, db/32+1);
5781 rt *= dt;
5782 rt >>= 5;
5783
5784 seq_printf(seq, " finish=%lu.%lumin", (unsigned long)rt / 60,
5785 ((unsigned long)rt % 60)/6);
5778 5786
5779 seq_printf(seq, " speed=%ldK/sec", db/2/dt); 5787 seq_printf(seq, " speed=%ldK/sec", db/2/dt);
5780} 5788}
@@ -5965,7 +5973,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
5965 return 0; 5973 return 0;
5966} 5974}
5967 5975
5968static struct seq_operations md_seq_ops = { 5976static const struct seq_operations md_seq_ops = {
5969 .start = md_seq_start, 5977 .start = md_seq_start,
5970 .next = md_seq_next, 5978 .next = md_seq_next,
5971 .stop = md_seq_stop, 5979 .stop = md_seq_stop,
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 81a54f17417e..499620afb44b 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1809,17 +1809,17 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1809 r10_bio->sector = sect; 1809 r10_bio->sector = sect;
1810 1810
1811 raid10_find_phys(conf, r10_bio); 1811 raid10_find_phys(conf, r10_bio);
1812 /* Need to check if this section will still be 1812
1813 /* Need to check if the array will still be
1813 * degraded 1814 * degraded
1814 */ 1815 */
1815 for (j=0; j<conf->copies;j++) { 1816 for (j=0; j<conf->raid_disks; j++)
1816 int d = r10_bio->devs[j].devnum; 1817 if (conf->mirrors[j].rdev == NULL ||
1817 if (conf->mirrors[d].rdev == NULL || 1818 test_bit(Faulty, &conf->mirrors[j].rdev->flags)) {
1818 test_bit(Faulty, &conf->mirrors[d].rdev->flags)) {
1819 still_degraded = 1; 1819 still_degraded = 1;
1820 break; 1820 break;
1821 } 1821 }
1822 } 1822
1823 must_sync = bitmap_start_sync(mddev->bitmap, sect, 1823 must_sync = bitmap_start_sync(mddev->bitmap, sect,
1824 &sync_blocks, still_degraded); 1824 &sync_blocks, still_degraded);
1825 1825
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c
index 1dba8f0832a0..5cf6c45b91fe 100644
--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -153,7 +153,7 @@ static int vidioc_g_tuner(struct file *file, void *priv,
153 mult = (fmi->flags & V4L2_TUNER_CAP_LOW) ? 1 : 1000; 153 mult = (fmi->flags & V4L2_TUNER_CAP_LOW) ? 1 : 1000;
154 v->rangelow = RSF16_MINFREQ / mult; 154 v->rangelow = RSF16_MINFREQ / mult;
155 v->rangehigh = RSF16_MAXFREQ / mult; 155 v->rangehigh = RSF16_MAXFREQ / mult;
156 v->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_MODE_STEREO; 156 v->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
157 v->capability = fmi->flags & V4L2_TUNER_CAP_LOW; 157 v->capability = fmi->flags & V4L2_TUNER_CAP_LOW;
158 v->audmode = V4L2_TUNER_MODE_STEREO; 158 v->audmode = V4L2_TUNER_MODE_STEREO;
159 v->signal = fmi_getsigstr(fmi); 159 v->signal = fmi_getsigstr(fmi);
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c
index c09ca8600ea1..935ff9bcdfcc 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -233,7 +233,7 @@ static int vidioc_g_tuner(struct file *file, void *priv,
233 mult = (fmr2->flags & V4L2_TUNER_CAP_LOW) ? 1 : 1000; 233 mult = (fmr2->flags & V4L2_TUNER_CAP_LOW) ? 1 : 1000;
234 v->rangelow = RSF16_MINFREQ / mult; 234 v->rangelow = RSF16_MINFREQ / mult;
235 v->rangehigh = RSF16_MAXFREQ / mult; 235 v->rangehigh = RSF16_MAXFREQ / mult;
236 v->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_MODE_STEREO; 236 v->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
237 v->capability = fmr2->flags&V4L2_TUNER_CAP_LOW; 237 v->capability = fmr2->flags&V4L2_TUNER_CAP_LOW;
238 v->audmode = fmr2->stereo ? V4L2_TUNER_MODE_STEREO: 238 v->audmode = fmr2->stereo ? V4L2_TUNER_MODE_STEREO:
239 V4L2_TUNER_MODE_MONO; 239 V4L2_TUNER_MODE_MONO;
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
index 5f582726985d..c4d181dde1ca 100644
--- a/drivers/media/video/cafe_ccic.c
+++ b/drivers/media/video/cafe_ccic.c
@@ -774,6 +774,7 @@ static int cafe_cam_init(struct cafe_camera *cam)
774 ret = __cafe_cam_reset(cam); 774 ret = __cafe_cam_reset(cam);
775 if (ret) 775 if (ret)
776 goto out; 776 goto out;
777 chip.ident = V4L2_IDENT_NONE;
777 chip.match.type = V4L2_CHIP_MATCH_I2C_ADDR; 778 chip.match.type = V4L2_CHIP_MATCH_I2C_ADDR;
778 chip.match.addr = cam->sensor_addr; 779 chip.match.addr = cam->sensor_addr;
779 ret = sensor_call(cam, core, g_chip_ident, &chip); 780 ret = sensor_call(cam, core, g_chip_ident, &chip);
diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c
index 0c49a98213c4..1dc070da8652 100644
--- a/drivers/media/video/cx23885/cx23885-dvb.c
+++ b/drivers/media/video/cx23885/cx23885-dvb.c
@@ -472,7 +472,7 @@ static int dvb_register(struct cx23885_tsport *port)
472 static struct xc2028_ctrl ctl = { 472 static struct xc2028_ctrl ctl = {
473 .fname = XC2028_DEFAULT_FIRMWARE, 473 .fname = XC2028_DEFAULT_FIRMWARE,
474 .max_len = 64, 474 .max_len = 64,
475 .scode_table = XC3028_FE_OREN538, 475 .demod = XC3028_FE_OREN538,
476 }; 476 };
477 477
478 fe = dvb_attach(xc2028_attach, 478 fe = dvb_attach(xc2028_attach,
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c
index b0195e8ee4d1..db2ac9a99acd 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -305,14 +305,17 @@ int ivtv_waitq(wait_queue_head_t *waitq)
305/* Generic utility functions */ 305/* Generic utility functions */
306int ivtv_msleep_timeout(unsigned int msecs, int intr) 306int ivtv_msleep_timeout(unsigned int msecs, int intr)
307{ 307{
308 int ret;
309 int timeout = msecs_to_jiffies(msecs); 308 int timeout = msecs_to_jiffies(msecs);
310 309
311 do { 310 do {
312 set_current_state(intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE); 311 set_current_state(intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);
313 timeout = schedule_timeout(timeout); 312 timeout = schedule_timeout(timeout);
314 if (intr && (ret = signal_pending(current))) 313 if (intr) {
315 return ret; 314 int ret = signal_pending(current);
315
316 if (ret)
317 return ret;
318 }
316 } while (timeout); 319 } while (timeout);
317 return 0; 320 return 0;
318} 321}
diff --git a/drivers/media/video/ivtv/ivtv-gpio.c b/drivers/media/video/ivtv/ivtv-gpio.c
index ceb05bdcaf62..85ac707228e7 100644
--- a/drivers/media/video/ivtv/ivtv-gpio.c
+++ b/drivers/media/video/ivtv/ivtv-gpio.c
@@ -190,8 +190,8 @@ static int subdev_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
190 190
191 mask = itv->card->gpio_audio_detect.mask; 191 mask = itv->card->gpio_audio_detect.mask;
192 if (mask == 0 || (read_reg(IVTV_REG_GPIO_IN) & mask)) 192 if (mask == 0 || (read_reg(IVTV_REG_GPIO_IN) & mask))
193 vt->rxsubchans = V4L2_TUNER_MODE_STEREO | 193 vt->rxsubchans = V4L2_TUNER_SUB_STEREO |
194 V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; 194 V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
195 else 195 else
196 vt->rxsubchans = V4L2_TUNER_SUB_MONO; 196 vt->rxsubchans = V4L2_TUNER_SUB_MONO;
197 return 0; 197 return 0;
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index 4a2d464f055e..c342a9fe983e 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -180,7 +180,7 @@ int ivtv_set_speed(struct ivtv *itv, int speed)
180 180
181 /* Wait for any DMA to finish */ 181 /* Wait for any DMA to finish */
182 prepare_to_wait(&itv->dma_waitq, &wait, TASK_INTERRUPTIBLE); 182 prepare_to_wait(&itv->dma_waitq, &wait, TASK_INTERRUPTIBLE);
183 while (itv->i_flags & IVTV_F_I_DMA) { 183 while (test_bit(IVTV_F_I_DMA, &itv->i_flags)) {
184 got_sig = signal_pending(current); 184 got_sig = signal_pending(current);
185 if (got_sig) 185 if (got_sig)
186 break; 186 break;
@@ -1710,7 +1710,8 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
1710 we are waiting unlock first and later lock again. */ 1710 we are waiting unlock first and later lock again. */
1711 mutex_unlock(&itv->serialize_lock); 1711 mutex_unlock(&itv->serialize_lock);
1712 prepare_to_wait(&itv->event_waitq, &wait, TASK_INTERRUPTIBLE); 1712 prepare_to_wait(&itv->event_waitq, &wait, TASK_INTERRUPTIBLE);
1713 if ((itv->i_flags & (IVTV_F_I_EV_DEC_STOPPED|IVTV_F_I_EV_VSYNC)) == 0) 1713 if (!test_bit(IVTV_F_I_EV_DEC_STOPPED, &itv->i_flags) &&
1714 !test_bit(IVTV_F_I_EV_VSYNC, &itv->i_flags))
1714 schedule(); 1715 schedule();
1715 finish_wait(&itv->event_waitq, &wait); 1716 finish_wait(&itv->event_waitq, &wait);
1716 mutex_lock(&itv->serialize_lock); 1717 mutex_lock(&itv->serialize_lock);
diff --git a/drivers/media/video/ivtv/ivtv-irq.c b/drivers/media/video/ivtv/ivtv-irq.c
index 01c14d2b381a..cd9db0bf33bf 100644
--- a/drivers/media/video/ivtv/ivtv-irq.c
+++ b/drivers/media/video/ivtv/ivtv-irq.c
@@ -196,7 +196,7 @@ static int stream_enc_dma_append(struct ivtv_stream *s, u32 data[CX2341X_MBOX_MA
196 bytes_needed, s->name); 196 bytes_needed, s->name);
197 return -1; 197 return -1;
198 } 198 }
199 if (rc && !s->buffers_stolen && (s->s_flags & IVTV_F_S_APPL_IO)) { 199 if (rc && !s->buffers_stolen && test_bit(IVTV_F_S_APPL_IO, &s->s_flags)) {
200 IVTV_WARN("All %s stream buffers are full. Dropping data.\n", s->name); 200 IVTV_WARN("All %s stream buffers are full. Dropping data.\n", s->name);
201 IVTV_WARN("Cause: the application is not reading fast enough.\n"); 201 IVTV_WARN("Cause: the application is not reading fast enough.\n");
202 } 202 }
diff --git a/drivers/media/video/ivtv/ivtv-yuv.c b/drivers/media/video/ivtv/ivtv-yuv.c
index 7912ed6b72ee..c0875378acc2 100644
--- a/drivers/media/video/ivtv/ivtv-yuv.c
+++ b/drivers/media/video/ivtv/ivtv-yuv.c
@@ -1063,7 +1063,8 @@ static int ivtv_yuv_udma_frame(struct ivtv *itv, struct ivtv_dma_frame *args)
1063 prepare_to_wait(&itv->dma_waitq, &wait, TASK_INTERRUPTIBLE); 1063 prepare_to_wait(&itv->dma_waitq, &wait, TASK_INTERRUPTIBLE);
1064 /* if no UDMA is pending and no UDMA is in progress, then the DMA 1064 /* if no UDMA is pending and no UDMA is in progress, then the DMA
1065 is finished */ 1065 is finished */
1066 while (itv->i_flags & (IVTV_F_I_UDMA_PENDING | IVTV_F_I_UDMA)) { 1066 while (test_bit(IVTV_F_I_UDMA_PENDING, &itv->i_flags) ||
1067 test_bit(IVTV_F_I_UDMA, &itv->i_flags)) {
1067 /* don't interrupt if the DMA is in progress but break off 1068 /* don't interrupt if the DMA is in progress but break off
1068 a still pending DMA. */ 1069 a still pending DMA. */
1069 got_sig = signal_pending(current); 1070 got_sig = signal_pending(current);
diff --git a/drivers/media/video/ivtv/ivtvfb.c b/drivers/media/video/ivtv/ivtvfb.c
index 66e6eb513076..fa6bb85cb4b0 100644
--- a/drivers/media/video/ivtv/ivtvfb.c
+++ b/drivers/media/video/ivtv/ivtvfb.c
@@ -298,7 +298,8 @@ static int ivtvfb_prep_dec_dma_to_device(struct ivtv *itv,
298 prepare_to_wait(&itv->dma_waitq, &wait, TASK_INTERRUPTIBLE); 298 prepare_to_wait(&itv->dma_waitq, &wait, TASK_INTERRUPTIBLE);
299 /* if no UDMA is pending and no UDMA is in progress, then the DMA 299 /* if no UDMA is pending and no UDMA is in progress, then the DMA
300 is finished */ 300 is finished */
301 while (itv->i_flags & (IVTV_F_I_UDMA_PENDING | IVTV_F_I_UDMA)) { 301 while (test_bit(IVTV_F_I_UDMA_PENDING, &itv->i_flags) ||
302 test_bit(IVTV_F_I_UDMA, &itv->i_flags)) {
302 /* don't interrupt if the DMA is in progress but break off 303 /* don't interrupt if the DMA is in progress but break off
303 a still pending DMA. */ 304 a still pending DMA. */
304 got_sig = signal_pending(current); 305 got_sig = signal_pending(current);
diff --git a/drivers/media/video/uvc/uvc_driver.c b/drivers/media/video/uvc/uvc_driver.c
index 399412d7f020..507dc85646b2 100644
--- a/drivers/media/video/uvc/uvc_driver.c
+++ b/drivers/media/video/uvc/uvc_driver.c
@@ -1726,14 +1726,17 @@ static int uvc_suspend(struct usb_interface *intf, pm_message_t message)
1726static int __uvc_resume(struct usb_interface *intf, int reset) 1726static int __uvc_resume(struct usb_interface *intf, int reset)
1727{ 1727{
1728 struct uvc_device *dev = usb_get_intfdata(intf); 1728 struct uvc_device *dev = usb_get_intfdata(intf);
1729 int ret;
1730 1729
1731 uvc_trace(UVC_TRACE_SUSPEND, "Resuming interface %u\n", 1730 uvc_trace(UVC_TRACE_SUSPEND, "Resuming interface %u\n",
1732 intf->cur_altsetting->desc.bInterfaceNumber); 1731 intf->cur_altsetting->desc.bInterfaceNumber);
1733 1732
1734 if (intf->cur_altsetting->desc.bInterfaceSubClass == SC_VIDEOCONTROL) { 1733 if (intf->cur_altsetting->desc.bInterfaceSubClass == SC_VIDEOCONTROL) {
1735 if (reset && (ret = uvc_ctrl_resume_device(dev)) < 0) 1734 if (reset) {
1736 return ret; 1735 int ret = uvc_ctrl_resume_device(dev);
1736
1737 if (ret < 0)
1738 return ret;
1739 }
1737 1740
1738 return uvc_status_resume(dev); 1741 return uvc_status_resume(dev);
1739 } 1742 }
diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c
index a95e17329c5b..6ce974d7362f 100644
--- a/drivers/media/video/uvc/uvc_video.c
+++ b/drivers/media/video/uvc/uvc_video.c
@@ -742,7 +742,7 @@ static int uvc_alloc_urb_buffers(struct uvc_video_device *video,
742 742
743 /* Buffers are already allocated, bail out. */ 743 /* Buffers are already allocated, bail out. */
744 if (video->urb_size) 744 if (video->urb_size)
745 return 0; 745 return video->urb_size / psize;
746 746
747 /* Compute the number of packets. Bulk endpoints might transfer UVC 747 /* Compute the number of packets. Bulk endpoints might transfer UVC
748 * payloads accross multiple URBs. 748 * payloads accross multiple URBs.
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index 88f10d6cbc92..be64a502ea27 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -42,6 +42,12 @@
42 printk(KERN_DEBUG "%s: " fmt, vfd->name, ## arg);\ 42 printk(KERN_DEBUG "%s: " fmt, vfd->name, ## arg);\
43 } while (0) 43 } while (0)
44 44
45/* Zero out the end of the struct pointed to by p. Everthing after, but
46 * not including, the specified field is cleared. */
47#define CLEAR_AFTER_FIELD(p, field) \
48 memset((u8 *)(p) + offsetof(typeof(*(p)), field) + sizeof((p)->field), \
49 0, sizeof(*(p)) - offsetof(typeof(*(p)), field) - sizeof((p)->field))
50
45struct std_descr { 51struct std_descr {
46 v4l2_std_id std; 52 v4l2_std_id std;
47 const char *descr; 53 const char *descr;
@@ -544,39 +550,39 @@ static int check_fmt(const struct v4l2_ioctl_ops *ops, enum v4l2_buf_type type)
544 550
545 switch (type) { 551 switch (type) {
546 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 552 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
547 if (ops->vidioc_try_fmt_vid_cap) 553 if (ops->vidioc_g_fmt_vid_cap)
548 return 0; 554 return 0;
549 break; 555 break;
550 case V4L2_BUF_TYPE_VIDEO_OVERLAY: 556 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
551 if (ops->vidioc_try_fmt_vid_overlay) 557 if (ops->vidioc_g_fmt_vid_overlay)
552 return 0; 558 return 0;
553 break; 559 break;
554 case V4L2_BUF_TYPE_VIDEO_OUTPUT: 560 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
555 if (ops->vidioc_try_fmt_vid_out) 561 if (ops->vidioc_g_fmt_vid_out)
556 return 0; 562 return 0;
557 break; 563 break;
558 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: 564 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
559 if (ops->vidioc_try_fmt_vid_out_overlay) 565 if (ops->vidioc_g_fmt_vid_out_overlay)
560 return 0; 566 return 0;
561 break; 567 break;
562 case V4L2_BUF_TYPE_VBI_CAPTURE: 568 case V4L2_BUF_TYPE_VBI_CAPTURE:
563 if (ops->vidioc_try_fmt_vbi_cap) 569 if (ops->vidioc_g_fmt_vbi_cap)
564 return 0; 570 return 0;
565 break; 571 break;
566 case V4L2_BUF_TYPE_VBI_OUTPUT: 572 case V4L2_BUF_TYPE_VBI_OUTPUT:
567 if (ops->vidioc_try_fmt_vbi_out) 573 if (ops->vidioc_g_fmt_vbi_out)
568 return 0; 574 return 0;
569 break; 575 break;
570 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: 576 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
571 if (ops->vidioc_try_fmt_sliced_vbi_cap) 577 if (ops->vidioc_g_fmt_sliced_vbi_cap)
572 return 0; 578 return 0;
573 break; 579 break;
574 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: 580 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
575 if (ops->vidioc_try_fmt_sliced_vbi_out) 581 if (ops->vidioc_g_fmt_sliced_vbi_out)
576 return 0; 582 return 0;
577 break; 583 break;
578 case V4L2_BUF_TYPE_PRIVATE: 584 case V4L2_BUF_TYPE_PRIVATE:
579 if (ops->vidioc_try_fmt_type_private) 585 if (ops->vidioc_g_fmt_type_private)
580 return 0; 586 return 0;
581 break; 587 break;
582 } 588 }
@@ -782,44 +788,53 @@ static long __video_do_ioctl(struct file *file,
782 788
783 switch (f->type) { 789 switch (f->type) {
784 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 790 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
791 CLEAR_AFTER_FIELD(f, fmt.pix);
785 v4l_print_pix_fmt(vfd, &f->fmt.pix); 792 v4l_print_pix_fmt(vfd, &f->fmt.pix);
786 if (ops->vidioc_s_fmt_vid_cap) 793 if (ops->vidioc_s_fmt_vid_cap)
787 ret = ops->vidioc_s_fmt_vid_cap(file, fh, f); 794 ret = ops->vidioc_s_fmt_vid_cap(file, fh, f);
788 break; 795 break;
789 case V4L2_BUF_TYPE_VIDEO_OVERLAY: 796 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
797 CLEAR_AFTER_FIELD(f, fmt.win);
790 if (ops->vidioc_s_fmt_vid_overlay) 798 if (ops->vidioc_s_fmt_vid_overlay)
791 ret = ops->vidioc_s_fmt_vid_overlay(file, 799 ret = ops->vidioc_s_fmt_vid_overlay(file,
792 fh, f); 800 fh, f);
793 break; 801 break;
794 case V4L2_BUF_TYPE_VIDEO_OUTPUT: 802 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
803 CLEAR_AFTER_FIELD(f, fmt.pix);
795 v4l_print_pix_fmt(vfd, &f->fmt.pix); 804 v4l_print_pix_fmt(vfd, &f->fmt.pix);
796 if (ops->vidioc_s_fmt_vid_out) 805 if (ops->vidioc_s_fmt_vid_out)
797 ret = ops->vidioc_s_fmt_vid_out(file, fh, f); 806 ret = ops->vidioc_s_fmt_vid_out(file, fh, f);
798 break; 807 break;
799 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: 808 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
809 CLEAR_AFTER_FIELD(f, fmt.win);
800 if (ops->vidioc_s_fmt_vid_out_overlay) 810 if (ops->vidioc_s_fmt_vid_out_overlay)
801 ret = ops->vidioc_s_fmt_vid_out_overlay(file, 811 ret = ops->vidioc_s_fmt_vid_out_overlay(file,
802 fh, f); 812 fh, f);
803 break; 813 break;
804 case V4L2_BUF_TYPE_VBI_CAPTURE: 814 case V4L2_BUF_TYPE_VBI_CAPTURE:
815 CLEAR_AFTER_FIELD(f, fmt.vbi);
805 if (ops->vidioc_s_fmt_vbi_cap) 816 if (ops->vidioc_s_fmt_vbi_cap)
806 ret = ops->vidioc_s_fmt_vbi_cap(file, fh, f); 817 ret = ops->vidioc_s_fmt_vbi_cap(file, fh, f);
807 break; 818 break;
808 case V4L2_BUF_TYPE_VBI_OUTPUT: 819 case V4L2_BUF_TYPE_VBI_OUTPUT:
820 CLEAR_AFTER_FIELD(f, fmt.vbi);
809 if (ops->vidioc_s_fmt_vbi_out) 821 if (ops->vidioc_s_fmt_vbi_out)
810 ret = ops->vidioc_s_fmt_vbi_out(file, fh, f); 822 ret = ops->vidioc_s_fmt_vbi_out(file, fh, f);
811 break; 823 break;
812 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: 824 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
825 CLEAR_AFTER_FIELD(f, fmt.sliced);
813 if (ops->vidioc_s_fmt_sliced_vbi_cap) 826 if (ops->vidioc_s_fmt_sliced_vbi_cap)
814 ret = ops->vidioc_s_fmt_sliced_vbi_cap(file, 827 ret = ops->vidioc_s_fmt_sliced_vbi_cap(file,
815 fh, f); 828 fh, f);
816 break; 829 break;
817 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: 830 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
831 CLEAR_AFTER_FIELD(f, fmt.sliced);
818 if (ops->vidioc_s_fmt_sliced_vbi_out) 832 if (ops->vidioc_s_fmt_sliced_vbi_out)
819 ret = ops->vidioc_s_fmt_sliced_vbi_out(file, 833 ret = ops->vidioc_s_fmt_sliced_vbi_out(file,
820 fh, f); 834 fh, f);
821 break; 835 break;
822 case V4L2_BUF_TYPE_PRIVATE: 836 case V4L2_BUF_TYPE_PRIVATE:
837 /* CLEAR_AFTER_FIELD(f, fmt.raw_data); <- does nothing */
823 if (ops->vidioc_s_fmt_type_private) 838 if (ops->vidioc_s_fmt_type_private)
824 ret = ops->vidioc_s_fmt_type_private(file, 839 ret = ops->vidioc_s_fmt_type_private(file,
825 fh, f); 840 fh, f);
@@ -836,46 +851,55 @@ static long __video_do_ioctl(struct file *file,
836 v4l2_type_names)); 851 v4l2_type_names));
837 switch (f->type) { 852 switch (f->type) {
838 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 853 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
854 CLEAR_AFTER_FIELD(f, fmt.pix);
839 if (ops->vidioc_try_fmt_vid_cap) 855 if (ops->vidioc_try_fmt_vid_cap)
840 ret = ops->vidioc_try_fmt_vid_cap(file, fh, f); 856 ret = ops->vidioc_try_fmt_vid_cap(file, fh, f);
841 if (!ret) 857 if (!ret)
842 v4l_print_pix_fmt(vfd, &f->fmt.pix); 858 v4l_print_pix_fmt(vfd, &f->fmt.pix);
843 break; 859 break;
844 case V4L2_BUF_TYPE_VIDEO_OVERLAY: 860 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
861 CLEAR_AFTER_FIELD(f, fmt.win);
845 if (ops->vidioc_try_fmt_vid_overlay) 862 if (ops->vidioc_try_fmt_vid_overlay)
846 ret = ops->vidioc_try_fmt_vid_overlay(file, 863 ret = ops->vidioc_try_fmt_vid_overlay(file,
847 fh, f); 864 fh, f);
848 break; 865 break;
849 case V4L2_BUF_TYPE_VIDEO_OUTPUT: 866 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
867 CLEAR_AFTER_FIELD(f, fmt.pix);
850 if (ops->vidioc_try_fmt_vid_out) 868 if (ops->vidioc_try_fmt_vid_out)
851 ret = ops->vidioc_try_fmt_vid_out(file, fh, f); 869 ret = ops->vidioc_try_fmt_vid_out(file, fh, f);
852 if (!ret) 870 if (!ret)
853 v4l_print_pix_fmt(vfd, &f->fmt.pix); 871 v4l_print_pix_fmt(vfd, &f->fmt.pix);
854 break; 872 break;
855 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: 873 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
874 CLEAR_AFTER_FIELD(f, fmt.win);
856 if (ops->vidioc_try_fmt_vid_out_overlay) 875 if (ops->vidioc_try_fmt_vid_out_overlay)
857 ret = ops->vidioc_try_fmt_vid_out_overlay(file, 876 ret = ops->vidioc_try_fmt_vid_out_overlay(file,
858 fh, f); 877 fh, f);
859 break; 878 break;
860 case V4L2_BUF_TYPE_VBI_CAPTURE: 879 case V4L2_BUF_TYPE_VBI_CAPTURE:
880 CLEAR_AFTER_FIELD(f, fmt.vbi);
861 if (ops->vidioc_try_fmt_vbi_cap) 881 if (ops->vidioc_try_fmt_vbi_cap)
862 ret = ops->vidioc_try_fmt_vbi_cap(file, fh, f); 882 ret = ops->vidioc_try_fmt_vbi_cap(file, fh, f);
863 break; 883 break;
864 case V4L2_BUF_TYPE_VBI_OUTPUT: 884 case V4L2_BUF_TYPE_VBI_OUTPUT:
885 CLEAR_AFTER_FIELD(f, fmt.vbi);
865 if (ops->vidioc_try_fmt_vbi_out) 886 if (ops->vidioc_try_fmt_vbi_out)
866 ret = ops->vidioc_try_fmt_vbi_out(file, fh, f); 887 ret = ops->vidioc_try_fmt_vbi_out(file, fh, f);
867 break; 888 break;
868 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: 889 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
890 CLEAR_AFTER_FIELD(f, fmt.sliced);
869 if (ops->vidioc_try_fmt_sliced_vbi_cap) 891 if (ops->vidioc_try_fmt_sliced_vbi_cap)
870 ret = ops->vidioc_try_fmt_sliced_vbi_cap(file, 892 ret = ops->vidioc_try_fmt_sliced_vbi_cap(file,
871 fh, f); 893 fh, f);
872 break; 894 break;
873 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: 895 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
896 CLEAR_AFTER_FIELD(f, fmt.sliced);
874 if (ops->vidioc_try_fmt_sliced_vbi_out) 897 if (ops->vidioc_try_fmt_sliced_vbi_out)
875 ret = ops->vidioc_try_fmt_sliced_vbi_out(file, 898 ret = ops->vidioc_try_fmt_sliced_vbi_out(file,
876 fh, f); 899 fh, f);
877 break; 900 break;
878 case V4L2_BUF_TYPE_PRIVATE: 901 case V4L2_BUF_TYPE_PRIVATE:
902 /* CLEAR_AFTER_FIELD(f, fmt.raw_data); <- does nothing */
879 if (ops->vidioc_try_fmt_type_private) 903 if (ops->vidioc_try_fmt_type_private)
880 ret = ops->vidioc_try_fmt_type_private(file, 904 ret = ops->vidioc_try_fmt_type_private(file,
881 fh, f); 905 fh, f);
@@ -898,6 +922,9 @@ static long __video_do_ioctl(struct file *file,
898 if (ret) 922 if (ret)
899 break; 923 break;
900 924
925 if (p->type < V4L2_BUF_TYPE_PRIVATE)
926 CLEAR_AFTER_FIELD(p, memory);
927
901 ret = ops->vidioc_reqbufs(file, fh, p); 928 ret = ops->vidioc_reqbufs(file, fh, p);
902 dbgarg(cmd, "count=%d, type=%s, memory=%s\n", 929 dbgarg(cmd, "count=%d, type=%s, memory=%s\n",
903 p->count, 930 p->count,
diff --git a/drivers/media/video/zoran/zoran_driver.c b/drivers/media/video/zoran/zoran_driver.c
index 092333b1c34f..643cccaa1aab 100644
--- a/drivers/media/video/zoran/zoran_driver.c
+++ b/drivers/media/video/zoran/zoran_driver.c
@@ -1863,22 +1863,20 @@ static int zoran_querycap(struct file *file, void *__fh, struct v4l2_capability
1863 1863
1864static int zoran_enum_fmt(struct zoran *zr, struct v4l2_fmtdesc *fmt, int flag) 1864static int zoran_enum_fmt(struct zoran *zr, struct v4l2_fmtdesc *fmt, int flag)
1865{ 1865{
1866 int num = -1, i; 1866 unsigned int num, i;
1867 1867
1868 for (i = 0; i < NUM_FORMATS; i++) { 1868 for (num = i = 0; i < NUM_FORMATS; i++) {
1869 if (zoran_formats[i].flags & flag) 1869 if (zoran_formats[i].flags & flag && num++ == fmt->index) {
1870 num++; 1870 strncpy(fmt->description, zoran_formats[i].name,
1871 if (num == fmt->index) 1871 sizeof(fmt->description) - 1);
1872 break; 1872 /* fmt struct pre-zeroed, so adding '\0' not neeed */
1873 fmt->pixelformat = zoran_formats[i].fourcc;
1874 if (zoran_formats[i].flags & ZORAN_FORMAT_COMPRESSED)
1875 fmt->flags |= V4L2_FMT_FLAG_COMPRESSED;
1876 return 0;
1877 }
1873 } 1878 }
1874 if (fmt->index < 0 /* late, but not too late */ || i == NUM_FORMATS) 1879 return -EINVAL;
1875 return -EINVAL;
1876
1877 strncpy(fmt->description, zoran_formats[i].name, sizeof(fmt->description)-1);
1878 fmt->pixelformat = zoran_formats[i].fourcc;
1879 if (zoran_formats[i].flags & ZORAN_FORMAT_COMPRESSED)
1880 fmt->flags |= V4L2_FMT_FLAG_COMPRESSED;
1881 return 0;
1882} 1880}
1883 1881
1884static int zoran_enum_fmt_vid_cap(struct file *file, void *__fh, 1882static int zoran_enum_fmt_vid_cap(struct file *file, void *__fh,
diff --git a/drivers/misc/isl29003.c b/drivers/misc/isl29003.c
index 2e2a5923d4c2..a71e245801ee 100644
--- a/drivers/misc/isl29003.c
+++ b/drivers/misc/isl29003.c
@@ -64,6 +64,7 @@ struct isl29003_data {
64 struct i2c_client *client; 64 struct i2c_client *client;
65 struct mutex lock; 65 struct mutex lock;
66 u8 reg_cache[ISL29003_NUM_CACHABLE_REGS]; 66 u8 reg_cache[ISL29003_NUM_CACHABLE_REGS];
67 u8 power_state_before_suspend;
67}; 68};
68 69
69static int gain_range[] = { 70static int gain_range[] = {
@@ -411,6 +412,9 @@ static int __devexit isl29003_remove(struct i2c_client *client)
411#ifdef CONFIG_PM 412#ifdef CONFIG_PM
412static int isl29003_suspend(struct i2c_client *client, pm_message_t mesg) 413static int isl29003_suspend(struct i2c_client *client, pm_message_t mesg)
413{ 414{
415 struct isl29003_data *data = i2c_get_clientdata(client);
416
417 data->power_state_before_suspend = isl29003_get_power_state(client);
414 return isl29003_set_power_state(client, 0); 418 return isl29003_set_power_state(client, 0);
415} 419}
416 420
@@ -421,10 +425,11 @@ static int isl29003_resume(struct i2c_client *client)
421 425
422 /* restore registers from cache */ 426 /* restore registers from cache */
423 for (i = 0; i < ARRAY_SIZE(data->reg_cache); i++) 427 for (i = 0; i < ARRAY_SIZE(data->reg_cache); i++)
424 if (!i2c_smbus_write_byte_data(client, i, data->reg_cache[i])) 428 if (i2c_smbus_write_byte_data(client, i, data->reg_cache[i]))
425 return -EIO; 429 return -EIO;
426 430
427 return 0; 431 return isl29003_set_power_state(client,
432 data->power_state_before_suspend);
428} 433}
429 434
430#else 435#else
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index fe8041e619ea..b25e9b6516ae 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -254,6 +254,14 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
254 brq.data.blocks = req->nr_sectors; 254 brq.data.blocks = req->nr_sectors;
255 255
256 /* 256 /*
257 * The block layer doesn't support all sector count
258 * restrictions, so we need to be prepared for too big
259 * requests.
260 */
261 if (brq.data.blocks > card->host->max_blk_count)
262 brq.data.blocks = card->host->max_blk_count;
263
264 /*
257 * After a read error, we redo the request one sector at a time 265 * After a read error, we redo the request one sector at a time
258 * in order to accurately determine which sectors can be read 266 * in order to accurately determine which sectors can be read
259 * successfully. 267 * successfully.
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index fa073ab3fa34..264911732756 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -706,7 +706,7 @@ static void mmc_power_up(struct mmc_host *host)
706 * This delay should be sufficient to allow the power supply 706 * This delay should be sufficient to allow the power supply
707 * to reach the minimum voltage. 707 * to reach the minimum voltage.
708 */ 708 */
709 mmc_delay(2); 709 mmc_delay(10);
710 710
711 host->ios.clock = host->f_min; 711 host->ios.clock = host->f_min;
712 host->ios.power_mode = MMC_POWER_ON; 712 host->ios.power_mode = MMC_POWER_ON;
@@ -716,7 +716,7 @@ static void mmc_power_up(struct mmc_host *host)
716 * This delay must be at least 74 clock sizes, or 1 ms, or the 716 * This delay must be at least 74 clock sizes, or 1 ms, or the
717 * time required to reach a stable voltage. 717 * time required to reach a stable voltage.
718 */ 718 */
719 mmc_delay(2); 719 mmc_delay(10);
720} 720}
721 721
722static void mmc_power_off(struct mmc_host *host) 722static void mmc_power_off(struct mmc_host *host)
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index a663429b3d55..36875dcfa492 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -514,6 +514,7 @@ static int __devinit mmci_probe(struct amba_device *dev, void *id)
514 } 514 }
515 515
516 host = mmc_priv(mmc); 516 host = mmc_priv(mmc);
517 host->mmc = mmc;
517 /* Bits 12 thru 19 is the designer */ 518 /* Bits 12 thru 19 is the designer */
518 host->hw_designer = (dev->periphid >> 12) & 0xff; 519 host->hw_designer = (dev->periphid >> 12) & 0xff;
519 /* Bits 20 thru 23 is the revison */ 520 /* Bits 20 thru 23 is the revison */
@@ -545,7 +546,6 @@ static int __devinit mmci_probe(struct amba_device *dev, void *id)
545 host->mclk = clk_get_rate(host->clk); 546 host->mclk = clk_get_rate(host->clk);
546 DBG(host, "eventual mclk rate: %u Hz\n", host->mclk); 547 DBG(host, "eventual mclk rate: %u Hz\n", host->mclk);
547 } 548 }
548 host->mmc = mmc;
549 host->base = ioremap(dev->res.start, SZ_4K); 549 host->base = ioremap(dev->res.start, SZ_4K);
550 if (!host->base) { 550 if (!host->base) {
551 ret = -ENOMEM; 551 ret = -ENOMEM;
diff --git a/drivers/mmc/host/mvsdio.c b/drivers/mmc/host/mvsdio.c
index b5c375d94ab3..c643d0fe118f 100644
--- a/drivers/mmc/host/mvsdio.c
+++ b/drivers/mmc/host/mvsdio.c
@@ -825,24 +825,23 @@ static int __exit mvsd_remove(struct platform_device *pdev)
825} 825}
826 826
827#ifdef CONFIG_PM 827#ifdef CONFIG_PM
828static int mvsd_suspend(struct platform_device *dev, pm_message_t state, 828static int mvsd_suspend(struct platform_device *dev, pm_message_t state)
829 u32 level)
830{ 829{
831 struct mmc_host *mmc = platform_get_drvdata(dev); 830 struct mmc_host *mmc = platform_get_drvdata(dev);
832 int ret = 0; 831 int ret = 0;
833 832
834 if (mmc && level == SUSPEND_DISABLE) 833 if (mmc)
835 ret = mmc_suspend_host(mmc, state); 834 ret = mmc_suspend_host(mmc, state);
836 835
837 return ret; 836 return ret;
838} 837}
839 838
840static int mvsd_resume(struct platform_device *dev, u32 level) 839static int mvsd_resume(struct platform_device *dev)
841{ 840{
842 struct mmc_host *mmc = platform_dev_get_drvdata(dev); 841 struct mmc_host *mmc = platform_get_drvdata(dev);
843 int ret = 0; 842 int ret = 0;
844 843
845 if (mmc && level == RESUME_ENABLE) 844 if (mmc)
846 ret = mmc_resume_host(mmc); 845 ret = mmc_resume_host(mmc);
847 846
848 return ret; 847 return ret;
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index cd37962ec44f..65be27995d5c 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -522,8 +522,8 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot(
522 522
523 host = sdhci_alloc_host(&pdev->dev, sizeof(struct sdhci_pci_slot)); 523 host = sdhci_alloc_host(&pdev->dev, sizeof(struct sdhci_pci_slot));
524 if (IS_ERR(host)) { 524 if (IS_ERR(host)) {
525 ret = PTR_ERR(host); 525 dev_err(&pdev->dev, "cannot allocate host\n");
526 goto unmap; 526 return ERR_PTR(PTR_ERR(host));
527 } 527 }
528 528
529 slot = sdhci_priv(host); 529 slot = sdhci_priv(host);
@@ -541,7 +541,7 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot(
541 ret = pci_request_region(pdev, bar, mmc_hostname(host->mmc)); 541 ret = pci_request_region(pdev, bar, mmc_hostname(host->mmc));
542 if (ret) { 542 if (ret) {
543 dev_err(&pdev->dev, "cannot request region\n"); 543 dev_err(&pdev->dev, "cannot request region\n");
544 return ERR_PTR(ret); 544 goto free;
545 } 545 }
546 546
547 addr = pci_resource_start(pdev, bar); 547 addr = pci_resource_start(pdev, bar);
@@ -572,6 +572,8 @@ unmap:
572 572
573release: 573release:
574 pci_release_region(pdev, bar); 574 pci_release_region(pdev, bar);
575
576free:
575 sdhci_free_host(host); 577 sdhci_free_host(host);
576 578
577 return ERR_PTR(ret); 579 return ERR_PTR(ret);
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index f20a834f4309..65c6f996bbd3 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -125,7 +125,7 @@
125#define SDHCI_INT_DATA_MASK (SDHCI_INT_DATA_END | SDHCI_INT_DMA_END | \ 125#define SDHCI_INT_DATA_MASK (SDHCI_INT_DATA_END | SDHCI_INT_DMA_END | \
126 SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL | \ 126 SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL | \
127 SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_DATA_CRC | \ 127 SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_DATA_CRC | \
128 SDHCI_INT_DATA_END_BIT) 128 SDHCI_INT_DATA_END_BIT | SDHCI_ADMA_ERROR)
129#define SDHCI_INT_ALL_MASK ((unsigned int)-1) 129#define SDHCI_INT_ALL_MASK ((unsigned int)-1)
130 130
131#define SDHCI_ACMD12_ERR 0x3C 131#define SDHCI_ACMD12_ERR 0x3C
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 8185b1f3e5e6..cc6369ea67dd 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -54,7 +54,7 @@
54#define SR_SRWD 0x80 /* SR write protect */ 54#define SR_SRWD 0x80 /* SR write protect */
55 55
56/* Define max times to check status register before we give up. */ 56/* Define max times to check status register before we give up. */
57#define MAX_READY_WAIT_COUNT 100000 57#define MAX_READY_WAIT_JIFFIES (10 * HZ) /* eg. M25P128 specs 6s max sector erase */
58#define CMD_SIZE 4 58#define CMD_SIZE 4
59 59
60#ifdef CONFIG_M25PXX_USE_FAST_READ 60#ifdef CONFIG_M25PXX_USE_FAST_READ
@@ -139,20 +139,20 @@ static inline int write_enable(struct m25p *flash)
139 */ 139 */
140static int wait_till_ready(struct m25p *flash) 140static int wait_till_ready(struct m25p *flash)
141{ 141{
142 int count; 142 unsigned long deadline;
143 int sr; 143 int sr;
144 144
145 /* one chip guarantees max 5 msec wait here after page writes, 145 deadline = jiffies + MAX_READY_WAIT_JIFFIES;
146 * but potentially three seconds (!) after page erase. 146
147 */ 147 do {
148 for (count = 0; count < MAX_READY_WAIT_COUNT; count++) {
149 if ((sr = read_sr(flash)) < 0) 148 if ((sr = read_sr(flash)) < 0)
150 break; 149 break;
151 else if (!(sr & SR_WIP)) 150 else if (!(sr & SR_WIP))
152 return 0; 151 return 0;
153 152
154 /* REVISIT sometimes sleeping would be best */ 153 cond_resched();
155 } 154
155 } while (!time_after_eq(jiffies, deadline));
156 156
157 return 1; 157 return 1;
158} 158}
@@ -246,10 +246,12 @@ static int m25p80_erase(struct mtd_info *mtd, struct erase_info *instr)
246 mutex_lock(&flash->lock); 246 mutex_lock(&flash->lock);
247 247
248 /* whole-chip erase? */ 248 /* whole-chip erase? */
249 if (len == flash->mtd.size && erase_chip(flash)) { 249 if (len == flash->mtd.size) {
250 instr->state = MTD_ERASE_FAILED; 250 if (erase_chip(flash)) {
251 mutex_unlock(&flash->lock); 251 instr->state = MTD_ERASE_FAILED;
252 return -EIO; 252 mutex_unlock(&flash->lock);
253 return -EIO;
254 }
253 255
254 /* REVISIT in some cases we could speed up erasing large regions 256 /* REVISIT in some cases we could speed up erasing large regions
255 * by using OPCODE_SE instead of OPCODE_BE_4K. We may have set up 257 * by using OPCODE_SE instead of OPCODE_BE_4K. We may have set up
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index fdd6ae859397..bccb4b1ffc46 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -48,11 +48,11 @@ static LIST_HEAD(mtd_notifiers);
48 */ 48 */
49static void mtd_release(struct device *dev) 49static void mtd_release(struct device *dev)
50{ 50{
51 struct mtd_info *mtd = dev_to_mtd(dev); 51 dev_t index = MTD_DEVT(dev_to_mtd(dev)->index);
52 52
53 /* remove /dev/mtdXro node if needed */ 53 /* remove /dev/mtdXro node if needed */
54 if (MTD_DEVT(mtd->index)) 54 if (index)
55 device_destroy(mtd_class, MTD_DEVT(mtd->index) + 1); 55 device_destroy(mtd_class, index + 1);
56} 56}
57 57
58static ssize_t mtd_type_show(struct device *dev, 58static ssize_t mtd_type_show(struct device *dev,
@@ -132,6 +132,17 @@ static ssize_t mtd_writesize_show(struct device *dev,
132} 132}
133static DEVICE_ATTR(writesize, S_IRUGO, mtd_writesize_show, NULL); 133static DEVICE_ATTR(writesize, S_IRUGO, mtd_writesize_show, NULL);
134 134
135static ssize_t mtd_subpagesize_show(struct device *dev,
136 struct device_attribute *attr, char *buf)
137{
138 struct mtd_info *mtd = dev_to_mtd(dev);
139 unsigned int subpagesize = mtd->writesize >> mtd->subpage_sft;
140
141 return snprintf(buf, PAGE_SIZE, "%u\n", subpagesize);
142
143}
144static DEVICE_ATTR(subpagesize, S_IRUGO, mtd_subpagesize_show, NULL);
145
135static ssize_t mtd_oobsize_show(struct device *dev, 146static ssize_t mtd_oobsize_show(struct device *dev,
136 struct device_attribute *attr, char *buf) 147 struct device_attribute *attr, char *buf)
137{ 148{
@@ -169,6 +180,7 @@ static struct attribute *mtd_attrs[] = {
169 &dev_attr_size.attr, 180 &dev_attr_size.attr,
170 &dev_attr_erasesize.attr, 181 &dev_attr_erasesize.attr,
171 &dev_attr_writesize.attr, 182 &dev_attr_writesize.attr,
183 &dev_attr_subpagesize.attr,
172 &dev_attr_oobsize.attr, 184 &dev_attr_oobsize.attr,
173 &dev_attr_numeraseregions.attr, 185 &dev_attr_numeraseregions.attr,
174 &dev_attr_name.attr, 186 &dev_attr_name.attr,
diff --git a/drivers/mtd/mtdsuper.c b/drivers/mtd/mtdsuper.c
index 92285d0089c2..af8b42e0a55b 100644
--- a/drivers/mtd/mtdsuper.c
+++ b/drivers/mtd/mtdsuper.c
@@ -74,8 +74,7 @@ static int get_sb_mtd_aux(struct file_system_type *fs_type, int flags,
74 74
75 ret = fill_super(sb, data, flags & MS_SILENT ? 1 : 0); 75 ret = fill_super(sb, data, flags & MS_SILENT ? 1 : 0);
76 if (ret < 0) { 76 if (ret < 0) {
77 up_write(&sb->s_umount); 77 deactivate_locked_super(sb);
78 deactivate_super(sb);
79 return ret; 78 return ret;
80 } 79 }
81 80
diff --git a/drivers/net/arm/ixp4xx_eth.c b/drivers/net/arm/ixp4xx_eth.c
index 448487e22fa3..672c9626b9ca 100644
--- a/drivers/net/arm/ixp4xx_eth.c
+++ b/drivers/net/arm/ixp4xx_eth.c
@@ -338,12 +338,12 @@ static int ixp4xx_mdio_register(void)
338 if (cpu_is_ixp43x()) { 338 if (cpu_is_ixp43x()) {
339 /* IXP43x lacks NPE-B and uses NPE-C for MII PHY access */ 339 /* IXP43x lacks NPE-B and uses NPE-C for MII PHY access */
340 if (!(ixp4xx_read_feature_bits() & IXP4XX_FEATURE_NPEC_ETH)) 340 if (!(ixp4xx_read_feature_bits() & IXP4XX_FEATURE_NPEC_ETH))
341 return -ENOSYS; 341 return -ENODEV;
342 mdio_regs = (struct eth_regs __iomem *)IXP4XX_EthC_BASE_VIRT; 342 mdio_regs = (struct eth_regs __iomem *)IXP4XX_EthC_BASE_VIRT;
343 } else { 343 } else {
344 /* All MII PHY accesses use NPE-B Ethernet registers */ 344 /* All MII PHY accesses use NPE-B Ethernet registers */
345 if (!(ixp4xx_read_feature_bits() & IXP4XX_FEATURE_NPEB_ETH0)) 345 if (!(ixp4xx_read_feature_bits() & IXP4XX_FEATURE_NPEB_ETH0))
346 return -ENOSYS; 346 return -ENODEV;
347 mdio_regs = (struct eth_regs __iomem *)IXP4XX_EthB_BASE_VIRT; 347 mdio_regs = (struct eth_regs __iomem *)IXP4XX_EthB_BASE_VIRT;
348 } 348 }
349 349
@@ -456,7 +456,8 @@ static inline void queue_put_desc(unsigned int queue, u32 phys,
456 debug_desc(phys, desc); 456 debug_desc(phys, desc);
457 BUG_ON(phys & 0x1F); 457 BUG_ON(phys & 0x1F);
458 qmgr_put_entry(queue, phys); 458 qmgr_put_entry(queue, phys);
459 BUG_ON(qmgr_stat_overflow(queue)); 459 /* Don't check for queue overflow here, we've allocated sufficient
460 length and queues >= 32 don't support this check anyway. */
460} 461}
461 462
462 463
@@ -512,8 +513,8 @@ static int eth_poll(struct napi_struct *napi, int budget)
512#endif 513#endif
513 napi_complete(napi); 514 napi_complete(napi);
514 qmgr_enable_irq(rxq); 515 qmgr_enable_irq(rxq);
515 if (!qmgr_stat_empty(rxq) && 516 if (!qmgr_stat_nearly_empty(rxq) &&
516 napi_reschedule(napi)) { 517 napi_reschedule(napi)) { /* really empty in fact */
517#if DEBUG_RX 518#if DEBUG_RX
518 printk(KERN_DEBUG "%s: eth_poll" 519 printk(KERN_DEBUG "%s: eth_poll"
519 " napi_reschedule successed\n", 520 " napi_reschedule successed\n",
@@ -630,7 +631,8 @@ static void eth_txdone_irq(void *unused)
630 port->tx_buff_tab[n_desc] = NULL; 631 port->tx_buff_tab[n_desc] = NULL;
631 } 632 }
632 633
633 start = qmgr_stat_empty(port->plat->txreadyq); 634 /* really empty in fact */
635 start = qmgr_stat_nearly_empty(port->plat->txreadyq);
634 queue_put_desc(port->plat->txreadyq, phys, desc); 636 queue_put_desc(port->plat->txreadyq, phys, desc);
635 if (start) { 637 if (start) {
636#if DEBUG_TX 638#if DEBUG_TX
@@ -708,13 +710,14 @@ static int eth_xmit(struct sk_buff *skb, struct net_device *dev)
708 queue_put_desc(TX_QUEUE(port->id), tx_desc_phys(port, n), desc); 710 queue_put_desc(TX_QUEUE(port->id), tx_desc_phys(port, n), desc);
709 dev->trans_start = jiffies; 711 dev->trans_start = jiffies;
710 712
711 if (qmgr_stat_empty(txreadyq)) { 713 if (qmgr_stat_nearly_empty(txreadyq)) { /* really empty in fact */
712#if DEBUG_TX 714#if DEBUG_TX
713 printk(KERN_DEBUG "%s: eth_xmit queue full\n", dev->name); 715 printk(KERN_DEBUG "%s: eth_xmit queue full\n", dev->name);
714#endif 716#endif
715 netif_stop_queue(dev); 717 netif_stop_queue(dev);
716 /* we could miss TX ready interrupt */ 718 /* we could miss TX ready interrupt */
717 if (!qmgr_stat_empty(txreadyq)) { 719 /* really empty in fact */
720 if (!qmgr_stat_nearly_empty(txreadyq)) {
718#if DEBUG_TX 721#if DEBUG_TX
719 printk(KERN_DEBUG "%s: eth_xmit ready again\n", 722 printk(KERN_DEBUG "%s: eth_xmit ready again\n",
720 dev->name); 723 dev->name);
@@ -814,29 +817,29 @@ static int request_queues(struct port *port)
814 int err; 817 int err;
815 818
816 err = qmgr_request_queue(RXFREE_QUEUE(port->id), RX_DESCS, 0, 0, 819 err = qmgr_request_queue(RXFREE_QUEUE(port->id), RX_DESCS, 0, 0,
817 "%s:RX-free", port->netdev->name); 820 "%s:RX-free", port->netdev->name);
818 if (err) 821 if (err)
819 return err; 822 return err;
820 823
821 err = qmgr_request_queue(port->plat->rxq, RX_DESCS, 0, 0, 824 err = qmgr_request_queue(port->plat->rxq, RX_DESCS, 0, 0,
822 "%s:RX", port->netdev->name); 825 "%s:RX", port->netdev->name);
823 if (err) 826 if (err)
824 goto rel_rxfree; 827 goto rel_rxfree;
825 828
826 err = qmgr_request_queue(TX_QUEUE(port->id), TX_DESCS, 0, 0, 829 err = qmgr_request_queue(TX_QUEUE(port->id), TX_DESCS, 0, 0,
827 "%s:TX", port->netdev->name); 830 "%s:TX", port->netdev->name);
828 if (err) 831 if (err)
829 goto rel_rx; 832 goto rel_rx;
830 833
831 err = qmgr_request_queue(port->plat->txreadyq, TX_DESCS, 0, 0, 834 err = qmgr_request_queue(port->plat->txreadyq, TX_DESCS, 0, 0,
832 "%s:TX-ready", port->netdev->name); 835 "%s:TX-ready", port->netdev->name);
833 if (err) 836 if (err)
834 goto rel_tx; 837 goto rel_tx;
835 838
836 /* TX-done queue handles skbs sent out by the NPEs */ 839 /* TX-done queue handles skbs sent out by the NPEs */
837 if (!ports_open) { 840 if (!ports_open) {
838 err = qmgr_request_queue(TXDONE_QUEUE, TXDONE_QUEUE_LEN, 0, 0, 841 err = qmgr_request_queue(TXDONE_QUEUE, TXDONE_QUEUE_LEN, 0, 0,
839 "%s:TX-done", DRV_NAME); 842 "%s:TX-done", DRV_NAME);
840 if (err) 843 if (err)
841 goto rel_txready; 844 goto rel_txready;
842 } 845 }
@@ -1174,7 +1177,7 @@ static int __devinit eth_init_one(struct platform_device *pdev)
1174 regs_phys = IXP4XX_EthC_BASE_PHYS; 1177 regs_phys = IXP4XX_EthC_BASE_PHYS;
1175 break; 1178 break;
1176 default: 1179 default:
1177 err = -ENOSYS; 1180 err = -ENODEV;
1178 goto err_free; 1181 goto err_free;
1179 } 1182 }
1180 1183
@@ -1189,15 +1192,10 @@ static int __devinit eth_init_one(struct platform_device *pdev)
1189 goto err_free; 1192 goto err_free;
1190 } 1193 }
1191 1194
1192 if (register_netdev(dev)) {
1193 err = -EIO;
1194 goto err_npe_rel;
1195 }
1196
1197 port->mem_res = request_mem_region(regs_phys, REGS_SIZE, dev->name); 1195 port->mem_res = request_mem_region(regs_phys, REGS_SIZE, dev->name);
1198 if (!port->mem_res) { 1196 if (!port->mem_res) {
1199 err = -EBUSY; 1197 err = -EBUSY;
1200 goto err_unreg; 1198 goto err_npe_rel;
1201 } 1199 }
1202 1200
1203 port->plat = plat; 1201 port->plat = plat;
@@ -1215,20 +1213,25 @@ static int __devinit eth_init_one(struct platform_device *pdev)
1215 snprintf(phy_id, BUS_ID_SIZE, PHY_ID_FMT, "0", plat->phy); 1213 snprintf(phy_id, BUS_ID_SIZE, PHY_ID_FMT, "0", plat->phy);
1216 port->phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link, 0, 1214 port->phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link, 0,
1217 PHY_INTERFACE_MODE_MII); 1215 PHY_INTERFACE_MODE_MII);
1218 if (IS_ERR(port->phydev)) { 1216 if ((err = IS_ERR(port->phydev)))
1219 printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name); 1217 goto err_free_mem;
1220 return PTR_ERR(port->phydev);
1221 }
1222 1218
1223 port->phydev->irq = PHY_POLL; 1219 port->phydev->irq = PHY_POLL;
1224 1220
1221 if ((err = register_netdev(dev)))
1222 goto err_phy_dis;
1223
1225 printk(KERN_INFO "%s: MII PHY %i on %s\n", dev->name, plat->phy, 1224 printk(KERN_INFO "%s: MII PHY %i on %s\n", dev->name, plat->phy,
1226 npe_name(port->npe)); 1225 npe_name(port->npe));
1227 1226
1228 return 0; 1227 return 0;
1229 1228
1230err_unreg: 1229err_phy_dis:
1231 unregister_netdev(dev); 1230 phy_disconnect(port->phydev);
1231err_free_mem:
1232 npe_port_tab[NPE_ID(port->id)] = NULL;
1233 platform_set_drvdata(pdev, NULL);
1234 release_resource(port->mem_res);
1232err_npe_rel: 1235err_npe_rel:
1233 npe_release(port->npe); 1236 npe_release(port->npe);
1234err_free: 1237err_free:
@@ -1242,6 +1245,7 @@ static int __devexit eth_remove_one(struct platform_device *pdev)
1242 struct port *port = netdev_priv(dev); 1245 struct port *port = netdev_priv(dev);
1243 1246
1244 unregister_netdev(dev); 1247 unregister_netdev(dev);
1248 phy_disconnect(port->phydev);
1245 npe_port_tab[NPE_ID(port->id)] = NULL; 1249 npe_port_tab[NPE_ID(port->id)] = NULL;
1246 platform_set_drvdata(pdev, NULL); 1250 platform_set_drvdata(pdev, NULL);
1247 npe_release(port->npe); 1251 npe_release(port->npe);
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index d47839184a06..b0cb29d4cc01 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -54,8 +54,8 @@
54 54
55#define DRV_MODULE_NAME "bnx2" 55#define DRV_MODULE_NAME "bnx2"
56#define PFX DRV_MODULE_NAME ": " 56#define PFX DRV_MODULE_NAME ": "
57#define DRV_MODULE_VERSION "2.0.0" 57#define DRV_MODULE_VERSION "2.0.1"
58#define DRV_MODULE_RELDATE "April 2, 2009" 58#define DRV_MODULE_RELDATE "May 6, 2009"
59#define FW_MIPS_FILE_06 "bnx2/bnx2-mips-06-4.6.16.fw" 59#define FW_MIPS_FILE_06 "bnx2/bnx2-mips-06-4.6.16.fw"
60#define FW_RV2P_FILE_06 "bnx2/bnx2-rv2p-06-4.6.16.fw" 60#define FW_RV2P_FILE_06 "bnx2/bnx2-rv2p-06-4.6.16.fw"
61#define FW_MIPS_FILE_09 "bnx2/bnx2-mips-09-4.6.17.fw" 61#define FW_MIPS_FILE_09 "bnx2/bnx2-mips-09-4.6.17.fw"
@@ -2600,6 +2600,7 @@ bnx2_get_hw_tx_cons(struct bnx2_napi *bnapi)
2600 /* Tell compiler that status block fields can change. */ 2600 /* Tell compiler that status block fields can change. */
2601 barrier(); 2601 barrier();
2602 cons = *bnapi->hw_tx_cons_ptr; 2602 cons = *bnapi->hw_tx_cons_ptr;
2603 barrier();
2603 if (unlikely((cons & MAX_TX_DESC_CNT) == MAX_TX_DESC_CNT)) 2604 if (unlikely((cons & MAX_TX_DESC_CNT) == MAX_TX_DESC_CNT))
2604 cons++; 2605 cons++;
2605 return cons; 2606 return cons;
@@ -2879,6 +2880,7 @@ bnx2_get_hw_rx_cons(struct bnx2_napi *bnapi)
2879 /* Tell compiler that status block fields can change. */ 2880 /* Tell compiler that status block fields can change. */
2880 barrier(); 2881 barrier();
2881 cons = *bnapi->hw_rx_cons_ptr; 2882 cons = *bnapi->hw_rx_cons_ptr;
2883 barrier();
2882 if (unlikely((cons & MAX_RX_DESC_CNT) == MAX_RX_DESC_CNT)) 2884 if (unlikely((cons & MAX_RX_DESC_CNT) == MAX_RX_DESC_CNT))
2883 cons++; 2885 cons++;
2884 return cons; 2886 return cons;
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 553a89919778..46d312bedfb8 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -1706,10 +1706,8 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave
1706 * Called with RTNL 1706 * Called with RTNL
1707 */ 1707 */
1708int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr) 1708int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr)
1709 __releases(&bond->curr_slave_lock)
1710 __releases(&bond->lock)
1711 __acquires(&bond->lock) 1709 __acquires(&bond->lock)
1712 __acquires(&bond->curr_slave_lock) 1710 __releases(&bond->lock)
1713{ 1711{
1714 struct bonding *bond = netdev_priv(bond_dev); 1712 struct bonding *bond = netdev_priv(bond_dev);
1715 struct sockaddr *sa = addr; 1713 struct sockaddr *sa = addr;
@@ -1745,9 +1743,6 @@ int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr)
1745 } 1743 }
1746 } 1744 }
1747 1745
1748 write_unlock_bh(&bond->curr_slave_lock);
1749 read_unlock(&bond->lock);
1750
1751 if (swap_slave) { 1746 if (swap_slave) {
1752 alb_swap_mac_addr(bond, swap_slave, bond->curr_active_slave); 1747 alb_swap_mac_addr(bond, swap_slave, bond->curr_active_slave);
1753 alb_fasten_mac_swap(bond, swap_slave, bond->curr_active_slave); 1748 alb_fasten_mac_swap(bond, swap_slave, bond->curr_active_slave);
@@ -1755,16 +1750,15 @@ int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr)
1755 alb_set_slave_mac_addr(bond->curr_active_slave, bond_dev->dev_addr, 1750 alb_set_slave_mac_addr(bond->curr_active_slave, bond_dev->dev_addr,
1756 bond->alb_info.rlb_enabled); 1751 bond->alb_info.rlb_enabled);
1757 1752
1753 read_lock(&bond->lock);
1758 alb_send_learning_packets(bond->curr_active_slave, bond_dev->dev_addr); 1754 alb_send_learning_packets(bond->curr_active_slave, bond_dev->dev_addr);
1759 if (bond->alb_info.rlb_enabled) { 1755 if (bond->alb_info.rlb_enabled) {
1760 /* inform clients mac address has changed */ 1756 /* inform clients mac address has changed */
1761 rlb_req_update_slave_clients(bond, bond->curr_active_slave); 1757 rlb_req_update_slave_clients(bond, bond->curr_active_slave);
1762 } 1758 }
1759 read_unlock(&bond->lock);
1763 } 1760 }
1764 1761
1765 read_lock(&bond->lock);
1766 write_lock_bh(&bond->curr_slave_lock);
1767
1768 return 0; 1762 return 0;
1769} 1763}
1770 1764
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 63369b6b14d4..74824028f85c 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2213,33 +2213,24 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in
2213{ 2213{
2214 struct bonding *bond = netdev_priv(bond_dev); 2214 struct bonding *bond = netdev_priv(bond_dev);
2215 struct slave *slave; 2215 struct slave *slave;
2216 int i, found = 0; 2216 int i, res = -ENODEV;
2217
2218 if (info->slave_id < 0) {
2219 return -ENODEV;
2220 }
2221 2217
2222 read_lock(&bond->lock); 2218 read_lock(&bond->lock);
2223 2219
2224 bond_for_each_slave(bond, slave, i) { 2220 bond_for_each_slave(bond, slave, i) {
2225 if (i == (int)info->slave_id) { 2221 if (i == (int)info->slave_id) {
2226 found = 1; 2222 res = 0;
2223 strcpy(info->slave_name, slave->dev->name);
2224 info->link = slave->link;
2225 info->state = slave->state;
2226 info->link_failure_count = slave->link_failure_count;
2227 break; 2227 break;
2228 } 2228 }
2229 } 2229 }
2230 2230
2231 read_unlock(&bond->lock); 2231 read_unlock(&bond->lock);
2232 2232
2233 if (found) { 2233 return res;
2234 strcpy(info->slave_name, slave->dev->name);
2235 info->link = slave->link;
2236 info->state = slave->state;
2237 info->link_failure_count = slave->link_failure_count;
2238 } else {
2239 return -ENODEV;
2240 }
2241
2242 return 0;
2243} 2234}
2244 2235
2245/*-------------------------------- Monitoring -------------------------------*/ 2236/*-------------------------------- Monitoring -------------------------------*/
@@ -5167,16 +5158,15 @@ int bond_create(char *name, struct bond_params *params)
5167 up_write(&bonding_rwsem); 5158 up_write(&bonding_rwsem);
5168 rtnl_unlock(); /* allows sysfs registration of net device */ 5159 rtnl_unlock(); /* allows sysfs registration of net device */
5169 res = bond_create_sysfs_entry(netdev_priv(bond_dev)); 5160 res = bond_create_sysfs_entry(netdev_priv(bond_dev));
5170 if (res < 0) { 5161 if (res < 0)
5171 rtnl_lock(); 5162 goto out_unreg;
5172 down_write(&bonding_rwsem);
5173 bond_deinit(bond_dev);
5174 unregister_netdevice(bond_dev);
5175 goto out_rtnl;
5176 }
5177 5163
5178 return 0; 5164 return 0;
5179 5165
5166out_unreg:
5167 rtnl_lock();
5168 down_write(&bonding_rwsem);
5169 unregister_netdevice(bond_dev);
5180out_bond: 5170out_bond:
5181 bond_deinit(bond_dev); 5171 bond_deinit(bond_dev);
5182out_netdev: 5172out_netdev:
@@ -5191,7 +5181,6 @@ static int __init bonding_init(void)
5191{ 5181{
5192 int i; 5182 int i;
5193 int res; 5183 int res;
5194 struct bonding *bond;
5195 5184
5196 printk(KERN_INFO "%s", version); 5185 printk(KERN_INFO "%s", version);
5197 5186
@@ -5222,13 +5211,6 @@ static int __init bonding_init(void)
5222 5211
5223 goto out; 5212 goto out;
5224err: 5213err:
5225 list_for_each_entry(bond, &bond_dev_list, bond_list) {
5226 bond_work_cancel_all(bond);
5227 destroy_workqueue(bond->wq);
5228 }
5229
5230 bond_destroy_sysfs();
5231
5232 rtnl_lock(); 5214 rtnl_lock();
5233 bond_free_all(); 5215 bond_free_all();
5234 rtnl_unlock(); 5216 rtnl_unlock();
diff --git a/drivers/net/cxgb3/t3_hw.c b/drivers/net/cxgb3/t3_hw.c
index e1bd690ff831..4f68aeb2679a 100644
--- a/drivers/net/cxgb3/t3_hw.c
+++ b/drivers/net/cxgb3/t3_hw.c
@@ -3779,7 +3779,7 @@ int t3_prep_adapter(struct adapter *adapter, const struct adapter_info *ai,
3779 3779
3780 adapter->params.info = ai; 3780 adapter->params.info = ai;
3781 adapter->params.nports = ai->nports0 + ai->nports1; 3781 adapter->params.nports = ai->nports0 + ai->nports1;
3782 adapter->params.chan_map = !!ai->nports0 | (!!ai->nports1 << 1); 3782 adapter->params.chan_map = (!!ai->nports0) | (!!ai->nports1 << 1);
3783 adapter->params.rev = t3_read_reg(adapter, A_PL_REV); 3783 adapter->params.rev = t3_read_reg(adapter, A_PL_REV);
3784 /* 3784 /*
3785 * We used to only run the "adapter check task" once a second if 3785 * We used to only run the "adapter check task" once a second if
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 6a46ceed9436..b1419e21b46b 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -3738,7 +3738,7 @@ static irqreturn_t e1000_intr(int irq, void *data)
3738 struct e1000_hw *hw = &adapter->hw; 3738 struct e1000_hw *hw = &adapter->hw;
3739 u32 rctl, icr = er32(ICR); 3739 u32 rctl, icr = er32(ICR);
3740 3740
3741 if (unlikely((!icr) || test_bit(__E1000_RESETTING, &adapter->flags))) 3741 if (unlikely((!icr) || test_bit(__E1000_DOWN, &adapter->flags)))
3742 return IRQ_NONE; /* Not our interrupt */ 3742 return IRQ_NONE; /* Not our interrupt */
3743 3743
3744 /* IMS will not auto-mask if INT_ASSERTED is not set, and if it is 3744 /* IMS will not auto-mask if INT_ASSERTED is not set, and if it is
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index 6e317caf429c..16a41389575a 100644
--- a/drivers/net/ehea/ehea.h
+++ b/drivers/net/ehea/ehea.h
@@ -40,7 +40,7 @@
40#include <asm/io.h> 40#include <asm/io.h>
41 41
42#define DRV_NAME "ehea" 42#define DRV_NAME "ehea"
43#define DRV_VERSION "EHEA_0100" 43#define DRV_VERSION "EHEA_0101"
44 44
45/* eHEA capability flags */ 45/* eHEA capability flags */
46#define DLPAR_PORT_ADD_REM 1 46#define DLPAR_PORT_ADD_REM 1
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index 604c844d0769..b22dab9153f6 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -545,14 +545,17 @@ static inline struct sk_buff *get_skb_by_index(struct sk_buff **skb_array,
545 x &= (arr_len - 1); 545 x &= (arr_len - 1);
546 546
547 pref = skb_array[x]; 547 pref = skb_array[x];
548 prefetchw(pref); 548 if (pref) {
549 prefetchw(pref + EHEA_CACHE_LINE); 549 prefetchw(pref);
550 550 prefetchw(pref + EHEA_CACHE_LINE);
551 pref = (skb_array[x]->data); 551
552 prefetch(pref); 552 pref = (skb_array[x]->data);
553 prefetch(pref + EHEA_CACHE_LINE); 553 prefetch(pref);
554 prefetch(pref + EHEA_CACHE_LINE * 2); 554 prefetch(pref + EHEA_CACHE_LINE);
555 prefetch(pref + EHEA_CACHE_LINE * 3); 555 prefetch(pref + EHEA_CACHE_LINE * 2);
556 prefetch(pref + EHEA_CACHE_LINE * 3);
557 }
558
556 skb = skb_array[skb_index]; 559 skb = skb_array[skb_index];
557 skb_array[skb_index] = NULL; 560 skb_array[skb_index] = NULL;
558 return skb; 561 return skb;
@@ -569,12 +572,14 @@ static inline struct sk_buff *get_skb_by_index_ll(struct sk_buff **skb_array,
569 x &= (arr_len - 1); 572 x &= (arr_len - 1);
570 573
571 pref = skb_array[x]; 574 pref = skb_array[x];
572 prefetchw(pref); 575 if (pref) {
573 prefetchw(pref + EHEA_CACHE_LINE); 576 prefetchw(pref);
577 prefetchw(pref + EHEA_CACHE_LINE);
574 578
575 pref = (skb_array[x]->data); 579 pref = (skb_array[x]->data);
576 prefetchw(pref); 580 prefetchw(pref);
577 prefetchw(pref + EHEA_CACHE_LINE); 581 prefetchw(pref + EHEA_CACHE_LINE);
582 }
578 583
579 skb = skb_array[wqe_index]; 584 skb = skb_array[wqe_index];
580 skb_array[wqe_index] = NULL; 585 skb_array[wqe_index] = NULL;
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 08c801490c72..e25343588fc7 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -2006,7 +2006,7 @@ static void igb_setup_rctl(struct igb_adapter *adapter)
2006 struct e1000_hw *hw = &adapter->hw; 2006 struct e1000_hw *hw = &adapter->hw;
2007 u32 rctl; 2007 u32 rctl;
2008 u32 srrctl = 0; 2008 u32 srrctl = 0;
2009 int i, j; 2009 int i;
2010 2010
2011 rctl = rd32(E1000_RCTL); 2011 rctl = rd32(E1000_RCTL);
2012 2012
@@ -2071,8 +2071,6 @@ static void igb_setup_rctl(struct igb_adapter *adapter)
2071 if (adapter->vfs_allocated_count) { 2071 if (adapter->vfs_allocated_count) {
2072 u32 vmolr; 2072 u32 vmolr;
2073 2073
2074 j = adapter->rx_ring[0].reg_idx;
2075
2076 /* set all queue drop enable bits */ 2074 /* set all queue drop enable bits */
2077 wr32(E1000_QDE, ALL_QUEUES); 2075 wr32(E1000_QDE, ALL_QUEUES);
2078 srrctl |= E1000_SRRCTL_DROP_EN; 2076 srrctl |= E1000_SRRCTL_DROP_EN;
@@ -2080,16 +2078,16 @@ static void igb_setup_rctl(struct igb_adapter *adapter)
2080 /* disable queue 0 to prevent tail write w/o re-config */ 2078 /* disable queue 0 to prevent tail write w/o re-config */
2081 wr32(E1000_RXDCTL(0), 0); 2079 wr32(E1000_RXDCTL(0), 0);
2082 2080
2083 vmolr = rd32(E1000_VMOLR(j)); 2081 vmolr = rd32(E1000_VMOLR(adapter->vfs_allocated_count));
2084 if (rctl & E1000_RCTL_LPE) 2082 if (rctl & E1000_RCTL_LPE)
2085 vmolr |= E1000_VMOLR_LPE; 2083 vmolr |= E1000_VMOLR_LPE;
2086 if (adapter->num_rx_queues > 0) 2084 if (adapter->num_rx_queues > 1)
2087 vmolr |= E1000_VMOLR_RSSE; 2085 vmolr |= E1000_VMOLR_RSSE;
2088 wr32(E1000_VMOLR(j), vmolr); 2086 wr32(E1000_VMOLR(adapter->vfs_allocated_count), vmolr);
2089 } 2087 }
2090 2088
2091 for (i = 0; i < adapter->num_rx_queues; i++) { 2089 for (i = 0; i < adapter->num_rx_queues; i++) {
2092 j = adapter->rx_ring[i].reg_idx; 2090 int j = adapter->rx_ring[i].reg_idx;
2093 wr32(E1000_SRRCTL(j), srrctl); 2091 wr32(E1000_SRRCTL(j), srrctl);
2094 } 2092 }
2095 2093
diff --git a/drivers/net/mlx4/en_rx.c b/drivers/net/mlx4/en_rx.c
index 7942c4d3cd88..9ee873e872b3 100644
--- a/drivers/net/mlx4/en_rx.c
+++ b/drivers/net/mlx4/en_rx.c
@@ -951,7 +951,6 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv,
951 if (err) { 951 if (err) {
952 mlx4_err(mdev, "Failed to allocate qp #%d\n", qpn); 952 mlx4_err(mdev, "Failed to allocate qp #%d\n", qpn);
953 goto out; 953 goto out;
954 return err;
955 } 954 }
956 qp->event = mlx4_en_sqp_event; 955 qp->event = mlx4_en_sqp_event;
957 956
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index b3185bf2c158..a400d7115f78 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -393,12 +393,12 @@ struct mv643xx_eth_private {
393 struct work_struct tx_timeout_task; 393 struct work_struct tx_timeout_task;
394 394
395 struct napi_struct napi; 395 struct napi_struct napi;
396 u8 oom;
396 u8 work_link; 397 u8 work_link;
397 u8 work_tx; 398 u8 work_tx;
398 u8 work_tx_end; 399 u8 work_tx_end;
399 u8 work_rx; 400 u8 work_rx;
400 u8 work_rx_refill; 401 u8 work_rx_refill;
401 u8 work_rx_oom;
402 402
403 int skb_size; 403 int skb_size;
404 struct sk_buff_head rx_recycle; 404 struct sk_buff_head rx_recycle;
@@ -661,7 +661,7 @@ static int rxq_refill(struct rx_queue *rxq, int budget)
661 dma_get_cache_alignment() - 1); 661 dma_get_cache_alignment() - 1);
662 662
663 if (skb == NULL) { 663 if (skb == NULL) {
664 mp->work_rx_oom |= 1 << rxq->index; 664 mp->oom = 1;
665 goto oom; 665 goto oom;
666 } 666 }
667 667
@@ -1255,7 +1255,6 @@ static void mib_counters_update(struct mv643xx_eth_private *mp)
1255 1255
1256 spin_lock_bh(&mp->mib_counters_lock); 1256 spin_lock_bh(&mp->mib_counters_lock);
1257 p->good_octets_received += mib_read(mp, 0x00); 1257 p->good_octets_received += mib_read(mp, 0x00);
1258 p->good_octets_received += (u64)mib_read(mp, 0x04) << 32;
1259 p->bad_octets_received += mib_read(mp, 0x08); 1258 p->bad_octets_received += mib_read(mp, 0x08);
1260 p->internal_mac_transmit_err += mib_read(mp, 0x0c); 1259 p->internal_mac_transmit_err += mib_read(mp, 0x0c);
1261 p->good_frames_received += mib_read(mp, 0x10); 1260 p->good_frames_received += mib_read(mp, 0x10);
@@ -1269,7 +1268,6 @@ static void mib_counters_update(struct mv643xx_eth_private *mp)
1269 p->frames_512_to_1023_octets += mib_read(mp, 0x30); 1268 p->frames_512_to_1023_octets += mib_read(mp, 0x30);
1270 p->frames_1024_to_max_octets += mib_read(mp, 0x34); 1269 p->frames_1024_to_max_octets += mib_read(mp, 0x34);
1271 p->good_octets_sent += mib_read(mp, 0x38); 1270 p->good_octets_sent += mib_read(mp, 0x38);
1272 p->good_octets_sent += (u64)mib_read(mp, 0x3c) << 32;
1273 p->good_frames_sent += mib_read(mp, 0x40); 1271 p->good_frames_sent += mib_read(mp, 0x40);
1274 p->excessive_collision += mib_read(mp, 0x44); 1272 p->excessive_collision += mib_read(mp, 0x44);
1275 p->multicast_frames_sent += mib_read(mp, 0x48); 1273 p->multicast_frames_sent += mib_read(mp, 0x48);
@@ -2167,8 +2165,10 @@ static int mv643xx_eth_poll(struct napi_struct *napi, int budget)
2167 2165
2168 mp = container_of(napi, struct mv643xx_eth_private, napi); 2166 mp = container_of(napi, struct mv643xx_eth_private, napi);
2169 2167
2170 mp->work_rx_refill |= mp->work_rx_oom; 2168 if (unlikely(mp->oom)) {
2171 mp->work_rx_oom = 0; 2169 mp->oom = 0;
2170 del_timer(&mp->rx_oom);
2171 }
2172 2172
2173 work_done = 0; 2173 work_done = 0;
2174 while (work_done < budget) { 2174 while (work_done < budget) {
@@ -2182,8 +2182,10 @@ static int mv643xx_eth_poll(struct napi_struct *napi, int budget)
2182 continue; 2182 continue;
2183 } 2183 }
2184 2184
2185 queue_mask = mp->work_tx | mp->work_tx_end | 2185 queue_mask = mp->work_tx | mp->work_tx_end | mp->work_rx;
2186 mp->work_rx | mp->work_rx_refill; 2186 if (likely(!mp->oom))
2187 queue_mask |= mp->work_rx_refill;
2188
2187 if (!queue_mask) { 2189 if (!queue_mask) {
2188 if (mv643xx_eth_collect_events(mp)) 2190 if (mv643xx_eth_collect_events(mp))
2189 continue; 2191 continue;
@@ -2204,7 +2206,7 @@ static int mv643xx_eth_poll(struct napi_struct *napi, int budget)
2204 txq_maybe_wake(mp->txq + queue); 2206 txq_maybe_wake(mp->txq + queue);
2205 } else if (mp->work_rx & queue_mask) { 2207 } else if (mp->work_rx & queue_mask) {
2206 work_done += rxq_process(mp->rxq + queue, work_tbd); 2208 work_done += rxq_process(mp->rxq + queue, work_tbd);
2207 } else if (mp->work_rx_refill & queue_mask) { 2209 } else if (!mp->oom && (mp->work_rx_refill & queue_mask)) {
2208 work_done += rxq_refill(mp->rxq + queue, work_tbd); 2210 work_done += rxq_refill(mp->rxq + queue, work_tbd);
2209 } else { 2211 } else {
2210 BUG(); 2212 BUG();
@@ -2212,7 +2214,7 @@ static int mv643xx_eth_poll(struct napi_struct *napi, int budget)
2212 } 2214 }
2213 2215
2214 if (work_done < budget) { 2216 if (work_done < budget) {
2215 if (mp->work_rx_oom) 2217 if (mp->oom)
2216 mod_timer(&mp->rx_oom, jiffies + (HZ / 10)); 2218 mod_timer(&mp->rx_oom, jiffies + (HZ / 10));
2217 napi_complete(napi); 2219 napi_complete(napi);
2218 wrlp(mp, INT_MASK, INT_TX_END | INT_RX | INT_EXT); 2220 wrlp(mp, INT_MASK, INT_TX_END | INT_RX | INT_EXT);
@@ -2372,7 +2374,7 @@ static int mv643xx_eth_open(struct net_device *dev)
2372 rxq_refill(mp->rxq + i, INT_MAX); 2374 rxq_refill(mp->rxq + i, INT_MAX);
2373 } 2375 }
2374 2376
2375 if (mp->work_rx_oom) { 2377 if (mp->oom) {
2376 mp->rx_oom.expires = jiffies + (HZ / 10); 2378 mp->rx_oom.expires = jiffies + (HZ / 10);
2377 add_timer(&mp->rx_oom); 2379 add_timer(&mp->rx_oom);
2378 } 2380 }
diff --git a/drivers/net/ne2k-pci.c b/drivers/net/ne2k-pci.c
index eb66f658f9d1..7d83896b8c26 100644
--- a/drivers/net/ne2k-pci.c
+++ b/drivers/net/ne2k-pci.c
@@ -374,18 +374,17 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
374 dev->ethtool_ops = &ne2k_pci_ethtool_ops; 374 dev->ethtool_ops = &ne2k_pci_ethtool_ops;
375 NS8390_init(dev, 0); 375 NS8390_init(dev, 0);
376 376
377 memcpy(dev->dev_addr, SA_prom, 6);
378 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
379
377 i = register_netdev(dev); 380 i = register_netdev(dev);
378 if (i) 381 if (i)
379 goto err_out_free_netdev; 382 goto err_out_free_netdev;
380 383
381 for(i = 0; i < 6; i++)
382 dev->dev_addr[i] = SA_prom[i];
383 printk("%s: %s found at %#lx, IRQ %d, %pM.\n", 384 printk("%s: %s found at %#lx, IRQ %d, %pM.\n",
384 dev->name, pci_clone_list[chip_idx].name, ioaddr, dev->irq, 385 dev->name, pci_clone_list[chip_idx].name, ioaddr, dev->irq,
385 dev->dev_addr); 386 dev->dev_addr);
386 387
387 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
388
389 return 0; 388 return 0;
390 389
391err_out_free_netdev: 390err_out_free_netdev:
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index eceadf787a67..bf4af5248cb7 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -664,7 +664,7 @@ static int netconsole_netdev_event(struct notifier_block *this,
664 struct netconsole_target *nt; 664 struct netconsole_target *nt;
665 struct net_device *dev = ptr; 665 struct net_device *dev = ptr;
666 666
667 if (!(event == NETDEV_CHANGENAME)) 667 if (!(event == NETDEV_CHANGENAME || event == NETDEV_UNREGISTER))
668 goto done; 668 goto done;
669 669
670 spin_lock_irqsave(&target_list_lock, flags); 670 spin_lock_irqsave(&target_list_lock, flags);
@@ -675,6 +675,15 @@ static int netconsole_netdev_event(struct notifier_block *this,
675 case NETDEV_CHANGENAME: 675 case NETDEV_CHANGENAME:
676 strlcpy(nt->np.dev_name, dev->name, IFNAMSIZ); 676 strlcpy(nt->np.dev_name, dev->name, IFNAMSIZ);
677 break; 677 break;
678 case NETDEV_UNREGISTER:
679 if (!nt->enabled)
680 break;
681 netpoll_cleanup(&nt->np);
682 nt->enabled = 0;
683 printk(KERN_INFO "netconsole: network logging stopped"
684 ", interface %s unregistered\n",
685 dev->name);
686 break;
678 } 687 }
679 } 688 }
680 netconsole_target_put(nt); 689 netconsole_target_put(nt);
diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index 8ee21030e9ac..dfc6cf765fbd 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -180,6 +180,20 @@ config USB_NET_CDCETHER
180 IEEE 802 "local assignment" bit is set in the address, a "usbX" 180 IEEE 802 "local assignment" bit is set in the address, a "usbX"
181 name is used instead. 181 name is used instead.
182 182
183config USB_NET_CDC_EEM
184 tristate "CDC EEM support"
185 depends on USB_USBNET && EXPERIMENTAL
186 help
187 This option supports devices conforming to the Communication Device
188 Class (CDC) Ethernet Emulation Model, a specification that's easy to
189 implement in device firmware. The CDC EEM specifications are available
190 from <http://www.usb.org/>.
191
192 This driver creates an interface named "ethX", where X depends on
193 what other networking devices you have in use. However, if the
194 IEEE 802 "local assignment" bit is set in the address, a "usbX"
195 name is used instead.
196
183config USB_NET_DM9601 197config USB_NET_DM9601
184 tristate "Davicom DM9601 based USB 1.1 10/100 ethernet devices" 198 tristate "Davicom DM9601 based USB 1.1 10/100 ethernet devices"
185 depends on USB_USBNET 199 depends on USB_USBNET
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
index 88a87eeb376a..c8aef62cf2b7 100644
--- a/drivers/net/usb/Makefile
+++ b/drivers/net/usb/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_USB_RTL8150) += rtl8150.o
9obj-$(CONFIG_USB_HSO) += hso.o 9obj-$(CONFIG_USB_HSO) += hso.o
10obj-$(CONFIG_USB_NET_AX8817X) += asix.o 10obj-$(CONFIG_USB_NET_AX8817X) += asix.o
11obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o 11obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o
12obj-$(CONFIG_USB_NET_CDC_EEM) += cdc_eem.o
12obj-$(CONFIG_USB_NET_DM9601) += dm9601.o 13obj-$(CONFIG_USB_NET_DM9601) += dm9601.o
13obj-$(CONFIG_USB_NET_SMSC95XX) += smsc95xx.o 14obj-$(CONFIG_USB_NET_SMSC95XX) += smsc95xx.o
14obj-$(CONFIG_USB_NET_GL620A) += gl620a.o 15obj-$(CONFIG_USB_NET_GL620A) += gl620a.o
diff --git a/drivers/net/usb/cdc_eem.c b/drivers/net/usb/cdc_eem.c
new file mode 100644
index 000000000000..80e01778dd3b
--- /dev/null
+++ b/drivers/net/usb/cdc_eem.c
@@ -0,0 +1,381 @@
1/*
2 * USB CDC EEM network interface driver
3 * Copyright (C) 2009 Oberthur Technologies
4 * by Omar Laazimani, Olivier Condemine
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/module.h>
22#include <linux/init.h>
23#include <linux/netdevice.h>
24#include <linux/etherdevice.h>
25#include <linux/ctype.h>
26#include <linux/ethtool.h>
27#include <linux/workqueue.h>
28#include <linux/mii.h>
29#include <linux/usb.h>
30#include <linux/crc32.h>
31#include <linux/usb/cdc.h>
32#include <linux/usb/usbnet.h>
33
34
35/*
36 * This driver is an implementation of the CDC "Ethernet Emulation
37 * Model" (EEM) specification, which encapsulates Ethernet frames
38 * for transport over USB using a simpler USB device model than the
39 * previous CDC "Ethernet Control Model" (ECM, or "CDC Ethernet").
40 *
41 * For details, see www.usb.org/developers/devclass_docs/CDC_EEM10.pdf
42 *
43 * This version has been tested with GIGAntIC WuaoW SIM Smart Card on 2.6.24,
44 * 2.6.27 and 2.6.30rc2 kernel.
45 * It has also been validated on Openmoko Om 2008.12 (based on 2.6.24 kernel).
46 * build on 23-April-2009
47 */
48
49#define EEM_HEAD 2 /* 2 byte header */
50
51/*-------------------------------------------------------------------------*/
52
53static void eem_linkcmd_complete(struct urb *urb)
54{
55 dev_kfree_skb(urb->context);
56 usb_free_urb(urb);
57}
58
59static void eem_linkcmd(struct usbnet *dev, struct sk_buff *skb)
60{
61 struct urb *urb;
62 int status;
63
64 urb = usb_alloc_urb(0, GFP_ATOMIC);
65 if (!urb)
66 goto fail;
67
68 usb_fill_bulk_urb(urb, dev->udev, dev->out,
69 skb->data, skb->len, eem_linkcmd_complete, skb);
70
71 status = usb_submit_urb(urb, GFP_ATOMIC);
72 if (status) {
73 usb_free_urb(urb);
74fail:
75 dev_kfree_skb(skb);
76 devwarn(dev, "link cmd failure\n");
77 return;
78 }
79}
80
81static int eem_bind(struct usbnet *dev, struct usb_interface *intf)
82{
83 int status = 0;
84
85 status = usbnet_get_endpoints(dev, intf);
86 if (status < 0) {
87 usb_set_intfdata(intf, NULL);
88 usb_driver_release_interface(driver_of(intf), intf);
89 return status;
90 }
91
92 /* no jumbogram (16K) support for now */
93
94 dev->net->hard_header_len += EEM_HEAD + ETH_FCS_LEN;
95
96 return 0;
97}
98
99/*
100 * EEM permits packing multiple Ethernet frames into USB transfers
101 * (a "bundle"), but for TX we don't try to do that.
102 */
103static struct sk_buff *eem_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
104 gfp_t flags)
105{
106 struct sk_buff *skb2 = NULL;
107 u16 len = skb->len;
108 u32 crc = 0;
109 int padlen = 0;
110
111 /* When ((len + EEM_HEAD + ETH_FCS_LEN) % dev->maxpacket) is
112 * zero, stick two bytes of zero length EEM packet on the end.
113 * Else the framework would add invalid single byte padding,
114 * since it can't know whether ZLPs will be handled right by
115 * all the relevant hardware and software.
116 */
117 if (!((len + EEM_HEAD + ETH_FCS_LEN) % dev->maxpacket))
118 padlen += 2;
119
120 if (!skb_cloned(skb)) {
121 int headroom = skb_headroom(skb);
122 int tailroom = skb_tailroom(skb);
123
124 if ((tailroom >= ETH_FCS_LEN + padlen)
125 && (headroom >= EEM_HEAD))
126 goto done;
127
128 if ((headroom + tailroom)
129 > (EEM_HEAD + ETH_FCS_LEN + padlen)) {
130 skb->data = memmove(skb->head +
131 EEM_HEAD,
132 skb->data,
133 skb->len);
134 skb_set_tail_pointer(skb, len);
135 goto done;
136 }
137 }
138
139 skb2 = skb_copy_expand(skb, EEM_HEAD, ETH_FCS_LEN + padlen, flags);
140 if (!skb2)
141 return NULL;
142
143 dev_kfree_skb_any(skb);
144 skb = skb2;
145
146done:
147 /* we don't use the "no Ethernet CRC" option */
148 crc = crc32_le(~0, skb->data, skb->len);
149 crc = ~crc;
150
151 put_unaligned_le32(crc, skb_put(skb, 4));
152
153 /* EEM packet header format:
154 * b0..13: length of ethernet frame
155 * b14: bmCRC (1 == valid Ethernet CRC)
156 * b15: bmType (0 == data)
157 */
158 len = skb->len;
159 put_unaligned_le16(BIT(14) | len, skb_push(skb, 2));
160
161 /* Bundle a zero length EEM packet if needed */
162 if (padlen)
163 put_unaligned_le16(0, skb_put(skb, 2));
164
165 return skb;
166}
167
168static int eem_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
169{
170 /*
171 * Our task here is to strip off framing, leaving skb with one
172 * data frame for the usbnet framework code to process. But we
173 * may have received multiple EEM payloads, or command payloads.
174 * So we must process _everything_ as if it's a header, except
175 * maybe the last data payload
176 *
177 * REVISIT the framework needs updating so that when we consume
178 * all payloads (the last or only message was a command, or a
179 * zero length EEM packet) that is not accounted as an rx_error.
180 */
181 do {
182 struct sk_buff *skb2 = NULL;
183 u16 header;
184 u16 len = 0;
185
186 /* incomplete EEM header? */
187 if (skb->len < EEM_HEAD)
188 return 0;
189
190 /*
191 * EEM packet header format:
192 * b0..14: EEM type dependant (Data or Command)
193 * b15: bmType
194 */
195 header = get_unaligned_le16(skb->data);
196 skb_pull(skb, EEM_HEAD);
197
198 /*
199 * The bmType bit helps to denote when EEM
200 * packet is data or command :
201 * bmType = 0 : EEM data payload
202 * bmType = 1 : EEM (link) command
203 */
204 if (header & BIT(15)) {
205 u16 bmEEMCmd;
206
207 /*
208 * EEM (link) command packet:
209 * b0..10: bmEEMCmdParam
210 * b11..13: bmEEMCmd
211 * b14: bmReserved (must be 0)
212 * b15: 1 (EEM command)
213 */
214 if (header & BIT(14)) {
215 devdbg(dev, "reserved command %04x\n", header);
216 continue;
217 }
218
219 bmEEMCmd = (header >> 11) & 0x7;
220 switch (bmEEMCmd) {
221
222 /* Responding to echo requests is mandatory. */
223 case 0: /* Echo command */
224 len = header & 0x7FF;
225
226 /* bogus command? */
227 if (skb->len < len)
228 return 0;
229
230 skb2 = skb_clone(skb, GFP_ATOMIC);
231 if (unlikely(!skb2))
232 goto next;
233 skb_trim(skb2, len);
234 put_unaligned_le16(BIT(15) | (1 << 11) | len,
235 skb_push(skb2, 2));
236 eem_linkcmd(dev, skb2);
237 break;
238
239 /*
240 * Host may choose to ignore hints.
241 * - suspend: peripheral ready to suspend
242 * - response: suggest N millisec polling
243 * - response complete: suggest N sec polling
244 */
245 case 2: /* Suspend hint */
246 case 3: /* Response hint */
247 case 4: /* Response complete hint */
248 continue;
249
250 /*
251 * Hosts should never receive host-to-peripheral
252 * or reserved command codes; or responses to an
253 * echo command we didn't send.
254 */
255 case 1: /* Echo response */
256 case 5: /* Tickle */
257 default: /* reserved */
258 devwarn(dev, "unexpected link command %d\n",
259 bmEEMCmd);
260 continue;
261 }
262
263 } else {
264 u32 crc, crc2;
265 int is_last;
266
267 /* zero length EEM packet? */
268 if (header == 0)
269 continue;
270
271 /*
272 * EEM data packet header :
273 * b0..13: length of ethernet frame
274 * b14: bmCRC
275 * b15: 0 (EEM data)
276 */
277 len = header & 0x3FFF;
278
279 /* bogus EEM payload? */
280 if (skb->len < len)
281 return 0;
282
283 /* bogus ethernet frame? */
284 if (len < (ETH_HLEN + ETH_FCS_LEN))
285 goto next;
286
287 /*
288 * Treat the last payload differently: framework
289 * code expects our "fixup" to have stripped off
290 * headers, so "skb" is a data packet (or error).
291 * Else if it's not the last payload, keep "skb"
292 * for further processing.
293 */
294 is_last = (len == skb->len);
295 if (is_last)
296 skb2 = skb;
297 else {
298 skb2 = skb_clone(skb, GFP_ATOMIC);
299 if (unlikely(!skb2))
300 return 0;
301 }
302
303 crc = get_unaligned_le32(skb2->data
304 + len - ETH_FCS_LEN);
305 skb_trim(skb2, len - ETH_FCS_LEN);
306
307 /*
308 * The bmCRC helps to denote when the CRC field in
309 * the Ethernet frame contains a calculated CRC:
310 * bmCRC = 1 : CRC is calculated
311 * bmCRC = 0 : CRC = 0xDEADBEEF
312 */
313 if (header & BIT(14))
314 crc2 = ~crc32_le(~0, skb2->data, len);
315 else
316 crc2 = 0xdeadbeef;
317
318 if (is_last)
319 return crc == crc2;
320
321 if (unlikely(crc != crc2)) {
322 dev->stats.rx_errors++;
323 dev_kfree_skb_any(skb2);
324 } else
325 usbnet_skb_return(dev, skb2);
326 }
327
328next:
329 skb_pull(skb, len);
330 } while (skb->len);
331
332 return 1;
333}
334
335static const struct driver_info eem_info = {
336 .description = "CDC EEM Device",
337 .flags = FLAG_ETHER,
338 .bind = eem_bind,
339 .rx_fixup = eem_rx_fixup,
340 .tx_fixup = eem_tx_fixup,
341};
342
343/*-------------------------------------------------------------------------*/
344
345static const struct usb_device_id products[] = {
346{
347 USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_EEM,
348 USB_CDC_PROTO_EEM),
349 .driver_info = (unsigned long) &eem_info,
350},
351{
352 /* EMPTY == end of list */
353},
354};
355MODULE_DEVICE_TABLE(usb, products);
356
357static struct usb_driver eem_driver = {
358 .name = "cdc_eem",
359 .id_table = products,
360 .probe = usbnet_probe,
361 .disconnect = usbnet_disconnect,
362 .suspend = usbnet_suspend,
363 .resume = usbnet_resume,
364};
365
366
367static int __init eem_init(void)
368{
369 return usb_register(&eem_driver);
370}
371module_init(eem_init);
372
373static void __exit eem_exit(void)
374{
375 usb_deregister(&eem_driver);
376}
377module_exit(eem_exit);
378
379MODULE_AUTHOR("Omar Laazimani <omar.oberthur@gmail.com>");
380MODULE_DESCRIPTION("USB CDC EEM");
381MODULE_LICENSE("GPL");
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index dc1665326592..5a7283372b53 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -941,6 +941,16 @@ static int smsc95xx_reset(struct usbnet *dev)
941 if (netif_msg_ifup(dev)) 941 if (netif_msg_ifup(dev))
942 devdbg(dev, "ID_REV = 0x%08x", read_buf); 942 devdbg(dev, "ID_REV = 0x%08x", read_buf);
943 943
944 /* Configure GPIO pins as LED outputs */
945 write_buf = LED_GPIO_CFG_SPD_LED | LED_GPIO_CFG_LNK_LED |
946 LED_GPIO_CFG_FDX_LED;
947 ret = smsc95xx_write_reg(dev, LED_GPIO_CFG, write_buf);
948 if (ret < 0) {
949 devwarn(dev, "Failed to write LED_GPIO_CFG register, ret=%d",
950 ret);
951 return ret;
952 }
953
944 /* Init Tx */ 954 /* Init Tx */
945 write_buf = 0; 955 write_buf = 0;
946 ret = smsc95xx_write_reg(dev, FLOW, write_buf); 956 ret = smsc95xx_write_reg(dev, FLOW, write_buf);
@@ -1231,6 +1241,11 @@ static const struct usb_device_id products[] = {
1231 USB_DEVICE(0x0424, 0x9500), 1241 USB_DEVICE(0x0424, 0x9500),
1232 .driver_info = (unsigned long) &smsc95xx_info, 1242 .driver_info = (unsigned long) &smsc95xx_info,
1233 }, 1243 },
1244 {
1245 /* SMSC9512/9514 USB Hub & Ethernet Device */
1246 USB_DEVICE(0x0424, 0xec00),
1247 .driver_info = (unsigned long) &smsc95xx_info,
1248 },
1234 { }, /* END */ 1249 { }, /* END */
1235}; 1250};
1236MODULE_DEVICE_TABLE(usb, products); 1251MODULE_DEVICE_TABLE(usb, products);
diff --git a/drivers/net/usb/smsc95xx.h b/drivers/net/usb/smsc95xx.h
index 66b5c84f302e..86bc44977fbd 100644
--- a/drivers/net/usb/smsc95xx.h
+++ b/drivers/net/usb/smsc95xx.h
@@ -99,6 +99,9 @@
99#define PM_CTL_WUPS_MULTI_ (0x00000003) 99#define PM_CTL_WUPS_MULTI_ (0x00000003)
100 100
101#define LED_GPIO_CFG (0x24) 101#define LED_GPIO_CFG (0x24)
102#define LED_GPIO_CFG_SPD_LED (0x01000000)
103#define LED_GPIO_CFG_LNK_LED (0x00100000)
104#define LED_GPIO_CFG_FDX_LED (0x00010000)
102 105
103#define GPIO_CFG (0x28) 106#define GPIO_CFG (0x28)
104 107
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 9c82a39497e5..4d1d47953fc6 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -616,10 +616,11 @@ static int virtnet_open(struct net_device *dev)
616static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, 616static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
617 struct scatterlist *data, int out, int in) 617 struct scatterlist *data, int out, int in)
618{ 618{
619 struct scatterlist sg[VIRTNET_SEND_COMMAND_SG_MAX + 2]; 619 struct scatterlist *s, sg[VIRTNET_SEND_COMMAND_SG_MAX + 2];
620 struct virtio_net_ctrl_hdr ctrl; 620 struct virtio_net_ctrl_hdr ctrl;
621 virtio_net_ctrl_ack status = ~0; 621 virtio_net_ctrl_ack status = ~0;
622 unsigned int tmp; 622 unsigned int tmp;
623 int i;
623 624
624 if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ)) { 625 if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ)) {
625 BUG(); /* Caller should know better */ 626 BUG(); /* Caller should know better */
@@ -637,7 +638,8 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
637 sg_init_table(sg, out + in); 638 sg_init_table(sg, out + in);
638 639
639 sg_set_buf(&sg[0], &ctrl, sizeof(ctrl)); 640 sg_set_buf(&sg[0], &ctrl, sizeof(ctrl));
640 memcpy(&sg[1], data, sizeof(struct scatterlist) * (out + in - 2)); 641 for_each_sg(data, s, out + in - 2, i)
642 sg_set_buf(&sg[i + 1], sg_virt(s), s->length);
641 sg_set_buf(&sg[out + in - 1], &status, sizeof(status)); 643 sg_set_buf(&sg[out + in - 1], &status, sizeof(status));
642 644
643 if (vi->cvq->vq_ops->add_buf(vi->cvq, sg, out, in, vi) != 0) 645 if (vi->cvq->vq_ops->add_buf(vi->cvq, sg, out, in, vi) != 0)
@@ -692,7 +694,7 @@ static void virtnet_set_rx_mode(struct net_device *dev)
692 promisc = ((dev->flags & IFF_PROMISC) != 0); 694 promisc = ((dev->flags & IFF_PROMISC) != 0);
693 allmulti = ((dev->flags & IFF_ALLMULTI) != 0); 695 allmulti = ((dev->flags & IFF_ALLMULTI) != 0);
694 696
695 sg_set_buf(sg, &promisc, sizeof(promisc)); 697 sg_init_one(sg, &promisc, sizeof(promisc));
696 698
697 if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_RX, 699 if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_RX,
698 VIRTIO_NET_CTRL_RX_PROMISC, 700 VIRTIO_NET_CTRL_RX_PROMISC,
@@ -700,7 +702,7 @@ static void virtnet_set_rx_mode(struct net_device *dev)
700 dev_warn(&dev->dev, "Failed to %sable promisc mode.\n", 702 dev_warn(&dev->dev, "Failed to %sable promisc mode.\n",
701 promisc ? "en" : "dis"); 703 promisc ? "en" : "dis");
702 704
703 sg_set_buf(sg, &allmulti, sizeof(allmulti)); 705 sg_init_one(sg, &allmulti, sizeof(allmulti));
704 706
705 if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_RX, 707 if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_RX,
706 VIRTIO_NET_CTRL_RX_ALLMULTI, 708 VIRTIO_NET_CTRL_RX_ALLMULTI,
@@ -716,6 +718,8 @@ static void virtnet_set_rx_mode(struct net_device *dev)
716 return; 718 return;
717 } 719 }
718 720
721 sg_init_table(sg, 2);
722
719 /* Store the unicast list and count in the front of the buffer */ 723 /* Store the unicast list and count in the front of the buffer */
720 mac_data->entries = dev->uc_count; 724 mac_data->entries = dev->uc_count;
721 addr = dev->uc_list; 725 addr = dev->uc_list;
@@ -744,24 +748,24 @@ static void virtnet_set_rx_mode(struct net_device *dev)
744 kfree(buf); 748 kfree(buf);
745} 749}
746 750
747static void virnet_vlan_rx_add_vid(struct net_device *dev, u16 vid) 751static void virtnet_vlan_rx_add_vid(struct net_device *dev, u16 vid)
748{ 752{
749 struct virtnet_info *vi = netdev_priv(dev); 753 struct virtnet_info *vi = netdev_priv(dev);
750 struct scatterlist sg; 754 struct scatterlist sg;
751 755
752 sg_set_buf(&sg, &vid, sizeof(vid)); 756 sg_init_one(&sg, &vid, sizeof(vid));
753 757
754 if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN, 758 if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN,
755 VIRTIO_NET_CTRL_VLAN_ADD, &sg, 1, 0)) 759 VIRTIO_NET_CTRL_VLAN_ADD, &sg, 1, 0))
756 dev_warn(&dev->dev, "Failed to add VLAN ID %d.\n", vid); 760 dev_warn(&dev->dev, "Failed to add VLAN ID %d.\n", vid);
757} 761}
758 762
759static void virnet_vlan_rx_kill_vid(struct net_device *dev, u16 vid) 763static void virtnet_vlan_rx_kill_vid(struct net_device *dev, u16 vid)
760{ 764{
761 struct virtnet_info *vi = netdev_priv(dev); 765 struct virtnet_info *vi = netdev_priv(dev);
762 struct scatterlist sg; 766 struct scatterlist sg;
763 767
764 sg_set_buf(&sg, &vid, sizeof(vid)); 768 sg_init_one(&sg, &vid, sizeof(vid));
765 769
766 if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN, 770 if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN,
767 VIRTIO_NET_CTRL_VLAN_DEL, &sg, 1, 0)) 771 VIRTIO_NET_CTRL_VLAN_DEL, &sg, 1, 0))
@@ -794,8 +798,8 @@ static const struct net_device_ops virtnet_netdev = {
794 .ndo_set_mac_address = virtnet_set_mac_address, 798 .ndo_set_mac_address = virtnet_set_mac_address,
795 .ndo_set_rx_mode = virtnet_set_rx_mode, 799 .ndo_set_rx_mode = virtnet_set_rx_mode,
796 .ndo_change_mtu = virtnet_change_mtu, 800 .ndo_change_mtu = virtnet_change_mtu,
797 .ndo_vlan_rx_add_vid = virnet_vlan_rx_add_vid, 801 .ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid,
798 .ndo_vlan_rx_kill_vid = virnet_vlan_rx_kill_vid, 802 .ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,
799#ifdef CONFIG_NET_POLL_CONTROLLER 803#ifdef CONFIG_NET_POLL_CONTROLLER
800 .ndo_poll_controller = virtnet_netpoll, 804 .ndo_poll_controller = virtnet_netpoll,
801#endif 805#endif
diff --git a/drivers/net/wan/ixp4xx_hss.c b/drivers/net/wan/ixp4xx_hss.c
index 3bf7d3f447db..1e56e58c6605 100644
--- a/drivers/net/wan/ixp4xx_hss.c
+++ b/drivers/net/wan/ixp4xx_hss.c
@@ -579,7 +579,8 @@ static inline void queue_put_desc(unsigned int queue, u32 phys,
579 debug_desc(phys, desc); 579 debug_desc(phys, desc);
580 BUG_ON(phys & 0x1F); 580 BUG_ON(phys & 0x1F);
581 qmgr_put_entry(queue, phys); 581 qmgr_put_entry(queue, phys);
582 BUG_ON(qmgr_stat_overflow(queue)); 582 /* Don't check for queue overflow here, we've allocated sufficient
583 length and queues >= 32 don't support this check anyway. */
583} 584}
584 585
585 586
@@ -789,7 +790,8 @@ static void hss_hdlc_txdone_irq(void *pdev)
789 free_buffer_irq(port->tx_buff_tab[n_desc]); 790 free_buffer_irq(port->tx_buff_tab[n_desc]);
790 port->tx_buff_tab[n_desc] = NULL; 791 port->tx_buff_tab[n_desc] = NULL;
791 792
792 start = qmgr_stat_empty(port->plat->txreadyq); 793 /* really empty in fact */
794 start = qmgr_stat_nearly_empty(port->plat->txreadyq);
793 queue_put_desc(port->plat->txreadyq, 795 queue_put_desc(port->plat->txreadyq,
794 tx_desc_phys(port, n_desc), desc); 796 tx_desc_phys(port, n_desc), desc);
795 if (start) { 797 if (start) {
@@ -867,13 +869,13 @@ static int hss_hdlc_xmit(struct sk_buff *skb, struct net_device *dev)
867 queue_put_desc(queue_ids[port->id].tx, tx_desc_phys(port, n), desc); 869 queue_put_desc(queue_ids[port->id].tx, tx_desc_phys(port, n), desc);
868 dev->trans_start = jiffies; 870 dev->trans_start = jiffies;
869 871
870 if (qmgr_stat_empty(txreadyq)) { 872 if (qmgr_stat_nearly_empty(txreadyq)) { /* really empty in fact */
871#if DEBUG_TX 873#if DEBUG_TX
872 printk(KERN_DEBUG "%s: hss_hdlc_xmit queue full\n", dev->name); 874 printk(KERN_DEBUG "%s: hss_hdlc_xmit queue full\n", dev->name);
873#endif 875#endif
874 netif_stop_queue(dev); 876 netif_stop_queue(dev);
875 /* we could miss TX ready interrupt */ 877 /* we could miss TX ready interrupt */
876 if (!qmgr_stat_empty(txreadyq)) { 878 if (!qmgr_stat_nearly_empty(txreadyq)) {
877#if DEBUG_TX 879#if DEBUG_TX
878 printk(KERN_DEBUG "%s: hss_hdlc_xmit ready again\n", 880 printk(KERN_DEBUG "%s: hss_hdlc_xmit ready again\n",
879 dev->name); 881 dev->name);
@@ -1249,7 +1251,7 @@ static int __devinit hss_init_one(struct platform_device *pdev)
1249 return -ENOMEM; 1251 return -ENOMEM;
1250 1252
1251 if ((port->npe = npe_request(0)) == NULL) { 1253 if ((port->npe = npe_request(0)) == NULL) {
1252 err = -ENOSYS; 1254 err = -ENODEV;
1253 goto err_free; 1255 goto err_free;
1254 } 1256 }
1255 1257
@@ -1311,7 +1313,7 @@ static int __init hss_init_module(void)
1311 if ((ixp4xx_read_feature_bits() & 1313 if ((ixp4xx_read_feature_bits() &
1312 (IXP4XX_FEATURE_HDLC | IXP4XX_FEATURE_HSS)) != 1314 (IXP4XX_FEATURE_HDLC | IXP4XX_FEATURE_HSS)) !=
1313 (IXP4XX_FEATURE_HDLC | IXP4XX_FEATURE_HSS)) 1315 (IXP4XX_FEATURE_HDLC | IXP4XX_FEATURE_HSS))
1314 return -ENOSYS; 1316 return -ENODEV;
1315 1317
1316 spin_lock_init(&npe_lock); 1318 spin_lock_init(&npe_lock);
1317 1319
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index c36d3a3d655f..d73475739127 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -6501,7 +6501,10 @@ static int airo_get_encode(struct net_device *dev,
6501 6501
6502 /* Copy the key to the user buffer */ 6502 /* Copy the key to the user buffer */
6503 dwrq->length = get_wep_key(local, index, &buf[0], sizeof(buf)); 6503 dwrq->length = get_wep_key(local, index, &buf[0], sizeof(buf));
6504 memcpy(extra, buf, dwrq->length); 6504 if (dwrq->length != -1)
6505 memcpy(extra, buf, dwrq->length);
6506 else
6507 dwrq->length = 0;
6505 6508
6506 return 0; 6509 return 0;
6507} 6510}
@@ -6659,7 +6662,10 @@ static int airo_get_encodeext(struct net_device *dev,
6659 6662
6660 /* Copy the key to the user buffer */ 6663 /* Copy the key to the user buffer */
6661 ext->key_len = get_wep_key(local, idx, &buf[0], sizeof(buf)); 6664 ext->key_len = get_wep_key(local, idx, &buf[0], sizeof(buf));
6662 memcpy(extra, buf, ext->key_len); 6665 if (ext->key_len != -1)
6666 memcpy(extra, buf, ext->key_len);
6667 else
6668 ext->key_len = 0;
6663 6669
6664 return 0; 6670 return 0;
6665} 6671}
diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c
index a08bc8a4fb69..32df27a9c7a2 100644
--- a/drivers/net/wireless/ath5k/base.c
+++ b/drivers/net/wireless/ath5k/base.c
@@ -214,7 +214,7 @@ static struct pci_driver ath5k_pci_driver = {
214 * Prototypes - MAC 802.11 stack related functions 214 * Prototypes - MAC 802.11 stack related functions
215 */ 215 */
216static int ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb); 216static int ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
217static int ath5k_reset(struct ath5k_softc *sc, bool stop, bool change_channel); 217static int ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan);
218static int ath5k_reset_wake(struct ath5k_softc *sc); 218static int ath5k_reset_wake(struct ath5k_softc *sc);
219static int ath5k_start(struct ieee80211_hw *hw); 219static int ath5k_start(struct ieee80211_hw *hw);
220static void ath5k_stop(struct ieee80211_hw *hw); 220static void ath5k_stop(struct ieee80211_hw *hw);
@@ -1038,16 +1038,13 @@ ath5k_chan_set(struct ath5k_softc *sc, struct ieee80211_channel *chan)
1038 if (chan->center_freq != sc->curchan->center_freq || 1038 if (chan->center_freq != sc->curchan->center_freq ||
1039 chan->hw_value != sc->curchan->hw_value) { 1039 chan->hw_value != sc->curchan->hw_value) {
1040 1040
1041 sc->curchan = chan;
1042 sc->curband = &sc->sbands[chan->band];
1043
1044 /* 1041 /*
1045 * To switch channels clear any pending DMA operations; 1042 * To switch channels clear any pending DMA operations;
1046 * wait long enough for the RX fifo to drain, reset the 1043 * wait long enough for the RX fifo to drain, reset the
1047 * hardware at the new frequency, and then re-enable 1044 * hardware at the new frequency, and then re-enable
1048 * the relevant bits of the h/w. 1045 * the relevant bits of the h/w.
1049 */ 1046 */
1050 return ath5k_reset(sc, true, true); 1047 return ath5k_reset(sc, chan);
1051 } 1048 }
1052 1049
1053 return 0; 1050 return 0;
@@ -2314,7 +2311,7 @@ ath5k_init(struct ath5k_softc *sc)
2314 sc->imask = AR5K_INT_RXOK | AR5K_INT_RXERR | AR5K_INT_RXEOL | 2311 sc->imask = AR5K_INT_RXOK | AR5K_INT_RXERR | AR5K_INT_RXEOL |
2315 AR5K_INT_RXORN | AR5K_INT_TXDESC | AR5K_INT_TXEOL | 2312 AR5K_INT_RXORN | AR5K_INT_TXDESC | AR5K_INT_TXEOL |
2316 AR5K_INT_FATAL | AR5K_INT_GLOBAL; 2313 AR5K_INT_FATAL | AR5K_INT_GLOBAL;
2317 ret = ath5k_reset(sc, false, false); 2314 ret = ath5k_reset(sc, NULL);
2318 if (ret) 2315 if (ret)
2319 goto done; 2316 goto done;
2320 2317
@@ -2599,18 +2596,25 @@ drop_packet:
2599 return NETDEV_TX_OK; 2596 return NETDEV_TX_OK;
2600} 2597}
2601 2598
2599/*
2600 * Reset the hardware. If chan is not NULL, then also pause rx/tx
2601 * and change to the given channel.
2602 */
2602static int 2603static int
2603ath5k_reset(struct ath5k_softc *sc, bool stop, bool change_channel) 2604ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan)
2604{ 2605{
2605 struct ath5k_hw *ah = sc->ah; 2606 struct ath5k_hw *ah = sc->ah;
2606 int ret; 2607 int ret;
2607 2608
2608 ATH5K_DBG(sc, ATH5K_DEBUG_RESET, "resetting\n"); 2609 ATH5K_DBG(sc, ATH5K_DEBUG_RESET, "resetting\n");
2609 2610
2610 if (stop) { 2611 if (chan) {
2611 ath5k_hw_set_imr(ah, 0); 2612 ath5k_hw_set_imr(ah, 0);
2612 ath5k_txq_cleanup(sc); 2613 ath5k_txq_cleanup(sc);
2613 ath5k_rx_stop(sc); 2614 ath5k_rx_stop(sc);
2615
2616 sc->curchan = chan;
2617 sc->curband = &sc->sbands[chan->band];
2614 } 2618 }
2615 ret = ath5k_hw_reset(ah, sc->opmode, sc->curchan, true); 2619 ret = ath5k_hw_reset(ah, sc->opmode, sc->curchan, true);
2616 if (ret) { 2620 if (ret) {
@@ -2648,7 +2652,7 @@ ath5k_reset_wake(struct ath5k_softc *sc)
2648{ 2652{
2649 int ret; 2653 int ret;
2650 2654
2651 ret = ath5k_reset(sc, true, true); 2655 ret = ath5k_reset(sc, sc->curchan);
2652 if (!ret) 2656 if (!ret)
2653 ieee80211_wake_queues(sc->hw); 2657 ieee80211_wake_queues(sc->hw);
2654 2658
diff --git a/drivers/net/wireless/ath5k/debug.c b/drivers/net/wireless/ath5k/debug.c
index 9770bb3d40f9..4904a07e4b59 100644
--- a/drivers/net/wireless/ath5k/debug.c
+++ b/drivers/net/wireless/ath5k/debug.c
@@ -424,7 +424,7 @@ ath5k_debug_dump_bands(struct ath5k_softc *sc)
424 424
425 for (b = 0; b < IEEE80211_NUM_BANDS; b++) { 425 for (b = 0; b < IEEE80211_NUM_BANDS; b++) {
426 struct ieee80211_supported_band *band = &sc->sbands[b]; 426 struct ieee80211_supported_band *band = &sc->sbands[b];
427 char bname[5]; 427 char bname[6];
428 switch (band->band) { 428 switch (band->band) {
429 case IEEE80211_BAND_2GHZ: 429 case IEEE80211_BAND_2GHZ:
430 strcpy(bname, "2 GHz"); 430 strcpy(bname, "2 GHz");
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index edfa5e149f71..bd438d8acf55 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -101,8 +101,8 @@ struct iwl_cfg iwl6000_2agn_cfg = {
101 .eeprom_ver = EEPROM_5000_EEPROM_VERSION, 101 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
102 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, 102 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
103 .mod_params = &iwl50_mod_params, 103 .mod_params = &iwl50_mod_params,
104 .valid_tx_ant = ANT_BC, 104 .valid_tx_ant = ANT_AB,
105 .valid_rx_ant = ANT_BC, 105 .valid_rx_ant = ANT_AB,
106 .need_pll_cfg = false, 106 .need_pll_cfg = false,
107}; 107};
108 108
@@ -117,8 +117,8 @@ struct iwl_cfg iwl6050_2agn_cfg = {
117 .eeprom_ver = EEPROM_5000_EEPROM_VERSION, 117 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
118 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION, 118 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
119 .mod_params = &iwl50_mod_params, 119 .mod_params = &iwl50_mod_params,
120 .valid_tx_ant = ANT_BC, 120 .valid_tx_ant = ANT_AB,
121 .valid_rx_ant = ANT_BC, 121 .valid_rx_ant = ANT_AB,
122 .need_pll_cfg = false, 122 .need_pll_cfg = false,
123}; 123};
124 124
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 1ef4192207a5..3bb28db4a40f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -3636,7 +3636,9 @@ static struct pci_device_id iwl_hw_card_ids[] = {
3636 {IWL_PCI_DEVICE(0x0085, 0x1112, iwl6000_2ag_cfg)}, 3636 {IWL_PCI_DEVICE(0x0085, 0x1112, iwl6000_2ag_cfg)},
3637 {IWL_PCI_DEVICE(0x0082, 0x1122, iwl6000_2ag_cfg)}, 3637 {IWL_PCI_DEVICE(0x0082, 0x1122, iwl6000_2ag_cfg)},
3638 {IWL_PCI_DEVICE(0x422B, PCI_ANY_ID, iwl6000_3agn_cfg)}, 3638 {IWL_PCI_DEVICE(0x422B, PCI_ANY_ID, iwl6000_3agn_cfg)},
3639 {IWL_PCI_DEVICE(0x422C, PCI_ANY_ID, iwl6000_2agn_cfg)},
3639 {IWL_PCI_DEVICE(0x4238, PCI_ANY_ID, iwl6000_3agn_cfg)}, 3640 {IWL_PCI_DEVICE(0x4238, PCI_ANY_ID, iwl6000_3agn_cfg)},
3641 {IWL_PCI_DEVICE(0x4239, PCI_ANY_ID, iwl6000_2agn_cfg)},
3640 {IWL_PCI_DEVICE(0x0082, PCI_ANY_ID, iwl6000_2agn_cfg)}, 3642 {IWL_PCI_DEVICE(0x0082, PCI_ANY_ID, iwl6000_2agn_cfg)},
3641 {IWL_PCI_DEVICE(0x0085, PCI_ANY_ID, iwl6000_3agn_cfg)}, 3643 {IWL_PCI_DEVICE(0x0085, PCI_ANY_ID, iwl6000_3agn_cfg)},
3642 {IWL_PCI_DEVICE(0x0086, PCI_ANY_ID, iwl6050_3agn_cfg)}, 3644 {IWL_PCI_DEVICE(0x0086, PCI_ANY_ID, iwl6050_3agn_cfg)},
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index 23644cf884f1..e7c65c4f741b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -925,11 +925,11 @@ void iwl_bg_scan_completed(struct work_struct *work)
925 925
926 IWL_DEBUG_SCAN(priv, "SCAN complete scan\n"); 926 IWL_DEBUG_SCAN(priv, "SCAN complete scan\n");
927 927
928 ieee80211_scan_completed(priv->hw, false);
929
928 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 930 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
929 return; 931 return;
930 932
931 ieee80211_scan_completed(priv->hw, false);
932
933 /* Since setting the TXPOWER may have been deferred while 933 /* Since setting the TXPOWER may have been deferred while
934 * performing the scan, fire one off */ 934 * performing the scan, fire one off */
935 mutex_lock(&priv->mutex); 935 mutex_lock(&priv->mutex);
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index 5798fe49c771..44ab03a12e40 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -719,6 +719,14 @@ static int iwl_set_tkip_dynamic_key_info(struct iwl_priv *priv,
719{ 719{
720 unsigned long flags; 720 unsigned long flags;
721 int ret = 0; 721 int ret = 0;
722 __le16 key_flags = 0;
723
724 key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK);
725 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
726 key_flags &= ~STA_KEY_FLG_INVALID;
727
728 if (sta_id == priv->hw_params.bcast_sta_id)
729 key_flags |= STA_KEY_MULTICAST_MSK;
722 730
723 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; 731 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
724 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; 732 keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
@@ -738,6 +746,9 @@ static int iwl_set_tkip_dynamic_key_info(struct iwl_priv *priv,
738 WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, 746 WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET,
739 "no space for a new key"); 747 "no space for a new key");
740 748
749 priv->stations[sta_id].sta.key.key_flags = key_flags;
750
751
741 /* This copy is acutally not needed: we get the key with each TX */ 752 /* This copy is acutally not needed: we get the key with each TX */
742 memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key, 16); 753 memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key, 16);
743 754
@@ -754,9 +765,7 @@ void iwl_update_tkip_key(struct iwl_priv *priv,
754{ 765{
755 u8 sta_id = IWL_INVALID_STATION; 766 u8 sta_id = IWL_INVALID_STATION;
756 unsigned long flags; 767 unsigned long flags;
757 __le16 key_flags = 0;
758 int i; 768 int i;
759 DECLARE_MAC_BUF(mac);
760 769
761 sta_id = iwl_find_station(priv, addr); 770 sta_id = iwl_find_station(priv, addr);
762 if (sta_id == IWL_INVALID_STATION) { 771 if (sta_id == IWL_INVALID_STATION) {
@@ -771,16 +780,8 @@ void iwl_update_tkip_key(struct iwl_priv *priv,
771 return; 780 return;
772 } 781 }
773 782
774 key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK);
775 key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
776 key_flags &= ~STA_KEY_FLG_INVALID;
777
778 if (sta_id == priv->hw_params.bcast_sta_id)
779 key_flags |= STA_KEY_MULTICAST_MSK;
780
781 spin_lock_irqsave(&priv->sta_lock, flags); 783 spin_lock_irqsave(&priv->sta_lock, flags);
782 784
783 priv->stations[sta_id].sta.key.key_flags = key_flags;
784 priv->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32; 785 priv->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32;
785 786
786 for (i = 0; i < 5; i++) 787 for (i = 0; i < 5; i++)
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 617c4235d971..4cce66133500 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -1694,7 +1694,6 @@ void iwl3945_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
1694 rxq->free_count = 0; 1694 rxq->free_count = 0;
1695 spin_unlock_irqrestore(&rxq->lock, flags); 1695 spin_unlock_irqrestore(&rxq->lock, flags);
1696} 1696}
1697EXPORT_SYMBOL(iwl3945_rx_queue_reset);
1698 1697
1699/* 1698/*
1700 * this should be called while priv->lock is locked 1699 * this should be called while priv->lock is locked
@@ -1745,7 +1744,6 @@ static void iwl3945_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rx
1745 rxq->bd = NULL; 1744 rxq->bd = NULL;
1746 rxq->rb_stts = NULL; 1745 rxq->rb_stts = NULL;
1747} 1746}
1748EXPORT_SYMBOL(iwl3945_rx_queue_free);
1749 1747
1750 1748
1751/* Convert linear signal-to-noise ratio into dB */ 1749/* Convert linear signal-to-noise ratio into dB */
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index db91db776508..bebf735cd4bd 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -2558,6 +2558,11 @@ static int rndis_wext_bind(struct usbnet *usbdev, struct usb_interface *intf)
2558 mutex_init(&priv->command_lock); 2558 mutex_init(&priv->command_lock);
2559 spin_lock_init(&priv->stats_lock); 2559 spin_lock_init(&priv->stats_lock);
2560 2560
2561 /* because rndis_command() sleeps we need to use workqueue */
2562 priv->workqueue = create_singlethread_workqueue("rndis_wlan");
2563 INIT_WORK(&priv->work, rndis_wext_worker);
2564 INIT_DELAYED_WORK(&priv->stats_work, rndis_update_wireless_stats);
2565
2561 /* try bind rndis_host */ 2566 /* try bind rndis_host */
2562 retval = generic_rndis_bind(usbdev, intf, FLAG_RNDIS_PHYM_WIRELESS); 2567 retval = generic_rndis_bind(usbdev, intf, FLAG_RNDIS_PHYM_WIRELESS);
2563 if (retval < 0) 2568 if (retval < 0)
@@ -2603,16 +2608,17 @@ static int rndis_wext_bind(struct usbnet *usbdev, struct usb_interface *intf)
2603 disassociate(usbdev, 1); 2608 disassociate(usbdev, 1);
2604 netif_carrier_off(usbdev->net); 2609 netif_carrier_off(usbdev->net);
2605 2610
2606 /* because rndis_command() sleeps we need to use workqueue */
2607 priv->workqueue = create_singlethread_workqueue("rndis_wlan");
2608 INIT_DELAYED_WORK(&priv->stats_work, rndis_update_wireless_stats);
2609 queue_delayed_work(priv->workqueue, &priv->stats_work, 2611 queue_delayed_work(priv->workqueue, &priv->stats_work,
2610 round_jiffies_relative(STATS_UPDATE_JIFFIES)); 2612 round_jiffies_relative(STATS_UPDATE_JIFFIES));
2611 INIT_WORK(&priv->work, rndis_wext_worker);
2612 2613
2613 return 0; 2614 return 0;
2614 2615
2615fail: 2616fail:
2617 cancel_delayed_work_sync(&priv->stats_work);
2618 cancel_work_sync(&priv->work);
2619 flush_workqueue(priv->workqueue);
2620 destroy_workqueue(priv->workqueue);
2621
2616 kfree(priv); 2622 kfree(priv);
2617 return retval; 2623 return retval;
2618} 2624}
diff --git a/drivers/net/wireless/rtl818x/rtl8187.h b/drivers/net/wireless/rtl818x/rtl8187.h
index 9718f61809cf..edeff82a4d06 100644
--- a/drivers/net/wireless/rtl818x/rtl8187.h
+++ b/drivers/net/wireless/rtl818x/rtl8187.h
@@ -120,6 +120,12 @@ struct rtl8187_priv {
120 __le64 buf; 120 __le64 buf;
121 struct sk_buff_head queue; 121 struct sk_buff_head queue;
122 } b_tx_status; /* This queue is used by both -b and non-b devices */ 122 } b_tx_status; /* This queue is used by both -b and non-b devices */
123 struct mutex io_mutex;
124 union {
125 u8 bits8;
126 __le16 bits16;
127 __le32 bits32;
128 } *io_dmabuf;
123}; 129};
124 130
125void rtl8187_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data); 131void rtl8187_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data);
@@ -129,10 +135,14 @@ static inline u8 rtl818x_ioread8_idx(struct rtl8187_priv *priv,
129{ 135{
130 u8 val; 136 u8 val;
131 137
138 mutex_lock(&priv->io_mutex);
132 usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0), 139 usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0),
133 RTL8187_REQ_GET_REG, RTL8187_REQT_READ, 140 RTL8187_REQ_GET_REG, RTL8187_REQT_READ,
134 (unsigned long)addr, idx & 0x03, &val, 141 (unsigned long)addr, idx & 0x03,
135 sizeof(val), HZ / 2); 142 &priv->io_dmabuf->bits8, sizeof(val), HZ / 2);
143
144 val = priv->io_dmabuf->bits8;
145 mutex_unlock(&priv->io_mutex);
136 146
137 return val; 147 return val;
138} 148}
@@ -147,10 +157,14 @@ static inline u16 rtl818x_ioread16_idx(struct rtl8187_priv *priv,
147{ 157{
148 __le16 val; 158 __le16 val;
149 159
160 mutex_lock(&priv->io_mutex);
150 usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0), 161 usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0),
151 RTL8187_REQ_GET_REG, RTL8187_REQT_READ, 162 RTL8187_REQ_GET_REG, RTL8187_REQT_READ,
152 (unsigned long)addr, idx & 0x03, &val, 163 (unsigned long)addr, idx & 0x03,
153 sizeof(val), HZ / 2); 164 &priv->io_dmabuf->bits16, sizeof(val), HZ / 2);
165
166 val = priv->io_dmabuf->bits16;
167 mutex_unlock(&priv->io_mutex);
154 168
155 return le16_to_cpu(val); 169 return le16_to_cpu(val);
156} 170}
@@ -165,10 +179,14 @@ static inline u32 rtl818x_ioread32_idx(struct rtl8187_priv *priv,
165{ 179{
166 __le32 val; 180 __le32 val;
167 181
182 mutex_lock(&priv->io_mutex);
168 usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0), 183 usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0),
169 RTL8187_REQ_GET_REG, RTL8187_REQT_READ, 184 RTL8187_REQ_GET_REG, RTL8187_REQT_READ,
170 (unsigned long)addr, idx & 0x03, &val, 185 (unsigned long)addr, idx & 0x03,
171 sizeof(val), HZ / 2); 186 &priv->io_dmabuf->bits32, sizeof(val), HZ / 2);
187
188 val = priv->io_dmabuf->bits32;
189 mutex_unlock(&priv->io_mutex);
172 190
173 return le32_to_cpu(val); 191 return le32_to_cpu(val);
174} 192}
@@ -181,10 +199,15 @@ static inline u32 rtl818x_ioread32(struct rtl8187_priv *priv, __le32 *addr)
181static inline void rtl818x_iowrite8_idx(struct rtl8187_priv *priv, 199static inline void rtl818x_iowrite8_idx(struct rtl8187_priv *priv,
182 u8 *addr, u8 val, u8 idx) 200 u8 *addr, u8 val, u8 idx)
183{ 201{
202 mutex_lock(&priv->io_mutex);
203
204 priv->io_dmabuf->bits8 = val;
184 usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0), 205 usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0),
185 RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE, 206 RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE,
186 (unsigned long)addr, idx & 0x03, &val, 207 (unsigned long)addr, idx & 0x03,
187 sizeof(val), HZ / 2); 208 &priv->io_dmabuf->bits8, sizeof(val), HZ / 2);
209
210 mutex_unlock(&priv->io_mutex);
188} 211}
189 212
190static inline void rtl818x_iowrite8(struct rtl8187_priv *priv, u8 *addr, u8 val) 213static inline void rtl818x_iowrite8(struct rtl8187_priv *priv, u8 *addr, u8 val)
@@ -195,12 +218,15 @@ static inline void rtl818x_iowrite8(struct rtl8187_priv *priv, u8 *addr, u8 val)
195static inline void rtl818x_iowrite16_idx(struct rtl8187_priv *priv, 218static inline void rtl818x_iowrite16_idx(struct rtl8187_priv *priv,
196 __le16 *addr, u16 val, u8 idx) 219 __le16 *addr, u16 val, u8 idx)
197{ 220{
198 __le16 buf = cpu_to_le16(val); 221 mutex_lock(&priv->io_mutex);
199 222
223 priv->io_dmabuf->bits16 = cpu_to_le16(val);
200 usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0), 224 usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0),
201 RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE, 225 RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE,
202 (unsigned long)addr, idx & 0x03, &buf, sizeof(buf), 226 (unsigned long)addr, idx & 0x03,
203 HZ / 2); 227 &priv->io_dmabuf->bits16, sizeof(val), HZ / 2);
228
229 mutex_unlock(&priv->io_mutex);
204} 230}
205 231
206static inline void rtl818x_iowrite16(struct rtl8187_priv *priv, __le16 *addr, 232static inline void rtl818x_iowrite16(struct rtl8187_priv *priv, __le16 *addr,
@@ -212,12 +238,15 @@ static inline void rtl818x_iowrite16(struct rtl8187_priv *priv, __le16 *addr,
212static inline void rtl818x_iowrite32_idx(struct rtl8187_priv *priv, 238static inline void rtl818x_iowrite32_idx(struct rtl8187_priv *priv,
213 __le32 *addr, u32 val, u8 idx) 239 __le32 *addr, u32 val, u8 idx)
214{ 240{
215 __le32 buf = cpu_to_le32(val); 241 mutex_lock(&priv->io_mutex);
216 242
243 priv->io_dmabuf->bits32 = cpu_to_le32(val);
217 usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0), 244 usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0),
218 RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE, 245 RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE,
219 (unsigned long)addr, idx & 0x03, &buf, sizeof(buf), 246 (unsigned long)addr, idx & 0x03,
220 HZ / 2); 247 &priv->io_dmabuf->bits32, sizeof(val), HZ / 2);
248
249 mutex_unlock(&priv->io_mutex);
221} 250}
222 251
223static inline void rtl818x_iowrite32(struct rtl8187_priv *priv, __le32 *addr, 252static inline void rtl818x_iowrite32(struct rtl8187_priv *priv, __le32 *addr,
diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index fd81884b9c7d..bac6cfba6abd 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -1329,6 +1329,14 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
1329 priv = dev->priv; 1329 priv = dev->priv;
1330 priv->is_rtl8187b = (id->driver_info == DEVICE_RTL8187B); 1330 priv->is_rtl8187b = (id->driver_info == DEVICE_RTL8187B);
1331 1331
1332 /* allocate "DMA aware" buffer for register accesses */
1333 priv->io_dmabuf = kmalloc(sizeof(*priv->io_dmabuf), GFP_KERNEL);
1334 if (!priv->io_dmabuf) {
1335 err = -ENOMEM;
1336 goto err_free_dev;
1337 }
1338 mutex_init(&priv->io_mutex);
1339
1332 SET_IEEE80211_DEV(dev, &intf->dev); 1340 SET_IEEE80211_DEV(dev, &intf->dev);
1333 usb_set_intfdata(intf, dev); 1341 usb_set_intfdata(intf, dev);
1334 priv->udev = udev; 1342 priv->udev = udev;
@@ -1495,7 +1503,7 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
1495 err = ieee80211_register_hw(dev); 1503 err = ieee80211_register_hw(dev);
1496 if (err) { 1504 if (err) {
1497 printk(KERN_ERR "rtl8187: Cannot register device\n"); 1505 printk(KERN_ERR "rtl8187: Cannot register device\n");
1498 goto err_free_dev; 1506 goto err_free_dmabuf;
1499 } 1507 }
1500 mutex_init(&priv->conf_mutex); 1508 mutex_init(&priv->conf_mutex);
1501 skb_queue_head_init(&priv->b_tx_status.queue); 1509 skb_queue_head_init(&priv->b_tx_status.queue);
@@ -1506,6 +1514,8 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
1506 1514
1507 return 0; 1515 return 0;
1508 1516
1517 err_free_dmabuf:
1518 kfree(priv->io_dmabuf);
1509 err_free_dev: 1519 err_free_dev:
1510 ieee80211_free_hw(dev); 1520 ieee80211_free_hw(dev);
1511 usb_set_intfdata(intf, NULL); 1521 usb_set_intfdata(intf, NULL);
@@ -1526,6 +1536,7 @@ static void __devexit rtl8187_disconnect(struct usb_interface *intf)
1526 priv = dev->priv; 1536 priv = dev->priv;
1527 usb_reset_device(priv->udev); 1537 usb_reset_device(priv->udev);
1528 usb_put_dev(interface_to_usbdev(intf)); 1538 usb_put_dev(interface_to_usbdev(intf));
1539 kfree(priv->io_dmabuf);
1529 ieee80211_free_hw(dev); 1540 ieee80211_free_hw(dev);
1530} 1541}
1531 1542
diff --git a/drivers/net/wireless/rtl818x/rtl8187_rtl8225.c b/drivers/net/wireless/rtl818x/rtl8187_rtl8225.c
index 78df281b297a..a09819386a1e 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_rtl8225.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_rtl8225.c
@@ -88,9 +88,15 @@ static void rtl8225_write_8051(struct ieee80211_hw *dev, u8 addr, __le16 data)
88 rtl818x_iowrite16(priv, &priv->map->RFPinsOutput, reg80); 88 rtl818x_iowrite16(priv, &priv->map->RFPinsOutput, reg80);
89 udelay(10); 89 udelay(10);
90 90
91 mutex_lock(&priv->io_mutex);
92
93 priv->io_dmabuf->bits16 = data;
91 usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0), 94 usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0),
92 RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE, 95 RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE,
93 addr, 0x8225, &data, sizeof(data), HZ / 2); 96 addr, 0x8225, &priv->io_dmabuf->bits16, sizeof(data),
97 HZ / 2);
98
99 mutex_unlock(&priv->io_mutex);
94 100
95 rtl818x_iowrite16(priv, &priv->map->RFPinsOutput, reg80 | (1 << 2)); 101 rtl818x_iowrite16(priv, &priv->map->RFPinsOutput, reg80 | (1 << 2));
96 udelay(10); 102 udelay(10);
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 001b328adf80..a563fbe559d0 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -59,6 +59,10 @@
59#define DMA_32BIT_PFN IOVA_PFN(DMA_BIT_MASK(32)) 59#define DMA_32BIT_PFN IOVA_PFN(DMA_BIT_MASK(32))
60#define DMA_64BIT_PFN IOVA_PFN(DMA_BIT_MASK(64)) 60#define DMA_64BIT_PFN IOVA_PFN(DMA_BIT_MASK(64))
61 61
62#ifndef PHYSICAL_PAGE_MASK
63#define PHYSICAL_PAGE_MASK PAGE_MASK
64#endif
65
62/* global iommu list, set NULL for ignored DMAR units */ 66/* global iommu list, set NULL for ignored DMAR units */
63static struct intel_iommu **g_iommus; 67static struct intel_iommu **g_iommus;
64 68
@@ -1216,7 +1220,7 @@ static void dmar_init_reserved_ranges(void)
1216 if (!r->flags || !(r->flags & IORESOURCE_MEM)) 1220 if (!r->flags || !(r->flags & IORESOURCE_MEM))
1217 continue; 1221 continue;
1218 addr = r->start; 1222 addr = r->start;
1219 addr &= PAGE_MASK; 1223 addr &= PHYSICAL_PAGE_MASK;
1220 size = r->end - addr; 1224 size = r->end - addr;
1221 size = PAGE_ALIGN(size); 1225 size = PAGE_ALIGN(size);
1222 iova = reserve_iova(&reserved_iova_list, IOVA_PFN(addr), 1226 iova = reserve_iova(&reserved_iova_list, IOVA_PFN(addr),
@@ -2173,7 +2177,8 @@ static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr,
2173 * is not a big problem 2177 * is not a big problem
2174 */ 2178 */
2175 ret = domain_page_mapping(domain, start_paddr, 2179 ret = domain_page_mapping(domain, start_paddr,
2176 ((u64)paddr) & PAGE_MASK, size, prot); 2180 ((u64)paddr) & PHYSICAL_PAGE_MASK,
2181 size, prot);
2177 if (ret) 2182 if (ret)
2178 goto error; 2183 goto error;
2179 2184
@@ -2463,8 +2468,8 @@ static int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int ne
2463 addr = page_to_phys(sg_page(sg)) + sg->offset; 2468 addr = page_to_phys(sg_page(sg)) + sg->offset;
2464 size = aligned_size((u64)addr, sg->length); 2469 size = aligned_size((u64)addr, sg->length);
2465 ret = domain_page_mapping(domain, start_addr + offset, 2470 ret = domain_page_mapping(domain, start_addr + offset,
2466 ((u64)addr) & PAGE_MASK, 2471 ((u64)addr) & PHYSICAL_PAGE_MASK,
2467 size, prot); 2472 size, prot);
2468 if (ret) { 2473 if (ret) {
2469 /* clear the page */ 2474 /* clear the page */
2470 dma_pte_clear_range(domain, start_addr, 2475 dma_pte_clear_range(domain, start_addr,
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 6f2e6295e773..362773247fbf 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -455,8 +455,6 @@ static int msix_capability_init(struct pci_dev *dev,
455 entry->msi_attrib.default_irq = dev->irq; 455 entry->msi_attrib.default_irq = dev->irq;
456 entry->msi_attrib.pos = pos; 456 entry->msi_attrib.pos = pos;
457 entry->mask_base = base; 457 entry->mask_base = base;
458 entry->masked = readl(base + j * PCI_MSIX_ENTRY_SIZE +
459 PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET);
460 msix_mask_irq(entry, 1); 458 msix_mask_irq(entry, 1);
461 459
462 list_add_tail(&entry->list, &dev->msi_list); 460 list_add_tail(&entry->list, &dev->msi_list);
@@ -493,6 +491,12 @@ static int msix_capability_init(struct pci_dev *dev,
493 msix_set_enable(dev, 1); 491 msix_set_enable(dev, 1);
494 dev->msix_enabled = 1; 492 dev->msix_enabled = 1;
495 493
494 list_for_each_entry(entry, &dev->msi_list, list) {
495 int vector = entry->msi_attrib.entry_nr;
496 entry->masked = readl(base + vector * PCI_MSIX_ENTRY_SIZE +
497 PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET);
498 }
499
496 return 0; 500 return 0;
497} 501}
498 502
diff --git a/drivers/pci/pcie/aer/aerdrv.h b/drivers/pci/pcie/aer/aerdrv.h
index c7ad68b6c6d6..aa14482a4779 100644
--- a/drivers/pci/pcie/aer/aerdrv.h
+++ b/drivers/pci/pcie/aer/aerdrv.h
@@ -95,6 +95,9 @@ struct aer_broadcast_data {
95static inline pci_ers_result_t merge_result(enum pci_ers_result orig, 95static inline pci_ers_result_t merge_result(enum pci_ers_result orig,
96 enum pci_ers_result new) 96 enum pci_ers_result new)
97{ 97{
98 if (new == PCI_ERS_RESULT_NONE)
99 return orig;
100
98 switch (orig) { 101 switch (orig) {
99 case PCI_ERS_RESULT_CAN_RECOVER: 102 case PCI_ERS_RESULT_CAN_RECOVER:
100 case PCI_ERS_RESULT_RECOVERED: 103 case PCI_ERS_RESULT_RECOVERED:
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index b924e2463f85..091ce70051e0 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -200,7 +200,7 @@ static int slot_reset_iter(struct device *device, void *data)
200 200
201static pci_ers_result_t pcie_portdrv_slot_reset(struct pci_dev *dev) 201static pci_ers_result_t pcie_portdrv_slot_reset(struct pci_dev *dev)
202{ 202{
203 pci_ers_result_t status = PCI_ERS_RESULT_NONE; 203 pci_ers_result_t status = PCI_ERS_RESULT_RECOVERED;
204 int retval; 204 int retval;
205 205
206 /* If fatal, restore cfg space for possible link reset at upstream */ 206 /* If fatal, restore cfg space for possible link reset at upstream */
diff --git a/drivers/rtc/rtc-twl4030.c b/drivers/rtc/rtc-twl4030.c
index a6341e4f9a0f..9c8c70c497dc 100644
--- a/drivers/rtc/rtc-twl4030.c
+++ b/drivers/rtc/rtc-twl4030.c
@@ -495,9 +495,7 @@ static int twl4030_rtc_suspend(struct platform_device *pdev, pm_message_t state)
495{ 495{
496 irqstat = rtc_irq_bits; 496 irqstat = rtc_irq_bits;
497 497
498 /* REVISIT alarm may need to wake us from sleep */ 498 mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_TIMER_M);
499 mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_TIMER_M |
500 BIT_RTC_INTERRUPTS_REG_IT_ALARM_M);
501 return 0; 499 return 0;
502} 500}
503 501
diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c
index f644c9571eab..22b59e13ba83 100644
--- a/drivers/scsi/osd/osd_uld.c
+++ b/drivers/scsi/osd/osd_uld.c
@@ -173,26 +173,26 @@ static const struct file_operations osd_fops = {
173 .unlocked_ioctl = osd_uld_ioctl, 173 .unlocked_ioctl = osd_uld_ioctl,
174}; 174};
175 175
176struct osd_dev *osduld_path_lookup(const char *path) 176struct osd_dev *osduld_path_lookup(const char *name)
177{ 177{
178 struct nameidata nd; 178 struct path path;
179 struct inode *inode; 179 struct inode *inode;
180 struct cdev *cdev; 180 struct cdev *cdev;
181 struct osd_uld_device *uninitialized_var(oud); 181 struct osd_uld_device *uninitialized_var(oud);
182 int error; 182 int error;
183 183
184 if (!path || !*path) { 184 if (!name || !*name) {
185 OSD_ERR("Mount with !path || !*path\n"); 185 OSD_ERR("Mount with !path || !*path\n");
186 return ERR_PTR(-EINVAL); 186 return ERR_PTR(-EINVAL);
187 } 187 }
188 188
189 error = path_lookup(path, LOOKUP_FOLLOW, &nd); 189 error = kern_path(name, LOOKUP_FOLLOW, &path);
190 if (error) { 190 if (error) {
191 OSD_ERR("path_lookup of %s faild=>%d\n", path, error); 191 OSD_ERR("path_lookup of %s failed=>%d\n", name, error);
192 return ERR_PTR(error); 192 return ERR_PTR(error);
193 } 193 }
194 194
195 inode = nd.path.dentry->d_inode; 195 inode = path.dentry->d_inode;
196 error = -EINVAL; /* Not the right device e.g osd_uld_device */ 196 error = -EINVAL; /* Not the right device e.g osd_uld_device */
197 if (!S_ISCHR(inode->i_mode)) { 197 if (!S_ISCHR(inode->i_mode)) {
198 OSD_DEBUG("!S_ISCHR()\n"); 198 OSD_DEBUG("!S_ISCHR()\n");
@@ -202,15 +202,15 @@ struct osd_dev *osduld_path_lookup(const char *path)
202 cdev = inode->i_cdev; 202 cdev = inode->i_cdev;
203 if (!cdev) { 203 if (!cdev) {
204 OSD_ERR("Before mounting an OSD Based filesystem\n"); 204 OSD_ERR("Before mounting an OSD Based filesystem\n");
205 OSD_ERR(" user-mode must open+close the %s device\n", path); 205 OSD_ERR(" user-mode must open+close the %s device\n", name);
206 OSD_ERR(" Example: bash: echo < %s\n", path); 206 OSD_ERR(" Example: bash: echo < %s\n", name);
207 goto out; 207 goto out;
208 } 208 }
209 209
210 /* The Magic wand. Is it our char-dev */ 210 /* The Magic wand. Is it our char-dev */
211 /* TODO: Support sg devices */ 211 /* TODO: Support sg devices */
212 if (cdev->owner != THIS_MODULE) { 212 if (cdev->owner != THIS_MODULE) {
213 OSD_ERR("Error mounting %s - is not an OSD device\n", path); 213 OSD_ERR("Error mounting %s - is not an OSD device\n", name);
214 goto out; 214 goto out;
215 } 215 }
216 216
@@ -220,7 +220,7 @@ struct osd_dev *osduld_path_lookup(const char *path)
220 error = 0; 220 error = 0;
221 221
222out: 222out:
223 path_put(&nd.path); 223 path_put(&path);
224 return error ? ERR_PTR(error) : &oud->od; 224 return error ? ERR_PTR(error) : &oud->od;
225} 225}
226EXPORT_SYMBOL(osduld_path_lookup); 226EXPORT_SYMBOL(osduld_path_lookup);
diff --git a/drivers/serial/jsm/jsm.h b/drivers/serial/jsm/jsm.h
index 8871aaa3dba6..c0a3e2734e24 100644
--- a/drivers/serial/jsm/jsm.h
+++ b/drivers/serial/jsm/jsm.h
@@ -130,8 +130,6 @@ struct jsm_board
130 struct pci_dev *pci_dev; 130 struct pci_dev *pci_dev;
131 u32 maxports; /* MAX ports this board can handle */ 131 u32 maxports; /* MAX ports this board can handle */
132 132
133 spinlock_t bd_lock; /* Used to protect board */
134
135 spinlock_t bd_intr_lock; /* Used to protect the poller tasklet and 133 spinlock_t bd_intr_lock; /* Used to protect the poller tasklet and
136 * the interrupt routine from each other. 134 * the interrupt routine from each other.
137 */ 135 */
diff --git a/drivers/serial/jsm/jsm_driver.c b/drivers/serial/jsm/jsm_driver.c
index d2d32a198629..b3604aa322a4 100644
--- a/drivers/serial/jsm/jsm_driver.c
+++ b/drivers/serial/jsm/jsm_driver.c
@@ -88,7 +88,6 @@ static int __devinit jsm_probe_one(struct pci_dev *pdev, const struct pci_device
88 else 88 else
89 brd->maxports = 2; 89 brd->maxports = 2;
90 90
91 spin_lock_init(&brd->bd_lock);
92 spin_lock_init(&brd->bd_intr_lock); 91 spin_lock_init(&brd->bd_intr_lock);
93 92
94 /* store which revision we have */ 93 /* store which revision we have */
diff --git a/drivers/serial/nwpserial.c b/drivers/serial/nwpserial.c
index 32f3eaf0d262..9e150b19d726 100644
--- a/drivers/serial/nwpserial.c
+++ b/drivers/serial/nwpserial.c
@@ -145,11 +145,13 @@ static irqreturn_t nwpserial_interrupt(int irq, void *dev_id)
145 ch = dcr_read(up->dcr_host, UART_RX); 145 ch = dcr_read(up->dcr_host, UART_RX);
146 if (up->port.ignore_status_mask != NWPSERIAL_STATUS_RXVALID) 146 if (up->port.ignore_status_mask != NWPSERIAL_STATUS_RXVALID)
147 tty_insert_flip_char(tty, ch, TTY_NORMAL); 147 tty_insert_flip_char(tty, ch, TTY_NORMAL);
148 } while (dcr_read(up->dcr_host, UART_RX) & UART_LSR_DR); 148 } while (dcr_read(up->dcr_host, UART_LSR) & UART_LSR_DR);
149 149
150 tty_flip_buffer_push(tty); 150 tty_flip_buffer_push(tty);
151 ret = IRQ_HANDLED; 151 ret = IRQ_HANDLED;
152 152
153 /* clear interrupt */
154 dcr_write(up->dcr_host, UART_IIR, 1);
153out: 155out:
154 spin_unlock(&up->port.lock); 156 spin_unlock(&up->port.lock);
155 return ret; 157 return ret;
diff --git a/drivers/serial/s3c6400.c b/drivers/serial/s3c6400.c
index 06936d13393f..3e3785233682 100644
--- a/drivers/serial/s3c6400.c
+++ b/drivers/serial/s3c6400.c
@@ -102,6 +102,7 @@ static struct s3c24xx_uart_info s3c6400_uart_inf = {
102 .name = "Samsung S3C6400 UART", 102 .name = "Samsung S3C6400 UART",
103 .type = PORT_S3C6400, 103 .type = PORT_S3C6400,
104 .fifosize = 64, 104 .fifosize = 64,
105 .has_divslot = 1,
105 .rx_fifomask = S3C2440_UFSTAT_RXMASK, 106 .rx_fifomask = S3C2440_UFSTAT_RXMASK,
106 .rx_fifoshift = S3C2440_UFSTAT_RXSHIFT, 107 .rx_fifoshift = S3C2440_UFSTAT_RXSHIFT,
107 .rx_fifofull = S3C2440_UFSTAT_RXFULL, 108 .rx_fifofull = S3C2440_UFSTAT_RXFULL,
diff --git a/drivers/serial/samsung.c b/drivers/serial/samsung.c
index e06686ae858b..93b5d75db126 100644
--- a/drivers/serial/samsung.c
+++ b/drivers/serial/samsung.c
@@ -508,6 +508,7 @@ s3c24xx_serial_setsource(struct uart_port *port, struct s3c24xx_uart_clksrc *c)
508struct baud_calc { 508struct baud_calc {
509 struct s3c24xx_uart_clksrc *clksrc; 509 struct s3c24xx_uart_clksrc *clksrc;
510 unsigned int calc; 510 unsigned int calc;
511 unsigned int divslot;
511 unsigned int quot; 512 unsigned int quot;
512 struct clk *src; 513 struct clk *src;
513}; 514};
@@ -517,6 +518,7 @@ static int s3c24xx_serial_calcbaud(struct baud_calc *calc,
517 struct s3c24xx_uart_clksrc *clksrc, 518 struct s3c24xx_uart_clksrc *clksrc,
518 unsigned int baud) 519 unsigned int baud)
519{ 520{
521 struct s3c24xx_uart_port *ourport = to_ourport(port);
520 unsigned long rate; 522 unsigned long rate;
521 523
522 calc->src = clk_get(port->dev, clksrc->name); 524 calc->src = clk_get(port->dev, clksrc->name);
@@ -527,8 +529,24 @@ static int s3c24xx_serial_calcbaud(struct baud_calc *calc,
527 rate /= clksrc->divisor; 529 rate /= clksrc->divisor;
528 530
529 calc->clksrc = clksrc; 531 calc->clksrc = clksrc;
530 calc->quot = (rate + (8 * baud)) / (16 * baud); 532
531 calc->calc = (rate / (calc->quot * 16)); 533 if (ourport->info->has_divslot) {
534 unsigned long div = rate / baud;
535
536 /* The UDIVSLOT register on the newer UARTs allows us to
537 * get a divisor adjustment of 1/16th on the baud clock.
538 *
539 * We don't keep the UDIVSLOT value (the 16ths we calculated
540 * by not multiplying the baud by 16) as it is easy enough
541 * to recalculate.
542 */
543
544 calc->quot = div / 16;
545 calc->calc = rate / div;
546 } else {
547 calc->quot = (rate + (8 * baud)) / (16 * baud);
548 calc->calc = (rate / (calc->quot * 16));
549 }
532 550
533 calc->quot--; 551 calc->quot--;
534 return 1; 552 return 1;
@@ -611,6 +629,30 @@ static unsigned int s3c24xx_serial_getclk(struct uart_port *port,
611 return best->quot; 629 return best->quot;
612} 630}
613 631
632/* udivslot_table[]
633 *
634 * This table takes the fractional value of the baud divisor and gives
635 * the recommended setting for the UDIVSLOT register.
636 */
637static u16 udivslot_table[16] = {
638 [0] = 0x0000,
639 [1] = 0x0080,
640 [2] = 0x0808,
641 [3] = 0x0888,
642 [4] = 0x2222,
643 [5] = 0x4924,
644 [6] = 0x4A52,
645 [7] = 0x54AA,
646 [8] = 0x5555,
647 [9] = 0xD555,
648 [10] = 0xD5D5,
649 [11] = 0xDDD5,
650 [12] = 0xDDDD,
651 [13] = 0xDFDD,
652 [14] = 0xDFDF,
653 [15] = 0xFFDF,
654};
655
614static void s3c24xx_serial_set_termios(struct uart_port *port, 656static void s3c24xx_serial_set_termios(struct uart_port *port,
615 struct ktermios *termios, 657 struct ktermios *termios,
616 struct ktermios *old) 658 struct ktermios *old)
@@ -623,6 +665,7 @@ static void s3c24xx_serial_set_termios(struct uart_port *port,
623 unsigned int baud, quot; 665 unsigned int baud, quot;
624 unsigned int ulcon; 666 unsigned int ulcon;
625 unsigned int umcon; 667 unsigned int umcon;
668 unsigned int udivslot = 0;
626 669
627 /* 670 /*
628 * We don't support modem control lines. 671 * We don't support modem control lines.
@@ -644,6 +687,7 @@ static void s3c24xx_serial_set_termios(struct uart_port *port,
644 /* check to see if we need to change clock source */ 687 /* check to see if we need to change clock source */
645 688
646 if (ourport->clksrc != clksrc || ourport->baudclk != clk) { 689 if (ourport->clksrc != clksrc || ourport->baudclk != clk) {
690 dbg("selecting clock %p\n", clk);
647 s3c24xx_serial_setsource(port, clksrc); 691 s3c24xx_serial_setsource(port, clksrc);
648 692
649 if (ourport->baudclk != NULL && !IS_ERR(ourport->baudclk)) { 693 if (ourport->baudclk != NULL && !IS_ERR(ourport->baudclk)) {
@@ -658,6 +702,13 @@ static void s3c24xx_serial_set_termios(struct uart_port *port,
658 ourport->baudclk_rate = clk ? clk_get_rate(clk) : 0; 702 ourport->baudclk_rate = clk ? clk_get_rate(clk) : 0;
659 } 703 }
660 704
705 if (ourport->info->has_divslot) {
706 unsigned int div = ourport->baudclk_rate / baud;
707
708 udivslot = udivslot_table[div & 15];
709 dbg("udivslot = %04x (div %d)\n", udivslot, div & 15);
710 }
711
661 switch (termios->c_cflag & CSIZE) { 712 switch (termios->c_cflag & CSIZE) {
662 case CS5: 713 case CS5:
663 dbg("config: 5bits/char\n"); 714 dbg("config: 5bits/char\n");
@@ -697,12 +748,16 @@ static void s3c24xx_serial_set_termios(struct uart_port *port,
697 748
698 spin_lock_irqsave(&port->lock, flags); 749 spin_lock_irqsave(&port->lock, flags);
699 750
700 dbg("setting ulcon to %08x, brddiv to %d\n", ulcon, quot); 751 dbg("setting ulcon to %08x, brddiv to %d, udivslot %08x\n",
752 ulcon, quot, udivslot);
701 753
702 wr_regl(port, S3C2410_ULCON, ulcon); 754 wr_regl(port, S3C2410_ULCON, ulcon);
703 wr_regl(port, S3C2410_UBRDIV, quot); 755 wr_regl(port, S3C2410_UBRDIV, quot);
704 wr_regl(port, S3C2410_UMCON, umcon); 756 wr_regl(port, S3C2410_UMCON, umcon);
705 757
758 if (ourport->info->has_divslot)
759 wr_regl(port, S3C2443_DIVSLOT, udivslot);
760
706 dbg("uart: ulcon = 0x%08x, ucon = 0x%08x, ufcon = 0x%08x\n", 761 dbg("uart: ulcon = 0x%08x, ucon = 0x%08x, ufcon = 0x%08x\n",
707 rd_regl(port, S3C2410_ULCON), 762 rd_regl(port, S3C2410_ULCON),
708 rd_regl(port, S3C2410_UCON), 763 rd_regl(port, S3C2410_UCON),
diff --git a/drivers/serial/samsung.h b/drivers/serial/samsung.h
index 571d6b90d206..7afb94843a08 100644
--- a/drivers/serial/samsung.h
+++ b/drivers/serial/samsung.h
@@ -21,6 +21,10 @@ struct s3c24xx_uart_info {
21 unsigned long tx_fifoshift; 21 unsigned long tx_fifoshift;
22 unsigned long tx_fifofull; 22 unsigned long tx_fifofull;
23 23
24 /* uart port features */
25
26 unsigned int has_divslot:1;
27
24 /* clock source control */ 28 /* clock source control */
25 29
26 int (*get_clksrc)(struct uart_port *, struct s3c24xx_uart_clksrc *clk); 30 int (*get_clksrc)(struct uart_port *, struct s3c24xx_uart_clksrc *clk);
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index 885194a07418..3f3c08c6ba4e 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -1373,6 +1373,9 @@ static void cleanup(struct spi_device *spi)
1373{ 1373{
1374 struct chip_data *chip = spi_get_ctldata(spi); 1374 struct chip_data *chip = spi_get_ctldata(spi);
1375 1375
1376 if (!chip)
1377 return;
1378
1376 if (gpio_is_valid(chip->gpio_cs)) 1379 if (gpio_is_valid(chip->gpio_cs))
1377 gpio_free(chip->gpio_cs); 1380 gpio_free(chip->gpio_cs);
1378 1381
diff --git a/drivers/staging/comedi/TODO b/drivers/staging/comedi/TODO
index 557812958464..15c9348fb938 100644
--- a/drivers/staging/comedi/TODO
+++ b/drivers/staging/comedi/TODO
@@ -11,4 +11,3 @@ Please send patches to Greg Kroah-Hartman <greg@kroah.com> and
11copy: 11copy:
12 Ian Abbott <abbotti@mev.co.uk> 12 Ian Abbott <abbotti@mev.co.uk>
13 Frank Mori Hess <fmhess@users.sourceforge.net> 13 Frank Mori Hess <fmhess@users.sourceforge.net>
14 David Schleef <ds@schleef.org>
diff --git a/drivers/staging/rt2870/rt2870.h b/drivers/staging/rt2870/rt2870.h
index a42caa370808..a69cf338e498 100644
--- a/drivers/staging/rt2870/rt2870.h
+++ b/drivers/staging/rt2870/rt2870.h
@@ -145,6 +145,7 @@
145 {USB_DEVICE(0x0789,0x0162)}, /* Logitec */ \ 145 {USB_DEVICE(0x0789,0x0162)}, /* Logitec */ \
146 {USB_DEVICE(0x0789,0x0163)}, /* Logitec */ \ 146 {USB_DEVICE(0x0789,0x0163)}, /* Logitec */ \
147 {USB_DEVICE(0x0789,0x0164)}, /* Logitec */ \ 147 {USB_DEVICE(0x0789,0x0164)}, /* Logitec */ \
148 {USB_DEVICE(0x7392,0x7717)}, /* Edimax */ \
148 { }/* Terminating entry */ \ 149 { }/* Terminating entry */ \
149} 150}
150 151
diff --git a/drivers/staging/rtl8187se/r8180.h b/drivers/staging/rtl8187se/r8180.h
index 12215fc61ddc..db446b7e2e08 100644
--- a/drivers/staging/rtl8187se/r8180.h
+++ b/drivers/staging/rtl8187se/r8180.h
@@ -19,7 +19,7 @@
19#define R8180H 19#define R8180H
20 20
21 21
22#define RTL8180_MODULE_NAME "rtl8180" 22#define RTL8180_MODULE_NAME "r8180"
23#define DMESG(x,a...) printk(KERN_INFO RTL8180_MODULE_NAME ": " x "\n", ## a) 23#define DMESG(x,a...) printk(KERN_INFO RTL8180_MODULE_NAME ": " x "\n", ## a)
24#define DMESGW(x,a...) printk(KERN_WARNING RTL8180_MODULE_NAME ": WW:" x "\n", ## a) 24#define DMESGW(x,a...) printk(KERN_WARNING RTL8180_MODULE_NAME ": WW:" x "\n", ## a)
25#define DMESGE(x,a...) printk(KERN_WARNING RTL8180_MODULE_NAME ": EE:" x "\n", ## a) 25#define DMESGE(x,a...) printk(KERN_WARNING RTL8180_MODULE_NAME ": EE:" x "\n", ## a)
diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c
index 6ecd12de4296..e10413cee0df 100644
--- a/drivers/staging/rtl8187se/r8180_core.c
+++ b/drivers/staging/rtl8187se/r8180_core.c
@@ -640,11 +640,9 @@ void rtl8180_proc_init_one(struct net_device *dev)
640{ 640{
641 struct proc_dir_entry *e; 641 struct proc_dir_entry *e;
642 struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); 642 struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
643 priv->dir_dev = create_proc_entry(dev->name, 643 priv->dir_dev = rtl8180_proc;
644 S_IFDIR | S_IRUGO | S_IXUGO,
645 rtl8180_proc);
646 if (!priv->dir_dev) { 644 if (!priv->dir_dev) {
647 DMESGE("Unable to initialize /proc/net/rtl8180/%s\n", 645 DMESGE("Unable to initialize /proc/net/r8180/%s\n",
648 dev->name); 646 dev->name);
649 return; 647 return;
650 } 648 }
@@ -654,7 +652,7 @@ void rtl8180_proc_init_one(struct net_device *dev)
654 652
655 if (!e) { 653 if (!e) {
656 DMESGE("Unable to initialize " 654 DMESGE("Unable to initialize "
657 "/proc/net/rtl8180/%s/stats-hw\n", 655 "/proc/net/r8180/%s/stats-hw\n",
658 dev->name); 656 dev->name);
659 } 657 }
660 658
@@ -663,7 +661,7 @@ void rtl8180_proc_init_one(struct net_device *dev)
663 661
664 if (!e) { 662 if (!e) {
665 DMESGE("Unable to initialize " 663 DMESGE("Unable to initialize "
666 "/proc/net/rtl8180/%s/stats-rx\n", 664 "/proc/net/r8180/%s/stats-rx\n",
667 dev->name); 665 dev->name);
668 } 666 }
669 667
@@ -673,7 +671,7 @@ void rtl8180_proc_init_one(struct net_device *dev)
673 671
674 if (!e) { 672 if (!e) {
675 DMESGE("Unable to initialize " 673 DMESGE("Unable to initialize "
676 "/proc/net/rtl8180/%s/stats-tx\n", 674 "/proc/net/r8180/%s/stats-tx\n",
677 dev->name); 675 dev->name);
678 } 676 }
679 #if 0 677 #if 0
@@ -702,7 +700,7 @@ void rtl8180_proc_init_one(struct net_device *dev)
702 700
703 if (!e) { 701 if (!e) {
704 DMESGE("Unable to initialize " 702 DMESGE("Unable to initialize "
705 "/proc/net/rtl8180/%s/registers\n", 703 "/proc/net/r8180/%s/registers\n",
706 dev->name); 704 dev->name);
707 } 705 }
708} 706}
@@ -977,13 +975,6 @@ void check_tx_ring(struct net_device *dev, int pri)
977 *tmp & (1<<15)? "ok": "err", *(tmp+4)); 975 *tmp & (1<<15)? "ok": "err", *(tmp+4));
978 } 976 }
979 977
980 DMESG("nic at %d",
981 (nic-nicbegin) / 8 /4);
982 DMESG("tail at %d", ((int)tail - (int)begin) /8 /4);
983 DMESG("head at %d", ((int)head - (int)begin) /8 /4);
984 DMESG("check free desc returns %d", check_nic_enought_desc(dev,pri));
985 DMESG("free desc is %d\n", get_curr_tx_free_desc(dev,pri));
986 //rtl8180_reset(dev);
987 return; 978 return;
988} 979}
989 980
@@ -1736,17 +1727,7 @@ short alloc_tx_desc_ring(struct net_device *dev, int bufsize, int count,
1736 * descriptor's buffer must be 256 byte aligned 1727 * descriptor's buffer must be 256 byte aligned
1737 * we shouldn't be here, since we set DMA mask ! 1728 * we shouldn't be here, since we set DMA mask !
1738 */ 1729 */
1739 DMESGW("Fixing TX alignment"); 1730 WARN(1, "DMA buffer is not aligned\n");
1740 desc = (u32*)((u8*)desc + 256);
1741#if (defined(CONFIG_HIGHMEM64G) || defined(CONFIG_64BIT_PHYS_ADDR))
1742 desc = (u32*)((u64)desc &~ 0xff);
1743 dma_desc = (dma_addr_t)((u8*)dma_desc + 256);
1744 dma_desc = (dma_addr_t)((u64)dma_desc &~ 0xff);
1745#else
1746 desc = (u32*)((u32)desc &~ 0xff);
1747 dma_desc = (dma_addr_t)((u8*)dma_desc + 256);
1748 dma_desc = (dma_addr_t)((u32)dma_desc &~ 0xff);
1749#endif
1750 } 1731 }
1751 tmp=desc; 1732 tmp=desc;
1752 for (i=0;i<count;i++) 1733 for (i=0;i<count;i++)
@@ -1984,18 +1965,7 @@ short alloc_rx_desc_ring(struct net_device *dev, u16 bufsize, int count)
1984 * descriptor's buffer must be 256 byte aligned 1965 * descriptor's buffer must be 256 byte aligned
1985 * should never happen since we specify the DMA mask 1966 * should never happen since we specify the DMA mask
1986 */ 1967 */
1987 1968 WARN(1, "DMA buffer is not aligned\n");
1988 DMESGW("Fixing RX alignment");
1989 desc = (u32*)((u8*)desc + 256);
1990#if (defined(CONFIG_HIGHMEM64G) || defined(CONFIG_64BIT_PHYS_ADDR))
1991 desc = (u32*)((u64)desc &~ 0xff);
1992 dma_desc = (dma_addr_t)((u8*)dma_desc + 256);
1993 dma_desc = (dma_addr_t)((u64)dma_desc &~ 0xff);
1994#else
1995 desc = (u32*)((u32)desc &~ 0xff);
1996 dma_desc = (dma_addr_t)((u8*)dma_desc + 256);
1997 dma_desc = (dma_addr_t)((u32)dma_desc &~ 0xff);
1998#endif
1999 } 1969 }
2000 1970
2001 priv->rxring=desc; 1971 priv->rxring=desc;
diff --git a/drivers/staging/winbond/wbusb.c b/drivers/staging/winbond/wbusb.c
index 9c3f9439f35e..3b2d52819b4c 100644
--- a/drivers/staging/winbond/wbusb.c
+++ b/drivers/staging/winbond/wbusb.c
@@ -386,7 +386,7 @@ static int wb35_probe(struct usb_interface *intf, const struct usb_device_id *id
386 if (err) 386 if (err)
387 goto error_free_hw; 387 goto error_free_hw;
388 388
389 usb_set_intfdata(intf, priv); 389 usb_set_intfdata(intf, dev);
390 390
391 return 0; 391 return 0;
392 392
@@ -415,10 +415,15 @@ static void wb35_hw_halt(struct wbsoft_priv *adapter)
415 415
416static void wb35_disconnect(struct usb_interface *intf) 416static void wb35_disconnect(struct usb_interface *intf)
417{ 417{
418 struct wbsoft_priv *priv = usb_get_intfdata(intf); 418 struct ieee80211_hw *hw = usb_get_intfdata(intf);
419 struct wbsoft_priv *priv = hw->priv;
419 420
420 wb35_hw_halt(priv); 421 wb35_hw_halt(priv);
421 422
423 ieee80211_stop_queues(hw);
424 ieee80211_unregister_hw(hw);
425 ieee80211_free_hw(hw);
426
422 usb_set_intfdata(intf, NULL); 427 usb_set_intfdata(intf, NULL);
423 usb_put_dev(interface_to_usbdev(intf)); 428 usb_put_dev(interface_to_usbdev(intf));
424} 429}
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index 89299a5ce168..0716cdb44cd8 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -27,6 +27,8 @@ obj-$(CONFIG_USB_WUSB) += wusbcore/
27 27
28obj-$(CONFIG_USB_ACM) += class/ 28obj-$(CONFIG_USB_ACM) += class/
29obj-$(CONFIG_USB_PRINTER) += class/ 29obj-$(CONFIG_USB_PRINTER) += class/
30obj-$(CONFIG_USB_WDM) += class/
31obj-$(CONFIG_USB_TMC) += class/
30 32
31obj-$(CONFIG_USB_STORAGE) += storage/ 33obj-$(CONFIG_USB_STORAGE) += storage/
32obj-$(CONFIG_USB) += storage/ 34obj-$(CONFIG_USB) += storage/
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index 6789089e2461..56802d2e994b 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -227,8 +227,14 @@ static ssize_t cxacru_sysfs_showattr_s8(s8 value, char *buf)
227 227
228static ssize_t cxacru_sysfs_showattr_dB(s16 value, char *buf) 228static ssize_t cxacru_sysfs_showattr_dB(s16 value, char *buf)
229{ 229{
230 return snprintf(buf, PAGE_SIZE, "%d.%02u\n", 230 if (likely(value >= 0)) {
231 value / 100, abs(value) % 100); 231 return snprintf(buf, PAGE_SIZE, "%u.%02u\n",
232 value / 100, value % 100);
233 } else {
234 value = -value;
235 return snprintf(buf, PAGE_SIZE, "-%u.%02u\n",
236 value / 100, value % 100);
237 }
232} 238}
233 239
234static ssize_t cxacru_sysfs_showattr_bool(u32 value, char *buf) 240static ssize_t cxacru_sysfs_showattr_bool(u32 value, char *buf)
diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c
index 4154be375c7a..58c4d37d312a 100644
--- a/drivers/usb/gadget/usbstring.c
+++ b/drivers/usb/gadget/usbstring.c
@@ -38,7 +38,7 @@ static int utf8_to_utf16le(const char *s, __le16 *cp, unsigned len)
38 uchar = (c & 0x1f) << 6; 38 uchar = (c & 0x1f) << 6;
39 39
40 c = (u8) *s++; 40 c = (u8) *s++;
41 if ((c & 0xc0) != 0xc0) 41 if ((c & 0xc0) != 0x80)
42 goto fail; 42 goto fail;
43 c &= 0x3f; 43 c &= 0x3f;
44 uchar |= c; 44 uchar |= c;
@@ -49,13 +49,13 @@ static int utf8_to_utf16le(const char *s, __le16 *cp, unsigned len)
49 uchar = (c & 0x0f) << 12; 49 uchar = (c & 0x0f) << 12;
50 50
51 c = (u8) *s++; 51 c = (u8) *s++;
52 if ((c & 0xc0) != 0xc0) 52 if ((c & 0xc0) != 0x80)
53 goto fail; 53 goto fail;
54 c &= 0x3f; 54 c &= 0x3f;
55 uchar |= c << 6; 55 uchar |= c << 6;
56 56
57 c = (u8) *s++; 57 c = (u8) *s++;
58 if ((c & 0xc0) != 0xc0) 58 if ((c & 0xc0) != 0x80)
59 goto fail; 59 goto fail;
60 c &= 0x3f; 60 c &= 0x3f;
61 uchar |= c; 61 uchar |= c;
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 8100f1d25904..0ab8474b00cb 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -56,6 +56,7 @@ static __u16 vendor = FTDI_VID;
56static __u16 product; 56static __u16 product;
57 57
58struct ftdi_private { 58struct ftdi_private {
59 struct kref kref;
59 ftdi_chip_type_t chip_type; 60 ftdi_chip_type_t chip_type;
60 /* type of device, either SIO or FT8U232AM */ 61 /* type of device, either SIO or FT8U232AM */
61 int baud_base; /* baud base clock for divisor setting */ 62 int baud_base; /* baud base clock for divisor setting */
@@ -669,6 +670,8 @@ static struct usb_device_id id_table_combined [] = {
669 { USB_DEVICE(ADI_VID, ADI_GNICE_PID), 670 { USB_DEVICE(ADI_VID, ADI_GNICE_PID),
670 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 671 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
671 { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) }, 672 { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) },
673 { USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID),
674 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
672 { }, /* Optional parameter entry */ 675 { }, /* Optional parameter entry */
673 { } /* Terminating entry */ 676 { } /* Terminating entry */
674}; 677};
@@ -1352,6 +1355,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
1352 return -ENOMEM; 1355 return -ENOMEM;
1353 } 1356 }
1354 1357
1358 kref_init(&priv->kref);
1355 spin_lock_init(&priv->rx_lock); 1359 spin_lock_init(&priv->rx_lock);
1356 spin_lock_init(&priv->tx_lock); 1360 spin_lock_init(&priv->tx_lock);
1357 init_waitqueue_head(&priv->delta_msr_wait); 1361 init_waitqueue_head(&priv->delta_msr_wait);
@@ -1468,6 +1472,13 @@ static void ftdi_shutdown(struct usb_serial *serial)
1468 dbg("%s", __func__); 1472 dbg("%s", __func__);
1469} 1473}
1470 1474
1475static void ftdi_sio_priv_release(struct kref *k)
1476{
1477 struct ftdi_private *priv = container_of(k, struct ftdi_private, kref);
1478
1479 kfree(priv);
1480}
1481
1471static int ftdi_sio_port_remove(struct usb_serial_port *port) 1482static int ftdi_sio_port_remove(struct usb_serial_port *port)
1472{ 1483{
1473 struct ftdi_private *priv = usb_get_serial_port_data(port); 1484 struct ftdi_private *priv = usb_get_serial_port_data(port);
@@ -1482,7 +1493,7 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port)
1482 1493
1483 if (priv) { 1494 if (priv) {
1484 usb_set_serial_port_data(port, NULL); 1495 usb_set_serial_port_data(port, NULL);
1485 kfree(priv); 1496 kref_put(&priv->kref, ftdi_sio_priv_release);
1486 } 1497 }
1487 1498
1488 return 0; 1499 return 0;
@@ -1547,7 +1558,8 @@ static int ftdi_open(struct tty_struct *tty,
1547 dev_err(&port->dev, 1558 dev_err(&port->dev,
1548 "%s - failed submitting read urb, error %d\n", 1559 "%s - failed submitting read urb, error %d\n",
1549 __func__, result); 1560 __func__, result);
1550 1561 else
1562 kref_get(&priv->kref);
1551 1563
1552 return result; 1564 return result;
1553} /* ftdi_open */ 1565} /* ftdi_open */
@@ -1589,11 +1601,11 @@ static void ftdi_close(struct tty_struct *tty,
1589 mutex_unlock(&port->serial->disc_mutex); 1601 mutex_unlock(&port->serial->disc_mutex);
1590 1602
1591 /* cancel any scheduled reading */ 1603 /* cancel any scheduled reading */
1592 cancel_delayed_work(&priv->rx_work); 1604 cancel_delayed_work_sync(&priv->rx_work);
1593 flush_scheduled_work();
1594 1605
1595 /* shutdown our bulk read */ 1606 /* shutdown our bulk read */
1596 usb_kill_urb(port->read_urb); 1607 usb_kill_urb(port->read_urb);
1608 kref_put(&priv->kref, ftdi_sio_priv_release);
1597} /* ftdi_close */ 1609} /* ftdi_close */
1598 1610
1599 1611
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index c09f658a448b..12330fa1c095 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -920,6 +920,12 @@
920#define JETI_SPC1201_PID 0x04b2 920#define JETI_SPC1201_PID 0x04b2
921 921
922/* 922/*
923 * Marvell SheevaPlug
924 */
925#define MARVELL_VID 0x9e88
926#define MARVELL_SHEEVAPLUG_PID 0x9e8f
927
928/*
923 * BmRequestType: 1100 0000b 929 * BmRequestType: 1100 0000b
924 * bRequest: FTDI_E2_READ 930 * bRequest: FTDI_E2_READ
925 * wValue: 0 931 * wValue: 0
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index fa65a3b08601..4b8b69045fe6 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -160,8 +160,9 @@ UNUSUAL_DEV( 0x0420, 0x0001, 0x0100, 0x0100,
160 US_SC_DEVICE, US_PR_DEVICE, NULL, 160 US_SC_DEVICE, US_PR_DEVICE, NULL,
161 US_FL_IGNORE_RESIDUE ), 161 US_FL_IGNORE_RESIDUE ),
162 162
163/* Reported by Andrew Nayenko <relan@bk.ru> */ 163/* Reported by Andrew Nayenko <relan@bk.ru>
164UNUSUAL_DEV( 0x0421, 0x0019, 0x0592, 0x0592, 164 * Updated for new firmware by Phillip Potter <phillipinda@hotmail.com> */
165UNUSUAL_DEV( 0x0421, 0x0019, 0x0592, 0x0610,
165 "Nokia", 166 "Nokia",
166 "Nokia 6288", 167 "Nokia 6288",
167 US_SC_DEVICE, US_PR_DEVICE, NULL, 168 US_SC_DEVICE, US_PR_DEVICE, NULL,
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 93258e114517..8083d862ebc5 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -1128,13 +1128,6 @@ config FB_INTEL
1128 830M/845G/852GM/855GM/865G/915G/915GM/945G/945GM/965G/965GM chipsets. 1128 830M/845G/852GM/855GM/865G/915G/915GM/945G/945GM/965G/965GM chipsets.
1129 Say Y if you have and plan to use such a board. 1129 Say Y if you have and plan to use such a board.
1130 1130
1131 If you say Y here and want DDC/I2C support you must first say Y to
1132 "I2C support" and "I2C bit-banging support" in the character devices
1133 section.
1134
1135 If you say M here then "I2C support" and "I2C bit-banging support"
1136 can be build either as modules or built-in.
1137
1138 To compile this driver as a module, choose M here: the 1131 To compile this driver as a module, choose M here: the
1139 module will be called intelfb. 1132 module will be called intelfb.
1140 1133
@@ -1207,11 +1200,10 @@ config FB_MATROX_G
1207 pixel and 32 bpp packed pixel. You can also use font widths 1200 pixel and 32 bpp packed pixel. You can also use font widths
1208 different from 8. 1201 different from 8.
1209 1202
1210 If you need support for G400 secondary head, you must first say Y to 1203 If you need support for G400 secondary head, you must say Y to
1211 "I2C support" in the character devices section, and then to 1204 "Matrox I2C support" and "G400 second head support" right below.
1212 "Matrox I2C support" and "G400 second head support" here in the 1205 G450/G550 secondary head and digital output are supported without
1213 framebuffer section. G450/G550 secondary head and digital output 1206 additional modules.
1214 are supported without additional modules.
1215 1207
1216 The driver starts in monitor mode. You must use the matroxset tool 1208 The driver starts in monitor mode. You must use the matroxset tool
1217 (available at <ftp://platan.vc.cvut.cz/pub/linux/matrox-latest/>) to 1209 (available at <ftp://platan.vc.cvut.cz/pub/linux/matrox-latest/>) to
@@ -1310,13 +1302,6 @@ config FB_RADEON
1310 a framebuffer device. There are both PCI and AGP versions. You 1302 a framebuffer device. There are both PCI and AGP versions. You
1311 don't need to choose this to run the Radeon in plain VGA mode. 1303 don't need to choose this to run the Radeon in plain VGA mode.
1312 1304
1313 If you say Y here and want DDC/I2C support you must first say Y to
1314 "I2C support" and "I2C bit-banging support" in the character devices
1315 section.
1316
1317 If you say M here then "I2C support" and "I2C bit-banging support"
1318 can be build either as modules or built-in.
1319
1320 There is a product page at 1305 There is a product page at
1321 http://apps.ati.com/ATIcompare/ 1306 http://apps.ati.com/ATIcompare/
1322 1307
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 0dbd6c68d76b..d8d0be5151e3 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -56,7 +56,6 @@ obj-$(CONFIG_FB_CT65550) += chipsfb.o
56obj-$(CONFIG_FB_IMSTT) += imsttfb.o 56obj-$(CONFIG_FB_IMSTT) += imsttfb.o
57obj-$(CONFIG_FB_FM2) += fm2fb.o 57obj-$(CONFIG_FB_FM2) += fm2fb.o
58obj-$(CONFIG_FB_VT8623) += vt8623fb.o 58obj-$(CONFIG_FB_VT8623) += vt8623fb.o
59obj-$(CONFIG_FB_CYBLA) += cyblafb.o
60obj-$(CONFIG_FB_TRIDENT) += tridentfb.o 59obj-$(CONFIG_FB_TRIDENT) += tridentfb.o
61obj-$(CONFIG_FB_LE80578) += vermilion/ 60obj-$(CONFIG_FB_LE80578) += vermilion/
62obj-$(CONFIG_FB_S3) += s3fb.o 61obj-$(CONFIG_FB_S3) += s3fb.o
diff --git a/drivers/video/cfbfillrect.c b/drivers/video/cfbfillrect.c
index 64b35766b2a2..ba9f58b2a5e8 100644
--- a/drivers/video/cfbfillrect.c
+++ b/drivers/video/cfbfillrect.c
@@ -9,10 +9,6 @@
9 * 9 *
10 * NOTES: 10 * NOTES:
11 * 11 *
12 * The code for depths like 24 that don't have integer number of pixels per
13 * long is broken and needs to be fixed. For now I turned these types of
14 * mode off.
15 *
16 * Also need to add code to deal with cards endians that are different than 12 * Also need to add code to deal with cards endians that are different than
17 * the native cpu endians. I also need to deal with MSB position in the word. 13 * the native cpu endians. I also need to deal with MSB position in the word.
18 * 14 *
@@ -139,7 +135,7 @@ bitfill_unaligned(struct fb_info *p, unsigned long __iomem *dst, int dst_idx,
139 135
140 // Trailing bits 136 // Trailing bits
141 if (last) 137 if (last)
142 FB_WRITEL(comp(pat, FB_READL(dst), first), dst); 138 FB_WRITEL(comp(pat, FB_READL(dst), last), dst);
143 } 139 }
144} 140}
145 141
@@ -281,7 +277,7 @@ bitfill_unaligned_rev(struct fb_info *p, unsigned long __iomem *dst,
281 277
282void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect) 278void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
283{ 279{
284 unsigned long pat, fg; 280 unsigned long pat, pat2, fg;
285 unsigned long width = rect->width, height = rect->height; 281 unsigned long width = rect->width, height = rect->height;
286 int bits = BITS_PER_LONG, bytes = bits >> 3; 282 int bits = BITS_PER_LONG, bytes = bits >> 3;
287 u32 bpp = p->var.bits_per_pixel; 283 u32 bpp = p->var.bits_per_pixel;
@@ -297,7 +293,7 @@ void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
297 else 293 else
298 fg = rect->color; 294 fg = rect->color;
299 295
300 pat = pixel_to_pat( bpp, fg); 296 pat = pixel_to_pat(bpp, fg);
301 297
302 dst = (unsigned long __iomem *)((unsigned long)p->screen_base & ~(bytes-1)); 298 dst = (unsigned long __iomem *)((unsigned long)p->screen_base & ~(bytes-1));
303 dst_idx = ((unsigned long)p->screen_base & (bytes - 1))*8; 299 dst_idx = ((unsigned long)p->screen_base & (bytes - 1))*8;
@@ -333,17 +329,16 @@ void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
333 dst_idx += p->fix.line_length*8; 329 dst_idx += p->fix.line_length*8;
334 } 330 }
335 } else { 331 } else {
336 int right; 332 int right, r;
337 int r;
338 int rot = (left-dst_idx) % bpp;
339 void (*fill_op)(struct fb_info *p, unsigned long __iomem *dst, 333 void (*fill_op)(struct fb_info *p, unsigned long __iomem *dst,
340 int dst_idx, unsigned long pat, int left, 334 int dst_idx, unsigned long pat, int left,
341 int right, unsigned n, int bits) = NULL; 335 int right, unsigned n, int bits) = NULL;
342 336#ifdef __LITTLE_ENDIAN
343 /* rotate pattern to correct start position */ 337 right = left;
344 pat = pat << rot | pat >> (bpp-rot); 338 left = bpp - right;
345 339#else
346 right = bpp-left; 340 right = bpp - left;
341#endif
347 switch (rect->rop) { 342 switch (rect->rop) {
348 case ROP_XOR: 343 case ROP_XOR:
349 fill_op = bitfill_unaligned_rev; 344 fill_op = bitfill_unaligned_rev;
@@ -352,17 +347,18 @@ void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
352 fill_op = bitfill_unaligned; 347 fill_op = bitfill_unaligned;
353 break; 348 break;
354 default: 349 default:
355 printk( KERN_ERR "cfb_fillrect(): unknown rop, defaulting to ROP_COPY\n"); 350 printk(KERN_ERR "cfb_fillrect(): unknown rop, defaulting to ROP_COPY\n");
356 fill_op = bitfill_unaligned; 351 fill_op = bitfill_unaligned;
357 break; 352 break;
358 } 353 }
359 while (height--) { 354 while (height--) {
360 dst += dst_idx >> (ffs(bits) - 1); 355 dst += dst_idx / bits;
361 dst_idx &= (bits - 1); 356 dst_idx &= (bits - 1);
362 fill_op(p, dst, dst_idx, pat, left, right, 357 r = dst_idx % bpp;
358 /* rotate pattern to the correct start position */
359 pat2 = le_long_to_cpu(rolx(cpu_to_le_long(pat), r, bpp));
360 fill_op(p, dst, dst_idx, pat2, left, right,
363 width*bpp, bits); 361 width*bpp, bits);
364 r = (p->fix.line_length*8) % bpp;
365 pat = pat << (bpp-r) | pat >> r;
366 dst_idx += p->fix.line_length*8; 362 dst_idx += p->fix.line_length*8;
367 } 363 }
368 } 364 }
diff --git a/drivers/video/fb_draw.h b/drivers/video/fb_draw.h
index 1db622192bde..04c01faaf772 100644
--- a/drivers/video/fb_draw.h
+++ b/drivers/video/fb_draw.h
@@ -33,11 +33,11 @@ pixel_to_pat( u32 bpp, u32 pixel)
33 case 8: 33 case 8:
34 return 0x0101010101010101ul*pixel; 34 return 0x0101010101010101ul*pixel;
35 case 12: 35 case 12:
36 return 0x0001001001001001ul*pixel; 36 return 0x1001001001001001ul*pixel;
37 case 16: 37 case 16:
38 return 0x0001000100010001ul*pixel; 38 return 0x0001000100010001ul*pixel;
39 case 24: 39 case 24:
40 return 0x0000000001000001ul*pixel; 40 return 0x0001000001000001ul*pixel;
41 case 32: 41 case 32:
42 return 0x0000000100000001ul*pixel; 42 return 0x0000000100000001ul*pixel;
43 default: 43 default:
@@ -58,11 +58,11 @@ pixel_to_pat( u32 bpp, u32 pixel)
58 case 8: 58 case 8:
59 return 0x01010101ul*pixel; 59 return 0x01010101ul*pixel;
60 case 12: 60 case 12:
61 return 0x00001001ul*pixel; 61 return 0x01001001ul*pixel;
62 case 16: 62 case 16:
63 return 0x00010001ul*pixel; 63 return 0x00010001ul*pixel;
64 case 24: 64 case 24:
65 return 0x00000001ul*pixel; 65 return 0x01000001ul*pixel;
66 case 32: 66 case 32:
67 return 0x00000001ul*pixel; 67 return 0x00000001ul*pixel;
68 default: 68 default:
@@ -167,4 +167,17 @@ static inline unsigned long fb_rev_pixels_in_long(unsigned long val,
167 167
168#endif /* CONFIG_FB_CFB_REV_PIXELS_IN_BYTE */ 168#endif /* CONFIG_FB_CFB_REV_PIXELS_IN_BYTE */
169 169
170#define cpu_to_le_long _cpu_to_le_long(BITS_PER_LONG)
171#define _cpu_to_le_long(x) __cpu_to_le_long(x)
172#define __cpu_to_le_long(x) cpu_to_le##x
173
174#define le_long_to_cpu _le_long_to_cpu(BITS_PER_LONG)
175#define _le_long_to_cpu(x) __le_long_to_cpu(x)
176#define __le_long_to_cpu(x) le##x##_to_cpu
177
178static inline unsigned long rolx(unsigned long word, unsigned int shift, unsigned int x)
179{
180 return (word << shift) | (word >> (x - shift));
181}
182
170#endif /* FB_DRAW_H */ 183#endif /* FB_DRAW_H */
diff --git a/drivers/video/gbefb.c b/drivers/video/gbefb.c
index fe5b519860b1..1a83709f9611 100644
--- a/drivers/video/gbefb.c
+++ b/drivers/video/gbefb.c
@@ -75,7 +75,7 @@ struct gbefb_par {
75static unsigned int gbe_mem_size = CONFIG_FB_GBE_MEM * 1024*1024; 75static unsigned int gbe_mem_size = CONFIG_FB_GBE_MEM * 1024*1024;
76static void *gbe_mem; 76static void *gbe_mem;
77static dma_addr_t gbe_dma_addr; 77static dma_addr_t gbe_dma_addr;
78unsigned long gbe_mem_phys; 78static unsigned long gbe_mem_phys;
79 79
80static struct { 80static struct {
81 uint16_t *cpu; 81 uint16_t *cpu;
@@ -185,8 +185,8 @@ static struct fb_videomode default_mode_LCD __initdata = {
185 .vmode = FB_VMODE_NONINTERLACED, 185 .vmode = FB_VMODE_NONINTERLACED,
186}; 186};
187 187
188struct fb_videomode *default_mode __initdata = &default_mode_CRT; 188static struct fb_videomode *default_mode __initdata = &default_mode_CRT;
189struct fb_var_screeninfo *default_var __initdata = &default_var_CRT; 189static struct fb_var_screeninfo *default_var __initdata = &default_var_CRT;
190 190
191static int flat_panel_enabled = 0; 191static int flat_panel_enabled = 0;
192 192
@@ -205,7 +205,7 @@ static void gbe_reset(void)
205 * console. 205 * console.
206 */ 206 */
207 207
208void gbe_turn_off(void) 208static void gbe_turn_off(void)
209{ 209{
210 int i; 210 int i;
211 unsigned int val, x, y, vpixen_off; 211 unsigned int val, x, y, vpixen_off;
@@ -1097,7 +1097,7 @@ static void gbefb_create_sysfs(struct device *dev)
1097 * Initialization 1097 * Initialization
1098 */ 1098 */
1099 1099
1100int __init gbefb_setup(char *options) 1100static int __init gbefb_setup(char *options)
1101{ 1101{
1102 char *this_opt; 1102 char *this_opt;
1103 1103
@@ -1283,7 +1283,7 @@ static struct platform_driver gbefb_driver = {
1283 1283
1284static struct platform_device *gbefb_device; 1284static struct platform_device *gbefb_device;
1285 1285
1286int __init gbefb_init(void) 1286static int __init gbefb_init(void)
1287{ 1287{
1288 int ret = platform_driver_register(&gbefb_driver); 1288 int ret = platform_driver_register(&gbefb_driver);
1289 if (!ret) { 1289 if (!ret) {
@@ -1301,7 +1301,7 @@ int __init gbefb_init(void)
1301 return ret; 1301 return ret;
1302} 1302}
1303 1303
1304void __exit gbefb_exit(void) 1304static void __exit gbefb_exit(void)
1305{ 1305{
1306 platform_device_unregister(gbefb_device); 1306 platform_device_unregister(gbefb_device);
1307 platform_driver_unregister(&gbefb_driver); 1307 platform_driver_unregister(&gbefb_driver);
diff --git a/drivers/video/sysfillrect.c b/drivers/video/sysfillrect.c
index f94d6b6e29ee..33ee3d34f9d2 100644
--- a/drivers/video/sysfillrect.c
+++ b/drivers/video/sysfillrect.c
@@ -124,7 +124,7 @@ bitfill_unaligned(struct fb_info *p, unsigned long *dst, int dst_idx,
124 124
125 /* Trailing bits */ 125 /* Trailing bits */
126 if (last) 126 if (last)
127 *dst = comp(pat, *dst, first); 127 *dst = comp(pat, *dst, last);
128 } 128 }
129} 129}
130 130
@@ -242,7 +242,7 @@ bitfill_unaligned_rev(struct fb_info *p, unsigned long *dst, int dst_idx,
242 242
243void sys_fillrect(struct fb_info *p, const struct fb_fillrect *rect) 243void sys_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
244{ 244{
245 unsigned long pat, fg; 245 unsigned long pat, pat2, fg;
246 unsigned long width = rect->width, height = rect->height; 246 unsigned long width = rect->width, height = rect->height;
247 int bits = BITS_PER_LONG, bytes = bits >> 3; 247 int bits = BITS_PER_LONG, bytes = bits >> 3;
248 u32 bpp = p->var.bits_per_pixel; 248 u32 bpp = p->var.bits_per_pixel;
@@ -292,17 +292,16 @@ void sys_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
292 dst_idx += p->fix.line_length*8; 292 dst_idx += p->fix.line_length*8;
293 } 293 }
294 } else { 294 } else {
295 int right; 295 int right, r;
296 int r;
297 int rot = (left-dst_idx) % bpp;
298 void (*fill_op)(struct fb_info *p, unsigned long *dst, 296 void (*fill_op)(struct fb_info *p, unsigned long *dst,
299 int dst_idx, unsigned long pat, int left, 297 int dst_idx, unsigned long pat, int left,
300 int right, unsigned n, int bits) = NULL; 298 int right, unsigned n, int bits) = NULL;
301 299#ifdef __LITTLE_ENDIAN
302 /* rotate pattern to correct start position */ 300 right = left;
303 pat = pat << rot | pat >> (bpp-rot); 301 left = bpp - right;
304 302#else
305 right = bpp-left; 303 right = bpp - left;
304#endif
306 switch (rect->rop) { 305 switch (rect->rop) {
307 case ROP_XOR: 306 case ROP_XOR:
308 fill_op = bitfill_unaligned_rev; 307 fill_op = bitfill_unaligned_rev;
@@ -311,18 +310,19 @@ void sys_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
311 fill_op = bitfill_unaligned; 310 fill_op = bitfill_unaligned;
312 break; 311 break;
313 default: 312 default:
314 printk(KERN_ERR "cfb_fillrect(): unknown rop, " 313 printk(KERN_ERR "sys_fillrect(): unknown rop, "
315 "defaulting to ROP_COPY\n"); 314 "defaulting to ROP_COPY\n");
316 fill_op = bitfill_unaligned; 315 fill_op = bitfill_unaligned;
317 break; 316 break;
318 } 317 }
319 while (height--) { 318 while (height--) {
320 dst += dst_idx >> (ffs(bits) - 1); 319 dst += dst_idx / bits;
321 dst_idx &= (bits - 1); 320 dst_idx &= (bits - 1);
322 fill_op(p, dst, dst_idx, pat, left, right, 321 r = dst_idx % bpp;
322 /* rotate pattern to the correct start position */
323 pat2 = le_long_to_cpu(rolx(cpu_to_le_long(pat), r, bpp));
324 fill_op(p, dst, dst_idx, pat2, left, right,
323 width*bpp, bits); 325 width*bpp, bits);
324 r = (p->fix.line_length*8) % bpp;
325 pat = pat << (bpp-r) | pat >> r;
326 dst_idx += p->fix.line_length*8; 326 dst_idx += p->fix.line_length*8;
327 } 327 }
328 } 328 }
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index e327b84820d2..a0fec298216e 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -2103,7 +2103,7 @@ static void viafb_remove_proc(struct proc_dir_entry *viafb_entry)
2103 2103
2104static int __devinit via_pci_probe(void) 2104static int __devinit via_pci_probe(void)
2105{ 2105{
2106 unsigned int default_xres, default_yres; 2106 unsigned long default_xres, default_yres;
2107 char *tmpc, *tmpm; 2107 char *tmpc, *tmpm;
2108 char *tmpc_sec, *tmpm_sec; 2108 char *tmpc_sec, *tmpm_sec;
2109 int vmode_index; 2109 int vmode_index;
@@ -2196,8 +2196,8 @@ static int __devinit via_pci_probe(void)
2196 viafb_FB_MM = viaparinfo->fbmem_virt; 2196 viafb_FB_MM = viaparinfo->fbmem_virt;
2197 tmpm = viafb_mode; 2197 tmpm = viafb_mode;
2198 tmpc = strsep(&tmpm, "x"); 2198 tmpc = strsep(&tmpm, "x");
2199 strict_strtoul(tmpc, 0, (unsigned long *)&default_xres); 2199 strict_strtoul(tmpc, 0, &default_xres);
2200 strict_strtoul(tmpm, 0, (unsigned long *)&default_yres); 2200 strict_strtoul(tmpm, 0, &default_yres);
2201 2201
2202 vmode_index = viafb_get_mode_index(default_xres, default_yres, 0); 2202 vmode_index = viafb_get_mode_index(default_xres, default_yres, 0);
2203 DEBUG_MSG(KERN_INFO "0->index=%d\n", vmode_index); 2203 DEBUG_MSG(KERN_INFO "0->index=%d\n", vmode_index);
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index efa4b363ce72..f5bbd9e83416 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -513,7 +513,8 @@ static ssize_t show_target(struct sys_device *dev, struct sysdev_attribute *attr
513 char *buf) 513 char *buf)
514{ 514{
515 return sprintf(buf, "%llu\n", 515 return sprintf(buf, "%llu\n",
516 (u64)balloon_stats.target_pages << PAGE_SHIFT); 516 (unsigned long long)balloon_stats.target_pages
517 << PAGE_SHIFT);
517} 518}
518 519
519static ssize_t store_target(struct sys_device *dev, 520static ssize_t store_target(struct sys_device *dev,