Resent-Date: Thu, 28 Jan 1999 19:20:18 +0100 (MET)
Date: Thu, 28 Jan 1999 19:18:08 +0100
From: Kars de Jong <jongk@cs.utwente.nl>
To: Andreas Schmitz <OTTER@chessy.aworld.de>
Cc: linux-m68k@lists.linux-m68k.org
Subject: Re: Oktagon patch (NCR53C9x)
Mail-Followup-To: Andreas Schmitz <OTTER@chessy.aworld.de>,
	linux-m68k@lists.linux-m68k.org
References: <2rsyYMD46BaUz1@otter.chessy.aworld.de>
In-Reply-To: <2rsyYMD46BaUz1@otter.chessy.aworld.de>; from Andreas Schmitz on Wed, Jan 27, 1999 at 07:21:44AM +0000
Resent-From: linux-m68k@phil.uni-sb.de

On Wed, Jan 27, 1999 at 07:21:44AM +0000, Andreas Schmitz wrote:
> PS: Why has the outb macro arguments changed relatively to x86?

I think this is my fault, I accidentally reversed them in NCR53C9x.h.
So they haven't changed.

Anyway, here is the Oktagon diff the way I like it. This means that it uses
esp_read()/esp_write() now. I also fixed some compiler warnings for
oktagon_esp.c, and made it work as a module. This diff replaces the one sent
by Andreas.

I have a problem though: What if people have one ESP based SCSI adapter
compiled into the kernel, and another one as a module? You can configure the
kernel like this, but it goes weird when compiling. First NCR53C9x.c is
compiled into the kernel, and then during "make modules" it is recompiled as
a module, and installed. The modular ESP driver then loads the NCR53C9x.c
module, even when it is already built into the kernel! This gives weird
problems, with the /proc filesystem for instance. When NCR53C9x is built
into the kernel, the modular host adapter should use the NCR53C9x built into
the kernel, in this case there shouldn't even be a NCR53C9x module.
Does anyone have some clever ideas I could use in the Makefile or something?

