2019-05-27 13:55:21 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2008-07-27 06:54:58 +07:00
|
|
|
/*
|
|
|
|
* Copyright 2008 by Karsten Keil <kkeil@novell.com>
|
|
|
|
*/
|
|
|
|
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2008-07-27 06:54:58 +07:00
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/stddef.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/mISDNif.h>
|
|
|
|
#include "core.h"
|
|
|
|
|
|
|
|
static u_int debug;
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Karsten Keil");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
module_param(debug, uint, S_IRUGO | S_IWUSR);
|
|
|
|
|
|
|
|
static u64 device_ids;
|
|
|
|
#define MAX_DEVICE_ID 63
|
|
|
|
|
|
|
|
static LIST_HEAD(Bprotocols);
|
2008-12-13 12:15:17 +07:00
|
|
|
static DEFINE_RWLOCK(bp_lock);
|
2008-07-27 06:54:58 +07:00
|
|
|
|
2008-08-16 05:09:24 +07:00
|
|
|
static void mISDN_dev_release(struct device *dev)
|
|
|
|
{
|
|
|
|
/* nothing to do: the device is part of its parent's data structure */
|
|
|
|
}
|
|
|
|
|
2013-07-25 05:05:12 +07:00
|
|
|
static ssize_t id_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2008-08-16 05:09:24 +07:00
|
|
|
{
|
|
|
|
struct mISDNdevice *mdev = dev_to_mISDN(dev);
|
|
|
|
|
|
|
|
if (!mdev)
|
|
|
|
return -ENODEV;
|
|
|
|
return sprintf(buf, "%d\n", mdev->id);
|
|
|
|
}
|
2013-07-25 05:05:12 +07:00
|
|
|
static DEVICE_ATTR_RO(id);
|
2008-08-16 05:09:24 +07:00
|
|
|
|
2013-07-25 05:05:12 +07:00
|
|
|
static ssize_t nrbchan_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2008-08-16 05:09:24 +07:00
|
|
|
{
|
|
|
|
struct mISDNdevice *mdev = dev_to_mISDN(dev);
|
|
|
|
|
|
|
|
if (!mdev)
|
|
|
|
return -ENODEV;
|
|
|
|
return sprintf(buf, "%d\n", mdev->nrbchan);
|
|
|
|
}
|
2013-07-25 05:05:12 +07:00
|
|
|
static DEVICE_ATTR_RO(nrbchan);
|
2008-08-16 05:09:24 +07:00
|
|
|
|
2013-07-25 05:05:12 +07:00
|
|
|
static ssize_t d_protocols_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2008-08-16 05:09:24 +07:00
|
|
|
{
|
|
|
|
struct mISDNdevice *mdev = dev_to_mISDN(dev);
|
|
|
|
|
|
|
|
if (!mdev)
|
|
|
|
return -ENODEV;
|
|
|
|
return sprintf(buf, "%d\n", mdev->Dprotocols);
|
|
|
|
}
|
2013-07-25 05:05:12 +07:00
|
|
|
static DEVICE_ATTR_RO(d_protocols);
|
2008-08-16 05:09:24 +07:00
|
|
|
|
2013-07-25 05:05:12 +07:00
|
|
|
static ssize_t b_protocols_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2008-08-16 05:09:24 +07:00
|
|
|
{
|
|
|
|
struct mISDNdevice *mdev = dev_to_mISDN(dev);
|
|
|
|
|
|
|
|
if (!mdev)
|
|
|
|
return -ENODEV;
|
|
|
|
return sprintf(buf, "%d\n", mdev->Bprotocols | get_all_Bprotocols());
|
|
|
|
}
|
2013-07-25 05:05:12 +07:00
|
|
|
static DEVICE_ATTR_RO(b_protocols);
|
2008-08-16 05:09:24 +07:00
|
|
|
|
2013-07-25 05:05:12 +07:00
|
|
|
static ssize_t protocol_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2008-08-16 05:09:24 +07:00
|
|
|
{
|
|
|
|
struct mISDNdevice *mdev = dev_to_mISDN(dev);
|
|
|
|
|
|
|
|
if (!mdev)
|
|
|
|
return -ENODEV;
|
|
|
|
return sprintf(buf, "%d\n", mdev->D.protocol);
|
|
|
|
}
|
2013-07-25 05:05:12 +07:00
|
|
|
static DEVICE_ATTR_RO(protocol);
|
2008-08-16 05:09:24 +07:00
|
|
|
|
2013-07-25 05:05:12 +07:00
|
|
|
static ssize_t name_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2008-08-16 05:09:24 +07:00
|
|
|
{
|
|
|
|
strcpy(buf, dev_name(dev));
|
|
|
|
return strlen(buf);
|
|
|
|
}
|
2013-07-25 05:05:12 +07:00
|
|
|
static DEVICE_ATTR_RO(name);
|
2008-08-16 05:09:24 +07:00
|
|
|
|
|
|
|
#if 0 /* hangs */
|
2013-07-25 05:05:12 +07:00
|
|
|
static ssize_t name_set(struct device *dev, struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
2008-08-16 05:09:24 +07:00
|
|
|
{
|
|
|
|
int err = 0;
|
|
|
|
char *out = kmalloc(count + 1, GFP_KERNEL);
|
|
|
|
|
|
|
|
if (!out)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
memcpy(out, buf, count);
|
|
|
|
if (count && out[count - 1] == '\n')
|
|
|
|
out[--count] = 0;
|
|
|
|
if (count)
|
|
|
|
err = device_rename(dev, out);
|
|
|
|
kfree(out);
|
|
|
|
|
|
|
|
return (err < 0) ? err : count;
|
|
|
|
}
|
2013-07-25 05:05:12 +07:00
|
|
|
static DEVICE_ATTR_RW(name);
|
2008-08-16 05:09:24 +07:00
|
|
|
#endif
|
|
|
|
|
2013-07-25 05:05:12 +07:00
|
|
|
static ssize_t channelmap_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2008-08-16 05:09:24 +07:00
|
|
|
{
|
|
|
|
struct mISDNdevice *mdev = dev_to_mISDN(dev);
|
|
|
|
char *bp = buf;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i <= mdev->nrbchan; i++)
|
|
|
|
*bp++ = test_channelmap(i, mdev->channelmap) ? '1' : '0';
|
|
|
|
|
|
|
|
return bp - buf;
|
|
|
|
}
|
2013-07-25 05:05:12 +07:00
|
|
|
static DEVICE_ATTR_RO(channelmap);
|
|
|
|
|
|
|
|
static struct attribute *mISDN_attrs[] = {
|
|
|
|
&dev_attr_id.attr,
|
|
|
|
&dev_attr_d_protocols.attr,
|
|
|
|
&dev_attr_b_protocols.attr,
|
|
|
|
&dev_attr_protocol.attr,
|
|
|
|
&dev_attr_channelmap.attr,
|
|
|
|
&dev_attr_nrbchan.attr,
|
|
|
|
&dev_attr_name.attr,
|
|
|
|
NULL,
|
2008-08-16 05:09:24 +07:00
|
|
|
};
|
2013-07-25 05:05:12 +07:00
|
|
|
ATTRIBUTE_GROUPS(mISDN);
|
2008-08-16 05:09:24 +07:00
|
|
|
|
|
|
|
static int mISDN_uevent(struct device *dev, struct kobj_uevent_env *env)
|
|
|
|
{
|
|
|
|
struct mISDNdevice *mdev = dev_to_mISDN(dev);
|
|
|
|
|
|
|
|
if (!mdev)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (add_uevent_var(env, "nchans=%d", mdev->nrbchan))
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mISDN_class_release(struct class *cls)
|
|
|
|
{
|
|
|
|
/* do nothing, it's static */
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct class mISDN_class = {
|
|
|
|
.name = "mISDN",
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.dev_uevent = mISDN_uevent,
|
2013-07-25 05:05:12 +07:00
|
|
|
.dev_groups = mISDN_groups,
|
2008-08-16 05:09:24 +07:00
|
|
|
.dev_release = mISDN_dev_release,
|
|
|
|
.class_release = mISDN_class_release,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2013-02-02 02:40:17 +07:00
|
|
|
_get_mdevice(struct device *dev, const void *id)
|
2008-08-16 05:09:24 +07:00
|
|
|
{
|
|
|
|
struct mISDNdevice *mdev = dev_to_mISDN(dev);
|
|
|
|
|
|
|
|
if (!mdev)
|
|
|
|
return 0;
|
2013-02-02 02:40:17 +07:00
|
|
|
if (mdev->id != *(const u_int *)id)
|
2008-08-16 05:09:24 +07:00
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-07-27 06:54:58 +07:00
|
|
|
struct mISDNdevice
|
|
|
|
*get_mdevice(u_int id)
|
|
|
|
{
|
2008-08-16 05:09:24 +07:00
|
|
|
return dev_to_mISDN(class_find_device(&mISDN_class, NULL, &id,
|
2012-02-20 10:52:38 +07:00
|
|
|
_get_mdevice));
|
2008-08-16 05:09:24 +07:00
|
|
|
}
|
2008-07-27 06:54:58 +07:00
|
|
|
|
2008-08-16 05:09:24 +07:00
|
|
|
static int
|
|
|
|
_get_mdevice_count(struct device *dev, void *cnt)
|
|
|
|
{
|
|
|
|
*(int *)cnt += 1;
|
|
|
|
return 0;
|
2008-07-27 06:54:58 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
get_mdevice_count(void)
|
|
|
|
{
|
2008-08-16 05:09:24 +07:00
|
|
|
int cnt = 0;
|
2008-07-27 06:54:58 +07:00
|
|
|
|
2008-08-16 05:09:24 +07:00
|
|
|
class_for_each_device(&mISDN_class, NULL, &cnt, _get_mdevice_count);
|
2008-07-27 06:54:58 +07:00
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
get_free_devid(void)
|
|
|
|
{
|
|
|
|
u_int i;
|
|
|
|
|
|
|
|
for (i = 0; i <= MAX_DEVICE_ID; i++)
|
|
|
|
if (!test_and_set_bit(i, (u_long *)&device_ids))
|
2008-08-16 05:09:24 +07:00
|
|
|
break;
|
|
|
|
if (i > MAX_DEVICE_ID)
|
2009-05-22 18:04:53 +07:00
|
|
|
return -EBUSY;
|
2008-08-16 05:09:24 +07:00
|
|
|
return i;
|
2008-07-27 06:54:58 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2008-08-16 05:09:24 +07:00
|
|
|
mISDN_register_device(struct mISDNdevice *dev,
|
2012-02-20 10:52:38 +07:00
|
|
|
struct device *parent, char *name)
|
2008-07-27 06:54:58 +07:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
2009-05-22 18:04:53 +07:00
|
|
|
err = get_free_devid();
|
|
|
|
if (err < 0)
|
2008-08-16 05:09:24 +07:00
|
|
|
goto error1;
|
2009-05-22 18:04:53 +07:00
|
|
|
dev->id = err;
|
2008-08-16 05:09:24 +07:00
|
|
|
|
|
|
|
device_initialize(&dev->dev);
|
2008-07-27 06:54:58 +07:00
|
|
|
if (name && name[0])
|
2008-08-16 05:04:33 +07:00
|
|
|
dev_set_name(&dev->dev, "%s", name);
|
2008-07-27 06:54:58 +07:00
|
|
|
else
|
2008-08-16 05:04:33 +07:00
|
|
|
dev_set_name(&dev->dev, "mISDN%d", dev->id);
|
2008-07-27 06:54:58 +07:00
|
|
|
if (debug & DEBUG_CORE)
|
|
|
|
printk(KERN_DEBUG "mISDN_register %s %d\n",
|
2012-02-20 10:52:38 +07:00
|
|
|
dev_name(&dev->dev), dev->id);
|
2008-07-27 06:54:58 +07:00
|
|
|
err = create_stack(dev);
|
|
|
|
if (err)
|
2008-08-16 05:09:24 +07:00
|
|
|
goto error1;
|
|
|
|
|
|
|
|
dev->dev.class = &mISDN_class;
|
|
|
|
dev->dev.platform_data = dev;
|
|
|
|
dev->dev.parent = parent;
|
|
|
|
dev_set_drvdata(&dev->dev, dev);
|
|
|
|
|
|
|
|
err = device_add(&dev->dev);
|
|
|
|
if (err)
|
|
|
|
goto error3;
|
2008-07-27 06:54:58 +07:00
|
|
|
return 0;
|
2008-08-16 05:09:24 +07:00
|
|
|
|
|
|
|
error3:
|
|
|
|
delete_stack(dev);
|
|
|
|
return err;
|
|
|
|
error1:
|
|
|
|
return err;
|
|
|
|
|
2008-07-27 06:54:58 +07:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(mISDN_register_device);
|
|
|
|
|
|
|
|
void
|
|
|
|
mISDN_unregister_device(struct mISDNdevice *dev) {
|
|
|
|
if (debug & DEBUG_CORE)
|
|
|
|
printk(KERN_DEBUG "mISDN_unregister %s %d\n",
|
2012-02-20 10:52:38 +07:00
|
|
|
dev_name(&dev->dev), dev->id);
|
2008-08-16 05:09:24 +07:00
|
|
|
/* sysfs_remove_link(&dev->dev.kobj, "device"); */
|
|
|
|
device_del(&dev->dev);
|
|
|
|
dev_set_drvdata(&dev->dev, NULL);
|
|
|
|
|
2008-07-27 06:54:58 +07:00
|
|
|
test_and_clear_bit(dev->id, (u_long *)&device_ids);
|
|
|
|
delete_stack(dev);
|
2008-08-16 05:09:24 +07:00
|
|
|
put_device(&dev->dev);
|
2008-07-27 06:54:58 +07:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(mISDN_unregister_device);
|
|
|
|
|
|
|
|
u_int
|
|
|
|
get_all_Bprotocols(void)
|
|
|
|
{
|
|
|
|
struct Bprotocol *bp;
|
|
|
|
u_int m = 0;
|
|
|
|
|
|
|
|
read_lock(&bp_lock);
|
|
|
|
list_for_each_entry(bp, &Bprotocols, list)
|
|
|
|
m |= bp->Bprotocols;
|
|
|
|
read_unlock(&bp_lock);
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Bprotocol *
|
|
|
|
get_Bprotocol4mask(u_int m)
|
|
|
|
{
|
|
|
|
struct Bprotocol *bp;
|
|
|
|
|
|
|
|
read_lock(&bp_lock);
|
|
|
|
list_for_each_entry(bp, &Bprotocols, list)
|
|
|
|
if (bp->Bprotocols & m) {
|
|
|
|
read_unlock(&bp_lock);
|
|
|
|
return bp;
|
|
|
|
}
|
|
|
|
read_unlock(&bp_lock);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Bprotocol *
|
|
|
|
get_Bprotocol4id(u_int id)
|
|
|
|
{
|
|
|
|
u_int m;
|
|
|
|
|
|
|
|
if (id < ISDN_P_B_START || id > 63) {
|
|
|
|
printk(KERN_WARNING "%s id not in range %d\n",
|
2012-02-20 10:52:38 +07:00
|
|
|
__func__, id);
|
2008-07-27 06:54:58 +07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
m = 1 << (id & ISDN_P_B_MASK);
|
|
|
|
return get_Bprotocol4mask(m);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
mISDN_register_Bprotocol(struct Bprotocol *bp)
|
|
|
|
{
|
|
|
|
u_long flags;
|
|
|
|
struct Bprotocol *old;
|
|
|
|
|
|
|
|
if (debug & DEBUG_CORE)
|
|
|
|
printk(KERN_DEBUG "%s: %s/%x\n", __func__,
|
2012-02-20 10:52:38 +07:00
|
|
|
bp->name, bp->Bprotocols);
|
2008-07-27 06:54:58 +07:00
|
|
|
old = get_Bprotocol4mask(bp->Bprotocols);
|
|
|
|
if (old) {
|
|
|
|
printk(KERN_WARNING
|
2012-02-20 10:52:38 +07:00
|
|
|
"register duplicate protocol old %s/%x new %s/%x\n",
|
|
|
|
old->name, old->Bprotocols, bp->name, bp->Bprotocols);
|
2008-07-27 06:54:58 +07:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
write_lock_irqsave(&bp_lock, flags);
|
|
|
|
list_add_tail(&bp->list, &Bprotocols);
|
|
|
|
write_unlock_irqrestore(&bp_lock, flags);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(mISDN_register_Bprotocol);
|
|
|
|
|
|
|
|
void
|
|
|
|
mISDN_unregister_Bprotocol(struct Bprotocol *bp)
|
|
|
|
{
|
|
|
|
u_long flags;
|
|
|
|
|
|
|
|
if (debug & DEBUG_CORE)
|
|
|
|
printk(KERN_DEBUG "%s: %s/%x\n", __func__, bp->name,
|
2012-02-20 10:52:38 +07:00
|
|
|
bp->Bprotocols);
|
2008-07-27 06:54:58 +07:00
|
|
|
write_lock_irqsave(&bp_lock, flags);
|
|
|
|
list_del(&bp->list);
|
|
|
|
write_unlock_irqrestore(&bp_lock, flags);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(mISDN_unregister_Bprotocol);
|
|
|
|
|
2012-05-04 11:15:35 +07:00
|
|
|
static const char *msg_no_channel = "<no channel>";
|
|
|
|
static const char *msg_no_stack = "<no stack>";
|
|
|
|
static const char *msg_no_stackdev = "<no stack device>";
|
|
|
|
|
|
|
|
const char *mISDNDevName4ch(struct mISDNchannel *ch)
|
|
|
|
{
|
|
|
|
if (!ch)
|
|
|
|
return msg_no_channel;
|
|
|
|
if (!ch->st)
|
|
|
|
return msg_no_stack;
|
|
|
|
if (!ch->st->dev)
|
|
|
|
return msg_no_stackdev;
|
|
|
|
return dev_name(&ch->st->dev->dev);
|
|
|
|
};
|
|
|
|
EXPORT_SYMBOL(mISDNDevName4ch);
|
|
|
|
|
2008-12-13 12:15:17 +07:00
|
|
|
static int
|
2008-07-27 06:54:58 +07:00
|
|
|
mISDNInit(void)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
printk(KERN_INFO "Modular ISDN core version %d.%d.%d\n",
|
2012-02-20 10:52:38 +07:00
|
|
|
MISDN_MAJOR_VERSION, MISDN_MINOR_VERSION, MISDN_RELEASE);
|
2008-09-06 14:03:46 +07:00
|
|
|
mISDN_init_clock(&debug);
|
2008-07-27 06:54:58 +07:00
|
|
|
mISDN_initstack(&debug);
|
2008-08-16 05:09:24 +07:00
|
|
|
err = class_register(&mISDN_class);
|
|
|
|
if (err)
|
|
|
|
goto error1;
|
2008-07-27 06:54:58 +07:00
|
|
|
err = mISDN_inittimer(&debug);
|
|
|
|
if (err)
|
2008-08-16 05:09:24 +07:00
|
|
|
goto error2;
|
2008-07-27 06:54:58 +07:00
|
|
|
err = l1_init(&debug);
|
2008-08-16 05:09:24 +07:00
|
|
|
if (err)
|
|
|
|
goto error3;
|
2008-07-27 06:54:58 +07:00
|
|
|
err = Isdnl2_Init(&debug);
|
2008-08-16 05:09:24 +07:00
|
|
|
if (err)
|
|
|
|
goto error4;
|
2008-07-27 06:54:58 +07:00
|
|
|
err = misdn_sock_init(&debug);
|
2008-08-16 05:09:24 +07:00
|
|
|
if (err)
|
|
|
|
goto error5;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
error5:
|
|
|
|
Isdnl2_cleanup();
|
|
|
|
error4:
|
|
|
|
l1_cleanup();
|
|
|
|
error3:
|
|
|
|
mISDN_timer_cleanup();
|
|
|
|
error2:
|
|
|
|
class_unregister(&mISDN_class);
|
|
|
|
error1:
|
2008-07-27 06:54:58 +07:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2008-12-13 12:15:17 +07:00
|
|
|
static void mISDN_cleanup(void)
|
2008-07-27 06:54:58 +07:00
|
|
|
{
|
|
|
|
misdn_sock_cleanup();
|
|
|
|
Isdnl2_cleanup();
|
2008-08-16 05:09:24 +07:00
|
|
|
l1_cleanup();
|
|
|
|
mISDN_timer_cleanup();
|
|
|
|
class_unregister(&mISDN_class);
|
2008-07-27 06:54:58 +07:00
|
|
|
|
|
|
|
printk(KERN_DEBUG "mISDNcore unloaded\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(mISDNInit);
|
|
|
|
module_exit(mISDN_cleanup);
|