media: hi846: fix usage of pm_runtime_get_if_in_use()
authorMartin Kepplinger <martin.kepplinger@puri.sm>
Tue, 25 Apr 2023 09:47:47 +0000 (11:47 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Jul 2023 14:21:51 +0000 (16:21 +0200)
commit42ec6269f98edd915ee37da3c6456bb6243ea56a
tree7383e8597dc2a9c834915aca893e445bb2efbdcb
parent1ac45cab77d68664001d6ab1932dbcf695b31e0d
media: hi846: fix usage of pm_runtime_get_if_in_use()

[ Upstream commit 04fc06f6dc1592ed5d675311ac50d8fba5db62ab ]

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: e8c0882685f9 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/i2c/hi846.c