diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-01-26 14:12:59 -0500 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-01-26 14:12:59 -0500 |
commit | 29ec683f019608ca0cb6cf69011426ecb5daa69e (patch) | |
tree | c87135ac016aa0a27c844dfde2c0e0202e4f0669 | |
parent | 7b971df185807ceb358471e16ce8754ccfcc7de9 (diff) |
ide-disk: add idedisk_set_doorlock() helper
There should be no functionality changes caused by this patch.
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r-- | drivers/ide/ide-disk.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index d8fdd865dea9..364dc57a5e1c 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -975,6 +975,17 @@ static ide_driver_t idedisk_driver = { | |||
975 | #endif | 975 | #endif |
976 | }; | 976 | }; |
977 | 977 | ||
978 | static int idedisk_set_doorlock(ide_drive_t *drive, int on) | ||
979 | { | ||
980 | ide_task_t task; | ||
981 | |||
982 | memset(&task, 0, sizeof(task)); | ||
983 | task.tf.command = on ? WIN_DOORLOCK : WIN_DOORUNLOCK; | ||
984 | task.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; | ||
985 | |||
986 | return ide_no_data_taskfile(drive, &task); | ||
987 | } | ||
988 | |||
978 | static int idedisk_open(struct inode *inode, struct file *filp) | 989 | static int idedisk_open(struct inode *inode, struct file *filp) |
979 | { | 990 | { |
980 | struct gendisk *disk = inode->i_bdev->bd_disk; | 991 | struct gendisk *disk = inode->i_bdev->bd_disk; |
@@ -989,17 +1000,13 @@ static int idedisk_open(struct inode *inode, struct file *filp) | |||
989 | idkp->openers++; | 1000 | idkp->openers++; |
990 | 1001 | ||
991 | if (drive->removable && idkp->openers == 1) { | 1002 | if (drive->removable && idkp->openers == 1) { |
992 | ide_task_t args; | ||
993 | memset(&args, 0, sizeof(ide_task_t)); | ||
994 | args.tf.command = WIN_DOORLOCK; | ||
995 | args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; | ||
996 | check_disk_change(inode->i_bdev); | 1003 | check_disk_change(inode->i_bdev); |
997 | /* | 1004 | /* |
998 | * Ignore the return code from door_lock, | 1005 | * Ignore the return code from door_lock, |
999 | * since the open() has already succeeded, | 1006 | * since the open() has already succeeded, |
1000 | * and the door_lock is irrelevant at this point. | 1007 | * and the door_lock is irrelevant at this point. |
1001 | */ | 1008 | */ |
1002 | if (drive->doorlocking && ide_no_data_taskfile(drive, &args)) | 1009 | if (drive->doorlocking && idedisk_set_doorlock(drive, 1)) |
1003 | drive->doorlocking = 0; | 1010 | drive->doorlocking = 0; |
1004 | } | 1011 | } |
1005 | return 0; | 1012 | return 0; |
@@ -1015,11 +1022,7 @@ static int idedisk_release(struct inode *inode, struct file *filp) | |||
1015 | ide_cacheflush_p(drive); | 1022 | ide_cacheflush_p(drive); |
1016 | 1023 | ||
1017 | if (drive->removable && idkp->openers == 1) { | 1024 | if (drive->removable && idkp->openers == 1) { |
1018 | ide_task_t args; | 1025 | if (drive->doorlocking && idedisk_set_doorlock(drive, 0)) |
1019 | memset(&args, 0, sizeof(ide_task_t)); | ||
1020 | args.tf.command = WIN_DOORUNLOCK; | ||
1021 | args.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE; | ||
1022 | if (drive->doorlocking && ide_no_data_taskfile(drive, &args)) | ||
1023 | drive->doorlocking = 0; | 1026 | drive->doorlocking = 0; |
1024 | } | 1027 | } |
1025 | 1028 | ||