From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-media@vger.kernel.org
Cc: sre@kernel.org
Subject: [PATCH v1.2 5/5] smiapp: Implement support for autosuspend
Date: Mon, 3 Oct 2016 11:57:02 +0300 [thread overview]
Message-ID: <1475485022-20484-1-git-send-email-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <1474374598-32451-1-git-send-email-sakari.ailus@linux.intel.com>
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>
---
since v1.1:
- More or less just rebased. The previous patch changed quite a bit so
this one did as well.
drivers/media/i2c/smiapp/smiapp-core.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 68adc1b..44e32cf 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(&client->dev);
+ pm_runtime_put_autosuspend(&client->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;
--
2.1.4
next prev parent reply other threads:[~2016-10-03 8:57 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-15 11:29 [PATCH 0/5] smiapp: Runtime PM support Sakari Ailus
2016-09-15 11:29 ` [PATCH 1/5] smiapp: Drop BUG_ON() in suspend path Sakari Ailus
2016-09-15 11:29 ` [PATCH 2/5] smiapp: Set device for pixel array and binner Sakari Ailus
2016-09-19 22:55 ` Sebastian Reichel
2016-09-15 11:29 ` [PATCH 3/5] smiapp: Set use suspend and resume ops for other functions Sakari Ailus
2016-09-19 22:54 ` Sebastian Reichel
2016-09-15 11:29 ` [PATCH 4/5] smiapp: Use runtime PM Sakari Ailus
2016-09-15 22:53 ` [PATCH v1.1 " Sakari Ailus
2016-09-19 22:51 ` Sebastian Reichel
2016-09-20 7:50 ` Sakari Ailus
2016-09-27 13:11 ` Sebastian Reichel
2016-10-03 8:55 ` [PATCH v1.2 " Sakari Ailus
2016-09-15 11:29 ` [PATCH 5/5] smiapp: Implement support for autosuspend Sakari Ailus
2016-09-19 22:53 ` Sebastian Reichel
2016-09-20 12:29 ` [PATCH v1.1 " Sakari Ailus
2016-09-23 0:14 ` Sebastian Reichel
2016-09-23 11:13 ` Sakari Ailus
2016-10-03 8:57 ` Sakari Ailus [this message]
2016-10-03 9:27 ` [PATCH v1.3 " Sakari Ailus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1475485022-20484-1-git-send-email-sakari.ailus@linux.intel.com \
--to=sakari.ailus@linux.intel.com \
--cc=linux-media@vger.kernel.org \
--cc=sre@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).