isci: phy state machine cleanup step1

c99 the struct initializers:
	1/ allows grep to consistently show method name associations.  The
	   naming is mostly consistent (except when it isn't) so this guarantees
	   coverage of present and future exception cases.
	2/ let's the compiler guarantee that the state table array entry
	   correlates with an actual state name and detect accidental reordering or
	   deletion of states.
	/ allows default handler's to be identified easily

Signed-off-by: Jacek Danecki <Jacek.Danecki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
Dan Williams 2011-02-23 00:14:06 -08:00
parent 858d4aa741
commit 8f31550c77
3 changed files with 145 additions and 208 deletions

View File

@ -115,9 +115,6 @@ enum sci_base_phy_states {
* Simply the final state for the base phy state machine.
*/
SCI_BASE_PHY_STATE_FINAL,
SCI_BASE_PHY_MAX_STATES
};
/**
@ -138,9 +135,7 @@ struct sci_base_phy {
struct sci_base_state_machine state_machine;
};
typedef enum sci_status (*SCI_BASE_PHY_HANDLER_T)(
struct sci_base_phy *
);
typedef enum sci_status (*sci_base_phy_handler_t)(struct sci_base_phy *);
/**
* struct sci_base_phy_state_handler - This structure contains all of the state
@ -155,25 +150,25 @@ struct sci_base_phy_state_handler {
* The start_handler specifies the method invoked when there is an
* attempt to start a phy.
*/
SCI_BASE_PHY_HANDLER_T start_handler;
sci_base_phy_handler_t start_handler;
/**
* The stop_handler specifies the method invoked when there is an
* attempt to stop a phy.
*/
SCI_BASE_PHY_HANDLER_T stop_handler;
sci_base_phy_handler_t stop_handler;
/**
* The reset_handler specifies the method invoked when there is an
* attempt to reset a phy.
*/
SCI_BASE_PHY_HANDLER_T reset_handler;
sci_base_phy_handler_t reset_handler;
/**
* The destruct_handler specifies the method invoked when attempting to
* destruct a phy.
*/
SCI_BASE_PHY_HANDLER_T destruct_handler;
sci_base_phy_handler_t destruct_handler;
};

View File

