Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 12ef6544 authored by Edmund Nadolski's avatar Edmund Nadolski Committed by Dan Williams
Browse files

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: default avatarEdmund Nadolski <edmund.nadolski@intel.com>
[fixed too large to inline functions]
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent e301370a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@ obj-$(CONFIG_SCSI_ISCI) += isci.o
isci-objs := init.o phy.o request.o sata.o \
	     remote_device.o port.o \
	     host.o task.o probe_roms.o \
	     state_machine.o \
	     remote_node_context.o \
	     remote_node_table.o \
	     unsolicited_frame_control.o \
+34 −5
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@
#include "remote_device.h"
#include "phy.h"
#include "pool.h"
#include "state_machine.h"
#include "isci.h"
#include "remote_node_table.h"
#include "registers.h"
#include "scu_unsolicited_frame.h"
+19 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@
#define __ISCI_H__

#include <linux/interrupt.h>
#include <linux/types.h>

#define DRV_NAME "isci"
#define SCI_PCI_BAR_COUNT 2
@@ -584,4 +585,22 @@ static inline void sci_del_timer(struct sci_timer *tmr)
	del_timer(&tmr->timer);
}

struct sci_base_state_machine {
	const struct sci_base_state *state_table;
	u32 initial_state_id;
	u32 current_state_id;
	u32 previous_state_id;
};

typedef void (*sci_state_transition_t)(struct sci_base_state_machine *sm);

struct sci_base_state {
	sci_state_transition_t enter_state;	/* Called on state entry */
	sci_state_transition_t exit_state;	/* Called on state exit */
};

extern void sci_init_sm(struct sci_base_state_machine *sm,
			const struct sci_base_state *state_table,
			u32 initial_state);
extern void sci_change_state(struct sci_base_state_machine *sm, u32 next_state);
#endif  /* __ISCI_H__ */
+1 −5
Original line number Diff line number Diff line
@@ -1294,11 +1294,7 @@ static const struct sci_base_state scic_sds_phy_state_table[] = {
void scic_sds_phy_construct(struct scic_sds_phy *sci_phy,
			    struct scic_sds_port *owning_port, u8 phy_index)
{
	sci_base_state_machine_construct(&sci_phy->sm,
					 scic_sds_phy_state_table,
					 SCI_PHY_INITIAL);

	sci_base_state_machine_start(&sci_phy->sm);
	sci_init_sm(&sci_phy->sm, scic_sds_phy_state_table, SCI_PHY_INITIAL);

	/* Copy the rest of the input data to our locals */
	sci_phy->owning_port = owning_port;
Loading