Commit 3d93561d authored by Stephen Hemminger's avatar Stephen Hemminger

[netdrvr skge] handle proc_fs errors.

Existing code does not
	- check if proc_fs functions return error.
	- use proc_mkdir to make the directory.

Note pSkRootDir defined twice.
parent c02cf91a
...@@ -607,12 +607,6 @@ static uintptr_t TxQueueAddr[SK_MAX_MACS][2] = {{0x680, 0x600},{0x780, 0x700}}; ...@@ -607,12 +607,6 @@ static uintptr_t TxQueueAddr[SK_MAX_MACS][2] = {{0x680, 0x600},{0x780, 0x700}};
static uintptr_t RxQueueAddr[SK_MAX_MACS] = {0x400, 0x480}; static uintptr_t RxQueueAddr[SK_MAX_MACS] = {0x400, 0x480};
#ifdef CONFIG_PROC_FS
static struct proc_dir_entry *pSkRootDir;
#endif
/***************************************************************************** /*****************************************************************************
* *
* skge_probe - find all SK-98xx adapters * skge_probe - find all SK-98xx adapters
...@@ -638,7 +632,6 @@ static int __init skge_probe (void) ...@@ -638,7 +632,6 @@ static int __init skge_probe (void)
SK_BOOL BootStringCount = SK_FALSE; SK_BOOL BootStringCount = SK_FALSE;
int retval; int retval;
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
int proc_root_initialized = 0;
struct proc_dir_entry *pProcFile; struct proc_dir_entry *pProcFile;
#endif #endif
...@@ -758,26 +751,28 @@ static int __init skge_probe (void) ...@@ -758,26 +751,28 @@ static int __init skge_probe (void)
sizeof(SK_Root_Dir_entry) - 1); sizeof(SK_Root_Dir_entry) - 1);
/*Create proc (directory)*/ /*Create proc (directory)*/
if(!proc_root_initialized) { if(!pSkRootDir) {
pSkRootDir = create_proc_entry(SK_Root_Dir_entry, pSkRootDir = proc_mkdir(SK_Root_Dir_entry, proc_net);
S_IFDIR | S_IWUSR | S_IRUGO | S_IXUGO, proc_net); if (!pSkRootDir)
pSkRootDir->owner = THIS_MODULE; printk(KERN_WARNING "%s: Unable to create /proc/net/%s",
proc_root_initialized = 1; dev->name, SK_Root_Dir_entry);
else
pSkRootDir->owner = THIS_MODULE;
} }
} }
/* Create proc file */
pProcFile = create_proc_entry(dev->name,
S_IFREG | S_IXUSR | S_IWGRP | S_IROTH,
pSkRootDir);
pProcFile->read_proc = sk_proc_read; /* Create proc file */
pProcFile->write_proc = NULL; if (pSkRootDir &&
pProcFile->nlink = 1; (pProcFile = create_proc_entry(dev->name,
pProcFile->size = sizeof(dev->name + 1); S_IFREG | S_IXUSR | S_IWGRP | S_IROTH,
pProcFile->data = (void *)pProcFile; pSkRootDir))) {
pProcFile->owner = THIS_MODULE; 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;
}
#endif #endif
pNet->PortNr = 0; pNet->PortNr = 0;
...@@ -831,17 +826,18 @@ static int __init skge_probe (void) ...@@ -831,17 +826,18 @@ static int __init skge_probe (void)
#endif #endif
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
pProcFile = create_proc_entry(dev->name, if (pSkRootDir
S_IFREG | S_IXUSR | S_IWGRP | S_IROTH, && (pProcFile = create_proc_entry(dev->name,
pSkRootDir); S_IFREG | S_IXUSR | S_IWGRP | S_IROTH,
pSkRootDir))) {
pProcFile->read_proc = sk_proc_read; pProcFile->read_proc = sk_proc_read;
pProcFile->write_proc = NULL; pProcFile->write_proc = NULL;
pProcFile->nlink = 1; pProcFile->nlink = 1;
pProcFile->size = sizeof(dev->name + 1); pProcFile->size = sizeof(dev->name + 1);
pProcFile->data = (void *)pProcFile; pProcFile->data = (void *)pProcFile;
pProcFile->owner = THIS_MODULE; pProcFile->owner = THIS_MODULE;
}
#endif #endif
memcpy((caddr_t) &dev->dev_addr, memcpy((caddr_t) &dev->dev_addr,
...@@ -1188,7 +1184,8 @@ SK_EVPARA EvPara; ...@@ -1188,7 +1184,8 @@ SK_EVPARA EvPara;
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
/* clear proc-dir */ /* clear proc-dir */
remove_proc_entry(pSkRootDir->name, proc_net); if (pSkRootDir)
remove_proc_entry(pSkRootDir->name, proc_net);
#endif #endif
} /* skge_cleanup_module */ } /* skge_cleanup_module */
......
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