aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/isci/port.c
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/scsi/isci/port.c
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/scsi/isci/port.c')
-rw-r--r--drivers/scsi/isci/port.c45
1 files changed, 22 insertions, 23 deletions
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