diff options
author | Dan Williams <dan.j.williams@intel.com> | 2011-05-01 17:38:26 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 07:04:45 -0400 |
commit | b8d82f6cdd0f04ddfa877d8d886e56ebd8526d25 (patch) | |
tree | de786be6793e2f1a315492bca296b654f90bed21 | |
parent | 1a6de2562b38e1e0e74c468554111ac54c062928 (diff) |
isci: unify remote_device destruct_handlers
Implement all states in scic_remote_device_destruct() and delete the state
handler.
Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r-- | drivers/scsi/isci/remote_device.c | 66 | ||||
-rw-r--r-- | drivers/scsi/isci/remote_device.h | 6 |
2 files changed, 17 insertions, 55 deletions
diff --git a/drivers/scsi/isci/remote_device.c b/drivers/scsi/isci/remote_device.c index 5141a924149c..dd66c0e8ac27 100644 --- a/drivers/scsi/isci/remote_device.c +++ b/drivers/scsi/isci/remote_device.c | |||
@@ -434,12 +434,6 @@ default_device_handler(struct scic_sds_remote_device *sci_dev, | |||
434 | return SCI_FAILURE_INVALID_STATE; | 434 | return SCI_FAILURE_INVALID_STATE; |
435 | } | 435 | } |
436 | 436 | ||
437 | static enum sci_status scic_sds_remote_device_default_destruct_handler( | ||
438 | struct scic_sds_remote_device *sci_dev) | ||
439 | { | ||
440 | return default_device_handler(sci_dev, __func__); | ||
441 | } | ||
442 | |||
443 | static enum sci_status scic_sds_remote_device_default_reset_handler( | 437 | static enum sci_status scic_sds_remote_device_default_reset_handler( |
444 | struct scic_sds_remote_device *sci_dev) | 438 | struct scic_sds_remote_device *sci_dev) |
445 | { | 439 | { |
@@ -661,33 +655,6 @@ static enum sci_status scic_sds_remote_device_general_event_handler( | |||
661 | 655 | ||
662 | /** | 656 | /** |
663 | * | 657 | * |
664 | * @sci_dev: The struct scic_sds_remote_device which is cast into a | ||
665 | * struct scic_sds_remote_device. | ||
666 | * | ||
667 | * This method will destruct a struct scic_sds_remote_device that is in a stopped | ||
668 | * state. This is the only state from which a destruct request will succeed. | ||
669 | * The RNi for this struct scic_sds_remote_device is returned to the free pool and the | ||
670 | * device object transitions to the SCI_BASE_REMOTE_DEVICE_STATE_FINAL. | ||
671 | * enum sci_status SCI_SUCCESS | ||
672 | */ | ||
673 | static enum sci_status scic_sds_remote_device_stopped_state_destruct_handler( | ||
674 | struct scic_sds_remote_device *sci_dev) | ||
675 | { | ||
676 | struct scic_sds_controller *scic; | ||
677 | |||
678 | scic = scic_sds_remote_device_get_controller(sci_dev); | ||
679 | scic_sds_controller_free_remote_node_context(scic, sci_dev, | ||
680 | sci_dev->rnc.remote_node_index); | ||
681 | sci_dev->rnc.remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX; | ||
682 | |||
683 | sci_base_state_machine_change_state(&sci_dev->state_machine, | ||
684 | SCI_BASE_REMOTE_DEVICE_STATE_FINAL); | ||
685 | |||
686 | return SCI_SUCCESS; | ||
687 | } | ||
688 | |||
689 | /** | ||
690 | * | ||
691 | * @device: The struct scic_sds_remote_device object which is cast to a | 658 | * @device: The struct scic_sds_remote_device object which is cast to a |
692 | * struct scic_sds_remote_device object. | 659 | * struct scic_sds_remote_device object. |
693 | * | 660 | * |
@@ -1256,7 +1223,6 @@ static enum sci_status scic_sds_smp_remote_device_ready_cmd_substate_frame_handl | |||
1256 | 1223 | ||
1257 | static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_state_handler_table[] = { | 1224 | static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_state_handler_table[] = { |
1258 | [SCI_BASE_REMOTE_DEVICE_STATE_INITIAL] = { | 1225 | [SCI_BASE_REMOTE_DEVICE_STATE_INITIAL] = { |
1259 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1260 | .reset_handler = scic_sds_remote_device_default_reset_handler, | 1226 | .reset_handler = scic_sds_remote_device_default_reset_handler, |
1261 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | 1227 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, |
1262 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | 1228 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, |
@@ -1270,7 +1236,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_ | |||
1270 | .frame_handler = scic_sds_remote_device_default_frame_handler | 1236 | .frame_handler = scic_sds_remote_device_default_frame_handler |
1271 | }, | 1237 | }, |
1272 | [SCI_BASE_REMOTE_DEVICE_STATE_STOPPED] = { | 1238 | [SCI_BASE_REMOTE_DEVICE_STATE_STOPPED] = { |
1273 | .destruct_handler = scic_sds_remote_device_stopped_state_destruct_handler, | ||
1274 | .reset_handler = scic_sds_remote_device_default_reset_handler, | 1239 | .reset_handler = scic_sds_remote_device_default_reset_handler, |
1275 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | 1240 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, |
1276 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | 1241 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, |
@@ -1284,7 +1249,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_ | |||
1284 | .frame_handler = scic_sds_remote_device_default_frame_handler | 1249 | .frame_handler = scic_sds_remote_device_default_frame_handler |
1285 | }, | 1250 | }, |
1286 | [SCI_BASE_REMOTE_DEVICE_STATE_STARTING] = { | 1251 | [SCI_BASE_REMOTE_DEVICE_STATE_STARTING] = { |
1287 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1288 | .reset_handler = scic_sds_remote_device_default_reset_handler, | 1252 | .reset_handler = scic_sds_remote_device_default_reset_handler, |
1289 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | 1253 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, |
1290 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | 1254 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, |
@@ -1298,7 +1262,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_ | |||
1298 | .frame_handler = scic_sds_remote_device_default_frame_handler | 1262 | .frame_handler = scic_sds_remote_device_default_frame_handler |
1299 | }, | 1263 | }, |
1300 | [SCI_BASE_REMOTE_DEVICE_STATE_READY] = { | 1264 | [SCI_BASE_REMOTE_DEVICE_STATE_READY] = { |
1301 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1302 | .reset_handler = scic_sds_remote_device_ready_state_reset_handler, | 1265 | .reset_handler = scic_sds_remote_device_ready_state_reset_handler, |
1303 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | 1266 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, |
1304 | .start_io_handler = scic_sds_remote_device_ready_state_start_io_handler, | 1267 | .start_io_handler = scic_sds_remote_device_ready_state_start_io_handler, |
@@ -1312,7 +1275,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_ | |||
1312 | .frame_handler = scic_sds_remote_device_general_frame_handler, | 1275 | .frame_handler = scic_sds_remote_device_general_frame_handler, |
1313 | }, | 1276 | }, |
1314 | [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = { | 1277 | [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = { |
1315 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1316 | .reset_handler = scic_sds_remote_device_ready_state_reset_handler, | 1278 | .reset_handler = scic_sds_remote_device_ready_state_reset_handler, |
1317 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | 1279 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, |
1318 | .start_io_handler = scic_sds_stp_remote_device_ready_idle_substate_start_io_handler, | 1280 | .start_io_handler = scic_sds_stp_remote_device_ready_idle_substate_start_io_handler, |
@@ -1326,7 +1288,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_ | |||
1326 | .frame_handler = scic_sds_remote_device_default_frame_handler | 1288 | .frame_handler = scic_sds_remote_device_default_frame_handler |
1327 | }, | 1289 | }, |
1328 | [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD] = { | 1290 | [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD] = { |
1329 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1330 | .reset_handler = scic_sds_remote_device_ready_state_reset_handler, | 1291 | .reset_handler = scic_sds_remote_device_ready_state_reset_handler, |
1331 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | 1292 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, |
1332 | .start_io_handler = scic_sds_stp_remote_device_ready_cmd_substate_start_io_handler, | 1293 | .start_io_handler = scic_sds_stp_remote_device_ready_cmd_substate_start_io_handler, |
@@ -1340,7 +1301,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_ | |||
1340 | .frame_handler = scic_sds_stp_remote_device_ready_cmd_substate_frame_handler | 1301 | .frame_handler = scic_sds_stp_remote_device_ready_cmd_substate_frame_handler |
1341 | }, | 1302 | }, |
1342 | [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ] = { | 1303 | [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ] = { |
1343 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1344 | .reset_handler = scic_sds_remote_device_ready_state_reset_handler, | 1304 | .reset_handler = scic_sds_remote_device_ready_state_reset_handler, |
1345 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | 1305 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, |
1346 | .start_io_handler = scic_sds_stp_remote_device_ready_ncq_substate_start_io_handler, | 1306 | .start_io_handler = scic_sds_stp_remote_device_ready_ncq_substate_start_io_handler, |
@@ -1354,7 +1314,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_ | |||
1354 | .frame_handler = scic_sds_stp_remote_device_ready_ncq_substate_frame_handler | 1314 | .frame_handler = scic_sds_stp_remote_device_ready_ncq_substate_frame_handler |
1355 | }, | 1315 | }, |
1356 | [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR] = { | 1316 | [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR] = { |
1357 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1358 | .reset_handler = scic_sds_remote_device_ready_state_reset_handler, | 1317 | .reset_handler = scic_sds_remote_device_ready_state_reset_handler, |
1359 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | 1318 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, |
1360 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | 1319 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, |
@@ -1368,7 +1327,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_ | |||
1368 | .frame_handler = scic_sds_remote_device_general_frame_handler | 1327 | .frame_handler = scic_sds_remote_device_general_frame_handler |
1369 | }, | 1328 | }, |
1370 | [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET] = { | 1329 | [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET] = { |
1371 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1372 | .reset_handler = scic_sds_remote_device_ready_state_reset_handler, | 1330 | .reset_handler = scic_sds_remote_device_ready_state_reset_handler, |
1373 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | 1331 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, |
1374 | .start_io_handler = scic_sds_stp_remote_device_ready_await_reset_substate_start_io_handler, | 1332 | .start_io_handler = scic_sds_stp_remote_device_ready_await_reset_substate_start_io_handler, |
@@ -1382,7 +1340,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_ | |||
1382 | .frame_handler = scic_sds_remote_device_general_frame_handler | 1340 | .frame_handler = scic_sds_remote_device_general_frame_handler |
1383 | }, | 1341 | }, |
1384 | [SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = { | 1342 | [SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = { |
1385 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1386 | .reset_handler = scic_sds_remote_device_default_reset_handler, | 1343 | .reset_handler = scic_sds_remote_device_default_reset_handler, |
1387 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | 1344 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, |
1388 | .start_io_handler = scic_sds_smp_remote_device_ready_idle_substate_start_io_handler, | 1345 | .start_io_handler = scic_sds_smp_remote_device_ready_idle_substate_start_io_handler, |
@@ -1396,7 +1353,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_ | |||
1396 | .frame_handler = scic_sds_remote_device_default_frame_handler | 1353 | .frame_handler = scic_sds_remote_device_default_frame_handler |
1397 | }, | 1354 | }, |
1398 | [SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD] = { | 1355 | [SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD] = { |
1399 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1400 | .reset_handler = scic_sds_remote_device_default_reset_handler, | 1356 | .reset_handler = scic_sds_remote_device_default_reset_handler, |
1401 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | 1357 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, |
1402 | .start_io_handler = scic_sds_smp_remote_device_ready_cmd_substate_start_io_handler, | 1358 | .start_io_handler = scic_sds_smp_remote_device_ready_cmd_substate_start_io_handler, |
@@ -1410,7 +1366,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_ | |||
1410 | .frame_handler = scic_sds_smp_remote_device_ready_cmd_substate_frame_handler | 1366 | .frame_handler = scic_sds_smp_remote_device_ready_cmd_substate_frame_handler |
1411 | }, | 1367 | }, |
1412 | [SCI_BASE_REMOTE_DEVICE_STATE_STOPPING] = { | 1368 | [SCI_BASE_REMOTE_DEVICE_STATE_STOPPING] = { |
1413 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1414 | .reset_handler = scic_sds_remote_device_default_reset_handler, | 1369 | .reset_handler = scic_sds_remote_device_default_reset_handler, |
1415 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | 1370 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, |
1416 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | 1371 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, |
@@ -1424,7 +1379,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_ | |||
1424 | .frame_handler = scic_sds_remote_device_general_frame_handler | 1379 | .frame_handler = scic_sds_remote_device_general_frame_handler |
1425 | }, | 1380 | }, |
1426 | [SCI_BASE_REMOTE_DEVICE_STATE_FAILED] = { | 1381 | [SCI_BASE_REMOTE_DEVICE_STATE_FAILED] = { |
1427 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1428 | .reset_handler = scic_sds_remote_device_default_reset_handler, | 1382 | .reset_handler = scic_sds_remote_device_default_reset_handler, |
1429 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | 1383 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, |
1430 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | 1384 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, |
@@ -1438,7 +1392,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_ | |||
1438 | .frame_handler = scic_sds_remote_device_general_frame_handler | 1392 | .frame_handler = scic_sds_remote_device_general_frame_handler |
1439 | }, | 1393 | }, |
1440 | [SCI_BASE_REMOTE_DEVICE_STATE_RESETTING] = { | 1394 | [SCI_BASE_REMOTE_DEVICE_STATE_RESETTING] = { |
1441 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1442 | .reset_handler = scic_sds_remote_device_default_reset_handler, | 1395 | .reset_handler = scic_sds_remote_device_default_reset_handler, |
1443 | .reset_complete_handler = scic_sds_remote_device_resetting_state_reset_complete_handler, | 1396 | .reset_complete_handler = scic_sds_remote_device_resetting_state_reset_complete_handler, |
1444 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | 1397 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, |
@@ -1452,7 +1405,6 @@ static const struct scic_sds_remote_device_state_handler scic_sds_remote_device_ | |||
1452 | .frame_handler = scic_sds_remote_device_general_frame_handler | 1405 | .frame_handler = scic_sds_remote_device_general_frame_handler |
1453 | }, | 1406 | }, |
1454 | [SCI_BASE_REMOTE_DEVICE_STATE_FINAL] = { | 1407 | [SCI_BASE_REMOTE_DEVICE_STATE_FINAL] = { |
1455 | .destruct_handler = scic_sds_remote_device_default_destruct_handler, | ||
1456 | .reset_handler = scic_sds_remote_device_default_reset_handler, | 1408 | .reset_handler = scic_sds_remote_device_default_reset_handler, |
1457 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, | 1409 | .reset_complete_handler = scic_sds_remote_device_default_reset_complete_handler, |
1458 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, | 1410 | .start_io_handler = scic_sds_remote_device_default_start_request_handler, |
@@ -1494,7 +1446,23 @@ static void scic_sds_remote_device_initial_state_enter(void *object) | |||
1494 | */ | 1446 | */ |
1495 | static enum sci_status scic_remote_device_destruct(struct scic_sds_remote_device *sci_dev) | 1447 | static enum sci_status scic_remote_device_destruct(struct scic_sds_remote_device *sci_dev) |
1496 | { | 1448 | { |
1497 | return sci_dev->state_handlers->destruct_handler(sci_dev); | 1449 | struct sci_base_state_machine *sm = &sci_dev->state_machine; |
1450 | enum scic_sds_remote_device_states state = sm->current_state_id; | ||
1451 | struct scic_sds_controller *scic; | ||
1452 | |||
1453 | if (state != SCI_BASE_REMOTE_DEVICE_STATE_STOPPED) { | ||
1454 | dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", | ||
1455 | __func__, state); | ||
1456 | return SCI_FAILURE_INVALID_STATE; | ||
1457 | } | ||
1458 | |||
1459 | scic = sci_dev->owning_port->owning_controller; | ||
1460 | scic_sds_controller_free_remote_node_context(scic, sci_dev, | ||
1461 | sci_dev->rnc.remote_node_index); | ||
1462 | sci_dev->rnc.remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX; | ||
1463 | sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_FINAL); | ||
1464 | |||
1465 | return SCI_SUCCESS; | ||
1498 | } | 1466 | } |
1499 | 1467 | ||
1500 | /** | 1468 | /** |
diff --git a/drivers/scsi/isci/remote_device.h b/drivers/scsi/isci/remote_device.h index dd8ac514cfd4..d09e3f273edb 100644 --- a/drivers/scsi/isci/remote_device.h +++ b/drivers/scsi/isci/remote_device.h | |||
@@ -387,12 +387,6 @@ typedef void (*scic_sds_remote_device_ready_not_ready_handler_t)( | |||
387 | */ | 387 | */ |
388 | struct scic_sds_remote_device_state_handler { | 388 | struct scic_sds_remote_device_state_handler { |
389 | /** | 389 | /** |
390 | * The destruct_handler specifies the method invoked when attempting to | ||
391 | * destruct a remote device. | ||
392 | */ | ||
393 | scic_sds_remote_device_handler_t destruct_handler; | ||
394 | |||
395 | /** | ||
396 | * The reset handler specifies the method invloked when requesting to | 390 | * The reset handler specifies the method invloked when requesting to |
397 | * reset a remote device. | 391 | * reset a remote device. |
398 | */ | 392 | */ |