Commit 0aaffcee authored by Daniel Drake's avatar Daniel Drake

Allow jumping to arbitrary state in a SSM

This is looking less and less like a simple state machine now, but it's
proving a useful model!
parent 77b5dab0
......@@ -297,6 +297,11 @@ void fpi_drvcb_identify_stopped(struct fp_dev *dev)
* There is also an implicit error state and an implicit accepting state
* (both with implicit edges from every state).
* You can also jump to any arbitrary state (while marking completion of the
* current state) while the machine is running. In other words there are
* implicit edges linking one state to every other state. OK, we're stretching
* the "state machine" description at this point.
* To create a ssm, you pass a state handler function and the total number of
* states (4 in the above example).
......@@ -377,7 +382,7 @@ void fpi_ssm_mark_completed(struct fpi_ssm *machine)
/* Mark a ssm as aborted with error. */
void fpi_ssm_mark_aborted(struct fpi_ssm *machine, int error)
fp_dbg("error %d", error);
fp_dbg("error %d from state %d", error, machine->cur_state);
BUG_ON(error == 0);
machine->error = error;
......@@ -395,3 +400,11 @@ void fpi_ssm_next_state(struct fpi_ssm *machine)
void fpi_ssm_jump_to_state(struct fpi_ssm *machine, int state)
BUG_ON(state >= machine->nr_states);
machine->cur_state = state;
......@@ -349,6 +349,7 @@ int fpi_ssm_has_completed(struct fpi_ssm *machine);
/* for drivers */
void fpi_ssm_next_state(struct fpi_ssm *machine);
void fpi_ssm_jump_to_state(struct fpi_ssm *machine, int state);
void fpi_ssm_mark_completed(struct fpi_ssm *machine);
void fpi_ssm_mark_aborted(struct fpi_ssm *machine, int error);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment