Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

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