[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1340000766-129148-13-git-send-email-ming.m.lin@intel.com>
Date: Mon, 18 Jun 2012 14:26:06 +0800
From: Lin Ming <ming.m.lin@...el.com>
To: Jeff Garzik <jgarzik@...ox.com>, Aaron Lu <aaron.lu@....com>,
Holger Macht <holger@...ac.de>,
Matthew Garrett <mjg@...hat.com>,
Alan Cox <alan@...rguk.ukuu.org.uk>,
David Woodhouse <David.Woodhouse@...el.com>
Cc: linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org,
linux-scsi@...r.kernel.org, linux-ide@...r.kernel.org,
linux-acpi@...r.kernel.org
Subject: [PATCH v5 12/12] [SCSI] sr: make sure ODD is in resumed state in block ioctl
From: Aaron Lu <aaron.lu@....com>
When application tries to access the ODD's block device by ioctl,
make sure ODD is in an active state.
Signed-off-by: Aaron Lu <aaron.lu@....com>
Signed-off-by: Lin Ming <ming.m.lin@...el.com>
---
drivers/scsi/sr.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 72488c2..3da0879 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -654,6 +654,13 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
void __user *argp = (void __user *)arg;
int ret;
+ /* Make sure the ODD is not suspended */
+ ret = pm_runtime_get_sync(&sdev->sdev_gendev);
+ if (ret < 0) {
+ pm_runtime_put_noidle(&sdev->sdev_gendev);
+ return -EACCES;
+ }
+
mutex_lock(&sr_mutex);
/*
@@ -685,6 +692,8 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
out:
mutex_unlock(&sr_mutex);
+ pm_runtime_mark_last_busy(&cd->device->sdev_gendev);
+ pm_runtime_put_autosuspend(&cd->device->sdev_gendev);
return ret;
}
--
1.7.10
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists