isci: c99 tables cleanup step1
authorHenryk Dembkowski <Henryk.Dembkowski@intel.com>
Sat, 12 Feb 2011 19:50:09 +0000 (11:50 -0800)
committerDan Williams <dan.j.williams@intel.com>
Sun, 3 Jul 2011 07:36:31 +0000 (00:36 -0700)
scic_sds_stp_remote_device_ready_substate_handler_table[]
scic_sds_smp_remote_device_ready_substate_handler_table[]

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.
3/ allows default handler's to be identified easily

Signed-off-by: Henryk Dembkowski <henryk.dembkowski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/scsi/isci/core/scic_sds_remote_device.h
drivers/scsi/isci/core/scic_sds_smp_remote_device.c
drivers/scsi/isci/core/scic_sds_stp_remote_device.c

index aed4eb640c26aff4369a483393b55c825dfc85f9..d91570f212c6fd1f3c799b8bbecdb7d7d28b4967 100644 (file)
@@ -158,8 +158,6 @@ enum scic_sds_stp_remote_device_ready_substates {
         * coming to be recovered from certain hardware specific error.
         */
        SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET,
-
-       SCIC_SDS_STP_REMOTE_DEVICE_READY_MAX_SUBSTATES
 };
 
 /**
@@ -179,8 +177,6 @@ enum scic_sds_smp_remote_device_ready_substates {
         * the device is placed in when a RNC suspend is received by the SCU hardware.
         */
        SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD,
-
-       SCIC_SDS_SMP_REMOTE_DEVICE_READY_MAX_SUBSTATES
 };
 
 /**
@@ -326,12 +322,8 @@ extern const struct sci_base_state scic_sds_stp_remote_device_ready_substate_tab
 extern const struct sci_base_state scic_sds_smp_remote_device_ready_substate_table[];
 
 extern const struct scic_sds_remote_device_state_handler scic_sds_remote_device_state_handler_table[];
-extern struct scic_sds_remote_device_state_handler
-       scic_sds_ssp_remote_device_ready_substate_handler_table[];
-extern struct scic_sds_remote_device_state_handler
-       scic_sds_stp_remote_device_ready_substate_handler_table[];
-extern struct scic_sds_remote_device_state_handler
-       scic_sds_smp_remote_device_ready_substate_handler_table[];
+extern const struct scic_sds_remote_device_state_handler scic_sds_stp_remote_device_ready_substate_handler_table[];
+extern const struct scic_sds_remote_device_state_handler scic_sds_smp_remote_device_ready_substate_handler_table[];
 
 /**
  * scic_sds_remote_device_increment_request_count() -
index 7cf78d3212cc888652d13834f002fb807713951c..b0ed9d11eb2d7982e9c7587ad44ce00e0c2ea53f 100644 (file)
@@ -214,49 +214,40 @@ static enum sci_status scic_sds_smp_remote_device_ready_cmd_substate_frame_handl
 
 /* --------------------------------------------------------------------------- */
 
