diff options
author | Tejun Heo <htejun@gmail.com> | 2007-01-20 02:00:28 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-02-09 17:39:37 -0500 |
commit | f0d36efdc624beb3d9e29b9ab9e9537bf0f25d5b (patch) | |
tree | eac4efb465aa682d6eaac61f76b3174ffd9fd8cd /drivers/ata/libata-sff.c | |
parent | 0529c159dbdd79794796c1b50b39442d72efbe97 (diff) |
libata: update libata core layer to use devres
Update libata core layer to use devres.
* ata_device_add() acquires all resources in managed mode.
* ata_host is allocated as devres associated with ata_host_release.
* Port attached status is handled as devres associated with
ata_host_attach_release().
* Initialization failure and host removal is handedl by releasing
devres group.
* Except for ata_scsi_release() removal, LLD interface remains the
same. Some functions use hacky is_managed test to support both
managed and unmanaged devices. These will go away once all LLDs are
updated to use devres.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/libata-sff.c')
-rw-r--r-- | drivers/ata/libata-sff.c | 56 |
1 files changed, 21 insertions, 35 deletions
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c index 9bbc8749620a..21efe92a7135 100644 --- a/drivers/ata/libata-sff.c +++ b/drivers/ata/libata-sff.c | |||
@@ -1006,15 +1006,18 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, | |||
1006 | int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | 1006 | int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, |
1007 | unsigned int n_ports) | 1007 | unsigned int n_ports) |
1008 | { | 1008 | { |
1009 | struct device *dev = &pdev->dev; | ||
1009 | struct ata_probe_ent *probe_ent = NULL; | 1010 | struct ata_probe_ent *probe_ent = NULL; |
1010 | struct ata_port_info *port[2]; | 1011 | struct ata_port_info *port[2]; |
1011 | u8 mask; | 1012 | u8 mask; |
1012 | unsigned int legacy_mode = 0; | 1013 | unsigned int legacy_mode = 0; |
1013 | int disable_dev_on_err = 1; | ||
1014 | int rc; | 1014 | int rc; |
1015 | 1015 | ||
1016 | DPRINTK("ENTER\n"); | 1016 | DPRINTK("ENTER\n"); |
1017 | 1017 | ||
1018 | if (!devres_open_group(dev, NULL, GFP_KERNEL)) | ||
1019 | return -ENOMEM; | ||
1020 | |||
1018 | BUG_ON(n_ports < 1 || n_ports > 2); | 1021 | BUG_ON(n_ports < 1 || n_ports > 2); |
1019 | 1022 | ||
1020 | port[0] = port_info[0]; | 1023 | port[0] = port_info[0]; |
@@ -1031,9 +1034,9 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | |||
1031 | boot for the primary video which is BIOS enabled | 1034 | boot for the primary video which is BIOS enabled |
1032 | */ | 1035 | */ |
1033 | 1036 | ||
1034 | rc = pci_enable_device(pdev); | 1037 | rc = pcim_enable_device(pdev); |
1035 | if (rc) | 1038 | if (rc) |
1036 | return rc; | 1039 | goto err_out; |
1037 | 1040 | ||
1038 | if ((pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) { | 1041 | if ((pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) { |
1039 | u8 tmp8; | 1042 | u8 tmp8; |
@@ -1049,7 +1052,8 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | |||
1049 | left a device in compatibility mode */ | 1052 | left a device in compatibility mode */ |
1050 | if (legacy_mode) { | 1053 | if (legacy_mode) { |
1051 | printk(KERN_ERR "ata: Compatibility mode ATA is not supported on this platform, skipping.\n"); | 1054 | printk(KERN_ERR "ata: Compatibility mode ATA is not supported on this platform, skipping.\n"); |
1052 | return -EOPNOTSUPP; | 1055 | rc = -EOPNOTSUPP; |
1056 | goto err_out; | ||
1053 | } | 1057 | } |
1054 | #endif | 1058 | #endif |
1055 | } | 1059 | } |
@@ -1057,13 +1061,13 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | |||
1057 | if (!legacy_mode) { | 1061 | if (!legacy_mode) { |
1058 | rc = pci_request_regions(pdev, DRV_NAME); | 1062 | rc = pci_request_regions(pdev, DRV_NAME); |
1059 | if (rc) { | 1063 | if (rc) { |
1060 | disable_dev_on_err = 0; | 1064 | pcim_pin_device(pdev); |
1061 | goto err_out; | 1065 | goto err_out; |
1062 | } | 1066 | } |
1063 | } else { | 1067 | } else { |
1064 | /* Deal with combined mode hack. This side of the logic all | 1068 | /* Deal with combined mode hack. This side of the logic all |
1065 | goes away once the combined mode hack is killed in 2.6.21 */ | 1069 | goes away once the combined mode hack is killed in 2.6.21 */ |
1066 | if (!request_region(ATA_PRIMARY_CMD, 8, "libata")) { | 1070 | if (!devm_request_region(dev, ATA_PRIMARY_CMD, 8, "libata")) { |
1067 | struct resource *conflict, res; | 1071 | struct resource *conflict, res; |
1068 | res.start = ATA_PRIMARY_CMD; | 1072 | res.start = ATA_PRIMARY_CMD; |
1069 | res.end = ATA_PRIMARY_CMD + 8 - 1; | 1073 | res.end = ATA_PRIMARY_CMD + 8 - 1; |
@@ -1073,7 +1077,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | |||
1073 | if (!strcmp(conflict->name, "libata")) | 1077 | if (!strcmp(conflict->name, "libata")) |
1074 | legacy_mode |= ATA_PORT_PRIMARY; | 1078 | legacy_mode |= ATA_PORT_PRIMARY; |
1075 | else { | 1079 | else { |
1076 | disable_dev_on_err = 0; | 1080 | pcim_pin_device(pdev); |
1077 | printk(KERN_WARNING "ata: 0x%0X IDE port busy\n" \ | 1081 | printk(KERN_WARNING "ata: 0x%0X IDE port busy\n" \ |
1078 | "ata: conflict with %s\n", | 1082 | "ata: conflict with %s\n", |
1079 | ATA_PRIMARY_CMD, | 1083 | ATA_PRIMARY_CMD, |
@@ -1082,7 +1086,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | |||
1082 | } else | 1086 | } else |
1083 | legacy_mode |= ATA_PORT_PRIMARY; | 1087 | legacy_mode |= ATA_PORT_PRIMARY; |
1084 | 1088 | ||
1085 | if (!request_region(ATA_SECONDARY_CMD, 8, "libata")) { | 1089 | if (!devm_request_region(dev, ATA_SECONDARY_CMD, 8, "libata")) { |
1086 | struct resource *conflict, res; | 1090 | struct resource *conflict, res; |
1087 | res.start = ATA_SECONDARY_CMD; | 1091 | res.start = ATA_SECONDARY_CMD; |
1088 | res.end = ATA_SECONDARY_CMD + 8 - 1; | 1092 | res.end = ATA_SECONDARY_CMD + 8 - 1; |
@@ -1092,7 +1096,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | |||
1092 | if (!strcmp(conflict->name, "libata")) | 1096 | if (!strcmp(conflict->name, "libata")) |
1093 | legacy_mode |= ATA_PORT_SECONDARY; | 1097 | legacy_mode |= ATA_PORT_SECONDARY; |
1094 | else { | 1098 | else { |
1095 | disable_dev_on_err = 0; | 1099 | pcim_pin_device(pdev); |
1096 | printk(KERN_WARNING "ata: 0x%X IDE port busy\n" \ | 1100 | printk(KERN_WARNING "ata: 0x%X IDE port busy\n" \ |
1097 | "ata: conflict with %s\n", | 1101 | "ata: conflict with %s\n", |
1098 | ATA_SECONDARY_CMD, | 1102 | ATA_SECONDARY_CMD, |
@@ -1112,16 +1116,16 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | |||
1112 | /* we have legacy mode, but all ports are unavailable */ | 1116 | /* we have legacy mode, but all ports are unavailable */ |
1113 | if (legacy_mode == (1 << 3)) { | 1117 | if (legacy_mode == (1 << 3)) { |
1114 | rc = -EBUSY; | 1118 | rc = -EBUSY; |
1115 | goto err_out_regions; | 1119 | goto err_out; |
1116 | } | 1120 | } |
1117 | 1121 | ||
1118 | /* TODO: If we get no DMA mask we should fall back to PIO */ | 1122 | /* TODO: If we get no DMA mask we should fall back to PIO */ |
1119 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | 1123 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); |
1120 | if (rc) | 1124 | if (rc) |
1121 | goto err_out_regions; | 1125 | goto err_out; |
1122 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | 1126 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); |
1123 | if (rc) | 1127 | if (rc) |
1124 | goto err_out_regions; | 1128 | goto err_out; |
1125 | 1129 | ||
1126 | if (legacy_mode) { | 1130 | if (legacy_mode) { |
1127 | probe_ent = ata_pci_init_legacy_port(pdev, port, legacy_mode); | 1131 | probe_ent = ata_pci_init_legacy_port(pdev, port, legacy_mode); |
@@ -1133,40 +1137,22 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, | |||
1133 | } | 1137 | } |
1134 | if (!probe_ent) { | 1138 | if (!probe_ent) { |
1135 | rc = -ENOMEM; | 1139 | rc = -ENOMEM; |
1136 | goto err_out_regions; | 1140 | goto err_out; |
1137 | } | 1141 | } |
1138 | 1142 | ||
1139 | pci_set_master(pdev); | 1143 | pci_set_master(pdev); |
1140 | 1144 | ||
1141 | if (!ata_device_add(probe_ent)) { | 1145 | if (!ata_device_add(probe_ent)) { |
1142 | rc = -ENODEV; | 1146 | rc = -ENODEV; |
1143 | goto err_out_ent; | 1147 | goto err_out; |
1144 | } | 1148 | } |
1145 | 1149 | ||
1146 | kfree(probe_ent); | 1150 | devm_kfree(dev, probe_ent); |
1147 | 1151 | devres_remove_group(dev, NULL); | |
1148 | return 0; | 1152 | return 0; |
1149 | 1153 | ||
1150 | err_out_ent: | ||
1151 | kfree(probe_ent); | ||
1152 | err_out_regions: | ||
1153 | /* All this conditional stuff is needed for the combined mode hack | ||
1154 | until 2.6.21 when it can go */ | ||
1155 | if (legacy_mode) { | ||
1156 | pci_release_region(pdev, 4); | ||
1157 | if (legacy_mode & ATA_PORT_PRIMARY) { | ||
1158 | release_region(ATA_PRIMARY_CMD, 8); | ||
1159 | pci_release_region(pdev, 1); | ||
1160 | } | ||
1161 | if (legacy_mode & ATA_PORT_SECONDARY) { | ||
1162 | release_region(ATA_SECONDARY_CMD, 8); | ||
1163 | pci_release_region(pdev, 3); | ||
1164 | } | ||
1165 | } else | ||
1166 | pci_release_regions(pdev); | ||
1167 | err_out: | 1154 | err_out: |
1168 | if (disable_dev_on_err) | 1155 | devres_release_group(dev, NULL); |
1169 | pci_disable_device(pdev); | ||
1170 | return rc; | 1156 | return rc; |
1171 | } | 1157 | } |
1172 | 1158 | ||