summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2008-03-19 09:44:19 +0000
committerJeff Garzik <jeff@garzik.org>2008-03-26 00:18:02 -0400
commit76af5699a359c3683f1c94444826d78be8d42513 (patch)
treea1309d7510e9570dd840f026965ce7146e00e48c /drivers
parent7f8cfd560875fd643024c02ea25d4f3b8f1fd31c (diff)
ni52: clean up check586()
take iscp-based testing into helper, kill the loop, stop wanking with reassignments of priv->iscp Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ni52.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/drivers/net/ni52.c b/drivers/net/ni52.c
index 3b1c4af615b..fa611f6a856 100644
--- a/drivers/net/ni52.c
+++ b/drivers/net/ni52.c
@@ -294,21 +294,38 @@ static int ni52_open(struct net_device *dev)
return 0; /* most done by init */
}
+static int check_iscp(struct net_device *dev, void __iomem *addr)
+{
+ struct iscp_struct __iomem *iscp = addr;
+ struct priv *p = dev->priv;
+ memset_io(iscp, 0, sizeof(struct iscp_struct));
+
+ writel(make24(iscp), &p->scp->iscp);
+ writeb(1, &iscp->busy);
+
+ ni_reset586();
+ ni_attn586();
+ mdelay(32); /* wait a while... */
+ /* i82586 clears 'busy' after successful init */
+ if (readb(&iscp->busy))
+ return 0;
+ return 1;
+}
+
/**********************************************
* Check to see if there's an 82586 out there.
*/
static int check586(struct net_device *dev, unsigned size)
{
- unsigned long where = dev->mem_start;
struct priv *p = dev->priv;
- char __iomem *iscp_addrs[2];
int i;
- p->mapped = (char __iomem *)isa_bus_to_virt(where);
+ p->mapped = (char __iomem *)isa_bus_to_virt(dev->mem_start);
p->base = p->mapped + size - 0x01000000;
p->memtop = p->mapped + size;
p->scp = (struct scp_struct __iomem *)(p->base + SCP_DEFAULT_ADDRESS);
p->scb = (struct scb_struct __iomem *) p->mapped;
+ p->iscp = (struct iscp_struct __iomem *)p->scp - 1;
memset_io(p->scp, 0, sizeof(struct scp_struct));
for (i = 0; i < sizeof(struct scp_struct); i++)
/* memory was writeable? */
@@ -318,26 +335,10 @@ static int check586(struct net_device *dev, unsigned size)
if (readb(&p->scp->sysbus) != SYSBUSVAL)
return 0;
- iscp_addrs[0] = p->mapped;
- iscp_addrs[1] = (char __iomem *)p->scp - sizeof(struct iscp_struct);
-
- for (i = 0; i < 2; i++) {
- p->iscp = (struct iscp_struct __iomem *) iscp_addrs[i];
- memset_io(p->iscp, 0, sizeof(struct iscp_struct));
-
- writel(make24(p->iscp), &p->scp->iscp);
- writeb(1, &p->iscp->busy);
-
- ni_reset586();
- ni_attn586();
- mdelay(32); /* wait a while... */
- /* i82586 clears 'busy' after successful init */
- if (readb(&p->iscp->busy))
- return 0;
- }
-
- p->iscp = (struct iscp_struct __iomem *)
- ((char __iomem *)p->scp - sizeof(struct iscp_struct));
+ if (!check_iscp(dev, p->mapped))
+ return 0;
+ if (!check_iscp(dev, p->iscp))
+ return 0;
return 1;
}