aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/libata-core.c49
-rw-r--r--drivers/scsi/libata-scsi.c46
-rw-r--r--drivers/scsi/libata.h3
3 files changed, 50 insertions, 48 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index ceffaef37d17..f731bbdd4236 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -71,7 +71,6 @@ static int fgb(u32 bitmap);
71static int ata_choose_xfer_mode(struct ata_port *ap, 71static int ata_choose_xfer_mode(struct ata_port *ap,
72 u8 *xfer_mode_out, 72 u8 *xfer_mode_out,
73 unsigned int *xfer_shift_out); 73 unsigned int *xfer_shift_out);
74static int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat);
75static void __ata_qc_complete(struct ata_queued_cmd *qc); 74static void __ata_qc_complete(struct ata_queued_cmd *qc);
76 75
77static unsigned int ata_unique_id = 1; 76static unsigned int ata_unique_id = 1;
@@ -3015,52 +3014,6 @@ fsm_start:
3015 goto fsm_start; 3014 goto fsm_start;
3016} 3015}
3017 3016
3018static void atapi_request_sense(struct ata_port *ap, struct ata_device *dev,
3019 struct scsi_cmnd *cmd)
3020{
3021 DECLARE_COMPLETION(wait);
3022 struct ata_queued_cmd *qc;
3023 unsigned long flags;
3024 int rc;
3025
3026 DPRINTK("ATAPI request sense\n");
3027
3028 qc = ata_qc_new_init(ap, dev);
3029 BUG_ON(qc == NULL);
3030
3031 /* FIXME: is this needed? */
3032 memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
3033
3034 ata_sg_init_one(qc, cmd->sense_buffer, sizeof(cmd->sense_buffer));
3035 qc->dma_dir = DMA_FROM_DEVICE;
3036
3037 memset(&qc->cdb, 0, ap->cdb_len);
3038 qc->cdb[0] = REQUEST_SENSE;
3039 qc->cdb[4] = SCSI_SENSE_BUFFERSIZE;
3040
3041 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
3042 qc->tf.command = ATA_CMD_PACKET;
3043
3044 qc->tf.protocol = ATA_PROT_ATAPI;
3045 qc->tf.lbam = (8 * 1024) & 0xff;
3046 qc->tf.lbah = (8 * 1024) >> 8;
3047 qc->nbytes = SCSI_SENSE_BUFFERSIZE;
3048
3049 qc->waiting = &wait;
3050 qc->complete_fn = ata_qc_complete_noop;
3051
3052 spin_lock_irqsave(&ap->host_set->lock, flags);
3053 rc = ata_qc_issue(qc);
3054 spin_unlock_irqrestore(&ap->host_set->lock, flags);
3055
3056 if (rc)
3057 ata_port_disable(ap);
3058 else
3059 wait_for_completion(&wait);
3060
3061 DPRINTK("EXIT\n");
3062}
3063
3064/** 3017/**
3065 * ata_qc_timeout - Handle timeout of queued command 3018 * ata_qc_timeout - Handle timeout of queued command
3066 * @qc: Command that timed out 3019 * @qc: Command that timed out
@@ -3254,7 +3207,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
3254 return qc; 3207 return qc;
3255} 3208}
3256 3209
3257static int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat) 3210int ata_qc_complete_noop(struct ata_queued_cmd *qc, u8 drv_stat)
3258{ 3211{
3259 return 0; 3212 return 0;
3260} 3213}
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 1a1ef3429e55..c58a7a19780f 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -1479,6 +1479,52 @@ void ata_scsi_badcmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), u8
1479 done(cmd); 1479 done(cmd);
1480} 1480}
1481 1481
1482void atapi_request_sense(struct ata_port *ap, struct ata_device *dev,
1483 struct scsi_cmnd *cmd)
1484{
1485 DECLARE_COMPLETION(wait);
1486 struct ata_queued_cmd *qc;
1487 unsigned long flags;
1488 int rc;
1489
1490 DPRINTK("ATAPI request sense\n");
1491
1492 qc = ata_qc_new_init(ap, dev);
1493 BUG_ON(qc == NULL);
1494
1495 /* FIXME: is this needed? */
1496 memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
1497
1498 ata_sg_init_one(qc, cmd->sense_buffer, sizeof(cmd->sense_buffer));
1499 qc->dma_dir = DMA_FROM_DEVICE;
1500
1501 memset(&qc->cdb, 0, ap->cdb_len);
1502 qc->cdb[0] = REQUEST_SENSE;
1503 qc->cdb[4] = SCSI_SENSE_BUFFERSIZE;
1504
1505 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
1506 qc->tf.command = ATA_CMD_PACKET;
1507
1508 qc->tf.protocol = ATA_PROT_ATAPI;
1509 qc->tf.lbam = (8 * 1024) & 0xff;
1510 qc->tf.lbah = (8 * 1024) >> 8;
1511 qc->nbytes = SCSI_SENSE_BUFFERSIZE;
1512
1513 qc->waiting = &wait;
1514 qc->complete_fn = ata_qc_complete_noop;
1515
1516 spin_lock_irqsave(&ap->host_set->lock, flags);
1517 rc = ata_qc_issue(qc);
1518 spin_unlock_irqrestore(&ap->host_set->lock, flags);
1519
1520 if (rc)
1521 ata_port_disable(ap);
1522 else
1523 wait_for_completion(&wait);
1524
1525 DPRINTK("EXIT\n");
1526}
1527
1482static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat) 1528static int atapi_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
1483{ 1529{
1484 struct scsi_cmnd *cmd = qc->scsicmd; 1530 struct scsi_cmnd *cmd = qc->scsicmd;
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h
index c7a1fa1c9abc..a4b55dc9c698 100644
--- a/drivers/scsi/libata.h
+++ b/drivers/scsi/libata.h
@@ -39,6 +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 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,
43 struct ata_device *dev); 44 struct ata_device *dev);
44extern void ata_qc_free(struct ata_queued_cmd *qc); 45extern void ata_qc_free(struct ata_queued_cmd *qc);
@@ -51,6 +52,8 @@ extern void swap_buf_le16(u16 *buf, unsigned int buf_words);
51 52
52 53
53/* libata-scsi.c */ 54/* libata-scsi.c */
55extern void atapi_request_sense(struct ata_port *ap, struct ata_device *dev,
56 struct scsi_cmnd *cmd);
54extern void ata_scsi_scan_host(struct ata_port *ap); 57extern void ata_scsi_scan_host(struct ata_port *ap);
55extern void ata_to_sense_error(struct ata_queued_cmd *qc, u8 drv_stat); 58extern void ata_to_sense_error(struct ata_queued_cmd *qc, u8 drv_stat);
56extern int ata_scsi_error(struct Scsi_Host *host); 59extern int ata_scsi_error(struct Scsi_Host *host);