aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ata/libata-sff.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 08b3a407473e..a620e235ccc2 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -946,35 +946,21 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
946{ 946{
947 struct ata_probe_ent *probe_ent = NULL; 947 struct ata_probe_ent *probe_ent = NULL;
948 struct ata_port_info *port[2]; 948 struct ata_port_info *port[2];
949 u8 tmp8, mask; 949 u8 mask;
950 unsigned int legacy_mode = 0; 950 unsigned int legacy_mode = 0;
951 int disable_dev_on_err = 1; 951 int disable_dev_on_err = 1;
952 int rc; 952 int rc;
953 953
954 DPRINTK("ENTER\n"); 954 DPRINTK("ENTER\n");
955 955
956 BUG_ON(n_ports < 1 || n_ports > 2);
957
956 port[0] = port_info[0]; 958 port[0] = port_info[0];
957 if (n_ports > 1) 959 if (n_ports > 1)
958 port[1] = port_info[1]; 960 port[1] = port_info[1];
959 else 961 else
960 port[1] = port[0]; 962 port[1] = port[0];
961 963
962 if ((port[0]->flags & ATA_FLAG_NO_LEGACY) == 0
963 && (pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) {
964 /* TODO: What if one channel is in native mode ... */
965 pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8);
966 mask = (1 << 2) | (1 << 0);
967 if ((tmp8 & mask) != mask)
968 legacy_mode = (1 << 3);
969 }
970
971 /* FIXME... */
972 if ((!legacy_mode) && (n_ports > 2)) {
973 printk(KERN_ERR "ata: BUG: native mode, n_ports > 2\n");
974 n_ports = 2;
975 /* For now */
976 }
977
978 /* FIXME: Really for ATA it isn't safe because the device may be 964 /* FIXME: Really for ATA it isn't safe because the device may be
979 multi-purpose and we want to leave it alone if it was already 965 multi-purpose and we want to leave it alone if it was already
980 enabled. Secondly for shared use as Arjan says we want refcounting 966 enabled. Secondly for shared use as Arjan says we want refcounting
@@ -987,6 +973,16 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
987 if (rc) 973 if (rc)
988 return rc; 974 return rc;
989 975
976 if ((pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) {
977 u8 tmp8;
978
979 /* TODO: What if one channel is in native mode ... */
980 pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8);
981 mask = (1 << 2) | (1 << 0);
982 if ((tmp8 & mask) != mask)
983 legacy_mode = (1 << 3);
984 }
985
990 rc = pci_request_regions(pdev, DRV_NAME); 986 rc = pci_request_regions(pdev, DRV_NAME);
991 if (rc) { 987 if (rc) {
992 disable_dev_on_err = 0; 988 disable_dev_on_err = 0;
@@ -1039,7 +1035,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
1039 goto err_out_regions; 1035 goto err_out_regions;
1040 } 1036 }
1041 1037
1042 /* FIXME: If we get no DMA mask we should fall back to PIO */ 1038 /* TODO: If we get no DMA mask we should fall back to PIO */
1043 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); 1039 rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
1044 if (rc) 1040 if (rc)
1045 goto err_out_regions; 1041 goto err_out_regions;
@@ -1062,13 +1058,17 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
1062 1058
1063 pci_set_master(pdev); 1059 pci_set_master(pdev);
1064 1060
1065 /* FIXME: check ata_device_add return */ 1061 if (!ata_device_add(probe_ent)) {
1066 ata_device_add(probe_ent); 1062 rc = -ENODEV;
1063 goto err_out_ent;
1064 }
1067 1065
1068 kfree(probe_ent); 1066 kfree(probe_ent);
1069 1067
1070 return 0; 1068 return 0;
1071 1069
1070err_out_ent:
1071 kfree(probe_ent);
1072err_out_regions: 1072err_out_regions:
1073 if (legacy_mode & ATA_PORT_PRIMARY) 1073 if (legacy_mode & ATA_PORT_PRIMARY)
1074 release_region(ATA_PRIMARY_CMD, 8); 1074 release_region(ATA_PRIMARY_CMD, 8);