aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/gigaset/common.c')
-rw-r--r--drivers/isdn/gigaset/common.c106
1 files changed, 49 insertions, 57 deletions
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index c3c9804796cd..f8e5759c636c 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Stuff used by all variants of the driver 2 * Stuff used by all variants of the driver
3 * 3 *
4 * Copyright (c) 2001 by Stefan Eilers <Eilers.Stefan@epost.de>, 4 * Copyright (c) 2001 by Stefan Eilers,
5 * Hansjoerg Lipp <hjlipp@web.de>, 5 * Hansjoerg Lipp <hjlipp@web.de>,
6 * Tilman Schmidt <tilman@imap.cc>. 6 * Tilman Schmidt <tilman@imap.cc>.
7 * 7 *
@@ -19,7 +19,7 @@
19#include <linux/moduleparam.h> 19#include <linux/moduleparam.h>
20 20
21/* Version Information */ 21/* Version Information */
22#define DRIVER_AUTHOR "Hansjoerg Lipp <hjlipp@web.de>, Tilman Schmidt <tilman@imap.cc>, Stefan Eilers <Eilers.Stefan@epost.de>" 22#define DRIVER_AUTHOR "Hansjoerg Lipp <hjlipp@web.de>, Tilman Schmidt <tilman@imap.cc>, Stefan Eilers"
23#define DRIVER_DESC "Driver for Gigaset 307x" 23#define DRIVER_DESC "Driver for Gigaset 307x"
24 24
25/* Module parameters */ 25/* Module parameters */
@@ -28,15 +28,7 @@ EXPORT_SYMBOL_GPL(gigaset_debuglevel);
28module_param_named(debug, gigaset_debuglevel, int, S_IRUGO|S_IWUSR); 28module_param_named(debug, gigaset_debuglevel, int, S_IRUGO|S_IWUSR);
29MODULE_PARM_DESC(debug, "debug level"); 29MODULE_PARM_DESC(debug, "debug level");
30 30
31/*====================================================================== 31/* driver state flags */
32 Prototypes of internal functions
33 */
34
35static struct cardstate *alloc_cs(struct gigaset_driver *drv);
36static void free_cs(struct cardstate *cs);
37static void make_valid(struct cardstate *cs, unsigned mask);
38static void make_invalid(struct cardstate *cs, unsigned mask);
39
40#define VALID_MINOR 0x01 32#define VALID_MINOR 0x01
41#define VALID_ID 0x02 33#define VALID_ID 0x02
42#define ASSIGNED 0x04 34#define ASSIGNED 0x04
@@ -400,6 +392,52 @@ static void gigaset_freebcs(struct bc_state *bcs)
400 } 392 }
401} 393}
402 394
395static struct cardstate *alloc_cs(struct gigaset_driver *drv)
396{
397 unsigned long flags;
398 unsigned i;
399 static struct cardstate *ret = NULL;
400
401 spin_lock_irqsave(&drv->lock, flags);
402 for (i = 0; i < drv->minors; ++i) {
403 if (!(drv->flags[i] & VALID_MINOR)) {
404 drv->flags[i] = VALID_MINOR;
405 ret = drv->cs + i;
406 }
407 if (ret)
408 break;
409 }
410 spin_unlock_irqrestore(&drv->lock, flags);
411 return ret;
412}
413
414static void free_cs(struct cardstate *cs)
415{
416 unsigned long flags;
417 struct gigaset_driver *drv = cs->driver;
418 spin_lock_irqsave(&drv->lock, flags);
419 drv->flags[cs->minor_index] = 0;
420 spin_unlock_irqrestore(&drv->lock, flags);
421}
422
423static void make_valid(struct cardstate *cs, unsigned mask)
424{
425 unsigned long flags;
426 struct gigaset_driver *drv = cs->driver;
427 spin_lock_irqsave(&drv->lock, flags);
428 drv->flags[cs->minor_index] |= mask;
429 spin_unlock_irqrestore(&drv->lock, flags);
430}
431
432static void make_invalid(struct cardstate *cs, unsigned mask)
433{
434 unsigned long flags;
435 struct gigaset_driver *drv = cs->driver;
436 spin_lock_irqsave(&drv->lock, flags);
437 drv->flags[cs->minor_index] &= ~mask;
438 spin_unlock_irqrestore(&drv->lock, flags);
439}
440
403void gigaset_freecs(struct cardstate *cs) 441void gigaset_freecs(struct cardstate *cs)
404{ 442{
405 int i; 443 int i;
@@ -1117,52 +1155,6 @@ out1:
1117} 1155}
1118EXPORT_SYMBOL_GPL(gigaset_initdriver); 1156EXPORT_SYMBOL_GPL(gigaset_initdriver);
1119 1157
1120static struct cardstate *alloc_cs(struct gigaset_driver *drv)
1121{
1122 unsigned long flags;
1123 unsigned i;
1124 static struct cardstate *ret = NULL;
1125
1126 spin_lock_irqsave(&drv->lock, flags);
1127 for (i = 0; i < drv->minors; ++i) {
1128 if (!(drv->flags[i] & VALID_MINOR)) {
1129 drv->flags[i] = VALID_MINOR;
1130 ret = drv->cs + i;
1131 }
1132 if (ret)
1133 break;
1134 }
1135 spin_unlock_irqrestore(&drv->lock, flags);
1136 return ret;
1137}
1138
1139static void free_cs(struct cardstate *cs)
1140{
1141 unsigned long flags;
1142 struct gigaset_driver *drv = cs->driver;
1143 spin_lock_irqsave(&drv->lock, flags);
1144 drv->flags[cs->minor_index] = 0;
1145 spin_unlock_irqrestore(&drv->lock, flags);
1146}
1147
1148static void make_valid(struct cardstate *cs, unsigned mask)
1149{
1150 unsigned long flags;
1151 struct gigaset_driver *drv = cs->driver;
1152 spin_lock_irqsave(&drv->lock, flags);
1153 drv->flags[cs->minor_index] |= mask;
1154 spin_unlock_irqrestore(&drv->lock, flags);
1155}
1156
1157static void make_invalid(struct cardstate *cs, unsigned mask)
1158{
1159 unsigned long flags;
1160 struct gigaset_driver *drv = cs->driver;
1161 spin_lock_irqsave(&drv->lock, flags);
1162 drv->flags[cs->minor_index] &= ~mask;
1163 spin_unlock_irqrestore(&drv->lock, flags);
1164}
1165
1166/* For drivers without fixed assignment device<->cardstate (usb) */ 1158/* For drivers without fixed assignment device<->cardstate (usb) */
1167struct cardstate *gigaset_getunassignedcs(struct gigaset_driver *drv) 1159struct cardstate *gigaset_getunassignedcs(struct gigaset_driver *drv)
1168{ 1160{