X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fscsi%2FNCR5380.c;h=9f0ddbe6dc765ef6decb10dfb30c0693cd92440b;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=6b3d2b2ad8d1a8f16ebc053dce7c009ae85ada02;hpb=6a77f38946aaee1cd85eeec6cf4229b204c15071;p=linux-2.6.git diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index 6b3d2b2ad..9f0ddbe6d 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -86,6 +86,15 @@ * 5. Test linked command handling code after Eric is ready with * the high level code. */ +#include +#include + +#ifndef NDEBUG +#define NDEBUG 0 +#endif +#ifndef NDEBUG_ABORT +#define NDEBUG_ABORT 0 +#endif #if (NDEBUG & NDEBUG_LISTS) #define LIST(x,y) {printk("LINE:%d Adding %p to %p\n", __LINE__, (void*)(x), (void*)(y)); if ((x)==(y)) udelay(5); } @@ -358,7 +367,7 @@ static struct { {PHASE_UNKNOWN, "UNKNOWN"} }; -#ifdef NDEBUG +#if NDEBUG static struct { unsigned char mask; const char *name; @@ -533,7 +542,7 @@ static int should_disconnect(unsigned char cmd) static void NCR5380_set_timer(struct NCR5380_hostdata *hostdata, unsigned long timeout) { hostdata->time_expires = jiffies + timeout; - schedule_delayed_work(&hostdata->coroutine, hostdata->time_expires); + schedule_delayed_work(&hostdata->coroutine, timeout); } @@ -598,10 +607,7 @@ static int __init NCR5380_probe_irq(struct Scsi_Host *instance, int possible) NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA | ICR_ASSERT_SEL); while (probe_irq == SCSI_IRQ_NONE && time_before(jiffies, timeout)) - { - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(1); - } + schedule_timeout_uninterruptible(1); NCR5380_write(SELECT_ENABLE_REG, 0); NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); @@ -671,16 +677,8 @@ static void __init NCR5380_print_options(struct Scsi_Host *instance) static void NCR5380_print_status(struct Scsi_Host *instance) { - static char pr_bfr[512]; - char *start; - int len; - NCR5380_dprint(NDEBUG_ANY, instance); NCR5380_dprint_phase(NDEBUG_ANY, instance); - - len = NCR5380_proc_info(instance, pr_bfr, &start, 0, sizeof(pr_bfr), 0); - pr_bfr[len] = 0; - printk("\n%s\n", pr_bfr); } /******************************************/ @@ -1247,13 +1245,13 @@ static void collect_stats(struct NCR5380_hostdata *hostdata, Scsi_Cmnd * cmd) case WRITE: case WRITE_6: case WRITE_10: - hostdata->time_write[cmd->device->id] += (jiffies - hostdata->timebase); + hostdata->time_write[scmd_id(cmd)] += (jiffies - hostdata->timebase); hostdata->pendingw--; break; case READ: case READ_6: case READ_10: - hostdata->time_read[cmd->device->id] += (jiffies - hostdata->timebase); + hostdata->time_read[scmd_id(cmd)] += (jiffies - hostdata->timebase); hostdata->pendingr--; break; } @@ -1385,7 +1383,7 @@ static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag) * the host and target ID's on the SCSI bus. */ - NCR5380_write(OUTPUT_DATA_REG, (hostdata->id_mask | (1 << cmd->device->id))); + NCR5380_write(OUTPUT_DATA_REG, (hostdata->id_mask | (1 << scmd_id(cmd)))); /* * Raise ATN while SEL is true before BSY goes false from arbitration, @@ -1430,7 +1428,7 @@ static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag) udelay(1); - dprintk(NDEBUG_SELECTION, ("scsi%d : selecting target %d\n", instance->host_no, cmd->device->id)); + dprintk(NDEBUG_SELECTION, ("scsi%d : selecting target %d\n", instance->host_no, scmd_id(cmd))); /* * The SCSI specification calls for a 250 ms timeout for the actual @@ -1483,7 +1481,7 @@ part2: if (!(NCR5380_read(STATUS_REG) & SR_BSY)) { NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); - if (hostdata->targets_present & (1 << cmd->device->id)) { + if (hostdata->targets_present & (1 << scmd_id(cmd))) { printk(KERN_DEBUG "scsi%d : weirdness\n", instance->host_no); if (hostdata->restart_select) printk(KERN_DEBUG "\trestart select\n"); @@ -1499,7 +1497,7 @@ part2: NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); return 0; } - hostdata->targets_present |= (1 << cmd->device->id); + hostdata->targets_present |= (1 << scmd_id(cmd)); /* * Since we followed the SCSI spec, and raised ATN while SEL @@ -2190,7 +2188,8 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) { * If the watchdog timer fires, all future accesses to this * device will use the polled-IO. */ - printk("scsi%d : switching target %d lun %d to slow handshake\n", instance->host_no, cmd->device->id, cmd->device->lun); + scmd_printk(KERN_INFO, cmd, + "switching to slow handshake\n"); cmd->device->borken = 1; NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN); sink = 1; @@ -2379,7 +2378,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) { * 3..length+1 arguments * * Start the extended message buffer with the EXTENDED_MESSAGE - * byte, since print_msg() wants the whole thing. + * byte, since spi_print_msg() wants the whole thing. */ extended_msg[0] = EXTENDED_MESSAGE; /* Accept first byte by clearing ACK */ @@ -2426,12 +2425,14 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) { default: if (!tmp) { printk("scsi%d: rejecting message ", instance->host_no); - print_msg(extended_msg); + spi_print_msg(extended_msg); printk("\n"); } else if (tmp != EXTENDED_MESSAGE) - printk("scsi%d: rejecting unknown message %02x from target %d, lun %d\n", instance->host_no, tmp, cmd->device->id, cmd->device->lun); + scmd_printk(KERN_INFO, cmd, + "rejecting unknown message %02x\n",tmp); else - printk("scsi%d: rejecting unknown extended message code %02x, length %d from target %d, lun %d\n", instance->host_no, extended_msg[1], extended_msg[0], cmd->device->id, cmd->device->lun); + scmd_printk(KERN_INFO, cmd, + "rejecting unknown extended message code %02x, length %d\n", extended_msg[1], extended_msg[0]); msgout = MESSAGE_REJECT; NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ATN); @@ -2560,7 +2561,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance) { if (!(msg[0] & 0x80)) { printk(KERN_ERR "scsi%d : expecting IDENTIFY message, got ", instance->host_no); - print_msg(msg); + spi_print_msg(msg); abort = 1; } else { /* Accept message by clearing ACK */ @@ -2685,12 +2686,7 @@ static int NCR5380_abort(Scsi_Cmnd * cmd) { Scsi_Cmnd *tmp, **prev; printk(KERN_WARNING "scsi%d : aborting command\n", instance->host_no); - print_Scsi_Cmnd(cmd); - - NCR5380_print_status(instance); - - printk(KERN_WARNING "scsi%d : aborting command\n", instance->host_no); - print_Scsi_Cmnd(cmd); + scsi_print_command(cmd); NCR5380_print_status(instance); @@ -2837,39 +2833,17 @@ static int NCR5380_abort(Scsi_Cmnd * cmd) { * Locks: host lock taken by caller */ -static int NCR5380_bus_reset(Scsi_Cmnd * cmd) { - NCR5380_local_declare(); - NCR5380_setup(cmd->device->host); - - NCR5380_print_status(cmd->device->host); - do_reset(cmd->device->host); - return SUCCESS; -} - -/* - * Function : int NCR5380_device_reset (Scsi_Cmnd *cmd) - * - * Purpose : reset a SCSI device - * - * Returns : FAILED - * - * Locks: io_request_lock held by caller - */ +static int NCR5380_bus_reset(Scsi_Cmnd * cmd) +{ + struct Scsi_Host *instance = cmd->device->host; -static int NCR5380_device_reset(Scsi_Cmnd * cmd) { - return FAILED; -} + NCR5380_local_declare(); + NCR5380_setup(instance); + NCR5380_print_status(instance); -/* - * Function : int NCR5380_host_reset (Scsi_Cmnd *cmd) - * - * Purpose : reset a SCSI device - * - * Returns : FAILED - * - * Locks: io_request_lock held by caller - */ + spin_lock_irq(instance->host_lock); + do_reset(instance); + spin_unlock_irq(instance->host_lock); -static int NCR5380_host_reset(Scsi_Cmnd * cmd) { - return FAILED; + return SUCCESS; }