scsi: scsi_lib: rework scsi_internal_device_unblock_nowait()
authorHannes Reinecke <hare@suse.de>
Fri, 11 Aug 2017 06:53:46 +0000 (08:53 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 25 Aug 2017 02:28:53 +0000 (22:28 -0400)
Rework scsi_internal_device_unblock_nowait() into using a switch
statement. No functional changes.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_lib.c

index f6097b89d5d381229cc0be0a9753c908de5caa47..4a295a630848f49fcf7377cc101844ac645ba54a 100644 (file)
@@ -3073,19 +3073,24 @@ int scsi_internal_device_unblock_nowait(struct scsi_device *sdev,
         * Try to transition the scsi device to SDEV_RUNNING or one of the
         * offlined states and goose the device queue if successful.
         */
-       if ((sdev->sdev_state == SDEV_BLOCK) ||
-           (sdev->sdev_state == SDEV_TRANSPORT_OFFLINE))
+       switch (sdev->sdev_state) {
+       case SDEV_BLOCK:
+       case SDEV_TRANSPORT_OFFLINE:
                sdev->sdev_state = new_state;
-       else if (sdev->sdev_state == SDEV_CREATED_BLOCK) {
+               break;
+       case SDEV_CREATED_BLOCK:
                if (new_state == SDEV_TRANSPORT_OFFLINE ||
                    new_state == SDEV_OFFLINE)
                        sdev->sdev_state = new_state;
                else
                        sdev->sdev_state = SDEV_CREATED;
-       } else if (sdev->sdev_state != SDEV_CANCEL &&
-                sdev->sdev_state != SDEV_OFFLINE)
+               break;
+       case SDEV_CANCEL:
+       case SDEV_OFFLINE:
+               break;
+       default:
                return -EINVAL;
-
+       }
        scsi_start_queue(sdev);
 
        return 0;