Skip to content

Commit

Permalink
media: hi846: fix usage of pm_runtime_get_if_in_use()
Browse files Browse the repository at this point in the history
pm_runtime_get_if_in_use() does not only return nonzero values when
the device is in use, it can return a negative errno too.

And especially during resuming from system suspend, when runtime pm
is not yet up again, -EAGAIN is being returned, so the subsequent
pm_runtime_put() call results in a refcount underflow.

Fix system-resume by handling -EAGAIN of pm_runtime_get_if_in_use().

Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Fixes: e8c0882 ("media: i2c: add driver for the SK Hynix Hi-846 8M pixel camera")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
  • Loading branch information
Martin Kepplinger authored and Hans Verkuil committed May 25, 2023
1 parent e103484 commit 04fc06f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/media/i2c/hi846.c
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,8 @@ static int hi846_set_ctrl(struct v4l2_ctrl *ctrl)
exposure_max);
}

if (!pm_runtime_get_if_in_use(&client->dev))
ret = pm_runtime_get_if_in_use(&client->dev);
if (!ret || ret == -EAGAIN)
return 0;

switch (ctrl->id) {
Expand Down

0 comments on commit 04fc06f

Please sign in to comment.