Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2008 by Karsten Keil <kkeil@novell.com> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 as |
| 6 | * published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | */ |
| 14 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 15 | #include <linux/slab.h> |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 16 | #include <linux/types.h> |
| 17 | #include <linux/stddef.h> |
| 18 | #include <linux/module.h> |
| 19 | #include <linux/spinlock.h> |
| 20 | #include <linux/mISDNif.h> |
| 21 | #include "core.h" |
| 22 | |
| 23 | static u_int debug; |
| 24 | |
| 25 | MODULE_AUTHOR("Karsten Keil"); |
| 26 | MODULE_LICENSE("GPL"); |
| 27 | module_param(debug, uint, S_IRUGO | S_IWUSR); |
| 28 | |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 29 | static u64 device_ids; |
| 30 | #define MAX_DEVICE_ID 63 |
| 31 | |
| 32 | static LIST_HEAD(Bprotocols); |
Hannes Eder | 5b83435 | 2008-12-12 21:15:17 -0800 | [diff] [blame] | 33 | static DEFINE_RWLOCK(bp_lock); |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 34 | |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 35 | static void mISDN_dev_release(struct device *dev) |
| 36 | { |
| 37 | /* nothing to do: the device is part of its parent's data structure */ |
| 38 | } |
| 39 | |
| 40 | static ssize_t _show_id(struct device *dev, |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 41 | struct device_attribute *attr, char *buf) |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 42 | { |
| 43 | struct mISDNdevice *mdev = dev_to_mISDN(dev); |
| 44 | |
| 45 | if (!mdev) |
| 46 | return -ENODEV; |
| 47 | return sprintf(buf, "%d\n", mdev->id); |
| 48 | } |
| 49 | |
| 50 | static ssize_t _show_nrbchan(struct device *dev, |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 51 | struct device_attribute *attr, char *buf) |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 52 | { |
| 53 | struct mISDNdevice *mdev = dev_to_mISDN(dev); |
| 54 | |
| 55 | if (!mdev) |
| 56 | return -ENODEV; |
| 57 | return sprintf(buf, "%d\n", mdev->nrbchan); |
| 58 | } |
| 59 | |
| 60 | static ssize_t _show_d_protocols(struct device *dev, |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 61 | struct device_attribute *attr, char *buf) |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 62 | { |
| 63 | struct mISDNdevice *mdev = dev_to_mISDN(dev); |
| 64 | |
| 65 | if (!mdev) |
| 66 | return -ENODEV; |
| 67 | return sprintf(buf, "%d\n", mdev->Dprotocols); |
| 68 | } |
| 69 | |
| 70 | static ssize_t _show_b_protocols(struct device *dev, |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 71 | struct device_attribute *attr, char *buf) |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 72 | { |
| 73 | struct mISDNdevice *mdev = dev_to_mISDN(dev); |
| 74 | |
| 75 | if (!mdev) |
| 76 | return -ENODEV; |
| 77 | return sprintf(buf, "%d\n", mdev->Bprotocols | get_all_Bprotocols()); |
| 78 | } |
| 79 | |
| 80 | static ssize_t _show_protocol(struct device *dev, |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 81 | struct device_attribute *attr, char *buf) |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 82 | { |
| 83 | struct mISDNdevice *mdev = dev_to_mISDN(dev); |
| 84 | |
| 85 | if (!mdev) |
| 86 | return -ENODEV; |
| 87 | return sprintf(buf, "%d\n", mdev->D.protocol); |
| 88 | } |
| 89 | |
| 90 | static ssize_t _show_name(struct device *dev, |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 91 | struct device_attribute *attr, char *buf) |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 92 | { |
| 93 | strcpy(buf, dev_name(dev)); |
| 94 | return strlen(buf); |
| 95 | } |
| 96 | |
| 97 | #if 0 /* hangs */ |
| 98 | static ssize_t _set_name(struct device *dev, struct device_attribute *attr, |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 99 | const char *buf, size_t count) |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 100 | { |
| 101 | int err = 0; |
| 102 | char *out = kmalloc(count + 1, GFP_KERNEL); |
| 103 | |
| 104 | if (!out) |
| 105 | return -ENOMEM; |
| 106 | |
| 107 | memcpy(out, buf, count); |
| 108 | if (count && out[count - 1] == '\n') |
| 109 | out[--count] = 0; |
| 110 | if (count) |
| 111 | err = device_rename(dev, out); |
| 112 | kfree(out); |
| 113 | |
| 114 | return (err < 0) ? err : count; |
| 115 | } |
| 116 | #endif |
| 117 | |
| 118 | static ssize_t _show_channelmap(struct device *dev, |
| 119 | struct device_attribute *attr, char *buf) |
| 120 | { |
| 121 | struct mISDNdevice *mdev = dev_to_mISDN(dev); |
| 122 | char *bp = buf; |
| 123 | int i; |
| 124 | |
| 125 | for (i = 0; i <= mdev->nrbchan; i++) |
| 126 | *bp++ = test_channelmap(i, mdev->channelmap) ? '1' : '0'; |
| 127 | |
| 128 | return bp - buf; |
| 129 | } |
| 130 | |
| 131 | static struct device_attribute mISDN_dev_attrs[] = { |
| 132 | __ATTR(id, S_IRUGO, _show_id, NULL), |
| 133 | __ATTR(d_protocols, S_IRUGO, _show_d_protocols, NULL), |
| 134 | __ATTR(b_protocols, S_IRUGO, _show_b_protocols, NULL), |
| 135 | __ATTR(protocol, S_IRUGO, _show_protocol, NULL), |
| 136 | __ATTR(channelmap, S_IRUGO, _show_channelmap, NULL), |
| 137 | __ATTR(nrbchan, S_IRUGO, _show_nrbchan, NULL), |
| 138 | __ATTR(name, S_IRUGO, _show_name, NULL), |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 139 | /* __ATTR(name, S_IRUGO | S_IWUSR, _show_name, _set_name), */ |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 140 | {} |
| 141 | }; |
| 142 | |
| 143 | #ifdef CONFIG_HOTPLUG |
| 144 | static int mISDN_uevent(struct device *dev, struct kobj_uevent_env *env) |
| 145 | { |
| 146 | struct mISDNdevice *mdev = dev_to_mISDN(dev); |
| 147 | |
| 148 | if (!mdev) |
| 149 | return 0; |
| 150 | |
| 151 | if (add_uevent_var(env, "nchans=%d", mdev->nrbchan)) |
| 152 | return -ENOMEM; |
| 153 | |
| 154 | return 0; |
| 155 | } |
| 156 | #endif |
| 157 | |
| 158 | static void mISDN_class_release(struct class *cls) |
| 159 | { |
| 160 | /* do nothing, it's static */ |
| 161 | } |
| 162 | |
| 163 | static struct class mISDN_class = { |
| 164 | .name = "mISDN", |
| 165 | .owner = THIS_MODULE, |
| 166 | #ifdef CONFIG_HOTPLUG |
| 167 | .dev_uevent = mISDN_uevent, |
| 168 | #endif |
| 169 | .dev_attrs = mISDN_dev_attrs, |
| 170 | .dev_release = mISDN_dev_release, |
| 171 | .class_release = mISDN_class_release, |
| 172 | }; |
| 173 | |
| 174 | static int |
| 175 | _get_mdevice(struct device *dev, void *id) |
| 176 | { |
| 177 | struct mISDNdevice *mdev = dev_to_mISDN(dev); |
| 178 | |
| 179 | if (!mdev) |
| 180 | return 0; |
| 181 | if (mdev->id != *(u_int *)id) |
| 182 | return 0; |
| 183 | return 1; |
| 184 | } |
| 185 | |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 186 | struct mISDNdevice |
| 187 | *get_mdevice(u_int id) |
| 188 | { |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 189 | return dev_to_mISDN(class_find_device(&mISDN_class, NULL, &id, |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 190 | _get_mdevice)); |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 191 | } |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 192 | |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 193 | static int |
| 194 | _get_mdevice_count(struct device *dev, void *cnt) |
| 195 | { |
| 196 | *(int *)cnt += 1; |
| 197 | return 0; |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | int |
| 201 | get_mdevice_count(void) |
| 202 | { |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 203 | int cnt = 0; |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 204 | |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 205 | class_for_each_device(&mISDN_class, NULL, &cnt, _get_mdevice_count); |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 206 | return cnt; |
| 207 | } |
| 208 | |
| 209 | static int |
| 210 | get_free_devid(void) |
| 211 | { |
| 212 | u_int i; |
| 213 | |
| 214 | for (i = 0; i <= MAX_DEVICE_ID; i++) |
| 215 | if (!test_and_set_bit(i, (u_long *)&device_ids)) |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 216 | break; |
| 217 | if (i > MAX_DEVICE_ID) |
Roel Kluin | ddacd14 | 2009-05-22 11:04:53 +0000 | [diff] [blame] | 218 | return -EBUSY; |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 219 | return i; |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | int |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 223 | mISDN_register_device(struct mISDNdevice *dev, |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 224 | struct device *parent, char *name) |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 225 | { |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 226 | int err; |
| 227 | |
Roel Kluin | ddacd14 | 2009-05-22 11:04:53 +0000 | [diff] [blame] | 228 | err = get_free_devid(); |
| 229 | if (err < 0) |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 230 | goto error1; |
Roel Kluin | ddacd14 | 2009-05-22 11:04:53 +0000 | [diff] [blame] | 231 | dev->id = err; |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 232 | |
| 233 | device_initialize(&dev->dev); |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 234 | if (name && name[0]) |
Matthias Urlichs | 837468d | 2008-08-16 00:04:33 +0200 | [diff] [blame] | 235 | dev_set_name(&dev->dev, "%s", name); |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 236 | else |
Matthias Urlichs | 837468d | 2008-08-16 00:04:33 +0200 | [diff] [blame] | 237 | dev_set_name(&dev->dev, "mISDN%d", dev->id); |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 238 | if (debug & DEBUG_CORE) |
| 239 | printk(KERN_DEBUG "mISDN_register %s %d\n", |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 240 | dev_name(&dev->dev), dev->id); |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 241 | err = create_stack(dev); |
| 242 | if (err) |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 243 | goto error1; |
| 244 | |
| 245 | dev->dev.class = &mISDN_class; |
| 246 | dev->dev.platform_data = dev; |
| 247 | dev->dev.parent = parent; |
| 248 | dev_set_drvdata(&dev->dev, dev); |
| 249 | |
| 250 | err = device_add(&dev->dev); |
| 251 | if (err) |
| 252 | goto error3; |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 253 | return 0; |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 254 | |
| 255 | error3: |
| 256 | delete_stack(dev); |
| 257 | return err; |
| 258 | error1: |
| 259 | return err; |
| 260 | |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 261 | } |
| 262 | EXPORT_SYMBOL(mISDN_register_device); |
| 263 | |
| 264 | void |
| 265 | mISDN_unregister_device(struct mISDNdevice *dev) { |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 266 | if (debug & DEBUG_CORE) |
| 267 | printk(KERN_DEBUG "mISDN_unregister %s %d\n", |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 268 | dev_name(&dev->dev), dev->id); |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 269 | /* sysfs_remove_link(&dev->dev.kobj, "device"); */ |
| 270 | device_del(&dev->dev); |
| 271 | dev_set_drvdata(&dev->dev, NULL); |
| 272 | |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 273 | test_and_clear_bit(dev->id, (u_long *)&device_ids); |
| 274 | delete_stack(dev); |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 275 | put_device(&dev->dev); |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 276 | } |
| 277 | EXPORT_SYMBOL(mISDN_unregister_device); |
| 278 | |
| 279 | u_int |
| 280 | get_all_Bprotocols(void) |
| 281 | { |
| 282 | struct Bprotocol *bp; |
| 283 | u_int m = 0; |
| 284 | |
| 285 | read_lock(&bp_lock); |
| 286 | list_for_each_entry(bp, &Bprotocols, list) |
| 287 | m |= bp->Bprotocols; |
| 288 | read_unlock(&bp_lock); |
| 289 | return m; |
| 290 | } |
| 291 | |
| 292 | struct Bprotocol * |
| 293 | get_Bprotocol4mask(u_int m) |
| 294 | { |
| 295 | struct Bprotocol *bp; |
| 296 | |
| 297 | read_lock(&bp_lock); |
| 298 | list_for_each_entry(bp, &Bprotocols, list) |
| 299 | if (bp->Bprotocols & m) { |
| 300 | read_unlock(&bp_lock); |
| 301 | return bp; |
| 302 | } |
| 303 | read_unlock(&bp_lock); |
| 304 | return NULL; |
| 305 | } |
| 306 | |
| 307 | struct Bprotocol * |
| 308 | get_Bprotocol4id(u_int id) |
| 309 | { |
| 310 | u_int m; |
| 311 | |
| 312 | if (id < ISDN_P_B_START || id > 63) { |
| 313 | printk(KERN_WARNING "%s id not in range %d\n", |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 314 | __func__, id); |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 315 | return NULL; |
| 316 | } |
| 317 | m = 1 << (id & ISDN_P_B_MASK); |
| 318 | return get_Bprotocol4mask(m); |
| 319 | } |
| 320 | |
| 321 | int |
| 322 | mISDN_register_Bprotocol(struct Bprotocol *bp) |
| 323 | { |
| 324 | u_long flags; |
| 325 | struct Bprotocol *old; |
| 326 | |
| 327 | if (debug & DEBUG_CORE) |
| 328 | printk(KERN_DEBUG "%s: %s/%x\n", __func__, |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 329 | bp->name, bp->Bprotocols); |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 330 | old = get_Bprotocol4mask(bp->Bprotocols); |
| 331 | if (old) { |
| 332 | printk(KERN_WARNING |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 333 | "register duplicate protocol old %s/%x new %s/%x\n", |
| 334 | old->name, old->Bprotocols, bp->name, bp->Bprotocols); |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 335 | return -EBUSY; |
| 336 | } |
| 337 | write_lock_irqsave(&bp_lock, flags); |
| 338 | list_add_tail(&bp->list, &Bprotocols); |
| 339 | write_unlock_irqrestore(&bp_lock, flags); |
| 340 | return 0; |
| 341 | } |
| 342 | EXPORT_SYMBOL(mISDN_register_Bprotocol); |
| 343 | |
| 344 | void |
| 345 | mISDN_unregister_Bprotocol(struct Bprotocol *bp) |
| 346 | { |
| 347 | u_long flags; |
| 348 | |
| 349 | if (debug & DEBUG_CORE) |
| 350 | printk(KERN_DEBUG "%s: %s/%x\n", __func__, bp->name, |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 351 | bp->Bprotocols); |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 352 | write_lock_irqsave(&bp_lock, flags); |
| 353 | list_del(&bp->list); |
| 354 | write_unlock_irqrestore(&bp_lock, flags); |
| 355 | } |
| 356 | EXPORT_SYMBOL(mISDN_unregister_Bprotocol); |
| 357 | |
Hannes Eder | 5b83435 | 2008-12-12 21:15:17 -0800 | [diff] [blame] | 358 | static int |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 359 | mISDNInit(void) |
| 360 | { |
| 361 | int err; |
| 362 | |
| 363 | printk(KERN_INFO "Modular ISDN core version %d.%d.%d\n", |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 364 | MISDN_MAJOR_VERSION, MISDN_MINOR_VERSION, MISDN_RELEASE); |
Andreas Eversberg | 3bd69ad | 2008-09-06 09:03:46 +0200 | [diff] [blame] | 365 | mISDN_init_clock(&debug); |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 366 | mISDN_initstack(&debug); |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 367 | err = class_register(&mISDN_class); |
| 368 | if (err) |
| 369 | goto error1; |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 370 | err = mISDN_inittimer(&debug); |
| 371 | if (err) |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 372 | goto error2; |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 373 | err = l1_init(&debug); |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 374 | if (err) |
| 375 | goto error3; |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 376 | err = Isdnl2_Init(&debug); |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 377 | if (err) |
| 378 | goto error4; |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 379 | err = misdn_sock_init(&debug); |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 380 | if (err) |
| 381 | goto error5; |
| 382 | return 0; |
| 383 | |
| 384 | error5: |
| 385 | Isdnl2_cleanup(); |
| 386 | error4: |
| 387 | l1_cleanup(); |
| 388 | error3: |
| 389 | mISDN_timer_cleanup(); |
| 390 | error2: |
| 391 | class_unregister(&mISDN_class); |
| 392 | error1: |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 393 | return err; |
| 394 | } |
| 395 | |
Hannes Eder | 5b83435 | 2008-12-12 21:15:17 -0800 | [diff] [blame] | 396 | static void mISDN_cleanup(void) |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 397 | { |
| 398 | misdn_sock_cleanup(); |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 399 | Isdnl2_cleanup(); |
Matthias Urlichs | b36b654 | 2008-08-16 00:09:24 +0200 | [diff] [blame] | 400 | l1_cleanup(); |
| 401 | mISDN_timer_cleanup(); |
| 402 | class_unregister(&mISDN_class); |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 403 | |
Karsten Keil | 1b2b03f | 2008-07-27 01:54:58 +0200 | [diff] [blame] | 404 | printk(KERN_DEBUG "mISDNcore unloaded\n"); |
| 405 | } |
| 406 | |
| 407 | module_init(mISDNInit); |
| 408 | module_exit(mISDN_cleanup); |