2323
2424
2525#define DMA (ptr ) ((a2091_scsiregs *)((ptr)->base))
26- #define HDATA (ptr ) ((struct WD33C93_hostdata *)((ptr)->hostdata))
2726
2827static int a2091_release (struct Scsi_Host * instance );
2928
@@ -45,39 +44,39 @@ static irqreturn_t a2091_intr(int irq, void *_instance)
4544
4645static int dma_setup (struct scsi_cmnd * cmd , int dir_in )
4746{
47+ struct Scsi_Host * instance = cmd -> device -> host ;
48+ struct WD33C93_hostdata * hdata = shost_priv (instance );
4849 unsigned short cntr = CNTR_PDMD | CNTR_INTEN ;
4950 unsigned long addr = virt_to_bus (cmd -> SCp .ptr );
50- struct Scsi_Host * instance = cmd -> device -> host ;
5151
5252 /* don't allow DMA if the physical address is bad */
5353 if (addr & A2091_XFER_MASK ) {
54- HDATA (instance )-> dma_bounce_len =
55- (cmd -> SCp .this_residual + 511 ) & ~0x1ff ;
56- HDATA (instance )-> dma_bounce_buffer =
57- kmalloc (HDATA (instance )-> dma_bounce_len , GFP_KERNEL );
54+ hdata -> dma_bounce_len = (cmd -> SCp .this_residual + 511 ) & ~0x1ff ;
55+ hdata -> dma_bounce_buffer = kmalloc (hdata -> dma_bounce_len ,
56+ GFP_KERNEL );
5857
5958 /* can't allocate memory; use PIO */
60- if (!HDATA ( instance ) -> dma_bounce_buffer ) {
61- HDATA ( instance ) -> dma_bounce_len = 0 ;
59+ if (!hdata -> dma_bounce_buffer ) {
60+ hdata -> dma_bounce_len = 0 ;
6261 return 1 ;
6362 }
6463
6564 /* get the physical address of the bounce buffer */
66- addr = virt_to_bus (HDATA ( instance ) -> dma_bounce_buffer );
65+ addr = virt_to_bus (hdata -> dma_bounce_buffer );
6766
6867 /* the bounce buffer may not be in the first 16M of physmem */
6968 if (addr & A2091_XFER_MASK ) {
7069 /* we could use chipmem... maybe later */
71- kfree (HDATA ( instance ) -> dma_bounce_buffer );
72- HDATA ( instance ) -> dma_bounce_buffer = NULL ;
73- HDATA ( instance ) -> dma_bounce_len = 0 ;
70+ kfree (hdata -> dma_bounce_buffer );
71+ hdata -> dma_bounce_buffer = NULL ;
72+ hdata -> dma_bounce_len = 0 ;
7473 return 1 ;
7574 }
7675
7776 if (!dir_in ) {
7877 /* copy to bounce buffer for a write */
79- memcpy (HDATA ( instance ) -> dma_bounce_buffer ,
80- cmd -> SCp .ptr , cmd -> SCp . this_residual );
78+ memcpy (hdata -> dma_bounce_buffer , cmd -> SCp . ptr ,
79+ cmd -> SCp .this_residual );
8180 }
8281 }
8382
@@ -86,7 +85,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
8685 cntr |= CNTR_DDIR ;
8786
8887 /* remember direction */
89- HDATA ( cmd -> device -> host ) -> dma_dir = dir_in ;
88+ hdata -> dma_dir = dir_in ;
9089
9190 DMA (cmd -> device -> host )-> CNTR = cntr ;
9291
@@ -110,17 +109,19 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
110109static void dma_stop (struct Scsi_Host * instance , struct scsi_cmnd * SCpnt ,
111110 int status )
112111{
112+ struct WD33C93_hostdata * hdata = shost_priv (instance );
113+
113114 /* disable SCSI interrupts */
114115 unsigned short cntr = CNTR_PDMD ;
115116
116- if (!HDATA ( instance ) -> dma_dir )
117+ if (!hdata -> dma_dir )
117118 cntr |= CNTR_DDIR ;
118119
119120 /* disable SCSI interrupts */
120121 DMA (instance )-> CNTR = cntr ;
121122
122123 /* flush if we were reading */
123- if (HDATA ( instance ) -> dma_dir ) {
124+ if (hdata -> dma_dir ) {
124125 DMA (instance )-> FLUSH = 1 ;
125126 while (!(DMA (instance )-> ISTR & ISTR_FE_FLG ))
126127 ;
@@ -136,14 +137,13 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt,
136137 DMA (instance )-> CNTR = CNTR_PDMD | CNTR_INTEN ;
137138
138139 /* copy from a bounce buffer, if necessary */
139- if (status && HDATA (instance )-> dma_bounce_buffer ) {
140- if (HDATA (instance )-> dma_dir )
141- memcpy (SCpnt -> SCp .ptr ,
142- HDATA (instance )-> dma_bounce_buffer ,
140+ if (status && hdata -> dma_bounce_buffer ) {
141+ if (hdata -> dma_dir )
142+ memcpy (SCpnt -> SCp .ptr , hdata -> dma_bounce_buffer ,
143143 SCpnt -> SCp .this_residual );
144- kfree (HDATA ( instance ) -> dma_bounce_buffer );
145- HDATA ( instance ) -> dma_bounce_buffer = NULL ;
146- HDATA ( instance ) -> dma_bounce_len = 0 ;
144+ kfree (hdata -> dma_bounce_buffer );
145+ hdata -> dma_bounce_buffer = NULL ;
146+ hdata -> dma_bounce_len = 0 ;
147147 }
148148}
149149
@@ -154,6 +154,7 @@ static int __init a2091_detect(struct scsi_host_template *tpnt)
154154 unsigned long address ;
155155 struct zorro_dev * z = NULL ;
156156 wd33c93_regs regs ;
157+ struct WD33C93_hostdata * hdata ;
157158 int num_a2091 = 0 ;
158159
159160 if (!MACH_IS_AMIGA || called )
@@ -180,9 +181,10 @@ static int __init a2091_detect(struct scsi_host_template *tpnt)
180181 DMA (instance )-> DAWR = DAWR_A2091 ;
181182 regs .SASR = & (DMA (instance )-> SASR );
182183 regs .SCMD = & (DMA (instance )-> SCMD );
183- HDATA (instance )-> no_sync = 0xff ;
184- HDATA (instance )-> fast = 0 ;
185- HDATA (instance )-> dma_mode = CTRL_DMA ;
184+ hdata = shost_priv (instance );
185+ hdata -> no_sync = 0xff ;
186+ hdata -> fast = 0 ;
187+ hdata -> dma_mode = CTRL_DMA ;
186188 wd33c93_init (instance , regs , dma_setup , dma_stop ,
187189 WD33C93_FS_8_10 );
188190 if (request_irq (IRQ_AMIGA_PORTS , a2091_intr , IRQF_SHARED ,
0 commit comments