Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8c32513b authored by Finn Thain's avatar Finn Thain Committed by Christoph Hellwig
Browse files

ncr5380: Cleanup host info() methods



If the host->info() method is not set, then host->name is used by default.
For atari_scsi, that is exactly the same text. So remove the redundant
info() method. Keep sun3_scsi.c in line with atari_scsi.

Some NCR5380 drivers return an empty string from the info() method
(arm/cumana_1.c arm/oak.c mac_scsi.c) while other drivers use the default
(dmx3191d dtc.c g_NCR5380.c pas16.c t128.c).

Implement a common info() method to replace a lot of duplicated code which
the various drivers use to announce the same information.

This replaces most of the (deprecated) show_info() output and all of the
NCR5380_print_info() output. This also eliminates a bunch of code in
g_NCR5380 which just duplicates functionality in the core driver.

Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Tested-by: default avatarMichael Schmitz <schmitzmic@gmail.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 270ac2c2
Loading
Loading
Loading
Loading
+46 −28
Original line number Diff line number Diff line
@@ -610,20 +610,45 @@ static int __init __maybe_unused NCR5380_probe_irq(struct Scsi_Host *instance,
}

/**
 *	NCR58380_print_options	-	show options
 *	@instance: unused for now
 *	NCR58380_info - report driver and host information
 *	@instance: relevant scsi host instance
 *
 *	Called by probe code indicating the NCR5380 driver options that 
 *	were selected. At some point this will switch to runtime options
 *	read from the adapter in question
 *	For use as the host template info() handler.
 *
 *	Locks: none
 */

static void __init __maybe_unused
NCR5380_print_options(struct Scsi_Host *instance)
static const char *NCR5380_info(struct Scsi_Host *instance)
{
	printk(" generic options"
	struct NCR5380_hostdata *hostdata = shost_priv(instance);

	return hostdata->info;
}

static void prepare_info(struct Scsi_Host *instance)
{
	struct NCR5380_hostdata *hostdata = shost_priv(instance);

	snprintf(hostdata->info, sizeof(hostdata->info),
	         "%s, io_port 0x%lx, n_io_port %d, "
	         "base 0x%lx, irq %d, "
	         "can_queue %d, cmd_per_lun %d, "
	         "sg_tablesize %d, this_id %d, "
	         "flags { %s%s%s}, "
#if defined(USLEEP_POLL) && defined(USLEEP_WAITLONG)
	         "USLEEP_POLL %d, USLEEP_WAITLONG %d, "
#endif
	         "options { %s} ",
	         instance->hostt->name, instance->io_port, instance->n_io_port,
	         instance->base, instance->irq,
	         instance->can_queue, instance->cmd_per_lun,
	         instance->sg_tablesize, instance->this_id,
	         hostdata->flags & FLAG_NCR53C400     ? "NCR53C400 "     : "",
	         hostdata->flags & FLAG_DTC3181E      ? "DTC3181E "      : "",
	         hostdata->flags & FLAG_NO_PSEUDO_DMA ? "NO_PSEUDO_DMA " : "",
#if defined(USLEEP_POLL) && defined(USLEEP_WAITLONG)
	         USLEEP_POLL, USLEEP_WAITLONG,
#endif
#ifdef AUTOPROBE_IRQ
	         "AUTOPROBE_IRQ "
#endif
@@ -631,26 +656,24 @@ NCR5380_print_options(struct Scsi_Host *instance)
	         "DIFFERENTIAL "
#endif
#ifdef REAL_DMA
	       " REAL DMA"
	         "REAL_DMA "
#endif
#ifdef REAL_DMA_POLL
	       " REAL DMA POLL"
	         "REAL_DMA_POLL "
#endif
#ifdef PARITY
	         "PARITY "
#endif
#ifdef PSEUDO_DMA
	       " PSEUDO DMA"
	         "PSEUDO_DMA "
#endif
#ifdef UNSAFE
	         "UNSAFE "
#endif
	    );
	printk(" USLEEP_POLL=%d USLEEP_SLEEP=%d", USLEEP_POLL, USLEEP_SLEEP);
	printk(" generic release=%d", NCR5380_PUBLIC_RELEASE);
	if (((struct NCR5380_hostdata *) instance->hostdata)->flags & FLAG_NCR53C400) {
		printk(" ncr53c400 release=%d", NCR53C400_PUBLIC_RELEASE);
	}
#ifdef NCR53C400
	         "NCR53C400 "
#endif
	         "");
}

