ide: add ide_transfer_pc() helper
[deliverable/linux.git] / drivers / scsi / ide-scsi.c
index d2dad9039e0d04a2cbe2c9001b4fb9334afc0046..d41348f2245e8acaf30942594679236e5c72662a 100644 (file)
@@ -391,7 +391,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
        ireason = hwif->INB(hwif->io_ports.nsect_addr);
 
        if (ireason & CD) {
-               printk(KERN_ERR "ide-scsi: CoD != 0 in idescsi_pc_intr\n");
+               printk(KERN_ERR "%s: CoD != 0 in %s\n", drive->name, __func__);
                return ide_do_reset (drive);
        }
        if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) {
@@ -406,9 +406,10 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
                temp = pc->xferred + bcount;
                if (temp > pc->req_xfer) {
                        if (temp > pc->buf_size) {
-                               printk(KERN_ERR "ide-scsi: The scsi wants to "
-                                       "send us more data than expected "
-                                       "- discarding data\n");
+                               printk(KERN_ERR "%s: The device wants to send "
+                                               "us more data than expected - "
+                                               "discarding data\n",
+                                               drive->name);
                                temp = pc->buf_size - pc->xferred;
                                if (temp) {
                                        if (pc->sg)
@@ -417,8 +418,9 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
                                        else
                                                hwif->input_data(drive, NULL,
                                                        pc->cur_pos, temp);
-                                       printk(KERN_ERR "ide-scsi: transferred"
-                                                       " %d of %d bytes\n",
+                                       printk(KERN_ERR "%s: transferred %d of "
+                                                       "%d bytes\n",
+                                                       drive->name,
                                                        temp, bcount);
                                }
                                pc->xferred += temp;
@@ -427,7 +429,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
                                ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry);
                                return ide_started;
                        }
-                       debug_log("The scsi wants to send us more data than "
+                       debug_log("The device wants to send us more data than "
                                  "expected - allowing transfer\n");
                }
                xferfunc = hwif->input_data;
@@ -451,36 +453,10 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
 
 static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive)
 {
-       ide_hwif_t *hwif = drive->hwif;
        idescsi_scsi_t *scsi = drive_to_idescsi(drive);
-       struct ide_atapi_pc *pc = scsi->pc;
-       ide_startstop_t startstop;
-       u8 ireason;
-
-       if (ide_wait_stat(&startstop,drive,DRQ_STAT,BUSY_STAT,WAIT_READY)) {
-               printk(KERN_ERR "ide-scsi: Strange, packet command "
-                       "initiated yet DRQ isn't asserted\n");
-               return startstop;
-       }
-       ireason = hwif->INB(hwif->io_ports.nsect_addr);
-       if ((ireason & CD) == 0 || (ireason & IO)) {
-               printk(KERN_ERR "ide-scsi: (IO,CoD) != (0,1) while "
-                               "issuing a packet command\n");
-               return ide_do_reset (drive);
-       }
 
-       /* Set the interrupt routine */
-       ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry);
-
-       if (pc->flags & PC_FLAG_DMA_OK) {
-               pc->flags |= PC_FLAG_DMA_IN_PROGRESS;
-               hwif->dma_ops->dma_start(drive);
-       }
-
-       /* Send the actual packet */
-       hwif->output_data(drive, NULL, scsi->pc->c, 12);
-
-       return ide_started;
+       return ide_transfer_pc(drive, scsi->pc, idescsi_pc_intr,
+                              get_timeout(scsi->pc), idescsi_expiry);
 }
 
 static inline int idescsi_set_direction(struct ide_atapi_pc *pc)
@@ -627,6 +603,8 @@ static void ide_scsi_remove(ide_drive_t *drive)
        put_disk(g);
 
        ide_scsi_put(scsi);
+
+       drive->scsi = 0;
 }
 
 static int ide_scsi_probe(ide_drive_t *);
@@ -967,6 +945,8 @@ static int ide_scsi_probe(ide_drive_t *drive)
            !(host = scsi_host_alloc(&idescsi_template,sizeof(idescsi_scsi_t))))
                return -ENODEV;
 
+       drive->scsi = 1;
+
        g = alloc_disk(1 << PARTN_BITS);
        if (!g)
                goto out_host_put;
@@ -1007,6 +987,7 @@ static int ide_scsi_probe(ide_drive_t *drive)
 
        put_disk(g);
 out_host_put:
+       drive->scsi = 0;
        scsi_host_put(host);
        return err;
 }
This page took 0.024787 seconds and 5 git commands to generate.