diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/isdn/hardware/eicon/capimain.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/isdn/hardware/eicon/capimain.c')
-rw-r--r-- | drivers/isdn/hardware/eicon/capimain.c | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/drivers/isdn/hardware/eicon/capimain.c b/drivers/isdn/hardware/eicon/capimain.c new file mode 100644 index 000000000000..8fe4f3f09353 --- /dev/null +++ b/drivers/isdn/hardware/eicon/capimain.c | |||
@@ -0,0 +1,147 @@ | |||
1 | /* $Id: capimain.c,v 1.24 2003/09/09 06:51:05 schindler Exp $ | ||
2 | * | ||
3 | * ISDN interface module for Eicon active cards DIVA. | ||
4 | * CAPI Interface | ||
5 | * | ||
6 | * Copyright 2000-2003 by Armin Schindler (mac@melware.de) | ||
7 | * Copyright 2000-2003 Cytronics & Melware (info@melware.de) | ||
8 | * | ||
9 | * This software may be used and distributed according to the terms | ||
10 | * of the GNU General Public License, incorporated herein by reference. | ||
11 | */ | ||
12 | |||
13 | #include <linux/config.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <asm/uaccess.h> | ||
17 | #include <linux/smp_lock.h> | ||
18 | #include <linux/skbuff.h> | ||
19 | |||
20 | #include "os_capi.h" | ||
21 | |||
22 | #include "platform.h" | ||
23 | #include "di_defs.h" | ||
24 | #include "capi20.h" | ||
25 | #include "divacapi.h" | ||
26 | #include "cp_vers.h" | ||
27 | #include "capifunc.h" | ||
28 | |||
29 | static char *main_revision = "$Revision: 1.24 $"; | ||
30 | static char *DRIVERNAME = | ||
31 | "Eicon DIVA - CAPI Interface driver (http://www.melware.net)"; | ||
32 | static char *DRIVERLNAME = "divacapi"; | ||
33 | |||
34 | MODULE_DESCRIPTION("CAPI driver for Eicon DIVA cards"); | ||
35 | MODULE_AUTHOR("Cytronics & Melware, Eicon Networks"); | ||
36 | MODULE_SUPPORTED_DEVICE("CAPI and DIVA card drivers"); | ||
37 | MODULE_LICENSE("GPL"); | ||
38 | |||
39 | /* | ||
40 | * get revision number from revision string | ||
41 | */ | ||
42 | static char *getrev(const char *revision) | ||
43 | { | ||
44 | char *rev; | ||
45 | char *p; | ||
46 | if ((p = strchr(revision, ':'))) { | ||
47 | rev = p + 2; | ||
48 | p = strchr(rev, '$'); | ||
49 | *--p = 0; | ||
50 | } else | ||
51 | rev = "1.0"; | ||
52 | return rev; | ||
53 | |||
54 | } | ||
55 | |||
56 | /* | ||
57 | * alloc a message buffer | ||
58 | */ | ||
59 | diva_os_message_buffer_s *diva_os_alloc_message_buffer(unsigned long size, | ||
60 | void **data_buf) | ||
61 | { | ||
62 | diva_os_message_buffer_s *dmb = alloc_skb(size, GFP_ATOMIC); | ||
63 | if (dmb) { | ||
64 | *data_buf = skb_put(dmb, size); | ||
65 | } | ||
66 | return (dmb); | ||
67 | } | ||
68 | |||
69 | /* | ||
70 | * free a message buffer | ||
71 | */ | ||
72 | void diva_os_free_message_buffer(diva_os_message_buffer_s * dmb) | ||
73 | { | ||
74 | kfree_skb(dmb); | ||
75 | } | ||
76 | |||
77 | /* | ||
78 | * proc function for controller info | ||
79 | */ | ||
80 | static int diva_ctl_read_proc(char *page, char **start, off_t off, | ||
81 | int count, int *eof, struct capi_ctr *ctrl) | ||
82 | { | ||
83 | diva_card *card = (diva_card *) ctrl->driverdata; | ||
84 | int len = 0; | ||
85 | |||
86 | len += sprintf(page + len, "%s\n", ctrl->name); | ||
87 | len += sprintf(page + len, "Serial No. : %s\n", ctrl->serial); | ||
88 | len += sprintf(page + len, "Id : %d\n", card->Id); | ||
89 | len += sprintf(page + len, "Channels : %d\n", card->d.channels); | ||
90 | |||
91 | if (off + count >= len) | ||
92 | *eof = 1; | ||
93 | if (len < off) | ||
94 | return 0; | ||
95 | *start = page + off; | ||
96 | return ((count < len - off) ? count : len - off); | ||
97 | } | ||
98 | |||
99 | /* | ||
100 | * set additional os settings in capi_ctr struct | ||
101 | */ | ||
102 | void diva_os_set_controller_struct(struct capi_ctr *ctrl) | ||
103 | { | ||
104 | ctrl->driver_name = DRIVERLNAME; | ||
105 | ctrl->load_firmware = NULL; | ||
106 | ctrl->reset_ctr = NULL; | ||
107 | ctrl->ctr_read_proc = diva_ctl_read_proc; | ||
108 | ctrl->owner = THIS_MODULE; | ||
109 | } | ||
110 | |||
111 | /* | ||
112 | * module init | ||
113 | */ | ||
114 | static int DIVA_INIT_FUNCTION divacapi_init(void) | ||
115 | { | ||
116 | char tmprev[32]; | ||
117 | int ret = 0; | ||
118 | |||
119 | sprintf(DRIVERRELEASE_CAPI, "%d.%d%s", DRRELMAJOR, DRRELMINOR, | ||
120 | DRRELEXTRA); | ||
121 | |||
122 | printk(KERN_INFO "%s\n", DRIVERNAME); | ||
123 | printk(KERN_INFO "%s: Rel:%s Rev:", DRIVERLNAME, DRIVERRELEASE_CAPI); | ||
124 | strcpy(tmprev, main_revision); | ||
125 | printk("%s Build: %s(%s)\n", getrev(tmprev), | ||
126 | diva_capi_common_code_build, DIVA_BUILD); | ||
127 | |||
128 | if (!(init_capifunc())) { | ||
129 | printk(KERN_ERR "%s: failed init capi_driver.\n", | ||
130 | DRIVERLNAME); | ||
131 | ret = -EIO; | ||
132 | } | ||
133 | |||
134 | return ret; | ||
135 | } | ||
136 | |||
137 | /* | ||
138 | * module exit | ||
139 | */ | ||
140 | static void DIVA_EXIT_FUNCTION divacapi_exit(void) | ||
141 | { | ||
142 | finit_capifunc(); | ||
143 | printk(KERN_INFO "%s: module unloaded.\n", DRIVERLNAME); | ||
144 | } | ||
145 | |||
146 | module_init(divacapi_init); | ||
147 | module_exit(divacapi_exit); | ||