diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:34 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:34 -0400 |
commit | d56c99e26b0ff45009bdf85556abee60591507cb (patch) | |
tree | 388d78d7ef10b517a137a06c2e00848b52ad176b /drivers/ide/ide-floppy.c | |
parent | e3faa2481e832568d13dfa3a52d17525b322cb8f (diff) |
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>
Diffstat (limited to 'drivers/ide/ide-floppy.c')
-rw-r--r-- | drivers/ide/ide-floppy.c | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 6a944cb7054f..84c333e44349 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -926,7 +926,7 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) | |||
926 | * the dsc bit, and return either 0 or 65536. | 926 | * the dsc bit, and return either 0 or 65536. |
927 | */ | 927 | */ |
928 | 928 | ||
929 | static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) | 929 | static int ide_floppy_get_format_progress(ide_drive_t *drive, int __user *arg) |
930 | { | 930 | { |
931 | idefloppy_floppy_t *floppy = drive->driver_data; | 931 | idefloppy_floppy_t *floppy = drive->driver_data; |
932 | struct ide_atapi_pc pc; | 932 | struct ide_atapi_pc pc; |
@@ -1232,11 +1232,10 @@ static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
1232 | return 0; | 1232 | return 0; |
1233 | } | 1233 | } |
1234 | 1234 | ||
1235 | static int ide_floppy_format_unit(idefloppy_floppy_t *floppy, | 1235 | static int ide_floppy_format_unit(ide_drive_t *drive, int __user *arg) |
1236 | int __user *arg) | ||
1237 | { | 1236 | { |
1237 | idefloppy_floppy_t *floppy = drive->driver_data; | ||
1238 | struct ide_atapi_pc pc; | 1238 | struct ide_atapi_pc pc; |
1239 | ide_drive_t *drive = floppy->drive; | ||
1240 | int blocks, length, flags, err = 0; | 1239 | int blocks, length, flags, err = 0; |
1241 | 1240 | ||
1242 | if (floppy->openers > 1) { | 1241 | if (floppy->openers > 1) { |
@@ -1281,6 +1280,24 @@ out: | |||
1281 | return err; | 1280 | return err; |
1282 | } | 1281 | } |
1283 | 1282 | ||
1283 | static int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file, | ||
1284 | unsigned int cmd, void __user *argp) | ||
1285 | { | ||
1286 | switch (cmd) { | ||
1287 | case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED: | ||
1288 | return 0; | ||
1289 | case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY: | ||
1290 | return ide_floppy_get_format_capacities(drive, argp); | ||
1291 | case IDEFLOPPY_IOCTL_FORMAT_START: | ||
1292 | if (!(file->f_mode & 2)) | ||
1293 | return -EPERM; | ||
1294 | return ide_floppy_format_unit(drive, (int __user *)argp); | ||
1295 | case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS: | ||
1296 | return ide_floppy_get_format_progress(drive, argp); | ||
1297 | default: | ||
1298 | return -ENOTTY; | ||
1299 | } | ||
1300 | } | ||
1284 | 1301 | ||
1285 | static int idefloppy_ioctl(struct inode *inode, struct file *file, | 1302 | static int idefloppy_ioctl(struct inode *inode, struct file *file, |
1286 | unsigned int cmd, unsigned long arg) | 1303 | unsigned int cmd, unsigned long arg) |
@@ -1292,23 +1309,12 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file, | |||
1292 | void __user *argp = (void __user *)arg; | 1309 | void __user *argp = (void __user *)arg; |
1293 | int err; | 1310 | int err; |
1294 | 1311 | ||
1295 | switch (cmd) { | 1312 | if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR) |
1296 | case CDROMEJECT: | ||
1297 | /* fall through */ | ||
1298 | case CDROM_LOCKDOOR: | ||
1299 | return ide_floppy_lockdoor(drive, &pc, arg, cmd); | 1313 | return ide_floppy_lockdoor(drive, &pc, arg, cmd); |
1300 | case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED: | ||
1301 | return 0; | ||
1302 | case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY: | ||
1303 | return ide_floppy_get_format_capacities(drive, argp); | ||
1304 | case IDEFLOPPY_IOCTL_FORMAT_START: | ||
1305 | if (!(file->f_mode & 2)) | ||
1306 | return -EPERM; | ||
1307 | 1314 | ||
1308 | return ide_floppy_format_unit(floppy, (int __user *)arg); | 1315 | err = ide_floppy_format_ioctl(drive, file, cmd, argp); |
1309 | case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS: | 1316 | if (err != -ENOTTY) |
1310 | return idefloppy_get_format_progress(drive, argp); | 1317 | return err; |
1311 | } | ||
1312 | 1318 | ||
1313 | /* | 1319 | /* |
1314 | * skip SCSI_IOCTL_SEND_COMMAND (deprecated) | 1320 | * skip SCSI_IOCTL_SEND_COMMAND (deprecated) |
@@ -1317,8 +1323,6 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file, | |||
1317 | if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND) | 1323 | if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND) |
1318 | err = scsi_cmd_ioctl(file, bdev->bd_disk->queue, | 1324 | err = scsi_cmd_ioctl(file, bdev->bd_disk->queue, |
1319 | bdev->bd_disk, cmd, argp); | 1325 | bdev->bd_disk, cmd, argp); |
1320 | else | ||
1321 | err = -ENOTTY; | ||
1322 | 1326 | ||
1323 | if (err == -ENOTTY) | 1327 | if (err == -ENOTTY) |
1324 | err = generic_ide_ioctl(drive, file, bdev, cmd, arg); | 1328 | err = generic_ide_ioctl(drive, file, bdev, cmd, arg); |