From db48255b32a2664d8b321a51f46084a669e11ac6 Mon Sep 17 00:00:00 2001 From: Henryk Dembkowski Date: Sat, 12 Feb 2011 11:50:09 -0800 Subject: [PATCH] isci: c99 tables cleanup step1 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 Signed-off-by: Dan Williams --- .../scsi/isci/core/scic_sds_remote_device.h | 12 +- .../isci/core/scic_sds_smp_remote_device.c | 75 +++--- .../isci/core/scic_sds_stp_remote_device.c | 215 ++++++++---------- 3 files changed, 132 insertions(+), 170 deletions(-) diff --git a/drivers/scsi/isci/core/scic_sds_remote_device.h b/drivers/scsi/isci/core/scic_sds_remote_device.h index aed4eb640c26..d91570f212c6 100644 --- a/drivers/scsi/isci/core/scic_sds_remote_device.h +++ b/drivers/scsi/isci/core/scic_sds_remote_device.h @@ -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() - diff --git a/drivers/scsi/isci/core/scic_sds_smp_remote_device.c b/drivers/scsi/isci/core/scic_sds_smp_remote_device.c index 7cf78d3212cc..b0ed9d11eb2d 100644 --- a/drivers/scsi/isci/core/scic_sds_smp_remote_device.c +++ b/drivers/scsi/isci/core/scic_sds_smp_remote_device.c @@ -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 } }; /* diff --git a/drivers/scsi/isci/core/scic_sds_stp_remote_device.c b/drivers/scsi/isci/core/scic_sds_stp_remote_device.c index 1320c95ee8d4..6aa170e92500 100644 --- a/drivers/scsi/isci/core/scic_sds_stp_remote_device.c +++ b/drivers/scsi/isci/core/scic_sds_stp_remote_device.c @@ -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 } }; -- 2.30.2