@@ -12,6 +12,7 @@
#include <linux/idr.h>
#include <linux/bsg.h>
#include <linux/slab.h>
+#include <linux/pm_runtime.h>
#include <scsi/scsi.h>
#include <scsi/scsi_ioctl.h>
@@ -306,12 +307,15 @@ static struct bsg_device *bsg_get_device(struct inode *inode, struct file *file)
static int bsg_open(struct inode *inode, struct file *file)
{
struct bsg_device *bd;
+ struct bsg_class_device *bcd;
bd = bsg_get_device(inode, file);
if (IS_ERR(bd))
return PTR_ERR(bd);
+ bcd = &bd->queue->bsg_dev;
+ pm_runtime_get_sync(bcd->class_dev->parent);
file->private_data = bd;
return 0;
}
@@ -319,8 +323,12 @@ static int bsg_open(struct inode *inode, struct file *file)
static int bsg_release(struct inode *inode, struct file *file)
{
struct bsg_device *bd = file->private_data;
+ struct bsg_class_device *bcd;
file->private_data = NULL;
+
+ bcd = &bd->queue->bsg_dev;
+ pm_runtime_put_sync(bcd->class_dev->parent);
return bsg_put_device(bd);
}