Commit 6fade450 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Martin K. Petersen

scsi: core: Remove scsi_compat_ioctl()

Just handle the compat case in scsi_ioctl() using in_compat_syscall().

Link: https://lore.kernel.org/r/20210724072033.1284840-7-hch@lst.deSigned-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 2c2db2c6
...@@ -877,8 +877,6 @@ static long ch_ioctl(struct file *file, ...@@ -877,8 +877,6 @@ static long ch_ioctl(struct file *file,
} }
default: default:
if (in_compat_syscall())
return scsi_compat_ioctl(ch->device, cmd, argp);
return scsi_ioctl(ch->device, cmd, argp); return scsi_ioctl(ch->device, cmd, argp);
} }
......
...@@ -189,8 +189,17 @@ static int scsi_ioctl_get_pci(struct scsi_device *sdev, void __user *arg) ...@@ -189,8 +189,17 @@ static int scsi_ioctl_get_pci(struct scsi_device *sdev, void __user *arg)
? -EFAULT: 0; ? -EFAULT: 0;
} }
/**
static int scsi_ioctl_common(struct scsi_device *sdev, int cmd, void __user *arg) * scsi_ioctl - Dispatch ioctl to scsi device
* @sdev: scsi device receiving ioctl
* @cmd: which ioctl is it
* @arg: data associated with ioctl
*
* Description: The scsi_ioctl() function differs from most ioctls in that it
* does not take a major/minor number as the dev field. Rather, it takes
* a pointer to a &struct scsi_device.
*/
int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
{ {
char scsi_cmd[MAX_COMMAND_SIZE]; char scsi_cmd[MAX_COMMAND_SIZE];
struct scsi_sense_hdr sense_hdr; struct scsi_sense_hdr sense_hdr;
...@@ -258,48 +267,19 @@ static int scsi_ioctl_common(struct scsi_device *sdev, int cmd, void __user *arg ...@@ -258,48 +267,19 @@ static int scsi_ioctl_common(struct scsi_device *sdev, int cmd, void __user *arg
case SG_SCSI_RESET: case SG_SCSI_RESET:
return scsi_ioctl_reset(sdev, arg); return scsi_ioctl_reset(sdev, arg);
} }
return -ENOIOCTLCMD;
}
/**
* scsi_ioctl - Dispatch ioctl to scsi device
* @sdev: scsi device receiving ioctl
* @cmd: which ioctl is it
* @arg: data associated with ioctl
*
* Description: The scsi_ioctl() function differs from most ioctls in that it
* does not take a major/minor number as the dev field. Rather, it takes
* a pointer to a &struct scsi_device.
*/
int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
{
int ret = scsi_ioctl_common(sdev, cmd, arg);
if (ret != -ENOIOCTLCMD)
return ret;
if (sdev->host->hostt->ioctl)
return sdev->host->hostt->ioctl(sdev, cmd, arg);
return -EINVAL;
}
EXPORT_SYMBOL(scsi_ioctl);
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
int scsi_compat_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) if (in_compat_syscall()) {
{ if (!sdev->host->hostt->compat_ioctl)
int ret = scsi_ioctl_common(sdev, cmd, arg); return -EINVAL;
if (ret != -ENOIOCTLCMD)
return ret;
if (sdev->host->hostt->compat_ioctl)
return sdev->host->hostt->compat_ioctl(sdev, cmd, arg); return sdev->host->hostt->compat_ioctl(sdev, cmd, arg);
}
return ret;
}
EXPORT_SYMBOL(scsi_compat_ioctl);
#endif #endif
if (!sdev->host->hostt->ioctl)
return -EINVAL;
return sdev->host->hostt->ioctl(sdev, cmd, arg);
}
EXPORT_SYMBOL(scsi_ioctl);
/* /*
* We can process a reset even when a device isn't fully operable. * We can process a reset even when a device isn't fully operable.
......
...@@ -1588,8 +1588,6 @@ static int sd_ioctl(struct block_device *bdev, fmode_t mode, ...@@ -1588,8 +1588,6 @@ static int sd_ioctl(struct block_device *bdev, fmode_t mode,
return error; return error;
} }
if (in_compat_syscall())
return scsi_compat_ioctl(sdp, cmd, p);
return scsi_ioctl(sdp, cmd, p); return scsi_ioctl(sdp, cmd, p);
} }
......
...@@ -1165,9 +1165,6 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) ...@@ -1165,9 +1165,6 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
ret = sg_ioctl_common(filp, sdp, sfp, cmd_in, p); ret = sg_ioctl_common(filp, sdp, sfp, cmd_in, p);
if (ret != -ENOIOCTLCMD) if (ret != -ENOIOCTLCMD)
return ret; return ret;
if (in_compat_syscall())
return scsi_compat_ioctl(sdp->device, cmd_in, p);
return scsi_ioctl(sdp->device, cmd_in, p); return scsi_ioctl(sdp->device, cmd_in, p);
} }
......
...@@ -584,9 +584,6 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, ...@@ -584,9 +584,6 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
goto put; goto put;
} }
if (in_compat_syscall())
ret = scsi_compat_ioctl(sdev, cmd, argp);
else
ret = scsi_ioctl(sdev, cmd, argp); ret = scsi_ioctl(sdev, cmd, argp);
put: put:
......
...@@ -3886,7 +3886,7 @@ static long st_compat_ioctl(struct file *file, unsigned int cmd_in, unsigned lon ...@@ -3886,7 +3886,7 @@ static long st_compat_ioctl(struct file *file, unsigned int cmd_in, unsigned lon
if (ret != -ENOTTY) if (ret != -ENOTTY)
return ret; return ret;
return scsi_compat_ioctl(STp->device, cmd_in, p); return scsi_ioctl(STp->device, cmd_in, p);
} }
#endif #endif
......
...@@ -44,7 +44,6 @@ typedef struct scsi_fctargaddress { ...@@ -44,7 +44,6 @@ typedef struct scsi_fctargaddress {
int scsi_ioctl_block_when_processing_errors(struct scsi_device *sdev, int scsi_ioctl_block_when_processing_errors(struct scsi_device *sdev,
int cmd, bool ndelay); int cmd, bool ndelay);
extern int scsi_ioctl(struct scsi_device *, int, void __user *); extern int scsi_ioctl(struct scsi_device *, int, void __user *);
extern int scsi_compat_ioctl(struct scsi_device *sdev, int cmd, void __user *arg);
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* _SCSI_IOCTL_H */ #endif /* _SCSI_IOCTL_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment