aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-04-03 17:33:42 -0400
committerDavid S. Miller <davem@davemloft.net>2008-04-03 17:33:42 -0400
commit3bb5da3837cc1aa17736b05139c9a22c3794851a (patch)
treec92d5684a866542b1cb20641607ac1643ce03a47 /drivers
parent7feb49c82a74bc7c091b8ab2a3f96baa33d08ece (diff)
parent9597362d354f8655ece324b01d0c640a0e99c077 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/asus_acpi.c2
-rw-r--r--drivers/acpi/battery.c11
-rw-r--r--drivers/acpi/dock.c1
-rw-r--r--drivers/acpi/ec.c11
-rw-r--r--drivers/acpi/pci_irq.c4
-rw-r--r--drivers/acpi/processor_idle.c19
-rw-r--r--drivers/acpi/sbshc.c1
-rw-r--r--drivers/acpi/scan.c18
-rw-r--r--drivers/acpi/sleep/main.c71
-rw-r--r--drivers/acpi/video.c60
-rw-r--r--drivers/ata/Kconfig1
-rw-r--r--drivers/ata/ahci.c6
-rw-r--r--drivers/ata/libata-core.c48
-rw-r--r--drivers/ata/libata-eh.c2
-rw-r--r--drivers/ata/libata-scsi.c14
-rw-r--r--drivers/ata/pata_it821x.c2
-rw-r--r--drivers/ata/pata_sil680.c6
-rw-r--r--drivers/ata/sata_promise.c109
-rw-r--r--drivers/base/core.c5
-rw-r--r--drivers/base/driver.c5
-rw-r--r--drivers/block/Kconfig10
-rw-r--r--drivers/block/Makefile1
-rw-r--r--drivers/block/nbd.c6
-rw-r--r--drivers/block/ps2esdi.c1079
-rw-r--r--drivers/char/drm/ati_pcigart.c102
-rw-r--r--drivers/char/drm/drmP.h3
-rw-r--r--drivers/char/drm/drm_fops.c7
-rw-r--r--drivers/char/drm/drm_lock.c35
-rw-r--r--drivers/char/drm/drm_pciids.h7
-rw-r--r--drivers/char/drm/drm_scatter.c11
-rw-r--r--drivers/char/drm/drm_vm.c20
-rw-r--r--drivers/char/drm/i915_dma.c3
-rw-r--r--drivers/char/drm/r128_cce.c1
-rw-r--r--drivers/char/drm/r300_cmdbuf.c54
-rw-r--r--drivers/char/drm/radeon_cp.c1
-rw-r--r--drivers/char/drm/radeon_drm.h12
-rw-r--r--drivers/char/drm/radeon_mem.c8
-rw-r--r--drivers/char/drm/via_dma.c59
-rw-r--r--drivers/char/drm/via_dmablit.c2
-rw-r--r--drivers/char/hw_random/Kconfig9
-rw-r--r--drivers/char/ip2/i2lib.c12
-rw-r--r--drivers/char/n_tty.c2
-rw-r--r--drivers/char/nozomi.c20
-rw-r--r--drivers/char/rio/riotable.c4
-rw-r--r--drivers/char/rio/riotty.c4
-rw-r--r--drivers/char/rocket.c37
-rw-r--r--drivers/char/rocket_int.h83
-rw-r--r--drivers/cpuidle/cpuidle.c4
-rw-r--r--drivers/cpuidle/sysfs.c10
-rw-r--r--drivers/crypto/hifn_795x.c28
-rw-r--r--drivers/dma/fsldma.c30
-rw-r--r--drivers/dma/fsldma.h48
-rw-r--r--drivers/dma/ioat_dca.c4
-rw-r--r--drivers/firewire/fw-ohci.c9
-rw-r--r--drivers/firewire/fw-transaction.c6
-rw-r--r--drivers/hid/hid-core.c2
-rw-r--r--drivers/hid/hid-input.c22
-rw-r--r--drivers/hid/usbhid/hid-core.c2
-rw-r--r--drivers/hid/usbhid/hid-quirks.c6
-rw-r--r--drivers/hwmon/Kconfig5
-rw-r--r--drivers/hwmon/ibmpex.c13
-rw-r--r--drivers/hwmon/w83781d.c21
-rw-r--r--drivers/i2c/busses/Kconfig2
-rw-r--r--drivers/i2c/busses/i2c-omap.c36
-rw-r--r--drivers/i2c/i2c-core.c4
-rw-r--r--drivers/ide/arm/ide_arm.c2
-rw-r--r--drivers/ide/cris/ide-cris.c2
-rw-r--r--drivers/ide/h8300/ide-h8300.c3
-rw-r--r--drivers/ide/ide-iops.c3
-rw-r--r--drivers/ide/ide-lib.c10
-rw-r--r--drivers/ide/ide-pnp.c2
-rw-r--r--drivers/ide/ide-probe.c5
-rw-r--r--drivers/ide/ide-tape.c5
-rw-r--r--drivers/ide/ide-taskfile.c36
-rw-r--r--drivers/ide/ide.c20
-rw-r--r--drivers/ide/legacy/buddha.c2
-rw-r--r--drivers/ide/legacy/falconide.c2
-rw-r--r--drivers/ide/legacy/gayle.c2
-rw-r--r--drivers/ide/legacy/macide.c2
-rw-r--r--drivers/ide/legacy/q40ide.c2
-rw-r--r--drivers/ide/pci/cmd640.c2
-rw-r--r--drivers/ide/ppc/mpc8xx.c2
-rw-r--r--drivers/ide/ppc/pmac.c2
-rw-r--r--drivers/infiniband/core/addr.c8
-rw-r--r--drivers/infiniband/core/cm.c2
-rw-r--r--drivers/infiniband/core/cma.c24
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_cm.c2
-rw-r--r--drivers/infiniband/hw/nes/nes_cm.c3
-rw-r--r--drivers/input/apm-power.c7
-rw-r--r--drivers/input/evdev.c3
-rw-r--r--drivers/input/joydev.c3
-rw-r--r--drivers/input/keyboard/pxa27x_keypad.c6
-rw-r--r--drivers/input/misc/cobalt_btns.c16
-rw-r--r--drivers/input/misc/ixp4xx-beeper.c1
-rw-r--r--drivers/input/mouse/alps.c5
-rw-r--r--drivers/input/mousedev.c3
-rw-r--r--drivers/input/serio/i8042-snirm.h75
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h7
-rw-r--r--drivers/input/serio/i8042.c3
-rw-r--r--drivers/input/serio/i8042.h2
-rw-r--r--drivers/input/tablet/wacom.h6
-rw-r--r--drivers/input/tablet/wacom_sys.c6
-rw-r--r--drivers/input/tablet/wacom_wac.c31
-rw-r--r--drivers/input/tablet/wacom_wac.h1
-rw-r--r--drivers/input/touchscreen/ads7846.c2
-rw-r--r--drivers/leds/leds-gpio.c20
-rw-r--r--drivers/lguest/Makefile8
-rw-r--r--drivers/lguest/core.c18
-rw-r--r--drivers/lguest/hypercalls.c11
-rw-r--r--drivers/lguest/interrupts_and_traps.c7
-rw-r--r--drivers/lguest/lguest_device.c11
-rw-r--r--drivers/lguest/lguest_user.c32
-rw-r--r--drivers/lguest/page_tables.c32
-rw-r--r--drivers/lguest/x86/core.c33
-rw-r--r--drivers/lguest/x86/switcher_32.S8
-rw-r--r--drivers/md/dm-crypt.c58
-rw-r--r--drivers/md/dm-io.c2
-rw-r--r--drivers/md/dm-raid1.c4
-rw-r--r--drivers/md/dm-snap.c2
-rw-r--r--drivers/md/kcopyd.c10
-rw-r--r--drivers/md/kcopyd.h4
-rw-r--r--drivers/md/md.c12
-rw-r--r--drivers/md/raid5.c6
-rw-r--r--drivers/media/common/saa7146_core.c13
-rw-r--r--drivers/media/common/saa7146_fops.c2
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.c4
-rw-r--r--drivers/media/dvb/dvb-usb/opera1.c2
-rw-r--r--drivers/media/radio/radio-cadet.c6
-rw-r--r--drivers/media/video/Kconfig4
-rw-r--r--drivers/media/video/adv7170.c2
-rw-r--r--drivers/media/video/adv7175.c2
-rw-r--r--drivers/media/video/bt819.c2
-rw-r--r--drivers/media/video/bt856.c2
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c32
-rw-r--r--drivers/media/video/cx23885/cx23885-cards.c6
-rw-r--r--drivers/media/video/cx23885/cx23885-core.c134
-rw-r--r--drivers/media/video/cx88/cx88-cards.c5
-rw-r--r--drivers/media/video/cx88/cx88-video.c2
-rw-r--r--drivers/media/video/dpc7146.c2
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.c7
-rw-r--r--drivers/media/video/ivtv/ivtv-firmware.c8
-rw-r--r--drivers/media/video/mt20xx.c2
-rw-r--r--drivers/media/video/mxb.c5
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-ctrl.c4
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-io.c2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-ioread.c2
-rw-r--r--drivers/media/video/pwc/pwc-if.c7
-rw-r--r--drivers/media/video/saa7110.c4
-rw-r--r--drivers/media/video/saa7111.c2
-rw-r--r--drivers/media/video/saa7114.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c41
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c5
-rw-r--r--drivers/media/video/saa7185.c2
-rw-r--r--drivers/media/video/tda9840.c2
-rw-r--r--drivers/media/video/tea6415c.c2
-rw-r--r--drivers/media/video/tea6420.c2
-rw-r--r--drivers/media/video/tvp5150.c8
-rw-r--r--drivers/media/video/usbvideo/usbvideo.c9
-rw-r--r--drivers/media/video/v4l1-compat.c50
-rw-r--r--drivers/media/video/v4l2-int-device.c2
-rw-r--r--drivers/media/video/zoran_driver.c2
-rw-r--r--drivers/media/video/zr364xx.c2
-rw-r--r--drivers/memstick/core/memstick.c9
-rw-r--r--drivers/memstick/core/mspro_block.c94
-rw-r--r--drivers/memstick/host/jmb38x_ms.c113
-rw-r--r--drivers/memstick/host/tifm_ms.c21
-rw-r--r--drivers/message/fusion/mptbase.c276
-rw-r--r--drivers/message/fusion/mptscsih.c11
-rw-r--r--drivers/mfd/asic3.c4
-rw-r--r--drivers/misc/fujitsu-laptop.c2
-rw-r--r--drivers/misc/ibmasm/module.c2
-rw-r--r--drivers/misc/lkdtm.c2
-rw-r--r--drivers/mmc/core/Makefile2
-rw-r--r--drivers/mmc/core/bus.c23
-rw-r--r--drivers/mmc/core/bus.h11
-rw-r--r--drivers/mmc/core/core.h2
-rw-r--r--drivers/mmc/core/mmc.c90
-rw-r--r--drivers/mmc/core/sd.c95
-rw-r--r--drivers/mmc/core/sdio.c2
-rw-r--r--drivers/mmc/core/sysfs.c43
-rw-r--r--drivers/mmc/core/sysfs.h26
-rw-r--r--drivers/mtd/devices/block2mtd.c1
-rw-r--r--drivers/mtd/maps/physmap.c15
-rw-r--r--drivers/mtd/nand/rtc_from4.c2
-rw-r--r--drivers/net/dm9000.c2
-rw-r--r--drivers/net/fec_mpc52xx_phy.c3
-rw-r--r--drivers/net/plip.c7
-rw-r--r--drivers/net/sky2.c6
-rw-r--r--drivers/net/usb/rtl8150.c2
-rw-r--r--drivers/pci/hotplug/pciehp_core.c2
-rw-r--r--drivers/pci/intel-iommu.c7
-rw-r--r--drivers/pci/pci.c21
-rw-r--r--drivers/pci/quirks.c11
-rw-r--r--drivers/pci/setup-bus.c5
-rw-r--r--drivers/pnp/isapnp/core.c25
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c8
-rw-r--r--drivers/rtc/Kconfig2
-rw-r--r--drivers/rtc/rtc-at91sam9.c6
-rw-r--r--drivers/scsi/Kconfig2
-rw-r--r--drivers/scsi/a100u2w.c9
-rw-r--r--drivers/scsi/advansys.c2
-rw-r--r--drivers/scsi/arcmsr/arcmsr.h14
-rw-r--r--drivers/scsi/gdth.c7
-rw-r--r--drivers/scsi/hosts.c16
-rw-r--r--drivers/scsi/libsas/sas_discover.c5
-rw-r--r--drivers/scsi/mvsas.c711
-rw-r--r--drivers/scsi/scsi_lib.c5
-rw-r--r--drivers/scsi/sd.c1
-rw-r--r--drivers/scsi/sr.c1
-rw-r--r--drivers/serial/8250_pci.c7
-rw-r--r--drivers/serial/atmel_serial.c30
-rw-r--r--drivers/serial/sh-sci.c4
-rw-r--r--drivers/thermal/Kconfig2
-rw-r--r--drivers/thermal/thermal.c169
-rw-r--r--drivers/uio/uio.c2
-rw-r--r--drivers/usb/core/message.c5
-rw-r--r--drivers/usb/core/quirks.c3
-rw-r--r--drivers/usb/gadget/inode.c4
-rw-r--r--drivers/usb/host/ehci-hub.c5
-rw-r--r--drivers/usb/host/ehci-pci.c14
-rw-r--r--drivers/usb/host/ohci-hcd.c2
-rw-r--r--drivers/usb/host/ohci-q.c2
-rw-r--r--drivers/usb/misc/usbtest.c3
-rw-r--r--drivers/usb/serial/cp2101.c1
-rw-r--r--drivers/usb/serial/keyspan.h4
-rw-r--r--drivers/usb/serial/pl2303.c1
-rw-r--r--drivers/usb/serial/pl2303.h1
-rw-r--r--drivers/usb/serial/sierra.c18
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c4
-rw-r--r--drivers/usb/serial/visor.c2
-rw-r--r--drivers/usb/storage/isd200.c6
-rw-r--r--drivers/usb/storage/transport.c3
-rw-r--r--drivers/usb/storage/unusual_devs.h11
-rw-r--r--drivers/video/Kconfig14
-rw-r--r--drivers/video/Makefile1
-rw-r--r--drivers/video/bf54x-lq043fb.c2
-rw-r--r--drivers/video/bfin-t350mcqb-fb.c38
-rw-r--r--drivers/video/fb_defio.c22
-rw-r--r--drivers/video/i810/i810_main.c2
-rw-r--r--drivers/video/metronomefb.c999
-rw-r--r--drivers/virtio/virtio_pci.c7
-rw-r--r--drivers/watchdog/it8712f_wdt.c14
244 files changed, 3393 insertions, 2973 deletions
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index d25ef961415c..44ad90c03c2e 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -610,7 +610,7 @@ write_led(const char __user * buffer, unsigned long count,
610 (led_out) ? (hotk->status | ledmask) : (hotk->status & ~ledmask); 610 (led_out) ? (hotk->status | ledmask) : (hotk->status & ~ledmask);
611 611
612 if (invert) /* invert target value */ 612 if (invert) /* invert target value */
613 led_out = !led_out & 0x1; 613 led_out = !led_out;
614 614
615 if (!write_acpi_int(hotk->handle, ledname, led_out, NULL)) 615 if (!write_acpi_int(hotk->handle, ledname, led_out, NULL))
616 printk(KERN_WARNING "Asus ACPI: LED (%s) write failed\n", 616 printk(KERN_WARNING "Asus ACPI: LED (%s) write failed\n",
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index f6215e809808..d5729d5dc190 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -293,13 +293,12 @@ static int extract_package(struct acpi_battery *battery,
293 strncpy(ptr, (u8 *)&element->integer.value, 293 strncpy(ptr, (u8 *)&element->integer.value,
294 sizeof(acpi_integer)); 294 sizeof(acpi_integer));
295 ptr[sizeof(acpi_integer)] = 0; 295 ptr[sizeof(acpi_integer)] = 0;
296 } else return -EFAULT; 296 } else
297 *ptr = 0; /* don't have value */
297 } else { 298 } else {
298 if (element->type == ACPI_TYPE_INTEGER) { 299 int *x = (int *)((u8 *)battery + offsets[i].offset);
299 int *x = (int *)((u8 *)battery + 300 *x = (element->type == ACPI_TYPE_INTEGER) ?
300 offsets[i].offset); 301 element->integer.value : -1;
301 *x = element->integer.value;
302 } else return -EFAULT;
303 } 302 }
304 } 303 }
305 return 0; 304 return 0;
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 307cef65c247..fa44fb96fc34 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -710,6 +710,7 @@ static ssize_t write_undock(struct device *dev, struct device_attribute *attr,
710 if (!count) 710 if (!count)
711 return -EINVAL; 711 return -EINVAL;
712 712
713 begin_undock(dock_station);
713 ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST); 714 ret = handle_eject_request(dock_station, ACPI_NOTIFY_EJECT_REQUEST);
714 return ret ? ret: count; 715 return ret ? ret: count;
715} 716}
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index e7e197e3a4ff..7222a18a0319 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -129,7 +129,6 @@ static struct acpi_ec {
129 struct mutex lock; 129 struct mutex lock;
130 wait_queue_head_t wait; 130 wait_queue_head_t wait;
131 struct list_head list; 131 struct list_head list;
132 atomic_t irq_count;
133 u8 handlers_installed; 132 u8 handlers_installed;
134} *boot_ec, *first_ec; 133} *boot_ec, *first_ec;
135 134
@@ -182,8 +181,6 @@ static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll)
182{ 181{
183 int ret = 0; 182 int ret = 0;
184 183
185 atomic_set(&ec->irq_count, 0);
186
187 if (unlikely(event == ACPI_EC_EVENT_OBF_1 && 184 if (unlikely(event == ACPI_EC_EVENT_OBF_1 &&
188 test_bit(EC_FLAGS_NO_OBF1_GPE, &ec->flags))) 185 test_bit(EC_FLAGS_NO_OBF1_GPE, &ec->flags)))
189 force_poll = 1; 186 force_poll = 1;
@@ -230,7 +227,6 @@ static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll)
230 while (time_before(jiffies, delay)) { 227 while (time_before(jiffies, delay)) {
231 if (acpi_ec_check_status(ec, event)) 228 if (acpi_ec_check_status(ec, event))
232 goto end; 229 goto end;
233 msleep(5);
234 } 230 }
235 } 231 }
236 pr_err(PREFIX "acpi_ec_wait timeout," 232 pr_err(PREFIX "acpi_ec_wait timeout,"
@@ -533,13 +529,6 @@ static u32 acpi_ec_gpe_handler(void *data)
533 struct acpi_ec *ec = data; 529 struct acpi_ec *ec = data;
534 530
535 pr_debug(PREFIX "~~~> interrupt\n"); 531 pr_debug(PREFIX "~~~> interrupt\n");
536 atomic_inc(&ec->irq_count);
537 if (atomic_read(&ec->irq_count) > 5) {
538 pr_err(PREFIX "GPE storm detected, disabling EC GPE\n");
539 acpi_disable_gpe(NULL, ec->gpe, ACPI_ISR);
540 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags);
541 return ACPI_INTERRUPT_HANDLED;
542 }
543 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags); 532 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
544 if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) 533 if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))
545 wake_up(&ec->wait); 534 wake_up(&ec->wait);
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 7af414a3c63e..89022a74faee 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -131,8 +131,8 @@ struct prt_quirk {
131 */ 131 */
132static struct prt_quirk prt_quirks[] = { 132static struct prt_quirk prt_quirks[] = {
133 { medion_md9580, 0, 0, 9, 'A', 133 { medion_md9580, 0, 0, 9, 'A',
134 "\\_SB_.PCI0.ISA.LNKA", 134 "\\_SB_.PCI0.ISA_.LNKA",
135 "\\_SB_.PCI0.ISA.LNKB"}, 135 "\\_SB_.PCI0.ISA_.LNKB"},
136 { dell_optiplex, 0, 0, 0xd, 'A', 136 { dell_optiplex, 0, 0, 0xd, 'A',
137 "\\_SB_.LNKB", 137 "\\_SB_.LNKB",
138 "\\_SB_.LNKA"}, 138 "\\_SB_.LNKA"},
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 6f3b217699e9..788da9781f80 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -216,8 +216,10 @@ static void acpi_safe_halt(void)
216 * test NEED_RESCHED: 216 * test NEED_RESCHED:
217 */ 217 */
218 smp_mb(); 218 smp_mb();
219 if (!need_resched()) 219 if (!need_resched()) {
220 safe_halt(); 220 safe_halt();
221 local_irq_disable();
222 }
221 current_thread_info()->status |= TS_POLLING; 223 current_thread_info()->status |= TS_POLLING;
222} 224}
223 225
@@ -421,7 +423,9 @@ static void acpi_processor_idle(void)
421 else 423 else
422 acpi_safe_halt(); 424 acpi_safe_halt();
423 425
424 local_irq_enable(); 426 if (irqs_disabled())
427 local_irq_enable();
428
425 return; 429 return;
426 } 430 }
427 431
@@ -530,7 +534,9 @@ static void acpi_processor_idle(void)
530 * skew otherwise. 534 * skew otherwise.
531 */ 535 */
532 sleep_ticks = 0xFFFFFFFF; 536 sleep_ticks = 0xFFFFFFFF;
533 local_irq_enable(); 537 if (irqs_disabled())
538 local_irq_enable();
539
534 break; 540 break;
535 541
536 case ACPI_STATE_C2: 542 case ACPI_STATE_C2:
@@ -1481,7 +1487,6 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
1481 return 0; 1487 return 0;
1482 } 1488 }
1483 1489
1484 acpi_unlazy_tlb(smp_processor_id());
1485 /* 1490 /*
1486 * Must be done before busmaster disable as we might need to 1491 * Must be done before busmaster disable as we might need to
1487 * access HPET ! 1492 * access HPET !
@@ -1571,6 +1576,8 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
1571 return 0; 1576 return 0;
1572 } 1577 }
1573 1578
1579 acpi_unlazy_tlb(smp_processor_id());
1580
1574 /* Tell the scheduler that we are going deep-idle: */ 1581 /* Tell the scheduler that we are going deep-idle: */
1575 sched_clock_idle_sleep_event(); 1582 sched_clock_idle_sleep_event();
1576 /* 1583 /*
@@ -1686,7 +1693,9 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr)
1686 switch (cx->type) { 1693 switch (cx->type) {
1687 case ACPI_STATE_C1: 1694 case ACPI_STATE_C1:
1688 state->flags |= CPUIDLE_FLAG_SHALLOW; 1695 state->flags |= CPUIDLE_FLAG_SHALLOW;
1689 state->flags |= CPUIDLE_FLAG_TIME_VALID; 1696 if (cx->entry_method == ACPI_CSTATE_FFH)
1697 state->flags |= CPUIDLE_FLAG_TIME_VALID;
1698
1690 state->enter = acpi_idle_enter_c1; 1699 state->enter = acpi_idle_enter_c1;
1691 dev->safe_state = state; 1700 dev->safe_state = state;
1692 break; 1701 break;
diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c
index a2cf3008ce6c..bcf2c70fca87 100644
--- a/drivers/acpi/sbshc.c
+++ b/drivers/acpi/sbshc.c
@@ -130,7 +130,6 @@ static int acpi_smbus_transaction(struct acpi_smb_hc *hc, u8 protocol,
130 goto end; 130 goto end;
131 } 131 }
132 smb_hc_write(hc, ACPI_SMB_COMMAND, command); 132 smb_hc_write(hc, ACPI_SMB_COMMAND, command);
133 smb_hc_write(hc, ACPI_SMB_COMMAND, command);
134 if (!(protocol & 0x01)) { 133 if (!(protocol & 0x01)) {
135 smb_hc_write(hc, ACPI_SMB_BLOCK_COUNT, length); 134 smb_hc_write(hc, ACPI_SMB_BLOCK_COUNT, length);
136 for (i = 0; i < length; ++i) 135 for (i = 0; i < length; ++i)
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 57570ac47803..e6ce262b5d44 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -39,20 +39,26 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
39 int size) 39 int size)
40{ 40{
41 int len; 41 int len;
42 int count;
42 43
43 if (!acpi_dev->flags.hardware_id) 44 if (!acpi_dev->flags.hardware_id && !acpi_dev->flags.compatible_ids)
44 return -ENODEV; 45 return -ENODEV;
45 46
46 len = snprintf(modalias, size, "acpi:%s:", 47 len = snprintf(modalias, size, "acpi:");
47 acpi_dev->pnp.hardware_id);
48 if (len < 0 || len >= size)
49 return -EINVAL;
50 size -= len; 48 size -= len;
51 49
50 if (acpi_dev->flags.hardware_id) {
51 count = snprintf(&modalias[len], size, "%s:",
52 acpi_dev->pnp.hardware_id);
53 if (count < 0 || count >= size)
54 return -EINVAL;
55 len += count;
56 size -= count;
57 }
58
52 if (acpi_dev->flags.compatible_ids) { 59 if (acpi_dev->flags.compatible_ids) {
53 struct acpi_compatible_id_list *cid_list; 60 struct acpi_compatible_id_list *cid_list;
54 int i; 61 int i;
55 int count;
56 62
57 cid_list = acpi_dev->pnp.cid_list; 63 cid_list = acpi_dev->pnp.cid_list;
58 for (i = 0; i < cid_list->count; i++) { 64 for (i = 0; i < cid_list->count; i++) {
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index d2f71a54726c..71183eea7906 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -26,21 +26,6 @@ u8 sleep_states[ACPI_S_STATE_COUNT];
26 26
27#ifdef CONFIG_PM_SLEEP 27#ifdef CONFIG_PM_SLEEP
28static u32 acpi_target_sleep_state = ACPI_STATE_S0; 28static u32 acpi_target_sleep_state = ACPI_STATE_S0;
29static bool acpi_sleep_finish_wake_up;
30
31/*
32 * ACPI 2.0 and later want us to execute _PTS after suspending devices, so we
33 * allow the user to request that behavior by using the 'acpi_new_pts_ordering'
34 * kernel command line option that causes the following variable to be set.
35 */
36static bool new_pts_ordering;
37
38static int __init acpi_new_pts_ordering(char *str)
39{
40 new_pts_ordering = true;
41 return 1;
42}
43__setup("acpi_new_pts_ordering", acpi_new_pts_ordering);
44#endif 29#endif
45 30
46static int acpi_sleep_prepare(u32 acpi_state) 31static int acpi_sleep_prepare(u32 acpi_state)
@@ -91,14 +76,6 @@ static int acpi_pm_begin(suspend_state_t pm_state)
91 76
92 if (sleep_states[acpi_state]) { 77 if (sleep_states[acpi_state]) {
93 acpi_target_sleep_state = acpi_state; 78 acpi_target_sleep_state = acpi_state;
94 if (new_pts_ordering)
95 return 0;
96
97 error = acpi_sleep_prepare(acpi_state);
98 if (error)
99 acpi_target_sleep_state = ACPI_STATE_S0;
100 else
101 acpi_sleep_finish_wake_up = true;
102 } else { 79 } else {
103 printk(KERN_ERR "ACPI does not support this state: %d\n", 80 printk(KERN_ERR "ACPI does not support this state: %d\n",
104 pm_state); 81 pm_state);
@@ -116,14 +93,11 @@ static int acpi_pm_begin(suspend_state_t pm_state)
116 93
117static int acpi_pm_prepare(void) 94static int acpi_pm_prepare(void)
118{ 95{
119 if (new_pts_ordering) { 96 int error = acpi_sleep_prepare(acpi_target_sleep_state);
120 int error = acpi_sleep_prepare(acpi_target_sleep_state);
121 97
122 if (error) { 98 if (error) {
123 acpi_target_sleep_state = ACPI_STATE_S0; 99 acpi_target_sleep_state = ACPI_STATE_S0;
124 return error; 100 return error;
125 }
126 acpi_sleep_finish_wake_up = true;
127 } 101 }
128 102
129 return ACPI_SUCCESS(acpi_hw_disable_all_gpes()) ? 0 : -EFAULT; 103 return ACPI_SUCCESS(acpi_hw_disable_all_gpes()) ? 0 : -EFAULT;
@@ -212,7 +186,6 @@ static void acpi_pm_finish(void)
212 acpi_set_firmware_waking_vector((acpi_physical_address) 0); 186 acpi_set_firmware_waking_vector((acpi_physical_address) 0);
213 187
214 acpi_target_sleep_state = ACPI_STATE_S0; 188 acpi_target_sleep_state = ACPI_STATE_S0;
215 acpi_sleep_finish_wake_up = false;
216 189
217#ifdef CONFIG_X86 190#ifdef CONFIG_X86
218 if (init_8259A_after_S1) { 191 if (init_8259A_after_S1) {
@@ -229,11 +202,10 @@ static void acpi_pm_finish(void)
229static void acpi_pm_end(void) 202static void acpi_pm_end(void)
230{ 203{
231 /* 204 /*
232 * This is necessary in case acpi_pm_finish() is not called directly 205 * This is necessary in case acpi_pm_finish() is not called during a
233 * during a failing transition to a sleep state. 206 * failing transition to a sleep state.
234 */ 207 */
235 if (acpi_sleep_finish_wake_up) 208 acpi_target_sleep_state = ACPI_STATE_S0;
236 acpi_pm_finish();
237} 209}
238 210
239static int acpi_pm_state_valid(suspend_state_t pm_state) 211static int acpi_pm_state_valid(suspend_state_t pm_state)
@@ -285,31 +257,18 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
285#ifdef CONFIG_HIBERNATION 257#ifdef CONFIG_HIBERNATION
286static int acpi_hibernation_begin(void) 258static int acpi_hibernation_begin(void)
287{ 259{
288 int error;
289
290 acpi_target_sleep_state = ACPI_STATE_S4; 260 acpi_target_sleep_state = ACPI_STATE_S4;
291 if (new_pts_ordering)
292 return 0;
293 261
294 error = acpi_sleep_prepare(ACPI_STATE_S4); 262 return 0;
295 if (error)
296 acpi_target_sleep_state = ACPI_STATE_S0;
297 else
298 acpi_sleep_finish_wake_up = true;
299
300 return error;
301} 263}
302 264
303static int acpi_hibernation_prepare(void) 265static int acpi_hibernation_prepare(void)
304{ 266{
305 if (new_pts_ordering) { 267 int error = acpi_sleep_prepare(ACPI_STATE_S4);
306 int error = acpi_sleep_prepare(ACPI_STATE_S4);
307 268
308 if (error) { 269 if (error) {
309 acpi_target_sleep_state = ACPI_STATE_S0; 270 acpi_target_sleep_state = ACPI_STATE_S0;
310 return error; 271 return error;
311 }
312 acpi_sleep_finish_wake_up = true;
313 } 272 }
314 273
315 return ACPI_SUCCESS(acpi_hw_disable_all_gpes()) ? 0 : -EFAULT; 274 return ACPI_SUCCESS(acpi_hw_disable_all_gpes()) ? 0 : -EFAULT;
@@ -353,17 +312,15 @@ static void acpi_hibernation_finish(void)
353 acpi_set_firmware_waking_vector((acpi_physical_address) 0); 312 acpi_set_firmware_waking_vector((acpi_physical_address) 0);
354 313
355 acpi_target_sleep_state = ACPI_STATE_S0; 314 acpi_target_sleep_state = ACPI_STATE_S0;
356 acpi_sleep_finish_wake_up = false;
357} 315}
358 316
359static void acpi_hibernation_end(void) 317static void acpi_hibernation_end(void)
360{ 318{
361 /* 319 /*
362 * This is necessary in case acpi_hibernation_finish() is not called 320 * This is necessary in case acpi_hibernation_finish() is not called
363 * directly during a failing transition to the sleep state. 321 * during a failing transition to the sleep state.
364 */ 322 */
365 if (acpi_sleep_finish_wake_up) 323 acpi_target_sleep_state = ACPI_STATE_S0;
366 acpi_hibernation_finish();
367} 324}
368 325
369static int acpi_hibernation_pre_restore(void) 326static int acpi_hibernation_pre_restore(void)
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 1bc0c74f2755..12fb44f16766 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -807,40 +807,11 @@ static void acpi_video_bus_find_cap(struct acpi_video_bus *video)
807static int acpi_video_bus_check(struct acpi_video_bus *video) 807static int acpi_video_bus_check(struct acpi_video_bus *video)
808{ 808{
809 acpi_status status = -ENOENT; 809 acpi_status status = -ENOENT;
810 long device_id; 810
811 struct device *dev;
812 struct acpi_device *device;
813 811
814 if (!video) 812 if (!video)
815 return -EINVAL; 813 return -EINVAL;
816 814
817 device = video->device;
818
819 status =
820 acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id);
821
822 if (!ACPI_SUCCESS(status))
823 return -ENODEV;
824
825 /* We need to attempt to determine whether the _ADR refers to a
826 PCI device or not. There's no terribly good way to do this,
827 so the best we can hope for is to assume that there'll never
828 be a video device in the host bridge */
829 if (device_id >= 0x10000) {
830 /* It looks like a PCI device. Does it exist? */
831 dev = acpi_get_physical_device(device->handle);
832 } else {
833 /* It doesn't look like a PCI device. Does its parent
834 exist? */
835 acpi_handle phandle;
836 if (acpi_get_parent(device->handle, &phandle))
837 return -ENODEV;
838 dev = acpi_get_physical_device(phandle);
839 }
840 if (!dev)
841 return -ENODEV;
842 put_device(dev);
843
844 /* Since there is no HID, CID and so on for VGA driver, we have 815 /* Since there is no HID, CID and so on for VGA driver, we have
845 * to check well known required nodes. 816 * to check well known required nodes.
846 */ 817 */
@@ -1366,37 +1337,8 @@ acpi_video_bus_write_DOS(struct file *file,
1366 1337
1367static int acpi_video_bus_add_fs(struct acpi_device *device) 1338static int acpi_video_bus_add_fs(struct acpi_device *device)
1368{ 1339{
1369 long device_id;
1370 int status;
1371 struct proc_dir_entry *entry = NULL; 1340 struct proc_dir_entry *entry = NULL;
1372 struct acpi_video_bus *video; 1341 struct acpi_video_bus *video;
1373 struct device *dev;
1374
1375 status =
1376 acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id);
1377
1378 if (!ACPI_SUCCESS(status))
1379 return -ENODEV;
1380
1381 /* We need to attempt to determine whether the _ADR refers to a
1382 PCI device or not. There's no terribly good way to do this,
1383 so the best we can hope for is to assume that there'll never
1384 be a video device in the host bridge */
1385 if (device_id >= 0x10000) {
1386 /* It looks like a PCI device. Does it exist? */
1387 dev = acpi_get_physical_device(device->handle);
1388 } else {
1389 /* It doesn't look like a PCI device. Does its parent
1390 exist? */
1391 acpi_handle phandle;
1392 if (acpi_get_parent(device->handle, &phandle))
1393 return -ENODEV;
1394 dev = acpi_get_physical_device(phandle);
1395 }
1396 if (!dev)
1397 return -ENODEV;
1398 put_device(dev);
1399
1400 1342
1401 1343
1402 video = acpi_driver_data(device); 1344 video = acpi_driver_data(device);
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index e469647330de..25aba69b59b4 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -30,6 +30,7 @@ config ATA_NONSTANDARD
30config ATA_ACPI 30config ATA_ACPI
31 bool 31 bool
32 depends on ACPI && PCI 32 depends on ACPI && PCI
33 select ACPI_DOCK
33 default y 34 default y
34 help 35 help
35 This option adds support for ATA-related ACPI objects. 36 This option adds support for ATA-related ACPI objects.
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 17ee6ed985d9..b1eb4e24c86a 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -433,6 +433,7 @@ static const struct ata_port_info ahci_port_info[] = {
433 /* board_ahci_sb600 */ 433 /* board_ahci_sb600 */
434 { 434 {
435 AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL | 435 AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL |
436 AHCI_HFLAG_32BIT_ONLY |
436 AHCI_HFLAG_SECT255 | AHCI_HFLAG_NO_PMP), 437 AHCI_HFLAG_SECT255 | AHCI_HFLAG_NO_PMP),
437 .flags = AHCI_FLAG_COMMON, 438 .flags = AHCI_FLAG_COMMON,
438 .link_flags = AHCI_LFLAG_COMMON, 439 .link_flags = AHCI_LFLAG_COMMON,
@@ -1217,8 +1218,11 @@ static void ahci_dev_config(struct ata_device *dev)
1217{ 1218{
1218 struct ahci_host_priv *hpriv = dev->link->ap->host->private_data; 1219 struct ahci_host_priv *hpriv = dev->link->ap->host->private_data;
1219 1220
1220 if (hpriv->flags & AHCI_HFLAG_SECT255) 1221 if (hpriv->flags & AHCI_HFLAG_SECT255) {
1221 dev->max_sectors = 255; 1222 dev->max_sectors = 255;
1223 ata_dev_printk(dev, KERN_INFO,
1224 "SB600 AHCI: limiting to 255 sectors per cmd\n");
1225 }
1222} 1226}
1223 1227
1224static unsigned int ahci_dev_classify(struct ata_port *ap) 1228static unsigned int ahci_dev_classify(struct ata_port *ap)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 4bbe31f98ef8..48519887f94a 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -972,7 +972,7 @@ static void ata_dev_disable_pm(struct ata_device *dev)
972void ata_lpm_schedule(struct ata_port *ap, enum link_pm policy) 972void ata_lpm_schedule(struct ata_port *ap, enum link_pm policy)
973{ 973{
974 ap->pm_policy = policy; 974 ap->pm_policy = policy;
975 ap->link.eh_info.action |= ATA_EHI_LPM; 975 ap->link.eh_info.action |= ATA_EH_LPM;
976 ap->link.eh_info.flags |= ATA_EHI_NO_AUTOPSY; 976 ap->link.eh_info.flags |= ATA_EHI_NO_AUTOPSY;
977 ata_port_schedule_eh(ap); 977 ata_port_schedule_eh(ap);
978} 978}
@@ -1416,12 +1416,12 @@ static int ata_hpa_resize(struct ata_device *dev)
1416 /* read native max address */ 1416 /* read native max address */
1417 rc = ata_read_native_max_address(dev, &native_sectors); 1417 rc = ata_read_native_max_address(dev, &native_sectors);
1418 if (rc) { 1418 if (rc) {
1419 /* If HPA isn't going to be unlocked, skip HPA 1419 /* If device aborted the command or HPA isn't going to
1420 * resizing from the next try. 1420 * be unlocked, skip HPA resizing.
1421 */ 1421 */
1422 if (!ata_ignore_hpa) { 1422 if (rc == -EACCES || !ata_ignore_hpa) {
1423 ata_dev_printk(dev, KERN_WARNING, "HPA support seems " 1423 ata_dev_printk(dev, KERN_WARNING, "HPA support seems "
1424 "broken, will skip HPA handling\n"); 1424 "broken, skipping HPA handling\n");
1425 dev->horkage |= ATA_HORKAGE_BROKEN_HPA; 1425 dev->horkage |= ATA_HORKAGE_BROKEN_HPA;
1426 1426
1427 /* we can continue if device aborted the command */ 1427 /* we can continue if device aborted the command */
@@ -2092,24 +2092,34 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
2092 id, sizeof(id[0]) * ATA_ID_WORDS, 0); 2092 id, sizeof(id[0]) * ATA_ID_WORDS, 0);
2093 if (err_mask) { 2093 if (err_mask) {
2094 if (err_mask & AC_ERR_NODEV_HINT) { 2094 if (err_mask & AC_ERR_NODEV_HINT) {
2095 DPRINTK("ata%u.%d: NODEV after polling detection\n", 2095 ata_dev_printk(dev, KERN_DEBUG,
2096 ap->print_id, dev->devno); 2096 "NODEV after polling detection\n");
2097 return -ENOENT; 2097 return -ENOENT;
2098 } 2098 }
2099 2099
2100 /* Device or controller might have reported the wrong 2100 if ((err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) {
2101 * device class. Give a shot at the other IDENTIFY if 2101 /* Device or controller might have reported
2102 * the current one is aborted by the device. 2102 * the wrong device class. Give a shot at the
2103 */ 2103 * other IDENTIFY if the current one is
2104 if (may_fallback && 2104 * aborted by the device.
2105 (err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) { 2105 */
2106 may_fallback = 0; 2106 if (may_fallback) {
2107 may_fallback = 0;
2107 2108
2108 if (class == ATA_DEV_ATA) 2109 if (class == ATA_DEV_ATA)
2109 class = ATA_DEV_ATAPI; 2110 class = ATA_DEV_ATAPI;
2110 else 2111 else
2111 class = ATA_DEV_ATA; 2112 class = ATA_DEV_ATA;
2112 goto retry; 2113 goto retry;
2114 }
2115
2116 /* Control reaches here iff the device aborted
2117 * both flavors of IDENTIFYs which happens
2118 * sometimes with phantom devices.
2119 */
2120 ata_dev_printk(dev, KERN_DEBUG,
2121 "both IDENTIFYs aborted, assuming NODEV\n");
2122 return -ENOENT;
2113 } 2123 }
2114 2124
2115 rc = -EIO; 2125 rc = -EIO;
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 681252fd8143..a5830329eda4 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -2748,7 +2748,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2748 ehc->i.flags &= ~ATA_EHI_SETMODE; 2748 ehc->i.flags &= ~ATA_EHI_SETMODE;
2749 } 2749 }
2750 2750
2751 if (ehc->i.action & ATA_EHI_LPM) 2751 if (ehc->i.action & ATA_EH_LPM)
2752 ata_link_for_each_dev(dev, link) 2752 ata_link_for_each_dev(dev, link)
2753 ata_dev_enable_pm(dev, ap->pm_policy); 2753 ata_dev_enable_pm(dev, ap->pm_policy);
2754 2754
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 8f0e8f2bc628..15795394b0a8 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -527,6 +527,14 @@ static struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev,
527 return qc; 527 return qc;
528} 528}
529 529
530static void ata_qc_set_pc_nbytes(struct ata_queued_cmd *qc)
531{
532 struct scsi_cmnd *scmd = qc->scsicmd;
533
534 qc->extrabytes = scmd->request->extra_len;
535 qc->nbytes = scsi_bufflen(scmd) + qc->extrabytes;
536}
537
530/** 538/**
531 * ata_dump_status - user friendly display of error info 539 * ata_dump_status - user friendly display of error info
532 * @id: id of the port in question 540 * @id: id of the port in question
@@ -2539,7 +2547,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
2539 } 2547 }
2540 2548
2541 qc->tf.command = ATA_CMD_PACKET; 2549 qc->tf.command = ATA_CMD_PACKET;
2542 qc->nbytes = scsi_bufflen(scmd) + scmd->request->extra_len; 2550 ata_qc_set_pc_nbytes(qc);
2543 2551
2544 /* check whether ATAPI DMA is safe */ 2552 /* check whether ATAPI DMA is safe */
2545 if (!using_pio && ata_check_atapi_dma(qc)) 2553 if (!using_pio && ata_check_atapi_dma(qc))
@@ -2550,7 +2558,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
2550 * want to set it properly, and for DMA where it is 2558 * want to set it properly, and for DMA where it is
2551 * effectively meaningless. 2559 * effectively meaningless.
2552 */ 2560 */
2553 nbytes = min(scmd->request->data_len, (unsigned int)63 * 1024); 2561 nbytes = min(ata_qc_raw_nbytes(qc), (unsigned int)63 * 1024);
2554 2562
2555 /* Most ATAPI devices which honor transfer chunk size don't 2563 /* Most ATAPI devices which honor transfer chunk size don't
2556 * behave according to the spec when odd chunk size which 2564 * behave according to the spec when odd chunk size which
@@ -2876,7 +2884,7 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
2876 * TODO: find out if we need to do more here to 2884 * TODO: find out if we need to do more here to
2877 * cover scatter/gather case. 2885 * cover scatter/gather case.
2878 */ 2886 */
2879 qc->nbytes = scsi_bufflen(scmd) + scmd->request->extra_len; 2887 ata_qc_set_pc_nbytes(qc);
2880 2888
2881 /* request result TF and be quiet about device error */ 2889 /* request result TF and be quiet about device error */
2882 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET; 2890 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET;
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index 109ddd42c266..257951d03dbb 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -564,7 +564,7 @@ static int it821x_check_atapi_dma(struct ata_queued_cmd *qc)
564 struct it821x_dev *itdev = ap->private_data; 564 struct it821x_dev *itdev = ap->private_data;
565 565
566 /* Only use dma for transfers to/from the media. */ 566 /* Only use dma for transfers to/from the media. */
567 if (qc->nbytes < 2048) 567 if (ata_qc_raw_nbytes(qc) < 2048)
568 return -EOPNOTSUPP; 568 return -EOPNOTSUPP;
569 569
570 /* No ATAPI DMA in smart mode */ 570 /* No ATAPI DMA in smart mode */
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c
index 503245a1eafa..3988e44f4934 100644
--- a/drivers/ata/pata_sil680.c
+++ b/drivers/ata/pata_sil680.c
@@ -269,7 +269,11 @@ static u8 sil680_init_chip(struct pci_dev *pdev, int *try_mmio)
269 dev_dbg(&pdev->dev, "sil680: BA5_EN = %d clock = %02X\n", 269 dev_dbg(&pdev->dev, "sil680: BA5_EN = %d clock = %02X\n",
270 tmpbyte & 1, tmpbyte & 0x30); 270 tmpbyte & 1, tmpbyte & 0x30);
271 271
272 *try_mmio = (tmpbyte & 1) || pci_resource_start(pdev, 5); 272 *try_mmio = 0;
273#ifdef CONFIG_PPC
274 if (machine_is(cell))
275 *try_mmio = (tmpbyte & 1) || pci_resource_start(pdev, 5);
276#endif
273 277
274 switch(tmpbyte & 0x30) { 278 switch(tmpbyte & 0x30) {
275 case 0x00: 279 case 0x00:
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c
index f251a5f569d5..11c1afea2db2 100644
--- a/drivers/ata/sata_promise.c
+++ b/drivers/ata/sata_promise.c
@@ -46,7 +46,7 @@
46#include "sata_promise.h" 46#include "sata_promise.h"
47 47
48#define DRV_NAME "sata_promise" 48#define DRV_NAME "sata_promise"
49#define DRV_VERSION "2.11" 49#define DRV_VERSION "2.12"
50 50
51enum { 51enum {
52 PDC_MAX_PORTS = 4, 52 PDC_MAX_PORTS = 4,
@@ -145,7 +145,9 @@ static int pdc_old_sata_check_atapi_dma(struct ata_queued_cmd *qc);
145static void pdc_irq_clear(struct ata_port *ap); 145static void pdc_irq_clear(struct ata_port *ap);
146static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc); 146static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc);
147static void pdc_freeze(struct ata_port *ap); 147static void pdc_freeze(struct ata_port *ap);
148static void pdc_sata_freeze(struct ata_port *ap);
148static void pdc_thaw(struct ata_port *ap); 149static void pdc_thaw(struct ata_port *ap);
150static void pdc_sata_thaw(struct ata_port *ap);
149static void pdc_pata_error_handler(struct ata_port *ap); 151static void pdc_pata_error_handler(struct ata_port *ap);
150static void pdc_sata_error_handler(struct ata_port *ap); 152static void pdc_sata_error_handler(struct ata_port *ap);
151static void pdc_post_internal_cmd(struct ata_queued_cmd *qc); 153static void pdc_post_internal_cmd(struct ata_queued_cmd *qc);
@@ -180,8 +182,8 @@ static const struct ata_port_operations pdc_sata_ops = {
180 182
181 .qc_prep = pdc_qc_prep, 183 .qc_prep = pdc_qc_prep,
182 .qc_issue = pdc_qc_issue_prot, 184 .qc_issue = pdc_qc_issue_prot,
183 .freeze = pdc_freeze, 185 .freeze = pdc_sata_freeze,
184 .thaw = pdc_thaw, 186 .thaw = pdc_sata_thaw,
185 .error_handler = pdc_sata_error_handler, 187 .error_handler = pdc_sata_error_handler,
186 .post_internal_cmd = pdc_post_internal_cmd, 188 .post_internal_cmd = pdc_post_internal_cmd,
187 .cable_detect = pdc_sata_cable_detect, 189 .cable_detect = pdc_sata_cable_detect,
@@ -205,8 +207,8 @@ static const struct ata_port_operations pdc_old_sata_ops = {
205 207
206 .qc_prep = pdc_qc_prep, 208 .qc_prep = pdc_qc_prep,
207 .qc_issue = pdc_qc_issue_prot, 209 .qc_issue = pdc_qc_issue_prot,
208 .freeze = pdc_freeze, 210 .freeze = pdc_sata_freeze,
209 .thaw = pdc_thaw, 211 .thaw = pdc_sata_thaw,
210 .error_handler = pdc_sata_error_handler, 212 .error_handler = pdc_sata_error_handler,
211 .post_internal_cmd = pdc_post_internal_cmd, 213 .post_internal_cmd = pdc_post_internal_cmd,
212 .cable_detect = pdc_sata_cable_detect, 214 .cable_detect = pdc_sata_cable_detect,
@@ -631,6 +633,41 @@ static void pdc_qc_prep(struct ata_queued_cmd *qc)
631 } 633 }
632} 634}
633 635
636static int pdc_is_sataii_tx4(unsigned long flags)
637{
638 const unsigned long mask = PDC_FLAG_GEN_II | PDC_FLAG_4_PORTS;
639 return (flags & mask) == mask;
640}
641
642static unsigned int pdc_port_no_to_ata_no(unsigned int port_no,
643 int is_sataii_tx4)
644{
645 static const unsigned char sataii_tx4_port_remap[4] = { 3, 1, 0, 2};
646 return is_sataii_tx4 ? sataii_tx4_port_remap[port_no] : port_no;
647}
648
649static unsigned int pdc_sata_nr_ports(const struct ata_port *ap)
650{
651 return (ap->flags & PDC_FLAG_4_PORTS) ? 4 : 2;
652}
653
654static unsigned int pdc_sata_ata_port_to_ata_no(const struct ata_port *ap)
655{
656 const struct ata_host *host = ap->host;
657 unsigned int nr_ports = pdc_sata_nr_ports(ap);
658 unsigned int i;
659
660 for(i = 0; i < nr_ports && host->ports[i] != ap; ++i)
661 ;
662 BUG_ON(i >= nr_ports);
663 return pdc_port_no_to_ata_no(i, pdc_is_sataii_tx4(ap->flags));
664}
665
666static unsigned int pdc_sata_hotplug_offset(const struct ata_port *ap)
667{
668 return (ap->flags & PDC_FLAG_GEN_II) ? PDC2_SATA_PLUG_CSR : PDC_SATA_PLUG_CSR;
669}
670
634static void pdc_freeze(struct ata_port *ap) 671static void pdc_freeze(struct ata_port *ap)
635{ 672{
636 void __iomem *mmio = ap->ioaddr.cmd_addr; 673 void __iomem *mmio = ap->ioaddr.cmd_addr;
@@ -643,6 +680,29 @@ static void pdc_freeze(struct ata_port *ap)
643 readl(mmio + PDC_CTLSTAT); /* flush */ 680 readl(mmio + PDC_CTLSTAT); /* flush */
644} 681}
645 682
683static void pdc_sata_freeze(struct ata_port *ap)
684{
685 struct ata_host *host = ap->host;
686 void __iomem *host_mmio = host->iomap[PDC_MMIO_BAR];
687 unsigned int hotplug_offset = pdc_sata_hotplug_offset(ap);
688 unsigned int ata_no = pdc_sata_ata_port_to_ata_no(ap);
689 u32 hotplug_status;
690
691 /* Disable hotplug events on this port.
692 *
693 * Locking:
694 * 1) hotplug register accesses must be serialised via host->lock
695 * 2) ap->lock == &ap->host->lock
696 * 3) ->freeze() and ->thaw() are called with ap->lock held
697 */
698 hotplug_status = readl(host_mmio + hotplug_offset);
699 hotplug_status |= 0x11 << (ata_no + 16);
700 writel(hotplug_status, host_mmio + hotplug_offset);
701 readl(host_mmio + hotplug_offset); /* flush */
702
703 pdc_freeze(ap);
704}
705
646static void pdc_thaw(struct ata_port *ap) 706static void pdc_thaw(struct ata_port *ap)
647{ 707{
648 void __iomem *mmio = ap->ioaddr.cmd_addr; 708 void __iomem *mmio = ap->ioaddr.cmd_addr;
@@ -658,6 +718,26 @@ static void pdc_thaw(struct ata_port *ap)
658 readl(mmio + PDC_CTLSTAT); /* flush */ 718 readl(mmio + PDC_CTLSTAT); /* flush */
659} 719}
660 720
721static void pdc_sata_thaw(struct ata_port *ap)
722{
723 struct ata_host *host = ap->host;
724 void __iomem *host_mmio = host->iomap[PDC_MMIO_BAR];
725 unsigned int hotplug_offset = pdc_sata_hotplug_offset(ap);
726 unsigned int ata_no = pdc_sata_ata_port_to_ata_no(ap);
727 u32 hotplug_status;
728
729 pdc_thaw(ap);
730
731 /* Enable hotplug events on this port.
732 * Locking: see pdc_sata_freeze().
733 */
734 hotplug_status = readl(host_mmio + hotplug_offset);
735 hotplug_status |= 0x11 << ata_no;
736 hotplug_status &= ~(0x11 << (ata_no + 16));
737 writel(hotplug_status, host_mmio + hotplug_offset);
738 readl(host_mmio + hotplug_offset); /* flush */
739}
740
661static void pdc_common_error_handler(struct ata_port *ap, ata_reset_fn_t hardreset) 741static void pdc_common_error_handler(struct ata_port *ap, ata_reset_fn_t hardreset)
662{ 742{
663 if (!(ap->pflags & ATA_PFLAG_FROZEN)) 743 if (!(ap->pflags & ATA_PFLAG_FROZEN))
@@ -765,19 +845,6 @@ static void pdc_irq_clear(struct ata_port *ap)
765 readl(mmio + PDC_INT_SEQMASK); 845 readl(mmio + PDC_INT_SEQMASK);
766} 846}
767 847
768static int pdc_is_sataii_tx4(unsigned long flags)
769{
770 const unsigned long mask = PDC_FLAG_GEN_II | PDC_FLAG_4_PORTS;
771 return (flags & mask) == mask;
772}
773
774static unsigned int pdc_port_no_to_ata_no(unsigned int port_no,
775 int is_sataii_tx4)
776{
777 static const unsigned char sataii_tx4_port_remap[4] = { 3, 1, 0, 2};
778 return is_sataii_tx4 ? sataii_tx4_port_remap[port_no] : port_no;
779}
780
781static irqreturn_t pdc_interrupt(int irq, void *dev_instance) 848static irqreturn_t pdc_interrupt(int irq, void *dev_instance)
782{ 849{
783 struct ata_host *host = dev_instance; 850 struct ata_host *host = dev_instance;
@@ -799,6 +866,8 @@ static irqreturn_t pdc_interrupt(int irq, void *dev_instance)
799 866
800 mmio_base = host->iomap[PDC_MMIO_BAR]; 867 mmio_base = host->iomap[PDC_MMIO_BAR];
801 868
869 spin_lock(&host->lock);
870
802 /* read and clear hotplug flags for all ports */ 871 /* read and clear hotplug flags for all ports */
803 if (host->ports[0]->flags & PDC_FLAG_GEN_II) 872 if (host->ports[0]->flags & PDC_FLAG_GEN_II)
804 hotplug_offset = PDC2_SATA_PLUG_CSR; 873 hotplug_offset = PDC2_SATA_PLUG_CSR;
@@ -814,11 +883,9 @@ static irqreturn_t pdc_interrupt(int irq, void *dev_instance)
814 883
815 if (mask == 0xffffffff && hotplug_status == 0) { 884 if (mask == 0xffffffff && hotplug_status == 0) {
816 VPRINTK("QUICK EXIT 2\n"); 885 VPRINTK("QUICK EXIT 2\n");
817 return IRQ_NONE; 886 goto done_irq;
818 } 887 }
819 888
820 spin_lock(&host->lock);
821
822 mask &= 0xffff; /* only 16 tags possible */ 889 mask &= 0xffff; /* only 16 tags possible */
823 if (mask == 0 && hotplug_status == 0) { 890 if (mask == 0 && hotplug_status == 0) {
824 VPRINTK("QUICK EXIT 3\n"); 891 VPRINTK("QUICK EXIT 3\n");
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 7de543d1d0b4..24198ad01976 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -19,6 +19,7 @@
19#include <linux/kdev_t.h> 19#include <linux/kdev_t.h>
20#include <linux/notifier.h> 20#include <linux/notifier.h>
21#include <linux/genhd.h> 21#include <linux/genhd.h>
22#include <linux/kallsyms.h>
22#include <asm/semaphore.h> 23#include <asm/semaphore.h>
23 24
24#include "base.h" 25#include "base.h"
@@ -68,6 +69,10 @@ static ssize_t dev_attr_show(struct kobject *kobj, struct attribute *attr,
68 69
69 if (dev_attr->show) 70 if (dev_attr->show)
70 ret = dev_attr->show(dev, dev_attr, buf); 71 ret = dev_attr->show(dev, dev_attr, buf);
72 if (ret >= (ssize_t)PAGE_SIZE) {
73 print_symbol("dev_attr_show: %s returned bad count\n",
74 (unsigned long)dev_attr->show);
75 }
71 return ret; 76 return ret;
72} 77}
73 78
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index bf31a0170a48..9a6537f14401 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -133,6 +133,7 @@ int driver_add_kobj(struct device_driver *drv, struct kobject *kobj,
133{ 133{
134 va_list args; 134 va_list args;
135 char *name; 135 char *name;
136 int ret;
136 137
137 va_start(args, fmt); 138 va_start(args, fmt);
138 name = kvasprintf(GFP_KERNEL, fmt, args); 139 name = kvasprintf(GFP_KERNEL, fmt, args);
@@ -141,7 +142,9 @@ int driver_add_kobj(struct device_driver *drv, struct kobject *kobj,
141 if (!name) 142 if (!name)
142 return -ENOMEM; 143 return -ENOMEM;
143 144
144 return kobject_add(kobj, &drv->p->kobj, "%s", name); 145 ret = kobject_add(kobj, &drv->p->kobj, "%s", name);
146 kfree(name);
147 return ret;
145} 148}
146EXPORT_SYMBOL_GPL(driver_add_kobj); 149EXPORT_SYMBOL_GPL(driver_add_kobj);
147 150
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index b6d230b3209f..0d1d2133d9bc 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -44,16 +44,6 @@ config MAC_FLOPPY
44 If you have a SWIM-3 (Super Woz Integrated Machine 3; from Apple) 44 If you have a SWIM-3 (Super Woz Integrated Machine 3; from Apple)
45 floppy controller, say Y here. Most commonly found in PowerMacs. 45 floppy controller, say Y here. Most commonly found in PowerMacs.
46 46
47config BLK_DEV_PS2
48 tristate "PS/2 ESDI hard disk support"
49 depends on MCA && MCA_LEGACY && BROKEN
50 help
51 Say Y here if you have a PS/2 machine with a MCA bus and an ESDI
52 hard disk.
53
54 To compile this driver as a module, choose M here: the
55 module will be called ps2esdi.
56
57config AMIGA_Z2RAM 47config AMIGA_Z2RAM
58 tristate "Amiga Zorro II ramdisk support" 48 tristate "Amiga Zorro II ramdisk support"
59 depends on ZORRO 49 depends on ZORRO
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 01c972415cb2..5e584306be99 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -13,7 +13,6 @@ obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o
13obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o 13obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o
14obj-$(CONFIG_BLK_DEV_RAM) += brd.o 14obj-$(CONFIG_BLK_DEV_RAM) += brd.o
15obj-$(CONFIG_BLK_DEV_LOOP) += loop.o 15obj-$(CONFIG_BLK_DEV_LOOP) += loop.o
16obj-$(CONFIG_BLK_DEV_PS2) += ps2esdi.o
17obj-$(CONFIG_BLK_DEV_XD) += xd.o 16obj-$(CONFIG_BLK_DEV_XD) += xd.o
18obj-$(CONFIG_BLK_CPQ_DA) += cpqarray.o 17obj-$(CONFIG_BLK_CPQ_DA) += cpqarray.o
19obj-$(CONFIG_BLK_CPQ_CISS_DA) += cciss.o 18obj-$(CONFIG_BLK_CPQ_CISS_DA) += cciss.o
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index b53fdb0a282c..60cc54368b66 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -153,6 +153,12 @@ static int sock_xmit(struct nbd_device *lo, int send, void *buf, int size,
153 struct kvec iov; 153 struct kvec iov;
154 sigset_t blocked, oldset; 154 sigset_t blocked, oldset;
155 155
156 if (unlikely(!sock)) {
157 printk(KERN_ERR "%s: Attempted %s on closed socket in sock_xmit\n",
158 lo->disk->disk_name, (send ? "send" : "recv"));
159 return -EINVAL;
160 }
161
156 /* Allow interception of SIGKILL only 162 /* Allow interception of SIGKILL only
157 * Don't allow other signals to interrupt the transmission */ 163 * Don't allow other signals to interrupt the transmission */
158 siginitsetinv(&blocked, sigmask(SIGKILL)); 164 siginitsetinv(&blocked, sigmask(SIGKILL));
diff --git a/drivers/block/ps2esdi.c b/drivers/block/ps2esdi.c
deleted file mode 100644
index 3c796e236253..000000000000
--- a/drivers/block/ps2esdi.c
+++ /dev/null
@@ -1,1079 +0,0 @@
1/* ps2esdi driver based on assembler code by Arindam Banerji,
2 written by Peter De Schrijver */
3/* Reassuring note to IBM : This driver was NOT developed by vice-versa
4 engineering the PS/2's BIOS */
5/* Dedicated to Wannes, Tofke, Ykke, Godot, Killroy and all those
6 other lovely fish out there... */
7/* This code was written during the long and boring WINA
8 elections 1994 */
9/* Thanks to Arindam Banerij for giving me the source of his driver */
10/* This code may be freely distributed and modified in any way,
11 as long as these notes remain intact */
12
13/* Revised: 05/07/94 by Arindam Banerji (axb@cse.nd.edu) */
14/* Revised: 09/08/94 by Peter De Schrijver (stud11@cc4.kuleuven.ac.be)
15 Thanks to Arindam Banerij for sending me the docs of the adapter */
16
17/* BA Modified for ThinkPad 720 by Boris Ashkinazi */
18/* (bash@vnet.ibm.com) 08/08/95 */
19
20/* Modified further for ThinkPad-720C by Uri Blumenthal */
21/* (uri@watson.ibm.com) Sep 11, 1995 */
22
23/* TODO :
24 + Timeouts
25 + Get disk parameters
26 + DMA above 16MB
27 + reset after read/write error
28 */
29
30#define DEVICE_NAME "PS/2 ESDI"
31
32#include <linux/major.h>
33#include <linux/errno.h>
34#include <linux/wait.h>
35#include <linux/interrupt.h>
36#include <linux/fs.h>
37#include <linux/kernel.h>
38#include <linux/genhd.h>
39#include <linux/ps2esdi.h>
40#include <linux/blkdev.h>
41#include <linux/mca-legacy.h>
42#include <linux/init.h>
43#include <linux/ioport.h>
44#include <linux/module.h>
45#include <linux/hdreg.h>
46
47#include <asm/system.h>
48#include <asm/io.h>
49#include <asm/dma.h>
50#include <asm/mca_dma.h>
51#include <asm/uaccess.h>
52
53#define PS2ESDI_IRQ 14
54#define MAX_HD 2
55#define MAX_RETRIES 5
56#define MAX_16BIT 65536
57#define ESDI_TIMEOUT 0xf000
58#define ESDI_STAT_TIMEOUT 4
59
60#define TYPE_0_CMD_BLK_LENGTH 2
61#define TYPE_1_CMD_BLK_LENGTH 4
62
63static void reset_ctrl(void);
64
65static int ps2esdi_geninit(void);
66
67static void do_ps2esdi_request(struct request_queue * q);
68
69static void ps2esdi_readwrite(int cmd, struct request *req);
70
71static void ps2esdi_fill_cmd_block(u_short * cmd_blk, u_short cmd,
72u_short cyl, u_short head, u_short sector, u_short length, u_char drive);
73
74static int ps2esdi_out_cmd_blk(u_short * cmd_blk);
75
76static void ps2esdi_prep_dma(char *buffer, u_short length, u_char dma_xmode);
77
78static irqreturn_t ps2esdi_interrupt_handler(int irq, void *dev_id);
79static void (*current_int_handler) (u_int) = NULL;
80static void ps2esdi_normal_interrupt_handler(u_int);
81static void ps2esdi_initial_reset_int_handler(u_int);
82static void ps2esdi_geometry_int_handler(u_int);
83static int ps2esdi_getgeo(struct block_device *bdev, struct hd_geometry *geo);
84
85static int ps2esdi_read_status_words(int num_words, int max_words, u_short * buffer);
86
87static void dump_cmd_complete_status(u_int int_ret_code);
88
89static void ps2esdi_get_device_cfg(void);
90
91static void ps2esdi_reset_timer(unsigned long unused);
92
93static u_int dma_arb_level; /* DMA arbitration level */
94
95static DECLARE_WAIT_QUEUE_HEAD(ps2esdi_int);
96
97static int no_int_yet;
98static int ps2esdi_drives;
99static u_short io_base;
100static DEFINE_TIMER(esdi_timer, ps2esdi_reset_timer, 0, 0);
101static int reset_status;
102static int ps2esdi_slot = -1;
103static int tp720esdi = 0; /* Is it Integrated ESDI of ThinkPad-720? */
104static int intg_esdi = 0; /* If integrated adapter */
105struct ps2esdi_i_struct {
106 unsigned int head, sect, cyl, wpcom, lzone, ctl;
107};
108static DEFINE_SPINLOCK(ps2esdi_lock);
109static struct request_queue *ps2esdi_queue;
110static struct request *current_req;
111
112#if 0
113#if 0 /* try both - I don't know which one is better... UB */
114static struct ps2esdi_i_struct ps2esdi_info[MAX_HD] =
115{
116 {4, 48, 1553, 0, 0, 0},
117 {0, 0, 0, 0, 0, 0}};
118#else
119static struct ps2esdi_i_struct ps2esdi_info[MAX_HD] =
120{
121 {64, 32, 161, 0, 0, 0},
122 {0, 0, 0, 0, 0, 0}};
123#endif
124#endif
125static struct ps2esdi_i_struct ps2esdi_info[MAX_HD] =
126{
127 {0, 0, 0, 0, 0, 0},
128 {0, 0, 0, 0, 0, 0}};
129
130static struct block_device_operations ps2esdi_fops =
131{
132 .owner = THIS_MODULE,
133 .getgeo = ps2esdi_getgeo,
134};
135
136static struct gendisk *ps2esdi_gendisk[2];
137
138/* initialization routine called by ll_rw_blk.c */
139static int __init ps2esdi_init(void)
140{
141
142 int error = 0;
143
144 /* register the device - pass the name and major number */
145 if (register_blkdev(PS2ESDI_MAJOR, "ed"))
146 return -EBUSY;
147
148 /* set up some global information - indicating device specific info */
149 ps2esdi_queue = blk_init_queue(do_ps2esdi_request, &ps2esdi_lock);
150 if (!ps2esdi_queue) {
151 unregister_blkdev(PS2ESDI_MAJOR, "ed");
152 return -ENOMEM;
153 }
154
155 /* some minor housekeeping - setup the global gendisk structure */
156 error = ps2esdi_geninit();
157 if (error) {
158 printk(KERN_WARNING "PS2ESDI: error initialising"
159 " device, releasing resources\n");
160 unregister_blkdev(PS2ESDI_MAJOR, "ed");
161 blk_cleanup_queue(ps2esdi_queue);
162 return error;
163 }
164 return 0;
165} /* ps2esdi_init */
166
167#ifndef MODULE
168
169module_init(ps2esdi_init);
170
171#else
172
173static int cyl[MAX_HD] = {-1,-1};
174static int head[MAX_HD] = {-1, -1};
175static int sect[MAX_HD] = {-1, -1};
176
177module_param(tp720esdi, bool, 0);
178module_param_array(cyl, int, NULL, 0);
179module_param_array(head, int, NULL, 0);
180module_param_array(sect, int, NULL, 0);
181MODULE_LICENSE("GPL");
182
183int init_module(void) {
184 int drive;
185
186 for(drive = 0; drive < MAX_HD; drive++) {
187 struct ps2esdi_i_struct *info = &ps2esdi_info[drive];
188
189 if (cyl[drive] != -1) {
190 info->cyl = info->lzone = cyl[drive];
191 info->wpcom = 0;
192 }
193 if (head[drive] != -1) {
194 info->head = head[drive];
195 info->ctl = (head[drive] > 8 ? 8 : 0);
196 }
197 if (sect[drive] != -1) info->sect = sect[drive];
198 }
199 return ps2esdi_init();
200}
201
202void
203cleanup_module(void) {
204 int i;
205 if(ps2esdi_slot) {
206 mca_mark_as_unused(ps2esdi_slot);
207 mca_set_adapter_procfn(ps2esdi_slot, NULL, NULL);
208 }
209 release_region(io_base, 4);
210 free_dma(dma_arb_level);
211 free_irq(PS2ESDI_IRQ, &ps2esdi_gendisk);
212 unregister_blkdev(PS2ESDI_MAJOR, "ed");
213 blk_cleanup_queue(ps2esdi_queue);
214 for (i = 0; i < ps2esdi_drives; i++) {
215 del_gendisk(ps2esdi_gendisk[i]);
216 put_disk(ps2esdi_gendisk[i]);
217 }
218}
219#endif /* MODULE */
220
221/* handles boot time command line parameters */
222void __init tp720_setup(char *str, int *ints)
223{
224 /* no params, just sets the tp720esdi flag if it exists */
225
226 printk("%s: TP 720 ESDI flag set\n", DEVICE_NAME);
227 tp720esdi = 1;
228}
229
230void __init ed_setup(char *str, int *ints)
231{
232 int hdind = 0;
233
234 /* handles 3 parameters only - corresponding to
235 1. Number of cylinders
236 2. Number of heads
237 3. Sectors/track
238 */
239
240 if (ints[0] != 3)
241 return;
242
243 /* print out the information - seen at boot time */
244 printk("%s: ints[0]=%d ints[1]=%d ints[2]=%d ints[3]=%d\n",
245 DEVICE_NAME, ints[0], ints[1], ints[2], ints[3]);
246
247 /* set the index into device specific information table */
248 if (ps2esdi_info[0].head != 0)
249 hdind = 1;
250
251 /* set up all the device information */
252 ps2esdi_info[hdind].head = ints[2];
253 ps2esdi_info[hdind].sect = ints[3];
254 ps2esdi_info[hdind].cyl = ints[1];
255 ps2esdi_info[hdind].wpcom = 0;
256 ps2esdi_info[hdind].lzone = ints[1];
257 ps2esdi_info[hdind].ctl = (ints[2] > 8 ? 8 : 0);
258#if 0 /* this may be needed for PS2/Mod.80, but it hurts ThinkPad! */
259 ps2esdi_drives = hdind + 1; /* increment index for the next time */
260#endif
261} /* ed_setup */
262
263static int ps2esdi_getinfo(char *buf, int slot, void *d)
264{
265 int len = 0;
266
267 len += sprintf(buf + len, "DMA Arbitration Level: %d\n",
268 dma_arb_level);
269 len += sprintf(buf + len, "IO Port: %x\n", io_base);
270 len += sprintf(buf + len, "IRQ: 14\n");
271 len += sprintf(buf + len, "Drives: %d\n", ps2esdi_drives);
272
273 return len;
274}
275
276/* ps2 esdi specific initialization - called thru the gendisk chain */
277static int __init ps2esdi_geninit(void)
278{
279 /*
280 The first part contains the initialization code
281 for the ESDI disk subsystem. All we really do
282 is search for the POS registers of the controller
283 to do some simple setup operations. First, we
284 must ensure that the controller is installed,
285 enabled, and configured as PRIMARY. Then we must
286 determine the DMA arbitration level being used by
287 the controller so we can handle data transfer
288 operations properly. If all of this works, then
289 we will set the INIT_FLAG to a non-zero value.
290 */
291
292 int slot = 0, i, reset_start, reset_end;
293 u_char status;
294 unsigned short adapterID;
295 int error = 0;
296
297 if ((slot = mca_find_adapter(INTG_ESDI_ID, 0)) != MCA_NOTFOUND) {
298 adapterID = INTG_ESDI_ID;
299 printk("%s: integrated ESDI adapter found in slot %d\n",
300 DEVICE_NAME, slot+1);
301#ifndef MODULE
302 mca_set_adapter_name(slot, "PS/2 Integrated ESDI");
303#endif
304 } else if ((slot = mca_find_adapter(NRML_ESDI_ID, 0)) != -1) {
305 adapterID = NRML_ESDI_ID;
306 printk("%s: normal ESDI adapter found in slot %d\n",
307 DEVICE_NAME, slot+1);
308 mca_set_adapter_name(slot, "PS/2 ESDI");
309 } else {
310 return -ENODEV;
311 }
312
313 ps2esdi_slot = slot;
314 mca_mark_as_used(slot);
315 mca_set_adapter_procfn(slot, (MCA_ProcFn) ps2esdi_getinfo, NULL);
316
317 /* Found the slot - read the POS register 2 to get the necessary
318 configuration and status information. POS register 2 has the
319 following information :
320 Bit Function
321 7 reserved = 0
322 6 arbitration method
323 0 - fairness enabled
324 1 - fairness disabled, linear priority assignment
325 5-2 arbitration level
326 1 alternate address
327 1 alternate address
328 0 - use addresses 0x3510 - 0x3517
329 0 adapter enable
330 */
331
332 status = mca_read_stored_pos(slot, 2);
333 /* is it enabled ? */
334 if (!(status & STATUS_ENABLED)) {
335 printk("%s: ESDI adapter disabled\n", DEVICE_NAME);
336 error = -ENODEV;
337 goto err_out1;
338 }
339 /* try to grab IRQ, and try to grab a slow IRQ if it fails, so we can
340 share with the SCSI driver */
341 if (request_irq(PS2ESDI_IRQ, ps2esdi_interrupt_handler,
342 IRQF_DISABLED | IRQF_SHARED, "PS/2 ESDI", &ps2esdi_gendisk)
343 && request_irq(PS2ESDI_IRQ, ps2esdi_interrupt_handler,
344 IRQF_SHARED, "PS/2 ESDI", &ps2esdi_gendisk)
345 ) {
346 printk("%s: Unable to get IRQ %d\n", DEVICE_NAME, PS2ESDI_IRQ);
347 error = -EBUSY;
348 goto err_out1;
349 }
350 if (status & STATUS_ALTERNATE)
351 io_base = ALT_IO_BASE;
352 else
353 io_base = PRIMARY_IO_BASE;
354
355 if (!request_region(io_base, 4, "ed")) {
356 printk(KERN_WARNING"Unable to request region 0x%x\n", io_base);
357 error = -EBUSY;
358 goto err_out2;
359 }
360 /* get the dma arbitration level */
361 dma_arb_level = (status >> 2) & 0xf;
362
363 /* BA */
364 printk("%s: DMA arbitration level : %d\n",
365 DEVICE_NAME, dma_arb_level);
366
367 LITE_ON;
368 current_int_handler = ps2esdi_initial_reset_int_handler;
369 reset_ctrl();
370 reset_status = 0;
371 reset_start = jiffies;
372 while (!reset_status) {
373 init_timer(&esdi_timer);
374 esdi_timer.expires = jiffies + HZ;
375 esdi_timer.data = 0;
376 add_timer(&esdi_timer);
377 sleep_on(&ps2esdi_int);
378 }
379 reset_end = jiffies;
380 LITE_OFF;
381 printk("%s: reset interrupt after %d jiffies, %u.%02u secs\n",
382 DEVICE_NAME, reset_end - reset_start, (reset_end - reset_start) / HZ,
383 (reset_end - reset_start) % HZ);
384
385
386 /* Integrated ESDI Disk and Controller has only one drive! */
387 if (adapterID == INTG_ESDI_ID) {/* if not "normal" PS2 ESDI adapter */
388 ps2esdi_drives = 1; /* then we have only one physical disk! */ intg_esdi = 1;
389 }
390
391
392
393 /* finally this part sets up some global data structures etc. */
394
395 ps2esdi_get_device_cfg();
396
397 /* some annoyance in the above routine returns TWO drives?
398 Is something else happining in the background?
399 Regaurdless we fix the # of drives again. AJK */
400 /* Integrated ESDI Disk and Controller has only one drive! */
401 if (adapterID == INTG_ESDI_ID) /* if not "normal" PS2 ESDI adapter */
402 ps2esdi_drives = 1; /* Not three or two, ONE DAMNIT! */
403
404 current_int_handler = ps2esdi_normal_interrupt_handler;
405
406 if (request_dma(dma_arb_level, "ed") !=0) {
407 printk(KERN_WARNING "PS2ESDI: Can't request dma-channel %d\n"
408 ,(int) dma_arb_level);
409 error = -EBUSY;
410 goto err_out3;
411 }
412 blk_queue_max_sectors(ps2esdi_queue, 128);
413
414 error = -ENOMEM;
415 for (i = 0; i < ps2esdi_drives; i++) {
416 struct gendisk *disk = alloc_disk(64);
417 if (!disk)
418 goto err_out4;
419 disk->major = PS2ESDI_MAJOR;
420 disk->first_minor = i<<6;
421 sprintf(disk->disk_name, "ed%c", 'a'+i);
422 disk->fops = &ps2esdi_fops;
423 ps2esdi_gendisk[i] = disk;
424 }
425
426 for (i = 0; i < ps2esdi_drives; i++) {
427 struct gendisk *disk = ps2esdi_gendisk[i];
428 set_capacity(disk, ps2esdi_info[i].head * ps2esdi_info[i].sect *
429 ps2esdi_info[i].cyl);
430 disk->queue = ps2esdi_queue;
431 disk->private_data = &ps2esdi_info[i];
432 add_disk(disk);
433 }
434 return 0;
435err_out4:
436 while (i--)
437 put_disk(ps2esdi_gendisk[i]);
438err_out3:
439 release_region(io_base, 4);
440err_out2:
441 free_irq(PS2ESDI_IRQ, &ps2esdi_gendisk);
442err_out1:
443 if(ps2esdi_slot) {
444 mca_mark_as_unused(ps2esdi_slot);
445 mca_set_adapter_procfn(ps2esdi_slot, NULL, NULL);
446 }
447 return error;
448}
449
450static void __init ps2esdi_get_device_cfg(void)
451{
452 u_short cmd_blk[TYPE_0_CMD_BLK_LENGTH];
453
454 /*BA */ printk("%s: Drive 0\n", DEVICE_NAME);
455 current_int_handler = ps2esdi_geometry_int_handler;
456 cmd_blk[0] = CMD_GET_DEV_CONFIG | 0x600;
457 cmd_blk[1] = 0;
458 no_int_yet = TRUE;
459 ps2esdi_out_cmd_blk(cmd_blk);
460 if (no_int_yet)
461 sleep_on(&ps2esdi_int);
462
463 if (ps2esdi_drives > 1) {
464 printk("%s: Drive 1\n", DEVICE_NAME); /*BA */
465 cmd_blk[0] = CMD_GET_DEV_CONFIG | (1 << 5) | 0x600;
466 cmd_blk[1] = 0;
467 no_int_yet = TRUE;
468 ps2esdi_out_cmd_blk(cmd_blk);
469 if (no_int_yet)
470 sleep_on(&ps2esdi_int);
471 } /* if second physical drive is present */
472 return;
473}
474
475/* strategy routine that handles most of the IO requests */
476static void do_ps2esdi_request(struct request_queue * q)
477{
478 struct request *req;
479 /* since, this routine is called with interrupts cleared - they
480 must be before it finishes */
481
482 req = elv_next_request(q);
483 if (!req)
484 return;
485
486#if 0
487 printk("%s:got request. device : %s command : %d sector : %ld count : %ld, buffer: %p\n",
488 DEVICE_NAME,
489 req->rq_disk->disk_name,
490 req->cmd, req->sector,
491 req->current_nr_sectors, req->buffer);
492#endif
493
494 /* check for above 16Mb dmas */
495 if (isa_virt_to_bus(req->buffer + req->current_nr_sectors * 512) > 16 * MB) {
496 printk("%s: DMA above 16MB not supported\n", DEVICE_NAME);
497 end_request(req, FAIL);
498 return;
499 }
500
501 if (req->sector+req->current_nr_sectors > get_capacity(req->rq_disk)) {
502 printk("Grrr. error. ps2esdi_drives: %d, %llu %llu\n",
503 ps2esdi_drives, req->sector,
504 (unsigned long long)get_capacity(req->rq_disk));
505 end_request(req, FAIL);
506 return;
507 }
508
509 switch (rq_data_dir(req)) {
510 case READ:
511 ps2esdi_readwrite(READ, req);
512 break;
513 case WRITE:
514 ps2esdi_readwrite(WRITE, req);
515 break;
516 default:
517 printk("%s: Unknown command\n", req->rq_disk->disk_name);
518 end_request(req, FAIL);
519 break;
520 } /* handle different commands */
521} /* main strategy routine */
522
523/* resets the ESDI adapter */
524static void reset_ctrl(void)
525{
526
527 u_long expire;
528 u_short status;
529
530 /* enable interrupts on the controller */
531 status = inb(ESDI_INTRPT);
532 outb((status & 0xe0) | ATT_EOI, ESDI_ATTN); /* to be sure we don't have
533 any interrupt pending... */
534 outb_p(CTRL_ENABLE_INTR, ESDI_CONTROL);
535
536 /* read the ESDI status port - if the controller is not busy,
537 simply do a soft reset (fast) - otherwise we'll have to do a
538 hard (slow) reset. */
539 if (!(inb_p(ESDI_STATUS) & STATUS_BUSY)) {
540 /*BA */ printk("%s: soft reset...\n", DEVICE_NAME);
541 outb_p(CTRL_SOFT_RESET, ESDI_ATTN);
542 }
543 /* soft reset */
544 else {
545 /*BA */
546 printk("%s: hard reset...\n", DEVICE_NAME);
547 outb_p(CTRL_HARD_RESET, ESDI_CONTROL);
548 expire = jiffies + 2*HZ;
549 while (time_before(jiffies, expire));
550 outb_p(1, ESDI_CONTROL);
551 } /* hard reset */
552
553
554} /* reset the controller */
555
556/* called by the strategy routine to handle read and write requests */
557static void ps2esdi_readwrite(int cmd, struct request *req)
558{
559 struct ps2esdi_i_struct *p = req->rq_disk->private_data;
560 unsigned block = req->sector;
561 unsigned count = req->current_nr_sectors;
562 int drive = p - ps2esdi_info;
563 u_short track, head, cylinder, sector;
564 u_short cmd_blk[TYPE_1_CMD_BLK_LENGTH];
565
566 /* do some relevant arithmatic */
567 track = block / p->sect;
568 head = track % p->head;
569 cylinder = track / p->head;
570 sector = block % p->sect;
571
572#if 0
573 printk("%s: cyl=%d head=%d sect=%d\n", DEVICE_NAME, cylinder, head, sector);
574#endif
575 /* call the routine that actually fills out a command block */
576 ps2esdi_fill_cmd_block
577 (cmd_blk,
578 (cmd == READ) ? CMD_READ : CMD_WRITE,
579 cylinder, head, sector, count, drive);
580
581 /* send the command block to the controller */
582 current_req = req;
583 spin_unlock_irq(&ps2esdi_lock);
584 if (ps2esdi_out_cmd_blk(cmd_blk)) {
585 spin_lock_irq(&ps2esdi_lock);
586 printk("%s: Controller failed\n", DEVICE_NAME);
587 if ((++req->errors) >= MAX_RETRIES)
588 end_request(req, FAIL);
589 }
590 /* check for failure to put out the command block */
591 else {
592 spin_lock_irq(&ps2esdi_lock);
593#if 0
594 printk("%s: waiting for xfer\n", DEVICE_NAME);
595#endif
596 /* turn disk lights on */
597 LITE_ON;
598 }
599
600} /* ps2esdi_readwrite */
601
602/* fill out the command block */
603static void ps2esdi_fill_cmd_block(u_short * cmd_blk, u_short cmd,
604 u_short cyl, u_short head, u_short sector, u_short length, u_char drive)
605{
606
607 cmd_blk[0] = (drive << 5) | cmd;
608 cmd_blk[1] = length;
609 cmd_blk[2] = ((cyl & 0x1f) << 11) | (head << 5) | sector;
610 cmd_blk[3] = (cyl & 0x3E0) >> 5;
611
612} /* fill out the command block */
613
614/* write a command block to the controller */
615static int ps2esdi_out_cmd_blk(u_short * cmd_blk)
616{
617
618 int i;
619 unsigned long jif;
620 u_char status;
621
622 /* enable interrupts */
623 outb(CTRL_ENABLE_INTR, ESDI_CONTROL);
624
625 /* do not write to the controller, if it is busy */
626 for (jif = jiffies + ESDI_STAT_TIMEOUT;
627 time_after(jif, jiffies) &&
628 (inb(ESDI_STATUS) & STATUS_BUSY); )
629 ;
630
631#if 0
632 printk("%s: i(1)=%ld\n", DEVICE_NAME, jif);
633#endif
634
635 /* if device is still busy - then just time out */
636 if (inb(ESDI_STATUS) & STATUS_BUSY) {
637 printk("%s: ps2esdi_out_cmd timed out (1)\n", DEVICE_NAME);
638 return ERROR;
639 } /* timeout ??? */
640 /* Set up the attention register in the controller */
641 outb(((*cmd_blk) & 0xE0) | 1, ESDI_ATTN);
642
643#if 0
644 printk("%s: sending %d words to controller\n", DEVICE_NAME, (((*cmd_blk) >> 14) + 1) << 1);
645#endif
646
647 /* one by one send each word out */
648 for (i = (((*cmd_blk) >> 14) + 1) << 1; i; i--) {
649 status = inb(ESDI_STATUS);
650 for (jif = jiffies + ESDI_STAT_TIMEOUT;
651 time_after(jif, jiffies) && (status & STATUS_BUSY) &&
652 (status & STATUS_CMD_INF); status = inb(ESDI_STATUS));
653 if ((status & (STATUS_BUSY | STATUS_CMD_INF)) == STATUS_BUSY) {
654#if 0
655 printk("%s: sending %04X\n", DEVICE_NAME, *cmd_blk);
656#endif
657 outw(*cmd_blk++, ESDI_CMD_INT);
658 } else {
659 printk("%s: ps2esdi_out_cmd timed out while sending command (status=%02X)\n",
660 DEVICE_NAME, status);
661 return ERROR;
662 }
663 } /* send all words out */
664 return OK;
665} /* send out the commands */
666
667
668/* prepare for dma - do all the necessary setup */
669static void ps2esdi_prep_dma(char *buffer, u_short length, u_char dma_xmode)
670{
671 unsigned long flags = claim_dma_lock();
672
673 mca_disable_dma(dma_arb_level);
674
675 mca_set_dma_addr(dma_arb_level, isa_virt_to_bus(buffer));
676
677 mca_set_dma_count(dma_arb_level, length * 512 / 2);
678
679 mca_set_dma_mode(dma_arb_level, dma_xmode);
680
681 mca_enable_dma(dma_arb_level);
682
683 release_dma_lock(flags);
684
685} /* prepare for dma */
686
687
688
689static irqreturn_t ps2esdi_interrupt_handler(int irq, void *dev_id)
690{
691 u_int int_ret_code;
692
693 if (inb(ESDI_STATUS) & STATUS_INTR) {
694 int_ret_code = inb(ESDI_INTRPT);
695 if (current_int_handler) {
696 /* Disable adapter interrupts till processing is finished */
697 outb(CTRL_DISABLE_INTR, ESDI_CONTROL);
698 current_int_handler(int_ret_code);
699 } else
700 printk("%s: help ! No interrupt handler.\n", DEVICE_NAME);
701 } else {
702 return IRQ_NONE;
703 }
704 return IRQ_HANDLED;
705}
706
707static void ps2esdi_initial_reset_int_handler(u_int int_ret_code)
708{
709
710 switch (int_ret_code & 0xf) {
711 case INT_RESET:
712 /*BA */
713 printk("%s: initial reset completed.\n", DEVICE_NAME);
714 outb((int_ret_code & 0xe0) | ATT_EOI, ESDI_ATTN);
715 wake_up(&ps2esdi_int);
716 break;
717 case INT_ATTN_ERROR:
718 printk("%s: Attention error. interrupt status : %02X\n", DEVICE_NAME,
719 int_ret_code);
720 printk("%s: status: %02x\n", DEVICE_NAME, inb(ESDI_STATUS));
721 break;
722 default:
723 printk("%s: initial reset handler received interrupt: %02X\n",
724 DEVICE_NAME, int_ret_code);
725 outb((int_ret_code & 0xe0) | ATT_EOI, ESDI_ATTN);
726 break;
727 }
728 outb(CTRL_ENABLE_INTR, ESDI_CONTROL);
729}
730
731
732static void ps2esdi_geometry_int_handler(u_int int_ret_code)
733{
734 u_int status, drive_num;
735 unsigned long rba;
736 int i;
737
738 drive_num = int_ret_code >> 5;
739 switch (int_ret_code & 0xf) {
740 case INT_CMD_COMPLETE:
741 for (i = ESDI_TIMEOUT; i && !(inb(ESDI_STATUS) & STATUS_STAT_AVAIL); i--);
742 if (!(inb(ESDI_STATUS) & STATUS_STAT_AVAIL)) {
743 printk("%s: timeout reading status word\n", DEVICE_NAME);
744 outb((int_ret_code & 0xe0) | ATT_EOI, ESDI_ATTN);
745 break;
746 }
747 status = inw(ESDI_STT_INT);
748 if ((status & 0x1F) == CMD_GET_DEV_CONFIG) {
749#define REPLY_WORDS 5 /* we already read word 0 */
750 u_short reply[REPLY_WORDS];
751
752 if (ps2esdi_read_status_words((status >> 8) - 1, REPLY_WORDS, reply)) {
753 /*BA */
754 printk("%s: Device Configuration Status for drive %u\n",
755 DEVICE_NAME, drive_num);
756
757 printk("%s: Spares/cyls: %u", DEVICE_NAME, reply[0] >> 8);
758
759 printk
760 ("Config bits: %s%s%s%s%s\n",
761 (reply[0] & CONFIG_IS) ? "Invalid Secondary, " : "",
762 ((reply[0] & CONFIG_ZD) && !(reply[0] & CONFIG_IS))
763 ? "Zero Defect, " : "Defects Present, ",
764 (reply[0] & CONFIG_SF) ? "Skewed Format, " : "",
765 (reply[0] & CONFIG_FR) ? "Removable, " : "Non-Removable, ",
766 (reply[0] & CONFIG_RT) ? "No Retries" : "Retries");
767
768 rba = reply[1] | ((unsigned long) reply[2] << 16);
769 printk("%s: Number of RBA's: %lu\n", DEVICE_NAME, rba);
770
771 printk("%s: Physical number of cylinders: %u, Sectors/Track: %u, Heads: %u\n",
772 DEVICE_NAME, reply[3], reply[4] >> 8, reply[4] & 0xff);
773
774 if (!ps2esdi_info[drive_num].head) {
775 ps2esdi_info[drive_num].head = 64;
776 ps2esdi_info[drive_num].sect = 32;
777 ps2esdi_info[drive_num].cyl = rba / (64 * 32);
778 ps2esdi_info[drive_num].wpcom = 0;
779 ps2esdi_info[drive_num].lzone = ps2esdi_info[drive_num].cyl;
780 ps2esdi_info[drive_num].ctl = 8;
781 if (tp720esdi) { /* store the retrieved parameters */
782 ps2esdi_info[0].head = reply[4] & 0Xff;
783 ps2esdi_info[0].sect = reply[4] >> 8;
784 ps2esdi_info[0].cyl = reply[3];
785 ps2esdi_info[0].wpcom = 0;
786 ps2esdi_info[0].lzone = reply[3];
787 } else {
788 if (!intg_esdi)
789 ps2esdi_drives++;
790 }
791 }
792#ifdef OBSOLETE
793 if (!ps2esdi_info[drive_num].head) {
794 ps2esdi_info[drive_num].head = reply[4] & 0Xff;
795 ps2esdi_info[drive_num].sect = reply[4] >> 8;
796 ps2esdi_info[drive_num].cyl = reply[3];
797 ps2esdi_info[drive_num].wpcom = 0;
798 ps2esdi_info[drive_num].lzone = reply[3];
799 if (tp720esdi) { /* store the retrieved parameters */
800 ps2esdi_info[0].head = reply[4] & 0Xff;
801 ps2esdi_info[0].sect = reply[4] >> 8;
802 ps2esdi_info[0].cyl = reply[3];
803 ps2esdi_info[0].wpcom = 0;
804 ps2esdi_info[0].lzone = reply[3];
805 } else {
806 ps2esdi_drives++;
807 }
808 }
809#endif
810
811 } else
812 printk("%s: failed while getting device config\n", DEVICE_NAME);
813#undef REPLY_WORDS
814 } else
815 printk("%s: command %02X unknown by geometry handler\n",
816 DEVICE_NAME, status & 0x1f);
817
818 outb((int_ret_code & 0xe0) | ATT_EOI, ESDI_ATTN);
819 break;
820
821 case INT_ATTN_ERROR:
822 printk("%s: Attention error. interrupt status : %02X\n", DEVICE_NAME,
823 int_ret_code);
824 printk("%s: Device not available\n", DEVICE_NAME);
825 break;
826 case INT_CMD_ECC:
827 case INT_CMD_RETRY:
828 case INT_CMD_ECC_RETRY:
829 case INT_CMD_WARNING:
830 case INT_CMD_ABORT:
831 case INT_CMD_FAILED:
832 case INT_DMA_ERR:
833 case INT_CMD_BLK_ERR:
834 /*BA */ printk("%s: Whaa. Error occurred...\n", DEVICE_NAME);
835 dump_cmd_complete_status(int_ret_code);
836 outb((int_ret_code & 0xe0) | ATT_EOI, ESDI_ATTN);
837 break;
838 default:
839 printk("%s: Unknown interrupt reason: %02X\n",
840 DEVICE_NAME, int_ret_code & 0xf);
841 outb((int_ret_code & 0xe0) | ATT_EOI, ESDI_ATTN);
842 break;
843 }
844
845 wake_up(&ps2esdi_int);
846 no_int_yet = FALSE;
847 outb(CTRL_ENABLE_INTR, ESDI_CONTROL);
848
849}
850
851static void ps2esdi_normal_interrupt_handler(u_int int_ret_code)
852{
853 unsigned long flags;
854 u_int status;
855 u_int ending;
856 int i;
857
858 switch (int_ret_code & 0x0f) {
859 case INT_TRANSFER_REQ:
860 ps2esdi_prep_dma(current_req->buffer,
861 current_req->current_nr_sectors,
862 (rq_data_dir(current_req) == READ)
863 ? MCA_DMA_MODE_16 | MCA_DMA_MODE_WRITE | MCA_DMA_MODE_XFER
864 : MCA_DMA_MODE_16 | MCA_DMA_MODE_READ);
865 outb(CTRL_ENABLE_DMA | CTRL_ENABLE_INTR, ESDI_CONTROL);
866 ending = -1;
867 break;
868
869 case INT_ATTN_ERROR:
870 printk("%s: Attention error. interrupt status : %02X\n", DEVICE_NAME,
871 int_ret_code);
872 outb(CTRL_ENABLE_INTR, ESDI_CONTROL);
873 ending = FAIL;
874 break;
875
876 case INT_CMD_COMPLETE:
877 for (i = ESDI_TIMEOUT; i && !(inb(ESDI_STATUS) & STATUS_STAT_AVAIL); i--);
878 if (!(inb(ESDI_STATUS) & STATUS_STAT_AVAIL)) {
879 printk("%s: timeout reading status word\n", DEVICE_NAME);
880 outb((int_ret_code & 0xe0) | ATT_EOI, ESDI_ATTN);
881 outb(CTRL_ENABLE_INTR, ESDI_CONTROL);
882 if ((++current_req->errors) >= MAX_RETRIES)
883 ending = FAIL;
884 else
885 ending = -1;
886 break;
887 }
888 status = inw(ESDI_STT_INT);
889 switch (status & 0x1F) {
890 case (CMD_READ & 0xff):
891 case (CMD_WRITE & 0xff):
892 LITE_OFF;
893 outb((int_ret_code & 0xe0) | ATT_EOI, ESDI_ATTN);
894 outb(CTRL_ENABLE_INTR, ESDI_CONTROL);
895 ending = SUCCES;
896 break;
897 default:
898 printk("%s: interrupt for unknown command %02X\n",
899 DEVICE_NAME, status & 0x1f);
900 outb((int_ret_code & 0xe0) | ATT_EOI, ESDI_ATTN);
901 outb(CTRL_ENABLE_INTR, ESDI_CONTROL);
902 ending = -1;
903 break;
904 }
905 break;
906 case INT_CMD_ECC:
907 case INT_CMD_RETRY:
908 case INT_CMD_ECC_RETRY:
909 LITE_OFF;
910 dump_cmd_complete_status(int_ret_code);
911 outb((int_ret_code & 0xe0) | ATT_EOI, ESDI_ATTN);
912 outb(CTRL_ENABLE_INTR, ESDI_CONTROL);
913 ending = SUCCES;
914 break;
915 case INT_CMD_WARNING:
916 case INT_CMD_ABORT:
917 case INT_CMD_FAILED:
918 case INT_DMA_ERR:
919 LITE_OFF;
920 dump_cmd_complete_status(int_ret_code);
921 outb((int_ret_code & 0xe0) | ATT_EOI, ESDI_ATTN);
922 outb(CTRL_ENABLE_INTR, ESDI_CONTROL);
923 if ((++current_req->errors) >= MAX_RETRIES)
924 ending = FAIL;
925 else
926 ending = -1;
927 break;
928
929 case INT_CMD_BLK_ERR:
930 dump_cmd_complete_status(int_ret_code);
931 outb((int_ret_code & 0xe0) | ATT_EOI, ESDI_ATTN);
932 outb(CTRL_ENABLE_INTR, ESDI_CONTROL);
933 ending = FAIL;
934 break;
935
936 case INT_CMD_FORMAT:
937 printk("%s: huh ? Who issued this format command ?\n"
938 ,DEVICE_NAME);
939 outb((int_ret_code & 0xe0) | ATT_EOI, ESDI_ATTN);
940 outb(CTRL_ENABLE_INTR, ESDI_CONTROL);
941 ending = -1;
942 break;
943
944 case INT_RESET:
945 /* BA printk("%s: reset completed.\n", DEVICE_NAME) */ ;
946 outb((int_ret_code & 0xe0) | ATT_EOI, ESDI_ATTN);
947 outb(CTRL_ENABLE_INTR, ESDI_CONTROL);
948 ending = -1;
949 break;
950
951 default:
952 printk("%s: Unknown interrupt reason: %02X\n",
953 DEVICE_NAME, int_ret_code & 0xf);
954 outb((int_ret_code & 0xe0) | ATT_EOI, ESDI_ATTN);
955 outb(CTRL_ENABLE_INTR, ESDI_CONTROL);
956 ending = -1;
957 break;
958 }
959 if(ending != -1) {
960 spin_lock_irqsave(&ps2esdi_lock, flags);
961 end_request(current_req, ending);
962 current_req = NULL;
963 do_ps2esdi_request(ps2esdi_queue);
964 spin_unlock_irqrestore(&ps2esdi_lock, flags);
965 }
966} /* handle interrupts */
967
968
969
970static int ps2esdi_read_status_words(int num_words,
971 int max_words,
972 u_short * buffer)
973{
974 int i;
975
976 for (; max_words && num_words; max_words--, num_words--, buffer++) {
977 for (i = ESDI_TIMEOUT; i && !(inb(ESDI_STATUS) & STATUS_STAT_AVAIL); i--);
978 if (!(inb(ESDI_STATUS) & STATUS_STAT_AVAIL)) {
979 printk("%s: timeout reading status word\n", DEVICE_NAME);
980 return FAIL;
981 }
982 *buffer = inw(ESDI_STT_INT);
983 }
984 return SUCCES;
985}
986
987
988
989
990static void dump_cmd_complete_status(u_int int_ret_code)
991{
992#define WAIT_FOR_STATUS \
993 for(i=ESDI_TIMEOUT;i && !(inb(ESDI_STATUS) & STATUS_STAT_AVAIL);i--); \
994 if(!(inb(ESDI_STATUS) & STATUS_STAT_AVAIL)) { \
995 printk("%s: timeout reading status word\n",DEVICE_NAME); \
996 return; \
997 }
998
999 int i, word_count;
1000 u_short stat_word;
1001 u_long rba;
1002
1003 printk("%s: Device: %u, interrupt ID: %02X\n",
1004 DEVICE_NAME, int_ret_code >> 5,
1005 int_ret_code & 0xf);
1006
1007 WAIT_FOR_STATUS;
1008 stat_word = inw(ESDI_STT_INT);
1009 word_count = (stat_word >> 8) - 1;
1010 printk("%s: %u status words, command: %02X\n", DEVICE_NAME, word_count,
1011 stat_word & 0xff);
1012
1013 if (word_count--) {
1014 WAIT_FOR_STATUS;
1015 stat_word = inw(ESDI_STT_INT);
1016 printk("%s: command status code: %02X, command error code: %02X\n",
1017 DEVICE_NAME, stat_word >> 8, stat_word & 0xff);
1018 }
1019 if (word_count--) {
1020 WAIT_FOR_STATUS;
1021 stat_word = inw(ESDI_STT_INT);
1022 printk("%s: device error code: %s%s%s%s%s,%02X\n", DEVICE_NAME,
1023 (stat_word & 0x1000) ? "Ready, " : "Not Ready, ",
1024 (stat_word & 0x0800) ? "Selected, " : "Not Selected, ",
1025 (stat_word & 0x0400) ? "Write Fault, " : "",
1026 (stat_word & 0x0200) ? "Track 0, " : "",
1027 (stat_word & 0x0100) ? "Seek or command complete, " : "",
1028 stat_word >> 8);
1029 }
1030 if (word_count--) {
1031 WAIT_FOR_STATUS;
1032 stat_word = inw(ESDI_STT_INT);
1033 printk("%s: Blocks to do: %u", DEVICE_NAME, stat_word);
1034 }
1035 if (word_count -= 2) {
1036 WAIT_FOR_STATUS;
1037 rba = inw(ESDI_STT_INT);
1038 WAIT_FOR_STATUS;
1039 rba |= inw(ESDI_STT_INT) << 16;
1040 printk(", Last Cyl: %u Head: %u Sector: %u\n",
1041 (u_short) ((rba & 0x1ff80000) >> 11),
1042 (u_short) ((rba & 0x7E0) >> 5), (u_short) (rba & 0x1f));
1043 } else
1044 printk("\n");
1045
1046 if (word_count--) {
1047 WAIT_FOR_STATUS;
1048 stat_word = inw(ESDI_STT_INT);
1049 printk("%s: Blocks required ECC: %u", DEVICE_NAME, stat_word);
1050 }
1051 printk("\n");
1052
1053#undef WAIT_FOR_STATUS
1054
1055}
1056
1057static int ps2esdi_getgeo(struct block_device *bdev, struct hd_geometry *geo)
1058{
1059 struct ps2esdi_i_struct *p = bdev->bd_disk->private_data;
1060
1061 geo->heads = p->head;
1062 geo->sectors = p->sect;
1063 geo->cylinders = p->cyl;
1064 return 0;
1065}
1066
1067static void ps2esdi_reset_timer(unsigned long unused)
1068{
1069
1070 int status;
1071
1072 status = inb(ESDI_INTRPT);
1073 if ((status & 0xf) == INT_RESET) {
1074 outb((status & 0xe0) | ATT_EOI, ESDI_ATTN);
1075 outb(CTRL_ENABLE_INTR, ESDI_CONTROL);
1076 reset_status = 1;
1077 }
1078 wake_up(&ps2esdi_int);
1079}
diff --git a/drivers/char/drm/ati_pcigart.c b/drivers/char/drm/ati_pcigart.c
index d352dbb4ccf7..141f4dfa0a11 100644
--- a/drivers/char/drm/ati_pcigart.c
+++ b/drivers/char/drm/ati_pcigart.c
@@ -35,42 +35,23 @@
35 35
36# define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */ 36# define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */
37 37
38static void *drm_ati_alloc_pcigart_table(int order) 38static int drm_ati_alloc_pcigart_table(struct drm_device *dev,
39 struct drm_ati_pcigart_info *gart_info)
39{ 40{
40 unsigned long address; 41 gart_info->table_handle = drm_pci_alloc(dev, gart_info->table_size,
41 struct page *page; 42 PAGE_SIZE,
42 int i; 43 gart_info->table_mask);
43 44 if (gart_info->table_handle == NULL)
44 DRM_DEBUG("%d order\n", order); 45 return -ENOMEM;
45
46 address = __get_free_pages(GFP_KERNEL | __GFP_COMP,
47 order);
48 if (address == 0UL) {
49 return NULL;
50 }
51
52 page = virt_to_page(address);
53
54 for (i = 0; i < order; i++, page++)
55 SetPageReserved(page);
56 46
57 DRM_DEBUG("returning 0x%08lx\n", address); 47 return 0;
58 return (void *)address;
59} 48}
60 49
61static void drm_ati_free_pcigart_table(void *address, int order) 50static void drm_ati_free_pcigart_table(struct drm_device *dev,
51 struct drm_ati_pcigart_info *gart_info)
62{ 52{
63 struct page *page; 53 drm_pci_free(dev, gart_info->table_handle);
64 int i; 54 gart_info->table_handle = NULL;
65 int num_pages = 1 << order;
66 DRM_DEBUG("\n");
67
68 page = virt_to_page((unsigned long)address);
69
70 for (i = 0; i < num_pages; i++, page++)
71 ClearPageReserved(page);
72
73 free_pages((unsigned long)address, order);
74} 55}
75 56
76int drm_ati_pcigart_cleanup(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info) 57int drm_ati_pcigart_cleanup(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info)
@@ -78,8 +59,7 @@ int drm_ati_pcigart_cleanup(struct drm_device *dev, struct drm_ati_pcigart_info
78 struct drm_sg_mem *entry = dev->sg; 59 struct drm_sg_mem *entry = dev->sg;
79 unsigned long pages; 60 unsigned long pages;
80 int i; 61 int i;
81 int order; 62 int max_pages;
82 int num_pages, max_pages;
83 63
84 /* we need to support large memory configurations */ 64 /* we need to support large memory configurations */
85 if (!entry) { 65 if (!entry) {
@@ -87,15 +67,7 @@ int drm_ati_pcigart_cleanup(struct drm_device *dev, struct drm_ati_pcigart_info
87 return 0; 67 return 0;
88 } 68 }
89 69
90 order = drm_order((gart_info->table_size + (PAGE_SIZE-1)) / PAGE_SIZE);
91 num_pages = 1 << order;
92
93 if (gart_info->bus_addr) { 70 if (gart_info->bus_addr) {
94 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) {
95 pci_unmap_single(dev->pdev, gart_info->bus_addr,
96 num_pages * PAGE_SIZE,
97 PCI_DMA_TODEVICE);
98 }
99 71
100 max_pages = (gart_info->table_size / sizeof(u32)); 72 max_pages = (gart_info->table_size / sizeof(u32));
101 pages = (entry->pages <= max_pages) 73 pages = (entry->pages <= max_pages)
@@ -112,10 +84,9 @@ int drm_ati_pcigart_cleanup(struct drm_device *dev, struct drm_ati_pcigart_info
112 gart_info->bus_addr = 0; 84 gart_info->bus_addr = 0;
113 } 85 }
114 86
115 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN 87 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN &&
116 && gart_info->addr) { 88 gart_info->table_handle) {
117 drm_ati_free_pcigart_table(gart_info->addr, order); 89 drm_ati_free_pcigart_table(dev, gart_info);
118 gart_info->addr = NULL;
119 } 90 }
120 91
121 return 1; 92 return 1;
@@ -127,11 +98,10 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga
127 struct drm_sg_mem *entry = dev->sg; 98 struct drm_sg_mem *entry = dev->sg;
128 void *address = NULL; 99 void *address = NULL;
129 unsigned long pages; 100 unsigned long pages;
130 u32 *pci_gart, page_base, bus_address = 0; 101 u32 *pci_gart, page_base;
102 dma_addr_t bus_address = 0;
131 int i, j, ret = 0; 103 int i, j, ret = 0;
132 int order;
133 int max_pages; 104 int max_pages;
134 int num_pages;
135 105
136 if (!entry) { 106 if (!entry) {
137 DRM_ERROR("no scatter/gather memory!\n"); 107 DRM_ERROR("no scatter/gather memory!\n");
@@ -141,36 +111,20 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga
141 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) { 111 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) {
142 DRM_DEBUG("PCI: no table in VRAM: using normal RAM\n"); 112 DRM_DEBUG("PCI: no table in VRAM: using normal RAM\n");
143 113
144 order = drm_order((gart_info->table_size + 114 ret = drm_ati_alloc_pcigart_table(dev, gart_info);
145 (PAGE_SIZE-1)) / PAGE_SIZE); 115 if (ret) {
146 num_pages = 1 << order;
147 address = drm_ati_alloc_pcigart_table(order);
148 if (!address) {
149 DRM_ERROR("cannot allocate PCI GART page!\n"); 116 DRM_ERROR("cannot allocate PCI GART page!\n");
150 goto done; 117 goto done;
151 } 118 }
152 119
153 if (!dev->pdev) { 120 address = gart_info->table_handle->vaddr;
154 DRM_ERROR("PCI device unknown!\n"); 121 bus_address = gart_info->table_handle->busaddr;
155 goto done;
156 }
157
158 bus_address = pci_map_single(dev->pdev, address,
159 num_pages * PAGE_SIZE,
160 PCI_DMA_TODEVICE);
161 if (bus_address == 0) {
162 DRM_ERROR("unable to map PCIGART pages!\n");
163 order = drm_order((gart_info->table_size +
164 (PAGE_SIZE-1)) / PAGE_SIZE);
165 drm_ati_free_pcigart_table(address, order);
166 address = NULL;
167 goto done;
168 }
169 } else { 122 } else {
170 address = gart_info->addr; 123 address = gart_info->addr;
171 bus_address = gart_info->bus_addr; 124 bus_address = gart_info->bus_addr;
172 DRM_DEBUG("PCI: Gart Table: VRAM %08X mapped at %08lX\n", 125 DRM_DEBUG("PCI: Gart Table: VRAM %08LX mapped at %08lX\n",
173 bus_address, (unsigned long)address); 126 (unsigned long long)bus_address,
127 (unsigned long)address);
174 } 128 }
175 129
176 pci_gart = (u32 *) address; 130 pci_gart = (u32 *) address;
@@ -214,6 +168,12 @@ int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *ga
214 } 168 }
215 } 169 }
216 170
171 if (gart_info->gart_table_location == DRM_ATI_GART_MAIN)
172 dma_sync_single_for_device(&dev->pdev->dev,
173 bus_address,
174 max_pages * sizeof(u32),
175 PCI_DMA_TODEVICE);
176
217 ret = 1; 177 ret = 1;
218 178
219#if defined(__i386__) || defined(__x86_64__) 179#if defined(__i386__) || defined(__x86_64__)
diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h
index a6789f25009b..8ea9dd1717a9 100644
--- a/drivers/char/drm/drmP.h
+++ b/drivers/char/drm/drmP.h
@@ -54,6 +54,7 @@
54#include <linux/pci.h> 54#include <linux/pci.h>
55#include <linux/jiffies.h> 55#include <linux/jiffies.h>
56#include <linux/smp_lock.h> /* For (un)lock_kernel */ 56#include <linux/smp_lock.h> /* For (un)lock_kernel */
57#include <linux/dma-mapping.h>
57#include <linux/mm.h> 58#include <linux/mm.h>
58#include <linux/cdev.h> 59#include <linux/cdev.h>
59#include <linux/mutex.h> 60#include <linux/mutex.h>
@@ -551,6 +552,8 @@ struct drm_ati_pcigart_info {
551 int gart_reg_if; 552 int gart_reg_if;
552 void *addr; 553 void *addr;
553 dma_addr_t bus_addr; 554 dma_addr_t bus_addr;
555 dma_addr_t table_mask;
556 struct drm_dma_handle *table_handle;
554 drm_local_map_t mapping; 557 drm_local_map_t mapping;
555 int table_size; 558 int table_size;
556}; 559};
diff --git a/drivers/char/drm/drm_fops.c b/drivers/char/drm/drm_fops.c
index 3992f73299cc..f09d4b5002b0 100644
--- a/drivers/char/drm/drm_fops.c
+++ b/drivers/char/drm/drm_fops.c
@@ -326,6 +326,7 @@ int drm_release(struct inode *inode, struct file *filp)
326 struct drm_file *file_priv = filp->private_data; 326 struct drm_file *file_priv = filp->private_data;
327 struct drm_device *dev = file_priv->head->dev; 327 struct drm_device *dev = file_priv->head->dev;
328 int retcode = 0; 328 int retcode = 0;
329 unsigned long irqflags;
329 330
330 lock_kernel(); 331 lock_kernel();
331 332
@@ -357,9 +358,11 @@ int drm_release(struct inode *inode, struct file *filp)
357 */ 358 */
358 359
359 do{ 360 do{
360 spin_lock(&dev->lock.spinlock); 361 spin_lock_irqsave(&dev->lock.spinlock,
362 irqflags);
361 locked = dev->lock.idle_has_lock; 363 locked = dev->lock.idle_has_lock;
362 spin_unlock(&dev->lock.spinlock); 364 spin_unlock_irqrestore(&dev->lock.spinlock,
365 irqflags);
363 if (locked) 366 if (locked)
364 break; 367 break;
365 schedule(); 368 schedule();
diff --git a/drivers/char/drm/drm_lock.c b/drivers/char/drm/drm_lock.c
index bea2a7d5b2b2..12dcdd1832f0 100644
--- a/drivers/char/drm/drm_lock.c
+++ b/drivers/char/drm/drm_lock.c
@@ -53,6 +53,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
53 DECLARE_WAITQUEUE(entry, current); 53 DECLARE_WAITQUEUE(entry, current);
54 struct drm_lock *lock = data; 54 struct drm_lock *lock = data;
55 int ret = 0; 55 int ret = 0;
56 unsigned long irqflags;
56 57
57 ++file_priv->lock_count; 58 ++file_priv->lock_count;
58 59
@@ -71,9 +72,9 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
71 return -EINVAL; 72 return -EINVAL;
72 73
73 add_wait_queue(&dev->lock.lock_queue, &entry); 74 add_wait_queue(&dev->lock.lock_queue, &entry);
74 spin_lock(&dev->lock.spinlock); 75 spin_lock_irqsave(&dev->lock.spinlock, irqflags);
75 dev->lock.user_waiters++; 76 dev->lock.user_waiters++;
76 spin_unlock(&dev->lock.spinlock); 77 spin_unlock_irqrestore(&dev->lock.spinlock, irqflags);
77 for (;;) { 78 for (;;) {
78 __set_current_state(TASK_INTERRUPTIBLE); 79 __set_current_state(TASK_INTERRUPTIBLE);
79 if (!dev->lock.hw_lock) { 80 if (!dev->lock.hw_lock) {
@@ -95,9 +96,9 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
95 break; 96 break;
96 } 97 }
97 } 98 }
98 spin_lock(&dev->lock.spinlock); 99 spin_lock_irqsave(&dev->lock.spinlock, irqflags);
99 dev->lock.user_waiters--; 100 dev->lock.user_waiters--;
100 spin_unlock(&dev->lock.spinlock); 101 spin_unlock_irqrestore(&dev->lock.spinlock, irqflags);
101 __set_current_state(TASK_RUNNING); 102 __set_current_state(TASK_RUNNING);
102 remove_wait_queue(&dev->lock.lock_queue, &entry); 103 remove_wait_queue(&dev->lock.lock_queue, &entry);
103 104
@@ -198,8 +199,9 @@ int drm_lock_take(struct drm_lock_data *lock_data,
198{ 199{
199 unsigned int old, new, prev; 200 unsigned int old, new, prev;
200 volatile unsigned int *lock = &lock_data->hw_lock->lock; 201 volatile unsigned int *lock = &lock_data->hw_lock->lock;
202 unsigned long irqflags;
201 203
202 spin_lock(&lock_data->spinlock); 204 spin_lock_irqsave(&lock_data->spinlock, irqflags);
203 do { 205 do {
204 old = *lock; 206 old = *lock;
205 if (old & _DRM_LOCK_HELD) 207 if (old & _DRM_LOCK_HELD)
@@ -211,7 +213,7 @@ int drm_lock_take(struct drm_lock_data *lock_data,
211 } 213 }
212 prev = cmpxchg(lock, old, new); 214 prev = cmpxchg(lock, old, new);
213 } while (prev != old); 215 } while (prev != old);
214 spin_unlock(&lock_data->spinlock); 216 spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
215 217
216 if (_DRM_LOCKING_CONTEXT(old) == context) { 218 if (_DRM_LOCKING_CONTEXT(old) == context) {
217 if (old & _DRM_LOCK_HELD) { 219 if (old & _DRM_LOCK_HELD) {
@@ -272,15 +274,16 @@ int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context)
272{ 274{
273 unsigned int old, new, prev; 275 unsigned int old, new, prev;
274 volatile unsigned int *lock = &lock_data->hw_lock->lock; 276 volatile unsigned int *lock = &lock_data->hw_lock->lock;
277 unsigned long irqflags;
275 278
276 spin_lock(&lock_data->spinlock); 279 spin_lock_irqsave(&lock_data->spinlock, irqflags);
277 if (lock_data->kernel_waiters != 0) { 280 if (lock_data->kernel_waiters != 0) {
278 drm_lock_transfer(lock_data, 0); 281 drm_lock_transfer(lock_data, 0);
279 lock_data->idle_has_lock = 1; 282 lock_data->idle_has_lock = 1;
280 spin_unlock(&lock_data->spinlock); 283 spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
281 return 1; 284 return 1;
282 } 285 }
283 spin_unlock(&lock_data->spinlock); 286 spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
284 287
285 do { 288 do {
286 old = *lock; 289 old = *lock;
@@ -344,19 +347,20 @@ static int drm_notifier(void *priv)
344void drm_idlelock_take(struct drm_lock_data *lock_data) 347void drm_idlelock_take(struct drm_lock_data *lock_data)
345{ 348{
346 int ret = 0; 349 int ret = 0;
350 unsigned long irqflags;
347 351
348 spin_lock(&lock_data->spinlock); 352 spin_lock_irqsave(&lock_data->spinlock, irqflags);
349 lock_data->kernel_waiters++; 353 lock_data->kernel_waiters++;
350 if (!lock_data->idle_has_lock) { 354 if (!lock_data->idle_has_lock) {
351 355
352 spin_unlock(&lock_data->spinlock); 356 spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
353 ret = drm_lock_take(lock_data, DRM_KERNEL_CONTEXT); 357 ret = drm_lock_take(lock_data, DRM_KERNEL_CONTEXT);
354 spin_lock(&lock_data->spinlock); 358 spin_lock_irqsave(&lock_data->spinlock, irqflags);
355 359
356 if (ret == 1) 360 if (ret == 1)
357 lock_data->idle_has_lock = 1; 361 lock_data->idle_has_lock = 1;
358 } 362 }
359 spin_unlock(&lock_data->spinlock); 363 spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
360} 364}
361EXPORT_SYMBOL(drm_idlelock_take); 365EXPORT_SYMBOL(drm_idlelock_take);
362 366
@@ -364,8 +368,9 @@ void drm_idlelock_release(struct drm_lock_data *lock_data)
364{ 368{
365 unsigned int old, prev; 369 unsigned int old, prev;
366 volatile unsigned int *lock = &lock_data->hw_lock->lock; 370 volatile unsigned int *lock = &lock_data->hw_lock->lock;
371 unsigned long irqflags;
367 372
368 spin_lock(&lock_data->spinlock); 373 spin_lock_irqsave(&lock_data->spinlock, irqflags);
369 if (--lock_data->kernel_waiters == 0) { 374 if (--lock_data->kernel_waiters == 0) {
370 if (lock_data->idle_has_lock) { 375 if (lock_data->idle_has_lock) {
371 do { 376 do {
@@ -376,7 +381,7 @@ void drm_idlelock_release(struct drm_lock_data *lock_data)
376 lock_data->idle_has_lock = 0; 381 lock_data->idle_has_lock = 0;
377 } 382 }
378 } 383 }
379 spin_unlock(&lock_data->spinlock); 384 spin_unlock_irqrestore(&lock_data->spinlock, irqflags);
380} 385}
381EXPORT_SYMBOL(drm_idlelock_release); 386EXPORT_SYMBOL(drm_idlelock_release);
382 387
diff --git a/drivers/char/drm/drm_pciids.h b/drivers/char/drm/drm_pciids.h
index 715b361f0c2b..a6a499f97e22 100644
--- a/drivers/char/drm/drm_pciids.h
+++ b/drivers/char/drm/drm_pciids.h
@@ -205,9 +205,9 @@
205 {0x1002, 0x71D6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 205 {0x1002, 0x71D6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
206 {0x1002, 0x71DA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \ 206 {0x1002, 0x71DA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \
207 {0x1002, 0x71DE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 207 {0x1002, 0x71DE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
208 {0x1002, 0x7200, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \ 208 {0x1002, 0x7200, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \
209 {0x1002, 0x7210, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 209 {0x1002, 0x7210, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
210 {0x1002, 0x7211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 210 {0x1002, 0x7211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
211 {0x1002, 0x7240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \ 211 {0x1002, 0x7240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
212 {0x1002, 0x7243, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \ 212 {0x1002, 0x7243, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
213 {0x1002, 0x7244, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \ 213 {0x1002, 0x7244, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \
@@ -238,6 +238,7 @@
238 {0x1002, 0x7834, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_NEW_MEMMAP}, \ 238 {0x1002, 0x7834, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_NEW_MEMMAP}, \
239 {0x1002, 0x7835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 239 {0x1002, 0x7835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
240 {0x1002, 0x791e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS690|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART}, \ 240 {0x1002, 0x791e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS690|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART}, \
241 {0x1002, 0x791f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS690|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART}, \
241 {0, 0, 0} 242 {0, 0, 0}
242 243
243#define r128_PCI_IDS \ 244#define r128_PCI_IDS \
diff --git a/drivers/char/drm/drm_scatter.c b/drivers/char/drm/drm_scatter.c
index 26d8f675ed5d..b2b0f3d41714 100644
--- a/drivers/char/drm/drm_scatter.c
+++ b/drivers/char/drm/drm_scatter.c
@@ -36,6 +36,15 @@
36 36
37#define DEBUG_SCATTER 0 37#define DEBUG_SCATTER 0
38 38
39static inline void *drm_vmalloc_dma(unsigned long size)
40{
41#if defined(__powerpc__) && defined(CONFIG_NOT_COHERENT_CACHE)
42 return __vmalloc(size, GFP_KERNEL, PAGE_KERNEL | _PAGE_NO_CACHE);
43#else
44 return vmalloc_32(size);
45#endif
46}
47
39void drm_sg_cleanup(struct drm_sg_mem * entry) 48void drm_sg_cleanup(struct drm_sg_mem * entry)
40{ 49{
41 struct page *page; 50 struct page *page;
@@ -104,7 +113,7 @@ int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request)
104 } 113 }
105 memset((void *)entry->busaddr, 0, pages * sizeof(*entry->busaddr)); 114 memset((void *)entry->busaddr, 0, pages * sizeof(*entry->busaddr));
106 115
107 entry->virtual = vmalloc_32(pages << PAGE_SHIFT); 116 entry->virtual = drm_vmalloc_dma(pages << PAGE_SHIFT);
108 if (!entry->virtual) { 117 if (!entry->virtual) {
109 drm_free(entry->busaddr, 118 drm_free(entry->busaddr,
110 entry->pages * sizeof(*entry->busaddr), DRM_MEM_PAGES); 119 entry->pages * sizeof(*entry->busaddr), DRM_MEM_PAGES);
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c
index 3d65c4dcd0c6..945df72a51a9 100644
--- a/drivers/char/drm/drm_vm.c
+++ b/drivers/char/drm/drm_vm.c
@@ -54,13 +54,24 @@ static pgprot_t drm_io_prot(uint32_t map_type, struct vm_area_struct *vma)
54 pgprot_val(tmp) |= _PAGE_NO_CACHE; 54 pgprot_val(tmp) |= _PAGE_NO_CACHE;
55 if (map_type == _DRM_REGISTERS) 55 if (map_type == _DRM_REGISTERS)
56 pgprot_val(tmp) |= _PAGE_GUARDED; 56 pgprot_val(tmp) |= _PAGE_GUARDED;
57#endif 57#elif defined(__ia64__)
58#if defined(__ia64__)
59 if (efi_range_is_wc(vma->vm_start, vma->vm_end - 58 if (efi_range_is_wc(vma->vm_start, vma->vm_end -
60 vma->vm_start)) 59 vma->vm_start))
61 tmp = pgprot_writecombine(tmp); 60 tmp = pgprot_writecombine(tmp);
62 else 61 else
63 tmp = pgprot_noncached(tmp); 62 tmp = pgprot_noncached(tmp);
63#elif defined(__sparc__)
64 tmp = pgprot_noncached(tmp);
65#endif
66 return tmp;
67}
68
69static pgprot_t drm_dma_prot(uint32_t map_type, struct vm_area_struct *vma)
70{
71 pgprot_t tmp = vm_get_page_prot(vma->vm_flags);
72
73#if defined(__powerpc__) && defined(CONFIG_NOT_COHERENT_CACHE)
74 tmp |= _PAGE_NO_CACHE;
64#endif 75#endif
65 return tmp; 76 return tmp;
66} 77}
@@ -603,9 +614,6 @@ static int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
603 offset = dev->driver->get_reg_ofs(dev); 614 offset = dev->driver->get_reg_ofs(dev);
604 vma->vm_flags |= VM_IO; /* not in core dump */ 615 vma->vm_flags |= VM_IO; /* not in core dump */
605 vma->vm_page_prot = drm_io_prot(map->type, vma); 616 vma->vm_page_prot = drm_io_prot(map->type, vma);
606#ifdef __sparc__
607 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
608#endif
609 if (io_remap_pfn_range(vma, vma->vm_start, 617 if (io_remap_pfn_range(vma, vma->vm_start,
610 (map->offset + offset) >> PAGE_SHIFT, 618 (map->offset + offset) >> PAGE_SHIFT,
611 vma->vm_end - vma->vm_start, 619 vma->vm_end - vma->vm_start,
@@ -624,6 +632,7 @@ static int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
624 page_to_pfn(virt_to_page(map->handle)), 632 page_to_pfn(virt_to_page(map->handle)),
625 vma->vm_end - vma->vm_start, vma->vm_page_prot)) 633 vma->vm_end - vma->vm_start, vma->vm_page_prot))
626 return -EAGAIN; 634 return -EAGAIN;
635 vma->vm_page_prot = drm_dma_prot(map->type, vma);
627 /* fall through to _DRM_SHM */ 636 /* fall through to _DRM_SHM */
628 case _DRM_SHM: 637 case _DRM_SHM:
629 vma->vm_ops = &drm_vm_shm_ops; 638 vma->vm_ops = &drm_vm_shm_ops;
@@ -631,6 +640,7 @@ static int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
631 /* Don't let this area swap. Change when 640 /* Don't let this area swap. Change when
632 DRM_KERNEL advisory is supported. */ 641 DRM_KERNEL advisory is supported. */
633 vma->vm_flags |= VM_RESERVED; 642 vma->vm_flags |= VM_RESERVED;
643 vma->vm_page_prot = drm_dma_prot(map->type, vma);
634 break; 644 break;
635 case _DRM_SCATTER_GATHER: 645 case _DRM_SCATTER_GATHER:
636 vma->vm_ops = &drm_vm_sg_ops; 646 vma->vm_ops = &drm_vm_sg_ops;
diff --git a/drivers/char/drm/i915_dma.c b/drivers/char/drm/i915_dma.c
index e9d6663bec73..a043bb12301a 100644
--- a/drivers/char/drm/i915_dma.c
+++ b/drivers/char/drm/i915_dma.c
@@ -804,6 +804,9 @@ void i915_driver_lastclose(struct drm_device * dev)
804{ 804{
805 drm_i915_private_t *dev_priv = dev->dev_private; 805 drm_i915_private_t *dev_priv = dev->dev_private;
806 806
807 if (!dev_priv)
808 return;
809
807 if (dev_priv->agp_heap) 810 if (dev_priv->agp_heap)
808 i915_mem_takedown(&(dev_priv->agp_heap)); 811 i915_mem_takedown(&(dev_priv->agp_heap));
809 812
diff --git a/drivers/char/drm/r128_cce.c b/drivers/char/drm/r128_cce.c
index 892e0a589846..f36adbd3aaf5 100644
--- a/drivers/char/drm/r128_cce.c
+++ b/drivers/char/drm/r128_cce.c
@@ -558,6 +558,7 @@ static int r128_do_init_cce(struct drm_device * dev, drm_r128_init_t * init)
558#if __OS_HAS_AGP 558#if __OS_HAS_AGP
559 if (dev_priv->is_pci) { 559 if (dev_priv->is_pci) {
560#endif 560#endif
561 dev_priv->gart_info.table_mask = DMA_BIT_MASK(32);
561 dev_priv->gart_info.gart_table_location = DRM_ATI_GART_MAIN; 562 dev_priv->gart_info.gart_table_location = DRM_ATI_GART_MAIN;
562 dev_priv->gart_info.table_size = R128_PCIGART_TABLE_SIZE; 563 dev_priv->gart_info.table_size = R128_PCIGART_TABLE_SIZE;
563 dev_priv->gart_info.addr = NULL; 564 dev_priv->gart_info.addr = NULL;
diff --git a/drivers/char/drm/r300_cmdbuf.c b/drivers/char/drm/r300_cmdbuf.c
index 0f4afc44245c..f535812e4057 100644
--- a/drivers/char/drm/r300_cmdbuf.c
+++ b/drivers/char/drm/r300_cmdbuf.c
@@ -729,6 +729,47 @@ static void r300_discard_buffer(struct drm_device * dev, struct drm_buf * buf)
729 buf->used = 0; 729 buf->used = 0;
730} 730}
731 731
732static void r300_cmd_wait(drm_radeon_private_t * dev_priv,
733 drm_r300_cmd_header_t header)
734{
735 u32 wait_until;
736 RING_LOCALS;
737
738 if (!header.wait.flags)
739 return;
740
741 wait_until = 0;
742
743 switch(header.wait.flags) {
744 case R300_WAIT_2D:
745 wait_until = RADEON_WAIT_2D_IDLE;
746 break;
747 case R300_WAIT_3D:
748 wait_until = RADEON_WAIT_3D_IDLE;
749 break;
750 case R300_NEW_WAIT_2D_3D:
751 wait_until = RADEON_WAIT_2D_IDLE|RADEON_WAIT_3D_IDLE;
752 break;
753 case R300_NEW_WAIT_2D_2D_CLEAN:
754 wait_until = RADEON_WAIT_2D_IDLE|RADEON_WAIT_2D_IDLECLEAN;
755 break;
756 case R300_NEW_WAIT_3D_3D_CLEAN:
757 wait_until = RADEON_WAIT_3D_IDLE|RADEON_WAIT_3D_IDLECLEAN;
758 break;
759 case R300_NEW_WAIT_2D_2D_CLEAN_3D_3D_CLEAN:
760 wait_until = RADEON_WAIT_2D_IDLE|RADEON_WAIT_2D_IDLECLEAN;
761 wait_until |= RADEON_WAIT_3D_IDLE|RADEON_WAIT_3D_IDLECLEAN;
762 break;
763 default:
764 return;
765 }
766
767 BEGIN_RING(2);
768 OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0));
769 OUT_RING(wait_until);
770 ADVANCE_RING();
771}
772
732static int r300_scratch(drm_radeon_private_t *dev_priv, 773static int r300_scratch(drm_radeon_private_t *dev_priv,
733 drm_radeon_kcmd_buffer_t *cmdbuf, 774 drm_radeon_kcmd_buffer_t *cmdbuf,
734 drm_r300_cmd_header_t header) 775 drm_r300_cmd_header_t header)
@@ -909,19 +950,8 @@ int r300_do_cp_cmdbuf(struct drm_device *dev,
909 break; 950 break;
910 951
911 case R300_CMD_WAIT: 952 case R300_CMD_WAIT:
912 /* simple enough, we can do it here */
913 DRM_DEBUG("R300_CMD_WAIT\n"); 953 DRM_DEBUG("R300_CMD_WAIT\n");
914 if (header.wait.flags == 0) 954 r300_cmd_wait(dev_priv, header);
915 break; /* nothing to do */
916
917 {
918 RING_LOCALS;
919
920 BEGIN_RING(2);
921 OUT_RING(CP_PACKET0(RADEON_WAIT_UNTIL, 0));
922 OUT_RING((header.wait.flags & 0xf) << 14);
923 ADVANCE_RING();
924 }
925 break; 955 break;
926 956
927 case R300_CMD_SCRATCH: 957 case R300_CMD_SCRATCH:
diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c
index 833abc7e55fb..9072e4a1894e 100644
--- a/drivers/char/drm/radeon_cp.c
+++ b/drivers/char/drm/radeon_cp.c
@@ -1807,6 +1807,7 @@ static int radeon_do_init_cp(struct drm_device * dev, drm_radeon_init_t * init)
1807 } else 1807 } else
1808#endif 1808#endif
1809 { 1809 {
1810 dev_priv->gart_info.table_mask = DMA_BIT_MASK(32);
1810 /* if we have an offset set from userspace */ 1811 /* if we have an offset set from userspace */
1811 if (dev_priv->pcigart_offset_set) { 1812 if (dev_priv->pcigart_offset_set) {
1812 dev_priv->gart_info.bus_addr = 1813 dev_priv->gart_info.bus_addr =
diff --git a/drivers/char/drm/radeon_drm.h b/drivers/char/drm/radeon_drm.h
index 71e5b21fad2c..aab82e121e07 100644
--- a/drivers/char/drm/radeon_drm.h
+++ b/drivers/char/drm/radeon_drm.h
@@ -225,8 +225,20 @@ typedef union {
225#define R300_CMD_WAIT 7 225#define R300_CMD_WAIT 7
226# define R300_WAIT_2D 0x1 226# define R300_WAIT_2D 0x1
227# define R300_WAIT_3D 0x2 227# define R300_WAIT_3D 0x2
228/* these two defines are DOING IT WRONG - however
229 * we have userspace which relies on using these.
230 * The wait interface is backwards compat new
231 * code should use the NEW_WAIT defines below
232 * THESE ARE NOT BIT FIELDS
233 */
228# define R300_WAIT_2D_CLEAN 0x3 234# define R300_WAIT_2D_CLEAN 0x3
229# define R300_WAIT_3D_CLEAN 0x4 235# define R300_WAIT_3D_CLEAN 0x4
236
237# define R300_NEW_WAIT_2D_3D 0x3
238# define R300_NEW_WAIT_2D_2D_CLEAN 0x4
239# define R300_NEW_WAIT_3D_3D_CLEAN 0x6
240# define R300_NEW_WAIT_2D_2D_CLEAN_3D_3D_CLEAN 0x8
241
230#define R300_CMD_SCRATCH 8 242#define R300_CMD_SCRATCH 8
231 243
232typedef union { 244typedef union {
diff --git a/drivers/char/drm/radeon_mem.c b/drivers/char/drm/radeon_mem.c
index 78b34fa7c89a..4af5286a36fb 100644
--- a/drivers/char/drm/radeon_mem.c
+++ b/drivers/char/drm/radeon_mem.c
@@ -88,7 +88,7 @@ static struct mem_block *alloc_block(struct mem_block *heap, int size,
88 88
89 list_for_each(p, heap) { 89 list_for_each(p, heap) {
90 int start = (p->start + mask) & ~mask; 90 int start = (p->start + mask) & ~mask;
91 if (p->file_priv == 0 && start + size <= p->start + p->size) 91 if (p->file_priv == NULL && start + size <= p->start + p->size)
92 return split_block(p, start, size, file_priv); 92 return split_block(p, start, size, file_priv);
93 } 93 }
94 94
@@ -113,7 +113,7 @@ static void free_block(struct mem_block *p)
113 /* Assumes a single contiguous range. Needs a special file_priv in 113 /* Assumes a single contiguous range. Needs a special file_priv in
114 * 'heap' to stop it being subsumed. 114 * 'heap' to stop it being subsumed.
115 */ 115 */
116 if (p->next->file_priv == 0) { 116 if (p->next->file_priv == NULL) {
117 struct mem_block *q = p->next; 117 struct mem_block *q = p->next;
118 p->size += q->size; 118 p->size += q->size;
119 p->next = q->next; 119 p->next = q->next;
@@ -121,7 +121,7 @@ static void free_block(struct mem_block *p)
121 drm_free(q, sizeof(*q), DRM_MEM_BUFS); 121 drm_free(q, sizeof(*q), DRM_MEM_BUFS);
122 } 122 }
123 123
124 if (p->prev->file_priv == 0) { 124 if (p->prev->file_priv == NULL) {
125 struct mem_block *q = p->prev; 125 struct mem_block *q = p->prev;
126 q->size += p->size; 126 q->size += p->size;
127 q->next = p->next; 127 q->next = p->next;
@@ -174,7 +174,7 @@ void radeon_mem_release(struct drm_file *file_priv, struct mem_block *heap)
174 * 'heap' to stop it being subsumed. 174 * 'heap' to stop it being subsumed.
175 */ 175 */
176 list_for_each(p, heap) { 176 list_for_each(p, heap) {
177 while (p->file_priv == 0 && p->next->file_priv == 0) { 177 while (p->file_priv == NULL && p->next->file_priv == NULL) {
178 struct mem_block *q = p->next; 178 struct mem_block *q = p->next;
179 p->size += q->size; 179 p->size += q->size;
180 p->next = q->next; 180 p->next = q->next;
diff --git a/drivers/char/drm/via_dma.c b/drivers/char/drm/via_dma.c
index 94baec692b57..7a339dba6a69 100644
--- a/drivers/char/drm/via_dma.c
+++ b/drivers/char/drm/via_dma.c
@@ -126,6 +126,8 @@ via_cmdbuf_wait(drm_via_private_t * dev_priv, unsigned int size)
126 hw_addr, cur_addr, next_addr); 126 hw_addr, cur_addr, next_addr);
127 return -1; 127 return -1;
128 } 128 }
129 if ((cur_addr < hw_addr) && (next_addr >= hw_addr))
130 msleep(1);
129 } while ((cur_addr < hw_addr) && (next_addr >= hw_addr)); 131 } while ((cur_addr < hw_addr) && (next_addr >= hw_addr));
130 return 0; 132 return 0;
131} 133}
@@ -416,27 +418,50 @@ static int via_hook_segment(drm_via_private_t * dev_priv,
416 int paused, count; 418 int paused, count;
417 volatile uint32_t *paused_at = dev_priv->last_pause_ptr; 419 volatile uint32_t *paused_at = dev_priv->last_pause_ptr;
418 uint32_t reader,ptr; 420 uint32_t reader,ptr;
421 uint32_t diff;
419 422
420 paused = 0; 423 paused = 0;
421 via_flush_write_combine(); 424 via_flush_write_combine();
422 (void) *(volatile uint32_t *)(via_get_dma(dev_priv) -1); 425 (void) *(volatile uint32_t *)(via_get_dma(dev_priv) -1);
426
423 *paused_at = pause_addr_lo; 427 *paused_at = pause_addr_lo;
424 via_flush_write_combine(); 428 via_flush_write_combine();
425 (void) *paused_at; 429 (void) *paused_at;
430
426 reader = *(dev_priv->hw_addr_ptr); 431 reader = *(dev_priv->hw_addr_ptr);
427 ptr = ((volatile char *)paused_at - dev_priv->dma_ptr) + 432 ptr = ((volatile char *)paused_at - dev_priv->dma_ptr) +
428 dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr + 4; 433 dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr + 4;
434
429 dev_priv->last_pause_ptr = via_get_dma(dev_priv) - 1; 435 dev_priv->last_pause_ptr = via_get_dma(dev_priv) - 1;
430 436
431 if ((ptr - reader) <= dev_priv->dma_diff ) { 437 /*
432 count = 10000000; 438 * If there is a possibility that the command reader will
433 while (!(paused = (VIA_READ(0x41c) & 0x80000000)) && count--); 439 * miss the new pause address and pause on the old one,
440 * In that case we need to program the new start address
441 * using PCI.
442 */
443
444 diff = (uint32_t) (ptr - reader) - dev_priv->dma_diff;
445 count = 10000000;
446 while(diff == 0 && count--) {
447 paused = (VIA_READ(0x41c) & 0x80000000);
448 if (paused)
449 break;
450 reader = *(dev_priv->hw_addr_ptr);
451 diff = (uint32_t) (ptr - reader) - dev_priv->dma_diff;
434 } 452 }
435 453
454 paused = VIA_READ(0x41c) & 0x80000000;
455
436 if (paused && !no_pci_fire) { 456 if (paused && !no_pci_fire) {
437 reader = *(dev_priv->hw_addr_ptr); 457 reader = *(dev_priv->hw_addr_ptr);
438 if ((ptr - reader) == dev_priv->dma_diff) { 458 diff = (uint32_t) (ptr - reader) - dev_priv->dma_diff;
439 459 diff &= (dev_priv->dma_high - 1);
460 if (diff != 0 && diff < (dev_priv->dma_high >> 1)) {
461 DRM_ERROR("Paused at incorrect address. "
462 "0x%08x, 0x%08x 0x%08x\n",
463 ptr, reader, dev_priv->dma_diff);
464 } else if (diff == 0) {
440 /* 465 /*
441 * There is a concern that these writes may stall the PCI bus 466 * There is a concern that these writes may stall the PCI bus
442 * if the GPU is not idle. However, idling the GPU first 467 * if the GPU is not idle. However, idling the GPU first
@@ -577,6 +602,7 @@ static void via_cmdbuf_jump(drm_via_private_t * dev_priv)
577 uint32_t pause_addr_lo, pause_addr_hi; 602 uint32_t pause_addr_lo, pause_addr_hi;
578 uint32_t jump_addr_lo, jump_addr_hi; 603 uint32_t jump_addr_lo, jump_addr_hi;
579 volatile uint32_t *last_pause_ptr; 604 volatile uint32_t *last_pause_ptr;
605 uint32_t dma_low_save1, dma_low_save2;
580 606
581 agp_base = dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr; 607 agp_base = dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr;
582 via_align_cmd(dev_priv, HC_HAGPBpID_JUMP, 0, &jump_addr_hi, 608 via_align_cmd(dev_priv, HC_HAGPBpID_JUMP, 0, &jump_addr_hi,
@@ -603,8 +629,29 @@ static void via_cmdbuf_jump(drm_via_private_t * dev_priv)
603 &pause_addr_lo, 0); 629 &pause_addr_lo, 0);
604 630
605 *last_pause_ptr = pause_addr_lo; 631 *last_pause_ptr = pause_addr_lo;
632 dma_low_save1 = dev_priv->dma_low;
606 633
607 via_hook_segment( dev_priv, jump_addr_hi, jump_addr_lo, 0); 634 /*
635 * Now, set a trap that will pause the regulator if it tries to rerun the old
636 * command buffer. (Which may happen if via_hook_segment detecs a command regulator pause
637 * and reissues the jump command over PCI, while the regulator has already taken the jump
638 * and actually paused at the current buffer end).
639 * There appears to be no other way to detect this condition, since the hw_addr_pointer
640 * does not seem to get updated immediately when a jump occurs.
641 */
642
643 last_pause_ptr =
644 via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0, &pause_addr_hi,
645 &pause_addr_lo, 0) - 1;
646 via_align_cmd(dev_priv, HC_HAGPBpID_PAUSE, 0, &pause_addr_hi,
647 &pause_addr_lo, 0);
648 *last_pause_ptr = pause_addr_lo;
649
650 dma_low_save2 = dev_priv->dma_low;
651 dev_priv->dma_low = dma_low_save1;
652 via_hook_segment(dev_priv, jump_addr_hi, jump_addr_lo, 0);
653 dev_priv->dma_low = dma_low_save2;
654 via_hook_segment(dev_priv, pause_addr_hi, pause_addr_lo, 0);
608} 655}
609 656
610 657
diff --git a/drivers/char/drm/via_dmablit.c b/drivers/char/drm/via_dmablit.c
index 33c5197b73c4..409e00afdd07 100644
--- a/drivers/char/drm/via_dmablit.c
+++ b/drivers/char/drm/via_dmablit.c
@@ -603,7 +603,7 @@ via_build_sg_info(struct drm_device *dev, drm_via_sg_info_t *vsg, drm_via_dmabli
603 * (Not a big limitation anyway.) 603 * (Not a big limitation anyway.)
604 */ 604 */
605 605
606 if ((xfer->mem_stride - xfer->line_length) >= PAGE_SIZE) { 606 if ((xfer->mem_stride - xfer->line_length) > 2*PAGE_SIZE) {
607 DRM_ERROR("Too large system memory stride. Stride: %d, " 607 DRM_ERROR("Too large system memory stride. Stride: %d, "
608 "Length: %d\n", xfer->mem_stride, xfer->line_length); 608 "Length: %d\n", xfer->mem_stride, xfer->line_length);
609 return -EINVAL; 609 return -EINVAL;
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index 6bbd4fa50f3b..8d6c2089d2a8 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -9,7 +9,14 @@ config HW_RANDOM
9 Hardware Random Number Generator Core infrastructure. 9 Hardware Random Number Generator Core infrastructure.
10 10
11 To compile this driver as a module, choose M here: the 11 To compile this driver as a module, choose M here: the
12 module will be called rng-core. 12 module will be called rng-core. This provides a device
13 that's usually called /dev/hw_random, and which exposes one
14 of possibly several hardware random number generators.
15
16 These hardware random number generators do not feed directly
17 into the kernel's random number generator. That is usually
18 handled by the "rngd" daemon. Documentation/hw_random.txt
19 has more information.
13 20
14 If unsure, say Y. 21 If unsure, say Y.
15 22
diff --git a/drivers/char/ip2/i2lib.c b/drivers/char/ip2/i2lib.c
index d6567b32fb5c..9c25320121ef 100644
--- a/drivers/char/ip2/i2lib.c
+++ b/drivers/char/ip2/i2lib.c
@@ -644,12 +644,12 @@ i2QueueCommands(int type, i2ChanStrPtr pCh, int timeout, int nCommands,
644 // Normal Expected path - We still hold LOCK 644 // Normal Expected path - We still hold LOCK
645 break; /* from for()- Enough room: goto proceed */ 645 break; /* from for()- Enough room: goto proceed */
646 } 646 }
647 } 647 ip2trace(CHANN, ITRC_QUEUE, 3, 1, totalsize);
648 648 WRITE_UNLOCK_IRQRESTORE(lock_var_p, flags);
649 ip2trace (CHANN, ITRC_QUEUE, 3, 1, totalsize ); 649 } else
650 ip2trace(CHANN, ITRC_QUEUE, 3, 1, totalsize);
650 651
651 // Prepare to wait for buffers to empty 652 /* Prepare to wait for buffers to empty */
652 WRITE_UNLOCK_IRQRESTORE(lock_var_p,flags);
653 serviceOutgoingFifo(pB); // Dump what we got 653 serviceOutgoingFifo(pB); // Dump what we got
654 654
655 if (timeout == 0) { 655 if (timeout == 0) {
@@ -1830,6 +1830,8 @@ i2StripFifo(i2eBordStrPtr pB)
1830 default: // Neither packet? should be impossible 1830 default: // Neither packet? should be impossible
1831 ip2trace (ITRC_NO_PORT, ITRC_SFIFO, 5, 1, 1831 ip2trace (ITRC_NO_PORT, ITRC_SFIFO, 5, 1,
1832 PTYPE_OF(pB->i2eLeadoffWord) ); 1832 PTYPE_OF(pB->i2eLeadoffWord) );
1833 WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock,
1834 bflags);
1833 1835
1834 break; 1836 break;
1835 } // End of switch on type of packets 1837 } // End of switch on type of packets
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index 46b2a1cc8b54..0c09409fa45d 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -1183,7 +1183,7 @@ static int copy_from_read_buf(struct tty_struct *tty,
1183 return retval; 1183 return retval;
1184} 1184}
1185 1185
1186extern ssize_t redirected_tty_write(struct file *, const char *, 1186extern ssize_t redirected_tty_write(struct file *, const char __user *,
1187 size_t, loff_t *); 1187 size_t, loff_t *);
1188 1188
1189/** 1189/**
diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c
index 6d0dc5f9b6bb..6a6843a0a674 100644
--- a/drivers/char/nozomi.c
+++ b/drivers/char/nozomi.c
@@ -438,7 +438,7 @@ static void read_mem32(u32 *buf, const void __iomem *mem_addr_start,
438 u32 size_bytes) 438 u32 size_bytes)
439{ 439{
440 u32 i = 0; 440 u32 i = 0;
441 const u32 *ptr = (__force u32 *) mem_addr_start; 441 const u32 __iomem *ptr = mem_addr_start;
442 u16 *buf16; 442 u16 *buf16;
443 443
444 if (unlikely(!ptr || !buf)) 444 if (unlikely(!ptr || !buf))
@@ -448,11 +448,11 @@ static void read_mem32(u32 *buf, const void __iomem *mem_addr_start,
448 switch (size_bytes) { 448 switch (size_bytes) {
449 case 2: /* 2 bytes */ 449 case 2: /* 2 bytes */
450 buf16 = (u16 *) buf; 450 buf16 = (u16 *) buf;
451 *buf16 = __le16_to_cpu(readw((void __iomem *)ptr)); 451 *buf16 = __le16_to_cpu(readw(ptr));
452 goto out; 452 goto out;
453 break; 453 break;
454 case 4: /* 4 bytes */ 454 case 4: /* 4 bytes */
455 *(buf) = __le32_to_cpu(readl((void __iomem *)ptr)); 455 *(buf) = __le32_to_cpu(readl(ptr));
456 goto out; 456 goto out;
457 break; 457 break;
458 } 458 }
@@ -461,11 +461,11 @@ static void read_mem32(u32 *buf, const void __iomem *mem_addr_start,
461 if (size_bytes - i == 2) { 461 if (size_bytes - i == 2) {
462 /* Handle 2 bytes in the end */ 462 /* Handle 2 bytes in the end */
463 buf16 = (u16 *) buf; 463 buf16 = (u16 *) buf;
464 *(buf16) = __le16_to_cpu(readw((void __iomem *)ptr)); 464 *(buf16) = __le16_to_cpu(readw(ptr));
465 i += 2; 465 i += 2;
466 } else { 466 } else {
467 /* Read 4 bytes */ 467 /* Read 4 bytes */
468 *(buf) = __le32_to_cpu(readl((void __iomem *)ptr)); 468 *(buf) = __le32_to_cpu(readl(ptr));
469 i += 4; 469 i += 4;
470 } 470 }
471 buf++; 471 buf++;
@@ -484,7 +484,7 @@ static u32 write_mem32(void __iomem *mem_addr_start, const u32 *buf,
484 u32 size_bytes) 484 u32 size_bytes)
485{ 485{
486 u32 i = 0; 486 u32 i = 0;
487 u32 *ptr = (__force u32 *) mem_addr_start; 487 u32 __iomem *ptr = mem_addr_start;
488 const u16 *buf16; 488 const u16 *buf16;
489 489
490 if (unlikely(!ptr || !buf)) 490 if (unlikely(!ptr || !buf))
@@ -494,7 +494,7 @@ static u32 write_mem32(void __iomem *mem_addr_start, const u32 *buf,
494 switch (size_bytes) { 494 switch (size_bytes) {
495 case 2: /* 2 bytes */ 495 case 2: /* 2 bytes */
496 buf16 = (const u16 *)buf; 496 buf16 = (const u16 *)buf;
497 writew(__cpu_to_le16(*buf16), (void __iomem *)ptr); 497 writew(__cpu_to_le16(*buf16), ptr);
498 return 2; 498 return 2;
499 break; 499 break;
500 case 1: /* 500 case 1: /*
@@ -502,7 +502,7 @@ static u32 write_mem32(void __iomem *mem_addr_start, const u32 *buf,
502 * so falling through.. 502 * so falling through..
503 */ 503 */
504 case 4: /* 4 bytes */ 504 case 4: /* 4 bytes */
505 writel(__cpu_to_le32(*buf), (void __iomem *)ptr); 505 writel(__cpu_to_le32(*buf), ptr);
506 return 4; 506 return 4;
507 break; 507 break;
508 } 508 }
@@ -511,11 +511,11 @@ static u32 write_mem32(void __iomem *mem_addr_start, const u32 *buf,
511 if (size_bytes - i == 2) { 511 if (size_bytes - i == 2) {
512 /* 2 bytes */ 512 /* 2 bytes */
513 buf16 = (const u16 *)buf; 513 buf16 = (const u16 *)buf;
514 writew(__cpu_to_le16(*buf16), (void __iomem *)ptr); 514 writew(__cpu_to_le16(*buf16), ptr);
515 i += 2; 515 i += 2;
516 } else { 516 } else {
517 /* 4 bytes */ 517 /* 4 bytes */
518 writel(__cpu_to_le32(*buf), (void __iomem *)ptr); 518 writel(__cpu_to_le32(*buf), ptr);
519 i += 4; 519 i += 4;
520 } 520 }
521 buf++; 521 buf++;
diff --git a/drivers/char/rio/riotable.c b/drivers/char/rio/riotable.c
index 991119c9f473..9b52892a501f 100644
--- a/drivers/char/rio/riotable.c
+++ b/drivers/char/rio/riotable.c
@@ -425,8 +425,10 @@ int RIOApel(struct rio_info *p)
425 425
426 MapP = &p->RIOConnectTable[Next++]; 426 MapP = &p->RIOConnectTable[Next++];
427 MapP->HostUniqueNum = HostP->UniqueNum; 427 MapP->HostUniqueNum = HostP->UniqueNum;
428 if ((HostP->Flags & RUN_STATE) != RC_RUNNING) 428 if ((HostP->Flags & RUN_STATE) != RC_RUNNING) {
429 rio_spin_unlock_irqrestore(&HostP->HostLock, flags);
429 continue; 430 continue;
431 }
430 MapP->RtaUniqueNum = 0; 432 MapP->RtaUniqueNum = 0;
431 MapP->ID = 0; 433 MapP->ID = 0;
432 MapP->Flags = SLOT_IN_USE; 434 MapP->Flags = SLOT_IN_USE;
diff --git a/drivers/char/rio/riotty.c b/drivers/char/rio/riotty.c
index a4f0b1e3e7fa..cfa54361473f 100644
--- a/drivers/char/rio/riotty.c
+++ b/drivers/char/rio/riotty.c
@@ -319,6 +319,7 @@ int riotopen(struct tty_struct *tty, struct file *filp)
319 PortP->State |= RIO_WOPEN; 319 PortP->State |= RIO_WOPEN;
320 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 320 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
321 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { 321 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
322 rio_spin_lock_irqsave(&PortP->portSem, flags);
322 /* 323 /*
323 ** ACTION: verify that this is a good thing 324 ** ACTION: verify that this is a good thing
324 ** to do here. -- ??? 325 ** to do here. -- ???
@@ -334,6 +335,7 @@ int riotopen(struct tty_struct *tty, struct file *filp)
334 func_exit(); 335 func_exit();
335 return -EINTR; 336 return -EINTR;
336 } 337 }
338 rio_spin_lock_irqsave(&PortP->portSem, flags);
337 } 339 }
338 PortP->State &= ~RIO_WOPEN; 340 PortP->State &= ~RIO_WOPEN;
339 } 341 }
@@ -493,6 +495,7 @@ int riotclose(void *ptr)
493 495
494 if (RIOShortCommand(p, PortP, CLOSE, 1, 0) == RIO_FAIL) { 496 if (RIOShortCommand(p, PortP, CLOSE, 1, 0) == RIO_FAIL) {
495 RIOPreemptiveCmd(p, PortP, FCLOSE); 497 RIOPreemptiveCmd(p, PortP, FCLOSE);
498 rio_spin_lock_irqsave(&PortP->portSem, flags);
496 goto close_end; 499 goto close_end;
497 } 500 }
498 501
@@ -508,6 +511,7 @@ int riotclose(void *ptr)
508 511
509 if (p->RIOHalted) { 512 if (p->RIOHalted) {
510 RIOClearUp(PortP); 513 RIOClearUp(PortP);
514 rio_spin_lock_irqsave(&PortP->portSem, flags);
511 goto close_end; 515 goto close_end;
512 } 516 }
513 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { 517 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index 72f289279d8f..f585bc8579e9 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -83,6 +83,7 @@
83#include <linux/pci.h> 83#include <linux/pci.h>
84#include <asm/uaccess.h> 84#include <asm/uaccess.h>
85#include <asm/atomic.h> 85#include <asm/atomic.h>
86#include <asm/unaligned.h>
86#include <linux/bitops.h> 87#include <linux/bitops.h>
87#include <linux/spinlock.h> 88#include <linux/spinlock.h>
88#include <linux/init.h> 89#include <linux/init.h>
@@ -1312,7 +1313,7 @@ static int rp_tiocmset(struct tty_struct *tty, struct file *file,
1312 if (clear & TIOCM_DTR) 1313 if (clear & TIOCM_DTR)
1313 info->channel.TxControl[3] &= ~SET_DTR; 1314 info->channel.TxControl[3] &= ~SET_DTR;
1314 1315
1315 sOutDW(info->channel.IndexAddr, *(DWord_t *) & (info->channel.TxControl[0])); 1316 out32(info->channel.IndexAddr, info->channel.TxControl);
1316 return 0; 1317 return 0;
1317} 1318}
1318 1319
@@ -1748,7 +1749,7 @@ static int rp_write(struct tty_struct *tty,
1748 1749
1749 /* Write remaining data into the port's xmit_buf */ 1750 /* Write remaining data into the port's xmit_buf */
1750 while (1) { 1751 while (1) {
1751 if (info->tty == 0) /* Seemingly obligatory check... */ 1752 if (!info->tty) /* Seemingly obligatory check... */
1752 goto end; 1753 goto end;
1753 1754
1754 c = min(count, min(XMIT_BUF_SIZE - info->xmit_cnt - 1, XMIT_BUF_SIZE - info->xmit_head)); 1755 c = min(count, min(XMIT_BUF_SIZE - info->xmit_cnt - 1, XMIT_BUF_SIZE - info->xmit_head));
@@ -2798,7 +2799,7 @@ static int sReadAiopNumChan(WordIO_t io)
2798 static Byte_t R[4] = { 0x00, 0x00, 0x34, 0x12 }; 2799 static Byte_t R[4] = { 0x00, 0x00, 0x34, 0x12 };
2799 2800
2800 /* write to chan 0 SRAM */ 2801 /* write to chan 0 SRAM */
2801 sOutDW((DWordIO_t) io + _INDX_ADDR, *((DWord_t *) & R[0])); 2802 out32((DWordIO_t) io + _INDX_ADDR, R);
2802 sOutW(io + _INDX_ADDR, 0); /* read from SRAM, chan 0 */ 2803 sOutW(io + _INDX_ADDR, 0); /* read from SRAM, chan 0 */
2803 x = sInW(io + _INDX_DATA); 2804 x = sInW(io + _INDX_DATA);
2804 sOutW(io + _INDX_ADDR, 0x4000); /* read from SRAM, chan 4 */ 2805 sOutW(io + _INDX_ADDR, 0x4000); /* read from SRAM, chan 4 */
@@ -2864,7 +2865,7 @@ static int sInitChan(CONTROLLER_T * CtlP, CHANNEL_T * ChP, int AiopNum,
2864 R[1] = RData[i + 1] + 0x10 * ChanNum; 2865 R[1] = RData[i + 1] + 0x10 * ChanNum;
2865 R[2] = RData[i + 2]; 2866 R[2] = RData[i + 2];
2866 R[3] = RData[i + 3]; 2867 R[3] = RData[i + 3];
2867 sOutDW(ChP->IndexAddr, *((DWord_t *) & R[0])); 2868 out32(ChP->IndexAddr, R);
2868 } 2869 }
2869 2870
2870 ChR = ChP->R; 2871 ChR = ChP->R;
@@ -2887,43 +2888,43 @@ static int sInitChan(CONTROLLER_T * CtlP, CHANNEL_T * ChP, int AiopNum,
2887 ChP->BaudDiv[1] = (Byte_t) ((ChOff + _BAUD) >> 8); 2888 ChP->BaudDiv[1] = (Byte_t) ((ChOff + _BAUD) >> 8);
2888 ChP->BaudDiv[2] = (Byte_t) brd9600; 2889 ChP->BaudDiv[2] = (Byte_t) brd9600;
2889 ChP->BaudDiv[3] = (Byte_t) (brd9600 >> 8); 2890 ChP->BaudDiv[3] = (Byte_t) (brd9600 >> 8);
2890 sOutDW(ChP->IndexAddr, *(DWord_t *) & ChP->BaudDiv[0]); 2891 out32(ChP->IndexAddr, ChP->BaudDiv);
2891 2892
2892 ChP->TxControl[0] = (Byte_t) (ChOff + _TX_CTRL); 2893 ChP->TxControl[0] = (Byte_t) (ChOff + _TX_CTRL);
2893 ChP->TxControl[1] = (Byte_t) ((ChOff + _TX_CTRL) >> 8); 2894 ChP->TxControl[1] = (Byte_t) ((ChOff + _TX_CTRL) >> 8);
2894 ChP->TxControl[2] = 0; 2895 ChP->TxControl[2] = 0;
2895 ChP->TxControl[3] = 0; 2896 ChP->TxControl[3] = 0;
2896 sOutDW(ChP->IndexAddr, *(DWord_t *) & ChP->TxControl[0]); 2897 out32(ChP->IndexAddr, ChP->TxControl);
2897 2898
2898 ChP->RxControl[0] = (Byte_t) (ChOff + _RX_CTRL); 2899 ChP->RxControl[0] = (Byte_t) (ChOff + _RX_CTRL);
2899 ChP->RxControl[1] = (Byte_t) ((ChOff + _RX_CTRL) >> 8); 2900 ChP->RxControl[1] = (Byte_t) ((ChOff + _RX_CTRL) >> 8);
2900 ChP->RxControl[2] = 0; 2901 ChP->RxControl[2] = 0;
2901 ChP->RxControl[3] = 0; 2902 ChP->RxControl[3] = 0;
2902 sOutDW(ChP->IndexAddr, *(DWord_t *) & ChP->RxControl[0]); 2903 out32(ChP->IndexAddr, ChP->RxControl);
2903 2904
2904 ChP->TxEnables[0] = (Byte_t) (ChOff + _TX_ENBLS); 2905 ChP->TxEnables[0] = (Byte_t) (ChOff + _TX_ENBLS);
2905 ChP->TxEnables[1] = (Byte_t) ((ChOff + _TX_ENBLS) >> 8); 2906 ChP->TxEnables[1] = (Byte_t) ((ChOff + _TX_ENBLS) >> 8);
2906 ChP->TxEnables[2] = 0; 2907 ChP->TxEnables[2] = 0;
2907 ChP->TxEnables[3] = 0; 2908 ChP->TxEnables[3] = 0;
2908 sOutDW(ChP->IndexAddr, *(DWord_t *) & ChP->TxEnables[0]); 2909 out32(ChP->IndexAddr, ChP->TxEnables);
2909 2910
2910 ChP->TxCompare[0] = (Byte_t) (ChOff + _TXCMP1); 2911 ChP->TxCompare[0] = (Byte_t) (ChOff + _TXCMP1);
2911 ChP->TxCompare[1] = (Byte_t) ((ChOff + _TXCMP1) >> 8); 2912 ChP->TxCompare[1] = (Byte_t) ((ChOff + _TXCMP1) >> 8);
2912 ChP->TxCompare[2] = 0; 2913 ChP->TxCompare[2] = 0;
2913 ChP->TxCompare[3] = 0; 2914 ChP->TxCompare[3] = 0;
2914 sOutDW(ChP->IndexAddr, *(DWord_t *) & ChP->TxCompare[0]); 2915 out32(ChP->IndexAddr, ChP->TxCompare);
2915 2916
2916 ChP->TxReplace1[0] = (Byte_t) (ChOff + _TXREP1B1); 2917 ChP->TxReplace1[0] = (Byte_t) (ChOff + _TXREP1B1);
2917 ChP->TxReplace1[1] = (Byte_t) ((ChOff + _TXREP1B1) >> 8); 2918 ChP->TxReplace1[1] = (Byte_t) ((ChOff + _TXREP1B1) >> 8);
2918 ChP->TxReplace1[2] = 0; 2919 ChP->TxReplace1[2] = 0;
2919 ChP->TxReplace1[3] = 0; 2920 ChP->TxReplace1[3] = 0;
2920 sOutDW(ChP->IndexAddr, *(DWord_t *) & ChP->TxReplace1[0]); 2921 out32(ChP->IndexAddr, ChP->TxReplace1);
2921 2922
2922 ChP->TxReplace2[0] = (Byte_t) (ChOff + _TXREP2); 2923 ChP->TxReplace2[0] = (Byte_t) (ChOff + _TXREP2);
2923 ChP->TxReplace2[1] = (Byte_t) ((ChOff + _TXREP2) >> 8); 2924 ChP->TxReplace2[1] = (Byte_t) ((ChOff + _TXREP2) >> 8);
2924 ChP->TxReplace2[2] = 0; 2925 ChP->TxReplace2[2] = 0;
2925 ChP->TxReplace2[3] = 0; 2926 ChP->TxReplace2[3] = 0;
2926 sOutDW(ChP->IndexAddr, *(DWord_t *) & ChP->TxReplace2[0]); 2927 out32(ChP->IndexAddr, ChP->TxReplace2);
2927 2928
2928 ChP->TxFIFOPtrs = ChOff + _TXF_OUTP; 2929 ChP->TxFIFOPtrs = ChOff + _TXF_OUTP;
2929 ChP->TxFIFO = ChOff + _TX_FIFO; 2930 ChP->TxFIFO = ChOff + _TX_FIFO;
@@ -2979,7 +2980,7 @@ static void sStopRxProcessor(CHANNEL_T * ChP)
2979 R[1] = ChP->R[1]; 2980 R[1] = ChP->R[1];
2980 R[2] = 0x0a; 2981 R[2] = 0x0a;
2981 R[3] = ChP->R[3]; 2982 R[3] = ChP->R[3];
2982 sOutDW(ChP->IndexAddr, *(DWord_t *) & R[0]); 2983 out32(ChP->IndexAddr, R);
2983} 2984}
2984 2985
2985/*************************************************************************** 2986/***************************************************************************
@@ -3094,13 +3095,13 @@ static int sWriteTxPrioByte(CHANNEL_T * ChP, Byte_t Data)
3094 *WordPtr = ChP->TxPrioBuf; /* data byte address */ 3095 *WordPtr = ChP->TxPrioBuf; /* data byte address */
3095 3096
3096 DWBuf[2] = Data; /* data byte value */ 3097 DWBuf[2] = Data; /* data byte value */
3097 sOutDW(IndexAddr, *((DWord_t *) (&DWBuf[0]))); /* write it out */ 3098 out32(IndexAddr, DWBuf); /* write it out */
3098 3099
3099 *WordPtr = ChP->TxPrioCnt; /* Tx priority count address */ 3100 *WordPtr = ChP->TxPrioCnt; /* Tx priority count address */
3100 3101
3101 DWBuf[2] = PRI_PEND + 1; /* indicate 1 byte pending */ 3102 DWBuf[2] = PRI_PEND + 1; /* indicate 1 byte pending */
3102 DWBuf[3] = 0; /* priority buffer pointer */ 3103 DWBuf[3] = 0; /* priority buffer pointer */
3103 sOutDW(IndexAddr, *((DWord_t *) (&DWBuf[0]))); /* write it out */ 3104 out32(IndexAddr, DWBuf); /* write it out */
3104 } else { /* write it to Tx FIFO */ 3105 } else { /* write it to Tx FIFO */
3105 3106
3106 sWriteTxByte(sGetTxRxDataIO(ChP), Data); 3107 sWriteTxByte(sGetTxRxDataIO(ChP), Data);
@@ -3147,11 +3148,11 @@ static void sEnInterrupts(CHANNEL_T * ChP, Word_t Flags)
3147 ChP->RxControl[2] |= 3148 ChP->RxControl[2] |=
3148 ((Byte_t) Flags & (RXINT_EN | SRCINT_EN | MCINT_EN)); 3149 ((Byte_t) Flags & (RXINT_EN | SRCINT_EN | MCINT_EN));
3149 3150
3150 sOutDW(ChP->IndexAddr, *(DWord_t *) & ChP->RxControl[0]); 3151 out32(ChP->IndexAddr, ChP->RxControl);
3151 3152
3152 ChP->TxControl[2] |= ((Byte_t) Flags & TXINT_EN); 3153 ChP->TxControl[2] |= ((Byte_t) Flags & TXINT_EN);
3153 3154
3154 sOutDW(ChP->IndexAddr, *(DWord_t *) & ChP->TxControl[0]); 3155 out32(ChP->IndexAddr, ChP->TxControl);
3155 3156
3156 if (Flags & CHANINT_EN) { 3157 if (Flags & CHANINT_EN) {
3157 Mask = sInB(ChP->IntMask) | sBitMapSetTbl[ChP->ChanNum]; 3158 Mask = sInB(ChP->IntMask) | sBitMapSetTbl[ChP->ChanNum];
@@ -3190,9 +3191,9 @@ static void sDisInterrupts(CHANNEL_T * ChP, Word_t Flags)
3190 3191
3191 ChP->RxControl[2] &= 3192 ChP->RxControl[2] &=
3192 ~((Byte_t) Flags & (RXINT_EN | SRCINT_EN | MCINT_EN)); 3193 ~((Byte_t) Flags & (RXINT_EN | SRCINT_EN | MCINT_EN));
3193 sOutDW(ChP->IndexAddr, *(DWord_t *) & ChP->RxControl[0]); 3194 out32(ChP->IndexAddr, ChP->RxControl);
3194 ChP->TxControl[2] &= ~((Byte_t) Flags & TXINT_EN); 3195 ChP->TxControl[2] &= ~((Byte_t) Flags & TXINT_EN);
3195 sOutDW(ChP->IndexAddr, *(DWord_t *) & ChP->TxControl[0]); 3196 out32(ChP->IndexAddr, ChP->TxControl);
3196 3197
3197 if (Flags & CHANINT_EN) { 3198 if (Flags & CHANINT_EN) {
3198 Mask = sInB(ChP->IntMask) & sBitMapClrTbl[ChP->ChanNum]; 3199 Mask = sInB(ChP->IntMask) & sBitMapClrTbl[ChP->ChanNum];
diff --git a/drivers/char/rocket_int.h b/drivers/char/rocket_int.h
index f3a75791b811..b01d38125a8f 100644
--- a/drivers/char/rocket_int.h
+++ b/drivers/char/rocket_int.h
@@ -26,7 +26,6 @@ typedef unsigned int ByteIO_t;
26typedef unsigned int Word_t; 26typedef unsigned int Word_t;
27typedef unsigned int WordIO_t; 27typedef unsigned int WordIO_t;
28 28
29typedef unsigned long DWord_t;
30typedef unsigned int DWordIO_t; 29typedef unsigned int DWordIO_t;
31 30
32/* 31/*
@@ -38,7 +37,6 @@ typedef unsigned int DWordIO_t;
38 * instruction. 37 * instruction.
39 */ 38 */
40 39
41#ifdef ROCKET_DEBUG_IO
42static inline void sOutB(unsigned short port, unsigned char value) 40static inline void sOutB(unsigned short port, unsigned char value)
43{ 41{
44#ifdef ROCKET_DEBUG_IO 42#ifdef ROCKET_DEBUG_IO
@@ -55,12 +53,13 @@ static inline void sOutW(unsigned short port, unsigned short value)
55 outw_p(value, port); 53 outw_p(value, port);
56} 54}
57 55
58static inline void sOutDW(unsigned short port, unsigned long value) 56static inline void out32(unsigned short port, Byte_t *p)
59{ 57{
58 u32 value = le32_to_cpu(get_unaligned((__le32 *)p));
60#ifdef ROCKET_DEBUG_IO 59#ifdef ROCKET_DEBUG_IO
61 printk(KERN_DEBUG "sOutDW(%x, %lx)...\n", port, value); 60 printk(KERN_DEBUG "out32(%x, %lx)...\n", port, value);
62#endif 61#endif
63 outl_p(cpu_to_le32(value), port); 62 outl_p(value, port);
64} 63}
65 64
66static inline unsigned char sInB(unsigned short port) 65static inline unsigned char sInB(unsigned short port)
@@ -73,14 +72,6 @@ static inline unsigned short sInW(unsigned short port)
73 return inw_p(port); 72 return inw_p(port);
74} 73}
75 74
76#else /* !ROCKET_DEBUG_IO */
77#define sOutB(a, b) outb_p(b, a)
78#define sOutW(a, b) outw_p(b, a)
79#define sOutDW(port, value) outl_p(cpu_to_le32(value), port)
80#define sInB(a) (inb_p(a))
81#define sInW(a) (inw_p(a))
82#endif /* ROCKET_DEBUG_IO */
83
84/* This is used to move arrays of bytes so byte swapping isn't appropriate. */ 75/* This is used to move arrays of bytes so byte swapping isn't appropriate. */
85#define sOutStrW(port, addr, count) if (count) outsw(port, addr, count) 76#define sOutStrW(port, addr, count) if (count) outsw(port, addr, count)
86#define sInStrW(port, addr, count) if (count) insw(port, addr, count) 77#define sInStrW(port, addr, count) if (count) insw(port, addr, count)
@@ -390,7 +381,7 @@ Call: sClrBreak(ChP)
390#define sClrBreak(ChP) \ 381#define sClrBreak(ChP) \
391do { \ 382do { \
392 (ChP)->TxControl[3] &= ~SETBREAK; \ 383 (ChP)->TxControl[3] &= ~SETBREAK; \
393 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \ 384 out32((ChP)->IndexAddr,(ChP)->TxControl); \
394} while (0) 385} while (0)
395 386
396/*************************************************************************** 387/***************************************************************************
@@ -402,7 +393,7 @@ Call: sClrDTR(ChP)
402#define sClrDTR(ChP) \ 393#define sClrDTR(ChP) \
403do { \ 394do { \
404 (ChP)->TxControl[3] &= ~SET_DTR; \ 395 (ChP)->TxControl[3] &= ~SET_DTR; \
405 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \ 396 out32((ChP)->IndexAddr,(ChP)->TxControl); \
406} while (0) 397} while (0)
407 398
408/*************************************************************************** 399/***************************************************************************
@@ -415,7 +406,7 @@ Call: sClrRTS(ChP)
415do { \ 406do { \
416 if ((ChP)->rtsToggle) break; \ 407 if ((ChP)->rtsToggle) break; \
417 (ChP)->TxControl[3] &= ~SET_RTS; \ 408 (ChP)->TxControl[3] &= ~SET_RTS; \
418 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \ 409 out32((ChP)->IndexAddr,(ChP)->TxControl); \
419} while (0) 410} while (0)
420 411
421/*************************************************************************** 412/***************************************************************************
@@ -489,7 +480,7 @@ Call: sDisCTSFlowCtl(ChP)
489#define sDisCTSFlowCtl(ChP) \ 480#define sDisCTSFlowCtl(ChP) \
490do { \ 481do { \
491 (ChP)->TxControl[2] &= ~CTSFC_EN; \ 482 (ChP)->TxControl[2] &= ~CTSFC_EN; \
492 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \ 483 out32((ChP)->IndexAddr,(ChP)->TxControl); \
493} while (0) 484} while (0)
494 485
495/*************************************************************************** 486/***************************************************************************
@@ -501,7 +492,7 @@ Call: sDisIXANY(ChP)
501#define sDisIXANY(ChP) \ 492#define sDisIXANY(ChP) \
502do { \ 493do { \
503 (ChP)->R[0x0e] = 0x86; \ 494 (ChP)->R[0x0e] = 0x86; \
504 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x0c]); \ 495 out32((ChP)->IndexAddr,&(ChP)->R[0x0c]); \
505} while (0) 496} while (0)
506 497
507/*************************************************************************** 498/***************************************************************************
@@ -515,7 +506,7 @@ Comments: Function sSetParity() can be used in place of functions sEnParity(),
515#define sDisParity(ChP) \ 506#define sDisParity(ChP) \
516do { \ 507do { \
517 (ChP)->TxControl[2] &= ~PARITY_EN; \ 508 (ChP)->TxControl[2] &= ~PARITY_EN; \
518 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \ 509 out32((ChP)->IndexAddr,(ChP)->TxControl); \
519} while (0) 510} while (0)
520 511
521/*************************************************************************** 512/***************************************************************************
@@ -527,7 +518,7 @@ Call: sDisRTSToggle(ChP)
527#define sDisRTSToggle(ChP) \ 518#define sDisRTSToggle(ChP) \
528do { \ 519do { \
529 (ChP)->TxControl[2] &= ~RTSTOG_EN; \ 520 (ChP)->TxControl[2] &= ~RTSTOG_EN; \
530 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \ 521 out32((ChP)->IndexAddr,(ChP)->TxControl); \
531 (ChP)->rtsToggle = 0; \ 522 (ChP)->rtsToggle = 0; \
532} while (0) 523} while (0)
533 524
@@ -540,7 +531,7 @@ Call: sDisRxFIFO(ChP)
540#define sDisRxFIFO(ChP) \ 531#define sDisRxFIFO(ChP) \
541do { \ 532do { \
542 (ChP)->R[0x32] = 0x0a; \ 533 (ChP)->R[0x32] = 0x0a; \
543 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x30]); \ 534 out32((ChP)->IndexAddr,&(ChP)->R[0x30]); \
544} while (0) 535} while (0)
545 536
546/*************************************************************************** 537/***************************************************************************
@@ -567,7 +558,7 @@ Call: sDisTransmit(ChP)
567#define sDisTransmit(ChP) \ 558#define sDisTransmit(ChP) \
568do { \ 559do { \
569 (ChP)->TxControl[3] &= ~TX_ENABLE; \ 560 (ChP)->TxControl[3] &= ~TX_ENABLE; \
570 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \ 561 out32((ChP)->IndexAddr,(ChP)->TxControl); \
571} while (0) 562} while (0)
572 563
573/*************************************************************************** 564/***************************************************************************
@@ -579,7 +570,7 @@ Call: sDisTxSoftFlowCtl(ChP)
579#define sDisTxSoftFlowCtl(ChP) \ 570#define sDisTxSoftFlowCtl(ChP) \
580do { \ 571do { \
581 (ChP)->R[0x06] = 0x8a; \ 572 (ChP)->R[0x06] = 0x8a; \
582 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x04]); \ 573 out32((ChP)->IndexAddr,&(ChP)->R[0x04]); \
583} while (0) 574} while (0)
584 575
585/*************************************************************************** 576/***************************************************************************
@@ -604,7 +595,7 @@ Call: sEnCTSFlowCtl(ChP)
604#define sEnCTSFlowCtl(ChP) \ 595#define sEnCTSFlowCtl(ChP) \
605do { \ 596do { \
606 (ChP)->TxControl[2] |= CTSFC_EN; \ 597 (ChP)->TxControl[2] |= CTSFC_EN; \
607 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \ 598 out32((ChP)->IndexAddr,(ChP)->TxControl); \
608} while (0) 599} while (0)
609 600
610/*************************************************************************** 601/***************************************************************************
@@ -616,7 +607,7 @@ Call: sEnIXANY(ChP)
616#define sEnIXANY(ChP) \ 607#define sEnIXANY(ChP) \
617do { \ 608do { \
618 (ChP)->R[0x0e] = 0x21; \ 609 (ChP)->R[0x0e] = 0x21; \
619 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x0c]); \ 610 out32((ChP)->IndexAddr,&(ChP)->R[0x0c]); \
620} while (0) 611} while (0)
621 612
622/*************************************************************************** 613/***************************************************************************
@@ -633,7 +624,7 @@ Warnings: Before enabling parity odd or even parity should be chosen using
633#define sEnParity(ChP) \ 624#define sEnParity(ChP) \
634do { \ 625do { \
635 (ChP)->TxControl[2] |= PARITY_EN; \ 626 (ChP)->TxControl[2] |= PARITY_EN; \
636 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \ 627 out32((ChP)->IndexAddr,(ChP)->TxControl); \
637} while (0) 628} while (0)
638 629
639/*************************************************************************** 630/***************************************************************************
@@ -647,10 +638,10 @@ Comments: This function will disable RTS flow control and clear the RTS
647#define sEnRTSToggle(ChP) \ 638#define sEnRTSToggle(ChP) \
648do { \ 639do { \
649 (ChP)->RxControl[2] &= ~RTSFC_EN; \ 640 (ChP)->RxControl[2] &= ~RTSFC_EN; \
650 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->RxControl[0]); \ 641 out32((ChP)->IndexAddr,(ChP)->RxControl); \
651 (ChP)->TxControl[2] |= RTSTOG_EN; \ 642 (ChP)->TxControl[2] |= RTSTOG_EN; \
652 (ChP)->TxControl[3] &= ~SET_RTS; \ 643 (ChP)->TxControl[3] &= ~SET_RTS; \
653 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \ 644 out32((ChP)->IndexAddr,(ChP)->TxControl); \
654 (ChP)->rtsToggle = 1; \ 645 (ChP)->rtsToggle = 1; \
655} while (0) 646} while (0)
656 647
@@ -663,7 +654,7 @@ Call: sEnRxFIFO(ChP)
663#define sEnRxFIFO(ChP) \ 654#define sEnRxFIFO(ChP) \
664do { \ 655do { \
665 (ChP)->R[0x32] = 0x08; \ 656 (ChP)->R[0x32] = 0x08; \
666 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x30]); \ 657 out32((ChP)->IndexAddr,&(ChP)->R[0x30]); \
667} while (0) 658} while (0)
668 659
669/*************************************************************************** 660/***************************************************************************
@@ -684,7 +675,7 @@ Warnings: This function must be called after valid microcode has been
684#define sEnRxProcessor(ChP) \ 675#define sEnRxProcessor(ChP) \
685do { \ 676do { \
686 (ChP)->RxControl[2] |= RXPROC_EN; \ 677 (ChP)->RxControl[2] |= RXPROC_EN; \
687 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->RxControl[0]); \ 678 out32((ChP)->IndexAddr,(ChP)->RxControl); \
688} while (0) 679} while (0)
689 680
690/*************************************************************************** 681/***************************************************************************
@@ -708,7 +699,7 @@ Call: sEnTransmit(ChP)
708#define sEnTransmit(ChP) \ 699#define sEnTransmit(ChP) \
709do { \ 700do { \
710 (ChP)->TxControl[3] |= TX_ENABLE; \ 701 (ChP)->TxControl[3] |= TX_ENABLE; \
711 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \ 702 out32((ChP)->IndexAddr,(ChP)->TxControl); \
712} while (0) 703} while (0)
713 704
714/*************************************************************************** 705/***************************************************************************
@@ -720,7 +711,7 @@ Call: sEnTxSoftFlowCtl(ChP)
720#define sEnTxSoftFlowCtl(ChP) \ 711#define sEnTxSoftFlowCtl(ChP) \
721do { \ 712do { \
722 (ChP)->R[0x06] = 0xc5; \ 713 (ChP)->R[0x06] = 0xc5; \
723 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x04]); \ 714 out32((ChP)->IndexAddr,&(ChP)->R[0x04]); \
724} while (0) 715} while (0)
725 716
726/*************************************************************************** 717/***************************************************************************
@@ -927,7 +918,7 @@ Call: sSendBreak(ChP)
927#define sSendBreak(ChP) \ 918#define sSendBreak(ChP) \
928do { \ 919do { \
929 (ChP)->TxControl[3] |= SETBREAK; \ 920 (ChP)->TxControl[3] |= SETBREAK; \
930 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \ 921 out32((ChP)->IndexAddr,(ChP)->TxControl); \
931} while (0) 922} while (0)
932 923
933/*************************************************************************** 924/***************************************************************************
@@ -941,7 +932,7 @@ Call: sSetBaud(ChP,Divisor)
941do { \ 932do { \
942 (ChP)->BaudDiv[2] = (Byte_t)(DIVISOR); \ 933 (ChP)->BaudDiv[2] = (Byte_t)(DIVISOR); \
943 (ChP)->BaudDiv[3] = (Byte_t)((DIVISOR) >> 8); \ 934 (ChP)->BaudDiv[3] = (Byte_t)((DIVISOR) >> 8); \
944 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->BaudDiv[0]); \ 935 out32((ChP)->IndexAddr,(ChP)->BaudDiv); \
945} while (0) 936} while (0)
946 937
947/*************************************************************************** 938/***************************************************************************
@@ -953,7 +944,7 @@ Call: sSetData7(ChP)
953#define sSetData7(ChP) \ 944#define sSetData7(ChP) \
954do { \ 945do { \
955 (ChP)->TxControl[2] &= ~DATA8BIT; \ 946 (ChP)->TxControl[2] &= ~DATA8BIT; \
956 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \ 947 out32((ChP)->IndexAddr,(ChP)->TxControl); \
957} while (0) 948} while (0)
958 949
959/*************************************************************************** 950/***************************************************************************
@@ -965,7 +956,7 @@ Call: sSetData8(ChP)
965#define sSetData8(ChP) \ 956#define sSetData8(ChP) \
966do { \ 957do { \
967 (ChP)->TxControl[2] |= DATA8BIT; \ 958 (ChP)->TxControl[2] |= DATA8BIT; \
968 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \ 959 out32((ChP)->IndexAddr,(ChP)->TxControl); \
969} while (0) 960} while (0)
970 961
971/*************************************************************************** 962/***************************************************************************
@@ -977,7 +968,7 @@ Call: sSetDTR(ChP)
977#define sSetDTR(ChP) \ 968#define sSetDTR(ChP) \
978do { \ 969do { \
979 (ChP)->TxControl[3] |= SET_DTR; \ 970 (ChP)->TxControl[3] |= SET_DTR; \
980 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \ 971 out32((ChP)->IndexAddr,(ChP)->TxControl); \
981} while (0) 972} while (0)
982 973
983/*************************************************************************** 974/***************************************************************************
@@ -994,7 +985,7 @@ Warnings: This function has no effect unless parity is enabled with function
994#define sSetEvenParity(ChP) \ 985#define sSetEvenParity(ChP) \
995do { \ 986do { \
996 (ChP)->TxControl[2] |= EVEN_PAR; \ 987 (ChP)->TxControl[2] |= EVEN_PAR; \
997 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \ 988 out32((ChP)->IndexAddr,(ChP)->TxControl); \
998} while (0) 989} while (0)
999 990
1000/*************************************************************************** 991/***************************************************************************
@@ -1011,7 +1002,7 @@ Warnings: This function has no effect unless parity is enabled with function
1011#define sSetOddParity(ChP) \ 1002#define sSetOddParity(ChP) \
1012do { \ 1003do { \
1013 (ChP)->TxControl[2] &= ~EVEN_PAR; \ 1004 (ChP)->TxControl[2] &= ~EVEN_PAR; \
1014 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \ 1005 out32((ChP)->IndexAddr,(ChP)->TxControl); \
1015} while (0) 1006} while (0)
1016 1007
1017/*************************************************************************** 1008/***************************************************************************
@@ -1024,7 +1015,7 @@ Call: sSetRTS(ChP)
1024do { \ 1015do { \
1025 if ((ChP)->rtsToggle) break; \ 1016 if ((ChP)->rtsToggle) break; \
1026 (ChP)->TxControl[3] |= SET_RTS; \ 1017 (ChP)->TxControl[3] |= SET_RTS; \
1027 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \ 1018 out32((ChP)->IndexAddr,(ChP)->TxControl); \
1028} while (0) 1019} while (0)
1029 1020
1030/*************************************************************************** 1021/***************************************************************************
@@ -1050,7 +1041,7 @@ Comments: An interrupt will be generated when the trigger level is reached
1050do { \ 1041do { \
1051 (ChP)->RxControl[2] &= ~TRIG_MASK; \ 1042 (ChP)->RxControl[2] &= ~TRIG_MASK; \
1052 (ChP)->RxControl[2] |= LEVEL; \ 1043 (ChP)->RxControl[2] |= LEVEL; \
1053 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->RxControl[0]); \ 1044 out32((ChP)->IndexAddr,(ChP)->RxControl); \
1054} while (0) 1045} while (0)
1055 1046
1056/*************************************************************************** 1047/***************************************************************************
@@ -1062,7 +1053,7 @@ Call: sSetStop1(ChP)
1062#define sSetStop1(ChP) \ 1053#define sSetStop1(ChP) \
1063do { \ 1054do { \
1064 (ChP)->TxControl[2] &= ~STOP2; \ 1055 (ChP)->TxControl[2] &= ~STOP2; \
1065 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \ 1056 out32((ChP)->IndexAddr,(ChP)->TxControl); \
1066} while (0) 1057} while (0)
1067 1058
1068/*************************************************************************** 1059/***************************************************************************
@@ -1074,7 +1065,7 @@ Call: sSetStop2(ChP)
1074#define sSetStop2(ChP) \ 1065#define sSetStop2(ChP) \
1075do { \ 1066do { \
1076 (ChP)->TxControl[2] |= STOP2; \ 1067 (ChP)->TxControl[2] |= STOP2; \
1077 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \ 1068 out32((ChP)->IndexAddr,(ChP)->TxControl); \
1078} while (0) 1069} while (0)
1079 1070
1080/*************************************************************************** 1071/***************************************************************************
@@ -1087,7 +1078,7 @@ Call: sSetTxXOFFChar(ChP,Ch)
1087#define sSetTxXOFFChar(ChP,CH) \ 1078#define sSetTxXOFFChar(ChP,CH) \
1088do { \ 1079do { \
1089 (ChP)->R[0x07] = (CH); \ 1080 (ChP)->R[0x07] = (CH); \
1090 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x04]); \ 1081 out32((ChP)->IndexAddr,&(ChP)->R[0x04]); \
1091} while (0) 1082} while (0)
1092 1083
1093/*************************************************************************** 1084/***************************************************************************
@@ -1100,7 +1091,7 @@ Call: sSetTxXONChar(ChP,Ch)
1100#define sSetTxXONChar(ChP,CH) \ 1091#define sSetTxXONChar(ChP,CH) \
1101do { \ 1092do { \
1102 (ChP)->R[0x0b] = (CH); \ 1093 (ChP)->R[0x0b] = (CH); \
1103 sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x08]); \ 1094 out32((ChP)->IndexAddr,&(ChP)->R[0x08]); \
1104} while (0) 1095} while (0)
1105 1096
1106/*************************************************************************** 1097/***************************************************************************
@@ -1113,7 +1104,7 @@ Comments: This function is used to start a Rx processor after it was
1113 will restart both the Rx processor and software input flow control. 1104 will restart both the Rx processor and software input flow control.
1114 1105
1115*/ 1106*/
1116#define sStartRxProcessor(ChP) sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0]) 1107#define sStartRxProcessor(ChP) out32((ChP)->IndexAddr,&(ChP)->R[0])
1117 1108
1118/*************************************************************************** 1109/***************************************************************************
1119Function: sWriteTxByte 1110Function: sWriteTxByte
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index d73663a52324..fc555a90bb21 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -67,7 +67,7 @@ static void cpuidle_idle_call(void)
67 /* enter the state and update stats */ 67 /* enter the state and update stats */
68 dev->last_residency = target_state->enter(dev, target_state); 68 dev->last_residency = target_state->enter(dev, target_state);
69 dev->last_state = target_state; 69 dev->last_state = target_state;
70 target_state->time += dev->last_residency; 70 target_state->time += (unsigned long long)dev->last_residency;
71 target_state->usage++; 71 target_state->usage++;
72 72
73 /* give the governor an opportunity to reflect on the outcome */ 73 /* give the governor an opportunity to reflect on the outcome */
@@ -224,7 +224,7 @@ static void poll_idle_init(struct cpuidle_device *dev)
224 state->exit_latency = 0; 224 state->exit_latency = 0;
225 state->target_residency = 0; 225 state->target_residency = 0;
226 state->power_usage = -1; 226 state->power_usage = -1;
227 state->flags = CPUIDLE_FLAG_POLL | CPUIDLE_FLAG_TIME_VALID; 227 state->flags = CPUIDLE_FLAG_POLL;
228 state->enter = poll_idle; 228 state->enter = poll_idle;
229} 229}
230#else 230#else
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index 69102ca05685..e949618b9be0 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -218,6 +218,12 @@ static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \
218 return sprintf(buf, "%u\n", state->_name);\ 218 return sprintf(buf, "%u\n", state->_name);\
219} 219}
220 220
221#define define_show_state_ull_function(_name) \
222static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \
223{ \
224 return sprintf(buf, "%llu\n", state->_name);\
225}
226
221#define define_show_state_str_function(_name) \ 227#define define_show_state_str_function(_name) \
222static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ 228static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \
223{ \ 229{ \
@@ -228,8 +234,8 @@ static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \
228 234
229define_show_state_function(exit_latency) 235define_show_state_function(exit_latency)
230define_show_state_function(power_usage) 236define_show_state_function(power_usage)
231define_show_state_function(usage) 237define_show_state_ull_function(usage)
232define_show_state_function(time) 238define_show_state_ull_function(time)
233define_show_state_str_function(name) 239define_show_state_str_function(name)
234define_show_state_str_function(desc) 240define_show_state_str_function(desc)
235 241
diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
index 3110bf7014f7..81f3f950cd7d 100644
--- a/drivers/crypto/hifn_795x.c
+++ b/drivers/crypto/hifn_795x.c
@@ -392,8 +392,8 @@ static atomic_t hifn_dev_number;
392 392
393struct hifn_desc 393struct hifn_desc
394{ 394{
395 volatile u32 l; 395 volatile __le32 l;
396 volatile u32 p; 396 volatile __le32 p;
397}; 397};
398 398
399struct hifn_dma { 399struct hifn_dma {
@@ -481,10 +481,10 @@ struct hifn_device
481 481
482struct hifn_base_command 482struct hifn_base_command
483{ 483{
484 volatile u16 masks; 484 volatile __le16 masks;
485 volatile u16 session_num; 485 volatile __le16 session_num;
486 volatile u16 total_source_count; 486 volatile __le16 total_source_count;
487 volatile u16 total_dest_count; 487 volatile __le16 total_dest_count;
488}; 488};
489 489
490#define HIFN_BASE_CMD_COMP 0x0100 /* enable compression engine */ 490#define HIFN_BASE_CMD_COMP 0x0100 /* enable compression engine */
@@ -504,10 +504,10 @@ struct hifn_base_command
504 */ 504 */
505struct hifn_crypt_command 505struct hifn_crypt_command
506{ 506{
507 volatile u16 masks; 507 volatile __le16 masks;
508 volatile u16 header_skip; 508 volatile __le16 header_skip;
509 volatile u16 source_count; 509 volatile __le16 source_count;
510 volatile u16 reserved; 510 volatile __le16 reserved;
511}; 511};
512 512
513#define HIFN_CRYPT_CMD_ALG_MASK 0x0003 /* algorithm: */ 513#define HIFN_CRYPT_CMD_ALG_MASK 0x0003 /* algorithm: */
@@ -670,7 +670,7 @@ static inline u32 hifn_read_0(struct hifn_device *dev, u32 reg)
670{ 670{
671 u32 ret; 671 u32 ret;
672 672
673 ret = readl((char *)(dev->bar[0]) + reg); 673 ret = readl(dev->bar[0] + reg);
674 674
675 return ret; 675 return ret;
676} 676}
@@ -679,19 +679,19 @@ static inline u32 hifn_read_1(struct hifn_device *dev, u32 reg)
679{ 679{
680 u32 ret; 680 u32 ret;
681 681
682 ret = readl((char *)(dev->bar[1]) + reg); 682 ret = readl(dev->bar[1] + reg);
683 683
684 return ret; 684 return ret;
685} 685}
686 686
687static inline void hifn_write_0(struct hifn_device *dev, u32 reg, u32 val) 687static inline void hifn_write_0(struct hifn_device *dev, u32 reg, u32 val)
688{ 688{
689 writel(val, (char *)(dev->bar[0]) + reg); 689 writel(val, dev->bar[0] + reg);
690} 690}
691 691
692static inline void hifn_write_1(struct hifn_device *dev, u32 reg, u32 val) 692static inline void hifn_write_1(struct hifn_device *dev, u32 reg, u32 val)
693{ 693{
694 writel(val, (char *)(dev->bar[1]) + reg); 694 writel(val, dev->bar[1] + reg);
695} 695}
696 696
697static void hifn_wait_puc(struct hifn_device *dev) 697static void hifn_wait_puc(struct hifn_device *dev)
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
index ad2f938597e2..72692309398a 100644
--- a/drivers/dma/fsldma.c
+++ b/drivers/dma/fsldma.c
@@ -123,6 +123,11 @@ static dma_addr_t get_ndar(struct fsl_dma_chan *fsl_chan)
123 return DMA_IN(fsl_chan, &fsl_chan->reg_base->ndar, 64); 123 return DMA_IN(fsl_chan, &fsl_chan->reg_base->ndar, 64);
124} 124}
125 125
126static u32 get_bcr(struct fsl_dma_chan *fsl_chan)
127{
128 return DMA_IN(fsl_chan, &fsl_chan->reg_base->bcr, 32);
129}
130
126static int dma_is_idle(struct fsl_dma_chan *fsl_chan) 131static int dma_is_idle(struct fsl_dma_chan *fsl_chan)
127{ 132{
128 u32 sr = get_sr(fsl_chan); 133 u32 sr = get_sr(fsl_chan);
@@ -426,6 +431,9 @@ fsl_dma_prep_interrupt(struct dma_chan *chan)
426 new->async_tx.cookie = -EBUSY; 431 new->async_tx.cookie = -EBUSY;
427 new->async_tx.ack = 0; 432 new->async_tx.ack = 0;
428 433
434 /* Insert the link descriptor to the LD ring */
435 list_add_tail(&new->node, &new->async_tx.tx_list);
436
429 /* Set End-of-link to the last link descriptor of new list*/ 437 /* Set End-of-link to the last link descriptor of new list*/
430 set_ld_eol(fsl_chan, new); 438 set_ld_eol(fsl_chan, new);
431 439
@@ -701,6 +709,23 @@ static irqreturn_t fsl_dma_chan_do_interrupt(int irq, void *data)
701 if (stat & FSL_DMA_SR_TE) 709 if (stat & FSL_DMA_SR_TE)
702 dev_err(fsl_chan->dev, "Transfer Error!\n"); 710 dev_err(fsl_chan->dev, "Transfer Error!\n");
703 711
712 /* Programming Error
713 * The DMA_INTERRUPT async_tx is a NULL transfer, which will
714 * triger a PE interrupt.
715 */
716 if (stat & FSL_DMA_SR_PE) {
717 dev_dbg(fsl_chan->dev, "event: Programming Error INT\n");
718 if (get_bcr(fsl_chan) == 0) {
719 /* BCR register is 0, this is a DMA_INTERRUPT async_tx.
720 * Now, update the completed cookie, and continue the
721 * next uncompleted transfer.
722 */
723 fsl_dma_update_completed_cookie(fsl_chan);
724 fsl_chan_xfer_ld_queue(fsl_chan);
725 }
726 stat &= ~FSL_DMA_SR_PE;
727 }
728
704 /* If the link descriptor segment transfer finishes, 729 /* If the link descriptor segment transfer finishes,
705 * we will recycle the used descriptor. 730 * we will recycle the used descriptor.
706 */ 731 */
@@ -841,6 +866,11 @@ static int fsl_dma_self_test(struct fsl_dma_chan *fsl_chan)
841 tx3 = fsl_dma_prep_memcpy(chan, dma_dest, dma_src, test_size / 4, 0); 866 tx3 = fsl_dma_prep_memcpy(chan, dma_dest, dma_src, test_size / 4, 0);
842 async_tx_ack(tx3); 867 async_tx_ack(tx3);
843 868
869 /* Interrupt tx test */
870 tx1 = fsl_dma_prep_interrupt(chan);
871 async_tx_ack(tx1);
872 cookie = fsl_dma_tx_submit(tx1);
873
844 /* Test exchanging the prepared tx sort */ 874 /* Test exchanging the prepared tx sort */
845 cookie = fsl_dma_tx_submit(tx3); 875 cookie = fsl_dma_tx_submit(tx3);
846 cookie = fsl_dma_tx_submit(tx2); 876 cookie = fsl_dma_tx_submit(tx2);
diff --git a/drivers/dma/fsldma.h b/drivers/dma/fsldma.h
index ba78c42121ba..6faf07ba0d0e 100644
--- a/drivers/dma/fsldma.h
+++ b/drivers/dma/fsldma.h
@@ -40,6 +40,7 @@
40#define FSL_DMA_MR_EOTIE 0x00000080 40#define FSL_DMA_MR_EOTIE 0x00000080
41 41
42#define FSL_DMA_SR_CH 0x00000020 42#define FSL_DMA_SR_CH 0x00000020
43#define FSL_DMA_SR_PE 0x00000010
43#define FSL_DMA_SR_CB 0x00000004 44#define FSL_DMA_SR_CB 0x00000004
44#define FSL_DMA_SR_TE 0x00000080 45#define FSL_DMA_SR_TE 0x00000080
45#define FSL_DMA_SR_EOSI 0x00000002 46#define FSL_DMA_SR_EOSI 0x00000002
@@ -74,12 +75,15 @@
74#define FSL_DMA_DGSR_EOSI 0x02 75#define FSL_DMA_DGSR_EOSI 0x02
75#define FSL_DMA_DGSR_EOLSI 0x01 76#define FSL_DMA_DGSR_EOLSI 0x01
76 77
78typedef u64 __bitwise v64;
79typedef u32 __bitwise v32;
80
77struct fsl_dma_ld_hw { 81struct fsl_dma_ld_hw {
78 u64 __bitwise src_addr; 82 v64 src_addr;
79 u64 __bitwise dst_addr; 83 v64 dst_addr;
80 u64 __bitwise next_ln_addr; 84 v64 next_ln_addr;
81 u32 __bitwise count; 85 v32 count;
82 u32 __bitwise reserve; 86 v32 reserve;
83} __attribute__((aligned(32))); 87} __attribute__((aligned(32)));
84 88
85struct fsl_desc_sw { 89struct fsl_desc_sw {
@@ -91,13 +95,13 @@ struct fsl_desc_sw {
91} __attribute__((aligned(32))); 95} __attribute__((aligned(32)));
92 96
93struct fsl_dma_chan_regs { 97struct fsl_dma_chan_regs {
94 u32 __bitwise mr; /* 0x00 - Mode Register */ 98 u32 mr; /* 0x00 - Mode Register */
95 u32 __bitwise sr; /* 0x04 - Status Register */ 99 u32 sr; /* 0x04 - Status Register */
96 u64 __bitwise cdar; /* 0x08 - Current descriptor address register */ 100 u64 cdar; /* 0x08 - Current descriptor address register */
97 u64 __bitwise sar; /* 0x10 - Source Address Register */ 101 u64 sar; /* 0x10 - Source Address Register */
98 u64 __bitwise dar; /* 0x18 - Destination Address Register */ 102 u64 dar; /* 0x18 - Destination Address Register */
99 u32 __bitwise bcr; /* 0x20 - Byte Count Register */ 103 u32 bcr; /* 0x20 - Byte Count Register */
100 u64 __bitwise ndar; /* 0x24 - Next Descriptor Address Register */ 104 u64 ndar; /* 0x24 - Next Descriptor Address Register */
101}; 105};
102 106
103struct fsl_dma_chan; 107struct fsl_dma_chan;
@@ -150,25 +154,27 @@ struct fsl_dma_chan {
150#ifndef __powerpc64__ 154#ifndef __powerpc64__
151static u64 in_be64(const u64 __iomem *addr) 155static u64 in_be64(const u64 __iomem *addr)
152{ 156{
153 return ((u64)in_be32((u32 *)addr) << 32) | (in_be32((u32 *)addr + 1)); 157 return ((u64)in_be32((u32 __iomem *)addr) << 32) |
158 (in_be32((u32 __iomem *)addr + 1));
154} 159}
155 160
156static void out_be64(u64 __iomem *addr, u64 val) 161static void out_be64(u64 __iomem *addr, u64 val)
157{ 162{
158 out_be32((u32 *)addr, val >> 32); 163 out_be32((u32 __iomem *)addr, val >> 32);
159 out_be32((u32 *)addr + 1, (u32)val); 164 out_be32((u32 __iomem *)addr + 1, (u32)val);
160} 165}
161 166
162/* There is no asm instructions for 64 bits reverse loads and stores */ 167/* There is no asm instructions for 64 bits reverse loads and stores */
163static u64 in_le64(const u64 __iomem *addr) 168static u64 in_le64(const u64 __iomem *addr)
164{ 169{
165 return ((u64)in_le32((u32 *)addr + 1) << 32) | (in_le32((u32 *)addr)); 170 return ((u64)in_le32((u32 __iomem *)addr + 1) << 32) |
171 (in_le32((u32 __iomem *)addr));
166} 172}
167 173
168static void out_le64(u64 __iomem *addr, u64 val) 174static void out_le64(u64 __iomem *addr, u64 val)
169{ 175{
170 out_le32((u32 *)addr + 1, val >> 32); 176 out_le32((u32 __iomem *)addr + 1, val >> 32);
171 out_le32((u32 *)addr, (u32)val); 177 out_le32((u32 __iomem *)addr, (u32)val);
172} 178}
173#endif 179#endif
174 180
@@ -181,9 +187,11 @@ static void out_le64(u64 __iomem *addr, u64 val)
181 187
182#define DMA_TO_CPU(fsl_chan, d, width) \ 188#define DMA_TO_CPU(fsl_chan, d, width) \
183 (((fsl_chan)->feature & FSL_DMA_BIG_ENDIAN) ? \ 189 (((fsl_chan)->feature & FSL_DMA_BIG_ENDIAN) ? \
184 be##width##_to_cpu(d) : le##width##_to_cpu(d)) 190 be##width##_to_cpu((__force __be##width)(v##width)d) : \
191 le##width##_to_cpu((__force __le##width)(v##width)d))
185#define CPU_TO_DMA(fsl_chan, c, width) \ 192#define CPU_TO_DMA(fsl_chan, c, width) \
186 (((fsl_chan)->feature & FSL_DMA_BIG_ENDIAN) ? \ 193 (((fsl_chan)->feature & FSL_DMA_BIG_ENDIAN) ? \
187 cpu_to_be##width(c) : cpu_to_le##width(c)) 194 (__force v##width)cpu_to_be##width(c) : \
195 (__force v##width)cpu_to_le##width(c))
188 196
189#endif /* __DMA_FSLDMA_H */ 197#endif /* __DMA_FSLDMA_H */
diff --git a/drivers/dma/ioat_dca.c b/drivers/dma/ioat_dca.c
index 0fa8a98051a8..9e922760b7ff 100644
--- a/drivers/dma/ioat_dca.c
+++ b/drivers/dma/ioat_dca.c
@@ -98,7 +98,7 @@ struct ioat_dca_slot {
98 98
99struct ioat_dca_priv { 99struct ioat_dca_priv {
100 void __iomem *iobase; 100 void __iomem *iobase;
101 void *dca_base; 101 void __iomem *dca_base;
102 int max_requesters; 102 int max_requesters;
103 int requester_count; 103 int requester_count;
104 u8 tag_map[IOAT_TAG_MAP_LEN]; 104 u8 tag_map[IOAT_TAG_MAP_LEN];
@@ -338,7 +338,7 @@ static struct dca_ops ioat2_dca_ops = {
338 .get_tag = ioat2_dca_get_tag, 338 .get_tag = ioat2_dca_get_tag,
339}; 339};
340 340
341static int ioat2_dca_count_dca_slots(void *iobase, u16 dca_offset) 341static int ioat2_dca_count_dca_slots(void __iomem *iobase, u16 dca_offset)
342{ 342{
343 int slots = 0; 343 int slots = 0;
344 u32 req; 344 u32 req;
diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c
index 996d61f0d460..ca6d51efd8bb 100644
--- a/drivers/firewire/fw-ohci.c
+++ b/drivers/firewire/fw-ohci.c
@@ -401,7 +401,8 @@ static void ar_context_tasklet(unsigned long data)
401 401
402 if (d->res_count == 0) { 402 if (d->res_count == 0) {
403 size_t size, rest, offset; 403 size_t size, rest, offset;
404 dma_addr_t buffer_bus; 404 dma_addr_t start_bus;
405 void *start;
405 406
406 /* 407 /*
407 * This descriptor is finished and we may have a 408 * This descriptor is finished and we may have a
@@ -410,9 +411,9 @@ static void ar_context_tasklet(unsigned long data)
410 */ 411 */
411 412
412 offset = offsetof(struct ar_buffer, data); 413 offset = offsetof(struct ar_buffer, data);
413 buffer_bus = le32_to_cpu(ab->descriptor.data_address) - offset; 414 start = buffer = ab;
415 start_bus = le32_to_cpu(ab->descriptor.data_address) - offset;
414 416
415 buffer = ab;
416 ab = ab->next; 417 ab = ab->next;
417 d = &ab->descriptor; 418 d = &ab->descriptor;
418 size = buffer + PAGE_SIZE - ctx->pointer; 419 size = buffer + PAGE_SIZE - ctx->pointer;
@@ -427,7 +428,7 @@ static void ar_context_tasklet(unsigned long data)
427 buffer = handle_ar_packet(ctx, buffer); 428 buffer = handle_ar_packet(ctx, buffer);
428 429
429 dma_free_coherent(ohci->card.device, PAGE_SIZE, 430 dma_free_coherent(ohci->card.device, PAGE_SIZE,
430 buffer, buffer_bus); 431 start, start_bus);
431 ar_context_add_page(ctx); 432 ar_context_add_page(ctx);
432 } else { 433 } else {
433 buffer = ctx->pointer; 434 buffer = ctx->pointer;
diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c
index 99529e59a0b1..e6f1bda38940 100644
--- a/drivers/firewire/fw-transaction.c
+++ b/drivers/firewire/fw-transaction.c
@@ -736,6 +736,12 @@ fw_core_handle_response(struct fw_card *card, struct fw_packet *p)
736 break; 736 break;
737 } 737 }
738 738
739 /*
740 * The response handler may be executed while the request handler
741 * is still pending. Cancel the request handler.
742 */
743 card->driver->cancel_packet(card, &t->packet);
744
739 t->callback(card, rcode, data, data_length, t->callback_data); 745 t->callback(card, rcode, data, data_length, t->callback_data);
740} 746}
741EXPORT_SYMBOL(fw_core_handle_response); 747EXPORT_SYMBOL(fw_core_handle_response);
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index d73a768e176e..f0b00ec1e47e 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -968,7 +968,7 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i
968 size--; 968 size--;
969 } 969 }
970 970
971 /* dump the report descriptor */ 971 /* dump the report */
972 dbg_hid("report %d (size %u) = ", n, size); 972 dbg_hid("report %d (size %u) = ", n, size);
973 for (i = 0; i < size; i++) 973 for (i = 0; i < size; i++)
974 dbg_hid_line(" %02x", data[i]); 974 dbg_hid_line(" %02x", data[i]);
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 5a38fb27d69f..c3eb3f13e2ca 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -98,18 +98,16 @@ struct hidinput_key_translation {
98 98
99static struct hidinput_key_translation apple_fn_keys[] = { 99static struct hidinput_key_translation apple_fn_keys[] = {
100 { KEY_BACKSPACE, KEY_DELETE }, 100 { KEY_BACKSPACE, KEY_DELETE },
101 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, 101 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
102 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, 102 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
103 { KEY_F3, KEY_CYCLEWINDOWS, APPLE_FLAG_FKEY }, /* Exposé */ 103 { KEY_F3, KEY_FN_F5, APPLE_FLAG_FKEY }, /* Exposé */
104 { KEY_F4, KEY_FN_F4, APPLE_FLAG_FKEY }, /* Dashboard */ 104 { KEY_F4, KEY_FN_F4, APPLE_FLAG_FKEY }, /* Dashboard */
105 { KEY_F5, KEY_FN_F5 }, 105 { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
106 { KEY_F6, KEY_FN_F6 }, 106 { KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
107 { KEY_F7, KEY_BACK, APPLE_FLAG_FKEY }, 107 { KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY },
108 { KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY }, 108 { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
109 { KEY_F9, KEY_FORWARD, APPLE_FLAG_FKEY }, 109 { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
110 { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY }, 110 { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
111 { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
112 { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
113 { KEY_UP, KEY_PAGEUP }, 111 { KEY_UP, KEY_PAGEUP },
114 { KEY_DOWN, KEY_PAGEDOWN }, 112 { KEY_DOWN, KEY_PAGEDOWN },
115 { KEY_LEFT, KEY_HOME }, 113 { KEY_LEFT, KEY_HOME },
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index b38e559b7a46..d95979f0e028 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -278,7 +278,7 @@ static int hid_submit_ctrl(struct hid_device *hid)
278 usbhid->urbctrl->pipe = usb_rcvctrlpipe(hid_to_usb_dev(hid), 0); 278 usbhid->urbctrl->pipe = usb_rcvctrlpipe(hid_to_usb_dev(hid), 0);
279 maxpacket = usb_maxpacket(hid_to_usb_dev(hid), usbhid->urbctrl->pipe, 0); 279 maxpacket = usb_maxpacket(hid_to_usb_dev(hid), usbhid->urbctrl->pipe, 0);
280 if (maxpacket > 0) { 280 if (maxpacket > 0) {
281 padlen = (len + maxpacket - 1) / maxpacket; 281 padlen = DIV_ROUND_UP(len, maxpacket);
282 padlen *= maxpacket; 282 padlen *= maxpacket;
283 if (padlen > usbhid->bufsize) 283 if (padlen > usbhid->bufsize)
284 padlen = usbhid->bufsize; 284 padlen = usbhid->bufsize;
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index e6d05f6b1c1c..e29a057cbea2 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -345,6 +345,9 @@
345#define USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR 0x0400 345#define USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR 0x0400
346#define USB_DEVICE_ID_N_S_HARMONY 0xc359 346#define USB_DEVICE_ID_N_S_HARMONY 0xc359
347 347
348#define USB_VENDOR_ID_NATSU 0x08b7
349#define USB_DEVICE_ID_NATSU_GAMEPAD 0x0001
350
348#define USB_VENDOR_ID_NEC 0x073e 351#define USB_VENDOR_ID_NEC 0x073e
349#define USB_DEVICE_ID_NEC_USB_GAME_PAD 0x0301 352#define USB_DEVICE_ID_NEC_USB_GAME_PAD 0x0301
350 353
@@ -426,6 +429,7 @@ static const struct hid_blacklist {
426 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, 429 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT },
427 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, 430 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT },
428 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, 431 { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT },
432 { USB_VENDOR_ID_NATSU, USB_DEVICE_ID_NATSU_GAMEPAD, HID_QUIRK_BADPAD },
429 { USB_VENDOR_ID_NEC, USB_DEVICE_ID_NEC_USB_GAME_PAD, HID_QUIRK_BADPAD }, 433 { USB_VENDOR_ID_NEC, USB_DEVICE_ID_NEC_USB_GAME_PAD, HID_QUIRK_BADPAD },
430 { USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RUMBLEPAD, HID_QUIRK_BADPAD }, 434 { USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RUMBLEPAD, HID_QUIRK_BADPAD },
431 { USB_VENDOR_ID_TOPMAX, USB_DEVICE_ID_TOPMAX_COBRAPAD, HID_QUIRK_BADPAD }, 435 { USB_VENDOR_ID_TOPMAX, USB_DEVICE_ID_TOPMAX_COBRAPAD, HID_QUIRK_BADPAD },
@@ -624,7 +628,7 @@ static const struct hid_blacklist {
624 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_APPLE_ISO_KEYBOARD }, 628 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_APPLE_ISO_KEYBOARD },
625 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS, HID_QUIRK_APPLE_HAS_FN }, 629 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS, HID_QUIRK_APPLE_HAS_FN },
626 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, 630 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
627 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_APPLE_ISO_KEYBOARD }, 631 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
628 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, 632 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
629 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI, HID_QUIRK_APPLE_HAS_FN }, 633 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI, HID_QUIRK_APPLE_HAS_FN },
630 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_APPLE_ISO_KEYBOARD }, 634 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_APPLE_ISO_KEYBOARD },
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 368879ff5d8c..4dc76bc45c9d 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -337,8 +337,9 @@ config SENSORS_IBMPEX
337 help 337 help
338 If you say yes here you get support for the temperature and 338 If you say yes here you get support for the temperature and
339 power sensors in various IBM System X servers that support 339 power sensors in various IBM System X servers that support
340 PowerExecutive. So far this includes the x3550, x3650, x3655, 340 PowerExecutive. So far this includes the x3350, x3550, x3650,
341 x3755, and certain HS20 blades. 341 x3655, and x3755; the x3800, x3850, and x3950 models that have
342 PCI Express; and some of the HS2x, LS2x, and QS2x blades.
342 343
343 This driver can also be built as a module. If so, the module 344 This driver can also be built as a module. If so, the module
344 will be called ibmpex. 345 will be called ibmpex.
diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c
index 9c9cdb0685e4..4e9b19c6732f 100644
--- a/drivers/hwmon/ibmpex.c
+++ b/drivers/hwmon/ibmpex.c
@@ -327,10 +327,14 @@ static int is_temp_sensor(const char *sensor_id, int len)
327 return 0; 327 return 0;
328} 328}
329 329
330static int power_sensor_multiplier(const char *sensor_id, int len) 330static int power_sensor_multiplier(struct ibmpex_bmc_data *data,
331 const char *sensor_id, int len)
331{ 332{
332 int i; 333 int i;
333 334
335 if (data->sensor_major == 2)
336 return 1000000;
337
334 for (i = PEX_SENSOR_TYPE_LEN; i < len - 1; i++) 338 for (i = PEX_SENSOR_TYPE_LEN; i < len - 1; i++)
335 if (!memcmp(&sensor_id[i], watt_sensor_sig, PEX_MULT_LEN)) 339 if (!memcmp(&sensor_id[i], watt_sensor_sig, PEX_MULT_LEN))
336 return 1000000; 340 return 1000000;
@@ -398,14 +402,15 @@ static int ibmpex_find_sensors(struct ibmpex_bmc_data *data)
398 num_power++; 402 num_power++;
399 sensor_counter = num_power; 403 sensor_counter = num_power;
400 data->sensors[i].multiplier = 404 data->sensors[i].multiplier =
401 power_sensor_multiplier(data->rx_msg_data, 405 power_sensor_multiplier(data,
402 data->rx_msg_len); 406 data->rx_msg_data,
407 data->rx_msg_len);
403 } else if (is_temp_sensor(data->rx_msg_data, 408 } else if (is_temp_sensor(data->rx_msg_data,
404 data->rx_msg_len)) { 409 data->rx_msg_len)) {
405 sensor_type = TEMP_SENSOR; 410 sensor_type = TEMP_SENSOR;
406 num_temp++; 411 num_temp++;
407 sensor_counter = num_temp; 412 sensor_counter = num_temp;
408 data->sensors[i].multiplier = 1; 413 data->sensors[i].multiplier = 1000;
409 } else 414 } else
410 continue; 415 continue;
411 416
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index 5c85670e2d16..f942ecdd47c8 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -1367,7 +1367,8 @@ w83781d_isa_probe(struct platform_device *pdev)
1367 1367
1368 /* Reserve the ISA region */ 1368 /* Reserve the ISA region */
1369 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 1369 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
1370 if (!request_region(res->start, W83781D_EXTENT, "w83781d")) { 1370 if (!request_region(res->start + W83781D_ADDR_REG_OFFSET, 2,
1371 "w83781d")) {
1371 err = -EBUSY; 1372 err = -EBUSY;
1372 goto exit; 1373 goto exit;
1373 } 1374 }
@@ -1415,7 +1416,7 @@ w83781d_isa_probe(struct platform_device *pdev)
1415 device_remove_file(&pdev->dev, &dev_attr_name); 1416 device_remove_file(&pdev->dev, &dev_attr_name);
1416 kfree(data); 1417 kfree(data);
1417 exit_release_region: 1418 exit_release_region:
1418 release_region(res->start, W83781D_EXTENT); 1419 release_region(res->start + W83781D_ADDR_REG_OFFSET, 2);
1419 exit: 1420 exit:
1420 return err; 1421 return err;
1421} 1422}
@@ -1429,7 +1430,7 @@ w83781d_isa_remove(struct platform_device *pdev)
1429 sysfs_remove_group(&pdev->dev.kobj, &w83781d_group); 1430 sysfs_remove_group(&pdev->dev.kobj, &w83781d_group);
1430 sysfs_remove_group(&pdev->dev.kobj, &w83781d_group_opt); 1431 sysfs_remove_group(&pdev->dev.kobj, &w83781d_group_opt);
1431 device_remove_file(&pdev->dev, &dev_attr_name); 1432 device_remove_file(&pdev->dev, &dev_attr_name);
1432 release_region(data->client.addr, W83781D_EXTENT); 1433 release_region(data->client.addr + W83781D_ADDR_REG_OFFSET, 2);
1433 kfree(data); 1434 kfree(data);
1434 1435
1435 return 0; 1436 return 0;
@@ -1797,8 +1798,17 @@ w83781d_isa_found(unsigned short address)
1797{ 1798{
1798 int val, save, found = 0; 1799 int val, save, found = 0;
1799 1800
1800 if (!request_region(address, W83781D_EXTENT, "w83781d")) 1801 /* We have to request the region in two parts because some
1802 boards declare base+4 to base+7 as a PNP device */
1803 if (!request_region(address, 4, "w83781d")) {
1804 pr_debug("w83781d: Failed to request low part of region\n");
1801 return 0; 1805 return 0;
1806 }
1807 if (!request_region(address + 4, 4, "w83781d")) {
1808 pr_debug("w83781d: Failed to request high part of region\n");
1809 release_region(address, 4);
1810 return 0;
1811 }
1802 1812
1803#define REALLY_SLOW_IO 1813#define REALLY_SLOW_IO
1804 /* We need the timeouts for at least some W83781D-like 1814 /* We need the timeouts for at least some W83781D-like
@@ -1871,7 +1881,8 @@ w83781d_isa_found(unsigned short address)
1871 val == 0x30 ? "W83782D" : "W83781D", (int)address); 1881 val == 0x30 ? "W83782D" : "W83781D", (int)address);
1872 1882
1873 release: 1883 release:
1874 release_region(address, W83781D_EXTENT); 1884 release_region(address + 4, 4);
1885 release_region(address, 4);
1875 return found; 1886 return found;
1876} 1887}
1877 1888
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 476b0bb72d6c..5fa9c3c67e0c 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -100,7 +100,7 @@ config I2C_AU1550
100 100
101config I2C_BLACKFIN_TWI 101config I2C_BLACKFIN_TWI
102 tristate "Blackfin TWI I2C support" 102 tristate "Blackfin TWI I2C support"
103 depends on BF534 || BF536 || BF537 || BF54x 103 depends on BF534 || BF536 || BF537
104 help 104 help
105 This is the TWI I2C device driver for Blackfin 534/536/537/54x. 105 This is the TWI I2C device driver for Blackfin 534/536/537/54x.
106 This driver can also be built as a module. If so, the module 106 This driver can also be built as a module. If so, the module
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index da6639707ea3..7ba31770d773 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -128,6 +128,8 @@ struct omap_i2c_dev {
128 size_t buf_len; 128 size_t buf_len;
129 struct i2c_adapter adapter; 129 struct i2c_adapter adapter;
130 unsigned rev1:1; 130 unsigned rev1:1;
131 unsigned idle:1;
132 u16 iestate; /* Saved interrupt register */
131}; 133};
132 134
133static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev, 135static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev,
@@ -174,18 +176,30 @@ static void omap_i2c_put_clocks(struct omap_i2c_dev *dev)
174 } 176 }
175} 177}
176 178
177static void omap_i2c_enable_clocks(struct omap_i2c_dev *dev) 179static void omap_i2c_unidle(struct omap_i2c_dev *dev)
178{ 180{
179 if (dev->iclk != NULL) 181 if (dev->iclk != NULL)
180 clk_enable(dev->iclk); 182 clk_enable(dev->iclk);
181 clk_enable(dev->fclk); 183 clk_enable(dev->fclk);
184 if (dev->iestate)
185 omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, dev->iestate);
186 dev->idle = 0;
182} 187}
183 188
184static void omap_i2c_disable_clocks(struct omap_i2c_dev *dev) 189static void omap_i2c_idle(struct omap_i2c_dev *dev)
185{ 190{
191 u16 iv;
192
193 dev->idle = 1;
194 dev->iestate = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG);
195 omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, 0);
196 if (dev->rev1)
197 iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG); /* Read clears */
198 else
199 omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, dev->iestate);
200 clk_disable(dev->fclk);
186 if (dev->iclk != NULL) 201 if (dev->iclk != NULL)
187 clk_disable(dev->iclk); 202 clk_disable(dev->iclk);
188 clk_disable(dev->fclk);
189} 203}
190 204
191static int omap_i2c_init(struct omap_i2c_dev *dev) 205static int omap_i2c_init(struct omap_i2c_dev *dev)
@@ -360,7 +374,7 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
360 int i; 374 int i;
361 int r; 375 int r;
362 376
363 omap_i2c_enable_clocks(dev); 377 omap_i2c_unidle(dev);
364 378
365 if ((r = omap_i2c_wait_for_bb(dev)) < 0) 379 if ((r = omap_i2c_wait_for_bb(dev)) < 0)
366 goto out; 380 goto out;
@@ -374,7 +388,7 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
374 if (r == 0) 388 if (r == 0)
375 r = num; 389 r = num;
376out: 390out:
377 omap_i2c_disable_clocks(dev); 391 omap_i2c_idle(dev);
378 return r; 392 return r;
379} 393}
380 394
@@ -403,6 +417,9 @@ omap_i2c_rev1_isr(int this_irq, void *dev_id)
403 struct omap_i2c_dev *dev = dev_id; 417 struct omap_i2c_dev *dev = dev_id;
404 u16 iv, w; 418 u16 iv, w;
405 419
420 if (dev->idle)
421 return IRQ_NONE;
422
406 iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG); 423 iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG);
407 switch (iv) { 424 switch (iv) {
408 case 0x00: /* None */ 425 case 0x00: /* None */
@@ -457,6 +474,9 @@ omap_i2c_isr(int this_irq, void *dev_id)
457 u16 stat, w; 474 u16 stat, w;
458 int count = 0; 475 int count = 0;
459 476
477 if (dev->idle)
478 return IRQ_NONE;
479
460 bits = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG); 480 bits = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG);
461 while ((stat = (omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG))) & bits) { 481 while ((stat = (omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG))) & bits) {
462 dev_dbg(dev->dev, "IRQ (ISR = 0x%04x)\n", stat); 482 dev_dbg(dev->dev, "IRQ (ISR = 0x%04x)\n", stat);
@@ -575,7 +595,7 @@ omap_i2c_probe(struct platform_device *pdev)
575 if ((r = omap_i2c_get_clocks(dev)) != 0) 595 if ((r = omap_i2c_get_clocks(dev)) != 0)
576 goto err_free_mem; 596 goto err_free_mem;
577 597
578 omap_i2c_enable_clocks(dev); 598 omap_i2c_unidle(dev);
579 599
580 if (cpu_is_omap15xx()) 600 if (cpu_is_omap15xx())
581 dev->rev1 = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) < 0x20; 601 dev->rev1 = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) < 0x20;
@@ -610,7 +630,7 @@ omap_i2c_probe(struct platform_device *pdev)
610 goto err_free_irq; 630 goto err_free_irq;
611 } 631 }
612 632
613 omap_i2c_disable_clocks(dev); 633 omap_i2c_idle(dev);
614 634
615 return 0; 635 return 0;
616 636
@@ -618,7 +638,7 @@ err_free_irq:
618 free_irq(dev->irq, dev); 638 free_irq(dev->irq, dev);
619err_unuse_clocks: 639err_unuse_clocks:
620 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); 640 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
621 omap_i2c_disable_clocks(dev); 641 omap_i2c_idle(dev);
622 omap_i2c_put_clocks(dev); 642 omap_i2c_put_clocks(dev);
623err_free_mem: 643err_free_mem:
624 platform_set_drvdata(pdev, NULL); 644 platform_set_drvdata(pdev, NULL);
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index fd84b2a36338..8b645c6b2cb5 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -489,8 +489,8 @@ EXPORT_SYMBOL(i2c_add_adapter);
489 * Context: can sleep 489 * Context: can sleep
490 * 490 *
491 * This routine is used to declare an I2C adapter when its bus number 491 * This routine is used to declare an I2C adapter when its bus number
492 * matters. Example: for I2C adapters from system-on-chip CPUs, or 492 * matters. For example, use it for I2C adapters from system-on-chip CPUs,
493 * otherwise built in to the system's mainboard, and where i2c_board_info 493 * or otherwise built in to the system's mainboard, and where i2c_board_info
494 * is used to properly configure I2C devices. 494 * is used to properly configure I2C devices.
495 * 495 *
496 * If no devices have pre-been declared for this bus, then be sure to 496 * If no devices have pre-been declared for this bus, then be sure to
diff --git a/drivers/ide/arm/ide_arm.c b/drivers/ide/arm/ide_arm.c
index 43a70e91363e..be9ff7334c52 100644
--- a/drivers/ide/arm/ide_arm.c
+++ b/drivers/ide/arm/ide_arm.c
@@ -46,3 +46,5 @@ static int __init ide_arm_init(void)
46} 46}
47 47
48module_init(ide_arm_init); 48module_init(ide_arm_init);
49
50MODULE_LICENSE("GPL");
diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c
index e79bf8f9b7db..c8ffbaf29a88 100644
--- a/drivers/ide/cris/ide-cris.c
+++ b/drivers/ide/cris/ide-cris.c
@@ -1067,3 +1067,5 @@ static void cris_dma_start(ide_drive_t *drive)
1067} 1067}
1068 1068
1069module_init(init_e100_ide); 1069module_init(init_e100_ide);
1070
1071MODULE_LICENSE("GPL");
diff --git a/drivers/ide/h8300/ide-h8300.c b/drivers/ide/h8300/ide-h8300.c
index 520aec075700..4108ec4ffa7f 100644
--- a/drivers/ide/h8300/ide-h8300.c
+++ b/drivers/ide/h8300/ide-h8300.c
@@ -110,6 +110,7 @@ static int __init h8300_ide_init(void)
110 ide_init_port_data(hwif, index); 110 ide_init_port_data(hwif, index);
111 ide_init_port_hw(hwif, &hw); 111 ide_init_port_hw(hwif, &hw);
112 hwif_setup(hwif); 112 hwif_setup(hwif);
113 hwif->host_flags = IDE_HFLAG_NO_IO_32BIT;
113 printk(KERN_INFO "ide%d: H8/300 generic IDE interface\n", index); 114 printk(KERN_INFO "ide%d: H8/300 generic IDE interface\n", index);
114 115
115 idx[0] = index; 116 idx[0] = index;
@@ -125,3 +126,5 @@ out_busy:
125} 126}
126 127
127module_init(h8300_ide_init); 128module_init(h8300_ide_init);
129
130MODULE_LICENSE("GPL");
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index c419266234a7..e77cee0e5d65 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -595,6 +595,7 @@ u8 eighty_ninty_three (ide_drive_t *drive)
595 595
596 /* 596 /*
597 * FIXME: 597 * FIXME:
598 * - change master/slave IDENTIFY order
598 * - force bit13 (80c cable present) check also for !ivb devices 599 * - force bit13 (80c cable present) check also for !ivb devices
599 * (unless the slave device is pre-ATA3) 600 * (unless the slave device is pre-ATA3)
600 */ 601 */
@@ -657,7 +658,7 @@ int ide_driveid_update(ide_drive_t *drive)
657 local_irq_restore(flags); 658 local_irq_restore(flags);
658 return 0; 659 return 0;
659 } 660 }
660 ata_input_data(drive, id, SECTOR_WORDS); 661 hwif->ata_input_data(drive, id, SECTOR_WORDS);
661 (void)ide_read_status(drive); /* clear drive IRQ */ 662 (void)ide_read_status(drive); /* clear drive IRQ */
662 local_irq_enable(); 663 local_irq_enable();
663 local_irq_restore(flags); 664 local_irq_restore(flags);
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index 29e2c9719c30..7031a8dcf692 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -122,7 +122,6 @@ static struct ide_pio_info {
122 const char *name; 122 const char *name;
123 int pio; 123 int pio;
124} ide_pio_blacklist [] = { 124} ide_pio_blacklist [] = {
125/* { "Conner Peripherals 1275MB - CFS1275A", 4 }, */
126 { "Conner Peripherals 540MB - CFS540A", 3 }, 125 { "Conner Peripherals 540MB - CFS540A", 3 },
127 126
128 { "WDC AC2700", 3 }, 127 { "WDC AC2700", 3 },
@@ -138,10 +137,8 @@ static struct ide_pio_info {
138 { "WDC AC1170", 1 }, 137 { "WDC AC1170", 1 },
139 { "WDC AC1210", 1 }, 138 { "WDC AC1210", 1 },
140 { "WDC AC280", 0 }, 139 { "WDC AC280", 0 },
141/* { "WDC AC21000", 4 }, */
142 { "WDC AC31000", 3 }, 140 { "WDC AC31000", 3 },
143 { "WDC AC31200", 3 }, 141 { "WDC AC31200", 3 },
144/* { "WDC AC31600", 4 }, */
145 142
146 { "Maxtor 7131 AT", 1 }, 143 { "Maxtor 7131 AT", 1 },
147 { "Maxtor 7171 AT", 1 }, 144 { "Maxtor 7171 AT", 1 },
@@ -155,13 +152,6 @@ static struct ide_pio_info {
155 { "SAMSUNG SHD-3122A", 1 }, 152 { "SAMSUNG SHD-3122A", 1 },
156 { "SAMSUNG SHD-3172A", 1 }, 153 { "SAMSUNG SHD-3172A", 1 },
157 154
158/* { "ST51080A", 4 },
159 * { "ST51270A", 4 },
160 * { "ST31220A", 4 },
161 * { "ST31640A", 4 },
162 * { "ST32140A", 4 },
163 * { "ST3780A", 4 },
164 */
165 { "ST5660A", 3 }, 155 { "ST5660A", 3 },
166 { "ST3660A", 3 }, 156 { "ST3660A", 3 },
167 { "ST3630A", 3 }, 157 { "ST3630A", 3 },
diff --git a/drivers/ide/ide-pnp.c b/drivers/ide/ide-pnp.c
index b163b2e52212..c14bb5380c25 100644
--- a/drivers/ide/ide-pnp.c
+++ b/drivers/ide/ide-pnp.c
@@ -86,3 +86,5 @@ static void __exit pnpide_exit(void)
86 86
87module_init(pnpide_init); 87module_init(pnpide_init);
88module_exit(pnpide_exit); 88module_exit(pnpide_exit);
89
90MODULE_LICENSE("GPL");
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 194ecb0049eb..47a114927c31 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -774,9 +774,10 @@ static int ide_probe_port(ide_hwif_t *hwif)
774 printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name); 774 printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name);
775 775
776 /* 776 /*
777 * Need to probe slave device first to make it release PDIAG-. 777 * Second drive should only exist if first drive was found,
778 * but a lot of cdrom drives are configured as single slaves.
778 */ 779 */
779 for (unit = MAX_DRIVES - 1; unit >= 0; unit--) { 780 for (unit = 0; unit < MAX_DRIVES; ++unit) {
780 ide_drive_t *drive = &hwif->drives[unit]; 781 ide_drive_t *drive = &hwif->drives[unit];
781 drive->dn = (hwif->channel ? 2 : 0) + unit; 782 drive->dn = (hwif->channel ? 2 : 0) + unit;
782 (void) probe_for_drive(drive); 783 (void) probe_for_drive(drive);
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 43e0e0557776..0598ecfd5f37 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -3765,11 +3765,6 @@ static int ide_tape_probe(ide_drive_t *drive)
3765 g->fops = &idetape_block_ops; 3765 g->fops = &idetape_block_ops;
3766 ide_register_region(g); 3766 ide_register_region(g);
3767 3767
3768 printk(KERN_WARNING "It is possible that this driver does not have any"
3769 " users anymore and, as a result, it will be REMOVED soon."
3770 " Please notify Bart <bzolnier@gmail.com> or Boris"
3771 " <petkovbb@gmail.com> in case you still need it.\n");
3772
3773 return 0; 3768 return 0;
3774 3769
3775out_free_tape: 3770out_free_tape:
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 0518a2e948cf..4c86a8d84b4c 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -423,6 +423,25 @@ void task_end_request(ide_drive_t *drive, struct request *rq, u8 stat)
423} 423}
424 424
425/* 425/*
426 * We got an interrupt on a task_in case, but no errors and no DRQ.
427 *
428 * It might be a spurious irq (shared irq), but it might be a
429 * command that had no output.
430 */
431static ide_startstop_t task_in_unexpected(ide_drive_t *drive, struct request *rq, u8 stat)
432{
433 /* Command all done? */
434 if (OK_STAT(stat, READY_STAT, BUSY_STAT)) {
435 task_end_request(drive, rq, stat);
436 return ide_stopped;
437 }
438
439 /* Assume it was a spurious irq */
440 ide_set_handler(drive, &task_in_intr, WAIT_WORSTCASE, NULL);
441 return ide_started;
442}
443
444/*
426 * Handler for command with PIO data-in phase (Read/Read Multiple). 445 * Handler for command with PIO data-in phase (Read/Read Multiple).
427 */ 446 */
428static ide_startstop_t task_in_intr(ide_drive_t *drive) 447static ide_startstop_t task_in_intr(ide_drive_t *drive)
@@ -431,18 +450,17 @@ static ide_startstop_t task_in_intr(ide_drive_t *drive)
431 struct request *rq = HWGROUP(drive)->rq; 450 struct request *rq = HWGROUP(drive)->rq;
432 u8 stat = ide_read_status(drive); 451 u8 stat = ide_read_status(drive);
433 452
434 /* new way for dealing with premature shared PCI interrupts */ 453 /* Error? */
435 if (!OK_STAT(stat, DRQ_STAT, BAD_R_STAT)) { 454 if (stat & ERR_STAT)
436 if (stat & (ERR_STAT | DRQ_STAT)) 455 return task_error(drive, rq, __FUNCTION__, stat);
437 return task_error(drive, rq, __FUNCTION__, stat); 456
438 /* No data yet, so wait for another IRQ. */ 457 /* Didn't want any data? Odd. */
439 ide_set_handler(drive, &task_in_intr, WAIT_WORSTCASE, NULL); 458 if (!(stat & DRQ_STAT))
440 return ide_started; 459 return task_in_unexpected(drive, rq, stat);
441 }
442 460
443 ide_pio_datablock(drive, rq, 0); 461 ide_pio_datablock(drive, rq, 0);
444 462
445 /* If it was the last datablock check status and finish transfer. */ 463 /* Are we done? Check status and finish transfer. */
446 if (!hwif->nleft) { 464 if (!hwif->nleft) {
447 stat = wait_drive_not_busy(drive); 465 stat = wait_drive_not_busy(drive);
448 if (!OK_STAT(stat, 0, BAD_STAT)) 466 if (!OK_STAT(stat, 0, BAD_STAT))
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 9976f9d627d4..fc69fe2e3ec0 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -1258,7 +1258,7 @@ static int __init ide_setup(char *s)
1258 drive = &hwif->drives[unit]; 1258 drive = &hwif->drives[unit];
1259 if (strncmp(s + 4, "ide-", 4) == 0) { 1259 if (strncmp(s + 4, "ide-", 4) == 0) {
1260 strlcpy(drive->driver_req, s + 4, sizeof(drive->driver_req)); 1260 strlcpy(drive->driver_req, s + 4, sizeof(drive->driver_req));
1261 goto done; 1261 goto obsolete_option;
1262 } 1262 }
1263 switch (match_parm(&s[3], hd_words, vals, 3)) { 1263 switch (match_parm(&s[3], hd_words, vals, 3)) {
1264 case -1: /* "none" */ 1264 case -1: /* "none" */
@@ -1290,13 +1290,13 @@ static int __init ide_setup(char *s)
1290 goto done; 1290 goto done;
1291 case -12: /* "remap" */ 1291 case -12: /* "remap" */
1292 drive->remap_0_to_1 = 1; 1292 drive->remap_0_to_1 = 1;
1293 goto done; 1293 goto obsolete_option;
1294 case -13: /* "remap63" */ 1294 case -13: /* "remap63" */
1295 drive->sect0 = 63; 1295 drive->sect0 = 63;
1296 goto done; 1296 goto obsolete_option;
1297 case -14: /* "scsi" */ 1297 case -14: /* "scsi" */
1298 drive->scsi = 1; 1298 drive->scsi = 1;
1299 goto done; 1299 goto obsolete_option;
1300 case 3: /* cyl,head,sect */ 1300 case 3: /* cyl,head,sect */
1301 drive->media = ide_disk; 1301 drive->media = ide_disk;
1302 drive->ready_stat = READY_STAT; 1302 drive->ready_stat = READY_STAT;
@@ -1370,32 +1370,32 @@ static int __init ide_setup(char *s)
1370#ifdef CONFIG_BLK_DEV_ALI14XX 1370#ifdef CONFIG_BLK_DEV_ALI14XX
1371 case -17: /* "ali14xx" */ 1371 case -17: /* "ali14xx" */
1372 probe_ali14xx = 1; 1372 probe_ali14xx = 1;
1373 goto done; 1373 goto obsolete_option;
1374#endif 1374#endif
1375#ifdef CONFIG_BLK_DEV_UMC8672 1375#ifdef CONFIG_BLK_DEV_UMC8672
1376 case -16: /* "umc8672" */ 1376 case -16: /* "umc8672" */
1377 probe_umc8672 = 1; 1377 probe_umc8672 = 1;
1378 goto done; 1378 goto obsolete_option;
1379#endif 1379#endif
1380#ifdef CONFIG_BLK_DEV_DTC2278 1380#ifdef CONFIG_BLK_DEV_DTC2278
1381 case -15: /* "dtc2278" */ 1381 case -15: /* "dtc2278" */
1382 probe_dtc2278 = 1; 1382 probe_dtc2278 = 1;
1383 goto done; 1383 goto obsolete_option;
1384#endif 1384#endif
1385#ifdef CONFIG_BLK_DEV_CMD640 1385#ifdef CONFIG_BLK_DEV_CMD640
1386 case -14: /* "cmd640_vlb" */ 1386 case -14: /* "cmd640_vlb" */
1387 cmd640_vlb = 1; 1387 cmd640_vlb = 1;
1388 goto done; 1388 goto obsolete_option;
1389#endif 1389#endif
1390#ifdef CONFIG_BLK_DEV_HT6560B 1390#ifdef CONFIG_BLK_DEV_HT6560B
1391 case -13: /* "ht6560b" */ 1391 case -13: /* "ht6560b" */
1392 probe_ht6560b = 1; 1392 probe_ht6560b = 1;
1393 goto done; 1393 goto obsolete_option;
1394#endif 1394#endif
1395#ifdef CONFIG_BLK_DEV_QD65XX 1395#ifdef CONFIG_BLK_DEV_QD65XX
1396 case -12: /* "qd65xx" */ 1396 case -12: /* "qd65xx" */
1397 probe_qd65xx = 1; 1397 probe_qd65xx = 1;
1398 goto done; 1398 goto obsolete_option;
1399#endif 1399#endif
1400#ifdef CONFIG_BLK_DEV_4DRIVES 1400#ifdef CONFIG_BLK_DEV_4DRIVES
1401 case -11: /* "four" drives on one set of ports */ 1401 case -11: /* "four" drives on one set of ports */
diff --git a/drivers/ide/legacy/buddha.c b/drivers/ide/legacy/buddha.c
index 50ffa871d5e9..fdd3791e465f 100644
--- a/drivers/ide/legacy/buddha.c
+++ b/drivers/ide/legacy/buddha.c
@@ -241,3 +241,5 @@ fail_base2:
241} 241}
242 242
243module_init(buddha_init); 243module_init(buddha_init);
244
245MODULE_LICENSE("GPL");
diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c
index 8949ce71bddc..e950afa5939c 100644
--- a/drivers/ide/legacy/falconide.c
+++ b/drivers/ide/legacy/falconide.c
@@ -93,3 +93,5 @@ static int __init falconide_init(void)
93} 93}
94 94
95module_init(falconide_init); 95module_init(falconide_init);
96
97MODULE_LICENSE("GPL");
diff --git a/drivers/ide/legacy/gayle.c b/drivers/ide/legacy/gayle.c
index b7d81090d5da..e3b4638cc883 100644
--- a/drivers/ide/legacy/gayle.c
+++ b/drivers/ide/legacy/gayle.c
@@ -195,3 +195,5 @@ found:
195} 195}
196 196
197module_init(gayle_init); 197module_init(gayle_init);
198
199MODULE_LICENSE("GPL");
diff --git a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c
index 9a79098d9eb4..eaf5dbe58bc2 100644
--- a/drivers/ide/legacy/macide.c
+++ b/drivers/ide/legacy/macide.c
@@ -137,3 +137,5 @@ static int __init macide_init(void)
137} 137}
138 138
139module_init(macide_init); 139module_init(macide_init);
140
141MODULE_LICENSE("GPL");
diff --git a/drivers/ide/legacy/q40ide.c b/drivers/ide/legacy/q40ide.c
index 1381b91bc316..2da28759686e 100644
--- a/drivers/ide/legacy/q40ide.c
+++ b/drivers/ide/legacy/q40ide.c
@@ -153,3 +153,5 @@ static int __init q40ide_init(void)
153} 153}
154 154
155module_init(q40ide_init); 155module_init(q40ide_init);
156
157MODULE_LICENSE("GPL");
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c
index ec667982809c..29fbc5ead03b 100644
--- a/drivers/ide/pci/cmd640.c
+++ b/drivers/ide/pci/cmd640.c
@@ -881,3 +881,5 @@ module_param_named(probe_vlb, cmd640_vlb, bool, 0);
881MODULE_PARM_DESC(probe_vlb, "probe for VLB version of CMD640 chipset"); 881MODULE_PARM_DESC(probe_vlb, "probe for VLB version of CMD640 chipset");
882 882
883module_init(cmd640x_init); 883module_init(cmd640x_init);
884
885MODULE_LICENSE("GPL");
diff --git a/drivers/ide/ppc/mpc8xx.c b/drivers/ide/ppc/mpc8xx.c
index 38fbfb8d5445..ebaba01c7551 100644
--- a/drivers/ide/ppc/mpc8xx.c
+++ b/drivers/ide/ppc/mpc8xx.c
@@ -853,3 +853,5 @@ static int __init mpc8xx_ide_probe(void)
853} 853}
854 854
855module_init(mpc8xx_ide_probe); 855module_init(mpc8xx_ide_probe);
856
857MODULE_LICENSE("GPL");
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 78c9eeb85634..d9ca52e6cdab 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1771,3 +1771,5 @@ static int __devinit pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
1771#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ 1771#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
1772 1772
1773module_init(pmac_ide_probe); 1773module_init(pmac_ide_probe);
1774
1775MODULE_LICENSE("GPL");
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index a58ad8a470f9..781ea5950373 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -154,7 +154,7 @@ static void addr_send_arp(struct sockaddr_in *dst_in)
154{ 154{
155 struct rtable *rt; 155 struct rtable *rt;
156 struct flowi fl; 156 struct flowi fl;
157 u32 dst_ip = dst_in->sin_addr.s_addr; 157 __be32 dst_ip = dst_in->sin_addr.s_addr;
158 158
159 memset(&fl, 0, sizeof fl); 159 memset(&fl, 0, sizeof fl);
160 fl.nl_u.ip4_u.daddr = dst_ip; 160 fl.nl_u.ip4_u.daddr = dst_ip;
@@ -169,8 +169,8 @@ static int addr_resolve_remote(struct sockaddr_in *src_in,
169 struct sockaddr_in *dst_in, 169 struct sockaddr_in *dst_in,
170 struct rdma_dev_addr *addr) 170 struct rdma_dev_addr *addr)
171{ 171{
172 u32 src_ip = src_in->sin_addr.s_addr; 172 __be32 src_ip = src_in->sin_addr.s_addr;
173 u32 dst_ip = dst_in->sin_addr.s_addr; 173 __be32 dst_ip = dst_in->sin_addr.s_addr;
174 struct flowi fl; 174 struct flowi fl;
175 struct rtable *rt; 175 struct rtable *rt;
176 struct neighbour *neigh; 176 struct neighbour *neigh;
@@ -257,7 +257,7 @@ static int addr_resolve_local(struct sockaddr_in *src_in,
257 struct rdma_dev_addr *addr) 257 struct rdma_dev_addr *addr)
258{ 258{
259 struct net_device *dev; 259 struct net_device *dev;
260 u32 src_ip = src_in->sin_addr.s_addr; 260 __be32 src_ip = src_in->sin_addr.s_addr;
261 __be32 dst_ip = dst_in->sin_addr.s_addr; 261 __be32 dst_ip = dst_in->sin_addr.s_addr;
262 int ret; 262 int ret;
263 263
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 4df405157086..faa7ce318a6d 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -393,7 +393,7 @@ static int cm_alloc_id(struct cm_id_private *cm_id_priv)
393 spin_unlock_irqrestore(&cm.lock, flags); 393 spin_unlock_irqrestore(&cm.lock, flags);
394 } while( (ret == -EAGAIN) && idr_pre_get(&cm.local_id_table, GFP_KERNEL) ); 394 } while( (ret == -EAGAIN) && idr_pre_get(&cm.local_id_table, GFP_KERNEL) );
395 395
396 cm_id_priv->id.local_id = (__force __be32) (id ^ cm.random_id_operand); 396 cm_id_priv->id.local_id = (__force __be32)id ^ cm.random_id_operand;
397 return ret; 397 return ret;
398} 398}
399 399
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 34507daaf9b6..d81c156a22b4 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -168,15 +168,15 @@ struct cma_work {
168union cma_ip_addr { 168union cma_ip_addr {
169 struct in6_addr ip6; 169 struct in6_addr ip6;
170 struct { 170 struct {
171 __u32 pad[3]; 171 __be32 pad[3];
172 __u32 addr; 172 __be32 addr;
173 } ip4; 173 } ip4;
174}; 174};
175 175
176struct cma_hdr { 176struct cma_hdr {
177 u8 cma_version; 177 u8 cma_version;
178 u8 ip_version; /* IP version: 7:4 */ 178 u8 ip_version; /* IP version: 7:4 */
179 __u16 port; 179 __be16 port;
180 union cma_ip_addr src_addr; 180 union cma_ip_addr src_addr;
181 union cma_ip_addr dst_addr; 181 union cma_ip_addr dst_addr;
182}; 182};
@@ -186,8 +186,8 @@ struct sdp_hh {
186 u8 sdp_version; /* Major version: 7:4 */ 186 u8 sdp_version; /* Major version: 7:4 */
187 u8 ip_version; /* IP version: 7:4 */ 187 u8 ip_version; /* IP version: 7:4 */
188 u8 sdp_specific1[10]; 188 u8 sdp_specific1[10];
189 __u16 port; 189 __be16 port;
190 __u16 sdp_specific2; 190 __be16 sdp_specific2;
191 union cma_ip_addr src_addr; 191 union cma_ip_addr src_addr;
192 union cma_ip_addr dst_addr; 192 union cma_ip_addr dst_addr;
193}; 193};
@@ -663,7 +663,7 @@ static inline int cma_any_port(struct sockaddr *addr)
663} 663}
664 664
665static int cma_get_net_info(void *hdr, enum rdma_port_space ps, 665static int cma_get_net_info(void *hdr, enum rdma_port_space ps,
666 u8 *ip_ver, __u16 *port, 666 u8 *ip_ver, __be16 *port,
667 union cma_ip_addr **src, union cma_ip_addr **dst) 667 union cma_ip_addr **src, union cma_ip_addr **dst)
668{ 668{
669 switch (ps) { 669 switch (ps) {
@@ -695,7 +695,7 @@ static int cma_get_net_info(void *hdr, enum rdma_port_space ps,
695 695
696static void cma_save_net_info(struct rdma_addr *addr, 696static void cma_save_net_info(struct rdma_addr *addr,
697 struct rdma_addr *listen_addr, 697 struct rdma_addr *listen_addr,
698 u8 ip_ver, __u16 port, 698 u8 ip_ver, __be16 port,
699 union cma_ip_addr *src, union cma_ip_addr *dst) 699 union cma_ip_addr *src, union cma_ip_addr *dst)
700{ 700{
701 struct sockaddr_in *listen4, *ip4; 701 struct sockaddr_in *listen4, *ip4;
@@ -996,7 +996,7 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id,
996 struct rdma_cm_id *id; 996 struct rdma_cm_id *id;
997 struct rdma_route *rt; 997 struct rdma_route *rt;
998 union cma_ip_addr *src, *dst; 998 union cma_ip_addr *src, *dst;
999 __u16 port; 999 __be16 port;
1000 u8 ip_ver; 1000 u8 ip_ver;
1001 1001
1002 if (cma_get_net_info(ib_event->private_data, listen_id->ps, 1002 if (cma_get_net_info(ib_event->private_data, listen_id->ps,
@@ -1043,7 +1043,7 @@ static struct rdma_id_private *cma_new_udp_id(struct rdma_cm_id *listen_id,
1043 struct rdma_id_private *id_priv; 1043 struct rdma_id_private *id_priv;
1044 struct rdma_cm_id *id; 1044 struct rdma_cm_id *id;
1045 union cma_ip_addr *src, *dst; 1045 union cma_ip_addr *src, *dst;
1046 __u16 port; 1046 __be16 port;
1047 u8 ip_ver; 1047 u8 ip_ver;
1048 int ret; 1048 int ret;
1049 1049
@@ -1165,7 +1165,7 @@ static void cma_set_compare_data(enum rdma_port_space ps, struct sockaddr *addr,
1165{ 1165{
1166 struct cma_hdr *cma_data, *cma_mask; 1166 struct cma_hdr *cma_data, *cma_mask;
1167 struct sdp_hh *sdp_data, *sdp_mask; 1167 struct sdp_hh *sdp_data, *sdp_mask;
1168 __u32 ip4_addr; 1168 __be32 ip4_addr;
1169 struct in6_addr ip6_addr; 1169 struct in6_addr ip6_addr;
1170 1170
1171 memset(compare, 0, sizeof *compare); 1171 memset(compare, 0, sizeof *compare);
@@ -1181,12 +1181,12 @@ static void cma_set_compare_data(enum rdma_port_space ps, struct sockaddr *addr,
1181 sdp_set_ip_ver(sdp_data, 4); 1181 sdp_set_ip_ver(sdp_data, 4);
1182 sdp_set_ip_ver(sdp_mask, 0xF); 1182 sdp_set_ip_ver(sdp_mask, 0xF);
1183 sdp_data->dst_addr.ip4.addr = ip4_addr; 1183 sdp_data->dst_addr.ip4.addr = ip4_addr;
1184 sdp_mask->dst_addr.ip4.addr = ~0; 1184 sdp_mask->dst_addr.ip4.addr = htonl(~0);
1185 } else { 1185 } else {
1186 cma_set_ip_ver(cma_data, 4); 1186 cma_set_ip_ver(cma_data, 4);
1187 cma_set_ip_ver(cma_mask, 0xF); 1187 cma_set_ip_ver(cma_mask, 0xF);
1188 cma_data->dst_addr.ip4.addr = ip4_addr; 1188 cma_data->dst_addr.ip4.addr = ip4_addr;
1189 cma_mask->dst_addr.ip4.addr = ~0; 1189 cma_mask->dst_addr.ip4.addr = htonl(~0);
1190 } 1190 }
1191 break; 1191 break;
1192 case AF_INET6: 1192 case AF_INET6:
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c
index 320f2b6ddee6..99f2f2a46bf7 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
@@ -1745,7 +1745,7 @@ int iwch_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
1745 1745
1746 /* bind QP to EP and move to RTS */ 1746 /* bind QP to EP and move to RTS */
1747 attrs.mpa_attr = ep->mpa_attr; 1747 attrs.mpa_attr = ep->mpa_attr;
1748 attrs.max_ird = ep->ord; 1748 attrs.max_ird = ep->ird;
1749 attrs.max_ord = ep->ord; 1749 attrs.max_ord = ep->ord;
1750 attrs.llp_stream_handle = ep; 1750 attrs.llp_stream_handle = ep;
1751 attrs.next_state = IWCH_QP_STATE_RTS; 1751 attrs.next_state = IWCH_QP_STATE_RTS;
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index 39adb267fb15..0bef878e0f65 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -40,6 +40,7 @@
40#include <linux/tcp.h> 40#include <linux/tcp.h>
41#include <linux/init.h> 41#include <linux/init.h>
42#include <linux/if_arp.h> 42#include <linux/if_arp.h>
43#include <linux/if_vlan.h>
43#include <linux/notifier.h> 44#include <linux/notifier.h>
44#include <linux/net.h> 45#include <linux/net.h>
45#include <linux/types.h> 46#include <linux/types.h>
@@ -1072,7 +1073,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
1072 ts = current_kernel_time(); 1073 ts = current_kernel_time();
1073 cm_node->tcp_cntxt.loc_seq_num = htonl(ts.tv_nsec); 1074 cm_node->tcp_cntxt.loc_seq_num = htonl(ts.tv_nsec);
1074 cm_node->tcp_cntxt.mss = nesvnic->max_frame_size - sizeof(struct iphdr) - 1075 cm_node->tcp_cntxt.mss = nesvnic->max_frame_size - sizeof(struct iphdr) -
1075 sizeof(struct tcphdr) - ETH_HLEN; 1076 sizeof(struct tcphdr) - ETH_HLEN - VLAN_HLEN;
1076 cm_node->tcp_cntxt.rcv_nxt = 0; 1077 cm_node->tcp_cntxt.rcv_nxt = 0;
1077 /* get a unique session ID , add thread_id to an upcounter to handle race */ 1078 /* get a unique session ID , add thread_id to an upcounter to handle race */
1078 atomic_inc(&cm_core->node_cnt); 1079 atomic_inc(&cm_core->node_cnt);
diff --git a/drivers/input/apm-power.c b/drivers/input/apm-power.c
index c36d110b349a..7d61a9660806 100644
--- a/drivers/input/apm-power.c
+++ b/drivers/input/apm-power.c
@@ -63,8 +63,6 @@ static int apmpower_connect(struct input_handler *handler,
63 handle->handler = handler; 63 handle->handler = handler;
64 handle->name = "apm-power"; 64 handle->name = "apm-power";
65 65
66 handler->private = handle;
67
68 error = input_register_handle(handle); 66 error = input_register_handle(handle);
69 if (error) { 67 if (error) {
70 printk(KERN_ERR 68 printk(KERN_ERR
@@ -87,11 +85,10 @@ static int apmpower_connect(struct input_handler *handler,
87 return 0; 85 return 0;
88} 86}
89 87
90static void apmpower_disconnect(struct input_handle *handler) 88static void apmpower_disconnect(struct input_handle *handle)
91{ 89{
92 struct input_handle *handle = handler->private;
93
94 input_close_device(handle); 90 input_close_device(handle);
91 input_unregister_handle(handle);
95 kfree(handle); 92 kfree(handle);
96} 93}
97 94
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 0727b0a12557..b32984bc516f 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -124,6 +124,7 @@ static void evdev_free(struct device *dev)
124{ 124{
125 struct evdev *evdev = container_of(dev, struct evdev, dev); 125 struct evdev *evdev = container_of(dev, struct evdev, dev);
126 126
127 input_put_device(evdev->handle.dev);
127 kfree(evdev); 128 kfree(evdev);
128} 129}
129 130
@@ -893,7 +894,7 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev,
893 evdev->exist = 1; 894 evdev->exist = 1;
894 evdev->minor = minor; 895 evdev->minor = minor;
895 896
896 evdev->handle.dev = dev; 897 evdev->handle.dev = input_get_device(dev);
897 evdev->handle.name = evdev->name; 898 evdev->handle.name = evdev->name;
898 evdev->handle.handler = handler; 899 evdev->handle.handler = handler;
899 evdev->handle.private = evdev; 900 evdev->handle.private = evdev;
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 22b2789ef58a..65d7077a75a1 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -171,6 +171,7 @@ static void joydev_free(struct device *dev)
171{ 171{
172 struct joydev *joydev = container_of(dev, struct joydev, dev); 172 struct joydev *joydev = container_of(dev, struct joydev, dev);
173 173
174 input_put_device(joydev->handle.dev);
174 kfree(joydev); 175 kfree(joydev);
175} 176}
176 177
@@ -750,7 +751,7 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev,
750 joydev->minor = minor; 751 joydev->minor = minor;
751 752
752 joydev->exist = 1; 753 joydev->exist = 1;
753 joydev->handle.dev = dev; 754 joydev->handle.dev = input_get_device(dev);
754 joydev->handle.name = joydev->name; 755 joydev->handle.name = joydev->name;
755 joydev->handle.handler = handler; 756 joydev->handle.handler = handler;
756 joydev->handle.private = joydev; 757 joydev->handle.private = joydev;
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
index 6224c2fb3b65..4e651c11c1da 100644
--- a/drivers/input/keyboard/pxa27x_keypad.c
+++ b/drivers/input/keyboard/pxa27x_keypad.c
@@ -50,9 +50,9 @@
50#define KPKDI 0x0048 50#define KPKDI 0x0048
51 51
52/* bit definitions */ 52/* bit definitions */
53#define KPC_MKRN(n) ((((n) & 0x7) - 1) << 26) /* matrix key row number */ 53#define KPC_MKRN(n) ((((n) - 1) & 0x7) << 26) /* matrix key row number */
54#define KPC_MKCN(n) ((((n) & 0x7) - 1) << 23) /* matrix key column number */ 54#define KPC_MKCN(n) ((((n) - 1) & 0x7) << 23) /* matrix key column number */
55#define KPC_DKN(n) ((((n) & 0x7) - 1) << 6) /* direct key number */ 55#define KPC_DKN(n) ((((n) - 1) & 0x7) << 6) /* direct key number */
56 56
57#define KPC_AS (0x1 << 30) /* Automatic Scan bit */ 57#define KPC_AS (0x1 << 30) /* Automatic Scan bit */
58#define KPC_ASACT (0x1 << 29) /* Automatic Scan on Activity */ 58#define KPC_ASACT (0x1 << 29) /* Automatic Scan on Activity */
diff --git a/drivers/input/misc/cobalt_btns.c b/drivers/input/misc/cobalt_btns.c
index 4833b1a82623..5511ef006a66 100644
--- a/drivers/input/misc/cobalt_btns.c
+++ b/drivers/input/misc/cobalt_btns.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Cobalt button interface driver. 2 * Cobalt button interface driver.
3 * 3 *
4 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp> 4 * Copyright (C) 2007-2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@
15 * 15 *
16 * You should have received a copy of the GNU General Public License 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 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */ 19 */
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/input-polldev.h> 21#include <linux/input-polldev.h>
@@ -55,7 +55,7 @@ static void handle_buttons(struct input_polled_dev *dev)
55 status = ~readl(bdev->reg) >> 24; 55 status = ~readl(bdev->reg) >> 24;
56 56
57 for (i = 0; i < ARRAY_SIZE(bdev->keymap); i++) { 57 for (i = 0; i < ARRAY_SIZE(bdev->keymap); i++) {
58 if (status & (1UL << i)) { 58 if (status & (1U << i)) {
59 if (++bdev->count[i] == BUTTONS_COUNT_THRESHOLD) { 59 if (++bdev->count[i] == BUTTONS_COUNT_THRESHOLD) {
60 input_event(input, EV_MSC, MSC_SCAN, i); 60 input_event(input, EV_MSC, MSC_SCAN, i);
61 input_report_key(input, bdev->keymap[i], 1); 61 input_report_key(input, bdev->keymap[i], 1);
@@ -97,16 +97,16 @@ static int __devinit cobalt_buttons_probe(struct platform_device *pdev)
97 input->name = "Cobalt buttons"; 97 input->name = "Cobalt buttons";
98 input->phys = "cobalt/input0"; 98 input->phys = "cobalt/input0";
99 input->id.bustype = BUS_HOST; 99 input->id.bustype = BUS_HOST;
100 input->cdev.dev = &pdev->dev; 100 input->dev.parent = &pdev->dev;
101 101
102 input->keycode = pdev->keymap; 102 input->keycode = bdev->keymap;
103 input->keycodemax = ARRAY_SIZE(pdev->keymap); 103 input->keycodemax = ARRAY_SIZE(bdev->keymap);
104 input->keycodesize = sizeof(unsigned short); 104 input->keycodesize = sizeof(unsigned short);
105 105
106 input_set_capability(input, EV_MSC, MSC_SCAN); 106 input_set_capability(input, EV_MSC, MSC_SCAN);
107 __set_bit(EV_KEY, input->evbit); 107 __set_bit(EV_KEY, input->evbit);
108 for (i = 0; i < ARRAY_SIZE(buttons_map); i++) 108 for (i = 0; i < ARRAY_SIZE(cobalt_map); i++)
109 __set_bit(input->keycode[i], input->keybit); 109 __set_bit(bdev->keymap[i], input->keybit);
110 __clear_bit(KEY_RESERVED, input->keybit); 110 __clear_bit(KEY_RESERVED, input->keybit);
111 111
112 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 112 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/drivers/input/misc/ixp4xx-beeper.c b/drivers/input/misc/ixp4xx-beeper.c
index d2ade7443b7d..798d84c44d03 100644
--- a/drivers/input/misc/ixp4xx-beeper.c
+++ b/drivers/input/misc/ixp4xx-beeper.c
@@ -25,6 +25,7 @@
25MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); 25MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
26MODULE_DESCRIPTION("ixp4xx beeper driver"); 26MODULE_DESCRIPTION("ixp4xx beeper driver");
27MODULE_LICENSE("GPL"); 27MODULE_LICENSE("GPL");
28MODULE_ALIAS("platform:ixp4xx-beeper");
28 29
29static DEFINE_SPINLOCK(beep_lock); 30static DEFINE_SPINLOCK(beep_lock);
30 31
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index b346a3b418ea..385e32bcf6a6 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -116,8 +116,8 @@ static void alps_process_packet(struct psmouse *psmouse)
116 } 116 }
117 117
118 if (priv->i->flags & ALPS_FW_BK_1) { 118 if (priv->i->flags & ALPS_FW_BK_1) {
119 back = packet[2] & 4; 119 back = packet[0] & 0x10;
120 forward = packet[0] & 0x10; 120 forward = packet[2] & 4;
121 } 121 }
122 122
123 if (priv->i->flags & ALPS_FW_BK_2) { 123 if (priv->i->flags & ALPS_FW_BK_2) {
@@ -483,6 +483,7 @@ int alps_init(struct psmouse *psmouse)
483 dev2->id.vendor = 0x0002; 483 dev2->id.vendor = 0x0002;
484 dev2->id.product = PSMOUSE_ALPS; 484 dev2->id.product = PSMOUSE_ALPS;
485 dev2->id.version = 0x0000; 485 dev2->id.version = 0x0000;
486 dev2->dev.parent = &psmouse->ps2dev.serio->dev;
486 487
487 dev2->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); 488 dev2->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
488 dev2->relbit[BIT_WORD(REL_X)] |= BIT_MASK(REL_X) | BIT_MASK(REL_Y); 489 dev2->relbit[BIT_WORD(REL_X)] |= BIT_MASK(REL_X) | BIT_MASK(REL_Y);
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index bbbe5e81adc1..b989748598ae 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -414,6 +414,7 @@ static void mousedev_free(struct device *dev)
414{ 414{
415 struct mousedev *mousedev = container_of(dev, struct mousedev, dev); 415 struct mousedev *mousedev = container_of(dev, struct mousedev, dev);
416 416
417 input_put_device(mousedev->handle.dev);
417 kfree(mousedev); 418 kfree(mousedev);
418} 419}
419 420
@@ -865,7 +866,7 @@ static struct mousedev *mousedev_create(struct input_dev *dev,
865 866
866 mousedev->minor = minor; 867 mousedev->minor = minor;
867 mousedev->exist = 1; 868 mousedev->exist = 1;
868 mousedev->handle.dev = dev; 869 mousedev->handle.dev = input_get_device(dev);
869 mousedev->handle.name = mousedev->name; 870 mousedev->handle.name = mousedev->name;
870 mousedev->handle.handler = handler; 871 mousedev->handle.handler = handler;
871 mousedev->handle.private = mousedev; 872 mousedev->handle.private = mousedev;
diff --git a/drivers/input/serio/i8042-snirm.h b/drivers/input/serio/i8042-snirm.h
new file mode 100644
index 000000000000..409a9341143d
--- /dev/null
+++ b/drivers/input/serio/i8042-snirm.h
@@ -0,0 +1,75 @@
1#ifndef _I8042_SNIRM_H
2#define _I8042_SNIRM_H
3
4#include <asm/sni.h>
5
6/*
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 */
11
12/*
13 * Names.
14 */
15
16#define I8042_KBD_PHYS_DESC "onboard/serio0"
17#define I8042_AUX_PHYS_DESC "onboard/serio1"
18#define I8042_MUX_PHYS_DESC "onboard/serio%d"
19
20/*
21 * IRQs.
22 */
23static int i8042_kbd_irq;
24static int i8042_aux_irq;
25#define I8042_KBD_IRQ i8042_kbd_irq
26#define I8042_AUX_IRQ i8042_aux_irq
27
28static void __iomem *kbd_iobase;
29
30#define I8042_COMMAND_REG (kbd_iobase + 0x64UL)
31#define I8042_DATA_REG (kbd_iobase + 0x60UL)
32
33static inline int i8042_read_data(void)
34{
35 return readb(kbd_iobase + 0x60UL);
36}
37
38static inline int i8042_read_status(void)
39{
40 return readb(kbd_iobase + 0x64UL);
41}
42
43static inline void i8042_write_data(int val)
44{
45 writeb(val, kbd_iobase + 0x60UL);
46}
47
48static inline void i8042_write_command(int val)
49{
50 writeb(val, kbd_iobase + 0x64UL);
51}
52static inline int i8042_platform_init(void)
53{
54 /* RM200 is strange ... */
55 if (sni_brd_type == SNI_BRD_RM200) {
56 kbd_iobase = ioremap(0x16000000, 4);
57 i8042_kbd_irq = 33;
58 i8042_aux_irq = 44;
59 } else {
60 kbd_iobase = ioremap(0x14000000, 4);
61 i8042_kbd_irq = 1;
62 i8042_aux_irq = 12;
63 }
64 if (!kbd_iobase)
65 return -ENOMEM;
66
67 return 0;
68}
69
70static inline void i8042_platform_exit(void)
71{
72
73}
74
75#endif /* _I8042_SNIRM_H */
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index 662e84482c26..60931aceb828 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -277,6 +277,13 @@ static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = {
277 DMI_MATCH(DMI_PRODUCT_NAME, "M636/A737 platform"), 277 DMI_MATCH(DMI_PRODUCT_NAME, "M636/A737 platform"),
278 }, 278 },
279 }, 279 },
280 {
281 .ident = "Lenovo 3000 n100",
282 .matches = {
283 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
284 DMI_MATCH(DMI_PRODUCT_VERSION, "3000 N100"),
285 },
286 },
280 { } 287 { }
281}; 288};
282 289
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 2763394869d2..65a74cfc187b 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -1151,7 +1151,6 @@ static int __devinit i8042_setup_kbd(void)
1151static int __devinit i8042_probe(struct platform_device *dev) 1151static int __devinit i8042_probe(struct platform_device *dev)
1152{ 1152{
1153 int error; 1153 int error;
1154 char param;
1155 1154
1156 error = i8042_controller_selftest(); 1155 error = i8042_controller_selftest();
1157 if (error) 1156 if (error)
@@ -1174,7 +1173,7 @@ static int __devinit i8042_probe(struct platform_device *dev)
1174 } 1173 }
1175#ifdef CONFIG_X86 1174#ifdef CONFIG_X86
1176 if (i8042_dritek) { 1175 if (i8042_dritek) {
1177 param = 0x90; 1176 char param = 0x90;
1178 error = i8042_command(&param, 0x1059); 1177 error = i8042_command(&param, 0x1059);
1179 if (error) 1178 if (error)
1180 goto out_fail; 1179 goto out_fail;
diff --git a/drivers/input/serio/i8042.h b/drivers/input/serio/i8042.h
index c972e5d03a3f..cbc1beb66574 100644
--- a/drivers/input/serio/i8042.h
+++ b/drivers/input/serio/i8042.h
@@ -18,6 +18,8 @@
18#include "i8042-jazzio.h" 18#include "i8042-jazzio.h"
19#elif defined(CONFIG_SGI_HAS_I8042) 19#elif defined(CONFIG_SGI_HAS_I8042)
20#include "i8042-ip22io.h" 20#include "i8042-ip22io.h"
21#elif defined(CONFIG_SNI_RM)
22#include "i8042-snirm.h"
21#elif defined(CONFIG_PPC) 23#elif defined(CONFIG_PPC)
22#include "i8042-ppcio.h" 24#include "i8042-ppcio.h"
23#elif defined(CONFIG_SPARC) 25#elif defined(CONFIG_SPARC)
diff --git a/drivers/input/tablet/wacom.h b/drivers/input/tablet/wacom.h
index 6542edb6f76e..acf9830698cb 100644
--- a/drivers/input/tablet/wacom.h
+++ b/drivers/input/tablet/wacom.h
@@ -11,7 +11,7 @@
11 * Copyright (c) 2000 Daniel Egger <egger@suse.de> 11 * Copyright (c) 2000 Daniel Egger <egger@suse.de>
12 * Copyright (c) 2001 Frederic Lepied <flepied@mandrakesoft.com> 12 * Copyright (c) 2001 Frederic Lepied <flepied@mandrakesoft.com>
13 * Copyright (c) 2004 Panagiotis Issaris <panagiotis.issaris@mech.kuleuven.ac.be> 13 * Copyright (c) 2004 Panagiotis Issaris <panagiotis.issaris@mech.kuleuven.ac.be>
14 * Copyright (c) 2002-2007 Ping Cheng <pingc@wacom.com> 14 * Copyright (c) 2002-2008 Ping Cheng <pingc@wacom.com>
15 * 15 *
16 * ChangeLog: 16 * ChangeLog:
17 * v0.1 (vp) - Initial release 17 * v0.1 (vp) - Initial release
@@ -65,6 +65,7 @@
65 * - and wacom_wac.c deals with Wacom specific code 65 * - and wacom_wac.c deals with Wacom specific code
66 * - Support Intuos3 4x6 66 * - Support Intuos3 4x6
67 * v1.47 (pc) - Added support for Bamboo 67 * v1.47 (pc) - Added support for Bamboo
68 * v1.48 (pc) - Added support for Bamboo1, BambooFun, and Cintiq 12WX
68 */ 69 */
69 70
70/* 71/*
@@ -85,7 +86,7 @@
85/* 86/*
86 * Version Information 87 * Version Information
87 */ 88 */
88#define DRIVER_VERSION "v1.47" 89#define DRIVER_VERSION "v1.48"
89#define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>" 90#define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>"
90#define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver" 91#define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver"
91#define DRIVER_LICENSE "GPL" 92#define DRIVER_LICENSE "GPL"
@@ -125,6 +126,7 @@ extern void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac
125extern void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 126extern void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
126extern void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 127extern void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
127extern void input_dev_mo(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 128extern void input_dev_mo(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
129extern void input_dev_bee(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
128extern __u16 wacom_le16_to_cpu(unsigned char *data); 130extern __u16 wacom_le16_to_cpu(unsigned char *data);
129extern __u16 wacom_be16_to_cpu(unsigned char *data); 131extern __u16 wacom_be16_to_cpu(unsigned char *data);
130extern struct wacom_features * get_wacom_feature(const struct usb_device_id *id); 132extern struct wacom_features * get_wacom_feature(const struct usb_device_id *id);
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index d64b1ea136b3..41caaef8e2d7 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -171,6 +171,7 @@ void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
171 input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_0) | 171 input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_0) |
172 BIT_MASK(BTN_1) | BIT_MASK(BTN_2) | BIT_MASK(BTN_3); 172 BIT_MASK(BTN_1) | BIT_MASK(BTN_2) | BIT_MASK(BTN_3);
173 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0); 173 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
174 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
174} 175}
175 176
176void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 177void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
@@ -180,6 +181,11 @@ void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
180 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0); 181 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
181} 182}
182 183
184void input_dev_bee(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
185{
186 input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_8) | BIT_MASK(BTN_9);
187}
188
183void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 189void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
184{ 190{
185 input_dev->evbit[0] |= BIT_MASK(EV_MSC) | BIT_MASK(EV_REL); 191 input_dev->evbit[0] |= BIT_MASK(EV_MSC) | BIT_MASK(EV_REL);
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index fc03ba256f4c..ffe33842143f 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -163,7 +163,9 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
163 } 163 }
164 164
165 id = STYLUS_DEVICE_ID; 165 id = STYLUS_DEVICE_ID;
166 if (data[1] & 0x80) { /* in prox */ 166 if ((data[1] & 0x80) && ((data[1] & 0x07) || data[2] || data[3] || data[4]
167 || data[5] || data[6] || (data[7] & 0x07))) {
168 /* in prox and not a pad data */
167 169
168 switch ((data[1] >> 5) & 3) { 170 switch ((data[1] >> 5) & 3) {
169 171
@@ -233,7 +235,6 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
233 if (data[7] & 0xf8) { 235 if (data[7] & 0xf8) {
234 wacom_input_sync(wcombo); /* sync last event */ 236 wacom_input_sync(wcombo); /* sync last event */
235 wacom->id[1] = 1; 237 wacom->id[1] = 1;
236 wacom->serial[1] = (data[7] & 0xf8);
237 wacom_report_key(wcombo, BTN_0, (data[7] & 0x40)); 238 wacom_report_key(wcombo, BTN_0, (data[7] & 0x40));
238 wacom_report_key(wcombo, BTN_4, (data[7] & 0x80)); 239 wacom_report_key(wcombo, BTN_4, (data[7] & 0x80));
239 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3); 240 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
@@ -252,10 +253,9 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
252 } 253 }
253 break; 254 break;
254 case WACOM_MO: 255 case WACOM_MO:
255 if ((data[7] & 0xf8) || (data[8] & 0x80)) { 256 if ((data[7] & 0xf8) || (data[8] & 0xff)) {
256 wacom_input_sync(wcombo); /* sync last event */ 257 wacom_input_sync(wcombo); /* sync last event */
257 wacom->id[1] = 1; 258 wacom->id[1] = 1;
258 wacom->serial[1] = (data[7] & 0xf8);
259 wacom_report_key(wcombo, BTN_0, (data[7] & 0x08)); 259 wacom_report_key(wcombo, BTN_0, (data[7] & 0x08));
260 wacom_report_key(wcombo, BTN_1, (data[7] & 0x20)); 260 wacom_report_key(wcombo, BTN_1, (data[7] & 0x20));
261 wacom_report_key(wcombo, BTN_4, (data[7] & 0x10)); 261 wacom_report_key(wcombo, BTN_4, (data[7] & 0x10));
@@ -434,10 +434,12 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
434 wacom_report_key(wcombo, BTN_5, (data[6] & 0x02)); 434 wacom_report_key(wcombo, BTN_5, (data[6] & 0x02));
435 wacom_report_key(wcombo, BTN_6, (data[6] & 0x04)); 435 wacom_report_key(wcombo, BTN_6, (data[6] & 0x04));
436 wacom_report_key(wcombo, BTN_7, (data[6] & 0x08)); 436 wacom_report_key(wcombo, BTN_7, (data[6] & 0x08));
437 wacom_report_key(wcombo, BTN_8, (data[5] & 0x10));
438 wacom_report_key(wcombo, BTN_9, (data[6] & 0x10));
437 wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]); 439 wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
438 wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]); 440 wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
439 441
440 if((data[5] & 0x0f) | (data[6] & 0x0f) | (data[1] & 0x1f) | 442 if ((data[5] & 0x1f) | (data[6] & 0x1f) | (data[1] & 0x1f) |
441 data[2] | (data[3] & 0x1f) | data[4]) 443 data[2] | (data[3] & 0x1f) | data[4])
442 wacom_report_key(wcombo, wacom->tool[1], 1); 444 wacom_report_key(wcombo, wacom->tool[1], 1);
443 else 445 else
@@ -481,13 +483,11 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
481 if (data[1] & 0x02) { 483 if (data[1] & 0x02) {
482 /* Rotation packet */ 484 /* Rotation packet */
483 if (wacom->features->type >= INTUOS3S) { 485 if (wacom->features->type >= INTUOS3S) {
484 /* I3 marker pen rotation reported as wheel 486 /* I3 marker pen rotation */
485 * due to valuator limitation
486 */
487 t = (data[6] << 3) | ((data[7] >> 5) & 7); 487 t = (data[6] << 3) | ((data[7] >> 5) & 7);
488 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) : 488 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
489 ((t-1) / 2 + 450)) : (450 - t / 2) ; 489 ((t-1) / 2 + 450)) : (450 - t / 2) ;
490 wacom_report_abs(wcombo, ABS_WHEEL, t); 490 wacom_report_abs(wcombo, ABS_Z, t);
491 } else { 491 } else {
492 /* 4D mouse rotation packet */ 492 /* 4D mouse rotation packet */
493 t = (data[6] << 3) | ((data[7] >> 5) & 7); 493 t = (data[6] << 3) | ((data[7] >> 5) & 7);
@@ -558,6 +558,7 @@ int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
558 case INTUOS3: 558 case INTUOS3:
559 case INTUOS3L: 559 case INTUOS3L:
560 case CINTIQ: 560 case CINTIQ:
561 case WACOM_BEE:
561 return (wacom_intuos_irq(wacom_wac, wcombo)); 562 return (wacom_intuos_irq(wacom_wac, wcombo));
562 break; 563 break;
563 default: 564 default:
@@ -577,6 +578,8 @@ void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_w
577 case GRAPHIRE: 578 case GRAPHIRE:
578 input_dev_g(input_dev, wacom_wac); 579 input_dev_g(input_dev, wacom_wac);
579 break; 580 break;
581 case WACOM_BEE:
582 input_dev_bee(input_dev, wacom_wac);
580 case INTUOS3: 583 case INTUOS3:
581 case INTUOS3L: 584 case INTUOS3L:
582 case CINTIQ: 585 case CINTIQ:
@@ -607,12 +610,15 @@ static struct wacom_features wacom_features[] = {
607 { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 63, GRAPHIRE }, 610 { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 63, GRAPHIRE },
608 { "Wacom Graphire4 4x5", 8, 10208, 7424, 511, 63, WACOM_G4 }, 611 { "Wacom Graphire4 4x5", 8, 10208, 7424, 511, 63, WACOM_G4 },
609 { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 63, WACOM_G4 }, 612 { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 63, WACOM_G4 },
613 { "Wacom BambooFun 4x5", 9, 14760, 9225, 511, 63, WACOM_MO },
614 { "Wacom BambooFun 6x8", 9, 21648, 13530, 511, 63, WACOM_MO },
610 { "Wacom Volito", 8, 5104, 3712, 511, 63, GRAPHIRE }, 615 { "Wacom Volito", 8, 5104, 3712, 511, 63, GRAPHIRE },
611 { "Wacom PenStation2", 8, 3250, 2320, 255, 63, GRAPHIRE }, 616 { "Wacom PenStation2", 8, 3250, 2320, 255, 63, GRAPHIRE },
612 { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 63, GRAPHIRE }, 617 { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 63, GRAPHIRE },
613 { "Wacom Volito2 2x3", 8, 3248, 2320, 511, 63, GRAPHIRE }, 618 { "Wacom Volito2 2x3", 8, 3248, 2320, 511, 63, GRAPHIRE },
614 { "Wacom PenPartner2", 8, 3250, 2320, 255, 63, GRAPHIRE }, 619 { "Wacom PenPartner2", 8, 3250, 2320, 511, 63, GRAPHIRE },
615 { "Wacom Bamboo", 9, 14760, 9225, 511, 63, WACOM_MO }, 620 { "Wacom Bamboo", 9, 14760, 9225, 511, 63, WACOM_MO },
621 { "Wacom Bamboo1", 8, 5104, 3712, 511, 63, GRAPHIRE },
616 { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 31, INTUOS }, 622 { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 31, INTUOS },
617 { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 31, INTUOS }, 623 { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 31, INTUOS },
618 { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 31, INTUOS }, 624 { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 31, INTUOS },
@@ -643,6 +649,7 @@ static struct wacom_features wacom_features[] = {
643 { "Wacom Intuos3 6x11", 10, 54204, 31750, 1023, 63, INTUOS3 }, 649 { "Wacom Intuos3 6x11", 10, 54204, 31750, 1023, 63, INTUOS3 },
644 { "Wacom Intuos3 4x6", 10, 31496, 19685, 1023, 63, INTUOS3S }, 650 { "Wacom Intuos3 4x6", 10, 31496, 19685, 1023, 63, INTUOS3S },
645 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 63, CINTIQ }, 651 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 63, CINTIQ },
652 { "Wacom Cintiq 12WX", 10, 53020, 33440, 1023, 63, WACOM_BEE },
646 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 31, INTUOS }, 653 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 31, INTUOS },
647 { } 654 { }
648}; 655};
@@ -656,12 +663,15 @@ static struct usb_device_id wacom_ids[] = {
656 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) }, 663 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) },
657 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x15) }, 664 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x15) },
658 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) }, 665 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) },
666 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x17) },
667 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x18) },
659 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) }, 668 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) },
660 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) }, 669 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) },
661 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) }, 670 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) },
662 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x63) }, 671 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x63) },
663 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x64) }, 672 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x64) },
664 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x65) }, 673 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x65) },
674 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x69) },
665 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) }, 675 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) },
666 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) }, 676 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) },
667 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) }, 677 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) },
@@ -692,6 +702,7 @@ static struct usb_device_id wacom_ids[] = {
692 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) }, 702 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) },
693 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB7) }, 703 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB7) },
694 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) }, 704 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },
705 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC6) },
695 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) }, 706 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
696 { } 707 { }
697}; 708};
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index a302e229bb8a..3342bc05847d 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -25,6 +25,7 @@ enum {
25 INTUOS3, 25 INTUOS3,
26 INTUOS3L, 26 INTUOS3L,
27 CINTIQ, 27 CINTIQ,
28 WACOM_BEE,
28 WACOM_MO, 29 WACOM_MO,
29 MAX_TYPE 30 MAX_TYPE
30}; 31};
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 58934a40f5ce..57a1c28bf122 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -213,7 +213,7 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
213 struct ads7846 *ts = dev_get_drvdata(dev); 213 struct ads7846 *ts = dev_get_drvdata(dev);
214 struct ser_req *req = kzalloc(sizeof *req, GFP_KERNEL); 214 struct ser_req *req = kzalloc(sizeof *req, GFP_KERNEL);
215 int status; 215 int status;
216 int sample; 216 int uninitialized_var(sample);
217 int use_internal; 217 int use_internal;
218 218
219 if (!req) 219 if (!req)
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 6c0a9c4761ee..4c0b05852cb6 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -49,13 +49,13 @@ static void gpio_led_set(struct led_classdev *led_cdev,
49 if (led_dat->active_low) 49 if (led_dat->active_low)
50 level = !level; 50 level = !level;
51 51
52 /* setting GPIOs with I2C/etc requires a preemptible task context */ 52 /* Setting GPIOs with I2C/etc requires a task context, and we don't
53 * seem to have a reliable way to know if we're already in one; so
54 * let's just assume the worst.
55 */
53 if (led_dat->can_sleep) { 56 if (led_dat->can_sleep) {
54 if (preempt_count()) { 57 led_dat->new_level = level;
55 led_dat->new_level = level; 58 schedule_work(&led_dat->work);
56 schedule_work(&led_dat->work);
57 } else
58 gpio_set_value_cansleep(led_dat->gpio, level);
59 } else 59 } else
60 gpio_set_value(led_dat->gpio, level); 60 gpio_set_value(led_dat->gpio, level);
61} 61}
@@ -79,6 +79,10 @@ static int gpio_led_probe(struct platform_device *pdev)
79 cur_led = &pdata->leds[i]; 79 cur_led = &pdata->leds[i];
80 led_dat = &leds_data[i]; 80 led_dat = &leds_data[i];
81 81
82 ret = gpio_request(cur_led->gpio, cur_led->name);
83 if (ret < 0)
84 goto err;
85
82 led_dat->cdev.name = cur_led->name; 86 led_dat->cdev.name = cur_led->name;
83 led_dat->cdev.default_trigger = cur_led->default_trigger; 87 led_dat->cdev.default_trigger = cur_led->default_trigger;
84 led_dat->gpio = cur_led->gpio; 88 led_dat->gpio = cur_led->gpio;
@@ -87,10 +91,6 @@ static int gpio_led_probe(struct platform_device *pdev)
87 led_dat->cdev.brightness_set = gpio_led_set; 91 led_dat->cdev.brightness_set = gpio_led_set;
88 led_dat->cdev.brightness = LED_OFF; 92 led_dat->cdev.brightness = LED_OFF;
89 93
90 ret = gpio_request(led_dat->gpio, led_dat->cdev.name);
91 if (ret < 0)
92 goto err;
93
94 gpio_direction_output(led_dat->gpio, led_dat->active_low); 94 gpio_direction_output(led_dat->gpio, led_dat->active_low);
95 95
96 INIT_WORK(&led_dat->work, gpio_led_work); 96 INIT_WORK(&led_dat->work, gpio_led_work);
diff --git a/drivers/lguest/Makefile b/drivers/lguest/Makefile
index 5e8272d296d8..7d463c26124f 100644
--- a/drivers/lguest/Makefile
+++ b/drivers/lguest/Makefile
@@ -19,3 +19,11 @@ Beer:
19 @for f in Preparation Guest Drivers Launcher Host Switcher Mastery; do echo "{==- $$f -==}"; make -s $$f; done; echo "{==-==}" 19 @for f in Preparation Guest Drivers Launcher Host Switcher Mastery; do echo "{==- $$f -==}"; make -s $$f; done; echo "{==-==}"
20Preparation Preparation! Guest Drivers Launcher Host Switcher Mastery: 20Preparation Preparation! Guest Drivers Launcher Host Switcher Mastery:
21 @sh ../../Documentation/lguest/extract $(PREFIX) `find ../../* -name '*.[chS]' -wholename '*lguest*'` 21 @sh ../../Documentation/lguest/extract $(PREFIX) `find ../../* -name '*.[chS]' -wholename '*lguest*'`
22Puppy:
23 @clear
24 @printf " __ \n (___()'\`;\n /, /\`\n \\\\\\\"--\\\\\\ \n"
25 @sleep 2; clear; printf "\n\n Sit!\n\n"; sleep 1; clear
26 @printf " __ \n ()'\`; \n /\\|\` \n / | \n(/_)_|_ \n"
27 @sleep 2; clear; printf "\n\n Stand!\n\n"; sleep 1; clear
28 @printf " __ \n ()'\`; \n /\\|\` \n /._.= \n /| / \n(_\_)_ \n"
29 @sleep 2; clear; printf "\n\n Good puppy!\n\n"; sleep 1; clear
diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
index c632c08cbbdc..5eea4356d703 100644
--- a/drivers/lguest/core.c
+++ b/drivers/lguest/core.c
@@ -1,8 +1,6 @@
1/*P:400 This contains run_guest() which actually calls into the Host<->Guest 1/*P:400 This contains run_guest() which actually calls into the Host<->Guest
2 * Switcher and analyzes the return, such as determining if the Guest wants the 2 * Switcher and analyzes the return, such as determining if the Guest wants the
3 * Host to do something. This file also contains useful helper routines, and a 3 * Host to do something. This file also contains useful helper routines. :*/
4 * couple of non-obvious setup and teardown pieces which were implemented after
5 * days of debugging pain. :*/
6#include <linux/module.h> 4#include <linux/module.h>
7#include <linux/stringify.h> 5#include <linux/stringify.h>
8#include <linux/stddef.h> 6#include <linux/stddef.h>
@@ -49,8 +47,8 @@ static __init int map_switcher(void)
49 * easy. 47 * easy.
50 */ 48 */
51 49
52 /* We allocate an array of "struct page"s. map_vm_area() wants the 50 /* We allocate an array of struct page pointers. map_vm_area() wants
53 * pages in this form, rather than just an array of pointers. */ 51 * this, rather than just an array of pages. */
54 switcher_page = kmalloc(sizeof(switcher_page[0])*TOTAL_SWITCHER_PAGES, 52 switcher_page = kmalloc(sizeof(switcher_page[0])*TOTAL_SWITCHER_PAGES,
55 GFP_KERNEL); 53 GFP_KERNEL);
56 if (!switcher_page) { 54 if (!switcher_page) {
@@ -172,7 +170,7 @@ void __lgread(struct lg_cpu *cpu, void *b, unsigned long addr, unsigned bytes)
172 } 170 }
173} 171}
174 172
175/* This is the write (copy into guest) version. */ 173/* This is the write (copy into Guest) version. */
176void __lgwrite(struct lg_cpu *cpu, unsigned long addr, const void *b, 174void __lgwrite(struct lg_cpu *cpu, unsigned long addr, const void *b,
177 unsigned bytes) 175 unsigned bytes)
178{ 176{
@@ -209,9 +207,9 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user)
209 if (cpu->break_out) 207 if (cpu->break_out)
210 return -EAGAIN; 208 return -EAGAIN;
211 209
212 /* Check if there are any interrupts which can be delivered 210 /* Check if there are any interrupts which can be delivered now:
213 * now: if so, this sets up the hander to be executed when we 211 * if so, this sets up the hander to be executed when we next
214 * next run the Guest. */ 212 * run the Guest. */
215 maybe_do_interrupt(cpu); 213 maybe_do_interrupt(cpu);
216 214
217 /* All long-lived kernel loops need to check with this horrible 215 /* All long-lived kernel loops need to check with this horrible
@@ -246,8 +244,10 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user)
246 lguest_arch_handle_trap(cpu); 244 lguest_arch_handle_trap(cpu);
247 } 245 }
248 246
247 /* Special case: Guest is 'dead' but wants a reboot. */
249 if (cpu->lg->dead == ERR_PTR(-ERESTART)) 248 if (cpu->lg->dead == ERR_PTR(-ERESTART))
250 return -ERESTART; 249 return -ERESTART;
250
251 /* The Guest is dead => "No such file or directory" */ 251 /* The Guest is dead => "No such file or directory" */
252 return -ENOENT; 252 return -ENOENT;
253} 253}
diff --git a/drivers/lguest/hypercalls.c b/drivers/lguest/hypercalls.c
index 0f2cb4fd7c69..54d66f05fefa 100644
--- a/drivers/lguest/hypercalls.c
+++ b/drivers/lguest/hypercalls.c
@@ -29,7 +29,7 @@
29#include "lg.h" 29#include "lg.h"
30 30
31/*H:120 This is the core hypercall routine: where the Guest gets what it wants. 31/*H:120 This is the core hypercall routine: where the Guest gets what it wants.
32 * Or gets killed. Or, in the case of LHCALL_CRASH, both. */ 32 * Or gets killed. Or, in the case of LHCALL_SHUTDOWN, both. */
33static void do_hcall(struct lg_cpu *cpu, struct hcall_args *args) 33static void do_hcall(struct lg_cpu *cpu, struct hcall_args *args)
34{ 34{
35 switch (args->arg0) { 35 switch (args->arg0) {
@@ -190,6 +190,13 @@ static void initialize(struct lg_cpu *cpu)
190 * pagetable. */ 190 * pagetable. */
191 guest_pagetable_clear_all(cpu); 191 guest_pagetable_clear_all(cpu);
192} 192}
193/*:*/
194
195/*M:013 If a Guest reads from a page (so creates a mapping) that it has never
196 * written to, and then the Launcher writes to it (ie. the output of a virtual
197 * device), the Guest will still see the old page. In practice, this never
198 * happens: why would the Guest read a page which it has never written to? But
199 * a similar scenario might one day bite us, so it's worth mentioning. :*/
193 200
194/*H:100 201/*H:100
195 * Hypercalls 202 * Hypercalls
@@ -227,7 +234,7 @@ void do_hypercalls(struct lg_cpu *cpu)
227 * However, if we are signalled or the Guest sends I/O to the 234 * However, if we are signalled or the Guest sends I/O to the
228 * Launcher, the run_guest() loop will exit without running the 235 * Launcher, the run_guest() loop will exit without running the
229 * Guest. When it comes back it would try to re-run the 236 * Guest. When it comes back it would try to re-run the
230 * hypercall. */ 237 * hypercall. Finding that bug sucked. */
231 cpu->hcall = NULL; 238 cpu->hcall = NULL;
232 } 239 }
233} 240}
diff --git a/drivers/lguest/interrupts_and_traps.c b/drivers/lguest/interrupts_and_traps.c
index 32e97c1858e5..0414ddf87587 100644
--- a/drivers/lguest/interrupts_and_traps.c
+++ b/drivers/lguest/interrupts_and_traps.c
@@ -144,7 +144,6 @@ void maybe_do_interrupt(struct lg_cpu *cpu)
144 if (copy_from_user(&blk, cpu->lg->lguest_data->blocked_interrupts, 144 if (copy_from_user(&blk, cpu->lg->lguest_data->blocked_interrupts,
145 sizeof(blk))) 145 sizeof(blk)))
146 return; 146 return;
147
148 bitmap_andnot(blk, cpu->irqs_pending, blk, LGUEST_IRQS); 147 bitmap_andnot(blk, cpu->irqs_pending, blk, LGUEST_IRQS);
149 148
150 /* Find the first interrupt. */ 149 /* Find the first interrupt. */
@@ -237,9 +236,9 @@ void free_interrupts(void)
237 clear_bit(syscall_vector, used_vectors); 236 clear_bit(syscall_vector, used_vectors);
238} 237}
239 238
240/*H:220 Now we've got the routines to deliver interrupts, delivering traps 239/*H:220 Now we've got the routines to deliver interrupts, delivering traps like
241 * like page fault is easy. The only trick is that Intel decided that some 240 * page fault is easy. The only trick is that Intel decided that some traps
242 * traps should have error codes: */ 241 * should have error codes: */
243static int has_err(unsigned int trap) 242static int has_err(unsigned int trap)
244{ 243{
245 return (trap == 8 || (trap >= 10 && trap <= 14) || trap == 17); 244 return (trap == 8 || (trap >= 10 && trap <= 14) || trap == 17);
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c
index 1b2ec0bf5eb1..2bc9bf7e88e5 100644
--- a/drivers/lguest/lguest_device.c
+++ b/drivers/lguest/lguest_device.c
@@ -1,10 +1,10 @@
1/*P:050 Lguest guests use a very simple method to describe devices. It's a 1/*P:050 Lguest guests use a very simple method to describe devices. It's a
2 * series of device descriptors contained just above the top of normal 2 * series of device descriptors contained just above the top of normal Guest
3 * memory. 3 * memory.
4 * 4 *
5 * We use the standard "virtio" device infrastructure, which provides us with a 5 * We use the standard "virtio" device infrastructure, which provides us with a
6 * console, a network and a block driver. Each one expects some configuration 6 * console, a network and a block driver. Each one expects some configuration
7 * information and a "virtqueue" mechanism to send and receive data. :*/ 7 * information and a "virtqueue" or two to send and receive data. :*/
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/bootmem.h> 9#include <linux/bootmem.h>
10#include <linux/lguest_launcher.h> 10#include <linux/lguest_launcher.h>
@@ -53,7 +53,7 @@ struct lguest_device {
53 * Device configurations 53 * Device configurations
54 * 54 *
55 * The configuration information for a device consists of one or more 55 * The configuration information for a device consists of one or more
56 * virtqueues, a feature bitmaks, and some configuration bytes. The 56 * virtqueues, a feature bitmap, and some configuration bytes. The
57 * configuration bytes don't really matter to us: the Launcher sets them up, and 57 * configuration bytes don't really matter to us: the Launcher sets them up, and
58 * the driver will look at them during setup. 58 * the driver will look at them during setup.
59 * 59 *
@@ -179,7 +179,7 @@ struct lguest_vq_info
179}; 179};
180 180
181/* When the virtio_ring code wants to prod the Host, it calls us here and we 181/* When the virtio_ring code wants to prod the Host, it calls us here and we
182 * make a hypercall. We hand the page number of the virtqueue so the Host 182 * make a hypercall. We hand the physical address of the virtqueue so the Host
183 * knows which virtqueue we're talking about. */ 183 * knows which virtqueue we're talking about. */
184static void lg_notify(struct virtqueue *vq) 184static void lg_notify(struct virtqueue *vq)
185{ 185{
@@ -199,7 +199,8 @@ static void lg_notify(struct virtqueue *vq)
199 * allocate its own pages and tell the Host where they are, but for lguest it's 199 * allocate its own pages and tell the Host where they are, but for lguest it's
200 * simpler for the Host to simply tell us where the pages are. 200 * simpler for the Host to simply tell us where the pages are.
201 * 201 *
202 * So we provide devices with a "find virtqueue and set it up" function. */ 202 * So we provide drivers with a "find the Nth virtqueue and set it up"
203 * function. */
203static struct virtqueue *lg_find_vq(struct virtio_device *vdev, 204static struct virtqueue *lg_find_vq(struct virtio_device *vdev,
204 unsigned index, 205 unsigned index,
205 void (*callback)(struct virtqueue *vq)) 206 void (*callback)(struct virtqueue *vq))
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index 2221485b0773..645e6e040bfb 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -73,7 +73,7 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o)
73 if (current != cpu->tsk) 73 if (current != cpu->tsk)
74 return -EPERM; 74 return -EPERM;
75 75
76 /* If the guest is already dead, we indicate why */ 76 /* If the Guest is already dead, we indicate why */
77 if (lg->dead) { 77 if (lg->dead) {
78 size_t len; 78 size_t len;
79 79
@@ -88,7 +88,7 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o)
88 return len; 88 return len;
89 } 89 }
90 90
91 /* If we returned from read() last time because the Guest notified, 91 /* If we returned from read() last time because the Guest sent I/O,
92 * clear the flag. */ 92 * clear the flag. */
93 if (cpu->pending_notify) 93 if (cpu->pending_notify)
94 cpu->pending_notify = 0; 94 cpu->pending_notify = 0;
@@ -97,14 +97,20 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o)
97 return run_guest(cpu, (unsigned long __user *)user); 97 return run_guest(cpu, (unsigned long __user *)user);
98} 98}
99 99
100/*L:025 This actually initializes a CPU. For the moment, a Guest is only
101 * uniprocessor, so "id" is always 0. */
100static int lg_cpu_start(struct lg_cpu *cpu, unsigned id, unsigned long start_ip) 102static int lg_cpu_start(struct lg_cpu *cpu, unsigned id, unsigned long start_ip)
101{ 103{
104 /* We have a limited number the number of CPUs in the lguest struct. */
102 if (id >= NR_CPUS) 105 if (id >= NR_CPUS)
103 return -EINVAL; 106 return -EINVAL;
104 107
108 /* Set up this CPU's id, and pointer back to the lguest struct. */
105 cpu->id = id; 109 cpu->id = id;
106 cpu->lg = container_of((cpu - id), struct lguest, cpus[0]); 110 cpu->lg = container_of((cpu - id), struct lguest, cpus[0]);
107 cpu->lg->nr_cpus++; 111 cpu->lg->nr_cpus++;
112
113 /* Each CPU has a timer it can set. */
108 init_clockdev(cpu); 114 init_clockdev(cpu);
109 115
110 /* We need a complete page for the Guest registers: they are accessible 116 /* We need a complete page for the Guest registers: they are accessible
@@ -120,11 +126,11 @@ static int lg_cpu_start(struct lg_cpu *cpu, unsigned id, unsigned long start_ip)
120 * address. */ 126 * address. */
121 lguest_arch_setup_regs(cpu, start_ip); 127 lguest_arch_setup_regs(cpu, start_ip);
122 128
123 /* Initialize the queue for the waker to wait on */ 129 /* Initialize the queue for the Waker to wait on */
124 init_waitqueue_head(&cpu->break_wq); 130 init_waitqueue_head(&cpu->break_wq);
125 131
126 /* We keep a pointer to the Launcher task (ie. current task) for when 132 /* We keep a pointer to the Launcher task (ie. current task) for when
127 * other Guests want to wake this one (inter-Guest I/O). */ 133 * other Guests want to wake this one (eg. console input). */
128 cpu->tsk = current; 134 cpu->tsk = current;
129 135
130 /* We need to keep a pointer to the Launcher's memory map, because if 136 /* We need to keep a pointer to the Launcher's memory map, because if
@@ -136,6 +142,7 @@ static int lg_cpu_start(struct lg_cpu *cpu, unsigned id, unsigned long start_ip)
136 * when the same Guest runs on the same CPU twice. */ 142 * when the same Guest runs on the same CPU twice. */
137 cpu->last_pages = NULL; 143 cpu->last_pages = NULL;
138 144
145 /* No error == success. */
139 return 0; 146 return 0;
140} 147}
141 148
@@ -182,17 +189,16 @@ static int initialize(struct file *file, const unsigned long __user *input)
182 } 189 }
183 190
184 /* Populate the easy fields of our "struct lguest" */ 191 /* Populate the easy fields of our "struct lguest" */
185 lg->mem_base = (void __user *)(long)args[0]; 192 lg->mem_base = (void __user *)args[0];
186 lg->pfn_limit = args[1]; 193 lg->pfn_limit = args[1];
187 194
188 /* This is the first cpu */ 195 /* This is the first cpu (cpu 0) and it will start booting at args[3] */
189 err = lg_cpu_start(&lg->cpus[0], 0, args[3]); 196 err = lg_cpu_start(&lg->cpus[0], 0, args[3]);
190 if (err) 197 if (err)
191 goto release_guest; 198 goto release_guest;
192 199
193 /* Initialize the Guest's shadow page tables, using the toplevel 200 /* Initialize the Guest's shadow page tables, using the toplevel
194 * address the Launcher gave us. This allocates memory, so can 201 * address the Launcher gave us. This allocates memory, so can fail. */
195 * fail. */
196 err = init_guest_pagetable(lg, args[2]); 202 err = init_guest_pagetable(lg, args[2]);
197 if (err) 203 if (err)
198 goto free_regs; 204 goto free_regs;
@@ -218,11 +224,16 @@ unlock:
218/*L:010 The first operation the Launcher does must be a write. All writes 224/*L:010 The first operation the Launcher does must be a write. All writes
219 * start with an unsigned long number: for the first write this must be 225 * start with an unsigned long number: for the first write this must be
220 * LHREQ_INITIALIZE to set up the Guest. After that the Launcher can use 226 * LHREQ_INITIALIZE to set up the Guest. After that the Launcher can use
221 * writes of other values to send interrupts. */ 227 * writes of other values to send interrupts.
228 *
229 * Note that we overload the "offset" in the /dev/lguest file to indicate what
230 * CPU number we're dealing with. Currently this is always 0, since we only
231 * support uniprocessor Guests, but you can see the beginnings of SMP support
232 * here. */
222static ssize_t write(struct file *file, const char __user *in, 233static ssize_t write(struct file *file, const char __user *in,
223 size_t size, loff_t *off) 234 size_t size, loff_t *off)
224{ 235{
225 /* Once the guest is initialized, we hold the "struct lguest" in the 236 /* Once the Guest is initialized, we hold the "struct lguest" in the
226 * file private data. */ 237 * file private data. */
227 struct lguest *lg = file->private_data; 238 struct lguest *lg = file->private_data;
228 const unsigned long __user *input = (const unsigned long __user *)in; 239 const unsigned long __user *input = (const unsigned long __user *)in;
@@ -230,6 +241,7 @@ static ssize_t write(struct file *file, const char __user *in,
230 struct lg_cpu *uninitialized_var(cpu); 241 struct lg_cpu *uninitialized_var(cpu);
231 unsigned int cpu_id = *off; 242 unsigned int cpu_id = *off;
232 243
244 /* The first value tells us what this request is. */
233 if (get_user(req, input) != 0) 245 if (get_user(req, input) != 0)
234 return -EFAULT; 246 return -EFAULT;
235 input++; 247 input++;
diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
index a7f64a9d67e0..d93500f24fbb 100644
--- a/drivers/lguest/page_tables.c
+++ b/drivers/lguest/page_tables.c
@@ -2,8 +2,8 @@
2 * previous encounters. It's functional, and as neat as it can be in the 2 * previous encounters. It's functional, and as neat as it can be in the
3 * circumstances, but be wary, for these things are subtle and break easily. 3 * circumstances, but be wary, for these things are subtle and break easily.
4 * The Guest provides a virtual to physical mapping, but we can neither trust 4 * The Guest provides a virtual to physical mapping, but we can neither trust
5 * it nor use it: we verify and convert it here to point the hardware to the 5 * it nor use it: we verify and convert it here then point the CPU to the
6 * actual Guest pages when running the Guest. :*/ 6 * converted Guest pages when running the Guest. :*/
7 7
8/* Copyright (C) Rusty Russell IBM Corporation 2006. 8/* Copyright (C) Rusty Russell IBM Corporation 2006.
9 * GPL v2 and any later version */ 9 * GPL v2 and any later version */
@@ -106,6 +106,11 @@ static unsigned long gpte_addr(pgd_t gpgd, unsigned long vaddr)
106 BUG_ON(!(pgd_flags(gpgd) & _PAGE_PRESENT)); 106 BUG_ON(!(pgd_flags(gpgd) & _PAGE_PRESENT));
107 return gpage + ((vaddr>>PAGE_SHIFT) % PTRS_PER_PTE) * sizeof(pte_t); 107 return gpage + ((vaddr>>PAGE_SHIFT) % PTRS_PER_PTE) * sizeof(pte_t);
108} 108}
109/*:*/
110
111/*M:014 get_pfn is slow; it takes the mmap sem and calls get_user_pages. We
112 * could probably try to grab batches of pages here as an optimization
113 * (ie. pre-faulting). :*/
109 114
110/*H:350 This routine takes a page number given by the Guest and converts it to 115/*H:350 This routine takes a page number given by the Guest and converts it to
111 * an actual, physical page number. It can fail for several reasons: the 116 * an actual, physical page number. It can fail for several reasons: the
@@ -113,8 +118,8 @@ static unsigned long gpte_addr(pgd_t gpgd, unsigned long vaddr)
113 * and the page is read-only, or the write flag was set and the page was 118 * and the page is read-only, or the write flag was set and the page was
114 * shared so had to be copied, but we ran out of memory. 119 * shared so had to be copied, but we ran out of memory.
115 * 120 *
116 * This holds a reference to the page, so release_pte() is careful to 121 * This holds a reference to the page, so release_pte() is careful to put that
117 * put that back. */ 122 * back. */
118static unsigned long get_pfn(unsigned long virtpfn, int write) 123static unsigned long get_pfn(unsigned long virtpfn, int write)
119{ 124{
120 struct page *page; 125 struct page *page;
@@ -532,13 +537,13 @@ static void do_set_pte(struct lg_cpu *cpu, int idx,
532 * all processes. So when the page table above that address changes, we update 537 * all processes. So when the page table above that address changes, we update
533 * all the page tables, not just the current one. This is rare. 538 * all the page tables, not just the current one. This is rare.
534 * 539 *
535 * The benefit is that when we have to track a new page table, we can copy keep 540 * The benefit is that when we have to track a new page table, we can keep all
536 * all the kernel mappings. This speeds up context switch immensely. */ 541 * the kernel mappings. This speeds up context switch immensely. */
537void guest_set_pte(struct lg_cpu *cpu, 542void guest_set_pte(struct lg_cpu *cpu,
538 unsigned long gpgdir, unsigned long vaddr, pte_t gpte) 543 unsigned long gpgdir, unsigned long vaddr, pte_t gpte)
539{ 544{
540 /* Kernel mappings must be changed on all top levels. Slow, but 545 /* Kernel mappings must be changed on all top levels. Slow, but doesn't
541 * doesn't happen often. */ 546 * happen often. */
542 if (vaddr >= cpu->lg->kernel_address) { 547 if (vaddr >= cpu->lg->kernel_address) {
543 unsigned int i; 548 unsigned int i;
544 for (i = 0; i < ARRAY_SIZE(cpu->lg->pgdirs); i++) 549 for (i = 0; i < ARRAY_SIZE(cpu->lg->pgdirs); i++)
@@ -704,12 +709,11 @@ static __init void populate_switcher_pte_page(unsigned int cpu,
704/* We've made it through the page table code. Perhaps our tired brains are 709/* We've made it through the page table code. Perhaps our tired brains are
705 * still processing the details, or perhaps we're simply glad it's over. 710 * still processing the details, or perhaps we're simply glad it's over.
706 * 711 *
707 * If nothing else, note that all this complexity in juggling shadow page 712 * If nothing else, note that all this complexity in juggling shadow page tables
708 * tables in sync with the Guest's page tables is for one reason: for most 713 * in sync with the Guest's page tables is for one reason: for most Guests this
709 * Guests this page table dance determines how bad performance will be. This 714 * page table dance determines how bad performance will be. This is why Xen
710 * is why Xen uses exotic direct Guest pagetable manipulation, and why both 715 * uses exotic direct Guest pagetable manipulation, and why both Intel and AMD
711 * Intel and AMD have implemented shadow page table support directly into 716 * have implemented shadow page table support directly into hardware.
712 * hardware.
713 * 717 *
714 * There is just one file remaining in the Host. */ 718 * There is just one file remaining in the Host. */
715 719
diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
index 635187812d52..5126d5d9ea0e 100644
--- a/drivers/lguest/x86/core.c
+++ b/drivers/lguest/x86/core.c
@@ -17,6 +17,13 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 19 */
20/*P:450 This file contains the x86-specific lguest code. It used to be all
21 * mixed in with drivers/lguest/core.c but several foolhardy code slashers
22 * wrestled most of the dependencies out to here in preparation for porting
23 * lguest to other architectures (see what I mean by foolhardy?).
24 *
25 * This also contains a couple of non-obvious setup and teardown pieces which
26 * were implemented after days of debugging pain. :*/
20#include <linux/kernel.h> 27#include <linux/kernel.h>
21#include <linux/start_kernel.h> 28#include <linux/start_kernel.h>
22#include <linux/string.h> 29#include <linux/string.h>
@@ -157,6 +164,8 @@ static void run_guest_once(struct lg_cpu *cpu, struct lguest_pages *pages)
157 * also simplify copy_in_guest_info(). Note that we'd still need to restore 164 * also simplify copy_in_guest_info(). Note that we'd still need to restore
158 * things when we exit to Launcher userspace, but that's fairly easy. 165 * things when we exit to Launcher userspace, but that's fairly easy.
159 * 166 *
167 * We could also try using this hooks for PGE, but that might be too expensive.
168 *
160 * The hooks were designed for KVM, but we can also put them to good use. :*/ 169 * The hooks were designed for KVM, but we can also put them to good use. :*/
161 170
162/*H:040 This is the i386-specific code to setup and run the Guest. Interrupts 171/*H:040 This is the i386-specific code to setup and run the Guest. Interrupts
@@ -182,7 +191,7 @@ void lguest_arch_run_guest(struct lg_cpu *cpu)
182 * was doing. */ 191 * was doing. */
183 run_guest_once(cpu, lguest_pages(raw_smp_processor_id())); 192 run_guest_once(cpu, lguest_pages(raw_smp_processor_id()));
184 193
185 /* Note that the "regs" pointer contains two extra entries which are 194 /* Note that the "regs" structure contains two extra entries which are
186 * not really registers: a trap number which says what interrupt or 195 * not really registers: a trap number which says what interrupt or
187 * trap made the switcher code come back, and an error code which some 196 * trap made the switcher code come back, and an error code which some
188 * traps set. */ 197 * traps set. */
@@ -293,11 +302,10 @@ void lguest_arch_handle_trap(struct lg_cpu *cpu)
293 break; 302 break;
294 case 14: /* We've intercepted a Page Fault. */ 303 case 14: /* We've intercepted a Page Fault. */
295 /* The Guest accessed a virtual address that wasn't mapped. 304 /* The Guest accessed a virtual address that wasn't mapped.
296 * This happens a lot: we don't actually set up most of the 305 * This happens a lot: we don't actually set up most of the page
297 * page tables for the Guest at all when we start: as it runs 306 * tables for the Guest at all when we start: as it runs it asks
298 * it asks for more and more, and we set them up as 307 * for more and more, and we set them up as required. In this
299 * required. In this case, we don't even tell the Guest that 308 * case, we don't even tell the Guest that the fault happened.
300 * the fault happened.
301 * 309 *
302 * The errcode tells whether this was a read or a write, and 310 * The errcode tells whether this was a read or a write, and
303 * whether kernel or userspace code. */ 311 * whether kernel or userspace code. */
@@ -342,7 +350,7 @@ void lguest_arch_handle_trap(struct lg_cpu *cpu)
342 if (!deliver_trap(cpu, cpu->regs->trapnum)) 350 if (!deliver_trap(cpu, cpu->regs->trapnum))
343 /* If the Guest doesn't have a handler (either it hasn't 351 /* If the Guest doesn't have a handler (either it hasn't
344 * registered any yet, or it's one of the faults we don't let 352 * registered any yet, or it's one of the faults we don't let
345 * it handle), it dies with a cryptic error message. */ 353 * it handle), it dies with this cryptic error message. */
346 kill_guest(cpu, "unhandled trap %li at %#lx (%#lx)", 354 kill_guest(cpu, "unhandled trap %li at %#lx (%#lx)",
347 cpu->regs->trapnum, cpu->regs->eip, 355 cpu->regs->trapnum, cpu->regs->eip,
348 cpu->regs->trapnum == 14 ? cpu->arch.last_pagefault 356 cpu->regs->trapnum == 14 ? cpu->arch.last_pagefault
@@ -375,8 +383,8 @@ void __init lguest_arch_host_init(void)
375 * The only exception is the interrupt handlers in switcher.S: their 383 * The only exception is the interrupt handlers in switcher.S: their
376 * addresses are placed in a table (default_idt_entries), so we need to 384 * addresses are placed in a table (default_idt_entries), so we need to
377 * update the table with the new addresses. switcher_offset() is a 385 * update the table with the new addresses. switcher_offset() is a
378 * convenience function which returns the distance between the builtin 386 * convenience function which returns the distance between the
379 * switcher code and the high-mapped copy we just made. */ 387 * compiled-in switcher code and the high-mapped copy we just made. */
380 for (i = 0; i < IDT_ENTRIES; i++) 388 for (i = 0; i < IDT_ENTRIES; i++)
381 default_idt_entries[i] += switcher_offset(); 389 default_idt_entries[i] += switcher_offset();
382 390
@@ -416,7 +424,7 @@ void __init lguest_arch_host_init(void)
416 state->guest_gdt_desc.address = (long)&state->guest_gdt; 424 state->guest_gdt_desc.address = (long)&state->guest_gdt;
417 425
418 /* We know where we want the stack to be when the Guest enters 426 /* We know where we want the stack to be when the Guest enters
419 * the switcher: in pages->regs. The stack grows upwards, so 427 * the Switcher: in pages->regs. The stack grows upwards, so
420 * we start it at the end of that structure. */ 428 * we start it at the end of that structure. */
421 state->guest_tss.sp0 = (long)(&pages->regs + 1); 429 state->guest_tss.sp0 = (long)(&pages->regs + 1);
422 /* And this is the GDT entry to use for the stack: we keep a 430 /* And this is the GDT entry to use for the stack: we keep a
@@ -513,8 +521,8 @@ int lguest_arch_init_hypercalls(struct lg_cpu *cpu)
513{ 521{
514 u32 tsc_speed; 522 u32 tsc_speed;
515 523
516 /* The pointer to the Guest's "struct lguest_data" is the only 524 /* The pointer to the Guest's "struct lguest_data" is the only argument.
517 * argument. We check that address now. */ 525 * We check that address now. */
518 if (!lguest_address_ok(cpu->lg, cpu->hcall->arg1, 526 if (!lguest_address_ok(cpu->lg, cpu->hcall->arg1,
519 sizeof(*cpu->lg->lguest_data))) 527 sizeof(*cpu->lg->lguest_data)))
520 return -EFAULT; 528 return -EFAULT;
@@ -546,6 +554,7 @@ int lguest_arch_init_hypercalls(struct lg_cpu *cpu)
546 554
547 return 0; 555 return 0;
548} 556}
557/*:*/
549 558
550/*L:030 lguest_arch_setup_regs() 559/*L:030 lguest_arch_setup_regs()
551 * 560 *
diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
index 0af8baaa0d4a..3fc15318a80f 100644
--- a/drivers/lguest/x86/switcher_32.S
+++ b/drivers/lguest/x86/switcher_32.S
@@ -1,6 +1,6 @@
1/*P:900 This is the Switcher: code which sits at 0xFFC00000 to do the low-level 1/*P:900 This is the Switcher: code which sits at 0xFFC00000 astride both the
2 * Guest<->Host switch. It is as simple as it can be made, but it's naturally 2 * Host and Guest to do the low-level Guest<->Host switch. It is as simple as
3 * very specific to x86. 3 * it can be made, but it's naturally very specific to x86.
4 * 4 *
5 * You have now completed Preparation. If this has whet your appetite; if you 5 * You have now completed Preparation. If this has whet your appetite; if you
6 * are feeling invigorated and refreshed then the next, more challenging stage 6 * are feeling invigorated and refreshed then the next, more challenging stage
@@ -189,7 +189,7 @@ ENTRY(switch_to_guest)
189 // Interrupts are turned back on: we are Guest. 189 // Interrupts are turned back on: we are Guest.
190 iret 190 iret
191 191
192// We treat two paths to switch back to the Host 192// We tread two paths to switch back to the Host
193// Yet both must save Guest state and restore Host 193// Yet both must save Guest state and restore Host
194// So we put the routine in a macro. 194// So we put the routine in a macro.
195#define SWITCH_TO_HOST \ 195#define SWITCH_TO_HOST \
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index b04f98df94ea..835def11419d 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (C) 2003 Christophe Saout <christophe@saout.de> 2 * Copyright (C) 2003 Christophe Saout <christophe@saout.de>
3 * Copyright (C) 2004 Clemens Fruhwirth <clemens@endorphin.org> 3 * Copyright (C) 2004 Clemens Fruhwirth <clemens@endorphin.org>
4 * Copyright (C) 2006-2007 Red Hat, Inc. All rights reserved. 4 * Copyright (C) 2006-2008 Red Hat, Inc. All rights reserved.
5 * 5 *
6 * This file is released under the GPL. 6 * This file is released under the GPL.
7 */ 7 */
@@ -93,6 +93,8 @@ struct crypt_config {
93 93
94 struct workqueue_struct *io_queue; 94 struct workqueue_struct *io_queue;
95 struct workqueue_struct *crypt_queue; 95 struct workqueue_struct *crypt_queue;
96 wait_queue_head_t writeq;
97
96 /* 98 /*
97 * crypto related data 99 * crypto related data
98 */ 100 */
@@ -331,14 +333,7 @@ static void crypt_convert_init(struct crypt_config *cc,
331 ctx->idx_out = bio_out ? bio_out->bi_idx : 0; 333 ctx->idx_out = bio_out ? bio_out->bi_idx : 0;
332 ctx->sector = sector + cc->iv_offset; 334 ctx->sector = sector + cc->iv_offset;
333 init_completion(&ctx->restart); 335 init_completion(&ctx->restart);
334 /* 336 atomic_set(&ctx->pending, 1);
335 * Crypto operation can be asynchronous,
336 * ctx->pending is increased after request submission.
337 * We need to ensure that we don't call the crypt finish
338 * operation before pending got incremented
339 * (dependent on crypt submission return code).
340 */
341 atomic_set(&ctx->pending, 2);
342} 337}
343 338
344static int crypt_convert_block(struct crypt_config *cc, 339static int crypt_convert_block(struct crypt_config *cc,
@@ -411,43 +406,42 @@ static void crypt_alloc_req(struct crypt_config *cc,
411static int crypt_convert(struct crypt_config *cc, 406static int crypt_convert(struct crypt_config *cc,
412 struct convert_context *ctx) 407 struct convert_context *ctx)
413{ 408{
414 int r = 0; 409 int r;
415 410
416 while(ctx->idx_in < ctx->bio_in->bi_vcnt && 411 while(ctx->idx_in < ctx->bio_in->bi_vcnt &&
417 ctx->idx_out < ctx->bio_out->bi_vcnt) { 412 ctx->idx_out < ctx->bio_out->bi_vcnt) {
418 413
419 crypt_alloc_req(cc, ctx); 414 crypt_alloc_req(cc, ctx);
420 415
416 atomic_inc(&ctx->pending);
417
421 r = crypt_convert_block(cc, ctx, cc->req); 418 r = crypt_convert_block(cc, ctx, cc->req);
422 419
423 switch (r) { 420 switch (r) {
421 /* async */
424 case -EBUSY: 422 case -EBUSY:
425 wait_for_completion(&ctx->restart); 423 wait_for_completion(&ctx->restart);
426 INIT_COMPLETION(ctx->restart); 424 INIT_COMPLETION(ctx->restart);
427 /* fall through*/ 425 /* fall through*/
428 case -EINPROGRESS: 426 case -EINPROGRESS:
429 atomic_inc(&ctx->pending);
430 cc->req = NULL; 427 cc->req = NULL;
431 r = 0; 428 ctx->sector++;
432 /* fall through*/ 429 continue;
430
431 /* sync */
433 case 0: 432 case 0:
433 atomic_dec(&ctx->pending);
434 ctx->sector++; 434 ctx->sector++;
435 continue; 435 continue;
436 }
437 436
438 break; 437 /* error */
438 default:
439 atomic_dec(&ctx->pending);
440 return r;
441 }
439 } 442 }
440 443
441 /* 444 return 0;
442 * If there are pending crypto operation run async
443 * code. Otherwise process return code synchronously.
444 * The step of 2 ensures that async finish doesn't
445 * call crypto finish too early.
446 */
447 if (atomic_sub_return(2, &ctx->pending))
448 return -EINPROGRESS;
449
450 return r;
451} 445}
452 446
453static void dm_crypt_bio_destructor(struct bio *bio) 447static void dm_crypt_bio_destructor(struct bio *bio)
@@ -624,8 +618,10 @@ static void kcryptd_io_read(struct dm_crypt_io *io)
624static void kcryptd_io_write(struct dm_crypt_io *io) 618static void kcryptd_io_write(struct dm_crypt_io *io)
625{ 619{
626 struct bio *clone = io->ctx.bio_out; 620 struct bio *clone = io->ctx.bio_out;
621 struct crypt_config *cc = io->target->private;
627 622
628 generic_make_request(clone); 623 generic_make_request(clone);
624 wake_up(&cc->writeq);
629} 625}
630 626
631static void kcryptd_io(struct work_struct *work) 627static void kcryptd_io(struct work_struct *work)
@@ -698,7 +694,8 @@ static void kcryptd_crypt_write_convert_loop(struct dm_crypt_io *io)
698 694
699 r = crypt_convert(cc, &io->ctx); 695 r = crypt_convert(cc, &io->ctx);
700 696
701 if (r != -EINPROGRESS) { 697 if (atomic_dec_and_test(&io->ctx.pending)) {
698 /* processed, no running async crypto */
702 kcryptd_crypt_write_io_submit(io, r, 0); 699 kcryptd_crypt_write_io_submit(io, r, 0);
703 if (unlikely(r < 0)) 700 if (unlikely(r < 0))
704 return; 701 return;
@@ -706,8 +703,12 @@ static void kcryptd_crypt_write_convert_loop(struct dm_crypt_io *io)
706 atomic_inc(&io->pending); 703 atomic_inc(&io->pending);
707 704
708 /* out of memory -> run queues */ 705 /* out of memory -> run queues */
709 if (unlikely(remaining)) 706 if (unlikely(remaining)) {
707 /* wait for async crypto then reinitialize pending */
708 wait_event(cc->writeq, !atomic_read(&io->ctx.pending));
709 atomic_set(&io->ctx.pending, 1);
710 congestion_wait(WRITE, HZ/100); 710 congestion_wait(WRITE, HZ/100);
711 }
711 } 712 }
712} 713}
713 714
@@ -746,7 +747,7 @@ static void kcryptd_crypt_read_convert(struct dm_crypt_io *io)
746 747
747 r = crypt_convert(cc, &io->ctx); 748 r = crypt_convert(cc, &io->ctx);
748 749
749 if (r != -EINPROGRESS) 750 if (atomic_dec_and_test(&io->ctx.pending))
750 kcryptd_crypt_read_done(io, r); 751 kcryptd_crypt_read_done(io, r);
751 752
752 crypt_dec_pending(io); 753 crypt_dec_pending(io);
@@ -1047,6 +1048,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1047 goto bad_crypt_queue; 1048 goto bad_crypt_queue;
1048 } 1049 }
1049 1050
1051 init_waitqueue_head(&cc->writeq);
1050 ti->private = cc; 1052 ti->private = cc;
1051 return 0; 1053 return 0;
1052 1054
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
index b8e342fe7586..8f25f628ef16 100644
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@ -114,7 +114,7 @@ static void dec_count(struct io *io, unsigned int region, int error)
114 wake_up_process(io->sleeper); 114 wake_up_process(io->sleeper);
115 115
116 else { 116 else {
117 int r = io->error; 117 unsigned long r = io->error;
118 io_notify_fn fn = io->callback; 118 io_notify_fn fn = io->callback;
119 void *context = io->context; 119 void *context = io->context;
120 120
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 51605870f898..762cb086bb7f 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -753,7 +753,7 @@ out:
753 * are in the no-sync state. We have to recover these by 753 * are in the no-sync state. We have to recover these by
754 * recopying from the default mirror to all the others. 754 * recopying from the default mirror to all the others.
755 *---------------------------------------------------------------*/ 755 *---------------------------------------------------------------*/
756static void recovery_complete(int read_err, unsigned int write_err, 756static void recovery_complete(int read_err, unsigned long write_err,
757 void *context) 757 void *context)
758{ 758{
759 struct region *reg = (struct region *)context; 759 struct region *reg = (struct region *)context;
@@ -767,7 +767,7 @@ static void recovery_complete(int read_err, unsigned int write_err,
767 } 767 }
768 768
769 if (write_err) { 769 if (write_err) {
770 DMERR_LIMIT("Write error during recovery (error = 0x%x)", 770 DMERR_LIMIT("Write error during recovery (error = 0x%lx)",
771 write_err); 771 write_err);
772 /* 772 /*
773 * Bits correspond to devices (excluding default mirror). 773 * Bits correspond to devices (excluding default mirror).
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index ae24eab8cd81..4dc8a43c034b 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -804,7 +804,7 @@ static void commit_callback(void *context, int success)
804 * Called when the copy I/O has finished. kcopyd actually runs 804 * Called when the copy I/O has finished. kcopyd actually runs
805 * this code so don't block. 805 * this code so don't block.
806 */ 806 */
807static void copy_callback(int read_err, unsigned int write_err, void *context) 807static void copy_callback(int read_err, unsigned long write_err, void *context)
808{ 808{
809 struct dm_snap_pending_exception *pe = context; 809 struct dm_snap_pending_exception *pe = context;
810 struct dm_snapshot *s = pe->snap; 810 struct dm_snapshot *s = pe->snap;
diff --git a/drivers/md/kcopyd.c b/drivers/md/kcopyd.c
index f3831f31223e..e76b52ade690 100644
--- a/drivers/md/kcopyd.c
+++ b/drivers/md/kcopyd.c
@@ -169,7 +169,7 @@ struct kcopyd_job {
169 * Error state of the job. 169 * Error state of the job.
170 */ 170 */
171 int read_err; 171 int read_err;
172 unsigned int write_err; 172 unsigned long write_err;
173 173
174 /* 174 /*
175 * Either READ or WRITE 175 * Either READ or WRITE
@@ -293,7 +293,7 @@ static int run_complete_job(struct kcopyd_job *job)
293{ 293{
294 void *context = job->context; 294 void *context = job->context;
295 int read_err = job->read_err; 295 int read_err = job->read_err;
296 unsigned int write_err = job->write_err; 296 unsigned long write_err = job->write_err;
297 kcopyd_notify_fn fn = job->fn; 297 kcopyd_notify_fn fn = job->fn;
298 struct kcopyd_client *kc = job->kc; 298 struct kcopyd_client *kc = job->kc;
299 299
@@ -396,7 +396,7 @@ static int process_jobs(struct list_head *jobs, int (*fn) (struct kcopyd_job *))
396 if (r < 0) { 396 if (r < 0) {
397 /* error this rogue job */ 397 /* error this rogue job */
398 if (job->rw == WRITE) 398 if (job->rw == WRITE)
399 job->write_err = (unsigned int) -1; 399 job->write_err = (unsigned long) -1L;
400 else 400 else
401 job->read_err = 1; 401 job->read_err = 1;
402 push(&_complete_jobs, job); 402 push(&_complete_jobs, job);
@@ -448,8 +448,8 @@ static void dispatch_job(struct kcopyd_job *job)
448} 448}
449 449
450#define SUB_JOB_SIZE 128 450#define SUB_JOB_SIZE 128
451static void segment_complete(int read_err, 451static void segment_complete(int read_err, unsigned long write_err,
452 unsigned int write_err, void *context) 452 void *context)
453{ 453{
454 /* FIXME: tidy this function */ 454 /* FIXME: tidy this function */
455 sector_t progress = 0; 455 sector_t progress = 0;
diff --git a/drivers/md/kcopyd.h b/drivers/md/kcopyd.h
index 4621ea055c0e..4845f2a0c676 100644
--- a/drivers/md/kcopyd.h
+++ b/drivers/md/kcopyd.h
@@ -32,8 +32,8 @@ void kcopyd_client_destroy(struct kcopyd_client *kc);
32 * read_err is a boolean, 32 * read_err is a boolean,
33 * write_err is a bitset, with 1 bit for each destination region 33 * write_err is a bitset, with 1 bit for each destination region
34 */ 34 */
35typedef void (*kcopyd_notify_fn)(int read_err, 35typedef void (*kcopyd_notify_fn)(int read_err, unsigned long write_err,
36 unsigned int write_err, void *context); 36 void *context);
37 37
38int kcopyd_copy(struct kcopyd_client *kc, struct io_region *from, 38int kcopyd_copy(struct kcopyd_client *kc, struct io_region *from,
39 unsigned int num_dests, struct io_region *dests, 39 unsigned int num_dests, struct io_region *dests,
diff --git a/drivers/md/md.c b/drivers/md/md.c
index ccbbf63727cc..61ccbd2683fa 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1864,17 +1864,6 @@ static struct rdev_sysfs_entry rdev_state =
1864__ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store); 1864__ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
1865 1865
1866static ssize_t 1866static ssize_t
1867super_show(mdk_rdev_t *rdev, char *page)
1868{
1869 if (rdev->sb_loaded && rdev->sb_size) {
1870 memcpy(page, page_address(rdev->sb_page), rdev->sb_size);
1871 return rdev->sb_size;
1872 } else
1873 return 0;
1874}
1875static struct rdev_sysfs_entry rdev_super = __ATTR_RO(super);
1876
1877static ssize_t
1878errors_show(mdk_rdev_t *rdev, char *page) 1867errors_show(mdk_rdev_t *rdev, char *page)
1879{ 1868{
1880 return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors)); 1869 return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
@@ -2060,7 +2049,6 @@ __ATTR(size, S_IRUGO|S_IWUSR, rdev_size_show, rdev_size_store);
2060 2049
2061static struct attribute *rdev_default_attrs[] = { 2050static struct attribute *rdev_default_attrs[] = {
2062 &rdev_state.attr, 2051 &rdev_state.attr,
2063 &rdev_super.attr,
2064 &rdev_errors.attr, 2052 &rdev_errors.attr,
2065 &rdev_slot.attr, 2053 &rdev_slot.attr,
2066 &rdev_offset.attr, 2054 &rdev_offset.attr,
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 2d6f1a51359c..c574cf5efb5c 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1143,7 +1143,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
1143 rdev = conf->disks[i].rdev; 1143 rdev = conf->disks[i].rdev;
1144 printk(KERN_INFO "raid5:%s: read error corrected (%lu sectors at %llu on %s)\n", 1144 printk(KERN_INFO "raid5:%s: read error corrected (%lu sectors at %llu on %s)\n",
1145 mdname(conf->mddev), STRIPE_SECTORS, 1145 mdname(conf->mddev), STRIPE_SECTORS,
1146 (unsigned long long)sh->sector + rdev->data_offset, 1146 (unsigned long long)(sh->sector + rdev->data_offset),
1147 bdevname(rdev->bdev, b)); 1147 bdevname(rdev->bdev, b));
1148 clear_bit(R5_ReadError, &sh->dev[i].flags); 1148 clear_bit(R5_ReadError, &sh->dev[i].flags);
1149 clear_bit(R5_ReWrite, &sh->dev[i].flags); 1149 clear_bit(R5_ReWrite, &sh->dev[i].flags);
@@ -1160,13 +1160,13 @@ static void raid5_end_read_request(struct bio * bi, int error)
1160 if (conf->mddev->degraded) 1160 if (conf->mddev->degraded)
1161 printk(KERN_WARNING "raid5:%s: read error not correctable (sector %llu on %s).\n", 1161 printk(KERN_WARNING "raid5:%s: read error not correctable (sector %llu on %s).\n",
1162 mdname(conf->mddev), 1162 mdname(conf->mddev),
1163 (unsigned long long)sh->sector + rdev->data_offset, 1163 (unsigned long long)(sh->sector + rdev->data_offset),
1164 bdn); 1164 bdn);
1165 else if (test_bit(R5_ReWrite, &sh->dev[i].flags)) 1165 else if (test_bit(R5_ReWrite, &sh->dev[i].flags))
1166 /* Oh, no!!! */ 1166 /* Oh, no!!! */
1167 printk(KERN_WARNING "raid5:%s: read error NOT corrected!! (sector %llu on %s).\n", 1167 printk(KERN_WARNING "raid5:%s: read error NOT corrected!! (sector %llu on %s).\n",
1168 mdname(conf->mddev), 1168 mdname(conf->mddev),
1169 (unsigned long long)sh->sector + rdev->data_offset, 1169 (unsigned long long)(sh->sector + rdev->data_offset),
1170 bdn); 1170 bdn);
1171 else if (atomic_read(&rdev->read_errors) 1171 else if (atomic_read(&rdev->read_errors)
1172 > conf->max_nr_stripes) 1172 > conf->max_nr_stripes)
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c
index 168a8d3a5e55..7707b8c7394b 100644
--- a/drivers/media/common/saa7146_core.c
+++ b/drivers/media/common/saa7146_core.c
@@ -306,25 +306,22 @@ static irqreturn_t interrupt_hw(int irq, void *dev_id)
306 return IRQ_NONE; 306 return IRQ_NONE;
307 } 307 }
308 308
309 if( 0 != (dev->ext)) { 309 if (dev->ext) {
310 if( 0 != (dev->ext->irq_mask & isr )) { 310 if (dev->ext->irq_mask & isr) {
311 if( 0 != dev->ext->irq_func ) { 311 if (dev->ext->irq_func)
312 dev->ext->irq_func(dev, &isr); 312 dev->ext->irq_func(dev, &isr);
313 }
314 isr &= ~dev->ext->irq_mask; 313 isr &= ~dev->ext->irq_mask;
315 } 314 }
316 } 315 }
317 if (0 != (isr & (MASK_27))) { 316 if (0 != (isr & (MASK_27))) {
318 DEB_INT(("irq: RPS0 (0x%08x).\n",isr)); 317 DEB_INT(("irq: RPS0 (0x%08x).\n",isr));
319 if( 0 != dev->vv_data && 0 != dev->vv_callback) { 318 if (dev->vv_data && dev->vv_callback)
320 dev->vv_callback(dev,isr); 319 dev->vv_callback(dev,isr);
321 }
322 isr &= ~MASK_27; 320 isr &= ~MASK_27;
323 } 321 }
324 if (0 != (isr & (MASK_28))) { 322 if (0 != (isr & (MASK_28))) {
325 if( 0 != dev->vv_data && 0 != dev->vv_callback) { 323 if (dev->vv_data && dev->vv_callback)
326 dev->vv_callback(dev,isr); 324 dev->vv_callback(dev,isr);
327 }
328 isr &= ~MASK_28; 325 isr &= ~MASK_28;
329 } 326 }
330 if (0 != (isr & (MASK_16|MASK_17))) { 327 if (0 != (isr & (MASK_16|MASK_17))) {
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
index f0703d8bc3e8..171afe7da6b6 100644
--- a/drivers/media/common/saa7146_fops.c
+++ b/drivers/media/common/saa7146_fops.c
@@ -272,7 +272,7 @@ static int fops_open(struct inode *inode, struct file *file)
272 272
273 result = 0; 273 result = 0;
274out: 274out:
275 if( fh != 0 && result != 0 ) { 275 if (fh && result != 0) {
276 kfree(fh); 276 kfree(fh);
277 file->private_data = NULL; 277 file->private_data = NULL;
278 } 278 }
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index ed3f8268ed11..4c8b62e2c035 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -784,8 +784,8 @@ static int dvb_net_ts_callback(const u8 *buffer1, size_t buffer1_len,
784{ 784{
785 struct net_device *dev = feed->priv; 785 struct net_device *dev = feed->priv;
786 786
787 if (buffer2 != 0) 787 if (buffer2)
788 printk(KERN_WARNING "buffer2 not 0: %p.\n", buffer2); 788 printk(KERN_WARNING "buffer2 not NULL: %p.\n", buffer2);
789 if (buffer1_len > 32768) 789 if (buffer1_len > 32768)
790 printk(KERN_WARNING "length > 32k: %zu.\n", buffer1_len); 790 printk(KERN_WARNING "length > 32k: %zu.\n", buffer1_len);
791 /* printk("TS callback: %u bytes, %u TS cells @ %p.\n", 791 /* printk("TS callback: %u bytes, %u TS cells @ %p.\n",
diff --git a/drivers/media/dvb/dvb-usb/opera1.c b/drivers/media/dvb/dvb-usb/opera1.c
index 21935bf7059e..302cc67407c3 100644
--- a/drivers/media/dvb/dvb-usb/opera1.c
+++ b/drivers/media/dvb/dvb-usb/opera1.c
@@ -478,9 +478,9 @@ static int opera1_xilinx_load_firmware(struct usb_device *dev,
478 err("could not restart the USB controller CPU."); 478 err("could not restart the USB controller CPU.");
479 ret = -EINVAL; 479 ret = -EINVAL;
480 } 480 }
481 kfree(p);
482 } 481 }
483 } 482 }
483 kfree(p);
484 if (fw) { 484 if (fw) {
485 release_firmware(fw); 485 release_firmware(fw);
486 } 486 }
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
index 34e317ced5a3..57b9e3adc8f0 100644
--- a/drivers/media/radio/radio-cadet.c
+++ b/drivers/media/radio/radio-cadet.c
@@ -587,6 +587,8 @@ static struct video_device cadet_radio=
587 .vidioc_s_input = vidioc_s_input, 587 .vidioc_s_input = vidioc_s_input,
588}; 588};
589 589
590#ifdef CONFIG_PNP
591
590static struct pnp_device_id cadet_pnp_devices[] = { 592static struct pnp_device_id cadet_pnp_devices[] = {
591 /* ADS Cadet AM/FM Radio Card */ 593 /* ADS Cadet AM/FM Radio Card */
592 {.id = "MSM0c24", .driver_data = 0}, 594 {.id = "MSM0c24", .driver_data = 0},
@@ -621,6 +623,10 @@ static struct pnp_driver cadet_pnp_driver = {
621 .remove = NULL, 623 .remove = NULL,
622}; 624};
623 625
626#else
627static struct pnp_driver cadet_pnp_driver;
628#endif
629
624static int cadet_probe(void) 630static int cadet_probe(void)
625{ 631{
626 static int iovals[8]={0x330,0x332,0x334,0x336,0x338,0x33a,0x33c,0x33e}; 632 static int iovals[8]={0x330,0x332,0x334,0x336,0x338,0x33a,0x33c,0x33e};
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 37072a21d8c9..1832966f53f3 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -305,7 +305,7 @@ comment "MPEG video encoders"
305 305
306config VIDEO_CX2341X 306config VIDEO_CX2341X
307 tristate "Conexant CX2341x MPEG encoders" 307 tristate "Conexant CX2341x MPEG encoders"
308 depends on VIDEO_V4L2 && EXPERIMENTAL 308 depends on VIDEO_V4L2 && EXPERIMENTAL && VIDEO_V4L2_COMMON
309 ---help--- 309 ---help---
310 Support for the Conexant CX23416 MPEG encoders 310 Support for the Conexant CX23416 MPEG encoders
311 and CX23415 MPEG encoder/decoders. 311 and CX23415 MPEG encoder/decoders.
@@ -382,7 +382,7 @@ endmenu # encoder / decoder chips
382 382
383config VIDEO_VIVI 383config VIDEO_VIVI
384 tristate "Virtual Video Driver" 384 tristate "Virtual Video Driver"
385 depends on VIDEO_V4L2 && !SPARC32 && !SPARC64 385 depends on VIDEO_DEV && VIDEO_V4L2 && !SPARC32 && !SPARC64
386 select VIDEOBUF_VMALLOC 386 select VIDEOBUF_VMALLOC
387 default n 387 default n
388 ---help--- 388 ---help---
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c
index cbab53fc6243..fea2e723e34b 100644
--- a/drivers/media/video/adv7170.c
+++ b/drivers/media/video/adv7170.c
@@ -408,7 +408,7 @@ adv7170_detect_client (struct i2c_adapter *adapter,
408 return 0; 408 return 0;
409 409
410 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 410 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
411 if (client == 0) 411 if (!client)
412 return -ENOMEM; 412 return -ENOMEM;
413 client->addr = address; 413 client->addr = address;
414 client->adapter = adapter; 414 client->adapter = adapter;
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
index 0d0c554bfdf7..10d4d89623f1 100644
--- a/drivers/media/video/adv7175.c
+++ b/drivers/media/video/adv7175.c
@@ -426,7 +426,7 @@ adv7175_detect_client (struct i2c_adapter *adapter,
426 return 0; 426 return 0;
427 427
428 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 428 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
429 if (client == 0) 429 if (!client)
430 return -ENOMEM; 430 return -ENOMEM;
431 client->addr = address; 431 client->addr = address;
432 client->adapter = adapter; 432 client->adapter = adapter;
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c
index 12d1b9248be5..e663cc045c41 100644
--- a/drivers/media/video/bt819.c
+++ b/drivers/media/video/bt819.c
@@ -524,7 +524,7 @@ bt819_detect_client (struct i2c_adapter *adapter,
524 return 0; 524 return 0;
525 525
526 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 526 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
527 if (client == 0) 527 if (!client)
528 return -ENOMEM; 528 return -ENOMEM;
529 client->addr = address; 529 client->addr = address;
530 client->adapter = adapter; 530 client->adapter = adapter;
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c
index e1028a76c042..7dee2e3235ad 100644
--- a/drivers/media/video/bt856.c
+++ b/drivers/media/video/bt856.c
@@ -311,7 +311,7 @@ bt856_detect_client (struct i2c_adapter *adapter,
311 return 0; 311 return 0;
312 312
313 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 313 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
314 if (client == 0) 314 if (!client)
315 return -ENOMEM; 315 return -ENOMEM;
316 client->addr = address; 316 client->addr = address;
317 client->adapter = adapter; 317 client->adapter = adapter;
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 5404fcc5276d..fcf8f2d208a8 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -1990,7 +1990,7 @@ static int bttv_g_frequency(struct file *file, void *priv,
1990 if (0 != err) 1990 if (0 != err)
1991 return err; 1991 return err;
1992 1992
1993 f->type = V4L2_TUNER_ANALOG_TV; 1993 f->type = btv->radio_user ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1994 f->frequency = btv->freq; 1994 f->frequency = btv->freq;
1995 1995
1996 return 0; 1996 return 0;
@@ -2009,7 +2009,8 @@ static int bttv_s_frequency(struct file *file, void *priv,
2009 2009
2010 if (unlikely(f->tuner != 0)) 2010 if (unlikely(f->tuner != 0))
2011 return -EINVAL; 2011 return -EINVAL;
2012 if (unlikely(f->type != V4L2_TUNER_ANALOG_TV)) 2012 if (unlikely(f->type != (btv->radio_user
2013 ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV)))
2013 return -EINVAL; 2014 return -EINVAL;
2014 mutex_lock(&btv->lock); 2015 mutex_lock(&btv->lock);
2015 btv->freq = f->frequency; 2016 btv->freq = f->frequency;
@@ -3389,7 +3390,6 @@ static struct video_device bttv_video_template =
3389 .vidiocgmbuf = vidiocgmbuf, 3390 .vidiocgmbuf = vidiocgmbuf,
3390#endif 3391#endif
3391 .vidioc_g_crop = bttv_g_crop, 3392 .vidioc_g_crop = bttv_g_crop,
3392 .vidioc_g_crop = bttv_g_crop,
3393 .vidioc_s_crop = bttv_s_crop, 3393 .vidioc_s_crop = bttv_s_crop,
3394 .vidioc_g_fbuf = bttv_g_fbuf, 3394 .vidioc_g_fbuf = bttv_g_fbuf,
3395 .vidioc_s_fbuf = bttv_s_fbuf, 3395 .vidioc_s_fbuf = bttv_s_fbuf,
@@ -3416,6 +3416,7 @@ static int radio_open(struct inode *inode, struct file *file)
3416{ 3416{
3417 int minor = iminor(inode); 3417 int minor = iminor(inode);
3418 struct bttv *btv = NULL; 3418 struct bttv *btv = NULL;
3419 struct bttv_fh *fh;
3419 unsigned int i; 3420 unsigned int i;
3420 3421
3421 dprintk("bttv: open minor=%d\n",minor); 3422 dprintk("bttv: open minor=%d\n",minor);
@@ -3430,12 +3431,19 @@ static int radio_open(struct inode *inode, struct file *file)
3430 return -ENODEV; 3431 return -ENODEV;
3431 3432
3432 dprintk("bttv%d: open called (radio)\n",btv->c.nr); 3433 dprintk("bttv%d: open called (radio)\n",btv->c.nr);
3434
3435 /* allocate per filehandle data */
3436 fh = kmalloc(sizeof(*fh), GFP_KERNEL);
3437 if (NULL == fh)
3438 return -ENOMEM;
3439 file->private_data = fh;
3440 *fh = btv->init;
3441 v4l2_prio_open(&btv->prio, &fh->prio);
3442
3433 mutex_lock(&btv->lock); 3443 mutex_lock(&btv->lock);
3434 3444
3435 btv->radio_user++; 3445 btv->radio_user++;
3436 3446
3437 file->private_data = btv;
3438
3439 bttv_call_i2c_clients(btv,AUDC_SET_RADIO,NULL); 3447 bttv_call_i2c_clients(btv,AUDC_SET_RADIO,NULL);
3440 audio_input(btv,TVAUDIO_INPUT_RADIO); 3448 audio_input(btv,TVAUDIO_INPUT_RADIO);
3441 3449
@@ -3445,7 +3453,8 @@ static int radio_open(struct inode *inode, struct file *file)
3445 3453
3446static int radio_release(struct inode *inode, struct file *file) 3454static int radio_release(struct inode *inode, struct file *file)
3447{ 3455{
3448 struct bttv *btv = file->private_data; 3456 struct bttv_fh *fh = file->private_data;
3457 struct bttv *btv = fh->btv;
3449 struct rds_command cmd; 3458 struct rds_command cmd;
3450 3459
3451 btv->radio_user--; 3460 btv->radio_user--;
@@ -3509,8 +3518,12 @@ static int radio_enum_input(struct file *file, void *priv,
3509static int radio_g_audio(struct file *file, void *priv, 3518static int radio_g_audio(struct file *file, void *priv,
3510 struct v4l2_audio *a) 3519 struct v4l2_audio *a)
3511{ 3520{
3521 if (a->index != 0)
3522 return -EINVAL;
3523
3512 memset(a, 0, sizeof(*a)); 3524 memset(a, 0, sizeof(*a));
3513 strcpy(a->name, "Radio"); 3525 strcpy(a->name, "Radio");
3526
3514 return 0; 3527 return 0;
3515} 3528}
3516 3529
@@ -3570,7 +3583,8 @@ static int radio_g_input(struct file *filp, void *priv, unsigned int *i)
3570static ssize_t radio_read(struct file *file, char __user *data, 3583static ssize_t radio_read(struct file *file, char __user *data,
3571 size_t count, loff_t *ppos) 3584 size_t count, loff_t *ppos)
3572{ 3585{
3573 struct bttv *btv = file->private_data; 3586 struct bttv_fh *fh = file->private_data;
3587 struct bttv *btv = fh->btv;
3574 struct rds_command cmd; 3588 struct rds_command cmd;
3575 cmd.block_count = count/3; 3589 cmd.block_count = count/3;
3576 cmd.buffer = data; 3590 cmd.buffer = data;
@@ -3584,7 +3598,8 @@ static ssize_t radio_read(struct file *file, char __user *data,
3584 3598
3585static unsigned int radio_poll(struct file *file, poll_table *wait) 3599static unsigned int radio_poll(struct file *file, poll_table *wait)
3586{ 3600{
3587 struct bttv *btv = file->private_data; 3601 struct bttv_fh *fh = file->private_data;
3602 struct bttv *btv = fh->btv;
3588 struct rds_command cmd; 3603 struct rds_command cmd;
3589 cmd.instance = file; 3604 cmd.instance = file;
3590 cmd.event_list = wait; 3605 cmd.event_list = wait;
@@ -3600,6 +3615,7 @@ static const struct file_operations radio_fops =
3600 .open = radio_open, 3615 .open = radio_open,
3601 .read = radio_read, 3616 .read = radio_read,
3602 .release = radio_release, 3617 .release = radio_release,
3618 .compat_ioctl = v4l_compat_ioctl32,
3603 .ioctl = video_ioctl2, 3619 .ioctl = video_ioctl2,
3604 .llseek = no_llseek, 3620 .llseek = no_llseek,
3605 .poll = radio_poll, 3621 .poll = radio_poll,
diff --git a/drivers/media/video/cx23885/cx23885-cards.c b/drivers/media/video/cx23885/cx23885-cards.c
index 2d414dad5c31..dfa269838e01 100644
--- a/drivers/media/video/cx23885/cx23885-cards.c
+++ b/drivers/media/video/cx23885/cx23885-cards.c
@@ -232,6 +232,7 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
232 case 78631: /* WinTV-HVR1800 (PCIe, OEM, No IR, No FM, Dual channel ATSC and MPEG2 HW Encoder */ 232 case 78631: /* WinTV-HVR1800 (PCIe, OEM, No IR, No FM, Dual channel ATSC and MPEG2 HW Encoder */
233 case 79001: /* WinTV-HVR1250 (PCIe, Retail, IR, full height, ATSC and Basic analog */ 233 case 79001: /* WinTV-HVR1250 (PCIe, Retail, IR, full height, ATSC and Basic analog */
234 case 79101: /* WinTV-HVR1250 (PCIe, Retail, IR, half height, ATSC and Basic analog */ 234 case 79101: /* WinTV-HVR1250 (PCIe, Retail, IR, half height, ATSC and Basic analog */
235 case 79561: /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, ATSC and Basic analog */
235 case 79571: /* WinTV-HVR1250 (PCIe, OEM, No IR, full height, ATSC and Basic analog */ 236 case 79571: /* WinTV-HVR1250 (PCIe, OEM, No IR, full height, ATSC and Basic analog */
236 case 79671: /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, ATSC and Basic analog */ 237 case 79671: /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, ATSC and Basic analog */
237 break; 238 break;
@@ -347,10 +348,13 @@ void cx23885_card_setup(struct cx23885_dev *dev)
347 case CX23885_BOARD_HAUPPAUGE_HVR1250: 348 case CX23885_BOARD_HAUPPAUGE_HVR1250:
348 case CX23885_BOARD_HAUPPAUGE_HVR1500: 349 case CX23885_BOARD_HAUPPAUGE_HVR1500:
349 case CX23885_BOARD_HAUPPAUGE_HVR1500Q: 350 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
351 if (dev->i2c_bus[0].i2c_rc == 0)
352 hauppauge_eeprom(dev, eeprom+0x80);
353 break;
350 case CX23885_BOARD_HAUPPAUGE_HVR1800: 354 case CX23885_BOARD_HAUPPAUGE_HVR1800:
351 case CX23885_BOARD_HAUPPAUGE_HVR1800lp: 355 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
352 if (dev->i2c_bus[0].i2c_rc == 0) 356 if (dev->i2c_bus[0].i2c_rc == 0)
353 hauppauge_eeprom(dev, eeprom+0x80); 357 hauppauge_eeprom(dev, eeprom+0xc0);
354 break; 358 break;
355 } 359 }
356 360
diff --git a/drivers/media/video/cx23885/cx23885-core.c b/drivers/media/video/cx23885/cx23885-core.c
index 8e40c7bcc06d..7f10b273598f 100644
--- a/drivers/media/video/cx23885/cx23885-core.c
+++ b/drivers/media/video/cx23885/cx23885-core.c
@@ -56,137 +56,6 @@ LIST_HEAD(cx23885_devlist);
56 56
57#define NO_SYNC_LINE (-1U) 57#define NO_SYNC_LINE (-1U)
58 58
59/*
60 * CX23885 Assumptions
61 * 1 line = 16 bytes of CDT
62 * cmds size = 80
63 * cdt size = 16 * linesize
64 * iqsize = 64
65 * maxlines = 6
66 *
67 * Address Space:
68 * 0x00000000 0x00008fff FIFO clusters
69 * 0x00010000 0x000104af Channel Management Data Structures
70 * 0x000104b0 0x000104ff Free
71 * 0x00010500 0x000108bf 15 channels * iqsize
72 * 0x000108c0 0x000108ff Free
73 * 0x00010900 0x00010e9f IQ's + Cluster Descriptor Tables
74 * 15 channels * (iqsize + (maxlines * linesize))
75 * 0x00010ea0 0x00010xxx Free
76 */
77
78static struct sram_channel cx23885_sram_channels[] = {
79 [SRAM_CH01] = {
80 .name = "VID A",
81 .cmds_start = 0x10000,
82 .ctrl_start = 0x105b0,
83 .cdt = 0x107b0,
84 .fifo_start = 0x40,
85 .fifo_size = 0x2800,
86 .ptr1_reg = DMA1_PTR1,
87 .ptr2_reg = DMA1_PTR2,
88 .cnt1_reg = DMA1_CNT1,
89 .cnt2_reg = DMA1_CNT2,
90 .jumponly = 1,
91 },
92 [SRAM_CH02] = {
93 .name = "ch2",
94 .cmds_start = 0x0,
95 .ctrl_start = 0x0,
96 .cdt = 0x0,
97 .fifo_start = 0x0,
98 .fifo_size = 0x0,
99 .ptr1_reg = DMA2_PTR1,
100 .ptr2_reg = DMA2_PTR2,
101 .cnt1_reg = DMA2_CNT1,
102 .cnt2_reg = DMA2_CNT2,
103 },
104 [SRAM_CH03] = {
105 .name = "TS1 B",
106 .cmds_start = 0x100A0,
107 .ctrl_start = 0x10630,
108 .cdt = 0x10870,
109 .fifo_start = 0x5000,
110 .fifo_size = 0x1000,
111 .ptr1_reg = DMA3_PTR1,
112 .ptr2_reg = DMA3_PTR2,
113 .cnt1_reg = DMA3_CNT1,
114 .cnt2_reg = DMA3_CNT2,
115 },
116 [SRAM_CH04] = {
117 .name = "ch4",
118 .cmds_start = 0x0,
119 .ctrl_start = 0x0,
120 .cdt = 0x0,
121 .fifo_start = 0x0,
122 .fifo_size = 0x0,
123 .ptr1_reg = DMA4_PTR1,
124 .ptr2_reg = DMA4_PTR2,
125 .cnt1_reg = DMA4_CNT1,
126 .cnt2_reg = DMA4_CNT2,
127 },
128 [SRAM_CH05] = {
129 .name = "ch5",
130 .cmds_start = 0x0,
131 .ctrl_start = 0x0,
132 .cdt = 0x0,
133 .fifo_start = 0x0,
134 .fifo_size = 0x0,
135 .ptr1_reg = DMA5_PTR1,
136 .ptr2_reg = DMA5_PTR2,
137 .cnt1_reg = DMA5_CNT1,
138 .cnt2_reg = DMA5_CNT2,
139 },
140 [SRAM_CH06] = {
141 .name = "TS2 C",
142 .cmds_start = 0x10140,
143 .ctrl_start = 0x10680,
144 .cdt = 0x108d0,
145 .fifo_start = 0x6000,
146 .fifo_size = 0x1000,
147 .ptr1_reg = DMA5_PTR1,
148 .ptr2_reg = DMA5_PTR2,
149 .cnt1_reg = DMA5_CNT1,
150 .cnt2_reg = DMA5_CNT2,
151 },
152 [SRAM_CH07] = {
153 .name = "ch7",
154 .cmds_start = 0x0,
155 .ctrl_start = 0x0,
156 .cdt = 0x0,
157 .fifo_start = 0x0,
158 .fifo_size = 0x0,
159 .ptr1_reg = DMA6_PTR1,
160 .ptr2_reg = DMA6_PTR2,
161 .cnt1_reg = DMA6_CNT1,
162 .cnt2_reg = DMA6_CNT2,
163 },
164 [SRAM_CH08] = {
165 .name = "ch8",
166 .cmds_start = 0x0,
167 .ctrl_start = 0x0,
168 .cdt = 0x0,
169 .fifo_start = 0x0,
170 .fifo_size = 0x0,
171 .ptr1_reg = DMA7_PTR1,
172 .ptr2_reg = DMA7_PTR2,
173 .cnt1_reg = DMA7_CNT1,
174 .cnt2_reg = DMA7_CNT2,
175 },
176 [SRAM_CH09] = {
177 .name = "ch9",
178 .cmds_start = 0x0,
179 .ctrl_start = 0x0,
180 .cdt = 0x0,
181 .fifo_start = 0x0,
182 .fifo_size = 0x0,
183 .ptr1_reg = DMA8_PTR1,
184 .ptr2_reg = DMA8_PTR2,
185 .cnt1_reg = DMA8_CNT1,
186 .cnt2_reg = DMA8_CNT2,
187 },
188};
189
190/* FIXME, these allocations will change when 59/* FIXME, these allocations will change when
191 * analog arrives. The be reviewed. 60 * analog arrives. The be reviewed.
192 * CX23887 Assumptions 61 * CX23887 Assumptions
@@ -754,6 +623,7 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
754 atomic_inc(&dev->refcount); 623 atomic_inc(&dev->refcount);
755 624
756 dev->nr = cx23885_devcount++; 625 dev->nr = cx23885_devcount++;
626 dev->sram_channels = cx23887_sram_channels;
757 sprintf(dev->name, "cx23885[%d]", dev->nr); 627 sprintf(dev->name, "cx23885[%d]", dev->nr);
758 628
759 mutex_lock(&devlist); 629 mutex_lock(&devlist);
@@ -763,13 +633,11 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
763 /* Configure the internal memory */ 633 /* Configure the internal memory */
764 if(dev->pci->device == 0x8880) { 634 if(dev->pci->device == 0x8880) {
765 dev->bridge = CX23885_BRIDGE_887; 635 dev->bridge = CX23885_BRIDGE_887;
766 dev->sram_channels = cx23887_sram_channels;
767 /* Apply a sensible clock frequency for the PCIe bridge */ 636 /* Apply a sensible clock frequency for the PCIe bridge */
768 dev->clk_freq = 25000000; 637 dev->clk_freq = 25000000;
769 } else 638 } else
770 if(dev->pci->device == 0x8852) { 639 if(dev->pci->device == 0x8852) {
771 dev->bridge = CX23885_BRIDGE_885; 640 dev->bridge = CX23885_BRIDGE_885;
772 dev->sram_channels = cx23885_sram_channels;
773 /* Apply a sensible clock frequency for the PCIe bridge */ 641 /* Apply a sensible clock frequency for the PCIe bridge */
774 dev->clk_freq = 28000000; 642 dev->clk_freq = 28000000;
775 } else 643 } else
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index e6b7f518c56e..8c9a8adf52de 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -2196,6 +2196,11 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
2196 cx88_reset(core); 2196 cx88_reset(core);
2197 cx88_card_setup_pre_i2c(core); 2197 cx88_card_setup_pre_i2c(core);
2198 cx88_i2c_init(core, pci); 2198 cx88_i2c_init(core, pci);
2199
2200 /* load tuner module, if needed */
2201 if (TUNER_ABSENT != core->board.tuner_type)
2202 request_module("tuner");
2203
2199 cx88_call_i2c_clients (core, TUNER_SET_STANDBY, NULL); 2204 cx88_call_i2c_clients (core, TUNER_SET_STANDBY, NULL);
2200 cx88_card_setup(core); 2205 cx88_card_setup(core);
2201 cx88_ir_init(core, pci); 2206 cx88_ir_init(core, pci);
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 7f1931aed207..227179620d13 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -1826,8 +1826,6 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
1826 cx_set(MO_PCI_INTMSK, core->pci_irqmask); 1826 cx_set(MO_PCI_INTMSK, core->pci_irqmask);
1827 1827
1828 /* load and configure helper modules */ 1828 /* load and configure helper modules */
1829 if (TUNER_ABSENT != core->board.tuner_type)
1830 request_module("tuner");
1831 1829
1832 if (core->board.audio_chip == AUDIO_CHIP_WM8775) 1830 if (core->board.audio_chip == AUDIO_CHIP_WM8775)
1833 request_module("wm8775"); 1831 request_module("wm8775");
diff --git a/drivers/media/video/dpc7146.c b/drivers/media/video/dpc7146.c
index 566e479e2629..9ceb6b2f3949 100644
--- a/drivers/media/video/dpc7146.c
+++ b/drivers/media/video/dpc7146.c
@@ -131,7 +131,7 @@ static int dpc_probe(struct saa7146_dev* dev)
131 device_for_each_child(&dpc->i2c_adapter.dev, dpc, dpc_check_clients); 131 device_for_each_child(&dpc->i2c_adapter.dev, dpc, dpc_check_clients);
132 132
133 /* check if all devices are present */ 133 /* check if all devices are present */
134 if( 0 == dpc->saa7111a ) { 134 if (!dpc->saa7111a) {
135 DEB_D(("dpc_v4l2.o: dpc_attach failed for this device.\n")); 135 DEB_D(("dpc_v4l2.o: dpc_attach failed for this device.\n"));
136 i2c_del_adapter(&dpc->i2c_adapter); 136 i2c_del_adapter(&dpc->i2c_adapter);
137 kfree(dpc); 137 kfree(dpc);
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index 7d1537cab867..c1caaa855b99 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -267,7 +267,7 @@ static int em28xx_write_ac97(struct em28xx *dev, u8 reg, u8 *val)
267 for (i = 0; i < 10; i++) { 267 for (i = 0; i < 10; i++) {
268 if ((ret = em28xx_read_reg(dev, AC97BUSY_REG)) < 0) 268 if ((ret = em28xx_read_reg(dev, AC97BUSY_REG)) < 0)
269 return ret; 269 return ret;
270 if (!((u8) ret) & 0x01) 270 if (!(ret & 0x01))
271 return 0; 271 return 0;
272 msleep(5); 272 msleep(5);
273 } 273 }
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c
index d42f120354e5..948ca35e7ee8 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -54,7 +54,6 @@
54#include "ivtv-vbi.h" 54#include "ivtv-vbi.h"
55#include "ivtv-routing.h" 55#include "ivtv-routing.h"
56#include "ivtv-gpio.h" 56#include "ivtv-gpio.h"
57#include "ivtv-yuv.h"
58 57
59#include <media/tveeprom.h> 58#include <media/tveeprom.h>
60#include <media/saa7115.h> 59#include <media/saa7115.h>
@@ -700,6 +699,9 @@ static int __devinit ivtv_init_struct1(struct ivtv *itv)
700 itv->vbi.in.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; 699 itv->vbi.in.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
701 itv->vbi.sliced_in = &itv->vbi.in.fmt.sliced; 700 itv->vbi.sliced_in = &itv->vbi.in.fmt.sliced;
702 701
702 /* Init the sg table for osd/yuv output */
703 sg_init_table(itv->udma.SGlist, IVTV_DMA_SG_OSD_ENT);
704
703 /* OSD */ 705 /* OSD */
704 itv->osd_global_alpha_state = 1; 706 itv->osd_global_alpha_state = 1;
705 itv->osd_global_alpha = 255; 707 itv->osd_global_alpha = 255;
@@ -1053,9 +1055,6 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
1053 goto free_io; 1055 goto free_io;
1054 } 1056 }
1055 1057
1056 /* Check yuv output filter table */
1057 if (itv->has_cx23415) ivtv_yuv_filter_check(itv);
1058
1059 ivtv_gpio_init(itv); 1058 ivtv_gpio_init(itv);
1060 1059
1061 /* active i2c */ 1060 /* active i2c */
diff --git a/drivers/media/video/ivtv/ivtv-firmware.c b/drivers/media/video/ivtv/ivtv-firmware.c
index 425eb1063904..6dba55b7e25a 100644
--- a/drivers/media/video/ivtv/ivtv-firmware.c
+++ b/drivers/media/video/ivtv/ivtv-firmware.c
@@ -22,6 +22,7 @@
22#include "ivtv-driver.h" 22#include "ivtv-driver.h"
23#include "ivtv-mailbox.h" 23#include "ivtv-mailbox.h"
24#include "ivtv-firmware.h" 24#include "ivtv-firmware.h"
25#include "ivtv-yuv.h"
25#include <linux/firmware.h> 26#include <linux/firmware.h>
26 27
27#define IVTV_MASK_SPU_ENABLE 0xFFFFFFFE 28#define IVTV_MASK_SPU_ENABLE 0xFFFFFFFE
@@ -225,11 +226,14 @@ int ivtv_firmware_init(struct ivtv *itv)
225 return 0; 226 return 0;
226 227
227 itv->dec_mbox.mbox = ivtv_search_mailbox(itv->dec_mem, IVTV_DECODER_SIZE); 228 itv->dec_mbox.mbox = ivtv_search_mailbox(itv->dec_mem, IVTV_DECODER_SIZE);
228 if (itv->dec_mbox.mbox == NULL) 229 if (itv->dec_mbox.mbox == NULL) {
229 IVTV_ERR("Decoder mailbox not found\n"); 230 IVTV_ERR("Decoder mailbox not found\n");
230 else if (itv->has_cx23415 && ivtv_vapi(itv, CX2341X_DEC_PING_FW, 0)) { 231 } else if (itv->has_cx23415 && ivtv_vapi(itv, CX2341X_DEC_PING_FW, 0)) {
231 IVTV_ERR("Decoder firmware dead!\n"); 232 IVTV_ERR("Decoder firmware dead!\n");
232 itv->dec_mbox.mbox = NULL; 233 itv->dec_mbox.mbox = NULL;
234 } else {
235 /* Firmware okay, so check yuv output filter table */
236 ivtv_yuv_filter_check(itv);
233 } 237 }
234 return itv->dec_mbox.mbox ? 0 : -ENODEV; 238 return itv->dec_mbox.mbox ? 0 : -ENODEV;
235} 239}
diff --git a/drivers/media/video/mt20xx.c b/drivers/media/video/mt20xx.c
index 58bab653330f..74fd6a01d4c4 100644
--- a/drivers/media/video/mt20xx.c
+++ b/drivers/media/video/mt20xx.c
@@ -647,7 +647,7 @@ struct dvb_frontend *microtune_attach(struct dvb_frontend *fe,
647 default: 647 default:
648 tuner_info("microtune %s found, not (yet?) supported, sorry :-/\n", 648 tuner_info("microtune %s found, not (yet?) supported, sorry :-/\n",
649 name); 649 name);
650 return 0; 650 return NULL;
651 } 651 }
652 652
653 strlcpy(fe->ops.tuner_ops.info.name, name, 653 strlcpy(fe->ops.tuner_ops.info.name, name,
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c
index add6d0d680be..cb5a510f9251 100644
--- a/drivers/media/video/mxb.c
+++ b/drivers/media/video/mxb.c
@@ -221,9 +221,8 @@ static int mxb_probe(struct saa7146_dev* dev)
221 device_for_each_child(&mxb->i2c_adapter.dev, mxb, mxb_check_clients); 221 device_for_each_child(&mxb->i2c_adapter.dev, mxb, mxb_check_clients);
222 222
223 /* check if all devices are present */ 223 /* check if all devices are present */
224 if( 0 == mxb->tea6420_1 || 0 == mxb->tea6420_2 || 0 == mxb->tea6415c 224 if (!mxb->tea6420_1 || !mxb->tea6420_2 || !mxb->tea6415c ||
225 || 0 == mxb->tda9840 || 0 == mxb->saa7111a || 0 == mxb->tuner ) { 225 !mxb->tda9840 || !mxb->saa7111a || !mxb->tuner) {
226
227 printk("mxb: did not find all i2c devices. aborting\n"); 226 printk("mxb: did not find all i2c devices. aborting\n");
228 i2c_del_adapter(&mxb->i2c_adapter); 227 i2c_del_adapter(&mxb->i2c_adapter);
229 kfree(mxb); 228 kfree(mxb);
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
index 46f156fb108c..5a3e8d21a38a 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
@@ -60,7 +60,7 @@ int pvr2_ctrl_set_mask_value(struct pvr2_ctrl *cptr,int mask,int val)
60 int ret = 0; 60 int ret = 0;
61 if (!cptr) return -EINVAL; 61 if (!cptr) return -EINVAL;
62 LOCK_TAKE(cptr->hdw->big_lock); do { 62 LOCK_TAKE(cptr->hdw->big_lock); do {
63 if (cptr->info->set_value != 0) { 63 if (cptr->info->set_value) {
64 if (cptr->info->type == pvr2_ctl_bitmask) { 64 if (cptr->info->type == pvr2_ctl_bitmask) {
65 mask &= cptr->info->def.type_bitmask.valid_bits; 65 mask &= cptr->info->def.type_bitmask.valid_bits;
66 } else if (cptr->info->type == pvr2_ctl_int) { 66 } else if (cptr->info->type == pvr2_ctl_int) {
@@ -265,7 +265,7 @@ unsigned int pvr2_ctrl_get_v4lflags(struct pvr2_ctrl *cptr)
265int pvr2_ctrl_is_writable(struct pvr2_ctrl *cptr) 265int pvr2_ctrl_is_writable(struct pvr2_ctrl *cptr)
266{ 266{
267 if (!cptr) return 0; 267 if (!cptr) return 0;
268 return cptr->info->set_value != 0; 268 return cptr->info->set_value != NULL;
269} 269}
270 270
271 271
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 41ae980405ed..d6955fa39598 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -2291,7 +2291,7 @@ static int pvr2_hdw_commit_setup(struct pvr2_hdw *hdw)
2291 2291
2292 for (idx = 0; idx < hdw->control_cnt; idx++) { 2292 for (idx = 0; idx < hdw->control_cnt; idx++) {
2293 cptr = hdw->controls + idx; 2293 cptr = hdw->controls + idx;
2294 if (cptr->info->is_dirty == 0) continue; 2294 if (!cptr->info->is_dirty) continue;
2295 if (!cptr->info->is_dirty(cptr)) continue; 2295 if (!cptr->info->is_dirty(cptr)) continue;
2296 commit_flag = !0; 2296 commit_flag = !0;
2297 2297
@@ -2646,7 +2646,7 @@ void pvr2_hdw_cpufw_set_enabled(struct pvr2_hdw *hdw,
2646 u16 address; 2646 u16 address;
2647 unsigned int pipe; 2647 unsigned int pipe;
2648 LOCK_TAKE(hdw->big_lock); do { 2648 LOCK_TAKE(hdw->big_lock); do {
2649 if ((hdw->fw_buffer == 0) == !enable_flag) break; 2649 if ((hdw->fw_buffer == NULL) == !enable_flag) break;
2650 2650
2651 if (!enable_flag) { 2651 if (!enable_flag) {
2652 pvr2_trace(PVR2_TRACE_FIRMWARE, 2652 pvr2_trace(PVR2_TRACE_FIRMWARE,
@@ -2715,7 +2715,7 @@ void pvr2_hdw_cpufw_set_enabled(struct pvr2_hdw *hdw,
2715/* Return true if we're in a mode for retrieval CPU firmware */ 2715/* Return true if we're in a mode for retrieval CPU firmware */
2716int pvr2_hdw_cpufw_get_enabled(struct pvr2_hdw *hdw) 2716int pvr2_hdw_cpufw_get_enabled(struct pvr2_hdw *hdw)
2717{ 2717{
2718 return hdw->fw_buffer != 0; 2718 return hdw->fw_buffer != NULL;
2719} 2719}
2720 2720
2721 2721
diff --git a/drivers/media/video/pvrusb2/pvrusb2-io.c b/drivers/media/video/pvrusb2/pvrusb2-io.c
index ce3c8982ffe0..a9889ff96ecc 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-io.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-io.c
@@ -563,7 +563,7 @@ void pvr2_stream_kill(struct pvr2_stream *sp)
563 struct pvr2_buffer *bp; 563 struct pvr2_buffer *bp;
564 mutex_lock(&sp->mutex); do { 564 mutex_lock(&sp->mutex); do {
565 pvr2_stream_internal_flush(sp); 565 pvr2_stream_internal_flush(sp);
566 while ((bp = pvr2_stream_get_ready_buffer(sp)) != 0) { 566 while ((bp = pvr2_stream_get_ready_buffer(sp)) != NULL) {
567 pvr2_buffer_set_idle(bp); 567 pvr2_buffer_set_idle(bp);
568 } 568 }
569 if (sp->buffer_total_count != sp->buffer_target_count) { 569 if (sp->buffer_total_count != sp->buffer_target_count) {
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ioread.c b/drivers/media/video/pvrusb2/pvrusb2-ioread.c
index f782418afa45..c572212c9f15 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-ioread.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-ioread.c
@@ -165,7 +165,7 @@ static int pvr2_ioread_start(struct pvr2_ioread *cp)
165 if (!(cp->stream)) return 0; 165 if (!(cp->stream)) return 0;
166 pvr2_trace(PVR2_TRACE_START_STOP, 166 pvr2_trace(PVR2_TRACE_START_STOP,
167 "/*---TRACE_READ---*/ pvr2_ioread_start id=%p",cp); 167 "/*---TRACE_READ---*/ pvr2_ioread_start id=%p",cp);
168 while ((bp = pvr2_stream_get_idle_buffer(cp->stream)) != 0) { 168 while ((bp = pvr2_stream_get_idle_buffer(cp->stream)) != NULL) {
169 stat = pvr2_buffer_queue(bp); 169 stat = pvr2_buffer_queue(bp);
170 if (stat < 0) { 170 if (stat < 0) {
171 pvr2_trace(PVR2_TRACE_DATA_FLOW, 171 pvr2_trace(PVR2_TRACE_DATA_FLOW,
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index f991d72fe108..e0a453a6543d 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -915,7 +915,7 @@ static void pwc_iso_stop(struct pwc_device *pdev)
915 struct urb *urb; 915 struct urb *urb;
916 916
917 urb = pdev->sbuf[i].urb; 917 urb = pdev->sbuf[i].urb;
918 if (urb != 0) { 918 if (urb) {
919 PWC_DEBUG_MEMORY("Unlinking URB %p\n", urb); 919 PWC_DEBUG_MEMORY("Unlinking URB %p\n", urb);
920 usb_kill_urb(urb); 920 usb_kill_urb(urb);
921 } 921 }
@@ -931,7 +931,7 @@ static void pwc_iso_free(struct pwc_device *pdev)
931 struct urb *urb; 931 struct urb *urb;
932 932
933 urb = pdev->sbuf[i].urb; 933 urb = pdev->sbuf[i].urb;
934 if (urb != 0) { 934 if (urb) {
935 PWC_DEBUG_MEMORY("Freeing URB\n"); 935 PWC_DEBUG_MEMORY("Freeing URB\n");
936 usb_free_urb(urb); 936 usb_free_urb(urb);
937 pdev->sbuf[i].urb = NULL; 937 pdev->sbuf[i].urb = NULL;
@@ -1759,8 +1759,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1759 1759
1760 /* Allocate video_device structure */ 1760 /* Allocate video_device structure */
1761 pdev->vdev = video_device_alloc(); 1761 pdev->vdev = video_device_alloc();
1762 if (pdev->vdev == 0) 1762 if (!pdev->vdev) {
1763 {
1764 PWC_ERROR("Err, cannot allocate video_device struture. Failing probe."); 1763 PWC_ERROR("Err, cannot allocate video_device struture. Failing probe.");
1765 kfree(pdev); 1764 kfree(pdev);
1766 return -ENOMEM; 1765 return -ENOMEM;
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c
index 061134a7ba9f..1df2602cd184 100644
--- a/drivers/media/video/saa7110.c
+++ b/drivers/media/video/saa7110.c
@@ -488,7 +488,7 @@ saa7110_detect_client (struct i2c_adapter *adapter,
488 return 0; 488 return 0;
489 489
490 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 490 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
491 if (client == 0) 491 if (!client)
492 return -ENOMEM; 492 return -ENOMEM;
493 client->addr = address; 493 client->addr = address;
494 client->adapter = adapter; 494 client->adapter = adapter;
@@ -496,7 +496,7 @@ saa7110_detect_client (struct i2c_adapter *adapter,
496 strlcpy(I2C_NAME(client), "saa7110", sizeof(I2C_NAME(client))); 496 strlcpy(I2C_NAME(client), "saa7110", sizeof(I2C_NAME(client)));
497 497
498 decoder = kzalloc(sizeof(struct saa7110), GFP_KERNEL); 498 decoder = kzalloc(sizeof(struct saa7110), GFP_KERNEL);
499 if (decoder == 0) { 499 if (!decoder) {
500 kfree(client); 500 kfree(client);
501 return -ENOMEM; 501 return -ENOMEM;
502 } 502 }
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c
index 7ae2d646d000..a0772c53bb1f 100644
--- a/drivers/media/video/saa7111.c
+++ b/drivers/media/video/saa7111.c
@@ -502,7 +502,7 @@ saa7111_detect_client (struct i2c_adapter *adapter,
502 return 0; 502 return 0;
503 503
504 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 504 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
505 if (client == 0) 505 if (!client)
506 return -ENOMEM; 506 return -ENOMEM;
507 client->addr = address; 507 client->addr = address;
508 client->adapter = adapter; 508 client->adapter = adapter;
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c
index 677df51de1a9..bf91a4faa706 100644
--- a/drivers/media/video/saa7114.c
+++ b/drivers/media/video/saa7114.c
@@ -841,7 +841,7 @@ saa7114_detect_client (struct i2c_adapter *adapter,
841 return 0; 841 return 0;
842 842
843 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 843 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
844 if (client == 0) 844 if (!client)
845 return -ENOMEM; 845 return -ENOMEM;
846 client->addr = address; 846 client->addr = address;
847 client->adapter = adapter; 847 client->adapter = adapter;
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index 262830da08c8..6f5744286e8c 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -2484,27 +2484,28 @@ struct saa7134_board saa7134_boards[] = {
2484 .tuner_addr = ADDR_UNSET, 2484 .tuner_addr = ADDR_UNSET,
2485 .radio_addr = ADDR_UNSET, 2485 .radio_addr = ADDR_UNSET,
2486 .gpiomask = 0x080200000, 2486 .gpiomask = 0x080200000,
2487 .inputs = {{ 2487 .inputs = { {
2488 .name = name_tv, 2488 .name = name_tv,
2489 .vmux = 4, 2489 .vmux = 4,
2490 .amux = TV, 2490 .amux = TV,
2491 .tv = 1, 2491 .tv = 1,
2492 },{ 2492 }, {
2493 .name = name_comp1, 2493 .name = name_comp1,
2494 .vmux = 1, 2494 .vmux = 1,
2495 .amux = LINE2, 2495 .amux = LINE2,
2496 },{ 2496 }, {
2497 .name = name_comp2, 2497 .name = name_comp2,
2498 .vmux = 0, 2498 .vmux = 0,
2499 .amux = LINE2, 2499 .amux = LINE2,
2500 },{ 2500 }, {
2501 .name = name_svideo, 2501 .name = name_svideo,
2502 .vmux = 8, 2502 .vmux = 8,
2503 .amux = LINE2, 2503 .amux = LINE2,
2504 }}, 2504 } },
2505 .radio = { 2505 .radio = {
2506 .name = name_radio, 2506 .name = name_radio,
2507 .amux = LINE1, 2507 .amux = TV,
2508 .gpio = 0x0200000,
2508 }, 2509 },
2509 }, 2510 },
2510 [SAA7134_BOARD_ASUSTeK_P7131_DUAL] = { 2511 [SAA7134_BOARD_ASUSTeK_P7131_DUAL] = {
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index 52baa4f7f7dd..58ab163fdbd7 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -1022,12 +1022,13 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
1022 saa7134_i2c_register(dev); 1022 saa7134_i2c_register(dev);
1023 1023
1024 /* initialize hardware #2 */ 1024 /* initialize hardware #2 */
1025 if (TUNER_ABSENT != dev->tuner_type)
1026 request_module("tuner");
1025 saa7134_board_init2(dev); 1027 saa7134_board_init2(dev);
1028
1026 saa7134_hwinit2(dev); 1029 saa7134_hwinit2(dev);
1027 1030
1028 /* load i2c helpers */ 1031 /* load i2c helpers */
1029 if (TUNER_ABSENT != dev->tuner_type)
1030 request_module("tuner");
1031 if (card_is_empress(dev)) { 1032 if (card_is_empress(dev)) {
1032 request_module("saa6752hs"); 1033 request_module("saa6752hs");
1033 } 1034 }
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c
index 66cc92c0ea66..41f70440fd3b 100644
--- a/drivers/media/video/saa7185.c
+++ b/drivers/media/video/saa7185.c
@@ -403,7 +403,7 @@ saa7185_detect_client (struct i2c_adapter *adapter,
403 return 0; 403 return 0;
404 404
405 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 405 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
406 if (client == 0) 406 if (!client)
407 return -ENOMEM; 407 return -ENOMEM;
408 client->addr = address; 408 client->addr = address;
409 client->adapter = adapter; 409 client->adapter = adapter;
diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c
index ef494febb5e4..bdca5d278978 100644
--- a/drivers/media/video/tda9840.c
+++ b/drivers/media/video/tda9840.c
@@ -172,7 +172,7 @@ static int detect(struct i2c_adapter *adapter, int address, int kind)
172 172
173 /* allocate memory for client structure */ 173 /* allocate memory for client structure */
174 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 174 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
175 if (0 == client) { 175 if (!client) {
176 printk("not enough kernel memory\n"); 176 printk("not enough kernel memory\n");
177 return -ENOMEM; 177 return -ENOMEM;
178 } 178 }
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c
index 523df0b8cc63..df2fad9f391e 100644
--- a/drivers/media/video/tea6415c.c
+++ b/drivers/media/video/tea6415c.c
@@ -64,7 +64,7 @@ static int detect(struct i2c_adapter *adapter, int address, int kind)
64 64
65 /* allocate memory for client structure */ 65 /* allocate memory for client structure */
66 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 66 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
67 if (0 == client) { 67 if (!client) {
68 return -ENOMEM; 68 return -ENOMEM;
69 } 69 }
70 70
diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c
index ca05cd655087..4ff6c63f7237 100644
--- a/drivers/media/video/tea6420.c
+++ b/drivers/media/video/tea6420.c
@@ -101,7 +101,7 @@ static int tea6420_detect(struct i2c_adapter *adapter, int address, int kind)
101 101
102 /* allocate memory for client structure */ 102 /* allocate memory for client structure */
103 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 103 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
104 if (0 == client) { 104 if (!client) {
105 return -ENOMEM; 105 return -ENOMEM;
106 } 106 }
107 107
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c
index 445eba4174d7..b6e24e714a23 100644
--- a/drivers/media/video/tvp5150.c
+++ b/drivers/media/video/tvp5150.c
@@ -672,7 +672,7 @@ static int tvp5150_set_vbi(struct i2c_client *c,
672 if (std == V4L2_STD_ALL) { 672 if (std == V4L2_STD_ALL) {
673 tvp5150_err("VBI can't be configured without knowing number of lines\n"); 673 tvp5150_err("VBI can't be configured without knowing number of lines\n");
674 return 0; 674 return 0;
675 } else if (std && V4L2_STD_625_50) { 675 } else if (std & V4L2_STD_625_50) {
676 /* Don't follow NTSC Line number convension */ 676 /* Don't follow NTSC Line number convension */
677 line += 3; 677 line += 3;
678 } 678 }
@@ -719,7 +719,7 @@ static int tvp5150_get_vbi(struct i2c_client *c,
719 if (std == V4L2_STD_ALL) { 719 if (std == V4L2_STD_ALL) {
720 tvp5150_err("VBI can't be configured without knowing number of lines\n"); 720 tvp5150_err("VBI can't be configured without knowing number of lines\n");
721 return 0; 721 return 0;
722 } else if (std && V4L2_STD_625_50) { 722 } else if (std & V4L2_STD_625_50) {
723 /* Don't follow NTSC Line number convension */ 723 /* Don't follow NTSC Line number convension */
724 line += 3; 724 line += 3;
725 } 725 }
@@ -1072,12 +1072,12 @@ static int tvp5150_detect_client(struct i2c_adapter *adapter,
1072 return 0; 1072 return 0;
1073 1073
1074 c = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 1074 c = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
1075 if (c == 0) 1075 if (!c)
1076 return -ENOMEM; 1076 return -ENOMEM;
1077 memcpy(c, &client_template, sizeof(struct i2c_client)); 1077 memcpy(c, &client_template, sizeof(struct i2c_client));
1078 1078
1079 core = kzalloc(sizeof(struct tvp5150), GFP_KERNEL); 1079 core = kzalloc(sizeof(struct tvp5150), GFP_KERNEL);
1080 if (core == 0) { 1080 if (!core) {
1081 kfree(c); 1081 kfree(c);
1082 return -ENOMEM; 1082 return -ENOMEM;
1083 } 1083 }
diff --git a/drivers/media/video/usbvideo/usbvideo.c b/drivers/media/video/usbvideo/usbvideo.c
index fb434b5602a3..5d363be7bc73 100644
--- a/drivers/media/video/usbvideo/usbvideo.c
+++ b/drivers/media/video/usbvideo/usbvideo.c
@@ -1034,6 +1034,11 @@ int usbvideo_RegisterVideoDevice(struct uvd *uvd)
1034 info("%s: iface=%d. endpoint=$%02x paletteBits=$%08lx", 1034 info("%s: iface=%d. endpoint=$%02x paletteBits=$%08lx",
1035 __FUNCTION__, uvd->iface, uvd->video_endp, uvd->paletteBits); 1035 __FUNCTION__, uvd->iface, uvd->video_endp, uvd->paletteBits);
1036 } 1036 }
1037 if (uvd->dev == NULL) {
1038 err("%s: uvd->dev == NULL", __FUNCTION__);
1039 return -EINVAL;
1040 }
1041 uvd->vdev.dev=&(uvd->dev->dev);
1037 if (video_register_device(&uvd->vdev, VFL_TYPE_GRABBER, video_nr) == -1) { 1042 if (video_register_device(&uvd->vdev, VFL_TYPE_GRABBER, video_nr) == -1) {
1038 err("%s: video_register_device failed", __FUNCTION__); 1043 err("%s: video_register_device failed", __FUNCTION__);
1039 return -EPIPE; 1044 return -EPIPE;
@@ -1041,10 +1046,6 @@ int usbvideo_RegisterVideoDevice(struct uvd *uvd)
1041 if (uvd->debug > 1) { 1046 if (uvd->debug > 1) {
1042 info("%s: video_register_device() successful", __FUNCTION__); 1047 info("%s: video_register_device() successful", __FUNCTION__);
1043 } 1048 }
1044 if (uvd->dev == NULL) {
1045 err("%s: uvd->dev == NULL", __FUNCTION__);
1046 return -EINVAL;
1047 }
1048 1049
1049 info("%s on /dev/video%d: canvas=%s videosize=%s", 1050 info("%s on /dev/video%d: canvas=%s videosize=%s",
1050 (uvd->handle != NULL) ? uvd->handle->drvName : "???", 1051 (uvd->handle != NULL) ? uvd->handle->drvName : "???",
diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c
index dcf22a3b672a..50e1ff9f2be5 100644
--- a/drivers/media/video/v4l1-compat.c
+++ b/drivers/media/video/v4l1-compat.c
@@ -303,7 +303,11 @@ v4l_compat_translate_ioctl(struct inode *inode,
303 { 303 {
304 struct video_capability *cap = arg; 304 struct video_capability *cap = arg;
305 305
306 cap2 = kzalloc(sizeof(*cap2),GFP_KERNEL); 306 cap2 = kzalloc(sizeof(*cap2), GFP_KERNEL);
307 if (!cap2) {
308 err = -ENOMEM;
309 break;
310 }
307 memset(cap, 0, sizeof(*cap)); 311 memset(cap, 0, sizeof(*cap));
308 memset(&fbuf2, 0, sizeof(fbuf2)); 312 memset(&fbuf2, 0, sizeof(fbuf2));
309 313
@@ -426,7 +430,11 @@ v4l_compat_translate_ioctl(struct inode *inode,
426 { 430 {
427 struct video_window *win = arg; 431 struct video_window *win = arg;
428 432
429 fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL); 433 fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL);
434 if (!fmt2) {
435 err = -ENOMEM;
436 break;
437 }
430 memset(win,0,sizeof(*win)); 438 memset(win,0,sizeof(*win));
431 439
432 fmt2->type = V4L2_BUF_TYPE_VIDEO_OVERLAY; 440 fmt2->type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
@@ -464,7 +472,11 @@ v4l_compat_translate_ioctl(struct inode *inode,
464 struct video_window *win = arg; 472 struct video_window *win = arg;
465 int err1,err2; 473 int err1,err2;
466 474
467 fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL); 475 fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL);
476 if (!fmt2) {
477 err = -ENOMEM;
478 break;
479 }
468 fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 480 fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
469 drv(inode, file, VIDIOC_STREAMOFF, &fmt2->type); 481 drv(inode, file, VIDIOC_STREAMOFF, &fmt2->type);
470 err1 = drv(inode, file, VIDIOC_G_FMT, fmt2); 482 err1 = drv(inode, file, VIDIOC_G_FMT, fmt2);
@@ -586,6 +598,12 @@ v4l_compat_translate_ioctl(struct inode *inode,
586 { 598 {
587 struct video_picture *pict = arg; 599 struct video_picture *pict = arg;
588 600
601 fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL);
602 if (!fmt2) {
603 err = -ENOMEM;
604 break;
605 }
606
589 pict->brightness = get_v4l_control(inode, file, 607 pict->brightness = get_v4l_control(inode, file,
590 V4L2_CID_BRIGHTNESS,drv); 608 V4L2_CID_BRIGHTNESS,drv);
591 pict->hue = get_v4l_control(inode, file, 609 pict->hue = get_v4l_control(inode, file,
@@ -597,7 +615,6 @@ v4l_compat_translate_ioctl(struct inode *inode,
597 pict->whiteness = get_v4l_control(inode, file, 615 pict->whiteness = get_v4l_control(inode, file,
598 V4L2_CID_WHITENESS, drv); 616 V4L2_CID_WHITENESS, drv);
599 617
600 fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL);
601 fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 618 fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
602 err = drv(inode, file, VIDIOC_G_FMT, fmt2); 619 err = drv(inode, file, VIDIOC_G_FMT, fmt2);
603 if (err < 0) { 620 if (err < 0) {
@@ -617,6 +634,11 @@ v4l_compat_translate_ioctl(struct inode *inode,
617 struct video_picture *pict = arg; 634 struct video_picture *pict = arg;
618 int mem_err = 0, ovl_err = 0; 635 int mem_err = 0, ovl_err = 0;
619 636
637 fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL);
638 if (!fmt2) {
639 err = -ENOMEM;
640 break;
641 }
620 memset(&fbuf2, 0, sizeof(fbuf2)); 642 memset(&fbuf2, 0, sizeof(fbuf2));
621 643
622 set_v4l_control(inode, file, 644 set_v4l_control(inode, file,
@@ -636,7 +658,6 @@ v4l_compat_translate_ioctl(struct inode *inode,
636 * different pixel formats for memory vs overlay. 658 * different pixel formats for memory vs overlay.
637 */ 659 */
638 660
639 fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL);
640 fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 661 fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
641 err = drv(inode, file, VIDIOC_G_FMT, fmt2); 662 err = drv(inode, file, VIDIOC_G_FMT, fmt2);
642 /* If VIDIOC_G_FMT failed, then the driver likely doesn't 663 /* If VIDIOC_G_FMT failed, then the driver likely doesn't
@@ -890,7 +911,11 @@ v4l_compat_translate_ioctl(struct inode *inode,
890 { 911 {
891 struct video_mmap *mm = arg; 912 struct video_mmap *mm = arg;
892 913
893 fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL); 914 fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL);
915 if (!fmt2) {
916 err = -ENOMEM;
917 break;
918 }
894 memset(&buf2,0,sizeof(buf2)); 919 memset(&buf2,0,sizeof(buf2));
895 920
896 fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 921 fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -986,7 +1011,11 @@ v4l_compat_translate_ioctl(struct inode *inode,
986 { 1011 {
987 struct vbi_format *fmt = arg; 1012 struct vbi_format *fmt = arg;
988 1013
989 fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL); 1014 fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL);
1015 if (!fmt2) {
1016 err = -ENOMEM;
1017 break;
1018 }
990 fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE; 1019 fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE;
991 1020
992 err = drv(inode, file, VIDIOC_G_FMT, fmt2); 1021 err = drv(inode, file, VIDIOC_G_FMT, fmt2);
@@ -1018,8 +1047,11 @@ v4l_compat_translate_ioctl(struct inode *inode,
1018 break; 1047 break;
1019 } 1048 }
1020 1049
1021 fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL); 1050 fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL);
1022 1051 if (!fmt2) {
1052 err = -ENOMEM;
1053 break;
1054 }
1023 fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE; 1055 fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE;
1024 fmt2->fmt.vbi.samples_per_line = fmt->samples_per_line; 1056 fmt2->fmt.vbi.samples_per_line = fmt->samples_per_line;
1025 fmt2->fmt.vbi.sampling_rate = fmt->sampling_rate; 1057 fmt2->fmt.vbi.sampling_rate = fmt->sampling_rate;
diff --git a/drivers/media/video/v4l2-int-device.c b/drivers/media/video/v4l2-int-device.c
index a545dcaf857f..0e4549922f26 100644
--- a/drivers/media/video/v4l2-int-device.c
+++ b/drivers/media/video/v4l2-int-device.c
@@ -156,3 +156,5 @@ int v4l2_int_ioctl_1(struct v4l2_int_device *d, int cmd, void *arg)
156 find_ioctl(d->u.slave, cmd, 156 find_ioctl(d->u.slave, cmd,
157 (v4l2_int_ioctl_func *)no_such_ioctl_1))(d, arg); 157 (v4l2_int_ioctl_func *)no_such_ioctl_1))(d, arg);
158} 158}
159
160MODULE_LICENSE("GPL");
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index dd3d7d2c8b0e..fea4946ee713 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -339,7 +339,7 @@ v4l_fbuffer_alloc (struct file *file)
339 /* Use kmalloc */ 339 /* Use kmalloc */
340 340
341 mem = kmalloc(fh->v4l_buffers.buffer_size, GFP_KERNEL); 341 mem = kmalloc(fh->v4l_buffers.buffer_size, GFP_KERNEL);
342 if (mem == 0) { 342 if (!mem) {
343 dprintk(1, 343 dprintk(1,
344 KERN_ERR 344 KERN_ERR
345 "%s: v4l_fbuffer_alloc() - kmalloc for V4L buf %d failed\n", 345 "%s: v4l_fbuffer_alloc() - kmalloc for V4L buf %d failed\n",
diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c
index 1b44784d0efb..04949c823654 100644
--- a/drivers/media/video/zr364xx.c
+++ b/drivers/media/video/zr364xx.c
@@ -390,7 +390,7 @@ static int read_frame(struct zr364xx_camera *cam, int framenum)
390} 390}
391 391
392 392
393static ssize_t zr364xx_read(struct file *file, char *buf, size_t cnt, 393static ssize_t zr364xx_read(struct file *file, char __user *buf, size_t cnt,
394 loff_t * ppos) 394 loff_t * ppos)
395{ 395{
396 unsigned long count = cnt; 396 unsigned long count = cnt;
diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c
index de80dba12f9b..946e3d3506ac 100644
--- a/drivers/memstick/core/memstick.c
+++ b/drivers/memstick/core/memstick.c
@@ -276,8 +276,6 @@ void memstick_init_req_sg(struct memstick_request *mrq, unsigned char tpc,
276 mrq->need_card_int = 1; 276 mrq->need_card_int = 1;
277 else 277 else
278 mrq->need_card_int = 0; 278 mrq->need_card_int = 0;
279
280 mrq->get_int_reg = 0;
281} 279}
282EXPORT_SYMBOL(memstick_init_req_sg); 280EXPORT_SYMBOL(memstick_init_req_sg);
283 281
@@ -311,8 +309,6 @@ void memstick_init_req(struct memstick_request *mrq, unsigned char tpc,
311 mrq->need_card_int = 1; 309 mrq->need_card_int = 1;
312 else 310 else
313 mrq->need_card_int = 0; 311 mrq->need_card_int = 0;
314
315 mrq->get_int_reg = 0;
316} 312}
317EXPORT_SYMBOL(memstick_init_req); 313EXPORT_SYMBOL(memstick_init_req);
318 314
@@ -342,6 +338,7 @@ static int h_memstick_read_dev_id(struct memstick_dev *card,
342 card->id.class = id_reg.class; 338 card->id.class = id_reg.class;
343 } 339 }
344 complete(&card->mrq_complete); 340 complete(&card->mrq_complete);
341 dev_dbg(&card->dev, "if_mode = %02x\n", id_reg.if_mode);
345 return -EAGAIN; 342 return -EAGAIN;
346 } 343 }
347} 344}
@@ -422,7 +419,6 @@ static void memstick_power_on(struct memstick_host *host)
422{ 419{
423 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_ON); 420 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_ON);
424 host->set_param(host, MEMSTICK_INTERFACE, MEMSTICK_SERIAL); 421 host->set_param(host, MEMSTICK_INTERFACE, MEMSTICK_SERIAL);
425 msleep(1);
426} 422}
427 423
428static void memstick_check(struct work_struct *work) 424static void memstick_check(struct work_struct *work)
@@ -579,7 +575,8 @@ EXPORT_SYMBOL(memstick_suspend_host);
579void memstick_resume_host(struct memstick_host *host) 575void memstick_resume_host(struct memstick_host *host)
580{ 576{
581 mutex_lock(&host->lock); 577 mutex_lock(&host->lock);
582 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_ON); 578 if (host->card)
579 memstick_power_on(host);
583 mutex_unlock(&host->lock); 580 mutex_unlock(&host->lock);
584 memstick_detect_change(host); 581 memstick_detect_change(host);
585} 582}
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c
index 1d637e4561d3..557dbbba5cb2 100644
--- a/drivers/memstick/core/mspro_block.c
+++ b/drivers/memstick/core/mspro_block.c
@@ -133,6 +133,7 @@ struct mspro_devinfo {
133struct mspro_block_data { 133struct mspro_block_data {
134 struct memstick_dev *card; 134 struct memstick_dev *card;
135 unsigned int usage_count; 135 unsigned int usage_count;
136 unsigned int caps;
136 struct gendisk *disk; 137 struct gendisk *disk;
137 struct request_queue *queue; 138 struct request_queue *queue;
138 spinlock_t q_lock; 139 spinlock_t q_lock;
@@ -577,7 +578,6 @@ static int h_mspro_block_wait_for_ced(struct memstick_dev *card,
577static int h_mspro_block_transfer_data(struct memstick_dev *card, 578static int h_mspro_block_transfer_data(struct memstick_dev *card,
578 struct memstick_request **mrq) 579 struct memstick_request **mrq)
579{ 580{
580 struct memstick_host *host = card->host;
581 struct mspro_block_data *msb = memstick_get_drvdata(card); 581 struct mspro_block_data *msb = memstick_get_drvdata(card);
582 unsigned char t_val = 0; 582 unsigned char t_val = 0;
583 struct scatterlist t_sg = { 0 }; 583 struct scatterlist t_sg = { 0 };
@@ -591,12 +591,12 @@ static int h_mspro_block_transfer_data(struct memstick_dev *card,
591 switch ((*mrq)->tpc) { 591 switch ((*mrq)->tpc) {
592 case MS_TPC_WRITE_REG: 592 case MS_TPC_WRITE_REG:
593 memstick_init_req(*mrq, MS_TPC_SET_CMD, &msb->transfer_cmd, 1); 593 memstick_init_req(*mrq, MS_TPC_SET_CMD, &msb->transfer_cmd, 1);
594 (*mrq)->get_int_reg = 1; 594 (*mrq)->need_card_int = 1;
595 return 0; 595 return 0;
596 case MS_TPC_SET_CMD: 596 case MS_TPC_SET_CMD:
597 t_val = (*mrq)->int_reg; 597 t_val = (*mrq)->int_reg;
598 memstick_init_req(*mrq, MS_TPC_GET_INT, NULL, 1); 598 memstick_init_req(*mrq, MS_TPC_GET_INT, NULL, 1);
599 if (host->caps & MEMSTICK_CAP_AUTO_GET_INT) 599 if (msb->caps & MEMSTICK_CAP_AUTO_GET_INT)
600 goto has_int_reg; 600 goto has_int_reg;
601 return 0; 601 return 0;
602 case MS_TPC_GET_INT: 602 case MS_TPC_GET_INT:
@@ -646,12 +646,12 @@ has_int_reg:
646 ? MS_TPC_READ_LONG_DATA 646 ? MS_TPC_READ_LONG_DATA
647 : MS_TPC_WRITE_LONG_DATA, 647 : MS_TPC_WRITE_LONG_DATA,
648 &t_sg); 648 &t_sg);
649 (*mrq)->get_int_reg = 1; 649 (*mrq)->need_card_int = 1;
650 return 0; 650 return 0;
651 case MS_TPC_READ_LONG_DATA: 651 case MS_TPC_READ_LONG_DATA:
652 case MS_TPC_WRITE_LONG_DATA: 652 case MS_TPC_WRITE_LONG_DATA:
653 msb->current_page++; 653 msb->current_page++;
654 if (host->caps & MEMSTICK_CAP_AUTO_GET_INT) { 654 if (msb->caps & MEMSTICK_CAP_AUTO_GET_INT) {
655 t_val = (*mrq)->int_reg; 655 t_val = (*mrq)->int_reg;
656 goto has_int_reg; 656 goto has_int_reg;
657 } else { 657 } else {
@@ -816,12 +816,13 @@ static int mspro_block_wait_for_ced(struct memstick_dev *card)
816 return card->current_mrq.error; 816 return card->current_mrq.error;
817} 817}
818 818
819static int mspro_block_switch_to_parallel(struct memstick_dev *card) 819static int mspro_block_set_interface(struct memstick_dev *card,
820 unsigned char sys_reg)
820{ 821{
821 struct memstick_host *host = card->host; 822 struct memstick_host *host = card->host;
822 struct mspro_block_data *msb = memstick_get_drvdata(card); 823 struct mspro_block_data *msb = memstick_get_drvdata(card);
823 struct mspro_param_register param = { 824 struct mspro_param_register param = {
824 .system = MEMSTICK_SYS_PAR4, 825 .system = sys_reg,
825 .data_count = 0, 826 .data_count = 0,
826 .data_address = 0, 827 .data_address = 0,
827 .tpc_param = 0 828 .tpc_param = 0
@@ -833,41 +834,70 @@ static int mspro_block_switch_to_parallel(struct memstick_dev *card)
833 sizeof(param)); 834 sizeof(param));
834 memstick_new_req(host); 835 memstick_new_req(host);
835 wait_for_completion(&card->mrq_complete); 836 wait_for_completion(&card->mrq_complete);
836 if (card->current_mrq.error) 837 return card->current_mrq.error;
837 return card->current_mrq.error; 838}
839
840static int mspro_block_switch_interface(struct memstick_dev *card)
841{
842 struct memstick_host *host = card->host;
843 struct mspro_block_data *msb = memstick_get_drvdata(card);
844 int rc = 0;
845
846 if (msb->caps & MEMSTICK_CAP_PAR4)
847 rc = mspro_block_set_interface(card, MEMSTICK_SYS_PAR4);
848 else
849 return 0;
850
851 if (rc) {
852 printk(KERN_WARNING
853 "%s: could not switch to 4-bit mode, error %d\n",
854 card->dev.bus_id, rc);
855 return 0;
856 }
838 857
839 msb->system = MEMSTICK_SYS_PAR4; 858 msb->system = MEMSTICK_SYS_PAR4;
840 host->set_param(host, MEMSTICK_INTERFACE, MEMSTICK_PAR4); 859 host->set_param(host, MEMSTICK_INTERFACE, MEMSTICK_PAR4);
860 printk(KERN_INFO "%s: switching to 4-bit parallel mode\n",
861 card->dev.bus_id);
862
863 if (msb->caps & MEMSTICK_CAP_PAR8) {
864 rc = mspro_block_set_interface(card, MEMSTICK_SYS_PAR8);
865
866 if (!rc) {
867 msb->system = MEMSTICK_SYS_PAR8;
868 host->set_param(host, MEMSTICK_INTERFACE,
869 MEMSTICK_PAR8);
870 printk(KERN_INFO
871 "%s: switching to 8-bit parallel mode\n",
872 card->dev.bus_id);
873 } else
874 printk(KERN_WARNING
875 "%s: could not switch to 8-bit mode, error %d\n",
876 card->dev.bus_id, rc);
877 }
841 878
842 card->next_request = h_mspro_block_req_init; 879 card->next_request = h_mspro_block_req_init;
843 msb->mrq_handler = h_mspro_block_default; 880 msb->mrq_handler = h_mspro_block_default;
844 memstick_init_req(&card->current_mrq, MS_TPC_GET_INT, NULL, 1); 881 memstick_init_req(&card->current_mrq, MS_TPC_GET_INT, NULL, 1);
845 memstick_new_req(card->host); 882 memstick_new_req(card->host);
846 wait_for_completion(&card->mrq_complete); 883 wait_for_completion(&card->mrq_complete);
884 rc = card->current_mrq.error;
847 885
848 if (card->current_mrq.error) { 886 if (rc) {
887 printk(KERN_WARNING
888 "%s: interface error, trying to fall back to serial\n",
889 card->dev.bus_id);
849 msb->system = MEMSTICK_SYS_SERIAL; 890 msb->system = MEMSTICK_SYS_SERIAL;
850 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF); 891 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF);
851 msleep(1000); 892 msleep(10);
852 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_ON); 893 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_ON);
853 host->set_param(host, MEMSTICK_INTERFACE, MEMSTICK_SERIAL); 894 host->set_param(host, MEMSTICK_INTERFACE, MEMSTICK_SERIAL);
854 895
855 if (memstick_set_rw_addr(card)) 896 rc = memstick_set_rw_addr(card);
856 return card->current_mrq.error; 897 if (!rc)
857 898 rc = mspro_block_set_interface(card, msb->system);
858 param.system = msb->system;
859
860 card->next_request = h_mspro_block_req_init;
861 msb->mrq_handler = h_mspro_block_default;
862 memstick_init_req(&card->current_mrq, MS_TPC_WRITE_REG, &param,
863 sizeof(param));
864 memstick_new_req(host);
865 wait_for_completion(&card->mrq_complete);
866
867 return -EFAULT;
868 } 899 }
869 900 return rc;
870 return 0;
871} 901}
872 902
873/* Memory allocated for attributes by this function should be freed by 903/* Memory allocated for attributes by this function should be freed by
@@ -1052,16 +1082,18 @@ static int mspro_block_init_card(struct memstick_dev *card)
1052 if (memstick_set_rw_addr(card)) 1082 if (memstick_set_rw_addr(card))
1053 return -EIO; 1083 return -EIO;
1054 1084
1055 if (host->caps & MEMSTICK_CAP_PAR4) { 1085 msb->caps = host->caps;
1056 if (mspro_block_switch_to_parallel(card)) 1086 rc = mspro_block_switch_interface(card);
1057 printk(KERN_WARNING "%s: could not switch to " 1087 if (rc)
1058 "parallel interface\n", card->dev.bus_id); 1088 return rc;
1059 }
1060 1089
1090 msleep(200);
1061 rc = mspro_block_wait_for_ced(card); 1091 rc = mspro_block_wait_for_ced(card);
1062 if (rc) 1092 if (rc)
1063 return rc; 1093 return rc;
1064 dev_dbg(&card->dev, "card activated\n"); 1094 dev_dbg(&card->dev, "card activated\n");
1095 if (msb->system != MEMSTICK_SYS_SERIAL)
1096 msb->caps |= MEMSTICK_CAP_AUTO_GET_INT;
1065 1097
1066 card->next_request = h_mspro_block_req_init; 1098 card->next_request = h_mspro_block_req_init;
1067 msb->mrq_handler = h_mspro_block_get_ro; 1099 msb->mrq_handler = h_mspro_block_get_ro;
diff --git a/drivers/memstick/host/jmb38x_ms.c b/drivers/memstick/host/jmb38x_ms.c
index 03fe8783b1ee..8770a5fac3b6 100644
--- a/drivers/memstick/host/jmb38x_ms.c
+++ b/drivers/memstick/host/jmb38x_ms.c
@@ -12,6 +12,7 @@
12#include <linux/spinlock.h> 12#include <linux/spinlock.h>
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/pci.h> 14#include <linux/pci.h>
15#include <linux/dma-mapping.h>
15#include <linux/delay.h> 16#include <linux/delay.h>
16#include <linux/highmem.h> 17#include <linux/highmem.h>
17#include <linux/memstick.h> 18#include <linux/memstick.h>
@@ -56,8 +57,6 @@ struct jmb38x_ms_host {
56 unsigned long timeout_jiffies; 57 unsigned long timeout_jiffies;
57 struct timer_list timer; 58 struct timer_list timer;
58 struct memstick_request *req; 59 struct memstick_request *req;
59 unsigned char eject:1,
60 use_dma:1;
61 unsigned char cmd_flags; 60 unsigned char cmd_flags;
62 unsigned char io_pos; 61 unsigned char io_pos;
63 unsigned int io_word[2]; 62 unsigned int io_word[2];
@@ -94,9 +93,22 @@ struct jmb38x_ms {
94#define HOST_CONTROL_IF_PAR4 0x1 93#define HOST_CONTROL_IF_PAR4 0x1
95#define HOST_CONTROL_IF_PAR8 0x3 94#define HOST_CONTROL_IF_PAR8 0x3
96 95
96#define STATUS_BUSY 0x00080000
97#define STATUS_MS_DAT7 0x00040000
98#define STATUS_MS_DAT6 0x00020000
99#define STATUS_MS_DAT5 0x00010000
100#define STATUS_MS_DAT4 0x00008000
101#define STATUS_MS_DAT3 0x00004000
102#define STATUS_MS_DAT2 0x00002000
103#define STATUS_MS_DAT1 0x00001000
104#define STATUS_MS_DAT0 0x00000800
97#define STATUS_HAS_MEDIA 0x00000400 105#define STATUS_HAS_MEDIA 0x00000400
98#define STATUS_FIFO_EMPTY 0x00000200 106#define STATUS_FIFO_EMPTY 0x00000200
99#define STATUS_FIFO_FULL 0x00000100 107#define STATUS_FIFO_FULL 0x00000100
108#define STATUS_MS_CED 0x00000080
109#define STATUS_MS_ERR 0x00000040
110#define STATUS_MS_BRQ 0x00000020
111#define STATUS_MS_CNK 0x00000001
100 112
101#define INT_STATUS_TPC_ERR 0x00080000 113#define INT_STATUS_TPC_ERR 0x00080000
102#define INT_STATUS_CRC_ERR 0x00040000 114#define INT_STATUS_CRC_ERR 0x00040000
@@ -119,11 +131,17 @@ struct jmb38x_ms {
119#define PAD_PU_PD_ON_MS_SOCK0 0x5f8f0000 131#define PAD_PU_PD_ON_MS_SOCK0 0x5f8f0000
120#define PAD_PU_PD_ON_MS_SOCK1 0x0f0f0000 132#define PAD_PU_PD_ON_MS_SOCK1 0x0f0f0000
121 133
134#define CLOCK_CONTROL_40MHZ 0x00000001
135#define CLOCK_CONTROL_50MHZ 0x00000002
136#define CLOCK_CONTROL_60MHZ 0x00000008
137#define CLOCK_CONTROL_62_5MHZ 0x0000000c
138#define CLOCK_CONTROL_OFF 0x00000000
139
122enum { 140enum {
123 CMD_READY = 0x01, 141 CMD_READY = 0x01,
124 FIFO_READY = 0x02, 142 FIFO_READY = 0x02,
125 REG_DATA = 0x04, 143 REG_DATA = 0x04,
126 AUTO_GET_INT = 0x08 144 DMA_DATA = 0x08
127}; 145};
128 146
129static unsigned int jmb38x_ms_read_data(struct jmb38x_ms_host *host, 147static unsigned int jmb38x_ms_read_data(struct jmb38x_ms_host *host,
@@ -273,7 +291,7 @@ static int jmb38x_ms_transfer_data(struct jmb38x_ms_host *host)
273{ 291{
274 unsigned int length; 292 unsigned int length;
275 unsigned int off; 293 unsigned int off;
276 unsigned int t_size, p_off, p_cnt; 294 unsigned int t_size, p_cnt;
277 unsigned char *buf; 295 unsigned char *buf;
278 struct page *pg; 296 struct page *pg;
279 unsigned long flags = 0; 297 unsigned long flags = 0;
@@ -287,6 +305,8 @@ static int jmb38x_ms_transfer_data(struct jmb38x_ms_host *host)
287 } 305 }
288 306
289 while (length) { 307 while (length) {
308 unsigned int uninitialized_var(p_off);
309
290 if (host->req->long_data) { 310 if (host->req->long_data) {
291 pg = nth_page(sg_page(&host->req->sg), 311 pg = nth_page(sg_page(&host->req->sg),
292 off >> PAGE_SHIFT); 312 off >> PAGE_SHIFT);
@@ -364,28 +384,27 @@ static int jmb38x_ms_issue_cmd(struct memstick_host *msh)
364 cmd |= TPC_DIR; 384 cmd |= TPC_DIR;
365 if (host->req->need_card_int) 385 if (host->req->need_card_int)
366 cmd |= TPC_WAIT_INT; 386 cmd |= TPC_WAIT_INT;
367 if (host->req->get_int_reg)
368 cmd |= TPC_GET_INT;
369 387
370 data = host->req->data; 388 data = host->req->data;
371 389
372 host->use_dma = !no_dma; 390 if (!no_dma)
391 host->cmd_flags |= DMA_DATA;
373 392
374 if (host->req->long_data) { 393 if (host->req->long_data) {
375 data_len = host->req->sg.length; 394 data_len = host->req->sg.length;
376 } else { 395 } else {
377 data_len = host->req->data_len; 396 data_len = host->req->data_len;
378 host->use_dma = 0; 397 host->cmd_flags &= ~DMA_DATA;
379 } 398 }
380 399
381 if (data_len <= 8) { 400 if (data_len <= 8) {
382 cmd &= ~(TPC_DATA_SEL | 0xf); 401 cmd &= ~(TPC_DATA_SEL | 0xf);
383 host->cmd_flags |= REG_DATA; 402 host->cmd_flags |= REG_DATA;
384 cmd |= data_len & 0xf; 403 cmd |= data_len & 0xf;
385 host->use_dma = 0; 404 host->cmd_flags &= ~DMA_DATA;
386 } 405 }
387 406
388 if (host->use_dma) { 407 if (host->cmd_flags & DMA_DATA) {
389 if (1 != pci_map_sg(host->chip->pdev, &host->req->sg, 1, 408 if (1 != pci_map_sg(host->chip->pdev, &host->req->sg, 1,
390 host->req->data_dir == READ 409 host->req->data_dir == READ
391 ? PCI_DMA_FROMDEVICE 410 ? PCI_DMA_FROMDEVICE
@@ -448,13 +467,12 @@ static void jmb38x_ms_complete_cmd(struct memstick_host *msh, int last)
448 readl(host->addr + INT_STATUS)); 467 readl(host->addr + INT_STATUS));
449 dev_dbg(msh->cdev.dev, "c hstatus %08x\n", readl(host->addr + STATUS)); 468 dev_dbg(msh->cdev.dev, "c hstatus %08x\n", readl(host->addr + STATUS));
450 469
451 if (host->req->get_int_reg) { 470 host->req->int_reg = readl(host->addr + STATUS) & 0xff;
452 t_val = readl(host->addr + TPC_P0); 471
453 host->req->int_reg = (t_val & 0xff); 472 writel(0, host->addr + BLOCK);
454 } 473 writel(0, host->addr + DMA_CONTROL);
455 474
456 if (host->use_dma) { 475 if (host->cmd_flags & DMA_DATA) {
457 writel(0, host->addr + DMA_CONTROL);
458 pci_unmap_sg(host->chip->pdev, &host->req->sg, 1, 476 pci_unmap_sg(host->chip->pdev, &host->req->sg, 1,
459 host->req->data_dir == READ 477 host->req->data_dir == READ
460 ? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE); 478 ? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE);
@@ -506,7 +524,7 @@ static irqreturn_t jmb38x_ms_isr(int irq, void *dev_id)
506 else 524 else
507 host->req->error = -ETIME; 525 host->req->error = -ETIME;
508 } else { 526 } else {
509 if (host->use_dma) { 527 if (host->cmd_flags & DMA_DATA) {
510 if (irq_status & INT_STATUS_EOTRAN) 528 if (irq_status & INT_STATUS_EOTRAN)
511 host->cmd_flags |= FIFO_READY; 529 host->cmd_flags |= FIFO_READY;
512 } else { 530 } else {
@@ -595,19 +613,18 @@ static void jmb38x_ms_reset(struct jmb38x_ms_host *host)
595{ 613{
596 unsigned int host_ctl = readl(host->addr + HOST_CONTROL); 614 unsigned int host_ctl = readl(host->addr + HOST_CONTROL);
597 615
598 writel(host_ctl | HOST_CONTROL_RESET_REQ | HOST_CONTROL_RESET, 616 writel(HOST_CONTROL_RESET_REQ, host->addr + HOST_CONTROL);
599 host->addr + HOST_CONTROL);
600 617
601 while (HOST_CONTROL_RESET_REQ 618 while (HOST_CONTROL_RESET_REQ
602 & (host_ctl = readl(host->addr + HOST_CONTROL))) { 619 & (host_ctl = readl(host->addr + HOST_CONTROL))) {
603 ndelay(100); 620 ndelay(20);
604 dev_dbg(&host->chip->pdev->dev, "reset\n"); 621 dev_dbg(&host->chip->pdev->dev, "reset %08x\n", host_ctl);
605 } 622 }
606 623
607 writel(INT_STATUS_ALL, host->addr + INT_STATUS_ENABLE); 624 writel(HOST_CONTROL_RESET, host->addr + HOST_CONTROL);
625 mmiowb();
608 writel(INT_STATUS_ALL, host->addr + INT_SIGNAL_ENABLE); 626 writel(INT_STATUS_ALL, host->addr + INT_SIGNAL_ENABLE);
609 627 writel(INT_STATUS_ALL, host->addr + INT_STATUS_ENABLE);
610 dev_dbg(&host->chip->pdev->dev, "reset\n");
611} 628}
612 629
613static void jmb38x_ms_set_param(struct memstick_host *msh, 630static void jmb38x_ms_set_param(struct memstick_host *msh,
@@ -615,10 +632,8 @@ static void jmb38x_ms_set_param(struct memstick_host *msh,
615 int value) 632 int value)
616{ 633{
617 struct jmb38x_ms_host *host = memstick_priv(msh); 634 struct jmb38x_ms_host *host = memstick_priv(msh);
618 unsigned int host_ctl; 635 unsigned int host_ctl = readl(host->addr + HOST_CONTROL);
619 unsigned long flags; 636 unsigned int clock_ctl = CLOCK_CONTROL_40MHZ, clock_delay = 0;
620
621 spin_lock_irqsave(&host->lock, flags);
622 637
623 switch (param) { 638 switch (param) {
624 case MEMSTICK_POWER: 639 case MEMSTICK_POWER:
@@ -626,60 +641,57 @@ static void jmb38x_ms_set_param(struct memstick_host *msh,
626 jmb38x_ms_reset(host); 641 jmb38x_ms_reset(host);
627 642
628 writel(host->id ? PAD_PU_PD_ON_MS_SOCK1 643 writel(host->id ? PAD_PU_PD_ON_MS_SOCK1
629 : PAD_PU_PD_ON_MS_SOCK0, 644 : PAD_PU_PD_ON_MS_SOCK0,
630 host->addr + PAD_PU_PD); 645 host->addr + PAD_PU_PD);
631 646
632 writel(PAD_OUTPUT_ENABLE_MS, 647 writel(PAD_OUTPUT_ENABLE_MS,
633 host->addr + PAD_OUTPUT_ENABLE); 648 host->addr + PAD_OUTPUT_ENABLE);
634 649
635 host_ctl = readl(host->addr + HOST_CONTROL); 650 host_ctl = 7;
636 host_ctl |= 7; 651 host_ctl |= HOST_CONTROL_POWER_EN
637 writel(host_ctl | (HOST_CONTROL_POWER_EN 652 | HOST_CONTROL_CLOCK_EN;
638 | HOST_CONTROL_CLOCK_EN), 653 writel(host_ctl, host->addr + HOST_CONTROL);
639 host->addr + HOST_CONTROL);
640 654
641 dev_dbg(&host->chip->pdev->dev, "power on\n"); 655 dev_dbg(&host->chip->pdev->dev, "power on\n");
642 } else if (value == MEMSTICK_POWER_OFF) { 656 } else if (value == MEMSTICK_POWER_OFF) {
643 writel(readl(host->addr + HOST_CONTROL) 657 host_ctl &= ~(HOST_CONTROL_POWER_EN
644 & ~(HOST_CONTROL_POWER_EN 658 | HOST_CONTROL_CLOCK_EN);
645 | HOST_CONTROL_CLOCK_EN), 659 writel(host_ctl, host->addr + HOST_CONTROL);
646 host->addr + HOST_CONTROL);
647 writel(0, host->addr + PAD_OUTPUT_ENABLE); 660 writel(0, host->addr + PAD_OUTPUT_ENABLE);
648 writel(PAD_PU_PD_OFF, host->addr + PAD_PU_PD); 661 writel(PAD_PU_PD_OFF, host->addr + PAD_PU_PD);
649 dev_dbg(&host->chip->pdev->dev, "power off\n"); 662 dev_dbg(&host->chip->pdev->dev, "power off\n");
650 } 663 }
651 break; 664 break;
652 case MEMSTICK_INTERFACE: 665 case MEMSTICK_INTERFACE:
653 /* jmb38x_ms_reset(host); */
654
655 host_ctl = readl(host->addr + HOST_CONTROL);
656 host_ctl &= ~(3 << HOST_CONTROL_IF_SHIFT); 666 host_ctl &= ~(3 << HOST_CONTROL_IF_SHIFT);
657 /* host_ctl |= 7; */
658 667
659 if (value == MEMSTICK_SERIAL) { 668 if (value == MEMSTICK_SERIAL) {
660 host_ctl &= ~HOST_CONTROL_FAST_CLK; 669 host_ctl &= ~HOST_CONTROL_FAST_CLK;
661 host_ctl |= HOST_CONTROL_IF_SERIAL 670 host_ctl |= HOST_CONTROL_IF_SERIAL
662 << HOST_CONTROL_IF_SHIFT; 671 << HOST_CONTROL_IF_SHIFT;
663 host_ctl |= HOST_CONTROL_REI; 672 host_ctl |= HOST_CONTROL_REI;
664 writel(0, host->addr + CLOCK_DELAY); 673 clock_ctl = CLOCK_CONTROL_40MHZ;
674 clock_delay = 0;
665 } else if (value == MEMSTICK_PAR4) { 675 } else if (value == MEMSTICK_PAR4) {
666 host_ctl |= HOST_CONTROL_FAST_CLK; 676 host_ctl |= HOST_CONTROL_FAST_CLK;
667 host_ctl |= HOST_CONTROL_IF_PAR4 677 host_ctl |= HOST_CONTROL_IF_PAR4
668 << HOST_CONTROL_IF_SHIFT; 678 << HOST_CONTROL_IF_SHIFT;
669 host_ctl &= ~HOST_CONTROL_REI; 679 host_ctl &= ~HOST_CONTROL_REI;
670 writel(4, host->addr + CLOCK_DELAY); 680 clock_ctl = CLOCK_CONTROL_40MHZ;
681 clock_delay = 4;
671 } else if (value == MEMSTICK_PAR8) { 682 } else if (value == MEMSTICK_PAR8) {
672 host_ctl |= HOST_CONTROL_FAST_CLK; 683 host_ctl |= HOST_CONTROL_FAST_CLK;
673 host_ctl |= HOST_CONTROL_IF_PAR8 684 host_ctl |= HOST_CONTROL_IF_PAR8
674 << HOST_CONTROL_IF_SHIFT; 685 << HOST_CONTROL_IF_SHIFT;
675 host_ctl &= ~HOST_CONTROL_REI; 686 host_ctl &= ~HOST_CONTROL_REI;
676 writel(4, host->addr + CLOCK_DELAY); 687 clock_ctl = CLOCK_CONTROL_60MHZ;
688 clock_delay = 0;
677 } 689 }
678 writel(host_ctl, host->addr + HOST_CONTROL); 690 writel(host_ctl, host->addr + HOST_CONTROL);
691 writel(clock_ctl, host->addr + CLOCK_CONTROL);
692 writel(clock_delay, host->addr + CLOCK_DELAY);
679 break; 693 break;
680 }; 694 };
681
682 spin_unlock_irqrestore(&host->lock, flags);
683} 695}
684 696
685#ifdef CONFIG_PM 697#ifdef CONFIG_PM
@@ -772,13 +784,10 @@ static struct memstick_host *jmb38x_ms_alloc_host(struct jmb38x_ms *jm, int cnt)
772 snprintf(host->host_id, DEVICE_ID_SIZE, DRIVER_NAME ":slot%d", 784 snprintf(host->host_id, DEVICE_ID_SIZE, DRIVER_NAME ":slot%d",
773 host->id); 785 host->id);
774 host->irq = jm->pdev->irq; 786 host->irq = jm->pdev->irq;
775 host->timeout_jiffies = msecs_to_jiffies(4000); 787 host->timeout_jiffies = msecs_to_jiffies(1000);
776 msh->request = jmb38x_ms_request; 788 msh->request = jmb38x_ms_request;
777 msh->set_param = jmb38x_ms_set_param; 789 msh->set_param = jmb38x_ms_set_param;
778 /* 790
779 msh->caps = MEMSTICK_CAP_AUTO_GET_INT | MEMSTICK_CAP_PAR4
780 | MEMSTICK_CAP_PAR8;
781 */
782 msh->caps = MEMSTICK_CAP_PAR4 | MEMSTICK_CAP_PAR8; 791 msh->caps = MEMSTICK_CAP_PAR4 | MEMSTICK_CAP_PAR8;
783 792
784 setup_timer(&host->timer, jmb38x_ms_abort, (unsigned long)msh); 793 setup_timer(&host->timer, jmb38x_ms_abort, (unsigned long)msh);
diff --git a/drivers/memstick/host/tifm_ms.c b/drivers/memstick/host/tifm_ms.c
index 2b5bf52a8302..8577de4ebb0e 100644
--- a/drivers/memstick/host/tifm_ms.c
+++ b/drivers/memstick/host/tifm_ms.c
@@ -182,7 +182,7 @@ static unsigned int tifm_ms_transfer_data(struct tifm_ms *host)
182 struct tifm_dev *sock = host->dev; 182 struct tifm_dev *sock = host->dev;
183 unsigned int length; 183 unsigned int length;
184 unsigned int off; 184 unsigned int off;
185 unsigned int t_size, p_off, p_cnt; 185 unsigned int t_size, p_cnt;
186 unsigned char *buf; 186 unsigned char *buf;
187 struct page *pg; 187 struct page *pg;
188 unsigned long flags = 0; 188 unsigned long flags = 0;
@@ -198,6 +198,8 @@ static unsigned int tifm_ms_transfer_data(struct tifm_ms *host)
198 host->block_pos); 198 host->block_pos);
199 199
200 while (length) { 200 while (length) {
201 unsigned int uninitialized_var(p_off);
202
201 if (host->req->long_data) { 203 if (host->req->long_data) {
202 pg = nth_page(sg_page(&host->req->sg), 204 pg = nth_page(sg_page(&host->req->sg),
203 off >> PAGE_SHIFT); 205 off >> PAGE_SHIFT);
@@ -340,11 +342,20 @@ static void tifm_ms_complete_cmd(struct tifm_ms *host)
340 342
341 del_timer(&host->timer); 343 del_timer(&host->timer);
342 344
343 if (host->use_dma) 345 host->req->int_reg = readl(sock->addr + SOCK_MS_STATUS) & 0xff;
346 host->req->int_reg = (host->req->int_reg & 1)
347 | ((host->req->int_reg << 4) & 0xe0);
348
349 writel(TIFM_FIFO_INT_SETALL,
350 sock->addr + SOCK_DMA_FIFO_INT_ENABLE_CLEAR);
351 writel(TIFM_DMA_RESET, sock->addr + SOCK_DMA_CONTROL);
352
353 if (host->use_dma) {
344 tifm_unmap_sg(sock, &host->req->sg, 1, 354 tifm_unmap_sg(sock, &host->req->sg, 1,
345 host->req->data_dir == READ 355 host->req->data_dir == READ
346 ? PCI_DMA_FROMDEVICE 356 ? PCI_DMA_FROMDEVICE
347 : PCI_DMA_TODEVICE); 357 : PCI_DMA_TODEVICE);
358 }
348 359
349 writel((~TIFM_CTRL_LED) & readl(sock->addr + SOCK_CONTROL), 360 writel((~TIFM_CTRL_LED) & readl(sock->addr + SOCK_CONTROL),
350 sock->addr + SOCK_CONTROL); 361 sock->addr + SOCK_CONTROL);
@@ -424,12 +435,6 @@ static void tifm_ms_card_event(struct tifm_dev *sock)
424 else if (host_status & TIFM_MS_STAT_CRC) 435 else if (host_status & TIFM_MS_STAT_CRC)
425 host->req->error = -EILSEQ; 436 host->req->error = -EILSEQ;
426 437
427 if (host->req->error) {
428 writel(TIFM_FIFO_INT_SETALL,
429 sock->addr + SOCK_DMA_FIFO_INT_ENABLE_CLEAR);
430 writel(TIFM_DMA_RESET, sock->addr + SOCK_DMA_CONTROL);
431 }
432
433 if (host_status & TIFM_MS_STAT_RDY) 438 if (host_status & TIFM_MS_STAT_RDY)
434 host->cmd_flags |= CMD_READY; 439 host->cmd_flags |= CMD_READY;
435 440
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 6b6df8679585..c6be6eba7dc3 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -1430,6 +1430,98 @@ mpt_get_product_name(u16 vendor, u16 device, u8 revision, char *prod_name)
1430 sprintf(prod_name, "%s", product_str); 1430 sprintf(prod_name, "%s", product_str);
1431} 1431}
1432 1432
1433/**
1434 * mpt_mapresources - map in memory mapped io
1435 * @ioc: Pointer to pointer to IOC adapter
1436 *
1437 **/
1438static int
1439mpt_mapresources(MPT_ADAPTER *ioc)
1440{
1441 u8 __iomem *mem;
1442 int ii;
1443 unsigned long mem_phys;
1444 unsigned long port;
1445 u32 msize;
1446 u32 psize;
1447 u8 revision;
1448 int r = -ENODEV;
1449 struct pci_dev *pdev;
1450
1451 pdev = ioc->pcidev;
1452 ioc->bars = pci_select_bars(pdev, IORESOURCE_MEM);
1453 if (pci_enable_device_mem(pdev)) {
1454 printk(MYIOC_s_ERR_FMT "pci_enable_device_mem() "
1455 "failed\n", ioc->name);
1456 return r;
1457 }
1458 if (pci_request_selected_regions(pdev, ioc->bars, "mpt")) {
1459 printk(MYIOC_s_ERR_FMT "pci_request_selected_regions() with "
1460 "MEM failed\n", ioc->name);
1461 return r;
1462 }
1463
1464 pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision);
1465
1466 if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)
1467 && !pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) {
1468 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT
1469 ": 64 BIT PCI BUS DMA ADDRESSING SUPPORTED\n",
1470 ioc->name));
1471 } else if (!pci_set_dma_mask(pdev, DMA_32BIT_MASK)
1472 && !pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK)) {
1473 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT
1474 ": 32 BIT PCI BUS DMA ADDRESSING SUPPORTED\n",
1475 ioc->name));
1476 } else {
1477 printk(MYIOC_s_WARN_FMT "no suitable DMA mask for %s\n",
1478 ioc->name, pci_name(pdev));
1479 pci_release_selected_regions(pdev, ioc->bars);
1480 return r;
1481 }
1482
1483 mem_phys = msize = 0;
1484 port = psize = 0;
1485 for (ii = 0; ii < DEVICE_COUNT_RESOURCE; ii++) {
1486 if (pci_resource_flags(pdev, ii) & PCI_BASE_ADDRESS_SPACE_IO) {
1487 if (psize)
1488 continue;
1489 /* Get I/O space! */
1490 port = pci_resource_start(pdev, ii);
1491 psize = pci_resource_len(pdev, ii);
1492 } else {
1493 if (msize)
1494 continue;
1495 /* Get memmap */
1496 mem_phys = pci_resource_start(pdev, ii);
1497 msize = pci_resource_len(pdev, ii);
1498 }
1499 }
1500 ioc->mem_size = msize;
1501
1502 mem = NULL;
1503 /* Get logical ptr for PciMem0 space */
1504 /*mem = ioremap(mem_phys, msize);*/
1505 mem = ioremap(mem_phys, msize);
1506 if (mem == NULL) {
1507 printk(MYIOC_s_ERR_FMT ": ERROR - Unable to map adapter"
1508 " memory!\n", ioc->name);
1509 return -EINVAL;
1510 }
1511 ioc->memmap = mem;
1512 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "mem = %p, mem_phys = %lx\n",
1513 ioc->name, mem, mem_phys));
1514
1515 ioc->mem_phys = mem_phys;
1516 ioc->chip = (SYSIF_REGS __iomem *)mem;
1517
1518 /* Save Port IO values in case we need to do downloadboot */
1519 ioc->pio_mem_phys = port;
1520 ioc->pio_chip = (SYSIF_REGS __iomem *)port;
1521
1522 return 0;
1523}
1524
1433/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1525/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1434/** 1526/**
1435 * mpt_attach - Install a PCI intelligent MPT adapter. 1527 * mpt_attach - Install a PCI intelligent MPT adapter.
@@ -1452,13 +1544,6 @@ int
1452mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) 1544mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1453{ 1545{
1454 MPT_ADAPTER *ioc; 1546 MPT_ADAPTER *ioc;
1455 u8 __iomem *mem;
1456 u8 __iomem *pmem;
1457 unsigned long mem_phys;
1458 unsigned long port;
1459 u32 msize;
1460 u32 psize;
1461 int ii;
1462 u8 cb_idx; 1547 u8 cb_idx;
1463 int r = -ENODEV; 1548 int r = -ENODEV;
1464 u8 revision; 1549 u8 revision;
@@ -1468,52 +1553,32 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1468 struct proc_dir_entry *dent, *ent; 1553 struct proc_dir_entry *dent, *ent;
1469#endif 1554#endif
1470 1555
1471 if (mpt_debug_level)
1472 printk(KERN_INFO MYNAM ": mpt_debug_level=%xh\n", mpt_debug_level);
1473
1474 ioc = kzalloc(sizeof(MPT_ADAPTER), GFP_ATOMIC); 1556 ioc = kzalloc(sizeof(MPT_ADAPTER), GFP_ATOMIC);
1475 if (ioc == NULL) { 1557 if (ioc == NULL) {
1476 printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n"); 1558 printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n");
1477 return -ENOMEM; 1559 return -ENOMEM;
1478 } 1560 }
1479 ioc->debug_level = mpt_debug_level; 1561
1480 ioc->id = mpt_ids++; 1562 ioc->id = mpt_ids++;
1481 sprintf(ioc->name, "ioc%d", ioc->id); 1563 sprintf(ioc->name, "ioc%d", ioc->id);
1482 1564
1483 ioc->bars = pci_select_bars(pdev, IORESOURCE_MEM); 1565 /*
1484 if (pci_enable_device_mem(pdev)) { 1566 * set initial debug level
1485 printk(MYIOC_s_ERR_FMT "pci_enable_device_mem() " 1567 * (refer to mptdebug.h)
1486 "failed\n", ioc->name); 1568 *
1487 kfree(ioc); 1569 */
1488 return r; 1570 ioc->debug_level = mpt_debug_level;
1489 } 1571 if (mpt_debug_level)
1490 if (pci_request_selected_regions(pdev, ioc->bars, "mpt")) { 1572 printk(KERN_INFO "mpt_debug_level=%xh\n", mpt_debug_level);
1491 printk(MYIOC_s_ERR_FMT "pci_request_selected_regions() with "
1492 "MEM failed\n", ioc->name);
1493 kfree(ioc);
1494 return r;
1495 }
1496 1573
1497 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": mpt_adapter_install\n", ioc->name)); 1574 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT ": mpt_adapter_install\n", ioc->name));
1498 1575
1499 if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) { 1576 ioc->pcidev = pdev;
1500 dprintk(ioc, printk(MYIOC_s_INFO_FMT 1577 if (mpt_mapresources(ioc)) {
1501 ": 64 BIT PCI BUS DMA ADDRESSING SUPPORTED\n", ioc->name));
1502 } else if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
1503 printk(MYIOC_s_WARN_FMT ": 32 BIT PCI BUS DMA ADDRESSING NOT SUPPORTED\n",
1504 ioc->name);
1505 kfree(ioc); 1578 kfree(ioc);
1506 return r; 1579 return r;
1507 } 1580 }
1508 1581
1509 if (!pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) {
1510 dprintk(ioc, printk(MYIOC_s_INFO_FMT
1511 ": Using 64 bit consistent mask\n", ioc->name));
1512 } else {
1513 dprintk(ioc, printk(MYIOC_s_INFO_FMT
1514 ": Not using 64 bit consistent mask\n", ioc->name));
1515 }
1516
1517 ioc->alloc_total = sizeof(MPT_ADAPTER); 1582 ioc->alloc_total = sizeof(MPT_ADAPTER);
1518 ioc->req_sz = MPT_DEFAULT_FRAME_SIZE; /* avoid div by zero! */ 1583 ioc->req_sz = MPT_DEFAULT_FRAME_SIZE; /* avoid div by zero! */
1519 ioc->reply_sz = MPT_REPLY_FRAME_SIZE; 1584 ioc->reply_sz = MPT_REPLY_FRAME_SIZE;
@@ -1551,48 +1616,9 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1551 /* Find lookup slot. */ 1616 /* Find lookup slot. */
1552 INIT_LIST_HEAD(&ioc->list); 1617 INIT_LIST_HEAD(&ioc->list);
1553 1618
1554 mem_phys = msize = 0;
1555 port = psize = 0;
1556 for (ii=0; ii < DEVICE_COUNT_RESOURCE; ii++) {
1557 if (pci_resource_flags(pdev, ii) & PCI_BASE_ADDRESS_SPACE_IO) {
1558 if (psize)
1559 continue;
1560 /* Get I/O space! */
1561 port = pci_resource_start(pdev, ii);
1562 psize = pci_resource_len(pdev,ii);
1563 } else {
1564 if (msize)
1565 continue;
1566 /* Get memmap */
1567 mem_phys = pci_resource_start(pdev, ii);
1568 msize = pci_resource_len(pdev,ii);
1569 }
1570 }
1571 ioc->mem_size = msize;
1572
1573 mem = NULL;
1574 /* Get logical ptr for PciMem0 space */
1575 /*mem = ioremap(mem_phys, msize);*/
1576 mem = ioremap(mem_phys, msize);
1577 if (mem == NULL) {
1578 printk(MYIOC_s_ERR_FMT "Unable to map adapter memory!\n", ioc->name);
1579 kfree(ioc);
1580 return -EINVAL;
1581 }
1582 ioc->memmap = mem;
1583 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "mem = %p, mem_phys = %lx\n", ioc->name, mem, mem_phys));
1584
1585 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "facts @ %p, pfacts[0] @ %p\n", 1619 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "facts @ %p, pfacts[0] @ %p\n",
1586 ioc->name, &ioc->facts, &ioc->pfacts[0])); 1620 ioc->name, &ioc->facts, &ioc->pfacts[0]));
1587 1621
1588 ioc->mem_phys = mem_phys;
1589 ioc->chip = (SYSIF_REGS __iomem *)mem;
1590
1591 /* Save Port IO values in case we need to do downloadboot */
1592 ioc->pio_mem_phys = port;
1593 pmem = (u8 __iomem *)port;
1594 ioc->pio_chip = (SYSIF_REGS __iomem *)pmem;
1595
1596 pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision); 1622 pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision);
1597 mpt_get_product_name(pdev->vendor, pdev->device, revision, ioc->prod_name); 1623 mpt_get_product_name(pdev->vendor, pdev->device, revision, ioc->prod_name);
1598 1624
@@ -1688,7 +1714,9 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1688 list_del(&ioc->list); 1714 list_del(&ioc->list);
1689 if (ioc->alt_ioc) 1715 if (ioc->alt_ioc)
1690 ioc->alt_ioc->alt_ioc = NULL; 1716 ioc->alt_ioc->alt_ioc = NULL;
1691 iounmap(mem); 1717 iounmap(ioc->memmap);
1718 if (r != -5)
1719 pci_release_selected_regions(pdev, ioc->bars);
1692 kfree(ioc); 1720 kfree(ioc);
1693 pci_set_drvdata(pdev, NULL); 1721 pci_set_drvdata(pdev, NULL);
1694 return r; 1722 return r;
@@ -1784,13 +1812,10 @@ mpt_suspend(struct pci_dev *pdev, pm_message_t state)
1784 u32 device_state; 1812 u32 device_state;
1785 MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 1813 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
1786 1814
1787 device_state=pci_choose_state(pdev, state); 1815 device_state = pci_choose_state(pdev, state);
1788 1816 printk(MYIOC_s_INFO_FMT "pci-suspend: pdev=0x%p, slot=%s, Entering "
1789 printk(MYIOC_s_INFO_FMT 1817 "operating state [D%d]\n", ioc->name, pdev, pci_name(pdev),
1790 "pci-suspend: pdev=0x%p, slot=%s, Entering operating state [D%d]\n", 1818 device_state);
1791 ioc->name, pdev, pci_name(pdev), device_state);
1792
1793 pci_save_state(pdev);
1794 1819
1795 /* put ioc into READY_STATE */ 1820 /* put ioc into READY_STATE */
1796 if(SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, CAN_SLEEP)) { 1821 if(SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, CAN_SLEEP)) {
@@ -1805,10 +1830,14 @@ mpt_suspend(struct pci_dev *pdev, pm_message_t state)
1805 /* Clear any lingering interrupt */ 1830 /* Clear any lingering interrupt */
1806 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); 1831 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);
1807 1832
1833 free_irq(ioc->pci_irq, ioc);
1834 if (mpt_msi_enable)
1835 pci_disable_msi(ioc->pcidev);
1836 ioc->pci_irq = -1;
1837 pci_save_state(pdev);
1808 pci_disable_device(pdev); 1838 pci_disable_device(pdev);
1809 pci_release_selected_regions(pdev, ioc->bars); 1839 pci_release_selected_regions(pdev, ioc->bars);
1810 pci_set_power_state(pdev, device_state); 1840 pci_set_power_state(pdev, device_state);
1811
1812 return 0; 1841 return 0;
1813} 1842}
1814 1843
@@ -1823,48 +1852,54 @@ mpt_resume(struct pci_dev *pdev)
1823 MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 1852 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
1824 u32 device_state = pdev->current_state; 1853 u32 device_state = pdev->current_state;
1825 int recovery_state; 1854 int recovery_state;
1855 int err;
1826 1856
1827 printk(MYIOC_s_INFO_FMT 1857 printk(MYIOC_s_INFO_FMT "pci-resume: pdev=0x%p, slot=%s, Previous "
1828 "pci-resume: pdev=0x%p, slot=%s, Previous operating state [D%d]\n", 1858 "operating state [D%d]\n", ioc->name, pdev, pci_name(pdev),
1829 ioc->name, pdev, pci_name(pdev), device_state); 1859 device_state);
1830 1860
1831 pci_set_power_state(pdev, 0); 1861 pci_set_power_state(pdev, PCI_D0);
1862 pci_enable_wake(pdev, PCI_D0, 0);
1832 pci_restore_state(pdev); 1863 pci_restore_state(pdev);
1833 if (ioc->facts.Flags & MPI_IOCFACTS_FLAGS_FW_DOWNLOAD_BOOT) { 1864 ioc->pcidev = pdev;
1834 ioc->bars = pci_select_bars(ioc->pcidev, IORESOURCE_MEM | 1865 err = mpt_mapresources(ioc);
1835 IORESOURCE_IO); 1866 if (err)
1836 if (pci_enable_device(pdev)) 1867 return err;
1837 return 0;
1838 } else {
1839 ioc->bars = pci_select_bars(pdev, IORESOURCE_MEM);
1840 if (pci_enable_device_mem(pdev))
1841 return 0;
1842 }
1843 if (pci_request_selected_regions(pdev, ioc->bars, "mpt"))
1844 return 0;
1845 1868
1846 /* enable interrupts */ 1869 printk(MYIOC_s_INFO_FMT "pci-resume: ioc-state=0x%x,doorbell=0x%x\n",
1847 CHIPREG_WRITE32(&ioc->chip->IntMask, MPI_HIM_DIM); 1870 ioc->name, (mpt_GetIocState(ioc, 1) >> MPI_IOC_STATE_SHIFT),
1848 ioc->active = 1; 1871 CHIPREG_READ32(&ioc->chip->Doorbell));
1849 1872
1850 printk(MYIOC_s_INFO_FMT 1873 /*
1851 "pci-resume: ioc-state=0x%x,doorbell=0x%x\n", 1874 * Errata workaround for SAS pci express:
1852 ioc->name, 1875 * Upon returning to the D0 state, the contents of the doorbell will be
1853 (mpt_GetIocState(ioc, 1) >> MPI_IOC_STATE_SHIFT), 1876 * stale data, and this will incorrectly signal to the host driver that
1854 CHIPREG_READ32(&ioc->chip->Doorbell)); 1877 * the firmware is ready to process mpt commands. The workaround is
1878 * to issue a diagnostic reset.
1879 */
1880 if (ioc->bus_type == SAS && (pdev->device ==
1881 MPI_MANUFACTPAGE_DEVID_SAS1068E || pdev->device ==
1882 MPI_MANUFACTPAGE_DEVID_SAS1064E)) {
1883 if (KickStart(ioc, 1, CAN_SLEEP) < 0) {
1884 printk(MYIOC_s_WARN_FMT "pci-resume: Cannot recover\n",
1885 ioc->name);
1886 goto out;
1887 }
1888 }
1855 1889
1856 /* bring ioc to operational state */ 1890 /* bring ioc to operational state */
1857 if ((recovery_state = mpt_do_ioc_recovery(ioc, 1891 printk(MYIOC_s_INFO_FMT "Sending mpt_do_ioc_recovery\n", ioc->name);
1858 MPT_HOSTEVENT_IOC_RECOVER, CAN_SLEEP)) != 0) { 1892 recovery_state = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_BRINGUP,
1859 printk(MYIOC_s_INFO_FMT 1893 CAN_SLEEP);
1860 "pci-resume: Cannot recover, error:[%x]\n", 1894 if (recovery_state != 0)
1861 ioc->name, recovery_state); 1895 printk(MYIOC_s_WARN_FMT "pci-resume: Cannot recover, "
1862 } else { 1896 "error:[%x]\n", ioc->name, recovery_state);
1897 else
1863 printk(MYIOC_s_INFO_FMT 1898 printk(MYIOC_s_INFO_FMT
1864 "pci-resume: success\n", ioc->name); 1899 "pci-resume: success\n", ioc->name);
1865 } 1900 out:
1866
1867 return 0; 1901 return 0;
1902
1868} 1903}
1869#endif 1904#endif
1870 1905
@@ -1903,6 +1938,7 @@ mpt_signal_reset(u8 index, MPT_ADAPTER *ioc, int reset_phase)
1903 * -3 if READY but PrimeIOCFifos Failed 1938 * -3 if READY but PrimeIOCFifos Failed
1904 * -4 if READY but IOCInit Failed 1939 * -4 if READY but IOCInit Failed
1905 * -5 if failed to enable_device and/or request_selected_regions 1940 * -5 if failed to enable_device and/or request_selected_regions
1941 * -6 if failed to upload firmware
1906 */ 1942 */
1907static int 1943static int
1908mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag) 1944mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
@@ -2097,7 +2133,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2097 } else { 2133 } else {
2098 printk(MYIOC_s_WARN_FMT 2134 printk(MYIOC_s_WARN_FMT
2099 "firmware upload failure!\n", ioc->name); 2135 "firmware upload failure!\n", ioc->name);
2100 ret = -5; 2136 ret = -6;
2101 } 2137 }
2102 } 2138 }
2103 } 2139 }
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 0c252f60c4c1..c207bda6723b 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1170,6 +1170,10 @@ mptscsih_shutdown(struct pci_dev *pdev)
1170int 1170int
1171mptscsih_suspend(struct pci_dev *pdev, pm_message_t state) 1171mptscsih_suspend(struct pci_dev *pdev, pm_message_t state)
1172{ 1172{
1173 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
1174
1175 scsi_block_requests(ioc->sh);
1176 flush_scheduled_work();
1173 mptscsih_shutdown(pdev); 1177 mptscsih_shutdown(pdev);
1174 return mpt_suspend(pdev,state); 1178 return mpt_suspend(pdev,state);
1175} 1179}
@@ -1183,7 +1187,12 @@ mptscsih_suspend(struct pci_dev *pdev, pm_message_t state)
1183int 1187int
1184mptscsih_resume(struct pci_dev *pdev) 1188mptscsih_resume(struct pci_dev *pdev)
1185{ 1189{
1186 return mpt_resume(pdev); 1190 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
1191 int rc;
1192
1193 rc = mpt_resume(pdev);
1194 scsi_unblock_requests(ioc->sh);
1195 return rc;
1187} 1196}
1188 1197
1189#endif 1198#endif
diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c
index 63fb1ff3ad10..f6f2d960cadb 100644
--- a/drivers/mfd/asic3.c
+++ b/drivers/mfd/asic3.c
@@ -28,14 +28,14 @@
28static inline void asic3_write_register(struct asic3 *asic, 28static inline void asic3_write_register(struct asic3 *asic,
29 unsigned int reg, u32 value) 29 unsigned int reg, u32 value)
30{ 30{
31 iowrite16(value, (unsigned long)asic->mapping + 31 iowrite16(value, asic->mapping +
32 (reg >> asic->bus_shift)); 32 (reg >> asic->bus_shift));
33} 33}
34 34
35static inline u32 asic3_read_register(struct asic3 *asic, 35static inline u32 asic3_read_register(struct asic3 *asic,
36 unsigned int reg) 36 unsigned int reg)
37{ 37{
38 return ioread16((unsigned long)asic->mapping + 38 return ioread16(asic->mapping +
39 (reg >> asic->bus_shift)); 39 (reg >> asic->bus_shift));
40} 40}
41 41
diff --git a/drivers/misc/fujitsu-laptop.c b/drivers/misc/fujitsu-laptop.c
index 1cfd7f3f1294..e2e7c05a147b 100644
--- a/drivers/misc/fujitsu-laptop.c
+++ b/drivers/misc/fujitsu-laptop.c
@@ -231,7 +231,7 @@ static int acpi_fujitsu_remove(struct acpi_device *device, int type)
231 231
232 if (!device || !acpi_driver_data(device)) 232 if (!device || !acpi_driver_data(device))
233 return -EINVAL; 233 return -EINVAL;
234 fujitsu->acpi_handle = 0; 234 fujitsu->acpi_handle = NULL;
235 235
236 return 0; 236 return 0;
237} 237}
diff --git a/drivers/misc/ibmasm/module.c b/drivers/misc/ibmasm/module.c
index 4f9d4a9da983..b5f6add34b0b 100644
--- a/drivers/misc/ibmasm/module.c
+++ b/drivers/misc/ibmasm/module.c
@@ -106,7 +106,7 @@ static int __devinit ibmasm_init_one(struct pci_dev *pdev, const struct pci_devi
106 sp->irq = pdev->irq; 106 sp->irq = pdev->irq;
107 sp->base_address = ioremap(pci_resource_start(pdev, 0), 107 sp->base_address = ioremap(pci_resource_start(pdev, 0),
108 pci_resource_len(pdev, 0)); 108 pci_resource_len(pdev, 0));
109 if (sp->base_address == 0) { 109 if (!sp->base_address) {
110 dev_err(sp->dev, "Failed to ioremap pci memory\n"); 110 dev_err(sp->dev, "Failed to ioremap pci memory\n");
111 result = -ENODEV; 111 result = -ENODEV;
112 goto error_ioremap; 112 goto error_ioremap;
diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c
index c884730c5eaf..1bfe5d16963b 100644
--- a/drivers/misc/lkdtm.c
+++ b/drivers/misc/lkdtm.c
@@ -197,7 +197,7 @@ static int lkdtm_parse_commandline(void)
197{ 197{
198 int i; 198 int i;
199 199
200 if (cpoint_name == INVALID || cpoint_type == NONE || 200 if (cpoint_name == NULL || cpoint_type == NULL ||
201 cpoint_count < 1 || recur_count < 1) 201 cpoint_count < 1 || recur_count < 1)
202 return -EINVAL; 202 return -EINVAL;
203 203
diff --git a/drivers/mmc/core/Makefile b/drivers/mmc/core/Makefile
index 4985807257a8..19a1a254a0c5 100644
--- a/drivers/mmc/core/Makefile
+++ b/drivers/mmc/core/Makefile
@@ -7,7 +7,7 @@ ifeq ($(CONFIG_MMC_DEBUG),y)
7endif 7endif
8 8
9obj-$(CONFIG_MMC) += mmc_core.o 9obj-$(CONFIG_MMC) += mmc_core.o
10mmc_core-y := core.o sysfs.o bus.o host.o \ 10mmc_core-y := core.o bus.o host.o \
11 mmc.o mmc_ops.o sd.o sd_ops.o \ 11 mmc.o mmc_ops.o sd.o sd_ops.o \
12 sdio.o sdio_ops.o sdio_bus.o \ 12 sdio.o sdio_ops.o sdio_bus.o \
13 sdio_cis.o sdio_io.o sdio_irq.o 13 sdio_cis.o sdio_io.o sdio_irq.o
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index b0c22cad9423..fd95b18e988b 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -17,7 +17,6 @@
17#include <linux/mmc/card.h> 17#include <linux/mmc/card.h>
18#include <linux/mmc/host.h> 18#include <linux/mmc/host.h>
19 19
20#include "sysfs.h"
21#include "core.h" 20#include "core.h"
22#include "sdio_cis.h" 21#include "sdio_cis.h"
23#include "bus.h" 22#include "bus.h"
@@ -43,7 +42,7 @@ static ssize_t mmc_type_show(struct device *dev,
43} 42}
44 43
45static struct device_attribute mmc_dev_attrs[] = { 44static struct device_attribute mmc_dev_attrs[] = {
46 MMC_ATTR_RO(type), 45 __ATTR(type, S_IRUGO, mmc_type_show, NULL),
47 __ATTR_NULL, 46 __ATTR_NULL,
48}; 47};
49 48
@@ -189,7 +188,7 @@ static void mmc_release_card(struct device *dev)
189/* 188/*
190 * Allocate and initialise a new MMC card structure. 189 * Allocate and initialise a new MMC card structure.
191 */ 190 */
192struct mmc_card *mmc_alloc_card(struct mmc_host *host) 191struct mmc_card *mmc_alloc_card(struct mmc_host *host, struct device_type *type)
193{ 192{
194 struct mmc_card *card; 193 struct mmc_card *card;
195 194
@@ -204,6 +203,7 @@ struct mmc_card *mmc_alloc_card(struct mmc_host *host)
204 card->dev.parent = mmc_classdev(host); 203 card->dev.parent = mmc_classdev(host);
205 card->dev.bus = &mmc_bus_type; 204 card->dev.bus = &mmc_bus_type;
206 card->dev.release = mmc_release_card; 205 card->dev.release = mmc_release_card;
206 card->dev.type = type;
207 207
208 return card; 208 return card;
209} 209}
@@ -248,24 +248,10 @@ int mmc_add_card(struct mmc_card *card)
248 type, card->rca); 248 type, card->rca);
249 } 249 }
250 250
251 card->dev.uevent_suppress = 1;
252
253 ret = device_add(&card->dev); 251 ret = device_add(&card->dev);
254 if (ret) 252 if (ret)
255 return ret; 253 return ret;
256 254
257 if (card->host->bus_ops->sysfs_add) {
258 ret = card->host->bus_ops->sysfs_add(card->host, card);
259 if (ret) {
260 device_del(&card->dev);
261 return ret;
262 }
263 }
264
265 card->dev.uevent_suppress = 0;
266
267 kobject_uevent(&card->dev.kobj, KOBJ_ADD);
268
269 mmc_card_set_present(card); 255 mmc_card_set_present(card);
270 256
271 return 0; 257 return 0;
@@ -285,9 +271,6 @@ void mmc_remove_card(struct mmc_card *card)
285 printk(KERN_INFO "%s: card %04x removed\n", 271 printk(KERN_INFO "%s: card %04x removed\n",
286 mmc_hostname(card->host), card->rca); 272 mmc_hostname(card->host), card->rca);
287 } 273 }
288
289 if (card->host->bus_ops->sysfs_remove)
290 card->host->bus_ops->sysfs_remove(card->host, card);
291 device_del(&card->dev); 274 device_del(&card->dev);
292 } 275 }
293 276
diff --git a/drivers/mmc/core/bus.h b/drivers/mmc/core/bus.h
index 4f35431116a8..18178766ab46 100644
--- a/drivers/mmc/core/bus.h
+++ b/drivers/mmc/core/bus.h
@@ -11,7 +11,16 @@
11#ifndef _MMC_CORE_BUS_H 11#ifndef _MMC_CORE_BUS_H
12#define _MMC_CORE_BUS_H 12#define _MMC_CORE_BUS_H
13 13
14struct mmc_card *mmc_alloc_card(struct mmc_host *host); 14#define MMC_DEV_ATTR(name, fmt, args...) \
15static ssize_t mmc_##name##_show (struct device *dev, struct device_attribute *attr, char *buf) \
16{ \
17 struct mmc_card *card = container_of(dev, struct mmc_card, dev); \
18 return sprintf(buf, fmt, args); \
19} \
20static DEVICE_ATTR(name, S_IRUGO, mmc_##name##_show, NULL)
21
22struct mmc_card *mmc_alloc_card(struct mmc_host *host,
23 struct device_type *type);
15int mmc_add_card(struct mmc_card *card); 24int mmc_add_card(struct mmc_card *card);
16void mmc_remove_card(struct mmc_card *card); 25void mmc_remove_card(struct mmc_card *card);
17 26
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
index 39daf2fb5dc4..cfa8e15b5923 100644
--- a/drivers/mmc/core/core.h
+++ b/drivers/mmc/core/core.h
@@ -18,8 +18,6 @@
18struct mmc_bus_ops { 18struct mmc_bus_ops {
19 void (*remove)(struct mmc_host *); 19 void (*remove)(struct mmc_host *);
20 void (*detect)(struct mmc_host *); 20 void (*detect)(struct mmc_host *);
21 int (*sysfs_add)(struct mmc_host *, struct mmc_card *card);
22 void (*sysfs_remove)(struct mmc_host *, struct mmc_card *card);
23 void (*suspend)(struct mmc_host *); 21 void (*suspend)(struct mmc_host *);
24 void (*resume)(struct mmc_host *); 22 void (*resume)(struct mmc_host *);
25}; 23};
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 68c0e3b2f0e8..3da29eef8f7d 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -17,7 +17,6 @@
17#include <linux/mmc/mmc.h> 17#include <linux/mmc/mmc.h>
18 18
19#include "core.h" 19#include "core.h"
20#include "sysfs.h"
21#include "bus.h" 20#include "bus.h"
22#include "mmc_ops.h" 21#include "mmc_ops.h"
23 22
@@ -248,6 +247,44 @@ out:
248 return err; 247 return err;
249} 248}
250 249
250MMC_DEV_ATTR(cid, "%08x%08x%08x%08x\n", card->raw_cid[0], card->raw_cid[1],
251 card->raw_cid[2], card->raw_cid[3]);
252MMC_DEV_ATTR(csd, "%08x%08x%08x%08x\n", card->raw_csd[0], card->raw_csd[1],
253 card->raw_csd[2], card->raw_csd[3]);
254MMC_DEV_ATTR(date, "%02d/%04d\n", card->cid.month, card->cid.year);
255MMC_DEV_ATTR(fwrev, "0x%x\n", card->cid.fwrev);
256MMC_DEV_ATTR(hwrev, "0x%x\n", card->cid.hwrev);
257MMC_DEV_ATTR(manfid, "0x%06x\n", card->cid.manfid);
258MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name);
259MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid);
260MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial);
261
262static struct attribute *mmc_std_attrs[] = {
263 &dev_attr_cid.attr,
264 &dev_attr_csd.attr,
265 &dev_attr_date.attr,
266 &dev_attr_fwrev.attr,
267 &dev_attr_hwrev.attr,
268 &dev_attr_manfid.attr,
269 &dev_attr_name.attr,
270 &dev_attr_oemid.attr,
271 &dev_attr_serial.attr,
272 NULL,
273};
274
275static struct attribute_group mmc_std_attr_group = {
276 .attrs = mmc_std_attrs,
277};
278
279static struct attribute_group *mmc_attr_groups[] = {
280 &mmc_std_attr_group,
281 NULL,
282};
283
284static struct device_type mmc_type = {
285 .groups = mmc_attr_groups,
286};
287
251/* 288/*
252 * Handle the detection and initialisation of a card. 289 * Handle the detection and initialisation of a card.
253 * 290 *
@@ -308,7 +345,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
308 /* 345 /*
309 * Allocate card structure. 346 * Allocate card structure.
310 */ 347 */
311 card = mmc_alloc_card(host); 348 card = mmc_alloc_card(host, &mmc_type);
312 if (IS_ERR(card)) { 349 if (IS_ERR(card)) {
313 err = PTR_ERR(card); 350 err = PTR_ERR(card);
314 goto err; 351 goto err;
@@ -459,53 +496,6 @@ static void mmc_detect(struct mmc_host *host)
459 } 496 }
460} 497}
461 498
462MMC_ATTR_FN(cid, "%08x%08x%08x%08x\n", card->raw_cid[0], card->raw_cid[1],
463 card->raw_cid[2], card->raw_cid[3]);
464MMC_ATTR_FN(csd, "%08x%08x%08x%08x\n", card->raw_csd[0], card->raw_csd[1],
465 card->raw_csd[2], card->raw_csd[3]);
466MMC_ATTR_FN(date, "%02d/%04d\n", card->cid.month, card->cid.year);
467MMC_ATTR_FN(fwrev, "0x%x\n", card->cid.fwrev);
468MMC_ATTR_FN(hwrev, "0x%x\n", card->cid.hwrev);
469MMC_ATTR_FN(manfid, "0x%06x\n", card->cid.manfid);
470MMC_ATTR_FN(name, "%s\n", card->cid.prod_name);
471MMC_ATTR_FN(oemid, "0x%04x\n", card->cid.oemid);
472MMC_ATTR_FN(serial, "0x%08x\n", card->cid.serial);
473
474static struct device_attribute mmc_dev_attrs[] = {
475 MMC_ATTR_RO(cid),
476 MMC_ATTR_RO(csd),
477 MMC_ATTR_RO(date),
478 MMC_ATTR_RO(fwrev),
479 MMC_ATTR_RO(hwrev),
480 MMC_ATTR_RO(manfid),
481 MMC_ATTR_RO(name),
482 MMC_ATTR_RO(oemid),
483 MMC_ATTR_RO(serial),
484 __ATTR_NULL,
485};
486
487/*
488 * Adds sysfs entries as relevant.
489 */
490static int mmc_sysfs_add(struct mmc_host *host, struct mmc_card *card)
491{
492 int ret;
493
494 ret = mmc_add_attrs(card, mmc_dev_attrs);
495 if (ret < 0)
496 return ret;
497
498 return 0;
499}
500
501/*
502 * Removes the sysfs entries added by mmc_sysfs_add().
503 */
504static void mmc_sysfs_remove(struct mmc_host *host, struct mmc_card *card)
505{
506 mmc_remove_attrs(card, mmc_dev_attrs);
507}
508
509#ifdef CONFIG_MMC_UNSAFE_RESUME 499#ifdef CONFIG_MMC_UNSAFE_RESUME
510 500
511/* 501/*
@@ -560,8 +550,6 @@ static void mmc_resume(struct mmc_host *host)
560static const struct mmc_bus_ops mmc_ops = { 550static const struct mmc_bus_ops mmc_ops = {
561 .remove = mmc_remove, 551 .remove = mmc_remove,
562 .detect = mmc_detect, 552 .detect = mmc_detect,
563 .sysfs_add = mmc_sysfs_add,
564 .sysfs_remove = mmc_sysfs_remove,
565 .suspend = mmc_suspend, 553 .suspend = mmc_suspend,
566 .resume = mmc_resume, 554 .resume = mmc_resume,
567}; 555};
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index d1c1e0f592f1..7ef3b15c5e3d 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -18,7 +18,6 @@
18#include <linux/mmc/sd.h> 18#include <linux/mmc/sd.h>
19 19
20#include "core.h" 20#include "core.h"
21#include "sysfs.h"
22#include "bus.h" 21#include "bus.h"
23#include "mmc_ops.h" 22#include "mmc_ops.h"
24#include "sd_ops.h" 23#include "sd_ops.h"
@@ -283,6 +282,47 @@ out:
283 return err; 282 return err;
284} 283}
285 284
285MMC_DEV_ATTR(cid, "%08x%08x%08x%08x\n", card->raw_cid[0], card->raw_cid[1],
286 card->raw_cid[2], card->raw_cid[3]);
287MMC_DEV_ATTR(csd, "%08x%08x%08x%08x\n", card->raw_csd[0], card->raw_csd[1],
288 card->raw_csd[2], card->raw_csd[3]);
289MMC_DEV_ATTR(scr, "%08x%08x\n", card->raw_scr[0], card->raw_scr[1]);
290MMC_DEV_ATTR(date, "%02d/%04d\n", card->cid.month, card->cid.year);
291MMC_DEV_ATTR(fwrev, "0x%x\n", card->cid.fwrev);
292MMC_DEV_ATTR(hwrev, "0x%x\n", card->cid.hwrev);
293MMC_DEV_ATTR(manfid, "0x%06x\n", card->cid.manfid);
294MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name);
295MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid);
296MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial);
297
298
299static struct attribute *sd_std_attrs[] = {
300 &dev_attr_cid.attr,
301 &dev_attr_csd.attr,
302 &dev_attr_scr.attr,
303 &dev_attr_date.attr,
304 &dev_attr_fwrev.attr,
305 &dev_attr_hwrev.attr,
306 &dev_attr_manfid.attr,
307 &dev_attr_name.attr,
308 &dev_attr_oemid.attr,
309 &dev_attr_serial.attr,
310 NULL,
311};
312
313static struct attribute_group sd_std_attr_group = {
314 .attrs = sd_std_attrs,
315};
316
317static struct attribute_group *sd_attr_groups[] = {
318 &sd_std_attr_group,
319 NULL,
320};
321
322static struct device_type sd_type = {
323 .groups = sd_attr_groups,
324};
325
286/* 326/*
287 * Handle the detection and initialisation of a card. 327 * Handle the detection and initialisation of a card.
288 * 328 *
@@ -352,7 +392,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
352 /* 392 /*
353 * Allocate card structure. 393 * Allocate card structure.
354 */ 394 */
355 card = mmc_alloc_card(host); 395 card = mmc_alloc_card(host, &sd_type);
356 if (IS_ERR(card)) { 396 if (IS_ERR(card)) {
357 err = PTR_ERR(card); 397 err = PTR_ERR(card);
358 goto err; 398 goto err;
@@ -518,55 +558,6 @@ static void mmc_sd_detect(struct mmc_host *host)
518 } 558 }
519} 559}
520 560
521MMC_ATTR_FN(cid, "%08x%08x%08x%08x\n", card->raw_cid[0], card->raw_cid[1],
522 card->raw_cid[2], card->raw_cid[3]);
523MMC_ATTR_FN(csd, "%08x%08x%08x%08x\n", card->raw_csd[0], card->raw_csd[1],
524 card->raw_csd[2], card->raw_csd[3]);
525MMC_ATTR_FN(scr, "%08x%08x\n", card->raw_scr[0], card->raw_scr[1]);
526MMC_ATTR_FN(date, "%02d/%04d\n", card->cid.month, card->cid.year);
527MMC_ATTR_FN(fwrev, "0x%x\n", card->cid.fwrev);
528MMC_ATTR_FN(hwrev, "0x%x\n", card->cid.hwrev);
529MMC_ATTR_FN(manfid, "0x%06x\n", card->cid.manfid);
530MMC_ATTR_FN(name, "%s\n", card->cid.prod_name);
531MMC_ATTR_FN(oemid, "0x%04x\n", card->cid.oemid);
532MMC_ATTR_FN(serial, "0x%08x\n", card->cid.serial);
533
534static struct device_attribute mmc_sd_dev_attrs[] = {
535 MMC_ATTR_RO(cid),
536 MMC_ATTR_RO(csd),
537 MMC_ATTR_RO(scr),
538 MMC_ATTR_RO(date),
539 MMC_ATTR_RO(fwrev),
540 MMC_ATTR_RO(hwrev),
541 MMC_ATTR_RO(manfid),
542 MMC_ATTR_RO(name),
543 MMC_ATTR_RO(oemid),
544 MMC_ATTR_RO(serial),
545 __ATTR_NULL,
546};
547
548/*
549 * Adds sysfs entries as relevant.
550 */
551static int mmc_sd_sysfs_add(struct mmc_host *host, struct mmc_card *card)
552{
553 int ret;
554
555 ret = mmc_add_attrs(card, mmc_sd_dev_attrs);
556 if (ret < 0)
557 return ret;
558
559 return 0;
560}
561
562/*
563 * Removes the sysfs entries added by mmc_sysfs_add().
564 */
565static void mmc_sd_sysfs_remove(struct mmc_host *host, struct mmc_card *card)
566{
567 mmc_remove_attrs(card, mmc_sd_dev_attrs);
568}
569
570#ifdef CONFIG_MMC_UNSAFE_RESUME 561#ifdef CONFIG_MMC_UNSAFE_RESUME
571 562
572/* 563/*
@@ -621,8 +612,6 @@ static void mmc_sd_resume(struct mmc_host *host)
621static const struct mmc_bus_ops mmc_sd_ops = { 612static const struct mmc_bus_ops mmc_sd_ops = {
622 .remove = mmc_sd_remove, 613 .remove = mmc_sd_remove,
623 .detect = mmc_sd_detect, 614 .detect = mmc_sd_detect,
624 .sysfs_add = mmc_sd_sysfs_add,
625 .sysfs_remove = mmc_sd_sysfs_remove,
626 .suspend = mmc_sd_suspend, 615 .suspend = mmc_sd_suspend,
627 .resume = mmc_sd_resume, 616 .resume = mmc_sd_resume,
628}; 617};
diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index 87a50f456efc..4eab79e09ccc 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -287,7 +287,7 @@ int mmc_attach_sdio(struct mmc_host *host, u32 ocr)
287 /* 287 /*
288 * Allocate card structure. 288 * Allocate card structure.
289 */ 289 */
290 card = mmc_alloc_card(host); 290 card = mmc_alloc_card(host, NULL);
291 if (IS_ERR(card)) { 291 if (IS_ERR(card)) {
292 err = PTR_ERR(card); 292 err = PTR_ERR(card);
293 goto err; 293 goto err;
diff --git a/drivers/mmc/core/sysfs.c b/drivers/mmc/core/sysfs.c
deleted file mode 100644
index 00a97e70f914..000000000000
--- a/drivers/mmc/core/sysfs.c
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * linux/drivers/mmc/core/sysfs.c
3 *
4 * Copyright (C) 2003 Russell King, All Rights Reserved.
5 * Copyright 2007 Pierre Ossman
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * MMC sysfs/driver model support.
12 */
13#include <linux/device.h>
14
15#include <linux/mmc/card.h>
16
17#include "sysfs.h"
18
19int mmc_add_attrs(struct mmc_card *card, struct device_attribute *attrs)
20{
21 int error = 0;
22 int i;
23
24 for (i = 0; attr_name(attrs[i]); i++) {
25 error = device_create_file(&card->dev, &attrs[i]);
26 if (error) {
27 while (--i >= 0)
28 device_remove_file(&card->dev, &attrs[i]);
29 break;
30 }
31 }
32
33 return error;
34}
35
36void mmc_remove_attrs(struct mmc_card *card, struct device_attribute *attrs)
37{
38 int i;
39
40 for (i = 0; attr_name(attrs[i]); i++)
41 device_remove_file(&card->dev, &attrs[i]);
42}
43
diff --git a/drivers/mmc/core/sysfs.h b/drivers/mmc/core/sysfs.h
deleted file mode 100644
index 4b8f670bd10f..000000000000
--- a/drivers/mmc/core/sysfs.h
+++ /dev/null
@@ -1,26 +0,0 @@
1/*
2 * linux/drivers/mmc/core/sysfs.h
3 *
4 * Copyright (C) 2003 Russell King, All Rights Reserved.
5 * Copyright 2007 Pierre Ossman
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef _MMC_CORE_SYSFS_H
12#define _MMC_CORE_SYSFS_H
13
14#define MMC_ATTR_FN(name, fmt, args...) \
15static ssize_t mmc_##name##_show (struct device *dev, struct device_attribute *attr, char *buf) \
16{ \
17 struct mmc_card *card = container_of(dev, struct mmc_card, dev);\
18 return sprintf(buf, fmt, args); \
19}
20
21#define MMC_ATTR_RO(name) __ATTR(name, S_IRUGO, mmc_##name##_show, NULL)
22
23int mmc_add_attrs(struct mmc_card *card, struct device_attribute *attrs);
24void mmc_remove_attrs(struct mmc_card *card, struct device_attribute *attrs);
25
26#endif
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index eeaaa9dce6ef..ad1880c67518 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -408,7 +408,6 @@ static int block2mtd_setup2(const char *val)
408 if (token[1]) { 408 if (token[1]) {
409 ret = parse_num(&erase_size, token[1]); 409 ret = parse_num(&erase_size, token[1]);
410 if (ret) { 410 if (ret) {
411 kfree(name);
412 parse_err("illegal erase size"); 411 parse_err("illegal erase size");
413 } 412 }
414 } 413 }
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index f00e04efbe28..bc4649a17b9d 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -202,9 +202,8 @@ static int physmap_flash_suspend(struct platform_device *dev, pm_message_t state
202 int ret = 0; 202 int ret = 0;
203 int i; 203 int i;
204 204
205 if (info) 205 for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++)
206 for (i = 0; i < MAX_RESOURCES; i++) 206 ret |= info->mtd[i]->suspend(info->mtd[i]);
207 ret |= info->mtd[i]->suspend(info->mtd[i]);
208 207
209 return ret; 208 return ret;
210} 209}
@@ -214,9 +213,9 @@ static int physmap_flash_resume(struct platform_device *dev)
214 struct physmap_flash_info *info = platform_get_drvdata(dev); 213 struct physmap_flash_info *info = platform_get_drvdata(dev);
215 int i; 214 int i;
216 215
217 if (info) 216 for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++)
218 for (i = 0; i < MAX_RESOURCES; i++) 217 info->mtd[i]->resume(info->mtd[i]);
219 info->mtd[i]->resume(info->mtd[i]); 218
220 return 0; 219 return 0;
221} 220}
222 221
@@ -225,8 +224,8 @@ static void physmap_flash_shutdown(struct platform_device *dev)
225 struct physmap_flash_info *info = platform_get_drvdata(dev); 224 struct physmap_flash_info *info = platform_get_drvdata(dev);
226 int i; 225 int i;
227 226
228 for (i = 0; i < MAX_RESOURCES; i++) 227 for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++)
229 if (info && info->mtd[i]->suspend(info->mtd[i]) == 0) 228 if (info->mtd[i]->suspend(info->mtd[i]) == 0)
230 info->mtd[i]->resume(info->mtd[i]); 229 info->mtd[i]->resume(info->mtd[i]);
231} 230}
232#else 231#else
diff --git a/drivers/mtd/nand/rtc_from4.c b/drivers/mtd/nand/rtc_from4.c
index 9189ec8f243e..0f6ac250f434 100644
--- a/drivers/mtd/nand/rtc_from4.c
+++ b/drivers/mtd/nand/rtc_from4.c
@@ -460,7 +460,7 @@ static int rtc_from4_errstat(struct mtd_info *mtd, struct nand_chip *this,
460 er_stat |= 1 << 1; 460 er_stat |= 1 << 1;
461 kfree(buf); 461 kfree(buf);
462 } 462 }
463 463out:
464 rtn = status; 464 rtn = status;
465 if (er_stat == 0) { /* if ECC is available */ 465 if (er_stat == 0) { /* if ECC is available */
466 rtn = (status & ~NAND_STATUS_FAIL); /* clear the error bit */ 466 rtn = (status & ~NAND_STATUS_FAIL); /* clear the error bit */
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index b09a53de1c53..d63cc93f055d 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -968,7 +968,7 @@ dm9000_interrupt(int irq, void *dev_id)
968struct dm9000_rxhdr { 968struct dm9000_rxhdr {
969 u8 RxPktReady; 969 u8 RxPktReady;
970 u8 RxStatus; 970 u8 RxStatus;
971 u16 RxLen; 971 __le16 RxLen;
972} __attribute__((__packed__)); 972} __attribute__((__packed__));
973 973
974/* 974/*
diff --git a/drivers/net/fec_mpc52xx_phy.c b/drivers/net/fec_mpc52xx_phy.c
index 1837584c4504..6a3ac4ea97e9 100644
--- a/drivers/net/fec_mpc52xx_phy.c
+++ b/drivers/net/fec_mpc52xx_phy.c
@@ -109,7 +109,8 @@ static int mpc52xx_fec_mdio_probe(struct of_device *of, const struct of_device_i
109 int irq = irq_of_parse_and_map(child, 0); 109 int irq = irq_of_parse_and_map(child, 0);
110 if (irq != NO_IRQ) { 110 if (irq != NO_IRQ) {
111 const u32 *id = of_get_property(child, "reg", NULL); 111 const u32 *id = of_get_property(child, "reg", NULL);
112 bus->irq[*id] = irq; 112 if (id)
113 bus->irq[*id] = irq;
113 } 114 }
114 } 115 }
115 116
diff --git a/drivers/net/plip.c b/drivers/net/plip.c
index fee3d7b1feba..1e965427b0e9 100644
--- a/drivers/net/plip.c
+++ b/drivers/net/plip.c
@@ -903,17 +903,18 @@ plip_interrupt(void *dev_id)
903 struct net_local *nl; 903 struct net_local *nl;
904 struct plip_local *rcv; 904 struct plip_local *rcv;
905 unsigned char c0; 905 unsigned char c0;
906 unsigned long flags;
906 907
907 nl = netdev_priv(dev); 908 nl = netdev_priv(dev);
908 rcv = &nl->rcv_data; 909 rcv = &nl->rcv_data;
909 910
910 spin_lock_irq (&nl->lock); 911 spin_lock_irqsave (&nl->lock, flags);
911 912
912 c0 = read_status(dev); 913 c0 = read_status(dev);
913 if ((c0 & 0xf8) != 0xc0) { 914 if ((c0 & 0xf8) != 0xc0) {
914 if ((dev->irq != -1) && (net_debug > 1)) 915 if ((dev->irq != -1) && (net_debug > 1))
915 printk(KERN_DEBUG "%s: spurious interrupt\n", dev->name); 916 printk(KERN_DEBUG "%s: spurious interrupt\n", dev->name);
916 spin_unlock_irq (&nl->lock); 917 spin_unlock_irqrestore (&nl->lock, flags);
917 return; 918 return;
918 } 919 }
919 920
@@ -942,7 +943,7 @@ plip_interrupt(void *dev_id)
942 break; 943 break;
943 } 944 }
944 945
945 spin_unlock_irq(&nl->lock); 946 spin_unlock_irqrestore(&nl->lock, flags);
946} 947}
947 948
948static int 949static int
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 54c662690f65..853bce0ac478 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -4329,10 +4329,14 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
4329 if (!hw) 4329 if (!hw)
4330 return 0; 4330 return 0;
4331 4331
4332 del_timer_sync(&hw->watchdog_timer);
4333 cancel_work_sync(&hw->restart_work);
4334
4332 for (i = 0; i < hw->ports; i++) { 4335 for (i = 0; i < hw->ports; i++) {
4333 struct net_device *dev = hw->dev[i]; 4336 struct net_device *dev = hw->dev[i];
4334 struct sky2_port *sky2 = netdev_priv(dev); 4337 struct sky2_port *sky2 = netdev_priv(dev);
4335 4338
4339 netif_device_detach(dev);
4336 if (netif_running(dev)) 4340 if (netif_running(dev))
4337 sky2_down(dev); 4341 sky2_down(dev);
4338 4342
@@ -4383,6 +4387,8 @@ static int sky2_resume(struct pci_dev *pdev)
4383 4387
4384 for (i = 0; i < hw->ports; i++) { 4388 for (i = 0; i < hw->ports; i++) {
4385 struct net_device *dev = hw->dev[i]; 4389 struct net_device *dev = hw->dev[i];
4390
4391 netif_device_attach(dev);
4386 if (netif_running(dev)) { 4392 if (netif_running(dev)) {
4387 err = sky2_up(dev); 4393 err = sky2_up(dev);
4388 if (err) { 4394 if (err) {
diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
index 7e1f00131f91..df56a518691c 100644
--- a/drivers/net/usb/rtl8150.c
+++ b/drivers/net/usb/rtl8150.c
@@ -376,7 +376,7 @@ static int alloc_all_urbs(rtl8150_t * dev)
376 return 0; 376 return 0;
377 } 377 }
378 dev->ctrl_urb = usb_alloc_urb(0, GFP_KERNEL); 378 dev->ctrl_urb = usb_alloc_urb(0, GFP_KERNEL);
379 if (!dev->intr_urb) { 379 if (!dev->ctrl_urb) {
380 usb_free_urb(dev->rx_urb); 380 usb_free_urb(dev->rx_urb);
381 usb_free_urb(dev->tx_urb); 381 usb_free_urb(dev->tx_urb);
382 usb_free_urb(dev->intr_urb); 382 usb_free_urb(dev->intr_urb);
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 7f4836b8e71e..5fa4ba0d9934 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -467,7 +467,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
467 t_slot = pciehp_find_slot(ctrl, ctrl->slot_device_offset); 467 t_slot = pciehp_find_slot(ctrl, ctrl->slot_device_offset);
468 468
469 t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */ 469 t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */
470 if (value) { 470 if (value && pciehp_force) {
471 rc = pciehp_enable_slot(t_slot); 471 rc = pciehp_enable_slot(t_slot);
472 if (rc) /* -ENODEV: shouldn't happen, but deal with it */ 472 if (rc) /* -ENODEV: shouldn't happen, but deal with it */
473 value = 0; 473 value = 0;
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 977d29b32295..4cb949f0ebd9 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -1097,6 +1097,8 @@ static void iommu_free_domain(struct dmar_domain *domain)
1097} 1097}
1098 1098
1099static struct iova_domain reserved_iova_list; 1099static struct iova_domain reserved_iova_list;
1100static struct lock_class_key reserved_alloc_key;
1101static struct lock_class_key reserved_rbtree_key;
1100 1102
1101static void dmar_init_reserved_ranges(void) 1103static void dmar_init_reserved_ranges(void)
1102{ 1104{
@@ -1107,6 +1109,11 @@ static void dmar_init_reserved_ranges(void)
1107 1109
1108 init_iova_domain(&reserved_iova_list, DMA_32BIT_PFN); 1110 init_iova_domain(&reserved_iova_list, DMA_32BIT_PFN);
1109 1111
1112 lockdep_set_class(&reserved_iova_list.iova_alloc_lock,
1113 &reserved_alloc_key);
1114 lockdep_set_class(&reserved_iova_list.iova_rbtree_lock,
1115 &reserved_rbtree_key);
1116
1110 /* IOAPIC ranges shouldn't be accessed by DMA */ 1117 /* IOAPIC ranges shouldn't be accessed by DMA */
1111 iova = reserve_iova(&reserved_iova_list, IOVA_PFN(IOAPIC_RANGE_START), 1118 iova = reserve_iova(&reserved_iova_list, IOVA_PFN(IOAPIC_RANGE_START),
1112 IOVA_PFN(IOAPIC_RANGE_END)); 1119 IOVA_PFN(IOAPIC_RANGE_END));
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 183fddaa38b7..a4445b7210bf 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -314,24 +314,6 @@ int pci_find_ht_capability(struct pci_dev *dev, int ht_cap)
314} 314}
315EXPORT_SYMBOL_GPL(pci_find_ht_capability); 315EXPORT_SYMBOL_GPL(pci_find_ht_capability);
316 316
317void pcie_wait_pending_transaction(struct pci_dev *dev)
318{
319 int pos;
320 u16 reg16;
321
322 pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
323 if (!pos)
324 return;
325 while (1) {
326 pci_read_config_word(dev, pos + PCI_EXP_DEVSTA, &reg16);
327 if (!(reg16 & PCI_EXP_DEVSTA_TRPND))
328 break;
329 cpu_relax();
330 }
331
332}
333EXPORT_SYMBOL_GPL(pcie_wait_pending_transaction);
334
335/** 317/**
336 * pci_find_parent_resource - return resource region of parent bus of given region 318 * pci_find_parent_resource - return resource region of parent bus of given region
337 * @dev: PCI device structure contains resources to be searched 319 * @dev: PCI device structure contains resources to be searched
@@ -936,9 +918,6 @@ pci_disable_device(struct pci_dev *dev)
936 if (atomic_sub_return(1, &dev->enable_cnt) != 0) 918 if (atomic_sub_return(1, &dev->enable_cnt) != 0)
937 return; 919 return;
938 920
939 /* Wait for all transactions are finished before disabling the device */
940 pcie_wait_pending_transaction(dev);
941
942 pci_read_config_word(dev, PCI_COMMAND, &pci_command); 921 pci_read_config_word(dev, PCI_COMMAND, &pci_command);
943 if (pci_command & PCI_COMMAND_MASTER) { 922 if (pci_command & PCI_COMMAND_MASTER) {
944 pci_command &= ~PCI_COMMAND_MASTER; 923 pci_command &= ~PCI_COMMAND_MASTER;
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index e9a333d98552..e887aa45c9cd 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -951,6 +951,12 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82375, quirk_e
951 * accesses to the SMBus registers, with potentially bad effects. Thus you 951 * accesses to the SMBus registers, with potentially bad effects. Thus you
952 * should be very careful when adding new entries: if SMM is accessing the 952 * should be very careful when adding new entries: if SMM is accessing the
953 * Intel SMBus, this is a very good reason to leave it hidden. 953 * Intel SMBus, this is a very good reason to leave it hidden.
954 *
955 * Likewise, many recent laptops use ACPI for thermal management. If the
956 * ACPI DSDT code accesses the SMBus, then Linux should not access it
957 * natively, and keeping the SMBus hidden is the right thing to do. If you
958 * are about to add an entry in the table below, please first disassemble
959 * the DSDT and double-check that there is no code accessing the SMBus.
954 */ 960 */
955static int asus_hides_smbus; 961static int asus_hides_smbus;
956 962
@@ -1028,11 +1034,6 @@ static void __init asus_hides_smbus_hostbridge(struct pci_dev *dev)
1028 case 0x12bf: /* HP xw4100 */ 1034 case 0x12bf: /* HP xw4100 */
1029 asus_hides_smbus = 1; 1035 asus_hides_smbus = 1;
1030 } 1036 }
1031 else if (dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB)
1032 switch (dev->subsystem_device) {
1033 case 0x099c: /* HP Compaq nx6110 */
1034 asus_hides_smbus = 1;
1035 }
1036 } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG)) { 1037 } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG)) {
1037 if (dev->device == PCI_DEVICE_ID_INTEL_82855PM_HB) 1038 if (dev->device == PCI_DEVICE_ID_INTEL_82855PM_HB)
1038 switch(dev->subsystem_device) { 1039 switch(dev->subsystem_device) {
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 125e7b7f34ff..f7cb8e0758b4 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -486,12 +486,7 @@ void __ref pci_bus_size_bridges(struct pci_bus *bus)
486 break; 486 break;
487 487
488 case PCI_CLASS_BRIDGE_PCI: 488 case PCI_CLASS_BRIDGE_PCI:
489 /* don't size subtractive decoding (transparent)
490 * PCI-to-PCI bridges */
491 if (bus->self->transparent)
492 break;
493 pci_bridge_check_ranges(bus); 489 pci_bridge_check_ranges(bus);
494 /* fall through */
495 default: 490 default:
496 pbus_size_io(bus); 491 pbus_size_io(bus);
497 /* If the bridge supports prefetchable range, size it 492 /* If the bridge supports prefetchable range, size it
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index 2c925b7cd93e..257f5d827d83 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -88,6 +88,15 @@ MODULE_LICENSE("GPL");
88#define _LTAG_MEM32RANGE 0x85 88#define _LTAG_MEM32RANGE 0x85
89#define _LTAG_FIXEDMEM32RANGE 0x86 89#define _LTAG_FIXEDMEM32RANGE 0x86
90 90
91/*
92 * Sizes of ISAPNP logical device configuration register sets.
93 * See PNP-ISA-v1.0a.pdf, Appendix A.
94 */
95#define ISAPNP_MAX_MEM 4
96#define ISAPNP_MAX_PORT 8
97#define ISAPNP_MAX_IRQ 2
98#define ISAPNP_MAX_DMA 2
99
91static unsigned char isapnp_checksum_value; 100static unsigned char isapnp_checksum_value;
92static DEFINE_MUTEX(isapnp_cfg_mutex); 101static DEFINE_MUTEX(isapnp_cfg_mutex);
93static int isapnp_csn_count; 102static int isapnp_csn_count;
@@ -945,14 +954,14 @@ static int isapnp_read_resources(struct pnp_dev *dev,
945 954
946 dev->active = isapnp_read_byte(ISAPNP_CFG_ACTIVATE); 955 dev->active = isapnp_read_byte(ISAPNP_CFG_ACTIVATE);
947 if (dev->active) { 956 if (dev->active) {
948 for (tmp = 0; tmp < PNP_MAX_PORT; tmp++) { 957 for (tmp = 0; tmp < ISAPNP_MAX_PORT; tmp++) {
949 ret = isapnp_read_word(ISAPNP_CFG_PORT + (tmp << 1)); 958 ret = isapnp_read_word(ISAPNP_CFG_PORT + (tmp << 1));
950 if (!ret) 959 if (!ret)
951 continue; 960 continue;
952 res->port_resource[tmp].start = ret; 961 res->port_resource[tmp].start = ret;
953 res->port_resource[tmp].flags = IORESOURCE_IO; 962 res->port_resource[tmp].flags = IORESOURCE_IO;
954 } 963 }
955 for (tmp = 0; tmp < PNP_MAX_MEM; tmp++) { 964 for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) {
956 ret = 965 ret =
957 isapnp_read_word(ISAPNP_CFG_MEM + (tmp << 3)) << 8; 966 isapnp_read_word(ISAPNP_CFG_MEM + (tmp << 3)) << 8;
958 if (!ret) 967 if (!ret)
@@ -960,7 +969,7 @@ static int isapnp_read_resources(struct pnp_dev *dev,
960 res->mem_resource[tmp].start = ret; 969 res->mem_resource[tmp].start = ret;
961 res->mem_resource[tmp].flags = IORESOURCE_MEM; 970 res->mem_resource[tmp].flags = IORESOURCE_MEM;
962 } 971 }
963 for (tmp = 0; tmp < PNP_MAX_IRQ; tmp++) { 972 for (tmp = 0; tmp < ISAPNP_MAX_IRQ; tmp++) {
964 ret = 973 ret =
965 (isapnp_read_word(ISAPNP_CFG_IRQ + (tmp << 1)) >> 974 (isapnp_read_word(ISAPNP_CFG_IRQ + (tmp << 1)) >>
966 8); 975 8);
@@ -970,7 +979,7 @@ static int isapnp_read_resources(struct pnp_dev *dev,
970 res->irq_resource[tmp].end = ret; 979 res->irq_resource[tmp].end = ret;
971 res->irq_resource[tmp].flags = IORESOURCE_IRQ; 980 res->irq_resource[tmp].flags = IORESOURCE_IRQ;
972 } 981 }
973 for (tmp = 0; tmp < PNP_MAX_DMA; tmp++) { 982 for (tmp = 0; tmp < ISAPNP_MAX_DMA; tmp++) {
974 ret = isapnp_read_byte(ISAPNP_CFG_DMA + tmp); 983 ret = isapnp_read_byte(ISAPNP_CFG_DMA + tmp);
975 if (ret == 4) 984 if (ret == 4)
976 continue; 985 continue;
@@ -1002,14 +1011,14 @@ static int isapnp_set_resources(struct pnp_dev *dev,
1002 isapnp_cfg_begin(dev->card->number, dev->number); 1011 isapnp_cfg_begin(dev->card->number, dev->number);
1003 dev->active = 1; 1012 dev->active = 1;
1004 for (tmp = 0; 1013 for (tmp = 0;
1005 tmp < PNP_MAX_PORT 1014 tmp < ISAPNP_MAX_PORT
1006 && (res->port_resource[tmp]. 1015 && (res->port_resource[tmp].
1007 flags & (IORESOURCE_IO | IORESOURCE_UNSET)) == IORESOURCE_IO; 1016 flags & (IORESOURCE_IO | IORESOURCE_UNSET)) == IORESOURCE_IO;
1008 tmp++) 1017 tmp++)
1009 isapnp_write_word(ISAPNP_CFG_PORT + (tmp << 1), 1018 isapnp_write_word(ISAPNP_CFG_PORT + (tmp << 1),
1010 res->port_resource[tmp].start); 1019 res->port_resource[tmp].start);
1011 for (tmp = 0; 1020 for (tmp = 0;
1012 tmp < PNP_MAX_IRQ 1021 tmp < ISAPNP_MAX_IRQ
1013 && (res->irq_resource[tmp]. 1022 && (res->irq_resource[tmp].
1014 flags & (IORESOURCE_IRQ | IORESOURCE_UNSET)) == IORESOURCE_IRQ; 1023 flags & (IORESOURCE_IRQ | IORESOURCE_UNSET)) == IORESOURCE_IRQ;
1015 tmp++) { 1024 tmp++) {
@@ -1019,14 +1028,14 @@ static int isapnp_set_resources(struct pnp_dev *dev,
1019 isapnp_write_byte(ISAPNP_CFG_IRQ + (tmp << 1), irq); 1028 isapnp_write_byte(ISAPNP_CFG_IRQ + (tmp << 1), irq);
1020 } 1029 }
1021 for (tmp = 0; 1030 for (tmp = 0;
1022 tmp < PNP_MAX_DMA 1031 tmp < ISAPNP_MAX_DMA
1023 && (res->dma_resource[tmp]. 1032 && (res->dma_resource[tmp].
1024 flags & (IORESOURCE_DMA | IORESOURCE_UNSET)) == IORESOURCE_DMA; 1033 flags & (IORESOURCE_DMA | IORESOURCE_UNSET)) == IORESOURCE_DMA;
1025 tmp++) 1034 tmp++)
1026 isapnp_write_byte(ISAPNP_CFG_DMA + tmp, 1035 isapnp_write_byte(ISAPNP_CFG_DMA + tmp,
1027 res->dma_resource[tmp].start); 1036 res->dma_resource[tmp].start);
1028 for (tmp = 0; 1037 for (tmp = 0;
1029 tmp < PNP_MAX_MEM 1038 tmp < ISAPNP_MAX_MEM
1030 && (res->mem_resource[tmp]. 1039 && (res->mem_resource[tmp].
1031 flags & (IORESOURCE_MEM | IORESOURCE_UNSET)) == IORESOURCE_MEM; 1040 flags & (IORESOURCE_MEM | IORESOURCE_UNSET)) == IORESOURCE_MEM;
1032 tmp++) 1041 tmp++)
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index 6aa231ef642d..2dcd1960aca8 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -85,7 +85,7 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res,
85 i < PNP_MAX_IRQ) 85 i < PNP_MAX_IRQ)
86 i++; 86 i++;
87 if (i >= PNP_MAX_IRQ && !warned) { 87 if (i >= PNP_MAX_IRQ && !warned) {
88 printk(KERN_ERR "pnpacpi: exceeded the max number of IRQ " 88 printk(KERN_WARNING "pnpacpi: exceeded the max number of IRQ "
89 "resources: %d \n", PNP_MAX_IRQ); 89 "resources: %d \n", PNP_MAX_IRQ);
90 warned = 1; 90 warned = 1;
91 return; 91 return;
@@ -187,7 +187,7 @@ static void pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res,
187 res->dma_resource[i].start = dma; 187 res->dma_resource[i].start = dma;
188 res->dma_resource[i].end = dma; 188 res->dma_resource[i].end = dma;
189 } else if (!warned) { 189 } else if (!warned) {
190 printk(KERN_ERR "pnpacpi: exceeded the max number of DMA " 190 printk(KERN_WARNING "pnpacpi: exceeded the max number of DMA "
191 "resources: %d \n", PNP_MAX_DMA); 191 "resources: %d \n", PNP_MAX_DMA);
192 warned = 1; 192 warned = 1;
193 } 193 }
@@ -213,7 +213,7 @@ static void pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res,
213 res->port_resource[i].start = io; 213 res->port_resource[i].start = io;
214 res->port_resource[i].end = io + len - 1; 214 res->port_resource[i].end = io + len - 1;
215 } else if (!warned) { 215 } else if (!warned) {
216 printk(KERN_ERR "pnpacpi: exceeded the max number of IO " 216 printk(KERN_WARNING "pnpacpi: exceeded the max number of IO "
217 "resources: %d \n", PNP_MAX_PORT); 217 "resources: %d \n", PNP_MAX_PORT);
218 warned = 1; 218 warned = 1;
219 } 219 }
@@ -241,7 +241,7 @@ static void pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res,
241 res->mem_resource[i].start = mem; 241 res->mem_resource[i].start = mem;
242 res->mem_resource[i].end = mem + len - 1; 242 res->mem_resource[i].end = mem + len - 1;
243 } else if (!warned) { 243 } else if (!warned) {
244 printk(KERN_ERR "pnpacpi: exceeded the max number of mem " 244 printk(KERN_WARNING "pnpacpi: exceeded the max number of mem "
245 "resources: %d\n", PNP_MAX_MEM); 245 "resources: %d\n", PNP_MAX_MEM);
246 warned = 1; 246 warned = 1;
247 } 247 }
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 82f5ad9c3af4..9e7de63b26ef 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -16,7 +16,7 @@ menuconfig RTC_CLASS
16 probably want to enable one or more of the interfaces below. 16 probably want to enable one or more of the interfaces below.
17 17
18 This driver can also be built as a module. If so, the module 18 This driver can also be built as a module. If so, the module
19 will be called rtc-class. 19 will be called rtc-core.
20 20
21if RTC_CLASS 21if RTC_CLASS
22 22
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c
index bbf10ecf416c..56728a2a3385 100644
--- a/drivers/rtc/rtc-at91sam9.c
+++ b/drivers/rtc/rtc-at91sam9.c
@@ -274,7 +274,7 @@ static irqreturn_t at91_rtc_interrupt(int irq, void *_rtc)
274 * SR clears it, so we must only read it in this irq handler! 274 * SR clears it, so we must only read it in this irq handler!
275 */ 275 */
276 mr = rtt_readl(rtc, MR) & (AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN); 276 mr = rtt_readl(rtc, MR) & (AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN);
277 sr = rtt_readl(rtc, SR) & mr; 277 sr = rtt_readl(rtc, SR) & (mr >> 16);
278 if (!sr) 278 if (!sr)
279 return IRQ_NONE; 279 return IRQ_NONE;
280 280
@@ -321,6 +321,10 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
321 if (!rtc) 321 if (!rtc)
322 return -ENOMEM; 322 return -ENOMEM;
323 323
324 /* platform setup code should have handled this; sigh */
325 if (!device_can_wakeup(&pdev->dev))
326 device_init_wakeup(&pdev->dev, 1);
327
324 platform_set_drvdata(pdev, rtc); 328 platform_set_drvdata(pdev, rtc);
325 rtc->rtt = (void __force __iomem *) (AT91_VA_BASE_SYS - AT91_BASE_SYS); 329 rtc->rtt = (void __force __iomem *) (AT91_VA_BASE_SYS - AT91_BASE_SYS);
326 rtc->rtt += r->start; 330 rtc->rtt += r->start;
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index c46666a24809..b9d374082b65 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -325,7 +325,7 @@ menuconfig SCSI_LOWLEVEL
325 depends on SCSI!=n 325 depends on SCSI!=n
326 default y 326 default y
327 327
328if SCSI_LOWLEVEL 328if SCSI_LOWLEVEL && SCSI
329 329
330config ISCSI_TCP 330config ISCSI_TCP
331 tristate "iSCSI Initiator over TCP/IP" 331 tristate "iSCSI Initiator over TCP/IP"
diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c
index f608d4a1d6da..792b2e807bf3 100644
--- a/drivers/scsi/a100u2w.c
+++ b/drivers/scsi/a100u2w.c
@@ -674,12 +674,13 @@ static struct orc_scb *__orc_alloc_scb(struct orc_host * host)
674 for (index = 0; index < 32; index++) { 674 for (index = 0; index < 32; index++) {
675 if ((host->allocation_map[channel][i] >> index) & 0x01) { 675 if ((host->allocation_map[channel][i] >> index) & 0x01) {
676 host->allocation_map[channel][i] &= ~(1 << index); 676 host->allocation_map[channel][i] &= ~(1 << index);
677 break; 677 idx = index + 32 * i;
678 /*
679 * Translate the index to a structure instance
680 */
681 return host->scb_virt + idx;
678 } 682 }
679 } 683 }
680 idx = index + 32 * i;
681 /* Translate the index to a structure instance */
682 return (struct orc_scb *) ((unsigned long) host->scb_virt + (idx * sizeof(struct orc_scb)));
683 } 684 }
684 return NULL; 685 return NULL;
685} 686}
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 3c2d6888bb8c..8591585e5cc5 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -6439,7 +6439,7 @@ static int AdvLoadMicrocode(AdvPortAddr iop_base, unsigned char *buf, int size,
6439 i += 2; 6439 i += 2;
6440 len += 2; 6440 len += 2;
6441 } else { 6441 } else {
6442 unsigned char off = buf[i] * 2; 6442 unsigned int off = buf[i] * 2;
6443 unsigned short word = (buf[off + 1] << 8) | buf[off]; 6443 unsigned short word = (buf[off + 1] << 8) | buf[off];
6444 AdvWriteWordAutoIncLram(iop_base, word); 6444 AdvWriteWordAutoIncLram(iop_base, word);
6445 len += 2; 6445 len += 2;
diff --git a/drivers/scsi/arcmsr/arcmsr.h b/drivers/scsi/arcmsr/arcmsr.h
index 0393707bdfce..3288be2e49f8 100644
--- a/drivers/scsi/arcmsr/arcmsr.h
+++ b/drivers/scsi/arcmsr/arcmsr.h
@@ -341,13 +341,13 @@ struct MessageUnit_B
341 uint32_t done_qbuffer[ARCMSR_MAX_HBB_POSTQUEUE]; 341 uint32_t done_qbuffer[ARCMSR_MAX_HBB_POSTQUEUE];
342 uint32_t postq_index; 342 uint32_t postq_index;
343 uint32_t doneq_index; 343 uint32_t doneq_index;
344 uint32_t __iomem *drv2iop_doorbell_reg; 344 void __iomem *drv2iop_doorbell_reg;
345 uint32_t __iomem *drv2iop_doorbell_mask_reg; 345 void __iomem *drv2iop_doorbell_mask_reg;
346 uint32_t __iomem *iop2drv_doorbell_reg; 346 void __iomem *iop2drv_doorbell_reg;
347 uint32_t __iomem *iop2drv_doorbell_mask_reg; 347 void __iomem *iop2drv_doorbell_mask_reg;
348 uint32_t __iomem *msgcode_rwbuffer_reg; 348 void __iomem *msgcode_rwbuffer_reg;
349 uint32_t __iomem *ioctl_wbuffer_reg; 349 void __iomem *ioctl_wbuffer_reg;
350 uint32_t __iomem *ioctl_rbuffer_reg; 350 void __iomem *ioctl_rbuffer_reg;
351}; 351};
352 352
353/* 353/*
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 27ebd336409b..0b2080d33575 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -493,6 +493,12 @@ int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd, char *cmnd,
493 if (!scp) 493 if (!scp)
494 return -ENOMEM; 494 return -ENOMEM;
495 495
496 scp->sense_buffer = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL);
497 if (!scp->sense_buffer) {
498 kfree(scp);
499 return -ENOMEM;
500 }
501
496 scp->device = sdev; 502 scp->device = sdev;
497 memset(&cmndinfo, 0, sizeof(cmndinfo)); 503 memset(&cmndinfo, 0, sizeof(cmndinfo));
498 504
@@ -513,6 +519,7 @@ int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd, char *cmnd,
513 rval = cmndinfo.status; 519 rval = cmndinfo.status;
514 if (info) 520 if (info)
515 *info = cmndinfo.info; 521 *info = cmndinfo.info;
522 kfree(scp->sense_buffer);
516 kfree(scp); 523 kfree(scp);
517 return rval; 524 return rval;
518} 525}
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 880c78bff0e1..ed7e0a1fc34d 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -218,18 +218,24 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
218 218
219 get_device(&shost->shost_gendev); 219 get_device(&shost->shost_gendev);
220 220
221 if (shost->transportt->host_size && 221 if (shost->transportt->host_size) {
222 (shost->shost_data = kzalloc(shost->transportt->host_size, 222 shost->shost_data = kzalloc(shost->transportt->host_size,
223 GFP_KERNEL)) == NULL) 223 GFP_KERNEL);
224 goto out_del_classdev; 224 if (shost->shost_data == NULL) {
225 error = -ENOMEM;
226 goto out_del_classdev;
227 }
228 }
225 229
226 if (shost->transportt->create_work_queue) { 230 if (shost->transportt->create_work_queue) {
227 snprintf(shost->work_q_name, KOBJ_NAME_LEN, "scsi_wq_%d", 231 snprintf(shost->work_q_name, KOBJ_NAME_LEN, "scsi_wq_%d",
228 shost->host_no); 232 shost->host_no);
229 shost->work_q = create_singlethread_workqueue( 233 shost->work_q = create_singlethread_workqueue(
230 shost->work_q_name); 234 shost->work_q_name);
231 if (!shost->work_q) 235 if (!shost->work_q) {
236 error = -EINVAL;
232 goto out_free_shost_data; 237 goto out_free_shost_data;
238 }
233 } 239 }
234 240
235 error = scsi_sysfs_add_host(shost); 241 error = scsi_sysfs_add_host(shost);
diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c
index 31b9af224243..709a6f75ca9d 100644
--- a/drivers/scsi/libsas/sas_discover.c
+++ b/drivers/scsi/libsas/sas_discover.c
@@ -295,11 +295,14 @@ static void sas_discover_domain(struct work_struct *work)
295 case FANOUT_DEV: 295 case FANOUT_DEV:
296 error = sas_discover_root_expander(dev); 296 error = sas_discover_root_expander(dev);
297 break; 297 break;
298#ifdef CONFIG_SCSI_SAS_ATA
299 case SATA_DEV: 298 case SATA_DEV:
300 case SATA_PM: 299 case SATA_PM:
300#ifdef CONFIG_SCSI_SAS_ATA
301 error = sas_discover_sata(dev); 301 error = sas_discover_sata(dev);
302 break; 302 break;
303#else
304 SAS_DPRINTK("ATA device seen but CONFIG_SCSI_SAS_ATA=N so cannot attach\n");
305 /* Fall through */
303#endif 306#endif
304 default: 307 default:
305 error = -ENXIO; 308 error = -ENXIO;
diff --git a/drivers/scsi/mvsas.c b/drivers/scsi/mvsas.c
index 5ec0665b3a3d..e55b9037adb2 100644
--- a/drivers/scsi/mvsas.c
+++ b/drivers/scsi/mvsas.c
@@ -37,11 +37,13 @@
37#include <linux/dma-mapping.h> 37#include <linux/dma-mapping.h>
38#include <linux/ctype.h> 38#include <linux/ctype.h>
39#include <scsi/libsas.h> 39#include <scsi/libsas.h>
40#include <scsi/scsi_tcq.h>
41#include <scsi/sas_ata.h>
40#include <asm/io.h> 42#include <asm/io.h>
41 43
42#define DRV_NAME "mvsas" 44#define DRV_NAME "mvsas"
43#define DRV_VERSION "0.5.1" 45#define DRV_VERSION "0.5.2"
44#define _MV_DUMP 0 46#define _MV_DUMP 0
45#define MVS_DISABLE_NVRAM 47#define MVS_DISABLE_NVRAM
46#define MVS_DISABLE_MSI 48#define MVS_DISABLE_MSI
47 49
@@ -52,7 +54,7 @@
52 readl(regs + MVS_##reg); \ 54 readl(regs + MVS_##reg); \
53 } while (0) 55 } while (0)
54 56
55#define MVS_ID_NOT_MAPPED 0xff 57#define MVS_ID_NOT_MAPPED 0x7f
56#define MVS_CHIP_SLOT_SZ (1U << mvi->chip->slot_width) 58#define MVS_CHIP_SLOT_SZ (1U << mvi->chip->slot_width)
57 59
58/* offset for D2H FIS in the Received FIS List Structure */ 60/* offset for D2H FIS in the Received FIS List Structure */
@@ -84,6 +86,7 @@ enum driver_configuration {
84 MVS_RX_FIS_COUNT = 17, /* Optional rx'd FISs (max 17) */ 86 MVS_RX_FIS_COUNT = 17, /* Optional rx'd FISs (max 17) */
85 87
86 MVS_QUEUE_SIZE = 30, /* Support Queue depth */ 88 MVS_QUEUE_SIZE = 30, /* Support Queue depth */
89 MVS_CAN_QUEUE = MVS_SLOTS - 1, /* SCSI Queue depth */
87}; 90};
88 91
89/* unchangeable hardware details */ 92/* unchangeable hardware details */
@@ -358,7 +361,20 @@ enum hw_register_bits {
358 361
359 /* VSR */ 362 /* VSR */
360 /* PHYMODE 6 (CDB) */ 363 /* PHYMODE 6 (CDB) */
361 PHY_MODE6_DTL_SPEED = (1U << 27), 364 PHY_MODE6_LATECLK = (1U << 29), /* Lock Clock */
365 PHY_MODE6_DTL_SPEED = (1U << 27), /* Digital Loop Speed */
366 PHY_MODE6_FC_ORDER = (1U << 26), /* Fibre Channel Mode Order*/
367 PHY_MODE6_MUCNT_EN = (1U << 24), /* u Count Enable */
368 PHY_MODE6_SEL_MUCNT_LEN = (1U << 22), /* Training Length Select */
369 PHY_MODE6_SELMUPI = (1U << 20), /* Phase Multi Select (init) */
370 PHY_MODE6_SELMUPF = (1U << 18), /* Phase Multi Select (final) */
371 PHY_MODE6_SELMUFF = (1U << 16), /* Freq Loop Multi Sel(final) */
372 PHY_MODE6_SELMUFI = (1U << 14), /* Freq Loop Multi Sel(init) */
373 PHY_MODE6_FREEZE_LOOP = (1U << 12), /* Freeze Rx CDR Loop */
374 PHY_MODE6_INT_RXFOFFS = (1U << 3), /* Rx CDR Freq Loop Enable */
375 PHY_MODE6_FRC_RXFOFFS = (1U << 2), /* Initial Rx CDR Offset */
376 PHY_MODE6_STAU_0D8 = (1U << 1), /* Rx CDR Freq Loop Saturate */
377 PHY_MODE6_RXSAT_DIS = (1U << 0), /* Saturate Ctl */
362}; 378};
363 379
364enum mvs_info_flags { 380enum mvs_info_flags {
@@ -511,7 +527,43 @@ enum status_buffer {
511}; 527};
512 528
513enum error_info_rec { 529enum error_info_rec {
514 CMD_ISS_STPD = (1U << 31), /* Cmd Issue Stopped */ 530 CMD_ISS_STPD = (1U << 31), /* Cmd Issue Stopped */
531 CMD_PI_ERR = (1U << 30), /* Protection info error. see flags2 */
532 RSP_OVER = (1U << 29), /* rsp buffer overflow */
533 RETRY_LIM = (1U << 28), /* FIS/frame retry limit exceeded */
534 UNK_FIS = (1U << 27), /* unknown FIS */
535 DMA_TERM = (1U << 26), /* DMA terminate primitive rx'd */
536 SYNC_ERR = (1U << 25), /* SYNC rx'd during frame xmit */
537 TFILE_ERR = (1U << 24), /* SATA taskfile Error bit set */
538 R_ERR = (1U << 23), /* SATA returned R_ERR prim */
539 RD_OFS = (1U << 20), /* Read DATA frame invalid offset */
540 XFER_RDY_OFS = (1U << 19), /* XFER_RDY offset error */
541 UNEXP_XFER_RDY = (1U << 18), /* unexpected XFER_RDY error */
542 DATA_OVER_UNDER = (1U << 16), /* data overflow/underflow */
543 INTERLOCK = (1U << 15), /* interlock error */
544 NAK = (1U << 14), /* NAK rx'd */
545 ACK_NAK_TO = (1U << 13), /* ACK/NAK timeout */
546 CXN_CLOSED = (1U << 12), /* cxn closed w/out ack/nak */
547 OPEN_TO = (1U << 11), /* I_T nexus lost, open cxn timeout */
548 PATH_BLOCKED = (1U << 10), /* I_T nexus lost, pathway blocked */
549 NO_DEST = (1U << 9), /* I_T nexus lost, no destination */
550 STP_RES_BSY = (1U << 8), /* STP resources busy */
551 BREAK = (1U << 7), /* break received */
552 BAD_DEST = (1U << 6), /* bad destination */
553 BAD_PROTO = (1U << 5), /* protocol not supported */
554 BAD_RATE = (1U << 4), /* cxn rate not supported */
555 WRONG_DEST = (1U << 3), /* wrong destination error */
556 CREDIT_TO = (1U << 2), /* credit timeout */
557 WDOG_TO = (1U << 1), /* watchdog timeout */
558 BUF_PAR = (1U << 0), /* buffer parity error */
559};
560
561enum error_info_rec_2 {
562 SLOT_BSY_ERR = (1U << 31), /* Slot Busy Error */
563 GRD_CHK_ERR = (1U << 14), /* Guard Check Error */
564 APP_CHK_ERR = (1U << 13), /* Application Check error */
565 REF_CHK_ERR = (1U << 12), /* Reference Check Error */
566 USR_BLK_NM = (1U << 0), /* User Block Number */
515}; 567};
516 568
517struct mvs_chip_info { 569struct mvs_chip_info {
@@ -543,28 +595,12 @@ struct mvs_cmd_hdr {
543 __le32 reserved[4]; 595 __le32 reserved[4];
544}; 596};
545 597
546struct mvs_slot_info {
547 struct sas_task *task;
548 u32 n_elem;
549 u32 tx;
550
551 /* DMA buffer for storing cmd tbl, open addr frame, status buffer,
552 * and PRD table
553 */
554 void *buf;
555 dma_addr_t buf_dma;
556#if _MV_DUMP
557 u32 cmd_size;
558#endif
559
560 void *response;
561};
562
563struct mvs_port { 598struct mvs_port {
564 struct asd_sas_port sas_port; 599 struct asd_sas_port sas_port;
565 u8 port_attached; 600 u8 port_attached;
566 u8 taskfileset; 601 u8 taskfileset;
567 u8 wide_port_phymap; 602 u8 wide_port_phymap;
603 struct list_head list;
568}; 604};
569 605
570struct mvs_phy { 606struct mvs_phy {
@@ -582,6 +618,27 @@ struct mvs_phy {
582 u32 frame_rcvd_size; 618 u32 frame_rcvd_size;
583 u8 frame_rcvd[32]; 619 u8 frame_rcvd[32];
584 u8 phy_attached; 620 u8 phy_attached;
621 enum sas_linkrate minimum_linkrate;
622 enum sas_linkrate maximum_linkrate;
623};
624
625struct mvs_slot_info {
626 struct list_head list;
627 struct sas_task *task;
628 u32 n_elem;
629 u32 tx;
630
631 /* DMA buffer for storing cmd tbl, open addr frame, status buffer,
632 * and PRD table
633 */
634 void *buf;
635 dma_addr_t buf_dma;
636#if _MV_DUMP
637 u32 cmd_size;
638#endif
639
640 void *response;
641 struct mvs_port *port;
585}; 642};
586 643
587struct mvs_info { 644struct mvs_info {
@@ -612,21 +669,14 @@ struct mvs_info {
612 669
613 const struct mvs_chip_info *chip; 670 const struct mvs_chip_info *chip;
614 671
615 unsigned long tags[MVS_SLOTS]; 672 u8 tags[MVS_SLOTS];
616 struct mvs_slot_info slot_info[MVS_SLOTS]; 673 struct mvs_slot_info slot_info[MVS_SLOTS];
617 /* further per-slot information */ 674 /* further per-slot information */
618 struct mvs_phy phy[MVS_MAX_PHYS]; 675 struct mvs_phy phy[MVS_MAX_PHYS];
619 struct mvs_port port[MVS_MAX_PHYS]; 676 struct mvs_port port[MVS_MAX_PHYS];
620 677#ifdef MVS_USE_TASKLET
621 u32 can_queue; /* per adapter */ 678 struct tasklet_struct tasklet;
622 u32 tag_out; /*Get*/ 679#endif
623 u32 tag_in; /*Give*/
624};
625
626struct mvs_queue_task {
627 struct list_head list;
628
629 void *uldd_task;
630}; 680};
631 681
632static int mvs_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func, 682static int mvs_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
@@ -641,10 +691,11 @@ static u32 mvs_read_port_irq_mask(struct mvs_info *mvi, u32 port);
641static u32 mvs_is_phy_ready(struct mvs_info *mvi, int i); 691static u32 mvs_is_phy_ready(struct mvs_info *mvi, int i);
642static void mvs_detect_porttype(struct mvs_info *mvi, int i); 692static void mvs_detect_porttype(struct mvs_info *mvi, int i);
643static void mvs_update_phyinfo(struct mvs_info *mvi, int i, int get_st); 693static void mvs_update_phyinfo(struct mvs_info *mvi, int i, int get_st);
694static void mvs_release_task(struct mvs_info *mvi, int phy_no);
644 695
645static int mvs_scan_finished(struct Scsi_Host *, unsigned long); 696static int mvs_scan_finished(struct Scsi_Host *, unsigned long);
646static void mvs_scan_start(struct Scsi_Host *); 697static void mvs_scan_start(struct Scsi_Host *);
647static int mvs_sas_slave_alloc(struct scsi_device *scsi_dev); 698static int mvs_slave_configure(struct scsi_device *sdev);
648 699
649static struct scsi_transport_template *mvs_stt; 700static struct scsi_transport_template *mvs_stt;
650 701
@@ -659,7 +710,7 @@ static struct scsi_host_template mvs_sht = {
659 .name = DRV_NAME, 710 .name = DRV_NAME,
660 .queuecommand = sas_queuecommand, 711 .queuecommand = sas_queuecommand,
661 .target_alloc = sas_target_alloc, 712 .target_alloc = sas_target_alloc,
662 .slave_configure = sas_slave_configure, 713 .slave_configure = mvs_slave_configure,
663 .slave_destroy = sas_slave_destroy, 714 .slave_destroy = sas_slave_destroy,
664 .scan_finished = mvs_scan_finished, 715 .scan_finished = mvs_scan_finished,
665 .scan_start = mvs_scan_start, 716 .scan_start = mvs_scan_start,
@@ -674,7 +725,7 @@ static struct scsi_host_template mvs_sht = {
674 .use_clustering = ENABLE_CLUSTERING, 725 .use_clustering = ENABLE_CLUSTERING,
675 .eh_device_reset_handler = sas_eh_device_reset_handler, 726 .eh_device_reset_handler = sas_eh_device_reset_handler,
676 .eh_bus_reset_handler = sas_eh_bus_reset_handler, 727 .eh_bus_reset_handler = sas_eh_bus_reset_handler,
677 .slave_alloc = mvs_sas_slave_alloc, 728 .slave_alloc = sas_slave_alloc,
678 .target_destroy = sas_target_destroy, 729 .target_destroy = sas_target_destroy,
679 .ioctl = sas_ioctl, 730 .ioctl = sas_ioctl,
680}; 731};
@@ -709,10 +760,10 @@ static void mvs_hexdump(u32 size, u8 *data, u32 baseaddr)
709 printk("\n"); 760 printk("\n");
710} 761}
711 762
763#if _MV_DUMP
712static void mvs_hba_sb_dump(struct mvs_info *mvi, u32 tag, 764static void mvs_hba_sb_dump(struct mvs_info *mvi, u32 tag,
713 enum sas_protocol proto) 765 enum sas_protocol proto)
714{ 766{
715#if _MV_DUMP
716 u32 offset; 767 u32 offset;
717 struct pci_dev *pdev = mvi->pdev; 768 struct pci_dev *pdev = mvi->pdev;
718 struct mvs_slot_info *slot = &mvi->slot_info[tag]; 769 struct mvs_slot_info *slot = &mvi->slot_info[tag];
@@ -723,14 +774,14 @@ static void mvs_hba_sb_dump(struct mvs_info *mvi, u32 tag,
723 tag); 774 tag);
724 mvs_hexdump(32, (u8 *) slot->response, 775 mvs_hexdump(32, (u8 *) slot->response,
725 (u32) slot->buf_dma + offset); 776 (u32) slot->buf_dma + offset);
726#endif
727} 777}
778#endif
728 779
729static void mvs_hba_memory_dump(struct mvs_info *mvi, u32 tag, 780static void mvs_hba_memory_dump(struct mvs_info *mvi, u32 tag,
730 enum sas_protocol proto) 781 enum sas_protocol proto)
731{ 782{
732#if _MV_DUMP 783#if _MV_DUMP
733 u32 sz, w_ptr, r_ptr; 784 u32 sz, w_ptr;
734 u64 addr; 785 u64 addr;
735 void __iomem *regs = mvi->regs; 786 void __iomem *regs = mvi->regs;
736 struct pci_dev *pdev = mvi->pdev; 787 struct pci_dev *pdev = mvi->pdev;
@@ -738,12 +789,10 @@ static void mvs_hba_memory_dump(struct mvs_info *mvi, u32 tag,
738 789
739 /*Delivery Queue */ 790 /*Delivery Queue */
740 sz = mr32(TX_CFG) & TX_RING_SZ_MASK; 791 sz = mr32(TX_CFG) & TX_RING_SZ_MASK;
741 w_ptr = mr32(TX_PROD_IDX) & TX_RING_SZ_MASK; 792 w_ptr = slot->tx;
742 r_ptr = mr32(TX_CONS_IDX) & TX_RING_SZ_MASK;
743 addr = mr32(TX_HI) << 16 << 16 | mr32(TX_LO); 793 addr = mr32(TX_HI) << 16 << 16 | mr32(TX_LO);
744 dev_printk(KERN_DEBUG, &pdev->dev, 794 dev_printk(KERN_DEBUG, &pdev->dev,
745 "Delivery Queue Size=%04d , WRT_PTR=%04X , RD_PTR=%04X\n", 795 "Delivery Queue Size=%04d , WRT_PTR=%04X\n", sz, w_ptr);
746 sz, w_ptr, r_ptr);
747 dev_printk(KERN_DEBUG, &pdev->dev, 796 dev_printk(KERN_DEBUG, &pdev->dev,
748 "Delivery Queue Base Address=0x%llX (PA)" 797 "Delivery Queue Base Address=0x%llX (PA)"
749 "(tx_dma=0x%llX), Entry=%04d\n", 798 "(tx_dma=0x%llX), Entry=%04d\n",
@@ -751,11 +800,11 @@ static void mvs_hba_memory_dump(struct mvs_info *mvi, u32 tag,
751 mvs_hexdump(sizeof(u32), (u8 *)(&mvi->tx[mvi->tx_prod]), 800 mvs_hexdump(sizeof(u32), (u8 *)(&mvi->tx[mvi->tx_prod]),
752 (u32) mvi->tx_dma + sizeof(u32) * w_ptr); 801 (u32) mvi->tx_dma + sizeof(u32) * w_ptr);
753 /*Command List */ 802 /*Command List */
754 addr = mr32(CMD_LIST_HI) << 16 << 16 | mr32(CMD_LIST_LO); 803 addr = mvi->slot_dma;
755 dev_printk(KERN_DEBUG, &pdev->dev, 804 dev_printk(KERN_DEBUG, &pdev->dev,
756 "Command List Base Address=0x%llX (PA)" 805 "Command List Base Address=0x%llX (PA)"
757 "(slot_dma=0x%llX), Header=%03d\n", 806 "(slot_dma=0x%llX), Header=%03d\n",
758 addr, mvi->slot_dma, tag); 807 addr, slot->buf_dma, tag);
759 dev_printk(KERN_DEBUG, &pdev->dev, "Command Header[%03d]:\n", tag); 808 dev_printk(KERN_DEBUG, &pdev->dev, "Command Header[%03d]:\n", tag);
760 /*mvs_cmd_hdr */ 809 /*mvs_cmd_hdr */
761 mvs_hexdump(sizeof(struct mvs_cmd_hdr), (u8 *)(&mvi->slot[tag]), 810 mvs_hexdump(sizeof(struct mvs_cmd_hdr), (u8 *)(&mvi->slot[tag]),
@@ -779,7 +828,7 @@ static void mvs_hba_memory_dump(struct mvs_info *mvi, u32 tag,
779 828
780static void mvs_hba_cq_dump(struct mvs_info *mvi) 829static void mvs_hba_cq_dump(struct mvs_info *mvi)
781{ 830{
782#if _MV_DUMP 831#if (_MV_DUMP > 2)
783 u64 addr; 832 u64 addr;
784 void __iomem *regs = mvi->regs; 833 void __iomem *regs = mvi->regs;
785 struct pci_dev *pdev = mvi->pdev; 834 struct pci_dev *pdev = mvi->pdev;
@@ -788,8 +837,8 @@ static void mvs_hba_cq_dump(struct mvs_info *mvi)
788 837
789 /*Completion Queue */ 838 /*Completion Queue */
790 addr = mr32(RX_HI) << 16 << 16 | mr32(RX_LO); 839 addr = mr32(RX_HI) << 16 << 16 | mr32(RX_LO);
791 dev_printk(KERN_DEBUG, &pdev->dev, "Completion Task = 0x%08X\n", 840 dev_printk(KERN_DEBUG, &pdev->dev, "Completion Task = 0x%p\n",
792 (u32) mvi->slot_info[rx_desc & RXQ_SLOT_MASK].task); 841 mvi->slot_info[rx_desc & RXQ_SLOT_MASK].task);
793 dev_printk(KERN_DEBUG, &pdev->dev, 842 dev_printk(KERN_DEBUG, &pdev->dev,
794 "Completion List Base Address=0x%llX (PA), " 843 "Completion List Base Address=0x%llX (PA), "
795 "CQ_Entry=%04d, CQ_WP=0x%08X\n", 844 "CQ_Entry=%04d, CQ_WP=0x%08X\n",
@@ -854,34 +903,53 @@ static int pci_go_64(struct pci_dev *pdev)
854 return rc; 903 return rc;
855} 904}
856 905
906static int mvs_find_tag(struct mvs_info *mvi, struct sas_task *task, u32 *tag)
907{
908 if (task->lldd_task) {
909 struct mvs_slot_info *slot;
910 slot = (struct mvs_slot_info *) task->lldd_task;
911 *tag = slot - mvi->slot_info;
912 return 1;
913 }
914 return 0;
915}
916
857static void mvs_tag_clear(struct mvs_info *mvi, u32 tag) 917static void mvs_tag_clear(struct mvs_info *mvi, u32 tag)
858{ 918{
859 mvi->tag_in = (mvi->tag_in + 1) & (MVS_SLOTS - 1); 919 void *bitmap = (void *) &mvi->tags;
860 mvi->tags[mvi->tag_in] = tag; 920 clear_bit(tag, bitmap);
861} 921}
862 922
863static void mvs_tag_free(struct mvs_info *mvi, u32 tag) 923static void mvs_tag_free(struct mvs_info *mvi, u32 tag)
864{ 924{
865 mvi->tag_out = (mvi->tag_out - 1) & (MVS_SLOTS - 1); 925 mvs_tag_clear(mvi, tag);
926}
927
928static void mvs_tag_set(struct mvs_info *mvi, unsigned int tag)
929{
930 void *bitmap = (void *) &mvi->tags;
931 set_bit(tag, bitmap);
866} 932}
867 933
868static int mvs_tag_alloc(struct mvs_info *mvi, u32 *tag_out) 934static int mvs_tag_alloc(struct mvs_info *mvi, u32 *tag_out)
869{ 935{
870 if (mvi->tag_out != mvi->tag_in) { 936 unsigned int index, tag;
871 *tag_out = mvi->tags[mvi->tag_out]; 937 void *bitmap = (void *) &mvi->tags;
872 mvi->tag_out = (mvi->tag_out + 1) & (MVS_SLOTS - 1); 938
873 return 0; 939 index = find_first_zero_bit(bitmap, MVS_SLOTS);
874 } 940 tag = index;
875 return -EBUSY; 941 if (tag >= MVS_SLOTS)
942 return -SAS_QUEUE_FULL;
943 mvs_tag_set(mvi, tag);
944 *tag_out = tag;
945 return 0;
876} 946}
877 947
878static void mvs_tag_init(struct mvs_info *mvi) 948static void mvs_tag_init(struct mvs_info *mvi)
879{ 949{
880 int i; 950 int i;
881 for (i = 0; i < MVS_SLOTS; ++i) 951 for (i = 0; i < MVS_SLOTS; ++i)
882 mvi->tags[i] = i; 952 mvs_tag_clear(mvi, i);
883 mvi->tag_out = 0;
884 mvi->tag_in = MVS_SLOTS - 1;
885} 953}
886 954
887#ifndef MVS_DISABLE_NVRAM 955#ifndef MVS_DISABLE_NVRAM
@@ -1013,10 +1081,21 @@ err_out:
1013static void mvs_bytes_dmaed(struct mvs_info *mvi, int i) 1081static void mvs_bytes_dmaed(struct mvs_info *mvi, int i)
1014{ 1082{
1015 struct mvs_phy *phy = &mvi->phy[i]; 1083 struct mvs_phy *phy = &mvi->phy[i];
1084 struct asd_sas_phy *sas_phy = mvi->sas.sas_phy[i];
1016 1085
1017 if (!phy->phy_attached) 1086 if (!phy->phy_attached)
1018 return; 1087 return;
1019 1088
1089 if (sas_phy->phy) {
1090 struct sas_phy *sphy = sas_phy->phy;
1091
1092 sphy->negotiated_linkrate = sas_phy->linkrate;
1093 sphy->minimum_linkrate = phy->minimum_linkrate;
1094 sphy->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS;
1095 sphy->maximum_linkrate = phy->maximum_linkrate;
1096 sphy->maximum_linkrate_hw = SAS_LINK_RATE_3_0_GBPS;
1097 }
1098
1020 if (phy->phy_type & PORT_TYPE_SAS) { 1099 if (phy->phy_type & PORT_TYPE_SAS) {
1021 struct sas_identify_frame *id; 1100 struct sas_identify_frame *id;
1022 1101
@@ -1053,80 +1132,149 @@ static void mvs_scan_start(struct Scsi_Host *shost)
1053 } 1132 }
1054} 1133}
1055 1134
1056static int mvs_sas_slave_alloc(struct scsi_device *scsi_dev) 1135static int mvs_slave_configure(struct scsi_device *sdev)
1057{ 1136{
1058 int rc; 1137 struct domain_device *dev = sdev_to_domain_dev(sdev);
1138 int ret = sas_slave_configure(sdev);
1059 1139
1060 rc = sas_slave_alloc(scsi_dev); 1140 if (ret)
1141 return ret;
1061 1142
1062 return rc; 1143 if (dev_is_sata(dev)) {
1144 /* struct ata_port *ap = dev->sata_dev.ap; */
1145 /* struct ata_device *adev = ap->link.device; */
1146
1147 /* clamp at no NCQ for the time being */
1148 /* adev->flags |= ATA_DFLAG_NCQ_OFF; */
1149 scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, 1);
1150 }
1151 return 0;
1063} 1152}
1064 1153
1065static void mvs_int_port(struct mvs_info *mvi, int port_no, u32 events) 1154static void mvs_int_port(struct mvs_info *mvi, int phy_no, u32 events)
1066{ 1155{
1067 struct pci_dev *pdev = mvi->pdev; 1156 struct pci_dev *pdev = mvi->pdev;
1068 struct sas_ha_struct *sas_ha = &mvi->sas; 1157 struct sas_ha_struct *sas_ha = &mvi->sas;
1069 struct mvs_phy *phy = &mvi->phy[port_no]; 1158 struct mvs_phy *phy = &mvi->phy[phy_no];
1070 struct asd_sas_phy *sas_phy = &phy->sas_phy; 1159 struct asd_sas_phy *sas_phy = &phy->sas_phy;
1071 1160
1072 phy->irq_status = mvs_read_port_irq_stat(mvi, port_no); 1161 phy->irq_status = mvs_read_port_irq_stat(mvi, phy_no);
1073 /* 1162 /*
1074 * events is port event now , 1163 * events is port event now ,
1075 * we need check the interrupt status which belongs to per port. 1164 * we need check the interrupt status which belongs to per port.
1076 */ 1165 */
1077 dev_printk(KERN_DEBUG, &pdev->dev, 1166 dev_printk(KERN_DEBUG, &pdev->dev,
1078 "Port %d Event = %X\n", 1167 "Port %d Event = %X\n",
1079 port_no, phy->irq_status); 1168 phy_no, phy->irq_status);
1080 1169
1081 if (phy->irq_status & (PHYEV_POOF | PHYEV_DEC_ERR)) { 1170 if (phy->irq_status & (PHYEV_POOF | PHYEV_DEC_ERR)) {
1082 if (!mvs_is_phy_ready(mvi, port_no)) { 1171 mvs_release_task(mvi, phy_no);
1172 if (!mvs_is_phy_ready(mvi, phy_no)) {
1083 sas_phy_disconnected(sas_phy); 1173 sas_phy_disconnected(sas_phy);
1084 sas_ha->notify_phy_event(sas_phy, PHYE_LOSS_OF_SIGNAL); 1174 sas_ha->notify_phy_event(sas_phy, PHYE_LOSS_OF_SIGNAL);
1175 dev_printk(KERN_INFO, &pdev->dev,
1176 "Port %d Unplug Notice\n", phy_no);
1177
1085 } else 1178 } else
1086 mvs_phy_control(sas_phy, PHY_FUNC_LINK_RESET, NULL); 1179 mvs_phy_control(sas_phy, PHY_FUNC_LINK_RESET, NULL);
1087 } 1180 }
1088 if (!(phy->irq_status & PHYEV_DEC_ERR)) { 1181 if (!(phy->irq_status & PHYEV_DEC_ERR)) {
1089 if (phy->irq_status & PHYEV_COMWAKE) { 1182 if (phy->irq_status & PHYEV_COMWAKE) {
1090 u32 tmp = mvs_read_port_irq_mask(mvi, port_no); 1183 u32 tmp = mvs_read_port_irq_mask(mvi, phy_no);
1091 mvs_write_port_irq_mask(mvi, port_no, 1184 mvs_write_port_irq_mask(mvi, phy_no,
1092 tmp | PHYEV_SIG_FIS); 1185 tmp | PHYEV_SIG_FIS);
1093 } 1186 }
1094 if (phy->irq_status & (PHYEV_SIG_FIS | PHYEV_ID_DONE)) { 1187 if (phy->irq_status & (PHYEV_SIG_FIS | PHYEV_ID_DONE)) {
1095 phy->phy_status = mvs_is_phy_ready(mvi, port_no); 1188 phy->phy_status = mvs_is_phy_ready(mvi, phy_no);
1096 if (phy->phy_status) { 1189 if (phy->phy_status) {
1097 mvs_detect_porttype(mvi, port_no); 1190 mvs_detect_porttype(mvi, phy_no);
1098 1191
1099 if (phy->phy_type & PORT_TYPE_SATA) { 1192 if (phy->phy_type & PORT_TYPE_SATA) {
1100 u32 tmp = mvs_read_port_irq_mask(mvi, 1193 u32 tmp = mvs_read_port_irq_mask(mvi,
1101 port_no); 1194 phy_no);
1102 tmp &= ~PHYEV_SIG_FIS; 1195 tmp &= ~PHYEV_SIG_FIS;
1103 mvs_write_port_irq_mask(mvi, 1196 mvs_write_port_irq_mask(mvi,
1104 port_no, tmp); 1197 phy_no, tmp);
1105 } 1198 }
1106 1199
1107 mvs_update_phyinfo(mvi, port_no, 0); 1200 mvs_update_phyinfo(mvi, phy_no, 0);
1108 sas_ha->notify_phy_event(sas_phy, 1201 sas_ha->notify_phy_event(sas_phy,
1109 PHYE_OOB_DONE); 1202 PHYE_OOB_DONE);
1110 mvs_bytes_dmaed(mvi, port_no); 1203 mvs_bytes_dmaed(mvi, phy_no);
1111 } else { 1204 } else {
1112 dev_printk(KERN_DEBUG, &pdev->dev, 1205 dev_printk(KERN_DEBUG, &pdev->dev,
1113 "plugin interrupt but phy is gone\n"); 1206 "plugin interrupt but phy is gone\n");
1114 mvs_phy_control(sas_phy, PHY_FUNC_LINK_RESET, 1207 mvs_phy_control(sas_phy, PHY_FUNC_LINK_RESET,
1115 NULL); 1208 NULL);
1116 } 1209 }
1117 } else if (phy->irq_status & PHYEV_BROAD_CH) 1210 } else if (phy->irq_status & PHYEV_BROAD_CH) {
1211 mvs_release_task(mvi, phy_no);
1118 sas_ha->notify_port_event(sas_phy, 1212 sas_ha->notify_port_event(sas_phy,
1119 PORTE_BROADCAST_RCVD); 1213 PORTE_BROADCAST_RCVD);
1214 }
1120 } 1215 }
1121 mvs_write_port_irq_stat(mvi, port_no, phy->irq_status); 1216 mvs_write_port_irq_stat(mvi, phy_no, phy->irq_status);
1122} 1217}
1123 1218
1124static void mvs_int_sata(struct mvs_info *mvi) 1219static void mvs_int_sata(struct mvs_info *mvi)
1125{ 1220{
1126 /* FIXME */ 1221 u32 tmp;
1222 void __iomem *regs = mvi->regs;
1223 tmp = mr32(INT_STAT_SRS);
1224 mw32(INT_STAT_SRS, tmp & 0xFFFF);
1225}
1226
1227static void mvs_slot_reset(struct mvs_info *mvi, struct sas_task *task,
1228 u32 slot_idx)
1229{
1230 void __iomem *regs = mvi->regs;
1231 struct domain_device *dev = task->dev;
1232 struct asd_sas_port *sas_port = dev->port;
1233 struct mvs_port *port = mvi->slot_info[slot_idx].port;
1234 u32 reg_set, phy_mask;
1235
1236 if (!sas_protocol_ata(task->task_proto)) {
1237 reg_set = 0;
1238 phy_mask = (port->wide_port_phymap) ? port->wide_port_phymap :
1239 sas_port->phy_mask;
1240 } else {
1241 reg_set = port->taskfileset;
1242 phy_mask = sas_port->phy_mask;
1243 }
1244 mvi->tx[mvi->tx_prod] = cpu_to_le32(TXQ_MODE_I | slot_idx |
1245 (TXQ_CMD_SLOT_RESET << TXQ_CMD_SHIFT) |
1246 (phy_mask << TXQ_PHY_SHIFT) |
1247 (reg_set << TXQ_SRS_SHIFT));
1248
1249 mw32(TX_PROD_IDX, mvi->tx_prod);
1250 mvi->tx_prod = (mvi->tx_prod + 1) & (MVS_CHIP_SLOT_SZ - 1);
1251}
1252
1253static int mvs_sata_done(struct mvs_info *mvi, struct sas_task *task,
1254 u32 slot_idx, int err)
1255{
1256 struct mvs_port *port = mvi->slot_info[slot_idx].port;
1257 struct task_status_struct *tstat = &task->task_status;
1258 struct ata_task_resp *resp = (struct ata_task_resp *)tstat->buf;
1259 int stat = SAM_GOOD;
1260
1261 resp->frame_len = sizeof(struct dev_to_host_fis);
1262 memcpy(&resp->ending_fis[0],
1263 SATA_RECEIVED_D2H_FIS(port->taskfileset),
1264 sizeof(struct dev_to_host_fis));
1265 tstat->buf_valid_size = sizeof(*resp);
1266 if (unlikely(err))
1267 stat = SAS_PROTO_RESPONSE;
1268 return stat;
1127} 1269}
1128 1270
1129static void mvs_slot_free(struct mvs_info *mvi, struct sas_task *task, 1271static void mvs_slot_free(struct mvs_info *mvi, u32 rx_desc)
1272{
1273 u32 slot_idx = rx_desc & RXQ_SLOT_MASK;
1274 mvs_tag_clear(mvi, slot_idx);
1275}
1276
1277static void mvs_slot_task_free(struct mvs_info *mvi, struct sas_task *task,
1130 struct mvs_slot_info *slot, u32 slot_idx) 1278 struct mvs_slot_info *slot, u32 slot_idx)
1131{ 1279{
1132 if (!sas_protocol_ata(task->task_proto)) 1280 if (!sas_protocol_ata(task->task_proto))
@@ -1149,38 +1297,58 @@ static void mvs_slot_free(struct mvs_info *mvi, struct sas_task *task,
1149 /* do nothing */ 1297 /* do nothing */
1150 break; 1298 break;
1151 } 1299 }
1152 1300 list_del(&slot->list);
1301 task->lldd_task = NULL;
1153 slot->task = NULL; 1302 slot->task = NULL;
1154 mvs_tag_clear(mvi, slot_idx); 1303 slot->port = NULL;
1155} 1304}
1156 1305
1157static void mvs_slot_err(struct mvs_info *mvi, struct sas_task *task, 1306static int mvs_slot_err(struct mvs_info *mvi, struct sas_task *task,
1158 u32 slot_idx) 1307 u32 slot_idx)
1159{ 1308{
1160 struct mvs_slot_info *slot = &mvi->slot_info[slot_idx]; 1309 struct mvs_slot_info *slot = &mvi->slot_info[slot_idx];
1161 u64 err_dw0 = *(u32 *) slot->response; 1310 u32 err_dw0 = le32_to_cpu(*(u32 *) (slot->response));
1162 void __iomem *regs = mvi->regs; 1311 u32 err_dw1 = le32_to_cpu(*(u32 *) (slot->response + 4));
1163 u32 tmp; 1312 int stat = SAM_CHECK_COND;
1164 1313
1165 if (err_dw0 & CMD_ISS_STPD) 1314 if (err_dw1 & SLOT_BSY_ERR) {
1166 if (sas_protocol_ata(task->task_proto)) { 1315 stat = SAS_QUEUE_FULL;
1167 tmp = mr32(INT_STAT_SRS); 1316 mvs_slot_reset(mvi, task, slot_idx);
1168 mw32(INT_STAT_SRS, tmp & 0xFFFF); 1317 }
1169 } 1318 switch (task->task_proto) {
1319 case SAS_PROTOCOL_SSP:
1320 break;
1321 case SAS_PROTOCOL_SMP:
1322 break;
1323 case SAS_PROTOCOL_SATA:
1324 case SAS_PROTOCOL_STP:
1325 case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:
1326 if (err_dw0 & TFILE_ERR)
1327 stat = mvs_sata_done(mvi, task, slot_idx, 1);
1328 break;
1329 default:
1330 break;
1331 }
1170 1332
1171 mvs_hba_sb_dump(mvi, slot_idx, task->task_proto); 1333 mvs_hexdump(16, (u8 *) slot->response, 0);
1334 return stat;
1172} 1335}
1173 1336
1174static int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc) 1337static int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc, u32 flags)
1175{ 1338{
1176 u32 slot_idx = rx_desc & RXQ_SLOT_MASK; 1339 u32 slot_idx = rx_desc & RXQ_SLOT_MASK;
1177 struct mvs_slot_info *slot = &mvi->slot_info[slot_idx]; 1340 struct mvs_slot_info *slot = &mvi->slot_info[slot_idx];
1178 struct sas_task *task = slot->task; 1341 struct sas_task *task = slot->task;
1179 struct task_status_struct *tstat = &task->task_status; 1342 struct task_status_struct *tstat;
1180 struct mvs_port *port = &mvi->port[task->dev->port->id]; 1343 struct mvs_port *port;
1181 bool aborted; 1344 bool aborted;
1182 void *to; 1345 void *to;
1183 1346
1347 if (unlikely(!task || !task->lldd_task))
1348 return -1;
1349
1350 mvs_hba_cq_dump(mvi);
1351
1184 spin_lock(&task->task_state_lock); 1352 spin_lock(&task->task_state_lock);
1185 aborted = task->task_state_flags & SAS_TASK_STATE_ABORTED; 1353 aborted = task->task_state_flags & SAS_TASK_STATE_ABORTED;
1186 if (!aborted) { 1354 if (!aborted) {
@@ -1190,22 +1358,27 @@ static int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc)
1190 } 1358 }
1191 spin_unlock(&task->task_state_lock); 1359 spin_unlock(&task->task_state_lock);
1192 1360
1193 if (aborted) 1361 if (aborted) {
1362 mvs_slot_task_free(mvi, task, slot, slot_idx);
1363 mvs_slot_free(mvi, rx_desc);
1194 return -1; 1364 return -1;
1365 }
1195 1366
1367 port = slot->port;
1368 tstat = &task->task_status;
1196 memset(tstat, 0, sizeof(*tstat)); 1369 memset(tstat, 0, sizeof(*tstat));
1197 tstat->resp = SAS_TASK_COMPLETE; 1370 tstat->resp = SAS_TASK_COMPLETE;
1198 1371
1199 1372 if (unlikely(!port->port_attached || flags)) {
1200 if (unlikely(!port->port_attached)) { 1373 mvs_slot_err(mvi, task, slot_idx);
1201 tstat->stat = SAS_PHY_DOWN; 1374 if (!sas_protocol_ata(task->task_proto))
1375 tstat->stat = SAS_PHY_DOWN;
1202 goto out; 1376 goto out;
1203 } 1377 }
1204 1378
1205 /* error info record present */ 1379 /* error info record present */
1206 if ((rx_desc & RXQ_ERR) && (*(u64 *) slot->response)) { 1380 if (unlikely((rx_desc & RXQ_ERR) && (*(u64 *) slot->response))) {
1207 tstat->stat = SAM_CHECK_COND; 1381 tstat->stat = mvs_slot_err(mvi, task, slot_idx);
1208 mvs_slot_err(mvi, task, slot_idx);
1209 goto out; 1382 goto out;
1210 } 1383 }
1211 1384
@@ -1242,21 +1415,7 @@ static int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc)
1242 case SAS_PROTOCOL_SATA: 1415 case SAS_PROTOCOL_SATA:
1243 case SAS_PROTOCOL_STP: 1416 case SAS_PROTOCOL_STP:
1244 case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP: { 1417 case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP: {
1245 struct ata_task_resp *resp = 1418 tstat->stat = mvs_sata_done(mvi, task, slot_idx, 0);
1246 (struct ata_task_resp *)tstat->buf;
1247
1248 if ((rx_desc & (RXQ_DONE | RXQ_ERR | RXQ_ATTN)) ==
1249 RXQ_DONE)
1250 tstat->stat = SAM_GOOD;
1251 else
1252 tstat->stat = SAM_CHECK_COND;
1253
1254 resp->frame_len = sizeof(struct dev_to_host_fis);
1255 memcpy(&resp->ending_fis[0],
1256 SATA_RECEIVED_D2H_FIS(port->taskfileset),
1257 sizeof(struct dev_to_host_fis));
1258 if (resp->ending_fis[2] & ATA_ERR)
1259 mvs_hexdump(16, resp->ending_fis, 0);
1260 break; 1419 break;
1261 } 1420 }
1262 1421
@@ -1266,11 +1425,34 @@ static int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc)
1266 } 1425 }
1267 1426
1268out: 1427out:
1269 mvs_slot_free(mvi, task, slot, slot_idx); 1428 mvs_slot_task_free(mvi, task, slot, slot_idx);
1429 if (unlikely(tstat->stat != SAS_QUEUE_FULL))
1430 mvs_slot_free(mvi, rx_desc);
1431
1432 spin_unlock(&mvi->lock);
1270 task->task_done(task); 1433 task->task_done(task);
1434 spin_lock(&mvi->lock);
1271 return tstat->stat; 1435 return tstat->stat;
1272} 1436}
1273 1437
1438static void mvs_release_task(struct mvs_info *mvi, int phy_no)
1439{
1440 struct list_head *pos, *n;
1441 struct mvs_slot_info *slot;
1442 struct mvs_phy *phy = &mvi->phy[phy_no];
1443 struct mvs_port *port = phy->port;
1444 u32 rx_desc;
1445
1446 if (!port)
1447 return;
1448
1449 list_for_each_safe(pos, n, &port->list) {
1450 slot = container_of(pos, struct mvs_slot_info, list);
1451 rx_desc = (u32) (slot - mvi->slot_info);
1452 mvs_slot_complete(mvi, rx_desc, 1);
1453 }
1454}
1455
1274static void mvs_int_full(struct mvs_info *mvi) 1456static void mvs_int_full(struct mvs_info *mvi)
1275{ 1457{
1276 void __iomem *regs = mvi->regs; 1458 void __iomem *regs = mvi->regs;
@@ -1305,40 +1487,43 @@ static int mvs_int_rx(struct mvs_info *mvi, bool self_clear)
1305 * we don't have to stall the CPU reading that register. 1487 * we don't have to stall the CPU reading that register.
1306 * The actual RX ring is offset by one dword, due to this. 1488 * The actual RX ring is offset by one dword, due to this.
1307 */ 1489 */
1308 rx_prod_idx = mr32(RX_CONS_IDX) & RX_RING_SZ_MASK; 1490 rx_prod_idx = mvi->rx_cons;
1309 if (rx_prod_idx == 0xfff) { /* h/w hasn't touched RX ring yet */ 1491 mvi->rx_cons = le32_to_cpu(mvi->rx[0]);
1310 mvi->rx_cons = 0xfff; 1492 if (mvi->rx_cons == 0xfff) /* h/w hasn't touched RX ring yet */
1311 return 0; 1493 return 0;
1312 }
1313 1494
1314 /* The CMPL_Q may come late, read from register and try again 1495 /* The CMPL_Q may come late, read from register and try again
1315 * note: if coalescing is enabled, 1496 * note: if coalescing is enabled,
1316 * it will need to read from register every time for sure 1497 * it will need to read from register every time for sure
1317 */ 1498 */
1318 if (mvi->rx_cons == rx_prod_idx) 1499 if (mvi->rx_cons == rx_prod_idx)
1319 return 0; 1500 mvi->rx_cons = mr32(RX_CONS_IDX) & RX_RING_SZ_MASK;
1320 1501
1321 if (mvi->rx_cons == 0xfff) 1502 if (mvi->rx_cons == rx_prod_idx)
1322 mvi->rx_cons = MVS_RX_RING_SZ - 1; 1503 return 0;
1323 1504
1324 while (mvi->rx_cons != rx_prod_idx) { 1505 while (mvi->rx_cons != rx_prod_idx) {
1325 1506
1326 /* increment our internal RX consumer pointer */ 1507 /* increment our internal RX consumer pointer */
1327 mvi->rx_cons = (mvi->rx_cons + 1) & (MVS_RX_RING_SZ - 1); 1508 rx_prod_idx = (rx_prod_idx + 1) & (MVS_RX_RING_SZ - 1);
1328 1509
1329 rx_desc = le32_to_cpu(mvi->rx[mvi->rx_cons + 1]); 1510 rx_desc = le32_to_cpu(mvi->rx[rx_prod_idx + 1]);
1330
1331 mvs_hba_cq_dump(mvi);
1332 1511
1333 if (likely(rx_desc & RXQ_DONE)) 1512 if (likely(rx_desc & RXQ_DONE))
1334 mvs_slot_complete(mvi, rx_desc); 1513 mvs_slot_complete(mvi, rx_desc, 0);
1335 if (rx_desc & RXQ_ATTN) { 1514 if (rx_desc & RXQ_ATTN) {
1336 attn = true; 1515 attn = true;
1337 dev_printk(KERN_DEBUG, &pdev->dev, "ATTN %X\n", 1516 dev_printk(KERN_DEBUG, &pdev->dev, "ATTN %X\n",
1338 rx_desc); 1517 rx_desc);
1339 } else if (rx_desc & RXQ_ERR) { 1518 } else if (rx_desc & RXQ_ERR) {
1519 if (!(rx_desc & RXQ_DONE))
1520 mvs_slot_complete(mvi, rx_desc, 0);
1340 dev_printk(KERN_DEBUG, &pdev->dev, "RXQ_ERR %X\n", 1521 dev_printk(KERN_DEBUG, &pdev->dev, "RXQ_ERR %X\n",
1341 rx_desc); 1522 rx_desc);
1523 } else if (rx_desc & RXQ_SLOT_RESET) {
1524 dev_printk(KERN_DEBUG, &pdev->dev, "Slot reset[%X]\n",
1525 rx_desc);
1526 mvs_slot_free(mvi, rx_desc);
1342 } 1527 }
1343 } 1528 }
1344 1529
@@ -1348,6 +1533,23 @@ static int mvs_int_rx(struct mvs_info *mvi, bool self_clear)
1348 return 0; 1533 return 0;
1349} 1534}
1350 1535
1536#ifdef MVS_USE_TASKLET
1537static void mvs_tasklet(unsigned long data)
1538{
1539 struct mvs_info *mvi = (struct mvs_info *) data;
1540 unsigned long flags;
1541
1542 spin_lock_irqsave(&mvi->lock, flags);
1543
1544#ifdef MVS_DISABLE_MSI
1545 mvs_int_full(mvi);
1546#else
1547 mvs_int_rx(mvi, true);
1548#endif
1549 spin_unlock_irqrestore(&mvi->lock, flags);
1550}
1551#endif
1552
1351static irqreturn_t mvs_interrupt(int irq, void *opaque) 1553static irqreturn_t mvs_interrupt(int irq, void *opaque)
1352{ 1554{
1353 struct mvs_info *mvi = opaque; 1555 struct mvs_info *mvi = opaque;
@@ -1356,18 +1558,21 @@ static irqreturn_t mvs_interrupt(int irq, void *opaque)
1356 1558
1357 stat = mr32(GBL_INT_STAT); 1559 stat = mr32(GBL_INT_STAT);
1358 1560
1359 /* clear CMD_CMPLT ASAP */
1360 mw32_f(INT_STAT, CINT_DONE);
1361
1362 if (stat == 0 || stat == 0xffffffff) 1561 if (stat == 0 || stat == 0xffffffff)
1363 return IRQ_NONE; 1562 return IRQ_NONE;
1364 1563
1564 /* clear CMD_CMPLT ASAP */
1565 mw32_f(INT_STAT, CINT_DONE);
1566
1567#ifndef MVS_USE_TASKLET
1365 spin_lock(&mvi->lock); 1568 spin_lock(&mvi->lock);
1366 1569
1367 mvs_int_full(mvi); 1570 mvs_int_full(mvi);
1368 1571
1369 spin_unlock(&mvi->lock); 1572 spin_unlock(&mvi->lock);
1370 1573#else
1574 tasklet_schedule(&mvi->tasklet);
1575#endif
1371 return IRQ_HANDLED; 1576 return IRQ_HANDLED;
1372} 1577}
1373 1578
@@ -1376,12 +1581,15 @@ static irqreturn_t mvs_msi_interrupt(int irq, void *opaque)
1376{ 1581{
1377 struct mvs_info *mvi = opaque; 1582 struct mvs_info *mvi = opaque;
1378 1583
1584#ifndef MVS_USE_TASKLET
1379 spin_lock(&mvi->lock); 1585 spin_lock(&mvi->lock);
1380 1586
1381 mvs_int_rx(mvi, true); 1587 mvs_int_rx(mvi, true);
1382 1588
1383 spin_unlock(&mvi->lock); 1589 spin_unlock(&mvi->lock);
1384 1590#else
1591 tasklet_schedule(&mvi->tasklet);
1592#endif
1385 return IRQ_HANDLED; 1593 return IRQ_HANDLED;
1386} 1594}
1387#endif 1595#endif
@@ -1576,15 +1784,19 @@ static u8 mvs_assign_reg_set(struct mvs_info *mvi, struct mvs_port *port)
1576 return MVS_ID_NOT_MAPPED; 1784 return MVS_ID_NOT_MAPPED;
1577} 1785}
1578 1786
1579static u32 mvs_get_ncq_tag(struct sas_task *task) 1787static u32 mvs_get_ncq_tag(struct sas_task *task, u32 *tag)
1580{ 1788{
1581 u32 tag = 0;
1582 struct ata_queued_cmd *qc = task->uldd_task; 1789 struct ata_queued_cmd *qc = task->uldd_task;
1583 1790
1584 if (qc) 1791 if (qc) {
1585 tag = qc->tag; 1792 if (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
1793 qc->tf.command == ATA_CMD_FPDMA_READ) {
1794 *tag = qc->tag;
1795 return 1;
1796 }
1797 }
1586 1798
1587 return tag; 1799 return 0;
1588} 1800}
1589 1801
1590static int mvs_task_prep_ata(struct mvs_info *mvi, 1802static int mvs_task_prep_ata(struct mvs_info *mvi,
@@ -1628,11 +1840,9 @@ static int mvs_task_prep_ata(struct mvs_info *mvi,
1628 hdr->flags = cpu_to_le32(flags); 1840 hdr->flags = cpu_to_le32(flags);
1629 1841
1630 /* FIXME: the low order order 5 bits for the TAG if enable NCQ */ 1842 /* FIXME: the low order order 5 bits for the TAG if enable NCQ */
1631 if (task->ata_task.use_ncq) { 1843 if (task->ata_task.use_ncq && mvs_get_ncq_tag(task, &hdr->tags))
1632 hdr->tags = cpu_to_le32(mvs_get_ncq_tag(task)); 1844 task->ata_task.fis.sector_count |= hdr->tags << 3;
1633 /*Fill in task file */ 1845 else
1634 task->ata_task.fis.sector_count = hdr->tags << 3;
1635 } else
1636 hdr->tags = cpu_to_le32(tag); 1846 hdr->tags = cpu_to_le32(tag);
1637 hdr->data_len = cpu_to_le32(task->total_xfer_len); 1847 hdr->data_len = cpu_to_le32(task->total_xfer_len);
1638 1848
@@ -1725,13 +1935,16 @@ static int mvs_task_prep_ssp(struct mvs_info *mvi,
1725 u32 flags; 1935 u32 flags;
1726 u32 resp_len, req_len, i, tag = tei->tag; 1936 u32 resp_len, req_len, i, tag = tei->tag;
1727 const u32 max_resp_len = SB_RFB_MAX; 1937 const u32 max_resp_len = SB_RFB_MAX;
1938 u8 phy_mask;
1728 1939
1729 slot = &mvi->slot_info[tag]; 1940 slot = &mvi->slot_info[tag];
1730 1941
1942 phy_mask = (port->wide_port_phymap) ? port->wide_port_phymap :
1943 task->dev->port->phy_mask;
1731 slot->tx = mvi->tx_prod; 1944 slot->tx = mvi->tx_prod;
1732 mvi->tx[mvi->tx_prod] = cpu_to_le32(TXQ_MODE_I | tag | 1945 mvi->tx[mvi->tx_prod] = cpu_to_le32(TXQ_MODE_I | tag |
1733 (TXQ_CMD_SSP << TXQ_CMD_SHIFT) | 1946 (TXQ_CMD_SSP << TXQ_CMD_SHIFT) |
1734 (port->wide_port_phymap << TXQ_PHY_SHIFT)); 1947 (phy_mask << TXQ_PHY_SHIFT));
1735 1948
1736 flags = MCH_RETRY; 1949 flags = MCH_RETRY;
1737 if (task->ssp_task.enable_first_burst) { 1950 if (task->ssp_task.enable_first_burst) {
@@ -1832,22 +2045,32 @@ static int mvs_task_exec(struct sas_task *task, const int num, gfp_t gfp_flags)
1832 void __iomem *regs = mvi->regs; 2045 void __iomem *regs = mvi->regs;
1833 struct mvs_task_exec_info tei; 2046 struct mvs_task_exec_info tei;
1834 struct sas_task *t = task; 2047 struct sas_task *t = task;
2048 struct mvs_slot_info *slot;
1835 u32 tag = 0xdeadbeef, rc, n_elem = 0; 2049 u32 tag = 0xdeadbeef, rc, n_elem = 0;
1836 unsigned long flags; 2050 unsigned long flags;
1837 u32 n = num, pass = 0; 2051 u32 n = num, pass = 0;
1838 2052
1839 spin_lock_irqsave(&mvi->lock, flags); 2053 spin_lock_irqsave(&mvi->lock, flags);
1840
1841 do { 2054 do {
2055 dev = t->dev;
1842 tei.port = &mvi->port[dev->port->id]; 2056 tei.port = &mvi->port[dev->port->id];
1843 2057
1844 if (!tei.port->port_attached) { 2058 if (!tei.port->port_attached) {
1845 struct task_status_struct *ts = &t->task_status; 2059 if (sas_protocol_ata(t->task_proto)) {
1846 ts->stat = SAS_PHY_DOWN; 2060 rc = SAS_PHY_DOWN;
1847 t->task_done(t); 2061 goto out_done;
1848 rc = 0; 2062 } else {
1849 goto exec_exit; 2063 struct task_status_struct *ts = &t->task_status;
2064 ts->resp = SAS_TASK_UNDELIVERED;
2065 ts->stat = SAS_PHY_DOWN;
2066 t->task_done(t);
2067 if (n > 1)
2068 t = list_entry(t->list.next,
2069 struct sas_task, list);
2070 continue;
2071 }
1850 } 2072 }
2073
1851 if (!sas_protocol_ata(t->task_proto)) { 2074 if (!sas_protocol_ata(t->task_proto)) {
1852 if (t->num_scatter) { 2075 if (t->num_scatter) {
1853 n_elem = pci_map_sg(mvi->pdev, t->scatter, 2076 n_elem = pci_map_sg(mvi->pdev, t->scatter,
@@ -1866,9 +2089,10 @@ static int mvs_task_exec(struct sas_task *task, const int num, gfp_t gfp_flags)
1866 if (rc) 2089 if (rc)
1867 goto err_out; 2090 goto err_out;
1868 2091
1869 mvi->slot_info[tag].task = t; 2092 slot = &mvi->slot_info[tag];
1870 mvi->slot_info[tag].n_elem = n_elem; 2093 t->lldd_task = NULL;
1871 memset(mvi->slot_info[tag].buf, 0, MVS_SLOT_BUF_SZ); 2094 slot->n_elem = n_elem;
2095 memset(slot->buf, 0, MVS_SLOT_BUF_SZ);
1872 tei.task = t; 2096 tei.task = t;
1873 tei.hdr = &mvi->slot[tag]; 2097 tei.hdr = &mvi->slot[tag];
1874 tei.tag = tag; 2098 tei.tag = tag;
@@ -1897,28 +2121,26 @@ static int mvs_task_exec(struct sas_task *task, const int num, gfp_t gfp_flags)
1897 if (rc) 2121 if (rc)
1898 goto err_out_tag; 2122 goto err_out_tag;
1899 2123
2124 slot->task = t;
2125 slot->port = tei.port;
2126 t->lldd_task = (void *) slot;
2127 list_add_tail(&slot->list, &slot->port->list);
1900 /* TODO: select normal or high priority */ 2128 /* TODO: select normal or high priority */
1901 2129
1902 spin_lock(&t->task_state_lock); 2130 spin_lock(&t->task_state_lock);
1903 t->task_state_flags |= SAS_TASK_AT_INITIATOR; 2131 t->task_state_flags |= SAS_TASK_AT_INITIATOR;
1904 spin_unlock(&t->task_state_lock); 2132 spin_unlock(&t->task_state_lock);
1905 2133
1906 if (n == 1) {
1907 spin_unlock_irqrestore(&mvi->lock, flags);
1908 mw32(TX_PROD_IDX, mvi->tx_prod);
1909 }
1910 mvs_hba_memory_dump(mvi, tag, t->task_proto); 2134 mvs_hba_memory_dump(mvi, tag, t->task_proto);
1911 2135
1912 ++pass; 2136 ++pass;
1913 mvi->tx_prod = (mvi->tx_prod + 1) & (MVS_CHIP_SLOT_SZ - 1); 2137 mvi->tx_prod = (mvi->tx_prod + 1) & (MVS_CHIP_SLOT_SZ - 1);
1914 2138 if (n > 1)
1915 if (n == 1) 2139 t = list_entry(t->list.next, struct sas_task, list);
1916 break;
1917
1918 t = list_entry(t->list.next, struct sas_task, list);
1919 } while (--n); 2140 } while (--n);
1920 2141
1921 return 0; 2142 rc = 0;
2143 goto out_done;
1922 2144
1923err_out_tag: 2145err_out_tag:
1924 mvs_tag_free(mvi, tag); 2146 mvs_tag_free(mvi, tag);
@@ -1928,7 +2150,7 @@ err_out:
1928 if (n_elem) 2150 if (n_elem)
1929 pci_unmap_sg(mvi->pdev, t->scatter, n_elem, 2151 pci_unmap_sg(mvi->pdev, t->scatter, n_elem,
1930 t->data_dir); 2152 t->data_dir);
1931exec_exit: 2153out_done:
1932 if (pass) 2154 if (pass)
1933 mw32(TX_PROD_IDX, (mvi->tx_prod - 1) & (MVS_CHIP_SLOT_SZ - 1)); 2155 mw32(TX_PROD_IDX, (mvi->tx_prod - 1) & (MVS_CHIP_SLOT_SZ - 1));
1934 spin_unlock_irqrestore(&mvi->lock, flags); 2156 spin_unlock_irqrestore(&mvi->lock, flags);
@@ -1937,42 +2159,59 @@ exec_exit:
1937 2159
1938static int mvs_task_abort(struct sas_task *task) 2160static int mvs_task_abort(struct sas_task *task)
1939{ 2161{
1940 int rc = 1; 2162 int rc;
1941 unsigned long flags; 2163 unsigned long flags;
1942 struct mvs_info *mvi = task->dev->port->ha->lldd_ha; 2164 struct mvs_info *mvi = task->dev->port->ha->lldd_ha;
1943 struct pci_dev *pdev = mvi->pdev; 2165 struct pci_dev *pdev = mvi->pdev;
2166 int tag;
1944 2167
1945 spin_lock_irqsave(&task->task_state_lock, flags); 2168 spin_lock_irqsave(&task->task_state_lock, flags);
1946 if (task->task_state_flags & SAS_TASK_STATE_DONE) { 2169 if (task->task_state_flags & SAS_TASK_STATE_DONE) {
1947 rc = TMF_RESP_FUNC_COMPLETE; 2170 rc = TMF_RESP_FUNC_COMPLETE;
2171 spin_unlock_irqrestore(&task->task_state_lock, flags);
1948 goto out_done; 2172 goto out_done;
1949 } 2173 }
1950 spin_unlock_irqrestore(&task->task_state_lock, flags); 2174 spin_unlock_irqrestore(&task->task_state_lock, flags);
1951 2175
1952 /*FIXME*/
1953 rc = TMF_RESP_FUNC_COMPLETE;
1954
1955 switch (task->task_proto) { 2176 switch (task->task_proto) {
1956 case SAS_PROTOCOL_SMP: 2177 case SAS_PROTOCOL_SMP:
1957 dev_printk(KERN_DEBUG, &pdev->dev, "SMP Abort! "); 2178 dev_printk(KERN_DEBUG, &pdev->dev, "SMP Abort! \n");
1958 break; 2179 break;
1959 case SAS_PROTOCOL_SSP: 2180 case SAS_PROTOCOL_SSP:
1960 dev_printk(KERN_DEBUG, &pdev->dev, "SSP Abort! "); 2181 dev_printk(KERN_DEBUG, &pdev->dev, "SSP Abort! \n");
1961 break; 2182 break;
1962 case SAS_PROTOCOL_SATA: 2183 case SAS_PROTOCOL_SATA:
1963 case SAS_PROTOCOL_STP: 2184 case SAS_PROTOCOL_STP:
1964 case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:{ 2185 case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:{
1965 dev_printk(KERN_DEBUG, &pdev->dev, "STP Abort! " 2186 dev_printk(KERN_DEBUG, &pdev->dev, "STP Abort! \n");
1966 "Dump D2H FIS: \n"); 2187#if _MV_DUMP
2188 dev_printk(KERN_DEBUG, &pdev->dev, "Dump D2H FIS: \n");
1967 mvs_hexdump(sizeof(struct host_to_dev_fis), 2189 mvs_hexdump(sizeof(struct host_to_dev_fis),
1968 (void *)&task->ata_task.fis, 0); 2190 (void *)&task->ata_task.fis, 0);
1969 dev_printk(KERN_DEBUG, &pdev->dev, "Dump ATAPI Cmd : \n"); 2191 dev_printk(KERN_DEBUG, &pdev->dev, "Dump ATAPI Cmd : \n");
1970 mvs_hexdump(16, task->ata_task.atapi_packet, 0); 2192 mvs_hexdump(16, task->ata_task.atapi_packet, 0);
2193#endif
2194 spin_lock_irqsave(&task->task_state_lock, flags);
2195 if (task->task_state_flags & SAS_TASK_NEED_DEV_RESET) {
2196 /* TODO */
2197 ;
2198 }
2199 spin_unlock_irqrestore(&task->task_state_lock, flags);
1971 break; 2200 break;
1972 } 2201 }
1973 default: 2202 default:
1974 break; 2203 break;
1975 } 2204 }
2205
2206 if (mvs_find_tag(mvi, task, &tag)) {
2207 spin_lock_irqsave(&mvi->lock, flags);
2208 mvs_slot_task_free(mvi, task, &mvi->slot_info[tag], tag);
2209 spin_unlock_irqrestore(&mvi->lock, flags);
2210 }
2211 if (!mvs_task_exec(task, 1, GFP_ATOMIC))
2212 rc = TMF_RESP_FUNC_COMPLETE;
2213 else
2214 rc = TMF_RESP_FUNC_FAILED;
1976out_done: 2215out_done:
1977 return rc; 2216 return rc;
1978} 2217}
@@ -2001,7 +2240,7 @@ static void mvs_free(struct mvs_info *mvi)
2001 mvi->rx_fis, mvi->rx_fis_dma); 2240 mvi->rx_fis, mvi->rx_fis_dma);
2002 if (mvi->rx) 2241 if (mvi->rx)
2003 dma_free_coherent(&mvi->pdev->dev, 2242 dma_free_coherent(&mvi->pdev->dev,
2004 sizeof(*mvi->rx) * MVS_RX_RING_SZ, 2243 sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1),
2005 mvi->rx, mvi->rx_dma); 2244 mvi->rx, mvi->rx_dma);
2006 if (mvi->slot) 2245 if (mvi->slot)
2007 dma_free_coherent(&mvi->pdev->dev, 2246 dma_free_coherent(&mvi->pdev->dev,
@@ -2109,6 +2348,9 @@ static struct mvs_info *__devinit mvs_alloc(struct pci_dev *pdev,
2109 return NULL; 2348 return NULL;
2110 2349
2111 spin_lock_init(&mvi->lock); 2350 spin_lock_init(&mvi->lock);
2351#ifdef MVS_USE_TASKLET
2352 tasklet_init(&mvi->tasklet, mvs_tasklet, (unsigned long)mvi);
2353#endif
2112 mvi->pdev = pdev; 2354 mvi->pdev = pdev;
2113 mvi->chip = chip; 2355 mvi->chip = chip;
2114 2356
@@ -2132,6 +2374,10 @@ static struct mvs_info *__devinit mvs_alloc(struct pci_dev *pdev,
2132 mvs_phy_init(mvi, i); 2374 mvs_phy_init(mvi, i);
2133 arr_phy[i] = &mvi->phy[i].sas_phy; 2375 arr_phy[i] = &mvi->phy[i].sas_phy;
2134 arr_port[i] = &mvi->port[i].sas_port; 2376 arr_port[i] = &mvi->port[i].sas_port;
2377 mvi->port[i].taskfileset = MVS_ID_NOT_MAPPED;
2378 mvi->port[i].wide_port_phymap = 0;
2379 mvi->port[i].port_attached = 0;
2380 INIT_LIST_HEAD(&mvi->port[i].list);
2135 } 2381 }
2136 2382
2137 SHOST_TO_SAS_HA(mvi->shost) = &mvi->sas; 2383 SHOST_TO_SAS_HA(mvi->shost) = &mvi->sas;
@@ -2148,9 +2394,10 @@ static struct mvs_info *__devinit mvs_alloc(struct pci_dev *pdev,
2148 mvi->sas.sas_phy = arr_phy; 2394 mvi->sas.sas_phy = arr_phy;
2149 mvi->sas.sas_port = arr_port; 2395 mvi->sas.sas_port = arr_port;
2150 mvi->sas.num_phys = chip->n_phy; 2396 mvi->sas.num_phys = chip->n_phy;
2151 mvi->sas.lldd_max_execute_num = MVS_CHIP_SLOT_SZ - 1; 2397 mvi->sas.lldd_max_execute_num = 1;
2152 mvi->sas.lldd_queue_size = MVS_QUEUE_SIZE; 2398 mvi->sas.lldd_queue_size = MVS_QUEUE_SIZE;
2153 mvi->can_queue = (MVS_CHIP_SLOT_SZ >> 1) - 1; 2399 mvi->shost->can_queue = MVS_CAN_QUEUE;
2400 mvi->shost->cmd_per_lun = MVS_SLOTS / mvi->sas.num_phys;
2154 mvi->sas.lldd_ha = mvi; 2401 mvi->sas.lldd_ha = mvi;
2155 mvi->sas.core.shost = mvi->shost; 2402 mvi->sas.core.shost = mvi->shost;
2156 2403
@@ -2203,11 +2450,11 @@ static struct mvs_info *__devinit mvs_alloc(struct pci_dev *pdev,
2203 memset(mvi->rx_fis, 0, MVS_RX_FISL_SZ); 2450 memset(mvi->rx_fis, 0, MVS_RX_FISL_SZ);
2204 2451
2205 mvi->rx = dma_alloc_coherent(&pdev->dev, 2452 mvi->rx = dma_alloc_coherent(&pdev->dev,
2206 sizeof(*mvi->rx) * MVS_RX_RING_SZ, 2453 sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1),
2207 &mvi->rx_dma, GFP_KERNEL); 2454 &mvi->rx_dma, GFP_KERNEL);
2208 if (!mvi->rx) 2455 if (!mvi->rx)
2209 goto err_out; 2456 goto err_out;
2210 memset(mvi->rx, 0, sizeof(*mvi->rx) * MVS_RX_RING_SZ); 2457 memset(mvi->rx, 0, sizeof(*mvi->rx) * (MVS_RX_RING_SZ + 1));
2211 2458
2212 mvi->rx[0] = cpu_to_le32(0xfff); 2459 mvi->rx[0] = cpu_to_le32(0xfff);
2213 mvi->rx_cons = 0xfff; 2460 mvi->rx_cons = 0xfff;
@@ -2357,7 +2604,7 @@ static void __devinit mvs_phy_hacks(struct mvs_info *mvi)
2357 mvs_cw32(regs, CMD_SAS_CTL0, tmp); 2604 mvs_cw32(regs, CMD_SAS_CTL0, tmp);
2358 2605
2359 /* workaround for WDTIMEOUT , set to 550 ms */ 2606 /* workaround for WDTIMEOUT , set to 550 ms */
2360 mvs_cw32(regs, CMD_WD_TIMER, 0xffffff); 2607 mvs_cw32(regs, CMD_WD_TIMER, 0x86470);
2361 2608
2362 /* not to halt for different port op during wideport link change */ 2609 /* not to halt for different port op during wideport link change */
2363 mvs_cw32(regs, CMD_APP_ERR_CONFIG, 0xffefbf7d); 2610 mvs_cw32(regs, CMD_APP_ERR_CONFIG, 0xffefbf7d);
@@ -2465,17 +2712,16 @@ static u32 mvs_is_phy_ready(struct mvs_info *mvi, int i)
2465{ 2712{
2466 u32 tmp; 2713 u32 tmp;
2467 struct mvs_phy *phy = &mvi->phy[i]; 2714 struct mvs_phy *phy = &mvi->phy[i];
2468 struct mvs_port *port; 2715 struct mvs_port *port = phy->port;;
2469 2716
2470 tmp = mvs_read_phy_ctl(mvi, i); 2717 tmp = mvs_read_phy_ctl(mvi, i);
2471 2718
2472 if ((tmp & PHY_READY_MASK) && !(phy->irq_status & PHYEV_POOF)) { 2719 if ((tmp & PHY_READY_MASK) && !(phy->irq_status & PHYEV_POOF)) {
2473 if (!phy->port) 2720 if (!port)
2474 phy->phy_attached = 1; 2721 phy->phy_attached = 1;
2475 return tmp; 2722 return tmp;
2476 } 2723 }
2477 2724
2478 port = phy->port;
2479 if (port) { 2725 if (port) {
2480 if (phy->phy_type & PORT_TYPE_SAS) { 2726 if (phy->phy_type & PORT_TYPE_SAS) {
2481 port->wide_port_phymap &= ~(1U << i); 2727 port->wide_port_phymap &= ~(1U << i);
@@ -2497,7 +2743,7 @@ static void mvs_update_phyinfo(struct mvs_info *mvi, int i,
2497{ 2743{
2498 struct mvs_phy *phy = &mvi->phy[i]; 2744 struct mvs_phy *phy = &mvi->phy[i];
2499 struct pci_dev *pdev = mvi->pdev; 2745 struct pci_dev *pdev = mvi->pdev;
2500 u32 tmp, j; 2746 u32 tmp;
2501 u64 tmp64; 2747 u64 tmp64;
2502 2748
2503 mvs_write_port_cfg_addr(mvi, i, PHYR_IDENTIFY); 2749 mvs_write_port_cfg_addr(mvi, i, PHYR_IDENTIFY);
@@ -2524,46 +2770,20 @@ static void mvs_update_phyinfo(struct mvs_info *mvi, int i,
2524 sas_phy->linkrate = 2770 sas_phy->linkrate =
2525 (phy->phy_status & PHY_NEG_SPP_PHYS_LINK_RATE_MASK) >> 2771 (phy->phy_status & PHY_NEG_SPP_PHYS_LINK_RATE_MASK) >>
2526 PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET; 2772 PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET;
2527 2773 phy->minimum_linkrate =
2528 /* Updated attached_sas_addr */ 2774 (phy->phy_status &
2529 mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_ADDR_HI); 2775 PHY_MIN_SPP_PHYS_LINK_RATE_MASK) >> 8;
2530 phy->att_dev_sas_addr = 2776 phy->maximum_linkrate =
2531 (u64) mvs_read_port_cfg_data(mvi, i) << 32; 2777 (phy->phy_status &
2532 2778 PHY_MAX_SPP_PHYS_LINK_RATE_MASK) >> 12;
2533 mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_ADDR_LO);
2534 phy->att_dev_sas_addr |= mvs_read_port_cfg_data(mvi, i);
2535
2536 dev_printk(KERN_DEBUG, &pdev->dev,
2537 "phy[%d] Get Attached Address 0x%llX ,"
2538 " SAS Address 0x%llX\n",
2539 i, phy->att_dev_sas_addr, phy->dev_sas_addr);
2540 dev_printk(KERN_DEBUG, &pdev->dev,
2541 "Rate = %x , type = %d\n",
2542 sas_phy->linkrate, phy->phy_type);
2543
2544#if 1
2545 /*
2546 * If the device is capable of supporting a wide port
2547 * on its phys, it may configure the phys as a wide port.
2548 */
2549 if (phy->phy_type & PORT_TYPE_SAS)
2550 for (j = 0; j < mvi->chip->n_phy && j != i; ++j) {
2551 if ((mvi->phy[j].phy_attached) &&
2552 (mvi->phy[j].phy_type & PORT_TYPE_SAS))
2553 if (phy->att_dev_sas_addr ==
2554 mvi->phy[j].att_dev_sas_addr - 1) {
2555 phy->att_dev_sas_addr =
2556 mvi->phy[j].att_dev_sas_addr;
2557 break;
2558 }
2559 }
2560
2561#endif
2562
2563 tmp64 = cpu_to_be64(phy->att_dev_sas_addr);
2564 memcpy(sas_phy->attached_sas_addr, &tmp64, SAS_ADDR_SIZE);
2565 2779
2566 if (phy->phy_type & PORT_TYPE_SAS) { 2780 if (phy->phy_type & PORT_TYPE_SAS) {
2781 /* Updated attached_sas_addr */
2782 mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_ADDR_HI);
2783 phy->att_dev_sas_addr =
2784 (u64) mvs_read_port_cfg_data(mvi, i) << 32;
2785 mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_ADDR_LO);
2786 phy->att_dev_sas_addr |= mvs_read_port_cfg_data(mvi, i);
2567 mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_DEV_INFO); 2787 mvs_write_port_cfg_addr(mvi, i, PHYR_ATT_DEV_INFO);
2568 phy->att_dev_info = mvs_read_port_cfg_data(mvi, i); 2788 phy->att_dev_info = mvs_read_port_cfg_data(mvi, i);
2569 phy->identify.device_type = 2789 phy->identify.device_type =
@@ -2582,6 +2802,7 @@ static void mvs_update_phyinfo(struct mvs_info *mvi, int i,
2582 } else if (phy->phy_type & PORT_TYPE_SATA) { 2802 } else if (phy->phy_type & PORT_TYPE_SATA) {
2583 phy->identify.target_port_protocols = SAS_PROTOCOL_STP; 2803 phy->identify.target_port_protocols = SAS_PROTOCOL_STP;
2584 if (mvs_is_sig_fis_received(phy->irq_status)) { 2804 if (mvs_is_sig_fis_received(phy->irq_status)) {
2805 phy->att_dev_sas_addr = i; /* temp */
2585 if (phy_st & PHY_OOB_DTCTD) 2806 if (phy_st & PHY_OOB_DTCTD)
2586 sas_phy->oob_mode = SATA_OOB_MODE; 2807 sas_phy->oob_mode = SATA_OOB_MODE;
2587 phy->frame_rcvd_size = 2808 phy->frame_rcvd_size =
@@ -2591,20 +2812,34 @@ static void mvs_update_phyinfo(struct mvs_info *mvi, int i,
2591 } else { 2812 } else {
2592 dev_printk(KERN_DEBUG, &pdev->dev, 2813 dev_printk(KERN_DEBUG, &pdev->dev,
2593 "No sig fis\n"); 2814 "No sig fis\n");
2815 phy->phy_type &= ~(PORT_TYPE_SATA);
2816 goto out_done;
2594 } 2817 }
2595 } 2818 }
2819 tmp64 = cpu_to_be64(phy->att_dev_sas_addr);
2820 memcpy(sas_phy->attached_sas_addr, &tmp64, SAS_ADDR_SIZE);
2821
2822 dev_printk(KERN_DEBUG, &pdev->dev,
2823 "phy[%d] Get Attached Address 0x%llX ,"
2824 " SAS Address 0x%llX\n",
2825 i, phy->att_dev_sas_addr, phy->dev_sas_addr);
2826 dev_printk(KERN_DEBUG, &pdev->dev,
2827 "Rate = %x , type = %d\n",
2828 sas_phy->linkrate, phy->phy_type);
2829
2596 /* workaround for HW phy decoding error on 1.5g disk drive */ 2830 /* workaround for HW phy decoding error on 1.5g disk drive */
2597 mvs_write_port_vsr_addr(mvi, i, VSR_PHY_MODE6); 2831 mvs_write_port_vsr_addr(mvi, i, VSR_PHY_MODE6);
2598 tmp = mvs_read_port_vsr_data(mvi, i); 2832 tmp = mvs_read_port_vsr_data(mvi, i);
2599 if (((phy->phy_status & PHY_NEG_SPP_PHYS_LINK_RATE_MASK) >> 2833 if (((phy->phy_status & PHY_NEG_SPP_PHYS_LINK_RATE_MASK) >>
2600 PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET) == 2834 PHY_NEG_SPP_PHYS_LINK_RATE_MASK_OFFSET) ==
2601 SAS_LINK_RATE_1_5_GBPS) 2835 SAS_LINK_RATE_1_5_GBPS)
2602 tmp &= ~PHY_MODE6_DTL_SPEED; 2836 tmp &= ~PHY_MODE6_LATECLK;
2603 else 2837 else
2604 tmp |= PHY_MODE6_DTL_SPEED; 2838 tmp |= PHY_MODE6_LATECLK;
2605 mvs_write_port_vsr_data(mvi, i, tmp); 2839 mvs_write_port_vsr_data(mvi, i, tmp);
2606 2840
2607 } 2841 }
2842out_done:
2608 if (get_st) 2843 if (get_st)
2609 mvs_write_port_irq_stat(mvi, i, phy->irq_status); 2844 mvs_write_port_irq_stat(mvi, i, phy->irq_status);
2610} 2845}
@@ -2629,6 +2864,11 @@ static void mvs_port_formed(struct asd_sas_phy *sas_phy)
2629 spin_unlock_irqrestore(&mvi->lock, flags); 2864 spin_unlock_irqrestore(&mvi->lock, flags);
2630} 2865}
2631 2866
2867static int mvs_I_T_nexus_reset(struct domain_device *dev)
2868{
2869 return TMF_RESP_FUNC_FAILED;
2870}
2871
2632static int __devinit mvs_hw_init(struct mvs_info *mvi) 2872static int __devinit mvs_hw_init(struct mvs_info *mvi)
2633{ 2873{
2634 void __iomem *regs = mvi->regs; 2874 void __iomem *regs = mvi->regs;
@@ -2790,13 +3030,12 @@ static int __devinit mvs_hw_init(struct mvs_info *mvi)
2790 /* enable CMD/CMPL_Q/RESP mode */ 3030 /* enable CMD/CMPL_Q/RESP mode */
2791 mw32(PCS, PCS_SATA_RETRY | PCS_FIS_RX_EN | PCS_CMD_EN); 3031 mw32(PCS, PCS_SATA_RETRY | PCS_FIS_RX_EN | PCS_CMD_EN);
2792 3032
2793 /* re-enable interrupts globally */
2794 mvs_hba_interrupt_enable(mvi);
2795
2796 /* enable completion queue interrupt */ 3033 /* enable completion queue interrupt */
2797 tmp = (CINT_PORT_MASK | CINT_DONE | CINT_MEM); 3034 tmp = (CINT_PORT_MASK | CINT_DONE | CINT_MEM | CINT_SRS);
2798 mw32(INT_MASK, tmp); 3035 mw32(INT_MASK, tmp);
2799 3036
3037 /* Enable SRS interrupt */
3038 mw32(INT_MASK_SRS, 0xFF);
2800 return 0; 3039 return 0;
2801} 3040}
2802 3041
@@ -2870,6 +3109,8 @@ static int __devinit mvs_pci_init(struct pci_dev *pdev,
2870 3109
2871 mvs_print_info(mvi); 3110 mvs_print_info(mvi);
2872 3111
3112 mvs_hba_interrupt_enable(mvi);
3113
2873 scsi_scan_host(mvi->shost); 3114 scsi_scan_host(mvi->shost);
2874 3115
2875 return 0; 3116 return 0;
@@ -2915,12 +3156,22 @@ static struct sas_domain_function_template mvs_transport_ops = {
2915 .lldd_execute_task = mvs_task_exec, 3156 .lldd_execute_task = mvs_task_exec,
2916 .lldd_control_phy = mvs_phy_control, 3157 .lldd_control_phy = mvs_phy_control,
2917 .lldd_abort_task = mvs_task_abort, 3158 .lldd_abort_task = mvs_task_abort,
2918 .lldd_port_formed = mvs_port_formed 3159 .lldd_port_formed = mvs_port_formed,
3160 .lldd_I_T_nexus_reset = mvs_I_T_nexus_reset,
2919}; 3161};
2920 3162
2921static struct pci_device_id __devinitdata mvs_pci_table[] = { 3163static struct pci_device_id __devinitdata mvs_pci_table[] = {
2922 { PCI_VDEVICE(MARVELL, 0x6320), chip_6320 }, 3164 { PCI_VDEVICE(MARVELL, 0x6320), chip_6320 },
2923 { PCI_VDEVICE(MARVELL, 0x6340), chip_6440 }, 3165 { PCI_VDEVICE(MARVELL, 0x6340), chip_6440 },
3166 {
3167 .vendor = PCI_VENDOR_ID_MARVELL,
3168 .device = 0x6440,
3169 .subvendor = PCI_ANY_ID,
3170 .subdevice = 0x6480,
3171 .class = 0,
3172 .class_mask = 0,
3173 .driver_data = chip_6480,
3174 },
2924 { PCI_VDEVICE(MARVELL, 0x6440), chip_6440 }, 3175 { PCI_VDEVICE(MARVELL, 0x6440), chip_6440 },
2925 { PCI_VDEVICE(MARVELL, 0x6480), chip_6480 }, 3176 { PCI_VDEVICE(MARVELL, 0x6480), chip_6480 },
2926 3177
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index ba21d97d1855..f40898dc2d14 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2162,10 +2162,15 @@ void sdev_evt_send(struct scsi_device *sdev, struct scsi_event *evt)
2162{ 2162{
2163 unsigned long flags; 2163 unsigned long flags;
2164 2164
2165#if 0
2166 /* FIXME: currently this check eliminates all media change events
2167 * for polled devices. Need to update to discriminate between AN
2168 * and polled events */
2165 if (!test_bit(evt->evt_type, sdev->supported_events)) { 2169 if (!test_bit(evt->evt_type, sdev->supported_events)) {
2166 kfree(evt); 2170 kfree(evt);
2167 return; 2171 return;
2168 } 2172 }
2173#endif
2169 2174
2170 spin_lock_irqsave(&sdev->list_lock, flags); 2175 spin_lock_irqsave(&sdev->list_lock, flags);
2171 list_add_tail(&evt->node, &sdev->event_list); 2176 list_add_tail(&evt->node, &sdev->event_list);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 7aee64dbfbeb..5fe7aaed904c 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1654,6 +1654,7 @@ static int sd_probe(struct device *dev)
1654 sdkp->disk = gd; 1654 sdkp->disk = gd;
1655 sdkp->index = index; 1655 sdkp->index = index;
1656 sdkp->openers = 0; 1656 sdkp->openers = 0;
1657 sdkp->previous_state = 1;
1657 1658
1658 if (!sdp->timeout) { 1659 if (!sdp->timeout) {
1659 if (sdp->type != TYPE_MOD) 1660 if (sdp->type != TYPE_MOD)
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 208565bdbe8e..7ee86d4a7618 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -623,6 +623,7 @@ static int sr_probe(struct device *dev)
623 cd->disk = disk; 623 cd->disk = disk;
624 cd->capacity = 0x1fffff; 624 cd->capacity = 0x1fffff;
625 cd->device->changed = 1; /* force recheck CD type */ 625 cd->device->changed = 1; /* force recheck CD type */
626 cd->previous_state = 1;
626 cd->use = 1; 627 cd->use = 1;
627 cd->readcd_known = 0; 628 cd->readcd_known = 0;
628 cd->readcd_cdda = 0; 629 cd->readcd_cdda = 0;
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index a8bec498cad6..f97224ce59da 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -1214,13 +1214,6 @@ static struct pciserial_board pci_boards[] __devinitdata = {
1214 .base_baud = 115200, 1214 .base_baud = 115200,
1215 .uart_offset = 8, 1215 .uart_offset = 8,
1216 }, 1216 },
1217 [pbn_b0_8_115200] = {
1218 .flags = FL_BASE0,
1219 .num_ports = 8,
1220 .base_baud = 115200,
1221 .uart_offset = 8,
1222 },
1223
1224 [pbn_b0_1_921600] = { 1217 [pbn_b0_1_921600] = {
1225 .flags = FL_BASE0, 1218 .flags = FL_BASE0,
1226 .num_ports = 1, 1219 .num_ports = 1,
diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c
index d57bf3e708d8..430997e33fc4 100644
--- a/drivers/serial/atmel_serial.c
+++ b/drivers/serial/atmel_serial.c
@@ -96,6 +96,7 @@
96 96
97 /* PDC registers */ 97 /* PDC registers */
98#define UART_PUT_PTCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_PTCR) 98#define UART_PUT_PTCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_PTCR)
99#define UART_GET_TCR(port) __raw_readl((port)->membase + ATMEL_PDC_TCR)
99#define UART_GET_PTSR(port) __raw_readl((port)->membase + ATMEL_PDC_PTSR) 100#define UART_GET_PTSR(port) __raw_readl((port)->membase + ATMEL_PDC_PTSR)
100 101
101#define UART_PUT_RPR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_RPR) 102#define UART_PUT_RPR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_RPR)
@@ -106,6 +107,7 @@
106 107
107#define UART_PUT_TPR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_TPR) 108#define UART_PUT_TPR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_TPR)
108#define UART_PUT_TCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_TCR) 109#define UART_PUT_TCR(port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_TCR)
110#define UART_GET_TCR(port) __raw_readl((port)->membase + ATMEL_PDC_TCR)
109 111
110static int (*atmel_open_hook)(struct uart_port *); 112static int (*atmel_open_hook)(struct uart_port *);
111static void (*atmel_close_hook)(struct uart_port *); 113static void (*atmel_close_hook)(struct uart_port *);
@@ -562,17 +564,22 @@ static void atmel_tx_dma(struct uart_port *port)
562 struct atmel_dma_buffer *pdc = &atmel_port->pdc_tx; 564 struct atmel_dma_buffer *pdc = &atmel_port->pdc_tx;
563 int count; 565 int count;
564 566
567 /* nothing left to transmit? */
568 if (UART_GET_TCR(port))
569 return;
570
565 xmit->tail += pdc->ofs; 571 xmit->tail += pdc->ofs;
566 xmit->tail &= UART_XMIT_SIZE - 1; 572 xmit->tail &= UART_XMIT_SIZE - 1;
567 573
568 port->icount.tx += pdc->ofs; 574 port->icount.tx += pdc->ofs;
569 pdc->ofs = 0; 575 pdc->ofs = 0;
570 576
571 if (!uart_circ_empty(xmit)) { 577 /* more to transmit - setup next transfer */
572 /* more to transmit - setup next transfer */
573 578
574 /* disable PDC transmit */ 579 /* disable PDC transmit */
575 UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS); 580 UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS);
581
582 if (!uart_circ_empty(xmit)) {
576 dma_sync_single_for_device(port->dev, 583 dma_sync_single_for_device(port->dev,
577 pdc->dma_addr, 584 pdc->dma_addr,
578 pdc->dma_size, 585 pdc->dma_size,
@@ -586,11 +593,6 @@ static void atmel_tx_dma(struct uart_port *port)
586 /* re-enable PDC transmit and interrupts */ 593 /* re-enable PDC transmit and interrupts */
587 UART_PUT_PTCR(port, ATMEL_PDC_TXTEN); 594 UART_PUT_PTCR(port, ATMEL_PDC_TXTEN);
588 UART_PUT_IER(port, ATMEL_US_ENDTX | ATMEL_US_TXBUFE); 595 UART_PUT_IER(port, ATMEL_US_ENDTX | ATMEL_US_TXBUFE);
589 } else {
590 /* nothing left to transmit - disable the transmitter */
591
592 /* disable PDC transmit */
593 UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS);
594 } 596 }
595 597
596 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 598 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
@@ -1274,6 +1276,7 @@ static void atmel_console_write(struct console *co, const char *s, u_int count)
1274{ 1276{
1275 struct uart_port *port = &atmel_ports[co->index].uart; 1277 struct uart_port *port = &atmel_ports[co->index].uart;
1276 unsigned int status, imr; 1278 unsigned int status, imr;
1279 unsigned int pdc_tx;
1277 1280
1278 /* 1281 /*
1279 * First, save IMR and then disable interrupts 1282 * First, save IMR and then disable interrupts
@@ -1281,6 +1284,10 @@ static void atmel_console_write(struct console *co, const char *s, u_int count)
1281 imr = UART_GET_IMR(port); 1284 imr = UART_GET_IMR(port);
1282 UART_PUT_IDR(port, ATMEL_US_RXRDY | ATMEL_US_TXRDY); 1285 UART_PUT_IDR(port, ATMEL_US_RXRDY | ATMEL_US_TXRDY);
1283 1286
1287 /* Store PDC transmit status and disable it */
1288 pdc_tx = UART_GET_PTSR(port) & ATMEL_PDC_TXTEN;
1289 UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS);
1290
1284 uart_console_write(port, s, count, atmel_console_putchar); 1291 uart_console_write(port, s, count, atmel_console_putchar);
1285 1292
1286 /* 1293 /*
@@ -1290,6 +1297,11 @@ static void atmel_console_write(struct console *co, const char *s, u_int count)
1290 do { 1297 do {
1291 status = UART_GET_CSR(port); 1298 status = UART_GET_CSR(port);
1292 } while (!(status & ATMEL_US_TXRDY)); 1299 } while (!(status & ATMEL_US_TXRDY));
1300
1301 /* Restore PDC transmit status */
1302 if (pdc_tx)
1303 UART_PUT_PTCR(port, ATMEL_PDC_TXTEN);
1304
1293 /* set interrupts back the way they were */ 1305 /* set interrupts back the way they were */
1294 UART_PUT_IER(port, imr); 1306 UART_PUT_IER(port, imr);
1295} 1307}
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index a8c116b80bff..9d244d1644e1 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -414,12 +414,12 @@ static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
414 defined(CONFIG_CPU_SUBTYPE_SH7785) 414 defined(CONFIG_CPU_SUBTYPE_SH7785)
415static inline int scif_txroom(struct uart_port *port) 415static inline int scif_txroom(struct uart_port *port)
416{ 416{
417 return SCIF_TXROOM_MAX - (sci_in(port, SCTFDR) & 0x7f); 417 return SCIF_TXROOM_MAX - (sci_in(port, SCTFDR) & 0xff);
418} 418}
419 419
420static inline int scif_rxroom(struct uart_port *port) 420static inline int scif_rxroom(struct uart_port *port)
421{ 421{
422 return sci_in(port, SCRFDR) & 0x7f; 422 return sci_in(port, SCRFDR) & 0xff;
423} 423}
424#else 424#else
425static inline int scif_txroom(struct uart_port *port) 425static inline int scif_txroom(struct uart_port *port)
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index 3ab313ed441c..17e71d56f31e 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -4,8 +4,6 @@
4 4
5menuconfig THERMAL 5menuconfig THERMAL
6 bool "Generic Thermal sysfs driver" 6 bool "Generic Thermal sysfs driver"
7 select HWMON
8 default y
9 help 7 help
10 Generic Thermal Sysfs driver offers a generic mechanism for 8 Generic Thermal Sysfs driver offers a generic mechanism for
11 thermal management. Usually it's made up of one or more thermal 9 thermal management. Usually it's made up of one or more thermal
diff --git a/drivers/thermal/thermal.c b/drivers/thermal/thermal.c
index 41bd4c805ace..8b86e53ccf7a 100644
--- a/drivers/thermal/thermal.c
+++ b/drivers/thermal/thermal.c
@@ -30,10 +30,8 @@
30#include <linux/idr.h> 30#include <linux/idr.h>
31#include <linux/thermal.h> 31#include <linux/thermal.h>
32#include <linux/spinlock.h> 32#include <linux/spinlock.h>
33#include <linux/hwmon.h>
34#include <linux/hwmon-sysfs.h>
35 33
36MODULE_AUTHOR("Zhang Rui"); 34MODULE_AUTHOR("Zhang Rui")
37MODULE_DESCRIPTION("Generic thermal management sysfs support"); 35MODULE_DESCRIPTION("Generic thermal management sysfs support");
38MODULE_LICENSE("GPL"); 36MODULE_LICENSE("GPL");
39 37
@@ -58,9 +56,6 @@ static LIST_HEAD(thermal_tz_list);
58static LIST_HEAD(thermal_cdev_list); 56static LIST_HEAD(thermal_cdev_list);
59static DEFINE_MUTEX(thermal_list_lock); 57static DEFINE_MUTEX(thermal_list_lock);
60 58
61static struct device *thermal_hwmon;
62#define MAX_THERMAL_ZONES 10
63
64static int get_idr(struct idr *idr, struct mutex *lock, int *id) 59static int get_idr(struct idr *idr, struct mutex *lock, int *id)
65{ 60{
66 int err; 61 int err;
@@ -92,67 +87,7 @@ static void release_idr(struct idr *idr, struct mutex *lock, int id)
92 mutex_unlock(lock); 87 mutex_unlock(lock);
93} 88}
94 89
95/* hwmon sys I/F*/ 90/* sys I/F for thermal zone */
96static ssize_t
97name_show(struct device *dev, struct device_attribute *attr, char *buf)
98{
99 return sprintf(buf, "thermal_sys_class\n");
100}
101
102static ssize_t
103temp_input_show(struct device *dev, struct device_attribute *attr, char *buf)
104{
105 struct thermal_zone_device *tz;
106 struct sensor_device_attribute *sensor_attr
107 = to_sensor_dev_attr(attr);
108
109 list_for_each_entry(tz, &thermal_tz_list, node)
110 if (tz->id == sensor_attr->index)
111 return tz->ops->get_temp(tz, buf);
112
113 return -ENODEV;
114}
115
116static ssize_t
117temp_crit_show(struct device *dev, struct device_attribute *attr,
118 char *buf)
119{
120 struct thermal_zone_device *tz;
121 struct sensor_device_attribute *sensor_attr
122 = to_sensor_dev_attr(attr);
123
124 list_for_each_entry(tz, &thermal_tz_list, node)
125 if (tz->id == sensor_attr->index)
126 return tz->ops->get_trip_temp(tz, 0, buf);
127
128 return -ENODEV;
129}
130
131static DEVICE_ATTR(name, 0444, name_show, NULL);
132static struct sensor_device_attribute sensor_attrs[] = {
133 SENSOR_ATTR(temp1_input, 0444, temp_input_show, NULL, 0),
134 SENSOR_ATTR(temp1_crit, 0444, temp_crit_show, NULL, 0),
135 SENSOR_ATTR(temp2_input, 0444, temp_input_show, NULL, 1),
136 SENSOR_ATTR(temp2_crit, 0444, temp_crit_show, NULL, 1),
137 SENSOR_ATTR(temp3_input, 0444, temp_input_show, NULL, 2),
138 SENSOR_ATTR(temp3_crit, 0444, temp_crit_show, NULL, 2),
139 SENSOR_ATTR(temp4_input, 0444, temp_input_show, NULL, 3),
140 SENSOR_ATTR(temp4_crit, 0444, temp_crit_show, NULL, 3),
141 SENSOR_ATTR(temp5_input, 0444, temp_input_show, NULL, 4),
142 SENSOR_ATTR(temp5_crit, 0444, temp_crit_show, NULL, 4),
143 SENSOR_ATTR(temp6_input, 0444, temp_input_show, NULL, 5),
144 SENSOR_ATTR(temp6_crit, 0444, temp_crit_show, NULL, 5),
145 SENSOR_ATTR(temp7_input, 0444, temp_input_show, NULL, 6),
146 SENSOR_ATTR(temp7_crit, 0444, temp_crit_show, NULL, 6),
147 SENSOR_ATTR(temp8_input, 0444, temp_input_show, NULL, 7),
148 SENSOR_ATTR(temp8_crit, 0444, temp_crit_show, NULL, 7),
149 SENSOR_ATTR(temp9_input, 0444, temp_input_show, NULL, 8),
150 SENSOR_ATTR(temp9_crit, 0444, temp_crit_show, NULL, 8),
151 SENSOR_ATTR(temp10_input, 0444, temp_input_show, NULL, 9),
152 SENSOR_ATTR(temp10_crit, 0444, temp_crit_show, NULL, 9),
153};
154
155/* thermal zone sys I/F */
156 91
157#define to_thermal_zone(_dev) \ 92#define to_thermal_zone(_dev) \
158 container_of(_dev, struct thermal_zone_device, device) 93 container_of(_dev, struct thermal_zone_device, device)
@@ -279,7 +214,7 @@ do { \
279 device_remove_file(_dev, &trip_point_attrs[_index * 2 + 1]); \ 214 device_remove_file(_dev, &trip_point_attrs[_index * 2 + 1]); \
280} while (0) 215} while (0)
281 216
282/* cooling device sys I/F */ 217/* sys I/F for cooling device */
283#define to_cooling_device(_dev) \ 218#define to_cooling_device(_dev) \
284 container_of(_dev, struct thermal_cooling_device, device) 219 container_of(_dev, struct thermal_cooling_device, device)
285 220
@@ -512,9 +447,6 @@ struct thermal_cooling_device *thermal_cooling_device_register(char *type,
512 struct thermal_zone_device *pos; 447 struct thermal_zone_device *pos;
513 int result; 448 int result;
514 449
515 if (!type)
516 return ERR_PTR(-EINVAL);
517
518 if (strlen(type) >= THERMAL_NAME_LENGTH) 450 if (strlen(type) >= THERMAL_NAME_LENGTH)
519 return ERR_PTR(-EINVAL); 451 return ERR_PTR(-EINVAL);
520 452
@@ -545,9 +477,11 @@ struct thermal_cooling_device *thermal_cooling_device_register(char *type,
545 } 477 }
546 478
547 /* sys I/F */ 479 /* sys I/F */
548 result = device_create_file(&cdev->device, &dev_attr_cdev_type); 480 if (type) {
549 if (result) 481 result = device_create_file(&cdev->device, &dev_attr_cdev_type);
550 goto unregister; 482 if (result)
483 goto unregister;
484 }
551 485
552 result = device_create_file(&cdev->device, &dev_attr_max_state); 486 result = device_create_file(&cdev->device, &dev_attr_max_state);
553 if (result) 487 if (result)
@@ -613,8 +547,8 @@ void thermal_cooling_device_unregister(struct
613 tz->ops->unbind(tz, cdev); 547 tz->ops->unbind(tz, cdev);
614 } 548 }
615 mutex_unlock(&thermal_list_lock); 549 mutex_unlock(&thermal_list_lock);
616 550 if (cdev->type[0])
617 device_remove_file(&cdev->device, &dev_attr_cdev_type); 551 device_remove_file(&cdev->device, &dev_attr_cdev_type);
618 device_remove_file(&cdev->device, &dev_attr_max_state); 552 device_remove_file(&cdev->device, &dev_attr_max_state);
619 device_remove_file(&cdev->device, &dev_attr_cur_state); 553 device_remove_file(&cdev->device, &dev_attr_cur_state);
620 554
@@ -646,9 +580,6 @@ struct thermal_zone_device *thermal_zone_device_register(char *type,
646 int result; 580 int result;
647 int count; 581 int count;
648 582
649 if (!type)
650 return ERR_PTR(-EINVAL);
651
652 if (strlen(type) >= THERMAL_NAME_LENGTH) 583 if (strlen(type) >= THERMAL_NAME_LENGTH)
653 return ERR_PTR(-EINVAL); 584 return ERR_PTR(-EINVAL);
654 585
@@ -670,13 +601,6 @@ struct thermal_zone_device *thermal_zone_device_register(char *type,
670 kfree(tz); 601 kfree(tz);
671 return ERR_PTR(result); 602 return ERR_PTR(result);
672 } 603 }
673 if (tz->id >= MAX_THERMAL_ZONES) {
674 printk(KERN_ERR PREFIX
675 "Too many thermal zones\n");
676 release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
677 kfree(tz);
678 return ERR_PTR(-EINVAL);
679 }
680 604
681 strcpy(tz->type, type); 605 strcpy(tz->type, type);
682 tz->ops = ops; 606 tz->ops = ops;
@@ -691,27 +615,12 @@ struct thermal_zone_device *thermal_zone_device_register(char *type,
691 return ERR_PTR(result); 615 return ERR_PTR(result);
692 } 616 }
693 617
694 /* hwmon sys I/F */
695 result = device_create_file(thermal_hwmon,
696 &sensor_attrs[tz->id * 2].dev_attr);
697 if (result)
698 goto unregister;
699
700 if (trips > 0) {
701 char buf[40];
702 result = tz->ops->get_trip_type(tz, 0, buf);
703 if (result > 0 && !strcmp(buf, "critical\n")) {
704 result = device_create_file(thermal_hwmon,
705 &sensor_attrs[tz->id * 2 + 1].dev_attr);
706 if (result)
707 goto unregister;
708 }
709 }
710
711 /* sys I/F */ 618 /* sys I/F */
712 result = device_create_file(&tz->device, &dev_attr_type); 619 if (type) {
713 if (result) 620 result = device_create_file(&tz->device, &dev_attr_type);
714 goto unregister; 621 if (result)
622 goto unregister;
623 }
715 624
716 result = device_create_file(&tz->device, &dev_attr_temp); 625 result = device_create_file(&tz->device, &dev_attr_temp);
717 if (result) 626 if (result)
@@ -778,17 +687,8 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
778 tz->ops->unbind(tz, cdev); 687 tz->ops->unbind(tz, cdev);
779 mutex_unlock(&thermal_list_lock); 688 mutex_unlock(&thermal_list_lock);
780 689
781 device_remove_file(thermal_hwmon, 690 if (tz->type[0])
782 &sensor_attrs[tz->id * 2].dev_attr); 691 device_remove_file(&tz->device, &dev_attr_type);
783 if (tz->trips > 0) {
784 char buf[40];
785 if (tz->ops->get_trip_type(tz, 0, buf) > 0)
786 if (!strcmp(buf, "critical\n"))
787 device_remove_file(thermal_hwmon,
788 &sensor_attrs[tz->id * 2 + 1].dev_attr);
789 }
790
791 device_remove_file(&tz->device, &dev_attr_type);
792 device_remove_file(&tz->device, &dev_attr_temp); 692 device_remove_file(&tz->device, &dev_attr_temp);
793 if (tz->ops->get_mode) 693 if (tz->ops->get_mode)
794 device_remove_file(&tz->device, &dev_attr_mode); 694 device_remove_file(&tz->device, &dev_attr_mode);
@@ -805,19 +705,6 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
805 705
806EXPORT_SYMBOL(thermal_zone_device_unregister); 706EXPORT_SYMBOL(thermal_zone_device_unregister);
807 707
808static void thermal_exit(void)
809{
810 if (thermal_hwmon) {
811 device_remove_file(thermal_hwmon, &dev_attr_name);
812 hwmon_device_unregister(thermal_hwmon);
813 }
814 class_unregister(&thermal_class);
815 idr_destroy(&thermal_tz_idr);
816 idr_destroy(&thermal_cdev_idr);
817 mutex_destroy(&thermal_idr_lock);
818 mutex_destroy(&thermal_list_lock);
819}
820
821static int __init thermal_init(void) 708static int __init thermal_init(void)
822{ 709{
823 int result = 0; 710 int result = 0;
@@ -829,21 +716,17 @@ static int __init thermal_init(void)
829 mutex_destroy(&thermal_idr_lock); 716 mutex_destroy(&thermal_idr_lock);
830 mutex_destroy(&thermal_list_lock); 717 mutex_destroy(&thermal_list_lock);
831 } 718 }
832
833 thermal_hwmon = hwmon_device_register(NULL);
834 if (IS_ERR(thermal_hwmon)) {
835 result = PTR_ERR(thermal_hwmon);
836 thermal_hwmon = NULL;
837 printk(KERN_ERR PREFIX
838 "unable to register hwmon device\n");
839 thermal_exit();
840 return result;
841 }
842
843 result = device_create_file(thermal_hwmon, &dev_attr_name);
844
845 return result; 719 return result;
846} 720}
847 721
722static void __exit thermal_exit(void)
723{
724 class_unregister(&thermal_class);
725 idr_destroy(&thermal_tz_idr);
726 idr_destroy(&thermal_cdev_idr);
727 mutex_destroy(&thermal_idr_lock);
728 mutex_destroy(&thermal_list_lock);
729}
730
848subsys_initcall(thermal_init); 731subsys_initcall(thermal_init);
849module_exit(thermal_exit); 732module_exit(thermal_exit);
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index e8a01f264540..11759080ca54 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -470,6 +470,8 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
470 470
471 vma->vm_flags |= VM_IO | VM_RESERVED; 471 vma->vm_flags |= VM_IO | VM_RESERVED;
472 472
473 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
474
473 return remap_pfn_range(vma, 475 return remap_pfn_range(vma,
474 vma->vm_start, 476 vma->vm_start,
475 idev->info->mem[mi].addr >> PAGE_SHIFT, 477 idev->info->mem[mi].addr >> PAGE_SHIFT,
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index fefb92296e8f..c311f67b7f08 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1206,7 +1206,10 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
1206 return -EINVAL; 1206 return -EINVAL;
1207 } 1207 }
1208 1208
1209 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1209 if (dev->quirks & USB_QUIRK_NO_SET_INTF)
1210 ret = -EPIPE;
1211 else
1212 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1210 USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE, 1213 USB_REQ_SET_INTERFACE, USB_RECIP_INTERFACE,
1211 alternate, interface, NULL, 0, 5000); 1214 alternate, interface, NULL, 0, 5000);
1212 1215
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index d9d1eb19f2a1..dfc5418ea10c 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -50,6 +50,9 @@ static const struct usb_device_id usb_quirk_list[] = {
50 /* M-Systems Flash Disk Pioneers */ 50 /* M-Systems Flash Disk Pioneers */
51 { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME }, 51 { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME },
52 52
53 /* X-Rite/Gretag-Macbeth Eye-One Pro display colorimeter */
54 { USB_DEVICE(0x0971, 0x2000), .driver_info = USB_QUIRK_NO_SET_INTF },
55
53 /* Action Semiconductor flash disk */ 56 /* Action Semiconductor flash disk */
54 { USB_DEVICE(0x10d6, 0x2200), .driver_info = 57 { USB_DEVICE(0x10d6, 0x2200), .driver_info =
55 USB_QUIRK_STRING_FETCH_255 }, 58 USB_QUIRK_STRING_FETCH_255 },
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 805602a687cb..0a6feafc8d28 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -1458,7 +1458,7 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1458 /* currently one config, two speeds */ 1458 /* currently one config, two speeds */
1459 case USB_REQ_SET_CONFIGURATION: 1459 case USB_REQ_SET_CONFIGURATION:
1460 if (ctrl->bRequestType != 0) 1460 if (ctrl->bRequestType != 0)
1461 break; 1461 goto unrecognized;
1462 if (0 == (u8) w_value) { 1462 if (0 == (u8) w_value) {
1463 value = 0; 1463 value = 0;
1464 dev->current_config = 0; 1464 dev->current_config = 0;
@@ -1505,7 +1505,7 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1505 /* PXA automagically handles this request too */ 1505 /* PXA automagically handles this request too */
1506 case USB_REQ_GET_CONFIGURATION: 1506 case USB_REQ_GET_CONFIGURATION:
1507 if (ctrl->bRequestType != 0x80) 1507 if (ctrl->bRequestType != 0x80)
1508 break; 1508 goto unrecognized;
1509 *(u8 *)req->buf = dev->current_config; 1509 *(u8 *)req->buf = dev->current_config;
1510 value = min (w_length, (u16) 1); 1510 value = min (w_length, (u16) 1);
1511 break; 1511 break;
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 40e8240b7851..4e065e556e4b 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -135,8 +135,6 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
135 hcd->state = HC_STATE_QUIESCING; 135 hcd->state = HC_STATE_QUIESCING;
136 } 136 }
137 ehci->command = ehci_readl(ehci, &ehci->regs->command); 137 ehci->command = ehci_readl(ehci, &ehci->regs->command);
138 if (ehci->reclaim)
139 end_unlink_async(ehci);
140 ehci_work(ehci); 138 ehci_work(ehci);
141 139
142 /* Unlike other USB host controller types, EHCI doesn't have 140 /* Unlike other USB host controller types, EHCI doesn't have
@@ -180,6 +178,9 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
180 ehci_halt (ehci); 178 ehci_halt (ehci);
181 hcd->state = HC_STATE_SUSPENDED; 179 hcd->state = HC_STATE_SUSPENDED;
182 180
181 if (ehci->reclaim)
182 end_unlink_async(ehci);
183
183 /* allow remote wakeup */ 184 /* allow remote wakeup */
184 mask = INTR_MASK; 185 mask = INTR_MASK;
185 if (!device_may_wakeup(&hcd->self.root_hub->dev)) 186 if (!device_may_wakeup(&hcd->self.root_hub->dev))
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 3ba01664f821..72ccd56e36dd 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -152,6 +152,20 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
152 break; 152 break;
153 } 153 }
154 break; 154 break;
155 case PCI_VENDOR_ID_VIA:
156 if (pdev->device == 0x3104 && (pdev->revision & 0xf0) == 0x60) {
157 u8 tmp;
158
159 /* The VT6212 defaults to a 1 usec EHCI sleep time which
160 * hogs the PCI bus *badly*. Setting bit 5 of 0x4B makes
161 * that sleep time use the conventional 10 usec.
162 */
163 pci_read_config_byte(pdev, 0x4b, &tmp);
164 if (tmp & 0x20)
165 break;
166 pci_write_config_byte(pdev, 0x4b, tmp | 0x20);
167 }
168 break;
155 } 169 }
156 170
157 ehci_reset(ehci); 171 ehci_reset(ehci);
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index dd4798ee028e..33f1c1c32edf 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -467,7 +467,7 @@ static void unlink_watchdog_func(unsigned long _ohci)
467out: 467out:
468 kfree(seen); 468 kfree(seen);
469 if (ohci->eds_scheduled) 469 if (ohci->eds_scheduled)
470 mod_timer(&ohci->unlink_watchdog, round_jiffies_relative(HZ)); 470 mod_timer(&ohci->unlink_watchdog, round_jiffies(jiffies + HZ));
471done: 471done:
472 spin_unlock_irqrestore(&ohci->lock, flags); 472 spin_unlock_irqrestore(&ohci->lock, flags);
473} 473}
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
index 51817322232b..9c9f3b59186f 100644
--- a/drivers/usb/host/ohci-q.c
+++ b/drivers/usb/host/ohci-q.c
@@ -169,7 +169,7 @@ static int ed_schedule (struct ohci_hcd *ohci, struct ed *ed)
169 if (quirk_zfmicro(ohci) 169 if (quirk_zfmicro(ohci)
170 && (ed->type == PIPE_INTERRUPT) 170 && (ed->type == PIPE_INTERRUPT)
171 && !(ohci->eds_scheduled++)) 171 && !(ohci->eds_scheduled++))
172 mod_timer(&ohci->unlink_watchdog, round_jiffies_relative(HZ)); 172 mod_timer(&ohci->unlink_watchdog, round_jiffies(jiffies + HZ));
173 wmb (); 173 wmb ();
174 174
175 /* we care about rm_list when setting CLE/BLE in case the HC was at 175 /* we care about rm_list when setting CLE/BLE in case the HC was at
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index da922dfc0dcc..b6b5b2affad1 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -378,6 +378,7 @@ alloc_sglist (int nents, int max, int vary)
378 sg = kmalloc (nents * sizeof *sg, GFP_KERNEL); 378 sg = kmalloc (nents * sizeof *sg, GFP_KERNEL);
379 if (!sg) 379 if (!sg)
380 return NULL; 380 return NULL;
381 sg_init_table(sg, nents);
381 382
382 for (i = 0; i < nents; i++) { 383 for (i = 0; i < nents; i++) {
383 char *buf; 384 char *buf;
@@ -390,7 +391,7 @@ alloc_sglist (int nents, int max, int vary)
390 } 391 }
391 392
392 /* kmalloc pages are always physically contiguous! */ 393 /* kmalloc pages are always physically contiguous! */
393 sg_init_one(&sg[i], buf, size); 394 sg_set_buf(&sg[i], buf, size);
394 395
395 switch (pattern) { 396 switch (pattern) {
396 case 0: 397 case 0:
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index f3ca66017a03..324bb61d68ff 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -75,6 +75,7 @@ static struct usb_device_id id_table [] = {
75 { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */ 75 { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */
76 { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */ 76 { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */
77 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */ 77 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */
78 { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */
78 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ 79 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
79 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ 80 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
80 { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */ 81 { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */
diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h
index 8a0d17401529..74ce8bca3e66 100644
--- a/drivers/usb/serial/keyspan.h
+++ b/drivers/usb/serial/keyspan.h
@@ -637,6 +637,7 @@ static struct usb_serial_driver keyspan_pre_device = {
637 .description = "Keyspan - (without firmware)", 637 .description = "Keyspan - (without firmware)",
638 .id_table = keyspan_pre_ids, 638 .id_table = keyspan_pre_ids,
639 .num_interrupt_in = NUM_DONT_CARE, 639 .num_interrupt_in = NUM_DONT_CARE,
640 .num_interrupt_out = NUM_DONT_CARE,
640 .num_bulk_in = NUM_DONT_CARE, 641 .num_bulk_in = NUM_DONT_CARE,
641 .num_bulk_out = NUM_DONT_CARE, 642 .num_bulk_out = NUM_DONT_CARE,
642 .num_ports = 1, 643 .num_ports = 1,
@@ -651,6 +652,7 @@ static struct usb_serial_driver keyspan_1port_device = {
651 .description = "Keyspan 1 port adapter", 652 .description = "Keyspan 1 port adapter",
652 .id_table = keyspan_1port_ids, 653 .id_table = keyspan_1port_ids,
653 .num_interrupt_in = NUM_DONT_CARE, 654 .num_interrupt_in = NUM_DONT_CARE,
655 .num_interrupt_out = NUM_DONT_CARE,
654 .num_bulk_in = NUM_DONT_CARE, 656 .num_bulk_in = NUM_DONT_CARE,
655 .num_bulk_out = NUM_DONT_CARE, 657 .num_bulk_out = NUM_DONT_CARE,
656 .num_ports = 1, 658 .num_ports = 1,
@@ -678,6 +680,7 @@ static struct usb_serial_driver keyspan_2port_device = {
678 .description = "Keyspan 2 port adapter", 680 .description = "Keyspan 2 port adapter",
679 .id_table = keyspan_2port_ids, 681 .id_table = keyspan_2port_ids,
680 .num_interrupt_in = NUM_DONT_CARE, 682 .num_interrupt_in = NUM_DONT_CARE,
683 .num_interrupt_out = NUM_DONT_CARE,
681 .num_bulk_in = NUM_DONT_CARE, 684 .num_bulk_in = NUM_DONT_CARE,
682 .num_bulk_out = NUM_DONT_CARE, 685 .num_bulk_out = NUM_DONT_CARE,
683 .num_ports = 2, 686 .num_ports = 2,
@@ -705,6 +708,7 @@ static struct usb_serial_driver keyspan_4port_device = {
705 .description = "Keyspan 4 port adapter", 708 .description = "Keyspan 4 port adapter",
706 .id_table = keyspan_4port_ids, 709 .id_table = keyspan_4port_ids,
707 .num_interrupt_in = NUM_DONT_CARE, 710 .num_interrupt_in = NUM_DONT_CARE,
711 .num_interrupt_out = NUM_DONT_CARE,
708 .num_bulk_in = NUM_DONT_CARE, 712 .num_bulk_in = NUM_DONT_CARE,
709 .num_bulk_out = NUM_DONT_CARE, 713 .num_bulk_out = NUM_DONT_CARE,
710 .num_ports = 4, 714 .num_ports = 4,
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index ae3ec1a64008..2af778555bdc 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -55,6 +55,7 @@ static struct usb_device_id id_table [] = {
55 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_DCU11) }, 55 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_DCU11) },
56 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ3) }, 56 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ3) },
57 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) }, 57 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) },
58 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ALDIGA) },
58 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, 59 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) },
59 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, 60 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) },
60 { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) }, 61 { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) },
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
index 237a41f6638a..10cf872e5ecb 100644
--- a/drivers/usb/serial/pl2303.h
+++ b/drivers/usb/serial/pl2303.h
@@ -13,6 +13,7 @@
13#define PL2303_PRODUCT_ID_DCU11 0x1234 13#define PL2303_PRODUCT_ID_DCU11 0x1234
14#define PL2303_PRODUCT_ID_PHAROS 0xaaa0 14#define PL2303_PRODUCT_ID_PHAROS 0xaaa0
15#define PL2303_PRODUCT_ID_RSAQ3 0xaaa2 15#define PL2303_PRODUCT_ID_RSAQ3 0xaaa2
16#define PL2303_PRODUCT_ID_ALDIGA 0x0611
16 17
17#define ATEN_VENDOR_ID 0x0557 18#define ATEN_VENDOR_ID 0x0557
18#define ATEN_VENDOR_ID2 0x0547 19#define ATEN_VENDOR_ID2 0x0547
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index e3d44ae8d448..ed678811e6a6 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -14,7 +14,7 @@
14 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org> 14 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org>
15*/ 15*/
16 16
17#define DRIVER_VERSION "v.1.2.7" 17#define DRIVER_VERSION "v.1.2.8"
18#define DRIVER_AUTHOR "Kevin Lloyd <linux@sierrawireless.com>" 18#define DRIVER_AUTHOR "Kevin Lloyd <linux@sierrawireless.com>"
19#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" 19#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems"
20 20
@@ -163,6 +163,7 @@ static struct usb_device_id id_table [] = {
163 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */ 163 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
164 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 & AC 875U */ 164 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 & AC 875U */
165 { USB_DEVICE(0x1199, 0x6813) }, /* Sierra Wireless MC8775 (Thinkpad internal) */ 165 { USB_DEVICE(0x1199, 0x6813) }, /* Sierra Wireless MC8775 (Thinkpad internal) */
166 { USB_DEVICE(0x1199, 0x6815) }, /* Sierra Wireless MC8775 */
166 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */ 167 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
167 { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780*/ 168 { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780*/
168 { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781*/ 169 { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781*/
@@ -196,9 +197,9 @@ struct sierra_port_private {
196 spinlock_t lock; /* lock the structure */ 197 spinlock_t lock; /* lock the structure */
197 int outstanding_urbs; /* number of out urbs in flight */ 198 int outstanding_urbs; /* number of out urbs in flight */
198 199
199 /* Input endpoints and buffer for this port */ 200 /* Input endpoints and buffers for this port */
200 struct urb *in_urbs[N_IN_URB]; 201 struct urb *in_urbs[N_IN_URB];
201 char in_buffer[N_IN_URB][IN_BUFLEN]; 202 char *in_buffer[N_IN_URB];
202 203
203 /* Settings for the port */ 204 /* Settings for the port */
204 int rts_state; /* Handshaking pins (outputs) */ 205 int rts_state; /* Handshaking pins (outputs) */
@@ -638,6 +639,15 @@ static int sierra_startup(struct usb_serial *serial)
638 return -ENOMEM; 639 return -ENOMEM;
639 } 640 }
640 spin_lock_init(&portdata->lock); 641 spin_lock_init(&portdata->lock);
642 for (j = 0; j < N_IN_URB; j++) {
643 portdata->in_buffer[j] = kmalloc(IN_BUFLEN, GFP_KERNEL);
644 if (!portdata->in_buffer[j]) {
645 for (--j; j >= 0; j--)
646 kfree(portdata->in_buffer[j]);
647 kfree(portdata);
648 return -ENOMEM;
649 }
650 }
641 651
642 usb_set_serial_port_data(port, portdata); 652 usb_set_serial_port_data(port, portdata);
643 653
@@ -681,7 +691,7 @@ static void sierra_shutdown(struct usb_serial *serial)
681 for (j = 0; j < N_IN_URB; j++) { 691 for (j = 0; j < N_IN_URB; j++) {
682 usb_kill_urb(portdata->in_urbs[j]); 692 usb_kill_urb(portdata->in_urbs[j]);
683 usb_free_urb(portdata->in_urbs[j]); 693 usb_free_urb(portdata->in_urbs[j]);
684 portdata->in_urbs[j] = NULL; 694 kfree(portdata->in_buffer[j]);
685 } 695 }
686 kfree(portdata); 696 kfree(portdata);
687 usb_set_serial_port_data(port, NULL); 697 usb_set_serial_port_data(port, NULL);
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index b517f93352ec..e3d241f67afc 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -265,8 +265,8 @@ static struct usb_serial_driver ti_1port_device = {
265 .description = "TI USB 3410 1 port adapter", 265 .description = "TI USB 3410 1 port adapter",
266 .usb_driver = &ti_usb_driver, 266 .usb_driver = &ti_usb_driver,
267 .id_table = ti_id_table_3410, 267 .id_table = ti_id_table_3410,
268 .num_interrupt_in = 1, 268 .num_interrupt_in = NUM_DONT_CARE,
269 .num_bulk_in = 1, 269 .num_bulk_in = NUM_DONT_CARE,
270 .num_bulk_out = 1, 270 .num_bulk_out = 1,
271 .num_ports = 1, 271 .num_ports = 1,
272 .attach = ti_startup, 272 .attach = ti_startup,
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index 22b3f78a388c..c2b01f7c3197 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -191,7 +191,7 @@ static struct usb_serial_driver handspring_device = {
191 .id_table = id_table, 191 .id_table = id_table,
192 .num_interrupt_in = NUM_DONT_CARE, 192 .num_interrupt_in = NUM_DONT_CARE,
193 .num_bulk_in = 2, 193 .num_bulk_in = 2,
194 .num_bulk_out = 2, 194 .num_bulk_out = NUM_DONT_CARE,
195 .num_ports = 2, 195 .num_ports = 2,
196 .open = visor_open, 196 .open = visor_open,
197 .close = visor_close, 197 .close = visor_close,
diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
index 2ae1e8673b19..971d13dd5e65 100644
--- a/drivers/usb/storage/isd200.c
+++ b/drivers/usb/storage/isd200.c
@@ -1230,6 +1230,7 @@ static int isd200_get_inquiry_data( struct us_data *us )
1230 1230
1231 /* Free driver structure */ 1231 /* Free driver structure */
1232 us->extra_destructor(info); 1232 us->extra_destructor(info);
1233 kfree(info);
1233 us->extra = NULL; 1234 us->extra = NULL;
1234 us->extra_destructor = NULL; 1235 us->extra_destructor = NULL;
1235 } 1236 }
@@ -1469,6 +1470,7 @@ static void isd200_free_info_ptrs(void *info_)
1469 if (info) { 1470 if (info) {
1470 kfree(info->id); 1471 kfree(info->id);
1471 kfree(info->RegsBuf); 1472 kfree(info->RegsBuf);
1473 kfree(info->srb.sense_buffer);
1472 } 1474 }
1473} 1475}
1474 1476
@@ -1494,7 +1496,9 @@ static int isd200_init_info(struct us_data *us)
1494 kzalloc(sizeof(struct hd_driveid), GFP_KERNEL); 1496 kzalloc(sizeof(struct hd_driveid), GFP_KERNEL);
1495 info->RegsBuf = (unsigned char *) 1497 info->RegsBuf = (unsigned char *)
1496 kmalloc(sizeof(info->ATARegs), GFP_KERNEL); 1498 kmalloc(sizeof(info->ATARegs), GFP_KERNEL);
1497 if (!info->id || !info->RegsBuf) { 1499 info->srb.sense_buffer =
1500 kmalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL);
1501 if (!info->id || !info->RegsBuf || !info->srb.sense_buffer) {
1498 isd200_free_info_ptrs(info); 1502 isd200_free_info_ptrs(info);
1499 kfree(info); 1503 kfree(info);
1500 retStatus = ISD200_ERROR; 1504 retStatus = ISD200_ERROR;
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 5780ed15f1ad..bdd4334bed5a 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -1009,7 +1009,8 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
1009 US_DEBUGP("Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n", 1009 US_DEBUGP("Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n",
1010 le32_to_cpu(bcs->Signature), bcs->Tag, 1010 le32_to_cpu(bcs->Signature), bcs->Tag,
1011 residue, bcs->Status); 1011 residue, bcs->Status);
1012 if (bcs->Tag != us->tag || bcs->Status > US_BULK_STAT_PHASE) { 1012 if (!(bcs->Tag == us->tag || (us->flags & US_FL_BULK_IGNORE_TAG)) ||
1013 bcs->Status > US_BULK_STAT_PHASE) {
1013 US_DEBUGP("Bulk logical error\n"); 1014 US_DEBUGP("Bulk logical error\n");
1014 return USB_STOR_TRANSPORT_ERROR; 1015 return USB_STOR_TRANSPORT_ERROR;
1015 } 1016 }
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 99679a8cfa02..e5219a56947c 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1589,6 +1589,17 @@ UNUSUAL_DEV( 0x22b8, 0x4810, 0x0001, 0x0001,
1589 US_SC_DEVICE, US_PR_DEVICE, NULL, 1589 US_SC_DEVICE, US_PR_DEVICE, NULL,
1590 US_FL_FIX_CAPACITY), 1590 US_FL_FIX_CAPACITY),
1591 1591
1592/*
1593 * Patch by Constantin Baranov <const@tltsu.ru>
1594 * Report by Andreas Koenecke.
1595 * Motorola ROKR Z6.
1596 */
1597UNUSUAL_DEV( 0x22b8, 0x6426, 0x0101, 0x0101,
1598 "Motorola",
1599 "MSnc.",
1600 US_SC_DEVICE, US_PR_DEVICE, NULL,
1601 US_FL_FIX_INQUIRY | US_FL_FIX_CAPACITY | US_FL_BULK_IGNORE_TAG),
1602
1592/* Reported by Radovan Garabik <garabik@kassiopeia.juls.savba.sk> */ 1603/* Reported by Radovan Garabik <garabik@kassiopeia.juls.savba.sk> */
1593UNUSUAL_DEV( 0x2735, 0x100b, 0x0000, 0x9999, 1604UNUSUAL_DEV( 0x2735, 0x100b, 0x0000, 0x9999,
1594 "MPIO", 1605 "MPIO",
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index e0b0580705e4..1bd5fb30237d 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -1893,6 +1893,20 @@ config FB_XILINX
1893 framebuffer. ML300 carries a 640*480 LCD display on the board, 1893 framebuffer. ML300 carries a 640*480 LCD display on the board,
1894 ML403 uses a standard DB15 VGA connector. 1894 ML403 uses a standard DB15 VGA connector.
1895 1895
1896config FB_METRONOME
1897 tristate "Metronome display controller support"
1898 depends on FB && ARCH_PXA && MMU
1899 select FB_SYS_FILLRECT
1900 select FB_SYS_COPYAREA
1901 select FB_SYS_IMAGEBLIT
1902 select FB_SYS_FOPS
1903 select FB_DEFERRED_IO
1904 help
1905 This enables support for the Metronome display controller. Tested
1906 with an E-Ink 800x600 display and Gumstix Connex through an AMLCD
1907 interface. Please read <file:Documentation/fb/metronomefb.txt>
1908 for more information.
1909
1896config FB_VIRTUAL 1910config FB_VIRTUAL
1897 tristate "Virtual Frame Buffer support (ONLY FOR TESTING!)" 1911 tristate "Virtual Frame Buffer support (ONLY FOR TESTING!)"
1898 depends on FB 1912 depends on FB
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 03371c789039..11c0e5e05f21 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -103,6 +103,7 @@ obj-$(CONFIG_FB_PMAG_AA) += pmag-aa-fb.o
103obj-$(CONFIG_FB_PMAG_BA) += pmag-ba-fb.o 103obj-$(CONFIG_FB_PMAG_BA) += pmag-ba-fb.o
104obj-$(CONFIG_FB_PMAGB_B) += pmagb-b-fb.o 104obj-$(CONFIG_FB_PMAGB_B) += pmagb-b-fb.o
105obj-$(CONFIG_FB_MAXINE) += maxinefb.o 105obj-$(CONFIG_FB_MAXINE) += maxinefb.o
106obj-$(CONFIG_FB_METRONOME) += metronomefb.o
106obj-$(CONFIG_FB_S1D13XXX) += s1d13xxxfb.o 107obj-$(CONFIG_FB_S1D13XXX) += s1d13xxxfb.o
107obj-$(CONFIG_FB_IMX) += imxfb.o 108obj-$(CONFIG_FB_IMX) += imxfb.o
108obj-$(CONFIG_FB_S3C2410) += s3c2410fb.o 109obj-$(CONFIG_FB_S3C2410) += s3c2410fb.o
diff --git a/drivers/video/bf54x-lq043fb.c b/drivers/video/bf54x-lq043fb.c
index 986a550c0439..eefba3d0e4b9 100644
--- a/drivers/video/bf54x-lq043fb.c
+++ b/drivers/video/bf54x-lq043fb.c
@@ -384,7 +384,7 @@ static int bfin_bf54x_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
384 * Other flags can be set, and are documented in 384 * Other flags can be set, and are documented in
385 * include/linux/mm.h 385 * include/linux/mm.h
386 */ 386 */
387 vma->vm_flags |= VM_MAYSHARE; 387 vma->vm_flags |= VM_MAYSHARE | VM_SHARED;
388 388
389 return 0; 389 return 0;
390} 390}
diff --git a/drivers/video/bfin-t350mcqb-fb.c b/drivers/video/bfin-t350mcqb-fb.c
index a2bb2de9e020..135d6dd7e672 100644
--- a/drivers/video/bfin-t350mcqb-fb.c
+++ b/drivers/video/bfin-t350mcqb-fb.c
@@ -91,6 +91,7 @@ struct bfin_t350mcqbfb_info {
91 int lq043_open_cnt; 91 int lq043_open_cnt;
92 int irq; 92 int irq;
93 spinlock_t lock; /* lock */ 93 spinlock_t lock; /* lock */
94 u32 pseudo_pal[16];
94}; 95};
95 96
96static int nocursor; 97static int nocursor;
@@ -182,13 +183,13 @@ static void bfin_t350mcqb_config_dma(struct bfin_t350mcqbfb_info *fbi)
182 183
183} 184}
184 185
185static int bfin_t350mcqb_request_ports(int action) 186static u16 ppi0_req_8[] = {P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2,
186{
187 u16 ppi0_req_8[] = {P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2,
188 P_PPI0_D0, P_PPI0_D1, P_PPI0_D2, 187 P_PPI0_D0, P_PPI0_D1, P_PPI0_D2,
189 P_PPI0_D3, P_PPI0_D4, P_PPI0_D5, 188 P_PPI0_D3, P_PPI0_D4, P_PPI0_D5,
190 P_PPI0_D6, P_PPI0_D7, 0}; 189 P_PPI0_D6, P_PPI0_D7, 0};
191 190
191static int bfin_t350mcqb_request_ports(int action)
192{
192 if (action) { 193 if (action) {
193 if (peripheral_request_list(ppi0_req_8, DRIVER_NAME)) { 194 if (peripheral_request_list(ppi0_req_8, DRIVER_NAME)) {
194 printk(KERN_ERR "Requesting Peripherals faild\n"); 195 printk(KERN_ERR "Requesting Peripherals faild\n");
@@ -301,7 +302,7 @@ static int bfin_t350mcqb_fb_mmap(struct fb_info *info, struct vm_area_struct *vm
301 * Other flags can be set, and are documented in 302 * Other flags can be set, and are documented in
302 * include/linux/mm.h 303 * include/linux/mm.h
303 */ 304 */
304 vma->vm_flags |= VM_MAYSHARE; 305 vma->vm_flags |= VM_MAYSHARE | VM_SHARED;
305 306
306 return 0; 307 return 0;
307} 308}
@@ -520,16 +521,7 @@ static int __init bfin_t350mcqb_probe(struct platform_device *pdev)
520 521
521 fbinfo->fbops = &bfin_t350mcqb_fb_ops; 522 fbinfo->fbops = &bfin_t350mcqb_fb_ops;
522 523
523 fbinfo->pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL); 524 fbinfo->pseudo_palette = &info->pseudo_pal;
524 if (!fbinfo->pseudo_palette) {
525 printk(KERN_ERR DRIVER_NAME
526 "Fail to allocate pseudo_palette\n");
527
528 ret = -ENOMEM;
529 goto out4;
530 }
531
532 memset(fbinfo->pseudo_palette, 0, sizeof(u32) * 16);
533 525
534 if (fb_alloc_cmap(&fbinfo->cmap, BFIN_LCD_NBR_PALETTE_ENTRIES, 0) 526 if (fb_alloc_cmap(&fbinfo->cmap, BFIN_LCD_NBR_PALETTE_ENTRIES, 0)
535 < 0) { 527 < 0) {
@@ -537,7 +529,7 @@ static int __init bfin_t350mcqb_probe(struct platform_device *pdev)
537 "Fail to allocate colormap (%d entries)\n", 529 "Fail to allocate colormap (%d entries)\n",
538 BFIN_LCD_NBR_PALETTE_ENTRIES); 530 BFIN_LCD_NBR_PALETTE_ENTRIES);
539 ret = -EFAULT; 531 ret = -EFAULT;
540 goto out5; 532 goto out4;
541 } 533 }
542 534
543 if (bfin_t350mcqb_request_ports(1)) { 535 if (bfin_t350mcqb_request_ports(1)) {
@@ -552,11 +544,11 @@ static int __init bfin_t350mcqb_probe(struct platform_device *pdev)
552 goto out7; 544 goto out7;
553 } 545 }
554 546
555 if (request_irq(info->irq, (void *)bfin_t350mcqb_irq_error, IRQF_DISABLED, 547 ret = request_irq(info->irq, bfin_t350mcqb_irq_error, IRQF_DISABLED,
556 "PPI ERROR", info) < 0) { 548 "PPI ERROR", info);
549 if (ret < 0) {
557 printk(KERN_ERR DRIVER_NAME 550 printk(KERN_ERR DRIVER_NAME
558 ": unable to request PPI ERROR IRQ\n"); 551 ": unable to request PPI ERROR IRQ\n");
559 ret = -EFAULT;
560 goto out7; 552 goto out7;
561 } 553 }
562 554
@@ -584,8 +576,6 @@ out7:
584 bfin_t350mcqb_request_ports(0); 576 bfin_t350mcqb_request_ports(0);
585out6: 577out6:
586 fb_dealloc_cmap(&fbinfo->cmap); 578 fb_dealloc_cmap(&fbinfo->cmap);
587out5:
588 kfree(fbinfo->pseudo_palette);
589out4: 579out4:
590 dma_free_coherent(NULL, fbinfo->fix.smem_len, info->fb_buffer, 580 dma_free_coherent(NULL, fbinfo->fix.smem_len, info->fb_buffer,
591 info->dma_handle); 581 info->dma_handle);
@@ -605,6 +595,8 @@ static int bfin_t350mcqb_remove(struct platform_device *pdev)
605 struct fb_info *fbinfo = platform_get_drvdata(pdev); 595 struct fb_info *fbinfo = platform_get_drvdata(pdev);
606 struct bfin_t350mcqbfb_info *info = fbinfo->par; 596 struct bfin_t350mcqbfb_info *info = fbinfo->par;
607 597
598 unregister_framebuffer(fbinfo);
599
608 free_dma(CH_PPI); 600 free_dma(CH_PPI);
609 free_irq(info->irq, info); 601 free_irq(info->irq, info);
610 602
@@ -612,7 +604,6 @@ static int bfin_t350mcqb_remove(struct platform_device *pdev)
612 dma_free_coherent(NULL, fbinfo->fix.smem_len, info->fb_buffer, 604 dma_free_coherent(NULL, fbinfo->fix.smem_len, info->fb_buffer,
613 info->dma_handle); 605 info->dma_handle);
614 606
615 kfree(fbinfo->pseudo_palette);
616 fb_dealloc_cmap(&fbinfo->cmap); 607 fb_dealloc_cmap(&fbinfo->cmap);
617 608
618#ifndef NO_BL_SUPPORT 609#ifndef NO_BL_SUPPORT
@@ -620,10 +611,11 @@ static int bfin_t350mcqb_remove(struct platform_device *pdev)
620 backlight_device_unregister(bl_dev); 611 backlight_device_unregister(bl_dev);
621#endif 612#endif
622 613
623 unregister_framebuffer(fbinfo);
624
625 bfin_t350mcqb_request_ports(0); 614 bfin_t350mcqb_request_ports(0);
626 615
616 platform_set_drvdata(pdev, NULL);
617 framebuffer_release(fbinfo);
618
627 printk(KERN_INFO DRIVER_NAME ": Unregister LCD driver.\n"); 619 printk(KERN_INFO DRIVER_NAME ": Unregister LCD driver.\n");
628 620
629 return 0; 621 return 0;
diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
index 0f8cfb988c90..24843fdd5395 100644
--- a/drivers/video/fb_defio.c
+++ b/drivers/video/fb_defio.c
@@ -4,7 +4,7 @@
4 * Copyright (C) 2006 Jaya Kumar 4 * Copyright (C) 2006 Jaya Kumar
5 * 5 *
6 * This file is subject to the terms and conditions of the GNU General Public 6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive 7 * License. See the file COPYING in the main directory of this archive
8 * for more details. 8 * for more details.
9 */ 9 */
10 10
@@ -31,7 +31,7 @@ static int fb_deferred_io_fault(struct vm_area_struct *vma,
31 unsigned long offset; 31 unsigned long offset;
32 struct page *page; 32 struct page *page;
33 struct fb_info *info = vma->vm_private_data; 33 struct fb_info *info = vma->vm_private_data;
34 /* info->screen_base is in System RAM */ 34 /* info->screen_base is virtual memory */
35 void *screen_base = (void __force *) info->screen_base; 35 void *screen_base = (void __force *) info->screen_base;
36 36
37 offset = vmf->pgoff << PAGE_SHIFT; 37 offset = vmf->pgoff << PAGE_SHIFT;
@@ -43,6 +43,15 @@ static int fb_deferred_io_fault(struct vm_area_struct *vma,
43 return VM_FAULT_SIGBUS; 43 return VM_FAULT_SIGBUS;
44 44
45 get_page(page); 45 get_page(page);
46
47 if (vma->vm_file)
48 page->mapping = vma->vm_file->f_mapping;
49 else
50 printk(KERN_ERR "no mapping available\n");
51
52 BUG_ON(!page->mapping);
53 page->index = vmf->pgoff;
54
46 vmf->page = page; 55 vmf->page = page;
47 return 0; 56 return 0;
48} 57}
@@ -138,11 +147,20 @@ EXPORT_SYMBOL_GPL(fb_deferred_io_init);
138 147
139void fb_deferred_io_cleanup(struct fb_info *info) 148void fb_deferred_io_cleanup(struct fb_info *info)
140{ 149{
150 void *screen_base = (void __force *) info->screen_base;
141 struct fb_deferred_io *fbdefio = info->fbdefio; 151 struct fb_deferred_io *fbdefio = info->fbdefio;
152 struct page *page;
153 int i;
142 154
143 BUG_ON(!fbdefio); 155 BUG_ON(!fbdefio);
144 cancel_delayed_work(&info->deferred_work); 156 cancel_delayed_work(&info->deferred_work);
145 flush_scheduled_work(); 157 flush_scheduled_work();
158
159 /* clear out the mapping that we setup */
160 for (i = 0 ; i < info->fix.smem_len; i += PAGE_SIZE) {
161 page = vmalloc_to_page(screen_base + i);
162 page->mapping = NULL;
163 }
146} 164}
147EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup); 165EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
148 166
diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
index 1d13dd099af8..a24e680d2b9c 100644
--- a/drivers/video/i810/i810_main.c
+++ b/drivers/video/i810/i810_main.c
@@ -1476,7 +1476,7 @@ static int i810fb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1476 struct i810fb_par *par = info->par; 1476 struct i810fb_par *par = info->par;
1477 u8 __iomem *mmio = par->mmio_start_virtual; 1477 u8 __iomem *mmio = par->mmio_start_virtual;
1478 1478
1479 if (!(par->dev_flags & LOCKUP)) 1479 if (par->dev_flags & LOCKUP)
1480 return -ENXIO; 1480 return -ENXIO;
1481 1481
1482 if (cursor->image.width > 64 || cursor->image.height > 64) 1482 if (cursor->image.width > 64 || cursor->image.height > 64)
diff --git a/drivers/video/metronomefb.c b/drivers/video/metronomefb.c
new file mode 100644
index 000000000000..e9a89fd82757
--- /dev/null
+++ b/drivers/video/metronomefb.c
@@ -0,0 +1,999 @@
1/*
2 * linux/drivers/video/metronomefb.c -- FB driver for Metronome controller
3 *
4 * Copyright (C) 2008, Jaya Kumar
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive for
8 * more details.
9 *
10 * Layout is based on skeletonfb.c by James Simmons and Geert Uytterhoeven.
11 *
12 * This work was made possible by help and equipment support from E-Ink
13 * Corporation. http://support.eink.com/community
14 *
15 * This driver is written to be used with the Metronome display controller.
16 * It was tested with an E-Ink 800x600 Vizplex EPD on a Gumstix Connex board
17 * using the Lyre interface board.
18 *
19 * General notes:
20 * - User must set metronomefb_enable=1 to enable it.
21 * - See Documentation/fb/metronomefb.txt for how metronome works.
22 */
23#include <linux/module.h>
24#include <linux/kernel.h>
25#include <linux/errno.h>
26#include <linux/string.h>
27#include <linux/mm.h>
28#include <linux/slab.h>
29#include <linux/vmalloc.h>
30#include <linux/delay.h>
31#include <linux/interrupt.h>
32#include <linux/fb.h>
33#include <linux/init.h>
34#include <linux/platform_device.h>
35#include <linux/list.h>
36#include <linux/firmware.h>
37#include <linux/dma-mapping.h>
38#include <linux/uaccess.h>
39#include <linux/irq.h>
40
41#include <asm/arch/pxa-regs.h>
42#include <asm/unaligned.h>
43
44#define DEBUG 1
45#ifdef DEBUG
46#define DPRINTK(f, a...) printk(KERN_DEBUG "%s: " f, __func__ , ## a)
47#else
48#define DPRINTK(f, a...)
49#endif
50
51
52/* Display specific information */
53#define DPY_W 832
54#define DPY_H 622
55
56struct metromem_desc {
57 u32 mFDADR0;
58 u32 mFSADR0;
59 u32 mFIDR0;
60 u32 mLDCMD0;
61};
62
63struct metromem_cmd {
64 u16 opcode;
65 u16 args[((64-2)/2)];
66 u16 csum;
67};
68
69struct metronomefb_par {
70 unsigned char *metromem;
71 struct metromem_desc *metromem_desc;
72 struct metromem_cmd *metromem_cmd;
73 unsigned char *metromem_wfm;
74 unsigned char *metromem_img;
75 u16 *metromem_img_csum;
76 u16 *csum_table;
77 int metromemsize;
78 dma_addr_t metromem_dma;
79 dma_addr_t metromem_desc_dma;
80 struct fb_info *info;
81 wait_queue_head_t waitq;
82 u8 frame_count;
83};
84
85/* frame differs from image. frame includes non-visible pixels */
86struct epd_frame {
87 int fw; /* frame width */
88 int fh; /* frame height */
89};
90
91static struct epd_frame epd_frame_table[] = {
92 {
93 .fw = 832,
94 .fh = 622
95 },
96};
97
98static struct fb_fix_screeninfo metronomefb_fix __devinitdata = {
99 .id = "metronomefb",
100 .type = FB_TYPE_PACKED_PIXELS,
101 .visual = FB_VISUAL_STATIC_PSEUDOCOLOR,
102 .xpanstep = 0,
103 .ypanstep = 0,
104 .ywrapstep = 0,
105 .line_length = DPY_W,
106 .accel = FB_ACCEL_NONE,
107};
108
109static struct fb_var_screeninfo metronomefb_var __devinitdata = {
110 .xres = DPY_W,
111 .yres = DPY_H,
112 .xres_virtual = DPY_W,
113 .yres_virtual = DPY_H,
114 .bits_per_pixel = 8,
115 .grayscale = 1,
116 .nonstd = 1,
117 .red = { 4, 3, 0 },
118 .green = { 0, 0, 0 },
119 .blue = { 0, 0, 0 },
120 .transp = { 0, 0, 0 },
121};
122
123static unsigned int metronomefb_enable;
124
125struct waveform_hdr {
126 u8 stuff[32];
127
128 u8 wmta[3];
129 u8 fvsn;
130
131 u8 luts;
132 u8 mc;
133 u8 trc;
134 u8 stuff3;
135
136 u8 endb;
137 u8 swtb;
138 u8 stuff2a[2];
139
140 u8 stuff2b[3];
141 u8 wfm_cs;
142} __attribute__ ((packed));
143
144/* main metronomefb functions */
145static u8 calc_cksum(int start, int end, u8 *mem)
146{
147 u8 tmp = 0;
148 int i;
149
150 for (i = start; i < end; i++)
151 tmp += mem[i];
152
153 return tmp;
154}
155
156static u16 calc_img_cksum(u16 *start, int length)
157{
158 u16 tmp = 0;
159
160 while (length--)
161 tmp += *start++;
162
163 return tmp;
164}
165
166/* here we decode the incoming waveform file and populate metromem */
167#define EXP_WFORM_SIZE 47001
168static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t,
169 u8 *frame_count)
170{
171 int tta;
172 int wmta;
173 int trn = 0;
174 int i;
175 unsigned char v;
176 u8 cksum;
177 int cksum_idx;
178 int wfm_idx, owfm_idx;
179 int mem_idx = 0;
180 struct waveform_hdr *wfm_hdr;
181
182 if (size != EXP_WFORM_SIZE) {
183 printk(KERN_ERR "Error: unexpected size %d != %d\n", size,
184 EXP_WFORM_SIZE);
185 return -EINVAL;
186 }
187
188 wfm_hdr = (struct waveform_hdr *) mem;
189
190 if (wfm_hdr->fvsn != 1) {
191 printk(KERN_ERR "Error: bad fvsn %x\n", wfm_hdr->fvsn);
192 return -EINVAL;
193 }
194 if (wfm_hdr->luts != 0) {
195 printk(KERN_ERR "Error: bad luts %x\n", wfm_hdr->luts);
196 return -EINVAL;
197 }
198 cksum = calc_cksum(32, 47, mem);
199 if (cksum != wfm_hdr->wfm_cs) {
200 printk(KERN_ERR "Error: bad cksum %x != %x\n", cksum,
201 wfm_hdr->wfm_cs);
202 return -EINVAL;
203 }
204 wfm_hdr->mc += 1;
205 wfm_hdr->trc += 1;
206 for (i = 0; i < 5; i++) {
207 if (*(wfm_hdr->stuff2a + i) != 0) {
208 printk(KERN_ERR "Error: unexpected value in padding\n");
209 return -EINVAL;
210 }
211 }
212
213 /* calculating trn. trn is something used to index into
214 the waveform. presumably selecting the right one for the
215 desired temperature. it works out the offset of the first
216 v that exceeds the specified temperature */
217 if ((sizeof(*wfm_hdr) + wfm_hdr->trc) > size)
218 return -EINVAL;
219
220 for (i = sizeof(*wfm_hdr); i <= sizeof(*wfm_hdr) + wfm_hdr->trc; i++) {
221 if (mem[i] > t) {
222 trn = i - sizeof(*wfm_hdr) - 1;
223 break;
224 }
225 }
226
227 /* check temperature range table checksum */
228 cksum_idx = sizeof(*wfm_hdr) + wfm_hdr->trc + 1;
229 if (cksum_idx > size)
230 return -EINVAL;
231 cksum = calc_cksum(sizeof(*wfm_hdr), cksum_idx, mem);
232 if (cksum != mem[cksum_idx]) {
233 printk(KERN_ERR "Error: bad temperature range table cksum"
234 " %x != %x\n", cksum, mem[cksum_idx]);
235 return -EINVAL;
236 }
237
238 /* check waveform mode table address checksum */
239 wmta = le32_to_cpu(get_unaligned((__le32 *) wfm_hdr->wmta));
240 wmta &= 0x00FFFFFF;
241 cksum_idx = wmta + m*4 + 3;
242 if (cksum_idx > size)
243 return -EINVAL;
244 cksum = calc_cksum(cksum_idx - 3, cksum_idx, mem);
245 if (cksum != mem[cksum_idx]) {
246 printk(KERN_ERR "Error: bad mode table address cksum"
247 " %x != %x\n", cksum, mem[cksum_idx]);
248 return -EINVAL;
249 }
250
251 /* check waveform temperature table address checksum */
252 tta = le32_to_cpu(get_unaligned((int *) (mem + wmta + m*4)));
253 tta &= 0x00FFFFFF;
254 cksum_idx = tta + trn*4 + 3;
255 if (cksum_idx > size)
256 return -EINVAL;
257 cksum = calc_cksum(cksum_idx - 3, cksum_idx, mem);
258 if (cksum != mem[cksum_idx]) {
259 printk(KERN_ERR "Error: bad temperature table address cksum"
260 " %x != %x\n", cksum, mem[cksum_idx]);
261 return -EINVAL;
262 }
263
264 /* here we do the real work of putting the waveform into the
265 metromem buffer. this does runlength decoding of the waveform */
266 wfm_idx = le32_to_cpu(get_unaligned((__le32 *) (mem + tta + trn*4)));
267 wfm_idx &= 0x00FFFFFF;
268 owfm_idx = wfm_idx;
269 if (wfm_idx > size)
270 return -EINVAL;
271 while (wfm_idx < size) {
272 unsigned char rl;
273 v = mem[wfm_idx++];
274 if (v == wfm_hdr->swtb) {
275 while (((v = mem[wfm_idx++]) != wfm_hdr->swtb) &&
276 wfm_idx < size)
277 metromem[mem_idx++] = v;
278
279 continue;
280 }
281
282 if (v == wfm_hdr->endb)
283 break;
284
285 rl = mem[wfm_idx++];
286 for (i = 0; i <= rl; i++)
287 metromem[mem_idx++] = v;
288 }
289
290 cksum_idx = wfm_idx;
291 if (cksum_idx > size)
292 return -EINVAL;
293 cksum = calc_cksum(owfm_idx, cksum_idx, mem);
294 if (cksum != mem[cksum_idx]) {
295 printk(KERN_ERR "Error: bad waveform data cksum"
296 " %x != %x\n", cksum, mem[cksum_idx]);
297 return -EINVAL;
298 }
299 *frame_count = (mem_idx/64);
300
301 return 0;
302}
303
304/* register offsets for gpio control */
305#define LED_GPIO_PIN 51
306#define STDBY_GPIO_PIN 48
307#define RST_GPIO_PIN 49
308#define RDY_GPIO_PIN 32
309#define ERR_GPIO_PIN 17
310#define PCBPWR_GPIO_PIN 16
311
312#define AF_SEL_GPIO_N 0x3
313#define GAFR0_U_OFFSET(pin) ((pin - 16) * 2)
314#define GAFR1_L_OFFSET(pin) ((pin - 32) * 2)
315#define GAFR1_U_OFFSET(pin) ((pin - 48) * 2)
316#define GPDR1_OFFSET(pin) (pin - 32)
317#define GPCR1_OFFSET(pin) (pin - 32)
318#define GPSR1_OFFSET(pin) (pin - 32)
319#define GPCR0_OFFSET(pin) (pin)
320#define GPSR0_OFFSET(pin) (pin)
321
322static void metronome_set_gpio_output(int pin, int val)
323{
324 u8 index;
325
326 index = pin >> 4;
327
328 switch (index) {
329 case 1:
330 if (val)
331 GPSR0 |= (1 << GPSR0_OFFSET(pin));
332 else
333 GPCR0 |= (1 << GPCR0_OFFSET(pin));
334 break;
335 case 2:
336 break;
337 case 3:
338 if (val)
339 GPSR1 |= (1 << GPSR1_OFFSET(pin));
340 else
341 GPCR1 |= (1 << GPCR1_OFFSET(pin));
342 break;
343 default:
344 printk(KERN_ERR "unimplemented\n");
345 }
346}
347
348static void __devinit metronome_init_gpio_pin(int pin, int dir)
349{
350 u8 index;
351 /* dir 0 is output, 1 is input
352 - do 2 things here:
353 - set gpio alternate function to standard gpio
354 - set gpio direction to input or output */
355
356 index = pin >> 4;
357 switch (index) {
358 case 1:
359 GAFR0_U &= ~(AF_SEL_GPIO_N << GAFR0_U_OFFSET(pin));
360
361 if (dir)
362 GPDR0 &= ~(1 << pin);
363 else
364 GPDR0 |= (1 << pin);
365 break;
366 case 2:
367 GAFR1_L &= ~(AF_SEL_GPIO_N << GAFR1_L_OFFSET(pin));
368
369 if (dir)
370 GPDR1 &= ~(1 << GPDR1_OFFSET(pin));
371 else
372 GPDR1 |= (1 << GPDR1_OFFSET(pin));
373 break;
374 case 3:
375 GAFR1_U &= ~(AF_SEL_GPIO_N << GAFR1_U_OFFSET(pin));
376
377 if (dir)
378 GPDR1 &= ~(1 << GPDR1_OFFSET(pin));
379 else
380 GPDR1 |= (1 << GPDR1_OFFSET(pin));
381 break;
382 default:
383 printk(KERN_ERR "unimplemented\n");
384 }
385}
386
387static void __devinit metronome_init_gpio_regs(void)
388{
389 metronome_init_gpio_pin(LED_GPIO_PIN, 0);
390 metronome_set_gpio_output(LED_GPIO_PIN, 0);
391
392 metronome_init_gpio_pin(STDBY_GPIO_PIN, 0);
393 metronome_set_gpio_output(STDBY_GPIO_PIN, 0);
394
395 metronome_init_gpio_pin(RST_GPIO_PIN, 0);
396 metronome_set_gpio_output(RST_GPIO_PIN, 0);
397
398 metronome_init_gpio_pin(RDY_GPIO_PIN, 1);
399
400 metronome_init_gpio_pin(ERR_GPIO_PIN, 1);
401
402 metronome_init_gpio_pin(PCBPWR_GPIO_PIN, 0);
403 metronome_set_gpio_output(PCBPWR_GPIO_PIN, 0);
404}
405
406static void metronome_disable_lcd_controller(struct metronomefb_par *par)
407{
408 LCSR = 0xffffffff; /* Clear LCD Status Register */
409 LCCR0 |= LCCR0_DIS; /* Disable LCD Controller */
410
411 /* we reset and just wait for things to settle */
412 msleep(200);
413}
414
415static void metronome_enable_lcd_controller(struct metronomefb_par *par)
416{
417 LCSR = 0xffffffff;
418 FDADR0 = par->metromem_desc_dma;
419 LCCR0 |= LCCR0_ENB;
420}
421
422static void __devinit metronome_init_lcdc_regs(struct metronomefb_par *par)
423{
424 /* here we do:
425 - disable the lcd controller
426 - setup lcd control registers
427 - setup dma descriptor
428 - reenable lcd controller
429 */
430
431 /* disable the lcd controller */
432 metronome_disable_lcd_controller(par);
433
434 /* setup lcd control registers */
435 LCCR0 = LCCR0_LDM | LCCR0_SFM | LCCR0_IUM | LCCR0_EFM | LCCR0_PAS
436 | LCCR0_QDM | LCCR0_BM | LCCR0_OUM;
437
438 LCCR1 = (epd_frame_table[0].fw/2 - 1) /* pixels per line */
439 | (27 << 10) /* hsync pulse width - 1 */
440 | (33 << 16) /* eol pixel count */
441 | (33 << 24); /* bol pixel count */
442
443 LCCR2 = (epd_frame_table[0].fh - 1) /* lines per panel */
444 | (24 << 10) /* vsync pulse width - 1 */
445 | (2 << 16) /* eof pixel count */
446 | (0 << 24); /* bof pixel count */
447
448 LCCR3 = 2 /* pixel clock divisor */
449 | (24 << 8) /* AC Bias pin freq */
450 | LCCR3_16BPP /* BPP */
451 | LCCR3_PCP; /* PCP falling edge */
452
453 /* setup dma descriptor */
454 par->metromem_desc->mFDADR0 = par->metromem_desc_dma;
455 par->metromem_desc->mFSADR0 = par->metromem_dma;
456 par->metromem_desc->mFIDR0 = 0;
457 par->metromem_desc->mLDCMD0 = epd_frame_table[0].fw
458 * epd_frame_table[0].fh;
459 /* reenable lcd controller */
460 metronome_enable_lcd_controller(par);
461}
462
463static int metronome_display_cmd(struct metronomefb_par *par)
464{
465 int i;
466 u16 cs;
467 u16 opcode;
468 static u8 borderval;
469 u8 *ptr;
470
471 /* setup display command
472 we can't immediately set the opcode since the controller
473 will try parse the command before we've set it all up
474 so we just set cs here and set the opcode at the end */
475
476 ptr = par->metromem;
477
478 if (par->metromem_cmd->opcode == 0xCC40)
479 opcode = cs = 0xCC41;
480 else
481 opcode = cs = 0xCC40;
482
483 /* set the args ( 2 bytes ) for display */
484 i = 0;
485 par->metromem_cmd->args[i] = 1 << 3 /* border update */
486 | ((borderval++ % 4) & 0x0F) << 4
487 | (par->frame_count - 1) << 8;
488 cs += par->metromem_cmd->args[i++];
489
490 /* the rest are 0 */
491 memset((u8 *) (par->metromem_cmd->args + i), 0, (32-i)*2);
492
493 par->metromem_cmd->csum = cs;
494 par->metromem_cmd->opcode = opcode; /* display cmd */
495
496 i = wait_event_interruptible_timeout(par->waitq, (GPLR1 & 0x01), HZ);
497 return i;
498}
499
500static int __devinit metronome_powerup_cmd(struct metronomefb_par *par)
501{
502 int i;
503 u16 cs;
504
505 /* setup power up command */
506 par->metromem_cmd->opcode = 0x1234; /* pwr up pseudo cmd */
507 cs = par->metromem_cmd->opcode;
508
509 /* set pwr1,2,3 to 1024 */
510 for (i = 0; i < 3; i++) {
511 par->metromem_cmd->args[i] = 1024;
512 cs += par->metromem_cmd->args[i];
513 }
514
515 /* the rest are 0 */
516 memset((u8 *) (par->metromem_cmd->args + i), 0, (32-i)*2);
517
518 par->metromem_cmd->csum = cs;
519
520 msleep(1);
521 metronome_set_gpio_output(RST_GPIO_PIN, 1);
522
523 msleep(1);
524 metronome_set_gpio_output(STDBY_GPIO_PIN, 1);
525
526 i = wait_event_timeout(par->waitq, (GPLR1 & 0x01), HZ);
527 return i;
528}
529
530static int __devinit metronome_config_cmd(struct metronomefb_par *par)
531{
532 int i;
533 u16 cs;
534
535 /* setup config command
536 we can't immediately set the opcode since the controller
537 will try parse the command before we've set it all up
538 so we just set cs here and set the opcode at the end */
539
540 cs = 0xCC10;
541
542 /* set the 12 args ( 8 bytes ) for config. see spec for meanings */
543 i = 0;
544 par->metromem_cmd->args[i] = 15 /* sdlew */
545 | 2 << 8 /* sdosz */
546 | 0 << 11 /* sdor */
547 | 0 << 12 /* sdces */
548 | 0 << 15; /* sdcer */
549 cs += par->metromem_cmd->args[i++];
550
551 par->metromem_cmd->args[i] = 42 /* gdspl */
552 | 1 << 8 /* gdr1 */
553 | 1 << 9 /* sdshr */
554 | 0 << 15; /* gdspp */
555 cs += par->metromem_cmd->args[i++];
556
557 par->metromem_cmd->args[i] = 18 /* gdspw */
558 | 0 << 15; /* dispc */
559 cs += par->metromem_cmd->args[i++];
560
561 par->metromem_cmd->args[i] = 599 /* vdlc */
562 | 0 << 11 /* dsi */
563 | 0 << 12; /* dsic */
564 cs += par->metromem_cmd->args[i++];
565
566 /* the rest are 0 */
567 memset((u8 *) (par->metromem_cmd->args + i), 0, (32-i)*2);
568
569 par->metromem_cmd->csum = cs;
570 par->metromem_cmd->opcode = 0xCC10; /* config cmd */
571
572 i = wait_event_timeout(par->waitq, (GPLR1 & 0x01), HZ);
573 return i;
574}
575
576static int __devinit metronome_init_cmd(struct metronomefb_par *par)
577{
578 int i;
579 u16 cs;
580
581 /* setup init command
582 we can't immediately set the opcode since the controller
583 will try parse the command before we've set it all up
584 so we just set cs here and set the opcode at the end */
585
586 cs = 0xCC20;
587
588 /* set the args ( 2 bytes ) for init */
589 i = 0;
590 par->metromem_cmd->args[i] = 0;
591 cs += par->metromem_cmd->args[i++];
592
593 /* the rest are 0 */
594 memset((u8 *) (par->metromem_cmd->args + i), 0, (32-i)*2);
595
596 par->metromem_cmd->csum = cs;
597 par->metromem_cmd->opcode = 0xCC20; /* init cmd */
598
599 i = wait_event_timeout(par->waitq, (GPLR1 & 0x01), HZ);
600 return i;
601}
602
603static int __devinit metronome_init_regs(struct metronomefb_par *par)
604{
605 int res;
606
607 metronome_init_gpio_regs();
608 metronome_init_lcdc_regs(par);
609
610 res = metronome_powerup_cmd(par);
611 if (res)
612 return res;
613
614 res = metronome_config_cmd(par);
615 if (res)
616 return res;
617
618 res = metronome_init_cmd(par);
619 if (res)
620 return res;
621
622 return res;
623}
624
625static void metronomefb_dpy_update(struct metronomefb_par *par)
626{
627 u16 cksum;
628 unsigned char *buf = (unsigned char __force *)par->info->screen_base;
629
630 /* copy from vm to metromem */
631 memcpy(par->metromem_img, buf, DPY_W*DPY_H);
632
633 cksum = calc_img_cksum((u16 *) par->metromem_img,
634 (epd_frame_table[0].fw * DPY_H)/2);
635 *((u16 *) (par->metromem_img) +
636 (epd_frame_table[0].fw * DPY_H)/2) = cksum;
637 metronome_display_cmd(par);
638}
639
640static u16 metronomefb_dpy_update_page(struct metronomefb_par *par, int index)
641{
642 int i;
643 u16 csum = 0;
644 u16 *buf = (u16 __force *) (par->info->screen_base + index);
645 u16 *img = (u16 *) (par->metromem_img + index);
646
647 /* swizzle from vm to metromem and recalc cksum at the same time*/
648 for (i = 0; i < PAGE_SIZE/2; i++) {
649 *(img + i) = (buf[i] << 5) & 0xE0E0;
650 csum += *(img + i);
651 }
652 return csum;
653}
654
655/* this is called back from the deferred io workqueue */
656static void metronomefb_dpy_deferred_io(struct fb_info *info,
657 struct list_head *pagelist)
658{
659 u16 cksum;
660 struct page *cur;
661 struct fb_deferred_io *fbdefio = info->fbdefio;
662 struct metronomefb_par *par = info->par;
663
664 /* walk the written page list and swizzle the data */
665 list_for_each_entry(cur, &fbdefio->pagelist, lru) {
666 cksum = metronomefb_dpy_update_page(par,
667 (cur->index << PAGE_SHIFT));
668 par->metromem_img_csum -= par->csum_table[cur->index];
669 par->csum_table[cur->index] = cksum;
670 par->metromem_img_csum += cksum;
671 }
672
673 metronome_display_cmd(par);
674}
675
676static void metronomefb_fillrect(struct fb_info *info,
677 const struct fb_fillrect *rect)
678{
679 struct metronomefb_par *par = info->par;
680
681 cfb_fillrect(info, rect);
682 metronomefb_dpy_update(par);
683}
684
685static void metronomefb_copyarea(struct fb_info *info,
686 const struct fb_copyarea *area)
687{
688 struct metronomefb_par *par = info->par;
689
690 cfb_copyarea(info, area);
691 metronomefb_dpy_update(par);
692}
693
694static void metronomefb_imageblit(struct fb_info *info,
695 const struct fb_image *image)
696{
697 struct metronomefb_par *par = info->par;
698
699 cfb_imageblit(info, image);
700 metronomefb_dpy_update(par);
701}
702
703/*
704 * this is the slow path from userspace. they can seek and write to
705 * the fb. it is based on fb_sys_write
706 */
707static ssize_t metronomefb_write(struct fb_info *info, const char __user *buf,
708 size_t count, loff_t *ppos)
709{
710 struct metronomefb_par *par = info->par;
711 unsigned long p = *ppos;
712 void *dst;
713 int err = 0;
714 unsigned long total_size;
715
716 if (info->state != FBINFO_STATE_RUNNING)
717 return -EPERM;
718
719 total_size = info->fix.smem_len;
720
721 if (p > total_size)
722 return -EFBIG;
723
724 if (count > total_size) {
725 err = -EFBIG;
726 count = total_size;
727 }
728
729 if (count + p > total_size) {
730 if (!err)
731 err = -ENOSPC;
732
733 count = total_size - p;
734 }
735
736 dst = (void __force *) (info->screen_base + p);
737
738 if (copy_from_user(dst, buf, count))
739 err = -EFAULT;
740
741 if (!err)
742 *ppos += count;
743
744 metronomefb_dpy_update(par);
745
746 return (err) ? err : count;
747}
748
749static struct fb_ops metronomefb_ops = {
750 .owner = THIS_MODULE,
751 .fb_write = metronomefb_write,
752 .fb_fillrect = metronomefb_fillrect,
753 .fb_copyarea = metronomefb_copyarea,
754 .fb_imageblit = metronomefb_imageblit,
755};
756
757static struct fb_deferred_io metronomefb_defio = {
758 .delay = HZ,
759 .deferred_io = metronomefb_dpy_deferred_io,
760};
761
762static irqreturn_t metronome_handle_irq(int irq, void *dev_id)
763{
764 struct fb_info *info = dev_id;
765 struct metronomefb_par *par = info->par;
766
767 wake_up_interruptible(&par->waitq);
768 return IRQ_HANDLED;
769}
770
771static int __devinit metronomefb_probe(struct platform_device *dev)
772{
773 struct fb_info *info;
774 int retval = -ENOMEM;
775 int videomemorysize;
776 unsigned char *videomemory;
777 struct metronomefb_par *par;
778 const struct firmware *fw_entry;
779 int cmd_size, wfm_size, img_size, padding_size, totalsize;
780 int i;
781
782 /* we have two blocks of memory.
783 info->screen_base which is vm, and is the fb used by apps.
784 par->metromem which is physically contiguous memory and
785 contains the display controller commands, waveform,
786 processed image data and padding. this is the data pulled
787 by the pxa255's LCD controller and pushed to Metronome */
788
789 videomemorysize = (DPY_W*DPY_H);
790 videomemory = vmalloc(videomemorysize);
791 if (!videomemory)
792 return retval;
793
794 memset(videomemory, 0, videomemorysize);
795
796 info = framebuffer_alloc(sizeof(struct metronomefb_par), &dev->dev);
797 if (!info)
798 goto err_vfree;
799
800 info->screen_base = (char __iomem *) videomemory;
801 info->fbops = &metronomefb_ops;
802
803 info->var = metronomefb_var;
804 info->fix = metronomefb_fix;
805 info->fix.smem_len = videomemorysize;
806 par = info->par;
807 par->info = info;
808 init_waitqueue_head(&par->waitq);
809
810 /* this table caches per page csum values. */
811 par->csum_table = vmalloc(videomemorysize/PAGE_SIZE);
812 if (!par->csum_table)
813 goto err_csum_table;
814
815 /* the metromem buffer is divided as follows:
816 command | CRC | padding
817 16kb waveform data | CRC | padding
818 image data | CRC
819 and an extra 256 bytes for dma descriptors
820 eg: IW=832 IH=622 WS=128
821 */
822
823 cmd_size = 1 * epd_frame_table[0].fw;
824 wfm_size = ((16*1024 + 2 + epd_frame_table[0].fw - 1)
825 / epd_frame_table[0].fw) * epd_frame_table[0].fw;
826 img_size = epd_frame_table[0].fh * epd_frame_table[0].fw;
827 padding_size = 4 * epd_frame_table[0].fw;
828 totalsize = cmd_size + wfm_size + img_size + padding_size;
829 par->metromemsize = PAGE_ALIGN(totalsize + 256);
830 DPRINTK("desired memory size = %d\n", par->metromemsize);
831 dev->dev.coherent_dma_mask = 0xffffffffull;
832 par->metromem = dma_alloc_writecombine(&dev->dev, par->metromemsize,
833 &par->metromem_dma, GFP_KERNEL);
834 if (!par->metromem) {
835 printk(KERN_ERR
836 "metronomefb: unable to allocate dma buffer\n");
837 goto err_vfree;
838 }
839
840 info->fix.smem_start = par->metromem_dma;
841 par->metromem_cmd = (struct metromem_cmd *) par->metromem;
842 par->metromem_wfm = par->metromem + cmd_size;
843 par->metromem_img = par->metromem + cmd_size + wfm_size;
844 par->metromem_img_csum = (u16 *) (par->metromem_img +
845 (epd_frame_table[0].fw * DPY_H));
846 DPRINTK("img offset=0x%x\n", cmd_size + wfm_size);
847 par->metromem_desc = (struct metromem_desc *) (par->metromem + cmd_size
848 + wfm_size + img_size + padding_size);
849 par->metromem_desc_dma = par->metromem_dma + cmd_size + wfm_size
850 + img_size + padding_size;
851
852 /* load the waveform in. assume mode 3, temp 31 for now */
853 /* a) request the waveform file from userspace
854 b) process waveform and decode into metromem */
855
856 retval = request_firmware(&fw_entry, "waveform.wbf", &dev->dev);
857 if (retval < 0) {
858 printk(KERN_ERR "metronomefb: couldn't get waveform\n");
859 goto err_dma_free;
860 }
861
862 retval = load_waveform((u8 *) fw_entry->data, fw_entry->size,
863 par->metromem_wfm, 3, 31, &par->frame_count);
864 if (retval < 0) {
865 printk(KERN_ERR "metronomefb: couldn't process waveform\n");
866 goto err_ld_wfm;
867 }
868 release_firmware(fw_entry);
869
870 retval = request_irq(IRQ_GPIO(RDY_GPIO_PIN), metronome_handle_irq,
871 IRQF_DISABLED, "Metronome", info);
872 if (retval) {
873 dev_err(&dev->dev, "request_irq failed: %d\n", retval);
874 goto err_ld_wfm;
875 }
876 set_irq_type(IRQ_GPIO(RDY_GPIO_PIN), IRQT_FALLING);
877
878 retval = metronome_init_regs(par);
879 if (retval < 0)
880 goto err_free_irq;
881
882 info->flags = FBINFO_FLAG_DEFAULT;
883
884 info->fbdefio = &metronomefb_defio;
885 fb_deferred_io_init(info);
886
887 retval = fb_alloc_cmap(&info->cmap, 8, 0);
888 if (retval < 0) {
889 printk(KERN_ERR "Failed to allocate colormap\n");
890 goto err_fb_rel;
891 }
892
893 /* set cmap */
894 for (i = 0; i < 8; i++)
895 info->cmap.red[i] = (((2*i)+1)*(0xFFFF))/16;
896 memcpy(info->cmap.green, info->cmap.red, sizeof(u16)*8);
897 memcpy(info->cmap.blue, info->cmap.red, sizeof(u16)*8);
898
899 retval = register_framebuffer(info);
900 if (retval < 0)
901 goto err_cmap;
902
903 platform_set_drvdata(dev, info);
904
905 printk(KERN_INFO
906 "fb%d: Metronome frame buffer device, using %dK of video"
907 " memory\n", info->node, videomemorysize >> 10);
908
909 return 0;
910
911err_cmap:
912 fb_dealloc_cmap(&info->cmap);
913err_fb_rel:
914 framebuffer_release(info);
915err_free_irq:
916 free_irq(IRQ_GPIO(RDY_GPIO_PIN), info);
917err_ld_wfm:
918 release_firmware(fw_entry);
919err_dma_free:
920 dma_free_writecombine(&dev->dev, par->metromemsize, par->metromem,
921 par->metromem_dma);
922err_csum_table:
923 vfree(par->csum_table);
924err_vfree:
925 vfree(videomemory);
926 return retval;
927}
928
929static int __devexit metronomefb_remove(struct platform_device *dev)
930{
931 struct fb_info *info = platform_get_drvdata(dev);
932
933 if (info) {
934 struct metronomefb_par *par = info->par;
935 fb_deferred_io_cleanup(info);
936 dma_free_writecombine(&dev->dev, par->metromemsize,
937 par->metromem, par->metromem_dma);
938 fb_dealloc_cmap(&info->cmap);
939 vfree(par->csum_table);
940 unregister_framebuffer(info);
941 vfree((void __force *)info->screen_base);
942 free_irq(IRQ_GPIO(RDY_GPIO_PIN), info);
943 framebuffer_release(info);
944 }
945 return 0;
946}
947
948static struct platform_driver metronomefb_driver = {
949 .probe = metronomefb_probe,
950 .remove = metronomefb_remove,
951 .driver = {
952 .name = "metronomefb",
953 },
954};
955
956static struct platform_device *metronomefb_device;
957
958static int __init metronomefb_init(void)
959{
960 int ret;
961
962 if (!metronomefb_enable) {
963 printk(KERN_ERR
964 "Use metronomefb_enable to enable the device\n");
965 return -ENXIO;
966 }
967
968 ret = platform_driver_register(&metronomefb_driver);
969 if (!ret) {
970 metronomefb_device = platform_device_alloc("metronomefb", 0);
971 if (metronomefb_device)
972 ret = platform_device_add(metronomefb_device);
973 else
974 ret = -ENOMEM;
975
976 if (ret) {
977 platform_device_put(metronomefb_device);
978 platform_driver_unregister(&metronomefb_driver);
979 }
980 }
981 return ret;
982
983}
984
985static void __exit metronomefb_exit(void)
986{
987 platform_device_unregister(metronomefb_device);
988 platform_driver_unregister(&metronomefb_driver);
989}
990
991module_param(metronomefb_enable, uint, 0);
992MODULE_PARM_DESC(metronomefb_enable, "Enable communication with Metronome");
993
994module_init(metronomefb_init);
995module_exit(metronomefb_exit);
996
997MODULE_DESCRIPTION("fbdev driver for Metronome controller");
998MODULE_AUTHOR("Jaya Kumar");
999MODULE_LICENSE("GPL");
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index 59a8f73dec73..c0df924766a7 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -37,7 +37,7 @@ struct virtio_pci_device
37 struct pci_dev *pci_dev; 37 struct pci_dev *pci_dev;
38 38
39 /* the IO mapping for the PCI config space */ 39 /* the IO mapping for the PCI config space */
40 void *ioaddr; 40 void __iomem *ioaddr;
41 41
42 /* a list of queues so we can dispatch IRQs */ 42 /* a list of queues so we can dispatch IRQs */
43 spinlock_t lock; 43 spinlock_t lock;
@@ -111,7 +111,7 @@ static void vp_get(struct virtio_device *vdev, unsigned offset,
111 void *buf, unsigned len) 111 void *buf, unsigned len)
112{ 112{
113 struct virtio_pci_device *vp_dev = to_vp_device(vdev); 113 struct virtio_pci_device *vp_dev = to_vp_device(vdev);
114 void *ioaddr = vp_dev->ioaddr + VIRTIO_PCI_CONFIG + offset; 114 void __iomem *ioaddr = vp_dev->ioaddr + VIRTIO_PCI_CONFIG + offset;
115 u8 *ptr = buf; 115 u8 *ptr = buf;
116 int i; 116 int i;
117 117
@@ -125,7 +125,7 @@ static void vp_set(struct virtio_device *vdev, unsigned offset,
125 const void *buf, unsigned len) 125 const void *buf, unsigned len)
126{ 126{
127 struct virtio_pci_device *vp_dev = to_vp_device(vdev); 127 struct virtio_pci_device *vp_dev = to_vp_device(vdev);
128 void *ioaddr = vp_dev->ioaddr + VIRTIO_PCI_CONFIG + offset; 128 void __iomem *ioaddr = vp_dev->ioaddr + VIRTIO_PCI_CONFIG + offset;
129 const u8 *ptr = buf; 129 const u8 *ptr = buf;
130 int i; 130 int i;
131 131
@@ -388,6 +388,7 @@ static void __devexit virtio_pci_remove(struct pci_dev *pci_dev)
388{ 388{
389 struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); 389 struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
390 390
391 unregister_virtio_device(&vp_dev->vdev);
391 free_irq(pci_dev->irq, vp_dev); 392 free_irq(pci_dev->irq, vp_dev);
392 pci_set_drvdata(pci_dev, NULL); 393 pci_set_drvdata(pci_dev, NULL);
393 pci_iounmap(pci_dev, vp_dev->ioaddr); 394 pci_iounmap(pci_dev, vp_dev->ioaddr);
diff --git a/drivers/watchdog/it8712f_wdt.c b/drivers/watchdog/it8712f_wdt.c
index 1efcad3b6fca..ca90c5192596 100644
--- a/drivers/watchdog/it8712f_wdt.c
+++ b/drivers/watchdog/it8712f_wdt.c
@@ -111,15 +111,6 @@ superio_inw(int reg)
111 return val; 111 return val;
112} 112}
113 113
114static void
115superio_outw(int val, int reg)
116{
117 outb(reg++, REG);
118 outb((val >> 8) & 0xff, VAL);
119 outb(reg, REG);
120 outb(val & 0xff, VAL);
121}
122
123static inline void 114static inline void
124superio_select(int ldn) 115superio_select(int ldn)
125{ 116{
@@ -170,9 +161,8 @@ it8712f_wdt_update_margin(void)
170 superio_outb(config, WDT_CONFIG); 161 superio_outb(config, WDT_CONFIG);
171 162
172 if (revision >= 0x08) 163 if (revision >= 0x08)
173 superio_outw(units, WDT_TIMEOUT); 164 superio_outb(units >> 8, WDT_TIMEOUT + 1);
174 else 165 superio_outb(units, WDT_TIMEOUT);
175 superio_outb(units, WDT_TIMEOUT);
176} 166}
177 167
178static int 168static int