[PATCH 05/18] ide-disk: move IDE_DFLAG_DOORLOCKING flag handling to idedisk_set_doorlock()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Bartlomiej Zolnierkiewicz
Date: Sunday, September 7, 2008 - 3:14 pm

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-disk.c |   22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

Index: b/drivers/ide/ide-disk.c
===================================================================
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -811,12 +811,21 @@ static ide_driver_t idedisk_driver = {
 static int idedisk_set_doorlock(ide_drive_t *drive, int on)
 {
 	ide_task_t task;
+	int ret;
+
+	if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) == 0)
+		return 0;
 
 	memset(&task, 0, sizeof(task));
 	task.tf.command = on ? ATA_CMD_MEDIA_LOCK : ATA_CMD_MEDIA_UNLOCK;
 	task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
 
-	return ide_no_data_taskfile(drive, &task);
+	ret = ide_no_data_taskfile(drive, &task);
+
+	if (ret)
+		drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
+
+	return ret;
 }
 
 static int idedisk_open(struct inode *inode, struct file *filp)
@@ -839,9 +848,7 @@ static int idedisk_open(struct inode *in
 		 * since the open() has already succeeded,
 		 * and the door_lock is irrelevant at this point.
 		 */
-		if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) &&
-		    idedisk_set_doorlock(drive, 1))
-			drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
+		idedisk_set_doorlock(drive, 1);
 		check_disk_change(inode->i_bdev);
 	}
 	return 0;
@@ -856,11 +863,8 @@ static int idedisk_release(struct inode 
 	if (idkp->openers == 1)
 		ide_cacheflush_p(drive);
 
-	if ((drive->dev_flags & IDE_DFLAG_REMOVABLE) && idkp->openers == 1) {
-		if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) &&
-		    idedisk_set_doorlock(drive, 0))
-			drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
-	}
+	if ((drive->dev_flags & IDE_DFLAG_REMOVABLE) && idkp->openers == 1)
+		idedisk_set_doorlock(drive, 0);
 
 	idkp->openers--;
 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/18] ide: add generic ATA/ATAPI disk driver, Bartlomiej Zolnierki ..., (Sun Sep 7, 3:14 pm)
[PATCH 01/18] ide-disk: fix IDE_DFLAG_LBA48 handling on resume, Bartlomiej Zolnierki ..., (Sun Sep 7, 3:14 pm)
[PATCH 02/18] ide-disk: lock media before checking for med ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:14 pm)
[PATCH 03/18] ide-floppy: use alloc_disk_node(), Bartlomiej Zolnierki ..., (Sun Sep 7, 3:14 pm)
[PATCH 04/18] ide-disk: use to_ide_drv() and ide_drv_g(), Bartlomiej Zolnierki ..., (Sun Sep 7, 3:14 pm)
[PATCH 05/18] ide-disk: move IDE_DFLAG_DOORLOCKING flag ha ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:14 pm)
[PATCH 06/18] ide-{disk,floppy}: set IDE_DFLAG_ATTACH in * ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:15 pm)
[PATCH 07/18] ide-floppy: drop 'floppy' argument from idef ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:15 pm)
[PATCH 08/18] ide-floppy: use drive-&gt;capacity64 for cachin ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:15 pm)
[PATCH 09/18] ide: IDE_AFLAG_MEDIA_CHANGED -&gt; IDE_DFLAG_ME ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:15 pm)
[PATCH 10/18] ide: IDE_AFLAG_WP -&gt; IDE_DFLAG_WP, Bartlomiej Zolnierki ..., (Sun Sep 7, 3:15 pm)
[PATCH 11/18] ide: IDE_AFLAG_FORMAT_IN_PROGRESS -&gt; IDE_DFL ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:15 pm)
[PATCH 12/18] ide: remove IDE_AFLAG_NO_DOORLOCKING, Bartlomiej Zolnierki ..., (Sun Sep 7, 3:15 pm)
[PATCH 13/18] ide-disk: factor out generic disk handling c ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:15 pm)
[PATCH 14/18] ide-disk: use IDE_DFLAG_MEDIA_CHANGED, Bartlomiej Zolnierki ..., (Sun Sep 7, 3:16 pm)
[PATCH 15/18] ide-floppy: factor out generic disk handling ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:16 pm)
[PATCH 16/18] ide: prepare for merging ide-gd-floppy.c wit ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:16 pm)
[PATCH 17/18] ide: allow device drivers to specify per-dev ..., Bartlomiej Zolnierki ..., (Sun Sep 7, 3:16 pm)
[PATCH 18/18] ide: add generic ATA/ATAPI disk driver, Bartlomiej Zolnierki ..., (Sun Sep 7, 3:16 pm)
Re: [PATCH 00/18] ide: add generic ATA/ATAPI disk driver, Borislav Petkov, (Wed Sep 10, 4:20 am)
Re: [PATCH 08/18] ide-floppy: use drive-&gt;capacity64 for ca ..., Bartlomiej Zolnierki ..., (Sat Sep 27, 8:34 am)