Commit 8fac33ce authored by Matthew Wilcox's avatar Matthew Wilcox Committed by David S. Miller

[DLCI]: Use module_init and fix ioctl handling.

parent 7d55f076
...@@ -16,7 +16,6 @@ extern int dmascc_init(void); ...@@ -16,7 +16,6 @@ extern int dmascc_init(void);
extern int arcnet_init(void); extern int arcnet_init(void);
extern int scc_enet_init(void); extern int scc_enet_init(void);
extern int fec_enet_init(void); extern int fec_enet_init(void);
extern int dlci_setup(void);
extern int sdla_setup(void); extern int sdla_setup(void);
extern int sdla_c_setup(void); extern int sdla_c_setup(void);
extern int comx_init(void); extern int comx_init(void);
...@@ -51,9 +50,6 @@ static struct net_probe pci_probes[] __initdata = { ...@@ -51,9 +50,6 @@ static struct net_probe pci_probes[] __initdata = {
#if defined(CONFIG_DMASCC) #if defined(CONFIG_DMASCC)
{dmascc_init, 0}, {dmascc_init, 0},
#endif #endif
#if defined(CONFIG_DLCI)
{dlci_setup, 0},
#endif
#if defined(CONFIG_SDLA) #if defined(CONFIG_SDLA)
{sdla_c_setup, 0}, {sdla_c_setup, 0},
#endif #endif
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/in.h> #include <linux/in.h>
#include <linux/init.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -577,9 +578,10 @@ int dlci_init(struct net_device *dev) ...@@ -577,9 +578,10 @@ int dlci_init(struct net_device *dev)
return(0); return(0);
} }
int __init dlci_setup(void) int __init init_dlci(void)
{ {
int i; int i;
dlci_ioctl_set(dlci_ioctl);
printk("%s.\n", version); printk("%s.\n", version);
...@@ -589,25 +591,16 @@ int __init dlci_setup(void) ...@@ -589,25 +591,16 @@ int __init dlci_setup(void)
for(i=0;i<sizeof(basename) / sizeof(char *);i++) for(i=0;i<sizeof(basename) / sizeof(char *);i++)
basename[i] = NULL; basename[i] = NULL;
return(0); return 0;
} }
#ifdef MODULE void __exit dlci_exit(void)
extern int (*dlci_ioctl_hook)(unsigned int, void *);
int init_module(void)
{ {
dlci_ioctl_hook = dlci_ioctl; dlci_ioctl_set(NULL);
return(dlci_setup());
} }
void cleanup_module(void) module_init(init_dlci);
{ module_exit(dlci_exit);
dlci_ioctl_hook = NULL;
}
#endif /* MODULE */
MODULE_AUTHOR("Mike McLagan"); MODULE_AUTHOR("Mike McLagan");
MODULE_DESCRIPTION("Frame Relay DLCI layer"); MODULE_DESCRIPTION("Frame Relay DLCI layer");
......
...@@ -192,7 +192,7 @@ struct frad_local ...@@ -192,7 +192,7 @@ struct frad_local
int register_frad(const char *name); int register_frad(const char *name);
int unregister_frad(const char *name); int unregister_frad(const char *name);
extern int (*dlci_ioctl_hook)(unsigned int, void *); extern void dlci_ioctl_set(int (*hook)(unsigned int, void *));
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
...@@ -228,13 +228,11 @@ EXPORT_SYMBOL(destroy_EII_client); ...@@ -228,13 +228,11 @@ EXPORT_SYMBOL(destroy_EII_client);
#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
EXPORT_SYMBOL(dev_change_flags); EXPORT_SYMBOL(dev_change_flags);
#endif #endif
EXPORT_SYMBOL(vlan_ioctl_set);
EXPORT_SYMBOL(scm_detach_fds); EXPORT_SYMBOL(scm_detach_fds);
#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
EXPORT_SYMBOL(br_handle_frame_hook); EXPORT_SYMBOL(br_handle_frame_hook);
EXPORT_SYMBOL(brioctl_set);
#endif #endif
#ifdef CONFIG_NET_DIVERT #ifdef CONFIG_NET_DIVERT
...@@ -285,11 +283,6 @@ EXPORT_SYMBOL(unregister_inetaddr_notifier); ...@@ -285,11 +283,6 @@ EXPORT_SYMBOL(unregister_inetaddr_notifier);
/* needed for ip_gre -cw */ /* needed for ip_gre -cw */
EXPORT_SYMBOL(ip_statistics); EXPORT_SYMBOL(ip_statistics);
#ifdef CONFIG_DLCI_MODULE
extern int (*dlci_ioctl_hook)(unsigned int, void *);
EXPORT_SYMBOL(dlci_ioctl_hook);
#endif
EXPORT_SYMBOL(xfrm_user_policy); EXPORT_SYMBOL(xfrm_user_policy);
EXPORT_SYMBOL(km_waitq); EXPORT_SYMBOL(km_waitq);
EXPORT_SYMBOL(km_new_mapping); EXPORT_SYMBOL(km_new_mapping);
......
...@@ -731,6 +731,7 @@ void brioctl_set(int (*hook)(unsigned long)) ...@@ -731,6 +731,7 @@ void brioctl_set(int (*hook)(unsigned long))
br_ioctl_hook = hook; br_ioctl_hook = hook;
up(&br_ioctl_mutex); up(&br_ioctl_mutex);
} }
EXPORT_SYMBOL(brioctl_set);
static DECLARE_MUTEX(vlan_ioctl_mutex); static DECLARE_MUTEX(vlan_ioctl_mutex);
static int (*vlan_ioctl_hook)(unsigned long arg); static int (*vlan_ioctl_hook)(unsigned long arg);
...@@ -741,12 +742,18 @@ void vlan_ioctl_set(int (*hook)(unsigned long)) ...@@ -741,12 +742,18 @@ void vlan_ioctl_set(int (*hook)(unsigned long))
vlan_ioctl_hook = hook; vlan_ioctl_hook = hook;
up(&vlan_ioctl_mutex); up(&vlan_ioctl_mutex);
} }
EXPORT_SYMBOL(vlan_ioctl_set);
#ifdef CONFIG_DLCI static DECLARE_MUTEX(dlci_ioctl_mutex);
extern int dlci_ioctl(unsigned int, void *); static int (*dlci_ioctl_hook)(unsigned int, void *);
#else
int (*dlci_ioctl_hook)(unsigned int, void *); void dlci_ioctl_set(int (*hook)(unsigned int, void *))
#endif {
down(&dlci_ioctl_mutex);
dlci_ioctl_hook = hook;
up(&dlci_ioctl_mutex);
}
EXPORT_SYMBOL(dlci_ioctl_set);
/* /*
* With an ioctl, arg may well be a user mode pointer, but we don't know * With an ioctl, arg may well be a user mode pointer, but we don't know
...@@ -820,24 +827,16 @@ static int sock_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -820,24 +827,16 @@ static int sock_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
break; break;
case SIOCADDDLCI: case SIOCADDDLCI:
case SIOCDELDLCI: case SIOCDELDLCI:
/* Convert this to always call through a hook */
#ifdef CONFIG_DLCI
lock_kernel();
err = dlci_ioctl(cmd, (void *)arg);
unlock_kernel();
break;
#else
err = -ENOPKG; err = -ENOPKG;
#ifdef CONFIG_KMOD #ifdef CONFIG_KMOD
if (!dlci_ioctl_hook) if (!dlci_ioctl_hook)
request_module("dlci"); request_module("dlci");
#endif #endif
if (dlci_ioctl_hook) { if (dlci_ioctl_hook) {
lock_kernel(); down(&dlci_ioctl_mutex);
err = dlci_ioctl_hook(cmd, (void *)arg); err = dlci_ioctl_hook(cmd, (void *)arg);
unlock_kernel(); up(&dlci_ioctl_mutex);
} }
#endif
break; break;
default: default:
err = sock->ops->ioctl(sock, cmd, arg); err = sock->ops->ioctl(sock, cmd, arg);
......
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