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