-struct scic_sds_remote_device_state_handler
-scic_sds_smp_remote_device_ready_substate_handler_table[
-       SCIC_SDS_SMP_REMOTE_DEVICE_READY_MAX_SUBSTATES] =
-{
-       /* SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE */
-       {
-               {
-                       scic_sds_remote_device_default_start_handler,
-                       scic_sds_remote_device_ready_state_stop_handler,
-                       scic_sds_remote_device_default_fail_handler,
-                       scic_sds_remote_device_default_destruct_handler,
-                       scic_sds_remote_device_default_reset_handler,
-                       scic_sds_remote_device_default_reset_complete_handler,
-                       scic_sds_smp_remote_device_ready_idle_substate_start_io_handler,
-                       scic_sds_remote_device_default_complete_request_handler,
-                       scic_sds_remote_device_default_continue_request_handler,
-                       scic_sds_remote_device_default_start_request_handler,
-                       scic_sds_remote_device_default_complete_request_handler
-               },
-               scic_sds_remote_device_default_suspend_handler,
-               scic_sds_remote_device_default_resume_handler,
-               scic_sds_remote_device_general_event_handler,
-               scic_sds_remote_device_default_frame_handler
+const struct scic_sds_remote_device_state_handler scic_sds_smp_remote_device_ready_substate_handler_table[] = {
+       [SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = {
+               .parent.start_handler           = scic_sds_remote_device_default_start_handler,
+               .parent.stop_handler            = scic_sds_remote_device_ready_state_stop_handler,
+               .parent.fail_handler            = scic_sds_remote_device_default_fail_handler,
+               .parent.destruct_handler        = scic_sds_remote_device_default_destruct_handler,
+               .parent.reset_handler           = scic_sds_remote_device_default_reset_handler,
+               .parent.reset_complete_handler  = scic_sds_remote_device_default_reset_complete_handler,
+               .parent.start_io_handler        = scic_sds_smp_remote_device_ready_idle_substate_start_io_handler,
+               .parent.complete_io_handler     = scic_sds_remote_device_default_complete_request_handler,
+               .parent.continue_io_handler     = scic_sds_remote_device_default_continue_request_handler,
+               .parent.start_task_handler      = scic_sds_remote_device_default_start_request_handler,
+               .parent.complete_task_handler   = scic_sds_remote_device_default_complete_request_handler,
+               .suspend_handler                = scic_sds_remote_device_default_suspend_handler,
+               .resume_handler                 = scic_sds_remote_device_default_resume_handler,
+               .event_handler                  = scic_sds_remote_device_general_event_handler,
+               .frame_handler                  = scic_sds_remote_device_default_frame_handler
        },
-       /* SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD */
-       {
-               {
-                       scic_sds_remote_device_default_start_handler,
-                       scic_sds_remote_device_ready_state_stop_handler,
-                       scic_sds_remote_device_default_fail_handler,
-                       scic_sds_remote_device_default_destruct_handler,
-                       scic_sds_remote_device_default_reset_handler,
-                       scic_sds_remote_device_default_reset_complete_handler,
-                       scic_sds_smp_remote_device_ready_cmd_substate_start_io_handler,
-                       scic_sds_smp_remote_device_ready_cmd_substate_complete_io_handler,
-                       scic_sds_remote_device_default_continue_request_handler,
-                       scic_sds_remote_device_default_start_request_handler,
-                       scic_sds_remote_device_default_complete_request_handler
-               },
-               scic_sds_remote_device_default_suspend_handler,
-               scic_sds_remote_device_default_resume_handler,
-               scic_sds_remote_device_general_event_handler,
-               scic_sds_smp_remote_device_ready_cmd_substate_frame_handler
+       [SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD] = {
+               .parent.start_handler           = scic_sds_remote_device_default_start_handler,
+               .parent.stop_handler            = scic_sds_remote_device_ready_state_stop_handler,
+               .parent.fail_handler            = scic_sds_remote_device_default_fail_handler,
+               .parent.destruct_handler        = scic_sds_remote_device_default_destruct_handler,
+               .parent.reset_handler           = scic_sds_remote_device_default_reset_handler,
+               .parent.reset_complete_handler  = scic_sds_remote_device_default_reset_complete_handler,
+               .parent.start_io_handler        = scic_sds_smp_remote_device_ready_cmd_substate_start_io_handler,
+               .parent.complete_io_handler     = scic_sds_smp_remote_device_ready_cmd_substate_complete_io_handler,
+               .parent.continue_io_handler     = scic_sds_remote_device_default_continue_request_handler,
+               .parent.start_task_handler      = scic_sds_remote_device_default_start_request_handler,
+               .parent.complete_task_handler   = scic_sds_remote_device_default_complete_request_handler,
+               .suspend_handler                = scic_sds_remote_device_default_suspend_handler,
+               .resume_handler                 = scic_sds_remote_device_default_resume_handler,
+               .event_handler                  = scic_sds_remote_device_general_event_handler,
+               .frame_handler                  = scic_sds_smp_remote_device_ready_cmd_substate_frame_handler
        }
 };
 /*
index 1320c95ee8d48c9144928b2fc2d74c6d2e7c7ab7..6aa170e92500f61fc89e987d8c954efb7227635c 100644 (file)
@@ -547,131 +547,110 @@ enum sci_status scic_sds_stp_remote_device_ready_atapi_error_substate_event_hand
 
 /* --------------------------------------------------------------------------- */
 
-struct scic_sds_remote_device_state_handler
-scic_sds_stp_remote_device_ready_substate_handler_table[
-       SCIC_SDS_STP_REMOTE_DEVICE_READY_MAX_SUBSTATES] =
-{
-       /* SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE */
-       {
-               {
-                       scic_sds_remote_device_default_start_handler,
-                       scic_sds_remote_device_ready_state_stop_handler,
-                       scic_sds_remote_device_default_fail_handler,
-                       scic_sds_remote_device_default_destruct_handler,
-                       scic_sds_remote_device_ready_state_reset_handler,
-                       scic_sds_remote_device_default_reset_complete_handler,
-                       scic_sds_stp_remote_device_ready_idle_substate_start_io_handler,
-                       scic_sds_remote_device_default_complete_request_handler,
-                       scic_sds_remote_device_default_continue_request_handler,
-                       scic_sds_stp_remote_device_ready_substate_start_request_handler,
-                       scic_sds_remote_device_default_complete_request_handler
-               },
-               scic_sds_remote_device_default_suspend_handler,
-               scic_sds_remote_device_default_resume_handler,
-               scic_sds_stp_remote_device_ready_idle_substate_event_handler,
-               scic_sds_remote_device_default_frame_handler
+const struct scic_sds_remote_device_state_handler scic_sds_stp_remote_device_ready_substate_handler_table[] = {
+       [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = {
+               .parent.start_handler           = scic_sds_remote_device_default_start_handler,
+               .parent.stop_handler            = scic_sds_remote_device_ready_state_stop_handler,
+               .parent.fail_handler            = scic_sds_remote_device_default_fail_handler,
+               .parent.destruct_handler        = scic_sds_remote_device_default_destruct_handler,
+               .parent.reset_handler           = scic_sds_remote_device_ready_state_reset_handler,
+               .parent.reset_complete_handler  = scic_sds_remote_device_default_reset_complete_handler,
+               .parent.start_io_handler        = scic_sds_stp_remote_device_ready_idle_substate_start_io_handler,
+               .parent.complete_io_handler     = scic_sds_remote_device_default_complete_request_handler,
+               .parent.continue_io_handler     = scic_sds_remote_device_default_continue_request_handler,
+               .parent.start_task_handler      = scic_sds_stp_remote_device_ready_substate_start_request_handler,
+               .parent.complete_task_handler   = scic_sds_remote_device_default_complete_request_handler,
+               .suspend_handler                = scic_sds_remote_device_default_suspend_handler,
+               .resume_handler                 = scic_sds_remote_device_default_resume_handler,
+               .event_handler                  = scic_sds_stp_remote_device_ready_idle_substate_event_handler,
+               .frame_handler                  = scic_sds_remote_device_default_frame_handler
        },
-       /* SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD */
-       {
-               {
-                       scic_sds_remote_device_default_start_handler,
-                       scic_sds_remote_device_ready_state_stop_handler,
-                       scic_sds_remote_device_default_fail_handler,
-                       scic_sds_remote_device_default_destruct_handler,
-                       scic_sds_remote_device_ready_state_reset_handler,
-                       scic_sds_remote_device_default_reset_complete_handler,
-                       scic_sds_stp_remote_device_ready_cmd_substate_start_io_handler,
-                       scic_sds_stp_remote_device_complete_request,
-                       scic_sds_remote_device_default_continue_request_handler,
-                       scic_sds_stp_remote_device_ready_substate_start_request_handler,
-                       scic_sds_stp_remote_device_complete_request,
-               },
-               scic_sds_stp_remote_device_ready_cmd_substate_suspend_handler,
-               scic_sds_remote_device_default_resume_handler,
-               scic_sds_remote_device_general_event_handler,
-               scic_sds_stp_remote_device_ready_cmd_substate_frame_handler
+       [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD] = {
+               .parent.start_handler           = scic_sds_remote_device_default_start_handler,
+               .parent.stop_handler            = scic_sds_remote_device_ready_state_stop_handler,
+               .parent.fail_handler            = scic_sds_remote_device_default_fail_handler,
+               .parent.destruct_handler        = scic_sds_remote_device_default_destruct_handler,
+               .parent.reset_handler           = scic_sds_remote_device_ready_state_reset_handler,
+               .parent.reset_complete_handler  = scic_sds_remote_device_default_reset_complete_handler,
+               .parent.start_io_handler        = scic_sds_stp_remote_device_ready_cmd_substate_start_io_handler,
+               .parent.complete_io_handler     = scic_sds_stp_remote_device_complete_request,
+               .parent.continue_io_handler     = scic_sds_remote_device_default_continue_request_handler,
+               .parent.start_task_handler      = scic_sds_stp_remote_device_ready_substate_start_request_handler,
+               .parent.complete_task_handler   = scic_sds_stp_remote_device_complete_request,
+               .suspend_handler                = scic_sds_stp_remote_device_ready_cmd_substate_suspend_handler,
+               .resume_handler                 = scic_sds_remote_device_default_resume_handler,
+               .event_handler                  = scic_sds_remote_device_general_event_handler,
+               .frame_handler                  = scic_sds_stp_remote_device_ready_cmd_substate_frame_handler
        },
-       /* SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ */
-       {
-               {
-                       scic_sds_remote_device_default_start_handler,
-                       scic_sds_remote_device_ready_state_stop_handler,
-                       scic_sds_remote_device_default_fail_handler,
-                       scic_sds_remote_device_default_destruct_handler,
-                       scic_sds_remote_device_ready_state_reset_handler,
-                       scic_sds_remote_device_default_reset_complete_handler,
-                       scic_sds_stp_remote_device_ready_ncq_substate_start_io_handler,
-                       scic_sds_stp_remote_device_complete_request,
-                       scic_sds_remote_device_default_continue_request_handler,
-                       scic_sds_stp_remote_device_ready_substate_start_request_handler,
-                       scic_sds_stp_remote_device_complete_request
-               },
-               scic_sds_remote_device_default_suspend_handler,
-               scic_sds_remote_device_default_resume_handler,
-               scic_sds_remote_device_general_event_handler,
-               scic_sds_stp_remote_device_ready_ncq_substate_frame_handler
+       [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ] = {
+               .parent.start_handler           = scic_sds_remote_device_default_start_handler,
+               .parent.stop_handler            = scic_sds_remote_device_ready_state_stop_handler,
+               .parent.fail_handler            = scic_sds_remote_device_default_fail_handler,
+               .parent.destruct_handler        = scic_sds_remote_device_default_destruct_handler,
+               .parent.reset_handler           = scic_sds_remote_device_ready_state_reset_handler,
+               .parent.reset_complete_handler  = scic_sds_remote_device_default_reset_complete_handler,
+               .parent.start_io_handler        = scic_sds_stp_remote_device_ready_ncq_substate_start_io_handler,
+               .parent.complete_io_handler     = scic_sds_stp_remote_device_complete_request,
+               .parent.continue_io_handler     = scic_sds_remote_device_default_continue_request_handler,
+               .parent.start_task_handler      = scic_sds_stp_remote_device_ready_substate_start_request_handler,
+               .parent.complete_task_handler   = scic_sds_stp_remote_device_complete_request,
+               .suspend_handler                = scic_sds_remote_device_default_suspend_handler,
+               .resume_handler                 = scic_sds_remote_device_default_resume_handler,
+               .event_handler                  = scic_sds_remote_device_general_event_handler,
+               .frame_handler                  = scic_sds_stp_remote_device_ready_ncq_substate_frame_handler
        },
-       /* SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR */
-       {
-               {
-                       scic_sds_remote_device_default_start_handler,
-                       scic_sds_remote_device_ready_state_stop_handler,
-                       scic_sds_remote_device_default_fail_handler,
-                       scic_sds_remote_device_default_destruct_handler,
-                       scic_sds_remote_device_ready_state_reset_handler,
-                       scic_sds_remote_device_default_reset_complete_handler,
-                       scic_sds_remote_device_default_start_request_handler,
-                       scic_sds_stp_remote_device_complete_request,
-                       scic_sds_remote_device_default_continue_request_handler,
-                       scic_sds_stp_remote_device_ready_substate_start_request_handler,
-                       scic_sds_stp_remote_device_complete_request
-               },
-               scic_sds_remote_device_default_suspend_handler,
-               scic_sds_remote_device_default_resume_handler,
-               scic_sds_remote_device_general_event_handler,
-               scic_sds_remote_device_general_frame_handler
+       [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR] = {
+               .parent.start_handler           = scic_sds_remote_device_default_start_handler,
+               .parent.stop_handler            = scic_sds_remote_device_ready_state_stop_handler,
+               .parent.fail_handler            = scic_sds_remote_device_default_fail_handler,
+               .parent.destruct_handler        = scic_sds_remote_device_default_destruct_handler,
+               .parent.reset_handler           = scic_sds_remote_device_ready_state_reset_handler,
+               .parent.reset_complete_handler  = scic_sds_remote_device_default_reset_complete_handler,
+               .parent.start_io_handler        = scic_sds_remote_device_default_start_request_handler,
+               .parent.complete_io_handler     = scic_sds_stp_remote_device_complete_request,
+               .parent.continue_io_handler     = scic_sds_remote_device_default_continue_request_handler,
+               .parent.start_task_handler      = scic_sds_stp_remote_device_ready_substate_start_request_handler,
+               .parent.complete_task_handler   = scic_sds_stp_remote_device_complete_request,
+               .suspend_handler                = scic_sds_remote_device_default_suspend_handler,
+               .resume_handler                 = scic_sds_remote_device_default_resume_handler,
+               .event_handler                  = scic_sds_remote_device_general_event_handler,
+               .frame_handler                  = scic_sds_remote_device_general_frame_handler
        },
 #if !defined(DISABLE_ATAPI)
-       /* SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_ATAPI_ERROR */
-       {
-               {
-                       scic_sds_remote_device_default_start_handler,
-                       scic_sds_remote_device_ready_state_stop_handler,
-                       scic_sds_remote_device_default_fail_handler,
-                       scic_sds_remote_device_default_destruct_handler,
-                       scic_sds_remote_device_ready_state_reset_handler,
-                       scic_sds_remote_device_default_reset_complete_handler,
-                       scic_sds_remote_device_default_start_request_handler,
-                       scic_sds_stp_remote_device_complete_request,
-                       scic_sds_remote_device_default_continue_request_handler,
-                       scic_sds_stp_remote_device_ready_substate_start_request_handler,
-                       scic_sds_stp_remote_device_complete_request
-               },
-               scic_sds_remote_device_default_suspend_handler,
-               scic_sds_remote_device_default_resume_handler,
-               scic_sds_stp_remote_device_ready_atapi_error_substate_event_handler,
-               scic_sds_remote_device_general_frame_handler
+       [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_ATAPI_ERROR] = {
+               .parent.start_handler           = scic_sds_remote_device_default_start_handler,
+               .parent.stop_handler            = scic_sds_remote_device_ready_state_stop_handler,
+               .parent.fail_handler            = scic_sds_remote_device_default_fail_handler,
+               .parent.destruct_handler        = scic_sds_remote_device_default_destruct_handler,
+               .parent.reset_handler           = scic_sds_remote_device_ready_state_reset_handler,
+               .parent.reset_complete_handler  = scic_sds_remote_device_default_reset_complete_handler,
+               .parent.start_io_handler        = scic_sds_remote_device_default_start_request_handler,
+               .parent.complete_io_handler     = scic_sds_stp_remote_device_complete_request,
+               .parent.continue_io_handler     = scic_sds_remote_device_default_continue_request_handler,
+               .parent.start_task_handler      = scic_sds_stp_remote_device_ready_substate_start_request_handler,
+               .parent.complete_task_handler   = scic_sds_stp_remote_device_complete_request,
+               .suspend_handler                = scic_sds_remote_device_default_suspend_handler,
+               .resume_handler                 = scic_sds_remote_device_default_resume_handler,
+               .event_handler                  = scic_sds_stp_remote_device_ready_atapi_error_substate_event_handler,
+               .frame_handler                  = scic_sds_remote_device_general_frame_handler
        },
 #endif
-       /* SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET */
-       {
-               {
-                       scic_sds_remote_device_default_start_handler,
-                       scic_sds_remote_device_ready_state_stop_handler,
-                       scic_sds_remote_device_default_fail_handler,
-                       scic_sds_remote_device_default_destruct_handler,
-                       scic_sds_remote_device_ready_state_reset_handler,
-                       scic_sds_remote_device_default_reset_complete_handler,
-                       scic_sds_stp_remote_device_ready_await_reset_substate_start_io_handler,
-                       scic_sds_stp_remote_device_ready_await_reset_substate_complete_request_handler,
-                       scic_sds_remote_device_default_continue_request_handler,
-                       scic_sds_stp_remote_device_ready_substate_start_request_handler,
-                       scic_sds_stp_remote_device_complete_request
-               },
-               scic_sds_remote_device_default_suspend_handler,
-               scic_sds_remote_device_default_resume_handler,
-               scic_sds_remote_device_general_event_handler,
-               scic_sds_remote_device_general_frame_handler
+       [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET] = {
+               .parent.start_handler           = scic_sds_remote_device_default_start_handler,
+               .parent.stop_handler            = scic_sds_remote_device_ready_state_stop_handler,
+               .parent.fail_handler            = scic_sds_remote_device_default_fail_handler,
+               .parent.destruct_handler        = scic_sds_remote_device_default_destruct_handler,
+               .parent.reset_handler           = scic_sds_remote_device_ready_state_reset_handler,
+               .parent.reset_complete_handler  = scic_sds_remote_device_default_reset_complete_handler,
+               .parent.start_io_handler        = scic_sds_stp_remote_device_ready_await_reset_substate_start_io_handler,
+               .parent.complete_io_handler     = scic_sds_stp_remote_device_ready_await_reset_substate_complete_request_handler,
+               .parent.continue_io_handler     = scic_sds_remote_device_default_continue_request_handler,
+               .parent.start_task_handler      = scic_sds_stp_remote_device_ready_substate_start_request_handler,
+               .parent.complete_task_handler   = scic_sds_stp_remote_device_complete_request,
+               .suspend_handler                = scic_sds_remote_device_default_suspend_handler,
+               .resume_handler                 = scic_sds_remote_device_default_resume_handler,
+               .event_handler                  = scic_sds_remote_device_general_event_handler,
+               .frame_handler                  = scic_sds_remote_device_general_frame_handler
        }
 };