aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-13 15:39:44 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-13 15:39:44 -0400
commit5bb1536a07cca0b66f2bb41dfdf84140939b8f1f (patch)
treeaebf71b8c9c782cfbb0044baea7d39b6090239d6
parent14d83b12c931b03dbe6b3dc79122db02521c890b (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>
-rw-r--r--drivers/ide/ide-floppy.c52
-rw-r--r--drivers/ide/ide-floppy.h3
-rw-r--r--drivers/ide/ide-floppy_ioctl.c54
3 files changed, 54 insertions, 55 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 9f2c6b2af98f..169d4d93a6a9 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -765,56 +765,6 @@ static int idefloppy_getgeo(struct block_device *bdev, struct hd_geometry *geo)
765 return 0; 765 return 0;
766} 766}
767 767
768static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc,
769 unsigned long arg, unsigned int cmd)
770{
771 idefloppy_floppy_t *floppy = drive->driver_data;
772 struct gendisk *disk = floppy->disk;
773 int prevent = (arg && cmd != CDROMEJECT) ? 1 : 0;
774
775 if (floppy->openers > 1)
776 return -EBUSY;
777
778 ide_set_media_lock(drive, disk, prevent);
779
780 if (cmd == CDROMEJECT)
781 ide_do_start_stop(drive, disk, 2);
782
783 return 0;
784}
785
786static int idefloppy_ioctl(struct inode *inode, struct file *file,
787 unsigned int cmd, unsigned long arg)
788{
789 struct block_device *bdev = inode->i_bdev;
790 struct ide_floppy_obj *floppy = ide_drv_g(bdev->bd_disk,
791 ide_floppy_obj);
792 ide_drive_t *drive = floppy->drive;
793 struct ide_atapi_pc pc;
794 void __user *argp = (void __user *)arg;
795 int err;
796
797 if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR)
798 return ide_floppy_lockdoor(drive, &pc, arg, cmd);
799
800 err = ide_floppy_format_ioctl(drive, file, cmd, argp);
801 if (err != -ENOTTY)
802 return err;
803
804 /*
805 * skip SCSI_IOCTL_SEND_COMMAND (deprecated)
806 * and CDROM_SEND_PACKET (legacy) ioctls
807 */
808 if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND)
809 err = scsi_cmd_ioctl(file, bdev->bd_disk->queue,
810 bdev->bd_disk, cmd, argp);
811
812 if (err == -ENOTTY)
813 err = generic_ide_ioctl(drive, file, bdev, cmd, arg);
814
815 return err;
816}
817
818static int idefloppy_media_changed(struct gendisk *disk) 768static int idefloppy_media_changed(struct gendisk *disk)
819{ 769{
820 struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj); 770 struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj);
@@ -842,7 +792,7 @@ static struct block_device_operations idefloppy_ops = {
842 .owner = THIS_MODULE, 792 .owner = THIS_MODULE,
843 .open = idefloppy_open, 793 .open = idefloppy_open,
844 .release = idefloppy_release, 794 .release = idefloppy_release,
845 .ioctl = idefloppy_ioctl, 795 .ioctl = ide_floppy_ioctl,
846 .getgeo = idefloppy_getgeo, 796 .getgeo = idefloppy_getgeo,
847 .media_changed = idefloppy_media_changed, 797 .media_changed = idefloppy_media_changed,
848 .revalidate_disk = idefloppy_revalidate_disk 798 .revalidate_disk = idefloppy_revalidate_disk
diff --git a/drivers/ide/ide-floppy.h b/drivers/ide/ide-floppy.h
index 00ad5f992dc0..914e4b2f855d 100644
--- a/drivers/ide/ide-floppy.h
+++ b/drivers/ide/ide-floppy.h
@@ -50,7 +50,6 @@ void ide_floppy_create_mode_sense_cmd(struct ide_atapi_pc *, u8);
50void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *); 50void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *);
51 51
52/* ide-floppy_ioctl.c */ 52/* ide-floppy_ioctl.c */
53int ide_floppy_format_ioctl(ide_drive_t *, struct file *, unsigned int, 53int ide_floppy_ioctl(struct inode *, struct file *, unsigned, unsigned long);
54 void __user *);
55 54
56#endif /*__IDE_FLOPPY_H */ 55#endif /*__IDE_FLOPPY_H */
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
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}