@ -103,7 +103,7 @@ static enum sci_status scic_sds_phy_link_layer_initialization(
this_phy->link_layer_registers = link_layer_registers;
/* Set our IDENTIFY frame data */
#define SCI_END_DEVICE 0x01
#define SCI_END_DEVICE 0x01
SCU_SAS_TIID_WRITE(
this_phy,
@ -1406,128 +1406,96 @@ static enum sci_status scic_sds_phy_starting_substate_await_sata_power_consume_p
/* --------------------------------------------------------------------------- */
struct scic_sds_phy_state_handler
scic_sds_phy_starting_substate_handler_table[SCIC_SDS_PHY_STARTING_MAX_SUBSTATES] =
{
/* SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL */
{
{
scic_sds_phy_default_start_handler,
scic_sds_phy_default_stop_handler,
scic_sds_phy_default_reset_handler,
scic_sds_phy_default_destroy_handler
},
scic_sds_phy_default_frame_handler,
scic_sds_phy_default_event_handler,
scic_sds_phy_default_consume_power_handler
const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_handler_table[] = {
[SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = {
.parent.start_handler = scic_sds_phy_default_start_handler,
.parent.stop_handler = scic_sds_phy_default_stop_handler,
.parent.reset_handler = scic_sds_phy_default_reset_handler,
.parent.destruct_handler = scic_sds_phy_default_destroy_handler,
.frame_handler = scic_sds_phy_default_frame_handler,
.event_handler = scic_sds_phy_default_event_handler,
.consume_power_handler = scic_sds_phy_default_consume_power_handler
},
/* SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN */
{
{
scic_sds_phy_default_start_handler,
scic_sds_phy_default_stop_handler,
scic_sds_phy_default_reset_handler,
scic_sds_phy_default_destroy_handler
},
scic_sds_phy_default_frame_handler,
scic_sds_phy_starting_substate_await_ossp_event_handler,
scic_sds_phy_default_consume_power_handler
[SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN] = {
.parent.start_handler = scic_sds_phy_default_start_handler,
.parent.stop_handler = scic_sds_phy_default_stop_handler,
.parent.reset_handler = scic_sds_phy_default_reset_handler,
.parent.destruct_handler = scic_sds_phy_default_destroy_handler,
.frame_handler = scic_sds_phy_default_frame_handler,
.event_handler = scic_sds_phy_starting_substate_await_ossp_event_handler,
.consume_power_handler = scic_sds_phy_default_consume_power_handler
},
/* SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN */
{
{
scic_sds_phy_default_start_handler,
scic_sds_phy_default_stop_handler,
scic_sds_phy_default_reset_handler,
scic_sds_phy_default_destroy_handler
},
scic_sds_phy_default_frame_handler,
scic_sds_phy_starting_substate_await_sas_phy_speed_event_handler,
scic_sds_phy_default_consume_power_handler
[SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN] = {
.parent.start_handler = scic_sds_phy_default_start_handler,
.parent.stop_handler = scic_sds_phy_default_stop_handler,
.parent.reset_handler = scic_sds_phy_default_reset_handler,
.parent.destruct_handler = scic_sds_phy_default_destroy_handler,
.frame_handler = scic_sds_phy_default_frame_handler,
.event_handler = scic_sds_phy_starting_substate_await_sas_phy_speed_event_handler,
.consume_power_handler = scic_sds_phy_default_consume_power_handler
},
/* SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF */
{
{
scic_sds_phy_default_start_handler,
scic_sds_phy_default_stop_handler,
scic_sds_phy_default_reset_handler,
scic_sds_phy_default_destroy_handler
},
scic_sds_phy_starting_substate_await_iaf_uf_frame_handler,
scic_sds_phy_starting_substate_await_iaf_uf_event_handler,
scic_sds_phy_default_consume_power_handler
[SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF] = {
.parent.start_handler = scic_sds_phy_default_start_handler,
.parent.stop_handler = scic_sds_phy_default_stop_handler,
.parent.reset_handler = scic_sds_phy_default_reset_handler,
.parent.destruct_handler = scic_sds_phy_default_destroy_handler,
.frame_handler = scic_sds_phy_starting_substate_await_iaf_uf_frame_handler,
.event_handler = scic_sds_phy_starting_substate_await_iaf_uf_event_handler,
.consume_power_handler = scic_sds_phy_default_consume_power_handler
},
/* SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER */
{
{
scic_sds_phy_default_start_handler,
scic_sds_phy_default_stop_handler,
scic_sds_phy_default_reset_handler,
scic_sds_phy_default_destroy_handler
},
scic_sds_phy_default_frame_handler,
scic_sds_phy_starting_substate_await_sas_power_event_handler,
scic_sds_phy_starting_substate_await_sas_power_consume_power_handler
[SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER] = {
.parent.start_handler = scic_sds_phy_default_start_handler,
.parent.stop_handler = scic_sds_phy_default_stop_handler,
.parent.reset_handler = scic_sds_phy_default_reset_handler,
.parent.destruct_handler = scic_sds_phy_default_destroy_handler,
.frame_handler = scic_sds_phy_default_frame_handler,
.event_handler = scic_sds_phy_starting_substate_await_sas_power_event_handler,
.consume_power_handler = scic_sds_phy_starting_substate_await_sas_power_consume_power_handler
},
/* SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER, */
{
{
scic_sds_phy_default_start_handler,
scic_sds_phy_default_stop_handler,
scic_sds_phy_default_reset_handler,
scic_sds_phy_default_destroy_handler
},
scic_sds_phy_default_frame_handler,
scic_sds_phy_starting_substate_await_sata_power_event_handler,
scic_sds_phy_starting_substate_await_sata_power_consume_power_handler
[SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER] = {
.parent.start_handler = scic_sds_phy_default_start_handler,
.parent.stop_handler = scic_sds_phy_default_stop_handler,
.parent.reset_handler = scic_sds_phy_default_reset_handler,
.parent.destruct_handler = scic_sds_phy_default_destroy_handler,
.frame_handler = scic_sds_phy_default_frame_handler,
.event_handler = scic_sds_phy_starting_substate_await_sata_power_event_handler,
.consume_power_handler = scic_sds_phy_starting_substate_await_sata_power_consume_power_handler
},
/* SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN, */
{
{
scic_sds_phy_default_start_handler,
scic_sds_phy_default_stop_handler,
scic_sds_phy_default_reset_handler,
scic_sds_phy_default_destroy_handler
},
scic_sds_phy_default_frame_handler,
scic_sds_phy_starting_substate_await_sata_phy_event_handler,
scic_sds_phy_default_consume_power_handler
[SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN] = {
.parent.start_handler = scic_sds_phy_default_start_handler,
.parent.stop_handler = scic_sds_phy_default_stop_handler,
.parent.reset_handler = scic_sds_phy_default_reset_handler,
.parent.destruct_handler = scic_sds_phy_default_destroy_handler,
.frame_handler = scic_sds_phy_default_frame_handler,
.event_handler = scic_sds_phy_starting_substate_await_sata_phy_event_handler,
.consume_power_handler = scic_sds_phy_default_consume_power_handler
},
/* SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN, */
{
{
scic_sds_phy_default_start_handler,
scic_sds_phy_default_stop_handler,
scic_sds_phy_default_reset_handler,
scic_sds_phy_default_destroy_handler
},
scic_sds_phy_default_frame_handler,
scic_sds_phy_starting_substate_await_sata_speed_event_handler,
scic_sds_phy_default_consume_power_handler
[SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN] = {
.parent.start_handler = scic_sds_phy_default_start_handler,
.parent.stop_handler = scic_sds_phy_default_stop_handler,
.parent.reset_handler = scic_sds_phy_default_reset_handler,
.parent.destruct_handler = scic_sds_phy_default_destroy_handler,
.frame_handler = scic_sds_phy_default_frame_handler,
.event_handler = scic_sds_phy_starting_substate_await_sata_speed_event_handler,
.consume_power_handler = scic_sds_phy_default_consume_power_handler
},
/* SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF, */
{
{
scic_sds_phy_default_start_handler,
scic_sds_phy_default_stop_handler,
scic_sds_phy_default_reset_handler,
scic_sds_phy_default_destroy_handler
},
scic_sds_phy_starting_substate_await_sig_fis_frame_handler,
scic_sds_phy_starting_substate_await_sig_fis_event_handler,
scic_sds_phy_default_consume_power_handler
[SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF] = {
.parent.start_handler = scic_sds_phy_default_start_handler,
.parent.stop_handler = scic_sds_phy_default_stop_handler,
.parent.reset_handler = scic_sds_phy_default_reset_handler,
.parent.destruct_handler = scic_sds_phy_default_destroy_handler,
.frame_handler = scic_sds_phy_starting_substate_await_sig_fis_frame_handler,
.event_handler = scic_sds_phy_starting_substate_await_sig_fis_event_handler,
.consume_power_handler = scic_sds_phy_default_consume_power_handler
},
/* SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL */
{
{
scic_sds_phy_default_start_handler,
scic_sds_phy_default_stop_handler,
scic_sds_phy_default_reset_handler,
scic_sds_phy_default_destroy_handler
},
scic_sds_phy_default_frame_handler,
scic_sds_phy_default_event_handler,
scic_sds_phy_default_consume_power_handler
[SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL] = {
.parent.start_handler = scic_sds_phy_default_start_handler,
.parent.stop_handler = scic_sds_phy_default_stop_handler,
.parent.reset_handler = scic_sds_phy_default_reset_handler,
.parent.destruct_handler = scic_sds_phy_default_destroy_handler,
.frame_handler = scic_sds_phy_default_frame_handler,
.event_handler = scic_sds_phy_default_event_handler,
.consume_power_handler = scic_sds_phy_default_consume_power_handler
}
};
@ -2344,80 +2312,60 @@ static enum sci_status scic_sds_phy_resetting_state_event_handler(
/* --------------------------------------------------------------------------- */
struct scic_sds_phy_state_handler
scic_sds_phy_state_handler_table[SCI_BASE_PHY_MAX_STATES] =
{
/* SCI_BASE_PHY_STATE_INITIAL */
{
{
scic_sds_phy_default_start_handler,
scic_sds_phy_default_stop_handler,
scic_sds_phy_default_reset_handler,
scic_sds_phy_default_destroy_handler
},
scic_sds_phy_default_frame_handler,
scic_sds_phy_default_event_handler,
scic_sds_phy_default_consume_power_handler
const struct scic_sds_phy_state_handler scic_sds_phy_state_handler_table[] = {
[SCI_BASE_PHY_STATE_INITIAL] = {
.parent.start_handler = scic_sds_phy_default_start_handler,
.parent.stop_handler = scic_sds_phy_default_stop_handler,
.parent.reset_handler = scic_sds_phy_default_reset_handler,
.parent.destruct_handler = scic_sds_phy_default_destroy_handler,
.frame_handler = scic_sds_phy_default_frame_handler,
.event_handler = scic_sds_phy_default_event_handler,
.consume_power_handler = scic_sds_phy_default_consume_power_handler
},
/* SCI_BASE_PHY_STATE_STOPPED */
{
{
scic_sds_phy_stopped_state_start_handler,
scic_sds_phy_default_stop_handler,
scic_sds_phy_default_reset_handler,
scic_sds_phy_stopped_state_destroy_handler
},
scic_sds_phy_default_frame_handler,
scic_sds_phy_default_event_handler,
scic_sds_phy_default_consume_power_handler
[SCI_BASE_PHY_STATE_STOPPED] = {
.parent.start_handler = scic_sds_phy_stopped_state_start_handler,
.parent.stop_handler = scic_sds_phy_default_stop_handler,
.parent.reset_handler = scic_sds_phy_default_reset_handler,
.parent.destruct_handler = scic_sds_phy_stopped_state_destroy_handler,
.frame_handler = scic_sds_phy_default_frame_handler,
.event_handler = scic_sds_phy_default_event_handler,
.consume_power_handler = scic_sds_phy_default_consume_power_handler
},
/* SCI_BASE_PHY_STATE_STARTING */
{
{
scic_sds_phy_default_start_handler,
scic_sds_phy_default_stop_handler,
scic_sds_phy_default_reset_handler,
scic_sds_phy_default_destroy_handler
},
scic_sds_phy_default_frame_handler,
scic_sds_phy_default_event_handler,
scic_sds_phy_default_consume_power_handler
[SCI_BASE_PHY_STATE_STARTING] = {
.parent.start_handler = scic_sds_phy_default_start_handler,
.parent.stop_handler = scic_sds_phy_default_stop_handler,
.parent.reset_handler = scic_sds_phy_default_reset_handler,
.parent.destruct_handler = scic_sds_phy_default_destroy_handler,
.frame_handler = scic_sds_phy_default_frame_handler,
.event_handler = scic_sds_phy_default_event_handler,
.consume_power_handler = scic_sds_phy_default_consume_power_handler
},
/* SCI_BASE_PHY_STATE_READY */
{
{
scic_sds_phy_default_start_handler,
scic_sds_phy_ready_state_stop_handler,
scic_sds_phy_ready_state_reset_handler,
scic_sds_phy_default_destroy_handler
},
scic_sds_phy_default_frame_handler,
scic_sds_phy_ready_state_event_handler,
scic_sds_phy_default_consume_power_handler
[SCI_BASE_PHY_STATE_READY] = {
.parent.start_handler = scic_sds_phy_default_start_handler,
.parent.stop_handler = scic_sds_phy_ready_state_stop_handler,
.parent.reset_handler = scic_sds_phy_ready_state_reset_handler,
.parent.destruct_handler = scic_sds_phy_default_destroy_handler,
.frame_handler = scic_sds_phy_default_frame_handler,
.event_handler = scic_sds_phy_ready_state_event_handler,
.consume_power_handler = scic_sds_phy_default_consume_power_handler
},
/* SCI_BASE_PHY_STATE_RESETTING */
{
{
scic_sds_phy_default_start_handler,
scic_sds_phy_default_stop_handler,
scic_sds_phy_default_reset_handler,
scic_sds_phy_default_destroy_handler
},
scic_sds_phy_default_frame_handler,
scic_sds_phy_resetting_state_event_handler,
scic_sds_phy_default_consume_power_handler
[SCI_BASE_PHY_STATE_RESETTING] = {
.parent.start_handler = scic_sds_phy_default_start_handler,
.parent.stop_handler = scic_sds_phy_default_stop_handler,
.parent.reset_handler = scic_sds_phy_default_reset_handler,
.parent.destruct_handler = scic_sds_phy_default_destroy_handler,
.frame_handler = scic_sds_phy_default_frame_handler,
.event_handler = scic_sds_phy_resetting_state_event_handler,
.consume_power_handler = scic_sds_phy_default_consume_power_handler
},
/* SCI_BASE_PHY_STATE_FINAL */
{
{
scic_sds_phy_default_start_handler,
scic_sds_phy_default_stop_handler,
scic_sds_phy_default_reset_handler,
scic_sds_phy_default_destroy_handler
},
scic_sds_phy_default_frame_handler,
scic_sds_phy_default_event_handler,
scic_sds_phy_default_consume_power_handler
[SCI_BASE_PHY_STATE_FINAL] = {
.parent.start_handler = scic_sds_phy_default_start_handler,
.parent.stop_handler = scic_sds_phy_default_stop_handler,
.parent.reset_handler = scic_sds_phy_default_reset_handler,
.parent.destruct_handler = scic_sds_phy_default_destroy_handler,
.frame_handler = scic_sds_phy_default_frame_handler,
.event_handler = scic_sds_phy_default_event_handler,
.consume_power_handler = scic_sds_phy_default_consume_power_handler
}
};

View File

@ -146,11 +146,6 @@ enum SCIC_SDS_PHY_STARTING_SUBSTATES {
* Exit state for this state machine
*/
SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL,
/**
* Maximum number of substates for the STARTING state machine
*/
SCIC_SDS_PHY_STARTING_MAX_SUBSTATES
};
struct scic_sds_port;
@ -248,7 +243,7 @@ struct scic_sds_phy {
*/
void *sata_timeout_timer;
struct scic_sds_phy_state_handler *state_handlers;
const struct scic_sds_phy_state_handler *state_handlers;
struct sci_base_state_machine starting_substate_machine;
@ -260,9 +255,9 @@ struct scic_sds_phy {
};
typedef enum sci_status (*SCIC_SDS_PHY_EVENT_HANDLER_T)(struct scic_sds_phy *, u32);
typedef enum sci_status (*SCIC_SDS_PHY_FRAME_HANDLER_T)(struct scic_sds_phy *, u32);
typedef enum sci_status (*SCIC_SDS_PHY_POWER_HANDLER_T)(struct scic_sds_phy *);
typedef enum sci_status (*scic_sds_phy_event_handler_t)(struct scic_sds_phy *, u32);
typedef enum sci_status (*scic_sds_phy_frame_handler_t)(struct scic_sds_phy *, u32);
typedef enum sci_status (*scic_sds_phy_power_handler_t)(struct scic_sds_phy *);
/**
* struct scic_sds_phy_state_handler -
@ -278,25 +273,24 @@ struct scic_sds_phy_state_handler {
/**
* The state handler for unsolicited frames received from the SCU hardware.
*/
SCIC_SDS_PHY_FRAME_HANDLER_T frame_handler;
scic_sds_phy_frame_handler_t frame_handler;
/**
* The state handler for events received from the SCU hardware.
*/
SCIC_SDS_PHY_EVENT_HANDLER_T event_handler;
scic_sds_phy_event_handler_t event_handler;
/**
* The state handler for staggered spinup.
*/
SCIC_SDS_PHY_POWER_HANDLER_T consume_power_handler;
scic_sds_phy_power_handler_t consume_power_handler;
};
extern struct scic_sds_phy_state_handler scic_sds_phy_state_handler_table[];
extern const struct scic_sds_phy_state_handler scic_sds_phy_state_handler_table[];
extern const struct sci_base_state scic_sds_phy_state_table[];
extern const struct sci_base_state scic_sds_phy_starting_substates[];
extern struct scic_sds_phy_state_handler
scic_sds_phy_starting_substate_handler_table[];
extern const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_handler_table[];
/**