diff options
author | Dan Williams <dan.j.williams@intel.com> | 2011-05-12 10:42:17 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 07:04:49 -0400 |
commit | 9269e0e898594c65dee6b20d4ed48e33dbbd4eeb (patch) | |
tree | f08aebe48d8005eec30a439c1c2d0e1e4b15d4a4 /drivers/scsi/isci/remote_device.c | |
parent | f34d9e5d3f34f395a497a8747316b04ef3e865b1 (diff) |
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>
Diffstat (limited to 'drivers/scsi/isci/remote_device.c')
-rw-r--r-- | drivers/scsi/isci/remote_device.c | 65 |
1 files changed, 30 insertions, 35 deletions
diff --git a/drivers/scsi/isci/remote_device.c b/drivers/scsi/isci/remote_device.c index b900e2c1b63e..68b63b04be19 100644 --- a/drivers/scsi/isci/remote_device.c +++ b/drivers/scsi/isci/remote_device.c | |||
@@ -807,9 +807,9 @@ static void scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handl | |||
807 | isci_remote_device_ready(scic_to_ihost(scic), idev); | 807 | isci_remote_device_ready(scic_to_ihost(scic), idev); |
808 | } | 808 | } |
809 | 809 | ||
810 | static void scic_sds_remote_device_initial_state_enter(void *object) | 810 | static void scic_sds_remote_device_initial_state_enter(struct sci_base_state_machine *sm) |
811 | { | 811 | { |
812 | struct scic_sds_remote_device *sci_dev = object; | 812 | struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); |
813 | 813 | ||
814 | /* Initial state is a transitional state to the stopped state */ | 814 | /* Initial state is a transitional state to the stopped state */ |
815 | sci_base_state_machine_change_state(&sci_dev->state_machine, | 815 | 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, | |||
904 | isci_remote_device_deconstruct(ihost, idev); | 904 | isci_remote_device_deconstruct(ihost, idev); |
905 | } | 905 | } |
906 | 906 | ||
907 | static void scic_sds_remote_device_stopped_state_enter(void *object) | 907 | static void scic_sds_remote_device_stopped_state_enter(struct sci_base_state_machine *sm) |
908 | { | 908 | { |
909 | struct scic_sds_remote_device *sci_dev = object; | 909 | struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); |
910 | struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller; | 910 | struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller; |
911 | struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); | 911 | struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); |
912 | u32 prev_state; | 912 | u32 prev_state; |
@@ -921,9 +921,9 @@ static void scic_sds_remote_device_stopped_state_enter(void *object) | |||
921 | scic_sds_controller_remote_device_stopped(scic, sci_dev); | 921 | scic_sds_controller_remote_device_stopped(scic, sci_dev); |
922 | } | 922 | } |
923 | 923 | ||
924 | static void scic_sds_remote_device_starting_state_enter(void *object) | 924 | static void scic_sds_remote_device_starting_state_enter(struct sci_base_state_machine *sm) |
925 | { | 925 | { |
926 | struct scic_sds_remote_device *sci_dev = object; | 926 | struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); |
927 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); | 927 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); |
928 | struct isci_host *ihost = scic_to_ihost(scic); | 928 | struct isci_host *ihost = scic_to_ihost(scic); |
929 | struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); | 929 | 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) | |||
932 | SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED); | 932 | SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED); |
933 | } | 933 | } |
934 | 934 | ||
935 | static void scic_sds_remote_device_ready_state_enter(void *object) | 935 | static void scic_sds_remote_device_ready_state_enter(struct sci_base_state_machine *sm) |
936 | { | 936 | { |
937 | struct scic_sds_remote_device *sci_dev = object; | 937 | struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); |
938 | struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller; | 938 | struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller; |
939 | struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); | 939 | struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); |
940 | struct domain_device *dev = idev->domain_dev; | 940 | struct domain_device *dev = idev->domain_dev; |
@@ -951,9 +951,9 @@ static void scic_sds_remote_device_ready_state_enter(void *object) | |||
951 | isci_remote_device_ready(scic_to_ihost(scic), idev); | 951 | isci_remote_device_ready(scic_to_ihost(scic), idev); |
952 | } | 952 | } |
953 | 953 | ||
954 | static void scic_sds_remote_device_ready_state_exit(void *object) | 954 | static void scic_sds_remote_device_ready_state_exit(struct sci_base_state_machine *sm) |
955 | { | 955 | { |
956 | struct scic_sds_remote_device *sci_dev = object; | 956 | struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); |
957 | struct domain_device *dev = sci_dev_to_domain(sci_dev); | 957 | struct domain_device *dev = sci_dev_to_domain(sci_dev); |
958 | 958 | ||
959 | if (dev->dev_type == SAS_END_DEV) { | 959 | if (dev->dev_type == SAS_END_DEV) { |
@@ -965,24 +965,24 @@ static void scic_sds_remote_device_ready_state_exit(void *object) | |||
965 | } | 965 | } |
966 | } | 966 | } |
967 | 967 | ||
968 | static void scic_sds_remote_device_resetting_state_enter(void *object) | 968 | static void scic_sds_remote_device_resetting_state_enter(struct sci_base_state_machine *sm) |
969 | { | 969 | { |
970 | struct scic_sds_remote_device *sci_dev = object; | 970 | struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); |
971 | 971 | ||
972 | scic_sds_remote_node_context_suspend( | 972 | scic_sds_remote_node_context_suspend( |
973 | &sci_dev->rnc, SCI_SOFTWARE_SUSPENSION, NULL, NULL); | 973 | &sci_dev->rnc, SCI_SOFTWARE_SUSPENSION, NULL, NULL); |
974 | } | 974 | } |
975 | 975 | ||
976 | static void scic_sds_remote_device_resetting_state_exit(void *object) | 976 | static void scic_sds_remote_device_resetting_state_exit(struct sci_base_state_machine *sm) |
977 | { | 977 | { |
978 | struct scic_sds_remote_device *sci_dev = object; | 978 | struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); |
979 | 979 | ||
980 | scic_sds_remote_node_context_resume(&sci_dev->rnc, NULL, NULL); | 980 | scic_sds_remote_node_context_resume(&sci_dev->rnc, NULL, NULL); |
981 | } | 981 | } |
982 | 982 | ||
983 | static void scic_sds_stp_remote_device_ready_idle_substate_enter(void *object) | 983 | static void scic_sds_stp_remote_device_ready_idle_substate_enter(struct sci_base_state_machine *sm) |
984 | { | 984 | { |
985 | struct scic_sds_remote_device *sci_dev = object; | 985 | struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); |
986 | 986 | ||
987 | sci_dev->working_request = NULL; | 987 | sci_dev->working_request = NULL; |
988 | if (scic_sds_remote_node_context_is_ready(&sci_dev->rnc)) { | 988 | 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) | |||
997 | } | 997 | } |
998 | } | 998 | } |
999 | 999 | ||
1000 | static void scic_sds_stp_remote_device_ready_cmd_substate_enter(void *object) | 1000 | static void scic_sds_stp_remote_device_ready_cmd_substate_enter(struct sci_base_state_machine *sm) |
1001 | { | 1001 | { |
1002 | struct scic_sds_remote_device *sci_dev = object; | 1002 | struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); |
1003 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); | 1003 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); |
1004 | 1004 | ||
1005 | BUG_ON(sci_dev->working_request == NULL); | 1005 | BUG_ON(sci_dev->working_request == NULL); |
@@ -1008,9 +1008,9 @@ static void scic_sds_stp_remote_device_ready_cmd_substate_enter(void *object) | |||
1008 | SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED); | 1008 | SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED); |
1009 | } | 1009 | } |
1010 | 1010 | ||
1011 | static void scic_sds_stp_remote_device_ready_ncq_error_substate_enter(void *object) | 1011 | static void scic_sds_stp_remote_device_ready_ncq_error_substate_enter(struct sci_base_state_machine *sm) |
1012 | { | 1012 | { |
1013 | struct scic_sds_remote_device *sci_dev = object; | 1013 | struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); |
1014 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); | 1014 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); |
1015 | struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); | 1015 | struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); |
1016 | 1016 | ||
@@ -1019,17 +1019,17 @@ static void scic_sds_stp_remote_device_ready_ncq_error_substate_enter(void *obje | |||
1019 | sci_dev->not_ready_reason); | 1019 | sci_dev->not_ready_reason); |
1020 | } | 1020 | } |
1021 | 1021 | ||
1022 | static void scic_sds_smp_remote_device_ready_idle_substate_enter(void *object) | 1022 | static void scic_sds_smp_remote_device_ready_idle_substate_enter(struct sci_base_state_machine *sm) |
1023 | { | 1023 | { |
1024 | struct scic_sds_remote_device *sci_dev = object; | 1024 | struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); |
1025 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); | 1025 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); |
1026 | 1026 | ||
1027 | isci_remote_device_ready(scic_to_ihost(scic), sci_dev_to_idev(sci_dev)); | 1027 | isci_remote_device_ready(scic_to_ihost(scic), sci_dev_to_idev(sci_dev)); |
1028 | } | 1028 | } |
1029 | 1029 | ||
1030 | static void scic_sds_smp_remote_device_ready_cmd_substate_enter(void *object) | 1030 | static void scic_sds_smp_remote_device_ready_cmd_substate_enter(struct sci_base_state_machine *sm) |
1031 | { | 1031 | { |
1032 | struct scic_sds_remote_device *sci_dev = object; | 1032 | struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); |
1033 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); | 1033 | struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); |
1034 | 1034 | ||
1035 | BUG_ON(sci_dev->working_request == NULL); | 1035 | BUG_ON(sci_dev->working_request == NULL); |
@@ -1038,9 +1038,9 @@ static void scic_sds_smp_remote_device_ready_cmd_substate_enter(void *object) | |||
1038 | SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED); | 1038 | SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED); |
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | static void scic_sds_smp_remote_device_ready_cmd_substate_exit(void *object) | 1041 | static void scic_sds_smp_remote_device_ready_cmd_substate_exit(struct sci_base_state_machine *sm) |
1042 | { | 1042 | { |
1043 | struct scic_sds_remote_device *sci_dev = object; | 1043 | struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); |
1044 | 1044 | ||
1045 | sci_dev->working_request = NULL; | 1045 | sci_dev->working_request = NULL; |
1046 | } | 1046 | } |
@@ -1102,16 +1102,11 @@ static void scic_remote_device_construct(struct scic_sds_port *sci_port, | |||
1102 | sci_dev->owning_port = sci_port; | 1102 | sci_dev->owning_port = sci_port; |
1103 | sci_dev->started_request_count = 0; | 1103 | sci_dev->started_request_count = 0; |
1104 | 1104 | ||
1105 | sci_base_state_machine_construct( | 1105 | sci_base_state_machine_construct(&sci_dev->state_machine, |
1106 | &sci_dev->state_machine, | 1106 | scic_sds_remote_device_state_table, |
1107 | sci_dev, | 1107 | SCI_BASE_REMOTE_DEVICE_STATE_INITIAL); |
1108 | scic_sds_remote_device_state_table, | ||
1109 | SCI_BASE_REMOTE_DEVICE_STATE_INITIAL | ||
1110 | ); | ||
1111 | 1108 | ||
1112 | sci_base_state_machine_start( | 1109 | sci_base_state_machine_start(&sci_dev->state_machine); |
1113 | &sci_dev->state_machine | ||
1114 | ); | ||
1115 | 1110 | ||
1116 | scic_sds_remote_node_context_construct(&sci_dev->rnc, | 1111 | scic_sds_remote_node_context_construct(&sci_dev->rnc, |
1117 | SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX); | 1112 | SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX); |