aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-floppy.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-floppy.c')
-rw-r--r--drivers/ide/ide-floppy.c32
1 files changed, 7 insertions, 25 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index ca12a230d9a6..f39cf404b030 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -325,15 +325,6 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
325 IDEFLOPPY_WAIT_CMD, NULL); 325 IDEFLOPPY_WAIT_CMD, NULL);
326} 326}
327 327
328static void idefloppy_create_prevent_cmd(struct ide_atapi_pc *pc, int prevent)
329{
330 debug_log("creating prevent removal command, prevent = %d\n", prevent);
331
332 ide_init_pc(pc);
333 pc->c[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL;
334 pc->c[4] = prevent;
335}
336
337void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *pc) 328void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *pc)
338{ 329{
339 ide_init_pc(pc); 330 ide_init_pc(pc);
@@ -712,6 +703,8 @@ static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy)
712 if (strncmp((char *)&id[ATA_ID_PROD], "IOMEGA Clik!", 11) == 0) { 703 if (strncmp((char *)&id[ATA_ID_PROD], "IOMEGA Clik!", 11) == 0) {
713 blk_queue_max_sectors(drive->queue, 64); 704 blk_queue_max_sectors(drive->queue, 64);
714 drive->atapi_flags |= IDE_AFLAG_CLIK_DRIVE; 705 drive->atapi_flags |= IDE_AFLAG_CLIK_DRIVE;
706 /* IOMEGA Clik! drives do not support lock/unlock commands */
707 drive->atapi_flags |= IDE_AFLAG_NO_DOORLOCK;
715 } 708 }
716 709
717 (void) ide_floppy_get_capacity(drive); 710 (void) ide_floppy_get_capacity(drive);
@@ -782,18 +775,6 @@ static ide_driver_t idefloppy_driver = {
782#endif 775#endif
783}; 776};
784 777
785static void ide_floppy_set_media_lock(ide_drive_t *drive, int on)
786{
787 struct ide_floppy_obj *floppy = drive->driver_data;
788 struct ide_atapi_pc pc;
789
790 /* IOMEGA Clik! drives do not support lock/unlock commands */
791 if ((drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE) == 0) {
792 idefloppy_create_prevent_cmd(&pc, on);
793 (void)ide_queue_pc_tail(drive, floppy->disk, &pc);
794 }
795}
796
797static int idefloppy_open(struct inode *inode, struct file *filp) 778static int idefloppy_open(struct inode *inode, struct file *filp)
798{ 779{
799 struct gendisk *disk = inode->i_bdev->bd_disk; 780 struct gendisk *disk = inode->i_bdev->bd_disk;
@@ -842,7 +823,7 @@ static int idefloppy_open(struct inode *inode, struct file *filp)
842 } 823 }
843 824
844 drive->atapi_flags |= IDE_AFLAG_MEDIA_CHANGED; 825 drive->atapi_flags |= IDE_AFLAG_MEDIA_CHANGED;
845 ide_floppy_set_media_lock(drive, 1); 826 ide_set_media_lock(drive, disk, 1);
846 check_disk_change(inode->i_bdev); 827 check_disk_change(inode->i_bdev);
847 } else if (drive->atapi_flags & IDE_AFLAG_FORMAT_IN_PROGRESS) { 828 } else if (drive->atapi_flags & IDE_AFLAG_FORMAT_IN_PROGRESS) {
848 ret = -EBUSY; 829 ret = -EBUSY;
@@ -865,7 +846,7 @@ static int idefloppy_release(struct inode *inode, struct file *filp)
865 debug_log("Reached %s\n", __func__); 846 debug_log("Reached %s\n", __func__);
866 847
867 if (floppy->openers == 1) { 848 if (floppy->openers == 1) {
868 ide_floppy_set_media_lock(drive, 0); 849 ide_set_media_lock(drive, disk, 0);
869 drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; 850 drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS;
870 } 851 }
871 852
@@ -891,16 +872,17 @@ static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc,
891 unsigned long arg, unsigned int cmd) 872 unsigned long arg, unsigned int cmd)
892{ 873{
893 idefloppy_floppy_t *floppy = drive->driver_data; 874 idefloppy_floppy_t *floppy = drive->driver_data;
875 struct gendisk *disk = floppy->disk;
894 int prevent = (arg && cmd != CDROMEJECT) ? 1 : 0; 876 int prevent = (arg && cmd != CDROMEJECT) ? 1 : 0;
895 877
896 if (floppy->openers > 1) 878 if (floppy->openers > 1)
897 return -EBUSY; 879 return -EBUSY;
898 880
899 ide_floppy_set_media_lock(drive, prevent); 881 ide_set_media_lock(drive, disk, prevent);
900 882
901 if (cmd == CDROMEJECT) { 883 if (cmd == CDROMEJECT) {
902 idefloppy_create_start_stop_cmd(pc, 2); 884 idefloppy_create_start_stop_cmd(pc, 2);
903 (void)ide_queue_pc_tail(drive, floppy->disk, pc); 885 (void)ide_queue_pc_tail(drive, disk, pc);
904 } 886 }
905 887
906 return 0; 888 return 0;