aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/gvp11.c
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert@linux-m68k.org>2010-04-04 05:00:37 -0400
committerJames Bottomley <James.Bottomley@suse.de>2010-05-02 16:01:24 -0400
commit52c3d8a65f779430bfae1305f7d50eb44df9875e (patch)
tree9d3e85ad666e4a939677118ef69776acebdaa64e /drivers/scsi/gvp11.c
parent6d1d5d43e5911bfdb7ec47cc3d1438dbbf2a9de2 (diff)
[SCSI] gvp11: Use shost_priv() and kill ugly HDATA() macro
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/gvp11.c')
-rw-r--r--drivers/scsi/gvp11.c93
1 files changed, 46 insertions, 47 deletions
diff --git a/drivers/scsi/gvp11.c b/drivers/scsi/gvp11.c
index bd5d90328ee0..18b7102bb80e 100644
--- a/drivers/scsi/gvp11.c
+++ b/drivers/scsi/gvp11.c
@@ -23,7 +23,6 @@
23 23
24 24
25#define DMA(ptr) ((gvp11_scsiregs *)((ptr)->base)) 25#define DMA(ptr) ((gvp11_scsiregs *)((ptr)->base))
26#define HDATA(ptr) ((struct WD33C93_hostdata *)((ptr)->hostdata))
27 26
28static irqreturn_t gvp11_intr(int irq, void *_instance) 27static irqreturn_t gvp11_intr(int irq, void *_instance)
29{ 28{
@@ -50,70 +49,66 @@ void gvp11_setup(char *str, int *ints)
50 49
51static int dma_setup(struct scsi_cmnd *cmd, int dir_in) 50static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
52{ 51{
52 struct Scsi_Host *instance = cmd->device->host;
53 struct WD33C93_hostdata *hdata = shost_priv(instance);
53 unsigned short cntr = GVP11_DMAC_INT_ENABLE; 54 unsigned short cntr = GVP11_DMAC_INT_ENABLE;
54 unsigned long addr = virt_to_bus(cmd->SCp.ptr); 55 unsigned long addr = virt_to_bus(cmd->SCp.ptr);
55 int bank_mask; 56 int bank_mask;
56 static int scsi_alloc_out_of_range = 0; 57 static int scsi_alloc_out_of_range = 0;
57 58
58 /* use bounce buffer if the physical address is bad */ 59 /* use bounce buffer if the physical address is bad */
59 if (addr & HDATA(cmd->device->host)->dma_xfer_mask) { 60 if (addr & hdata->dma_xfer_mask) {
60 HDATA(cmd->device->host)->dma_bounce_len = 61 hdata->dma_bounce_len = (cmd->SCp.this_residual + 511) & ~0x1ff;
61 (cmd->SCp.this_residual + 511) & ~0x1ff;
62 62
63 if (!scsi_alloc_out_of_range) { 63 if (!scsi_alloc_out_of_range) {
64 HDATA(cmd->device->host)->dma_bounce_buffer = 64 hdata->dma_bounce_buffer =
65 kmalloc(HDATA(cmd->device->host)->dma_bounce_len, 65 kmalloc(hdata->dma_bounce_len, GFP_KERNEL);
66 GFP_KERNEL); 66 hdata->dma_buffer_pool = BUF_SCSI_ALLOCED;
67 HDATA(cmd->device->host)->dma_buffer_pool =
68 BUF_SCSI_ALLOCED;
69 } 67 }
70 68
71 if (scsi_alloc_out_of_range || 69 if (scsi_alloc_out_of_range ||
72 !HDATA(cmd->device->host)->dma_bounce_buffer) { 70 !hdata->dma_bounce_buffer) {
73 HDATA(cmd->device->host)->dma_bounce_buffer = 71 hdata->dma_bounce_buffer =
74 amiga_chip_alloc(HDATA(cmd->device->host)->dma_bounce_len, 72 amiga_chip_alloc(hdata->dma_bounce_len,
75 "GVP II SCSI Bounce Buffer"); 73 "GVP II SCSI Bounce Buffer");
76 74
77 if (!HDATA(cmd->device->host)->dma_bounce_buffer) { 75 if (!hdata->dma_bounce_buffer) {
78 HDATA(cmd->device->host)->dma_bounce_len = 0; 76 hdata->dma_bounce_len = 0;
79 return 1; 77 return 1;
80 } 78 }
81 79
82 HDATA(cmd->device->host)->dma_buffer_pool = 80 hdata->dma_buffer_pool = BUF_CHIP_ALLOCED;
83 BUF_CHIP_ALLOCED;
84 } 81 }
85 82
86 /* check if the address of the bounce buffer is OK */ 83 /* check if the address of the bounce buffer is OK */
87 addr = virt_to_bus(HDATA(cmd->device->host)->dma_bounce_buffer); 84 addr = virt_to_bus(hdata->dma_bounce_buffer);
88 85
89 if (addr & HDATA(cmd->device->host)->dma_xfer_mask) { 86 if (addr & hdata->dma_xfer_mask) {
90 /* fall back to Chip RAM if address out of range */ 87 /* fall back to Chip RAM if address out of range */
91 if (HDATA(cmd->device->host)->dma_buffer_pool == 88 if (hdata->dma_buffer_pool == BUF_SCSI_ALLOCED) {
92 BUF_SCSI_ALLOCED) { 89 kfree(hdata->dma_bounce_buffer);
93 kfree(HDATA(cmd->device->host)->dma_bounce_buffer);
94 scsi_alloc_out_of_range = 1; 90 scsi_alloc_out_of_range = 1;
95 } else { 91 } else {
96 amiga_chip_free(HDATA(cmd->device->host)->dma_bounce_buffer); 92 amiga_chip_free(hdata->dma_bounce_buffer);
97 } 93 }
98 94
99 HDATA(cmd->device->host)->dma_bounce_buffer = 95 hdata->dma_bounce_buffer =
100 amiga_chip_alloc(HDATA(cmd->device->host)->dma_bounce_len, 96 amiga_chip_alloc(hdata->dma_bounce_len,
101 "GVP II SCSI Bounce Buffer"); 97 "GVP II SCSI Bounce Buffer");
102 98
103 if (!HDATA(cmd->device->host)->dma_bounce_buffer) { 99 if (!hdata->dma_bounce_buffer) {
104 HDATA(cmd->device->host)->dma_bounce_len = 0; 100 hdata->dma_bounce_len = 0;
105 return 1; 101 return 1;
106 } 102 }
107 103
108 addr = virt_to_bus(HDATA(cmd->device->host)->dma_bounce_buffer); 104 addr = virt_to_bus(hdata->dma_bounce_buffer);
109 HDATA(cmd->device->host)->dma_buffer_pool = 105 hdata->dma_buffer_pool = BUF_CHIP_ALLOCED;
110 BUF_CHIP_ALLOCED;
111 } 106 }
112 107
113 if (!dir_in) { 108 if (!dir_in) {
114 /* copy to bounce buffer for a write */ 109 /* copy to bounce buffer for a write */
115 memcpy(HDATA(cmd->device->host)->dma_bounce_buffer, 110 memcpy(hdata->dma_bounce_buffer, cmd->SCp.ptr,
116 cmd->SCp.ptr, cmd->SCp.this_residual); 111 cmd->SCp.this_residual);
117 } 112 }
118 } 113 }
119 114
@@ -121,7 +116,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
121 if (!dir_in) 116 if (!dir_in)
122 cntr |= GVP11_DMAC_DIR_WRITE; 117 cntr |= GVP11_DMAC_DIR_WRITE;
123 118
124 HDATA(cmd->device->host)->dma_dir = dir_in; 119 hdata->dma_dir = dir_in;
125 DMA(cmd->device->host)->CNTR = cntr; 120 DMA(cmd->device->host)->CNTR = cntr;
126 121
127 /* setup DMA *physical* address */ 122 /* setup DMA *physical* address */
@@ -135,7 +130,8 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
135 cache_push(addr, cmd->SCp.this_residual); 130 cache_push(addr, cmd->SCp.this_residual);
136 } 131 }
137 132
138 if ((bank_mask = (~HDATA(cmd->device->host)->dma_xfer_mask >> 18) & 0x01c0)) 133 bank_mask = (~hdata->dma_xfer_mask >> 18) & 0x01c0;
134 if (bank_mask)
139 DMA(cmd->device->host)->BANK = bank_mask & (addr >> 18); 135 DMA(cmd->device->host)->BANK = bank_mask & (addr >> 18);
140 136
141 /* start DMA */ 137 /* start DMA */
@@ -148,25 +144,26 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
148static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, 144static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt,
149 int status) 145 int status)
150{ 146{
147 struct WD33C93_hostdata *hdata = shost_priv(instance);
148
151 /* stop DMA */ 149 /* stop DMA */
152 DMA(instance)->SP_DMA = 1; 150 DMA(instance)->SP_DMA = 1;
153 /* remove write bit from CONTROL bits */ 151 /* remove write bit from CONTROL bits */
154 DMA(instance)->CNTR = GVP11_DMAC_INT_ENABLE; 152 DMA(instance)->CNTR = GVP11_DMAC_INT_ENABLE;
155 153
156 /* copy from a bounce buffer, if necessary */ 154 /* copy from a bounce buffer, if necessary */
157 if (status && HDATA(instance)->dma_bounce_buffer) { 155 if (status && hdata->dma_bounce_buffer) {
158 if (HDATA(instance)->dma_dir && SCpnt) 156 if (hdata->dma_dir && SCpnt)
159 memcpy(SCpnt->SCp.ptr, 157 memcpy(SCpnt->SCp.ptr, hdata->dma_bounce_buffer,
160 HDATA(instance)->dma_bounce_buffer,
161 SCpnt->SCp.this_residual); 158 SCpnt->SCp.this_residual);
162 159
163 if (HDATA(instance)->dma_buffer_pool == BUF_SCSI_ALLOCED) 160 if (hdata->dma_buffer_pool == BUF_SCSI_ALLOCED)
164 kfree(HDATA(instance)->dma_bounce_buffer); 161 kfree(hdata->dma_bounce_buffer);
165 else 162 else
166 amiga_chip_free(HDATA(instance)->dma_bounce_buffer); 163 amiga_chip_free(hdata->dma_bounce_buffer);
167 164
168 HDATA(instance)->dma_bounce_buffer = NULL; 165 hdata->dma_bounce_buffer = NULL;
169 HDATA(instance)->dma_bounce_len = 0; 166 hdata->dma_bounce_len = 0;
170 } 167 }
171} 168}
172 169
@@ -180,6 +177,7 @@ int __init gvp11_detect(struct scsi_host_template *tpnt)
180 unsigned int epc; 177 unsigned int epc;
181 struct zorro_dev *z = NULL; 178 struct zorro_dev *z = NULL;
182 unsigned int default_dma_xfer_mask; 179 unsigned int default_dma_xfer_mask;
180 struct WD33C93_hostdata *hdata;
183 wd33c93_regs regs; 181 wd33c93_regs regs;
184 int num_gvp11 = 0; 182 int num_gvp11 = 0;
185#ifdef CHECK_WD33C93 183#ifdef CHECK_WD33C93
@@ -306,10 +304,11 @@ int __init gvp11_detect(struct scsi_host_template *tpnt)
306 instance->irq = IRQ_AMIGA_PORTS; 304 instance->irq = IRQ_AMIGA_PORTS;
307 instance->unique_id = z->slotaddr; 305 instance->unique_id = z->slotaddr;
308 306
307 hdata = shost_priv(instance);
309 if (gvp11_xfer_mask) 308 if (gvp11_xfer_mask)
310 HDATA(instance)->dma_xfer_mask = gvp11_xfer_mask; 309 hdata->dma_xfer_mask = gvp11_xfer_mask;
311 else 310 else
312 HDATA(instance)->dma_xfer_mask = default_dma_xfer_mask; 311 hdata->dma_xfer_mask = default_dma_xfer_mask;
313 312
314 DMA(instance)->secret2 = 1; 313 DMA(instance)->secret2 = 1;
315 DMA(instance)->secret1 = 0; 314 DMA(instance)->secret1 = 0;
@@ -327,9 +326,9 @@ int __init gvp11_detect(struct scsi_host_template *tpnt)
327 */ 326 */
328 regs.SASR = &(DMA(instance)->SASR); 327 regs.SASR = &(DMA(instance)->SASR);
329 regs.SCMD = &(DMA(instance)->SCMD); 328 regs.SCMD = &(DMA(instance)->SCMD);
330 HDATA(instance)->no_sync = 0xff; 329 hdata->no_sync = 0xff;
331 HDATA(instance)->fast = 0; 330 hdata->fast = 0;
332 HDATA(instance)->dma_mode = CTRL_DMA; 331 hdata->dma_mode = CTRL_DMA;
333 wd33c93_init(instance, regs, dma_setup, dma_stop, 332 wd33c93_init(instance, regs, dma_setup, dma_stop,
334 (epc & GVP_SCSICLKMASK) ? WD33C93_FS_8_10 333 (epc & GVP_SCSICLKMASK) ? WD33C93_FS_8_10
335 : WD33C93_FS_12_15); 334 : WD33C93_FS_12_15);