diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-13 15:39:44 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-13 15:39:44 -0400 |
commit | 5bb1536a07cca0b66f2bb41dfdf84140939b8f1f (patch) | |
tree | aebf71b8c9c782cfbb0044baea7d39b6090239d6 /drivers/ide/ide-floppy_ioctl.c | |
parent | 14d83b12c931b03dbe6b3dc79122db02521c890b (diff) |
ide-floppy: move all ioctl handling to ide-floppy_ioctl.c (take 2)
While at it:
- idefloppy_ioctl() -> ide_floppy_ioctl()
v2:
Fix for idefloppy_ioctl name change from Stephen Rothwell.
Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-floppy_ioctl.c')
-rw-r--r-- | drivers/ide/ide-floppy_ioctl.c | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/drivers/ide/ide-floppy_ioctl.c b/drivers/ide/ide-floppy_ioctl.c index 9723ed9c61b4..a3a7a0809e2b 100644 --- a/drivers/ide/ide-floppy_ioctl.c +++ b/drivers/ide/ide-floppy_ioctl.c | |||
@@ -223,8 +223,26 @@ static int ide_floppy_get_format_progress(ide_drive_t *drive, int __user *arg) | |||
223 | return 0; | 223 | return 0; |
224 | } | 224 | } |
225 | 225 | ||
226 | int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file, | 226 | static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc, |
227 | unsigned int cmd, void __user *argp) | 227 | unsigned long arg, unsigned int cmd) |
228 | { | ||
229 | idefloppy_floppy_t *floppy = drive->driver_data; | ||
230 | struct gendisk *disk = floppy->disk; | ||
231 | int prevent = (arg && cmd != CDROMEJECT) ? 1 : 0; | ||
232 | |||
233 | if (floppy->openers > 1) | ||
234 | return -EBUSY; | ||
235 | |||
236 | ide_set_media_lock(drive, disk, prevent); | ||
237 | |||
238 | if (cmd == CDROMEJECT) | ||
239 | ide_do_start_stop(drive, disk, 2); | ||
240 | |||
241 | return 0; | ||
242 | } | ||
243 | |||
244 | static int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file, | ||
245 | unsigned int cmd, void __user *argp) | ||
228 | { | 246 | { |
229 | switch (cmd) { | 247 | switch (cmd) { |
230 | case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED: | 248 | case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED: |
@@ -241,3 +259,35 @@ int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file, | |||
241 | return -ENOTTY; | 259 | return -ENOTTY; |
242 | } | 260 | } |
243 | } | 261 | } |
262 | |||
263 | int ide_floppy_ioctl(struct inode *inode, struct file *file, | ||
264 | unsigned int cmd, unsigned long arg) | ||
265 | { | ||
266 | struct block_device *bdev = inode->i_bdev; | ||
267 | struct ide_floppy_obj *floppy = ide_drv_g(bdev->bd_disk, | ||
268 | ide_floppy_obj); | ||
269 | ide_drive_t *drive = floppy->drive; | ||
270 | struct ide_atapi_pc pc; | ||
271 | void __user *argp = (void __user *)arg; | ||
272 | int err; | ||
273 | |||
274 | if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR) | ||
275 | return ide_floppy_lockdoor(drive, &pc, arg, cmd); | ||
276 | |||
277 | err = ide_floppy_format_ioctl(drive, file, cmd, argp); | ||
278 | if (err != -ENOTTY) | ||
279 | return err; | ||
280 | |||
281 | /* | ||
282 | * skip SCSI_IOCTL_SEND_COMMAND (deprecated) | ||
283 | * and CDROM_SEND_PACKET (legacy) ioctls | ||
284 | */ | ||
285 | if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND) | ||
286 | err = scsi_cmd_ioctl(file, bdev->bd_disk->queue, | ||
287 | bdev->bd_disk, cmd, argp); | ||
288 | |||
289 | if (err == -ENOTTY) | ||
290 | err = generic_ide_ioctl(drive, file, bdev, cmd, arg); | ||
291 | |||
292 | return err; | ||
293 | } | ||