ide-floppy: add ide_floppy_format_ioctl() helper
* Factor out IDEFLOPPY_IOCTL_FORMAT_* ioctls handling from idefloppy_ioctl() to ide_floppy_format_ioctl(). While at it: * Pass 'drive' instead of 'floppy' to ide_floppy_format_unit(). * idefloppy_get_format_progress() -> ide_floppy_get_format_progress() There should be no functional changes caused by this patch. Cc: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
This commit is contained in:
parent
e3faa2481e
commit
d56c99e26b
1 changed files with 25 additions and 21 deletions
|
@ -926,7 +926,7 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg)
|
||||||
* the dsc bit, and return either 0 or 65536.
|
* the dsc bit, and return either 0 or 65536.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg)
|
static int ide_floppy_get_format_progress(ide_drive_t *drive, int __user *arg)
|
||||||
{
|
{
|
||||||
idefloppy_floppy_t *floppy = drive->driver_data;
|
idefloppy_floppy_t *floppy = drive->driver_data;
|
||||||
struct ide_atapi_pc pc;
|
struct ide_atapi_pc pc;
|
||||||
|
@ -1232,11 +1232,10 @@ static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ide_floppy_format_unit(idefloppy_floppy_t *floppy,
|
static int ide_floppy_format_unit(ide_drive_t *drive, int __user *arg)
|
||||||
int __user *arg)
|
|
||||||
{
|
{
|
||||||
|
idefloppy_floppy_t *floppy = drive->driver_data;
|
||||||
struct ide_atapi_pc pc;
|
struct ide_atapi_pc pc;
|
||||||
ide_drive_t *drive = floppy->drive;
|
|
||||||
int blocks, length, flags, err = 0;
|
int blocks, length, flags, err = 0;
|
||||||
|
|
||||||
if (floppy->openers > 1) {
|
if (floppy->openers > 1) {
|
||||||
|
@ -1281,6 +1280,24 @@ out:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file,
|
||||||
|
unsigned int cmd, void __user *argp)
|
||||||
|
{
|
||||||
|
switch (cmd) {
|
||||||
|
case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED:
|
||||||
|
return 0;
|
||||||
|
case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY:
|
||||||
|
return ide_floppy_get_format_capacities(drive, argp);
|
||||||
|
case IDEFLOPPY_IOCTL_FORMAT_START:
|
||||||
|
if (!(file->f_mode & 2))
|
||||||
|
return -EPERM;
|
||||||
|
return ide_floppy_format_unit(drive, (int __user *)argp);
|
||||||
|
case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS:
|
||||||
|
return ide_floppy_get_format_progress(drive, argp);
|
||||||
|
default:
|
||||||
|
return -ENOTTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int idefloppy_ioctl(struct inode *inode, struct file *file,
|
static int idefloppy_ioctl(struct inode *inode, struct file *file,
|
||||||
unsigned int cmd, unsigned long arg)
|
unsigned int cmd, unsigned long arg)
|
||||||
|
@ -1292,23 +1309,12 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file,
|
||||||
void __user *argp = (void __user *)arg;
|
void __user *argp = (void __user *)arg;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
switch (cmd) {
|
if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR)
|
||||||
case CDROMEJECT:
|
|
||||||
/* fall through */
|
|
||||||
case CDROM_LOCKDOOR:
|
|
||||||
return ide_floppy_lockdoor(drive, &pc, arg, cmd);
|
return ide_floppy_lockdoor(drive, &pc, arg, cmd);
|
||||||
case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED:
|
|
||||||
return 0;
|
|
||||||
case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY:
|
|
||||||
return ide_floppy_get_format_capacities(drive, argp);
|
|
||||||
case IDEFLOPPY_IOCTL_FORMAT_START:
|
|
||||||
if (!(file->f_mode & 2))
|
|
||||||
return -EPERM;
|
|
||||||
|
|
||||||
return ide_floppy_format_unit(floppy, (int __user *)arg);
|
err = ide_floppy_format_ioctl(drive, file, cmd, argp);
|
||||||
case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS:
|
if (err != -ENOTTY)
|
||||||
return idefloppy_get_format_progress(drive, argp);
|
return err;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* skip SCSI_IOCTL_SEND_COMMAND (deprecated)
|
* skip SCSI_IOCTL_SEND_COMMAND (deprecated)
|
||||||
|
@ -1317,8 +1323,6 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file,
|
||||||
if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND)
|
if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND)
|
||||||
err = scsi_cmd_ioctl(file, bdev->bd_disk->queue,
|
err = scsi_cmd_ioctl(file, bdev->bd_disk->queue,
|
||||||
bdev->bd_disk, cmd, argp);
|
bdev->bd_disk, cmd, argp);
|
||||||
else
|
|
||||||
err = -ENOTTY;
|
|
||||||
|
|
||||||
if (err == -ENOTTY)
|
if (err == -ENOTTY)
|
||||||
err = generic_ide_ioctl(drive, file, bdev, cmd, arg);
|
err = generic_ide_ioctl(drive, file, bdev, cmd, arg);
|
||||||
|
|
Loading…
Add table
Reference in a new issue