diff options
author | Geert Uytterhoeven <geert@linux-m68k.org> | 2010-04-04 05:00:36 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-05-02 16:01:09 -0400 |
commit | 6d1d5d43e5911bfdb7ec47cc3d1438dbbf2a9de2 (patch) | |
tree | 830d152506398a92b3d68761cd3e7e8298c162d8 /drivers/scsi/a2091.c | |
parent | 21351013402ab4556d1ef62aed6cbe8dfb809f77 (diff) |
[SCSI] a2091: 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/a2091.c')
-rw-r--r-- | drivers/scsi/a2091.c | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/drivers/scsi/a2091.c b/drivers/scsi/a2091.c index 8469c239f9fb..95584059863b 100644 --- a/drivers/scsi/a2091.c +++ b/drivers/scsi/a2091.c | |||
@@ -23,7 +23,6 @@ | |||
23 | 23 | ||
24 | 24 | ||
25 | #define DMA(ptr) ((a2091_scsiregs *)((ptr)->base)) | 25 | #define DMA(ptr) ((a2091_scsiregs *)((ptr)->base)) |
26 | #define HDATA(ptr) ((struct WD33C93_hostdata *)((ptr)->hostdata)) | ||
27 | 26 | ||
28 | static int a2091_release(struct Scsi_Host *instance); | 27 | static int a2091_release(struct Scsi_Host *instance); |
29 | 28 | ||
@@ -45,39 +44,39 @@ static irqreturn_t a2091_intr(int irq, void *_instance) | |||
45 | 44 | ||
46 | static int dma_setup(struct scsi_cmnd *cmd, int dir_in) | 45 | static int dma_setup(struct scsi_cmnd *cmd, int dir_in) |
47 | { | 46 | { |
47 | struct Scsi_Host *instance = cmd->device->host; | ||
48 | struct WD33C93_hostdata *hdata = shost_priv(instance); | ||
48 | unsigned short cntr = CNTR_PDMD | CNTR_INTEN; | 49 | unsigned short cntr = CNTR_PDMD | CNTR_INTEN; |
49 | unsigned long addr = virt_to_bus(cmd->SCp.ptr); | 50 | unsigned long addr = virt_to_bus(cmd->SCp.ptr); |
50 | struct Scsi_Host *instance = cmd->device->host; | ||
51 | 51 | ||
52 | /* don't allow DMA if the physical address is bad */ | 52 | /* don't allow DMA if the physical address is bad */ |
53 | if (addr & A2091_XFER_MASK) { | 53 | if (addr & A2091_XFER_MASK) { |
54 | HDATA(instance)->dma_bounce_len = | 54 | hdata->dma_bounce_len = (cmd->SCp.this_residual + 511) & ~0x1ff; |
55 | (cmd->SCp.this_residual + 511) & ~0x1ff; | 55 | hdata->dma_bounce_buffer = kmalloc(hdata->dma_bounce_len, |
56 | HDATA(instance)->dma_bounce_buffer = | 56 | GFP_KERNEL); |
57 | kmalloc(HDATA(instance)->dma_bounce_len, GFP_KERNEL); | ||
58 | 57 | ||
59 | /* can't allocate memory; use PIO */ | 58 | /* can't allocate memory; use PIO */ |
60 | if (!HDATA(instance)->dma_bounce_buffer) { | 59 | if (!hdata->dma_bounce_buffer) { |
61 | HDATA(instance)->dma_bounce_len = 0; | 60 | hdata->dma_bounce_len = 0; |
62 | return 1; | 61 | return 1; |
63 | } | 62 | } |
64 | 63 | ||
65 | /* get the physical address of the bounce buffer */ | 64 | /* get the physical address of the bounce buffer */ |
66 | addr = virt_to_bus(HDATA(instance)->dma_bounce_buffer); | 65 | addr = virt_to_bus(hdata->dma_bounce_buffer); |
67 | 66 | ||
68 | /* the bounce buffer may not be in the first 16M of physmem */ | 67 | /* the bounce buffer may not be in the first 16M of physmem */ |
69 | if (addr & A2091_XFER_MASK) { | 68 | if (addr & A2091_XFER_MASK) { |
70 | /* we could use chipmem... maybe later */ | 69 | /* we could use chipmem... maybe later */ |
71 | kfree(HDATA(instance)->dma_bounce_buffer); | 70 | kfree(hdata->dma_bounce_buffer); |
72 | HDATA(instance)->dma_bounce_buffer = NULL; | 71 | hdata->dma_bounce_buffer = NULL; |
73 | HDATA(instance)->dma_bounce_len = 0; | 72 | hdata->dma_bounce_len = 0; |
74 | return 1; | 73 | return 1; |
75 | } | 74 | } |
76 | 75 | ||
77 | if (!dir_in) { | 76 | if (!dir_in) { |
78 | /* copy to bounce buffer for a write */ | 77 | /* copy to bounce buffer for a write */ |
79 | memcpy(HDATA(instance)->dma_bounce_buffer, | 78 | memcpy(hdata->dma_bounce_buffer, cmd->SCp.ptr, |
80 | cmd->SCp.ptr, cmd->SCp.this_residual); | 79 | cmd->SCp.this_residual); |
81 | } | 80 | } |
82 | } | 81 | } |
83 | 82 | ||
@@ -86,7 +85,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) | |||
86 | cntr |= CNTR_DDIR; | 85 | cntr |= CNTR_DDIR; |
87 | 86 | ||
88 | /* remember direction */ | 87 | /* remember direction */ |
89 | HDATA(cmd->device->host)->dma_dir = dir_in; | 88 | hdata->dma_dir = dir_in; |
90 | 89 | ||
91 | DMA(cmd->device->host)->CNTR = cntr; | 90 | DMA(cmd->device->host)->CNTR = cntr; |
92 | 91 | ||
@@ -110,17 +109,19 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) | |||
110 | static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, | 109 | static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, |
111 | int status) | 110 | int status) |
112 | { | 111 | { |
112 | struct WD33C93_hostdata *hdata = shost_priv(instance); | ||
113 | |||
113 | /* disable SCSI interrupts */ | 114 | /* disable SCSI interrupts */ |
114 | unsigned short cntr = CNTR_PDMD; | 115 | unsigned short cntr = CNTR_PDMD; |
115 | 116 | ||
116 | if (!HDATA(instance)->dma_dir) | 117 | if (!hdata->dma_dir) |
117 | cntr |= CNTR_DDIR; | 118 | cntr |= CNTR_DDIR; |
118 | 119 | ||
119 | /* disable SCSI interrupts */ | 120 | /* disable SCSI interrupts */ |
120 | DMA(instance)->CNTR = cntr; | 121 | DMA(instance)->CNTR = cntr; |
121 | 122 | ||
122 | /* flush if we were reading */ | 123 | /* flush if we were reading */ |
123 | if (HDATA(instance)->dma_dir) { | 124 | if (hdata->dma_dir) { |
124 | DMA(instance)->FLUSH = 1; | 125 | DMA(instance)->FLUSH = 1; |
125 | while (!(DMA(instance)->ISTR & ISTR_FE_FLG)) | 126 | while (!(DMA(instance)->ISTR & ISTR_FE_FLG)) |
126 | ; | 127 | ; |
@@ -136,14 +137,13 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, | |||
136 | DMA(instance)->CNTR = CNTR_PDMD | CNTR_INTEN; | 137 | DMA(instance)->CNTR = CNTR_PDMD | CNTR_INTEN; |
137 | 138 | ||
138 | /* copy from a bounce buffer, if necessary */ | 139 | /* copy from a bounce buffer, if necessary */ |
139 | if (status && HDATA(instance)->dma_bounce_buffer) { | 140 | if (status && hdata->dma_bounce_buffer) { |
140 | if (HDATA(instance)->dma_dir) | 141 | if (hdata->dma_dir) |
141 | memcpy(SCpnt->SCp.ptr, | 142 | memcpy(SCpnt->SCp.ptr, hdata->dma_bounce_buffer, |
142 | HDATA(instance)->dma_bounce_buffer, | ||
143 | SCpnt->SCp.this_residual); | 143 | SCpnt->SCp.this_residual); |
144 | kfree(HDATA(instance)->dma_bounce_buffer); | 144 | kfree(hdata->dma_bounce_buffer); |
145 | HDATA(instance)->dma_bounce_buffer = NULL; | 145 | hdata->dma_bounce_buffer = NULL; |
146 | HDATA(instance)->dma_bounce_len = 0; | 146 | hdata->dma_bounce_len = 0; |
147 | } | 147 | } |
148 | } | 148 | } |
149 | 149 | ||
@@ -154,6 +154,7 @@ static int __init a2091_detect(struct scsi_host_template *tpnt) | |||
154 | unsigned long address; | 154 | unsigned long address; |
155 | struct zorro_dev *z = NULL; | 155 | struct zorro_dev *z = NULL; |
156 | wd33c93_regs regs; | 156 | wd33c93_regs regs; |
157 | struct WD33C93_hostdata *hdata; | ||
157 | int num_a2091 = 0; | 158 | int num_a2091 = 0; |
158 | 159 | ||
159 | if (!MACH_IS_AMIGA || called) | 160 | if (!MACH_IS_AMIGA || called) |
@@ -180,9 +181,10 @@ static int __init a2091_detect(struct scsi_host_template *tpnt) | |||
180 | DMA(instance)->DAWR = DAWR_A2091; | 181 | DMA(instance)->DAWR = DAWR_A2091; |
181 | regs.SASR = &(DMA(instance)->SASR); | 182 | regs.SASR = &(DMA(instance)->SASR); |
182 | regs.SCMD = &(DMA(instance)->SCMD); | 183 | regs.SCMD = &(DMA(instance)->SCMD); |
183 | HDATA(instance)->no_sync = 0xff; | 184 | hdata = shost_priv(instance); |
184 | HDATA(instance)->fast = 0; | 185 | hdata->no_sync = 0xff; |
185 | HDATA(instance)->dma_mode = CTRL_DMA; | 186 | hdata->fast = 0; |
187 | hdata->dma_mode = CTRL_DMA; | ||
186 | wd33c93_init(instance, regs, dma_setup, dma_stop, | 188 | wd33c93_init(instance, regs, dma_setup, dma_stop, |
187 | WD33C93_FS_8_10); | 189 | WD33C93_FS_8_10); |
188 | if (request_irq(IRQ_AMIGA_PORTS, a2091_intr, IRQF_SHARED, | 190 | if (request_irq(IRQ_AMIGA_PORTS, a2091_intr, IRQF_SHARED, |