1*1802d0beSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 21b2b03f8SKarsten Keil /* 31b2b03f8SKarsten Keil * 41b2b03f8SKarsten Keil * Author Karsten Keil <kkeil@novell.com> 51b2b03f8SKarsten Keil * 61b2b03f8SKarsten Keil * Thanks to Jan den Ouden 71b2b03f8SKarsten Keil * Fritz Elfert 81b2b03f8SKarsten Keil * Copyright 2008 by Karsten Keil <kkeil@novell.com> 91b2b03f8SKarsten Keil */ 101b2b03f8SKarsten Keil 111b2b03f8SKarsten Keil #ifndef _MISDN_FSM_H 121b2b03f8SKarsten Keil #define _MISDN_FSM_H 131b2b03f8SKarsten Keil 141b2b03f8SKarsten Keil #include <linux/timer.h> 151b2b03f8SKarsten Keil 161b2b03f8SKarsten Keil /* Statemachine */ 171b2b03f8SKarsten Keil 181b2b03f8SKarsten Keil struct FsmInst; 191b2b03f8SKarsten Keil 201b2b03f8SKarsten Keil typedef void (*FSMFNPTR)(struct FsmInst *, int, void *); 211b2b03f8SKarsten Keil 221b2b03f8SKarsten Keil struct Fsm { 231b2b03f8SKarsten Keil FSMFNPTR *jumpmatrix; 241b2b03f8SKarsten Keil int state_count, event_count; 251b2b03f8SKarsten Keil char **strEvent, **strState; 261b2b03f8SKarsten Keil }; 271b2b03f8SKarsten Keil 281b2b03f8SKarsten Keil struct FsmInst { 291b2b03f8SKarsten Keil struct Fsm *fsm; 301b2b03f8SKarsten Keil int state; 311b2b03f8SKarsten Keil int debug; 321b2b03f8SKarsten Keil void *userdata; 331b2b03f8SKarsten Keil int userint; 341b2b03f8SKarsten Keil void (*printdebug) (struct FsmInst *, char *, ...); 351b2b03f8SKarsten Keil }; 361b2b03f8SKarsten Keil 371b2b03f8SKarsten Keil struct FsmNode { 381b2b03f8SKarsten Keil int state, event; 391b2b03f8SKarsten Keil void (*routine) (struct FsmInst *, int, void *); 401b2b03f8SKarsten Keil }; 411b2b03f8SKarsten Keil 421b2b03f8SKarsten Keil struct FsmTimer { 431b2b03f8SKarsten Keil struct FsmInst *fi; 441b2b03f8SKarsten Keil struct timer_list tl; 451b2b03f8SKarsten Keil int event; 461b2b03f8SKarsten Keil void *arg; 471b2b03f8SKarsten Keil }; 481b2b03f8SKarsten Keil 4954a6a043SAnton Vasilyev extern int mISDN_FsmNew(struct Fsm *, struct FsmNode *, int); 501b2b03f8SKarsten Keil extern void mISDN_FsmFree(struct Fsm *); 511b2b03f8SKarsten Keil extern int mISDN_FsmEvent(struct FsmInst *, int , void *); 521b2b03f8SKarsten Keil extern void mISDN_FsmChangeState(struct FsmInst *, int); 531b2b03f8SKarsten Keil extern void mISDN_FsmInitTimer(struct FsmInst *, struct FsmTimer *); 541b2b03f8SKarsten Keil extern int mISDN_FsmAddTimer(struct FsmTimer *, int, int, void *, int); 551b2b03f8SKarsten Keil extern void mISDN_FsmRestartTimer(struct FsmTimer *, int, int, void *, int); 561b2b03f8SKarsten Keil extern void mISDN_FsmDelTimer(struct FsmTimer *, int); 571b2b03f8SKarsten Keil 581b2b03f8SKarsten Keil #endif 59