aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-floppy_ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-floppy_ioctl.c')
-rw-r--r--drivers/ide/ide-floppy_ioctl.c56
1 files changed, 53 insertions, 3 deletions
diff --git a/drivers/ide/ide-floppy_ioctl.c b/drivers/ide/ide-floppy_ioctl.c
index 5ffc4512d14b..a3a7a0809e2b 100644
--- a/drivers/ide/ide-floppy_ioctl.c
+++ b/drivers/ide/ide-floppy_ioctl.c
@@ -195,7 +195,7 @@ static int ide_floppy_get_format_progress(ide_drive_t *drive, int __user *arg)
195 int progress_indication = 0x10000; 195 int progress_indication = 0x10000;
196 196
197 if (drive->atapi_flags & IDE_AFLAG_SRFP) { 197 if (drive->atapi_flags & IDE_AFLAG_SRFP) {
198 ide_floppy_create_request_sense_cmd(&pc); 198 ide_create_request_sense_cmd(drive, &pc);
199 if (ide_queue_pc_tail(drive, floppy->disk, &pc)) 199 if (ide_queue_pc_tail(drive, floppy->disk, &pc))
200 return -EIO; 200 return -EIO;
201 201
@@ -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
226int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file, 226static 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
244static 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
263int 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}