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

scsi: ncr5380: Use correct types for DMA routines

Apply prototypes to get consistent function signatures for the DMA
functions implemented in the board-specific drivers. To avoid using
macros to alter actual parameters, some of those functions are reworked
slightly.

This is a step toward the goal of passing the board-specific routines
to the core driver using an ops struct (as in a platform driver or
library module).

This also helps fix some inconsistent types: where the core driver uses
ints (cmd->SCp.this_residual and hostdata->dma_len) for keeping track of
transfers, certain board-specific routines used unsigned long.

While we are fixing these function signatures, pass the hostdata pointer
to DMA routines instead of a Scsi_Host pointer, for shorter and faster
code.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Tested-by: Ondrej Zary <linux@rainbow-software.org>
Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Acked-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Finn Thain and committed by
Martin K. Petersen
4a98f896 7c606631

+176 -114
+41 -33
drivers/scsi/NCR5380.c
··· 121 121 * 122 122 * Either real DMA *or* pseudo DMA may be implemented 123 123 * 124 - * NCR5380_dma_write_setup(instance, src, count) - initialize 125 - * NCR5380_dma_read_setup(instance, dst, count) - initialize 126 - * NCR5380_dma_residual(instance); - residual count 124 + * NCR5380_dma_xfer_len - determine size of DMA/PDMA transfer 125 + * NCR5380_dma_send_setup - execute DMA/PDMA from memory to 5380 126 + * NCR5380_dma_recv_setup - execute DMA/PDMA from 5380 to memory 127 + * NCR5380_dma_residual - residual byte count 127 128 * 128 129 * The generic driver is initialized by calling NCR5380_init(instance), 129 130 * after setting the appropriate host specific fields and ID. If the ··· 872 871 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); 873 872 NCR5380_read(RESET_PARITY_INTERRUPT_REG); 874 873 875 - transferred = hostdata->dma_len - NCR5380_dma_residual(instance); 874 + transferred = hostdata->dma_len - NCR5380_dma_residual(hostdata); 876 875 hostdata->dma_len = 0; 877 876 878 877 data = (unsigned char **)&hostdata->connected->SCp.ptr; ··· 1579 1578 * starting the NCR. This is also the cleaner way for the TT. 1580 1579 */ 1581 1580 if (p & SR_IO) 1582 - result = NCR5380_dma_recv_setup(instance, d, c); 1581 + result = NCR5380_dma_recv_setup(hostdata, d, c); 1583 1582 else 1584 - result = NCR5380_dma_send_setup(instance, d, c); 1583 + result = NCR5380_dma_send_setup(hostdata, d, c); 1585 1584 } 1586 1585 1587 1586 /* ··· 1613 1612 * NCR access, else the DMA setup gets trashed! 1614 1613 */ 1615 1614 if (p & SR_IO) 1616 - result = NCR5380_dma_recv_setup(instance, d, c); 1615 + result = NCR5380_dma_recv_setup(hostdata, d, c); 1617 1616 else 1618 - result = NCR5380_dma_send_setup(instance, d, c); 1617 + result = NCR5380_dma_send_setup(hostdata, d, c); 1619 1618 } 1620 1619 1621 1620 /* On failure, NCR5380_dma_xxxx_setup() returns a negative int. */ ··· 1755 1754 NCR5380_dprint_phase(NDEBUG_INFORMATION, instance); 1756 1755 } 1757 1756 #ifdef CONFIG_SUN3 1758 - if (phase == PHASE_CMDOUT) { 1759 - void *d; 1760 - unsigned long count; 1757 + if (phase == PHASE_CMDOUT && 1758 + sun3_dma_setup_done != cmd) { 1759 + int count; 1761 1760 1762 1761 if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) { 1763 - count = cmd->SCp.buffer->length; 1764 - d = sg_virt(cmd->SCp.buffer); 1765 - } else { 1766 - count = cmd->SCp.this_residual; 1767 - d = cmd->SCp.ptr; 1762 + ++cmd->SCp.buffer; 1763 + --cmd->SCp.buffers_residual; 1764 + cmd->SCp.this_residual = cmd->SCp.buffer->length; 1765 + cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); 1768 1766 } 1769 1767 1770 - if (sun3_dma_setup_done != cmd && 1771 - sun3scsi_dma_xfer_len(count, cmd) > 0) { 1772 - sun3scsi_dma_setup(instance, d, count, 1773 - rq_data_dir(cmd->request)); 1768 + count = sun3scsi_dma_xfer_len(hostdata, cmd); 1769 + 1770 + if (count > 0) { 1771 + if (rq_data_dir(cmd->request)) 1772 + sun3scsi_dma_send_setup(hostdata, 1773 + cmd->SCp.ptr, count); 1774 + else 1775 + sun3scsi_dma_recv_setup(hostdata, 1776 + cmd->SCp.ptr, count); 1774 1777 sun3_dma_setup_done = cmd; 1775 1778 } 1776 1779 #ifdef SUN3_SCSI_VME ··· 1835 1830 1836 1831 transfersize = 0; 1837 1832 if (!cmd->device->borken) 1838 - transfersize = NCR5380_dma_xfer_len(instance, cmd, phase); 1833 + transfersize = NCR5380_dma_xfer_len(hostdata, cmd); 1839 1834 1840 1835 if (transfersize > 0) { 1841 1836 len = transfersize; ··· 2212 2207 } 2213 2208 2214 2209 #ifdef CONFIG_SUN3 2215 - { 2216 - void *d; 2217 - unsigned long count; 2210 + if (sun3_dma_setup_done != tmp) { 2211 + int count; 2218 2212 2219 2213 if (!tmp->SCp.this_residual && tmp->SCp.buffers_residual) { 2220 - count = tmp->SCp.buffer->length; 2221 - d = sg_virt(tmp->SCp.buffer); 2222 - } else { 2223 - count = tmp->SCp.this_residual; 2224 - d = tmp->SCp.ptr; 2214 + ++tmp->SCp.buffer; 2215 + --tmp->SCp.buffers_residual; 2216 + tmp->SCp.this_residual = tmp->SCp.buffer->length; 2217 + tmp->SCp.ptr = sg_virt(tmp->SCp.buffer); 2225 2218 } 2226 2219 2227 - if (sun3_dma_setup_done != tmp && 2228 - sun3scsi_dma_xfer_len(count, tmp) > 0) { 2229 - sun3scsi_dma_setup(instance, d, count, 2230 - rq_data_dir(tmp->request)); 2220 + count = sun3scsi_dma_xfer_len(hostdata, tmp); 2221 + 2222 + if (count > 0) { 2223 + if (rq_data_dir(tmp->request)) 2224 + sun3scsi_dma_send_setup(hostdata, 2225 + tmp->SCp.ptr, count); 2226 + else 2227 + sun3scsi_dma_recv_setup(hostdata, 2228 + tmp->SCp.ptr, count); 2231 2229 sun3_dma_setup_done = tmp; 2232 2230 } 2233 2231 }
+25
drivers/scsi/NCR5380.h
··· 317 317 reg, bit, val, wait); 318 318 } 319 319 320 + static int NCR5380_dma_xfer_len(struct NCR5380_hostdata *, 321 + struct scsi_cmnd *); 322 + static int NCR5380_dma_send_setup(struct NCR5380_hostdata *, 323 + unsigned char *, int); 324 + static int NCR5380_dma_recv_setup(struct NCR5380_hostdata *, 325 + unsigned char *, int); 326 + static int NCR5380_dma_residual(struct NCR5380_hostdata *); 327 + 328 + static inline int NCR5380_dma_xfer_none(struct NCR5380_hostdata *hostdata, 329 + struct scsi_cmnd *cmd) 330 + { 331 + return 0; 332 + } 333 + 334 + static inline int NCR5380_dma_setup_none(struct NCR5380_hostdata *hostdata, 335 + unsigned char *data, int count) 336 + { 337 + return 0; 338 + } 339 + 340 + static inline int NCR5380_dma_residual_none(struct NCR5380_hostdata *hostdata) 341 + { 342 + return 0; 343 + } 344 + 320 345 #endif /* __KERNEL__ */ 321 346 #endif /* NCR5380_H */
+16 -10
drivers/scsi/arm/cumana_1.c
··· 17 17 #define NCR5380_read(reg) cumanascsi_read(hostdata, reg) 18 18 #define NCR5380_write(reg, value) cumanascsi_write(hostdata, reg, value) 19 19 20 - #define NCR5380_dma_xfer_len(instance, cmd, phase) (cmd->transfersize) 20 + #define NCR5380_dma_xfer_len cumanascsi_dma_xfer_len 21 21 #define NCR5380_dma_recv_setup cumanascsi_pread 22 22 #define NCR5380_dma_send_setup cumanascsi_pwrite 23 - #define NCR5380_dma_residual(instance) (0) 23 + #define NCR5380_dma_residual NCR5380_dma_residual_none 24 24 25 25 #define NCR5380_intr cumanascsi_intr 26 26 #define NCR5380_queue_command cumanascsi_queue_command ··· 40 40 #define L(v) (((v)<<16)|((v) & 0x0000ffff)) 41 41 #define H(v) (((v)>>16)|((v) & 0xffff0000)) 42 42 43 - static inline int cumanascsi_pwrite(struct Scsi_Host *host, 43 + static inline int cumanascsi_pwrite(struct NCR5380_hostdata *hostdata, 44 44 unsigned char *addr, int len) 45 45 { 46 46 unsigned long *laddr; 47 - u8 __iomem *base = priv(host)->io; 48 - u8 __iomem *dma = priv(host)->pdma_io + 0x2000; 47 + u8 __iomem *base = hostdata->io; 48 + u8 __iomem *dma = hostdata->pdma_io + 0x2000; 49 49 50 50 if(!len) return 0; 51 51 ··· 100 100 } 101 101 } 102 102 end: 103 - writeb(priv(host)->ctrl | 0x40, base + CTRL); 103 + writeb(hostdata->ctrl | 0x40, base + CTRL); 104 104 105 105 if (len) 106 106 return -1; 107 107 return 0; 108 108 } 109 109 110 - static inline int cumanascsi_pread(struct Scsi_Host *host, 110 + static inline int cumanascsi_pread(struct NCR5380_hostdata *hostdata, 111 111 unsigned char *addr, int len) 112 112 { 113 113 unsigned long *laddr; 114 - u8 __iomem *base = priv(host)->io; 115 - u8 __iomem *dma = priv(host)->pdma_io + 0x2000; 114 + u8 __iomem *base = hostdata->io; 115 + u8 __iomem *dma = hostdata->pdma_io + 0x2000; 116 116 117 117 if(!len) return 0; 118 118 ··· 166 166 } 167 167 } 168 168 end: 169 - writeb(priv(host)->ctrl | 0x40, base + CTRL); 169 + writeb(hostdata->ctrl | 0x40, base + CTRL); 170 170 171 171 if (len) 172 172 return -1; 173 173 return 0; 174 + } 175 + 176 + static int cumanascsi_dma_xfer_len(struct NCR5380_hostdata *hostdata, 177 + struct scsi_cmnd *cmd) 178 + { 179 + return cmd->transfersize; 174 180 } 175 181 176 182 static u8 cumanascsi_read(struct NCR5380_hostdata *hostdata,
+7 -6
drivers/scsi/arm/oak.c
··· 19 19 #define NCR5380_read(reg) readb(hostdata->io + ((reg) << 2)) 20 20 #define NCR5380_write(reg, value) writeb(value, hostdata->io + ((reg) << 2)) 21 21 22 - #define NCR5380_dma_xfer_len(instance, cmd, phase) (0) 22 + #define NCR5380_dma_xfer_len NCR5380_dma_xfer_none 23 23 #define NCR5380_dma_recv_setup oakscsi_pread 24 24 #define NCR5380_dma_send_setup oakscsi_pwrite 25 - #define NCR5380_dma_residual(instance) (0) 25 + #define NCR5380_dma_residual NCR5380_dma_residual_none 26 26 27 27 #define NCR5380_queue_command oakscsi_queue_command 28 28 #define NCR5380_info oakscsi_info ··· 37 37 #define STAT ((128 + 16) << 2) 38 38 #define DATA ((128 + 8) << 2) 39 39 40 - static inline int oakscsi_pwrite(struct Scsi_Host *instance, 40 + static inline int oakscsi_pwrite(struct NCR5380_hostdata *hostdata, 41 41 unsigned char *addr, int len) 42 42 { 43 - u8 __iomem *base = priv(instance)->io; 43 + u8 __iomem *base = hostdata->io; 44 44 45 45 printk("writing %p len %d\n",addr, len); 46 46 ··· 52 52 return 0; 53 53 } 54 54 55 - static inline int oakscsi_pread(struct Scsi_Host *instance, 55 + static inline int oakscsi_pread(struct NCR5380_hostdata *hostdata, 56 56 unsigned char *addr, int len) 57 57 { 58 - u8 __iomem *base = priv(instance)->io; 58 + u8 __iomem *base = hostdata->io; 59 + 59 60 printk("reading %p len %d\n", addr, len); 60 61 while(len > 0) 61 62 {
+26 -19
drivers/scsi/atari_scsi.c
··· 67 67 #define NCR5380_abort atari_scsi_abort 68 68 #define NCR5380_info atari_scsi_info 69 69 70 - #define NCR5380_dma_recv_setup(instance, data, count) \ 71 - atari_scsi_dma_setup(instance, data, count, 0) 72 - #define NCR5380_dma_send_setup(instance, data, count) \ 73 - atari_scsi_dma_setup(instance, data, count, 1) 74 - #define NCR5380_dma_residual(instance) \ 75 - atari_scsi_dma_residual(instance) 76 - #define NCR5380_dma_xfer_len(instance, cmd, phase) \ 77 - atari_dma_xfer_len(cmd->SCp.this_residual, cmd, !((phase) & SR_IO)) 70 + #define NCR5380_dma_xfer_len atari_scsi_dma_xfer_len 71 + #define NCR5380_dma_recv_setup atari_scsi_dma_recv_setup 72 + #define NCR5380_dma_send_setup atari_scsi_dma_send_setup 73 + #define NCR5380_dma_residual atari_scsi_dma_residual 78 74 79 75 #define NCR5380_acquire_dma_irq(instance) falcon_get_lock(instance) 80 76 #define NCR5380_release_dma_irq(instance) falcon_release_lock() ··· 453 457 __setup("atascsi=", atari_scsi_setup); 454 458 #endif /* !MODULE */ 455 459 456 - 457 - static unsigned long atari_scsi_dma_setup(struct Scsi_Host *instance, 460 + static unsigned long atari_scsi_dma_setup(struct NCR5380_hostdata *hostdata, 458 461 void *data, unsigned long count, 459 462 int dir) 460 463 { 461 464 unsigned long addr = virt_to_phys(data); 462 465 463 - dprintk(NDEBUG_DMA, "scsi%d: setting up dma, data = %p, phys = %lx, count = %ld, " 464 - "dir = %d\n", instance->host_no, data, addr, count, dir); 466 + dprintk(NDEBUG_DMA, "scsi%d: setting up dma, data = %p, phys = %lx, count = %ld, dir = %d\n", 467 + hostdata->host->host_no, data, addr, count, dir); 465 468 466 469 if (!IS_A_TT() && !STRAM_ADDR(addr)) { 467 470 /* If we have a non-DMAable address on a Falcon, use the dribble ··· 517 522 return count; 518 523 } 519 524 525 + static inline int atari_scsi_dma_recv_setup(struct NCR5380_hostdata *hostdata, 526 + unsigned char *data, int count) 527 + { 528 + return atari_scsi_dma_setup(hostdata, data, count, 0); 529 + } 520 530 521 - static long atari_scsi_dma_residual(struct Scsi_Host *instance) 531 + static inline int atari_scsi_dma_send_setup(struct NCR5380_hostdata *hostdata, 532 + unsigned char *data, int count) 533 + { 534 + return atari_scsi_dma_setup(hostdata, data, count, 1); 535 + } 536 + 537 + static int atari_scsi_dma_residual(struct NCR5380_hostdata *hostdata) 522 538 { 523 539 return atari_dma_residual; 524 540 } ··· 570 564 * the overrun problem, so this question is academic :-) 571 565 */ 572 566 573 - static unsigned long atari_dma_xfer_len(unsigned long wanted_len, 574 - struct scsi_cmnd *cmd, int write_flag) 567 + static int atari_scsi_dma_xfer_len(struct NCR5380_hostdata *hostdata, 568 + struct scsi_cmnd *cmd) 575 569 { 576 - unsigned long possible_len, limit; 570 + int wanted_len = cmd->SCp.this_residual; 571 + int possible_len, limit; 577 572 578 573 if (wanted_len < DMA_MIN_SIZE) 579 574 return 0; ··· 611 604 * use the dribble buffer and thus can do only STRAM_BUFFER_SIZE bytes. 612 605 */ 613 606 614 - if (write_flag) { 607 + if (cmd->sc_data_direction == DMA_TO_DEVICE) { 615 608 /* Write operation can always use the DMA, but the transfer size must 616 609 * be rounded up to the next multiple of 512 (atari_dma_setup() does 617 610 * this). ··· 651 644 possible_len = limit; 652 645 653 646 if (possible_len != wanted_len) 654 - dprintk(NDEBUG_DMA, "Sorry, must cut DMA transfer size to %ld bytes " 655 - "instead of %ld\n", possible_len, wanted_len); 647 + dprintk(NDEBUG_DMA, "DMA transfer now %d bytes instead of %d\n", 648 + possible_len, wanted_len); 656 649 657 650 return possible_len; 658 651 }
+4 -4
drivers/scsi/dmx3191d.c
··· 37 37 #define NCR5380_read(reg) inb(hostdata->base + (reg)) 38 38 #define NCR5380_write(reg, value) outb(value, hostdata->base + (reg)) 39 39 40 - #define NCR5380_dma_xfer_len(instance, cmd, phase) (0) 41 - #define NCR5380_dma_recv_setup(instance, dst, len) (0) 42 - #define NCR5380_dma_send_setup(instance, src, len) (0) 43 - #define NCR5380_dma_residual(instance) (0) 40 + #define NCR5380_dma_xfer_len NCR5380_dma_xfer_none 41 + #define NCR5380_dma_recv_setup NCR5380_dma_setup_none 42 + #define NCR5380_dma_send_setup NCR5380_dma_setup_none 43 + #define NCR5380_dma_residual NCR5380_dma_residual_none 44 44 45 45 #define NCR5380_implementation_fields /* none */ 46 46
+5 -8
drivers/scsi/g_NCR5380.c
··· 332 332 333 333 /** 334 334 * generic_NCR5380_pread - pseudo DMA read 335 - * @instance: adapter to read from 335 + * @hostdata: scsi host private data 336 336 * @dst: buffer to read into 337 337 * @len: buffer length 338 338 * ··· 340 340 * controller 341 341 */ 342 342 343 - static inline int generic_NCR5380_pread(struct Scsi_Host *instance, 343 + static inline int generic_NCR5380_pread(struct NCR5380_hostdata *hostdata, 344 344 unsigned char *dst, int len) 345 345 { 346 - struct NCR5380_hostdata *hostdata = shost_priv(instance); 347 346 int blocks = len / 128; 348 347 int start = 0; 349 348 ··· 405 406 406 407 /** 407 408 * generic_NCR5380_pwrite - pseudo DMA write 408 - * @instance: adapter to read from 409 + * @hostdata: scsi host private data 409 410 * @dst: buffer to read into 410 411 * @len: buffer length 411 412 * ··· 413 414 * controller 414 415 */ 415 416 416 - static inline int generic_NCR5380_pwrite(struct Scsi_Host *instance, 417 + static inline int generic_NCR5380_pwrite(struct NCR5380_hostdata *hostdata, 417 418 unsigned char *src, int len) 418 419 { 419 - struct NCR5380_hostdata *hostdata = shost_priv(instance); 420 420 int blocks = len / 128; 421 421 int start = 0; 422 422 ··· 478 480 return 0; 479 481 } 480 482 481 - static int generic_NCR5380_dma_xfer_len(struct Scsi_Host *instance, 483 + static int generic_NCR5380_dma_xfer_len(struct NCR5380_hostdata *hostdata, 482 484 struct scsi_cmnd *cmd) 483 485 { 484 - struct NCR5380_hostdata *hostdata = shost_priv(instance); 485 486 int transfersize = cmd->transfersize; 486 487 487 488 if (hostdata->flags & FLAG_NO_PSEUDO_DMA)
+2 -3
drivers/scsi/g_NCR5380.h
··· 32 32 #define NCR53C400_host_buffer 0x3900 33 33 #define NCR53C400_region_size 0x3a00 34 34 35 - #define NCR5380_dma_xfer_len(instance, cmd, phase) \ 36 - generic_NCR5380_dma_xfer_len(instance, cmd) 35 + #define NCR5380_dma_xfer_len generic_NCR5380_dma_xfer_len 37 36 #define NCR5380_dma_recv_setup generic_NCR5380_pread 38 37 #define NCR5380_dma_send_setup generic_NCR5380_pwrite 39 - #define NCR5380_dma_residual(instance) (0) 38 + #define NCR5380_dma_residual NCR5380_dma_residual_none 40 39 41 40 #define NCR5380_intr generic_NCR5380_intr 42 41 #define NCR5380_queue_command generic_NCR5380_queue_command
+18 -18
drivers/scsi/mac_scsi.c
··· 33 33 #define NCR5380_read(reg) in_8(hostdata->io + ((reg) << 4)) 34 34 #define NCR5380_write(reg, value) out_8(hostdata->io + ((reg) << 4), value) 35 35 36 - #define NCR5380_dma_xfer_len(instance, cmd, phase) \ 37 - macscsi_dma_xfer_len(instance, cmd) 36 + #define NCR5380_dma_xfer_len macscsi_dma_xfer_len 38 37 #define NCR5380_dma_recv_setup macscsi_pread 39 38 #define NCR5380_dma_send_setup macscsi_pwrite 40 - #define NCR5380_dma_residual(instance) (hostdata->pdma_residual) 39 + #define NCR5380_dma_residual macscsi_dma_residual 41 40 42 41 #define NCR5380_intr macscsi_intr 43 42 #define NCR5380_queue_command macscsi_queue_command ··· 151 152 : "0"(s), "1"(d), "2"(n) \ 152 153 : "d0") 153 154 154 - static int macscsi_pread(struct Scsi_Host *instance, 155 - unsigned char *dst, int len) 155 + static inline int macscsi_pread(struct NCR5380_hostdata *hostdata, 156 + unsigned char *dst, int len) 156 157 { 157 - struct NCR5380_hostdata *hostdata = shost_priv(instance); 158 158 unsigned char *s = hostdata->pdma_io + (INPUT_DATA_REG << 4); 159 159 unsigned char *d = dst; 160 160 int n = len; ··· 179 181 if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH)) 180 182 return 0; 181 183 182 - dsprintk(NDEBUG_PSEUDO_DMA, instance, 184 + dsprintk(NDEBUG_PSEUDO_DMA, hostdata->host, 183 185 "%s: bus error (%d/%d)\n", __func__, transferred, len); 184 - NCR5380_dprint(NDEBUG_PSEUDO_DMA, instance); 186 + NCR5380_dprint(NDEBUG_PSEUDO_DMA, hostdata->host); 185 187 d = dst + transferred; 186 188 n = len - transferred; 187 189 } 188 190 189 191 scmd_printk(KERN_ERR, hostdata->connected, 190 192 "%s: phase mismatch or !DRQ\n", __func__); 191 - NCR5380_dprint(NDEBUG_PSEUDO_DMA, instance); 193 + NCR5380_dprint(NDEBUG_PSEUDO_DMA, hostdata->host); 192 194 return -1; 193 195 } 194 196 ··· 253 255 : "0"(s), "1"(d), "2"(n) \ 254 256 : "d0") 255 257 256 - static int macscsi_pwrite(struct Scsi_Host *instance, 257 - unsigned char *src, int len) 258 + static inline int macscsi_pwrite(struct NCR5380_hostdata *hostdata, 259 + unsigned char *src, int len) 258 260 { 259 - struct NCR5380_hostdata *hostdata = shost_priv(instance); 260 261 unsigned char *s = src; 261 262 unsigned char *d = hostdata->pdma_io + (OUTPUT_DATA_REG << 4); 262 263 int n = len; ··· 287 290 return 0; 288 291 } 289 292 290 - dsprintk(NDEBUG_PSEUDO_DMA, instance, 293 + dsprintk(NDEBUG_PSEUDO_DMA, hostdata->host, 291 294 "%s: bus error (%d/%d)\n", __func__, transferred, len); 292 - NCR5380_dprint(NDEBUG_PSEUDO_DMA, instance); 295 + NCR5380_dprint(NDEBUG_PSEUDO_DMA, hostdata->host); 293 296 s = src + transferred; 294 297 n = len - transferred; 295 298 } 296 299 297 300 scmd_printk(KERN_ERR, hostdata->connected, 298 301 "%s: phase mismatch or !DRQ\n", __func__); 299 - NCR5380_dprint(NDEBUG_PSEUDO_DMA, instance); 302 + NCR5380_dprint(NDEBUG_PSEUDO_DMA, hostdata->host); 300 303 301 304 return -1; 302 305 } 303 306 304 - static int macscsi_dma_xfer_len(struct Scsi_Host *instance, 307 + static int macscsi_dma_xfer_len(struct NCR5380_hostdata *hostdata, 305 308 struct scsi_cmnd *cmd) 306 309 { 307 - struct NCR5380_hostdata *hostdata = shost_priv(instance); 308 - 309 310 if (hostdata->flags & FLAG_NO_PSEUDO_DMA || 310 311 cmd->SCp.this_residual < 16) 311 312 return 0; 312 313 313 314 return cmd->SCp.this_residual; 315 + } 316 + 317 + static int macscsi_dma_residual(struct NCR5380_hostdata *hostdata) 318 + { 319 + return hostdata->pdma_residual; 314 320 } 315 321 316 322 #include "NCR5380.c"
+32 -13
drivers/scsi/sun3_scsi.c
··· 51 51 #define NCR5380_abort sun3scsi_abort 52 52 #define NCR5380_info sun3scsi_info 53 53 54 - #define NCR5380_dma_recv_setup(instance, data, count) (count) 55 - #define NCR5380_dma_send_setup(instance, data, count) (count) 56 - #define NCR5380_dma_residual(instance) \ 57 - sun3scsi_dma_residual(instance) 58 - #define NCR5380_dma_xfer_len(instance, cmd, phase) \ 59 - sun3scsi_dma_xfer_len(cmd->SCp.this_residual, cmd) 54 + #define NCR5380_dma_xfer_len sun3scsi_dma_xfer_len 55 + #define NCR5380_dma_recv_setup sun3scsi_dma_count 56 + #define NCR5380_dma_send_setup sun3scsi_dma_count 57 + #define NCR5380_dma_residual sun3scsi_dma_residual 60 58 61 59 #define NCR5380_acquire_dma_irq(instance) (1) 62 60 #define NCR5380_release_dma_irq(instance) ··· 141 143 } 142 144 143 145 /* sun3scsi_dma_setup() -- initialize the dma controller for a read/write */ 144 - static unsigned long sun3scsi_dma_setup(struct Scsi_Host *instance, 145 - void *data, unsigned long count, int write_flag) 146 + static int sun3scsi_dma_setup(struct NCR5380_hostdata *hostdata, 147 + unsigned char *data, int count, int write_flag) 146 148 { 147 149 void *addr; 148 150 ··· 194 196 dregs->csr |= CSR_FIFO; 195 197 196 198 if(dregs->fifo_count != count) { 197 - shost_printk(KERN_ERR, instance, "FIFO mismatch %04x not %04x\n", 199 + shost_printk(KERN_ERR, hostdata->host, 200 + "FIFO mismatch %04x not %04x\n", 198 201 dregs->fifo_count, (unsigned int) count); 199 - NCR5380_dprint(NDEBUG_DMA, instance); 202 + NCR5380_dprint(NDEBUG_DMA, hostdata->host); 200 203 } 201 204 202 205 /* setup udc */ ··· 232 233 233 234 } 234 235 235 - static inline unsigned long sun3scsi_dma_residual(struct Scsi_Host *instance) 236 + static int sun3scsi_dma_count(struct NCR5380_hostdata *hostdata, 237 + unsigned char *data, int count) 238 + { 239 + return count; 240 + } 241 + 242 + static inline int sun3scsi_dma_recv_setup(struct NCR5380_hostdata *hostdata, 243 + unsigned char *data, int count) 244 + { 245 + return sun3scsi_dma_setup(hostdata, data, count, 0); 246 + } 247 + 248 + static inline int sun3scsi_dma_send_setup(struct NCR5380_hostdata *hostdata, 249 + unsigned char *data, int count) 250 + { 251 + return sun3scsi_dma_setup(hostdata, data, count, 1); 252 + } 253 + 254 + static int sun3scsi_dma_residual(struct NCR5380_hostdata *hostdata) 236 255 { 237 256 return last_residual; 238 257 } 239 258 240 - static inline unsigned long sun3scsi_dma_xfer_len(unsigned long wanted_len, 241 - struct scsi_cmnd *cmd) 259 + static int sun3scsi_dma_xfer_len(struct NCR5380_hostdata *hostdata, 260 + struct scsi_cmnd *cmd) 242 261 { 262 + int wanted_len = cmd->SCp.this_residual; 263 + 243 264 if (wanted_len < DMA_MIN_SIZE || cmd->request->cmd_type != REQ_TYPE_FS) 244 265 return 0; 245 266