xref: /linux/drivers/isdn/mISDN/fsm.h (revision 24bce201d79807b668bf9d9e0aca801c5c0d5f78)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  *
4  * Author       Karsten Keil <kkeil@novell.com>
5  *
6  * Thanks to    Jan den Ouden
7  *              Fritz Elfert
8  * Copyright 2008  by Karsten Keil <kkeil@novell.com>
9  */
10 
11 #ifndef _MISDN_FSM_H
12 #define _MISDN_FSM_H
13 
14 #include <linux/timer.h>
15 
16 /* Statemachine */
17 
18 struct FsmInst;
19 
20 typedef void (*FSMFNPTR)(struct FsmInst *, int, void *);
21 
22 struct Fsm {
23 	FSMFNPTR *jumpmatrix;
24 	int state_count, event_count;
25 	char **strEvent, **strState;
26 };
27 
28 struct FsmInst {
29 	struct Fsm *fsm;
30 	int state;
31 	int debug;
32 	void *userdata;
33 	int userint;
34 	void (*printdebug) (struct FsmInst *, char *, ...);
35 };
36 
37 struct FsmNode {
38 	int state, event;
39 	void (*routine) (struct FsmInst *, int, void *);
40 };
41 
42 struct FsmTimer {
43 	struct FsmInst *fi;
44 	struct timer_list tl;
45 	int event;
46 	void *arg;
47 };
48 
49 extern int mISDN_FsmNew(struct Fsm *, struct FsmNode *, int);
50 extern void mISDN_FsmFree(struct Fsm *);
51 extern int mISDN_FsmEvent(struct FsmInst *, int , void *);
52 extern void mISDN_FsmChangeState(struct FsmInst *, int);
53 extern void mISDN_FsmInitTimer(struct FsmInst *, struct FsmTimer *);
54 extern int mISDN_FsmAddTimer(struct FsmTimer *, int, int, void *, int);
55 extern void mISDN_FsmRestartTimer(struct FsmTimer *, int, int, void *, int);
56 extern void mISDN_FsmDelTimer(struct FsmTimer *, int);
57 
58 #endif
59