aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ata/ahci.c24
-rw-r--r--drivers/ata/libata-core.c62
-rw-r--r--drivers/ata/libata-scsi.c67
-rw-r--r--drivers/ata/libata-sff.c37
-rw-r--r--drivers/ata/pata_isapnp.c1
-rw-r--r--drivers/ata/sata_promise.c9
-rw-r--r--drivers/base/class.c59
-rw-r--r--drivers/base/core.c10
-rw-r--r--drivers/base/dd.c13
-rw-r--r--drivers/base/firmware_class.c4
-rw-r--r--drivers/block/loop.c100
-rw-r--r--drivers/cdrom/mcdx.c2
-rw-r--r--drivers/char/agp/agp.h6
-rw-r--r--drivers/char/agp/intel-agp.c576
-rw-r--r--drivers/char/stallion.c81
-rw-r--r--drivers/ide/ide-disk.c12
-rw-r--r--drivers/ide/ide-probe.c12
-rw-r--r--drivers/ide/ide.c9
-rw-r--r--drivers/ide/pci/amd74xx.c12
-rw-r--r--drivers/ide/pci/generic.c37
-rw-r--r--drivers/ide/pci/hpt366.c8
-rw-r--r--drivers/ide/pci/it821x.c34
-rw-r--r--drivers/ide/pci/serverworks.c51
-rw-r--r--drivers/infiniband/hw/amso1100/c2.c2
-rw-r--r--drivers/input/keyboard/pxa27x_keyboard.c6
-rw-r--r--drivers/isdn/hardware/eicon/divasfunc.c2
-rw-r--r--drivers/media/common/Kconfig1
-rw-r--r--drivers/media/dvb/b2c2/Makefile7
-rw-r--r--drivers/media/dvb/cinergyT2/cinergyT2.c3
-rw-r--r--drivers/media/dvb/frontends/tda10086.c21
-rw-r--r--drivers/media/dvb/frontends/tda826x.c4
-rw-r--r--drivers/media/video/Kconfig2
-rw-r--r--drivers/media/video/ivtv/ivtv-cards.h2
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.c1
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.h16
-rw-r--r--drivers/media/video/ivtv/ivtv-fileops.c16
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c45
-rw-r--r--drivers/media/video/ivtv/ivtv-irq.c204
-rw-r--r--drivers/media/video/ivtv/ivtv-queue.c31
-rw-r--r--drivers/media/video/ivtv/ivtv-queue.h39
-rw-r--r--drivers/media/video/ivtv/ivtv-streams.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-vbi.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-vbi.h2
-rw-r--r--drivers/media/video/saa7111.c49
-rw-r--r--drivers/media/video/usbvision/usbvision-core.c82
-rw-r--r--drivers/media/video/usbvision/usbvision.h1
-rw-r--r--drivers/mmc/core/sd.c26
-rw-r--r--drivers/mmc/host/at91_mci.c5
-rw-r--r--drivers/mmc/host/au1xmmc.c3
-rw-r--r--drivers/net/bnx2.c61
-rw-r--r--drivers/net/bnx2.h1
-rw-r--r--drivers/serial/amba-pl010.c4
-rw-r--r--drivers/tc/zs.c2
-rw-r--r--drivers/usb/atm/cxacru.c52
-rw-r--r--drivers/usb/class/usblp.c5
-rw-r--r--drivers/usb/core/Kconfig22
-rw-r--r--drivers/usb/core/config.c42
-rw-r--r--drivers/usb/gadget/epautoconf.c2
-rw-r--r--drivers/usb/gadget/inode.c8
-rw-r--r--drivers/usb/gadget/net2280.c6
-rw-r--r--drivers/usb/gadget/omap_udc.c6
-rw-r--r--drivers/usb/gadget/rndis.c35
-rw-r--r--drivers/usb/host/ohci-hub.c2
-rw-r--r--drivers/usb/storage/unusual_devs.h21
64 files changed, 1259 insertions, 810 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 7baeaffefe7a..545f330e59a5 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -426,6 +426,30 @@ static const struct pci_device_id ahci_pci_tbl[] = {
426 { PCI_VDEVICE(NVIDIA, 0x0559), board_ahci }, /* MCP67 */ 426 { PCI_VDEVICE(NVIDIA, 0x0559), board_ahci }, /* MCP67 */
427 { PCI_VDEVICE(NVIDIA, 0x055a), board_ahci }, /* MCP67 */ 427 { PCI_VDEVICE(NVIDIA, 0x055a), board_ahci }, /* MCP67 */
428 { PCI_VDEVICE(NVIDIA, 0x055b), board_ahci }, /* MCP67 */ 428 { PCI_VDEVICE(NVIDIA, 0x055b), board_ahci }, /* MCP67 */
429 { PCI_VDEVICE(NVIDIA, 0x07f0), board_ahci }, /* MCP73 */
430 { PCI_VDEVICE(NVIDIA, 0x07f1), board_ahci }, /* MCP73 */
431 { PCI_VDEVICE(NVIDIA, 0x07f2), board_ahci }, /* MCP73 */
432 { PCI_VDEVICE(NVIDIA, 0x07f3), board_ahci }, /* MCP73 */
433 { PCI_VDEVICE(NVIDIA, 0x07f4), board_ahci }, /* MCP73 */
434 { PCI_VDEVICE(NVIDIA, 0x07f5), board_ahci }, /* MCP73 */
435 { PCI_VDEVICE(NVIDIA, 0x07f6), board_ahci }, /* MCP73 */
436 { PCI_VDEVICE(NVIDIA, 0x07f7), board_ahci }, /* MCP73 */
437 { PCI_VDEVICE(NVIDIA, 0x07f8), board_ahci }, /* MCP73 */
438 { PCI_VDEVICE(NVIDIA, 0x07f9), board_ahci }, /* MCP73 */
439 { PCI_VDEVICE(NVIDIA, 0x07fa), board_ahci }, /* MCP73 */
440 { PCI_VDEVICE(NVIDIA, 0x07fb), board_ahci }, /* MCP73 */
441 { PCI_VDEVICE(NVIDIA, 0x0ad0), board_ahci }, /* MCP77 */
442 { PCI_VDEVICE(NVIDIA, 0x0ad1), board_ahci }, /* MCP77 */
443 { PCI_VDEVICE(NVIDIA, 0x0ad2), board_ahci }, /* MCP77 */
444 { PCI_VDEVICE(NVIDIA, 0x0ad3), board_ahci }, /* MCP77 */
445 { PCI_VDEVICE(NVIDIA, 0x0ad4), board_ahci }, /* MCP77 */
446 { PCI_VDEVICE(NVIDIA, 0x0ad5), board_ahci }, /* MCP77 */
447 { PCI_VDEVICE(NVIDIA, 0x0ad6), board_ahci }, /* MCP77 */
448 { PCI_VDEVICE(NVIDIA, 0x0ad7), board_ahci }, /* MCP77 */
449 { PCI_VDEVICE(NVIDIA, 0x0ad8), board_ahci }, /* MCP77 */
450 { PCI_VDEVICE(NVIDIA, 0x0ad9), board_ahci }, /* MCP77 */
451 { PCI_VDEVICE(NVIDIA, 0x0ada), board_ahci }, /* MCP77 */
452 { PCI_VDEVICE(NVIDIA, 0x0adb), board_ahci }, /* MCP77 */
429 453
430 /* SiS */ 454 /* SiS */
431 { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */ 455 { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 4733f009c7c9..047eabd75363 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1727,7 +1727,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
1727 1727
1728 /* sanity check */ 1728 /* sanity check */
1729 rc = -EINVAL; 1729 rc = -EINVAL;
1730 reason = "device reports illegal type"; 1730 reason = "device reports invalid type";
1731 1731
1732 if (class == ATA_DEV_ATA) { 1732 if (class == ATA_DEV_ATA) {
1733 if (!ata_id_is_ata(id) && !ata_id_is_cfa(id)) 1733 if (!ata_id_is_ata(id) && !ata_id_is_cfa(id))
@@ -1900,6 +1900,13 @@ int ata_dev_configure(struct ata_device *dev)
1900 if (ata_msg_probe(ap)) 1900 if (ata_msg_probe(ap))
1901 ata_dump_id(id); 1901 ata_dump_id(id);
1902 1902
1903 /* SCSI only uses 4-char revisions, dump full 8 chars from ATA */
1904 ata_id_c_string(dev->id, fwrevbuf, ATA_ID_FW_REV,
1905 sizeof(fwrevbuf));
1906
1907 ata_id_c_string(dev->id, modelbuf, ATA_ID_PROD,
1908 sizeof(modelbuf));
1909
1903 /* ATA-specific feature tests */ 1910 /* ATA-specific feature tests */
1904 if (dev->class == ATA_DEV_ATA) { 1911 if (dev->class == ATA_DEV_ATA) {
1905 if (ata_id_is_cfa(id)) { 1912 if (ata_id_is_cfa(id)) {
@@ -1914,13 +1921,6 @@ int ata_dev_configure(struct ata_device *dev)
1914 1921
1915 dev->n_sectors = ata_id_n_sectors(id); 1922 dev->n_sectors = ata_id_n_sectors(id);
1916 1923
1917 /* SCSI only uses 4-char revisions, dump full 8 chars from ATA */
1918 ata_id_c_string(dev->id, fwrevbuf, ATA_ID_FW_REV,
1919 sizeof(fwrevbuf));
1920
1921 ata_id_c_string(dev->id, modelbuf, ATA_ID_PROD,
1922 sizeof(modelbuf));
1923
1924 if (dev->id[59] & 0x100) 1924 if (dev->id[59] & 0x100)
1925 dev->multi_count = dev->id[59] & 0xff; 1925 dev->multi_count = dev->id[59] & 0xff;
1926 1926
@@ -2009,7 +2009,9 @@ int ata_dev_configure(struct ata_device *dev)
2009 2009
2010 /* print device info to dmesg */ 2010 /* print device info to dmesg */
2011 if (ata_msg_drv(ap) && print_info) 2011 if (ata_msg_drv(ap) && print_info)
2012 ata_dev_printk(dev, KERN_INFO, "ATAPI, max %s%s\n", 2012 ata_dev_printk(dev, KERN_INFO,
2013 "ATAPI: %s, %s, max %s%s\n",
2014 modelbuf, fwrevbuf,
2013 ata_mode_string(xfer_mask), 2015 ata_mode_string(xfer_mask),
2014 cdb_intr_string); 2016 cdb_intr_string);
2015 } 2017 }
@@ -3059,22 +3061,28 @@ static int ata_bus_post_reset(struct ata_port *ap, unsigned int devmask,
3059 } 3061 }
3060 } 3062 }
3061 3063
3062 /* if device 1 was found in ata_devchk, wait for 3064 /* if device 1 was found in ata_devchk, wait for register
3063 * register access, then wait for BSY to clear 3065 * access briefly, then wait for BSY to clear.
3064 */ 3066 */
3065 while (dev1) { 3067 if (dev1) {
3066 u8 nsect, lbal; 3068 int i;
3067 3069
3068 ap->ops->dev_select(ap, 1); 3070 ap->ops->dev_select(ap, 1);
3069 nsect = ioread8(ioaddr->nsect_addr); 3071
3070 lbal = ioread8(ioaddr->lbal_addr); 3072 /* Wait for register access. Some ATAPI devices fail
3071 if ((nsect == 1) && (lbal == 1)) 3073 * to set nsect/lbal after reset, so don't waste too
3072 break; 3074 * much time on it. We're gonna wait for !BSY anyway.
3073 if (time_after(jiffies, deadline)) 3075 */
3074 return -EBUSY; 3076 for (i = 0; i < 2; i++) {
3075 msleep(50); /* give drive a breather */ 3077 u8 nsect, lbal;
3076 } 3078
3077 if (dev1) { 3079 nsect = ioread8(ioaddr->nsect_addr);
3080 lbal = ioread8(ioaddr->lbal_addr);
3081 if ((nsect == 1) && (lbal == 1))
3082 break;
3083 msleep(50); /* give drive a breather */
3084 }
3085
3078 rc = ata_wait_ready(ap, deadline); 3086 rc = ata_wait_ready(ap, deadline);
3079 if (rc) { 3087 if (rc) {
3080 if (rc != -ENODEV) 3088 if (rc != -ENODEV)
@@ -3769,6 +3777,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
3769 { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA }, 3777 { "_NEC DV5800A", NULL, ATA_HORKAGE_NODMA },
3770 { "SAMSUNG CD-ROM SN-124","N001", ATA_HORKAGE_NODMA }, 3778 { "SAMSUNG CD-ROM SN-124","N001", ATA_HORKAGE_NODMA },
3771 { "Seagate STT20000A", NULL, ATA_HORKAGE_NODMA }, 3779 { "Seagate STT20000A", NULL, ATA_HORKAGE_NODMA },
3780 { "IOMEGA ZIP 250 ATAPI", NULL, ATA_HORKAGE_NODMA }, /* temporary fix */
3772 3781
3773 /* Weird ATAPI devices */ 3782 /* Weird ATAPI devices */
3774 { "TORiSAN DVD-ROM DRD-N216", NULL, ATA_HORKAGE_MAX_SEC_128 | 3783 { "TORiSAN DVD-ROM DRD-N216", NULL, ATA_HORKAGE_MAX_SEC_128 |
@@ -3791,6 +3800,8 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
3791 { "HTS541060G9SA00", "MB3OC60D", ATA_HORKAGE_NONCQ, }, 3800 { "HTS541060G9SA00", "MB3OC60D", ATA_HORKAGE_NONCQ, },
3792 { "HTS541080G9SA00", "MB4OC60D", ATA_HORKAGE_NONCQ, }, 3801 { "HTS541080G9SA00", "MB4OC60D", ATA_HORKAGE_NONCQ, },
3793 { "HTS541010G9SA00", "MBZOC60D", ATA_HORKAGE_NONCQ, }, 3802 { "HTS541010G9SA00", "MBZOC60D", ATA_HORKAGE_NONCQ, },
3803 /* Drives which do spurious command completion */
3804 { "HTS541680J9SA00", "SB2IC7EP", ATA_HORKAGE_NONCQ, },
3794 3805
3795 /* Devices with NCQ limits */ 3806 /* Devices with NCQ limits */
3796 3807
@@ -6313,7 +6324,8 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
6313 /* init sata_spd_limit to the current value */ 6324 /* init sata_spd_limit to the current value */
6314 if (sata_scr_read(ap, SCR_CONTROL, &scontrol) == 0) { 6325 if (sata_scr_read(ap, SCR_CONTROL, &scontrol) == 0) {
6315 int spd = (scontrol >> 4) & 0xf; 6326 int spd = (scontrol >> 4) & 0xf;
6316 ap->hw_sata_spd_limit &= (1 << spd) - 1; 6327 if (spd)
6328 ap->hw_sata_spd_limit &= (1 << spd) - 1;
6317 } 6329 }
6318 ap->sata_spd_limit = ap->hw_sata_spd_limit; 6330 ap->sata_spd_limit = ap->hw_sata_spd_limit;
6319 6331
@@ -6433,6 +6445,9 @@ int ata_host_activate(struct ata_host *host, int irq,
6433 if (rc) 6445 if (rc)
6434 devm_free_irq(host->dev, irq, host); 6446 devm_free_irq(host->dev, irq, host);
6435 6447
6448 /* Used to print device info at probe */
6449 host->irq = irq;
6450
6436 return rc; 6451 return rc;
6437} 6452}
6438 6453
@@ -6818,6 +6833,7 @@ EXPORT_SYMBOL_GPL(ata_check_status);
6818EXPORT_SYMBOL_GPL(ata_altstatus); 6833EXPORT_SYMBOL_GPL(ata_altstatus);
6819EXPORT_SYMBOL_GPL(ata_exec_command); 6834EXPORT_SYMBOL_GPL(ata_exec_command);
6820EXPORT_SYMBOL_GPL(ata_port_start); 6835EXPORT_SYMBOL_GPL(ata_port_start);
6836EXPORT_SYMBOL_GPL(ata_sff_port_start);
6821EXPORT_SYMBOL_GPL(ata_interrupt); 6837EXPORT_SYMBOL_GPL(ata_interrupt);
6822EXPORT_SYMBOL_GPL(ata_do_set_mode); 6838EXPORT_SYMBOL_GPL(ata_do_set_mode);
6823EXPORT_SYMBOL_GPL(ata_data_xfer); 6839EXPORT_SYMBOL_GPL(ata_data_xfer);
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index b3900cfbd880..c228df298bd8 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1363,12 +1363,22 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1363 * schedule EH_REVALIDATE operation to update the IDENTIFY DEVICE 1363 * schedule EH_REVALIDATE operation to update the IDENTIFY DEVICE
1364 * cache 1364 * cache
1365 */ 1365 */
1366 if (ap->ops->error_handler && 1366 if (ap->ops->error_handler && !need_sense) {
1367 !need_sense && (qc->tf.command == ATA_CMD_SET_FEATURES) && 1367 switch (qc->tf.command) {
1368 ((qc->tf.feature == SETFEATURES_WC_ON) || 1368 case ATA_CMD_SET_FEATURES:
1369 (qc->tf.feature == SETFEATURES_WC_OFF))) { 1369 if ((qc->tf.feature == SETFEATURES_WC_ON) ||
1370 ap->eh_info.action |= ATA_EH_REVALIDATE; 1370 (qc->tf.feature == SETFEATURES_WC_OFF)) {
1371 ata_port_schedule_eh(ap); 1371 ap->eh_info.action |= ATA_EH_REVALIDATE;
1372 ata_port_schedule_eh(ap);
1373 }
1374 break;
1375
1376 case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */
1377 case ATA_CMD_SET_MULTI: /* multi_count changed */
1378 ap->eh_info.action |= ATA_EH_REVALIDATE;
1379 ata_port_schedule_eh(ap);
1380 break;
1381 }
1372 } 1382 }
1373 1383
1374 /* For ATA pass thru (SAT) commands, generate a sense block if 1384 /* For ATA pass thru (SAT) commands, generate a sense block if
@@ -2506,22 +2516,21 @@ ata_scsi_map_proto(u8 byte1)
2506 return ATA_PROT_NODATA; 2516 return ATA_PROT_NODATA;
2507 2517
2508 case 6: /* DMA */ 2518 case 6: /* DMA */
2519 case 10: /* UDMA Data-in */
2520 case 11: /* UDMA Data-Out */
2509 return ATA_PROT_DMA; 2521 return ATA_PROT_DMA;
2510 2522
2511 case 4: /* PIO Data-in */ 2523 case 4: /* PIO Data-in */
2512 case 5: /* PIO Data-out */ 2524 case 5: /* PIO Data-out */
2513 return ATA_PROT_PIO; 2525 return ATA_PROT_PIO;
2514 2526
2515 case 10: /* Device Reset */
2516 case 0: /* Hard Reset */ 2527 case 0: /* Hard Reset */
2517 case 1: /* SRST */ 2528 case 1: /* SRST */
2518 case 2: /* Bus Idle */ 2529 case 8: /* Device Diagnostic */
2519 case 7: /* Packet */ 2530 case 9: /* Device Reset */
2520 case 8: /* DMA Queued */ 2531 case 7: /* DMA Queued */
2521 case 9: /* Device Diagnostic */ 2532 case 12: /* FPDMA */
2522 case 11: /* UDMA Data-in */ 2533 case 15: /* Return Response Info */
2523 case 12: /* UDMA Data-Out */
2524 case 13: /* FPDMA */
2525 default: /* Reserved */ 2534 default: /* Reserved */
2526 break; 2535 break;
2527 } 2536 }
@@ -2552,10 +2561,6 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
2552 if (tf->protocol == ATA_PROT_DMA && dev->dma_mode == 0) 2561 if (tf->protocol == ATA_PROT_DMA && dev->dma_mode == 0)
2553 goto invalid_fld; 2562 goto invalid_fld;
2554 2563
2555 if (cdb[1] & 0xe0)
2556 /* PIO multi not supported yet */
2557 goto invalid_fld;
2558
2559 /* 2564 /*
2560 * 12 and 16 byte CDBs use different offsets to 2565 * 12 and 16 byte CDBs use different offsets to
2561 * provide the various register values. 2566 * provide the various register values.
@@ -2600,12 +2605,26 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
2600 tf->device = cdb[8]; 2605 tf->device = cdb[8];
2601 tf->command = cdb[9]; 2606 tf->command = cdb[9];
2602 } 2607 }
2603 /* 2608
2604 * If slave is possible, enforce correct master/slave bit 2609 /* enforce correct master/slave bit */
2605 */ 2610 tf->device = dev->devno ?
2606 if (qc->ap->flags & ATA_FLAG_SLAVE_POSS) 2611 tf->device | ATA_DEV1 : tf->device & ~ATA_DEV1;
2607 tf->device = qc->dev->devno ? 2612
2608 tf->device | ATA_DEV1 : tf->device & ~ATA_DEV1; 2613 /* sanity check for pio multi commands */
2614 if ((cdb[1] & 0xe0) && !is_multi_taskfile(tf))
2615 goto invalid_fld;
2616
2617 if (is_multi_taskfile(tf)) {
2618 unsigned int multi_count = 1 << (cdb[1] >> 5);
2619
2620 /* compare the passed through multi_count
2621 * with the cached multi_count of libata
2622 */
2623 if (multi_count != dev->multi_count)
2624 ata_dev_printk(dev, KERN_WARNING,
2625 "invalid multi_count %u ignored\n",
2626 multi_count);
2627 }
2609 2628
2610 /* READ/WRITE LONG use a non-standard sect_size */ 2629 /* READ/WRITE LONG use a non-standard sect_size */
2611 qc->sect_size = ATA_SECT_SIZE; 2630 qc->sect_size = ATA_SECT_SIZE;
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index e35d13466c69..ce84805ba5f1 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -80,25 +80,25 @@ u8 ata_dummy_irq_on (struct ata_port *ap) { return 0; }
80u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) 80u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq)
81{ 81{
82 unsigned int bits = chk_drq ? ATA_BUSY | ATA_DRQ : ATA_BUSY; 82 unsigned int bits = chk_drq ? ATA_BUSY | ATA_DRQ : ATA_BUSY;
83 u8 host_stat, post_stat, status; 83 u8 host_stat = 0, post_stat = 0, status;
84 84
85 status = ata_busy_wait(ap, bits, 1000); 85 status = ata_busy_wait(ap, bits, 1000);
86 if (status & bits) 86 if (status & bits)
87 if (ata_msg_err(ap)) 87 if (ata_msg_err(ap))
88 printk(KERN_ERR "abnormal status 0x%X\n", status); 88 printk(KERN_ERR "abnormal status 0x%X\n", status);
89 89
90 /* get controller status; clear intr, err bits */ 90 if (ap->ioaddr.bmdma_addr) {
91 host_stat = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); 91 /* get controller status; clear intr, err bits */
92 iowrite8(host_stat | ATA_DMA_INTR | ATA_DMA_ERR, 92 host_stat = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
93 ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); 93 iowrite8(host_stat | ATA_DMA_INTR | ATA_DMA_ERR,
94 94 ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
95 post_stat = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
96 95
96 post_stat = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
97 }
97 if (ata_msg_intr(ap)) 98 if (ata_msg_intr(ap))
98 printk(KERN_INFO "%s: irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n", 99 printk(KERN_INFO "%s: irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n",
99 __FUNCTION__, 100 __FUNCTION__,
100 host_stat, post_stat, status); 101 host_stat, post_stat, status);
101
102 return status; 102 return status;
103} 103}
104 104
@@ -516,6 +516,27 @@ void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc)
516 ata_bmdma_stop(qc); 516 ata_bmdma_stop(qc);
517} 517}
518 518
519/**
520 * ata_sff_port_start - Set port up for dma.
521 * @ap: Port to initialize
522 *
523 * Called just after data structures for each port are
524 * initialized. Allocates space for PRD table if the device
525 * is DMA capable SFF.
526 *
527 * May be used as the port_start() entry in ata_port_operations.
528 *
529 * LOCKING:
530 * Inherited from caller.
531 */
532
533int ata_sff_port_start(struct ata_port *ap)
534{
535 if (ap->ioaddr.bmdma_addr)
536 return ata_port_start(ap);
537 return 0;
538}
539
519#ifdef CONFIG_PCI 540#ifdef CONFIG_PCI
520 541
521static int ata_resources_present(struct pci_dev *pdev, int port) 542static int ata_resources_present(struct pci_dev *pdev, int port)
diff --git a/drivers/ata/pata_isapnp.c b/drivers/ata/pata_isapnp.c
index 1f647b648204..5525518204e6 100644
--- a/drivers/ata/pata_isapnp.c
+++ b/drivers/ata/pata_isapnp.c
@@ -77,7 +77,6 @@ static int isapnp_init_one(struct pnp_dev *idev, const struct pnp_device_id *dev
77 struct ata_host *host; 77 struct ata_host *host;
78 struct ata_port *ap; 78 struct ata_port *ap;
79 void __iomem *cmd_addr, *ctl_addr; 79 void __iomem *cmd_addr, *ctl_addr;
80 int rc;
81 80
82 if (pnp_port_valid(idev, 0) == 0) 81 if (pnp_port_valid(idev, 0) == 0)
83 return -ENODEV; 82 return -ENODEV;
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c
index 2b924a69b365..6dc0b011a6b7 100644
--- a/drivers/ata/sata_promise.c
+++ b/drivers/ata/sata_promise.c
@@ -784,9 +784,12 @@ static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc)
784 if (qc->dev->flags & ATA_DFLAG_CDB_INTR) 784 if (qc->dev->flags & ATA_DFLAG_CDB_INTR)
785 break; 785 break;
786 /*FALLTHROUGH*/ 786 /*FALLTHROUGH*/
787 case ATA_PROT_NODATA:
788 if (qc->tf.flags & ATA_TFLAG_POLLING)
789 break;
790 /*FALLTHROUGH*/
787 case ATA_PROT_ATAPI_DMA: 791 case ATA_PROT_ATAPI_DMA:
788 case ATA_PROT_DMA: 792 case ATA_PROT_DMA:
789 case ATA_PROT_NODATA:
790 pdc_packet_start(qc); 793 pdc_packet_start(qc);
791 return 0; 794 return 0;
792 795
@@ -800,7 +803,7 @@ static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc)
800static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf) 803static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
801{ 804{
802 WARN_ON (tf->protocol == ATA_PROT_DMA || 805 WARN_ON (tf->protocol == ATA_PROT_DMA ||
803 tf->protocol == ATA_PROT_NODATA); 806 tf->protocol == ATA_PROT_ATAPI_DMA);
804 ata_tf_load(ap, tf); 807 ata_tf_load(ap, tf);
805} 808}
806 809
@@ -808,7 +811,7 @@ static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
808static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf) 811static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
809{ 812{
810 WARN_ON (tf->protocol == ATA_PROT_DMA || 813 WARN_ON (tf->protocol == ATA_PROT_DMA ||
811 tf->protocol == ATA_PROT_NODATA); 814 tf->protocol == ATA_PROT_ATAPI_DMA);
812 ata_exec_command(ap, tf); 815 ata_exec_command(ap, tf);
813} 816}
814 817
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 20c4ea6eb50d..8c506dbe3913 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -369,36 +369,6 @@ char *make_class_name(const char *name, struct kobject *kobj)
369 return class_name; 369 return class_name;
370} 370}
371 371
372static int deprecated_class_uevent(char **envp, int num_envp, int *cur_index,
373 char *buffer, int buffer_size,
374 int *cur_len,
375 struct class_device *class_dev)
376{
377 struct device *dev = class_dev->dev;
378 char *path;
379
380 if (!dev)
381 return 0;
382
383 /* add device, backing this class device (deprecated) */
384 path = kobject_get_path(&dev->kobj, GFP_KERNEL);
385
386 add_uevent_var(envp, num_envp, cur_index, buffer, buffer_size,
387 cur_len, "PHYSDEVPATH=%s", path);
388 kfree(path);
389
390 if (dev->bus)
391 add_uevent_var(envp, num_envp, cur_index,
392 buffer, buffer_size, cur_len,
393 "PHYSDEVBUS=%s", dev->bus->name);
394
395 if (dev->driver)
396 add_uevent_var(envp, num_envp, cur_index,
397 buffer, buffer_size, cur_len,
398 "PHYSDEVDRIVER=%s", dev->driver->name);
399 return 0;
400}
401
402static int make_deprecated_class_device_links(struct class_device *class_dev) 372static int make_deprecated_class_device_links(struct class_device *class_dev)
403{ 373{
404 char *class_name; 374 char *class_name;
@@ -430,11 +400,6 @@ static void remove_deprecated_class_device_links(struct class_device *class_dev)
430 kfree(class_name); 400 kfree(class_name);
431} 401}
432#else 402#else
433static inline int deprecated_class_uevent(char **envp, int num_envp,
434 int *cur_index, char *buffer,
435 int buffer_size, int *cur_len,
436 struct class_device *class_dev)
437{ return 0; }
438static inline int make_deprecated_class_device_links(struct class_device *cd) 403static inline int make_deprecated_class_device_links(struct class_device *cd)
439{ return 0; } 404{ return 0; }
440static void remove_deprecated_class_device_links(struct class_device *cd) 405static void remove_deprecated_class_device_links(struct class_device *cd)
@@ -445,15 +410,13 @@ static int class_uevent(struct kset *kset, struct kobject *kobj, char **envp,
445 int num_envp, char *buffer, int buffer_size) 410 int num_envp, char *buffer, int buffer_size)
446{ 411{
447 struct class_device *class_dev = to_class_dev(kobj); 412 struct class_device *class_dev = to_class_dev(kobj);
413 struct device *dev = class_dev->dev;
448 int i = 0; 414 int i = 0;
449 int length = 0; 415 int length = 0;
450 int retval = 0; 416 int retval = 0;
451 417
452 pr_debug("%s - name = %s\n", __FUNCTION__, class_dev->class_id); 418 pr_debug("%s - name = %s\n", __FUNCTION__, class_dev->class_id);
453 419
454 deprecated_class_uevent(envp, num_envp, &i, buffer, buffer_size,
455 &length, class_dev);
456
457 if (MAJOR(class_dev->devt)) { 420 if (MAJOR(class_dev->devt)) {
458 add_uevent_var(envp, num_envp, &i, 421 add_uevent_var(envp, num_envp, &i,
459 buffer, buffer_size, &length, 422 buffer, buffer_size, &length,
@@ -464,6 +427,26 @@ static int class_uevent(struct kset *kset, struct kobject *kobj, char **envp,
464 "MINOR=%u", MINOR(class_dev->devt)); 427 "MINOR=%u", MINOR(class_dev->devt));
465 } 428 }
466 429
430 if (dev) {
431 const char *path = kobject_get_path(&dev->kobj, GFP_KERNEL);
432 if (path) {
433 add_uevent_var(envp, num_envp, &i,
434 buffer, buffer_size, &length,
435 "PHYSDEVPATH=%s", path);
436 kfree(path);
437 }
438
439 if (dev->bus)
440 add_uevent_var(envp, num_envp, &i,
441 buffer, buffer_size, &length,
442 "PHYSDEVBUS=%s", dev->bus->name);
443
444 if (dev->driver)
445 add_uevent_var(envp, num_envp, &i,
446 buffer, buffer_size, &length,
447 "PHYSDEVDRIVER=%s", dev->driver->name);
448 }
449
467 /* terminate, set to next free slot, shrink available space */ 450 /* terminate, set to next free slot, shrink available space */
468 envp[i] = NULL; 451 envp[i] = NULL;
469 envp = &envp[i]; 452 envp = &envp[i];
diff --git a/drivers/base/core.c b/drivers/base/core.c
index b78fc1e68264..dd40d78a023d 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -180,10 +180,12 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, char **envp,
180 const char *path; 180 const char *path;
181 181
182 path = kobject_get_path(&parent->kobj, GFP_KERNEL); 182 path = kobject_get_path(&parent->kobj, GFP_KERNEL);
183 add_uevent_var(envp, num_envp, &i, 183 if (path) {
184 buffer, buffer_size, &length, 184 add_uevent_var(envp, num_envp, &i,
185 "PHYSDEVPATH=%s", path); 185 buffer, buffer_size, &length,
186 kfree(path); 186 "PHYSDEVPATH=%s", path);
187 kfree(path);
188 }
187 189
188 add_uevent_var(envp, num_envp, &i, 190 add_uevent_var(envp, num_envp, &i,
189 buffer, buffer_size, &length, 191 buffer, buffer_size, &length,
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 92428e55b0c2..b0088b0efecd 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -207,19 +207,6 @@ static int __device_attach(struct device_driver * drv, void * data)
207 return driver_probe_device(drv, dev); 207 return driver_probe_device(drv, dev);
208} 208}
209 209
210static int device_probe_drivers(void *data)
211{
212 struct device *dev = data;
213 int ret = 0;
214
215 if (dev->bus) {
216 down(&dev->sem);
217 ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach);
218 up(&dev->sem);
219 }
220 return ret;
221}
222
223/** 210/**
224 * device_attach - try to attach device to a driver. 211 * device_attach - try to attach device to a driver.
225 * @dev: device. 212 * @dev: device.
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 97ab5bd1c4d6..89a5f4a54913 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * firmware_class.c - Multi purpose firmware loading support 2 * firmware_class.c - Multi purpose firmware loading support
3 * 3 *
4 * Copyright (c) 2003 Manuel Estrada Sainz <ranty@debian.org> 4 * Copyright (c) 2003 Manuel Estrada Sainz
5 * 5 *
6 * Please see Documentation/firmware_class/ for more information. 6 * Please see Documentation/firmware_class/ for more information.
7 * 7 *
@@ -23,7 +23,7 @@
23 23
24#define to_dev(obj) container_of(obj, struct device, kobj) 24#define to_dev(obj) container_of(obj, struct device, kobj)
25 25
26MODULE_AUTHOR("Manuel Estrada Sainz <ranty@debian.org>"); 26MODULE_AUTHOR("Manuel Estrada Sainz");
27MODULE_DESCRIPTION("Multi purpose firmware loading support"); 27MODULE_DESCRIPTION("Multi purpose firmware loading support");
28MODULE_LICENSE("GPL"); 28MODULE_LICENSE("GPL");
29 29
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 5526eadb6592..0ed5470d2533 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1354,7 +1354,7 @@ static struct block_device_operations lo_fops = {
1354 */ 1354 */
1355static int max_loop; 1355static int max_loop;
1356module_param(max_loop, int, 0); 1356module_param(max_loop, int, 0);
1357MODULE_PARM_DESC(max_loop, "obsolete, loop device is created on-demand"); 1357MODULE_PARM_DESC(max_loop, "Maximum number of loop devices");
1358MODULE_LICENSE("GPL"); 1358MODULE_LICENSE("GPL");
1359MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR); 1359MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR);
1360 1360
@@ -1394,16 +1394,11 @@ int loop_unregister_transfer(int number)
1394EXPORT_SYMBOL(loop_register_transfer); 1394EXPORT_SYMBOL(loop_register_transfer);
1395EXPORT_SYMBOL(loop_unregister_transfer); 1395EXPORT_SYMBOL(loop_unregister_transfer);
1396 1396
1397static struct loop_device *loop_init_one(int i) 1397static struct loop_device *loop_alloc(int i)
1398{ 1398{
1399 struct loop_device *lo; 1399 struct loop_device *lo;
1400 struct gendisk *disk; 1400 struct gendisk *disk;
1401 1401
1402 list_for_each_entry(lo, &loop_devices, lo_list) {
1403 if (lo->lo_number == i)
1404 return lo;
1405 }
1406
1407 lo = kzalloc(sizeof(*lo), GFP_KERNEL); 1402 lo = kzalloc(sizeof(*lo), GFP_KERNEL);
1408 if (!lo) 1403 if (!lo)
1409 goto out; 1404 goto out;
@@ -1427,8 +1422,6 @@ static struct loop_device *loop_init_one(int i)
1427 disk->private_data = lo; 1422 disk->private_data = lo;
1428 disk->queue = lo->lo_queue; 1423 disk->queue = lo->lo_queue;
1429 sprintf(disk->disk_name, "loop%d", i); 1424 sprintf(disk->disk_name, "loop%d", i);
1430 add_disk(disk);
1431 list_add_tail(&lo->lo_list, &loop_devices);
1432 return lo; 1425 return lo;
1433 1426
1434out_free_queue: 1427out_free_queue:
@@ -1439,15 +1432,37 @@ out:
1439 return NULL; 1432 return NULL;
1440} 1433}
1441 1434
1442static void loop_del_one(struct loop_device *lo) 1435static void loop_free(struct loop_device *lo)
1443{ 1436{
1444 del_gendisk(lo->lo_disk);
1445 blk_cleanup_queue(lo->lo_queue); 1437 blk_cleanup_queue(lo->lo_queue);
1446 put_disk(lo->lo_disk); 1438 put_disk(lo->lo_disk);
1447 list_del(&lo->lo_list); 1439 list_del(&lo->lo_list);
1448 kfree(lo); 1440 kfree(lo);
1449} 1441}
1450 1442
1443static struct loop_device *loop_init_one(int i)
1444{
1445 struct loop_device *lo;
1446
1447 list_for_each_entry(lo, &loop_devices, lo_list) {
1448 if (lo->lo_number == i)
1449 return lo;
1450 }
1451
1452 lo = loop_alloc(i);
1453 if (lo) {
1454 add_disk(lo->lo_disk);
1455 list_add_tail(&lo->lo_list, &loop_devices);
1456 }
1457 return lo;
1458}
1459
1460static void loop_del_one(struct loop_device *lo)
1461{
1462 del_gendisk(lo->lo_disk);
1463 loop_free(lo);
1464}
1465
1451static struct kobject *loop_probe(dev_t dev, int *part, void *data) 1466static struct kobject *loop_probe(dev_t dev, int *part, void *data)
1452{ 1467{
1453 struct loop_device *lo; 1468 struct loop_device *lo;
@@ -1464,28 +1479,77 @@ static struct kobject *loop_probe(dev_t dev, int *part, void *data)
1464 1479
1465static int __init loop_init(void) 1480static int __init loop_init(void)
1466{ 1481{
1467 if (register_blkdev(LOOP_MAJOR, "loop")) 1482 int i, nr;
1468 return -EIO; 1483 unsigned long range;
1469 blk_register_region(MKDEV(LOOP_MAJOR, 0), 1UL << MINORBITS, 1484 struct loop_device *lo, *next;
1470 THIS_MODULE, loop_probe, NULL, NULL); 1485
1486 /*
1487 * loop module now has a feature to instantiate underlying device
1488 * structure on-demand, provided that there is an access dev node.
1489 * However, this will not work well with user space tool that doesn't
1490 * know about such "feature". In order to not break any existing
1491 * tool, we do the following:
1492 *
1493 * (1) if max_loop is specified, create that many upfront, and this
1494 * also becomes a hard limit.
1495 * (2) if max_loop is not specified, create 8 loop device on module
1496 * load, user can further extend loop device by create dev node
1497 * themselves and have kernel automatically instantiate actual
1498 * device on-demand.
1499 */
1500 if (max_loop > 1UL << MINORBITS)
1501 return -EINVAL;
1471 1502
1472 if (max_loop) { 1503 if (max_loop) {
1473 printk(KERN_INFO "loop: the max_loop option is obsolete " 1504 nr = max_loop;
1474 "and will be removed in March 2008\n"); 1505 range = max_loop;
1506 } else {
1507 nr = 8;
1508 range = 1UL << MINORBITS;
1509 }
1510
1511 if (register_blkdev(LOOP_MAJOR, "loop"))
1512 return -EIO;
1475 1513
1514 for (i = 0; i < nr; i++) {
1515 lo = loop_alloc(i);
1516 if (!lo)
1517 goto Enomem;
1518 list_add_tail(&lo->lo_list, &loop_devices);
1476 } 1519 }
1520
1521 /* point of no return */
1522
1523 list_for_each_entry(lo, &loop_devices, lo_list)
1524 add_disk(lo->lo_disk);
1525
1526 blk_register_region(MKDEV(LOOP_MAJOR, 0), range,
1527 THIS_MODULE, loop_probe, NULL, NULL);
1528
1477 printk(KERN_INFO "loop: module loaded\n"); 1529 printk(KERN_INFO "loop: module loaded\n");
1478 return 0; 1530 return 0;
1531
1532Enomem:
1533 printk(KERN_INFO "loop: out of memory\n");
1534
1535 list_for_each_entry_safe(lo, next, &loop_devices, lo_list)
1536 loop_free(lo);
1537
1538 unregister_blkdev(LOOP_MAJOR, "loop");
1539 return -ENOMEM;
1479} 1540}
1480 1541
1481static void __exit loop_exit(void) 1542static void __exit loop_exit(void)
1482{ 1543{
1544 unsigned long range;
1483 struct loop_device *lo, *next; 1545 struct loop_device *lo, *next;
1484 1546
1547 range = max_loop ? max_loop : 1UL << MINORBITS;
1548
1485 list_for_each_entry_safe(lo, next, &loop_devices, lo_list) 1549 list_for_each_entry_safe(lo, next, &loop_devices, lo_list)
1486 loop_del_one(lo); 1550 loop_del_one(lo);
1487 1551
1488 blk_unregister_region(MKDEV(LOOP_MAJOR, 0), 1UL << MINORBITS); 1552 blk_unregister_region(MKDEV(LOOP_MAJOR, 0), range);
1489 if (unregister_blkdev(LOOP_MAJOR, "loop")) 1553 if (unregister_blkdev(LOOP_MAJOR, "loop"))
1490 printk(KERN_WARNING "loop: cannot unregister blkdev\n"); 1554 printk(KERN_WARNING "loop: cannot unregister blkdev\n");
1491} 1555}
diff --git a/drivers/cdrom/mcdx.c b/drivers/cdrom/mcdx.c
index f574962f4288..4310cc84dfed 100644
--- a/drivers/cdrom/mcdx.c
+++ b/drivers/cdrom/mcdx.c
@@ -1053,11 +1053,11 @@ static void __exit mcdx_exit(void)
1053 if (unregister_blkdev(MAJOR_NR, "mcdx") != 0) { 1053 if (unregister_blkdev(MAJOR_NR, "mcdx") != 0) {
1054 xwarn("cleanup() unregister_blkdev() failed\n"); 1054 xwarn("cleanup() unregister_blkdev() failed\n");
1055 } 1055 }
1056 blk_cleanup_queue(mcdx_queue);
1057#if !MCDX_QUIET 1056#if !MCDX_QUIET
1058 else 1057 else
1059 xinfo("cleanup() succeeded\n"); 1058 xinfo("cleanup() succeeded\n");
1060#endif 1059#endif
1060 blk_cleanup_queue(mcdx_queue);
1061} 1061}
1062 1062
1063#ifdef MODULE 1063#ifdef MODULE
diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h
index fdbca25a3948..35ab1a9f8e8b 100644
--- a/drivers/char/agp/agp.h
+++ b/drivers/char/agp/agp.h
@@ -176,7 +176,7 @@ struct agp_bridge_data {
176#define I830_GMCH_MEM_MASK 0x1 176#define I830_GMCH_MEM_MASK 0x1
177#define I830_GMCH_MEM_64M 0x1 177#define I830_GMCH_MEM_64M 0x1
178#define I830_GMCH_MEM_128M 0 178#define I830_GMCH_MEM_128M 0
179#define I830_GMCH_GMS_MASK 0x70 179#define I830_GMCH_GMS_MASK 0xF0
180#define I830_GMCH_GMS_DISABLED 0x00 180#define I830_GMCH_GMS_DISABLED 0x00
181#define I830_GMCH_GMS_LOCAL 0x10 181#define I830_GMCH_GMS_LOCAL 0x10
182#define I830_GMCH_GMS_STOLEN_512 0x20 182#define I830_GMCH_GMS_STOLEN_512 0x20
@@ -231,6 +231,10 @@ struct agp_bridge_data {
231#define I965_PGETBL_SIZE_512KB (0 << 1) 231#define I965_PGETBL_SIZE_512KB (0 << 1)
232#define I965_PGETBL_SIZE_256KB (1 << 1) 232#define I965_PGETBL_SIZE_256KB (1 << 1)
233#define I965_PGETBL_SIZE_128KB (2 << 1) 233#define I965_PGETBL_SIZE_128KB (2 << 1)
234#define G33_PGETBL_SIZE_MASK (3 << 8)
235#define G33_PGETBL_SIZE_1M (1 << 8)
236#define G33_PGETBL_SIZE_2M (2 << 8)
237
234#define I810_DRAM_CTL 0x3000 238#define I810_DRAM_CTL 0x3000
235#define I810_DRAM_ROW_0 0x00000001 239#define I810_DRAM_ROW_0 0x00000001
236#define I810_DRAM_ROW_0_SDRAM 0x00000001 240#define I810_DRAM_ROW_0_SDRAM 0x00000001
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index 9c69f2e761f5..d383168b75fa 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -20,6 +20,14 @@
20#define PCI_DEVICE_ID_INTEL_82965G_IG 0x29A2 20#define PCI_DEVICE_ID_INTEL_82965G_IG 0x29A2
21#define PCI_DEVICE_ID_INTEL_82965GM_HB 0x2A00 21#define PCI_DEVICE_ID_INTEL_82965GM_HB 0x2A00
22#define PCI_DEVICE_ID_INTEL_82965GM_IG 0x2A02 22#define PCI_DEVICE_ID_INTEL_82965GM_IG 0x2A02
23#define PCI_DEVICE_ID_INTEL_82965GME_IG 0x2A12
24#define PCI_DEVICE_ID_INTEL_82945GME_IG 0x27AE
25#define PCI_DEVICE_ID_INTEL_G33_HB 0x29C0
26#define PCI_DEVICE_ID_INTEL_G33_IG 0x29C2
27#define PCI_DEVICE_ID_INTEL_Q35_HB 0x29B0
28#define PCI_DEVICE_ID_INTEL_Q35_IG 0x29B2
29#define PCI_DEVICE_ID_INTEL_Q33_HB 0x29D0
30#define PCI_DEVICE_ID_INTEL_Q33_IG 0x29D2
23 31
24#define IS_I965 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82946GZ_HB || \ 32#define IS_I965 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82946GZ_HB || \
25 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_1_HB || \ 33 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_1_HB || \
@@ -27,6 +35,9 @@
27 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \ 35 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \
28 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB) 36 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB)
29 37
38#define IS_G33 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G33_HB || \
39 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q35_HB || \
40 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q33_HB)
30 41
31extern int agp_memory_reserved; 42extern int agp_memory_reserved;
32 43
@@ -53,6 +64,8 @@ extern int agp_memory_reserved;
53#define I915_PTEADDR 0x1C 64#define I915_PTEADDR 0x1C
54#define I915_GMCH_GMS_STOLEN_48M (0x6 << 4) 65#define I915_GMCH_GMS_STOLEN_48M (0x6 << 4)
55#define I915_GMCH_GMS_STOLEN_64M (0x7 << 4) 66#define I915_GMCH_GMS_STOLEN_64M (0x7 << 4)
67#define G33_GMCH_GMS_STOLEN_128M (0x8 << 4)
68#define G33_GMCH_GMS_STOLEN_256M (0x9 << 4)
56 69
57/* Intel 965G registers */ 70/* Intel 965G registers */
58#define I965_MSAC 0x62 71#define I965_MSAC 0x62
@@ -86,11 +99,18 @@ static struct gatt_mask intel_i810_masks[] =
86 .type = INTEL_AGP_CACHED_MEMORY} 99 .type = INTEL_AGP_CACHED_MEMORY}
87}; 100};
88 101
89static struct _intel_i810_private { 102static struct _intel_private {
90 struct pci_dev *i810_dev; /* device one */ 103 struct pci_dev *pcidev; /* device one */
91 volatile u8 __iomem *registers; 104 u8 __iomem *registers;
105 u32 __iomem *gtt; /* I915G */
92 int num_dcache_entries; 106 int num_dcache_entries;
93} intel_i810_private; 107 /* gtt_entries is the number of gtt entries that are already mapped
108 * to stolen memory. Stolen memory is larger than the memory mapped
109 * through gtt_entries, as it includes some reserved space for the BIOS
110 * popup and for the GTT.
111 */
112 int gtt_entries; /* i830+ */
113} intel_private;
94 114
95static int intel_i810_fetch_size(void) 115static int intel_i810_fetch_size(void)
96{ 116{
@@ -127,32 +147,32 @@ static int intel_i810_configure(void)
127 147
128 current_size = A_SIZE_FIX(agp_bridge->current_size); 148 current_size = A_SIZE_FIX(agp_bridge->current_size);
129 149
130 if (!intel_i810_private.registers) { 150 if (!intel_private.registers) {
131 pci_read_config_dword(intel_i810_private.i810_dev, I810_MMADDR, &temp); 151 pci_read_config_dword(intel_private.pcidev, I810_MMADDR, &temp);
132 temp &= 0xfff80000; 152 temp &= 0xfff80000;
133 153
134 intel_i810_private.registers = ioremap(temp, 128 * 4096); 154 intel_private.registers = ioremap(temp, 128 * 4096);
135 if (!intel_i810_private.registers) { 155 if (!intel_private.registers) {
136 printk(KERN_ERR PFX "Unable to remap memory.\n"); 156 printk(KERN_ERR PFX "Unable to remap memory.\n");
137 return -ENOMEM; 157 return -ENOMEM;
138 } 158 }
139 } 159 }
140 160
141 if ((readl(intel_i810_private.registers+I810_DRAM_CTL) 161 if ((readl(intel_private.registers+I810_DRAM_CTL)
142 & I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) { 162 & I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) {
143 /* This will need to be dynamically assigned */ 163 /* This will need to be dynamically assigned */
144 printk(KERN_INFO PFX "detected 4MB dedicated video ram.\n"); 164 printk(KERN_INFO PFX "detected 4MB dedicated video ram.\n");
145 intel_i810_private.num_dcache_entries = 1024; 165 intel_private.num_dcache_entries = 1024;
146 } 166 }
147 pci_read_config_dword(intel_i810_private.i810_dev, I810_GMADDR, &temp); 167 pci_read_config_dword(intel_private.pcidev, I810_GMADDR, &temp);
148 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 168 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
149 writel(agp_bridge->gatt_bus_addr | I810_PGETBL_ENABLED, intel_i810_private.registers+I810_PGETBL_CTL); 169 writel(agp_bridge->gatt_bus_addr | I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL);
150 readl(intel_i810_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ 170 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
151 171
152 if (agp_bridge->driver->needs_scratch_page) { 172 if (agp_bridge->driver->needs_scratch_page) {
153 for (i = 0; i < current_size->num_entries; i++) { 173 for (i = 0; i < current_size->num_entries; i++) {
154 writel(agp_bridge->scratch_page, intel_i810_private.registers+I810_PTE_BASE+(i*4)); 174 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
155 readl(intel_i810_private.registers+I810_PTE_BASE+(i*4)); /* PCI posting. */ 175 readl(intel_private.registers+I810_PTE_BASE+(i*4)); /* PCI posting. */
156 } 176 }
157 } 177 }
158 global_cache_flush(); 178 global_cache_flush();
@@ -161,9 +181,9 @@ static int intel_i810_configure(void)
161 181
162static void intel_i810_cleanup(void) 182static void intel_i810_cleanup(void)
163{ 183{
164 writel(0, intel_i810_private.registers+I810_PGETBL_CTL); 184 writel(0, intel_private.registers+I810_PGETBL_CTL);
165 readl(intel_i810_private.registers); /* PCI Posting. */ 185 readl(intel_private.registers); /* PCI Posting. */
166 iounmap(intel_i810_private.registers); 186 iounmap(intel_private.registers);
167} 187}
168 188
169static void intel_i810_tlbflush(struct agp_memory *mem) 189static void intel_i810_tlbflush(struct agp_memory *mem)
@@ -261,9 +281,9 @@ static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
261 global_cache_flush(); 281 global_cache_flush();
262 for (i = pg_start; i < (pg_start + mem->page_count); i++) { 282 for (i = pg_start; i < (pg_start + mem->page_count); i++) {
263 writel((i*4096)|I810_PTE_LOCAL|I810_PTE_VALID, 283 writel((i*4096)|I810_PTE_LOCAL|I810_PTE_VALID,
264 intel_i810_private.registers+I810_PTE_BASE+(i*4)); 284 intel_private.registers+I810_PTE_BASE+(i*4));
265 } 285 }
266 readl(intel_i810_private.registers+I810_PTE_BASE+((i-1)*4)); 286 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4));
267 break; 287 break;
268 case AGP_PHYS_MEMORY: 288 case AGP_PHYS_MEMORY:
269 case AGP_NORMAL_MEMORY: 289 case AGP_NORMAL_MEMORY:
@@ -273,9 +293,9 @@ static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
273 writel(agp_bridge->driver->mask_memory(agp_bridge, 293 writel(agp_bridge->driver->mask_memory(agp_bridge,
274 mem->memory[i], 294 mem->memory[i],
275 mask_type), 295 mask_type),
276 intel_i810_private.registers+I810_PTE_BASE+(j*4)); 296 intel_private.registers+I810_PTE_BASE+(j*4));
277 } 297 }
278 readl(intel_i810_private.registers+I810_PTE_BASE+((j-1)*4)); 298 readl(intel_private.registers+I810_PTE_BASE+((j-1)*4));
279 break; 299 break;
280 default: 300 default:
281 goto out_err; 301 goto out_err;
@@ -298,9 +318,9 @@ static int intel_i810_remove_entries(struct agp_memory *mem, off_t pg_start,
298 return 0; 318 return 0;
299 319
300 for (i = pg_start; i < (mem->page_count + pg_start); i++) { 320 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
301 writel(agp_bridge->scratch_page, intel_i810_private.registers+I810_PTE_BASE+(i*4)); 321 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
302 } 322 }
303 readl(intel_i810_private.registers+I810_PTE_BASE+((i-1)*4)); 323 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4));
304 324
305 agp_bridge->driver->tlb_flush(mem); 325 agp_bridge->driver->tlb_flush(mem);
306 return 0; 326 return 0;
@@ -354,7 +374,7 @@ static struct agp_memory *intel_i810_alloc_by_type(size_t pg_count, int type)
354 struct agp_memory *new; 374 struct agp_memory *new;
355 375
356 if (type == AGP_DCACHE_MEMORY) { 376 if (type == AGP_DCACHE_MEMORY) {
357 if (pg_count != intel_i810_private.num_dcache_entries) 377 if (pg_count != intel_private.num_dcache_entries)
358 return NULL; 378 return NULL;
359 379
360 new = agp_create_memory(1); 380 new = agp_create_memory(1);
@@ -404,18 +424,6 @@ static struct aper_size_info_fixed intel_i830_sizes[] =
404 {512, 131072, 7}, 424 {512, 131072, 7},
405}; 425};
406 426
407static struct _intel_i830_private {
408 struct pci_dev *i830_dev; /* device one */
409 volatile u8 __iomem *registers;
410 volatile u32 __iomem *gtt; /* I915G */
411 /* gtt_entries is the number of gtt entries that are already mapped
412 * to stolen memory. Stolen memory is larger than the memory mapped
413 * through gtt_entries, as it includes some reserved space for the BIOS
414 * popup and for the GTT.
415 */
416 int gtt_entries;
417} intel_i830_private;
418
419static void intel_i830_init_gtt_entries(void) 427static void intel_i830_init_gtt_entries(void)
420{ 428{
421 u16 gmch_ctrl; 429 u16 gmch_ctrl;
@@ -429,7 +437,7 @@ static void intel_i830_init_gtt_entries(void)
429 437
430 if (IS_I965) { 438 if (IS_I965) {
431 u32 pgetbl_ctl; 439 u32 pgetbl_ctl;
432 pgetbl_ctl = readl(intel_i830_private.registers+I810_PGETBL_CTL); 440 pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL);
433 441
434 /* The 965 has a field telling us the size of the GTT, 442 /* The 965 has a field telling us the size of the GTT,
435 * which may be larger than what is necessary to map the 443 * which may be larger than what is necessary to map the
@@ -451,6 +459,22 @@ static void intel_i830_init_gtt_entries(void)
451 size = 512; 459 size = 512;
452 } 460 }
453 size += 4; /* add in BIOS popup space */ 461 size += 4; /* add in BIOS popup space */
462 } else if (IS_G33) {
463 /* G33's GTT size defined in gmch_ctrl */
464 switch (gmch_ctrl & G33_PGETBL_SIZE_MASK) {
465 case G33_PGETBL_SIZE_1M:
466 size = 1024;
467 break;
468 case G33_PGETBL_SIZE_2M:
469 size = 2048;
470 break;
471 default:
472 printk(KERN_INFO PFX "Unknown page table size 0x%x, "
473 "assuming 512KB\n",
474 (gmch_ctrl & G33_PGETBL_SIZE_MASK));
475 size = 512;
476 }
477 size += 4;
454 } else { 478 } else {
455 /* On previous hardware, the GTT size was just what was 479 /* On previous hardware, the GTT size was just what was
456 * required to map the aperture. 480 * required to map the aperture.
@@ -471,7 +495,7 @@ static void intel_i830_init_gtt_entries(void)
471 gtt_entries = MB(8) - KB(size); 495 gtt_entries = MB(8) - KB(size);
472 break; 496 break;
473 case I830_GMCH_GMS_LOCAL: 497 case I830_GMCH_GMS_LOCAL:
474 rdct = readb(intel_i830_private.registers+I830_RDRAM_CHANNEL_TYPE); 498 rdct = readb(intel_private.registers+I830_RDRAM_CHANNEL_TYPE);
475 gtt_entries = (I830_RDRAM_ND(rdct) + 1) * 499 gtt_entries = (I830_RDRAM_ND(rdct) + 1) *
476 MB(ddt[I830_RDRAM_DDT(rdct)]); 500 MB(ddt[I830_RDRAM_DDT(rdct)]);
477 local = 1; 501 local = 1;
@@ -502,7 +526,8 @@ static void intel_i830_init_gtt_entries(void)
502 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || 526 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
503 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || 527 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
504 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || 528 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
505 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || IS_I965 ) 529 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB ||
530 IS_I965 || IS_G33)
506 gtt_entries = MB(48) - KB(size); 531 gtt_entries = MB(48) - KB(size);
507 else 532 else
508 gtt_entries = 0; 533 gtt_entries = 0;
@@ -512,10 +537,24 @@ static void intel_i830_init_gtt_entries(void)
512 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || 537 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
513 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || 538 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
514 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || 539 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
515 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || IS_I965) 540 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB ||
541 IS_I965 || IS_G33)
516 gtt_entries = MB(64) - KB(size); 542 gtt_entries = MB(64) - KB(size);
517 else 543 else
518 gtt_entries = 0; 544 gtt_entries = 0;
545 break;
546 case G33_GMCH_GMS_STOLEN_128M:
547 if (IS_G33)
548 gtt_entries = MB(128) - KB(size);
549 else
550 gtt_entries = 0;
551 break;
552 case G33_GMCH_GMS_STOLEN_256M:
553 if (IS_G33)
554 gtt_entries = MB(256) - KB(size);
555 else
556 gtt_entries = 0;
557 break;
519 default: 558 default:
520 gtt_entries = 0; 559 gtt_entries = 0;
521 break; 560 break;
@@ -529,7 +568,7 @@ static void intel_i830_init_gtt_entries(void)
529 "No pre-allocated video memory detected.\n"); 568 "No pre-allocated video memory detected.\n");
530 gtt_entries /= KB(4); 569 gtt_entries /= KB(4);
531 570
532 intel_i830_private.gtt_entries = gtt_entries; 571 intel_private.gtt_entries = gtt_entries;
533} 572}
534 573
535/* The intel i830 automatically initializes the agp aperture during POST. 574/* The intel i830 automatically initializes the agp aperture during POST.
@@ -547,14 +586,14 @@ static int intel_i830_create_gatt_table(struct agp_bridge_data *bridge)
547 num_entries = size->num_entries; 586 num_entries = size->num_entries;
548 agp_bridge->gatt_table_real = NULL; 587 agp_bridge->gatt_table_real = NULL;
549 588
550 pci_read_config_dword(intel_i830_private.i830_dev,I810_MMADDR,&temp); 589 pci_read_config_dword(intel_private.pcidev,I810_MMADDR,&temp);
551 temp &= 0xfff80000; 590 temp &= 0xfff80000;
552 591
553 intel_i830_private.registers = ioremap(temp,128 * 4096); 592 intel_private.registers = ioremap(temp,128 * 4096);
554 if (!intel_i830_private.registers) 593 if (!intel_private.registers)
555 return -ENOMEM; 594 return -ENOMEM;
556 595
557 temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000; 596 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
558 global_cache_flush(); /* FIXME: ?? */ 597 global_cache_flush(); /* FIXME: ?? */
559 598
560 /* we have to call this as early as possible after the MMIO base address is known */ 599 /* we have to call this as early as possible after the MMIO base address is known */
@@ -614,20 +653,20 @@ static int intel_i830_configure(void)
614 653
615 current_size = A_SIZE_FIX(agp_bridge->current_size); 654 current_size = A_SIZE_FIX(agp_bridge->current_size);
616 655
617 pci_read_config_dword(intel_i830_private.i830_dev,I810_GMADDR,&temp); 656 pci_read_config_dword(intel_private.pcidev,I810_GMADDR,&temp);
618 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 657 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
619 658
620 pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl); 659 pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl);
621 gmch_ctrl |= I830_GMCH_ENABLED; 660 gmch_ctrl |= I830_GMCH_ENABLED;
622 pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl); 661 pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl);
623 662
624 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_i830_private.registers+I810_PGETBL_CTL); 663 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL);
625 readl(intel_i830_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ 664 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
626 665
627 if (agp_bridge->driver->needs_scratch_page) { 666 if (agp_bridge->driver->needs_scratch_page) {
628 for (i = intel_i830_private.gtt_entries; i < current_size->num_entries; i++) { 667 for (i = intel_private.gtt_entries; i < current_size->num_entries; i++) {
629 writel(agp_bridge->scratch_page, intel_i830_private.registers+I810_PTE_BASE+(i*4)); 668 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
630 readl(intel_i830_private.registers+I810_PTE_BASE+(i*4)); /* PCI Posting. */ 669 readl(intel_private.registers+I810_PTE_BASE+(i*4)); /* PCI Posting. */
631 } 670 }
632 } 671 }
633 672
@@ -637,7 +676,7 @@ static int intel_i830_configure(void)
637 676
638static void intel_i830_cleanup(void) 677static void intel_i830_cleanup(void)
639{ 678{
640 iounmap(intel_i830_private.registers); 679 iounmap(intel_private.registers);
641} 680}
642 681
643static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int type) 682static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int type)
@@ -653,9 +692,9 @@ static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int
653 temp = agp_bridge->current_size; 692 temp = agp_bridge->current_size;
654 num_entries = A_SIZE_FIX(temp)->num_entries; 693 num_entries = A_SIZE_FIX(temp)->num_entries;
655 694
656 if (pg_start < intel_i830_private.gtt_entries) { 695 if (pg_start < intel_private.gtt_entries) {
657 printk (KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_i830_private.gtt_entries == 0x%.8x\n", 696 printk (KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_private.gtt_entries == 0x%.8x\n",
658 pg_start,intel_i830_private.gtt_entries); 697 pg_start,intel_private.gtt_entries);
659 698
660 printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n"); 699 printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n");
661 goto out_err; 700 goto out_err;
@@ -683,9 +722,9 @@ static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int
683 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 722 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
684 writel(agp_bridge->driver->mask_memory(agp_bridge, 723 writel(agp_bridge->driver->mask_memory(agp_bridge,
685 mem->memory[i], mask_type), 724 mem->memory[i], mask_type),
686 intel_i830_private.registers+I810_PTE_BASE+(j*4)); 725 intel_private.registers+I810_PTE_BASE+(j*4));
687 } 726 }
688 readl(intel_i830_private.registers+I810_PTE_BASE+((j-1)*4)); 727 readl(intel_private.registers+I810_PTE_BASE+((j-1)*4));
689 agp_bridge->driver->tlb_flush(mem); 728 agp_bridge->driver->tlb_flush(mem);
690 729
691out: 730out:
@@ -703,15 +742,15 @@ static int intel_i830_remove_entries(struct agp_memory *mem,off_t pg_start,
703 if (mem->page_count == 0) 742 if (mem->page_count == 0)
704 return 0; 743 return 0;
705 744
706 if (pg_start < intel_i830_private.gtt_entries) { 745 if (pg_start < intel_private.gtt_entries) {
707 printk (KERN_INFO PFX "Trying to disable local/stolen memory\n"); 746 printk (KERN_INFO PFX "Trying to disable local/stolen memory\n");
708 return -EINVAL; 747 return -EINVAL;
709 } 748 }
710 749
711 for (i = pg_start; i < (mem->page_count + pg_start); i++) { 750 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
712 writel(agp_bridge->scratch_page, intel_i830_private.registers+I810_PTE_BASE+(i*4)); 751 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
713 } 752 }
714 readl(intel_i830_private.registers+I810_PTE_BASE+((i-1)*4)); 753 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4));
715 754
716 agp_bridge->driver->tlb_flush(mem); 755 agp_bridge->driver->tlb_flush(mem);
717 return 0; 756 return 0;
@@ -734,7 +773,7 @@ static int intel_i915_configure(void)
734 773
735 current_size = A_SIZE_FIX(agp_bridge->current_size); 774 current_size = A_SIZE_FIX(agp_bridge->current_size);
736 775
737 pci_read_config_dword(intel_i830_private.i830_dev, I915_GMADDR, &temp); 776 pci_read_config_dword(intel_private.pcidev, I915_GMADDR, &temp);
738 777
739 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 778 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
740 779
@@ -742,13 +781,13 @@ static int intel_i915_configure(void)
742 gmch_ctrl |= I830_GMCH_ENABLED; 781 gmch_ctrl |= I830_GMCH_ENABLED;
743 pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl); 782 pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl);
744 783
745 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_i830_private.registers+I810_PGETBL_CTL); 784 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL);
746 readl(intel_i830_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ 785 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
747 786
748 if (agp_bridge->driver->needs_scratch_page) { 787 if (agp_bridge->driver->needs_scratch_page) {
749 for (i = intel_i830_private.gtt_entries; i < current_size->num_entries; i++) { 788 for (i = intel_private.gtt_entries; i < current_size->num_entries; i++) {
750 writel(agp_bridge->scratch_page, intel_i830_private.gtt+i); 789 writel(agp_bridge->scratch_page, intel_private.gtt+i);
751 readl(intel_i830_private.gtt+i); /* PCI Posting. */ 790 readl(intel_private.gtt+i); /* PCI Posting. */
752 } 791 }
753 } 792 }
754 793
@@ -758,8 +797,8 @@ static int intel_i915_configure(void)
758 797
759static void intel_i915_cleanup(void) 798static void intel_i915_cleanup(void)
760{ 799{
761 iounmap(intel_i830_private.gtt); 800 iounmap(intel_private.gtt);
762 iounmap(intel_i830_private.registers); 801 iounmap(intel_private.registers);
763} 802}
764 803
765static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start, 804static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start,
@@ -776,9 +815,9 @@ static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start,
776 temp = agp_bridge->current_size; 815 temp = agp_bridge->current_size;
777 num_entries = A_SIZE_FIX(temp)->num_entries; 816 num_entries = A_SIZE_FIX(temp)->num_entries;
778 817
779 if (pg_start < intel_i830_private.gtt_entries) { 818 if (pg_start < intel_private.gtt_entries) {
780 printk (KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_i830_private.gtt_entries == 0x%.8x\n", 819 printk (KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_private.gtt_entries == 0x%.8x\n",
781 pg_start,intel_i830_private.gtt_entries); 820 pg_start,intel_private.gtt_entries);
782 821
783 printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n"); 822 printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n");
784 goto out_err; 823 goto out_err;
@@ -805,10 +844,10 @@ static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start,
805 844
806 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 845 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
807 writel(agp_bridge->driver->mask_memory(agp_bridge, 846 writel(agp_bridge->driver->mask_memory(agp_bridge,
808 mem->memory[i], mask_type), intel_i830_private.gtt+j); 847 mem->memory[i], mask_type), intel_private.gtt+j);
809 } 848 }
810 849
811 readl(intel_i830_private.gtt+j-1); 850 readl(intel_private.gtt+j-1);
812 agp_bridge->driver->tlb_flush(mem); 851 agp_bridge->driver->tlb_flush(mem);
813 852
814 out: 853 out:
@@ -826,15 +865,15 @@ static int intel_i915_remove_entries(struct agp_memory *mem,off_t pg_start,
826 if (mem->page_count == 0) 865 if (mem->page_count == 0)
827 return 0; 866 return 0;
828 867
829 if (pg_start < intel_i830_private.gtt_entries) { 868 if (pg_start < intel_private.gtt_entries) {
830 printk (KERN_INFO PFX "Trying to disable local/stolen memory\n"); 869 printk (KERN_INFO PFX "Trying to disable local/stolen memory\n");
831 return -EINVAL; 870 return -EINVAL;
832 } 871 }
833 872
834 for (i = pg_start; i < (mem->page_count + pg_start); i++) { 873 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
835 writel(agp_bridge->scratch_page, intel_i830_private.gtt+i); 874 writel(agp_bridge->scratch_page, intel_private.gtt+i);
836 } 875 }
837 readl(intel_i830_private.gtt+i-1); 876 readl(intel_private.gtt+i-1);
838 877
839 agp_bridge->driver->tlb_flush(mem); 878 agp_bridge->driver->tlb_flush(mem);
840 return 0; 879 return 0;
@@ -850,7 +889,7 @@ static int intel_i9xx_fetch_size(void)
850 int aper_size; /* size in megabytes */ 889 int aper_size; /* size in megabytes */
851 int i; 890 int i;
852 891
853 aper_size = pci_resource_len(intel_i830_private.i830_dev, 2) / MB(1); 892 aper_size = pci_resource_len(intel_private.pcidev, 2) / MB(1);
854 893
855 for (i = 0; i < num_sizes; i++) { 894 for (i = 0; i < num_sizes; i++) {
856 if (aper_size == intel_i830_sizes[i].size) { 895 if (aper_size == intel_i830_sizes[i].size) {
@@ -878,20 +917,20 @@ static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge)
878 num_entries = size->num_entries; 917 num_entries = size->num_entries;
879 agp_bridge->gatt_table_real = NULL; 918 agp_bridge->gatt_table_real = NULL;
880 919
881 pci_read_config_dword(intel_i830_private.i830_dev, I915_MMADDR, &temp); 920 pci_read_config_dword(intel_private.pcidev, I915_MMADDR, &temp);
882 pci_read_config_dword(intel_i830_private.i830_dev, I915_PTEADDR,&temp2); 921 pci_read_config_dword(intel_private.pcidev, I915_PTEADDR,&temp2);
883 922
884 intel_i830_private.gtt = ioremap(temp2, 256 * 1024); 923 intel_private.gtt = ioremap(temp2, 256 * 1024);
885 if (!intel_i830_private.gtt) 924 if (!intel_private.gtt)
886 return -ENOMEM; 925 return -ENOMEM;
887 926
888 temp &= 0xfff80000; 927 temp &= 0xfff80000;
889 928
890 intel_i830_private.registers = ioremap(temp,128 * 4096); 929 intel_private.registers = ioremap(temp,128 * 4096);
891 if (!intel_i830_private.registers) 930 if (!intel_private.registers)
892 return -ENOMEM; 931 return -ENOMEM;
893 932
894 temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000; 933 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
895 global_cache_flush(); /* FIXME: ? */ 934 global_cache_flush(); /* FIXME: ? */
896 935
897 /* we have to call this as early as possible after the MMIO base address is known */ 936 /* we have to call this as early as possible after the MMIO base address is known */
@@ -938,20 +977,20 @@ static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge)
938 num_entries = size->num_entries; 977 num_entries = size->num_entries;
939 agp_bridge->gatt_table_real = NULL; 978 agp_bridge->gatt_table_real = NULL;
940 979
941 pci_read_config_dword(intel_i830_private.i830_dev, I915_MMADDR, &temp); 980 pci_read_config_dword(intel_private.pcidev, I915_MMADDR, &temp);
942 981
943 temp &= 0xfff00000; 982 temp &= 0xfff00000;
944 intel_i830_private.gtt = ioremap((temp + (512 * 1024)) , 512 * 1024); 983 intel_private.gtt = ioremap((temp + (512 * 1024)) , 512 * 1024);
945 984
946 if (!intel_i830_private.gtt) 985 if (!intel_private.gtt)
947 return -ENOMEM; 986 return -ENOMEM;
948 987
949 988
950 intel_i830_private.registers = ioremap(temp,128 * 4096); 989 intel_private.registers = ioremap(temp,128 * 4096);
951 if (!intel_i830_private.registers) 990 if (!intel_private.registers)
952 return -ENOMEM; 991 return -ENOMEM;
953 992
954 temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000; 993 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
955 global_cache_flush(); /* FIXME: ? */ 994 global_cache_flush(); /* FIXME: ? */
956 995
957 /* we have to call this as early as possible after the MMIO base address is known */ 996 /* we have to call this as early as possible after the MMIO base address is known */
@@ -1722,41 +1761,126 @@ static const struct agp_bridge_driver intel_7505_driver = {
1722 .agp_type_to_mask_type = agp_generic_type_to_mask_type, 1761 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1723}; 1762};
1724 1763
1725static int find_i810(u16 device) 1764static const struct agp_bridge_driver intel_g33_driver = {
1726{ 1765 .owner = THIS_MODULE,
1727 struct pci_dev *i810_dev; 1766 .aperture_sizes = intel_i830_sizes,
1728 1767 .size_type = FIXED_APER_SIZE,
1729 i810_dev = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL); 1768 .num_aperture_sizes = 4,
1730 if (!i810_dev) 1769 .needs_scratch_page = TRUE,
1731 return 0; 1770 .configure = intel_i915_configure,
1732 intel_i810_private.i810_dev = i810_dev; 1771 .fetch_size = intel_i9xx_fetch_size,
1733 return 1; 1772 .cleanup = intel_i915_cleanup,
1734} 1773 .tlb_flush = intel_i810_tlbflush,
1774 .mask_memory = intel_i965_mask_memory,
1775 .masks = intel_i810_masks,
1776 .agp_enable = intel_i810_agp_enable,
1777 .cache_flush = global_cache_flush,
1778 .create_gatt_table = intel_i915_create_gatt_table,
1779 .free_gatt_table = intel_i830_free_gatt_table,
1780 .insert_memory = intel_i915_insert_entries,
1781 .remove_memory = intel_i915_remove_entries,
1782 .alloc_by_type = intel_i830_alloc_by_type,
1783 .free_by_type = intel_i810_free_by_type,
1784 .agp_alloc_page = agp_generic_alloc_page,
1785 .agp_destroy_page = agp_generic_destroy_page,
1786 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
1787};
1735 1788
1736static int find_i830(u16 device) 1789static int find_gmch(u16 device)
1737{ 1790{
1738 struct pci_dev *i830_dev; 1791 struct pci_dev *gmch_device;
1739 1792
1740 i830_dev = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL); 1793 gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL);
1741 if (i830_dev && PCI_FUNC(i830_dev->devfn) != 0) { 1794 if (gmch_device && PCI_FUNC(gmch_device->devfn) != 0) {
1742 i830_dev = pci_get_device(PCI_VENDOR_ID_INTEL, 1795 gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL,
1743 device, i830_dev); 1796 device, gmch_device);
1744 } 1797 }
1745 1798
1746 if (!i830_dev) 1799 if (!gmch_device)
1747 return 0; 1800 return 0;
1748 1801
1749 intel_i830_private.i830_dev = i830_dev; 1802 intel_private.pcidev = gmch_device;
1750 return 1; 1803 return 1;
1751} 1804}
1752 1805
1806/* Table to describe Intel GMCH and AGP/PCIE GART drivers. At least one of
1807 * driver and gmch_driver must be non-null, and find_gmch will determine
1808 * which one should be used if a gmch_chip_id is present.
1809 */
1810static const struct intel_driver_description {
1811 unsigned int chip_id;
1812 unsigned int gmch_chip_id;
1813 char *name;
1814 const struct agp_bridge_driver *driver;
1815 const struct agp_bridge_driver *gmch_driver;
1816} intel_agp_chipsets[] = {
1817 { PCI_DEVICE_ID_INTEL_82443LX_0, 0, "440LX", &intel_generic_driver, NULL },
1818 { PCI_DEVICE_ID_INTEL_82443BX_0, 0, "440BX", &intel_generic_driver, NULL },
1819 { PCI_DEVICE_ID_INTEL_82443GX_0, 0, "440GX", &intel_generic_driver, NULL },
1820 { PCI_DEVICE_ID_INTEL_82810_MC1, PCI_DEVICE_ID_INTEL_82810_IG1, "i810",
1821 NULL, &intel_810_driver },
1822 { PCI_DEVICE_ID_INTEL_82810_MC3, PCI_DEVICE_ID_INTEL_82810_IG3, "i810",
1823 NULL, &intel_810_driver },
1824 { PCI_DEVICE_ID_INTEL_82810E_MC, PCI_DEVICE_ID_INTEL_82810E_IG, "i810",
1825 NULL, &intel_810_driver },
1826 { PCI_DEVICE_ID_INTEL_82815_MC, PCI_DEVICE_ID_INTEL_82815_CGC, "i815",
1827 &intel_810_driver, &intel_815_driver },
1828 { PCI_DEVICE_ID_INTEL_82820_HB, 0, "i820", &intel_820_driver, NULL },
1829 { PCI_DEVICE_ID_INTEL_82820_UP_HB, 0, "i820", &intel_820_driver, NULL },
1830 { PCI_DEVICE_ID_INTEL_82830_HB, PCI_DEVICE_ID_INTEL_82830_CGC, "830M",
1831 &intel_830mp_driver, &intel_830_driver },
1832 { PCI_DEVICE_ID_INTEL_82840_HB, 0, "i840", &intel_840_driver, NULL },
1833 { PCI_DEVICE_ID_INTEL_82845_HB, 0, "845G", &intel_845_driver, NULL },
1834 { PCI_DEVICE_ID_INTEL_82845G_HB, PCI_DEVICE_ID_INTEL_82845G_IG, "830M",
1835 &intel_845_driver, &intel_830_driver },
1836 { PCI_DEVICE_ID_INTEL_82850_HB, 0, "i850", &intel_850_driver, NULL },
1837 { PCI_DEVICE_ID_INTEL_82855PM_HB, 0, "855PM", &intel_845_driver, NULL },
1838 { PCI_DEVICE_ID_INTEL_82855GM_HB, PCI_DEVICE_ID_INTEL_82855GM_IG, "855GM",
1839 &intel_845_driver, &intel_830_driver },
1840 { PCI_DEVICE_ID_INTEL_82860_HB, 0, "i860", &intel_860_driver, NULL },
1841 { PCI_DEVICE_ID_INTEL_82865_HB, PCI_DEVICE_ID_INTEL_82865_IG, "865",
1842 &intel_845_driver, &intel_830_driver },
1843 { PCI_DEVICE_ID_INTEL_82875_HB, 0, "i875", &intel_845_driver, NULL },
1844 { PCI_DEVICE_ID_INTEL_82915G_HB, PCI_DEVICE_ID_INTEL_82915G_IG, "915G",
1845 &intel_845_driver, &intel_915_driver },
1846 { PCI_DEVICE_ID_INTEL_82915GM_HB, PCI_DEVICE_ID_INTEL_82915GM_IG, "915GM",
1847 &intel_845_driver, &intel_915_driver },
1848 { PCI_DEVICE_ID_INTEL_82945G_HB, PCI_DEVICE_ID_INTEL_82945G_IG, "945G",
1849 &intel_845_driver, &intel_915_driver },
1850 { PCI_DEVICE_ID_INTEL_82945GM_HB, PCI_DEVICE_ID_INTEL_82945GM_IG, "945GM",
1851 &intel_845_driver, &intel_915_driver },
1852 { PCI_DEVICE_ID_INTEL_82945GM_HB, PCI_DEVICE_ID_INTEL_82945GME_IG, "945GME",
1853 &intel_845_driver, &intel_915_driver },
1854 { PCI_DEVICE_ID_INTEL_82946GZ_HB, PCI_DEVICE_ID_INTEL_82946GZ_IG, "946GZ",
1855 &intel_845_driver, &intel_i965_driver },
1856 { PCI_DEVICE_ID_INTEL_82965G_1_HB, PCI_DEVICE_ID_INTEL_82965G_1_IG, "965G",
1857 &intel_845_driver, &intel_i965_driver },
1858 { PCI_DEVICE_ID_INTEL_82965Q_HB, PCI_DEVICE_ID_INTEL_82965Q_IG, "965Q",
1859 &intel_845_driver, &intel_i965_driver },
1860 { PCI_DEVICE_ID_INTEL_82965G_HB, PCI_DEVICE_ID_INTEL_82965G_IG, "965G",
1861 &intel_845_driver, &intel_i965_driver },
1862 { PCI_DEVICE_ID_INTEL_82965GM_HB, PCI_DEVICE_ID_INTEL_82965GM_IG, "965GM",
1863 &intel_845_driver, &intel_i965_driver },
1864 { PCI_DEVICE_ID_INTEL_82965GM_HB, PCI_DEVICE_ID_INTEL_82965GME_IG, "965GME/GLE",
1865 &intel_845_driver, &intel_i965_driver },
1866 { PCI_DEVICE_ID_INTEL_7505_0, 0, "E7505", &intel_7505_driver, NULL },
1867 { PCI_DEVICE_ID_INTEL_7205_0, 0, "E7205", &intel_7505_driver, NULL },
1868 { PCI_DEVICE_ID_INTEL_G33_HB, PCI_DEVICE_ID_INTEL_G33_IG, "G33",
1869 &intel_845_driver, &intel_g33_driver },
1870 { PCI_DEVICE_ID_INTEL_Q35_HB, PCI_DEVICE_ID_INTEL_Q35_IG, "Q35",
1871 &intel_845_driver, &intel_g33_driver },
1872 { PCI_DEVICE_ID_INTEL_Q33_HB, PCI_DEVICE_ID_INTEL_Q33_IG, "Q33",
1873 &intel_845_driver, &intel_g33_driver },
1874 { 0, 0, NULL, NULL, NULL }
1875};
1876
1753static int __devinit agp_intel_probe(struct pci_dev *pdev, 1877static int __devinit agp_intel_probe(struct pci_dev *pdev,
1754 const struct pci_device_id *ent) 1878 const struct pci_device_id *ent)
1755{ 1879{
1756 struct agp_bridge_data *bridge; 1880 struct agp_bridge_data *bridge;
1757 char *name = "(unknown)";
1758 u8 cap_ptr = 0; 1881 u8 cap_ptr = 0;
1759 struct resource *r; 1882 struct resource *r;
1883 int i;
1760 1884
1761 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP); 1885 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
1762 1886
@@ -1764,195 +1888,42 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
1764 if (!bridge) 1888 if (!bridge)
1765 return -ENOMEM; 1889 return -ENOMEM;
1766 1890
1767 switch (pdev->device) { 1891 for (i = 0; intel_agp_chipsets[i].name != NULL; i++) {
1768 case PCI_DEVICE_ID_INTEL_82443LX_0: 1892 /* In case that multiple models of gfx chip may
1769 bridge->driver = &intel_generic_driver; 1893 stand on same host bridge type, this can be
1770 name = "440LX"; 1894 sure we detect the right IGD. */
1771 break; 1895 if ((pdev->device == intel_agp_chipsets[i].chip_id) &&
1772 case PCI_DEVICE_ID_INTEL_82443BX_0: 1896 ((intel_agp_chipsets[i].gmch_chip_id == 0) ||
1773 bridge->driver = &intel_generic_driver; 1897 find_gmch(intel_agp_chipsets[i].gmch_chip_id)))
1774 name = "440BX"; 1898 break;
1775 break; 1899 }
1776 case PCI_DEVICE_ID_INTEL_82443GX_0: 1900
1777 bridge->driver = &intel_generic_driver; 1901 if (intel_agp_chipsets[i].name == NULL) {
1778 name = "440GX";
1779 break;
1780 case PCI_DEVICE_ID_INTEL_82810_MC1:
1781 name = "i810";
1782 if (!find_i810(PCI_DEVICE_ID_INTEL_82810_IG1))
1783 goto fail;
1784 bridge->driver = &intel_810_driver;
1785 break;
1786 case PCI_DEVICE_ID_INTEL_82810_MC3:
1787 name = "i810 DC100";
1788 if (!find_i810(PCI_DEVICE_ID_INTEL_82810_IG3))
1789 goto fail;
1790 bridge->driver = &intel_810_driver;
1791 break;
1792 case PCI_DEVICE_ID_INTEL_82810E_MC:
1793 name = "i810 E";
1794 if (!find_i810(PCI_DEVICE_ID_INTEL_82810E_IG))
1795 goto fail;
1796 bridge->driver = &intel_810_driver;
1797 break;
1798 case PCI_DEVICE_ID_INTEL_82815_MC:
1799 /*
1800 * The i815 can operate either as an i810 style
1801 * integrated device, or as an AGP4X motherboard.
1802 */
1803 if (find_i810(PCI_DEVICE_ID_INTEL_82815_CGC))
1804 bridge->driver = &intel_810_driver;
1805 else
1806 bridge->driver = &intel_815_driver;
1807 name = "i815";
1808 break;
1809 case PCI_DEVICE_ID_INTEL_82820_HB:
1810 case PCI_DEVICE_ID_INTEL_82820_UP_HB:
1811 bridge->driver = &intel_820_driver;
1812 name = "i820";
1813 break;
1814 case PCI_DEVICE_ID_INTEL_82830_HB:
1815 if (find_i830(PCI_DEVICE_ID_INTEL_82830_CGC))
1816 bridge->driver = &intel_830_driver;
1817 else
1818 bridge->driver = &intel_830mp_driver;
1819 name = "830M";
1820 break;
1821 case PCI_DEVICE_ID_INTEL_82840_HB:
1822 bridge->driver = &intel_840_driver;
1823 name = "i840";
1824 break;
1825 case PCI_DEVICE_ID_INTEL_82845_HB:
1826 bridge->driver = &intel_845_driver;
1827 name = "i845";
1828 break;
1829 case PCI_DEVICE_ID_INTEL_82845G_HB:
1830 if (find_i830(PCI_DEVICE_ID_INTEL_82845G_IG))
1831 bridge->driver = &intel_830_driver;
1832 else
1833 bridge->driver = &intel_845_driver;
1834 name = "845G";
1835 break;
1836 case PCI_DEVICE_ID_INTEL_82850_HB:
1837 bridge->driver = &intel_850_driver;
1838 name = "i850";
1839 break;
1840 case PCI_DEVICE_ID_INTEL_82855PM_HB:
1841 bridge->driver = &intel_845_driver;
1842 name = "855PM";
1843 break;
1844 case PCI_DEVICE_ID_INTEL_82855GM_HB:
1845 if (find_i830(PCI_DEVICE_ID_INTEL_82855GM_IG)) {
1846 bridge->driver = &intel_830_driver;
1847 name = "855";
1848 } else {
1849 bridge->driver = &intel_845_driver;
1850 name = "855GM";
1851 }
1852 break;
1853 case PCI_DEVICE_ID_INTEL_82860_HB:
1854 bridge->driver = &intel_860_driver;
1855 name = "i860";
1856 break;
1857 case PCI_DEVICE_ID_INTEL_82865_HB:
1858 if (find_i830(PCI_DEVICE_ID_INTEL_82865_IG))
1859 bridge->driver = &intel_830_driver;
1860 else
1861 bridge->driver = &intel_845_driver;
1862 name = "865";
1863 break;
1864 case PCI_DEVICE_ID_INTEL_82875_HB:
1865 bridge->driver = &intel_845_driver;
1866 name = "i875";
1867 break;
1868 case PCI_DEVICE_ID_INTEL_82915G_HB:
1869 if (find_i830(PCI_DEVICE_ID_INTEL_82915G_IG))
1870 bridge->driver = &intel_915_driver;
1871 else
1872 bridge->driver = &intel_845_driver;
1873 name = "915G";
1874 break;
1875 case PCI_DEVICE_ID_INTEL_82915GM_HB:
1876 if (find_i830(PCI_DEVICE_ID_INTEL_82915GM_IG))
1877 bridge->driver = &intel_915_driver;
1878 else
1879 bridge->driver = &intel_845_driver;
1880 name = "915GM";
1881 break;
1882 case PCI_DEVICE_ID_INTEL_82945G_HB:
1883 if (find_i830(PCI_DEVICE_ID_INTEL_82945G_IG))
1884 bridge->driver = &intel_915_driver;
1885 else
1886 bridge->driver = &intel_845_driver;
1887 name = "945G";
1888 break;
1889 case PCI_DEVICE_ID_INTEL_82945GM_HB:
1890 if (find_i830(PCI_DEVICE_ID_INTEL_82945GM_IG))
1891 bridge->driver = &intel_915_driver;
1892 else
1893 bridge->driver = &intel_845_driver;
1894 name = "945GM";
1895 break;
1896 case PCI_DEVICE_ID_INTEL_82946GZ_HB:
1897 if (find_i830(PCI_DEVICE_ID_INTEL_82946GZ_IG))
1898 bridge->driver = &intel_i965_driver;
1899 else
1900 bridge->driver = &intel_845_driver;
1901 name = "946GZ";
1902 break;
1903 case PCI_DEVICE_ID_INTEL_82965G_1_HB:
1904 if (find_i830(PCI_DEVICE_ID_INTEL_82965G_1_IG))
1905 bridge->driver = &intel_i965_driver;
1906 else
1907 bridge->driver = &intel_845_driver;
1908 name = "965G";
1909 break;
1910 case PCI_DEVICE_ID_INTEL_82965Q_HB:
1911 if (find_i830(PCI_DEVICE_ID_INTEL_82965Q_IG))
1912 bridge->driver = &intel_i965_driver;
1913 else
1914 bridge->driver = &intel_845_driver;
1915 name = "965Q";
1916 break;
1917 case PCI_DEVICE_ID_INTEL_82965G_HB:
1918 if (find_i830(PCI_DEVICE_ID_INTEL_82965G_IG))
1919 bridge->driver = &intel_i965_driver;
1920 else
1921 bridge->driver = &intel_845_driver;
1922 name = "965G";
1923 break;
1924 case PCI_DEVICE_ID_INTEL_82965GM_HB:
1925 if (find_i830(PCI_DEVICE_ID_INTEL_82965GM_IG))
1926 bridge->driver = &intel_i965_driver;
1927 else
1928 bridge->driver = &intel_845_driver;
1929 name = "965GM";
1930 break;
1931 case PCI_DEVICE_ID_INTEL_7505_0:
1932 bridge->driver = &intel_7505_driver;
1933 name = "E7505";
1934 break;
1935 case PCI_DEVICE_ID_INTEL_7205_0:
1936 bridge->driver = &intel_7505_driver;
1937 name = "E7205";
1938 break;
1939 default:
1940 if (cap_ptr) 1902 if (cap_ptr)
1941 printk(KERN_WARNING PFX "Unsupported Intel chipset (device id: %04x)\n", 1903 printk(KERN_WARNING PFX "Unsupported Intel chipset"
1942 pdev->device); 1904 "(device id: %04x)\n", pdev->device);
1943 agp_put_bridge(bridge); 1905 agp_put_bridge(bridge);
1944 return -ENODEV; 1906 return -ENODEV;
1945 }; 1907 }
1908
1909 if (intel_agp_chipsets[i].gmch_chip_id != 0)
1910 bridge->driver = intel_agp_chipsets[i].gmch_driver;
1911 else
1912 bridge->driver = intel_agp_chipsets[i].driver;
1913
1914 if (bridge->driver == NULL) {
1915 printk(KERN_WARNING PFX "Failed to find bridge device "
1916 "(chip_id: %04x)\n", intel_agp_chipsets[i].gmch_chip_id);
1917 agp_put_bridge(bridge);
1918 return -ENODEV;
1919 }
1946 1920
1947 bridge->dev = pdev; 1921 bridge->dev = pdev;
1948 bridge->capndx = cap_ptr; 1922 bridge->capndx = cap_ptr;
1923 bridge->dev_private_data = &intel_private;
1949 1924
1950 if (bridge->driver == &intel_810_driver) 1925 printk(KERN_INFO PFX "Detected an Intel %s Chipset.\n",
1951 bridge->dev_private_data = &intel_i810_private; 1926 intel_agp_chipsets[i].name);
1952 else if (bridge->driver == &intel_830_driver)
1953 bridge->dev_private_data = &intel_i830_private;
1954
1955 printk(KERN_INFO PFX "Detected an Intel %s Chipset.\n", name);
1956 1927
1957 /* 1928 /*
1958 * The following fixes the case where the BIOS has "forgotten" to 1929 * The following fixes the case where the BIOS has "forgotten" to
@@ -1988,12 +1959,6 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
1988 1959
1989 pci_set_drvdata(pdev, bridge); 1960 pci_set_drvdata(pdev, bridge);
1990 return agp_add_bridge(bridge); 1961 return agp_add_bridge(bridge);
1991
1992fail:
1993 printk(KERN_ERR PFX "Detected an Intel %s chipset, "
1994 "but could not find the secondary device.\n", name);
1995 agp_put_bridge(bridge);
1996 return -ENODEV;
1997} 1962}
1998 1963
1999static void __devexit agp_intel_remove(struct pci_dev *pdev) 1964static void __devexit agp_intel_remove(struct pci_dev *pdev)
@@ -2002,10 +1967,8 @@ static void __devexit agp_intel_remove(struct pci_dev *pdev)
2002 1967
2003 agp_remove_bridge(bridge); 1968 agp_remove_bridge(bridge);
2004 1969
2005 if (intel_i810_private.i810_dev) 1970 if (intel_private.pcidev)
2006 pci_dev_put(intel_i810_private.i810_dev); 1971 pci_dev_put(intel_private.pcidev);
2007 if (intel_i830_private.i830_dev)
2008 pci_dev_put(intel_i830_private.i830_dev);
2009 1972
2010 agp_put_bridge(bridge); 1973 agp_put_bridge(bridge);
2011} 1974}
@@ -2021,10 +1984,8 @@ static int agp_intel_resume(struct pci_dev *pdev)
2021 * as host bridge (00:00) resumes before graphics device (02:00), 1984 * as host bridge (00:00) resumes before graphics device (02:00),
2022 * then our access to its pci space can work right. 1985 * then our access to its pci space can work right.
2023 */ 1986 */
2024 if (intel_i810_private.i810_dev) 1987 if (intel_private.pcidev)
2025 pci_restore_state(intel_i810_private.i810_dev); 1988 pci_restore_state(intel_private.pcidev);
2026 if (intel_i830_private.i830_dev)
2027 pci_restore_state(intel_i830_private.i830_dev);
2028 1989
2029 if (bridge->driver == &intel_generic_driver) 1990 if (bridge->driver == &intel_generic_driver)
2030 intel_configure(); 1991 intel_configure();
@@ -2087,6 +2048,9 @@ static struct pci_device_id agp_intel_pci_table[] = {
2087 ID(PCI_DEVICE_ID_INTEL_82965Q_HB), 2048 ID(PCI_DEVICE_ID_INTEL_82965Q_HB),
2088 ID(PCI_DEVICE_ID_INTEL_82965G_HB), 2049 ID(PCI_DEVICE_ID_INTEL_82965G_HB),
2089 ID(PCI_DEVICE_ID_INTEL_82965GM_HB), 2050 ID(PCI_DEVICE_ID_INTEL_82965GM_HB),
2051 ID(PCI_DEVICE_ID_INTEL_G33_HB),
2052 ID(PCI_DEVICE_ID_INTEL_Q35_HB),
2053 ID(PCI_DEVICE_ID_INTEL_Q33_HB),
2090 { } 2054 { }
2091}; 2055};
2092 2056
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index e45113a7a472..45bf2a262a85 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -2172,11 +2172,12 @@ static int __devinit stl_initech(struct stlbrd *brdp)
2172 } 2172 }
2173 status = inb(ioaddr + ECH_PNLSTATUS); 2173 status = inb(ioaddr + ECH_PNLSTATUS);
2174 if ((status & ECH_PNLIDMASK) != nxtid) 2174 if ((status & ECH_PNLIDMASK) != nxtid)
2175 goto err_fr; 2175 break;
2176 panelp = kzalloc(sizeof(struct stlpanel), GFP_KERNEL); 2176 panelp = kzalloc(sizeof(struct stlpanel), GFP_KERNEL);
2177 if (!panelp) { 2177 if (!panelp) {
2178 printk("STALLION: failed to allocate memory " 2178 printk("STALLION: failed to allocate memory "
2179 "(size=%Zd)\n", sizeof(struct stlpanel)); 2179 "(size=%Zd)\n", sizeof(struct stlpanel));
2180 retval = -ENOMEM;
2180 goto err_fr; 2181 goto err_fr;
2181 } 2182 }
2182 panelp->magic = STL_PANELMAGIC; 2183 panelp->magic = STL_PANELMAGIC;
@@ -2223,8 +2224,10 @@ static int __devinit stl_initech(struct stlbrd *brdp)
2223 brdp->nrports += panelp->nrports; 2224 brdp->nrports += panelp->nrports;
2224 brdp->panels[panelnr++] = panelp; 2225 brdp->panels[panelnr++] = panelp;
2225 if ((brdp->brdtype != BRD_ECHPCI) && 2226 if ((brdp->brdtype != BRD_ECHPCI) &&
2226 (ioaddr >= (brdp->ioaddr2 + brdp->iosize2))) 2227 (ioaddr >= (brdp->ioaddr2 + brdp->iosize2))) {
2228 retval = -EINVAL;
2227 goto err_fr; 2229 goto err_fr;
2230 }
2228 } 2231 }
2229 2232
2230 brdp->nrpanels = panelnr; 2233 brdp->nrpanels = panelnr;
@@ -2371,6 +2374,7 @@ static int __devinit stl_pciprobe(struct pci_dev *pdev,
2371 dev_err(&pdev->dev, "too many boards found, " 2374 dev_err(&pdev->dev, "too many boards found, "
2372 "maximum supported %d\n", STL_MAXBRDS); 2375 "maximum supported %d\n", STL_MAXBRDS);
2373 mutex_unlock(&stl_brdslock); 2376 mutex_unlock(&stl_brdslock);
2377 retval = -ENODEV;
2374 goto err_fr; 2378 goto err_fr;
2375 } 2379 }
2376 brdp->brdnr = (unsigned int)brdnr; 2380 brdp->brdnr = (unsigned int)brdnr;
@@ -4710,6 +4714,29 @@ static int __init stallion_module_init(void)
4710 spin_lock_init(&stallion_lock); 4714 spin_lock_init(&stallion_lock);
4711 spin_lock_init(&brd_lock); 4715 spin_lock_init(&brd_lock);
4712 4716
4717 stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
4718 if (!stl_serial) {
4719 retval = -ENOMEM;
4720 goto err;
4721 }
4722
4723 stl_serial->owner = THIS_MODULE;
4724 stl_serial->driver_name = stl_drvname;
4725 stl_serial->name = "ttyE";
4726 stl_serial->major = STL_SERIALMAJOR;
4727 stl_serial->minor_start = 0;
4728 stl_serial->type = TTY_DRIVER_TYPE_SERIAL;
4729 stl_serial->subtype = SERIAL_TYPE_NORMAL;
4730 stl_serial->init_termios = stl_deftermios;
4731 stl_serial->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
4732 tty_set_operations(stl_serial, &stl_ops);
4733
4734 retval = tty_register_driver(stl_serial);
4735 if (retval) {
4736 printk("STALLION: failed to register serial driver\n");
4737 goto err_frtty;
4738 }
4739
4713/* 4740/*
4714 * Find any dynamically supported boards. That is via module load 4741 * Find any dynamically supported boards. That is via module load
4715 * line options. 4742 * line options.
@@ -4739,13 +4766,9 @@ static int __init stallion_module_init(void)
4739 4766
4740 /* this has to be _after_ isa finding because of locking */ 4767 /* this has to be _after_ isa finding because of locking */
4741 retval = pci_register_driver(&stl_pcidriver); 4768 retval = pci_register_driver(&stl_pcidriver);
4742 if (retval && stl_nrbrds == 0) 4769 if (retval && stl_nrbrds == 0) {
4743 goto err; 4770 printk(KERN_ERR "STALLION: can't register pci driver\n");
4744 4771 goto err_unrtty;
4745 stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
4746 if (!stl_serial) {
4747 retval = -ENOMEM;
4748 goto err_pcidr;
4749 } 4772 }
4750 4773
4751/* 4774/*
@@ -4756,43 +4779,18 @@ static int __init stallion_module_init(void)
4756 printk("STALLION: failed to register serial board device\n"); 4779 printk("STALLION: failed to register serial board device\n");
4757 4780
4758 stallion_class = class_create(THIS_MODULE, "staliomem"); 4781 stallion_class = class_create(THIS_MODULE, "staliomem");
4759 if (IS_ERR(stallion_class)) { 4782 if (IS_ERR(stallion_class))
4760 retval = PTR_ERR(stallion_class); 4783 printk("STALLION: failed to create class\n");
4761 goto err_reg;
4762 }
4763 for (i = 0; i < 4; i++) 4784 for (i = 0; i < 4; i++)
4764 class_device_create(stallion_class, NULL, 4785 class_device_create(stallion_class, NULL,
4765 MKDEV(STL_SIOMEMMAJOR, i), NULL, 4786 MKDEV(STL_SIOMEMMAJOR, i), NULL,
4766 "staliomem%d", i); 4787 "staliomem%d", i);
4767 4788
4768 stl_serial->owner = THIS_MODULE;
4769 stl_serial->driver_name = stl_drvname;
4770 stl_serial->name = "ttyE";
4771 stl_serial->major = STL_SERIALMAJOR;
4772 stl_serial->minor_start = 0;
4773 stl_serial->type = TTY_DRIVER_TYPE_SERIAL;
4774 stl_serial->subtype = SERIAL_TYPE_NORMAL;
4775 stl_serial->init_termios = stl_deftermios;
4776 stl_serial->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
4777 tty_set_operations(stl_serial, &stl_ops);
4778
4779 retval = tty_register_driver(stl_serial);
4780 if (retval) {
4781 printk("STALLION: failed to register serial driver\n");
4782 goto err_clsdev;
4783 }
4784
4785 return 0; 4789 return 0;
4786err_clsdev: 4790err_unrtty:
4787 for (i = 0; i < 4; i++) 4791 tty_unregister_driver(stl_serial);
4788 class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i)); 4792err_frtty:
4789 class_destroy(stallion_class);
4790err_reg:
4791 unregister_chrdev(STL_SIOMEMMAJOR, "staliomem");
4792 put_tty_driver(stl_serial); 4793 put_tty_driver(stl_serial);
4793err_pcidr:
4794 pci_unregister_driver(&stl_pcidriver);
4795 stl_free_isabrds();
4796err: 4794err:
4797 return retval; 4795 return retval;
4798} 4796}
@@ -4821,8 +4819,6 @@ static void __exit stallion_module_exit(void)
4821 tty_unregister_device(stl_serial, 4819 tty_unregister_device(stl_serial,
4822 brdp->brdnr * STL_MAXPORTS + j); 4820 brdp->brdnr * STL_MAXPORTS + j);
4823 } 4821 }
4824 tty_unregister_driver(stl_serial);
4825 put_tty_driver(stl_serial);
4826 4822
4827 for (i = 0; i < 4; i++) 4823 for (i = 0; i < 4; i++)
4828 class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i)); 4824 class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i));
@@ -4834,6 +4830,9 @@ static void __exit stallion_module_exit(void)
4834 pci_unregister_driver(&stl_pcidriver); 4830 pci_unregister_driver(&stl_pcidriver);
4835 4831
4836 stl_free_isabrds(); 4832 stl_free_isabrds();
4833
4834 tty_unregister_driver(stl_serial);
4835 put_tty_driver(stl_serial);
4837} 4836}
4838 4837
4839module_init(stallion_module_init); 4838module_init(stallion_module_init);
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 7fff773f2df7..dc2175c81f5e 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -1037,6 +1037,17 @@ static void ide_disk_release(struct kref *kref)
1037 1037
1038static int ide_disk_probe(ide_drive_t *drive); 1038static int ide_disk_probe(ide_drive_t *drive);
1039 1039
1040/*
1041 * On HPA drives the capacity needs to be
1042 * reinitilized on resume otherwise the disk
1043 * can not be used and a hard reset is required
1044 */
1045static void ide_disk_resume(ide_drive_t *drive)
1046{
1047 if (idedisk_supports_hpa(drive->id))
1048 init_idedisk_capacity(drive);
1049}
1050
1040static void ide_device_shutdown(ide_drive_t *drive) 1051static void ide_device_shutdown(ide_drive_t *drive)
1041{ 1052{
1042#ifdef CONFIG_ALPHA 1053#ifdef CONFIG_ALPHA
@@ -1071,6 +1082,7 @@ static ide_driver_t idedisk_driver = {
1071 }, 1082 },
1072 .probe = ide_disk_probe, 1083 .probe = ide_disk_probe,
1073 .remove = ide_disk_remove, 1084 .remove = ide_disk_remove,
1085 .resume = ide_disk_resume,
1074 .shutdown = ide_device_shutdown, 1086 .shutdown = ide_device_shutdown,
1075 .version = IDEDISK_VERSION, 1087 .version = IDEDISK_VERSION,
1076 .media = ide_disk, 1088 .media = ide_disk,
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 3cebed77f55d..41bfa4d21ab6 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -717,7 +717,7 @@ EXPORT_SYMBOL_GPL(ide_undecoded_slave);
717 * This routine only knows how to look for drive units 0 and 1 717 * This routine only knows how to look for drive units 0 and 1
718 * on an interface, so any setting of MAX_DRIVES > 2 won't work here. 718 * on an interface, so any setting of MAX_DRIVES > 2 won't work here.
719 */ 719 */
720static void probe_hwif(ide_hwif_t *hwif) 720static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif))
721{ 721{
722 unsigned int unit; 722 unsigned int unit;
723 unsigned long flags; 723 unsigned long flags;
@@ -820,6 +820,9 @@ static void probe_hwif(ide_hwif_t *hwif)
820 return; 820 return;
821 } 821 }
822 822
823 if (fixup)
824 fixup(hwif);
825
823 for (unit = 0; unit < MAX_DRIVES; ++unit) { 826 for (unit = 0; unit < MAX_DRIVES; ++unit) {
824 ide_drive_t *drive = &hwif->drives[unit]; 827 ide_drive_t *drive = &hwif->drives[unit];
825 828
@@ -874,10 +877,7 @@ static int hwif_init(ide_hwif_t *hwif);
874 877
875int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)) 878int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif))
876{ 879{
877 probe_hwif(hwif); 880 probe_hwif(hwif, fixup);
878
879 if (fixup)
880 fixup(hwif);
881 881
882 if (!hwif_init(hwif)) { 882 if (!hwif_init(hwif)) {
883 printk(KERN_INFO "%s: failed to initialize IDE interface\n", 883 printk(KERN_INFO "%s: failed to initialize IDE interface\n",
@@ -1404,7 +1404,7 @@ int ideprobe_init (void)
1404 1404
1405 for (index = 0; index < MAX_HWIFS; ++index) 1405 for (index = 0; index < MAX_HWIFS; ++index)
1406 if (probe[index]) 1406 if (probe[index])
1407 probe_hwif(&ide_hwifs[index]); 1407 probe_hwif(&ide_hwifs[index], NULL);
1408 for (index = 0; index < MAX_HWIFS; ++index) 1408 for (index = 0; index < MAX_HWIFS; ++index)
1409 if (probe[index]) 1409 if (probe[index])
1410 hwif_init(&ide_hwifs[index]); 1410 hwif_init(&ide_hwifs[index]);
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 6002713a20a1..0af0d1614f75 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -1010,9 +1010,11 @@ static int generic_ide_resume(struct device *dev)
1010{ 1010{
1011 ide_drive_t *drive = dev->driver_data; 1011 ide_drive_t *drive = dev->driver_data;
1012 ide_hwif_t *hwif = HWIF(drive); 1012 ide_hwif_t *hwif = HWIF(drive);
1013 ide_driver_t *drv = to_ide_driver(dev->driver);
1013 struct request rq; 1014 struct request rq;
1014 struct request_pm_state rqpm; 1015 struct request_pm_state rqpm;
1015 ide_task_t args; 1016 ide_task_t args;
1017 int err;
1016 1018
1017 /* Call ACPI _STM only once */ 1019 /* Call ACPI _STM only once */
1018 if (!(drive->dn % 2)) 1020 if (!(drive->dn % 2))
@@ -1029,7 +1031,12 @@ static int generic_ide_resume(struct device *dev)
1029 rqpm.pm_step = ide_pm_state_start_resume; 1031 rqpm.pm_step = ide_pm_state_start_resume;
1030 rqpm.pm_state = PM_EVENT_ON; 1032 rqpm.pm_state = PM_EVENT_ON;
1031 1033
1032 return ide_do_drive_cmd(drive, &rq, ide_head_wait); 1034 err = ide_do_drive_cmd(drive, &rq, ide_head_wait);
1035
1036 if (err == 0 && drv && drv->resume)
1037 drv->resume(drive);
1038
1039 return err;
1033} 1040}
1034 1041
1035int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev, 1042int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev,
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c
index becb1a5648b0..9db1be826e80 100644
--- a/drivers/ide/pci/amd74xx.c
+++ b/drivers/ide/pci/amd74xx.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Version 2.13 2 * Version 2.15
3 * 3 *
4 * AMD 755/756/766/8111 and nVidia nForce/2/2s/3/3s/CK804/MCP04 4 * AMD 755/756/766/8111 and nVidia nForce/2/2s/3/3s/CK804/MCP04
5 * IDE driver for Linux. 5 * IDE driver for Linux.
@@ -76,6 +76,8 @@ static struct amd_ide_chip {
76 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, 0x50, AMD_UDMA_133 }, 76 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, 0x50, AMD_UDMA_133 },
77 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, 0x50, AMD_UDMA_133 }, 77 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, 0x50, AMD_UDMA_133 },
78 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE, 0x50, AMD_UDMA_133 }, 78 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE, 0x50, AMD_UDMA_133 },
79 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE, 0x50, AMD_UDMA_133 },
80 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE, 0x50, AMD_UDMA_133 },
79 { PCI_DEVICE_ID_AMD_CS5536_IDE, 0x40, AMD_UDMA_100 }, 81 { PCI_DEVICE_ID_AMD_CS5536_IDE, 0x40, AMD_UDMA_100 },
80 { 0 } 82 { 0 }
81}; 83};
@@ -494,7 +496,9 @@ static ide_pci_device_t amd74xx_chipsets[] __devinitdata = {
494 /* 17 */ DECLARE_NV_DEV("NFORCE-MCP61"), 496 /* 17 */ DECLARE_NV_DEV("NFORCE-MCP61"),
495 /* 18 */ DECLARE_NV_DEV("NFORCE-MCP65"), 497 /* 18 */ DECLARE_NV_DEV("NFORCE-MCP65"),
496 /* 19 */ DECLARE_NV_DEV("NFORCE-MCP67"), 498 /* 19 */ DECLARE_NV_DEV("NFORCE-MCP67"),
497 /* 20 */ DECLARE_AMD_DEV("AMD5536"), 499 /* 20 */ DECLARE_NV_DEV("NFORCE-MCP73"),
500 /* 21 */ DECLARE_NV_DEV("NFORCE-MCP77"),
501 /* 22 */ DECLARE_AMD_DEV("AMD5536"),
498}; 502};
499 503
500static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id) 504static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id)
@@ -534,7 +538,9 @@ static struct pci_device_id amd74xx_pci_tbl[] = {
534 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 17 }, 538 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 17 },
535 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 18 }, 539 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 18 },
536 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 19 }, 540 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 19 },
537 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 20 }, 541 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 20 },
542 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 21 },
543 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 22 },
538 { 0, }, 544 { 0, },
539}; 545};
540MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl); 546MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl);
diff --git a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c
index f2c5a141ca10..0d51a11e81da 100644
--- a/drivers/ide/pci/generic.c
+++ b/drivers/ide/pci/generic.c
@@ -198,32 +198,41 @@ static ide_pci_device_t generic_chipsets[] __devinitdata = {
198static int __devinit generic_init_one(struct pci_dev *dev, const struct pci_device_id *id) 198static int __devinit generic_init_one(struct pci_dev *dev, const struct pci_device_id *id)
199{ 199{
200 ide_pci_device_t *d = &generic_chipsets[id->driver_data]; 200 ide_pci_device_t *d = &generic_chipsets[id->driver_data];
201 u16 command;
202 int ret = -ENODEV; 201 int ret = -ENODEV;
203 202
204 /* Don't use the generic entry unless instructed to do so */ 203 /* Don't use the generic entry unless instructed to do so */
205 if (id->driver_data == 0 && ide_generic_all == 0) 204 if (id->driver_data == 0 && ide_generic_all == 0)
206 goto out; 205 goto out;
207 206
208 if (dev->vendor == PCI_VENDOR_ID_UMC && 207 switch (dev->vendor) {
209 dev->device == PCI_DEVICE_ID_UMC_UM8886A && 208 case PCI_VENDOR_ID_UMC:
210 (!(PCI_FUNC(dev->devfn) & 1))) 209 if (dev->device == PCI_DEVICE_ID_UMC_UM8886A &&
211 goto out; /* UM8886A/BF pair */ 210 !(PCI_FUNC(dev->devfn) & 1))
212 211 goto out; /* UM8886A/BF pair */
213 if (dev->vendor == PCI_VENDOR_ID_OPTI && 212 break;
214 dev->device == PCI_DEVICE_ID_OPTI_82C558 && 213 case PCI_VENDOR_ID_OPTI:
215 (!(PCI_FUNC(dev->devfn) & 1))) 214 if (dev->device == PCI_DEVICE_ID_OPTI_82C558 &&
216 goto out; 215 !(PCI_FUNC(dev->devfn) & 1))
217 216 goto out;
218 if (dev->vendor == PCI_VENDOR_ID_JMICRON) { 217 break;
219 if (dev->device != PCI_DEVICE_ID_JMICRON_JMB368 && PCI_FUNC(dev->devfn) != 1) 218 case PCI_VENDOR_ID_JMICRON:
219 if (dev->device != PCI_DEVICE_ID_JMICRON_JMB368 &&
220 PCI_FUNC(dev->devfn) != 1)
221 goto out;
222 break;
223 case PCI_VENDOR_ID_NS:
224 if (dev->device == PCI_DEVICE_ID_NS_87410 &&
225 (dev->class >> 8) != PCI_CLASS_STORAGE_IDE)
220 goto out; 226 goto out;
227 break;
221 } 228 }
222 229
223 if (dev->vendor != PCI_VENDOR_ID_JMICRON) { 230 if (dev->vendor != PCI_VENDOR_ID_JMICRON) {
231 u16 command;
224 pci_read_config_word(dev, PCI_COMMAND, &command); 232 pci_read_config_word(dev, PCI_COMMAND, &command);
225 if (!(command & PCI_COMMAND_IO)) { 233 if (!(command & PCI_COMMAND_IO)) {
226 printk(KERN_INFO "Skipping disabled %s IDE controller.\n", d->name); 234 printk(KERN_INFO "Skipping disabled %s IDE "
235 "controller.\n", d->name);
227 goto out; 236 goto out;
228 } 237 }
229 } 238 }
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index fcbc5605b38e..ce8a5449a574 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/hpt366.c Version 1.03 May 4, 2007 2 * linux/drivers/ide/pci/hpt366.c Version 1.04 Jun 4, 2007
3 * 3 *
4 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> 4 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org>
5 * Portions Copyright (C) 2001 Sun Microsystems, Inc. 5 * Portions Copyright (C) 2001 Sun Microsystems, Inc.
@@ -106,7 +106,8 @@
106 * switch to calculating PCI clock frequency based on the chip's base DPLL 106 * switch to calculating PCI clock frequency based on the chip's base DPLL
107 * frequency 107 * frequency
108 * - switch to using the DPLL clock and enable UltraATA/133 mode by default on 108 * - switch to using the DPLL clock and enable UltraATA/133 mode by default on
109 * anything newer than HPT370/A 109 * anything newer than HPT370/A (except HPT374 that is not capable of this
110 * mode according to the manual)
110 * - fold PCI clock detection and DPLL setup code into init_chipset_hpt366(), 111 * - fold PCI clock detection and DPLL setup code into init_chipset_hpt366(),
111 * also fixing the interchanged 25/40 MHz PCI clock cases for HPT36x chips; 112 * also fixing the interchanged 25/40 MHz PCI clock cases for HPT36x chips;
112 * unify HPT36x/37x timing setup code and the speedproc handlers by joining 113 * unify HPT36x/37x timing setup code and the speedproc handlers by joining
@@ -365,7 +366,6 @@ static u32 sixty_six_base_hpt37x[] = {
365}; 366};
366 367
367#define HPT366_DEBUG_DRIVE_INFO 0 368#define HPT366_DEBUG_DRIVE_INFO 0
368#define HPT374_ALLOW_ATA133_6 1
369#define HPT371_ALLOW_ATA133_6 1 369#define HPT371_ALLOW_ATA133_6 1
370#define HPT302_ALLOW_ATA133_6 1 370#define HPT302_ALLOW_ATA133_6 1
371#define HPT372_ALLOW_ATA133_6 1 371#define HPT372_ALLOW_ATA133_6 1
@@ -450,7 +450,7 @@ static struct hpt_info hpt370a __devinitdata = {
450 450
451static struct hpt_info hpt374 __devinitdata = { 451static struct hpt_info hpt374 __devinitdata = {
452 .chip_type = HPT374, 452 .chip_type = HPT374,
453 .max_mode = HPT374_ALLOW_ATA133_6 ? 4 : 3, 453 .max_mode = 3,
454 .dpll_clk = 48, 454 .dpll_clk = 48,
455 .settings = hpt37x_settings 455 .settings = hpt37x_settings
456}; 456};
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index 5faaff87d580..4bd4bf02e917 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -1,6 +1,6 @@
1 1
2/* 2/*
3 * linux/drivers/ide/pci/it821x.c Version 0.10 Mar 10 2007 3 * linux/drivers/ide/pci/it821x.c Version 0.15 Jun 2 2007
4 * 4 *
5 * Copyright (C) 2004 Red Hat <alan@redhat.com> 5 * Copyright (C) 2004 Red Hat <alan@redhat.com>
6 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz 6 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz
@@ -262,7 +262,7 @@ static int it821x_tunepio(ide_drive_t *drive, u8 set_pio)
262 } 262 }
263 263
264 if (itdev->smart) 264 if (itdev->smart)
265 goto set_drive_speed; 265 return 0;
266 266
267 /* We prefer 66Mhz clock for PIO 0-3, don't care for PIO4 */ 267 /* We prefer 66Mhz clock for PIO 0-3, don't care for PIO4 */
268 itdev->want[unit][1] = pio_want[set_pio]; 268 itdev->want[unit][1] = pio_want[set_pio];
@@ -271,7 +271,6 @@ static int it821x_tunepio(ide_drive_t *drive, u8 set_pio)
271 it821x_clock_strategy(drive); 271 it821x_clock_strategy(drive);
272 it821x_program(drive, itdev->pio[unit]); 272 it821x_program(drive, itdev->pio[unit]);
273 273
274set_drive_speed:
275 return ide_config_drive_speed(drive, XFER_PIO_0 + set_pio); 274 return ide_config_drive_speed(drive, XFER_PIO_0 + set_pio);
276} 275}
277 276
@@ -455,12 +454,12 @@ static int it821x_tune_chipset (ide_drive_t *drive, byte xferspeed)
455 default: 454 default:
456 return 1; 455 return 1;
457 } 456 }
457
458 return ide_config_drive_speed(drive, speed);
458 } 459 }
459 /* 460
460 * In smart mode the clocking is done by the host controller 461 /* don't touch anything in the smart mode */
461 * snooping the mode we picked. The rest of it is not our problem 462 return 0;
462 */
463 return ide_config_drive_speed(drive, speed);
464} 463}
465 464
466/** 465/**
@@ -559,17 +558,10 @@ static void __devinit it821x_fixups(ide_hwif_t *hwif)
559 if(idbits[129] != 1) 558 if(idbits[129] != 1)
560 printk("(%dK stripe)", idbits[146]); 559 printk("(%dK stripe)", idbits[146]);
561 printk(".\n"); 560 printk(".\n");
562 /* Now the core code will have wrongly decided no DMA
563 so we need to fix this */
564 hwif->dma_off_quietly(drive);
565#ifdef CONFIG_IDEDMA_ONLYDISK
566 if (drive->media == ide_disk)
567#endif
568 ide_set_dma(drive);
569 } else { 561 } else {
570 /* Non RAID volume. Fixups to stop the core code 562 /* Non RAID volume. Fixups to stop the core code
571 doing unsupported things */ 563 doing unsupported things */
572 id->field_valid &= 1; 564 id->field_valid &= 3;
573 id->queue_depth = 0; 565 id->queue_depth = 0;
574 id->command_set_1 = 0; 566 id->command_set_1 = 0;
575 id->command_set_2 &= 0xC400; 567 id->command_set_2 &= 0xC400;
@@ -584,6 +576,16 @@ static void __devinit it821x_fixups(ide_hwif_t *hwif)
584 printk(KERN_INFO "%s: Performing identify fixups.\n", 576 printk(KERN_INFO "%s: Performing identify fixups.\n",
585 drive->name); 577 drive->name);
586 } 578 }
579
580 /*
581 * Set MWDMA0 mode as enabled/support - just to tell
582 * IDE core that DMA is supported (it821x hardware
583 * takes care of DMA mode programming).
584 */
585 if (id->capability & 1) {
586 id->dma_mword |= 0x0101;
587 drive->current_speed = XFER_MW_DMA_0;
588 }
587 } 589 }
588 590
589} 591}
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c
index 47bcd91c9b5f..d9c4fd1ae996 100644
--- a/drivers/ide/pci/serverworks.c
+++ b/drivers/ide/pci/serverworks.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/serverworks.c Version 0.9 Mar 4 2007 2 * linux/drivers/ide/pci/serverworks.c Version 0.11 Jun 2 2007
3 * 3 *
4 * Copyright (C) 1998-2000 Michel Aubry 4 * Copyright (C) 1998-2000 Michel Aubry
5 * Copyright (C) 1998-2000 Andrzej Krzysztofowicz 5 * Copyright (C) 1998-2000 Andrzej Krzysztofowicz
@@ -170,42 +170,55 @@ static int svwks_tune_chipset (ide_drive_t *drive, u8 xferspeed)
170 if (!drive->init_speed) { 170 if (!drive->init_speed) {
171 u8 dma_stat = inb(hwif->dma_status); 171 u8 dma_stat = inb(hwif->dma_status);
172 172
173dma_pio:
174 if (((ultra_enable << (7-drive->dn) & 0x80) == 0x80) && 173 if (((ultra_enable << (7-drive->dn) & 0x80) == 0x80) &&
175 ((dma_stat & (1<<(5+unit))) == (1<<(5+unit)))) { 174 ((dma_stat & (1<<(5+unit))) == (1<<(5+unit)))) {
176 drive->current_speed = drive->init_speed = XFER_UDMA_0 + udma_modes[(ultra_timing >> (4*unit)) & ~(0xF0)]; 175 drive->current_speed = drive->init_speed = XFER_UDMA_0 + udma_modes[(ultra_timing >> (4*unit)) & ~(0xF0)];
177 return 0; 176 return 0;
178 } else if ((dma_timing) && 177 } else if ((dma_timing) &&
179 ((dma_stat&(1<<(5+unit)))==(1<<(5+unit)))) { 178 ((dma_stat&(1<<(5+unit)))==(1<<(5+unit)))) {
180 u8 dmaspeed = dma_timing; 179 u8 dmaspeed;
181 180
182 dma_timing &= ~0xFFU; 181 switch (dma_timing & 0x77) {
183 if ((dmaspeed & 0x20) == 0x20) 182 case 0x20:
184 dmaspeed = XFER_MW_DMA_2; 183 dmaspeed = XFER_MW_DMA_2;
185 else if ((dmaspeed & 0x21) == 0x21) 184 break;
185 case 0x21:
186 dmaspeed = XFER_MW_DMA_1; 186 dmaspeed = XFER_MW_DMA_1;
187 else if ((dmaspeed & 0x77) == 0x77) 187 break;
188 case 0x77:
188 dmaspeed = XFER_MW_DMA_0; 189 dmaspeed = XFER_MW_DMA_0;
189 else 190 break;
191 default:
190 goto dma_pio; 192 goto dma_pio;
193 }
194
191 drive->current_speed = drive->init_speed = dmaspeed; 195 drive->current_speed = drive->init_speed = dmaspeed;
192 return 0; 196 return 0;
193 } else if (pio_timing) { 197 }
194 u8 piospeed = pio_timing; 198dma_pio:
199 if (pio_timing) {
200 u8 piospeed;
195 201
196 pio_timing &= ~0xFFU; 202 switch (pio_timing & 0x7f) {
197 if ((piospeed & 0x20) == 0x20) 203 case 0x20:
198 piospeed = XFER_PIO_4; 204 piospeed = XFER_PIO_4;
199 else if ((piospeed & 0x22) == 0x22) 205 break;
206 case 0x22:
200 piospeed = XFER_PIO_3; 207 piospeed = XFER_PIO_3;
201 else if ((piospeed & 0x34) == 0x34) 208 break;
209 case 0x34:
202 piospeed = XFER_PIO_2; 210 piospeed = XFER_PIO_2;
203 else if ((piospeed & 0x47) == 0x47) 211 break;
212 case 0x47:
204 piospeed = XFER_PIO_1; 213 piospeed = XFER_PIO_1;
205 else if ((piospeed & 0x5d) == 0x5d) 214 break;
215 case 0x5d:
206 piospeed = XFER_PIO_0; 216 piospeed = XFER_PIO_0;
207 else 217 break;
218 default:
208 goto oem_setup_failed; 219 goto oem_setup_failed;
220 }
221
209 drive->current_speed = drive->init_speed = piospeed; 222 drive->current_speed = drive->init_speed = piospeed;
210 return 0; 223 return 0;
211 } 224 }
@@ -214,8 +227,8 @@ dma_pio:
214 227
215oem_setup_failed: 228oem_setup_failed:
216 229
217 pio_timing &= ~0xFFU; 230 pio_timing = 0;
218 dma_timing &= ~0xFFU; 231 dma_timing = 0;
219 ultra_timing &= ~(0x0F << (4*unit)); 232 ultra_timing &= ~(0x0F << (4*unit));
220 ultra_enable &= ~(0x01 << drive->dn); 233 ultra_enable &= ~(0x01 << drive->dn);
221 csb5_pio &= ~(0x0F << (4*drive->dn)); 234 csb5_pio &= ~(0x0F << (4*drive->dn));
diff --git a/drivers/infiniband/hw/amso1100/c2.c b/drivers/infiniband/hw/amso1100/c2.c
index 58bc272bd407..0aecea67f3e6 100644
--- a/drivers/infiniband/hw/amso1100/c2.c
+++ b/drivers/infiniband/hw/amso1100/c2.c
@@ -672,7 +672,7 @@ static int c2_up(struct net_device *netdev)
672 * rdma interface. 672 * rdma interface.
673 */ 673 */
674 in_dev = in_dev_get(netdev); 674 in_dev = in_dev_get(netdev);
675 in_dev->cnf.arp_ignore = 1; 675 IN_DEV_CONF_SET(in_dev, ARP_IGNORE, 1);
676 in_dev_put(in_dev); 676 in_dev_put(in_dev);
677 677
678 return 0; 678 return 0;
diff --git a/drivers/input/keyboard/pxa27x_keyboard.c b/drivers/input/keyboard/pxa27x_keyboard.c
index 06eaf766d9d2..f9e82c9ca421 100644
--- a/drivers/input/keyboard/pxa27x_keyboard.c
+++ b/drivers/input/keyboard/pxa27x_keyboard.c
@@ -104,7 +104,7 @@ static int pxakbd_open(struct input_dev *dev)
104 KPREC = 0x7F; 104 KPREC = 0x7F;
105 105
106 /* Enable unit clock */ 106 /* Enable unit clock */
107 pxa_set_cken(CKEN19_KEYPAD, 1); 107 pxa_set_cken(CKEN_KEYPAD, 1);
108 108
109 return 0; 109 return 0;
110} 110}
@@ -112,7 +112,7 @@ static int pxakbd_open(struct input_dev *dev)
112static void pxakbd_close(struct input_dev *dev) 112static void pxakbd_close(struct input_dev *dev)
113{ 113{
114 /* Disable clock unit */ 114 /* Disable clock unit */
115 pxa_set_cken(CKEN19_KEYPAD, 0); 115 pxa_set_cken(CKEN_KEYPAD, 0);
116} 116}
117 117
118#ifdef CONFIG_PM 118#ifdef CONFIG_PM
@@ -185,7 +185,7 @@ static int __devinit pxakbd_probe(struct platform_device *pdev)
185 DRIVER_NAME, pdev); 185 DRIVER_NAME, pdev);
186 if (error) { 186 if (error) {
187 printk(KERN_ERR "Cannot request keypad IRQ\n"); 187 printk(KERN_ERR "Cannot request keypad IRQ\n");
188 pxa_set_cken(CKEN19_KEYPAD, 0); 188 pxa_set_cken(CKEN_KEYPAD, 0);
189 goto err_free_dev; 189 goto err_free_dev;
190 } 190 }
191 191
diff --git a/drivers/isdn/hardware/eicon/divasfunc.c b/drivers/isdn/hardware/eicon/divasfunc.c
index 46fc21a3f8ff..d36a4c09e25d 100644
--- a/drivers/isdn/hardware/eicon/divasfunc.c
+++ b/drivers/isdn/hardware/eicon/divasfunc.c
@@ -195,7 +195,7 @@ static int DIVA_INIT_FUNCTION connect_didd(void)
195/* 195/*
196 * disconnect from didd 196 * disconnect from didd
197 */ 197 */
198static void DIVA_EXIT_FUNCTION disconnect_didd(void) 198static void disconnect_didd(void)
199{ 199{
200 IDI_SYNC_REQ req; 200 IDI_SYNC_REQ req;
201 201
diff --git a/drivers/media/common/Kconfig b/drivers/media/common/Kconfig
index c120114c241b..5c63c8e24ee7 100644
--- a/drivers/media/common/Kconfig
+++ b/drivers/media/common/Kconfig
@@ -4,5 +4,6 @@ config VIDEO_SAA7146
4 4
5config VIDEO_SAA7146_VV 5config VIDEO_SAA7146_VV
6 tristate 6 tristate
7 depends on VIDEO_DEV
7 select VIDEO_BUF 8 select VIDEO_BUF
8 select VIDEO_SAA7146 9 select VIDEO_SAA7146
diff --git a/drivers/media/dvb/b2c2/Makefile b/drivers/media/dvb/b2c2/Makefile
index 1a1c3bca55fa..bff00b58bf65 100644
--- a/drivers/media/dvb/b2c2/Makefile
+++ b/drivers/media/dvb/b2c2/Makefile
@@ -1,8 +1,11 @@
1b2c2-flexcop-objs = flexcop.o flexcop-fe-tuner.o flexcop-i2c.o \ 1b2c2-flexcop-objs = flexcop.o flexcop-fe-tuner.o flexcop-i2c.o \
2 flexcop-sram.o flexcop-eeprom.o flexcop-misc.o flexcop-hw-filter.o \ 2 flexcop-sram.o flexcop-eeprom.o flexcop-misc.o flexcop-hw-filter.o
3 flexcop-dma.o
4obj-$(CONFIG_DVB_B2C2_FLEXCOP) += b2c2-flexcop.o 3obj-$(CONFIG_DVB_B2C2_FLEXCOP) += b2c2-flexcop.o
5 4
5ifneq ($(CONFIG_DVB_B2C2_FLEXCOP_PCI),)
6b2c2-flexcop-objs += flexcop-dma.o
7endif
8
6b2c2-flexcop-pci-objs = flexcop-pci.o 9b2c2-flexcop-pci-objs = flexcop-pci.o
7obj-$(CONFIG_DVB_B2C2_FLEXCOP_PCI) += b2c2-flexcop-pci.o 10obj-$(CONFIG_DVB_B2C2_FLEXCOP_PCI) += b2c2-flexcop-pci.o
8 11
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c
index 34d7abc900d7..6aba5b39ed14 100644
--- a/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -519,8 +519,7 @@ static int cinergyt2_release (struct inode *inode, struct file *file)
519 struct dvb_device *dvbdev = file->private_data; 519 struct dvb_device *dvbdev = file->private_data;
520 struct cinergyt2 *cinergyt2 = dvbdev->priv; 520 struct cinergyt2 *cinergyt2 = dvbdev->priv;
521 521
522 if (mutex_lock_interruptible(&cinergyt2->sem)) 522 mutex_lock(&cinergyt2->sem);
523 return -ERESTARTSYS;
524 523
525 if (!cinergyt2->disconnect_pending && (file->f_flags & O_ACCMODE) != O_RDONLY) { 524 if (!cinergyt2->disconnect_pending && (file->f_flags & O_ACCMODE) != O_RDONLY) {
526 cancel_delayed_work(&cinergyt2->query_work); 525 cancel_delayed_work(&cinergyt2->query_work);
diff --git a/drivers/media/dvb/frontends/tda10086.c b/drivers/media/dvb/frontends/tda10086.c
index ccc429cbbad0..0f2d4b415560 100644
--- a/drivers/media/dvb/frontends/tda10086.c
+++ b/drivers/media/dvb/frontends/tda10086.c
@@ -41,6 +41,7 @@ struct tda10086_state {
41 /* private demod data */ 41 /* private demod data */
42 u32 frequency; 42 u32 frequency;
43 u32 symbol_rate; 43 u32 symbol_rate;
44 bool has_lock;
44}; 45};
45 46
46static int debug = 0; 47static int debug = 0;
@@ -116,7 +117,7 @@ static int tda10086_init(struct dvb_frontend* fe)
116 // misc setup 117 // misc setup
117 tda10086_write_byte(state, 0x01, 0x94); 118 tda10086_write_byte(state, 0x01, 0x94);
118 tda10086_write_byte(state, 0x02, 0x35); // NOTE: TT drivers appear to disable CSWP 119 tda10086_write_byte(state, 0x02, 0x35); // NOTE: TT drivers appear to disable CSWP
119 tda10086_write_byte(state, 0x03, 0x64); 120 tda10086_write_byte(state, 0x03, 0xe4);
120 tda10086_write_byte(state, 0x04, 0x43); 121 tda10086_write_byte(state, 0x04, 0x43);
121 tda10086_write_byte(state, 0x0c, 0x0c); 122 tda10086_write_byte(state, 0x0c, 0x0c);
122 tda10086_write_byte(state, 0x1b, 0xb0); // noise threshold 123 tda10086_write_byte(state, 0x1b, 0xb0); // noise threshold
@@ -146,7 +147,7 @@ static int tda10086_init(struct dvb_frontend* fe)
146 // setup AGC 147 // setup AGC
147 tda10086_write_byte(state, 0x05, 0x0B); 148 tda10086_write_byte(state, 0x05, 0x0B);
148 tda10086_write_byte(state, 0x37, 0x63); 149 tda10086_write_byte(state, 0x37, 0x63);
149 tda10086_write_byte(state, 0x3f, 0x03); // NOTE: flydvb uses 0x0a and varies it 150 tda10086_write_byte(state, 0x3f, 0x0a); // NOTE: flydvb varies it
150 tda10086_write_byte(state, 0x40, 0x64); 151 tda10086_write_byte(state, 0x40, 0x64);
151 tda10086_write_byte(state, 0x41, 0x4f); 152 tda10086_write_byte(state, 0x41, 0x4f);
152 tda10086_write_byte(state, 0x42, 0x43); 153 tda10086_write_byte(state, 0x42, 0x43);
@@ -398,6 +399,10 @@ static int tda10086_set_frontend(struct dvb_frontend* fe,
398 399
399 dprintk ("%s\n", __FUNCTION__); 400 dprintk ("%s\n", __FUNCTION__);
400 401
402 // modify parameters for tuning
403 tda10086_write_byte(state, 0x02, 0x35);
404 state->has_lock = false;
405
401 // set params 406 // set params
402 if (fe->ops.tuner_ops.set_params) { 407 if (fe->ops.tuner_ops.set_params) {
403 fe->ops.tuner_ops.set_params(fe, fe_params); 408 fe->ops.tuner_ops.set_params(fe, fe_params);
@@ -542,8 +547,14 @@ static int tda10086_read_status(struct dvb_frontend* fe, fe_status_t *fe_status)
542 *fe_status |= FE_HAS_VITERBI; 547 *fe_status |= FE_HAS_VITERBI;
543 if (val & 0x08) 548 if (val & 0x08)
544 *fe_status |= FE_HAS_SYNC; 549 *fe_status |= FE_HAS_SYNC;
545 if (val & 0x10) 550 if (val & 0x10) {
546 *fe_status |= FE_HAS_LOCK; 551 *fe_status |= FE_HAS_LOCK;
552 if (!state->has_lock) {
553 state->has_lock = true;
554 // modify parameters for stable reception
555 tda10086_write_byte(state, 0x02, 0x00);
556 }
557 }
547 558
548 return 0; 559 return 0;
549} 560}
@@ -555,7 +566,7 @@ static int tda10086_read_signal_strength(struct dvb_frontend* fe, u16 * signal)
555 566
556 dprintk ("%s\n", __FUNCTION__); 567 dprintk ("%s\n", __FUNCTION__);
557 568
558 _str = tda10086_read_byte(state, 0x43); 569 _str = 0xff - tda10086_read_byte(state, 0x43);
559 *signal = (_str << 8) | _str; 570 *signal = (_str << 8) | _str;
560 571
561 return 0; 572 return 0;
@@ -568,7 +579,7 @@ static int tda10086_read_snr(struct dvb_frontend* fe, u16 * snr)
568 579
569 dprintk ("%s\n", __FUNCTION__); 580 dprintk ("%s\n", __FUNCTION__);
570 581
571 _snr = tda10086_read_byte(state, 0x1c); 582 _snr = 0xff - tda10086_read_byte(state, 0x1c);
572 *snr = (_snr << 8) | _snr; 583 *snr = (_snr << 8) | _snr;
573 584
574 return 0; 585 return 0;
diff --git a/drivers/media/dvb/frontends/tda826x.c b/drivers/media/dvb/frontends/tda826x.c
index 79f971dc52b6..bd3ebc284835 100644
--- a/drivers/media/dvb/frontends/tda826x.c
+++ b/drivers/media/dvb/frontends/tda826x.c
@@ -89,8 +89,8 @@ static int tda826x_set_params(struct dvb_frontend *fe, struct dvb_frontend_param
89 buf[2] = (1<<5) | 0x0b; // 1Mhz + 0.45 VCO 89 buf[2] = (1<<5) | 0x0b; // 1Mhz + 0.45 VCO
90 buf[3] = div >> 7; 90 buf[3] = div >> 7;
91 buf[4] = div << 1; 91 buf[4] = div << 1;
92 buf[5] = 0xff; // basedband filter to max 92 buf[5] = 0x77; // baseband cut-off 19 MHz
93 buf[6] = 0xfe; // gains at max + no RF attenuation 93 buf[6] = 0xfe; // baseband gain 9 db + no RF attenuation
94 buf[7] = 0x83; // charge pumps at high, tests off 94 buf[7] = 0x83; // charge pumps at high, tests off
95 buf[8] = 0x80; // recommended value 4 for AMPVCO + disable ports. 95 buf[8] = 0x80; // recommended value 4 for AMPVCO + disable ports.
96 buf[9] = 0x1a; // normal caltime + recommended values for SELTH + SELVTL 96 buf[9] = 0x1a; // normal caltime + recommended values for SELTH + SELVTL
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 5cb3f54b548b..4cca55170e21 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -347,7 +347,7 @@ endmenu # encoder / decoder chips
347 347
348config VIDEO_VIVI 348config VIDEO_VIVI
349 tristate "Virtual Video Driver" 349 tristate "Virtual Video Driver"
350 depends on VIDEO_V4L2 && !SPARC32 && !SPARC64 && PCI 350 depends on VIDEO_V4L2 && !SPARC32 && !SPARC64 && PCI && VIDEO_DEV
351 select VIDEO_BUF 351 select VIDEO_BUF
352 default n 352 default n
353 ---help--- 353 ---help---
diff --git a/drivers/media/video/ivtv/ivtv-cards.h b/drivers/media/video/ivtv/ivtv-cards.h
index 15012f88b802..91e9e90c14a5 100644
--- a/drivers/media/video/ivtv/ivtv-cards.h
+++ b/drivers/media/video/ivtv/ivtv-cards.h
@@ -86,7 +86,7 @@
86 V4L2_CAP_AUDIO | V4L2_CAP_READWRITE | V4L2_CAP_VBI_CAPTURE | \ 86 V4L2_CAP_AUDIO | V4L2_CAP_READWRITE | V4L2_CAP_VBI_CAPTURE | \
87 V4L2_CAP_SLICED_VBI_CAPTURE) 87 V4L2_CAP_SLICED_VBI_CAPTURE)
88#define IVTV_CAP_DECODER (V4L2_CAP_VBI_OUTPUT | V4L2_CAP_VIDEO_OUTPUT | \ 88#define IVTV_CAP_DECODER (V4L2_CAP_VBI_OUTPUT | V4L2_CAP_VIDEO_OUTPUT | \
89 V4L2_CAP_SLICED_VBI_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_OVERLAY | V4L2_CAP_VIDEO_OUTPUT_POS) 89 V4L2_CAP_SLICED_VBI_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_OVERLAY)
90 90
91struct ivtv_card_video_input { 91struct ivtv_card_video_input {
92 u8 video_type; /* video input type */ 92 u8 video_type; /* video input type */
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c
index e29f949adf57..efc66355339a 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -652,6 +652,7 @@ static int __devinit ivtv_init_struct1(struct ivtv *itv)
652 itv->dma_timer.data = (unsigned long)itv; 652 itv->dma_timer.data = (unsigned long)itv;
653 653
654 itv->cur_dma_stream = -1; 654 itv->cur_dma_stream = -1;
655 itv->cur_pio_stream = -1;
655 itv->audio_stereo_mode = AUDIO_STEREO; 656 itv->audio_stereo_mode = AUDIO_STEREO;
656 itv->audio_bilingual_mode = AUDIO_MONO_LEFT; 657 itv->audio_bilingual_mode = AUDIO_MONO_LEFT;
657 658
diff --git a/drivers/media/video/ivtv/ivtv-driver.h b/drivers/media/video/ivtv/ivtv-driver.h
index 552f04511ead..e6e56f175f3f 100644
--- a/drivers/media/video/ivtv/ivtv-driver.h
+++ b/drivers/media/video/ivtv/ivtv-driver.h
@@ -237,6 +237,7 @@ extern const u32 yuv_offset[4];
237#define IVTV_IRQ_ENC_VBI_CAP (0x1 << 29) 237#define IVTV_IRQ_ENC_VBI_CAP (0x1 << 29)
238#define IVTV_IRQ_ENC_VIM_RST (0x1 << 28) 238#define IVTV_IRQ_ENC_VIM_RST (0x1 << 28)
239#define IVTV_IRQ_ENC_DMA_COMPLETE (0x1 << 27) 239#define IVTV_IRQ_ENC_DMA_COMPLETE (0x1 << 27)
240#define IVTV_IRQ_ENC_PIO_COMPLETE (0x1 << 25)
240#define IVTV_IRQ_DEC_AUD_MODE_CHG (0x1 << 24) 241#define IVTV_IRQ_DEC_AUD_MODE_CHG (0x1 << 24)
241#define IVTV_IRQ_DEC_DATA_REQ (0x1 << 22) 242#define IVTV_IRQ_DEC_DATA_REQ (0x1 << 22)
242#define IVTV_IRQ_DEC_DMA_COMPLETE (0x1 << 20) 243#define IVTV_IRQ_DEC_DMA_COMPLETE (0x1 << 20)
@@ -247,7 +248,8 @@ extern const u32 yuv_offset[4];
247#define IVTV_IRQ_DEC_VSYNC (0x1 << 10) 248#define IVTV_IRQ_DEC_VSYNC (0x1 << 10)
248 249
249/* IRQ Masks */ 250/* IRQ Masks */
250#define IVTV_IRQ_MASK_INIT (IVTV_IRQ_DMA_ERR|IVTV_IRQ_ENC_DMA_COMPLETE|IVTV_IRQ_DMA_READ) 251#define IVTV_IRQ_MASK_INIT (IVTV_IRQ_DMA_ERR|IVTV_IRQ_ENC_DMA_COMPLETE|\
252 IVTV_IRQ_DMA_READ|IVTV_IRQ_ENC_PIO_COMPLETE)
251 253
252#define IVTV_IRQ_MASK_CAPTURE (IVTV_IRQ_ENC_START_CAP | IVTV_IRQ_ENC_EOS) 254#define IVTV_IRQ_MASK_CAPTURE (IVTV_IRQ_ENC_START_CAP | IVTV_IRQ_ENC_EOS)
253#define IVTV_IRQ_MASK_DECODE (IVTV_IRQ_DEC_DATA_REQ|IVTV_IRQ_DEC_AUD_MODE_CHG) 255#define IVTV_IRQ_MASK_DECODE (IVTV_IRQ_DEC_DATA_REQ|IVTV_IRQ_DEC_AUD_MODE_CHG)
@@ -374,6 +376,9 @@ struct ivtv_mailbox_data {
374#define IVTV_F_S_STREAMOFF 7 /* signal end of stream EOS */ 376#define IVTV_F_S_STREAMOFF 7 /* signal end of stream EOS */
375#define IVTV_F_S_APPL_IO 8 /* this stream is used read/written by an application */ 377#define IVTV_F_S_APPL_IO 8 /* this stream is used read/written by an application */
376 378
379#define IVTV_F_S_PIO_PENDING 9 /* this stream has pending PIO */
380#define IVTV_F_S_PIO_HAS_VBI 1 /* the current PIO request also requests VBI data */
381
377/* per-ivtv, i_flags */ 382/* per-ivtv, i_flags */
378#define IVTV_F_I_DMA 0 /* DMA in progress */ 383#define IVTV_F_I_DMA 0 /* DMA in progress */
379#define IVTV_F_I_UDMA 1 /* UDMA in progress */ 384#define IVTV_F_I_UDMA 1 /* UDMA in progress */
@@ -390,8 +395,11 @@ struct ivtv_mailbox_data {
390#define IVTV_F_I_DECODING_YUV 12 /* this stream is YUV frame decoding */ 395#define IVTV_F_I_DECODING_YUV 12 /* this stream is YUV frame decoding */
391#define IVTV_F_I_ENC_PAUSED 13 /* the encoder is paused */ 396#define IVTV_F_I_ENC_PAUSED 13 /* the encoder is paused */
392#define IVTV_F_I_VALID_DEC_TIMINGS 14 /* last_dec_timing is valid */ 397#define IVTV_F_I_VALID_DEC_TIMINGS 14 /* last_dec_timing is valid */
393#define IVTV_F_I_WORK_HANDLER_VBI 15 /* there is work to be done for VBI */ 398#define IVTV_F_I_HAVE_WORK 15 /* Used in the interrupt handler: there is work to be done */
394#define IVTV_F_I_WORK_HANDLER_YUV 16 /* there is work to be done for YUV */ 399#define IVTV_F_I_WORK_HANDLER_VBI 16 /* there is work to be done for VBI */
400#define IVTV_F_I_WORK_HANDLER_YUV 17 /* there is work to be done for YUV */
401#define IVTV_F_I_WORK_HANDLER_PIO 18 /* there is work to be done for PIO */
402#define IVTV_F_I_PIO 19 /* PIO in progress */
395 403
396/* Event notifications */ 404/* Event notifications */
397#define IVTV_F_I_EV_DEC_STOPPED 28 /* decoder stopped event */ 405#define IVTV_F_I_EV_DEC_STOPPED 28 /* decoder stopped event */
@@ -484,6 +492,7 @@ struct ivtv_stream {
484 492
485 /* Base Dev SG Array for cx23415/6 */ 493 /* Base Dev SG Array for cx23415/6 */
486 struct ivtv_SG_element *SGarray; 494 struct ivtv_SG_element *SGarray;
495 struct ivtv_SG_element *PIOarray;
487 dma_addr_t SG_handle; 496 dma_addr_t SG_handle;
488 int SG_length; 497 int SG_length;
489 498
@@ -706,6 +715,7 @@ struct ivtv {
706 atomic_t decoding; /* count number of active decoding streams */ 715 atomic_t decoding; /* count number of active decoding streams */
707 u32 irq_rr_idx; /* Round-robin stream index */ 716 u32 irq_rr_idx; /* Round-robin stream index */
708 int cur_dma_stream; /* index of stream doing DMA */ 717 int cur_dma_stream; /* index of stream doing DMA */
718 int cur_pio_stream; /* index of stream doing PIO */
709 u32 dma_data_req_offset; 719 u32 dma_data_req_offset;
710 u32 dma_data_req_size; 720 u32 dma_data_req_size;
711 int output_mode; /* NONE, MPG, YUV, UDMA YUV, passthrough */ 721 int output_mode; /* NONE, MPG, YUV, UDMA YUV, passthrough */
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c
index 8976487a65f3..555d5e6369c3 100644
--- a/drivers/media/video/ivtv/ivtv-fileops.c
+++ b/drivers/media/video/ivtv/ivtv-fileops.c
@@ -32,6 +32,8 @@
32#include "ivtv-yuv.h" 32#include "ivtv-yuv.h"
33#include "ivtv-controls.h" 33#include "ivtv-controls.h"
34#include "ivtv-ioctl.h" 34#include "ivtv-ioctl.h"
35#include "ivtv-cards.h"
36#include <media/saa7115.h>
35 37
36/* This function tries to claim the stream for a specific file descriptor. 38/* This function tries to claim the stream for a specific file descriptor.
37 If no one else is using this stream then the stream is claimed and 39 If no one else is using this stream then the stream is claimed and
@@ -786,6 +788,13 @@ int ivtv_v4l2_close(struct inode *inode, struct file *filp)
786 ivtv_call_i2c_clients(itv, VIDIOC_S_STD, &itv->std); 788 ivtv_call_i2c_clients(itv, VIDIOC_S_STD, &itv->std);
787 /* Select correct audio input (i.e. TV tuner or Line in) */ 789 /* Select correct audio input (i.e. TV tuner or Line in) */
788 ivtv_audio_set_io(itv); 790 ivtv_audio_set_io(itv);
791 if (itv->hw_flags & IVTV_HW_SAA711X)
792 {
793 struct v4l2_crystal_freq crystal_freq;
794 crystal_freq.freq = SAA7115_FREQ_32_11_MHZ;
795 crystal_freq.flags = 0;
796 ivtv_saa7115(itv, VIDIOC_INT_S_CRYSTAL_FREQ, &crystal_freq);
797 }
789 /* Done! Unmute and continue. */ 798 /* Done! Unmute and continue. */
790 ivtv_unmute(itv); 799 ivtv_unmute(itv);
791 ivtv_release_stream(s); 800 ivtv_release_stream(s);
@@ -872,6 +881,13 @@ int ivtv_v4l2_open(struct inode *inode, struct file *filp)
872 set_bit(IVTV_F_I_RADIO_USER, &itv->i_flags); 881 set_bit(IVTV_F_I_RADIO_USER, &itv->i_flags);
873 /* Select the correct audio input (i.e. radio tuner) */ 882 /* Select the correct audio input (i.e. radio tuner) */
874 ivtv_audio_set_io(itv); 883 ivtv_audio_set_io(itv);
884 if (itv->hw_flags & IVTV_HW_SAA711X)
885 {
886 struct v4l2_crystal_freq crystal_freq;
887 crystal_freq.freq = SAA7115_FREQ_32_11_MHZ;
888 crystal_freq.flags = SAA7115_FREQ_FL_APLL;
889 ivtv_saa7115(itv, VIDIOC_INT_S_CRYSTAL_FREQ, &crystal_freq);
890 }
875 /* Done! Unmute and continue. */ 891 /* Done! Unmute and continue. */
876 ivtv_unmute(itv); 892 ivtv_unmute(itv);
877 } 893 }
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index 1989ec1cb973..57af1762de1f 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -532,11 +532,6 @@ static int ivtv_try_or_set_fmt(struct ivtv *itv, int streamtype,
532 itv->yuv_info.yuv_forced_update = 1; 532 itv->yuv_info.yuv_forced_update = 1;
533 return 0; 533 return 0;
534 } 534 }
535 if (!ivtv_vapi(itv, CX2341X_OSD_SET_FRAMEBUFFER_WINDOW, 4,
536 r.width, r.height, r.left, r.top))
537 itv->main_rect = r;
538 else
539 return -EINVAL;
540 } 535 }
541 return 0; 536 return 0;
542 } 537 }
@@ -799,9 +794,39 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
799 return ivtv_get_fmt(itv, id->type, fmt); 794 return ivtv_get_fmt(itv, id->type, fmt);
800 } 795 }
801 796
797 case VIDIOC_CROPCAP: {
798 struct v4l2_cropcap *cropcap = arg;
799
800 if (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
801 cropcap->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
802 return -EINVAL;
803 cropcap->bounds.top = cropcap->bounds.left = 0;
804 cropcap->bounds.width = 720;
805 if (cropcap->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
806 cropcap->bounds.height = itv->is_50hz ? 576 : 480;
807 cropcap->pixelaspect.numerator = itv->is_50hz ? 59 : 10;
808 cropcap->pixelaspect.denominator = itv->is_50hz ? 54 : 11;
809 } else {
810 cropcap->bounds.height = itv->is_out_50hz ? 576 : 480;
811 cropcap->pixelaspect.numerator = itv->is_out_50hz ? 59 : 10;
812 cropcap->pixelaspect.denominator = itv->is_out_50hz ? 54 : 11;
813 }
814 cropcap->defrect = cropcap->bounds;
815 return 0;
816 }
817
802 case VIDIOC_S_CROP: { 818 case VIDIOC_S_CROP: {
803 struct v4l2_crop *crop = arg; 819 struct v4l2_crop *crop = arg;
804 820
821 if (crop->type == V4L2_BUF_TYPE_VIDEO_OUTPUT &&
822 (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) {
823 if (!ivtv_vapi(itv, CX2341X_OSD_SET_FRAMEBUFFER_WINDOW, 4,
824 crop->c.width, crop->c.height, crop->c.left, crop->c.top)) {
825 itv->main_rect = crop->c;
826 return 0;
827 }
828 return -EINVAL;
829 }
805 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 830 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
806 return -EINVAL; 831 return -EINVAL;
807 return itv->video_dec_func(itv, VIDIOC_S_CROP, arg); 832 return itv->video_dec_func(itv, VIDIOC_S_CROP, arg);
@@ -810,6 +835,11 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
810 case VIDIOC_G_CROP: { 835 case VIDIOC_G_CROP: {
811 struct v4l2_crop *crop = arg; 836 struct v4l2_crop *crop = arg;
812 837
838 if (crop->type == V4L2_BUF_TYPE_VIDEO_OUTPUT &&
839 (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) {
840 crop->c = itv->main_rect;
841 return 0;
842 }
813 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 843 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
814 return -EINVAL; 844 return -EINVAL;
815 return itv->video_dec_func(itv, VIDIOC_G_CROP, arg); 845 return itv->video_dec_func(itv, VIDIOC_G_CROP, arg);
@@ -977,7 +1007,7 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
977 if (itv->hw_flags & IVTV_HW_CX25840) { 1007 if (itv->hw_flags & IVTV_HW_CX25840) {
978 itv->vbi.sliced_decoder_line_size = itv->is_60hz ? 272 : 284; 1008 itv->vbi.sliced_decoder_line_size = itv->is_60hz ? 272 : 284;
979 } 1009 }
980 IVTV_DEBUG_INFO("Switching standard to %llx.\n", itv->std); 1010 IVTV_DEBUG_INFO("Switching standard to %llx.\n", (unsigned long long)itv->std);
981 1011
982 /* Tuner */ 1012 /* Tuner */
983 ivtv_call_i2c_clients(itv, VIDIOC_S_STD, &itv->std); 1013 ivtv_call_i2c_clients(itv, VIDIOC_S_STD, &itv->std);
@@ -1207,7 +1237,7 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
1207 (s->buffers - s->q_free.buffers) * 100 / s->buffers, 1237 (s->buffers - s->q_free.buffers) * 100 / s->buffers,
1208 (s->buffers * s->buf_size) / 1024, s->buffers); 1238 (s->buffers * s->buf_size) / 1024, s->buffers);
1209 } 1239 }
1210 IVTV_INFO("Read MPEG/VBI: %lld/%lld bytes\n", itv->mpg_data_received, itv->vbi_data_inserted); 1240 IVTV_INFO("Read MPEG/VBI: %lld/%lld bytes\n", (long long)itv->mpg_data_received, (long long)itv->vbi_data_inserted);
1211 IVTV_INFO("================== END STATUS CARD #%d ==================\n", itv->num); 1241 IVTV_INFO("================== END STATUS CARD #%d ==================\n", itv->num);
1212 break; 1242 break;
1213 } 1243 }
@@ -1455,6 +1485,7 @@ static int ivtv_v4l2_do_ioctl(struct inode *inode, struct file *filp,
1455 case VIDIOC_S_FMT: 1485 case VIDIOC_S_FMT:
1456 case VIDIOC_TRY_FMT: 1486 case VIDIOC_TRY_FMT:
1457 case VIDIOC_ENUM_FMT: 1487 case VIDIOC_ENUM_FMT:
1488 case VIDIOC_CROPCAP:
1458 case VIDIOC_G_CROP: 1489 case VIDIOC_G_CROP:
1459 case VIDIOC_S_CROP: 1490 case VIDIOC_S_CROP:
1460 case VIDIOC_G_FREQUENCY: 1491 case VIDIOC_G_FREQUENCY:
diff --git a/drivers/media/video/ivtv/ivtv-irq.c b/drivers/media/video/ivtv/ivtv-irq.c
index c3a047b381b3..ba98bf054f2e 100644
--- a/drivers/media/video/ivtv/ivtv-irq.c
+++ b/drivers/media/video/ivtv/ivtv-irq.c
@@ -31,8 +31,6 @@
31 31
32#define DMA_MAGIC_COOKIE 0x000001fe 32#define DMA_MAGIC_COOKIE 0x000001fe
33 33
34#define SLICED_VBI_PIO 1
35
36static void ivtv_dma_dec_start(struct ivtv_stream *s); 34static void ivtv_dma_dec_start(struct ivtv_stream *s);
37 35
38static const int ivtv_stream_map[] = { 36static const int ivtv_stream_map[] = {
@@ -42,12 +40,40 @@ static const int ivtv_stream_map[] = {
42 IVTV_ENC_STREAM_TYPE_VBI, 40 IVTV_ENC_STREAM_TYPE_VBI,
43}; 41};
44 42
45static inline int ivtv_use_pio(struct ivtv_stream *s) 43
44static void ivtv_pio_work_handler(struct ivtv *itv)
46{ 45{
47 struct ivtv *itv = s->itv; 46 struct ivtv_stream *s = &itv->streams[itv->cur_pio_stream];
47 struct ivtv_buffer *buf;
48 struct list_head *p;
49 int i = 0;
50
51 IVTV_DEBUG_DMA("ivtv_pio_work_handler\n");
52 if (itv->cur_pio_stream < 0 || itv->cur_pio_stream >= IVTV_MAX_STREAMS ||
53 s->v4l2dev == NULL || !ivtv_use_pio(s)) {
54 itv->cur_pio_stream = -1;
55 /* trigger PIO complete user interrupt */
56 write_reg(IVTV_IRQ_ENC_PIO_COMPLETE, 0x44);
57 return;
58 }
59 IVTV_DEBUG_DMA("Process PIO %s\n", s->name);
60 buf = list_entry(s->q_dma.list.next, struct ivtv_buffer, list);
61 list_for_each(p, &s->q_dma.list) {
62 struct ivtv_buffer *buf = list_entry(p, struct ivtv_buffer, list);
63 u32 size = s->PIOarray[i].size & 0x3ffff;
48 64
49 return s->dma == PCI_DMA_NONE || 65 /* Copy the data from the card to the buffer */
50 (SLICED_VBI_PIO && s->type == IVTV_ENC_STREAM_TYPE_VBI && itv->vbi.sliced_in->service_set); 66 if (s->type == IVTV_DEC_STREAM_TYPE_VBI) {
67 memcpy_fromio(buf->buf, itv->dec_mem + s->PIOarray[i].src - IVTV_DECODER_OFFSET, size);
68 }
69 else {
70 memcpy_fromio(buf->buf, itv->enc_mem + s->PIOarray[i].src, size);
71 }
72 if (s->PIOarray[i].size & 0x80000000)
73 break;
74 i++;
75 }
76 write_reg(IVTV_IRQ_ENC_PIO_COMPLETE, 0x44);
51} 77}
52 78
53void ivtv_irq_work_handler(struct work_struct *work) 79void ivtv_irq_work_handler(struct work_struct *work)
@@ -56,8 +82,11 @@ void ivtv_irq_work_handler(struct work_struct *work)
56 82
57 DEFINE_WAIT(wait); 83 DEFINE_WAIT(wait);
58 84
85 if (test_and_clear_bit(IVTV_F_I_WORK_HANDLER_PIO, &itv->i_flags))
86 ivtv_pio_work_handler(itv);
87
59 if (test_and_clear_bit(IVTV_F_I_WORK_HANDLER_VBI, &itv->i_flags)) 88 if (test_and_clear_bit(IVTV_F_I_WORK_HANDLER_VBI, &itv->i_flags))
60 vbi_work_handler(itv); 89 ivtv_vbi_work_handler(itv);
61 90
62 if (test_and_clear_bit(IVTV_F_I_WORK_HANDLER_YUV, &itv->i_flags)) 91 if (test_and_clear_bit(IVTV_F_I_WORK_HANDLER_YUV, &itv->i_flags))
63 ivtv_yuv_work_handler(itv); 92 ivtv_yuv_work_handler(itv);
@@ -173,8 +202,7 @@ static int stream_enc_dma_append(struct ivtv_stream *s, u32 data[CX2341X_MBOX_MA
173 } 202 }
174 s->buffers_stolen = rc; 203 s->buffers_stolen = rc;
175 204
176 /* got the buffers, now fill in SGarray (DMA) or copy the data from the card 205 /* got the buffers, now fill in SGarray (DMA) */
177 to the buffers (PIO). */
178 buf = list_entry(s->q_predma.list.next, struct ivtv_buffer, list); 206 buf = list_entry(s->q_predma.list.next, struct ivtv_buffer, list);
179 memset(buf->buf, 0, 128); 207 memset(buf->buf, 0, 128);
180 list_for_each(p, &s->q_predma.list) { 208 list_for_each(p, &s->q_predma.list) {
@@ -182,21 +210,11 @@ static int stream_enc_dma_append(struct ivtv_stream *s, u32 data[CX2341X_MBOX_MA
182 210
183 if (skip_bufs-- > 0) 211 if (skip_bufs-- > 0)
184 continue; 212 continue;
185 if (!ivtv_use_pio(s)) { 213 s->SGarray[idx].dst = cpu_to_le32(buf->dma_handle);
186 s->SGarray[idx].dst = cpu_to_le32(buf->dma_handle); 214 s->SGarray[idx].src = cpu_to_le32(offset);
187 s->SGarray[idx].src = cpu_to_le32(offset); 215 s->SGarray[idx].size = cpu_to_le32(s->buf_size);
188 s->SGarray[idx].size = cpu_to_le32(s->buf_size);
189 }
190 buf->bytesused = (size < s->buf_size) ? size : s->buf_size; 216 buf->bytesused = (size < s->buf_size) ? size : s->buf_size;
191 217
192 /* If PIO, then copy the data from the card to the buffer */
193 if (s->type == IVTV_DEC_STREAM_TYPE_VBI) {
194 memcpy_fromio(buf->buf, itv->dec_mem + offset - IVTV_DECODER_OFFSET, buf->bytesused);
195 }
196 else if (ivtv_use_pio(s)) {
197 memcpy_fromio(buf->buf, itv->enc_mem + offset, buf->bytesused);
198 }
199
200 s->q_predma.bytesused += buf->bytesused; 218 s->q_predma.bytesused += buf->bytesused;
201 size -= buf->bytesused; 219 size -= buf->bytesused;
202 offset += s->buf_size; 220 offset += s->buf_size;
@@ -224,11 +242,6 @@ static void dma_post(struct ivtv_stream *s)
224 u32 *u32buf; 242 u32 *u32buf;
225 int x = 0; 243 int x = 0;
226 244
227 if (ivtv_use_pio(s)) {
228 if (s->q_predma.bytesused)
229 ivtv_queue_move(s, &s->q_predma, NULL, &s->q_dma, s->q_predma.bytesused);
230 s->SG_length = 0;
231 }
232 IVTV_DEBUG_DMA("%s %s completed (%x)\n", ivtv_use_pio(s) ? "PIO" : "DMA", 245 IVTV_DEBUG_DMA("%s %s completed (%x)\n", ivtv_use_pio(s) ? "PIO" : "DMA",
233 s->name, s->dma_offset); 246 s->name, s->dma_offset);
234 list_for_each(p, &s->q_dma.list) { 247 list_for_each(p, &s->q_dma.list) {
@@ -278,10 +291,14 @@ static void dma_post(struct ivtv_stream *s)
278 if (buf) 291 if (buf)
279 buf->bytesused += s->dma_last_offset; 292 buf->bytesused += s->dma_last_offset;
280 if (buf && s->type == IVTV_DEC_STREAM_TYPE_VBI) { 293 if (buf && s->type == IVTV_DEC_STREAM_TYPE_VBI) {
281 /* Parse and Groom VBI Data */ 294 list_for_each(p, &s->q_dma.list) {
282 s->q_dma.bytesused -= buf->bytesused; 295 buf = list_entry(p, struct ivtv_buffer, list);
283 ivtv_process_vbi_data(itv, buf, 0, s->type); 296
284 s->q_dma.bytesused += buf->bytesused; 297 /* Parse and Groom VBI Data */
298 s->q_dma.bytesused -= buf->bytesused;
299 ivtv_process_vbi_data(itv, buf, 0, s->type);
300 s->q_dma.bytesused += buf->bytesused;
301 }
285 if (s->id == -1) { 302 if (s->id == -1) {
286 ivtv_queue_move(s, &s->q_dma, NULL, &s->q_free, 0); 303 ivtv_queue_move(s, &s->q_dma, NULL, &s->q_free, 0);
287 return; 304 return;
@@ -351,10 +368,14 @@ static void ivtv_dma_enc_start(struct ivtv_stream *s)
351 struct ivtv_stream *s_vbi = &itv->streams[IVTV_ENC_STREAM_TYPE_VBI]; 368 struct ivtv_stream *s_vbi = &itv->streams[IVTV_ENC_STREAM_TYPE_VBI];
352 int i; 369 int i;
353 370
371 IVTV_DEBUG_DMA("start %s for %s\n", ivtv_use_dma(s) ? "DMA" : "PIO", s->name);
372
354 if (s->q_predma.bytesused) 373 if (s->q_predma.bytesused)
355 ivtv_queue_move(s, &s->q_predma, NULL, &s->q_dma, s->q_predma.bytesused); 374 ivtv_queue_move(s, &s->q_predma, NULL, &s->q_dma, s->q_predma.bytesused);
356 IVTV_DEBUG_DMA("start DMA for %s\n", s->name); 375
357 s->SGarray[s->SG_length - 1].size = cpu_to_le32(le32_to_cpu(s->SGarray[s->SG_length - 1].size) + 256); 376 if (ivtv_use_dma(s))
377 s->SGarray[s->SG_length - 1].size =
378 cpu_to_le32(le32_to_cpu(s->SGarray[s->SG_length - 1].size) + 256);
358 379
359 /* If this is an MPEG stream, and VBI data is also pending, then append the 380 /* If this is an MPEG stream, and VBI data is also pending, then append the
360 VBI DMA to the MPEG DMA and transfer both sets of data at once. 381 VBI DMA to the MPEG DMA and transfer both sets of data at once.
@@ -368,7 +389,8 @@ static void ivtv_dma_enc_start(struct ivtv_stream *s)
368 if (s->type == IVTV_ENC_STREAM_TYPE_MPG && s_vbi->SG_length && 389 if (s->type == IVTV_ENC_STREAM_TYPE_MPG && s_vbi->SG_length &&
369 s->SG_length + s_vbi->SG_length <= s->buffers) { 390 s->SG_length + s_vbi->SG_length <= s->buffers) {
370 ivtv_queue_move(s_vbi, &s_vbi->q_predma, NULL, &s_vbi->q_dma, s_vbi->q_predma.bytesused); 391 ivtv_queue_move(s_vbi, &s_vbi->q_predma, NULL, &s_vbi->q_dma, s_vbi->q_predma.bytesused);
371 s_vbi->SGarray[s_vbi->SG_length - 1].size = cpu_to_le32(le32_to_cpu(s_vbi->SGarray[s->SG_length - 1].size) + 256); 392 if (ivtv_use_dma(s_vbi))
393 s_vbi->SGarray[s_vbi->SG_length - 1].size = cpu_to_le32(le32_to_cpu(s_vbi->SGarray[s->SG_length - 1].size) + 256);
372 for (i = 0; i < s_vbi->SG_length; i++) { 394 for (i = 0; i < s_vbi->SG_length; i++) {
373 s->SGarray[s->SG_length++] = s_vbi->SGarray[i]; 395 s->SGarray[s->SG_length++] = s_vbi->SGarray[i];
374 } 396 }
@@ -381,14 +403,26 @@ static void ivtv_dma_enc_start(struct ivtv_stream *s)
381 /* Mark last buffer size for Interrupt flag */ 403 /* Mark last buffer size for Interrupt flag */
382 s->SGarray[s->SG_length - 1].size |= cpu_to_le32(0x80000000); 404 s->SGarray[s->SG_length - 1].size |= cpu_to_le32(0x80000000);
383 405
384 /* Sync Hardware SG List of buffers */ 406 if (ivtv_use_pio(s)) {
385 ivtv_stream_sync_for_device(s); 407 for (i = 0; i < s->SG_length; i++) {
386 write_reg(s->SG_handle, IVTV_REG_ENCDMAADDR); 408 s->PIOarray[i].src = le32_to_cpu(s->SGarray[i].src);
387 write_reg_sync(read_reg(IVTV_REG_DMAXFER) | 0x02, IVTV_REG_DMAXFER); 409 s->PIOarray[i].size = le32_to_cpu(s->SGarray[i].size);
388 set_bit(IVTV_F_I_DMA, &itv->i_flags); 410 }
389 itv->cur_dma_stream = s->type; 411 set_bit(IVTV_F_I_WORK_HANDLER_PIO, &itv->i_flags);
390 itv->dma_timer.expires = jiffies + HZ / 10; 412 set_bit(IVTV_F_I_HAVE_WORK, &itv->i_flags);
391 add_timer(&itv->dma_timer); 413 set_bit(IVTV_F_I_PIO, &itv->i_flags);
414 itv->cur_pio_stream = s->type;
415 }
416 else {
417 /* Sync Hardware SG List of buffers */
418 ivtv_stream_sync_for_device(s);
419 write_reg(s->SG_handle, IVTV_REG_ENCDMAADDR);
420 write_reg_sync(read_reg(IVTV_REG_DMAXFER) | 0x02, IVTV_REG_DMAXFER);
421 set_bit(IVTV_F_I_DMA, &itv->i_flags);
422 itv->cur_dma_stream = s->type;
423 itv->dma_timer.expires = jiffies + HZ / 10;
424 add_timer(&itv->dma_timer);
425 }
392} 426}
393 427
394static void ivtv_dma_dec_start(struct ivtv_stream *s) 428static void ivtv_dma_dec_start(struct ivtv_stream *s)
@@ -489,6 +523,40 @@ static void ivtv_irq_enc_dma_complete(struct ivtv *itv)
489 wake_up(&itv->dma_waitq); 523 wake_up(&itv->dma_waitq);
490} 524}
491 525
526static void ivtv_irq_enc_pio_complete(struct ivtv *itv)
527{
528 struct ivtv_stream *s;
529
530 if (itv->cur_pio_stream < 0 || itv->cur_pio_stream >= IVTV_MAX_STREAMS) {
531 itv->cur_pio_stream = -1;
532 return;
533 }
534 s = &itv->streams[itv->cur_pio_stream];
535 IVTV_DEBUG_IRQ("ENC PIO COMPLETE %s\n", s->name);
536 s->SG_length = 0;
537 clear_bit(IVTV_F_I_ENC_VBI, &itv->i_flags);
538 clear_bit(IVTV_F_I_PIO, &itv->i_flags);
539 itv->cur_pio_stream = -1;
540 dma_post(s);
541 if (s->type == IVTV_ENC_STREAM_TYPE_MPG)
542 ivtv_vapi(itv, CX2341X_ENC_SCHED_DMA_TO_HOST, 3, 0, 0, 0);
543 else if (s->type == IVTV_ENC_STREAM_TYPE_YUV)
544 ivtv_vapi(itv, CX2341X_ENC_SCHED_DMA_TO_HOST, 3, 0, 0, 1);
545 else if (s->type == IVTV_ENC_STREAM_TYPE_PCM)
546 ivtv_vapi(itv, CX2341X_ENC_SCHED_DMA_TO_HOST, 3, 0, 0, 2);
547 clear_bit(IVTV_F_I_PIO, &itv->i_flags);
548 if (test_and_clear_bit(IVTV_F_S_DMA_HAS_VBI, &s->s_flags)) {
549 u32 tmp;
550
551 s = &itv->streams[IVTV_ENC_STREAM_TYPE_VBI];
552 tmp = s->dma_offset;
553 s->dma_offset = itv->vbi.dma_offset;
554 dma_post(s);
555 s->dma_offset = tmp;
556 }
557 wake_up(&itv->dma_waitq);
558}
559
492static void ivtv_irq_dma_err(struct ivtv *itv) 560static void ivtv_irq_dma_err(struct ivtv *itv)
493{ 561{
494 u32 data[CX2341X_MBOX_MAX_DATA]; 562 u32 data[CX2341X_MBOX_MAX_DATA];
@@ -532,13 +600,7 @@ static void ivtv_irq_enc_start_cap(struct ivtv *itv)
532 clear_bit(IVTV_F_I_ENC_VBI, &itv->i_flags); 600 clear_bit(IVTV_F_I_ENC_VBI, &itv->i_flags);
533 s = &itv->streams[ivtv_stream_map[data[0]]]; 601 s = &itv->streams[ivtv_stream_map[data[0]]];
534 if (!stream_enc_dma_append(s, data)) { 602 if (!stream_enc_dma_append(s, data)) {
535 if (ivtv_use_pio(s)) { 603 set_bit(ivtv_use_pio(s) ? IVTV_F_S_PIO_PENDING : IVTV_F_S_DMA_PENDING, &s->s_flags);
536 dma_post(s);
537 ivtv_vapi(itv, CX2341X_ENC_SCHED_DMA_TO_HOST, 3, 0, 0, data[0]);
538 }
539 else {
540 set_bit(IVTV_F_S_DMA_PENDING, &s->s_flags);
541 }
542 } 604 }
543} 605}
544 606
@@ -551,15 +613,6 @@ static void ivtv_irq_enc_vbi_cap(struct ivtv *itv)
551 IVTV_DEBUG_IRQ("ENC START VBI CAP\n"); 613 IVTV_DEBUG_IRQ("ENC START VBI CAP\n");
552 s = &itv->streams[IVTV_ENC_STREAM_TYPE_VBI]; 614 s = &itv->streams[IVTV_ENC_STREAM_TYPE_VBI];
553 615
554 if (ivtv_use_pio(s)) {
555 if (stream_enc_dma_append(s, data))
556 return;
557 if (s->q_predma.bytesused)
558 ivtv_queue_move(s, &s->q_predma, NULL, &s->q_dma, s->q_predma.bytesused);
559 s->SG_length = 0;
560 dma_post(s);
561 return;
562 }
563 /* If more than two VBI buffers are pending, then 616 /* If more than two VBI buffers are pending, then
564 clear the old ones and start with this new one. 617 clear the old ones and start with this new one.
565 This can happen during transition stages when MPEG capturing is 618 This can happen during transition stages when MPEG capturing is
@@ -582,11 +635,11 @@ static void ivtv_irq_enc_vbi_cap(struct ivtv *itv)
582 if (!stream_enc_dma_append(s, data) && 635 if (!stream_enc_dma_append(s, data) &&
583 !test_bit(IVTV_F_S_STREAMING, &s_mpg->s_flags)) { 636 !test_bit(IVTV_F_S_STREAMING, &s_mpg->s_flags)) {
584 set_bit(IVTV_F_I_ENC_VBI, &itv->i_flags); 637 set_bit(IVTV_F_I_ENC_VBI, &itv->i_flags);
585 set_bit(IVTV_F_S_DMA_PENDING, &s->s_flags); 638 set_bit(ivtv_use_pio(s) ? IVTV_F_S_PIO_PENDING : IVTV_F_S_DMA_PENDING, &s->s_flags);
586 } 639 }
587} 640}
588 641
589static void ivtv_irq_dev_vbi_reinsert(struct ivtv *itv) 642static void ivtv_irq_dec_vbi_reinsert(struct ivtv *itv)
590{ 643{
591 u32 data[CX2341X_MBOX_MAX_DATA]; 644 u32 data[CX2341X_MBOX_MAX_DATA];
592 struct ivtv_stream *s = &itv->streams[IVTV_DEC_STREAM_TYPE_VBI]; 645 struct ivtv_stream *s = &itv->streams[IVTV_DEC_STREAM_TYPE_VBI];
@@ -594,7 +647,7 @@ static void ivtv_irq_dev_vbi_reinsert(struct ivtv *itv)
594 IVTV_DEBUG_IRQ("DEC VBI REINSERT\n"); 647 IVTV_DEBUG_IRQ("DEC VBI REINSERT\n");
595 if (test_bit(IVTV_F_S_CLAIMED, &s->s_flags) && 648 if (test_bit(IVTV_F_S_CLAIMED, &s->s_flags) &&
596 !stream_enc_dma_append(s, data)) { 649 !stream_enc_dma_append(s, data)) {
597 dma_post(s); 650 set_bit(IVTV_F_S_PIO_PENDING, &s->s_flags);
598 } 651 }
599} 652}
600 653
@@ -657,7 +710,6 @@ static void ivtv_irq_vsync(struct ivtv *itv)
657 } 710 }
658 if (frame != (itv->lastVsyncFrame & 1)) { 711 if (frame != (itv->lastVsyncFrame & 1)) {
659 struct ivtv_stream *s = ivtv_get_output_stream(itv); 712 struct ivtv_stream *s = ivtv_get_output_stream(itv);
660 int work = 0;
661 713
662 itv->lastVsyncFrame += 1; 714 itv->lastVsyncFrame += 1;
663 if (frame == 0) { 715 if (frame == 0) {
@@ -678,7 +730,7 @@ static void ivtv_irq_vsync(struct ivtv *itv)
678 /* Send VBI to saa7127 */ 730 /* Send VBI to saa7127 */
679 if (frame) { 731 if (frame) {
680 set_bit(IVTV_F_I_WORK_HANDLER_VBI, &itv->i_flags); 732 set_bit(IVTV_F_I_WORK_HANDLER_VBI, &itv->i_flags);
681 work = 1; 733 set_bit(IVTV_F_I_HAVE_WORK, &itv->i_flags);
682 } 734 }
683 735
684 /* Check if we need to update the yuv registers */ 736 /* Check if we need to update the yuv registers */
@@ -691,11 +743,9 @@ static void ivtv_irq_vsync(struct ivtv *itv)
691 itv->yuv_info.new_frame_info[last_dma_frame].update = 0; 743 itv->yuv_info.new_frame_info[last_dma_frame].update = 0;
692 itv->yuv_info.yuv_forced_update = 0; 744 itv->yuv_info.yuv_forced_update = 0;
693 set_bit(IVTV_F_I_WORK_HANDLER_YUV, &itv->i_flags); 745 set_bit(IVTV_F_I_WORK_HANDLER_YUV, &itv->i_flags);
694 work = 1; 746 set_bit(IVTV_F_I_HAVE_WORK, &itv->i_flags);
695 } 747 }
696 } 748 }
697 if (work)
698 queue_work(itv->irq_work_queues, &itv->irq_work_queue);
699 } 749 }
700} 750}
701 751
@@ -755,6 +805,10 @@ irqreturn_t ivtv_irq_handler(int irq, void *dev_id)
755 ivtv_irq_enc_dma_complete(itv); 805 ivtv_irq_enc_dma_complete(itv);
756 } 806 }
757 807
808 if (combo & IVTV_IRQ_ENC_PIO_COMPLETE) {
809 ivtv_irq_enc_pio_complete(itv);
810 }
811
758 if (combo & IVTV_IRQ_DMA_ERR) { 812 if (combo & IVTV_IRQ_DMA_ERR) {
759 ivtv_irq_dma_err(itv); 813 ivtv_irq_dma_err(itv);
760 } 814 }
@@ -768,7 +822,7 @@ irqreturn_t ivtv_irq_handler(int irq, void *dev_id)
768 } 822 }
769 823
770 if (combo & IVTV_IRQ_DEC_VBI_RE_INSERT) { 824 if (combo & IVTV_IRQ_DEC_VBI_RE_INSERT) {
771 ivtv_irq_dev_vbi_reinsert(itv); 825 ivtv_irq_dec_vbi_reinsert(itv);
772 } 826 }
773 827
774 if (combo & IVTV_IRQ_ENC_EOS) { 828 if (combo & IVTV_IRQ_ENC_EOS) {
@@ -813,6 +867,22 @@ irqreturn_t ivtv_irq_handler(int irq, void *dev_id)
813 } 867 }
814 } 868 }
815 869
870 if ((combo & IVTV_IRQ_DMA) && !test_bit(IVTV_F_I_PIO, &itv->i_flags)) {
871 for (i = 0; i < IVTV_MAX_STREAMS; i++) {
872 int idx = (i + itv->irq_rr_idx++) % IVTV_MAX_STREAMS;
873 struct ivtv_stream *s = &itv->streams[idx];
874
875 if (!test_and_clear_bit(IVTV_F_S_PIO_PENDING, &s->s_flags))
876 continue;
877 if (s->type == IVTV_DEC_STREAM_TYPE_VBI || s->type < IVTV_DEC_STREAM_TYPE_MPG)
878 ivtv_dma_enc_start(s);
879 break;
880 }
881 }
882
883 if (test_and_clear_bit(IVTV_F_I_HAVE_WORK, &itv->i_flags))
884 queue_work(itv->irq_work_queues, &itv->irq_work_queue);
885
816 spin_unlock(&itv->dma_reg_lock); 886 spin_unlock(&itv->dma_reg_lock);
817 887
818 /* If we've just handled a 'forced' vsync, it's safest to say it 888 /* If we've just handled a 'forced' vsync, it's safest to say it
diff --git a/drivers/media/video/ivtv/ivtv-queue.c b/drivers/media/video/ivtv/ivtv-queue.c
index ccfcef1ad91a..a04f9387f63d 100644
--- a/drivers/media/video/ivtv/ivtv-queue.c
+++ b/drivers/media/video/ivtv/ivtv-queue.c
@@ -195,14 +195,26 @@ int ivtv_stream_alloc(struct ivtv_stream *s)
195 s->dma != PCI_DMA_NONE ? "DMA " : "", 195 s->dma != PCI_DMA_NONE ? "DMA " : "",
196 s->name, s->buffers, s->buf_size, s->buffers * s->buf_size / 1024); 196 s->name, s->buffers, s->buf_size, s->buffers * s->buf_size / 1024);
197 197
198 /* Allocate DMA SG Arrays */ 198 if (ivtv_might_use_pio(s)) {
199 if (s->dma != PCI_DMA_NONE) { 199 s->PIOarray = (struct ivtv_SG_element *)kzalloc(SGsize, GFP_KERNEL);
200 s->SGarray = (struct ivtv_SG_element *)kzalloc(SGsize, GFP_KERNEL); 200 if (s->PIOarray == NULL) {
201 if (s->SGarray == NULL) { 201 IVTV_ERR("Could not allocate PIOarray for %s stream\n", s->name);
202 IVTV_ERR("Could not allocate SGarray for %s stream\n", s->name);
203 return -ENOMEM; 202 return -ENOMEM;
204 } 203 }
205 s->SG_length = 0; 204 }
205
206 /* Allocate DMA SG Arrays */
207 s->SGarray = (struct ivtv_SG_element *)kzalloc(SGsize, GFP_KERNEL);
208 if (s->SGarray == NULL) {
209 IVTV_ERR("Could not allocate SGarray for %s stream\n", s->name);
210 if (ivtv_might_use_pio(s)) {
211 kfree(s->PIOarray);
212 s->PIOarray = NULL;
213 }
214 return -ENOMEM;
215 }
216 s->SG_length = 0;
217 if (ivtv_might_use_dma(s)) {
206 s->SG_handle = pci_map_single(itv->dev, s->SGarray, SGsize, s->dma); 218 s->SG_handle = pci_map_single(itv->dev, s->SGarray, SGsize, s->dma);
207 ivtv_stream_sync_for_cpu(s); 219 ivtv_stream_sync_for_cpu(s);
208 } 220 }
@@ -219,7 +231,7 @@ int ivtv_stream_alloc(struct ivtv_stream *s)
219 break; 231 break;
220 } 232 }
221 INIT_LIST_HEAD(&buf->list); 233 INIT_LIST_HEAD(&buf->list);
222 if (s->dma != PCI_DMA_NONE) { 234 if (ivtv_might_use_dma(s)) {
223 buf->dma_handle = pci_map_single(s->itv->dev, 235 buf->dma_handle = pci_map_single(s->itv->dev,
224 buf->buf, s->buf_size + 256, s->dma); 236 buf->buf, s->buf_size + 256, s->dma);
225 ivtv_buf_sync_for_cpu(s, buf); 237 ivtv_buf_sync_for_cpu(s, buf);
@@ -242,7 +254,7 @@ void ivtv_stream_free(struct ivtv_stream *s)
242 254
243 /* empty q_free */ 255 /* empty q_free */
244 while ((buf = ivtv_dequeue(s, &s->q_free))) { 256 while ((buf = ivtv_dequeue(s, &s->q_free))) {
245 if (s->dma != PCI_DMA_NONE) 257 if (ivtv_might_use_dma(s))
246 pci_unmap_single(s->itv->dev, buf->dma_handle, 258 pci_unmap_single(s->itv->dev, buf->dma_handle,
247 s->buf_size + 256, s->dma); 259 s->buf_size + 256, s->dma);
248 kfree(buf->buf); 260 kfree(buf->buf);
@@ -256,6 +268,9 @@ void ivtv_stream_free(struct ivtv_stream *s)
256 sizeof(struct ivtv_SG_element) * s->buffers, PCI_DMA_TODEVICE); 268 sizeof(struct ivtv_SG_element) * s->buffers, PCI_DMA_TODEVICE);
257 s->SG_handle = IVTV_DMA_UNMAPPED; 269 s->SG_handle = IVTV_DMA_UNMAPPED;
258 } 270 }
271 kfree(s->SGarray);
272 kfree(s->PIOarray);
273 s->PIOarray = NULL;
259 s->SGarray = NULL; 274 s->SGarray = NULL;
260 s->SG_length = 0; 275 s->SG_length = 0;
261 } 276 }
diff --git a/drivers/media/video/ivtv/ivtv-queue.h b/drivers/media/video/ivtv/ivtv-queue.h
index 903edd4b4381..2ed8d548255d 100644
--- a/drivers/media/video/ivtv/ivtv-queue.h
+++ b/drivers/media/video/ivtv/ivtv-queue.h
@@ -20,18 +20,43 @@
20 */ 20 */
21 21
22#define IVTV_DMA_UNMAPPED ((u32) -1) 22#define IVTV_DMA_UNMAPPED ((u32) -1)
23#define SLICED_VBI_PIO 1
23 24
24/* ivtv_buffer utility functions */ 25/* ivtv_buffer utility functions */
26
27static inline int ivtv_might_use_pio(struct ivtv_stream *s)
28{
29 return s->dma == PCI_DMA_NONE || (SLICED_VBI_PIO && s->type == IVTV_ENC_STREAM_TYPE_VBI);
30}
31
32static inline int ivtv_use_pio(struct ivtv_stream *s)
33{
34 struct ivtv *itv = s->itv;
35
36 return s->dma == PCI_DMA_NONE ||
37 (SLICED_VBI_PIO && s->type == IVTV_ENC_STREAM_TYPE_VBI && itv->vbi.sliced_in->service_set);
38}
39
40static inline int ivtv_might_use_dma(struct ivtv_stream *s)
41{
42 return s->dma != PCI_DMA_NONE;
43}
44
45static inline int ivtv_use_dma(struct ivtv_stream *s)
46{
47 return !ivtv_use_pio(s);
48}
49
25static inline void ivtv_buf_sync_for_cpu(struct ivtv_stream *s, struct ivtv_buffer *buf) 50static inline void ivtv_buf_sync_for_cpu(struct ivtv_stream *s, struct ivtv_buffer *buf)
26{ 51{
27 if (s->dma != PCI_DMA_NONE) 52 if (ivtv_use_dma(s))
28 pci_dma_sync_single_for_cpu(s->itv->dev, buf->dma_handle, 53 pci_dma_sync_single_for_cpu(s->itv->dev, buf->dma_handle,
29 s->buf_size + 256, s->dma); 54 s->buf_size + 256, s->dma);
30} 55}
31 56
32static inline void ivtv_buf_sync_for_device(struct ivtv_stream *s, struct ivtv_buffer *buf) 57static inline void ivtv_buf_sync_for_device(struct ivtv_stream *s, struct ivtv_buffer *buf)
33{ 58{
34 if (s->dma != PCI_DMA_NONE) 59 if (ivtv_use_dma(s))
35 pci_dma_sync_single_for_device(s->itv->dev, buf->dma_handle, 60 pci_dma_sync_single_for_device(s->itv->dev, buf->dma_handle,
36 s->buf_size + 256, s->dma); 61 s->buf_size + 256, s->dma);
37} 62}
@@ -53,12 +78,14 @@ void ivtv_stream_free(struct ivtv_stream *s);
53 78
54static inline void ivtv_stream_sync_for_cpu(struct ivtv_stream *s) 79static inline void ivtv_stream_sync_for_cpu(struct ivtv_stream *s)
55{ 80{
56 pci_dma_sync_single_for_cpu(s->itv->dev, s->SG_handle, 81 if (ivtv_use_dma(s))
57 sizeof(struct ivtv_SG_element) * s->buffers, PCI_DMA_TODEVICE); 82 pci_dma_sync_single_for_cpu(s->itv->dev, s->SG_handle,
83 sizeof(struct ivtv_SG_element) * s->buffers, PCI_DMA_TODEVICE);
58} 84}
59 85
60static inline void ivtv_stream_sync_for_device(struct ivtv_stream *s) 86static inline void ivtv_stream_sync_for_device(struct ivtv_stream *s)
61{ 87{
62 pci_dma_sync_single_for_device(s->itv->dev, s->SG_handle, 88 if (ivtv_use_dma(s))
63 sizeof(struct ivtv_SG_element) * s->buffers, PCI_DMA_TODEVICE); 89 pci_dma_sync_single_for_device(s->itv->dev, s->SG_handle,
90 sizeof(struct ivtv_SG_element) * s->buffers, PCI_DMA_TODEVICE);
64} 91}
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c
index 01a41a844a30..6af88ae9295f 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -868,7 +868,7 @@ int ivtv_stop_v4l2_decode_stream(struct ivtv_stream *s, int flags, u64 pts)
868 if (!test_bit(IVTV_F_S_STREAMING, &s->s_flags)) 868 if (!test_bit(IVTV_F_S_STREAMING, &s->s_flags))
869 return 0; 869 return 0;
870 870
871 IVTV_DEBUG_INFO("Stop Decode at %llu, flags: %x\n", pts, flags); 871 IVTV_DEBUG_INFO("Stop Decode at %llu, flags: %x\n", (unsigned long long)pts, flags);
872 872
873 /* Stop Decoder */ 873 /* Stop Decoder */
874 if (!(flags & VIDEO_CMD_STOP_IMMEDIATELY) || pts) { 874 if (!(flags & VIDEO_CMD_STOP_IMMEDIATELY) || pts) {
diff --git a/drivers/media/video/ivtv/ivtv-vbi.c b/drivers/media/video/ivtv/ivtv-vbi.c
index 5efa5a867818..3ba46e07ea1f 100644
--- a/drivers/media/video/ivtv/ivtv-vbi.c
+++ b/drivers/media/video/ivtv/ivtv-vbi.c
@@ -450,7 +450,7 @@ void ivtv_disable_vbi(struct ivtv *itv)
450} 450}
451 451
452 452
453void vbi_work_handler(struct ivtv *itv) 453void ivtv_vbi_work_handler(struct ivtv *itv)
454{ 454{
455 struct v4l2_sliced_vbi_data data; 455 struct v4l2_sliced_vbi_data data;
456 456
diff --git a/drivers/media/video/ivtv/ivtv-vbi.h b/drivers/media/video/ivtv/ivtv-vbi.h
index cdaea697b3ec..ec211b49702c 100644
--- a/drivers/media/video/ivtv/ivtv-vbi.h
+++ b/drivers/media/video/ivtv/ivtv-vbi.h
@@ -23,4 +23,4 @@ void ivtv_process_vbi_data(struct ivtv *itv, struct ivtv_buffer *buf,
23int ivtv_used_line(struct ivtv *itv, int line, int field); 23int ivtv_used_line(struct ivtv *itv, int line, int field);
24void ivtv_disable_vbi(struct ivtv *itv); 24void ivtv_disable_vbi(struct ivtv *itv);
25void ivtv_set_vbi(unsigned long arg); 25void ivtv_set_vbi(unsigned long arg);
26void vbi_work_handler(struct ivtv *itv); 26void ivtv_vbi_work_handler(struct ivtv *itv);
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c
index 74839f98b7c4..c1a392e47170 100644
--- a/drivers/media/video/saa7111.c
+++ b/drivers/media/video/saa7111.c
@@ -75,10 +75,6 @@ struct saa7111 {
75 int norm; 75 int norm;
76 int input; 76 int input;
77 int enable; 77 int enable;
78 int bright;
79 int contrast;
80 int hue;
81 int sat;
82}; 78};
83 79
84#define I2C_SAA7111 0x48 80#define I2C_SAA7111 0x48
@@ -96,6 +92,17 @@ saa7111_write (struct i2c_client *client,
96 return i2c_smbus_write_byte_data(client, reg, value); 92 return i2c_smbus_write_byte_data(client, reg, value);
97} 93}
98 94
95static inline void
96saa7111_write_if_changed(struct i2c_client *client, u8 reg, u8 value)
97{
98 struct saa7111 *decoder = i2c_get_clientdata(client);
99
100 if (decoder->reg[reg] != value) {
101 decoder->reg[reg] = value;
102 i2c_smbus_write_byte_data(client, reg, value);
103 }
104}
105
99static int 106static int
100saa7111_write_block (struct i2c_client *client, 107saa7111_write_block (struct i2c_client *client,
101 const u8 *data, 108 const u8 *data,
@@ -439,28 +446,14 @@ saa7111_command (struct i2c_client *client,
439 { 446 {
440 struct video_picture *pic = arg; 447 struct video_picture *pic = arg;
441 448
442 if (decoder->bright != pic->brightness) { 449 /* We want 0 to 255 we get 0-65535 */
443 /* We want 0 to 255 we get 0-65535 */ 450 saa7111_write_if_changed(client, 0x0a, pic->brightness >> 8);
444 decoder->bright = pic->brightness; 451 /* We want 0 to 127 we get 0-65535 */
445 saa7111_write(client, 0x0a, decoder->bright >> 8); 452 saa7111_write(client, 0x0b, pic->contrast >> 9);
446 } 453 /* We want 0 to 127 we get 0-65535 */
447 if (decoder->contrast != pic->contrast) { 454 saa7111_write(client, 0x0c, pic->colour >> 9);
448 /* We want 0 to 127 we get 0-65535 */ 455 /* We want -128 to 127 we get 0-65535 */
449 decoder->contrast = pic->contrast; 456 saa7111_write(client, 0x0d, (pic->hue - 32768) >> 8);
450 saa7111_write(client, 0x0b,
451 decoder->contrast >> 9);
452 }
453 if (decoder->sat != pic->colour) {
454 /* We want 0 to 127 we get 0-65535 */
455 decoder->sat = pic->colour;
456 saa7111_write(client, 0x0c, decoder->sat >> 9);
457 }
458 if (decoder->hue != pic->hue) {
459 /* We want -128 to 127 we get 0-65535 */
460 decoder->hue = pic->hue;
461 saa7111_write(client, 0x0d,
462 (decoder->hue - 32768) >> 8);
463 }
464 } 457 }
465 break; 458 break;
466 459
@@ -524,10 +517,6 @@ saa7111_detect_client (struct i2c_adapter *adapter,
524 decoder->norm = VIDEO_MODE_NTSC; 517 decoder->norm = VIDEO_MODE_NTSC;
525 decoder->input = 0; 518 decoder->input = 0;
526 decoder->enable = 1; 519 decoder->enable = 1;
527 decoder->bright = 32768;
528 decoder->contrast = 32768;
529 decoder->hue = 32768;
530 decoder->sat = 32768;
531 i2c_set_clientdata(client, decoder); 520 i2c_set_clientdata(client, decoder);
532 521
533 i = i2c_attach_client(client); 522 i = i2c_attach_client(client);
diff --git a/drivers/media/video/usbvision/usbvision-core.c b/drivers/media/video/usbvision/usbvision-core.c
index 9118a6227ea6..7df071eb0a3b 100644
--- a/drivers/media/video/usbvision/usbvision-core.c
+++ b/drivers/media/video/usbvision/usbvision-core.c
@@ -1414,6 +1414,11 @@ static void usbvision_isocIrq(struct urb *urb)
1414 if (!USBVISION_IS_OPERATIONAL(usbvision)) 1414 if (!USBVISION_IS_OPERATIONAL(usbvision))
1415 return; 1415 return;
1416 1416
1417 /* any urb with wrong status is ignored without acknowledgement */
1418 if (urb->status == -ENOENT) {
1419 return;
1420 }
1421
1417 f = &usbvision->curFrame; 1422 f = &usbvision->curFrame;
1418 1423
1419 /* Manage streaming interruption */ 1424 /* Manage streaming interruption */
@@ -1436,18 +1441,21 @@ static void usbvision_isocIrq(struct urb *urb)
1436 if (usbvision->streaming == Stream_On) { 1441 if (usbvision->streaming == Stream_On) {
1437 1442
1438 /* If we collected enough data let's parse! */ 1443 /* If we collected enough data let's parse! */
1439 if (scratch_len(usbvision) > USBVISION_HEADER_LENGTH) { /* 12 == header_length */ 1444 if ((scratch_len(usbvision) > USBVISION_HEADER_LENGTH) &&
1440 /*If we don't have a frame we're current working on, complain */ 1445 (!list_empty(&(usbvision->inqueue))) ) {
1441 if(!list_empty(&(usbvision->inqueue))) { 1446 if (!(*f)) {
1442 if (!(*f)) { 1447 (*f) = list_entry(usbvision->inqueue.next,
1443 (*f) = list_entry(usbvision->inqueue.next,struct usbvision_frame, frame); 1448 struct usbvision_frame,
1444 } 1449 frame);
1445 usbvision_parse_data(usbvision);
1446 }
1447 else {
1448 PDEBUG(DBG_IRQ, "received data, but no one needs it");
1449 scratch_reset(usbvision);
1450 } 1450 }
1451 usbvision_parse_data(usbvision);
1452 }
1453 else {
1454 /*If we don't have a frame
1455 we're current working on, complain */
1456 PDEBUG(DBG_IRQ,
1457 "received data, but no one needs it");
1458 scratch_reset(usbvision);
1451 } 1459 }
1452 } 1460 }
1453 else { 1461 else {
@@ -1466,10 +1474,10 @@ static void usbvision_isocIrq(struct urb *urb)
1466 urb->dev = usbvision->dev; 1474 urb->dev = usbvision->dev;
1467 errCode = usb_submit_urb (urb, GFP_ATOMIC); 1475 errCode = usb_submit_urb (urb, GFP_ATOMIC);
1468 1476
1469 /* Disable this warning. By design of the driver. */ 1477 if(errCode) {
1470 // if(errCode) { 1478 err("%s: usb_submit_urb failed: error %d",
1471 // err("%s: usb_submit_urb failed: error %d", __FUNCTION__, errCode); 1479 __FUNCTION__, errCode);
1472 // } 1480 }
1473 1481
1474 return; 1482 return;
1475} 1483}
@@ -2394,7 +2402,7 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
2394{ 2402{
2395 struct usb_device *dev = usbvision->dev; 2403 struct usb_device *dev = usbvision->dev;
2396 int bufIdx, errCode, regValue; 2404 int bufIdx, errCode, regValue;
2397 const int sb_size = USBVISION_URB_FRAMES * USBVISION_MAX_ISOC_PACKET_SIZE; 2405 int sb_size;
2398 2406
2399 if (!USBVISION_IS_OPERATIONAL(usbvision)) 2407 if (!USBVISION_IS_OPERATIONAL(usbvision))
2400 return -EFAULT; 2408 return -EFAULT;
@@ -2408,11 +2416,14 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
2408 usbvision->last_error = errCode; 2416 usbvision->last_error = errCode;
2409 return -EBUSY; 2417 return -EBUSY;
2410 } 2418 }
2419 sb_size = USBVISION_URB_FRAMES * usbvision->isocPacketSize;
2411 2420
2412 regValue = (16 - usbvision_read_reg(usbvision, USBVISION_ALTER_REG)) & 0x0F; 2421 regValue = (16 - usbvision_read_reg(usbvision,
2422 USBVISION_ALTER_REG)) & 0x0F;
2413 2423
2414 usbvision->usb_bandwidth = regValue >> 1; 2424 usbvision->usb_bandwidth = regValue >> 1;
2415 PDEBUG(DBG_ISOC, "USB Bandwidth Usage: %dMbit/Sec", usbvision->usb_bandwidth); 2425 PDEBUG(DBG_ISOC, "USB Bandwidth Usage: %dMbit/Sec",
2426 usbvision->usb_bandwidth);
2416 2427
2417 2428
2418 2429
@@ -2428,7 +2439,11 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
2428 return -ENOMEM; 2439 return -ENOMEM;
2429 } 2440 }
2430 usbvision->sbuf[bufIdx].urb = urb; 2441 usbvision->sbuf[bufIdx].urb = urb;
2431 usbvision->sbuf[bufIdx].data = usb_buffer_alloc(usbvision->dev, sb_size, GFP_KERNEL,&urb->transfer_dma); 2442 usbvision->sbuf[bufIdx].data =
2443 usb_buffer_alloc(usbvision->dev,
2444 sb_size,
2445 GFP_KERNEL,
2446 &urb->transfer_dma);
2432 urb->dev = dev; 2447 urb->dev = dev;
2433 urb->context = usbvision; 2448 urb->context = usbvision;
2434 urb->pipe = usb_rcvisocpipe(dev, usbvision->video_endp); 2449 urb->pipe = usb_rcvisocpipe(dev, usbvision->video_endp);
@@ -2442,21 +2457,26 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
2442 for (j = k = 0; j < USBVISION_URB_FRAMES; j++, 2457 for (j = k = 0; j < USBVISION_URB_FRAMES; j++,
2443 k += usbvision->isocPacketSize) { 2458 k += usbvision->isocPacketSize) {
2444 urb->iso_frame_desc[j].offset = k; 2459 urb->iso_frame_desc[j].offset = k;
2445 urb->iso_frame_desc[j].length = usbvision->isocPacketSize; 2460 urb->iso_frame_desc[j].length =
2461 usbvision->isocPacketSize;
2446 } 2462 }
2447 } 2463 }
2448 2464
2449 2465
2450 /* Submit all URBs */ 2466 /* Submit all URBs */
2451 for (bufIdx = 0; bufIdx < USBVISION_NUMSBUF; bufIdx++) { 2467 for (bufIdx = 0; bufIdx < USBVISION_NUMSBUF; bufIdx++) {
2452 errCode = usb_submit_urb(usbvision->sbuf[bufIdx].urb, GFP_KERNEL); 2468 errCode = usb_submit_urb(usbvision->sbuf[bufIdx].urb,
2469 GFP_KERNEL);
2453 if (errCode) { 2470 if (errCode) {
2454 err("%s: usb_submit_urb(%d) failed: error %d", __FUNCTION__, bufIdx, errCode); 2471 err("%s: usb_submit_urb(%d) failed: error %d",
2472 __FUNCTION__, bufIdx, errCode);
2455 } 2473 }
2456 } 2474 }
2457 2475
2458 usbvision->streaming = Stream_Idle; 2476 usbvision->streaming = Stream_Idle;
2459 PDEBUG(DBG_ISOC, "%s: streaming=1 usbvision->video_endp=$%02x", __FUNCTION__, usbvision->video_endp); 2477 PDEBUG(DBG_ISOC, "%s: streaming=1 usbvision->video_endp=$%02x",
2478 __FUNCTION__,
2479 usbvision->video_endp);
2460 return 0; 2480 return 0;
2461} 2481}
2462 2482
@@ -2470,7 +2490,7 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
2470void usbvision_stop_isoc(struct usb_usbvision *usbvision) 2490void usbvision_stop_isoc(struct usb_usbvision *usbvision)
2471{ 2491{
2472 int bufIdx, errCode, regValue; 2492 int bufIdx, errCode, regValue;
2473 const int sb_size = USBVISION_URB_FRAMES * USBVISION_MAX_ISOC_PACKET_SIZE; 2493 int sb_size = USBVISION_URB_FRAMES * usbvision->isocPacketSize;
2474 2494
2475 if ((usbvision->streaming == Stream_Off) || (usbvision->dev == NULL)) 2495 if ((usbvision->streaming == Stream_Off) || (usbvision->dev == NULL))
2476 return; 2496 return;
@@ -2499,15 +2519,19 @@ void usbvision_stop_isoc(struct usb_usbvision *usbvision)
2499 errCode = usb_set_interface(usbvision->dev, usbvision->iface, 2519 errCode = usb_set_interface(usbvision->dev, usbvision->iface,
2500 usbvision->ifaceAlt); 2520 usbvision->ifaceAlt);
2501 if (errCode < 0) { 2521 if (errCode < 0) {
2502 err("%s: usb_set_interface() failed: error %d", __FUNCTION__, errCode); 2522 err("%s: usb_set_interface() failed: error %d",
2523 __FUNCTION__, errCode);
2503 usbvision->last_error = errCode; 2524 usbvision->last_error = errCode;
2504 } 2525 }
2505 regValue = (16 - usbvision_read_reg(usbvision, USBVISION_ALTER_REG)) & 0x0F; 2526 regValue = (16-usbvision_read_reg(usbvision, USBVISION_ALTER_REG)) & 0x0F;
2506 usbvision->isocPacketSize = (regValue == 0) ? 0 : (regValue * 64) - 1; 2527 usbvision->isocPacketSize =
2507 PDEBUG(DBG_ISOC, "ISO Packet Length:%d", usbvision->isocPacketSize); 2528 (regValue == 0) ? 0 : (regValue * 64) - 1;
2529 PDEBUG(DBG_ISOC, "ISO Packet Length:%d",
2530 usbvision->isocPacketSize);
2508 2531
2509 usbvision->usb_bandwidth = regValue >> 1; 2532 usbvision->usb_bandwidth = regValue >> 1;
2510 PDEBUG(DBG_ISOC, "USB Bandwidth Usage: %dMbit/Sec", usbvision->usb_bandwidth); 2533 PDEBUG(DBG_ISOC, "USB Bandwidth Usage: %dMbit/Sec",
2534 usbvision->usb_bandwidth);
2511 } 2535 }
2512} 2536}
2513 2537
diff --git a/drivers/media/video/usbvision/usbvision.h b/drivers/media/video/usbvision/usbvision.h
index bd6f6422ed54..c759d00d7014 100644
--- a/drivers/media/video/usbvision/usbvision.h
+++ b/drivers/media/video/usbvision/usbvision.h
@@ -146,7 +146,6 @@
146#define USBVISION_CLIPMASK_SIZE (MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT / 8) //bytesize of clipmask 146#define USBVISION_CLIPMASK_SIZE (MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT / 8) //bytesize of clipmask
147 147
148#define USBVISION_URB_FRAMES 32 148#define USBVISION_URB_FRAMES 32
149#define USBVISION_MAX_ISOC_PACKET_SIZE 959 // NT1003 Specs Document says 1023
150 149
151#define USBVISION_NUM_HEADERMARKER 20 150#define USBVISION_NUM_HEADERMARKER 20
152#define USBVISION_NUMFRAMES 3 /* Maximum number of frames an application can get */ 151#define USBVISION_NUMFRAMES 3 /* Maximum number of frames an application can get */
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index c1dfd03d559a..41bfb5dfe6ff 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -15,6 +15,7 @@
15#include <linux/mmc/host.h> 15#include <linux/mmc/host.h>
16#include <linux/mmc/card.h> 16#include <linux/mmc/card.h>
17#include <linux/mmc/mmc.h> 17#include <linux/mmc/mmc.h>
18#include <linux/mmc/sd.h>
18 19
19#include "core.h" 20#include "core.h"
20#include "sysfs.h" 21#include "sysfs.h"
@@ -192,6 +193,16 @@ static int mmc_read_switch(struct mmc_card *card)
192 int err; 193 int err;
193 u8 *status; 194 u8 *status;
194 195
196 if (card->scr.sda_vsn < SCR_SPEC_VER_1)
197 return MMC_ERR_NONE;
198
199 if (!(card->csd.cmdclass & CCC_SWITCH)) {
200 printk(KERN_WARNING "%s: card lacks mandatory switch "
201 "function, performance might suffer.\n",
202 mmc_hostname(card->host));
203 return MMC_ERR_NONE;
204 }
205
195 err = MMC_ERR_FAILED; 206 err = MMC_ERR_FAILED;
196 207
197 status = kmalloc(64, GFP_KERNEL); 208 status = kmalloc(64, GFP_KERNEL);
@@ -204,10 +215,9 @@ static int mmc_read_switch(struct mmc_card *card)
204 215
205 err = mmc_sd_switch(card, 0, 0, 1, status); 216 err = mmc_sd_switch(card, 0, 0, 1, status);
206 if (err != MMC_ERR_NONE) { 217 if (err != MMC_ERR_NONE) {
207 /* 218 printk(KERN_WARNING "%s: problem reading switch "
208 * Card not supporting high-speed will ignore the 219 "capabilities, performance might suffer.\n",
209 * command. 220 mmc_hostname(card->host));
210 */
211 err = MMC_ERR_NONE; 221 err = MMC_ERR_NONE;
212 goto out; 222 goto out;
213 } 223 }
@@ -229,6 +239,12 @@ static int mmc_switch_hs(struct mmc_card *card)
229 int err; 239 int err;
230 u8 *status; 240 u8 *status;
231 241
242 if (card->scr.sda_vsn < SCR_SPEC_VER_1)
243 return MMC_ERR_NONE;
244
245 if (!(card->csd.cmdclass & CCC_SWITCH))
246 return MMC_ERR_NONE;
247
232 if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED)) 248 if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED))
233 return MMC_ERR_NONE; 249 return MMC_ERR_NONE;
234 250
@@ -402,7 +418,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
402 /* 418 /*
403 * Switch to wider bus (if supported). 419 * Switch to wider bus (if supported).
404 */ 420 */
405 if ((host->caps && MMC_CAP_4_BIT_DATA) && 421 if ((host->caps & MMC_CAP_4_BIT_DATA) &&
406 (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) { 422 (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) {
407 err = mmc_app_set_bus_width(card, MMC_BUS_WIDTH_4); 423 err = mmc_app_set_bus_width(card, MMC_BUS_WIDTH_4);
408 if (err != MMC_ERR_NONE) 424 if (err != MMC_ERR_NONE)
diff --git a/drivers/mmc/host/at91_mci.c b/drivers/mmc/host/at91_mci.c
index e37943c314cb..5b00c194b628 100644
--- a/drivers/mmc/host/at91_mci.c
+++ b/drivers/mmc/host/at91_mci.c
@@ -417,7 +417,7 @@ static unsigned int at91_mci_send_command(struct at91mci_host *host, struct mmc_
417 blocks = 0; 417 blocks = 0;
418 } 418 }
419 419
420 if (cmd->opcode == MMC_STOP_TRANSMISSION) 420 if (host->flags & FL_SENT_STOP)
421 cmdr |= AT91_MCI_TRCMD_STOP; 421 cmdr |= AT91_MCI_TRCMD_STOP;
422 422
423 if (host->bus_mode == MMC_BUSMODE_OPENDRAIN) 423 if (host->bus_mode == MMC_BUSMODE_OPENDRAIN)
@@ -563,8 +563,7 @@ static void at91mci_completed_command(struct at91mci_host *host)
563 if (status & (AT91_MCI_RINDE | AT91_MCI_RDIRE | AT91_MCI_RCRCE | 563 if (status & (AT91_MCI_RINDE | AT91_MCI_RDIRE | AT91_MCI_RCRCE |
564 AT91_MCI_RENDE | AT91_MCI_RTOE | AT91_MCI_DCRCE | 564 AT91_MCI_RENDE | AT91_MCI_RTOE | AT91_MCI_DCRCE |
565 AT91_MCI_DTOE | AT91_MCI_OVRE | AT91_MCI_UNRE)) { 565 AT91_MCI_DTOE | AT91_MCI_OVRE | AT91_MCI_UNRE)) {
566 if ((status & AT91_MCI_RCRCE) && 566 if ((status & AT91_MCI_RCRCE) && !(mmc_resp_type(cmd) & MMC_RSP_CRC)) {
567 ((cmd->opcode == MMC_SEND_OP_COND) || (cmd->opcode == SD_APP_OP_COND))) {
568 cmd->error = MMC_ERR_NONE; 567 cmd->error = MMC_ERR_NONE;
569 } 568 }
570 else { 569 else {
diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c
index f967226d7505..52b63f11ddd6 100644
--- a/drivers/mmc/host/au1xmmc.c
+++ b/drivers/mmc/host/au1xmmc.c
@@ -76,8 +76,7 @@ const struct {
76#endif 76#endif
77}; 77};
78 78
79#define AU1XMMC_CONTROLLER_COUNT \ 79#define AU1XMMC_CONTROLLER_COUNT (ARRAY_SIZE(au1xmmc_card_table))
80 (sizeof(au1xmmc_card_table) / sizeof(au1xmmc_card_table[0]))
81 80
82/* This array stores pointers for the hosts (used by the IRQ handler) */ 81/* This array stores pointers for the hosts (used by the IRQ handler) */
83struct au1xmmc_host *au1xmmc_hosts[AU1XMMC_CONTROLLER_COUNT]; 82struct au1xmmc_host *au1xmmc_hosts[AU1XMMC_CONTROLLER_COUNT];
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index da7c3b0c533c..ce3ed67a878e 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -54,8 +54,8 @@
54 54
55#define DRV_MODULE_NAME "bnx2" 55#define DRV_MODULE_NAME "bnx2"
56#define PFX DRV_MODULE_NAME ": " 56#define PFX DRV_MODULE_NAME ": "
57#define DRV_MODULE_VERSION "1.5.10" 57#define DRV_MODULE_VERSION "1.5.11"
58#define DRV_MODULE_RELDATE "May 1, 2007" 58#define DRV_MODULE_RELDATE "June 4, 2007"
59 59
60#define RUN_AT(x) (jiffies + (x)) 60#define RUN_AT(x) (jiffies + (x))
61 61
@@ -1778,6 +1778,15 @@ bnx2_init_5709_context(struct bnx2 *bp)
1778 val = BNX2_CTX_COMMAND_ENABLED | BNX2_CTX_COMMAND_MEM_INIT | (1 << 12); 1778 val = BNX2_CTX_COMMAND_ENABLED | BNX2_CTX_COMMAND_MEM_INIT | (1 << 12);
1779 val |= (BCM_PAGE_BITS - 8) << 16; 1779 val |= (BCM_PAGE_BITS - 8) << 16;
1780 REG_WR(bp, BNX2_CTX_COMMAND, val); 1780 REG_WR(bp, BNX2_CTX_COMMAND, val);
1781 for (i = 0; i < 10; i++) {
1782 val = REG_RD(bp, BNX2_CTX_COMMAND);
1783 if (!(val & BNX2_CTX_COMMAND_MEM_INIT))
1784 break;
1785 udelay(2);
1786 }
1787 if (val & BNX2_CTX_COMMAND_MEM_INIT)
1788 return -EBUSY;
1789
1781 for (i = 0; i < bp->ctx_pages; i++) { 1790 for (i = 0; i < bp->ctx_pages; i++) {
1782 int j; 1791 int j;
1783 1792
@@ -1811,6 +1820,7 @@ bnx2_init_context(struct bnx2 *bp)
1811 vcid = 96; 1820 vcid = 96;
1812 while (vcid) { 1821 while (vcid) {
1813 u32 vcid_addr, pcid_addr, offset; 1822 u32 vcid_addr, pcid_addr, offset;
1823 int i;
1814 1824
1815 vcid--; 1825 vcid--;
1816 1826
@@ -1831,16 +1841,20 @@ bnx2_init_context(struct bnx2 *bp)
1831 pcid_addr = vcid_addr; 1841 pcid_addr = vcid_addr;
1832 } 1842 }
1833 1843
1834 REG_WR(bp, BNX2_CTX_VIRT_ADDR, 0x00); 1844 for (i = 0; i < (CTX_SIZE / PHY_CTX_SIZE); i++) {
1835 REG_WR(bp, BNX2_CTX_PAGE_TBL, pcid_addr); 1845 vcid_addr += (i << PHY_CTX_SHIFT);
1846 pcid_addr += (i << PHY_CTX_SHIFT);
1836 1847
1837 /* Zero out the context. */ 1848 REG_WR(bp, BNX2_CTX_VIRT_ADDR, 0x00);
1838 for (offset = 0; offset < PHY_CTX_SIZE; offset += 4) { 1849 REG_WR(bp, BNX2_CTX_PAGE_TBL, pcid_addr);
1839 CTX_WR(bp, 0x00, offset, 0); 1850
1840 } 1851 /* Zero out the context. */
1852 for (offset = 0; offset < PHY_CTX_SIZE; offset += 4)
1853 CTX_WR(bp, 0x00, offset, 0);
1841 1854
1842 REG_WR(bp, BNX2_CTX_VIRT_ADDR, vcid_addr); 1855 REG_WR(bp, BNX2_CTX_VIRT_ADDR, vcid_addr);
1843 REG_WR(bp, BNX2_CTX_PAGE_TBL, pcid_addr); 1856 REG_WR(bp, BNX2_CTX_PAGE_TBL, pcid_addr);
1857 }
1844 } 1858 }
1845} 1859}
1846 1860
@@ -3691,9 +3705,11 @@ bnx2_init_chip(struct bnx2 *bp)
3691 3705
3692 /* Initialize context mapping and zero out the quick contexts. The 3706 /* Initialize context mapping and zero out the quick contexts. The
3693 * context block must have already been enabled. */ 3707 * context block must have already been enabled. */
3694 if (CHIP_NUM(bp) == CHIP_NUM_5709) 3708 if (CHIP_NUM(bp) == CHIP_NUM_5709) {
3695 bnx2_init_5709_context(bp); 3709 rc = bnx2_init_5709_context(bp);
3696 else 3710 if (rc)
3711 return rc;
3712 } else
3697 bnx2_init_context(bp); 3713 bnx2_init_context(bp);
3698 3714
3699 if ((rc = bnx2_init_cpus(bp)) != 0) 3715 if ((rc = bnx2_init_cpus(bp)) != 0)
@@ -3772,7 +3788,10 @@ bnx2_init_chip(struct bnx2 *bp)
3772 REG_WR(bp, BNX2_HC_CMD_TICKS, 3788 REG_WR(bp, BNX2_HC_CMD_TICKS,
3773 (bp->cmd_ticks_int << 16) | bp->cmd_ticks); 3789 (bp->cmd_ticks_int << 16) | bp->cmd_ticks);
3774 3790
3775 REG_WR(bp, BNX2_HC_STATS_TICKS, bp->stats_ticks & 0xffff00); 3791 if (CHIP_NUM(bp) == CHIP_NUM_5708)
3792 REG_WR(bp, BNX2_HC_STATS_TICKS, 0);
3793 else
3794 REG_WR(bp, BNX2_HC_STATS_TICKS, bp->stats_ticks & 0xffff00);
3776 REG_WR(bp, BNX2_HC_STAT_COLLECT_TICKS, 0xbb8); /* 3ms */ 3795 REG_WR(bp, BNX2_HC_STAT_COLLECT_TICKS, 0xbb8); /* 3ms */
3777 3796
3778 if (CHIP_ID(bp) == CHIP_ID_5706_A1) 3797 if (CHIP_ID(bp) == CHIP_ID_5706_A1)
@@ -3799,6 +3818,11 @@ bnx2_init_chip(struct bnx2 *bp)
3799 /* Initialize the receive filter. */ 3818 /* Initialize the receive filter. */
3800 bnx2_set_rx_mode(bp->dev); 3819 bnx2_set_rx_mode(bp->dev);
3801 3820
3821 if (CHIP_NUM(bp) == CHIP_NUM_5709) {
3822 val = REG_RD(bp, BNX2_MISC_NEW_CORE_CTL);
3823 val |= BNX2_MISC_NEW_CORE_CTL_DMA_ENABLE;
3824 REG_WR(bp, BNX2_MISC_NEW_CORE_CTL, val);
3825 }
3802 rc = bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT2 | BNX2_DRV_MSG_CODE_RESET, 3826 rc = bnx2_fw_sync(bp, BNX2_DRV_MSG_DATA_WAIT2 | BNX2_DRV_MSG_CODE_RESET,
3803 0); 3827 0);
3804 3828
@@ -4620,6 +4644,11 @@ bnx2_timer(unsigned long data)
4620 4644
4621 bp->stats_blk->stat_FwRxDrop = REG_RD_IND(bp, BNX2_FW_RX_DROP_COUNT); 4645 bp->stats_blk->stat_FwRxDrop = REG_RD_IND(bp, BNX2_FW_RX_DROP_COUNT);
4622 4646
4647 /* workaround occasional corrupted counters */
4648 if (CHIP_NUM(bp) == CHIP_NUM_5708 && bp->stats_ticks)
4649 REG_WR(bp, BNX2_HC_COMMAND, bp->hc_cmd |
4650 BNX2_HC_COMMAND_STATS_NOW);
4651
4623 if (bp->phy_flags & PHY_SERDES_FLAG) { 4652 if (bp->phy_flags & PHY_SERDES_FLAG) {
4624 if (CHIP_NUM(bp) == CHIP_NUM_5706) 4653 if (CHIP_NUM(bp) == CHIP_NUM_5706)
4625 bnx2_5706_serdes_timer(bp); 4654 bnx2_5706_serdes_timer(bp);
@@ -5417,6 +5446,10 @@ bnx2_set_coalesce(struct net_device *dev, struct ethtool_coalesce *coal)
5417 0xff; 5446 0xff;
5418 5447
5419 bp->stats_ticks = coal->stats_block_coalesce_usecs; 5448 bp->stats_ticks = coal->stats_block_coalesce_usecs;
5449 if (CHIP_NUM(bp) == CHIP_NUM_5708) {
5450 if (bp->stats_ticks != 0 && bp->stats_ticks != USEC_PER_SEC)
5451 bp->stats_ticks = USEC_PER_SEC;
5452 }
5420 if (bp->stats_ticks > 0xffff00) bp->stats_ticks = 0xffff00; 5453 if (bp->stats_ticks > 0xffff00) bp->stats_ticks = 0xffff00;
5421 bp->stats_ticks &= 0xffff00; 5454 bp->stats_ticks &= 0xffff00;
5422 5455
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index bd6288d6350f..49a5de253b17 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -1373,6 +1373,7 @@ struct l2_fhdr {
1373#define BNX2_MISC_NEW_CORE_CTL 0x000008c8 1373#define BNX2_MISC_NEW_CORE_CTL 0x000008c8
1374#define BNX2_MISC_NEW_CORE_CTL_LINK_HOLDOFF_SUCCESS (1L<<0) 1374#define BNX2_MISC_NEW_CORE_CTL_LINK_HOLDOFF_SUCCESS (1L<<0)
1375#define BNX2_MISC_NEW_CORE_CTL_LINK_HOLDOFF_REQ (1L<<1) 1375#define BNX2_MISC_NEW_CORE_CTL_LINK_HOLDOFF_REQ (1L<<1)
1376#define BNX2_MISC_NEW_CORE_CTL_DMA_ENABLE (1L<<16)
1376#define BNX2_MISC_NEW_CORE_CTL_RESERVED_CMN (0x3fffL<<2) 1377#define BNX2_MISC_NEW_CORE_CTL_RESERVED_CMN (0x3fffL<<2)
1377#define BNX2_MISC_NEW_CORE_CTL_RESERVED_TC (0xffffL<<16) 1378#define BNX2_MISC_NEW_CORE_CTL_RESERVED_TC (0xffffL<<16)
1378 1379
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
index 00d1255e4c12..e88da72f8304 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/serial/amba-pl010.c
@@ -167,9 +167,9 @@ static void pl010_rx_chars(struct uart_amba_port *uap)
167 ignore_char: 167 ignore_char:
168 status = readb(uap->port.membase + UART01x_FR); 168 status = readb(uap->port.membase + UART01x_FR);
169 } 169 }
170 spin_unlock(&port->lock); 170 spin_unlock(&uap->port.lock);
171 tty_flip_buffer_push(tty); 171 tty_flip_buffer_push(tty);
172 spin_lock(&port->lock); 172 spin_lock(&uap->port.lock);
173} 173}
174 174
175static void pl010_tx_chars(struct uart_amba_port *uap) 175static void pl010_tx_chars(struct uart_amba_port *uap)
diff --git a/drivers/tc/zs.c b/drivers/tc/zs.c
index 3524e3fc08b9..61de78a9f6ee 100644
--- a/drivers/tc/zs.c
+++ b/drivers/tc/zs.c
@@ -2182,7 +2182,7 @@ struct dec_serial_hook zs_kgdbhook = {
2182 .init_info = kgdbhook_init_info, 2182 .init_info = kgdbhook_init_info,
2183 .rx_char = kgdbhook_rx_char, 2183 .rx_char = kgdbhook_rx_char,
2184 .cflags = B38400 | CS8 | CLOCAL, 2184 .cflags = B38400 | CS8 | CLOCAL,
2185} 2185};
2186 2186
2187void __init zs_kgdb_hook(int tty_num) 2187void __init zs_kgdb_hook(int tty_num)
2188{ 2188{
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index 30b7bfbc985a..8bcf7fe1dd80 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -476,8 +476,6 @@ static int cxacru_start_wait_urb(struct urb *urb, struct completion *done,
476 add_timer(&timer); 476 add_timer(&timer);
477 wait_for_completion(done); 477 wait_for_completion(done);
478 status = urb->status; 478 status = urb->status;
479 if (status == -ECONNRESET)
480 status = -ETIMEDOUT;
481 del_timer_sync(&timer); 479 del_timer_sync(&timer);
482 480
483 if (actual_length) 481 if (actual_length)
@@ -629,10 +627,22 @@ static int cxacru_card_status(struct cxacru_data *instance)
629 return 0; 627 return 0;
630} 628}
631 629
630static void cxacru_remove_device_files(struct usbatm_data *usbatm_instance,
631 struct atm_dev *atm_dev)
632{
633 struct usb_interface *intf = usbatm_instance->usb_intf;
634
635 #define CXACRU_DEVICE_REMOVE_FILE(_name) \
636 device_remove_file(&intf->dev, &dev_attr_##_name);
637 CXACRU_ALL_FILES(REMOVE);
638 #undef CXACRU_DEVICE_REMOVE_FILE
639}
640
632static int cxacru_atm_start(struct usbatm_data *usbatm_instance, 641static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
633 struct atm_dev *atm_dev) 642 struct atm_dev *atm_dev)
634{ 643{
635 struct cxacru_data *instance = usbatm_instance->driver_data; 644 struct cxacru_data *instance = usbatm_instance->driver_data;
645 struct usb_interface *intf = usbatm_instance->usb_intf;
636 /* 646 /*
637 struct atm_dev *atm_dev = usbatm_instance->atm_dev; 647 struct atm_dev *atm_dev = usbatm_instance->atm_dev;
638 */ 648 */
@@ -649,14 +659,18 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
649 return ret; 659 return ret;
650 } 660 }
651 661
662 #define CXACRU_DEVICE_CREATE_FILE(_name) \
663 ret = device_create_file(&intf->dev, &dev_attr_##_name); \
664 if (unlikely(ret)) \
665 goto fail_sysfs;
666 CXACRU_ALL_FILES(CREATE);
667 #undef CXACRU_DEVICE_CREATE_FILE
668
652 /* start ADSL */ 669 /* start ADSL */
653 mutex_lock(&instance->adsl_state_serialize); 670 mutex_lock(&instance->adsl_state_serialize);
654 ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, NULL, 0); 671 ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, NULL, 0);
655 if (ret < 0) { 672 if (ret < 0)
656 atm_err(usbatm_instance, "cxacru_atm_start: CHIP_ADSL_LINE_START returned %d\n", ret); 673 atm_err(usbatm_instance, "cxacru_atm_start: CHIP_ADSL_LINE_START returned %d\n", ret);
657 mutex_unlock(&instance->adsl_state_serialize);
658 return ret;
659 }
660 674
661 /* Start status polling */ 675 /* Start status polling */
662 mutex_lock(&instance->poll_state_serialize); 676 mutex_lock(&instance->poll_state_serialize);
@@ -680,6 +694,11 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
680 if (start_polling) 694 if (start_polling)
681 cxacru_poll_status(&instance->poll_work.work); 695 cxacru_poll_status(&instance->poll_work.work);
682 return 0; 696 return 0;
697
698fail_sysfs:
699 usb_err(usbatm_instance, "cxacru_atm_start: device_create_file failed (%d)\n", ret);
700 cxacru_remove_device_files(usbatm_instance, atm_dev);
701 return ret;
683} 702}
684 703
685static void cxacru_poll_status(struct work_struct *work) 704static void cxacru_poll_status(struct work_struct *work)
@@ -1065,13 +1084,6 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
1065 goto fail; 1084 goto fail;
1066 } 1085 }
1067 1086
1068 #define CXACRU_DEVICE_CREATE_FILE(_name) \
1069 ret = device_create_file(&intf->dev, &dev_attr_##_name); \
1070 if (unlikely(ret)) \
1071 goto fail_sysfs;
1072 CXACRU_ALL_FILES(CREATE);
1073 #undef CXACRU_DEVICE_CREATE_FILE
1074
1075 usb_fill_int_urb(instance->rcv_urb, 1087 usb_fill_int_urb(instance->rcv_urb,
1076 usb_dev, usb_rcvintpipe(usb_dev, CXACRU_EP_CMD), 1088 usb_dev, usb_rcvintpipe(usb_dev, CXACRU_EP_CMD),
1077 instance->rcv_buf, PAGE_SIZE, 1089 instance->rcv_buf, PAGE_SIZE,
@@ -1092,14 +1104,6 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
1092 1104
1093 return 0; 1105 return 0;
1094 1106
1095 fail_sysfs:
1096 dbg("cxacru_bind: device_create_file failed (%d)\n", ret);
1097
1098 #define CXACRU_DEVICE_REMOVE_FILE(_name) \
1099 device_remove_file(&intf->dev, &dev_attr_##_name);
1100 CXACRU_ALL_FILES(REMOVE);
1101 #undef CXACRU_DEVICE_REVOVE_FILE
1102
1103 fail: 1107 fail:
1104 free_page((unsigned long) instance->snd_buf); 1108 free_page((unsigned long) instance->snd_buf);
1105 free_page((unsigned long) instance->rcv_buf); 1109 free_page((unsigned long) instance->rcv_buf);
@@ -1146,11 +1150,6 @@ static void cxacru_unbind(struct usbatm_data *usbatm_instance,
1146 free_page((unsigned long) instance->snd_buf); 1150 free_page((unsigned long) instance->snd_buf);
1147 free_page((unsigned long) instance->rcv_buf); 1151 free_page((unsigned long) instance->rcv_buf);
1148 1152
1149 #define CXACRU_DEVICE_REMOVE_FILE(_name) \
1150 device_remove_file(&intf->dev, &dev_attr_##_name);
1151 CXACRU_ALL_FILES(REMOVE);
1152 #undef CXACRU_DEVICE_REVOVE_FILE
1153
1154 kfree(instance); 1153 kfree(instance);
1155 1154
1156 usbatm_instance->driver_data = NULL; 1155 usbatm_instance->driver_data = NULL;
@@ -1231,6 +1230,7 @@ static struct usbatm_driver cxacru_driver = {
1231 .heavy_init = cxacru_heavy_init, 1230 .heavy_init = cxacru_heavy_init,
1232 .unbind = cxacru_unbind, 1231 .unbind = cxacru_unbind,
1233 .atm_start = cxacru_atm_start, 1232 .atm_start = cxacru_atm_start,
1233 .atm_stop = cxacru_remove_device_files,
1234 .bulk_in = CXACRU_EP_DATA, 1234 .bulk_in = CXACRU_EP_DATA,
1235 .bulk_out = CXACRU_EP_DATA, 1235 .bulk_out = CXACRU_EP_DATA,
1236 .rx_padding = 3, 1236 .rx_padding = 3,
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index 7b1edfe46b28..6778f9af7943 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -347,10 +347,8 @@ static int handle_bidir (struct usblp *usblp)
347 if (usblp->bidir && usblp->used && !usblp->sleeping) { 347 if (usblp->bidir && usblp->used && !usblp->sleeping) {
348 usblp->readcount = 0; 348 usblp->readcount = 0;
349 usblp->readurb->dev = usblp->dev; 349 usblp->readurb->dev = usblp->dev;
350 if (usb_submit_urb(usblp->readurb, GFP_KERNEL) < 0) { 350 if (usb_submit_urb(usblp->readurb, GFP_KERNEL) < 0)
351 usblp->used = 0;
352 return -EIO; 351 return -EIO;
353 }
354 } 352 }
355 353
356 return 0; 354 return 0;
@@ -412,6 +410,7 @@ static int usblp_open(struct inode *inode, struct file *file)
412 usblp->readurb->status = 0; 410 usblp->readurb->status = 0;
413 411
414 if (handle_bidir(usblp) < 0) { 412 if (handle_bidir(usblp) < 0) {
413 usblp->used = 0;
415 file->private_data = NULL; 414 file->private_data = NULL;
416 retval = -EIO; 415 retval = -EIO;
417 } 416 }
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index f493fb1eaa27..346fc030c929 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -40,21 +40,25 @@ config USB_DEVICEFS
40config USB_DEVICE_CLASS 40config USB_DEVICE_CLASS
41 bool "USB device class-devices (DEPRECATED)" 41 bool "USB device class-devices (DEPRECATED)"
42 depends on USB 42 depends on USB
43 default n 43 default y
44 ---help--- 44 ---help---
45 Userspace access to USB devices is granted by device-nodes exported 45 Userspace access to USB devices is granted by device-nodes exported
46 directly from the usbdev in sysfs. Old versions of the driver 46 directly from the usbdev in sysfs. Old versions of the driver
47 core and udev needed additional class devices to export device nodes. 47 core and udev needed additional class devices to export device nodes.
48 48
49 These additional devices are difficult to handle in userspace, if 49 These additional devices are difficult to handle in userspace, if
50 information about USB interfaces must be available. One device contains 50 information about USB interfaces must be available. One device
51 the device node, the other device contains the interface data. Both 51 contains the device node, the other device contains the interface
52 devices are at the same level in sysfs (siblings) and one can't access 52 data. Both devices are at the same level in sysfs (siblings) and one
53 the other. The device node created directly by the usbdev is the parent 53 can't access the other. The device node created directly by the
54 device of the interface and therefore easily accessible from the interface 54 usb device is the parent device of the interface and therefore
55 event. 55 easily accessible from the interface event.
56 56
57 This option provides backward compatibility if needed. 57 This option provides backward compatibility for libusb device
58 nodes (lsusb) when usbfs is not used, and the following udev rule
59 doesn't exist:
60 SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", \
61 NAME="bus/usb/$env{BUSNUM}/$env{DEVNUM}", MODE="0644"
58 62
59config USB_DYNAMIC_MINORS 63config USB_DYNAMIC_MINORS
60 bool "Dynamic USB minor allocation (EXPERIMENTAL)" 64 bool "Dynamic USB minor allocation (EXPERIMENTAL)"
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 2d4fd530e5e4..dd3482328ad2 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -1,4 +1,5 @@
1#include <linux/usb.h> 1#include <linux/usb.h>
2#include <linux/usb/ch9.h>
2#include <linux/module.h> 3#include <linux/module.h>
3#include <linux/init.h> 4#include <linux/init.h>
4#include <linux/slab.h> 5#include <linux/slab.h>
@@ -49,7 +50,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
49 unsigned char *buffer0 = buffer; 50 unsigned char *buffer0 = buffer;
50 struct usb_endpoint_descriptor *d; 51 struct usb_endpoint_descriptor *d;
51 struct usb_host_endpoint *endpoint; 52 struct usb_host_endpoint *endpoint;
52 int n, i; 53 int n, i, j;
53 54
54 d = (struct usb_endpoint_descriptor *) buffer; 55 d = (struct usb_endpoint_descriptor *) buffer;
55 buffer += d->bLength; 56 buffer += d->bLength;
@@ -84,6 +85,45 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
84 memcpy(&endpoint->desc, d, n); 85 memcpy(&endpoint->desc, d, n);
85 INIT_LIST_HEAD(&endpoint->urb_list); 86 INIT_LIST_HEAD(&endpoint->urb_list);
86 87
88 /* If the bInterval value is outside the legal range,
89 * set it to a default value: 32 ms */
90 i = 0; /* i = min, j = max, n = default */
91 j = 255;
92 if (usb_endpoint_xfer_int(d)) {
93 i = 1;
94 switch (to_usb_device(ddev)->speed) {
95 case USB_SPEED_HIGH:
96 n = 9; /* 32 ms = 2^(9-1) uframes */
97 j = 16;
98 break;
99 default: /* USB_SPEED_FULL or _LOW */
100 /* For low-speed, 10 ms is the official minimum.
101 * But some "overclocked" devices might want faster
102 * polling so we'll allow it. */
103 n = 32;
104 break;
105 }
106 } else if (usb_endpoint_xfer_isoc(d)) {
107 i = 1;
108 j = 16;
109 switch (to_usb_device(ddev)->speed) {
110 case USB_SPEED_HIGH:
111 n = 9; /* 32 ms = 2^(9-1) uframes */
112 break;
113 default: /* USB_SPEED_FULL */
114 n = 6; /* 32 ms = 2^(6-1) frames */
115 break;
116 }
117 }
118 if (d->bInterval < i || d->bInterval > j) {
119 dev_warn(ddev, "config %d interface %d altsetting %d "
120 "endpoint 0x%X has an invalid bInterval %d, "
121 "changing to %d\n",
122 cfgno, inum, asnum,
123 d->bEndpointAddress, d->bInterval, n);
124 endpoint->desc.bInterval = n;
125 }
126
87 /* Skip over any Class Specific or Vendor Specific descriptors; 127 /* Skip over any Class Specific or Vendor Specific descriptors;
88 * find the next endpoint or interface descriptor */ 128 * find the next endpoint or interface descriptor */
89 endpoint->extra = buffer; 129 endpoint->extra = buffer;
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index f28af06905a5..6042364402b8 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -132,7 +132,7 @@ ep_matches (
132 * where it's an output parameter representing the full speed limit. 132 * where it's an output parameter representing the full speed limit.
133 * the usb spec fixes high speed bulk maxpacket at 512 bytes. 133 * the usb spec fixes high speed bulk maxpacket at 512 bytes.
134 */ 134 */
135 max = 0x7ff & le16_to_cpup (&desc->wMaxPacketSize); 135 max = 0x7ff & le16_to_cpu(desc->wMaxPacketSize);
136 switch (type) { 136 switch (type) {
137 case USB_ENDPOINT_XFER_INT: 137 case USB_ENDPOINT_XFER_INT:
138 /* INT: limit 64 bytes full speed, 1024 high speed */ 138 /* INT: limit 64 bytes full speed, 1024 high speed */
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 188c74a95216..46d0e5252744 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -1369,12 +1369,12 @@ config_buf (struct dev_data *dev, u8 type, unsigned index)
1369 hs = !hs; 1369 hs = !hs;
1370 if (hs) { 1370 if (hs) {
1371 dev->req->buf = dev->hs_config; 1371 dev->req->buf = dev->hs_config;
1372 len = le16_to_cpup (&dev->hs_config->wTotalLength); 1372 len = le16_to_cpu(dev->hs_config->wTotalLength);
1373 } else 1373 } else
1374#endif 1374#endif
1375 { 1375 {
1376 dev->req->buf = dev->config; 1376 dev->req->buf = dev->config;
1377 len = le16_to_cpup (&dev->config->wTotalLength); 1377 len = le16_to_cpu(dev->config->wTotalLength);
1378 } 1378 }
1379 ((u8 *)dev->req->buf) [1] = type; 1379 ((u8 *)dev->req->buf) [1] = type;
1380 return len; 1380 return len;
@@ -1885,7 +1885,7 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1885 1885
1886 /* full or low speed config */ 1886 /* full or low speed config */
1887 dev->config = (void *) kbuf; 1887 dev->config = (void *) kbuf;
1888 total = le16_to_cpup (&dev->config->wTotalLength); 1888 total = le16_to_cpu(dev->config->wTotalLength);
1889 if (!is_valid_config (dev->config) || total >= length) 1889 if (!is_valid_config (dev->config) || total >= length)
1890 goto fail; 1890 goto fail;
1891 kbuf += total; 1891 kbuf += total;
@@ -1894,7 +1894,7 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1894 /* optional high speed config */ 1894 /* optional high speed config */
1895 if (kbuf [1] == USB_DT_CONFIG) { 1895 if (kbuf [1] == USB_DT_CONFIG) {
1896 dev->hs_config = (void *) kbuf; 1896 dev->hs_config = (void *) kbuf;
1897 total = le16_to_cpup (&dev->hs_config->wTotalLength); 1897 total = le16_to_cpu(dev->hs_config->wTotalLength);
1898 if (!is_valid_config (dev->hs_config) || total >= length) 1898 if (!is_valid_config (dev->hs_config) || total >= length)
1899 goto fail; 1899 goto fail;
1900 kbuf += total; 1900 kbuf += total;
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 52779c52b56d..d975ecf18e00 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -2440,9 +2440,9 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
2440 2440
2441 tmp = 0; 2441 tmp = 0;
2442 2442
2443#define w_value le16_to_cpup (&u.r.wValue) 2443#define w_value le16_to_cpu(u.r.wValue)
2444#define w_index le16_to_cpup (&u.r.wIndex) 2444#define w_index le16_to_cpu(u.r.wIndex)
2445#define w_length le16_to_cpup (&u.r.wLength) 2445#define w_length le16_to_cpu(u.r.wLength)
2446 2446
2447 /* ack the irq */ 2447 /* ack the irq */
2448 writel (1 << SETUP_PACKET_INTERRUPT, &dev->regs->irqstat0); 2448 writel (1 << SETUP_PACKET_INTERRUPT, &dev->regs->irqstat0);
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index b394e63894d2..c4975a6cf777 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -1651,9 +1651,9 @@ static void ep0_irq(struct omap_udc *udc, u16 irq_src)
1651 UDC_EP_NUM_REG = 0; 1651 UDC_EP_NUM_REG = 0;
1652 } while (UDC_IRQ_SRC_REG & UDC_SETUP); 1652 } while (UDC_IRQ_SRC_REG & UDC_SETUP);
1653 1653
1654#define w_value le16_to_cpup (&u.r.wValue) 1654#define w_value le16_to_cpu(u.r.wValue)
1655#define w_index le16_to_cpup (&u.r.wIndex) 1655#define w_index le16_to_cpu(u.r.wIndex)
1656#define w_length le16_to_cpup (&u.r.wLength) 1656#define w_length le16_to_cpu(u.r.wLength)
1657 1657
1658 /* Delegate almost all control requests to the gadget driver, 1658 /* Delegate almost all control requests to the gadget driver,
1659 * except for a handful of ch9 status/feature requests that 1659 * except for a handful of ch9 status/feature requests that
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index 6ec8cf1a3ccb..708657c89132 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -186,10 +186,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
186 DEBUG("query OID %08x value, len %d:\n", OID, buf_len); 186 DEBUG("query OID %08x value, len %d:\n", OID, buf_len);
187 for (i = 0; i < buf_len; i += 16) { 187 for (i = 0; i < buf_len; i += 16) {
188 DEBUG ("%03d: %08x %08x %08x %08x\n", i, 188 DEBUG ("%03d: %08x %08x %08x %08x\n", i,
189 le32_to_cpup((__le32 *)&buf[i]), 189 le32_to_cpu(get_unaligned((__le32 *)
190 le32_to_cpup((__le32 *)&buf[i + 4]), 190 &buf[i])),
191 le32_to_cpup((__le32 *)&buf[i + 8]), 191 le32_to_cpu(get_unaligned((__le32 *)
192 le32_to_cpup((__le32 *)&buf[i + 12])); 192 &buf[i + 4])),
193 le32_to_cpu(get_unaligned((__le32 *)
194 &buf[i + 8])),
195 le32_to_cpu(get_unaligned((__le32 *)
196 &buf[i + 12])));
193 } 197 }
194 } 198 }
195 199
@@ -665,7 +669,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
665 break; 669 break;
666 case OID_PNP_QUERY_POWER: 670 case OID_PNP_QUERY_POWER:
667 DEBUG("%s: OID_PNP_QUERY_POWER D%d\n", __FUNCTION__, 671 DEBUG("%s: OID_PNP_QUERY_POWER D%d\n", __FUNCTION__,
668 le32_to_cpup((__le32 *) buf) - 1); 672 le32_to_cpu(get_unaligned((__le32 *)buf)) - 1);
669 /* only suspend is a real power state, and 673 /* only suspend is a real power state, and
670 * it can't be entered by OID_PNP_SET_POWER... 674 * it can't be entered by OID_PNP_SET_POWER...
671 */ 675 */
@@ -704,10 +708,14 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len,
704 DEBUG("set OID %08x value, len %d:\n", OID, buf_len); 708 DEBUG("set OID %08x value, len %d:\n", OID, buf_len);
705 for (i = 0; i < buf_len; i += 16) { 709 for (i = 0; i < buf_len; i += 16) {
706 DEBUG ("%03d: %08x %08x %08x %08x\n", i, 710 DEBUG ("%03d: %08x %08x %08x %08x\n", i,
707 le32_to_cpup((__le32 *)&buf[i]), 711 le32_to_cpu(get_unaligned((__le32 *)
708 le32_to_cpup((__le32 *)&buf[i + 4]), 712 &buf[i])),
709 le32_to_cpup((__le32 *)&buf[i + 8]), 713 le32_to_cpu(get_unaligned((__le32 *)
710 le32_to_cpup((__le32 *)&buf[i + 12])); 714 &buf[i + 4])),
715 le32_to_cpu(get_unaligned((__le32 *)
716 &buf[i + 8])),
717 le32_to_cpu(get_unaligned((__le32 *)
718 &buf[i + 12])));
711 } 719 }
712 } 720 }
713 721
@@ -721,7 +729,8 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len,
721 * PROMISCUOUS, DIRECTED, 729 * PROMISCUOUS, DIRECTED,
722 * MULTICAST, ALL_MULTICAST, BROADCAST 730 * MULTICAST, ALL_MULTICAST, BROADCAST
723 */ 731 */
724 *params->filter = (u16) le32_to_cpup((__le32 *)buf); 732 *params->filter = (u16) le32_to_cpu(get_unaligned(
733 (__le32 *)buf));
725 DEBUG("%s: OID_GEN_CURRENT_PACKET_FILTER %08x\n", 734 DEBUG("%s: OID_GEN_CURRENT_PACKET_FILTER %08x\n",
726 __FUNCTION__, *params->filter); 735 __FUNCTION__, *params->filter);
727 736
@@ -771,7 +780,7 @@ update_linkstate:
771 * resuming, Windows forces a reset, and then SET_POWER D0. 780 * resuming, Windows forces a reset, and then SET_POWER D0.
772 * FIXME ... then things go batty; Windows wedges itself. 781 * FIXME ... then things go batty; Windows wedges itself.
773 */ 782 */
774 i = le32_to_cpup((__force __le32 *)buf); 783 i = le32_to_cpu(get_unaligned((__le32 *)buf));
775 DEBUG("%s: OID_PNP_SET_POWER D%d\n", __FUNCTION__, i - 1); 784 DEBUG("%s: OID_PNP_SET_POWER D%d\n", __FUNCTION__, i - 1);
776 switch (i) { 785 switch (i) {
777 case NdisDeviceStateD0: 786 case NdisDeviceStateD0:
@@ -1058,8 +1067,8 @@ int rndis_msg_parser (u8 configNr, u8 *buf)
1058 return -ENOMEM; 1067 return -ENOMEM;
1059 1068
1060 tmp = (__le32 *) buf; 1069 tmp = (__le32 *) buf;
1061 MsgType = le32_to_cpup(tmp++); 1070 MsgType = le32_to_cpu(get_unaligned(tmp++));
1062 MsgLength = le32_to_cpup(tmp++); 1071 MsgLength = le32_to_cpu(get_unaligned(tmp++));
1063 1072
1064 if (configNr >= RNDIS_MAX_CONFIGS) 1073 if (configNr >= RNDIS_MAX_CONFIGS)
1065 return -ENOTSUPP; 1074 return -ENOTSUPP;
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 216c9c9d4d6d..bb9cc595219e 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -417,6 +417,8 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
417 unsigned long flags; 417 unsigned long flags;
418 418
419 spin_lock_irqsave (&ohci->lock, flags); 419 spin_lock_irqsave (&ohci->lock, flags);
420 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))
421 goto done;
420 422
421 /* undocumented erratum seen on at least rev D */ 423 /* undocumented erratum seen on at least rev D */
422 if ((ohci->flags & OHCI_QUIRK_AMD756) 424 if ((ohci->flags & OHCI_QUIRK_AMD756)
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index d230ee72f9cd..54979c239c63 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1179,8 +1179,8 @@ UNUSUAL_DEV( 0x0a17, 0x006, 0x0000, 0xffff,
1179 US_SC_DEVICE, US_PR_DEVICE, NULL, 1179 US_SC_DEVICE, US_PR_DEVICE, NULL,
1180 US_FL_FIX_INQUIRY ), 1180 US_FL_FIX_INQUIRY ),
1181 1181
1182/* These are virtual windows driver CDs, which the zd1211rw driver automatically 1182/* These are virtual windows driver CDs, which the zd1211rw driver
1183 * converts into a WLAN devices. */ 1183 * automatically converts into WLAN devices. */
1184UNUSUAL_DEV( 0x0ace, 0x2011, 0x0101, 0x0101, 1184UNUSUAL_DEV( 0x0ace, 0x2011, 0x0101, 0x0101,
1185 "ZyXEL", 1185 "ZyXEL",
1186 "G-220F USB-WLAN Install", 1186 "G-220F USB-WLAN Install",
@@ -1193,6 +1193,14 @@ UNUSUAL_DEV( 0x0ace, 0x20ff, 0x0101, 0x0101,
1193 US_SC_DEVICE, US_PR_DEVICE, NULL, 1193 US_SC_DEVICE, US_PR_DEVICE, NULL,
1194 US_FL_IGNORE_DEVICE ), 1194 US_FL_IGNORE_DEVICE ),
1195 1195
1196/* SanDisk that has a second LUN for a driver ISO, reported by
1197 * Ben Collins <bcollins@ubuntu.com> */
1198UNUSUAL_DEV( 0x0781, 0x5406, 0x0000, 0xffff,
1199 "SanDisk",
1200 "U3 Cruzer Micro driver ISO",
1201 US_SC_DEVICE, US_PR_DEVICE, NULL,
1202 US_FL_SINGLE_LUN ),
1203
1196#ifdef CONFIG_USB_STORAGE_ISD200 1204#ifdef CONFIG_USB_STORAGE_ISD200
1197UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110, 1205UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110,
1198 "ATI", 1206 "ATI",
@@ -1271,6 +1279,15 @@ UNUSUAL_DEV( 0x0dd8, 0x1060, 0x0000, 0xffff,
1271 US_SC_DEVICE, US_PR_DEVICE, NULL, 1279 US_SC_DEVICE, US_PR_DEVICE, NULL,
1272 US_FL_FIX_INQUIRY ), 1280 US_FL_FIX_INQUIRY ),
1273 1281
1282/* Reported by Edward Chapman (taken from linux-usb mailing list)
1283 Netac OnlyDisk Mini U2CV2 512MB USB 2.0 Flash Drive */
1284UNUSUAL_DEV( 0x0dd8, 0xd202, 0x0000, 0x9999,
1285 "Netac",
1286 "USB Flash Disk",
1287 US_SC_DEVICE, US_PR_DEVICE, NULL,
1288 US_FL_IGNORE_RESIDUE ),
1289
1290
1274/* Patch by Stephan Walter <stephan.walter@epfl.ch> 1291/* Patch by Stephan Walter <stephan.walter@epfl.ch>
1275 * I don't know why, but it works... */ 1292 * I don't know why, but it works... */
1276UNUSUAL_DEV( 0x0dda, 0x0001, 0x0012, 0x0012, 1293UNUSUAL_DEV( 0x0dda, 0x0001, 0x0012, 0x0012,