diff options
author | Dan Williams <dan.j.williams@intel.com> | 2011-02-23 00:14:06 -0800 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 03:55:27 -0700 |
commit | 8f31550c77849250ec49d1509b6bb63b4ddc59e4 (patch) | |
tree | 380980cfaf7923b701a2cb95ba17071c9afa225a /drivers/scsi/isci/core | |
parent | 858d4aa741c80fb7579cda3517853f0cffc73772 (diff) | |
download | op-kernel-dev-8f31550c77849250ec49d1509b6bb63b4ddc59e4.zip op-kernel-dev-8f31550c77849250ec49d1509b6bb63b4ddc59e4.tar.gz |
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>
Diffstat (limited to 'drivers/scsi/isci/core')
-rw-r--r-- | drivers/scsi/isci/core/sci_base_phy.h | 15 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_phy.c | 314 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_phy.h | 24 |
3 files changed, 145 insertions, 208 deletions
diff --git a/drivers/scsi/isci/core/sci_base_phy.h b/drivers/scsi/isci/core/sci_base_phy.h index 6c0d9bb..7e2c7e3 100644 --- a/drivers/scsi/isci/core/sci_base_phy.h +++ b/drivers/scsi/isci/core/sci_base_phy.h @@ -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; }; diff --git a/drivers/scsi/isci/core/scic_sds_phy.c b/drivers/scsi/isci/core/scic_sds_phy.c index 743e5a6..98e9179 100644 --- a/drivers/scsi/isci/core/scic_sds_phy.c +++ b/drivers/scsi/isci/core/scic_sds_phy.c @@ -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 } }; diff --git a/drivers/scsi/isci/core/scic_sds_phy.h b/drivers/scsi/isci/core/scic_sds_phy.h index 3b88259..9ba09bb 100644 --- a/drivers/scsi/isci/core/scic_sds_phy.h +++ b/drivers/scsi/isci/core/scic_sds_phy.h @@ -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[]; /** |