diff options
author | Christoph Hellwig <hch@lst.de> | 2014-10-11 14:06:47 +0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2014-11-12 13:16:10 +0300 |
commit | 176aa9d6ee2db582e7e856dbe1983004a82869b4 (patch) | |
tree | 5c1e97cbdc98dd9162ef6f81af19eca932f8117e /drivers/scsi/scsi_ioctl.c | |
parent | 1ee8e889d946b3b1c2cc8b99e29eac47d1581dfd (diff) | |
download | linux-176aa9d6ee2db582e7e856dbe1983004a82869b4.tar.xz |
scsi: refactor scsi_reset_provider handling
Pull the common code from the two callers into the function,
and rename it to scsi_ioctl_reset.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Diffstat (limited to 'drivers/scsi/scsi_ioctl.c')
-rw-r--r-- | drivers/scsi/scsi_ioctl.c | 33 |
1 files changed, 1 insertions, 32 deletions
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c index 5207274574f5..5ddc08f39987 100644 --- a/drivers/scsi/scsi_ioctl.c +++ b/drivers/scsi/scsi_ioctl.c @@ -292,8 +292,6 @@ EXPORT_SYMBOL(scsi_ioctl); int scsi_nonblockable_ioctl(struct scsi_device *sdev, int cmd, void __user *arg, int ndelay) { - int val, val2, result; - /* The first set of iocts may be executed even if we're doing * error processing, as long as the device was opened * non-blocking */ @@ -305,36 +303,7 @@ int scsi_nonblockable_ioctl(struct scsi_device *sdev, int cmd, switch (cmd) { case SG_SCSI_RESET: - result = get_user(val, (int __user *)arg); - if (result) - return result; - if (val & SG_SCSI_RESET_NO_ESCALATE) { - val &= ~SG_SCSI_RESET_NO_ESCALATE; - val2 = SCSI_TRY_RESET_NO_ESCALATE; - } else - val2 = 0; - if (val == SG_SCSI_RESET_NOTHING) - return 0; - switch (val) { - case SG_SCSI_RESET_DEVICE: - val2 |= SCSI_TRY_RESET_DEVICE; - break; - case SG_SCSI_RESET_TARGET: - val2 |= SCSI_TRY_RESET_TARGET; - break; - case SG_SCSI_RESET_BUS: - val2 |= SCSI_TRY_RESET_BUS; - break; - case SG_SCSI_RESET_HOST: - val2 |= SCSI_TRY_RESET_HOST; - break; - default: - return -EINVAL; - } - if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) - return -EACCES; - return (scsi_reset_provider(sdev, val2) == - SUCCESS) ? 0 : -EIO; + return scsi_ioctl_reset(sdev, arg); } return -ENODEV; } |