Kars.
-- 
------------------------------------------------------------------------------
Kars de Jong             Signaalkamp rules the waves!       Turrican@Discworld
--------======]**-----|      jongk@cs.utwente.nl      |-----**[======---------

Index: arch/m68k/config.in
===================================================================
RCS file: /usr/src/CVS/linux/arch/m68k/config.in,v
retrieving revision 1.2
diff -u -r1.2 config.in
--- config.in	1999/01/18 19:38:07	1.2
+++ config.in	1999/01/28 15:11:22
@@ -147,6 +147,7 @@
     bool 'A4091 SCSI support' CONFIG_A4091_SCSI
     bool 'WarpEngine SCSI support' CONFIG_WARPENGINE_SCSI
     bool 'Blizzard PowerUP 603e+ SCSI' CONFIG_BLZ603EPLUS_SCSI
+    dep_tristate 'BSC Oktagon SCSI support' CONFIG_OKTAGON_SCSI $CONFIG_SCSI
 #    bool 'Cyberstorm Mk III SCSI support' CONFIG_CYBERSTORMIII_SCSI
 #    bool 'GVP Turbo 040/060 SCSI support' CONFIG_GVP_TURBO_SCSI
   fi
Index: drivers/scsi/Makefile
===================================================================
RCS file: /usr/src/CVS/linux/drivers/scsi/Makefile,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 Makefile
--- Makefile	1999/01/18 16:20:45	1.1.1.1
+++ Makefile	1999/01/28 14:09:56
@@ -18,7 +18,10 @@
 CFLAGS_seagate.o =   -DARBITRATE -DPARITY -DSEAGATE_USE_ASM
 
 .SUFFIXES:
-.SUFFIXES: .c .o .h .a
+.SUFFIXES: .c .o .h .a .S
+
+.S.o:
+	$(CC) -D__ASSEMBLY__ -c $< -o $*.o
 
 ifeq (${CFLAGS},)
 CFLAGS = -D__KERNEL__=1 \
@@ -254,6 +257,14 @@
 else
   ifeq ($(CONFIG_FASTLANE_SCSI),m)
   M_OBJS += NCR53C9x.o fastlane.o
+  endif
+endif
+
+ifeq ($(CONFIG_OKTAGON_SCSI),y)
+L_OBJS += NCR53C9x.o oktagon_esp.o oktagon_io.o
+else
+  ifeq ($(CONFIG_OKTAGON_SCSI),m)
+  M_OBJS += NCR53C9x.o oktagon_esp.o oktagon_io.o
   endif
 endif
 
Index: drivers/scsi/NCR53C9x.c
===================================================================
RCS file: /usr/src/CVS/linux/drivers/scsi/NCR53C9x.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 NCR53C9x.c
--- NCR53C9x.c	1999/01/18 16:21:03	1.1.1.1
+++ NCR53C9x.c	1999/01/28 17:52:24
@@ -6,6 +6,9 @@
  *
  * Most DMA dependencies put in driver specific files by 
  * Jesper Skov (jskov@cygnus.co.uk)
+ *
+ * Set up to use esp_read/esp_write (preprocessor macros in NCR53c9x.h) by
+ * Tymm Twillman (tymm@coe.missouri.edu)
  */
 
 /* TODO:
@@ -508,7 +511,7 @@
 }
 
 /* This places the ESP into a known state at boot time. */
-static void esp_bootup_reset(struct NCR_ESP *esp, struct ESP_regs *eregs)
+void esp_bootup_reset(struct NCR_ESP *esp, struct ESP_regs *eregs)
 {
 	volatile unchar trash;
 
@@ -547,6 +550,9 @@
 	esp->edev = esp_dev;
 	esp->esp_id = nesps++;
 
+	/* Set bitshift value (only used on Amiga with multiple ESPs) */
+	esp->shift = 2;
+
 	/* Put into the chain of esp chips detected */
 	if(espchain) {
 		elink = espchain;
@@ -560,6 +566,20 @@
 	return esp;
 }
 
+void esp_deallocate(struct NCR_ESP *esp)
+{
+	struct NCR_ESP *elink;
+
+	if(espchain == esp) {
+		espchain = 0;
+	} else {
+		for(elink = espchain; elink && (elink->next != esp); elink = elink->next);
+		if(elink) 
+			elink->next = esp->next;
+	}
+	nesps--;
+}
+
 /* Complete initialization of ESP structure and device
  * Caller must have initialized appropriate parts of the ESP structure
  * between the call to esp_allocate and this function.
@@ -1794,7 +1814,7 @@
 		int oldphase, i = 0; /* or where we left off last time ?? esp->current_data ?? */
 		int fifocnt = 0;
 
-		oldphase = eregs->esp_status & ESP_STAT_PMASK;
+		oldphase = esp_read(eregs->esp_status) & ESP_STAT_PMASK;
 
 		/*
 		 * polled transfer; ugly, can we make this happen in a DRQ 
@@ -3395,7 +3415,7 @@
 	esp->sreg = esp_read(eregs->esp_status);
 	esp->sreg &= (~ESP_STAT_INTR);
 	esp->seqreg = (esp_read(eregs->esp_sstep) & ESP_STEP_VBITS);
-	esp->ireg = eregs->esp_intrpt;   /* Unlatch intr and stat regs */
+	esp->ireg = esp_read(eregs->esp_intrpt);   /* Unlatch intr and stat regs */
 	ESPIRQ(("handle_irq: [sreg<%02x> sstep<%02x> ireg<%02x>]\n",
 		esp->sreg, esp->seqreg, esp->ireg));
 	if(esp->sreg & (ESP_STAT_SPAM)) {
@@ -3596,5 +3616,7 @@
 void esp_release(void)
 {
 	MOD_DEC_USE_COUNT;
+	esps_in_use--;
+	esps_running = esps_in_use;
 }
 #endif
Index: drivers/scsi/NCR53C9x.h
===================================================================
RCS file: /usr/src/CVS/linux/drivers/scsi/NCR53C9x.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 NCR53C9x.h
--- NCR53C9x.h	1999/01/18 16:21:03	1.1.1.1
+++ NCR53C9x.h	1999/01/28 17:54:31
@@ -6,6 +6,8 @@
  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  *
  * Generalization by Jesper Skov (jskov@cygnus.co.uk)
+ *
+ * More generalization (for i386 stuff) by Tymm Twillman (tymm@computer.org)
  */
 
 #ifndef NCR53C9X_H
@@ -20,6 +22,22 @@
 #define PAD_SIZE 3
 #endif
 
+/* Handle multiple hostadapters on Amiga
+ * generally PAD_SIZE = 3
+ * but there is one exception: Oktagon (PAD_SIZE = 1) */
+#if defined(CONFIG_OKTAGON_SCSI) || defined(CONFIG_OKTAGON_SCSI_MODULE)
+#undef PAD_SIZE
+#if defined(CONFIG_BLZ1230_SCSI) || defined(CONFIG_BLZ1230_SCSI_MODULE) || \
+    defined(CONFIG_BLZ2060_SCSI) || defined(CONFIG_BLZ2060_SCSI_MODULE) || \
+    defined(CONFIG_CYBERSTORM_SCSI) || defined(CONFIG_CYBERSTORM_SCSI_MODULE) || \
+    defined(CONFIG_CYBERSTORMII_SCSI) || defined(CONFIG_CYBERSTORMII_SCSI_MODULE) || \
+    defined(CONFIG_FASTLANE_SCSI) || defined(CONFIG_FASTLANE_SCSI_MODULE)
+#define MULTIPLE_PAD_SIZES
+#else
+#define PAD_SIZE 1
+#endif
+#endif
+
 /* Macros for debugging messages */
 
 #define DEBUG_ESP
@@ -107,8 +125,10 @@
 #ifdef CONFIG_JAZZ_ESP
 #define EREGS_PAD(n)
 #else
+#ifndef MULTIPLE_PAD_SIZES
 #define EREGS_PAD(n)    unchar n[PAD_SIZE];
 #endif
+#endif
 
 /* The ESP SCSI controllers have their register sets in three
  * "classes":
@@ -120,12 +140,10 @@
  * Yet, they all live within the same IO space.
  */
 
-/* All the ESP registers are one byte each and are accessed longwords
- * apart with a big-endian ordering to the bytes.
- */
-
 #ifndef __i386__
 
+#ifndef MULTIPLE_PAD_SIZES
+
 #define esp_write(__reg, __val) ((__reg) = (__val))
 #define esp_read(__reg) (__reg)
 
@@ -172,14 +190,51 @@
     volatile unchar esp_fgrnd;  /* rw  Data base for fifo             0x3c  */
 };
 
+#else /* MULTIPLE_PAD_SIZES */
+
+#define esp_write(__reg, __val) (*(__reg) = (__val))
+#define esp_read(__reg) (*(__reg))
+
+struct ESP_regs {
+    unsigned char io_addr[64]; /* dummy */
+                                                 /* Access    Description              Offset */
+#define esp_tclow   io_addr                      /* rw  Low bits of the transfer count 0x00   */
+#define esp_tcmed   io_addr + (1<<(esp->shift))  /* rw  Mid bits of the transfer count 0x04   */
+#define esp_fdata   io_addr + (2<<(esp->shift))  /* rw  FIFO data bits                 0x08   */
+#define esp_cmnd    io_addr + (3<<(esp->shift))  /* rw  SCSI command bits              0x0c   */
+#define esp_status  io_addr + (4<<(esp->shift))  /* ro  ESP status register            0x10   */
+#define esp_busid   esp_status                   /* wo  Bus ID for select/reselect     0x10   */
+#define esp_intrpt  io_addr + (5<<(esp->shift))  /* ro  Kind of interrupt              0x14   */
+#define esp_timeo   esp_intrpt                   /* wo  Timeout value for select/resel 0x14   */
+#define esp_sstep   io_addr + (6<<(esp->shift))  /* ro  Sequence step register         0x18   */
+#define esp_stp     esp_sstep                    /* wo  Transfer period per sync       0x18   */
+#define esp_fflags  io_addr + (7<<(esp->shift))  /* ro  Bits of current FIFO info      0x1c   */
+#define esp_soff    esp_fflags                   /* wo  Sync offset                    0x1c   */
+#define esp_cfg1    io_addr + (8<<(esp->shift))  /* rw  First configuration register   0x20   */
+#define esp_cfact   io_addr + (9<<(esp->shift))  /* wo  Clock conversion factor        0x24   */
+#define esp_ctest   io_addr + (10<<(esp->shift)) /* wo  Chip test register             0x28   */
+#define esp_cfg2    io_addr + (11<<(esp->shift)) /* rw  Second configuration register  0x2c   */
+
+    /* The following is only found on the 53C9X series SCSI chips */
+#define esp_cfg3    io_addr + (12<<(esp->shift)) /* rw  Third configuration register   0x30  */
+#define esp_cfg4    io_addr + (13<<(esp->shift)) /* rw  Fourth configuration register  0x34  */
+
+    /* The following is found on all chips except the NCR53C90 (ESP100) */
+#define esp_tchi    io_addr + (14<<(esp->shift)) /* rw  High bits of transfer count    0x38  */
+#define esp_uid     esp_tchi                     /* ro  Unique ID code                 0x38  */
+#define esp_fgrnd   io_addr + (15<<(esp->shift)) /* rw  Data base for fifo             0x3c  */
+};
+
+#endif
+
 #else /* !defined __i386__ */
 
-#define esp_write(__reg, __val) outb((__reg), (__val))
+#define esp_write(__reg, __val) outb((__val), (__reg))
 #define esp_read(__reg) inb((__reg))
 
 struct ESP_regs {
     unsigned int io_addr;
-                                  /* Access    Description              Offset */
+                                 /* Access    Description              Offset */
 #define esp_tclow   io_addr      /* rw  Low bits of the transfer count 0x00   */
 #define esp_tcmed   io_addr + 1  /* rw  Mid bits of the transfer count 0x04   */
 #define esp_fdata   io_addr + 2  /* rw  FIFO data bits                 0x08   */
@@ -339,6 +394,9 @@
 
   unchar do_pio_cmds;		/* Do command transfer with pio */
 
+  /* How much bits do we have to shift the registers */
+  unsigned char shift;
+
   /* Functions handling DMA
    */ 
   /* Required functions */
@@ -581,6 +639,7 @@
 extern inline void esp_cmd(struct NCR_ESP *esp, struct ESP_regs *eregs,
 			   unchar cmd);
 extern struct NCR_ESP *esp_allocate(Scsi_Host_Template *, void *);
+extern void esp_deallocate(struct NCR_ESP *);
 extern void esp_release(void);
 extern void esp_initialize(struct NCR_ESP *);
 extern void esp_intr(int, void *, struct pt_regs *);
Index: drivers/scsi/blz1230.c
===================================================================
RCS file: /usr/src/CVS/linux/drivers/scsi/blz1230.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 blz1230.c
--- blz1230.c	1999/01/18 16:21:03	1.1.1.1
+++ blz1230.c	1999/01/28 17:50:50
@@ -82,12 +82,15 @@
 		eregs = (struct ESP_regs *)(address + BLZ1230II_ESP_ADDR);
 #endif
 
-		eregs->esp_cfg1 = (ESP_CONFIG1_PENABLE | 7);
+		esp = esp_allocate(tpnt, (void *) esp_dev);
+
+		esp_write(eregs->esp_cfg1, (ESP_CONFIG1_PENABLE | 7));
 		udelay(5);
-		if(eregs->esp_cfg1 != (ESP_CONFIG1_PENABLE | 7))
+		if(esp_read(eregs->esp_cfg1) != (ESP_CONFIG1_PENABLE | 7)){
+			esp_deallocate(esp);
+			scsi_unregister(esp->ehost);
 			return 0; /* Bail out if address did not hold data */
-
-		esp = esp_allocate(tpnt, (void *) esp_dev);
+		}
 
 		/* Do command transfer with programmed I/O */
 		esp->do_pio_cmds = 1;
@@ -251,7 +254,7 @@
 
 static int dma_irq_p(struct NCR_ESP *esp)
 {
-	return (esp->eregs->esp_status & ESP_STAT_INTR);
+	return (esp_read(esp->eregs->esp_status) & ESP_STAT_INTR);
 }
 
 static int dma_ports_p(struct NCR_ESP *esp)
@@ -289,6 +292,7 @@
 	unsigned int key;
 
 	key = ((struct NCR_ESP *)instance->hostdata)->slot;
+	esp_deallocate((struct NCR_ESP *)instance->hostdata);
 	esp_release();
 	zorro_unconfig_board(key, 0);
 	free_irq(IRQ_AMIGA_PORTS, esp_intr);
Index: drivers/scsi/blz2060.c
===================================================================
RCS file: /usr/src/CVS/linux/drivers/scsi/blz2060.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 blz2060.c
--- blz2060.c	1999/01/18 16:21:04	1.1.1.1
+++ blz2060.c	1999/01/28 17:51:10
@@ -203,7 +203,7 @@
 
 static int dma_irq_p(struct NCR_ESP *esp)
 {
-	return (esp->eregs->esp_status & ESP_STAT_INTR);
+	return (esp_read(esp->eregs->esp_status) & ESP_STAT_INTR);
 }
 
 static void dma_led_off(struct NCR_ESP *esp)
@@ -252,6 +252,7 @@
 	unsigned int key;
 
 	key = ((struct NCR_ESP *)instance->hostdata)->slot;
+	esp_deallocate((struct NCR_ESP *)instance->hostdata);
 	esp_release();
 	zorro_unconfig_board(key, 0);
 	free_irq(IRQ_AMIGA_PORTS, esp_intr);
Index: drivers/scsi/cyberstorm.c
===================================================================
RCS file: /usr/src/CVS/linux/drivers/scsi/cyberstorm.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 cyberstorm.c
--- cyberstorm.c	1999/01/18 16:21:04	1.1.1.1
+++ cyberstorm.c	1999/01/28 16:12:41
@@ -265,7 +265,7 @@
 static int dma_irq_p(struct NCR_ESP *esp)
 {
 	/* It's important to check the DMA IRQ bit in the correct way! */
-	return ((esp->eregs->esp_status & ESP_STAT_INTR) &&
+	return ((esp_read(esp->eregs->esp_status) & ESP_STAT_INTR) &&
 		((((struct cyber_dma_registers *)(esp->dregs))->cond_reg) &
 		 CYBER_DMA_HNDL_INTR));
 }
@@ -317,6 +317,7 @@
 	unsigned int key;
 
 	key = ((struct NCR_ESP *)instance->hostdata)->slot;
+	esp_deallocate((struct NCR_ESP *)instance->hostdata);
 	esp_release();
 	zorro_unconfig_board(key, 0);
 	free_irq(IRQ_AMIGA_PORTS, esp_intr);
Index: drivers/scsi/cyberstormII.c
===================================================================
RCS file: /usr/src/CVS/linux/drivers/scsi/cyberstormII.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 cyberstormII.c
--- cyberstormII.c	1999/01/18 16:21:04	1.1.1.1
+++ cyberstormII.c	1999/01/28 16:16:13
@@ -73,12 +73,15 @@
 		address = (unsigned long)ZTWO_VADDR(esp_dev->cd_BoardAddr);
 		eregs = (struct ESP_regs *)(address + CYBERII_ESP_ADDR);
 
-		eregs->esp_cfg1 = (ESP_CONFIG1_PENABLE | 7);
+		esp = esp_allocate(tpnt, (void *) esp_dev);
+
+		esp_write(eregs->esp_cfg1, (ESP_CONFIG1_PENABLE | 7));
 		udelay(5);
-		if(eregs->esp_cfg1 != (ESP_CONFIG1_PENABLE | 7))
+		if(esp_read(eregs->esp_cfg1) != (ESP_CONFIG1_PENABLE | 7)) {
+			esp_deallocate(esp);
+			scsi_unregister(esp->ehost);
 			return 0; /* Bail out if address did not hold data */
-
-		esp = esp_allocate(tpnt, (void *) esp_dev);
+		}
 
 		/* Do command transfer with programmed I/O */
 		esp->do_pio_cmds = 1;
@@ -216,7 +219,7 @@
 static int dma_irq_p(struct NCR_ESP *esp)
 {
 	/* It's important to check the DMA IRQ bit in the correct way! */
-	return (esp->eregs->esp_status & ESP_STAT_INTR);
+	return (esp_read(esp->eregs->esp_status) & ESP_STAT_INTR);
 }
 
 static void dma_led_off(struct NCR_ESP *esp)
@@ -264,6 +267,7 @@
 	unsigned int key;
 
 	key = ((struct NCR_ESP *)instance->hostdata)->slot;
+	esp_deallocate((struct NCR_ESP *)instance->hostdata); 
 	esp_release();
 	zorro_unconfig_board(key, 0);
 	free_irq(IRQ_AMIGA_PORTS, esp_intr);
Index: drivers/scsi/fastlane.c
===================================================================
RCS file: /usr/src/CVS/linux/drivers/scsi/fastlane.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 fastlane.c
--- fastlane.c	1999/01/18 16:21:04	1.1.1.1
+++ fastlane.c	1999/01/28 16:17:00
@@ -313,7 +313,7 @@
 	   (dma_status & FASTLANE_DMA_CREQ) &&
 #endif
 	   (!(dma_status & FASTLANE_DMA_MINT)) &&
-	   ((((struct ESP_regs *) (esp->eregs))->esp_status) & ESP_STAT_INTR));
+	   (esp_read(((struct ESP_regs *) (esp->eregs))->esp_status) & ESP_STAT_INTR));
 }
 
 static void dma_led_off(struct NCR_ESP *esp)
@@ -363,6 +363,7 @@
 	unsigned int key;
 
 	key = ((struct NCR_ESP *)instance->hostdata)->slot;
+	esp_deallocate((struct NCR_ESP *)instance->hostdata);
 	esp_release();
 	zorro_unconfig_board(key, 0);
 	free_irq(IRQ_AMIGA_PORTS, esp_intr);
Index: drivers/scsi/hosts.c
===================================================================
RCS file: /usr/src/CVS/linux/drivers/scsi/hosts.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 hosts.c
--- hosts.c	1999/01/18 20:27:43	1.1.1.2
+++ hosts.c	1999/01/28 14:09:57
@@ -95,6 +95,10 @@
 #include "fastlane.h"
 #endif
 
+#ifdef CONFIG_OKTAGON_SCSI
+#include "oktagon_esp.h"
+#endif
+
 #ifdef CONFIG_ATARI_SCSI
 #include "atari_scsi.h"
 #endif
@@ -389,6 +393,9 @@
 #endif
 #ifdef CONFIG_FASTLANE_SCSI
 	SCSI_FASTLANE,
+#endif
+#ifdef CONFIG_OKTAGON_SCSI
+	SCSI_OKTAGON_ESP,
 #endif
 #endif
 
Index: drivers/scsi/jazz_esp.c
===================================================================
RCS file: /usr/src/CVS/linux/drivers/scsi/jazz_esp.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 jazz_esp.c
--- jazz_esp.c	1999/01/18 16:21:05	1.1.1.1
+++ jazz_esp.c	1999/01/28 14:58:27
@@ -196,7 +196,7 @@
 
 static int dma_irq_p(struct NCR_ESP *esp)
 {
-    return (esp->eregs->esp_status & ESP_STAT_INTR);
+    return (esp_read(esp->eregs->esp_status) & ESP_STAT_INTR);
 }
 
 static int dma_ports_p(struct NCR_ESP *esp)
Index: drivers/scsi/mac_esp.c
===================================================================
RCS file: /usr/src/CVS/linux/drivers/scsi/mac_esp.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 mac_esp.c
--- mac_esp.c	1999/01/18 20:27:51	1.1.1.2
+++ mac_esp.c	1999/01/28 14:58:03
@@ -480,7 +480,7 @@
 static int esp_dafb_dma_irq_p(struct NCR_ESP * esp)
 {
 	unsigned int ret;
-	int sreg = esp->eregs->esp_status;
+	int sreg = esp_read(esp->eregs->esp_status);
 
 #ifdef DEBUG_MAC_ESP
 	printk("mac_esp: esp_dafb_dma_irq_p dafb %d irq %d\n", 
@@ -521,7 +521,7 @@
 static int esp_iosb_dma_irq_p(struct NCR_ESP * esp)
 {
 	int ret  = mac_irq_pending(IRQ_MAC_SCSI) || mac_irq_pending(IRQ_MAC_SCSIDRQ);
-	int sreg = esp->eregs->esp_status;
+	int sreg = esp_read(esp->eregs->esp_status);
 
 #ifdef DEBUG_MAC_ESP
 	printk("mac_esp: dma_irq_p drq %d irq %d sreg %x curr %p disc %p\n", 
@@ -625,7 +625,7 @@
 
 static int dma_irq_p(struct NCR_ESP * esp)
 {
-	int i = esp->eregs->esp_status;
+	int i = esp_read(esp->eregs->esp_status);
 
 #ifdef DEBUG_MAC_ESP
 	printk("mac_esp: dma_irq_p status %d\n", i);
@@ -640,7 +640,7 @@
 	 * Copied from iosb_dma_irq_p()
 	 */
 	int ret  = mac_irq_pending(IRQ_MAC_SCSI) || mac_irq_pending(IRQ_MAC_SCSIDRQ);
-	int sreg = esp->eregs->esp_status;
+	int sreg = esp_read(esp->eregs->esp_status);
 
 #ifdef DEBUG_MAC_ESP
 	printk("mac_esp: dma_irq_p drq %d irq %d sreg %x curr %p disc %p\n", 
Index: drivers/scsi/mca_53c9x.c
===================================================================
RCS file: /usr/src/CVS/linux/drivers/scsi/mca_53c9x.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 mca_53c9x.c
--- mca_53c9x.c	1999/01/18 16:21:06	1.1.1.1
+++ mca_53c9x.c	1999/01/28 16:22:30
@@ -156,6 +156,8 @@
 			 "NCR 53c9x SCSI", esp_intr))
 			{
 				printk("Unable to request IRQ %d.\n", esp->irq);
+				esp_deallocate(esp);
+				unregister_scsi(esp->ehost);
 				return 0;
 			}
 
@@ -163,6 +165,8 @@
 				printk("Unable to request DMA channel %d.\n",
 				 esp->dma);
 				free_irq(esp->irq, esp_intr);
+				esp_deallocate(esp);
+				unregister_scsi(esp->ehost);
 				return 0;
 			}
 
@@ -259,7 +263,7 @@
 	struct NCR_ESP *esp = (struct NCR_ESP *)host->hostdata;
 	unsigned char tmp_byte;
 
-
+	esp_deallocate(esp);
 	/*
 	 * Tell the 86C01 to stop sending interrupts
 	 */

