patch-2.4.17 linux/drivers/scsi/t128.c

Next file: linux/drivers/scsi/tmscsim.c
Previous file: linux/drivers/scsi/sym53c8xx_defs.h
Back to the patch index
Back to the overall index

diff -Naur -X /home/marcelo/lib/dontdiff linux-2.4.16/drivers/scsi/t128.c linux/drivers/scsi/t128.c
@@ -47,17 +47,12 @@
  * increase compared to polled I/O.
  *
  * PARITY - enable parity checking.  Not supported.
- * 
- * SCSI2 - enable support for SCSI-II tagged queueing.  Untested.
- *
  *
  * UNSAFE - leave interrupts enabled during pseudo-DMA transfers.  You
  *          only really want to use this if you're having a problem with
  *          dropped characters during high speed communications, and even
  *          then, you're going to be better off twiddling with transfersize.
  *
- * USLEEP - enable support for devices that don't disconnect.  Untested.
- *
  * The card is detected and initialized in one of several ways : 
  * 1.  Autoprobe (default) - since the board is memory mapped, 
  *     a BIOS signature is scanned for to locate the registers.
@@ -101,10 +96,6 @@
  * 14 10-12
  * 15 9-11
  */
- 
-/*
- * $Log: t128.c,v $
- */
 
 #include <asm/system.h>
 #include <linux/signal.h>
@@ -123,276 +114,252 @@
 #include <linux/module.h>
 
 static struct override {
-    unsigned long address;
-    int irq;
-} overrides 
+	unsigned long address;
+	int irq;
+} overrides
 #ifdef T128_OVERRIDE
-    [] __initdata = T128_OVERRIDE;
+[] __initdata = T128_OVERRIDE;
 #else
-    [4] __initdata = {{0, IRQ_AUTO}, {0, IRQ_AUTO}, 
-        {0 ,IRQ_AUTO}, {0, IRQ_AUTO}};
+[4] __initdata = { 
+	{ 0, IRQ_AUTO},
+	{ 0, IRQ_AUTO},
+	{ 0, IRQ_AUTO},
+	{ 0, IRQ_AUTO}
+};
 #endif
 
 #define NO_OVERRIDES (sizeof(overrides) / sizeof(struct override))
 
 static struct base {
-    unsigned int address;
-    int noauto;
+	unsigned int address;
+	int noauto;
 } bases[] __initdata = {
-    { 0xcc000, 0}, { 0xc8000, 0}, { 0xdc000, 0}, { 0xd8000, 0}
+	{0xcc000, 0},
+	{0xc8000, 0},
+	{0xdc000, 0},
+	{0xd8000, 0}
 };
 
 #define NO_BASES (sizeof (bases) / sizeof (struct base))
 
 static const struct signature {
-    const char *string;
-    int offset;
+	const char *string;
+	int offset;
 } signatures[] __initdata = {
-{"TSROM: SCSI BIOS, Version 1.12", 0x36},
+	{"TSROM: SCSI BIOS, Version 1.12", 0x36},
 };
 
 #define NO_SIGNATURES (sizeof (signatures) /  sizeof (struct signature))
 
-/*
- * Function : t128_setup(char *str, int *ints)
- *
- * Purpose : LILO command line initialization of the overrides array,
- * 
- * Inputs : str - unused, ints - array of integer parameters with ints[0]
- *	equal to the number of ints.
+/**
+ *	t128_setup
+ *	@str: command line 
  *
+ *	LILO command line initialization of the overrides array,
  */
 
