7 #include <linux/module.h>
8 #include <linux/slab.h>
16 init_fsm(
char *
name,
const char **state_names,
const char **event_names,
int nr_states,
27 "fsm(%s): init_fsm: Couldn't alloc instance\n", name);
30 strlcpy(this->name, name,
sizeof(this->name));
33 f = kzalloc(
sizeof(
fsm), order);
36 "fsm(%s): init_fsm: Couldn't alloc fsm\n", name);
49 "fsm(%s): init_fsm: Couldn't alloc jumptable\n", name);
55 for (i = 0; i < tmpl_len; i++) {
56 if ((tmpl[i].cond_state >= nr_states) ||
57 (tmpl[i].cond_event >= nr_events) ) {
59 "fsm(%s): init_fsm: Bad template l=%d st(%ld/%ld) ev(%ld/%ld)\n",
60 name, i, (
long)tmpl[i].cond_state, (
long)f->
nr_states,
76 kfree(this->
f->jumpmatrix);
82 "fsm: kfree_fsm called with NULL argument\n");
93 idx = fi->history_index;
96 for (i = 0; i < fi->history_size; i++) {
97 int e = fi->history[
idx].event;
98 int s = fi->history[idx++].
state;
108 fi->history_size = fi->history_index = 0;
115 fi->history[fi->history_index++].event =
event;
136 this->fi->
name,
this);
138 fsm_event(this->fi, this->expire_event, this->event_arg);
145 this->tl.function = (
void *)fsm_expire_timer;
146 this->tl.data = (
long)
this;
170 this->fi->
name,
this, millisec);
174 this->tl.function = (
void *)fsm_expire_timer;
175 this->tl.data = (
long)
this;
176 this->expire_event =
event;
177 this->event_arg =
arg;
178 this->tl.expires =
jiffies + (millisec *
HZ) / 1000;
190 this->fi->
name,
this, millisec);
195 this->tl.function = (
void *)fsm_expire_timer;
196 this->tl.data = (
long)
this;
197 this->expire_event =
event;
198 this->event_arg =
arg;
199 this->tl.expires =
jiffies + (millisec *
HZ) / 1000;
211 #if FSM_DEBUG_HISTORY