[SCSI] implement runtime Power Management
[deliverable/linux.git] / drivers / scsi / sg.c
index d4549092400ce3328d29df047238b0a057f182d2..2968c6b83ddba4cf34a5a2019b025f521c5683d7 100644 (file)
@@ -245,6 +245,10 @@ sg_open(struct inode *inode, struct file *filp)
        if (retval)
                goto sg_put;
 
+       retval = scsi_autopm_get_device(sdp->device);
+       if (retval)
+               goto sdp_put;
+
        if (!((flags & O_NONBLOCK) ||
              scsi_block_when_processing_errors(sdp->device))) {
                retval = -ENXIO;
@@ -302,8 +306,11 @@ sg_open(struct inode *inode, struct file *filp)
        }
        retval = 0;
 error_out:
-       if (retval)
+       if (retval) {
+               scsi_autopm_put_device(sdp->device);
+sdp_put:
                scsi_device_put(sdp->device);
+       }
 sg_put:
        if (sdp)
                sg_put_dev(sdp);
@@ -327,6 +334,7 @@ sg_release(struct inode *inode, struct file *filp)
        sdp->exclude = 0;
        wake_up_interruptible(&sdp->o_excl_wait);
 
+       scsi_autopm_put_device(sdp->device);
        kref_put(&sfp->f_ref, sg_remove_sfp);
        return 0;
 }
This page took 0.030093 seconds and 5 git commands to generate.