isci: add some type safety to the state machine interface

Now that any given object type only has one state_machine we can use
container_of() to get back to the given state machine owner.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
Dan Williams 2011-05-12 07:42:17 -07:00
Родитель f34d9e5d3f
Коммит 9269e0e898
8 изменённых файлов: 148 добавлений и 194 удалений

Просмотреть файл

@ -1404,17 +1404,17 @@ static void isci_user_parameters_get(
u->max_number_concurrent_device_spin_up = max_concurr_spinup; u->max_number_concurrent_device_spin_up = max_concurr_spinup;
} }
static void scic_sds_controller_initial_state_enter(void *object) static void scic_sds_controller_initial_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_controller *scic = object; struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
sci_base_state_machine_change_state(&scic->state_machine, sci_base_state_machine_change_state(&scic->state_machine,
SCI_BASE_CONTROLLER_STATE_RESET); SCI_BASE_CONTROLLER_STATE_RESET);
} }
static inline void scic_sds_controller_starting_state_exit(void *object) static inline void scic_sds_controller_starting_state_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_controller *scic = object; struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
isci_timer_stop(scic->timeout_timer); isci_timer_stop(scic->timeout_timer);
} }
@ -1539,17 +1539,17 @@ static enum sci_status scic_controller_set_interrupt_coalescence(
} }
static void scic_sds_controller_ready_state_enter(void *object) static void scic_sds_controller_ready_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_controller *scic = object; struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
/* set the default interrupt coalescence number and timeout value. */ /* set the default interrupt coalescence number and timeout value. */
scic_controller_set_interrupt_coalescence(scic, 0x10, 250); scic_controller_set_interrupt_coalescence(scic, 0x10, 250);
} }
static void scic_sds_controller_ready_state_exit(void *object) static void scic_sds_controller_ready_state_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_controller *scic = object; struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
/* disable interrupt coalescence. */ /* disable interrupt coalescence. */
scic_controller_set_interrupt_coalescence(scic, 0, 0); scic_controller_set_interrupt_coalescence(scic, 0, 0);
@ -1638,9 +1638,9 @@ static enum sci_status scic_sds_controller_stop_devices(struct scic_sds_controll
return status; return status;
} }
static void scic_sds_controller_stopping_state_enter(void *object) static void scic_sds_controller_stopping_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_controller *scic = object; struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
/* Stop all of the components for this controller */ /* Stop all of the components for this controller */
scic_sds_controller_stop_phys(scic); scic_sds_controller_stop_phys(scic);
@ -1648,9 +1648,9 @@ static void scic_sds_controller_stopping_state_enter(void *object)
scic_sds_controller_stop_devices(scic); scic_sds_controller_stop_devices(scic);
} }
static void scic_sds_controller_stopping_state_exit(void *object) static void scic_sds_controller_stopping_state_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_controller *scic = object; struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
isci_timer_stop(scic->timeout_timer); isci_timer_stop(scic->timeout_timer);
} }
@ -1679,9 +1679,9 @@ static void scic_sds_controller_reset_hardware(struct scic_sds_controller *scic)
writel(0, &scic->scu_registers->sdma.unsolicited_frame_get_pointer); writel(0, &scic->scu_registers->sdma.unsolicited_frame_get_pointer);
} }
static void scic_sds_controller_resetting_state_enter(void *object) static void scic_sds_controller_resetting_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_controller *scic = object; struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
scic_sds_controller_reset_hardware(scic); scic_sds_controller_reset_hardware(scic);
sci_base_state_machine_change_state(&scic->state_machine, sci_base_state_machine_change_state(&scic->state_machine,
@ -1785,8 +1785,8 @@ static enum sci_status scic_controller_construct(struct scic_sds_controller *sci
u8 i; u8 i;
sci_base_state_machine_construct(&scic->state_machine, sci_base_state_machine_construct(&scic->state_machine,
scic, scic_sds_controller_state_table, scic_sds_controller_state_table,
SCI_BASE_CONTROLLER_STATE_INITIAL); SCI_BASE_CONTROLLER_STATE_INITIAL);
sci_base_state_machine_start(&scic->state_machine); sci_base_state_machine_start(&scic->state_machine);

Просмотреть файл

@ -1026,81 +1026,80 @@ enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy,
} }
static void scic_sds_phy_starting_initial_substate_enter(void *object) static void scic_sds_phy_starting_initial_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = object; struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
/* This is just an temporary state go off to the starting state */ /* This is just an temporary state go off to the starting state */
sci_base_state_machine_change_state(&sci_phy->state_machine, sci_base_state_machine_change_state(&sci_phy->state_machine,
SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN); SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN);
} }
static void scic_sds_phy_starting_await_sas_power_substate_enter(void *object) static void scic_sds_phy_starting_await_sas_power_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = object; struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller; struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller;
scic_sds_controller_power_control_queue_insert(scic, sci_phy); scic_sds_controller_power_control_queue_insert(scic, sci_phy);
} }
static void scic_sds_phy_starting_await_sas_power_substate_exit(void *object) static void scic_sds_phy_starting_await_sas_power_substate_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = object; struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller; struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller;
scic_sds_controller_power_control_queue_remove(scic, sci_phy); scic_sds_controller_power_control_queue_remove(scic, sci_phy);
} }
static void scic_sds_phy_starting_await_sata_power_substate_enter(void *object) static void scic_sds_phy_starting_await_sata_power_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = object; struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller; struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller;
scic_sds_controller_power_control_queue_insert(scic, sci_phy); scic_sds_controller_power_control_queue_insert(scic, sci_phy);
} }
static void scic_sds_phy_starting_await_sata_power_substate_exit(void *object) static void scic_sds_phy_starting_await_sata_power_substate_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = object; struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller; struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller;
scic_sds_controller_power_control_queue_remove(scic, sci_phy); scic_sds_controller_power_control_queue_remove(scic, sci_phy);
} }
static void scic_sds_phy_starting_await_sata_phy_substate_enter(void *object) static void scic_sds_phy_starting_await_sata_phy_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = object; struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
isci_timer_start(sci_phy->sata_timeout_timer, isci_timer_start(sci_phy->sata_timeout_timer,
SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT); SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT);
} }
static void scic_sds_phy_starting_await_sata_phy_substate_exit(void *object) static void scic_sds_phy_starting_await_sata_phy_substate_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = object; struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
isci_timer_stop(sci_phy->sata_timeout_timer); isci_timer_stop(sci_phy->sata_timeout_timer);
} }
static void scic_sds_phy_starting_await_sata_speed_substate_enter(void *object) static void scic_sds_phy_starting_await_sata_speed_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = object; struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
isci_timer_start(sci_phy->sata_timeout_timer, isci_timer_start(sci_phy->sata_timeout_timer,
SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT); SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT);
} }
static void scic_sds_phy_starting_await_sata_speed_substate_exit( static void scic_sds_phy_starting_await_sata_speed_substate_exit(struct sci_base_state_machine *sm)
void *object)
{ {
struct scic_sds_phy *sci_phy = object; struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
isci_timer_stop(sci_phy->sata_timeout_timer); isci_timer_stop(sci_phy->sata_timeout_timer);
} }
static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(void *object) static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = object; struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
if (scic_sds_port_link_detected(sci_phy->owning_port, sci_phy)) { if (scic_sds_port_link_detected(sci_phy->owning_port, sci_phy)) {
@ -1118,16 +1117,16 @@ static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(void *object)
sci_phy->is_in_link_training = false; sci_phy->is_in_link_training = false;
} }
static void scic_sds_phy_starting_await_sig_fis_uf_substate_exit(void *object) static void scic_sds_phy_starting_await_sig_fis_uf_substate_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = object; struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
isci_timer_stop(sci_phy->sata_timeout_timer); isci_timer_stop(sci_phy->sata_timeout_timer);
} }
static void scic_sds_phy_starting_final_substate_enter(void *object) static void scic_sds_phy_starting_final_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = object; struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
/* State machine has run to completion so exit out and change /* State machine has run to completion so exit out and change
* the base state machine to the ready state * the base state machine to the ready state
@ -1217,9 +1216,9 @@ static void scu_link_layer_tx_hard_reset(
&sci_phy->link_layer_registers->phy_configuration); &sci_phy->link_layer_registers->phy_configuration);
} }
static void scic_sds_phy_stopped_state_enter(void *object) static void scic_sds_phy_stopped_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = object; struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
struct scic_sds_port *sci_port = sci_phy->owning_port; struct scic_sds_port *sci_port = sci_phy->owning_port;
struct scic_sds_controller *scic = sci_port->owning_controller; struct scic_sds_controller *scic = sci_port->owning_controller;
struct isci_host *ihost = scic_to_ihost(scic); struct isci_host *ihost = scic_to_ihost(scic);
@ -1242,9 +1241,9 @@ static void scic_sds_phy_stopped_state_enter(void *object)
sci_phy); sci_phy);
} }
static void scic_sds_phy_starting_state_enter(void *object) static void scic_sds_phy_starting_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = object; struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
scu_link_layer_stop_protocol_engine(sci_phy); scu_link_layer_stop_protocol_engine(sci_phy);
scu_link_layer_start_oob(sci_phy); scu_link_layer_start_oob(sci_phy);
@ -1262,9 +1261,9 @@ static void scic_sds_phy_starting_state_enter(void *object)
SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL); SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL);
} }
static void scic_sds_phy_ready_state_enter(void *object) static void scic_sds_phy_ready_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = object; struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
scic_sds_controller_link_up(scic_sds_phy_get_controller(sci_phy), scic_sds_controller_link_up(scic_sds_phy_get_controller(sci_phy),
phy_get_non_dummy_port(sci_phy), phy_get_non_dummy_port(sci_phy),
@ -1272,16 +1271,16 @@ static void scic_sds_phy_ready_state_enter(void *object)
} }
static void scic_sds_phy_ready_state_exit(void *object) static void scic_sds_phy_ready_state_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = object; struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
scic_sds_phy_suspend(sci_phy); scic_sds_phy_suspend(sci_phy);
} }
static void scic_sds_phy_resetting_state_enter(void *object) static void scic_sds_phy_resetting_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_phy *sci_phy = object; struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
/* The phy is being reset, therefore deactivate it from the port. In /* The phy is being reset, therefore deactivate it from the port. In
* the resetting state we don't notify the user regarding link up and * the resetting state we don't notify the user regarding link up and
@ -1351,7 +1350,6 @@ void scic_sds_phy_construct(struct scic_sds_phy *sci_phy,
struct scic_sds_port *owning_port, u8 phy_index) struct scic_sds_port *owning_port, u8 phy_index)
{ {
sci_base_state_machine_construct(&sci_phy->state_machine, sci_base_state_machine_construct(&sci_phy->state_machine,
sci_phy,
scic_sds_phy_state_table, scic_sds_phy_state_table,
SCI_BASE_PHY_STATE_INITIAL); SCI_BASE_PHY_STATE_INITIAL);

Просмотреть файл

@ -1133,9 +1133,9 @@ scic_sds_port_resume_port_task_scheduler(struct scic_sds_port *port)
writel(pts_control_value, &port->port_task_scheduler_registers->control); writel(pts_control_value, &port->port_task_scheduler_registers->control);
} }
static void scic_sds_port_ready_substate_waiting_enter(void *object) static void scic_sds_port_ready_substate_waiting_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_port *sci_port = object; struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
scic_sds_port_suspend_port_task_scheduler(sci_port); scic_sds_port_suspend_port_task_scheduler(sci_port);
@ -1148,10 +1148,10 @@ static void scic_sds_port_ready_substate_waiting_enter(void *object)
} }
} }
static void scic_sds_port_ready_substate_operational_enter(void *object) static void scic_sds_port_ready_substate_operational_enter(struct sci_base_state_machine *sm)
{ {
u32 index; u32 index;
struct scic_sds_port *sci_port = object; struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
struct scic_sds_controller *scic = sci_port->owning_controller; struct scic_sds_controller *scic = sci_port->owning_controller;
struct isci_host *ihost = scic_to_ihost(scic); struct isci_host *ihost = scic_to_ihost(scic);
struct isci_port *iport = sci_port_to_iport(sci_port); struct isci_port *iport = sci_port_to_iport(sci_port);
@ -1210,9 +1210,9 @@ static void scic_sds_port_invalidate_dummy_remote_node(struct scic_sds_port *sci
* exiting the SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL. This function reports * exiting the SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL. This function reports
* the port not ready and suspends the port task scheduler. none * the port not ready and suspends the port task scheduler. none
*/ */
static void scic_sds_port_ready_substate_operational_exit(void *object) static void scic_sds_port_ready_substate_operational_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_port *sci_port = object; struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
struct scic_sds_controller *scic = sci_port->owning_controller; struct scic_sds_controller *scic = sci_port->owning_controller;
struct isci_host *ihost = scic_to_ihost(scic); struct isci_host *ihost = scic_to_ihost(scic);
struct isci_port *iport = sci_port_to_iport(sci_port); struct isci_port *iport = sci_port_to_iport(sci_port);
@ -1230,9 +1230,9 @@ static void scic_sds_port_ready_substate_operational_exit(void *object)
scic_sds_port_invalidate_dummy_remote_node(sci_port); scic_sds_port_invalidate_dummy_remote_node(sci_port);
} }
static void scic_sds_port_ready_substate_configuring_enter(void *object) static void scic_sds_port_ready_substate_configuring_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_port *sci_port = object; struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
struct scic_sds_controller *scic = sci_port->owning_controller; struct scic_sds_controller *scic = sci_port->owning_controller;
struct isci_host *ihost = scic_to_ihost(scic); struct isci_host *ihost = scic_to_ihost(scic);
struct isci_port *iport = sci_port_to_iport(sci_port); struct isci_port *iport = sci_port_to_iport(sci_port);
@ -1247,9 +1247,9 @@ static void scic_sds_port_ready_substate_configuring_enter(void *object)
SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL); SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL);
} }
static void scic_sds_port_ready_substate_configuring_exit(void *object) static void scic_sds_port_ready_substate_configuring_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_port *sci_port = object; struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
scic_sds_port_suspend_port_task_scheduler(sci_port); scic_sds_port_suspend_port_task_scheduler(sci_port);
if (sci_port->ready_exit) if (sci_port->ready_exit)
@ -1710,9 +1710,9 @@ static void scic_sds_port_post_dummy_remote_node(struct scic_sds_port *sci_port)
scic_sds_controller_post_request(scic, command); scic_sds_controller_post_request(scic, command);
} }
static void scic_sds_port_stopped_state_enter(void *object) static void scic_sds_port_stopped_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_port *sci_port = object; struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
if (sci_port->state_machine.previous_state_id == SCI_BASE_PORT_STATE_STOPPING) { if (sci_port->state_machine.previous_state_id == SCI_BASE_PORT_STATE_STOPPING) {
/* /*
@ -1723,17 +1723,17 @@ static void scic_sds_port_stopped_state_enter(void *object)
} }
} }
static void scic_sds_port_stopped_state_exit(void *object) static void scic_sds_port_stopped_state_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_port *sci_port = object; struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
/* Enable and suspend the port task scheduler */ /* Enable and suspend the port task scheduler */
scic_sds_port_enable_port_task_scheduler(sci_port); scic_sds_port_enable_port_task_scheduler(sci_port);
} }
static void scic_sds_port_ready_state_enter(void *object) static void scic_sds_port_ready_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_port *sci_port = object; struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
struct scic_sds_controller *scic = sci_port->owning_controller; struct scic_sds_controller *scic = sci_port->owning_controller;
struct isci_host *ihost = scic_to_ihost(scic); struct isci_host *ihost = scic_to_ihost(scic);
struct isci_port *iport = sci_port_to_iport(sci_port); struct isci_port *iport = sci_port_to_iport(sci_port);
@ -1753,25 +1753,25 @@ static void scic_sds_port_ready_state_enter(void *object)
SCIC_SDS_PORT_READY_SUBSTATE_WAITING); SCIC_SDS_PORT_READY_SUBSTATE_WAITING);
} }
static void scic_sds_port_resetting_state_exit(void *object) static void scic_sds_port_resetting_state_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_port *sci_port = object; struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
isci_timer_stop(sci_port->timer_handle); isci_timer_stop(sci_port->timer_handle);
} }
static void scic_sds_port_stopping_state_exit(void *object) static void scic_sds_port_stopping_state_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_port *sci_port = object; struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
isci_timer_stop(sci_port->timer_handle); isci_timer_stop(sci_port->timer_handle);
scic_sds_port_destroy_dummy_resources(sci_port); scic_sds_port_destroy_dummy_resources(sci_port);
} }
static void scic_sds_port_failed_state_enter(void *object) static void scic_sds_port_failed_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_port *sci_port = object; struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
struct isci_port *iport = sci_port_to_iport(sci_port); struct isci_port *iport = sci_port_to_iport(sci_port);
isci_port_hard_reset_complete(iport, SCI_FAILURE_TIMEOUT); isci_port_hard_reset_complete(iport, SCI_FAILURE_TIMEOUT);
@ -1813,7 +1813,6 @@ void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 index,
struct scic_sds_controller *scic) struct scic_sds_controller *scic)
{ {
sci_base_state_machine_construct(&sci_port->state_machine, sci_base_state_machine_construct(&sci_port->state_machine,
sci_port,
scic_sds_port_state_table, scic_sds_port_state_table,
SCI_BASE_PORT_STATE_STOPPED); SCI_BASE_PORT_STATE_STOPPED);

Просмотреть файл

@ -807,9 +807,9 @@ static void scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handl
isci_remote_device_ready(scic_to_ihost(scic), idev); isci_remote_device_ready(scic_to_ihost(scic), idev);
} }
static void scic_sds_remote_device_initial_state_enter(void *object) static void scic_sds_remote_device_initial_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = object; struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine);
/* Initial state is a transitional state to the stopped state */ /* Initial state is a transitional state to the stopped state */
sci_base_state_machine_change_state(&sci_dev->state_machine, sci_base_state_machine_change_state(&sci_dev->state_machine,
@ -904,9 +904,9 @@ static void isci_remote_device_stop_complete(struct isci_host *ihost,
isci_remote_device_deconstruct(ihost, idev); isci_remote_device_deconstruct(ihost, idev);
} }
static void scic_sds_remote_device_stopped_state_enter(void *object) static void scic_sds_remote_device_stopped_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = object; struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine);
struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller; struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller;
struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); struct isci_remote_device *idev = sci_dev_to_idev(sci_dev);
u32 prev_state; u32 prev_state;
@ -921,9 +921,9 @@ static void scic_sds_remote_device_stopped_state_enter(void *object)
scic_sds_controller_remote_device_stopped(scic, sci_dev); scic_sds_controller_remote_device_stopped(scic, sci_dev);
} }
static void scic_sds_remote_device_starting_state_enter(void *object) static void scic_sds_remote_device_starting_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = object; struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine);
struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
struct isci_host *ihost = scic_to_ihost(scic); struct isci_host *ihost = scic_to_ihost(scic);
struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); struct isci_remote_device *idev = sci_dev_to_idev(sci_dev);
@ -932,9 +932,9 @@ static void scic_sds_remote_device_starting_state_enter(void *object)
SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED); SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED);
} }
static void scic_sds_remote_device_ready_state_enter(void *object) static void scic_sds_remote_device_ready_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = object; struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine);
struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller; struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller;
struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); struct isci_remote_device *idev = sci_dev_to_idev(sci_dev);
struct domain_device *dev = idev->domain_dev; struct domain_device *dev = idev->domain_dev;
@ -951,9 +951,9 @@ static void scic_sds_remote_device_ready_state_enter(void *object)
isci_remote_device_ready(scic_to_ihost(scic), idev); isci_remote_device_ready(scic_to_ihost(scic), idev);
} }
static void scic_sds_remote_device_ready_state_exit(void *object) static void scic_sds_remote_device_ready_state_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = object; struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine);
struct domain_device *dev = sci_dev_to_domain(sci_dev); struct domain_device *dev = sci_dev_to_domain(sci_dev);
if (dev->dev_type == SAS_END_DEV) { if (dev->dev_type == SAS_END_DEV) {
@ -965,24 +965,24 @@ static void scic_sds_remote_device_ready_state_exit(void *object)
} }
} }
static void scic_sds_remote_device_resetting_state_enter(void *object) static void scic_sds_remote_device_resetting_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = object; struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine);
scic_sds_remote_node_context_suspend( scic_sds_remote_node_context_suspend(
&sci_dev->rnc, SCI_SOFTWARE_SUSPENSION, NULL, NULL); &sci_dev->rnc, SCI_SOFTWARE_SUSPENSION, NULL, NULL);
} }
static void scic_sds_remote_device_resetting_state_exit(void *object) static void scic_sds_remote_device_resetting_state_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = object; struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine);
scic_sds_remote_node_context_resume(&sci_dev->rnc, NULL, NULL); scic_sds_remote_node_context_resume(&sci_dev->rnc, NULL, NULL);
} }
static void scic_sds_stp_remote_device_ready_idle_substate_enter(void *object) static void scic_sds_stp_remote_device_ready_idle_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = object; struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine);
sci_dev->working_request = NULL; sci_dev->working_request = NULL;
if (scic_sds_remote_node_context_is_ready(&sci_dev->rnc)) { if (scic_sds_remote_node_context_is_ready(&sci_dev->rnc)) {
@ -997,9 +997,9 @@ static void scic_sds_stp_remote_device_ready_idle_substate_enter(void *object)
} }
} }
static void scic_sds_stp_remote_device_ready_cmd_substate_enter(void *object) static void scic_sds_stp_remote_device_ready_cmd_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = object; struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine);
struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
BUG_ON(sci_dev->working_request == NULL); BUG_ON(sci_dev->working_request == NULL);
@ -1008,9 +1008,9 @@ static void scic_sds_stp_remote_device_ready_cmd_substate_enter(void *object)
SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED); SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED);
} }
static void scic_sds_stp_remote_device_ready_ncq_error_substate_enter(void *object) static void scic_sds_stp_remote_device_ready_ncq_error_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = object; struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine);
struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); struct isci_remote_device *idev = sci_dev_to_idev(sci_dev);
@ -1019,17 +1019,17 @@ static void scic_sds_stp_remote_device_ready_ncq_error_substate_enter(void *obje
sci_dev->not_ready_reason); sci_dev->not_ready_reason);
} }
static void scic_sds_smp_remote_device_ready_idle_substate_enter(void *object) static void scic_sds_smp_remote_device_ready_idle_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = object; struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine);
struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
isci_remote_device_ready(scic_to_ihost(scic), sci_dev_to_idev(sci_dev)); isci_remote_device_ready(scic_to_ihost(scic), sci_dev_to_idev(sci_dev));
} }
static void scic_sds_smp_remote_device_ready_cmd_substate_enter(void *object) static void scic_sds_smp_remote_device_ready_cmd_substate_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = object; struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine);
struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
BUG_ON(sci_dev->working_request == NULL); BUG_ON(sci_dev->working_request == NULL);
@ -1038,9 +1038,9 @@ static void scic_sds_smp_remote_device_ready_cmd_substate_enter(void *object)
SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED); SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED);
} }
static void scic_sds_smp_remote_device_ready_cmd_substate_exit(void *object) static void scic_sds_smp_remote_device_ready_cmd_substate_exit(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_device *sci_dev = object; struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine);
sci_dev->working_request = NULL; sci_dev->working_request = NULL;
} }
@ -1102,16 +1102,11 @@ static void scic_remote_device_construct(struct scic_sds_port *sci_port,
sci_dev->owning_port = sci_port; sci_dev->owning_port = sci_port;
sci_dev->started_request_count = 0; sci_dev->started_request_count = 0;
sci_base_state_machine_construct( sci_base_state_machine_construct(&sci_dev->state_machine,
&sci_dev->state_machine, scic_sds_remote_device_state_table,
sci_dev, SCI_BASE_REMOTE_DEVICE_STATE_INITIAL);
scic_sds_remote_device_state_table,
SCI_BASE_REMOTE_DEVICE_STATE_INITIAL
);
sci_base_state_machine_start( sci_base_state_machine_start(&sci_dev->state_machine);
&sci_dev->state_machine
);
scic_sds_remote_node_context_construct(&sci_dev->rnc, scic_sds_remote_node_context_construct(&sci_dev->rnc,
SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX); SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX);

Просмотреть файл

@ -266,10 +266,9 @@ static void scic_sds_remote_node_context_invalidate_context_buffer(
SCU_CONTEXT_COMMAND_POST_RNC_INVALIDATE); SCU_CONTEXT_COMMAND_POST_RNC_INVALIDATE);
} }
static void scic_sds_remote_node_context_initial_state_enter(void *object) static void scic_sds_remote_node_context_initial_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_node_context *rnc = object; struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine);
struct sci_base_state_machine *sm = &rnc->state_machine;
/* Check to see if we have gotten back to the initial state because /* Check to see if we have gotten back to the initial state because
* someone requested to destroy the remote node context object. * someone requested to destroy the remote node context object.
@ -280,23 +279,23 @@ static void scic_sds_remote_node_context_initial_state_enter(void *object)
} }
} }
static void scic_sds_remote_node_context_posting_state_enter(void *object) static void scic_sds_remote_node_context_posting_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_node_context *sci_rnc = object; struct scic_sds_remote_node_context *sci_rnc = container_of(sm, typeof(*sci_rnc), state_machine);
scic_sds_remote_node_context_validate_context_buffer(sci_rnc); scic_sds_remote_node_context_validate_context_buffer(sci_rnc);
} }
static void scic_sds_remote_node_context_invalidating_state_enter(void *object) static void scic_sds_remote_node_context_invalidating_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_node_context *rnc = object; struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine);
scic_sds_remote_node_context_invalidate_context_buffer(rnc); scic_sds_remote_node_context_invalidate_context_buffer(rnc);
} }
static void scic_sds_remote_node_context_resuming_state_enter(void *object) static void scic_sds_remote_node_context_resuming_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_node_context *rnc = object; struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine);
struct scic_sds_remote_device *sci_dev; struct scic_sds_remote_device *sci_dev;
struct domain_device *dev; struct domain_device *dev;
@ -317,9 +316,9 @@ static void scic_sds_remote_node_context_resuming_state_enter(void *object)
scic_sds_remote_device_post_request(sci_dev, SCU_CONTEXT_COMMAND_POST_RNC_RESUME); scic_sds_remote_device_post_request(sci_dev, SCU_CONTEXT_COMMAND_POST_RNC_RESUME);
} }
static void scic_sds_remote_node_context_ready_state_enter(void *object) static void scic_sds_remote_node_context_ready_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_node_context *rnc = object; struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine);
rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED; rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED;
@ -327,17 +326,16 @@ static void scic_sds_remote_node_context_ready_state_enter(void *object)
scic_sds_remote_node_context_notify_user(rnc); scic_sds_remote_node_context_notify_user(rnc);
} }
static void scic_sds_remote_node_context_tx_suspended_state_enter(void *object) static void scic_sds_remote_node_context_tx_suspended_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_remote_node_context *rnc = object; struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine);
scic_sds_remote_node_context_continue_state_transitions(rnc); scic_sds_remote_node_context_continue_state_transitions(rnc);
} }
static void scic_sds_remote_node_context_tx_rx_suspended_state_enter( static void scic_sds_remote_node_context_tx_rx_suspended_state_enter(struct sci_base_state_machine *sm)
void *object)
{ {
struct scic_sds_remote_node_context *rnc = object; struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine);
scic_sds_remote_node_context_continue_state_transitions(rnc); scic_sds_remote_node_context_continue_state_transitions(rnc);
} }
@ -375,12 +373,9 @@ void scic_sds_remote_node_context_construct(struct scic_sds_remote_node_context
rnc->remote_node_index = remote_node_index; rnc->remote_node_index = remote_node_index;
rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED; rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED;
sci_base_state_machine_construct( sci_base_state_machine_construct(&rnc->state_machine,
&rnc->state_machine, scic_sds_remote_node_context_state_table,
rnc, SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE);
scic_sds_remote_node_context_state_table,
SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE
);
sci_base_state_machine_start(&rnc->state_machine); sci_base_state_machine_start(&rnc->state_machine);
} }

Просмотреть файл

@ -2900,10 +2900,9 @@ static void isci_request_io_request_complete(struct isci_host *isci_host,
isci_host_can_dequeue(isci_host, 1); isci_host_can_dequeue(isci_host, 1);
} }
static void scic_sds_request_started_state_enter(void *object) static void scic_sds_request_started_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_request *sci_req = object; struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine);
struct sci_base_state_machine *sm = &sci_req->state_machine;
struct isci_request *ireq = sci_req_to_ireq(sci_req); struct isci_request *ireq = sci_req_to_ireq(sci_req);
struct domain_device *dev = sci_dev_to_domain(sci_req->target_device); struct domain_device *dev = sci_dev_to_domain(sci_req->target_device);
struct sas_task *task; struct sas_task *task;
@ -2942,9 +2941,9 @@ static void scic_sds_request_started_state_enter(void *object)
} }
} }
static void scic_sds_request_completed_state_enter(void *object) static void scic_sds_request_completed_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_request *sci_req = object; struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine);
struct scic_sds_controller *scic = sci_req->owning_controller; struct scic_sds_controller *scic = sci_req->owning_controller;
struct isci_host *ihost = scic_to_ihost(scic); struct isci_host *ihost = scic_to_ihost(scic);
struct isci_request *ireq = sci_req_to_ireq(sci_req); struct isci_request *ireq = sci_req_to_ireq(sci_req);
@ -2957,42 +2956,41 @@ static void scic_sds_request_completed_state_enter(void *object)
isci_task_request_complete(ihost, ireq, sci_req->sci_status); isci_task_request_complete(ihost, ireq, sci_req->sci_status);
} }
static void scic_sds_request_aborting_state_enter(void *object) static void scic_sds_request_aborting_state_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_request *sci_req = object; struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine);
/* Setting the abort bit in the Task Context is required by the silicon. */ /* Setting the abort bit in the Task Context is required by the silicon. */
sci_req->task_context_buffer->abort = 1; sci_req->task_context_buffer->abort = 1;
} }
static void scic_sds_stp_request_started_non_data_await_h2d_completion_enter( static void scic_sds_stp_request_started_non_data_await_h2d_completion_enter(struct sci_base_state_machine *sm)
void *object)
{ {
struct scic_sds_request *sci_req = object; struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine);
scic_sds_remote_device_set_working_request(sci_req->target_device, scic_sds_remote_device_set_working_request(sci_req->target_device,
sci_req); sci_req);
} }
static void scic_sds_stp_request_started_pio_await_h2d_completion_enter(void *object) static void scic_sds_stp_request_started_pio_await_h2d_completion_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_request *sci_req = object; struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine);
scic_sds_remote_device_set_working_request(sci_req->target_device, scic_sds_remote_device_set_working_request(sci_req->target_device,
sci_req); sci_req);
} }
static void scic_sds_stp_request_started_soft_reset_await_h2d_asserted_completion_enter(void *object) static void scic_sds_stp_request_started_soft_reset_await_h2d_asserted_completion_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_request *sci_req = object; struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine);
scic_sds_remote_device_set_working_request(sci_req->target_device, scic_sds_remote_device_set_working_request(sci_req->target_device,
sci_req); sci_req);
} }
static void scic_sds_stp_request_started_soft_reset_await_h2d_diagnostic_completion_enter(void *object) static void scic_sds_stp_request_started_soft_reset_await_h2d_diagnostic_completion_enter(struct sci_base_state_machine *sm)
{ {
struct scic_sds_request *sci_req = object; struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine);
struct scu_task_context *task_context; struct scu_task_context *task_context;
struct host_to_dev_fis *h2d_fis; struct host_to_dev_fis *h2d_fis;
enum sci_status status; enum sci_status status;
@ -3052,8 +3050,9 @@ static void scic_sds_general_request_construct(struct scic_sds_controller *scic,
struct scic_sds_remote_device *sci_dev, struct scic_sds_remote_device *sci_dev,
u16 io_tag, struct scic_sds_request *sci_req) u16 io_tag, struct scic_sds_request *sci_req)
{ {
sci_base_state_machine_construct(&sci_req->state_machine, sci_req, sci_base_state_machine_construct(&sci_req->state_machine,
scic_sds_request_state_table, SCI_BASE_REQUEST_STATE_INITIAL); scic_sds_request_state_table,
SCI_BASE_REQUEST_STATE_INITIAL);
sci_base_state_machine_start(&sci_req->state_machine); sci_base_state_machine_start(&sci_req->state_machine);
sci_req->io_tag = io_tag; sci_req->io_tag = io_tag;

Просмотреть файл

@ -68,7 +68,7 @@ static void sci_state_machine_exit_state(struct sci_base_state_machine *sm)
sci_state_transition_t exit = sm->state_table[state].exit_state; sci_state_transition_t exit = sm->state_table[state].exit_state;
if (exit) if (exit)
exit(sm->state_machine_owner); exit(sm);
} }
static void sci_state_machine_enter_state(struct sci_base_state_machine *sm) static void sci_state_machine_enter_state(struct sci_base_state_machine *sm)
@ -77,22 +77,15 @@ static void sci_state_machine_enter_state(struct sci_base_state_machine *sm)
sci_state_transition_t enter = sm->state_table[state].enter_state; sci_state_transition_t enter = sm->state_table[state].enter_state;
if (enter) if (enter)
enter(sm->state_machine_owner); enter(sm);
} }
/*
* ******************************************************************************
* * P R O T E C T E D M E T H O D S
* ****************************************************************************** */
/** /**
* This method will set the initial state and state table for the state * This method will set the initial state and state table for the state
* machine. The caller should follow this request with the initialize * machine. The caller should follow this request with the initialize
* request to cause the state machine to start. * request to cause the state machine to start.
* @sm: This parameter provides the state machine object to be * @sm: This parameter provides the state machine object to be
* constructed. * constructed.
* @state_machine_owner: This parameter indicates the object that is owns the
* state machine being constructed.
* @state_table: This parameter specifies the table of state objects that is * @state_table: This parameter specifies the table of state objects that is
* managed by this state machine. * managed by this state machine.
* @initial_state: This parameter specifies the value of the initial state for * @initial_state: This parameter specifies the value of the initial state for
@ -100,11 +93,9 @@ static void sci_state_machine_enter_state(struct sci_base_state_machine *sm)
* *
*/ */
void sci_base_state_machine_construct(struct sci_base_state_machine *sm, void sci_base_state_machine_construct(struct sci_base_state_machine *sm,
void *owner,
const struct sci_base_state *state_table, const struct sci_base_state *state_table,
u32 initial_state) u32 initial_state)
{ {
sm->state_machine_owner = owner;
sm->initial_state_id = initial_state; sm->initial_state_id = initial_state;
sm->previous_state_id = initial_state; sm->previous_state_id = initial_state;
sm->current_state_id = initial_state; sm->current_state_id = initial_state;

Просмотреть файл

@ -58,9 +58,9 @@
#include <linux/types.h> #include <linux/types.h>
struct sci_base_state_machine;
typedef void (*sci_base_state_handler_t)(void); typedef void (*sci_base_state_handler_t)(void);
typedef void (*sci_state_transition_t)(struct sci_base_state_machine *sm);
typedef void (*sci_state_transition_t)(void *base_object);
/** /**
* struct sci_base_state - The base state object abstracts the fields common to * struct sci_base_state - The base state object abstracts the fields common to
@ -80,7 +80,6 @@ struct sci_base_state {
* invoked when the state is exited. * invoked when the state is exited.
*/ */
sci_state_transition_t exit_state; sci_state_transition_t exit_state;
}; };
/** /**
@ -95,13 +94,6 @@ struct sci_base_state_machine {
*/ */
const struct sci_base_state *state_table; const struct sci_base_state *state_table;
/**
* This field points to the object to which this state machine is
* associated. It serves as a cookie to be provided to the state
* enter/exit methods.
*/
void *state_machine_owner;
/** /**
* This field simply indicates the state value for the state machine's * This field simply indicates the state value for the state machine's
* initial state. * initial state.
@ -120,28 +112,13 @@ struct sci_base_state_machine {
}; };
/* void sci_base_state_machine_construct(struct sci_base_state_machine *sm,
* ****************************************************************************** const struct sci_base_state *state_table,
* * P R O T E C T E D M E T H O D S u32 initial_state);
* ****************************************************************************** */ void sci_base_state_machine_start(struct sci_base_state_machine *sm);
void sci_base_state_machine_stop(struct sci_base_state_machine *sm);
void sci_base_state_machine_construct( void sci_base_state_machine_change_state(struct sci_base_state_machine *sm,
struct sci_base_state_machine *this_state_machine, u32 next_state);
void *state_machine_owner, u32 sci_base_state_machine_get_state(struct sci_base_state_machine *sm);
const struct sci_base_state *state_table,
u32 initial_state);
void sci_base_state_machine_start(
struct sci_base_state_machine *this_state_machine);
void sci_base_state_machine_stop(
struct sci_base_state_machine *this_state_machine);
void sci_base_state_machine_change_state(
struct sci_base_state_machine *this_state_machine,
u32 next_state);
u32 sci_base_state_machine_get_state(
struct sci_base_state_machine *this_state_machine);
#endif /* _SCI_BASE_STATE_MACHINE_H_ */ #endif /* _SCI_BASE_STATE_MACHINE_H_ */