Commit 173a9b29 authored by Alexander Viro's avatar Alexander Viro Committed by David S. Miller

[NET]: Move sk98lin driver away from init_etherdev().

parent 19e4e57a
...@@ -383,6 +383,7 @@ struct s_DevNet { ...@@ -383,6 +383,7 @@ struct s_DevNet {
int Mtu; int Mtu;
int Up; int Up;
SK_AC *pAC; SK_AC *pAC;
struct proc_dir_entry *proc;
}; };
typedef struct s_TxPort TX_PORT; typedef struct s_TxPort TX_PORT;
......
...@@ -351,11 +351,7 @@ static int SkGeIocMib(DEV_NET*, unsigned int, int); ...@@ -351,11 +351,7 @@ static int SkGeIocMib(DEV_NET*, unsigned int, int);
static const char SK_Root_Dir_entry[] = "sk98lin"; static const char SK_Root_Dir_entry[] = "sk98lin";
static struct proc_dir_entry *pSkRootDir; static struct proc_dir_entry *pSkRootDir;
extern struct file_operations sk_proc_fops;
//extern struct proc_dir_entry Our_Proc_Dir;
extern int sk_proc_read(char *buffer, char **buffer_location,
off_t offset, int buffer_length, int *eof, void *data);
#ifdef DEBUG #ifdef DEBUG
static void DumpMsg(struct sk_buff*, char*); static void DumpMsg(struct sk_buff*, char*);
...@@ -399,7 +395,6 @@ static int __init skge_probe (void) ...@@ -399,7 +395,6 @@ static int __init skge_probe (void)
struct pci_dev *pdev = NULL; struct pci_dev *pdev = NULL;
unsigned long base_address; unsigned long base_address;
struct net_device *dev = NULL; struct net_device *dev = NULL;
struct proc_dir_entry *pProcFile;
if (probed) if (probed)
return -ENODEV; return -ENODEV;
...@@ -420,7 +415,6 @@ static int __init skge_probe (void) ...@@ -420,7 +415,6 @@ static int __init skge_probe (void)
while((pdev = pci_find_device(PCI_VENDOR_ID_SYSKONNECT, while((pdev = pci_find_device(PCI_VENDOR_ID_SYSKONNECT,
PCI_DEVICE_ID_SYSKONNECT_GE, pdev)) != NULL) { PCI_DEVICE_ID_SYSKONNECT_GE, pdev)) != NULL) {
dev = NULL;
pNet = NULL; pNet = NULL;
if (pci_enable_device(pdev)) if (pci_enable_device(pdev))
...@@ -431,7 +425,8 @@ static int __init skge_probe (void) ...@@ -431,7 +425,8 @@ static int __init skge_probe (void)
pci_set_dma_mask(pdev, (u64) 0xffffffff)) pci_set_dma_mask(pdev, (u64) 0xffffffff))
continue; continue;
if ((dev = init_etherdev(dev, sizeof(DEV_NET))) == 0) { dev = alloc_etherdev(sizeof(DEV_NET));
if (!dev) {
printk(KERN_ERR "Unable to allocate etherdev " printk(KERN_ERR "Unable to allocate etherdev "
"structure!\n"); "structure!\n");
break; break;
...@@ -440,7 +435,7 @@ static int __init skge_probe (void) ...@@ -440,7 +435,7 @@ static int __init skge_probe (void)
pNet = dev->priv; pNet = dev->priv;
pNet->pAC = kmalloc(sizeof(SK_AC), GFP_KERNEL); pNet->pAC = kmalloc(sizeof(SK_AC), GFP_KERNEL);
if (pNet->pAC == NULL){ if (pNet->pAC == NULL){
kfree(dev->priv); kfree(dev);
printk(KERN_ERR "Unable to allocate adapter " printk(KERN_ERR "Unable to allocate adapter "
"structure!\n"); "structure!\n");
break; break;
...@@ -477,15 +472,6 @@ static int __init skge_probe (void) ...@@ -477,15 +472,6 @@ static int __init skge_probe (void)
proc_root_initialized = 1; proc_root_initialized = 1;
} }
pProcFile = create_proc_entry(dev->name,
S_IFREG | 0444, pSkRootDir);
pProcFile->read_proc = sk_proc_read;
pProcFile->write_proc = NULL;
pProcFile->nlink = 1;
pProcFile->size = sizeof(dev->name+1);
pProcFile->data = (void*)pProcFile;
pProcFile->owner = THIS_MODULE;
/* /*
* Dummy value. * Dummy value.
*/ */
...@@ -532,11 +518,29 @@ static int __init skge_probe (void) ...@@ -532,11 +518,29 @@ static int __init skge_probe (void)
pNet->PortNr = 0; pNet->PortNr = 0;
pNet->NetNr = 0; pNet->NetNr = 0;
if (register_netdev(dev) != 0) {
printk(KERN_ERR "Unable to register etherdev\n");
sk98lin_root_dev = pAC->Next;
remove_proc_entry(dev->name, pSkRootDir);
FreeResources(dev);
kfree(dev);
continue;
}
pNet->proc = create_proc_entry(dev->name,
S_IFREG | 0444, pSkRootDir);
if (pNet->proc) {
pNet->proc->data = dev;
pNet->proc->owner = THIS_MODULE;
pNet->proc->proc_fops = &sk_proc_fops;
}
boards_found++; boards_found++;
/* More then one port found */ /* More then one port found */
if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) { if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) {
if ((dev = init_etherdev(NULL, sizeof(DEV_NET))) == 0) { dev = alloc_etherdev(sizeof(DEV_NET));
if (!dev) {
printk(KERN_ERR "Unable to allocate etherdev " printk(KERN_ERR "Unable to allocate etherdev "
"structure!\n"); "structure!\n");
break; break;
...@@ -559,21 +563,26 @@ static int __init skge_probe (void) ...@@ -559,21 +563,26 @@ static int __init skge_probe (void)
dev->do_ioctl = &SkGeIoctl; dev->do_ioctl = &SkGeIoctl;
dev->change_mtu = &SkGeChangeMtu; dev->change_mtu = &SkGeChangeMtu;
pProcFile = create_proc_entry(dev->name,
S_IFREG | 0444, pSkRootDir);
pProcFile->read_proc = sk_proc_read;
pProcFile->write_proc = NULL;
pProcFile->nlink = 1;
pProcFile->size = sizeof(dev->name+1);
pProcFile->data = (void*)pProcFile;
pProcFile->owner = THIS_MODULE;
memcpy((caddr_t) &dev->dev_addr, memcpy((caddr_t) &dev->dev_addr,
(caddr_t) &pAC->Addr.Net[1].CurrentMacAddress, 6); (caddr_t) &pAC->Addr.Net[1].CurrentMacAddress, 6);
printk("%s: %s\n", dev->name, pAC->DeviceStr); printk("%s: %s\n", dev->name, pAC->DeviceStr);
printk(" PrefPort:B RlmtMode:Dual Check Link State\n"); printk(" PrefPort:B RlmtMode:Dual Check Link State\n");
if (register_netdev(dev) != 0) {
printk(KERN_ERR "Unable to register etherdev\n");
kfree(dev);
break;
}
pNet->proc = create_proc_entry(dev->name,
S_IFREG | 0444, pSkRootDir);
if (pNet->proc) {
pNet->proc->data = dev;
pNet->proc->owner = THIS_MODULE;
pNet->proc->proc_fops = &sk_proc_fops;
}
} }
...@@ -740,6 +749,7 @@ static int __init skge_init_module(void) ...@@ -740,6 +749,7 @@ static int __init skge_init_module(void)
return cards ? 0 : -ENODEV; return cards ? 0 : -ENODEV;
} /* skge_init_module */ } /* skge_init_module */
spinlock_t sk_devs_lock = SPIN_LOCK_UNLOCKED;
/***************************************************************************** /*****************************************************************************
* *
...@@ -766,6 +776,11 @@ SK_EVPARA EvPara; ...@@ -766,6 +776,11 @@ SK_EVPARA EvPara;
netif_stop_queue(sk98lin_root_dev); netif_stop_queue(sk98lin_root_dev);
SkGeYellowLED(pAC, pAC->IoBase, 0); SkGeYellowLED(pAC, pAC->IoBase, 0);
if (pNet->proc) {
spin_lock(&sk_devs_lock);
pNet->proc->data = NULL;
spin_unlock(&sk_devs_lock);
}
if(pAC->BoardLevel == 2) { if(pAC->BoardLevel == 2) {
/* board is still alive */ /* board is still alive */
...@@ -792,6 +807,12 @@ SK_EVPARA EvPara; ...@@ -792,6 +807,12 @@ SK_EVPARA EvPara;
} }
if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 2){ if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 2){
pNet = (DEV_NET*) pAC->dev[1]->priv;
if (pNet->proc) {
spin_lock(&sk_devs_lock);
pNet->proc->data = NULL;
spin_unlock(&sk_devs_lock);
}
unregister_netdev(pAC->dev[1]); unregister_netdev(pAC->dev[1]);
kfree(pAC->dev[1]); kfree(pAC->dev[1]);
} }
......
This diff is collapsed.
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