aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c/smiapp/smiapp-core.c
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2016-09-14 12:29:23 -0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-10-21 15:42:43 -0200
commit93bef23024983d707248c25a849f5860119cd5e4 (patch)
treea3e6e4610bf83aa8aa11341d1a4099b997a608b9 /drivers/media/i2c/smiapp/smiapp-core.c
parentcbba45d43631d0414266d7e79827da3f491f1b1e (diff)
[media] smiapp: Implement support for autosuspend
Delay suspending the device by 1000 ms by default. This is done on explicit power off through s_power() callback, through releasing the file descriptor, NVM read or when the probe finishes. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/i2c/smiapp/smiapp-core.c')
-rw-r--r--drivers/media/i2c/smiapp/smiapp-core.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 68adc1b28985..59872b31f832 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -1380,17 +1380,22 @@ static int smiapp_power_off(struct device *dev)
static int smiapp_set_power(struct v4l2_subdev *subdev, int on)
{
- int rval = 0;
+ int rval;
- if (on) {
- rval = pm_runtime_get_sync(subdev->dev);
- if (rval >= 0)
- return 0;
+ if (!on) {
+ pm_runtime_mark_last_busy(subdev->dev);
+ pm_runtime_put_autosuspend(subdev->dev);
- if (rval != -EBUSY && rval != -EAGAIN)
- pm_runtime_set_active(subdev->dev);
+ return 0;
}
+ rval = pm_runtime_get_sync(subdev->dev);
+ if (rval >= 0)
+ return 0;
+
+ if (rval != -EBUSY && rval != -EAGAIN)
+ pm_runtime_set_active(subdev->dev);
+
pm_runtime_put(subdev->dev);
return rval;
@@ -2340,7 +2345,8 @@ smiapp_sysfs_nvm_read(struct device *dev, struct device_attribute *attr,
return -ENODEV;
}
- pm_runtime_put(&client->dev);
+ pm_runtime_mark_last_busy(&client->dev);
+ pm_runtime_put_autosuspend(&client->dev);
}
/*
* NVM is still way below a PAGE_SIZE, so we can safely
@@ -2681,7 +2687,8 @@ static int smiapp_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
static int smiapp_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
{
- pm_runtime_put(sd->dev);
+ pm_runtime_mark_last_busy(sd->dev);
+ pm_runtime_put_autosuspend(sd->dev);
return 0;
}
@@ -3093,7 +3100,9 @@ static int smiapp_probe(struct i2c_client *client,
if (rval < 0)
goto out_media_entity_cleanup;
- pm_runtime_put(&client->dev);
+ pm_runtime_set_autosuspend_delay(&client->dev, 1000);
+ pm_runtime_use_autosuspend(&client->dev);
+ pm_runtime_put_autosuspend(&client->dev);
return 0;

Privacy Policy