Skip to contentSkip to conversation

SCSI:implement PM for st

PATCH In review Oliver Neukum 2 participants 2 messages Jan 16, 2012 – Jan 22, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SCSI:implement PM for st

Quoted 1 line

From 595fa6688232fd68f221fc2734545d3e995c465a Mon Sep 17 00:00:00 2001

From: Oliver Neukum <[email protected]>
Date: Sun, 15 Jan 2012 00:16:51 +0100
Subject: [PATCH] SCSI:implement PM for st

This implements basic power management for SCSI tapes.

---
 drivers/scsi/st.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
drivers/scsi/st.c +11 -0
index 9b28f39..9262cdf 100644
@@ -1177,6 +1177,7 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
 static int st_open(struct inode *inode, struct file *filp)
 {
 	int i, retval = (-EIO);
+	int resumed = 0;
 	struct scsi_tape *STp;
 	struct st_partstat *STps;
 	int dev = TAPE_NR(inode);
@@ -1211,6 +1212,11 @@ static int st_open(struct inode *inode, struct file *filp)
 	write_unlock(&st_dev_arr_lock);
 	STp->rew_at_close = STp->autorew_dev = (iminor(inode) & 0x80) == 0;
 
+	if (scsi_autopm_get_device(STp->device) < 0) {
+		retval = -EIO;
+		goto err_out;
+	}
+	resumed = 1;
 	if (!scsi_block_when_processing_errors(STp->device)) {
 		retval = (-ENXIO);
 		goto err_out;
@@ -1258,6 +1264,8 @@ static int st_open(struct inode *inode, struct file *filp)
 	normalize_buffer(STp->buffer);
 	STp->in_use = 0;
 	scsi_tape_put(STp);
+	if (resumed)
+		scsi_autopm_put_device(STp->device);
 	mutex_unlock(&st_mutex);
 	return retval;
 
@@ -1391,6 +1399,7 @@ static int st_release(struct inode *inode, struct file *filp)
 	write_lock(&st_dev_arr_lock);
 	STp->in_use = 0;
 	write_unlock(&st_dev_arr_lock);
+	scsi_autopm_put_device(STp->device);
 	scsi_tape_put(STp);
 
 	return result;
@@ -4154,6 +4163,7 @@ static int st_probe(struct device *dev)
 		if (error)
 			goto out_free_tape;
 	}
+	scsi_autopm_put_device(SDp);
 
 	sdev_printk(KERN_NOTICE, SDp,
 		    "Attached scsi tape %s\n", tape_name(tpnt));
@@ -4201,6 +4211,7 @@ static int st_remove(struct device *dev)
 	struct scsi_tape *tpnt;
 	int i, j, mode;
 
+	scsi_autopm_get_device(SDp);
 	write_lock(&st_dev_arr_lock);
 	for (i = 0; i < st_dev_max; i++) {
 		tpnt = scsi_tapes[i];
Signature · 1 line
1.7.1
Acked-by on v1 1/1
#1 lore raw

drivers/scsi/st.c static int check_tape(struct scsi_tape *STp, struct file *filp)

Quoted 17 lines · Oliver Neukum

From 595fa6688232fd68f221fc2734545d3e995c465a Mon Sep 17 00:00:00 2001
From: Oliver Neukum <[email protected]>
Date: Sun, 15 Jan 2012 00:16:51 +0100
Subject: [PATCH] SCSI:implement PM for st

This implements basic power management for SCSI tapes.

---
 drivers/scsi/st.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
drivers/scsi/st.c +0 -0
index 9b28f39..9262cdf 100644
@@ -1177,6 +1177,7 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)

Thanks,
Kai