aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2008-03-19 05:44:19 -0400
committerJeff Garzik <jeff@garzik.org>2008-03-26 00:18:02 -0400
commit76af5699a359c3683f1c94444826d78be8d42513 (patch)
treea1309d7510e9570dd840f026965ce7146e00e48c /drivers/net
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/net')
-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 3b1c4af615b6..fa611f6a8563 100644
--- a/drivers/net/ni52.c
+++ b/drivers/net/ni52.c
@@ -294,21 +294,38 @@ static int ni52_open(struct net_device *dev)
294 return 0; /* most done by init */ 294 return 0; /* most done by init */
295} 295}
296 296
297static int check_iscp(struct net_device *dev, void __iomem *addr)
298{
299 struct iscp_struct __iomem *iscp = addr;
300 struct priv *p = dev->priv;
301 memset_io(iscp, 0, sizeof(struct iscp_struct));
302
303 writel(make24(iscp), &p->scp->iscp);
304 writeb(1, &iscp->busy);
305
306 ni_reset586();
307 ni_attn586();
308 mdelay(32); /* wait a while... */
309 /* i82586 clears 'busy' after successful init */
310 if (readb(&iscp->busy))
311 return 0;
312 return 1;
313}
314
297/********************************************** 315/**********************************************
298 * Check to see if there's an 82586 out there. 316 * Check to see if there's an 82586 out there.
299 */ 317 */
300static int check586(struct net_device *dev, unsigned size) 318static int check586(struct net_device *dev, unsigned size)
301{ 319{
302 unsigned long where = dev->mem_start;
303 struct priv *p = dev->priv; 320 struct priv *p = dev->priv;
304 char __iomem *iscp_addrs[2];
305 int i; 321 int i;
306 322
307 p->mapped = (char __iomem *)isa_bus_to_virt(where); 323 p->mapped = (char __iomem *)isa_bus_to_virt(dev->mem_start);
308 p->base = p->mapped + size - 0x01000000; 324 p->base = p->mapped + size - 0x01000000;
309 p->memtop = p->mapped + size; 325 p->memtop = p->mapped + size;
310 p->scp = (struct scp_struct __iomem *)(p->base + SCP_DEFAULT_ADDRESS); 326 p->scp = (struct scp_struct __iomem *)(p->base + SCP_DEFAULT_ADDRESS);
311 p->scb = (struct scb_struct __iomem *) p->mapped; 327 p->scb = (struct scb_struct __iomem *) p->mapped;
328 p->iscp = (struct iscp_struct __iomem *)p->scp - 1;
312 memset_io(p->scp, 0, sizeof(struct scp_struct)); 329 memset_io(p->scp, 0, sizeof(struct scp_struct));
313 for (i = 0; i < sizeof(struct scp_struct); i++) 330 for (i = 0; i < sizeof(struct scp_struct); i++)
314 /* memory was writeable? */ 331 /* memory was writeable? */
@@ -318,26 +335,10 @@ static int check586(struct net_device *dev, unsigned size)
318 if (readb(&p->scp->sysbus) != SYSBUSVAL) 335 if (readb(&p->scp->sysbus) != SYSBUSVAL)
319 return 0; 336 return 0;
320 337
321 iscp_addrs[0] = p->mapped; 338 if (!check_iscp(dev, p->mapped))
322 iscp_addrs[1] = (char __iomem *)p->scp - sizeof(struct iscp_struct); 339 return 0;
323 340 if (!check_iscp(dev, p->iscp))
324 for (i = 0; i < 2; i++) { 341 return 0;
325 p->iscp = (struct iscp_struct __iomem *) iscp_addrs[i];
326 memset_io(p->iscp, 0, sizeof(struct iscp_struct));
327
328 writel(make24(p->iscp), &p->scp->iscp);
329 writeb(1, &p->iscp->busy);
330
331 ni_reset586();
332 ni_attn586();
333 mdelay(32); /* wait a while... */
334 /* i82586 clears 'busy' after successful init */
335 if (readb(&p->iscp->busy))
336 return 0;
337 }
338
339 p->iscp = (struct iscp_struct __iomem *)
340 ((char __iomem *)p->scp - sizeof(struct iscp_struct));
341 return 1; 342 return 1;
342} 343}
343 344