diff options
-rw-r--r-- | drivers/ide/ide-floppy.c | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 38dca45ffd11..4bab0932c94a 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -1038,6 +1038,17 @@ static ide_driver_t idefloppy_driver = { | |||
1038 | #endif | 1038 | #endif |
1039 | }; | 1039 | }; |
1040 | 1040 | ||
1041 | static void ide_floppy_set_media_lock(ide_drive_t *drive, int on) | ||
1042 | { | ||
1043 | struct ide_atapi_pc pc; | ||
1044 | |||
1045 | /* IOMEGA Clik! drives do not support lock/unlock commands */ | ||
1046 | if ((drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE) == 0) { | ||
1047 | idefloppy_create_prevent_cmd(&pc, on); | ||
1048 | (void)idefloppy_queue_pc_tail(drive, &pc); | ||
1049 | } | ||
1050 | } | ||
1051 | |||
1041 | static int idefloppy_open(struct inode *inode, struct file *filp) | 1052 | static int idefloppy_open(struct inode *inode, struct file *filp) |
1042 | { | 1053 | { |
1043 | struct gendisk *disk = inode->i_bdev->bd_disk; | 1054 | struct gendisk *disk = inode->i_bdev->bd_disk; |
@@ -1084,12 +1095,9 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
1084 | ret = -EROFS; | 1095 | ret = -EROFS; |
1085 | goto out_put_floppy; | 1096 | goto out_put_floppy; |
1086 | } | 1097 | } |
1098 | |||
1087 | drive->atapi_flags |= IDE_AFLAG_MEDIA_CHANGED; | 1099 | drive->atapi_flags |= IDE_AFLAG_MEDIA_CHANGED; |
1088 | /* IOMEGA Clik! drives do not support lock/unlock commands */ | 1100 | ide_floppy_set_media_lock(drive, 1); |
1089 | if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) { | ||
1090 | idefloppy_create_prevent_cmd(&pc, 1); | ||
1091 | (void) idefloppy_queue_pc_tail(drive, &pc); | ||
1092 | } | ||
1093 | check_disk_change(inode->i_bdev); | 1101 | check_disk_change(inode->i_bdev); |
1094 | } else if (drive->atapi_flags & IDE_AFLAG_FORMAT_IN_PROGRESS) { | 1102 | } else if (drive->atapi_flags & IDE_AFLAG_FORMAT_IN_PROGRESS) { |
1095 | ret = -EBUSY; | 1103 | ret = -EBUSY; |
@@ -1108,17 +1116,11 @@ static int idefloppy_release(struct inode *inode, struct file *filp) | |||
1108 | struct gendisk *disk = inode->i_bdev->bd_disk; | 1116 | struct gendisk *disk = inode->i_bdev->bd_disk; |
1109 | struct ide_floppy_obj *floppy = ide_floppy_g(disk); | 1117 | struct ide_floppy_obj *floppy = ide_floppy_g(disk); |
1110 | ide_drive_t *drive = floppy->drive; | 1118 | ide_drive_t *drive = floppy->drive; |
1111 | struct ide_atapi_pc pc; | ||
1112 | 1119 | ||
1113 | debug_log("Reached %s\n", __func__); | 1120 | debug_log("Reached %s\n", __func__); |
1114 | 1121 | ||
1115 | if (floppy->openers == 1) { | 1122 | if (floppy->openers == 1) { |
1116 | /* IOMEGA Clik! drives do not support lock/unlock commands */ | 1123 | ide_floppy_set_media_lock(drive, 0); |
1117 | if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) { | ||
1118 | idefloppy_create_prevent_cmd(&pc, 0); | ||
1119 | (void) idefloppy_queue_pc_tail(drive, &pc); | ||
1120 | } | ||
1121 | |||
1122 | drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; | 1124 | drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; |
1123 | } | 1125 | } |
1124 | 1126 | ||
@@ -1144,21 +1146,12 @@ static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
1144 | unsigned long arg, unsigned int cmd) | 1146 | unsigned long arg, unsigned int cmd) |
1145 | { | 1147 | { |
1146 | idefloppy_floppy_t *floppy = drive->driver_data; | 1148 | idefloppy_floppy_t *floppy = drive->driver_data; |
1149 | int prevent = (arg && cmd != CDROMEJECT) ? 1 : 0; | ||
1147 | 1150 | ||
1148 | if (floppy->openers > 1) | 1151 | if (floppy->openers > 1) |
1149 | return -EBUSY; | 1152 | return -EBUSY; |
1150 | 1153 | ||
1151 | /* The IOMEGA Clik! Drive doesn't support this command - | 1154 | ide_floppy_set_media_lock(drive, prevent); |
1152 | * no room for an eject mechanism */ | ||
1153 | if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) { | ||
1154 | int prevent = arg ? 1 : 0; | ||
1155 | |||
1156 | if (cmd == CDROMEJECT) | ||
1157 | prevent = 0; | ||
1158 | |||
1159 | idefloppy_create_prevent_cmd(pc, prevent); | ||
1160 | (void) idefloppy_queue_pc_tail(floppy->drive, pc); | ||
1161 | } | ||
1162 | 1155 | ||
1163 | if (cmd == CDROMEJECT) { | 1156 | if (cmd == CDROMEJECT) { |
1164 | idefloppy_create_start_stop_cmd(pc, 2); | 1157 | idefloppy_create_start_stop_cmd(pc, 2); |