]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
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 | ||
1da177e4 LT |
13 | #include <linux/module.h> |
14 | #include <linux/init.h> | |
15 | #include <asm/uaccess.h> | |
9a58a80a | 16 | #include <linux/seq_file.h> |
1da177e4 LT |
17 | #include <linux/skbuff.h> |
18 | ||
19 | #include "os_capi.h" | |
20 | ||
21 | #include "platform.h" | |
22 | #include "di_defs.h" | |
23 | #include "capi20.h" | |
24 | #include "divacapi.h" | |
25 | #include "cp_vers.h" | |
26 | #include "capifunc.h" | |
27 | ||
28 | static char *main_revision = "$Revision: 1.24 $"; | |
29 | static char *DRIVERNAME = | |
30 | "Eicon DIVA - CAPI Interface driver (http://www.melware.net)"; | |
31 | static char *DRIVERLNAME = "divacapi"; | |
32 | ||
33 | MODULE_DESCRIPTION("CAPI driver for Eicon DIVA cards"); | |
34 | MODULE_AUTHOR("Cytronics & Melware, Eicon Networks"); | |
35 | MODULE_SUPPORTED_DEVICE("CAPI and DIVA card drivers"); | |
36 | MODULE_LICENSE("GPL"); | |
37 | ||
38 | /* | |
39 | * get revision number from revision string | |
40 | */ | |
41 | static char *getrev(const char *revision) | |
42 | { | |
43 | char *rev; | |
44 | char *p; | |
45 | if ((p = strchr(revision, ':'))) { | |
46 | rev = p + 2; | |
47 | p = strchr(rev, '$'); | |
48 | *--p = 0; | |
49 | } else | |
50 | rev = "1.0"; | |
51 | return rev; | |
52 | ||
53 | } | |
54 | ||
55 | /* | |
56 | * alloc a message buffer | |
57 | */ | |
58 | diva_os_message_buffer_s *diva_os_alloc_message_buffer(unsigned long size, | |
59 | void **data_buf) | |
60 | { | |
61 | diva_os_message_buffer_s *dmb = alloc_skb(size, GFP_ATOMIC); | |
62 | if (dmb) { | |
63 | *data_buf = skb_put(dmb, size); | |
64 | } | |
65 | return (dmb); | |
66 | } | |
67 | ||
68 | /* | |
69 | * free a message buffer | |
70 | */ | |
71 | void diva_os_free_message_buffer(diva_os_message_buffer_s * dmb) | |
72 | { | |
73 | kfree_skb(dmb); | |
74 | } | |
75 | ||
76 | /* | |
77 | * proc function for controller info | |
78 | */ | |
9a58a80a | 79 | static int diva_ctl_proc_show(struct seq_file *m, void *v) |
1da177e4 | 80 | { |
9a58a80a | 81 | struct capi_ctr *ctrl = m->private; |
1da177e4 | 82 | diva_card *card = (diva_card *) ctrl->driverdata; |
9a58a80a AD |
83 | |
84 | seq_printf(m, "%s\n", ctrl->name); | |
85 | seq_printf(m, "Serial No. : %s\n", ctrl->serial); | |
86 | seq_printf(m, "Id : %d\n", card->Id); | |
87 | seq_printf(m, "Channels : %d\n", card->d.channels); | |
88 | ||
89 | return 0; | |
90 | } | |
91 | ||
92 | static int diva_ctl_proc_open(struct inode *inode, struct file *file) | |
93 | { | |
94 | return single_open(file, diva_ctl_proc_show, NULL); | |
1da177e4 LT |
95 | } |
96 | ||
9a58a80a AD |
97 | static const struct file_operations diva_ctl_proc_fops = { |
98 | .owner = THIS_MODULE, | |
99 | .open = diva_ctl_proc_open, | |
100 | .read = seq_read, | |
101 | .llseek = seq_lseek, | |
102 | .release = single_release, | |
103 | }; | |
104 | ||
1da177e4 LT |
105 | /* |
106 | * set additional os settings in capi_ctr struct | |
107 | */ | |
108 | void diva_os_set_controller_struct(struct capi_ctr *ctrl) | |
109 | { | |
110 | ctrl->driver_name = DRIVERLNAME; | |
111 | ctrl->load_firmware = NULL; | |
112 | ctrl->reset_ctr = NULL; | |
9a58a80a | 113 | ctrl->proc_fops = &diva_ctl_proc_fops; |
1da177e4 LT |
114 | ctrl->owner = THIS_MODULE; |
115 | } | |
116 | ||
117 | /* | |
118 | * module init | |
119 | */ | |
120 | static int DIVA_INIT_FUNCTION divacapi_init(void) | |
121 | { | |
122 | char tmprev[32]; | |
123 | int ret = 0; | |
124 | ||
125 | sprintf(DRIVERRELEASE_CAPI, "%d.%d%s", DRRELMAJOR, DRRELMINOR, | |
126 | DRRELEXTRA); | |
127 | ||
128 | printk(KERN_INFO "%s\n", DRIVERNAME); | |
129 | printk(KERN_INFO "%s: Rel:%s Rev:", DRIVERLNAME, DRIVERRELEASE_CAPI); | |
130 | strcpy(tmprev, main_revision); | |
131 | printk("%s Build: %s(%s)\n", getrev(tmprev), | |
132 | diva_capi_common_code_build, DIVA_BUILD); | |
133 | ||
134 | if (!(init_capifunc())) { | |
135 | printk(KERN_ERR "%s: failed init capi_driver.\n", | |
136 | DRIVERLNAME); | |
137 | ret = -EIO; | |
138 | } | |
139 | ||
140 | return ret; | |
141 | } | |
142 | ||
143 | /* | |
144 | * module exit | |
145 | */ | |
146 | static void DIVA_EXIT_FUNCTION divacapi_exit(void) | |
147 | { | |
148 | finit_capifunc(); | |
149 | printk(KERN_INFO "%s: module unloaded.\n", DRIVERLNAME); | |
150 | } | |
151 | ||
152 | module_init(divacapi_init); | |
153 | module_exit(divacapi_exit); |