aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pci/quirks.c4
-rw-r--r--drivers/scsi/ahci.c46
-rw-r--r--drivers/scsi/ata_piix.c15
-rw-r--r--drivers/scsi/libata-core.c33
-rw-r--r--drivers/scsi/libata-scsi.c46
-rw-r--r--drivers/scsi/libata.h2
-rw-r--r--drivers/scsi/pdc_adma.c26
-rw-r--r--drivers/scsi/sata_mv.c23
-rw-r--r--drivers/scsi/sata_nv.c3
-rw-r--r--drivers/scsi/sata_promise.c19
-rw-r--r--drivers/scsi/sata_qstor.c25
-rw-r--r--drivers/scsi/sata_sil.c7
-rw-r--r--drivers/scsi/sata_sil24.c33
-rw-r--r--drivers/scsi/sata_sis.c13
-rw-r--r--drivers/scsi/sata_svw.c3
-rw-r--r--drivers/scsi/sata_sx4.c13
-rw-r--r--drivers/scsi/sata_uli.c5
-rw-r--r--drivers/scsi/sata_via.c38
-rw-r--r--drivers/scsi/sata_vsc.c3
-rw-r--r--fs/nfs/inode.c2
-rw-r--r--include/linux/libata.h28
21 files changed, 221 insertions, 166 deletions
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index bbd9c2323d8c..5627ce1d2b32 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -356,7 +356,7 @@ static void piix4_mem_quirk(struct pci_dev *dev, const char *name, unsigned int
356/* 356/*
357 * PIIX4 ACPI: Two IO regions pointed to by longwords at 357 * PIIX4 ACPI: Two IO regions pointed to by longwords at
358 * 0x40 (64 bytes of ACPI registers) 358 * 0x40 (64 bytes of ACPI registers)
359 * 0x90 (32 bytes of SMB registers) 359 * 0x90 (16 bytes of SMB registers)
360 * and a few strange programmable PIIX4 device resources. 360 * and a few strange programmable PIIX4 device resources.
361 */ 361 */
362static void __devinit quirk_piix4_acpi(struct pci_dev *dev) 362static void __devinit quirk_piix4_acpi(struct pci_dev *dev)
@@ -366,7 +366,7 @@ static void __devinit quirk_piix4_acpi(struct pci_dev *dev)
366 pci_read_config_dword(dev, 0x40, &region); 366 pci_read_config_dword(dev, 0x40, &region);
367 quirk_io_region(dev, region, 64, PCI_BRIDGE_RESOURCES, "PIIX4 ACPI"); 367 quirk_io_region(dev, region, 64, PCI_BRIDGE_RESOURCES, "PIIX4 ACPI");
368 pci_read_config_dword(dev, 0x90, &region); 368 pci_read_config_dword(dev, 0x90, &region);
369 quirk_io_region(dev, region, 32, PCI_BRIDGE_RESOURCES+1, "PIIX4 SMB"); 369 quirk_io_region(dev, region, 16, PCI_BRIDGE_RESOURCES+1, "PIIX4 SMB");
370 370
371 /* Device resource A has enables for some of the other ones */ 371 /* Device resource A has enables for some of the other ones */
372 pci_read_config_dword(dev, 0x5c, &res_a); 372 pci_read_config_dword(dev, 0x5c, &res_a);
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
index 03829aedfd39..e2a5657d5fdb 100644
--- a/drivers/scsi/ahci.c
+++ b/drivers/scsi/ahci.c
@@ -41,6 +41,7 @@
41#include <linux/interrupt.h> 41#include <linux/interrupt.h>
42#include <linux/sched.h> 42#include <linux/sched.h>
43#include <linux/dma-mapping.h> 43#include <linux/dma-mapping.h>
44#include <linux/device.h>
44#include "scsi.h" 45#include "scsi.h"
45#include <scsi/scsi_host.h> 46#include <scsi/scsi_host.h>
46#include <linux/libata.h> 47#include <linux/libata.h>
@@ -600,7 +601,7 @@ static void ahci_eng_timeout(struct ata_port *ap)
600 * not being called from the SCSI EH. 601 * not being called from the SCSI EH.
601 */ 602 */
602 qc->scsidone = scsi_finish_command; 603 qc->scsidone = scsi_finish_command;
603 ata_qc_complete(qc, ATA_ERR); 604 ata_qc_complete(qc, AC_ERR_OTHER);
604 } 605 }
605 606
606 spin_unlock_irqrestore(&host_set->lock, flags); 607 spin_unlock_irqrestore(&host_set->lock, flags);
@@ -629,7 +630,7 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc)
629 if (status & PORT_IRQ_FATAL) { 630 if (status & PORT_IRQ_FATAL) {
630 ahci_intr_error(ap, status); 631 ahci_intr_error(ap, status);
631 if (qc) 632 if (qc)
632 ata_qc_complete(qc, ATA_ERR); 633 ata_qc_complete(qc, AC_ERR_OTHER);
633 } 634 }
634 635
635 return 1; 636 return 1;
@@ -674,10 +675,10 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *
674 if (!ahci_host_intr(ap, qc)) 675 if (!ahci_host_intr(ap, qc))
675 if (ata_ratelimit()) { 676 if (ata_ratelimit()) {
676 struct pci_dev *pdev = 677 struct pci_dev *pdev =
677 to_pci_dev(ap->host_set->dev); 678 to_pci_dev(ap->host_set->dev);
678 printk(KERN_WARNING 679 dev_printk(KERN_WARNING, &pdev->dev,
679 "ahci(%s): unhandled interrupt on port %u\n", 680 "unhandled interrupt on port %u\n",
680 pci_name(pdev), i); 681 i);
681 } 682 }
682 683
683 VPRINTK("port %u\n", i); 684 VPRINTK("port %u\n", i);
@@ -685,10 +686,9 @@ static irqreturn_t ahci_interrupt (int irq, void *dev_instance, struct pt_regs *
685 VPRINTK("port %u (no irq)\n", i); 686 VPRINTK("port %u (no irq)\n", i);
686 if (ata_ratelimit()) { 687 if (ata_ratelimit()) {
687 struct pci_dev *pdev = 688 struct pci_dev *pdev =
688 to_pci_dev(ap->host_set->dev); 689 to_pci_dev(ap->host_set->dev);
689 printk(KERN_WARNING 690 dev_printk(KERN_WARNING, &pdev->dev,
690 "ahci(%s): interrupt on disabled port %u\n", 691 "interrupt on disabled port %u\n", i);
691 pci_name(pdev), i);
692 } 692 }
693 } 693 }
694 694
@@ -760,8 +760,8 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent)
760 760
761 tmp = readl(mmio + HOST_CTL); 761 tmp = readl(mmio + HOST_CTL);
762 if (tmp & HOST_RESET) { 762 if (tmp & HOST_RESET) {
763 printk(KERN_ERR DRV_NAME "(%s): controller reset failed (0x%x)\n", 763 dev_printk(KERN_ERR, &pdev->dev,
764 pci_name(pdev), tmp); 764 "controller reset failed (0x%x)\n", tmp);
765 return -EIO; 765 return -EIO;
766 } 766 }
767 767
@@ -789,22 +789,22 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent)
789 if (rc) { 789 if (rc) {
790 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 790 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
791 if (rc) { 791 if (rc) {
792 printk(KERN_ERR DRV_NAME "(%s): 64-bit DMA enable failed\n", 792 dev_printk(KERN_ERR, &pdev->dev,
793 pci_name(pdev)); 793 "64-bit DMA enable failed\n");
794 return rc; 794 return rc;
795 } 795 }
796 } 796 }
797 } else { 797 } else {
798 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 798 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
799 if (rc) { 799 if (rc) {
800 printk(KERN_ERR DRV_NAME "(%s): 32-bit DMA enable failed\n", 800 dev_printk(KERN_ERR, &pdev->dev,
801 pci_name(pdev)); 801 "32-bit DMA enable failed\n");
802 return rc; 802 return rc;
803 } 803 }
804 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 804 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
805 if (rc) { 805 if (rc) {
806 printk(KERN_ERR DRV_NAME "(%s): 32-bit consistent DMA enable failed\n", 806 dev_printk(KERN_ERR, &pdev->dev,
807 pci_name(pdev)); 807 "32-bit consistent DMA enable failed\n");
808 return rc; 808 return rc;
809 } 809 }
810 } 810 }
@@ -907,10 +907,10 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent)
907 else 907 else
908 scc_s = "unknown"; 908 scc_s = "unknown";
909 909
910 printk(KERN_INFO DRV_NAME "(%s) AHCI %02x%02x.%02x%02x " 910 dev_printk(KERN_INFO, &pdev->dev,
911 "AHCI %02x%02x.%02x%02x "
911 "%u slots %u ports %s Gbps 0x%x impl %s mode\n" 912 "%u slots %u ports %s Gbps 0x%x impl %s mode\n"
912 , 913 ,
913 pci_name(pdev),
914 914
915 (vers >> 24) & 0xff, 915 (vers >> 24) & 0xff,
916 (vers >> 16) & 0xff, 916 (vers >> 16) & 0xff,
@@ -923,11 +923,11 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent)
923 impl, 923 impl,
924 scc_s); 924 scc_s);
925 925
926 printk(KERN_INFO DRV_NAME "(%s) flags: " 926 dev_printk(KERN_INFO, &pdev->dev,
927 "flags: "
927 "%s%s%s%s%s%s" 928 "%s%s%s%s%s%s"
928 "%s%s%s%s%s%s%s\n" 929 "%s%s%s%s%s%s%s\n"
929 , 930 ,
930 pci_name(pdev),
931 931
932 cap & (1 << 31) ? "64bit " : "", 932 cap & (1 << 31) ? "64bit " : "",
933 cap & (1 << 30) ? "ncq " : "", 933 cap & (1 << 30) ? "ncq " : "",
@@ -960,7 +960,7 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
960 VPRINTK("ENTER\n"); 960 VPRINTK("ENTER\n");
961 961
962 if (!printed_version++) 962 if (!printed_version++)
963 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 963 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
964 964
965 rc = pci_enable_device(pdev); 965 rc = pci_enable_device(pdev);
966 if (rc) 966 if (rc)
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c
index be021478f416..7f8aa1b552ce 100644
--- a/drivers/scsi/ata_piix.c
+++ b/drivers/scsi/ata_piix.c
@@ -45,6 +45,7 @@
45#include <linux/init.h> 45#include <linux/init.h>
46#include <linux/blkdev.h> 46#include <linux/blkdev.h>
47#include <linux/delay.h> 47#include <linux/delay.h>
48#include <linux/device.h>
48#include "scsi.h" 49#include "scsi.h"
49#include <scsi/scsi_host.h> 50#include <scsi/scsi_host.h>
50#include <linux/libata.h> 51#include <linux/libata.h>
@@ -621,18 +622,19 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
621{ 622{
622 static int printed_version; 623 static int printed_version;
623 struct ata_port_info *port_info[2]; 624 struct ata_port_info *port_info[2];
624 unsigned int combined = 0, n_ports = 1; 625 unsigned int combined = 0;
625 unsigned int pata_chan = 0, sata_chan = 0; 626 unsigned int pata_chan = 0, sata_chan = 0;
626 627
627 if (!printed_version++) 628 if (!printed_version++)
628 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 629 dev_printk(KERN_DEBUG, &pdev->dev,
630 "version " DRV_VERSION "\n");
629 631
630 /* no hotplugging support (FIXME) */ 632 /* no hotplugging support (FIXME) */
631 if (!in_module_init) 633 if (!in_module_init)
632 return -ENODEV; 634 return -ENODEV;
633 635
634 port_info[0] = &piix_port_info[ent->driver_data]; 636 port_info[0] = &piix_port_info[ent->driver_data];
635 port_info[1] = NULL; 637 port_info[1] = &piix_port_info[ent->driver_data];
636 638
637 if (port_info[0]->host_flags & PIIX_FLAG_AHCI) { 639 if (port_info[0]->host_flags & PIIX_FLAG_AHCI) {
638 u8 tmp; 640 u8 tmp;
@@ -670,12 +672,13 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
670 port_info[sata_chan] = &piix_port_info[ent->driver_data]; 672 port_info[sata_chan] = &piix_port_info[ent->driver_data];
671 port_info[sata_chan]->host_flags |= ATA_FLAG_SLAVE_POSS; 673 port_info[sata_chan]->host_flags |= ATA_FLAG_SLAVE_POSS;
672 port_info[pata_chan] = &piix_port_info[ich5_pata]; 674 port_info[pata_chan] = &piix_port_info[ich5_pata];
673 n_ports++;
674 675
675 printk(KERN_WARNING DRV_NAME ": combined mode detected\n"); 676 dev_printk(KERN_WARNING, &pdev->dev,
677 "combined mode detected (p=%u, s=%u)\n",
678 pata_chan, sata_chan);
676 } 679 }
677 680
678 return ata_pci_init_one(pdev, port_info, n_ports); 681 return ata_pci_init_one(pdev, port_info, 2);
679} 682}
680 683
681static int __init piix_init(void) 684static int __init piix_init(void)
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index d8f248dd0d01..b1011f4b995c 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -2667,14 +2667,14 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
2667 * None. (grabs host lock) 2667 * None. (grabs host lock)
2668 */ 2668 */
2669 2669
2670void ata_poll_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) 2670void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
2671{ 2671{
2672 struct ata_port *ap = qc->ap; 2672 struct ata_port *ap = qc->ap;
2673 unsigned long flags; 2673 unsigned long flags;
2674 2674
2675 spin_lock_irqsave(&ap->host_set->lock, flags); 2675 spin_lock_irqsave(&ap->host_set->lock, flags);
2676 ata_irq_on(ap); 2676 ata_irq_on(ap);
2677 ata_qc_complete(qc, drv_stat); 2677 ata_qc_complete(qc, err_mask);
2678 spin_unlock_irqrestore(&ap->host_set->lock, flags); 2678 spin_unlock_irqrestore(&ap->host_set->lock, flags);
2679} 2679}
2680 2680
@@ -2771,7 +2771,7 @@ static int ata_pio_complete (struct ata_port *ap)
2771 2771
2772 ap->hsm_task_state = HSM_ST_IDLE; 2772 ap->hsm_task_state = HSM_ST_IDLE;
2773 2773
2774 ata_poll_qc_complete(qc, drv_stat); 2774 ata_poll_qc_complete(qc, 0);
2775 2775
2776 /* another command may start at this point */ 2776 /* another command may start at this point */
2777 2777
@@ -3266,18 +3266,15 @@ static void ata_pio_block(struct ata_port *ap)
3266static void ata_pio_error(struct ata_port *ap) 3266static void ata_pio_error(struct ata_port *ap)
3267{ 3267{
3268 struct ata_queued_cmd *qc; 3268 struct ata_queued_cmd *qc;
3269 u8 drv_stat; 3269
3270 printk(KERN_WARNING "ata%u: PIO error\n", ap->id);
3270 3271
3271 qc = ata_qc_from_tag(ap, ap->active_tag); 3272 qc = ata_qc_from_tag(ap, ap->active_tag);
3272 assert(qc != NULL); 3273 assert(qc != NULL);
3273 3274
3274 drv_stat = ata_chk_status(ap);
3275 printk(KERN_WARNING "ata%u: PIO error, drv_stat 0x%x\n",
3276 ap->id, drv_stat);
3277
3278 ap->hsm_task_state = HSM_ST_IDLE; 3275 ap->hsm_task_state = HSM_ST_IDLE;
3279 3276
3280 ata_poll_qc_complete(qc, drv_stat | ATA_ERR); 3277 ata_poll_qc_complete(qc, AC_ERR_ATA_BUS);
3281} 3278}
3282 3279
3283static void ata_pio_task(void *_data) 3280static void ata_pio_task(void *_data)
@@ -3402,7 +3399,7 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc)
3402 ap->hsm_task_state = HSM_ST_IDLE; 3399 ap->hsm_task_state = HSM_ST_IDLE;
3403 3400
3404 /* complete taskfile transaction */ 3401 /* complete taskfile transaction */
3405 ata_qc_complete(qc, drv_stat); 3402 ata_qc_complete(qc, ac_err_mask(drv_stat));
3406 break; 3403 break;
3407 } 3404 }
3408 3405
@@ -3507,7 +3504,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
3507 return qc; 3504 return qc;
3508} 3505}
3509 3506
3510int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat) 3507int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask)
3511{ 3508{
3512 return 0; 3509 return 0;
3513} 3510}
@@ -3566,7 +3563,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
3566 * spin_lock_irqsave(host_set lock) 3563 * spin_lock_irqsave(host_set lock)
3567 */ 3564 */
3568 3565
3569void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) 3566void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
3570{ 3567{
3571 int rc; 3568 int rc;
3572 3569
@@ -3583,7 +3580,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
3583 qc->flags &= ~ATA_QCFLAG_ACTIVE; 3580 qc->flags &= ~ATA_QCFLAG_ACTIVE;
3584 3581
3585 /* call completion callback */ 3582 /* call completion callback */
3586 rc = qc->complete_fn(qc, drv_stat); 3583 rc = qc->complete_fn(qc, err_mask);
3587 3584
3588 /* if callback indicates not to complete command (non-zero), 3585 /* if callback indicates not to complete command (non-zero),
3589 * return immediately 3586 * return immediately
@@ -4169,7 +4166,7 @@ fsm_start:
4169 ap->hsm_task_state = HSM_ST_IDLE; 4166 ap->hsm_task_state = HSM_ST_IDLE;
4170 4167
4171 /* complete taskfile transaction */ 4168 /* complete taskfile transaction */
4172 ata_qc_complete(qc, status); 4169 ata_qc_complete(qc, ac_err_mask(status));
4173 break; 4170 break;
4174 4171
4175 case HSM_ST_ERR: 4172 case HSM_ST_ERR:
@@ -4746,11 +4743,11 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
4746 return probe_ent; 4743 return probe_ent;
4747} 4744}
4748 4745
4749static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, struct ata_port_info **port, int port_num) 4746static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, struct ata_port_info *port, int port_num)
4750{ 4747{
4751 struct ata_probe_ent *probe_ent; 4748 struct ata_probe_ent *probe_ent;
4752 4749
4753 probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port[0]); 4750 probe_ent = ata_probe_ent_alloc(pci_dev_to_dev(pdev), port);
4754 if (!probe_ent) 4751 if (!probe_ent)
4755 return NULL; 4752 return NULL;
4756 4753
@@ -4897,9 +4894,9 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
4897 4894
4898 if (legacy_mode) { 4895 if (legacy_mode) {
4899 if (legacy_mode & (1 << 0)) 4896 if (legacy_mode & (1 << 0))
4900 probe_ent = ata_pci_init_legacy_port(pdev, port, 0); 4897 probe_ent = ata_pci_init_legacy_port(pdev, port[0], 0);
4901 if (legacy_mode & (1 << 1)) 4898 if (legacy_mode & (1 << 1))
4902 probe_ent2 = ata_pci_init_legacy_port(pdev, port, 1); 4899 probe_ent2 = ata_pci_init_legacy_port(pdev, port[1], 1);
4903 } else { 4900 } else {
4904 if (n_ports == 2) 4901 if (n_ports == 2)
4905 probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); 4902 probe_ent = ata_pci_init_native_mode(pdev, port, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 89a04b1a5a0e..1e3792f86fcf 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -560,7 +560,7 @@ void ata_gen_ata_desc_sense(struct ata_queued_cmd *qc)
560 * Use ata_to_sense_error() to map status register bits 560 * Use ata_to_sense_error() to map status register bits
561 * onto sense key, asc & ascq. 561 * onto sense key, asc & ascq.
562 */ 562 */
563 if (unlikely(tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ))) { 563 if (tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) {
564 ata_to_sense_error(qc->ap->id, tf->command, tf->feature, 564 ata_to_sense_error(qc->ap->id, tf->command, tf->feature,
565 &sb[1], &sb[2], &sb[3]); 565 &sb[1], &sb[2], &sb[3]);
566 sb[1] &= 0x0f; 566 sb[1] &= 0x0f;
@@ -635,7 +635,7 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc)
635 * Use ata_to_sense_error() to map status register bits 635 * Use ata_to_sense_error() to map status register bits
636 * onto sense key, asc & ascq. 636 * onto sense key, asc & ascq.
637 */ 637 */
638 if (unlikely(tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ))) { 638 if (tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) {
639 ata_to_sense_error(qc->ap->id, tf->command, tf->feature, 639 ata_to_sense_error(qc->ap->id, tf->command, tf->feature,
640 &sb[2], &sb[12], &sb[13]); 640 &sb[2], &sb[12], &sb[13]);
641 sb[2] &= 0x0f; 641 sb[2] &= 0x0f;
@@ -644,7 +644,11 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc)
644 sb[0] = 0x70; 644 sb[0] = 0x70;
645 sb[7] = 0x0a; 645 sb[7] = 0x0a;
646 646
647 if (tf->flags & ATA_TFLAG_LBA && !(tf->flags & ATA_TFLAG_LBA48)) { 647 if (tf->flags & ATA_TFLAG_LBA48) {
648 /* TODO: find solution for LBA48 descriptors */
649 }
650
651 else if (tf->flags & ATA_TFLAG_LBA) {
648 /* A small (28b) LBA will fit in the 32b info field */ 652 /* A small (28b) LBA will fit in the 32b info field */
649 sb[0] |= 0x80; /* set valid bit */ 653 sb[0] |= 0x80; /* set valid bit */
650 sb[3] = tf->device & 0x0f; 654 sb[3] = tf->device & 0x0f;
@@ -652,6 +656,10 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc)
652 sb[5] = tf->lbam; 656 sb[5] = tf->lbam;
653 sb[6] = tf->lbal; 657 sb[6] = tf->lbal;
654 } 658 }
659
660 else {
661 /* TODO: C/H/S */
662 }
655} 663}
656 664
657/** 665/**
@@ -1199,10 +1207,12 @@ nothing_to_do:
1199 return 1; 1207 return 1;
1200} 1208}
1201 1209
1202static int ata_scsi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) 1210static int ata_scsi_qc_complete(struct ata_queued_cmd *qc,
1211 unsigned int err_mask)
1203{ 1212{
1204 struct scsi_cmnd *cmd = qc->scsicmd; 1213 struct scsi_cmnd *cmd = qc->scsicmd;
1205 int need_sense = drv_stat & (ATA_ERR | ATA_BUSY | ATA_DRQ); 1214 u8 *cdb = cmd->cmnd;
1215 int need_sense = (err_mask != 0);
1206 1216
1207 /* For ATA pass thru (SAT) commands, generate a sense block if 1217 /* For ATA pass thru (SAT) commands, generate a sense block if
1208 * user mandated it or if there's an error. Note that if we 1218 * user mandated it or if there's an error. Note that if we
@@ -1211,8 +1221,8 @@ static int ata_scsi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
1211 * whether the command completed successfully or not. If there 1221 * whether the command completed successfully or not. If there
1212 * was no error, SK, ASC and ASCQ will all be zero. 1222 * was no error, SK, ASC and ASCQ will all be zero.
1213 */ 1223 */
1214 if (((cmd->cmnd[0] == ATA_16) || (cmd->cmnd[0] == ATA_12)) && 1224 if (((cdb[0] == ATA_16) || (cdb[0] == ATA_12)) &&
1215 ((cmd->cmnd[2] & 0x20) || need_sense)) { 1225 ((cdb[2] & 0x20) || need_sense)) {
1216 ata_gen_ata_desc_sense(qc); 1226 ata_gen_ata_desc_sense(qc);
1217 } else { 1227 } else {
1218 if (!need_sense) { 1228 if (!need_sense) {
@@ -1995,21 +2005,13 @@ void atapi_request_sense(struct ata_port *ap, struct ata_device *dev,
1995 DPRINTK("EXIT\n"); 2005 DPRINTK("EXIT\n");
1996} 2006}
1997 2007
1998static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) 2008static int atapi_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
1999{ 2009{
2000 struct scsi_cmnd *cmd = qc->scsicmd; 2010 struct scsi_cmnd *cmd = qc->scsicmd;
2001 2011
2002 VPRINTK("ENTER, drv_stat == 0x%x\n", drv_stat); 2012 VPRINTK("ENTER, err_mask 0x%X\n", err_mask);
2003
2004 if (unlikely(drv_stat & (ATA_BUSY | ATA_DRQ)))
2005 /* FIXME: not quite right; we don't want the
2006 * translation of taskfile registers into
2007 * a sense descriptors, since that's only
2008 * correct for ATA, not ATAPI
2009 */
2010 ata_gen_ata_desc_sense(qc);
2011 2013
2012 else if (unlikely(drv_stat & ATA_ERR)) { 2014 if (unlikely(err_mask & AC_ERR_DEV)) {
2013 DPRINTK("request check condition\n"); 2015 DPRINTK("request check condition\n");
2014 2016
2015 /* FIXME: command completion with check condition 2017 /* FIXME: command completion with check condition
@@ -2026,6 +2028,14 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
2026 return 1; 2028 return 1;
2027 } 2029 }
2028 2030
2031 else if (unlikely(err_mask))
2032 /* FIXME: not quite right; we don't want the
2033 * translation of taskfile registers into
2034 * a sense descriptors, since that's only
2035 * correct for ATA, not ATAPI
2036 */
2037 ata_gen_ata_desc_sense(qc);
2038
2029 else { 2039 else {
2030 u8 *scsicmd = cmd->cmnd; 2040 u8 *scsicmd = cmd->cmnd;
2031 2041
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h
index 65c264b91136..10ecd9e15e4f 100644
--- a/drivers/scsi/libata.h
+++ b/drivers/scsi/libata.h
@@ -39,7 +39,7 @@ struct ata_scsi_args {
39 39
40/* libata-core.c */ 40/* libata-core.c */
41extern int atapi_enabled; 41extern int atapi_enabled;
42extern int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat); 42extern int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask);
43extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, 43extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
44 struct ata_device *dev); 44 struct ata_device *dev);
45extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc); 45extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc);
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c
index 6a9d0dc085c1..fc9ee6fefa1c 100644
--- a/drivers/scsi/pdc_adma.c
+++ b/drivers/scsi/pdc_adma.c
@@ -40,6 +40,7 @@
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/interrupt.h> 41#include <linux/interrupt.h>
42#include <linux/sched.h> 42#include <linux/sched.h>
43#include <linux/device.h>
43#include "scsi.h" 44#include "scsi.h"
44#include <scsi/scsi_host.h> 45#include <scsi/scsi_host.h>
45#include <asm/io.h> 46#include <asm/io.h>
@@ -451,7 +452,7 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set)
451 struct adma_port_priv *pp; 452 struct adma_port_priv *pp;
452 struct ata_queued_cmd *qc; 453 struct ata_queued_cmd *qc;
453 void __iomem *chan = ADMA_REGS(mmio_base, port_no); 454 void __iomem *chan = ADMA_REGS(mmio_base, port_no);
454 u8 drv_stat = 0, status = readb(chan + ADMA_STATUS); 455 u8 status = readb(chan + ADMA_STATUS);
455 456
456 if (status == 0) 457 if (status == 0)
457 continue; 458 continue;
@@ -464,11 +465,14 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set)
464 continue; 465 continue;
465 qc = ata_qc_from_tag(ap, ap->active_tag); 466 qc = ata_qc_from_tag(ap, ap->active_tag);
466 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) { 467 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) {
468 unsigned int err_mask = 0;
469
467 if ((status & (aPERR | aPSD | aUIRQ))) 470 if ((status & (aPERR | aPSD | aUIRQ)))
468 drv_stat = ATA_ERR; 471 err_mask = AC_ERR_OTHER;
469 else if (pp->pkt[0] != cDONE) 472 else if (pp->pkt[0] != cDONE)
470 drv_stat = ATA_ERR; 473 err_mask = AC_ERR_OTHER;
471 ata_qc_complete(qc, drv_stat); 474
475 ata_qc_complete(qc, err_mask);
472 } 476 }
473 } 477 }
474 return handled; 478 return handled;
@@ -498,7 +502,7 @@ static inline unsigned int adma_intr_mmio(struct ata_host_set *host_set)
498 502
499 /* complete taskfile transaction */ 503 /* complete taskfile transaction */
500 pp->state = adma_state_idle; 504 pp->state = adma_state_idle;
501 ata_qc_complete(qc, status); 505 ata_qc_complete(qc, ac_err_mask(status));
502 handled = 1; 506 handled = 1;
503 } 507 }
504 } 508 }
@@ -623,16 +627,14 @@ static int adma_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base)
623 627
624 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 628 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
625 if (rc) { 629 if (rc) {
626 printk(KERN_ERR DRV_NAME 630 dev_printk(KERN_ERR, &pdev->dev,
627 "(%s): 32-bit DMA enable failed\n", 631 "32-bit DMA enable failed\n");
628 pci_name(pdev));
629 return rc; 632 return rc;
630 } 633 }
631 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 634 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
632 if (rc) { 635 if (rc) {
633 printk(KERN_ERR DRV_NAME 636 dev_printk(KERN_ERR, &pdev->dev,
634 "(%s): 32-bit consistent DMA enable failed\n", 637 "32-bit consistent DMA enable failed\n");
635 pci_name(pdev));
636 return rc; 638 return rc;
637 } 639 }
638 return 0; 640 return 0;
@@ -648,7 +650,7 @@ static int adma_ata_init_one(struct pci_dev *pdev,
648 int rc, port_no; 650 int rc, port_no;
649 651
650 if (!printed_version++) 652 if (!printed_version++)
651 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 653 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
652 654
653 rc = pci_enable_device(pdev); 655 rc = pci_enable_device(pdev);
654 if (rc) 656 if (rc)
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
index f22726d8a8ac..2a68b6227464 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/scsi/sata_mv.c
@@ -29,6 +29,7 @@
29#include <linux/interrupt.h> 29#include <linux/interrupt.h>
30#include <linux/sched.h> 30#include <linux/sched.h>
31#include <linux/dma-mapping.h> 31#include <linux/dma-mapping.h>
32#include <linux/device.h>
32#include "scsi.h" 33#include "scsi.h"
33#include <scsi/scsi_host.h> 34#include <scsi/scsi_host.h>
34#include <linux/libata.h> 35#include <linux/libata.h>
@@ -1066,6 +1067,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1066 struct ata_queued_cmd *qc; 1067 struct ata_queued_cmd *qc;
1067 u32 hc_irq_cause; 1068 u32 hc_irq_cause;
1068 int shift, port, port0, hard_port, handled; 1069 int shift, port, port0, hard_port, handled;
1070 unsigned int err_mask;
1069 u8 ata_status = 0; 1071 u8 ata_status = 0;
1070 1072
1071 if (hc == 0) { 1073 if (hc == 0) {
@@ -1101,15 +1103,15 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1101 handled++; 1103 handled++;
1102 } 1104 }
1103 1105
1106 err_mask = ac_err_mask(ata_status);
1107
1104 shift = port << 1; /* (port * 2) */ 1108 shift = port << 1; /* (port * 2) */
1105 if (port >= MV_PORTS_PER_HC) { 1109 if (port >= MV_PORTS_PER_HC) {
1106 shift++; /* skip bit 8 in the HC Main IRQ reg */ 1110 shift++; /* skip bit 8 in the HC Main IRQ reg */
1107 } 1111 }
1108 if ((PORT0_ERR << shift) & relevant) { 1112 if ((PORT0_ERR << shift) & relevant) {
1109 mv_err_intr(ap); 1113 mv_err_intr(ap);
1110 /* OR in ATA_ERR to ensure libata knows we took one */ 1114 err_mask |= AC_ERR_OTHER;
1111 ata_status = readb((void __iomem *)
1112 ap->ioaddr.status_addr) | ATA_ERR;
1113 handled++; 1115 handled++;
1114 } 1116 }
1115 1117
@@ -1119,7 +1121,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1119 VPRINTK("port %u IRQ found for qc, " 1121 VPRINTK("port %u IRQ found for qc, "
1120 "ata_status 0x%x\n", port,ata_status); 1122 "ata_status 0x%x\n", port,ata_status);
1121 /* mark qc status appropriately */ 1123 /* mark qc status appropriately */
1122 ata_qc_complete(qc, ata_status); 1124 ata_qc_complete(qc, err_mask);
1123 } 1125 }
1124 } 1126 }
1125 } 1127 }
@@ -1295,7 +1297,7 @@ static void mv_eng_timeout(struct ata_port *ap)
1295 */ 1297 */
1296 spin_lock_irqsave(&ap->host_set->lock, flags); 1298 spin_lock_irqsave(&ap->host_set->lock, flags);
1297 qc->scsidone = scsi_finish_command; 1299 qc->scsidone = scsi_finish_command;
1298 ata_qc_complete(qc, ATA_ERR); 1300 ata_qc_complete(qc, AC_ERR_OTHER);
1299 spin_unlock_irqrestore(&ap->host_set->lock, flags); 1301 spin_unlock_irqrestore(&ap->host_set->lock, flags);
1300 } 1302 }
1301} 1303}
@@ -1437,9 +1439,9 @@ static void mv_print_info(struct ata_probe_ent *probe_ent)
1437 else 1439 else
1438 scc_s = "unknown"; 1440 scc_s = "unknown";
1439 1441
1440 printk(KERN_INFO DRV_NAME 1442 dev_printk(KERN_INFO, &pdev->dev,
1441 "(%s) %u slots %u ports %s mode IRQ via %s\n", 1443 "%u slots %u ports %s mode IRQ via %s\n",
1442 pci_name(pdev), (unsigned)MV_MAX_Q_DEPTH, probe_ent->n_ports, 1444 (unsigned)MV_MAX_Q_DEPTH, probe_ent->n_ports,
1443 scc_s, (MV_HP_FLAG_MSI & hpriv->hp_flags) ? "MSI" : "INTx"); 1445 scc_s, (MV_HP_FLAG_MSI & hpriv->hp_flags) ? "MSI" : "INTx");
1444} 1446}
1445 1447
@@ -1460,9 +1462,8 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1460 void __iomem *mmio_base; 1462 void __iomem *mmio_base;
1461 int pci_dev_busy = 0, rc; 1463 int pci_dev_busy = 0, rc;
1462 1464
1463 if (!printed_version++) { 1465 if (!printed_version++)
1464 printk(KERN_INFO DRV_NAME " version " DRV_VERSION "\n"); 1466 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
1465 }
1466 1467
1467 rc = pci_enable_device(pdev); 1468 rc = pci_enable_device(pdev);
1468 if (rc) { 1469 if (rc) {
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c
index 73c2c5a29049..5569d5797134 100644
--- a/drivers/scsi/sata_nv.c
+++ b/drivers/scsi/sata_nv.c
@@ -61,6 +61,7 @@
61#include <linux/blkdev.h> 61#include <linux/blkdev.h>
62#include <linux/delay.h> 62#include <linux/delay.h>
63#include <linux/interrupt.h> 63#include <linux/interrupt.h>
64#include <linux/device.h>
64#include "scsi.h" 65#include "scsi.h"
65#include <scsi/scsi_host.h> 66#include <scsi/scsi_host.h>
66#include <linux/libata.h> 67#include <linux/libata.h>
@@ -383,7 +384,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
383 return -ENODEV; 384 return -ENODEV;
384 385
385 if (!printed_version++) 386 if (!printed_version++)
386 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 387 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
387 388
388 rc = pci_enable_device(pdev); 389 rc = pci_enable_device(pdev);
389 if (rc) 390 if (rc)
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c
index 3c3ab866351f..b2e2f1825edb 100644
--- a/drivers/scsi/sata_promise.c
+++ b/drivers/scsi/sata_promise.c
@@ -38,6 +38,7 @@
38#include <linux/delay.h> 38#include <linux/delay.h>
39#include <linux/interrupt.h> 39#include <linux/interrupt.h>
40#include <linux/sched.h> 40#include <linux/sched.h>
41#include <linux/device.h>
41#include "scsi.h" 42#include "scsi.h"
42#include <scsi/scsi_host.h> 43#include <scsi/scsi_host.h>
43#include <linux/libata.h> 44#include <linux/libata.h>
@@ -402,7 +403,8 @@ static void pdc_eng_timeout(struct ata_port *ap)
402 case ATA_PROT_DMA: 403 case ATA_PROT_DMA:
403 case ATA_PROT_NODATA: 404 case ATA_PROT_NODATA:
404 printk(KERN_ERR "ata%u: command timeout\n", ap->id); 405 printk(KERN_ERR "ata%u: command timeout\n", ap->id);
405 ata_qc_complete(qc, ata_wait_idle(ap) | ATA_ERR); 406 drv_stat = ata_wait_idle(ap);
407 ata_qc_complete(qc, __ac_err_mask(drv_stat));
406 break; 408 break;
407 409
408 default: 410 default:
@@ -411,7 +413,7 @@ static void pdc_eng_timeout(struct ata_port *ap)
411 printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", 413 printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n",
412 ap->id, qc->tf.command, drv_stat); 414 ap->id, qc->tf.command, drv_stat);
413 415
414 ata_qc_complete(qc, drv_stat); 416 ata_qc_complete(qc, ac_err_mask(drv_stat));
415 break; 417 break;
416 } 418 }
417 419
@@ -423,24 +425,21 @@ out:
423static inline unsigned int pdc_host_intr( struct ata_port *ap, 425static inline unsigned int pdc_host_intr( struct ata_port *ap,
424 struct ata_queued_cmd *qc) 426 struct ata_queued_cmd *qc)
425{ 427{
426 u8 status; 428 unsigned int handled = 0, err_mask = 0;
427 unsigned int handled = 0, have_err = 0;
428 u32 tmp; 429 u32 tmp;
429 void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL; 430 void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL;
430 431
431 tmp = readl(mmio); 432 tmp = readl(mmio);
432 if (tmp & PDC_ERR_MASK) { 433 if (tmp & PDC_ERR_MASK) {
433 have_err = 1; 434 err_mask = AC_ERR_DEV;
434 pdc_reset_port(ap); 435 pdc_reset_port(ap);
435 } 436 }
436 437
437 switch (qc->tf.protocol) { 438 switch (qc->tf.protocol) {
438 case ATA_PROT_DMA: 439 case ATA_PROT_DMA:
439 case ATA_PROT_NODATA: 440 case ATA_PROT_NODATA:
440 status = ata_wait_idle(ap); 441 err_mask |= ac_err_mask(ata_wait_idle(ap));
441 if (have_err) 442 ata_qc_complete(qc, err_mask);
442 status |= ATA_ERR;
443 ata_qc_complete(qc, status);
444 handled = 1; 443 handled = 1;
445 break; 444 break;
446 445
@@ -638,7 +637,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
638 int rc; 637 int rc;
639 638
640 if (!printed_version++) 639 if (!printed_version++)
641 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 640 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
642 641
643 /* 642 /*
644 * If this driver happens to only be useful on Apple's K2, then 643 * If this driver happens to only be useful on Apple's K2, then
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c
index 6317a9a96e69..6998c5141607 100644
--- a/drivers/scsi/sata_qstor.c
+++ b/drivers/scsi/sata_qstor.c
@@ -35,6 +35,7 @@
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/interrupt.h> 36#include <linux/interrupt.h>
37#include <linux/sched.h> 37#include <linux/sched.h>
38#include <linux/device.h>
38#include "scsi.h" 39#include "scsi.h"
39#include <scsi/scsi_host.h> 40#include <scsi/scsi_host.h>
40#include <asm/io.h> 41#include <asm/io.h>
@@ -399,11 +400,12 @@ static inline unsigned int qs_intr_pkt(struct ata_host_set *host_set)
399 qc = ata_qc_from_tag(ap, ap->active_tag); 400 qc = ata_qc_from_tag(ap, ap->active_tag);
400 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) { 401 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) {
401 switch (sHST) { 402 switch (sHST) {
402 case 0: /* sucessful CPB */ 403 case 0: /* successful CPB */
403 case 3: /* device error */ 404 case 3: /* device error */
404 pp->state = qs_state_idle; 405 pp->state = qs_state_idle;
405 qs_enter_reg_mode(qc->ap); 406 qs_enter_reg_mode(qc->ap);
406 ata_qc_complete(qc, sDST); 407 ata_qc_complete(qc,
408 ac_err_mask(sDST));
407 break; 409 break;
408 default: 410 default:
409 break; 411 break;
@@ -440,7 +442,7 @@ static inline unsigned int qs_intr_mmio(struct ata_host_set *host_set)
440 442
441 /* complete taskfile transaction */ 443 /* complete taskfile transaction */
442 pp->state = qs_state_idle; 444 pp->state = qs_state_idle;
443 ata_qc_complete(qc, status); 445 ata_qc_complete(qc, ac_err_mask(status));
444 handled = 1; 446 handled = 1;
445 } 447 }
446 } 448 }
@@ -598,25 +600,22 @@ static int qs_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base)
598 if (rc) { 600 if (rc) {
599 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 601 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
600 if (rc) { 602 if (rc) {
601 printk(KERN_ERR DRV_NAME 603 dev_printk(KERN_ERR, &pdev->dev,
602 "(%s): 64-bit DMA enable failed\n", 604 "64-bit DMA enable failed\n");
603 pci_name(pdev));
604 return rc; 605 return rc;
605 } 606 }
606 } 607 }
607 } else { 608 } else {
608 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 609 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
609 if (rc) { 610 if (rc) {
610 printk(KERN_ERR DRV_NAME 611 dev_printk(KERN_ERR, &pdev->dev,
611 "(%s): 32-bit DMA enable failed\n", 612 "32-bit DMA enable failed\n");
612 pci_name(pdev));
613 return rc; 613 return rc;
614 } 614 }
615 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 615 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
616 if (rc) { 616 if (rc) {
617 printk(KERN_ERR DRV_NAME 617 dev_printk(KERN_ERR, &pdev->dev,
618 "(%s): 32-bit consistent DMA enable failed\n", 618 "32-bit consistent DMA enable failed\n");
619 pci_name(pdev));
620 return rc; 619 return rc;
621 } 620 }
622 } 621 }
@@ -633,7 +632,7 @@ static int qs_ata_init_one(struct pci_dev *pdev,
633 int rc, port_no; 632 int rc, port_no;
634 633
635 if (!printed_version++) 634 if (!printed_version++)
636 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 635 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
637 636
638 rc = pci_enable_device(pdev); 637 rc = pci_enable_device(pdev);
639 if (rc) 638 if (rc)
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c
index 3a056173fb95..435f7e0085ec 100644
--- a/drivers/scsi/sata_sil.c
+++ b/drivers/scsi/sata_sil.c
@@ -41,6 +41,7 @@
41#include <linux/blkdev.h> 41#include <linux/blkdev.h>
42#include <linux/delay.h> 42#include <linux/delay.h>
43#include <linux/interrupt.h> 43#include <linux/interrupt.h>
44#include <linux/device.h>
44#include "scsi.h" 45#include "scsi.h"
45#include <scsi/scsi_host.h> 46#include <scsi/scsi_host.h>
46#include <linux/libata.h> 47#include <linux/libata.h>
@@ -386,7 +387,7 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
386 u8 cls; 387 u8 cls;
387 388
388 if (!printed_version++) 389 if (!printed_version++)
389 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 390 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
390 391
391 /* 392 /*
392 * If this driver happens to only be useful on Apple's K2, then 393 * If this driver happens to only be useful on Apple's K2, then
@@ -463,8 +464,8 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
463 writeb(cls, mmio_base + SIL_FIFO_W3); 464 writeb(cls, mmio_base + SIL_FIFO_W3);
464 } 465 }
465 } else 466 } else
466 printk(KERN_WARNING DRV_NAME "(%s): cache line size not set. Driver may not function\n", 467 dev_printk(KERN_WARNING, &pdev->dev,
467 pci_name(pdev)); 468 "cache line size not set. Driver may not function\n");
468 469
469 if (ent->driver_data == sil_3114) { 470 if (ent->driver_data == sil_3114) {
470 irq_mask = SIL_MASK_4PORT; 471 irq_mask = SIL_MASK_4PORT;
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c
index e18a1e2bb65e..c66548025657 100644
--- a/drivers/scsi/sata_sil24.c
+++ b/drivers/scsi/sata_sil24.c
@@ -35,6 +35,7 @@
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/interrupt.h> 36#include <linux/interrupt.h>
37#include <linux/dma-mapping.h> 37#include <linux/dma-mapping.h>
38#include <linux/device.h>
38#include <scsi/scsi_host.h> 39#include <scsi/scsi_host.h>
39#include "scsi.h" 40#include "scsi.h"
40#include <linux/libata.h> 41#include <linux/libata.h>
@@ -498,7 +499,7 @@ static void sil24_eng_timeout(struct ata_port *ap)
498 499
499 qc = ata_qc_from_tag(ap, ap->active_tag); 500 qc = ata_qc_from_tag(ap, ap->active_tag);
500 if (!qc) { 501 if (!qc) {
501 printk(KERN_ERR "ata%u: BUG: tiemout without command\n", 502 printk(KERN_ERR "ata%u: BUG: timeout without command\n",
502 ap->id); 503 ap->id);
503 return; 504 return;
504 } 505 }
@@ -512,7 +513,7 @@ static void sil24_eng_timeout(struct ata_port *ap)
512 */ 513 */
513 printk(KERN_ERR "ata%u: command timeout\n", ap->id); 514 printk(KERN_ERR "ata%u: command timeout\n", ap->id);
514 qc->scsidone = scsi_finish_command; 515 qc->scsidone = scsi_finish_command;
515 ata_qc_complete(qc, ATA_ERR); 516 ata_qc_complete(qc, AC_ERR_OTHER);
516 517
517 sil24_reset_controller(ap); 518 sil24_reset_controller(ap);
518} 519}
@@ -523,6 +524,7 @@ static void sil24_error_intr(struct ata_port *ap, u32 slot_stat)
523 struct sil24_port_priv *pp = ap->private_data; 524 struct sil24_port_priv *pp = ap->private_data;
524 void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; 525 void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;
525 u32 irq_stat, cmd_err, sstatus, serror; 526 u32 irq_stat, cmd_err, sstatus, serror;
527 unsigned int err_mask;
526 528
527 irq_stat = readl(port + PORT_IRQ_STAT); 529 irq_stat = readl(port + PORT_IRQ_STAT);
528 writel(irq_stat, port + PORT_IRQ_STAT); /* clear irq */ 530 writel(irq_stat, port + PORT_IRQ_STAT); /* clear irq */
@@ -550,17 +552,18 @@ static void sil24_error_intr(struct ata_port *ap, u32 slot_stat)
550 * Device is reporting error, tf registers are valid. 552 * Device is reporting error, tf registers are valid.
551 */ 553 */
552 sil24_update_tf(ap); 554 sil24_update_tf(ap);
555 err_mask = ac_err_mask(pp->tf.command);
553 } else { 556 } else {
554 /* 557 /*
555 * Other errors. libata currently doesn't have any 558 * Other errors. libata currently doesn't have any
556 * mechanism to report these errors. Just turn on 559 * mechanism to report these errors. Just turn on
557 * ATA_ERR. 560 * ATA_ERR.
558 */ 561 */
559 pp->tf.command = ATA_ERR; 562 err_mask = AC_ERR_OTHER;
560 } 563 }
561 564
562 if (qc) 565 if (qc)
563 ata_qc_complete(qc, pp->tf.command); 566 ata_qc_complete(qc, err_mask);
564 567
565 sil24_reset_controller(ap); 568 sil24_reset_controller(ap);
566} 569}
@@ -585,7 +588,7 @@ static inline void sil24_host_intr(struct ata_port *ap)
585 sil24_update_tf(ap); 588 sil24_update_tf(ap);
586 589
587 if (qc) 590 if (qc)
588 ata_qc_complete(qc, pp->tf.command); 591 ata_qc_complete(qc, ac_err_mask(pp->tf.command));
589 } else 592 } else
590 sil24_error_intr(ap, slot_stat); 593 sil24_error_intr(ap, slot_stat);
591} 594}
@@ -688,7 +691,7 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
688 int i, rc; 691 int i, rc;
689 692
690 if (!printed_version++) 693 if (!printed_version++)
691 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 694 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
692 695
693 rc = pci_enable_device(pdev); 696 rc = pci_enable_device(pdev);
694 if (rc) 697 if (rc)
@@ -748,14 +751,14 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
748 */ 751 */
749 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 752 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
750 if (rc) { 753 if (rc) {
751 printk(KERN_ERR DRV_NAME "(%s): 32-bit DMA enable failed\n", 754 dev_printk(KERN_ERR, &pdev->dev,
752 pci_name(pdev)); 755 "32-bit DMA enable failed\n");
753 goto out_free; 756 goto out_free;
754 } 757 }
755 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 758 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
756 if (rc) { 759 if (rc) {
757 printk(KERN_ERR DRV_NAME "(%s): 32-bit consistent DMA enable failed\n", 760 dev_printk(KERN_ERR, &pdev->dev,
758 pci_name(pdev)); 761 "32-bit consistent DMA enable failed\n");
759 goto out_free; 762 goto out_free;
760 } 763 }
761 764
@@ -791,9 +794,8 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
791 break; 794 break;
792 } 795 }
793 if (tmp & PORT_CS_PORT_RST) 796 if (tmp & PORT_CS_PORT_RST)
794 printk(KERN_ERR DRV_NAME 797 dev_printk(KERN_ERR, &pdev->dev,
795 "(%s): failed to clear port RST\n", 798 "failed to clear port RST\n");
796 pci_name(pdev));
797 } 799 }
798 800
799 /* Zero error counters. */ 801 /* Zero error counters. */
@@ -822,9 +824,8 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
822 824
823 /* Reset itself */ 825 /* Reset itself */
824 if (__sil24_reset_controller(port)) 826 if (__sil24_reset_controller(port))
825 printk(KERN_ERR DRV_NAME 827 dev_printk(KERN_ERR, &pdev->dev,
826 "(%s): failed to reset controller\n", 828 "failed to reset controller\n");
827 pci_name(pdev));
828 } 829 }
829 830
830 /* Turn on interrupts */ 831 /* Turn on interrupts */
diff --git a/drivers/scsi/sata_sis.c b/drivers/scsi/sata_sis.c
index 057f7b98b6c4..42288be0e561 100644
--- a/drivers/scsi/sata_sis.c
+++ b/drivers/scsi/sata_sis.c
@@ -38,6 +38,7 @@
38#include <linux/blkdev.h> 38#include <linux/blkdev.h>
39#include <linux/delay.h> 39#include <linux/delay.h>
40#include <linux/interrupt.h> 40#include <linux/interrupt.h>
41#include <linux/device.h>
41#include "scsi.h" 42#include "scsi.h"
42#include <scsi/scsi_host.h> 43#include <scsi/scsi_host.h>
43#include <linux/libata.h> 44#include <linux/libata.h>
@@ -237,6 +238,7 @@ static void sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
237 238
238static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 239static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
239{ 240{
241 static int printed_version;
240 struct ata_probe_ent *probe_ent = NULL; 242 struct ata_probe_ent *probe_ent = NULL;
241 int rc; 243 int rc;
242 u32 genctl; 244 u32 genctl;
@@ -245,6 +247,9 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
245 u8 pmr; 247 u8 pmr;
246 u8 port2_start; 248 u8 port2_start;
247 249
250 if (!printed_version++)
251 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
252
248 rc = pci_enable_device(pdev); 253 rc = pci_enable_device(pdev);
249 if (rc) 254 if (rc)
250 return rc; 255 return rc;
@@ -288,16 +293,18 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
288 pci_read_config_byte(pdev, SIS_PMR, &pmr); 293 pci_read_config_byte(pdev, SIS_PMR, &pmr);
289 if (ent->device != 0x182) { 294 if (ent->device != 0x182) {
290 if ((pmr & SIS_PMR_COMBINED) == 0) { 295 if ((pmr & SIS_PMR_COMBINED) == 0) {
291 printk(KERN_INFO "sata_sis: Detected SiS 180/181 chipset in SATA mode\n"); 296 dev_printk(KERN_INFO, &pdev->dev,
297 "Detected SiS 180/181 chipset in SATA mode\n");
292 port2_start = 64; 298 port2_start = 64;
293 } 299 }
294 else { 300 else {
295 printk(KERN_INFO "sata_sis: Detected SiS 180/181 chipset in combined mode\n"); 301 dev_printk(KERN_INFO, &pdev->dev,
302 "Detected SiS 180/181 chipset in combined mode\n");
296 port2_start=0; 303 port2_start=0;
297 } 304 }
298 } 305 }
299 else { 306 else {
300 printk(KERN_INFO "sata_sis: Detected SiS 182 chipset\n"); 307 dev_printk(KERN_INFO, &pdev->dev, "Detected SiS 182 chipset\n");
301 port2_start = 0x20; 308 port2_start = 0x20;
302 } 309 }
303 310
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c
index 46208f52d0e1..db615ff794d8 100644
--- a/drivers/scsi/sata_svw.c
+++ b/drivers/scsi/sata_svw.c
@@ -44,6 +44,7 @@
44#include <linux/blkdev.h> 44#include <linux/blkdev.h>
45#include <linux/delay.h> 45#include <linux/delay.h>
46#include <linux/interrupt.h> 46#include <linux/interrupt.h>
47#include <linux/device.h>
47#include "scsi.h" 48#include "scsi.h"
48#include <scsi/scsi_host.h> 49#include <scsi/scsi_host.h>
49#include <linux/libata.h> 50#include <linux/libata.h>
@@ -362,7 +363,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
362 int i; 363 int i;
363 364
364 if (!printed_version++) 365 if (!printed_version++)
365 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 366 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
366 367
367 /* 368 /*
368 * If this driver happens to only be useful on Apple's K2, then 369 * If this driver happens to only be useful on Apple's K2, then
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c
index 1908c588ebb9..ea921e693689 100644
--- a/drivers/scsi/sata_sx4.c
+++ b/drivers/scsi/sata_sx4.c
@@ -38,6 +38,7 @@
38#include <linux/delay.h> 38#include <linux/delay.h>
39#include <linux/interrupt.h> 39#include <linux/interrupt.h>
40#include <linux/sched.h> 40#include <linux/sched.h>
41#include <linux/device.h>
41#include "scsi.h" 42#include "scsi.h"
42#include <scsi/scsi_host.h> 43#include <scsi/scsi_host.h>
43#include <linux/libata.h> 44#include <linux/libata.h>
@@ -719,7 +720,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
719 VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->id, 720 VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->id,
720 readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); 721 readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT));
721 /* get drive status; clear intr; complete txn */ 722 /* get drive status; clear intr; complete txn */
722 ata_qc_complete(qc, ata_wait_idle(ap)); 723 ata_qc_complete(qc, ac_err_mask(ata_wait_idle(ap)));
723 pdc20621_pop_hdma(qc); 724 pdc20621_pop_hdma(qc);
724 } 725 }
725 726
@@ -757,7 +758,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
757 VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->id, 758 VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->id,
758 readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); 759 readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT));
759 /* get drive status; clear intr; complete txn */ 760 /* get drive status; clear intr; complete txn */
760 ata_qc_complete(qc, ata_wait_idle(ap)); 761 ata_qc_complete(qc, ac_err_mask(ata_wait_idle(ap)));
761 pdc20621_pop_hdma(qc); 762 pdc20621_pop_hdma(qc);
762 } 763 }
763 handled = 1; 764 handled = 1;
@@ -767,7 +768,7 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
767 768
768 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); 769 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
769 DPRINTK("BUS_NODATA (drv_stat 0x%X)\n", status); 770 DPRINTK("BUS_NODATA (drv_stat 0x%X)\n", status);
770 ata_qc_complete(qc, status); 771 ata_qc_complete(qc, ac_err_mask(status));
771 handled = 1; 772 handled = 1;
772 773
773 } else { 774 } else {
@@ -882,7 +883,7 @@ static void pdc_eng_timeout(struct ata_port *ap)
882 case ATA_PROT_DMA: 883 case ATA_PROT_DMA:
883 case ATA_PROT_NODATA: 884 case ATA_PROT_NODATA:
884 printk(KERN_ERR "ata%u: command timeout\n", ap->id); 885 printk(KERN_ERR "ata%u: command timeout\n", ap->id);
885 ata_qc_complete(qc, ata_wait_idle(ap) | ATA_ERR); 886 ata_qc_complete(qc, __ac_err_mask(ata_wait_idle(ap)));
886 break; 887 break;
887 888
888 default: 889 default:
@@ -891,7 +892,7 @@ static void pdc_eng_timeout(struct ata_port *ap)
891 printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", 892 printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n",
892 ap->id, qc->tf.command, drv_stat); 893 ap->id, qc->tf.command, drv_stat);
893 894
894 ata_qc_complete(qc, drv_stat); 895 ata_qc_complete(qc, ac_err_mask(drv_stat));
895 break; 896 break;
896 } 897 }
897 898
@@ -1386,7 +1387,7 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
1386 int rc; 1387 int rc;
1387 1388
1388 if (!printed_version++) 1389 if (!printed_version++)
1389 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 1390 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
1390 1391
1391 /* 1392 /*
1392 * If this driver happens to only be useful on Apple's K2, then 1393 * If this driver happens to only be useful on Apple's K2, then
diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c
index d68dc7d3422c..a5e245c098e1 100644
--- a/drivers/scsi/sata_uli.c
+++ b/drivers/scsi/sata_uli.c
@@ -32,6 +32,7 @@
32#include <linux/blkdev.h> 32#include <linux/blkdev.h>
33#include <linux/delay.h> 33#include <linux/delay.h>
34#include <linux/interrupt.h> 34#include <linux/interrupt.h>
35#include <linux/device.h>
35#include "scsi.h" 36#include "scsi.h"
36#include <scsi/scsi_host.h> 37#include <scsi/scsi_host.h>
37#include <linux/libata.h> 38#include <linux/libata.h>
@@ -178,12 +179,16 @@ static void uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
178 179
179static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 180static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
180{ 181{
182 static int printed_version;
181 struct ata_probe_ent *probe_ent; 183 struct ata_probe_ent *probe_ent;
182 struct ata_port_info *ppi; 184 struct ata_port_info *ppi;
183 int rc; 185 int rc;
184 unsigned int board_idx = (unsigned int) ent->driver_data; 186 unsigned int board_idx = (unsigned int) ent->driver_data;
185 int pci_dev_busy = 0; 187 int pci_dev_busy = 0;
186 188
189 if (!printed_version++)
190 dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
191
187 rc = pci_enable_device(pdev); 192 rc = pci_enable_device(pdev);
188 if (rc) 193 if (rc)
189 return rc; 194 return rc;
diff --git a/drivers/scsi/sata_via.c b/drivers/scsi/sata_via.c
index 80e291a909a9..b3ecdbe400e9 100644
--- a/drivers/scsi/sata_via.c
+++ b/drivers/scsi/sata_via.c
@@ -41,6 +41,7 @@
41#include <linux/init.h> 41#include <linux/init.h>
42#include <linux/blkdev.h> 42#include <linux/blkdev.h>
43#include <linux/delay.h> 43#include <linux/delay.h>
44#include <linux/device.h>
44#include "scsi.h" 45#include "scsi.h"
45#include <scsi/scsi_host.h> 46#include <scsi/scsi_host.h>
46#include <linux/libata.h> 47#include <linux/libata.h>
@@ -259,15 +260,15 @@ static void svia_configure(struct pci_dev *pdev)
259 u8 tmp8; 260 u8 tmp8;
260 261
261 pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, &tmp8); 262 pci_read_config_byte(pdev, PCI_INTERRUPT_LINE, &tmp8);
262 printk(KERN_INFO DRV_NAME "(%s): routed to hard irq line %d\n", 263 dev_printk(KERN_INFO, &pdev->dev, "routed to hard irq line %d\n",
263 pci_name(pdev),
264 (int) (tmp8 & 0xf0) == 0xf0 ? 0 : tmp8 & 0x0f); 264 (int) (tmp8 & 0xf0) == 0xf0 ? 0 : tmp8 & 0x0f);
265 265
266 /* make sure SATA channels are enabled */ 266 /* make sure SATA channels are enabled */
267 pci_read_config_byte(pdev, SATA_CHAN_ENAB, &tmp8); 267 pci_read_config_byte(pdev, SATA_CHAN_ENAB, &tmp8);
268 if ((tmp8 & ALL_PORTS) != ALL_PORTS) { 268 if ((tmp8 & ALL_PORTS) != ALL_PORTS) {
269 printk(KERN_DEBUG DRV_NAME "(%s): enabling SATA channels (0x%x)\n", 269 dev_printk(KERN_DEBUG, &pdev->dev,
270 pci_name(pdev), (int) tmp8); 270 "enabling SATA channels (0x%x)\n",
271 (int) tmp8);
271 tmp8 |= ALL_PORTS; 272 tmp8 |= ALL_PORTS;
272 pci_write_config_byte(pdev, SATA_CHAN_ENAB, tmp8); 273 pci_write_config_byte(pdev, SATA_CHAN_ENAB, tmp8);
273 } 274 }
@@ -275,8 +276,9 @@ static void svia_configure(struct pci_dev *pdev)
275 /* make sure interrupts for each channel sent to us */ 276 /* make sure interrupts for each channel sent to us */
276 pci_read_config_byte(pdev, SATA_INT_GATE, &tmp8); 277 pci_read_config_byte(pdev, SATA_INT_GATE, &tmp8);
277 if ((tmp8 & ALL_PORTS) != ALL_PORTS) { 278 if ((tmp8 & ALL_PORTS) != ALL_PORTS) {
278 printk(KERN_DEBUG DRV_NAME "(%s): enabling SATA channel interrupts (0x%x)\n", 279 dev_printk(KERN_DEBUG, &pdev->dev,
279 pci_name(pdev), (int) tmp8); 280 "enabling SATA channel interrupts (0x%x)\n",
281 (int) tmp8);
280 tmp8 |= ALL_PORTS; 282 tmp8 |= ALL_PORTS;
281 pci_write_config_byte(pdev, SATA_INT_GATE, tmp8); 283 pci_write_config_byte(pdev, SATA_INT_GATE, tmp8);
282 } 284 }
@@ -284,8 +286,9 @@ static void svia_configure(struct pci_dev *pdev)
284 /* make sure native mode is enabled */ 286 /* make sure native mode is enabled */
285 pci_read_config_byte(pdev, SATA_NATIVE_MODE, &tmp8); 287 pci_read_config_byte(pdev, SATA_NATIVE_MODE, &tmp8);
286 if ((tmp8 & NATIVE_MODE_ALL) != NATIVE_MODE_ALL) { 288 if ((tmp8 & NATIVE_MODE_ALL) != NATIVE_MODE_ALL) {
287 printk(KERN_DEBUG DRV_NAME "(%s): enabling SATA channel native mode (0x%x)\n", 289 dev_printk(KERN_DEBUG, &pdev->dev,
288 pci_name(pdev), (int) tmp8); 290 "enabling SATA channel native mode (0x%x)\n",
291 (int) tmp8);
289 tmp8 |= NATIVE_MODE_ALL; 292 tmp8 |= NATIVE_MODE_ALL;
290 pci_write_config_byte(pdev, SATA_NATIVE_MODE, tmp8); 293 pci_write_config_byte(pdev, SATA_NATIVE_MODE, tmp8);
291 } 294 }
@@ -303,7 +306,7 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
303 u8 tmp8; 306 u8 tmp8;
304 307
305 if (!printed_version++) 308 if (!printed_version++)
306 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 309 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
307 310
308 rc = pci_enable_device(pdev); 311 rc = pci_enable_device(pdev);
309 if (rc) 312 if (rc)
@@ -318,8 +321,9 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
318 if (board_id == vt6420) { 321 if (board_id == vt6420) {
319 pci_read_config_byte(pdev, SATA_PATA_SHARING, &tmp8); 322 pci_read_config_byte(pdev, SATA_PATA_SHARING, &tmp8);
320 if (tmp8 & SATA_2DEV) { 323 if (tmp8 & SATA_2DEV) {
321 printk(KERN_ERR DRV_NAME "(%s): SATA master/slave not supported (0x%x)\n", 324 dev_printk(KERN_ERR, &pdev->dev,
322 pci_name(pdev), (int) tmp8); 325 "SATA master/slave not supported (0x%x)\n",
326 (int) tmp8);
323 rc = -EIO; 327 rc = -EIO;
324 goto err_out_regions; 328 goto err_out_regions;
325 } 329 }
@@ -332,10 +336,11 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
332 for (i = 0; i < ARRAY_SIZE(svia_bar_sizes); i++) 336 for (i = 0; i < ARRAY_SIZE(svia_bar_sizes); i++)
333 if ((pci_resource_start(pdev, i) == 0) || 337 if ((pci_resource_start(pdev, i) == 0) ||
334 (pci_resource_len(pdev, i) < bar_sizes[i])) { 338 (pci_resource_len(pdev, i) < bar_sizes[i])) {
335 printk(KERN_ERR DRV_NAME "(%s): invalid PCI BAR %u (sz 0x%lx, val 0x%lx)\n", 339 dev_printk(KERN_ERR, &pdev->dev,
336 pci_name(pdev), i, 340 "invalid PCI BAR %u (sz 0x%lx, val 0x%lx)\n",
337 pci_resource_start(pdev, i), 341 i,
338 pci_resource_len(pdev, i)); 342 pci_resource_start(pdev, i),
343 pci_resource_len(pdev, i));
339 rc = -ENODEV; 344 rc = -ENODEV;
340 goto err_out_regions; 345 goto err_out_regions;
341 } 346 }
@@ -353,8 +358,7 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
353 probe_ent = vt6421_init_probe_ent(pdev); 358 probe_ent = vt6421_init_probe_ent(pdev);
354 359
355 if (!probe_ent) { 360 if (!probe_ent) {
356 printk(KERN_ERR DRV_NAME "(%s): out of memory\n", 361 dev_printk(KERN_ERR, &pdev->dev, "out of memory\n");
357 pci_name(pdev));
358 rc = -ENOMEM; 362 rc = -ENOMEM;
359 goto err_out_regions; 363 goto err_out_regions;
360 } 364 }
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c
index 3766afe4b288..4349bc9193e3 100644
--- a/drivers/scsi/sata_vsc.c
+++ b/drivers/scsi/sata_vsc.c
@@ -42,6 +42,7 @@
42#include <linux/delay.h> 42#include <linux/delay.h>
43#include <linux/interrupt.h> 43#include <linux/interrupt.h>
44#include <linux/dma-mapping.h> 44#include <linux/dma-mapping.h>
45#include <linux/device.h>
45#include "scsi.h" 46#include "scsi.h"
46#include <scsi/scsi_host.h> 47#include <scsi/scsi_host.h>
47#include <linux/libata.h> 48#include <linux/libata.h>
@@ -295,7 +296,7 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d
295 int rc; 296 int rc;
296 297
297 if (!printed_version++) 298 if (!printed_version++)
298 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 299 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
299 300
300 rc = pci_enable_device(pdev); 301 rc = pci_enable_device(pdev);
301 if (rc) 302 if (rc)
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index f2781ca42761..fc0f12ba89cc 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1274,14 +1274,12 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
1274 } 1274 }
1275 1275
1276 if ((fattr->valid & NFS_ATTR_FATTR) == 0) { 1276 if ((fattr->valid & NFS_ATTR_FATTR) == 0) {
1277 spin_unlock(&inode->i_lock);
1278 return 0; 1277 return 0;
1279 } 1278 }
1280 1279
1281 /* Has the inode gone and changed behind our back? */ 1280 /* Has the inode gone and changed behind our back? */
1282 if (nfsi->fileid != fattr->fileid 1281 if (nfsi->fileid != fattr->fileid
1283 || (inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) { 1282 || (inode->i_mode & S_IFMT) != (fattr->mode & S_IFMT)) {
1284 spin_unlock(&inode->i_lock);
1285 return -EIO; 1283 return -EIO;
1286 } 1284 }
1287 1285
diff --git a/include/linux/libata.h b/include/linux/libata.h
index ed6aacc236dd..457bdc44e4b1 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -175,6 +175,13 @@ enum hsm_task_states {
175 write CDB or first data block */ 175 write CDB or first data block */
176}; 176};
177 177
178enum ata_completion_errors {
179 AC_ERR_OTHER = (1 << 0),
180 AC_ERR_DEV = (1 << 1),
181 AC_ERR_ATA_BUS = (1 << 2),
182 AC_ERR_HOST_BUS = (1 << 3),
183};
184
178/* forward declarations */ 185/* forward declarations */
179struct scsi_device; 186struct scsi_device;
180struct ata_port_operations; 187struct ata_port_operations;
@@ -182,7 +189,7 @@ struct ata_port;
182struct ata_queued_cmd; 189struct ata_queued_cmd;
183 190
184/* typedefs */ 191/* typedefs */
185typedef int (*ata_qc_cb_t) (struct ata_queued_cmd *qc, u8 drv_stat); 192typedef int (*ata_qc_cb_t) (struct ata_queued_cmd *qc, unsigned int err_mask);
186 193
187struct ata_ioports { 194struct ata_ioports {
188 unsigned long cmd_addr; 195 unsigned long cmd_addr;
@@ -456,7 +463,7 @@ extern void ata_bmdma_start (struct ata_queued_cmd *qc);
456extern void ata_bmdma_stop(struct ata_queued_cmd *qc); 463extern void ata_bmdma_stop(struct ata_queued_cmd *qc);
457extern u8 ata_bmdma_status(struct ata_port *ap); 464extern u8 ata_bmdma_status(struct ata_port *ap);
458extern void ata_bmdma_irq_clear(struct ata_port *ap); 465extern void ata_bmdma_irq_clear(struct ata_port *ap);
459extern void ata_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat); 466extern void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask);
460extern void ata_eng_timeout(struct ata_port *ap); 467extern void ata_eng_timeout(struct ata_port *ap);
461extern void ata_scsi_simulate(u16 *id, struct scsi_cmnd *cmd, 468extern void ata_scsi_simulate(u16 *id, struct scsi_cmnd *cmd,
462 void (*done)(struct scsi_cmnd *)); 469 void (*done)(struct scsi_cmnd *));
@@ -719,4 +726,21 @@ static inline int ata_try_flush_cache(const struct ata_device *dev)
719 ata_id_has_flush_ext(dev->id); 726 ata_id_has_flush_ext(dev->id);
720} 727}
721 728
729static inline unsigned int ac_err_mask(u8 status)
730{
731 if (status & ATA_BUSY)
732 return AC_ERR_ATA_BUS;
733 if (status & (ATA_ERR | ATA_DF))
734 return AC_ERR_DEV;
735 return 0;
736}
737
738static inline unsigned int __ac_err_mask(u8 status)
739{
740 unsigned int mask = ac_err_mask(status);
741 if (mask == 0)
742 return AC_ERR_OTHER;
743 return mask;
744}
745
722#endif /* __LINUX_LIBATA_H__ */ 746#endif /* __LINUX_LIBATA_H__ */