/**
@@ -728,13 +751,6 @@ static int __maybe_unused NCR5380_show_info(struct seq_file *m,
	SPRINTF("PAS16 release=%d", PAS16_PUBLIC_RELEASE);
#endif

	SPRINTF("\nBase Addr: 0x%05lX    ", (long) instance->base);
	SPRINTF("io_port: %04x      ", (int) instance->io_port);
	if (instance->irq == NO_IRQ)
		SPRINTF("IRQ: None.\n");
	else
		SPRINTF("IRQ: %d.\n", instance->irq);

#ifdef DTC_PUBLIC_RELEASE
	SPRINTF("Highwater I/O busy_spin_counts -- write: %d  read: %d\n", dtc_wmaxi, dtc_maxi);
#endif
@@ -842,6 +858,8 @@ static int NCR5380_init(struct Scsi_Host *instance, int flags)
	hostdata->host = instance;
	hostdata->time_expires = 0;

	prepare_info(instance);

	NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
	NCR5380_write(MODE_REG, MR_BASE);
	NCR5380_write(TARGET_COMMAND_REG, 0);
+2 −1
Original line number Diff line number Diff line
@@ -273,6 +273,7 @@ struct NCR5380_hostdata {
	volatile Scsi_Cmnd *selecting;
	struct delayed_work coroutine;		/* our co-routine */
	struct scsi_eh_save ses;
	char info[256];
};

#ifdef __KERNEL__
@@ -307,7 +308,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance);
static irqreturn_t NCR5380_intr(int irq, void *dev_id);
#endif
static void NCR5380_main(struct work_struct *work);
static void __maybe_unused NCR5380_print_options(struct Scsi_Host *instance);
static const char *NCR5380_info(struct Scsi_Host *instance);
static void NCR5380_reselect(struct Scsi_Host *instance);
static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd *cmd);
#if defined(PSEUDO_DMA) || defined(REAL_DMA) || defined(REAL_DMA_POLL)
+1 −13
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#define NCR5380_write(reg, value)	cumanascsi_write(_instance, reg, value)
#define NCR5380_intr			cumanascsi_intr
#define NCR5380_queue_command		cumanascsi_queue_command
#define NCR5380_info			cumanascsi_info

#define NCR5380_implementation_fields	\
	unsigned ctrl;			\
@@ -41,11 +42,6 @@ void cumanascsi_setup(char *str, int *ints)
{
}

const char *cumanascsi_info(struct Scsi_Host *spnt)
{
	return "";
}

#define CTRL	0x16fc
#define STAT	0x2004
#define L(v)	(((v)<<16)|((v) & 0x0000ffff))
@@ -266,14 +262,6 @@ static int cumanascsi1_probe(struct expansion_card *ec,
		goto out_unmap;
	}

	printk("scsi%d: at port 0x%08lx irq %d",
		host->host_no, host->io_port, host->irq);
	printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
		host->can_queue, host->cmd_per_lun, CUMANASCSI_PUBLIC_RELEASE);
	printk("\nscsi%d:", host->host_no);
	NCR5380_print_options(host);
	printk("\n");

	ret = scsi_add_host(host, &ec->dev);
	if (ret)
		goto out_free_irq;
+1 −13
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#define NCR5380_read(reg)		readb(_base + ((reg) << 2))
#define NCR5380_write(reg, value)	writeb(value, _base + ((reg) << 2))
#define NCR5380_queue_command		oakscsi_queue_command
#define NCR5380_info			oakscsi_info
#define NCR5380_show_info		oakscsi_show_info
#define NCR5380_write_info		oakscsi_write_info

@@ -40,11 +41,6 @@
#undef START_DMA_INITIATOR_RECEIVE_REG
#define START_DMA_INITIATOR_RECEIVE_REG	(128 + 7)

const char * oakscsi_info (struct Scsi_Host *spnt)
{
	return "";
}

#define STAT	((128 + 16) << 2)
#define DATA	((128 + 8) << 2)

