Skip to content

Commit

Permalink
[media] smiapp: Implement power-on and power-off sequences without ru…
Browse files Browse the repository at this point in the history
…ntime PM

Power on the sensor when the module is loaded and power it off when it is
removed.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
  • Loading branch information
Sakari Ailus authored and Mauro Carvalho Chehab committed Dec 21, 2016
1 parent d183e4e commit 9447082
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions drivers/media/i2c/smiapp/smiapp-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2741,8 +2741,6 @@ static const struct v4l2_subdev_internal_ops smiapp_internal_ops = {
* I2C Driver
*/

#ifdef CONFIG_PM

static int smiapp_suspend(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
Expand Down Expand Up @@ -2783,13 +2781,6 @@ static int smiapp_resume(struct device *dev)
return rval;
}

#else

#define smiapp_suspend NULL
#define smiapp_resume NULL

#endif /* CONFIG_PM */

static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)
{
struct smiapp_hwconfig *hwcfg;
Expand Down Expand Up @@ -2913,13 +2904,9 @@ static int smiapp_probe(struct i2c_client *client,
if (IS_ERR(sensor->xshutdown))
return PTR_ERR(sensor->xshutdown);

pm_runtime_enable(&client->dev);

rval = pm_runtime_get_sync(&client->dev);
if (rval < 0) {
rval = -ENODEV;
goto out_power_off;
}
rval = smiapp_power_on(&client->dev);
if (rval < 0)
return rval;

rval = smiapp_identify_module(sensor);
if (rval) {
Expand Down Expand Up @@ -3100,6 +3087,9 @@ static int smiapp_probe(struct i2c_client *client,
if (rval < 0)
goto out_media_entity_cleanup;

pm_runtime_set_active(&client->dev);
pm_runtime_get_noresume(&client->dev);
pm_runtime_enable(&client->dev);
pm_runtime_set_autosuspend_delay(&client->dev, 1000);
pm_runtime_use_autosuspend(&client->dev);
pm_runtime_put_autosuspend(&client->dev);
Expand All @@ -3113,8 +3103,7 @@ static int smiapp_probe(struct i2c_client *client,
smiapp_cleanup(sensor);

out_power_off:
pm_runtime_put(&client->dev);
pm_runtime_disable(&client->dev);
smiapp_power_off(&client->dev);

return rval;
}
Expand All @@ -3127,8 +3116,10 @@ static int smiapp_remove(struct i2c_client *client)

v4l2_async_unregister_subdev(subdev);

pm_runtime_suspend(&client->dev);
pm_runtime_disable(&client->dev);
if (!pm_runtime_status_suspended(&client->dev))
smiapp_power_off(&client->dev);
pm_runtime_set_suspended(&client->dev);

for (i = 0; i < sensor->ssds_used; i++) {
v4l2_device_unregister_subdev(&sensor->ssds[i].sd);
Expand Down

0 comments on commit 9447082

Please sign in to comment.