aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libata-core.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2005-12-13 00:49:31 -0500
committerJeff Garzik <jgarzik@pobox.com>2005-12-13 01:34:45 -0500
commita012370322eafee642369784ff71afe81f5a8592 (patch)
tree21888b2919dd6d8f2f2b5adb48c692ae24436391 /drivers/scsi/libata-core.c
parenta2a7a662f80d8b7f2295a36de1f9b033ed0b910c (diff)
[PATCH] libata: use ata_exec_internal()
This patch converts all users of libata internal commands to use ata_exec_internal(). Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
Diffstat (limited to 'drivers/scsi/libata-core.c')
-rw-r--r--drivers/scsi/libata-core.c145
1 files changed, 44 insertions, 101 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index de80abeab065..01070366bb19 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -1198,9 +1198,8 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
1198 u16 tmp; 1198 u16 tmp;
1199 unsigned long xfer_modes; 1199 unsigned long xfer_modes;
1200 unsigned int using_edd; 1200 unsigned int using_edd;
1201 DECLARE_COMPLETION(wait); 1201 struct ata_taskfile tf;
1202 struct ata_queued_cmd *qc; 1202 unsigned int err_mask;
1203 unsigned long flags;
1204 int rc; 1203 int rc;
1205 1204
1206 if (!ata_dev_present(dev)) { 1205 if (!ata_dev_present(dev)) {
@@ -1221,40 +1220,26 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
1221 1220
1222 ata_dev_select(ap, device, 1, 1); /* select device 0/1 */ 1221 ata_dev_select(ap, device, 1, 1); /* select device 0/1 */
1223 1222
1224 qc = ata_qc_new_init(ap, dev);
1225 BUG_ON(qc == NULL);
1226
1227 ata_sg_init_one(qc, dev->id, sizeof(dev->id));
1228 qc->dma_dir = DMA_FROM_DEVICE;
1229 qc->tf.protocol = ATA_PROT_PIO;
1230 qc->nsect = 1;
1231
1232retry: 1223retry:
1224 ata_tf_init(ap, &tf, device);
1225
1233 if (dev->class == ATA_DEV_ATA) { 1226 if (dev->class == ATA_DEV_ATA) {
1234 qc->tf.command = ATA_CMD_ID_ATA; 1227 tf.command = ATA_CMD_ID_ATA;
1235 DPRINTK("do ATA identify\n"); 1228 DPRINTK("do ATA identify\n");
1236 } else { 1229 } else {
1237 qc->tf.command = ATA_CMD_ID_ATAPI; 1230 tf.command = ATA_CMD_ID_ATAPI;
1238 DPRINTK("do ATAPI identify\n"); 1231 DPRINTK("do ATAPI identify\n");
1239 } 1232 }
1240 1233
1241 qc->waiting = &wait; 1234 tf.protocol = ATA_PROT_PIO;
1242 qc->complete_fn = ata_qc_complete_noop;
1243
1244 spin_lock_irqsave(&ap->host_set->lock, flags);
1245 rc = ata_qc_issue(qc);
1246 spin_unlock_irqrestore(&ap->host_set->lock, flags);
1247 1235
1248 if (rc) 1236 err_mask = ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE,
1249 goto err_out; 1237 dev->id, sizeof(dev->id));
1250 else
1251 ata_qc_wait_err(qc, &wait);
1252 1238
1253 spin_lock_irqsave(&ap->host_set->lock, flags); 1239 if (err_mask) {
1254 ap->ops->tf_read(ap, &qc->tf); 1240 if (err_mask & ~AC_ERR_DEV)
1255 spin_unlock_irqrestore(&ap->host_set->lock, flags); 1241 goto err_out;
1256 1242
1257 if (qc->tf.command & ATA_ERR) {
1258 /* 1243 /*
1259 * arg! EDD works for all test cases, but seems to return 1244 * arg! EDD works for all test cases, but seems to return
1260 * the ATA signature for some ATAPI devices. Until the 1245 * the ATA signature for some ATAPI devices. Until the
@@ -1267,14 +1252,9 @@ retry:
1267 * to have this problem. 1252 * to have this problem.
1268 */ 1253 */
1269 if ((using_edd) && (dev->class == ATA_DEV_ATA)) { 1254 if ((using_edd) && (dev->class == ATA_DEV_ATA)) {
1270 u8 err = qc->tf.feature; 1255 u8 err = tf.feature;
1271 if (err & ATA_ABORTED) { 1256 if (err & ATA_ABORTED) {
1272 dev->class = ATA_DEV_ATAPI; 1257 dev->class = ATA_DEV_ATAPI;
1273 qc->cursg = 0;
1274 qc->cursg_ofs = 0;
1275 qc->cursect = 0;
1276 qc->nsect = 1;
1277 qc->err_mask = 0;
1278 goto retry; 1258 goto retry;
1279 } 1259 }
1280 } 1260 }
@@ -2378,34 +2358,23 @@ static int ata_choose_xfer_mode(const struct ata_port *ap,
2378 2358
2379static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) 2359static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev)
2380{ 2360{
2381 DECLARE_COMPLETION(wait); 2361 struct ata_taskfile tf;
2382 struct ata_queued_cmd *qc;
2383 int rc;
2384 unsigned long flags;
2385 2362
2386 /* set up set-features taskfile */ 2363 /* set up set-features taskfile */
2387 DPRINTK("set features - xfer mode\n"); 2364 DPRINTK("set features - xfer mode\n");
2388 2365
2389 qc = ata_qc_new_init(ap, dev); 2366 ata_tf_init(ap, &tf, dev->devno);
2390 BUG_ON(qc == NULL); 2367 tf.command = ATA_CMD_SET_FEATURES;
2391 2368 tf.feature = SETFEATURES_XFER;
2392 qc->tf.command = ATA_CMD_SET_FEATURES; 2369 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
2393 qc->tf.feature = SETFEATURES_XFER; 2370 tf.protocol = ATA_PROT_NODATA;
2394 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 2371 tf.nsect = dev->xfer_mode;
2395 qc->tf.protocol = ATA_PROT_NODATA;
2396 qc->tf.nsect = dev->xfer_mode;
2397
2398 qc->waiting = &wait;
2399 qc->complete_fn = ata_qc_complete_noop;
2400
2401 spin_lock_irqsave(&ap->host_set->lock, flags);
2402 rc = ata_qc_issue(qc);
2403 spin_unlock_irqrestore(&ap->host_set->lock, flags);
2404 2372
2405 if (rc) 2373 if (ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0)) {
2374 printk(KERN_ERR "ata%u: failed to set xfermode, disabled\n",
2375 ap->id);
2406 ata_port_disable(ap); 2376 ata_port_disable(ap);
2407 else 2377 }
2408 ata_qc_wait_err(qc, &wait);
2409 2378
2410 DPRINTK("EXIT\n"); 2379 DPRINTK("EXIT\n");
2411} 2380}
@@ -2420,41 +2389,25 @@ static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev)
2420 2389
2421static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev) 2390static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev)
2422{ 2391{
2423 DECLARE_COMPLETION(wait); 2392 struct ata_taskfile tf;
2424 struct ata_queued_cmd *qc;
2425 unsigned long flags;
2426 int rc;
2427
2428 qc = ata_qc_new_init(ap, dev);
2429 BUG_ON(qc == NULL);
2430 2393
2431 ata_sg_init_one(qc, dev->id, sizeof(dev->id)); 2394 ata_tf_init(ap, &tf, dev->devno);
2432 qc->dma_dir = DMA_FROM_DEVICE;
2433 2395
2434 if (dev->class == ATA_DEV_ATA) { 2396 if (dev->class == ATA_DEV_ATA) {
2435 qc->tf.command = ATA_CMD_ID_ATA; 2397 tf.command = ATA_CMD_ID_ATA;
2436 DPRINTK("do ATA identify\n"); 2398 DPRINTK("do ATA identify\n");
2437 } else { 2399 } else {
2438 qc->tf.command = ATA_CMD_ID_ATAPI; 2400 tf.command = ATA_CMD_ID_ATAPI;
2439 DPRINTK("do ATAPI identify\n"); 2401 DPRINTK("do ATAPI identify\n");
2440 } 2402 }
2441 2403
2442 qc->tf.flags |= ATA_TFLAG_DEVICE; 2404 tf.flags |= ATA_TFLAG_DEVICE;
2443 qc->tf.protocol = ATA_PROT_PIO; 2405 tf.protocol = ATA_PROT_PIO;
2444 qc->nsect = 1;
2445
2446 qc->waiting = &wait;
2447 qc->complete_fn = ata_qc_complete_noop;
2448
2449 spin_lock_irqsave(&ap->host_set->lock, flags);
2450 rc = ata_qc_issue(qc);
2451 spin_unlock_irqrestore(&ap->host_set->lock, flags);
2452 2406
2453 if (rc) 2407 if (ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE,
2408 dev->id, sizeof(dev->id)))
2454 goto err_out; 2409 goto err_out;
2455 2410
2456 ata_qc_wait_err(qc, &wait);
2457
2458 swap_buf_le16(dev->id, ATA_ID_WORDS); 2411 swap_buf_le16(dev->id, ATA_ID_WORDS);
2459 2412
2460 ata_dump_id(dev); 2413 ata_dump_id(dev);
@@ -2463,6 +2416,7 @@ static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev)
2463 2416
2464 return; 2417 return;
2465err_out: 2418err_out:
2419 printk(KERN_ERR "ata%u: failed to reread ID, disabled\n", ap->id);
2466 ata_port_disable(ap); 2420 ata_port_disable(ap);
2467} 2421}
2468 2422
@@ -2476,10 +2430,7 @@ err_out:
2476 2430
2477static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev) 2431static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev)
2478{ 2432{
2479 DECLARE_COMPLETION(wait); 2433 struct ata_taskfile tf;
2480 struct ata_queued_cmd *qc;
2481 int rc;
2482 unsigned long flags;
2483 u16 sectors = dev->id[6]; 2434 u16 sectors = dev->id[6];
2484 u16 heads = dev->id[3]; 2435 u16 heads = dev->id[3];
2485 2436
@@ -2490,26 +2441,18 @@ static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev)
2490 /* set up init dev params taskfile */ 2441 /* set up init dev params taskfile */
2491 DPRINTK("init dev params \n"); 2442 DPRINTK("init dev params \n");
2492 2443
2493 qc = ata_qc_new_init(ap, dev); 2444 ata_tf_init(ap, &tf, dev->devno);
2494 BUG_ON(qc == NULL); 2445 tf.command = ATA_CMD_INIT_DEV_PARAMS;
2495 2446 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
2496 qc->tf.command = ATA_CMD_INIT_DEV_PARAMS; 2447 tf.protocol = ATA_PROT_NODATA;
2497 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 2448 tf.nsect = sectors;
2498 qc->tf.protocol = ATA_PROT_NODATA; 2449 tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */
2499 qc->tf.nsect = sectors;
2500 qc->tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */
2501
2502 qc->waiting = &wait;
2503 qc->complete_fn = ata_qc_complete_noop;
2504
2505 spin_lock_irqsave(&ap->host_set->lock, flags);
2506 rc = ata_qc_issue(qc);
2507 spin_unlock_irqrestore(&ap->host_set->lock, flags);
2508 2450
2509 if (rc) 2451 if (ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0)) {
2452 printk(KERN_ERR "ata%u: failed to init parameters, disabled\n",
2453 ap->id);
2510 ata_port_disable(ap); 2454 ata_port_disable(ap);
2511 else 2455 }
2512 ata_qc_wait_err(qc, &wait);
2513 2456
2514 DPRINTK("EXIT\n"); 2457 DPRINTK("EXIT\n");
2515} 2458}