|
@@ -1299,6 +1299,16 @@ static int idetape_create_prevent_cmd(ide_drive_t *drive,
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static int ide_tape_set_media_lock(ide_drive_t *drive, int on)
|
|
|
|
+{
|
|
|
|
+ struct ide_atapi_pc pc;
|
|
|
|
+
|
|
|
|
+ if (!idetape_create_prevent_cmd(drive, &pc, on))
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+ return idetape_queue_pc_tail(drive, &pc);
|
|
|
|
+}
|
|
|
|
+
|
|
static void __ide_tape_discard_merge_buffer(ide_drive_t *drive)
|
|
static void __ide_tape_discard_merge_buffer(ide_drive_t *drive)
|
|
{
|
|
{
|
|
idetape_tape_t *tape = drive->driver_data;
|
|
idetape_tape_t *tape = drive->driver_data;
|
|
@@ -1927,9 +1937,8 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count)
|
|
* attempting to eject.
|
|
* attempting to eject.
|
|
*/
|
|
*/
|
|
if (tape->door_locked) {
|
|
if (tape->door_locked) {
|
|
- if (idetape_create_prevent_cmd(drive, &pc, 0))
|
|
|
|
- if (!idetape_queue_pc_tail(drive, &pc))
|
|
|
|
- tape->door_locked = DOOR_UNLOCKED;
|
|
|
|
|
|
+ if (!ide_tape_set_media_lock(drive, 0))
|
|
|
|
+ tape->door_locked = DOOR_UNLOCKED;
|
|
}
|
|
}
|
|
ide_tape_discard_merge_buffer(drive, 0);
|
|
ide_tape_discard_merge_buffer(drive, 0);
|
|
idetape_create_load_unload_cmd(drive, &pc,
|
|
idetape_create_load_unload_cmd(drive, &pc,
|
|
@@ -1973,17 +1982,13 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count)
|
|
case MTFSR:
|
|
case MTFSR:
|
|
case MTBSR:
|
|
case MTBSR:
|
|
case MTLOCK:
|
|
case MTLOCK:
|
|
- if (!idetape_create_prevent_cmd(drive, &pc, 1))
|
|
|
|
- return 0;
|
|
|
|
- retval = idetape_queue_pc_tail(drive, &pc);
|
|
|
|
|
|
+ retval = ide_tape_set_media_lock(drive, 1);
|
|
if (retval)
|
|
if (retval)
|
|
return retval;
|
|
return retval;
|
|
tape->door_locked = DOOR_EXPLICITLY_LOCKED;
|
|
tape->door_locked = DOOR_EXPLICITLY_LOCKED;
|
|
return 0;
|
|
return 0;
|
|
case MTUNLOCK:
|
|
case MTUNLOCK:
|
|
- if (!idetape_create_prevent_cmd(drive, &pc, 0))
|
|
|
|
- return 0;
|
|
|
|
- retval = idetape_queue_pc_tail(drive, &pc);
|
|
|
|
|
|
+ retval = ide_tape_set_media_lock(drive, 0);
|
|
if (retval)
|
|
if (retval)
|
|
return retval;
|
|
return retval;
|
|
tape->door_locked = DOOR_UNLOCKED;
|
|
tape->door_locked = DOOR_UNLOCKED;
|
|
@@ -2085,7 +2090,6 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp)
|
|
unsigned int minor = iminor(inode), i = minor & ~0xc0;
|
|
unsigned int minor = iminor(inode), i = minor & ~0xc0;
|
|
ide_drive_t *drive;
|
|
ide_drive_t *drive;
|
|
idetape_tape_t *tape;
|
|
idetape_tape_t *tape;
|
|
- struct ide_atapi_pc pc;
|
|
|
|
int retval;
|
|
int retval;
|
|
|
|
|
|
if (i >= MAX_HWIFS * MAX_DRIVES)
|
|
if (i >= MAX_HWIFS * MAX_DRIVES)
|
|
@@ -2148,11 +2152,9 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp)
|
|
|
|
|
|
/* Lock the tape drive door so user can't eject. */
|
|
/* Lock the tape drive door so user can't eject. */
|
|
if (tape->chrdev_dir == IDETAPE_DIR_NONE) {
|
|
if (tape->chrdev_dir == IDETAPE_DIR_NONE) {
|
|
- if (idetape_create_prevent_cmd(drive, &pc, 1)) {
|
|
|
|
- if (!idetape_queue_pc_tail(drive, &pc)) {
|
|
|
|
- if (tape->door_locked != DOOR_EXPLICITLY_LOCKED)
|
|
|
|
- tape->door_locked = DOOR_LOCKED;
|
|
|
|
- }
|
|
|
|
|
|
+ if (!ide_tape_set_media_lock(drive, 1)) {
|
|
|
|
+ if (tape->door_locked != DOOR_EXPLICITLY_LOCKED)
|
|
|
|
+ tape->door_locked = DOOR_LOCKED;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
unlock_kernel();
|
|
unlock_kernel();
|
|
@@ -2185,7 +2187,6 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp)
|
|
{
|
|
{
|
|
struct ide_tape_obj *tape = ide_tape_f(filp);
|
|
struct ide_tape_obj *tape = ide_tape_f(filp);
|
|
ide_drive_t *drive = tape->drive;
|
|
ide_drive_t *drive = tape->drive;
|
|
- struct ide_atapi_pc pc;
|
|
|
|
unsigned int minor = iminor(inode);
|
|
unsigned int minor = iminor(inode);
|
|
|
|
|
|
lock_kernel();
|
|
lock_kernel();
|
|
@@ -2204,10 +2205,8 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp)
|
|
(void) idetape_rewind_tape(drive);
|
|
(void) idetape_rewind_tape(drive);
|
|
if (tape->chrdev_dir == IDETAPE_DIR_NONE) {
|
|
if (tape->chrdev_dir == IDETAPE_DIR_NONE) {
|
|
if (tape->door_locked == DOOR_LOCKED) {
|
|
if (tape->door_locked == DOOR_LOCKED) {
|
|
- if (idetape_create_prevent_cmd(drive, &pc, 0)) {
|
|
|
|
- if (!idetape_queue_pc_tail(drive, &pc))
|
|
|
|
- tape->door_locked = DOOR_UNLOCKED;
|
|
|
|
- }
|
|
|
|
|
|
+ if (!ide_tape_set_media_lock(drive, 0))
|
|
|
|
+ tape->door_locked = DOOR_UNLOCKED;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
clear_bit(IDE_AFLAG_BUSY, &drive->atapi_flags);
|
|
clear_bit(IDE_AFLAG_BUSY, &drive->atapi_flags);
|