aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2011-05-12 10:42:17 -0400
committerDan Williams <dan.j.williams@intel.com>2011-07-03 07:04:49 -0400
commit9269e0e898594c65dee6b20d4ed48e33dbbd4eeb (patch)
treef08aebe48d8005eec30a439c1c2d0e1e4b15d4a4 /drivers
parentf34d9e5d3f34f395a497a8747316b04ef3e865b1 (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')
-rw-r--r--drivers/scsi/isci/host.c32
-rw-r--r--drivers/scsi/isci/phy.c70
-rw-r--r--drivers/scsi/isci/port.c45
-rw-r--r--drivers/scsi/isci/remote_device.c65
-rw-r--r--drivers/scsi/isci/remote_node_context.c39
-rw-r--r--drivers/scsi/isci/request.c35
-rw-r--r--drivers/scsi/isci/state_machine.c13
-rw-r--r--drivers/scsi/isci/state_machine.h43
8 files changed, 148 insertions, 194 deletions
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c
index a942384f2798..6cd7648197e1 100644
--- a/drivers/scsi/isci/host.c
+++ b/drivers/scsi/isci/host.c
@@ -1404,17 +1404,17 @@ static void isci_user_parameters_get(
1404 u->max_number_concurrent_device_spin_up = max_concurr_spinup; 1404 u->max_number_concurrent_device_spin_up = max_concurr_spinup;
1405} 1405}
1406 1406
1407static void scic_sds_controller_initial_state_enter(void *object) 1407static void scic_sds_controller_initial_state_enter(struct sci_base_state_machine *sm)
1408{ 1408{
1409 struct scic_sds_controller *scic = object; 1409 struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
1410 1410
1411 sci_base_state_machine_change_state(&scic->state_machine, 1411 sci_base_state_machine_change_state(&scic->state_machine,
1412 SCI_BASE_CONTROLLER_STATE_RESET); 1412 SCI_BASE_CONTROLLER_STATE_RESET);
1413} 1413}
1414 1414
1415static inline void scic_sds_controller_starting_state_exit(void *object) 1415static inline void scic_sds_controller_starting_state_exit(struct sci_base_state_machine *sm)
1416{ 1416{
1417 struct scic_sds_controller *scic = object; 1417 struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
1418 1418
1419 isci_timer_stop(scic->timeout_timer); 1419 isci_timer_stop(scic->timeout_timer);
1420} 1420}
@@ -1539,17 +1539,17 @@ static enum sci_status scic_controller_set_interrupt_coalescence(
1539} 1539}
1540 1540
1541 1541
1542static void scic_sds_controller_ready_state_enter(void *object) 1542static void scic_sds_controller_ready_state_enter(struct sci_base_state_machine *sm)
1543{ 1543{
1544 struct scic_sds_controller *scic = object; 1544 struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
1545 1545
1546 /* set the default interrupt coalescence number and timeout value. */ 1546 /* set the default interrupt coalescence number and timeout value. */
1547 scic_controller_set_interrupt_coalescence(scic, 0x10, 250); 1547 scic_controller_set_interrupt_coalescence(scic, 0x10, 250);
1548} 1548}
1549 1549
1550static void scic_sds_controller_ready_state_exit(void *object) 1550static void scic_sds_controller_ready_state_exit(struct sci_base_state_machine *sm)
1551{ 1551{
1552 struct scic_sds_controller *scic = object; 1552 struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
1553 1553
1554 /* disable interrupt coalescence. */ 1554 /* disable interrupt coalescence. */
1555 scic_controller_set_interrupt_coalescence(scic, 0, 0); 1555 scic_controller_set_interrupt_coalescence(scic, 0, 0);
@@ -1638,9 +1638,9 @@ static enum sci_status scic_sds_controller_stop_devices(struct scic_sds_controll
1638 return status; 1638 return status;
1639} 1639}
1640 1640
1641static void scic_sds_controller_stopping_state_enter(void *object) 1641static void scic_sds_controller_stopping_state_enter(struct sci_base_state_machine *sm)
1642{ 1642{
1643 struct scic_sds_controller *scic = object; 1643 struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
1644 1644
1645 /* Stop all of the components for this controller */ 1645 /* Stop all of the components for this controller */
1646 scic_sds_controller_stop_phys(scic); 1646 scic_sds_controller_stop_phys(scic);
@@ -1648,9 +1648,9 @@ static void scic_sds_controller_stopping_state_enter(void *object)
1648 scic_sds_controller_stop_devices(scic); 1648 scic_sds_controller_stop_devices(scic);
1649} 1649}
1650 1650
1651static void scic_sds_controller_stopping_state_exit(void *object) 1651static void scic_sds_controller_stopping_state_exit(struct sci_base_state_machine *sm)
1652{ 1652{
1653 struct scic_sds_controller *scic = object; 1653 struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
1654 1654
1655 isci_timer_stop(scic->timeout_timer); 1655 isci_timer_stop(scic->timeout_timer);
1656} 1656}
@@ -1679,9 +1679,9 @@ static void scic_sds_controller_reset_hardware(struct scic_sds_controller *scic)
1679 writel(0, &scic->scu_registers->sdma.unsolicited_frame_get_pointer); 1679 writel(0, &scic->scu_registers->sdma.unsolicited_frame_get_pointer);
1680} 1680}
1681 1681
1682static void scic_sds_controller_resetting_state_enter(void *object) 1682static void scic_sds_controller_resetting_state_enter(struct sci_base_state_machine *sm)
1683{ 1683{
1684 struct scic_sds_controller *scic = object; 1684 struct scic_sds_controller *scic = container_of(sm, typeof(*scic), state_machine);
1685 1685
1686 scic_sds_controller_reset_hardware(scic); 1686 scic_sds_controller_reset_hardware(scic);
1687 sci_base_state_machine_change_state(&scic->state_machine, 1687 sci_base_state_machine_change_state(&scic->state_machine,
@@ -1785,8 +1785,8 @@ static enum sci_status scic_controller_construct(struct scic_sds_controller *sci
1785 u8 i; 1785 u8 i;
1786 1786
1787 sci_base_state_machine_construct(&scic->state_machine, 1787 sci_base_state_machine_construct(&scic->state_machine,
1788 scic, scic_sds_controller_state_table, 1788 scic_sds_controller_state_table,
1789 SCI_BASE_CONTROLLER_STATE_INITIAL); 1789 SCI_BASE_CONTROLLER_STATE_INITIAL);
1790 1790
1791 sci_base_state_machine_start(&scic->state_machine); 1791 sci_base_state_machine_start(&scic->state_machine);
1792 1792
diff --git a/drivers/scsi/isci/phy.c b/drivers/scsi/isci/phy.c
index 8bd1a85f621e..f21e10e2888c 100644
--- a/drivers/scsi/isci/phy.c
+++ b/drivers/scsi/isci/phy.c
@@ -1026,81 +1026,80 @@ enum sci_status scic_sds_phy_frame_handler(struct scic_sds_phy *sci_phy,
1026 1026
1027} 1027}
1028 1028
1029static void scic_sds_phy_starting_initial_substate_enter(void *object) 1029static void scic_sds_phy_starting_initial_substate_enter(struct sci_base_state_machine *sm)
1030{ 1030{
1031 struct scic_sds_phy *sci_phy = object; 1031 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
1032 1032
1033 /* This is just an temporary state go off to the starting state */ 1033 /* This is just an temporary state go off to the starting state */
1034 sci_base_state_machine_change_state(&sci_phy->state_machine, 1034 sci_base_state_machine_change_state(&sci_phy->state_machine,
1035 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN); 1035 SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN);
1036} 1036}
1037 1037
1038static void scic_sds_phy_starting_await_sas_power_substate_enter(void *object) 1038static void scic_sds_phy_starting_await_sas_power_substate_enter(struct sci_base_state_machine *sm)
1039{ 1039{
1040 struct scic_sds_phy *sci_phy = object; 1040 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
1041 struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller; 1041 struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller;
1042 1042
1043 scic_sds_controller_power_control_queue_insert(scic, sci_phy); 1043 scic_sds_controller_power_control_queue_insert(scic, sci_phy);
1044} 1044}
1045 1045
1046static void scic_sds_phy_starting_await_sas_power_substate_exit(void *object) 1046static void scic_sds_phy_starting_await_sas_power_substate_exit(struct sci_base_state_machine *sm)
1047{ 1047{
1048 struct scic_sds_phy *sci_phy = object; 1048 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
1049 struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller; 1049 struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller;
1050 1050
1051 scic_sds_controller_power_control_queue_remove(scic, sci_phy); 1051 scic_sds_controller_power_control_queue_remove(scic, sci_phy);
1052} 1052}
1053 1053
1054static void scic_sds_phy_starting_await_sata_power_substate_enter(void *object) 1054static void scic_sds_phy_starting_await_sata_power_substate_enter(struct sci_base_state_machine *sm)
1055{ 1055{
1056 struct scic_sds_phy *sci_phy = object; 1056 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
1057 struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller; 1057 struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller;
1058 1058
1059 scic_sds_controller_power_control_queue_insert(scic, sci_phy); 1059 scic_sds_controller_power_control_queue_insert(scic, sci_phy);
1060} 1060}
1061 1061
1062static void scic_sds_phy_starting_await_sata_power_substate_exit(void *object) 1062static void scic_sds_phy_starting_await_sata_power_substate_exit(struct sci_base_state_machine *sm)
1063{ 1063{
1064 struct scic_sds_phy *sci_phy = object; 1064 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
1065 struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller; 1065 struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller;
1066 1066
1067 scic_sds_controller_power_control_queue_remove(scic, sci_phy); 1067 scic_sds_controller_power_control_queue_remove(scic, sci_phy);
1068} 1068}
1069 1069
1070static void scic_sds_phy_starting_await_sata_phy_substate_enter(void *object) 1070static void scic_sds_phy_starting_await_sata_phy_substate_enter(struct sci_base_state_machine *sm)
1071{ 1071{
1072 struct scic_sds_phy *sci_phy = object; 1072 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
1073 1073
1074 isci_timer_start(sci_phy->sata_timeout_timer, 1074 isci_timer_start(sci_phy->sata_timeout_timer,
1075 SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT); 1075 SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT);
1076} 1076}
1077 1077
1078static void scic_sds_phy_starting_await_sata_phy_substate_exit(void *object) 1078static void scic_sds_phy_starting_await_sata_phy_substate_exit(struct sci_base_state_machine *sm)
1079{ 1079{
1080 struct scic_sds_phy *sci_phy = object; 1080 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
1081 1081
1082 isci_timer_stop(sci_phy->sata_timeout_timer); 1082 isci_timer_stop(sci_phy->sata_timeout_timer);
1083} 1083}
1084 1084
1085static void scic_sds_phy_starting_await_sata_speed_substate_enter(void *object) 1085static void scic_sds_phy_starting_await_sata_speed_substate_enter(struct sci_base_state_machine *sm)
1086{ 1086{
1087 struct scic_sds_phy *sci_phy = object; 1087 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
1088 1088
1089 isci_timer_start(sci_phy->sata_timeout_timer, 1089 isci_timer_start(sci_phy->sata_timeout_timer,
1090 SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT); 1090 SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT);
1091} 1091}
1092 1092
1093static void scic_sds_phy_starting_await_sata_speed_substate_exit( 1093static void scic_sds_phy_starting_await_sata_speed_substate_exit(struct sci_base_state_machine *sm)
1094 void *object)
1095{ 1094{
1096 struct scic_sds_phy *sci_phy = object; 1095 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
1097 1096
1098 isci_timer_stop(sci_phy->sata_timeout_timer); 1097 isci_timer_stop(sci_phy->sata_timeout_timer);
1099} 1098}
1100 1099
1101static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(void *object) 1100static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(struct sci_base_state_machine *sm)
1102{ 1101{
1103 struct scic_sds_phy *sci_phy = object; 1102 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
1104 1103
1105 if (scic_sds_port_link_detected(sci_phy->owning_port, sci_phy)) { 1104 if (scic_sds_port_link_detected(sci_phy->owning_port, sci_phy)) {
1106 1105
@@ -1118,16 +1117,16 @@ static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(void *object)
1118 sci_phy->is_in_link_training = false; 1117 sci_phy->is_in_link_training = false;
1119} 1118}
1120 1119
1121static void scic_sds_phy_starting_await_sig_fis_uf_substate_exit(void *object) 1120static void scic_sds_phy_starting_await_sig_fis_uf_substate_exit(struct sci_base_state_machine *sm)
1122{ 1121{
1123 struct scic_sds_phy *sci_phy = object; 1122 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
1124 1123
1125 isci_timer_stop(sci_phy->sata_timeout_timer); 1124 isci_timer_stop(sci_phy->sata_timeout_timer);
1126} 1125}
1127 1126
1128static void scic_sds_phy_starting_final_substate_enter(void *object) 1127static void scic_sds_phy_starting_final_substate_enter(struct sci_base_state_machine *sm)
1129{ 1128{
1130 struct scic_sds_phy *sci_phy = object; 1129 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
1131 1130
1132 /* State machine has run to completion so exit out and change 1131 /* State machine has run to completion so exit out and change
1133 * the base state machine to the ready state 1132 * the base state machine to the ready state
@@ -1217,9 +1216,9 @@ static void scu_link_layer_tx_hard_reset(
1217 &sci_phy->link_layer_registers->phy_configuration); 1216 &sci_phy->link_layer_registers->phy_configuration);
1218} 1217}
1219 1218
1220static void scic_sds_phy_stopped_state_enter(void *object) 1219static void scic_sds_phy_stopped_state_enter(struct sci_base_state_machine *sm)
1221{ 1220{
1222 struct scic_sds_phy *sci_phy = object; 1221 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
1223 struct scic_sds_port *sci_port = sci_phy->owning_port; 1222 struct scic_sds_port *sci_port = sci_phy->owning_port;
1224 struct scic_sds_controller *scic = sci_port->owning_controller; 1223 struct scic_sds_controller *scic = sci_port->owning_controller;
1225 struct isci_host *ihost = scic_to_ihost(scic); 1224 struct isci_host *ihost = scic_to_ihost(scic);
@@ -1242,9 +1241,9 @@ static void scic_sds_phy_stopped_state_enter(void *object)
1242 sci_phy); 1241 sci_phy);
1243} 1242}
1244 1243
1245static void scic_sds_phy_starting_state_enter(void *object) 1244static void scic_sds_phy_starting_state_enter(struct sci_base_state_machine *sm)
1246{ 1245{
1247 struct scic_sds_phy *sci_phy = object; 1246 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
1248 1247
1249 scu_link_layer_stop_protocol_engine(sci_phy); 1248 scu_link_layer_stop_protocol_engine(sci_phy);
1250 scu_link_layer_start_oob(sci_phy); 1249 scu_link_layer_start_oob(sci_phy);
@@ -1262,9 +1261,9 @@ static void scic_sds_phy_starting_state_enter(void *object)
1262 SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL); 1261 SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL);
1263} 1262}
1264 1263
1265static void scic_sds_phy_ready_state_enter(void *object) 1264static void scic_sds_phy_ready_state_enter(struct sci_base_state_machine *sm)
1266{ 1265{
1267 struct scic_sds_phy *sci_phy = object; 1266 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
1268 1267
1269 scic_sds_controller_link_up(scic_sds_phy_get_controller(sci_phy), 1268 scic_sds_controller_link_up(scic_sds_phy_get_controller(sci_phy),
1270 phy_get_non_dummy_port(sci_phy), 1269 phy_get_non_dummy_port(sci_phy),
@@ -1272,16 +1271,16 @@ static void scic_sds_phy_ready_state_enter(void *object)
1272 1271
1273} 1272}
1274 1273
1275static void scic_sds_phy_ready_state_exit(void *object) 1274static void scic_sds_phy_ready_state_exit(struct sci_base_state_machine *sm)
1276{ 1275{
1277 struct scic_sds_phy *sci_phy = object; 1276 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
1278 1277
1279 scic_sds_phy_suspend(sci_phy); 1278 scic_sds_phy_suspend(sci_phy);
1280} 1279}
1281 1280
1282static void scic_sds_phy_resetting_state_enter(void *object) 1281static void scic_sds_phy_resetting_state_enter(struct sci_base_state_machine *sm)
1283{ 1282{
1284 struct scic_sds_phy *sci_phy = object; 1283 struct scic_sds_phy *sci_phy = container_of(sm, typeof(*sci_phy), state_machine);
1285 1284
1286 /* The phy is being reset, therefore deactivate it from the port. In 1285 /* The phy is being reset, therefore deactivate it from the port. In
1287 * the resetting state we don't notify the user regarding link up and 1286 * the resetting state we don't notify the user regarding link up and
@@ -1351,7 +1350,6 @@ void scic_sds_phy_construct(struct scic_sds_phy *sci_phy,
1351 struct scic_sds_port *owning_port, u8 phy_index) 1350 struct scic_sds_port *owning_port, u8 phy_index)
1352{ 1351{
1353 sci_base_state_machine_construct(&sci_phy->state_machine, 1352 sci_base_state_machine_construct(&sci_phy->state_machine,
1354 sci_phy,
1355 scic_sds_phy_state_table, 1353 scic_sds_phy_state_table,
1356 SCI_BASE_PHY_STATE_INITIAL); 1354 SCI_BASE_PHY_STATE_INITIAL);
1357 1355
diff --git a/drivers/scsi/isci/port.c b/drivers/scsi/isci/port.c
index f43c1f6c9669..3050415e228d 100644
--- a/drivers/scsi/isci/port.c
+++ b/drivers/scsi/isci/port.c
@@ -1133,9 +1133,9 @@ scic_sds_port_resume_port_task_scheduler(struct scic_sds_port *port)
1133 writel(pts_control_value, &port->port_task_scheduler_registers->control); 1133 writel(pts_control_value, &port->port_task_scheduler_registers->control);
1134} 1134}
1135 1135
1136static void scic_sds_port_ready_substate_waiting_enter(void *object) 1136static void scic_sds_port_ready_substate_waiting_enter(struct sci_base_state_machine *sm)
1137{ 1137{
1138 struct scic_sds_port *sci_port = object; 1138 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
1139 1139
1140 scic_sds_port_suspend_port_task_scheduler(sci_port); 1140 scic_sds_port_suspend_port_task_scheduler(sci_port);
1141 1141
@@ -1148,10 +1148,10 @@ static void scic_sds_port_ready_substate_waiting_enter(void *object)
1148 } 1148 }
1149} 1149}
1150 1150
1151static void scic_sds_port_ready_substate_operational_enter(void *object) 1151static void scic_sds_port_ready_substate_operational_enter(struct sci_base_state_machine *sm)
1152{ 1152{
1153 u32 index; 1153 u32 index;
1154 struct scic_sds_port *sci_port = object; 1154 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
1155 struct scic_sds_controller *scic = sci_port->owning_controller; 1155 struct scic_sds_controller *scic = sci_port->owning_controller;
1156 struct isci_host *ihost = scic_to_ihost(scic); 1156 struct isci_host *ihost = scic_to_ihost(scic);
1157 struct isci_port *iport = sci_port_to_iport(sci_port); 1157 struct isci_port *iport = sci_port_to_iport(sci_port);
@@ -1210,9 +1210,9 @@ static void scic_sds_port_invalidate_dummy_remote_node(struct scic_sds_port *sci
1210 * exiting the SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL. This function reports 1210 * exiting the SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL. This function reports
1211 * the port not ready and suspends the port task scheduler. none 1211 * the port not ready and suspends the port task scheduler. none
1212 */ 1212 */
1213static void scic_sds_port_ready_substate_operational_exit(void *object) 1213static void scic_sds_port_ready_substate_operational_exit(struct sci_base_state_machine *sm)
1214{ 1214{
1215 struct scic_sds_port *sci_port = object; 1215 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
1216 struct scic_sds_controller *scic = sci_port->owning_controller; 1216 struct scic_sds_controller *scic = sci_port->owning_controller;
1217 struct isci_host *ihost = scic_to_ihost(scic); 1217 struct isci_host *ihost = scic_to_ihost(scic);
1218 struct isci_port *iport = sci_port_to_iport(sci_port); 1218 struct isci_port *iport = sci_port_to_iport(sci_port);
@@ -1230,9 +1230,9 @@ static void scic_sds_port_ready_substate_operational_exit(void *object)
1230 scic_sds_port_invalidate_dummy_remote_node(sci_port); 1230 scic_sds_port_invalidate_dummy_remote_node(sci_port);
1231} 1231}
1232 1232
1233static void scic_sds_port_ready_substate_configuring_enter(void *object) 1233static void scic_sds_port_ready_substate_configuring_enter(struct sci_base_state_machine *sm)
1234{ 1234{
1235 struct scic_sds_port *sci_port = object; 1235 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
1236 struct scic_sds_controller *scic = sci_port->owning_controller; 1236 struct scic_sds_controller *scic = sci_port->owning_controller;
1237 struct isci_host *ihost = scic_to_ihost(scic); 1237 struct isci_host *ihost = scic_to_ihost(scic);
1238 struct isci_port *iport = sci_port_to_iport(sci_port); 1238 struct isci_port *iport = sci_port_to_iport(sci_port);
@@ -1247,9 +1247,9 @@ static void scic_sds_port_ready_substate_configuring_enter(void *object)
1247 SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL); 1247 SCIC_SDS_PORT_READY_SUBSTATE_OPERATIONAL);
1248} 1248}
1249 1249
1250static void scic_sds_port_ready_substate_configuring_exit(void *object) 1250static void scic_sds_port_ready_substate_configuring_exit(struct sci_base_state_machine *sm)
1251{ 1251{
1252 struct scic_sds_port *sci_port = object; 1252 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
1253 1253
1254 scic_sds_port_suspend_port_task_scheduler(sci_port); 1254 scic_sds_port_suspend_port_task_scheduler(sci_port);
1255 if (sci_port->ready_exit) 1255 if (sci_port->ready_exit)
@@ -1710,9 +1710,9 @@ static void scic_sds_port_post_dummy_remote_node(struct scic_sds_port *sci_port)
1710 scic_sds_controller_post_request(scic, command); 1710 scic_sds_controller_post_request(scic, command);
1711} 1711}
1712 1712
1713static void scic_sds_port_stopped_state_enter(void *object) 1713static void scic_sds_port_stopped_state_enter(struct sci_base_state_machine *sm)
1714{ 1714{
1715 struct scic_sds_port *sci_port = object; 1715 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
1716 1716
1717 if (sci_port->state_machine.previous_state_id == SCI_BASE_PORT_STATE_STOPPING) { 1717 if (sci_port->state_machine.previous_state_id == SCI_BASE_PORT_STATE_STOPPING) {
1718 /* 1718 /*
@@ -1723,17 +1723,17 @@ static void scic_sds_port_stopped_state_enter(void *object)
1723 } 1723 }
1724} 1724}
1725 1725
1726static void scic_sds_port_stopped_state_exit(void *object) 1726static void scic_sds_port_stopped_state_exit(struct sci_base_state_machine *sm)
1727{ 1727{
1728 struct scic_sds_port *sci_port = object; 1728 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
1729 1729
1730 /* Enable and suspend the port task scheduler */ 1730 /* Enable and suspend the port task scheduler */
1731 scic_sds_port_enable_port_task_scheduler(sci_port); 1731 scic_sds_port_enable_port_task_scheduler(sci_port);
1732} 1732}
1733 1733
1734static void scic_sds_port_ready_state_enter(void *object) 1734static void scic_sds_port_ready_state_enter(struct sci_base_state_machine *sm)
1735{ 1735{
1736 struct scic_sds_port *sci_port = object; 1736 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
1737 struct scic_sds_controller *scic = sci_port->owning_controller; 1737 struct scic_sds_controller *scic = sci_port->owning_controller;
1738 struct isci_host *ihost = scic_to_ihost(scic); 1738 struct isci_host *ihost = scic_to_ihost(scic);
1739 struct isci_port *iport = sci_port_to_iport(sci_port); 1739 struct isci_port *iport = sci_port_to_iport(sci_port);
@@ -1753,25 +1753,25 @@ static void scic_sds_port_ready_state_enter(void *object)
1753 SCIC_SDS_PORT_READY_SUBSTATE_WAITING); 1753 SCIC_SDS_PORT_READY_SUBSTATE_WAITING);
1754} 1754}
1755 1755
1756static void scic_sds_port_resetting_state_exit(void *object) 1756static void scic_sds_port_resetting_state_exit(struct sci_base_state_machine *sm)
1757{ 1757{
1758 struct scic_sds_port *sci_port = object; 1758 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
1759 1759
1760 isci_timer_stop(sci_port->timer_handle); 1760 isci_timer_stop(sci_port->timer_handle);
1761} 1761}
1762 1762
1763static void scic_sds_port_stopping_state_exit(void *object) 1763static void scic_sds_port_stopping_state_exit(struct sci_base_state_machine *sm)
1764{ 1764{
1765 struct scic_sds_port *sci_port = object; 1765 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
1766 1766
1767 isci_timer_stop(sci_port->timer_handle); 1767 isci_timer_stop(sci_port->timer_handle);
1768 1768
1769 scic_sds_port_destroy_dummy_resources(sci_port); 1769 scic_sds_port_destroy_dummy_resources(sci_port);
1770} 1770}
1771 1771
1772static void scic_sds_port_failed_state_enter(void *object) 1772static void scic_sds_port_failed_state_enter(struct sci_base_state_machine *sm)
1773{ 1773{
1774 struct scic_sds_port *sci_port = object; 1774 struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine);
1775 struct isci_port *iport = sci_port_to_iport(sci_port); 1775 struct isci_port *iport = sci_port_to_iport(sci_port);
1776 1776
1777 isci_port_hard_reset_complete(iport, SCI_FAILURE_TIMEOUT); 1777 isci_port_hard_reset_complete(iport, SCI_FAILURE_TIMEOUT);
@@ -1813,7 +1813,6 @@ void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 index,
1813 struct scic_sds_controller *scic) 1813 struct scic_sds_controller *scic)
1814{ 1814{
1815 sci_base_state_machine_construct(&sci_port->state_machine, 1815 sci_base_state_machine_construct(&sci_port->state_machine,
1816 sci_port,
1817 scic_sds_port_state_table, 1816 scic_sds_port_state_table,
1818 SCI_BASE_PORT_STATE_STOPPED); 1817 SCI_BASE_PORT_STATE_STOPPED);
1819 1818
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
810static void scic_sds_remote_device_initial_state_enter(void *object) 810static 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
907static void scic_sds_remote_device_stopped_state_enter(void *object) 907static 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
924static void scic_sds_remote_device_starting_state_enter(void *object) 924static 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
935static void scic_sds_remote_device_ready_state_enter(void *object) 935static 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
954static void scic_sds_remote_device_ready_state_exit(void *object) 954static 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
968static void scic_sds_remote_device_resetting_state_enter(void *object) 968static 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
976static void scic_sds_remote_device_resetting_state_exit(void *object) 976static 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
983static void scic_sds_stp_remote_device_ready_idle_substate_enter(void *object) 983static 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
1000static void scic_sds_stp_remote_device_ready_cmd_substate_enter(void *object) 1000static 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
1011static void scic_sds_stp_remote_device_ready_ncq_error_substate_enter(void *object) 1011static 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
1022static void scic_sds_smp_remote_device_ready_idle_substate_enter(void *object) 1022static 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
1030static void scic_sds_smp_remote_device_ready_cmd_substate_enter(void *object) 1030static 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
1041static void scic_sds_smp_remote_device_ready_cmd_substate_exit(void *object) 1041static 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);
diff --git a/drivers/scsi/isci/remote_node_context.c b/drivers/scsi/isci/remote_node_context.c
index 82507bd228d4..e7fa5bac7d53 100644
--- a/drivers/scsi/isci/remote_node_context.c
+++ b/drivers/scsi/isci/remote_node_context.c
@@ -266,10 +266,9 @@ static void scic_sds_remote_node_context_invalidate_context_buffer(
266 SCU_CONTEXT_COMMAND_POST_RNC_INVALIDATE); 266 SCU_CONTEXT_COMMAND_POST_RNC_INVALIDATE);
267} 267}
268 268
269static void scic_sds_remote_node_context_initial_state_enter(void *object) 269static void scic_sds_remote_node_context_initial_state_enter(struct sci_base_state_machine *sm)
270{ 270{
271 struct scic_sds_remote_node_context *rnc = object; 271 struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine);
272 struct sci_base_state_machine *sm = &rnc->state_machine;
273 272
274 /* Check to see if we have gotten back to the initial state because 273 /* Check to see if we have gotten back to the initial state because
275 * someone requested to destroy the remote node context object. 274 * someone requested to destroy the remote node context object.
@@ -280,23 +279,23 @@ static void scic_sds_remote_node_context_initial_state_enter(void *object)
280 } 279 }
281} 280}
282 281
283static void scic_sds_remote_node_context_posting_state_enter(void *object) 282static void scic_sds_remote_node_context_posting_state_enter(struct sci_base_state_machine *sm)
284{ 283{
285 struct scic_sds_remote_node_context *sci_rnc = object; 284 struct scic_sds_remote_node_context *sci_rnc = container_of(sm, typeof(*sci_rnc), state_machine);
286 285
287 scic_sds_remote_node_context_validate_context_buffer(sci_rnc); 286 scic_sds_remote_node_context_validate_context_buffer(sci_rnc);
288} 287}
289 288
290static void scic_sds_remote_node_context_invalidating_state_enter(void *object) 289static void scic_sds_remote_node_context_invalidating_state_enter(struct sci_base_state_machine *sm)
291{ 290{
292 struct scic_sds_remote_node_context *rnc = object; 291 struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine);
293 292
294 scic_sds_remote_node_context_invalidate_context_buffer(rnc); 293 scic_sds_remote_node_context_invalidate_context_buffer(rnc);
295} 294}
296 295
297static void scic_sds_remote_node_context_resuming_state_enter(void *object) 296static void scic_sds_remote_node_context_resuming_state_enter(struct sci_base_state_machine *sm)
298{ 297{
299 struct scic_sds_remote_node_context *rnc = object; 298 struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine);
300 struct scic_sds_remote_device *sci_dev; 299 struct scic_sds_remote_device *sci_dev;
301 struct domain_device *dev; 300 struct domain_device *dev;
302 301
@@ -317,9 +316,9 @@ static void scic_sds_remote_node_context_resuming_state_enter(void *object)
317 scic_sds_remote_device_post_request(sci_dev, SCU_CONTEXT_COMMAND_POST_RNC_RESUME); 316 scic_sds_remote_device_post_request(sci_dev, SCU_CONTEXT_COMMAND_POST_RNC_RESUME);
318} 317}
319 318
320static void scic_sds_remote_node_context_ready_state_enter(void *object) 319static void scic_sds_remote_node_context_ready_state_enter(struct sci_base_state_machine *sm)
321{ 320{
322 struct scic_sds_remote_node_context *rnc = object; 321 struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine);
323 322
324 rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED; 323 rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED;
325 324
@@ -327,17 +326,16 @@ static void scic_sds_remote_node_context_ready_state_enter(void *object)
327 scic_sds_remote_node_context_notify_user(rnc); 326 scic_sds_remote_node_context_notify_user(rnc);
328} 327}
329 328
330static void scic_sds_remote_node_context_tx_suspended_state_enter(void *object) 329static void scic_sds_remote_node_context_tx_suspended_state_enter(struct sci_base_state_machine *sm)
331{ 330{
332 struct scic_sds_remote_node_context *rnc = object; 331 struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine);
333 332
334 scic_sds_remote_node_context_continue_state_transitions(rnc); 333 scic_sds_remote_node_context_continue_state_transitions(rnc);
335} 334}
336 335
337static void scic_sds_remote_node_context_tx_rx_suspended_state_enter( 336static void scic_sds_remote_node_context_tx_rx_suspended_state_enter(struct sci_base_state_machine *sm)
338 void *object)
339{ 337{
340 struct scic_sds_remote_node_context *rnc = object; 338 struct scic_sds_remote_node_context *rnc = container_of(sm, typeof(*rnc), state_machine);
341 339
342 scic_sds_remote_node_context_continue_state_transitions(rnc); 340 scic_sds_remote_node_context_continue_state_transitions(rnc);
343} 341}
@@ -375,12 +373,9 @@ void scic_sds_remote_node_context_construct(struct scic_sds_remote_node_context
375 rnc->remote_node_index = remote_node_index; 373 rnc->remote_node_index = remote_node_index;
376 rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED; 374 rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED;
377 375
378 sci_base_state_machine_construct( 376 sci_base_state_machine_construct(&rnc->state_machine,
379 &rnc->state_machine, 377 scic_sds_remote_node_context_state_table,
380 rnc, 378 SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE);
381 scic_sds_remote_node_context_state_table,
382 SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE
383 );
384 379
385 sci_base_state_machine_start(&rnc->state_machine); 380 sci_base_state_machine_start(&rnc->state_machine);
386} 381}
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index c63064ede38d..063ef04080d5 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -2900,10 +2900,9 @@ static void isci_request_io_request_complete(struct isci_host *isci_host,
2900 isci_host_can_dequeue(isci_host, 1); 2900 isci_host_can_dequeue(isci_host, 1);
2901} 2901}
2902 2902
2903static void scic_sds_request_started_state_enter(void *object) 2903static void scic_sds_request_started_state_enter(struct sci_base_state_machine *sm)
2904{ 2904{
2905 struct scic_sds_request *sci_req = object; 2905 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine);
2906 struct sci_base_state_machine *sm = &sci_req->state_machine;
2907 struct isci_request *ireq = sci_req_to_ireq(sci_req); 2906 struct isci_request *ireq = sci_req_to_ireq(sci_req);
2908 struct domain_device *dev = sci_dev_to_domain(sci_req->target_device); 2907 struct domain_device *dev = sci_dev_to_domain(sci_req->target_device);
2909 struct sas_task *task; 2908 struct sas_task *task;
@@ -2942,9 +2941,9 @@ static void scic_sds_request_started_state_enter(void *object)
2942 } 2941 }
2943} 2942}
2944 2943
2945static void scic_sds_request_completed_state_enter(void *object) 2944static void scic_sds_request_completed_state_enter(struct sci_base_state_machine *sm)
2946{ 2945{
2947 struct scic_sds_request *sci_req = object; 2946 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine);
2948 struct scic_sds_controller *scic = sci_req->owning_controller; 2947 struct scic_sds_controller *scic = sci_req->owning_controller;
2949 struct isci_host *ihost = scic_to_ihost(scic); 2948 struct isci_host *ihost = scic_to_ihost(scic);
2950 struct isci_request *ireq = sci_req_to_ireq(sci_req); 2949 struct isci_request *ireq = sci_req_to_ireq(sci_req);
@@ -2957,42 +2956,41 @@ static void scic_sds_request_completed_state_enter(void *object)
2957 isci_task_request_complete(ihost, ireq, sci_req->sci_status); 2956 isci_task_request_complete(ihost, ireq, sci_req->sci_status);
2958} 2957}
2959 2958
2960static void scic_sds_request_aborting_state_enter(void *object) 2959static void scic_sds_request_aborting_state_enter(struct sci_base_state_machine *sm)
2961{ 2960{
2962 struct scic_sds_request *sci_req = object; 2961 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine);
2963 2962
2964 /* Setting the abort bit in the Task Context is required by the silicon. */ 2963 /* Setting the abort bit in the Task Context is required by the silicon. */
2965 sci_req->task_context_buffer->abort = 1; 2964 sci_req->task_context_buffer->abort = 1;
2966} 2965}
2967 2966
2968static void scic_sds_stp_request_started_non_data_await_h2d_completion_enter( 2967static void scic_sds_stp_request_started_non_data_await_h2d_completion_enter(struct sci_base_state_machine *sm)
2969 void *object)
2970{ 2968{
2971 struct scic_sds_request *sci_req = object; 2969 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine);
2972 2970
2973 scic_sds_remote_device_set_working_request(sci_req->target_device, 2971 scic_sds_remote_device_set_working_request(sci_req->target_device,
2974 sci_req); 2972 sci_req);
2975} 2973}
2976 2974
2977static void scic_sds_stp_request_started_pio_await_h2d_completion_enter(void *object) 2975static void scic_sds_stp_request_started_pio_await_h2d_completion_enter(struct sci_base_state_machine *sm)
2978{ 2976{
2979 struct scic_sds_request *sci_req = object; 2977 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine);
2980 2978
2981 scic_sds_remote_device_set_working_request(sci_req->target_device, 2979 scic_sds_remote_device_set_working_request(sci_req->target_device,
2982 sci_req); 2980 sci_req);
2983} 2981}
2984 2982
2985static void scic_sds_stp_request_started_soft_reset_await_h2d_asserted_completion_enter(void *object) 2983static void scic_sds_stp_request_started_soft_reset_await_h2d_asserted_completion_enter(struct sci_base_state_machine *sm)
2986{ 2984{
2987 struct scic_sds_request *sci_req = object; 2985 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine);
2988 2986
2989 scic_sds_remote_device_set_working_request(sci_req->target_device, 2987 scic_sds_remote_device_set_working_request(sci_req->target_device,
2990 sci_req); 2988 sci_req);
2991} 2989}
2992 2990
2993static void scic_sds_stp_request_started_soft_reset_await_h2d_diagnostic_completion_enter(void *object) 2991static void scic_sds_stp_request_started_soft_reset_await_h2d_diagnostic_completion_enter(struct sci_base_state_machine *sm)
2994{ 2992{
2995 struct scic_sds_request *sci_req = object; 2993 struct scic_sds_request *sci_req = container_of(sm, typeof(*sci_req), state_machine);
2996 struct scu_task_context *task_context; 2994 struct scu_task_context *task_context;
2997 struct host_to_dev_fis *h2d_fis; 2995 struct host_to_dev_fis *h2d_fis;
2998 enum sci_status status; 2996 enum sci_status status;
@@ -3052,8 +3050,9 @@ static void scic_sds_general_request_construct(struct scic_sds_controller *scic,
3052 struct scic_sds_remote_device *sci_dev, 3050 struct scic_sds_remote_device *sci_dev,
3053 u16 io_tag, struct scic_sds_request *sci_req) 3051 u16 io_tag, struct scic_sds_request *sci_req)
3054{ 3052{
3055 sci_base_state_machine_construct(&sci_req->state_machine, sci_req, 3053 sci_base_state_machine_construct(&sci_req->state_machine,
3056 scic_sds_request_state_table, SCI_BASE_REQUEST_STATE_INITIAL); 3054 scic_sds_request_state_table,
3055 SCI_BASE_REQUEST_STATE_INITIAL);
3057 sci_base_state_machine_start(&sci_req->state_machine); 3056 sci_base_state_machine_start(&sci_req->state_machine);
3058 3057
3059 sci_req->io_tag = io_tag; 3058 sci_req->io_tag = io_tag;
diff --git a/drivers/scsi/isci/state_machine.c b/drivers/scsi/isci/state_machine.c
index 6057782af8c2..1bcd925e502f 100644
--- a/drivers/scsi/isci/state_machine.c
+++ b/drivers/scsi/isci/state_machine.c
@@ -68,7 +68,7 @@ static void sci_state_machine_exit_state(struct sci_base_state_machine *sm)
68 sci_state_transition_t exit = sm->state_table[state].exit_state; 68 sci_state_transition_t exit = sm->state_table[state].exit_state;
69 69
70 if (exit) 70 if (exit)
71 exit(sm->state_machine_owner); 71 exit(sm);
72} 72}
73 73
74static void sci_state_machine_enter_state(struct sci_base_state_machine *sm) 74static void sci_state_machine_enter_state(struct sci_base_state_machine *sm)
@@ -77,22 +77,15 @@ static void sci_state_machine_enter_state(struct sci_base_state_machine *sm)
77 sci_state_transition_t enter = sm->state_table[state].enter_state; 77 sci_state_transition_t enter = sm->state_table[state].enter_state;
78 78
79 if (enter) 79 if (enter)
80 enter(sm->state_machine_owner); 80 enter(sm);
81} 81}
82 82
83/*
84 * ******************************************************************************
85 * * P R O T E C T E D M E T H O D S
86 * ****************************************************************************** */
87
88/** 83/**
89 * This method will set the initial state and state table for the state 84 * This method will set the initial state and state table for the state
90 * machine. The caller should follow this request with the initialize 85 * machine. The caller should follow this request with the initialize
91 * request to cause the state machine to start. 86 * request to cause the state machine to start.
92 * @sm: This parameter provides the state machine object to be 87 * @sm: This parameter provides the state machine object to be
93 * constructed. 88 * constructed.
94 * @state_machine_owner: This parameter indicates the object that is owns the
95 * state machine being constructed.
96 * @state_table: This parameter specifies the table of state objects that is 89 * @state_table: This parameter specifies the table of state objects that is
97 * managed by this state machine. 90 * managed by this state machine.
98 * @initial_state: This parameter specifies the value of the initial state for 91 * @initial_state: This parameter specifies the value of the initial state for
@@ -100,11 +93,9 @@ static void sci_state_machine_enter_state(struct sci_base_state_machine *sm)
100 * 93 *
101 */ 94 */
102void sci_base_state_machine_construct(struct sci_base_state_machine *sm, 95void sci_base_state_machine_construct(struct sci_base_state_machine *sm,
103 void *owner,
104 const struct sci_base_state *state_table, 96 const struct sci_base_state *state_table,
105 u32 initial_state) 97 u32 initial_state)
106{ 98{
107 sm->state_machine_owner = owner;
108 sm->initial_state_id = initial_state; 99 sm->initial_state_id = initial_state;
109 sm->previous_state_id = initial_state; 100 sm->previous_state_id = initial_state;
110 sm->current_state_id = initial_state; 101 sm->current_state_id = initial_state;
diff --git a/drivers/scsi/isci/state_machine.h b/drivers/scsi/isci/state_machine.h
index 60ef1cf5abf4..067ed9126bf2 100644
--- a/drivers/scsi/isci/state_machine.h
+++ b/drivers/scsi/isci/state_machine.h
@@ -58,9 +58,9 @@
58 58
59#include <linux/types.h> 59#include <linux/types.h>
60 60
61struct sci_base_state_machine;
61typedef void (*sci_base_state_handler_t)(void); 62typedef void (*sci_base_state_handler_t)(void);
62 63typedef void (*sci_state_transition_t)(struct sci_base_state_machine *sm);
63typedef void (*sci_state_transition_t)(void *base_object);
64 64
65/** 65/**
66 * struct sci_base_state - The base state object abstracts the fields common to 66 * struct sci_base_state - The base state object abstracts the fields common to
@@ -80,7 +80,6 @@ struct sci_base_state {
80 * invoked when the state is exited. 80 * invoked when the state is exited.
81 */ 81 */
82 sci_state_transition_t exit_state; 82 sci_state_transition_t exit_state;
83
84}; 83};
85 84
86/** 85/**
@@ -96,13 +95,6 @@ struct sci_base_state_machine {
96 const struct sci_base_state *state_table; 95 const struct sci_base_state *state_table;
97 96
98 /** 97 /**
99 * This field points to the object to which this state machine is
100 * associated. It serves as a cookie to be provided to the state
101 * enter/exit methods.
102 */
103 void *state_machine_owner;
104
105 /**
106 * This field simply indicates the state value for the state machine's 98 * This field simply indicates the state value for the state machine's
107 * initial state. 99 * initial state.
108 */ 100 */
@@ -120,28 +112,13 @@ struct sci_base_state_machine {
120 112
121}; 113};
122 114
123/* 115void sci_base_state_machine_construct(struct sci_base_state_machine *sm,
124 * ****************************************************************************** 116 const struct sci_base_state *state_table,
125 * * P R O T E C T E D M E T H O D S 117 u32 initial_state);
126 * ****************************************************************************** */ 118void sci_base_state_machine_start(struct sci_base_state_machine *sm);
127 119void sci_base_state_machine_stop(struct sci_base_state_machine *sm);
128void sci_base_state_machine_construct( 120void sci_base_state_machine_change_state(struct sci_base_state_machine *sm,
129 struct sci_base_state_machine *this_state_machine, 121 u32 next_state);
130 void *state_machine_owner, 122u32 sci_base_state_machine_get_state(struct sci_base_state_machine *sm);
131 const struct sci_base_state *state_table,
132 u32 initial_state);
133
134void sci_base_state_machine_start(
135 struct sci_base_state_machine *this_state_machine);
136
137void sci_base_state_machine_stop(
138 struct sci_base_state_machine *this_state_machine);
139
140void sci_base_state_machine_change_state(
141 struct sci_base_state_machine *this_state_machine,
142 u32 next_state);
143
144u32 sci_base_state_machine_get_state(
145 struct sci_base_state_machine *this_state_machine);
146 123
147#endif /* _SCI_BASE_STATE_MACHINE_H_ */ 124#endif /* _SCI_BASE_STATE_MACHINE_H_ */