Commit 4ff36718 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by James Bottomley
Browse files

[SCSI] Improve inquiry printing



 - Replace scsi_device_types array API with scsi_device_type function API.
   Gets rid of a lot of common code, as well as being easier to use.
 - Add the new device types in SPC4 r05a, and rename some of the older ones.
 - Reformat the printing of inquiry data; now fits on one line and
   includes PQ.

I think I've addressed all the feedback from the previous versions.  My
current test box prints:

scsi 2:0:1:0: Direct access     HP 18.2G ATLAS10K3_18_SCA HP05 PQ: 0 ANSI: 2

Signed-off-by: default avatarMatthew Wilcox <matthew@wil.cx>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 008cd5bb
Loading
Loading
Loading
Loading
+5 −9
Original line number Diff line number Diff line
@@ -251,10 +251,6 @@ scsi_cmd_stack_free(int ctlr)
	stk->pool = NULL;
}

/* scsi_device_types comes from scsi.h */
#define DEVICETYPE(n) (n<0 || n>MAX_SCSI_DEVICE_CODE) ? \
	"Unknown" : scsi_device_types[n]

#if 0
static int xmargin=8;
static int amargin=60;
@@ -389,7 +385,7 @@ cciss_scsi_add_entry(int ctlr, int hostno,
	   time anyway (the scsi layer's inquiries will show that info) */
	if (hostno != -1)
		printk("cciss%d: %s device c%db%dt%dl%d added.\n", 
			ctlr, DEVICETYPE(sd->devtype), hostno, 
			ctlr, scsi_device_type(sd->devtype), hostno,
			sd->bus, sd->target, sd->lun);
	return 0;
}
@@ -407,7 +403,7 @@ cciss_scsi_remove_entry(int ctlr, int hostno, int entry)
		ccissscsi[ctlr].dev[i] = ccissscsi[ctlr].dev[i+1];
	ccissscsi[ctlr].ndevices--;
	printk("cciss%d: %s device c%db%dt%dl%d removed.\n",
		ctlr, DEVICETYPE(sd.devtype), hostno, 
		ctlr, scsi_device_type(sd.devtype), hostno,
			sd.bus, sd.target, sd.lun);
}

@@ -458,7 +454,7 @@ adjust_cciss_scsi_table(int ctlr, int hostno,
		if (found == 0) { /* device no longer present. */ 
			changes++;
			/* printk("cciss%d: %s device c%db%dt%dl%d removed.\n",
				ctlr, DEVICETYPE(csd->devtype), hostno, 
				ctlr, scsi_device_type(csd->devtype), hostno,
					csd->bus, csd->target, csd->lun); */
			cciss_scsi_remove_entry(ctlr, hostno, i);
			/* note, i not incremented */
@@ -468,7 +464,7 @@ adjust_cciss_scsi_table(int ctlr, int hostno,
			printk("cciss%d: device c%db%dt%dl%d type changed "
				"(device type now %s).\n",
				ctlr, hostno, csd->bus, csd->target, csd->lun,
					DEVICETYPE(csd->devtype));
					scsi_device_type(csd->devtype));
			csd->devtype = sd[j].devtype;
			i++;	/* so just move along. */
		} else 		/* device is same as it ever was, */
@@ -1098,7 +1094,7 @@ cciss_update_non_disk_devices(int cntl_num, int hostno)
			if (ncurrent >= CCISS_MAX_SCSI_DEVS_PER_HBA) {
				printk(KERN_INFO "cciss%d: %s ignored, "
					"too many devices.\n", cntl_num,
					DEVICETYPE(devtype));
					scsi_device_type(devtype));
				break;
			}
			memcpy(&currentsd[ncurrent].scsi3addr[0], 
+1 −2
Original line number Diff line number Diff line
@@ -248,8 +248,7 @@ int fcal_proc_info (struct Scsi_Host *host, char *buffer, char **start, off_t of
				if (scd->id == target) {
					SPRINTF ("  [AL-PA: %02x, Id: %02d, Port WWN: %08x%08x, Node WWN: %08x%08x]  ",
						alpa, target, u1[0], u1[1], u2[0], u2[1]);
					SPRINTF ("%s ", (scd->type < MAX_SCSI_DEVICE_CODE) ?
						scsi_device_types[(short) scd->type] : "Unknown device");
					SPRINTF ("%s ", scsi_device_type(scd->type));

					for (j = 0; (j < 8) && (scd->vendor[j] >= 0x20); j++)
						SPRINTF ("%c", scd->vendor[j]);
+1 −2
Original line number Diff line number Diff line
@@ -811,7 +811,6 @@ static int generic_NCR5380_proc_info(struct Scsi_Host *scsi_ptr, char *buffer, c
	struct NCR5380_hostdata *hostdata;
#ifdef NCR5380_STATS
	struct scsi_device *dev;
	extern const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE];
#endif

	NCR5380_setup(scsi_ptr);
@@ -851,7 +850,7 @@ static int generic_NCR5380_proc_info(struct Scsi_Host *scsi_ptr, char *buffer, c
		long tr = hostdata->time_read[dev->id] / HZ;
		long tw = hostdata->time_write[dev->id] / HZ;

		PRINTP("  T:%d %s " ANDP dev->id ANDP(dev->type < MAX_SCSI_DEVICE_CODE) ? scsi_device_types[(int) dev->type] : "Unknown");
		PRINTP("  T:%d %s " ANDP dev->id ANDP scsi_device_type(dev->type));
		for (i = 0; i < 8; i++)
			if (dev->vendor[i] >= 0x20)
				*(buffer + (len++)) = dev->vendor[i];
+1 −3
Original line number Diff line number Diff line
@@ -2822,9 +2822,7 @@ mega_print_inquiry(char *page, char *scsi_inq)

	i = scsi_inq[0] & 0x1f;

	len += sprintf(page+len, "  Type:   %s ",
		i < MAX_SCSI_DEVICE_CODE ? scsi_device_types[i] :
		   "Unknown          ");
	len += sprintf(page+len, "  Type:   %s ", scsi_device_type(i));

	len += sprintf(page+len,
	"                 ANSI SCSI revision: %02x", scsi_inq[2] & 0x07);
+26 −10
Original line number Diff line number Diff line
@@ -96,24 +96,40 @@ unsigned int scsi_logging_level;
EXPORT_SYMBOL(scsi_logging_level);
#endif

const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE] = {
	"Direct-Access    ",
	"Sequential-Access",
static const char *const scsi_device_types[] = {
	"Direct access    ",
	"Sequential access",
	"Printer          ",
	"Processor        ",
	"WORM             ",
	"CD-ROM           ",
	"CD/DVD           ",
	"Scanner          ",
	"Optical Device   ",
	"Medium Changer   ",
	"Optical memory   ",
	"Media changer    ",
	"Communications   ",
	"Unknown          ",
	"Unknown          ",
	"ASC IT8          ",
	"ASC IT8          ",
	"RAID             ",
	"Enclosure        ",
	"Direct-Access-RBC",
	"Direct access RBC",
	"Optical card     ",
	"Bridge controller",
	"Object storage   ",
	"Automation/Drive ",
};
EXPORT_SYMBOL(scsi_device_types);

const char * scsi_device_type(unsigned type)
{
	if (type == 0x1e)
		return "Well-known LUN   ";
	if (type == 0x1f)
		return "No Device        ";
	if (type > ARRAY_SIZE(scsi_device_types))
		return "Unknown          ";
	return scsi_device_types[type];
}

EXPORT_SYMBOL(scsi_device_type);

struct scsi_host_cmd_pool {
	kmem_cache_t	*slab;
Loading