aboutsummaryrefslogtreecommitdiff
path: root/drivers/scsi/isci/host.c
diff options
context:
space:
mode:
authorEdmund Nadolski <edmund.nadolski@intel.com>2011-06-02 00:10:50 +0000
committerDan Williams <dan.j.williams@intel.com>2011-07-03 04:04:50 -0700
commit12ef65444de9d387a383b9991960848bed5bbe74 (patch)
treecc7145adf102b57ae4bc347974b23974d795d2c8 /drivers/scsi/isci/host.c
parente301370ac553a9a0ac0d1d25e769b86cf60395b3 (diff)
isci: additional state machine cleanup
Additional state machine cleanups: o Remove static functions sci_state_machine_exit_state() and sci_state_machine_enter_state() o Combines sci_base_state_machine_construct() and sci_base_state_machine_start() into a single function, sci_init_sm() o Remove sci_base_state_machine_stop() which is unused. o Kill state_machine.[ch] Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com> [fixed too large to inline functions] Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/scsi/isci/host.c')
-rw-r--r--drivers/scsi/isci/host.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c
index 81ee64c0a4b..f502882a2e1 100644
--- a/drivers/scsi/isci/host.c
+++ b/drivers/scsi/isci/host.c
@@ -197,6 +197,39 @@
*/
#define COMPLETION_QUEUE_CYCLE_BIT(x) ((x) & 0x80000000)
+/* Init the state machine and call the state entry function (if any) */
+void sci_init_sm(struct sci_base_state_machine *sm,
+ const struct sci_base_state *state_table, u32 initial_state)
+{
+ sci_state_transition_t handler;
+
+ sm->initial_state_id = initial_state;
+ sm->previous_state_id = initial_state;
+ sm->current_state_id = initial_state;
+ sm->state_table = state_table;
+
+ handler = sm->state_table[initial_state].enter_state;
+ if (handler)
+ handler(sm);
+}
+
+/* Call the state exit fn, update the current state, call the state entry fn */
+void sci_change_state(struct sci_base_state_machine *sm, u32 next_state)
+{
+ sci_state_transition_t handler;
+
+ handler = sm->state_table[sm->current_state_id].exit_state;
+ if (handler)
+ handler(sm);
+
+ sm->previous_state_id = sm->current_state_id;
+ sm->current_state_id = next_state;
+
+ handler = sm->state_table[sm->current_state_id].enter_state;
+ if (handler)
+ handler(sm);
+}
+
static bool scic_sds_controller_completion_queue_has_entries(
struct scic_sds_controller *scic)
{
@@ -1807,11 +1840,7 @@ static enum sci_status scic_controller_construct(struct scic_sds_controller *sci
struct isci_host *ihost = scic_to_ihost(scic);
u8 i;
- sci_base_state_machine_construct(&scic->sm,
- scic_sds_controller_state_table,
- SCIC_INITIAL);
-
- sci_base_state_machine_start(&scic->sm);
+ sci_init_sm(&scic->sm, scic_sds_controller_state_table, SCIC_INITIAL);
scic->scu_registers = scu_base;
scic->smu_registers = smu_base;