Commit f6de7acc authored by Joe Perches's avatar Joe Perches Committed by David S. Miller

drivers/net/mac8390.c: Add mac8390_init function

Reduce indentation, make code a little neater.
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8e4d9696
......@@ -295,42 +295,13 @@ static int __init mac8390_memsize(unsigned long membase)
return i * 0x1000;
}
struct net_device * __init mac8390_probe(int unit)
static bool __init mac8390_init(struct net_device *dev, struct nubus_dev *ndev,
enum mac8390_type cardtype)
{
struct net_device *dev;
volatile unsigned short *i;
struct nubus_dev *ndev = NULL;
int err = -ENODEV;
struct nubus_dir dir;
struct nubus_dirent ent;
int offset;
static unsigned int slots;
enum mac8390_type cardtype;
/* probably should check for Nubus instead */
if (!MACH_IS_MAC)
return ERR_PTR(-ENODEV);
dev = ____alloc_ei_netdev(0);
if (!dev)
return ERR_PTR(-ENOMEM);
if (unit >= 0)
sprintf(dev->name, "eth%d", unit);
while ((ndev = nubus_find_type(NUBUS_CAT_NETWORK, NUBUS_TYPE_ETHERNET,
ndev))) {
/* Have we seen it already? */
if (slots & (1<<ndev->board->slot))
continue;
slots |= 1<<ndev->board->slot;
cardtype = mac8390_ident(ndev);
if (cardtype == MAC8390_NONE)
continue;
volatile unsigned short *i;
printk_once(KERN_INFO pr_fmt(version));
......@@ -339,30 +310,32 @@ struct net_device * __init mac8390_probe(int unit)
dev->base_addr = (ndev->board->slot_addr |
((ndev->board->slot & 0xf) << 20));
/* Get some Nubus info - we will trust the card's idea
of where its memory and registers are. */
/*
* Get some Nubus info - we will trust the card's idea
* of where its memory and registers are.
*/
if (nubus_get_func_dir(ndev, &dir) == -1) {
pr_err("%s: Unable to get Nubus functional directory for slot %X!\n",
dev->name, ndev->board->slot);
continue;
return false;
}
/* Get the MAC address */
if (nubus_find_rsrc(&dir, NUBUS_RESID_MAC_ADDRESS, &ent) == -1) {
pr_info("%s: Couldn't get MAC address!\n", dev->name);
continue;
} else {
nubus_get_rsrc_mem(dev->dev_addr, &ent, 6);
return false;
}
nubus_get_rsrc_mem(dev->dev_addr, &ent, 6);
if (useresources[cardtype] == 1) {
nubus_rewinddir(&dir);
if (nubus_find_rsrc(&dir, NUBUS_RESID_MINOR_BASEOS,
&ent) == -1) {
pr_err("%s: Memory offset resource for slot %X not found!\n",
dev->name, ndev->board->slot);
continue;
return false;
}
nubus_get_rsrc_mem(&offset, &ent, 4);
dev->mem_start = dev->base_addr + offset;
......@@ -382,33 +355,25 @@ struct net_device * __init mac8390_probe(int unit)
switch (cardtype) {
case MAC8390_KINETICS:
case MAC8390_DAYNA: /* it's the same */
dev->base_addr =
(int)(ndev->board->slot_addr +
dev->base_addr = (int)(ndev->board->slot_addr +
DAYNA_8390_BASE);
dev->mem_start =
(int)(ndev->board->slot_addr +
dev->mem_start = (int)(ndev->board->slot_addr +
DAYNA_8390_MEM);
dev->mem_end =
dev->mem_start +
dev->mem_end = dev->mem_start +
mac8390_memsize(dev->mem_start);
break;
case MAC8390_INTERLAN:
dev->base_addr =
(int)(ndev->board->slot_addr +
dev->base_addr = (int)(ndev->board->slot_addr +
INTERLAN_8390_BASE);
dev->mem_start =
(int)(ndev->board->slot_addr +
dev->mem_start = (int)(ndev->board->slot_addr +
INTERLAN_8390_MEM);
dev->mem_end =
dev->mem_start +
dev->mem_end = dev->mem_start +
mac8390_memsize(dev->mem_start);
break;
case MAC8390_CABLETRON:
dev->base_addr =
(int)(ndev->board->slot_addr +
dev->base_addr = (int)(ndev->board->slot_addr +
CABLETRON_8390_BASE);
dev->mem_start =
(int)(ndev->board->slot_addr +
dev->mem_start = (int)(ndev->board->slot_addr +
CABLETRON_8390_MEM);
/* The base address is unreadable if 0x00
* has been written to the command register
......@@ -418,18 +383,56 @@ struct net_device * __init mac8390_probe(int unit)
*/
i = (void *)dev->base_addr;
*i = 0x21;
dev->mem_end =
dev->mem_start +
dev->mem_end = dev->mem_start +
mac8390_memsize(dev->mem_start);
break;
default:
pr_err("Card type %s is unsupported, sorry\n",
ndev->board->name);
continue;
return false;
}
}
return true;
}
struct net_device * __init mac8390_probe(int unit)
{
struct net_device *dev;
struct nubus_dev *ndev = NULL;
int err = -ENODEV;
static unsigned int slots;
enum mac8390_type cardtype;
/* probably should check for Nubus instead */
if (!MACH_IS_MAC)
return ERR_PTR(-ENODEV);
dev = ____alloc_ei_netdev(0);
if (!dev)
return ERR_PTR(-ENOMEM);
if (unit >= 0)
sprintf(dev->name, "eth%d", unit);
while ((ndev = nubus_find_type(NUBUS_CAT_NETWORK, NUBUS_TYPE_ETHERNET,
ndev))) {
/* Have we seen it already? */
if (slots & (1 << ndev->board->slot))
continue;
slots |= 1 << ndev->board->slot;
cardtype = mac8390_ident(ndev);
if (cardtype == MAC8390_NONE)
continue;
if (!mac8390_init(dev, ndev, cardtype))
continue;
/* Do the nasty 8390 stuff */
if (!mac8390_initdev(dev, ndev, cardtype))
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment