OSDN Git Service

media: i2c: ccs-core: fix pm_runtime_get_sync() usage count
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Fri, 23 Apr 2021 15:19:11 +0000 (17:19 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 10 May 2021 09:36:33 +0000 (11:36 +0200)
commitda3a1858c3a37c09446e1470c48352897d59d11b
treed00988558d73aa738cd9a9c8deaf0e2fcb97cf8c
parent6005a8e955e4e451e4bf6000affaab566d4cab5e
media: i2c: ccs-core: fix pm_runtime_get_sync() usage count

The pm_runtime_get_sync() internally increments the
dev->power.usage_count without decrementing it, even on errors.

There is a bug at ccs_pm_get_init(): when this function returns
an error, the stream is not started, and RPM usage_count
should not be incremented. However, if the calls to
v4l2_ctrl_handler_setup() return errors, it will be kept
incremented.

At ccs_suspend() the best is to replace it by the new
pm_runtime_resume_and_get(), introduced by:
commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
in order to properly decrement the usage counter automatically,
in the case of errors.

Fixes: 96e3a6b92f23 ("media: smiapp: Avoid maintaining power state information")
Cc: stable@vger.kernel.org
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/i2c/ccs/ccs-core.c