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 { ...@@ -266,7 +266,6 @@ struct s_TxD {
typedef struct s_DevNet DEV_NET; typedef struct s_DevNet DEV_NET;
struct s_DevNet { struct s_DevNet {
struct proc_dir_entry *proc;
int PortNr; int PortNr;
int NetNr; int NetNr;
int Mtu; int Mtu;
...@@ -395,7 +394,7 @@ struct s_AC { ...@@ -395,7 +394,7 @@ struct s_AC {
SK_U32 PciDevId; /* pci device id */ SK_U32 PciDevId; /* pci device id */
struct SK_NET_DEVICE *dev[2]; /* pointer to device struct */ struct SK_NET_DEVICE *dev[2]; /* pointer to device struct */
char Name[30]; /* driver name */ char Name[30]; /* driver name */
struct SK_NET_DEVICE *Next; /* link all devices (for clearing) */
int RxBufSize; /* length of receive buffers */ int RxBufSize; /* length of receive buffers */
struct net_device_stats stats; /* linux 'netstat -i' statistics */ struct net_device_stats stats; /* linux 'netstat -i' statistics */
int Index; /* internal board index number */ int Index; /* internal board index number */
......
...@@ -233,12 +233,27 @@ static int SkDrvDeInitAdapter(SK_AC *pAC, int devNbr); ...@@ -233,12 +233,27 @@ static int SkDrvDeInitAdapter(SK_AC *pAC, int devNbr);
* Extern Function Prototypes * Extern Function Prototypes
* *
******************************************************************************/ ******************************************************************************/
static const char SKRootName[] = "sk98lin";
#ifdef CONFIG_PROC_FS
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 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 SkDimEnableModerationIfNeeded(SK_AC *pAC);
extern void SkDimDisplayModerationSettings(SK_AC *pAC); extern void SkDimDisplayModerationSettings(SK_AC *pAC);
...@@ -252,7 +267,6 @@ static void DumpLong(char*, int); ...@@ -252,7 +267,6 @@ static void DumpLong(char*, int);
#endif #endif
/* global variables *********************************************************/ /* global variables *********************************************************/
struct SK_NET_DEVICE *SkGeRootDev = NULL;
static SK_BOOL DoPrintInterfaceChange = SK_TRUE; static SK_BOOL DoPrintInterfaceChange = SK_TRUE;
/* local variables **********************************************************/ /* local variables **********************************************************/
...@@ -601,12 +615,6 @@ SK_BOOL DualNet; ...@@ -601,12 +615,6 @@ SK_BOOL DualNet;
return(-EAGAIN); return(-EAGAIN);
} }
/*
* Register the device here
*/
pAC->Next = SkGeRootDev;
SkGeRootDev = dev;
return (0); return (0);
} /* SkGeBoardInit */ } /* SkGeBoardInit */
...@@ -4876,9 +4884,6 @@ static int __devinit skge_probe_one(struct pci_dev *pdev, ...@@ -4876,9 +4884,6 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
SK_AC *pAC; SK_AC *pAC;
DEV_NET *pNet = NULL; DEV_NET *pNet = NULL;
struct net_device *dev = NULL; struct net_device *dev = NULL;
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *pProcFile;
#endif
static int boards_found = 0; static int boards_found = 0;
int error = -ENODEV; int error = -ENODEV;
...@@ -4974,14 +4979,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev, ...@@ -4974,14 +4979,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6); memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6);
#ifdef CONFIG_PROC_FS SkGeProcCreate(dev);
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
pNet->PortNr = 0; pNet->PortNr = 0;
pNet->NetNr = 0; pNet->NetNr = 0;
...@@ -5028,16 +5026,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev, ...@@ -5028,16 +5026,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
free_netdev(dev); free_netdev(dev);
pAC->dev[1] = pAC->dev[0]; pAC->dev[1] = pAC->dev[0];
} else { } else {
#ifdef CONFIG_PROC_FS SkGeProcCreate(dev);
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
memcpy(&dev->dev_addr, memcpy(&dev->dev_addr,
&pAC->Addr.Net[1].CurrentMacAddress, 6); &pAC->Addr.Net[1].CurrentMacAddress, 6);
...@@ -5075,17 +5064,12 @@ static void __devexit skge_remove_one(struct pci_dev *pdev) ...@@ -5075,17 +5064,12 @@ static void __devexit skge_remove_one(struct pci_dev *pdev)
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = pci_get_drvdata(pdev);
DEV_NET *pNet = (DEV_NET *) dev->priv; DEV_NET *pNet = (DEV_NET *) dev->priv;
SK_AC *pAC = pNet->pAC; SK_AC *pAC = pNet->pAC;
int have_second_mac = 0; struct net_device *otherdev = pAC->dev[1];
if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 2)
have_second_mac = 1;
remove_proc_entry(dev->name, pSkRootDir); SkGeProcRemove(dev);
unregister_netdev(dev); unregister_netdev(dev);
if (have_second_mac) { if (otherdev != dev)
remove_proc_entry(pAC->dev[1]->name, pSkRootDir); SkGeProcRemove(otherdev);
unregister_netdev(pAC->dev[1]);
}
SkGeYellowLED(pAC, pAC->IoBase, 0); SkGeYellowLED(pAC, pAC->IoBase, 0);
...@@ -5118,8 +5102,8 @@ static void __devexit skge_remove_one(struct pci_dev *pdev) ...@@ -5118,8 +5102,8 @@ static void __devexit skge_remove_one(struct pci_dev *pdev)
FreeResources(dev); FreeResources(dev);
free_netdev(dev); free_netdev(dev);
if (have_second_mac) if (otherdev != dev)
free_netdev(pAC->dev[1]); free_netdev(otherdev);
kfree(pAC); kfree(pAC);
} }
...@@ -5152,34 +5136,21 @@ static int __init skge_init(void) ...@@ -5152,34 +5136,21 @@ static int __init skge_init(void)
{ {
int error; int error;
#ifdef CONFIG_PROC_FS pSkRootDir = proc_mkdir(SKRootName, proc_net);
memcpy(&SK_Root_Dir_entry, BOOT_STRING, sizeof(SK_Root_Dir_entry) - 1); if (pSkRootDir)
pSkRootDir->owner = THIS_MODULE;
pSkRootDir = proc_mkdir(SK_Root_Dir_entry, proc_net);
if (!pSkRootDir) { error = pci_register_driver(&skge_driver);
printk(KERN_WARNING "Unable to create /proc/net/%s", if (error)
SK_Root_Dir_entry); proc_net_remove(SKRootName);
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
}
return error; return error;
} }
static void __exit skge_exit(void) static void __exit skge_exit(void)
{ {
pci_unregister_driver(&skge_driver); pci_unregister_driver(&skge_driver);
#ifdef CONFIG_PROC_FS proc_net_remove(SKRootName);
remove_proc_entry(pSkRootDir->name, proc_net);
#endif
} }
module_init(skge_init); 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