diff options
author | Geert Uytterhoeven <geert@linux-m68k.org> | 2010-04-12 15:55:25 -0400 |
---|---|---|
committer | Geert Uytterhoeven <geert@linux-m68k.org> | 2010-05-26 13:51:08 -0400 |
commit | cf2ed279f915f36c84ce21a5933ad4bba9f81de8 (patch) | |
tree | 8a5444029f1134136332b981ad32670761b96183 /drivers/scsi/gvp11.c | |
parent | c1d288a58936cd0654844d807e53a203f4838fb4 (diff) |
m68k/scsi: gvp11 - Do not use legacy Scsi_Host.base
Acked-by: James Bottomley <James.Bottomley@suse.de>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Diffstat (limited to 'drivers/scsi/gvp11.c')
-rw-r--r-- | drivers/scsi/gvp11.c | 105 |
1 files changed, 56 insertions, 49 deletions
diff --git a/drivers/scsi/gvp11.c b/drivers/scsi/gvp11.c index 4507a16ee1c6..2ce26eb7a1ec 100644 --- a/drivers/scsi/gvp11.c +++ b/drivers/scsi/gvp11.c | |||
@@ -18,11 +18,16 @@ | |||
18 | 18 | ||
19 | #define CHECK_WD33C93 | 19 | #define CHECK_WD33C93 |
20 | 20 | ||
21 | struct gvp11_hostdata { | ||
22 | struct WD33C93_hostdata wh; | ||
23 | struct gvp11_scsiregs *regs; | ||
24 | }; | ||
25 | |||
21 | static irqreturn_t gvp11_intr(int irq, void *data) | 26 | static irqreturn_t gvp11_intr(int irq, void *data) |
22 | { | 27 | { |
23 | struct Scsi_Host *instance = data; | 28 | struct Scsi_Host *instance = data; |
24 | struct gvp11_scsiregs *regs = (struct gvp11_scsiregs *)(instance->base); | 29 | struct gvp11_hostdata *hdata = shost_priv(instance); |
25 | unsigned int status = regs->CNTR; | 30 | unsigned int status = hdata->regs->CNTR; |
26 | unsigned long flags; | 31 | unsigned long flags; |
27 | 32 | ||
28 | if (!(status & GVP11_DMAC_INT_PENDING)) | 33 | if (!(status & GVP11_DMAC_INT_PENDING)) |
@@ -44,65 +49,66 @@ void gvp11_setup(char *str, int *ints) | |||
44 | static int dma_setup(struct scsi_cmnd *cmd, int dir_in) | 49 | static int dma_setup(struct scsi_cmnd *cmd, int dir_in) |
45 | { | 50 | { |
46 | struct Scsi_Host *instance = cmd->device->host; | 51 | struct Scsi_Host *instance = cmd->device->host; |
47 | struct WD33C93_hostdata *hdata = shost_priv(instance); | 52 | struct gvp11_hostdata *hdata = shost_priv(instance); |
48 | struct gvp11_scsiregs *regs = (struct gvp11_scsiregs *)(instance->base); | 53 | struct WD33C93_hostdata *wh = &hdata->wh; |
54 | struct gvp11_scsiregs *regs = hdata->regs; | ||
49 | unsigned short cntr = GVP11_DMAC_INT_ENABLE; | 55 | unsigned short cntr = GVP11_DMAC_INT_ENABLE; |
50 | unsigned long addr = virt_to_bus(cmd->SCp.ptr); | 56 | unsigned long addr = virt_to_bus(cmd->SCp.ptr); |
51 | int bank_mask; | 57 | int bank_mask; |
52 | static int scsi_alloc_out_of_range = 0; | 58 | static int scsi_alloc_out_of_range = 0; |
53 | 59 | ||
54 | /* use bounce buffer if the physical address is bad */ | 60 | /* use bounce buffer if the physical address is bad */ |
55 | if (addr & hdata->dma_xfer_mask) { | 61 | if (addr & wh->dma_xfer_mask) { |
56 | hdata->dma_bounce_len = (cmd->SCp.this_residual + 511) & ~0x1ff; | 62 | wh->dma_bounce_len = (cmd->SCp.this_residual + 511) & ~0x1ff; |
57 | 63 | ||
58 | if (!scsi_alloc_out_of_range) { | 64 | if (!scsi_alloc_out_of_range) { |
59 | hdata->dma_bounce_buffer = | 65 | wh->dma_bounce_buffer = |
60 | kmalloc(hdata->dma_bounce_len, GFP_KERNEL); | 66 | kmalloc(wh->dma_bounce_len, GFP_KERNEL); |
61 | hdata->dma_buffer_pool = BUF_SCSI_ALLOCED; | 67 | wh->dma_buffer_pool = BUF_SCSI_ALLOCED; |
62 | } | 68 | } |
63 | 69 | ||
64 | if (scsi_alloc_out_of_range || | 70 | if (scsi_alloc_out_of_range || |
65 | !hdata->dma_bounce_buffer) { | 71 | !wh->dma_bounce_buffer) { |
66 | hdata->dma_bounce_buffer = | 72 | wh->dma_bounce_buffer = |
67 | amiga_chip_alloc(hdata->dma_bounce_len, | 73 | amiga_chip_alloc(wh->dma_bounce_len, |
68 | "GVP II SCSI Bounce Buffer"); | 74 | "GVP II SCSI Bounce Buffer"); |
69 | 75 | ||
70 | if (!hdata->dma_bounce_buffer) { | 76 | if (!wh->dma_bounce_buffer) { |
71 | hdata->dma_bounce_len = 0; | 77 | wh->dma_bounce_len = 0; |
72 | return 1; | 78 | return 1; |
73 | } | 79 | } |
74 | 80 | ||
75 | hdata->dma_buffer_pool = BUF_CHIP_ALLOCED; | 81 | wh->dma_buffer_pool = BUF_CHIP_ALLOCED; |
76 | } | 82 | } |
77 | 83 | ||
78 | /* check if the address of the bounce buffer is OK */ | 84 | /* check if the address of the bounce buffer is OK */ |
79 | addr = virt_to_bus(hdata->dma_bounce_buffer); | 85 | addr = virt_to_bus(wh->dma_bounce_buffer); |
80 | 86 | ||
81 | if (addr & hdata->dma_xfer_mask) { | 87 | if (addr & wh->dma_xfer_mask) { |
82 | /* fall back to Chip RAM if address out of range */ | 88 | /* fall back to Chip RAM if address out of range */ |
83 | if (hdata->dma_buffer_pool == BUF_SCSI_ALLOCED) { | 89 | if (wh->dma_buffer_pool == BUF_SCSI_ALLOCED) { |
84 | kfree(hdata->dma_bounce_buffer); | 90 | kfree(wh->dma_bounce_buffer); |
85 | scsi_alloc_out_of_range = 1; | 91 | scsi_alloc_out_of_range = 1; |
86 | } else { | 92 | } else { |
87 | amiga_chip_free(hdata->dma_bounce_buffer); | 93 | amiga_chip_free(wh->dma_bounce_buffer); |
88 | } | 94 | } |
89 | 95 | ||
90 | hdata->dma_bounce_buffer = | 96 | wh->dma_bounce_buffer = |
91 | amiga_chip_alloc(hdata->dma_bounce_len, | 97 | amiga_chip_alloc(wh->dma_bounce_len, |
92 | "GVP II SCSI Bounce Buffer"); | 98 | "GVP II SCSI Bounce Buffer"); |
93 | 99 | ||
94 | if (!hdata->dma_bounce_buffer) { | 100 | if (!wh->dma_bounce_buffer) { |
95 | hdata->dma_bounce_len = 0; | 101 | wh->dma_bounce_len = 0; |
96 | return 1; | 102 | return 1; |
97 | } | 103 | } |
98 | 104 | ||
99 | addr = virt_to_bus(hdata->dma_bounce_buffer); | 105 | addr = virt_to_bus(wh->dma_bounce_buffer); |
100 | hdata->dma_buffer_pool = BUF_CHIP_ALLOCED; | 106 | wh->dma_buffer_pool = BUF_CHIP_ALLOCED; |
101 | } | 107 | } |
102 | 108 | ||
103 | if (!dir_in) { | 109 | if (!dir_in) { |
104 | /* copy to bounce buffer for a write */ | 110 | /* copy to bounce buffer for a write */ |
105 | memcpy(hdata->dma_bounce_buffer, cmd->SCp.ptr, | 111 | memcpy(wh->dma_bounce_buffer, cmd->SCp.ptr, |
106 | cmd->SCp.this_residual); | 112 | cmd->SCp.this_residual); |
107 | } | 113 | } |
108 | } | 114 | } |
@@ -111,7 +117,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) | |||
111 | if (!dir_in) | 117 | if (!dir_in) |
112 | cntr |= GVP11_DMAC_DIR_WRITE; | 118 | cntr |= GVP11_DMAC_DIR_WRITE; |
113 | 119 | ||
114 | hdata->dma_dir = dir_in; | 120 | wh->dma_dir = dir_in; |
115 | regs->CNTR = cntr; | 121 | regs->CNTR = cntr; |
116 | 122 | ||
117 | /* setup DMA *physical* address */ | 123 | /* setup DMA *physical* address */ |
@@ -125,7 +131,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) | |||
125 | cache_push(addr, cmd->SCp.this_residual); | 131 | cache_push(addr, cmd->SCp.this_residual); |
126 | } | 132 | } |
127 | 133 | ||
128 | bank_mask = (~hdata->dma_xfer_mask >> 18) & 0x01c0; | 134 | bank_mask = (~wh->dma_xfer_mask >> 18) & 0x01c0; |
129 | if (bank_mask) | 135 | if (bank_mask) |
130 | regs->BANK = bank_mask & (addr >> 18); | 136 | regs->BANK = bank_mask & (addr >> 18); |
131 | 137 | ||
@@ -139,8 +145,9 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) | |||
139 | static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, | 145 | static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, |
140 | int status) | 146 | int status) |
141 | { | 147 | { |
142 | struct gvp11_scsiregs *regs = (struct gvp11_scsiregs *)(instance->base); | 148 | struct gvp11_hostdata *hdata = shost_priv(instance); |
143 | struct WD33C93_hostdata *hdata = shost_priv(instance); | 149 | struct WD33C93_hostdata *wh = &hdata->wh; |
150 | struct gvp11_scsiregs *regs = hdata->regs; | ||
144 | 151 | ||
145 | /* stop DMA */ | 152 | /* stop DMA */ |
146 | regs->SP_DMA = 1; | 153 | regs->SP_DMA = 1; |
@@ -148,18 +155,18 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, | |||
148 | regs->CNTR = GVP11_DMAC_INT_ENABLE; | 155 | regs->CNTR = GVP11_DMAC_INT_ENABLE; |
149 | 156 | ||
150 | /* copy from a bounce buffer, if necessary */ | 157 | /* copy from a bounce buffer, if necessary */ |
151 | if (status && hdata->dma_bounce_buffer) { | 158 | if (status && wh->dma_bounce_buffer) { |
152 | if (hdata->dma_dir && SCpnt) | 159 | if (wh->dma_dir && SCpnt) |
153 | memcpy(SCpnt->SCp.ptr, hdata->dma_bounce_buffer, | 160 | memcpy(SCpnt->SCp.ptr, wh->dma_bounce_buffer, |
154 | SCpnt->SCp.this_residual); | 161 | SCpnt->SCp.this_residual); |
155 | 162 | ||
156 | if (hdata->dma_buffer_pool == BUF_SCSI_ALLOCED) | 163 | if (wh->dma_buffer_pool == BUF_SCSI_ALLOCED) |
157 | kfree(hdata->dma_bounce_buffer); | 164 | kfree(wh->dma_bounce_buffer); |
158 | else | 165 | else |
159 | amiga_chip_free(hdata->dma_bounce_buffer); | 166 | amiga_chip_free(wh->dma_bounce_buffer); |
160 | 167 | ||
161 | hdata->dma_bounce_buffer = NULL; | 168 | wh->dma_bounce_buffer = NULL; |
162 | hdata->dma_bounce_len = 0; | 169 | wh->dma_bounce_len = 0; |
163 | } | 170 | } |
164 | } | 171 | } |
165 | 172 | ||
@@ -284,7 +291,7 @@ static int __devinit gvp11_probe(struct zorro_dev *z, | |||
284 | int error; | 291 | int error; |
285 | unsigned int epc; | 292 | unsigned int epc; |
286 | unsigned int default_dma_xfer_mask; | 293 | unsigned int default_dma_xfer_mask; |
287 | struct WD33C93_hostdata *hdata; | 294 | struct gvp11_hostdata *hdata; |
288 | struct gvp11_scsiregs *regs; | 295 | struct gvp11_scsiregs *regs; |
289 | wd33c93_regs wdregs; | 296 | wd33c93_regs wdregs; |
290 | 297 | ||
@@ -309,13 +316,12 @@ static int __devinit gvp11_probe(struct zorro_dev *z, | |||
309 | goto fail_check_or_alloc; | 316 | goto fail_check_or_alloc; |
310 | 317 | ||
311 | instance = scsi_host_alloc(&gvp11_scsi_template, | 318 | instance = scsi_host_alloc(&gvp11_scsi_template, |
312 | sizeof(struct WD33C93_hostdata)); | 319 | sizeof(struct gvp11_hostdata)); |
313 | if (!instance) { | 320 | if (!instance) { |
314 | error = -ENOMEM; | 321 | error = -ENOMEM; |
315 | goto fail_check_or_alloc; | 322 | goto fail_check_or_alloc; |
316 | } | 323 | } |
317 | 324 | ||
318 | instance->base = (unsigned long)regs; | ||
319 | instance->irq = IRQ_AMIGA_PORTS; | 325 | instance->irq = IRQ_AMIGA_PORTS; |
320 | instance->unique_id = z->slotaddr; | 326 | instance->unique_id = z->slotaddr; |
321 | 327 | ||
@@ -332,13 +338,14 @@ static int __devinit gvp11_probe(struct zorro_dev *z, | |||
332 | 338 | ||
333 | hdata = shost_priv(instance); | 339 | hdata = shost_priv(instance); |
334 | if (gvp11_xfer_mask) | 340 | if (gvp11_xfer_mask) |
335 | hdata->dma_xfer_mask = gvp11_xfer_mask; | 341 | hdata->wh.dma_xfer_mask = gvp11_xfer_mask; |
336 | else | 342 | else |
337 | hdata->dma_xfer_mask = default_dma_xfer_mask; | 343 | hdata->wh.dma_xfer_mask = default_dma_xfer_mask; |
338 | 344 | ||
339 | hdata->no_sync = 0xff; | 345 | hdata->wh.no_sync = 0xff; |
340 | hdata->fast = 0; | 346 | hdata->wh.fast = 0; |
341 | hdata->dma_mode = CTRL_DMA; | 347 | hdata->wh.dma_mode = CTRL_DMA; |
348 | hdata->regs = regs; | ||
342 | 349 | ||
343 | /* | 350 | /* |
344 | * Check for 14MHz SCSI clock | 351 | * Check for 14MHz SCSI clock |
@@ -375,9 +382,9 @@ fail_check_or_alloc: | |||
375 | static void __devexit gvp11_remove(struct zorro_dev *z) | 382 | static void __devexit gvp11_remove(struct zorro_dev *z) |
376 | { | 383 | { |
377 | struct Scsi_Host *instance = zorro_get_drvdata(z); | 384 | struct Scsi_Host *instance = zorro_get_drvdata(z); |
378 | struct gvp11_scsiregs *regs = (struct gvp11_scsiregs *)(instance->base); | 385 | struct gvp11_hostdata *hdata = shost_priv(instance); |
379 | 386 | ||
380 | regs->CNTR = 0; | 387 | hdata->regs->CNTR = 0; |
381 | scsi_remove_host(instance); | 388 | scsi_remove_host(instance); |
382 | free_irq(IRQ_AMIGA_PORTS, instance); | 389 | free_irq(IRQ_AMIGA_PORTS, instance); |
383 | scsi_host_put(instance); | 390 | scsi_host_put(instance); |