diff options
author | Tejun Heo <htejun@gmail.com> | 2006-03-01 02:09:35 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-03-03 17:31:04 -0500 |
commit | ffeae418c12a304f6a9b6468043954d4e67a2b1e (patch) | |
tree | 789b1a221d2f454c496e9220246cfb094ea386dc /drivers/scsi | |
parent | d9572b1d5e60b63e27e17f1f7771c5a26dd5d81e (diff) |
[PATCH] libata: separate out ata_dev_configure()
Separate out ata_dev_configure() from ata_dev_identify() such that
ata_dev_configure() only configures @dev according to passed in @id.
The function now does not disable device on failure, it just returns
appropirate error code.
As this change leaves ata_dev_identify() with only reading ID, calling
configure and disabling devices according to the results, this patch
also kills ata_dev_identify() and inlines the logic into
ata_bus_probe().
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/libata-core.c | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index fecda706d85..ba26c66cc11 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -1054,45 +1054,31 @@ static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev, | |||
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | /** | 1056 | /** |
1057 | * ata_dev_identify - obtain IDENTIFY x DEVICE page | 1057 | * ata_dev_configure - Configure the specified ATA/ATAPI device |
1058 | * @ap: port on which device we wish to probe resides | 1058 | * @ap: Port on which target device resides |
1059 | * @device: device bus address, starting at zero | 1059 | * @dev: Target device to configure |
1060 | * | 1060 | * |
1061 | * Following bus reset, we issue the IDENTIFY [PACKET] DEVICE | 1061 | * Configure @dev according to @dev->id. Generic and low-level |
1062 | * command, and read back the 512-byte device information page. | 1062 | * driver specific fixups are also applied. |
1063 | * The device information page is fed to us via the standard | ||
1064 | * PIO-IN protocol, but we hand-code it here. (TODO: investigate | ||
1065 | * using standard PIO-IN paths) | ||
1066 | * | ||
1067 | * After reading the device information page, we use several | ||
1068 | * bits of information from it to initialize data structures | ||
1069 | * that will be used during the lifetime of the ata_device. | ||
1070 | * Other data from the info page is used to disqualify certain | ||
1071 | * older ATA devices we do not wish to support. | ||
1072 | * | 1063 | * |
1073 | * LOCKING: | 1064 | * LOCKING: |
1074 | * Inherited from caller. Some functions called by this function | 1065 | * Kernel thread context (may sleep) |
1075 | * obtain the host_set lock. | 1066 | * |
1067 | * RETURNS: | ||
1068 | * 0 on success, -errno otherwise | ||
1076 | */ | 1069 | */ |
1077 | 1070 | static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev) | |
1078 | static void ata_dev_identify(struct ata_port *ap, unsigned int device) | ||
1079 | { | 1071 | { |
1080 | struct ata_device *dev = &ap->device[device]; | ||
1081 | unsigned long xfer_modes; | 1072 | unsigned long xfer_modes; |
1082 | int i, rc; | 1073 | int i, rc; |
1083 | 1074 | ||
1084 | if (!ata_dev_present(dev)) { | 1075 | if (!ata_dev_present(dev)) { |
1085 | DPRINTK("ENTER/EXIT (host %u, dev %u) -- nodev\n", | 1076 | DPRINTK("ENTER/EXIT (host %u, dev %u) -- nodev\n", |
1086 | ap->id, device); | 1077 | ap->id, dev->devno); |
1087 | return; | 1078 | return 0; |
1088 | } | 1079 | } |
1089 | 1080 | ||
1090 | DPRINTK("ENTER, host %u, dev %u\n", ap->id, device); | 1081 | DPRINTK("ENTER, host %u, dev %u\n", ap->id, dev->devno); |
1091 | |||
1092 | WARN_ON(dev->id != NULL); | ||
1093 | rc = ata_dev_read_id(ap, dev, &dev->class, 1, &dev->id); | ||
1094 | if (rc) | ||
1095 | goto err_out; | ||
1096 | 1082 | ||
1097 | /* | 1083 | /* |
1098 | * common ATA, ATAPI feature tests | 1084 | * common ATA, ATAPI feature tests |
@@ -1101,6 +1087,7 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) | |||
1101 | /* we require DMA support (bits 8 of word 49) */ | 1087 | /* we require DMA support (bits 8 of word 49) */ |
1102 | if (!ata_id_has_dma(dev->id)) { | 1088 | if (!ata_id_has_dma(dev->id)) { |
1103 | printk(KERN_DEBUG "ata%u: no dma\n", ap->id); | 1089 | printk(KERN_DEBUG "ata%u: no dma\n", ap->id); |
1090 | rc = -EINVAL; | ||
1104 | goto err_out_nosup; | 1091 | goto err_out_nosup; |
1105 | } | 1092 | } |
1106 | 1093 | ||
@@ -1125,12 +1112,12 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) | |||
1125 | 1112 | ||
1126 | /* print device info to dmesg */ | 1113 | /* print device info to dmesg */ |
1127 | printk(KERN_INFO "ata%u: dev %u ATA-%d, max %s, %Lu sectors:%s\n", | 1114 | printk(KERN_INFO "ata%u: dev %u ATA-%d, max %s, %Lu sectors:%s\n", |
1128 | ap->id, device, | 1115 | ap->id, dev->devno, |
1129 | ata_id_major_version(dev->id), | 1116 | ata_id_major_version(dev->id), |
1130 | ata_mode_string(xfer_modes), | 1117 | ata_mode_string(xfer_modes), |
1131 | (unsigned long long)dev->n_sectors, | 1118 | (unsigned long long)dev->n_sectors, |
1132 | dev->flags & ATA_DFLAG_LBA48 ? " LBA48" : " LBA"); | 1119 | dev->flags & ATA_DFLAG_LBA48 ? " LBA48" : " LBA"); |
1133 | } else { | 1120 | } else { |
1134 | /* CHS */ | 1121 | /* CHS */ |
1135 | 1122 | ||
1136 | /* Default translation */ | 1123 | /* Default translation */ |
@@ -1147,7 +1134,7 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) | |||
1147 | 1134 | ||
1148 | /* print device info to dmesg */ | 1135 | /* print device info to dmesg */ |
1149 | printk(KERN_INFO "ata%u: dev %u ATA-%d, max %s, %Lu sectors: CHS %d/%d/%d\n", | 1136 | printk(KERN_INFO "ata%u: dev %u ATA-%d, max %s, %Lu sectors: CHS %d/%d/%d\n", |
1150 | ap->id, device, | 1137 | ap->id, dev->devno, |
1151 | ata_id_major_version(dev->id), | 1138 | ata_id_major_version(dev->id), |
1152 | ata_mode_string(xfer_modes), | 1139 | ata_mode_string(xfer_modes), |
1153 | (unsigned long long)dev->n_sectors, | 1140 | (unsigned long long)dev->n_sectors, |
@@ -1163,13 +1150,14 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) | |||
1163 | rc = atapi_cdb_len(dev->id); | 1150 | rc = atapi_cdb_len(dev->id); |
1164 | if ((rc < 12) || (rc > ATAPI_CDB_LEN)) { | 1151 | if ((rc < 12) || (rc > ATAPI_CDB_LEN)) { |
1165 | printk(KERN_WARNING "ata%u: unsupported CDB len\n", ap->id); | 1152 | printk(KERN_WARNING "ata%u: unsupported CDB len\n", ap->id); |
1153 | rc = -EINVAL; | ||
1166 | goto err_out_nosup; | 1154 | goto err_out_nosup; |
1167 | } | 1155 | } |
1168 | dev->cdb_len = (unsigned int) rc; | 1156 | dev->cdb_len = (unsigned int) rc; |
1169 | 1157 | ||
1170 | /* print device info to dmesg */ | 1158 | /* print device info to dmesg */ |
1171 | printk(KERN_INFO "ata%u: dev %u ATAPI, max %s\n", | 1159 | printk(KERN_INFO "ata%u: dev %u ATAPI, max %s\n", |
1172 | ap->id, device, | 1160 | ap->id, dev->devno, |
1173 | ata_mode_string(xfer_modes)); | 1161 | ata_mode_string(xfer_modes)); |
1174 | } | 1162 | } |
1175 | 1163 | ||
@@ -1180,14 +1168,13 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) | |||
1180 | ap->device[i].cdb_len); | 1168 | ap->device[i].cdb_len); |
1181 | 1169 | ||
1182 | DPRINTK("EXIT, drv_stat = 0x%x\n", ata_chk_status(ap)); | 1170 | DPRINTK("EXIT, drv_stat = 0x%x\n", ata_chk_status(ap)); |
1183 | return; | 1171 | return 0; |
1184 | 1172 | ||
1185 | err_out_nosup: | 1173 | err_out_nosup: |
1186 | printk(KERN_WARNING "ata%u: dev %u not supported, ignoring\n", | 1174 | printk(KERN_WARNING "ata%u: dev %u not supported, ignoring\n", |
1187 | ap->id, device); | 1175 | ap->id, dev->devno); |
1188 | err_out: | ||
1189 | dev->class++; /* converts ATA_DEV_xxx into ATA_DEV_xxx_UNSUP */ | ||
1190 | DPRINTK("EXIT, err\n"); | 1176 | DPRINTK("EXIT, err\n"); |
1177 | return rc; | ||
1191 | } | 1178 | } |
1192 | 1179 | ||
1193 | 1180 | ||
@@ -1263,11 +1250,24 @@ static int ata_bus_probe(struct ata_port *ap) | |||
1263 | goto err_out; | 1250 | goto err_out; |
1264 | 1251 | ||
1265 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 1252 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
1266 | ata_dev_identify(ap, i); | 1253 | struct ata_device *dev = &ap->device[i]; |
1267 | if (ata_dev_present(&ap->device[i])) { | 1254 | |
1268 | found = 1; | 1255 | if (!ata_dev_present(dev)) |
1269 | ata_dev_config(ap,i); | 1256 | continue; |
1257 | |||
1258 | WARN_ON(dev->id != NULL); | ||
1259 | if (ata_dev_read_id(ap, dev, &dev->class, 1, &dev->id)) { | ||
1260 | dev->class = ATA_DEV_NONE; | ||
1261 | continue; | ||
1270 | } | 1262 | } |
1263 | |||
1264 | if (ata_dev_configure(ap, dev)) { | ||
1265 | dev->class++; /* disable device */ | ||
1266 | continue; | ||
1267 | } | ||
1268 | |||
1269 | ata_dev_config(ap, i); | ||
1270 | found = 1; | ||
1271 | } | 1271 | } |
1272 | 1272 | ||
1273 | if ((!found) || (ap->flags & ATA_FLAG_PORT_DISABLED)) | 1273 | if ((!found) || (ap->flags & ATA_FLAG_PORT_DISABLED)) |