@@ -153,14 +149,6 @@ static int oakscsi_probe(struct expansion_card *ec, const struct ecard_id *id)

	NCR5380_init(host, 0);

	printk("scsi%d: at port 0x%08lx irqs disabled",
		host->host_no, host->io_port);
	printk(" options CAN_QUEUE=%d  CMD_PER_LUN=%d release=%d",
		host->can_queue, host->cmd_per_lun, OAKSCSI_PUBLIC_RELEASE);
	printk("\nscsi%d:", host->host_no);
	NCR5380_print_options(host);
	printk("\n");

	ret = scsi_add_host(host, &ec->dev);
	if (ret)
		goto out_unmap;
+35 −22
Original line number Diff line number Diff line
@@ -144,12 +144,6 @@
 * be able to coexist with appropriate changes to the high level
 * SCSI code.
 *
 * A NCR5380_PUBLIC_REVISION macro is provided, with the release
 * number (updated for each public release) printed by the
 * NCR5380_print_options command, which should be called from the
 * wrapper detect function, so that I know what release of the driver
 * users are using.
 *
 * Issues specific to the NCR5380 :
 *
 * When used in a PIO or pseudo-dma mode, the NCR5380 is a braindead
@@ -247,7 +241,6 @@
 * NCR5380_queue_command
 * NCR5380_reset
 * NCR5380_abort
 * NCR5380_proc_info
 *
 * to be the global entry points into the specific driver, ie
 * #define NCR5380_queue_command t128_queue_command.
@@ -259,8 +252,7 @@
 * The generic driver is initialized by calling NCR5380_init(instance),
 * after setting the appropriate host specific fields and ID.  If the
 * driver wishes to autoprobe for an IRQ line, the NCR5380_probe_irq(instance,
 * possible) function may be used.  Before the specific driver initialization
 * code finishes, NCR5380_print_options should be called.
 * possible) function may be used.
 */

static struct Scsi_Host *first_instance = NULL;
@@ -670,30 +662,49 @@ static inline void NCR5380_all_init(void)
	}
}


/*
 * Function : void NCR58380_print_options (struct Scsi_Host *instance)
/**
 * NCR58380_info - report driver and host information
 * @instance: relevant scsi host instance
 *
 * Purpose : called by probe code indicating the NCR5380 driver
 *	     options that were selected.
 * For use as the host template info() handler.
 *
 * Inputs : instance, pointer to this instance.  Unused.
 * Locks: none
 */

static void __init NCR5380_print_options(struct Scsi_Host *instance)
static const char *NCR5380_info(struct Scsi_Host *instance)
{
	struct NCR5380_hostdata *hostdata = shost_priv(instance);

	return hostdata->info;
}

static void prepare_info(struct Scsi_Host *instance)
{
	printk(" generic options"
	struct NCR5380_hostdata *hostdata = shost_priv(instance);

	snprintf(hostdata->info, sizeof(hostdata->info),
	         "%s, io_port 0x%lx, n_io_port %d, "
	         "base 0x%lx, irq %d, "
	         "can_queue %d, cmd_per_lun %d, "
	         "sg_tablesize %d, this_id %d, "
	         "options { %s} ",
	         instance->hostt->name, instance->io_port, instance->n_io_port,
	         instance->base, instance->irq,
	         instance->can_queue, instance->cmd_per_lun,
	         instance->sg_tablesize, instance->this_id,
#ifdef DIFFERENTIAL
	         "DIFFERENTIAL "
#endif
#ifdef REAL_DMA
	       " REAL DMA"
	         "REAL_DMA "
#endif
#ifdef PARITY
	         "PARITY "
#endif
#ifdef SUPPORT_TAGS
	       " SCSI-2 TAGGED QUEUING"
	         "SUPPORT_TAGS "
#endif
	       );
	printk(" generic release=%d", NCR5380_PUBLIC_RELEASE);
	         "");
}

/*
@@ -839,6 +850,8 @@ static int __init NCR5380_init(struct Scsi_Host *instance, int flags)
		first_instance = instance;
	}

	prepare_info(instance);

	NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
	NCR5380_write(MODE_REG, MR_BASE);
	NCR5380_write(TARGET_COMMAND_REG, 0);
Loading