From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-acpi@vger.kernel.org
Cc: linux-media@vger.kernel.org, rafael@kernel.org,
jacopo.mondi@ideasonboard.com, laurent.pinchart@ideasonboard.com
Subject: [PATCH 6/6] media: imx219: Use pm_runtime_get_if_active(), put usage_count correctly
Date: Wed, 15 Nov 2023 20:18:40 +0200 [thread overview]
Message-ID: <20231115181840.1509046-7-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <20231115181840.1509046-1-sakari.ailus@linux.intel.com>
Use pm_runtime_get_if_active() to get the device's runtime PM usage_count
and set controls, then use runtime PM autosuspend once the controls have
been set (instead of likely transitioning to suspended state immediately).
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/imx219.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index 8436880dcf7a..b38ee8b3e073 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -371,7 +371,7 @@ static int imx219_set_ctrl(struct v4l2_ctrl *ctrl)
struct i2c_client *client = v4l2_get_subdevdata(&imx219->sd);
const struct v4l2_mbus_framefmt *format;
struct v4l2_subdev_state *state;
- int ret = 0;
+ int ret = 0, pm_status;
state = v4l2_subdev_get_locked_active_state(&imx219->sd);
format = v4l2_subdev_get_pad_format(&imx219->sd, state, 0);
@@ -393,7 +393,8 @@ static int imx219_set_ctrl(struct v4l2_ctrl *ctrl)
* Applying V4L2 control value only happens
* when power is up for streaming
*/
- if (pm_runtime_get_if_in_use(&client->dev) == 0)
+ pm_status = pm_runtime_get_if_active(&client->dev);
+ if (!pm_status)
return 0;
switch (ctrl->id) {
@@ -446,7 +447,8 @@ static int imx219_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
- pm_runtime_put(&client->dev);
+ if (pm_status > 0)
+ pm_runtime_put(&client->dev);
return ret;
}
--
2.39.2
prev parent reply other threads:[~2023-11-15 18:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-15 18:18 [PATCH 0/6] Small Runtime PM API changes Sakari Ailus
2023-11-15 18:18 ` [PATCH 1/6] pm: runtime: Simplify pm_runtime_get_if_active() usage Sakari Ailus
2023-11-15 21:04 ` kernel test robot
2023-11-15 18:18 ` [PATCH 2/6] pm: runtime: Add pm_runtime_put_mark_busy_autosusp() helper Sakari Ailus
2023-11-15 18:18 ` [PATCH 3/6] media: Documentation: Improve camera sensor runtime PM documentation Sakari Ailus
2023-11-15 18:18 ` [PATCH 4/6] media: ov8858: Use pm_runtime_get_if_active(), put usage_count correctly Sakari Ailus
2023-11-15 22:09 ` kernel test robot
2023-11-15 18:18 ` [PATCH 5/6] media: imx319: " Sakari Ailus
2023-11-15 18:18 ` Sakari Ailus [this message]
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=20231115181840.1509046-7-sakari.ailus@linux.intel.com \
--to=sakari.ailus@linux.intel.com \
--cc=jacopo.mondi@ideasonboard.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=rafael@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