aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorOndrej Zary <linux@rainbow-software.org>2015-02-06 17:11:33 -0500
committerJames Bottomley <JBottomley@Odin.com>2015-04-09 21:07:20 -0400
commit0c2b64819105986c12d7412a1cb5b91e3d80c15c (patch)
treed1ebe4f15790f129087abf1ed8dda7c98d3c9df1 /drivers/scsi
parentf8846be334443b432f5daf22099e9f4bdd02ba9f (diff)
aha1542: Split aha1542_out
aha1542_out are in fact two separate functions. Split them into aha1542_out and aha1542_outb to simplify the code. Signed-off-by: Ondrej Zary <linux@rainbow-software.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: James Bottomley <JBottomley@Odin.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/aha1542.c75
1 files changed, 35 insertions, 40 deletions
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index b4ada244bcb2..7bf4604ede47 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -151,41 +151,42 @@ static inline bool wait_mask(u16 port, u8 mask, u8 allof, u8 noneof, int timeout
151 routine does not send something out while we are in the middle of this. 151 routine does not send something out while we are in the middle of this.
152 Fortunately, it is only at boot time that multi-byte messages 152 Fortunately, it is only at boot time that multi-byte messages
153 are ever sent. */ 153 are ever sent. */
154static int aha1542_out(unsigned int base, u8 *cmdp, int len) 154static int aha1542_outb(unsigned int base, u8 cmd)
155{ 155{
156 unsigned long flags = 0; 156 unsigned long flags;
157 int got_lock; 157
158 158 while (1) {
159 if (len == 1) { 159 if (!wait_mask(STATUS(base), CDF, 0, CDF, 0)) {
160 got_lock = 0; 160 printk(KERN_ERR "aha1542_outb failed");
161 while (1 == 1) { 161 return 1;
162 if (!wait_mask(STATUS(base), CDF, 0, CDF, 0))
163 goto fail;
164 spin_lock_irqsave(&aha1542_lock, flags);
165 if (inb(STATUS(base)) & CDF) {
166 spin_unlock_irqrestore(&aha1542_lock, flags);
167 continue;
168 }
169 outb(*cmdp, DATA(base));
170 spin_unlock_irqrestore(&aha1542_lock, flags);
171 return 0;
172 } 162 }
173 } else {
174 spin_lock_irqsave(&aha1542_lock, flags); 163 spin_lock_irqsave(&aha1542_lock, flags);
175 got_lock = 1; 164 if (inb(STATUS(base)) & CDF) {
176 while (len--) { 165 spin_unlock_irqrestore(&aha1542_lock, flags);
177 if (!wait_mask(STATUS(base), CDF, 0, CDF, 0)) 166 continue;
178 goto fail;
179 outb(*cmdp++, DATA(base));
180 } 167 }
168 outb(cmd, DATA(base));
181 spin_unlock_irqrestore(&aha1542_lock, flags); 169 spin_unlock_irqrestore(&aha1542_lock, flags);
170 return 0;
182 } 171 }
172}
173
174static int aha1542_out(unsigned int base, u8 *cmdp, int len)
175{
176 unsigned long flags;
177
178 spin_lock_irqsave(&aha1542_lock, flags);
179 while (len--) {
180 if (!wait_mask(STATUS(base), CDF, 0, CDF, 0)) {
181 spin_unlock_irqrestore(&aha1542_lock, flags);
182 printk(KERN_ERR "aha1542_out failed(%d): ", len + 1);
183 return 1;
184 }
185 outb(*cmdp++, DATA(base));
186 }
187 spin_unlock_irqrestore(&aha1542_lock, flags);
188
183 return 0; 189 return 0;
184fail:
185 if (got_lock)
186 spin_unlock_irqrestore(&aha1542_lock, flags);
187 printk(KERN_ERR "aha1542_out failed(%d): ", len + 1);
188 return 1;
189} 190}
190 191
191/* Only used at boot time, so we do not need to worry about latency as much 192/* Only used at boot time, so we do not need to worry about latency as much
@@ -268,7 +269,6 @@ static int makecode(unsigned hosterr, unsigned scsierr)
268 269
269static int aha1542_test_port(int bse, struct Scsi_Host *shpnt) 270static int aha1542_test_port(int bse, struct Scsi_Host *shpnt)
270{ 271{
271 u8 inquiry_cmd[] = {CMD_INQUIRY};
272 u8 inquiry_result[4]; 272 u8 inquiry_result[4];
273 u8 *cmdp; 273 u8 *cmdp;
274 int len; 274 int len;
@@ -303,7 +303,7 @@ static int aha1542_test_port(int bse, struct Scsi_Host *shpnt)
303 /* Perform a host adapter inquiry instead so we do not need to set 303 /* Perform a host adapter inquiry instead so we do not need to set
304 up the mailboxes ahead of time */ 304 up the mailboxes ahead of time */
305 305
306 aha1542_out(bse, inquiry_cmd, 1); 306 aha1542_outb(bse, CMD_INQUIRY);
307 307
308 debug = 3; 308 debug = 3;
309 len = 4; 309 len = 4;
@@ -527,7 +527,6 @@ static irqreturn_t do_aha1542_intr_handle(int dummy, void *dev_id)
527static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) 527static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
528{ 528{
529 struct aha1542_hostdata *aha1542 = shost_priv(SCpnt->device->host); 529 struct aha1542_hostdata *aha1542 = shost_priv(SCpnt->device->host);
530 u8 ahacmd = CMD_START_SCSI;
531 u8 direction; 530 u8 direction;
532 u8 *cmd = (u8 *) SCpnt->cmnd; 531 u8 *cmd = (u8 *) SCpnt->cmnd;
533 u8 target = SCpnt->device->id; 532 u8 target = SCpnt->device->id;
@@ -666,7 +665,7 @@ static int aha1542_queuecommand_lck(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *
666 DEB(printk("aha1542_queuecommand: now waiting for interrupt ")); 665 DEB(printk("aha1542_queuecommand: now waiting for interrupt "));
667 SCpnt->scsi_done = done; 666 SCpnt->scsi_done = done;
668 mb[mbo].status = 1; 667 mb[mbo].status = 1;
669 aha1542_out(SCpnt->device->host->io_port, &ahacmd, 1); /* start scsi command */ 668 aha1542_outb(SCpnt->device->host->io_port, CMD_START_SCSI);
670 } else 669 } else
671 printk("aha1542_queuecommand: done can't be NULL\n"); 670 printk("aha1542_queuecommand: done can't be NULL\n");
672 671
@@ -703,14 +702,13 @@ fail:
703 702
704static int aha1542_getconfig(int base_io, unsigned char *irq_level, unsigned char *dma_chan, unsigned char *scsi_id) 703static int aha1542_getconfig(int base_io, unsigned char *irq_level, unsigned char *dma_chan, unsigned char *scsi_id)
705{ 704{
706 u8 inquiry_cmd[] = {CMD_RETCONF};
707 u8 inquiry_result[3]; 705 u8 inquiry_result[3];
708 int i; 706 int i;
709 i = inb(STATUS(base_io)); 707 i = inb(STATUS(base_io));
710 if (i & DF) { 708 if (i & DF) {
711 i = inb(DATA(base_io)); 709 i = inb(DATA(base_io));
712 }; 710 };
713 aha1542_out(base_io, inquiry_cmd, 1); 711 aha1542_outb(base_io, CMD_RETCONF);
714 aha1542_in(base_io, inquiry_result, 3, 0); 712 aha1542_in(base_io, inquiry_result, 3, 0);
715 if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0)) 713 if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0))
716 goto fail; 714 goto fail;
@@ -779,8 +777,7 @@ static int aha1542_mbenable(int base)
779 777
780 retval = BIOS_TRANSLATION_6432; 778 retval = BIOS_TRANSLATION_6432;
781 779
782 mbenable_cmd[0] = CMD_EXTBIOS; 780 aha1542_outb(base, CMD_EXTBIOS);
783 aha1542_out(base, mbenable_cmd, 1);
784 if (aha1542_in(base, mbenable_result, 2, 100)) 781 if (aha1542_in(base, mbenable_result, 2, 100))
785 return retval; 782 return retval;
786 if (!wait_mask(INTRFLAGS(base), INTRMASK, HACC, 0, 100)) 783 if (!wait_mask(INTRFLAGS(base), INTRMASK, HACC, 0, 100))
@@ -810,14 +807,13 @@ fail:
810/* Query the board to find out if it is a 1542 or a 1740, or whatever. */ 807/* Query the board to find out if it is a 1542 or a 1740, or whatever. */
811static int aha1542_query(int base_io, int *transl) 808static int aha1542_query(int base_io, int *transl)
812{ 809{
813 u8 inquiry_cmd[] = {CMD_INQUIRY};
814 u8 inquiry_result[4]; 810 u8 inquiry_result[4];
815 int i; 811 int i;
816 i = inb(STATUS(base_io)); 812 i = inb(STATUS(base_io));
817 if (i & DF) { 813 if (i & DF) {
818 i = inb(DATA(base_io)); 814 i = inb(DATA(base_io));
819 }; 815 };
820 aha1542_out(base_io, inquiry_cmd, 1); 816 aha1542_outb(base_io, CMD_INQUIRY);
821 aha1542_in(base_io, inquiry_result, 4, 0); 817 aha1542_in(base_io, inquiry_result, 4, 0);
822 if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0)) 818 if (!wait_mask(INTRFLAGS(base_io), INTRMASK, HACC, 0, 0))
823 goto fail; 819 goto fail;
@@ -1079,7 +1075,6 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt)
1079 u8 lun = SCpnt->device->lun; 1075 u8 lun = SCpnt->device->lun;
1080 int mbo; 1076 int mbo;
1081 struct ccb *ccb = aha1542->ccb; 1077 struct ccb *ccb = aha1542->ccb;
1082 u8 ahacmd = CMD_START_SCSI;
1083 1078
1084 spin_lock_irqsave(&aha1542_lock, flags); 1079 spin_lock_irqsave(&aha1542_lock, flags);
1085 mbo = aha1542->aha1542_last_mbo_used + 1; 1080 mbo = aha1542->aha1542_last_mbo_used + 1;
@@ -1119,7 +1114,7 @@ static int aha1542_dev_reset(Scsi_Cmnd * SCpnt)
1119 * Now tell the 1542 to flush all pending commands for this 1114 * Now tell the 1542 to flush all pending commands for this
1120 * target 1115 * target
1121 */ 1116 */
1122 aha1542_out(SCpnt->device->host->io_port, &ahacmd, 1); 1117 aha1542_outb(SCpnt->device->host->io_port, CMD_START_SCSI);
1123 1118
1124 scmd_printk(KERN_WARNING, SCpnt, 1119 scmd_printk(KERN_WARNING, SCpnt,
1125 "Trying device reset for target\n"); 1120 "Trying device reset for target\n");