2323
2424
2525#define DMA (ptr ) ((a3000_scsiregs *)((ptr)->base))
26- #define HDATA (ptr ) ((struct WD33C93_hostdata *)((ptr)->hostdata))
2726
2827static struct Scsi_Host * a3000_host = NULL ;
2928
@@ -48,6 +47,7 @@ static irqreturn_t a3000_intr(int irq, void *dummy)
4847
4948static int dma_setup (struct scsi_cmnd * cmd , int dir_in )
5049{
50+ struct WD33C93_hostdata * hdata = shost_priv (a3000_host );
5151 unsigned short cntr = CNTR_PDMD | CNTR_INTEN ;
5252 unsigned long addr = virt_to_bus (cmd -> SCp .ptr );
5353
@@ -58,32 +58,31 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
5858 * buffer
5959 */
6060 if (addr & A3000_XFER_MASK ) {
61- HDATA (a3000_host )-> dma_bounce_len =
62- (cmd -> SCp .this_residual + 511 ) & ~0x1ff ;
63- HDATA (a3000_host )-> dma_bounce_buffer =
64- kmalloc (HDATA (a3000_host )-> dma_bounce_len , GFP_KERNEL );
61+ hdata -> dma_bounce_len = (cmd -> SCp .this_residual + 511 ) & ~0x1ff ;
62+ hdata -> dma_bounce_buffer = kmalloc (hdata -> dma_bounce_len ,
63+ GFP_KERNEL );
6564
6665 /* can't allocate memory; use PIO */
67- if (!HDATA ( a3000_host ) -> dma_bounce_buffer ) {
68- HDATA ( a3000_host ) -> dma_bounce_len = 0 ;
66+ if (!hdata -> dma_bounce_buffer ) {
67+ hdata -> dma_bounce_len = 0 ;
6968 return 1 ;
7069 }
7170
7271 if (!dir_in ) {
7372 /* copy to bounce buffer for a write */
74- memcpy (HDATA ( a3000_host ) -> dma_bounce_buffer ,
75- cmd -> SCp .ptr , cmd -> SCp . this_residual );
73+ memcpy (hdata -> dma_bounce_buffer , cmd -> SCp . ptr ,
74+ cmd -> SCp .this_residual );
7675 }
7776
78- addr = virt_to_bus (HDATA ( a3000_host ) -> dma_bounce_buffer );
77+ addr = virt_to_bus (hdata -> dma_bounce_buffer );
7978 }
8079
8180 /* setup dma direction */
8281 if (!dir_in )
8382 cntr |= CNTR_DDIR ;
8483
8584 /* remember direction */
86- HDATA ( a3000_host ) -> dma_dir = dir_in ;
85+ hdata -> dma_dir = dir_in ;
8786
8887 DMA (a3000_host )-> CNTR = cntr ;
8988
@@ -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 DMA (instance )-> CNTR = cntr ;
120121 mb (); /* make sure CNTR is updated before next IO */
121122
122123 /* flush if we were reading */
123- if (HDATA ( instance ) -> dma_dir ) {
124+ if (hdata -> dma_dir ) {
124125 DMA (instance )-> FLUSH = 1 ;
125126 mb (); /* don't allow prefetch */
126127 while (!(DMA (instance )-> ISTR & ISTR_FE_FLG ))
@@ -143,26 +144,27 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt,
143144 mb (); /* make sure CNTR is updated before next IO */
144145
145146 /* copy from a bounce buffer, if necessary */
146- if (status && HDATA ( instance ) -> dma_bounce_buffer ) {
147+ if (status && hdata -> dma_bounce_buffer ) {
147148 if (SCpnt ) {
148- if (HDATA ( instance ) -> dma_dir && SCpnt )
149+ if (hdata -> dma_dir && SCpnt )
149150 memcpy (SCpnt -> SCp .ptr ,
150- HDATA ( instance ) -> dma_bounce_buffer ,
151+ hdata -> dma_bounce_buffer ,
151152 SCpnt -> SCp .this_residual );
152- kfree (HDATA ( instance ) -> dma_bounce_buffer );
153- HDATA ( instance ) -> dma_bounce_buffer = NULL ;
154- HDATA ( instance ) -> dma_bounce_len = 0 ;
153+ kfree (hdata -> dma_bounce_buffer );
154+ hdata -> dma_bounce_buffer = NULL ;
155+ hdata -> dma_bounce_len = 0 ;
155156 } else {
156- kfree (HDATA ( instance ) -> dma_bounce_buffer );
157- HDATA ( instance ) -> dma_bounce_buffer = NULL ;
158- HDATA ( instance ) -> dma_bounce_len = 0 ;
157+ kfree (hdata -> dma_bounce_buffer );
158+ hdata -> dma_bounce_buffer = NULL ;
159+ hdata -> dma_bounce_len = 0 ;
159160 }
160161 }
161162}
162163
163164static int __init a3000_detect (struct scsi_host_template * tpnt )
164165{
165166 wd33c93_regs regs ;
167+ struct WD33C93_hostdata * hdata ;
166168
167169 if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT (A3000_SCSI ))
168170 return 0 ;
@@ -181,9 +183,10 @@ static int __init a3000_detect(struct scsi_host_template *tpnt)
181183 DMA (a3000_host )-> DAWR = DAWR_A3000 ;
182184 regs .SASR = & (DMA (a3000_host )-> SASR );
183185 regs .SCMD = & (DMA (a3000_host )-> SCMD );
184- HDATA (a3000_host )-> no_sync = 0xff ;
185- HDATA (a3000_host )-> fast = 0 ;
186- HDATA (a3000_host )-> dma_mode = CTRL_DMA ;
186+ hdata = shost_priv (a3000_host );
187+ hdata -> no_sync = 0xff ;
188+ hdata -> fast = 0 ;
189+ hdata -> dma_mode = CTRL_DMA ;
187190 wd33c93_init (a3000_host , regs , dma_setup , dma_stop , WD33C93_FS_12_15 );
188191 if (request_irq (IRQ_AMIGA_PORTS , a3000_intr , IRQF_SHARED , "A3000 SCSI" ,
189192 a3000_intr ))
0 commit comments