diff options
Diffstat (limited to 'drivers/isdn/hardware/eicon/diva_didd.c')
-rw-r--r-- | drivers/isdn/hardware/eicon/diva_didd.c | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/drivers/isdn/hardware/eicon/diva_didd.c b/drivers/isdn/hardware/eicon/diva_didd.c new file mode 100644 index 000000000000..7fdf8ae5be52 --- /dev/null +++ b/drivers/isdn/hardware/eicon/diva_didd.c | |||
@@ -0,0 +1,151 @@ | |||
1 | /* $Id: diva_didd.c,v 1.13.6.4 2005/02/11 19:40:25 armin Exp $ | ||
2 | * | ||
3 | * DIDD Interface module for Eicon active cards. | ||
4 | * | ||
5 | * Functions are in dadapter.c | ||
6 | * | ||
7 | * Copyright 2002-2003 by Armin Schindler (mac@melware.de) | ||
8 | * Copyright 2002-2003 Cytronics & Melware (info@melware.de) | ||
9 | * | ||
10 | * This software may be used and distributed according to the terms | ||
11 | * of the GNU General Public License, incorporated herein by reference. | ||
12 | */ | ||
13 | |||
14 | #include <linux/config.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/proc_fs.h> | ||
19 | |||
20 | #include "platform.h" | ||
21 | #include "di_defs.h" | ||
22 | #include "dadapter.h" | ||
23 | #include "divasync.h" | ||
24 | #include "did_vers.h" | ||
25 | |||
26 | static char *main_revision = "$Revision: 1.13.6.4 $"; | ||
27 | |||
28 | static char *DRIVERNAME = | ||
29 | "Eicon DIVA - DIDD table (http://www.melware.net)"; | ||
30 | static char *DRIVERLNAME = "divadidd"; | ||
31 | char *DRIVERRELEASE_DIDD = "2.0"; | ||
32 | |||
33 | static char *main_proc_dir = "eicon"; | ||
34 | |||
35 | MODULE_DESCRIPTION("DIDD table driver for diva drivers"); | ||
36 | MODULE_AUTHOR("Cytronics & Melware, Eicon Networks"); | ||
37 | MODULE_SUPPORTED_DEVICE("Eicon diva drivers"); | ||
38 | MODULE_LICENSE("GPL"); | ||
39 | |||
40 | #define DBG_MINIMUM (DL_LOG + DL_FTL + DL_ERR) | ||
41 | #define DBG_DEFAULT (DBG_MINIMUM + DL_XLOG + DL_REG) | ||
42 | |||
43 | extern int diddfunc_init(void); | ||
44 | extern void diddfunc_finit(void); | ||
45 | |||
46 | extern void DIVA_DIDD_Read(void *, int); | ||
47 | |||
48 | static struct proc_dir_entry *proc_didd; | ||
49 | struct proc_dir_entry *proc_net_eicon = NULL; | ||
50 | |||
51 | EXPORT_SYMBOL(DIVA_DIDD_Read); | ||
52 | EXPORT_SYMBOL(proc_net_eicon); | ||
53 | |||
54 | static char *getrev(const char *revision) | ||
55 | { | ||
56 | char *rev; | ||
57 | char *p; | ||
58 | if ((p = strchr(revision, ':'))) { | ||
59 | rev = p + 2; | ||
60 | p = strchr(rev, '$'); | ||
61 | *--p = 0; | ||
62 | } else | ||
63 | rev = "1.0"; | ||
64 | return rev; | ||
65 | } | ||
66 | |||
67 | static int | ||
68 | proc_read(char *page, char **start, off_t off, int count, int *eof, | ||
69 | void *data) | ||
70 | { | ||
71 | int len = 0; | ||
72 | char tmprev[32]; | ||
73 | |||
74 | strcpy(tmprev, main_revision); | ||
75 | len += sprintf(page + len, "%s\n", DRIVERNAME); | ||
76 | len += sprintf(page + len, "name : %s\n", DRIVERLNAME); | ||
77 | len += sprintf(page + len, "release : %s\n", DRIVERRELEASE_DIDD); | ||
78 | len += sprintf(page + len, "build : %s(%s)\n", | ||
79 | diva_didd_common_code_build, DIVA_BUILD); | ||
80 | len += sprintf(page + len, "revision : %s\n", getrev(tmprev)); | ||
81 | |||
82 | if (off + count >= len) | ||
83 | *eof = 1; | ||
84 | if (len < off) | ||
85 | return 0; | ||
86 | *start = page + off; | ||
87 | return ((count < len - off) ? count : len - off); | ||
88 | } | ||
89 | |||
90 | static int DIVA_INIT_FUNCTION create_proc(void) | ||
91 | { | ||
92 | proc_net_eicon = create_proc_entry(main_proc_dir, S_IFDIR, proc_net); | ||
93 | |||
94 | if (proc_net_eicon) { | ||
95 | if ((proc_didd = | ||
96 | create_proc_entry(DRIVERLNAME, S_IFREG | S_IRUGO, | ||
97 | proc_net_eicon))) { | ||
98 | proc_didd->read_proc = proc_read; | ||
99 | } | ||
100 | return (1); | ||
101 | } | ||
102 | return (0); | ||
103 | } | ||
104 | |||
105 | static void DIVA_EXIT_FUNCTION remove_proc(void) | ||
106 | { | ||
107 | remove_proc_entry(DRIVERLNAME, proc_net_eicon); | ||
108 | remove_proc_entry(main_proc_dir, proc_net); | ||
109 | } | ||
110 | |||
111 | static int DIVA_INIT_FUNCTION divadidd_init(void) | ||
112 | { | ||
113 | char tmprev[32]; | ||
114 | int ret = 0; | ||
115 | |||
116 | printk(KERN_INFO "%s\n", DRIVERNAME); | ||
117 | printk(KERN_INFO "%s: Rel:%s Rev:", DRIVERLNAME, DRIVERRELEASE_DIDD); | ||
118 | strcpy(tmprev, main_revision); | ||
119 | printk("%s Build:%s(%s)\n", getrev(tmprev), | ||
120 | diva_didd_common_code_build, DIVA_BUILD); | ||
121 | |||
122 | if (!create_proc()) { | ||
123 | printk(KERN_ERR "%s: could not create proc entry\n", | ||
124 | DRIVERLNAME); | ||
125 | ret = -EIO; | ||
126 | goto out; | ||
127 | } | ||
128 | |||
129 | if (!diddfunc_init()) { | ||
130 | printk(KERN_ERR "%s: failed to connect to DIDD.\n", | ||
131 | DRIVERLNAME); | ||
132 | #ifdef MODULE | ||
133 | remove_proc(); | ||
134 | #endif | ||
135 | ret = -EIO; | ||
136 | goto out; | ||
137 | } | ||
138 | |||
139 | out: | ||
140 | return (ret); | ||
141 | } | ||
142 | |||
143 | static void DIVA_EXIT_FUNCTION divadidd_exit(void) | ||
144 | { | ||
145 | diddfunc_finit(); | ||
146 | remove_proc(); | ||
147 | printk(KERN_INFO "%s: module unloaded.\n", DRIVERLNAME); | ||
148 | } | ||
149 | |||
150 | module_init(divadidd_init); | ||
151 | module_exit(divadidd_exit); | ||