Commit 9a78f14f authored by Stephen Hemminger's avatar Stephen Hemminger

[PATCH] sk98: /proc interface related changes

The /proc intereface can be cleaned up a lot:
+ Pass the device to through the proc data/seq_private hook.
+ No longer needs to have a list of network devices
+ use seq_printf directly rather than indirection into a buffer
+ failure to create proc directory or interface should not
  be fatal.
+ if PROC_FS not configured, let the stubs cause the necessary
  code elimination rather than using #ifdef
Signed-off-by: default avatarStephen Hemminger <shemminger@osdl.org>
Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent 39ca4394
......@@ -266,7 +266,6 @@ struct s_TxD {
typedef struct s_DevNet DEV_NET;
struct s_DevNet {
struct proc_dir_entry *proc;
int PortNr;
int NetNr;
int Mtu;
......@@ -395,7 +394,7 @@ struct s_AC {
SK_U32 PciDevId; /* pci device id */
struct SK_NET_DEVICE *dev[2]; /* pointer to device struct */
char Name[30]; /* driver name */
struct SK_NET_DEVICE *Next; /* link all devices (for clearing) */
int RxBufSize; /* length of receive buffers */
struct net_device_stats stats; /* linux 'netstat -i' statistics */
int Index; /* internal board index number */
......
......@@ -233,12 +233,27 @@ static int SkDrvDeInitAdapter(SK_AC *pAC, int devNbr);
* Extern Function Prototypes
*
******************************************************************************/
#ifdef CONFIG_PROC_FS
static const char SK_Root_Dir_entry[] = "sk98lin";
static const char SKRootName[] = "sk98lin";
static struct proc_dir_entry *pSkRootDir;
extern struct file_operations sk_proc_fops;
#endif
static inline void SkGeProcCreate(struct net_device *dev)
{
struct proc_dir_entry *pe;
if (pSkRootDir &&
(pe = create_proc_entry(dev->name, S_IRUGO, pSkRootDir))) {
pe->proc_fops = &sk_proc_fops;
pe->data = dev;
pe->owner = THIS_MODULE;
}
}
static inline void SkGeProcRemove(struct net_device *dev)
{
if (pSkRootDir)
remove_proc_entry(dev->name, pSkRootDir);
}
extern void SkDimEnableModerationIfNeeded(SK_AC *pAC);
extern void SkDimDisplayModerationSettings(SK_AC *pAC);
......@@ -252,7 +267,6 @@ static void DumpLong(char*, int);
#endif
/* global variables *********************************************************/
struct SK_NET_DEVICE *SkGeRootDev = NULL;
static SK_BOOL DoPrintInterfaceChange = SK_TRUE;
/* local variables **********************************************************/
......@@ -601,12 +615,6 @@ SK_BOOL DualNet;
return(-EAGAIN);
}
/*
* Register the device here
*/
pAC->Next = SkGeRootDev;
SkGeRootDev = dev;
return (0);
} /* SkGeBoardInit */
......@@ -4876,9 +4884,6 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
SK_AC *pAC;
DEV_NET *pNet = NULL;
struct net_device *dev = NULL;
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *pProcFile;
#endif
static int boards_found = 0;
int error = -ENODEV;
......@@ -4974,14 +4979,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6);
#ifdef CONFIG_PROC_FS
pProcFile = create_proc_entry(dev->name, S_IRUGO, pSkRootDir);
if (pProcFile) {
pProcFile->proc_fops = &sk_proc_fops;
pProcFile->data = dev;
pProcFile->owner = THIS_MODULE;
}
#endif
SkGeProcCreate(dev);
pNet->PortNr = 0;
pNet->NetNr = 0;
......@@ -5028,16 +5026,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
free_netdev(dev);
pAC->dev[1] = pAC->dev[0];
} else {
#ifdef CONFIG_PROC_FS
pProcFile = create_proc_entry(dev->name, S_IRUGO,
pSkRootDir);
if (pProcFile) {
pProcFile->proc_fops = &sk_proc_fops;
pProcFile->data = dev;
pProcFile->owner = THIS_MODULE;
}
#endif
SkGeProcCreate(dev);
memcpy(&dev->dev_addr,
&pAC->Addr.Net[1].CurrentMacAddress, 6);
......@@ -5075,17 +5064,12 @@ static void __devexit skge_remove_one(struct pci_dev *pdev)
struct net_device *dev = pci_get_drvdata(pdev);
DEV_NET *pNet = (DEV_NET *) dev->priv;
SK_AC *pAC = pNet->pAC;
int have_second_mac = 0;
if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 2)
have_second_mac = 1;
struct net_device *otherdev = pAC->dev[1];
remove_proc_entry(dev->name, pSkRootDir);
SkGeProcRemove(dev);
unregister_netdev(dev);
if (have_second_mac) {
remove_proc_entry(pAC->dev[1]->name, pSkRootDir);
unregister_netdev(pAC->dev[1]);
}
if (otherdev != dev)
SkGeProcRemove(otherdev);
SkGeYellowLED(pAC, pAC->IoBase, 0);
......@@ -5118,8 +5102,8 @@ static void __devexit skge_remove_one(struct pci_dev *pdev)
FreeResources(dev);
free_netdev(dev);
if (have_second_mac)
free_netdev(pAC->dev[1]);
if (otherdev != dev)
free_netdev(otherdev);
kfree(pAC);
}
......@@ -5152,34 +5136,21 @@ static int __init skge_init(void)
{
int error;
#ifdef CONFIG_PROC_FS
memcpy(&SK_Root_Dir_entry, BOOT_STRING, sizeof(SK_Root_Dir_entry) - 1);
pSkRootDir = proc_mkdir(SK_Root_Dir_entry, proc_net);
if (!pSkRootDir) {
printk(KERN_WARNING "Unable to create /proc/net/%s",
SK_Root_Dir_entry);
return -ENOMEM;
}
pSkRootDir->owner = THIS_MODULE;
#endif
error = pci_module_init(&skge_driver);
if (error) {
#ifdef CONFIG_PROC_FS
remove_proc_entry(pSkRootDir->name, proc_net);
#endif
}
pSkRootDir = proc_mkdir(SKRootName, proc_net);
if (pSkRootDir)
pSkRootDir->owner = THIS_MODULE;
error = pci_register_driver(&skge_driver);
if (error)
proc_net_remove(SKRootName);
return error;
}
static void __exit skge_exit(void)
{
pci_unregister_driver(&skge_driver);
#ifdef CONFIG_PROC_FS
remove_proc_entry(pSkRootDir->name, proc_net);
#endif
pci_unregister_driver(&skge_driver);
proc_net_remove(SKRootName);
}
module_init(skge_init);
......
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