aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-disk.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-17 12:09:10 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-17 12:09:10 -0400
commit81ee1bb51fff76aaa738668b92406b5117f125ed (patch)
treea0af9e0a39a017d917300a92fccdd3d22530b629 /drivers/ide/ide-disk.c
parentd7e747596829c1c11833ca0a1f5e64f400d20bf2 (diff)
ide-disk: move IDE_DFLAG_DOORLOCKING flag handling to idedisk_set_doorlock()
There should be no functional changes caused by this patch. Acked-by: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-disk.c')
-rw-r--r--drivers/ide/ide-disk.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 6c9c898aff62..289a533afbd6 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -817,12 +817,21 @@ static ide_driver_t idedisk_driver = {
817static int idedisk_set_doorlock(ide_drive_t *drive, int on) 817static int idedisk_set_doorlock(ide_drive_t *drive, int on)
818{ 818{
819 ide_task_t task; 819 ide_task_t task;
820 int ret;
821
822 if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) == 0)
823 return 0;
820 824
821 memset(&task, 0, sizeof(task)); 825 memset(&task, 0, sizeof(task));
822 task.tf.command = on ? ATA_CMD_MEDIA_LOCK : ATA_CMD_MEDIA_UNLOCK; 826 task.tf.command = on ? ATA_CMD_MEDIA_LOCK : ATA_CMD_MEDIA_UNLOCK;
823 task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; 827 task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
824 828
825 return ide_no_data_taskfile(drive, &task); 829 ret = ide_no_data_taskfile(drive, &task);
830
831 if (ret)
832 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
833
834 return ret;
826} 835}
827 836
828static int idedisk_open(struct inode *inode, struct file *filp) 837static int idedisk_open(struct inode *inode, struct file *filp)
@@ -845,9 +854,7 @@ static int idedisk_open(struct inode *inode, struct file *filp)
845 * since the open() has already succeeded, 854 * since the open() has already succeeded,
846 * and the door_lock is irrelevant at this point. 855 * and the door_lock is irrelevant at this point.
847 */ 856 */
848 if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) && 857 idedisk_set_doorlock(drive, 1);
849 idedisk_set_doorlock(drive, 1))
850 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
851 check_disk_change(inode->i_bdev); 858 check_disk_change(inode->i_bdev);
852 } 859 }
853 return 0; 860 return 0;
@@ -862,11 +869,8 @@ static int idedisk_release(struct inode *inode, struct file *filp)
862 if (idkp->openers == 1) 869 if (idkp->openers == 1)
863 ide_cacheflush_p(drive); 870 ide_cacheflush_p(drive);
864 871
865 if ((drive->dev_flags & IDE_DFLAG_REMOVABLE) && idkp->openers == 1) { 872 if ((drive->dev_flags & IDE_DFLAG_REMOVABLE) && idkp->openers == 1)
866 if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) && 873 idedisk_set_doorlock(drive, 0);
867 idedisk_set_doorlock(drive, 0))
868 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
869 }
870 874
871 idkp->openers--; 875 idkp->openers--;
872 876