xref: /openbmc/linux/include/linux/mISDNif.h (revision 23680f0b)
1 /*
2  *
3  * Author	Karsten Keil <kkeil@novell.com>
4  *
5  * Copyright 2008  by Karsten Keil <kkeil@novell.com>
6  *
7  * This code is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This code is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU LESSER GENERAL PUBLIC LICENSE for more details.
15  *
16  */
17 
18 #ifndef mISDNIF_H
19 #define mISDNIF_H
20 
21 #include <linux/types.h>
22 #include <linux/errno.h>
23 #include <linux/socket.h>
24 
25 /*
26  * ABI Version 32 bit
27  *
28  * <8 bit> Major version
29  *		- changed if any interface become backwards incompatible
30  *
31  * <8 bit> Minor version
32  *              - changed if any interface is extended but backwards compatible
33  *
34  * <16 bit> Release number
35  *              - should be incremented on every checkin
36  */
37 #define	MISDN_MAJOR_VERSION	1
38 #define	MISDN_MINOR_VERSION	1
39 #define MISDN_RELEASE		29
40 
41 /* primitives for information exchange
42  * generell format
43  * <16  bit  0 >
44  * <8  bit command>
45  *    BIT 8 = 1 LAYER private
46  *    BIT 7 = 1 answer
47  *    BIT 6 = 1 DATA
48  * <8  bit target layer mask>
49  *
50  * Layer = 00 is reserved for general commands
51    Layer = 01  L2 -> HW
52    Layer = 02  HW -> L2
53    Layer = 04  L3 -> L2
54    Layer = 08  L2 -> L3
55  * Layer = FF is reserved for broadcast commands
56  */
57 
58 #define MISDN_CMDMASK		0xff00
59 #define MISDN_LAYERMASK		0x00ff
60 
61 /* generell commands */
62 #define OPEN_CHANNEL		0x0100
63 #define CLOSE_CHANNEL		0x0200
64 #define CONTROL_CHANNEL		0x0300
65 #define CHECK_DATA		0x0400
66 
67 /* layer 2 -> layer 1 */
68 #define PH_ACTIVATE_REQ		0x0101
69 #define PH_DEACTIVATE_REQ	0x0201
70 #define PH_DATA_REQ		0x2001
71 #define MPH_ACTIVATE_REQ	0x0501
72 #define MPH_DEACTIVATE_REQ	0x0601
73 #define MPH_INFORMATION_REQ	0x0701
74 #define PH_CONTROL_REQ		0x0801
75 
76 /* layer 1 -> layer 2 */
77 #define PH_ACTIVATE_IND		0x0102
78 #define PH_ACTIVATE_CNF		0x4102
79 #define PH_DEACTIVATE_IND	0x0202
80 #define PH_DEACTIVATE_CNF	0x4202
81 #define PH_DATA_IND		0x2002
82 #define PH_DATA_E_IND		0x3002
83 #define MPH_ACTIVATE_IND	0x0502
84 #define MPH_DEACTIVATE_IND	0x0602
85 #define MPH_INFORMATION_IND	0x0702
86 #define PH_DATA_CNF		0x6002
87 #define PH_CONTROL_IND		0x0802
88 #define PH_CONTROL_CNF		0x4802
89 
90 /* layer 3 -> layer 2 */
91 #define DL_ESTABLISH_REQ	0x1004
92 #define DL_RELEASE_REQ		0x1104
93 #define DL_DATA_REQ		0x3004
94 #define DL_UNITDATA_REQ		0x3104
95 #define DL_INFORMATION_REQ	0x0004
96 
97 /* layer 2 -> layer 3 */
98 #define DL_ESTABLISH_IND	0x1008
99 #define DL_ESTABLISH_CNF	0x5008
100 #define DL_RELEASE_IND		0x1108
101 #define DL_RELEASE_CNF		0x5108
102 #define DL_DATA_IND		0x3008
103 #define DL_UNITDATA_IND		0x3108
104 #define DL_INFORMATION_IND	0x0008
105 
106 /* intern layer 2 management */
107 #define MDL_ASSIGN_REQ		0x1804
108 #define MDL_ASSIGN_IND		0x1904
109 #define MDL_REMOVE_REQ		0x1A04
110 #define MDL_REMOVE_IND		0x1B04
111 #define MDL_STATUS_UP_IND	0x1C04
112 #define MDL_STATUS_DOWN_IND	0x1D04
113 #define MDL_STATUS_UI_IND	0x1E04
114 #define MDL_ERROR_IND		0x1F04
115 #define MDL_ERROR_RSP		0x5F04
116 
117 /* intern layer 2 */
118 #define DL_TIMER200_IND		0x7004
119 #define DL_TIMER203_IND		0x7304
120 #define DL_INTERN_MSG		0x7804
121 
122 /* DL_INFORMATION_IND types */
123 #define DL_INFO_L2_CONNECT	0x0001
124 #define DL_INFO_L2_REMOVED	0x0002
125 
126 /* PH_CONTROL types */
127 /* TOUCH TONE IS 0x20XX  XX "0"..."9", "A","B","C","D","*","#" */
128 #define DTMF_TONE_VAL		0x2000
129 #define DTMF_TONE_MASK		0x007F
130 #define DTMF_TONE_START		0x2100
131 #define DTMF_TONE_STOP		0x2200
132 #define DTMF_HFC_COEF		0x4000
133 #define DSP_CONF_JOIN		0x2403
134 #define DSP_CONF_SPLIT		0x2404
135 #define DSP_RECEIVE_OFF		0x2405
136 #define DSP_RECEIVE_ON		0x2406
137 #define DSP_ECHO_ON		0x2407
138 #define DSP_ECHO_OFF		0x2408
139 #define DSP_MIX_ON		0x2409
140 #define DSP_MIX_OFF		0x240a
141 #define DSP_DELAY		0x240b
142 #define DSP_JITTER		0x240c
143 #define DSP_TXDATA_ON		0x240d
144 #define DSP_TXDATA_OFF		0x240e
145 #define DSP_TX_DEJITTER		0x240f
146 #define DSP_TX_DEJ_OFF		0x2410
147 #define DSP_TONE_PATT_ON	0x2411
148 #define DSP_TONE_PATT_OFF	0x2412
149 #define DSP_VOL_CHANGE_TX	0x2413
150 #define DSP_VOL_CHANGE_RX	0x2414
151 #define DSP_BF_ENABLE_KEY	0x2415
152 #define DSP_BF_DISABLE		0x2416
153 #define DSP_BF_ACCEPT		0x2416
154 #define DSP_BF_REJECT		0x2417
155 #define DSP_PIPELINE_CFG	0x2418
156 #define HFC_VOL_CHANGE_TX	0x2601
157 #define HFC_VOL_CHANGE_RX	0x2602
158 #define HFC_SPL_LOOP_ON		0x2603
159 #define HFC_SPL_LOOP_OFF	0x2604
160 /* for T30 FAX and analog modem */
161 #define HW_MOD_FRM		0x4000
162 #define HW_MOD_FRH		0x4001
163 #define HW_MOD_FTM		0x4002
164 #define HW_MOD_FTH		0x4003
165 #define HW_MOD_FTS		0x4004
166 #define HW_MOD_CONNECT		0x4010
167 #define HW_MOD_OK		0x4011
168 #define HW_MOD_NOCARR		0x4012
169 #define HW_MOD_FCERROR		0x4013
170 #define HW_MOD_READY		0x4014
171 #define HW_MOD_LASTDATA		0x4015
172 
173 /* DSP_TONE_PATT_ON parameter */
174 #define TONE_OFF			0x0000
175 #define TONE_GERMAN_DIALTONE		0x0001
176 #define TONE_GERMAN_OLDDIALTONE		0x0002
177 #define TONE_AMERICAN_DIALTONE		0x0003
178 #define TONE_GERMAN_DIALPBX		0x0004
179 #define TONE_GERMAN_OLDDIALPBX		0x0005
180 #define TONE_AMERICAN_DIALPBX		0x0006
181 #define TONE_GERMAN_RINGING		0x0007
182 #define TONE_GERMAN_OLDRINGING		0x0008
183 #define TONE_AMERICAN_RINGPBX		0x000b
184 #define TONE_GERMAN_RINGPBX		0x000c
185 #define TONE_GERMAN_OLDRINGPBX		0x000d
186 #define TONE_AMERICAN_RINGING		0x000e
187 #define TONE_GERMAN_BUSY		0x000f
188 #define TONE_GERMAN_OLDBUSY		0x0010
189 #define TONE_AMERICAN_BUSY		0x0011
190 #define TONE_GERMAN_HANGUP		0x0012
191 #define TONE_GERMAN_OLDHANGUP		0x0013
192 #define TONE_AMERICAN_HANGUP		0x0014
193 #define TONE_SPECIAL_INFO		0x0015
194 #define TONE_GERMAN_GASSENBESETZT	0x0016
195 #define TONE_GERMAN_AUFSCHALTTON	0x0016
196 
197 /* MPH_INFORMATION_IND */
198 #define L1_SIGNAL_LOS_OFF	0x0010
199 #define L1_SIGNAL_LOS_ON	0x0011
200 #define L1_SIGNAL_AIS_OFF	0x0012
201 #define L1_SIGNAL_AIS_ON	0x0013
202 #define L1_SIGNAL_RDI_OFF	0x0014
203 #define L1_SIGNAL_RDI_ON	0x0015
204 #define L1_SIGNAL_SLIP_RX	0x0020
205 #define L1_SIGNAL_SLIP_TX	0x0021
206 
207 /*
208  * protocol ids
209  * D channel 1-31
210  * B channel 33 - 63
211  */
212 
213 #define ISDN_P_NONE		0
214 #define ISDN_P_BASE		0
215 #define ISDN_P_TE_S0		0x01
216 #define ISDN_P_NT_S0  		0x02
217 #define ISDN_P_TE_E1		0x03
218 #define ISDN_P_NT_E1  		0x04
219 #define ISDN_P_TE_UP0		0x05
220 #define ISDN_P_NT_UP0		0x06
221 
222 #define IS_ISDN_P_TE(p) ((p == ISDN_P_TE_S0) || (p == ISDN_P_TE_E1) || \
223 				(p == ISDN_P_TE_UP0) || (p == ISDN_P_LAPD_TE))
224 #define IS_ISDN_P_NT(p) ((p == ISDN_P_NT_S0) || (p == ISDN_P_NT_E1) || \
225 				(p == ISDN_P_NT_UP0) || (p == ISDN_P_LAPD_NT))
226 #define IS_ISDN_P_S0(p) ((p == ISDN_P_TE_S0) || (p == ISDN_P_NT_S0))
227 #define IS_ISDN_P_E1(p) ((p == ISDN_P_TE_E1) || (p == ISDN_P_NT_E1))
228 #define IS_ISDN_P_UP0(p) ((p == ISDN_P_TE_UP0) || (p == ISDN_P_NT_UP0))
229 
230 
231 #define ISDN_P_LAPD_TE		0x10
232 #define	ISDN_P_LAPD_NT		0x11
233 
234 #define ISDN_P_B_MASK		0x1f
235 #define ISDN_P_B_START		0x20
236 
237 #define ISDN_P_B_RAW		0x21
238 #define ISDN_P_B_HDLC		0x22
239 #define ISDN_P_B_X75SLP		0x23
240 #define ISDN_P_B_L2DTMF		0x24
241 #define ISDN_P_B_L2DSP		0x25
242 #define ISDN_P_B_L2DSPHDLC	0x26
243 #define ISDN_P_B_T30_FAX	0x27
244 #define ISDN_P_B_MODEM_ASYNC	0x28
245 
246 #define OPTION_L2_PMX		1
247 #define OPTION_L2_PTP		2
248 #define OPTION_L2_FIXEDTEI	3
249 #define OPTION_L2_CLEANUP	4
250 #define OPTION_L1_HOLD		5
251 
252 /* should be in sync with linux/kobject.h:KOBJ_NAME_LEN */
253 #define MISDN_MAX_IDLEN		20
254 
255 struct mISDNhead {
256 	unsigned int	prim;
257 	unsigned int	id;
258 }  __packed;
259 
260 #define MISDN_HEADER_LEN	sizeof(struct mISDNhead)
261 #define MAX_DATA_SIZE		2048
262 #define MAX_DATA_MEM		(MAX_DATA_SIZE + MISDN_HEADER_LEN)
263 #define MAX_DFRAME_LEN		260
264 
265 #define MISDN_ID_ADDR_MASK	0xFFFF
266 #define MISDN_ID_TEI_MASK	0xFF00
267 #define MISDN_ID_SAPI_MASK	0x00FF
268 #define MISDN_ID_TEI_ANY	0x7F00
269 
270 #define MISDN_ID_ANY		0xFFFF
271 #define MISDN_ID_NONE		0xFFFE
272 
273 #define GROUP_TEI		127
274 #define TEI_SAPI		63
275 #define CTRL_SAPI		0
276 
277 #define MISDN_MAX_CHANNEL	127
278 #define MISDN_CHMAP_SIZE	((MISDN_MAX_CHANNEL + 1) >> 3)
279 
280 #define SOL_MISDN	0
281 
282 struct sockaddr_mISDN {
283 	sa_family_t    family;
284 	unsigned char	dev;
285 	unsigned char	channel;
286 	unsigned char	sapi;
287 	unsigned char	tei;
288 };
289 
290 struct mISDNversion {
291 	unsigned char	major;
292 	unsigned char	minor;
293 	unsigned short	release;
294 };
295 
296 struct mISDN_devinfo {
297 	u_int			id;
298 	u_int			Dprotocols;
299 	u_int			Bprotocols;
300 	u_int			protocol;
301 	u_char			channelmap[MISDN_CHMAP_SIZE];
302 	u_int			nrbchan;
303 	char			name[MISDN_MAX_IDLEN];
304 };
305 
306 struct mISDN_devrename {
307 	u_int			id;
308 	char			name[MISDN_MAX_IDLEN]; /* new name */
309 };
310 
311 /* MPH_INFORMATION_REQ payload */
312 struct ph_info_ch {
313 	__u32 protocol;
314 	__u64 Flags;
315 };
316 
317 struct ph_info_dch {
318 	struct ph_info_ch ch;
319 	__u16 state;
320 	__u16 num_bch;
321 };
322 
323 struct ph_info {
324 	struct ph_info_dch dch;
325 	struct ph_info_ch  bch[];
326 };
327 
328 /* timer device ioctl */
329 #define IMADDTIMER	_IOR('I', 64, int)
330 #define IMDELTIMER	_IOR('I', 65, int)
331 
332 /* socket ioctls */
333 #define	IMGETVERSION	_IOR('I', 66, int)
334 #define	IMGETCOUNT	_IOR('I', 67, int)
335 #define IMGETDEVINFO	_IOR('I', 68, int)
336 #define IMCTRLREQ	_IOR('I', 69, int)
337 #define IMCLEAR_L2	_IOR('I', 70, int)
338 #define IMSETDEVNAME	_IOR('I', 71, struct mISDN_devrename)
339 #define IMHOLD_L1	_IOR('I', 72, int)
340 
341 static inline int
test_channelmap(u_int nr,u_char * map)342 test_channelmap(u_int nr, u_char *map)
343 {
344 	if (nr <= MISDN_MAX_CHANNEL)
345 		return map[nr >> 3] & (1 << (nr & 7));
346 	else
347 		return 0;
348 }
349 
350 static inline void
set_channelmap(u_int nr,u_char * map)351 set_channelmap(u_int nr, u_char *map)
352 {
353 	map[nr >> 3] |= (1 << (nr & 7));
354 }
355 
356 static inline void
clear_channelmap(u_int nr,u_char * map)357 clear_channelmap(u_int nr, u_char *map)
358 {
359 	map[nr >> 3] &= ~(1 << (nr & 7));
360 }
361 
362 /* CONTROL_CHANNEL parameters */
363 #define MISDN_CTRL_GETOP		0x0000
364 #define MISDN_CTRL_LOOP			0x0001
365 #define MISDN_CTRL_CONNECT		0x0002
366 #define MISDN_CTRL_DISCONNECT		0x0004
367 #define MISDN_CTRL_RX_BUFFER		0x0008
368 #define MISDN_CTRL_PCMCONNECT		0x0010
369 #define MISDN_CTRL_PCMDISCONNECT	0x0020
370 #define MISDN_CTRL_SETPEER		0x0040
371 #define MISDN_CTRL_UNSETPEER		0x0080
372 #define MISDN_CTRL_RX_OFF		0x0100
373 #define MISDN_CTRL_FILL_EMPTY		0x0200
374 #define MISDN_CTRL_GETPEER		0x0400
375 #define MISDN_CTRL_L1_TIMER3		0x0800
376 #define MISDN_CTRL_HW_FEATURES_OP	0x2000
377 #define MISDN_CTRL_HW_FEATURES		0x2001
378 #define MISDN_CTRL_HFC_OP		0x4000
379 #define MISDN_CTRL_HFC_PCM_CONN		0x4001
380 #define MISDN_CTRL_HFC_PCM_DISC		0x4002
381 #define MISDN_CTRL_HFC_CONF_JOIN	0x4003
382 #define MISDN_CTRL_HFC_CONF_SPLIT	0x4004
383 #define MISDN_CTRL_HFC_RECEIVE_OFF	0x4005
384 #define MISDN_CTRL_HFC_RECEIVE_ON	0x4006
385 #define MISDN_CTRL_HFC_ECHOCAN_ON 	0x4007
386 #define MISDN_CTRL_HFC_ECHOCAN_OFF 	0x4008
387 #define MISDN_CTRL_HFC_WD_INIT		0x4009
388 #define MISDN_CTRL_HFC_WD_RESET		0x400A
389 
390 /* special RX buffer value for MISDN_CTRL_RX_BUFFER request.p1 is the minimum
391  * buffer size request.p2 the maximum. Using  MISDN_CTRL_RX_SIZE_IGNORE will
392  * not change the value, but still read back the actual stetting.
393  */
394 #define MISDN_CTRL_RX_SIZE_IGNORE	-1
395 
396 /* socket options */
397 #define MISDN_TIME_STAMP		0x0001
398 
399 struct mISDN_ctrl_req {
400 	int		op;
401 	int		channel;
402 	int		p1;
403 	int		p2;
404 };
405 
406 /* muxer options */
407 #define MISDN_OPT_ALL		1
408 #define MISDN_OPT_TEIMGR	2
409 
410 #ifdef __KERNEL__
411 #include <linux/list.h>
412 #include <linux/skbuff.h>
413 #include <linux/net.h>
414 #include <net/sock.h>
415 #include <linux/completion.h>
416 
417 #define DEBUG_CORE		0x000000ff
418 #define DEBUG_CORE_FUNC		0x00000002
419 #define DEBUG_SOCKET		0x00000004
420 #define DEBUG_MANAGER		0x00000008
421 #define DEBUG_SEND_ERR		0x00000010
422 #define DEBUG_MSG_THREAD	0x00000020
423 #define DEBUG_QUEUE_FUNC	0x00000040
424 #define DEBUG_L1		0x0000ff00
425 #define DEBUG_L1_FSM		0x00000200
426 #define DEBUG_L2		0x00ff0000
427 #define DEBUG_L2_FSM		0x00020000
428 #define DEBUG_L2_CTRL		0x00040000
429 #define DEBUG_L2_RECV		0x00080000
430 #define DEBUG_L2_TEI		0x00100000
431 #define DEBUG_L2_TEIFSM		0x00200000
432 #define DEBUG_TIMER		0x01000000
433 #define DEBUG_CLOCK		0x02000000
434 
435 #define mISDN_HEAD_P(s)		((struct mISDNhead *)&s->cb[0])
436 #define mISDN_HEAD_PRIM(s)	(((struct mISDNhead *)&s->cb[0])->prim)
437 #define mISDN_HEAD_ID(s)	(((struct mISDNhead *)&s->cb[0])->id)
438 
439 /* socket states */
440 #define MISDN_OPEN	1
441 #define MISDN_BOUND	2
442 #define MISDN_CLOSED	3
443 
444 struct mISDNchannel;
445 struct mISDNdevice;
446 struct mISDNstack;
447 struct mISDNclock;
448 
449 struct channel_req {
450 	u_int			protocol;
451 	struct sockaddr_mISDN	adr;
452 	struct mISDNchannel	*ch;
453 };
454 
455 typedef	int	(ctrl_func_t)(struct mISDNchannel *, u_int, void *);
456 typedef	int	(send_func_t)(struct mISDNchannel *, struct sk_buff *);
457 typedef int	(create_func_t)(struct channel_req *);
458 
459 struct Bprotocol {
460 	struct list_head	list;
461 	char			*name;
462 	u_int			Bprotocols;
463 	create_func_t		*create;
464 };
465 
466 struct mISDNchannel {
467 	struct list_head	list;
468 	u_int			protocol;
469 	u_int			nr;
470 	u_long			opt;
471 	u_int			addr;
472 	struct mISDNstack	*st;
473 	struct mISDNchannel	*peer;
474 	send_func_t		*send;
475 	send_func_t		*recv;
476 	ctrl_func_t		*ctrl;
477 };
478 
479 struct mISDN_sock_list {
480 	struct hlist_head	head;
481 	rwlock_t		lock;
482 };
483 
484 struct mISDN_sock {
485 	struct sock		sk;
486 	struct mISDNchannel	ch;
487 	u_int			cmask;
488 	struct mISDNdevice	*dev;
489 };
490 
491 
492 
493 struct mISDNdevice {
494 	struct mISDNchannel	D;
495 	u_int			id;
496 	u_int			Dprotocols;
497 	u_int			Bprotocols;
498 	u_int			nrbchan;
499 	u_char			channelmap[MISDN_CHMAP_SIZE];
500 	struct list_head	bchannels;
501 	struct mISDNchannel	*teimgr;
502 	struct device		dev;
503 };
504 
505 struct mISDNstack {
506 	u_long			status;
507 	struct mISDNdevice	*dev;
508 	struct task_struct	*thread;
509 	struct completion	*notify;
510 	wait_queue_head_t	workq;
511 	struct sk_buff_head	msgq;
512 	struct list_head	layer2;
513 	struct mISDNchannel	*layer1;
514 	struct mISDNchannel	own;
515 	struct mutex		lmutex; /* protect lists */
516 	struct mISDN_sock_list	l1sock;
517 #ifdef MISDN_MSG_STATS
518 	u_int			msg_cnt;
519 	u_int			sleep_cnt;
520 	u_int			stopped_cnt;
521 #endif
522 };
523 
524 typedef	int	(clockctl_func_t)(void *, int);
525 
526 struct	mISDNclock {
527 	struct list_head	list;
528 	char			name[64];
529 	int			pri;
530 	clockctl_func_t		*ctl;
531 	void			*priv;
532 };
533 
534 /* global alloc/queue functions */
535 
536 static inline struct sk_buff *
mI_alloc_skb(unsigned int len,gfp_t gfp_mask)537 mI_alloc_skb(unsigned int len, gfp_t gfp_mask)
538 {
539 	struct sk_buff	*skb;
540 
541 	skb = alloc_skb(len + MISDN_HEADER_LEN, gfp_mask);
542 	if (likely(skb))
543 		skb_reserve(skb, MISDN_HEADER_LEN);
544 	return skb;
545 }
546 
547 static inline struct sk_buff *
_alloc_mISDN_skb(u_int prim,u_int id,u_int len,void * dp,gfp_t gfp_mask)548 _alloc_mISDN_skb(u_int prim, u_int id, u_int len, void *dp, gfp_t gfp_mask)
549 {
550 	struct sk_buff	*skb = mI_alloc_skb(len, gfp_mask);
551 	struct mISDNhead *hh;
552 
553 	if (!skb)
554 		return NULL;
555 	if (len)
556 		skb_put_data(skb, dp, len);
557 	hh = mISDN_HEAD_P(skb);
558 	hh->prim = prim;
559 	hh->id = id;
560 	return skb;
561 }
562 
563 static inline void
_queue_data(struct mISDNchannel * ch,u_int prim,u_int id,u_int len,void * dp,gfp_t gfp_mask)564 _queue_data(struct mISDNchannel *ch, u_int prim,
565     u_int id, u_int len, void *dp, gfp_t gfp_mask)
566 {
567 	struct sk_buff		*skb;
568 
569 	if (!ch->peer)
570 		return;
571 	skb = _alloc_mISDN_skb(prim, id, len, dp, gfp_mask);
572 	if (!skb)
573 		return;
574 	if (ch->recv(ch->peer, skb))
575 		dev_kfree_skb(skb);
576 }
577 
578 /* global register/unregister functions */
579 
580 extern int	mISDN_register_device(struct mISDNdevice *,
581 					struct device *parent, char *name);
582 extern void	mISDN_unregister_device(struct mISDNdevice *);
583 extern int	mISDN_register_Bprotocol(struct Bprotocol *);
584 extern void	mISDN_unregister_Bprotocol(struct Bprotocol *);
585 extern struct mISDNclock *mISDN_register_clock(char *, int, clockctl_func_t *,
586 						void *);
587 extern void	mISDN_unregister_clock(struct mISDNclock *);
588 
dev_to_mISDN(const struct device * dev)589 static inline struct mISDNdevice *dev_to_mISDN(const struct device *dev)
590 {
591 	if (dev)
592 		return dev_get_drvdata(dev);
593 	else
594 		return NULL;
595 }
596 
597 extern void	set_channel_address(struct mISDNchannel *, u_int, u_int);
598 extern void	mISDN_clock_update(struct mISDNclock *, int, ktime_t *);
599 extern unsigned short mISDN_clock_get(void);
600 extern const char *mISDNDevName4ch(struct mISDNchannel *);
601 
602 #endif /* __KERNEL__ */
603 #endif /* mISDNIF_H */
604