-void __init t128_setup(char *str, int *ints){
-    static int commandline_current = 0;
-    int i;
-    if (ints[0] != 2) 
-	printk("t128_setup : usage t128=address,irq\n");
-    else 
-	if (commandline_current < NO_OVERRIDES) {
-	    overrides[commandline_current].address = ints[1];
-	    overrides[commandline_current].irq = ints[2];
-	    for (i = 0; i < NO_BASES; ++i)
-		if (bases[i].address == ints[1]) {
-		    bases[i].noauto = 1;
-		    break;
-		}
-	    ++commandline_current;
+int __init t128_setup(char *str)
+{
+	static int commandline_current = 0;
+	int ints[10];
+	int i;
+	
+	get_options(str, sizeof(ints) / sizeof(int), ints);
+
+	if (ints[0] != 2)
+		printk(KERN_ERR "t128_setup : usage t128=address,irq\n");
+	else if (commandline_current < NO_OVERRIDES) {
+		overrides[commandline_current].address = ints[1];
+		overrides[commandline_current].irq = ints[2];
+		for (i = 0; i < NO_BASES; ++i)
+			if (bases[i].address == ints[1]) {
+				bases[i].noauto = 1;
+				break;
+			}
+		++commandline_current;
 	}
+	return 1;
 }
 
-/* 
- * Function : int t128_detect(Scsi_Host_Template * tpnt)
+__setup("t128=", t128_setup);
+
+/**
+ *	t128_detect	-	detect controllers
+ *	@tpnt: SCSI template
  *
- * Purpose : detects and initializes T128,T128F, or T228 controllers
+ *	Detects and initializes T128,T128F, or T228 controllers
  *	that were autoprobed, overridden on the LILO command line, 
  *	or specified at compile time.
- *
- * Inputs : tpnt - template for this SCSI adapter.
- * 
- * Returns : 1 if a host adapter was found, 0 if not.
- *
  */
 
-int __init t128_detect(Scsi_Host_Template * tpnt){
-    static int current_override = 0, current_base = 0;
-    struct Scsi_Host *instance;
-    unsigned long base;
-    int sig, count;
-
-    tpnt->proc_name = "t128";
-    tpnt->proc_info = &t128_proc_info;
-
-    for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
-	base = 0;
-
-	if (overrides[current_override].address)
-	    base = overrides[current_override].address;
-	else 
-	    for (; !base && (current_base < NO_BASES); ++current_base) {
-#if (TDEBUG & TDEBUG_INIT)
-    printk("scsi-t128 : probing address %08x\n", bases[current_base].address);
-#endif
-		for (sig = 0; sig < NO_SIGNATURES; ++sig) 
-		    if (!bases[current_base].noauto && 
-			isa_check_signature(bases[current_base].address +
-					signatures[sig].offset,
-					signatures[sig].string,
-					strlen(signatures[sig].string))) {
-			base = bases[current_base].address;
-#if (TDEBUG & TDEBUG_INIT)
-			printk("scsi-t128 : detected board.\n");
-#endif
+int __init t128_detect(Scsi_Host_Template * tpnt)
+{
+	static int current_override = 0, current_base = 0;
+	struct Scsi_Host *instance;
+	unsigned long base;
+	int sig, count;
+
+	tpnt->proc_name = "t128";
+	tpnt->proc_info = &t128_proc_info;
+
+	for (count = 0; current_override < NO_OVERRIDES; ++current_override) 
+	{
+		base = 0;
+
+		if (overrides[current_override].address)
+			base = overrides[current_override].address;
+		else
+			for (; !base && (current_base < NO_BASES); ++current_base) {
+				for (sig = 0; sig < NO_SIGNATURES; ++sig)
+					if (!bases[current_base].noauto &&
+					    isa_check_signature(bases[current_base].address + signatures[sig].offset,
+								signatures[sig].string,
+								strlen(signatures[sig].string)))
+					{
+						base = bases[current_base].address;
+						break;
+					}
+			}
+
+		if (!base)
 			break;
-		    }
-	    }
 
-#if defined(TDEBUG) && (TDEBUG & TDEBUG_INIT)
-	printk("scsi-t128 : base = %08x\n", (unsigned int) base);
-#endif
+		instance = scsi_register(tpnt, sizeof(struct NCR5380_hostdata));
+		if (instance == NULL)
+			break;
 
-	if (!base)
-	    break;
+		instance->base = base;
 
-	instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
-	if(instance == NULL)
-		break;
-		
-	instance->base = base;
-
-	NCR5380_init(instance, 0);
-
-	if (overrides[current_override].irq != IRQ_AUTO)
-	    instance->irq = overrides[current_override].irq;
-	else 
-	    instance->irq = NCR5380_probe_irq(instance, T128_IRQS);
-
-	if (instance->irq != IRQ_NONE) 
-	    if (request_irq(instance->irq, do_t128_intr, SA_INTERRUPT, "t128", NULL)) {
-		printk("scsi%d : IRQ%d not free, interrupts disabled\n", 
-		    instance->host_no, instance->irq);
-		instance->irq = IRQ_NONE;
-	    } 
-
-	if (instance->irq == IRQ_NONE) {
-	    printk("scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no);
-	    printk("scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
-	}
+		NCR5380_init(instance, 0);
 
-#if defined(TDEBUG) && (TDEBUG & TDEBUG_INIT)
-	printk("scsi%d : irq = %d\n", instance->host_no, instance->irq);
-#endif
+		if (overrides[current_override].irq != IRQ_AUTO)
+			instance->irq = overrides[current_override].irq;
+		else
+			instance->irq = NCR5380_probe_irq(instance, T128_IRQS);
+
+		if (instance->irq != IRQ_NONE)
+			if (request_irq(instance->irq, do_t128_intr, SA_INTERRUPT, "t128", NULL)) 
+			{
+				printk(KERN_WARNING "scsi%d : IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq);
+				instance->irq = IRQ_NONE;
+			}
+
+		if (instance->irq == IRQ_NONE) {
+			printk(KERN_INFO "scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no);
+			printk(KERN_INFO "scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
+		}
+
+		printk(KERN_INFO "scsi%d : at 0x%08lx", instance->host_no,instance->base);
+		if (instance->irq == IRQ_NONE)
+			printk(" interrupts disabled");
+		else
+			printk(" irq %d", instance->irq);
+		printk(" options CAN_QUEUE=%d  CMD_PER_LUN=%d release=%d", CAN_QUEUE, CMD_PER_LUN, T128_PUBLIC_RELEASE);
+		NCR5380_print_options(instance);
+		printk("\n");
 
-	printk("scsi%d : at 0x%08lx", instance->host_no, instance->base);
-	if (instance->irq == IRQ_NONE)
-	    printk (" interrupts disabled");
-	else 
-	    printk (" irq %d", instance->irq);
-	printk(" options CAN_QUEUE=%d  CMD_PER_LUN=%d release=%d",
-	    CAN_QUEUE, CMD_PER_LUN, T128_PUBLIC_RELEASE);
-	NCR5380_print_options(instance);
-	printk("\n");
-
-	++current_override;
-	++count;
-    }
-    return count;
+		++current_override;
+		++count;
+	}
+	return count;
 }
 
-/*
- * Function : int t128_biosparam(Disk * disk, kdev_t dev, int *ip)
+/**
+ *	t128_biosparam		-	disk geometry
+ *	@disk: device 
+ *	@dev: device major/minor
+ *	@ip: array to return results
  *
- * Purpose : Generates a BIOS / DOS compatible H-C-S mapping for 
+ *	Generates a BIOS / DOS compatible H-C-S mapping for 
  *	the specified device / size.
  * 
- * Inputs : size = size of device in sectors (512 bytes), dev = block device
- *	major / minor, ip[] = {heads, sectors, cylinders}  
- *
- * Returns : always 0 (success), initializes ip
- *	
+ *	Most SCSI boards use this mapping, I could be incorrect.  Some one
+ *	using hard disks on a trantor should verify that this mapping
+ *	corresponds to that used by the BIOS / ASPI driver by running the
+ *	linux fdisk program and matching the H_C_S coordinates to those
+ *	that DOS uses.
  */
 
-/* 
- * XXX Most SCSI boards use this mapping, I could be incorrect.  Some one
- * using hard disks on a trantor should verify that this mapping corresponds
- * to that used by the BIOS / ASPI driver by running the linux fdisk program
- * and matching the H_C_S coordinates to what DOS uses.
- */
-
-int t128_biosparam(Disk * disk, kdev_t dev, int * ip)
+int t128_biosparam(Disk * disk, kdev_t dev, int *ip)
 {
-  int size = disk->capacity;
-  ip[0] = 64;
-  ip[1] = 32;
-  ip[2] = size >> 11;
-  return 0;
+	int size = disk->capacity;
+	ip[0] = 64;
+	ip[1] = 32;
+	ip[2] = size >> 11;
+	return 0;
 }
 
-/*
- * Function : int NCR5380_pread (struct Scsi_Host *instance, 
- *	unsigned char *dst, int len)
+/**
+ *	NCR5380_pread		-	pseudo DMA read
+ *	@instance: controller
+ *	@dst: buffer to write to
+ *	@len: expect/max length
  *
- * Purpose : Fast 5380 pseudo-dma read function, transfers len bytes to 
- *	dst
- * 
- * Inputs : dst = destination, len = length in bytes
- *
- * Returns : 0 on success, non zero on a failure such as a watchdog 
- * 	timeout.
+ *	Fast 5380 pseudo-dma read function, transfers len bytes to 
+ *	dst from the controller.
  */
 
-static inline int NCR5380_pread (struct Scsi_Host *instance, unsigned char *dst,
-    int len) {
-    unsigned long reg = instance->base + T_DATA_REG_OFFSET;
-    unsigned char *d = dst;
-    register int i = len;
-
-
-#if 0
-    for (; i; --i) {
-	while (!(isa_readb(instance->base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
-#else
-    while (!(isa_readb(instance->base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
-    for (; i; --i) {
-#endif
-	*d++ = isa_readb(reg);
-    }
+static inline int NCR5380_pread(struct Scsi_Host *instance,
+				unsigned char *dst, int len)
+{
+	unsigned long reg = instance->base + T_DATA_REG_OFFSET;
+	unsigned char *d = dst;
+	int i = len;
+
+	while (!(isa_readb(instance->base + T_STATUS_REG_OFFSET) & T_ST_RDY))
+	       	barrier();
+	for (; i; --i) {
+		*d++ = isa_readb(reg);
+	}
 
-    if (isa_readb(instance->base + T_STATUS_REG_OFFSET) & T_ST_TIM) {
-	unsigned char tmp;
-	unsigned long foo;
-	foo = instance->base + T_CONTROL_REG_OFFSET;
-	tmp = isa_readb(foo);
-	isa_writeb(tmp | T_CR_CT, foo);
-	isa_writeb(tmp, foo);
-	printk("scsi%d : watchdog timer fired in NCR5380_pread()\n",
-	    instance->host_no);
-	return -1;
-    } else
-	return 0;
+	if (isa_readb(instance->base + T_STATUS_REG_OFFSET) & T_ST_TIM) {
+		unsigned char tmp;
+		unsigned long foo;
+		foo = instance->base + T_CONTROL_REG_OFFSET;
+		tmp = isa_readb(foo);
+		isa_writeb(tmp | T_CR_CT, foo);
+		isa_writeb(tmp, foo);
+		printk(KERN_ERR "scsi%d : watchdog timer fired in t128 NCR5380_pread.\n", instance->host_no);
+		return -1;
+	} else
+		return 0;
 }
 
-/*
- * Function : int NCR5380_pwrite (struct Scsi_Host *instance, 
- *	unsigned char *src, int len)
+/**
+ *	NCR5380_pwrite		-	pseudo DMA write
+ *	@instance: controller
+ *	@dst: buffer to write to
+ *	@len: expect/max length
  *
- * Purpose : Fast 5380 pseudo-dma write function, transfers len bytes from
- *	src
- * 
- * Inputs : src = source, len = length in bytes
- *
- * Returns : 0 on success, non zero on a failure such as a watchdog 
- * 	timeout.
+ *	Fast 5380 pseudo-dma write function, transfers len bytes from
+ *	dst to the controller.
  */
 
-static inline int NCR5380_pwrite (struct Scsi_Host *instance, unsigned char *src,
-    int len) {
-    unsigned long reg = instance->base + T_DATA_REG_OFFSET;
-    unsigned char *s = src;
-    register int i = len;
-
-#if 0
-    for (; i; --i) {
-	while (!(isa_readb(instance->base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
-#else
-    while (!(isa_readb(instance->base+T_STATUS_REG_OFFSET) & T_ST_RDY)) barrier();
-    for (; i; --i) {
-#endif
-	isa_writeb(*s++, reg);
-    }
 
-    if (isa_readb(instance->base + T_STATUS_REG_OFFSET) & T_ST_TIM) {
-	unsigned char tmp;
-	unsigned long foo;
-	foo = instance->base + T_CONTROL_REG_OFFSET;
-	tmp = isa_readb(foo);
-	isa_writeb(tmp | T_CR_CT, foo);
-	isa_writeb(tmp, foo);
-	printk("scsi%d : watchdog timer fired in NCR5380_pwrite()\n",
-	    instance->host_no);
-	return -1;
-    } else 
-	return 0;
+static inline int NCR5380_pwrite(struct Scsi_Host *instance,
+				 unsigned char *src, int len)
+{
+	unsigned long reg = instance->base + T_DATA_REG_OFFSET;
+	unsigned char *s = src;
+	int i = len;
+
+	while (!(isa_readb(instance->base + T_STATUS_REG_OFFSET) & T_ST_RDY))
+		barrier();
+	for (; i; --i) {
+		isa_writeb(*s++, reg);
+	}
+
+	if (isa_readb(instance->base + T_STATUS_REG_OFFSET) & T_ST_TIM) {
+		unsigned char tmp;
+		unsigned long foo;
+		foo = instance->base + T_CONTROL_REG_OFFSET;
+		tmp = isa_readb(foo);
+		isa_writeb(tmp | T_CR_CT, foo);
+		isa_writeb(tmp, foo);
+		printk(KERN_ERR "scsi%d : watchdog timer fired in t128 NCR5380_pwrite()\n", instance->host_no);
+		return -1;
+	} else
+		return 0;
 }
 
 MODULE_LICENSE("GPL");

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)