atp870u: Remove ugly gotos #5

Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Reviewed-by: Hannes Reinicke <hare@suse.de>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Ondrej Zary 2015-11-17 19:23:53 +01:00 committed by Martin K. Petersen
parent 58c4d046b4
commit c7fcc089b0
1 changed files with 63 additions and 73 deletions

View File

@ -1007,28 +1007,22 @@ static void tscam(struct Scsi_Host *host)
;
outb(1, 0x80);
udelay(100);
for (n = 0; n < 0x30000; n++) {
if ((inb(dev->ioport[0] + 0x1c) & 0x80) != 0) { /* bsy ? */
goto wait_io;
}
}
goto TCM_SYNC;
wait_io:
for (n = 0; n < 0x30000; n++) {
if ((inb(dev->ioport[0] + 0x1c) & 0x81) == 0x0081) {
goto wait_io1;
}
}
goto TCM_SYNC;
wait_io1:
inb(0x80);
val |= 0x8003; /* io,cd,db7 */
outw(val, dev->ioport[0] + 0x1c);
inb(0x80);
val &= 0x00bf; /* no sel */
outw(val, dev->ioport[0] + 0x1c);
outb(2, 0x80);
TCM_SYNC:
for (n = 0; n < 0x30000; n++)
if ((inb(dev->ioport[0] + 0x1c) & 0x80) != 0) /* bsy ? */
break;
if (n < 0x30000)
for (n = 0; n < 0x30000; n++)
if ((inb(dev->ioport[0] + 0x1c) & 0x81) == 0x0081) {
inb(0x80);
val |= 0x8003; /* io,cd,db7 */
outw(val, dev->ioport[0] + 0x1c);
inb(0x80);
val &= 0x00bf; /* no sel */
outw(val, dev->ioport[0] + 0x1c);
outb(2, 0x80);
break;
}
while (1) {
/*
* The funny division into multiple delays is to accomodate
* arches like ARM where udelay() multiplies its argument by
@ -1059,31 +1053,28 @@ static void tscam(struct Scsi_Host *host)
outb(4, 0x80);
i = 8;
j = 0;
TCM_ID:
if ((inw(dev->ioport[0] + 0x1c) & 0x2000) == 0) {
goto TCM_ID;
}
outb(5, 0x80);
val &= 0x00ff; /* get ID_STRING */
val |= 0x2000;
k = fun_scam(dev, &val);
if ((k & 0x03) == 0) {
goto TCM_5;
}
mbuf[j] <<= 0x01;
mbuf[j] &= 0xfe;
if ((k & 0x02) != 0) {
mbuf[j] |= 0x01;
}
i--;
if (i > 0) {
goto TCM_ID;
}
j++;
i = 8;
goto TCM_ID;
TCM_5: /* isolation complete.. */
while (1) {
if ((inw(dev->ioport[0] + 0x1c) & 0x2000) == 0)
continue;
outb(5, 0x80);
val &= 0x00ff; /* get ID_STRING */
val |= 0x2000;
k = fun_scam(dev, &val);
if ((k & 0x03) == 0)
break;
mbuf[j] <<= 0x01;
mbuf[j] &= 0xfe;
if ((k & 0x02) != 0)
mbuf[j] |= 0x01;
i--;
if (i > 0)
continue;
j++;
i = 8;
}
/* isolation complete.. */
/* mbuf[32]=0;
printk(" \n%x %x %x %s\n ",assignid_map,mbuf[0],mbuf[1],&mbuf[2]); */
i = 15;
@ -1091,33 +1082,33 @@ static void tscam(struct Scsi_Host *host)
if ((j & 0x20) != 0) { /* bit5=1:ID up to 7 */
i = 7;
}
if ((j & 0x06) == 0) { /* IDvalid? */
goto G2Q5;
if ((j & 0x06) != 0) { /* IDvalid? */
k = mbuf[1];
while (1) {
m = 1;
m <<= k;
if ((m & assignid_map) == 0)
break;
if (k > 0)
k--;
else
break;
}
}
k = mbuf[1];
small_id:
m = 1;
m <<= k;
if ((m & assignid_map) == 0) {
goto G2Q_QUIN;
if ((m & assignid_map) != 0) { /* srch from max acceptable ID# */
k = i; /* max acceptable ID# */
while (1) {
m = 1;
m <<= k;
if ((m & assignid_map) == 0)
break;
if (k > 0)
k--;
else
break;
}
}
if (k > 0) {
k--;
goto small_id;
}
G2Q5: /* srch from max acceptable ID# */
k = i; /* max acceptable ID# */
G2Q_LP:
m = 1;
m <<= k;
if ((m & assignid_map) == 0) {
goto G2Q_QUIN;
}
if (k > 0) {
k--;
goto G2Q_LP;
}
G2Q_QUIN: /* k=binID#, */
/* k=binID#, */
assignid_map |= m;
if (k < 8) {
quintet[0] = 0x38; /* 1st dft ID<8 */
@ -1136,8 +1127,7 @@ static void tscam(struct Scsi_Host *host)
val |= m;
fun_scam(dev, &val);
goto TCM_SYNC;
}
}
static void is870(struct atp_unit *dev, unsigned int wkport)