mbox series

[v5,00/30] media: i2c: use pm_runtime_resume_and_get() were possible

Message ID cover.1620314098.git.mchehab+huawei@kernel.org (mailing list archive)
Headers show
Series media: i2c: use pm_runtime_resume_and_get() were possible | expand

Message

Mauro Carvalho Chehab May 6, 2021, 3:22 p.m. UTC
Dealing with PM runtime (RPM) is different than dealing with other kAPIs used
on media, as most pm_runtime_get_*() functions won't return to the the state
before the call if an error rises. They, instead, increment an usage_count.

Due to that, there were several bugs on media. Just on this review, we found
24 such errors.

So, let's use pm_runtime_resume_and_get() whenever possible, as it
has two advantages over :

1. On errors, it decrements the usage count;
2. It always return zero on success or an error code. This prevents a 
   common error pattern of checking if ret is not zero to identify
   for errors.

There are however a few places where calls to pm_runtime_get_sync()
are kept. On several of those, a comment was added, in order to
help preventing trivial patches that could try to change them.

PS.: This series was submitted already together with the fix patches
at:

	https://lore.kernel.org/linux-media/cover.1619621413.git.mchehab+huawei@kernel.org/

I opted to break it on 3 parts, in order to make easier to review.

This is the second part.

Mauro Carvalho Chehab (30):
  media: i2c: ak7375: use pm_runtime_resume_and_get()
  media: i2c: dw9714: use pm_runtime_resume_and_get()
  media: i2c: dw9768: use pm_runtime_resume_and_get()
  media: i2c: dw9807-vcm: use pm_runtime_resume_and_get()
  media: i2c: hi556: use pm_runtime_resume_and_get()
  media: i2c: imx214: use pm_runtime_resume_and_get()
  media: i2c: imx219: use pm_runtime_resume_and_get()
  media: i2c: imx258: use pm_runtime_resume_and_get()
  media: i2c: imx274: use pm_runtime_resume_and_get()
  media: i2c: imx290: use pm_runtime_resume_and_get()
  media: i2c: imx319: use pm_runtime_resume_and_get()
  media: i2c: imx355: use pm_runtime_resume_and_get()
  media: i2c: mt9m001: use pm_runtime_resume_and_get()
  media: i2c: ov02a10: use pm_runtime_resume_and_get()
  media: i2c: ov13858: use pm_runtime_resume_and_get()
  media: i2c: ov2659: use pm_runtime_resume_and_get()
  media: i2c: ov2685: use pm_runtime_resume_and_get()
  media: i2c: ov2740: use pm_runtime_resume_and_get()
  media: i2c: ov5647: use pm_runtime_resume_and_get()
  media: i2c: ov5648: use pm_runtime_resume_and_get()
  media: i2c: ov5670: use pm_runtime_resume_and_get()
  media: i2c: ov5675: use pm_runtime_resume_and_get()
  media: i2c: ov5695: use pm_runtime_resume_and_get()
  media: i2c: ov7740: use pm_runtime_resume_and_get()
  media: i2c: ov8856: use pm_runtime_resume_and_get()
  media: i2c: ov8865: use pm_runtime_resume_and_get()
  media: i2c: ov9734: use pm_runtime_resume_and_get()
  media: i2c: tvp5150: use pm_runtime_resume_and_get()
  media: i2c: video-i2c: use pm_runtime_resume_and_get()
  media: i2c: ccs-core: use pm_runtime_resume_and_get()

 drivers/media/i2c/ak7375.c       | 10 +---------
 drivers/media/i2c/ccs/ccs-core.c |  7 ++-----
 drivers/media/i2c/dw9714.c       | 10 +---------
 drivers/media/i2c/dw9768.c       | 10 +---------
 drivers/media/i2c/dw9807-vcm.c   | 10 +---------
 drivers/media/i2c/hi556.c        |  3 +--
 drivers/media/i2c/imx214.c       |  6 ++----
 drivers/media/i2c/imx219.c       |  6 ++----
 drivers/media/i2c/imx258.c       |  6 ++----
 drivers/media/i2c/imx274.c       |  3 +--
 drivers/media/i2c/imx290.c       |  6 ++----
 drivers/media/i2c/imx319.c       |  6 ++----
 drivers/media/i2c/imx355.c       |  6 ++----
 drivers/media/i2c/mt9m001.c      |  9 +++++++--
 drivers/media/i2c/ov02a10.c      |  6 ++----
 drivers/media/i2c/ov13858.c      |  6 ++----
 drivers/media/i2c/ov2659.c       |  6 ++----
 drivers/media/i2c/ov2685.c       |  7 +++----
 drivers/media/i2c/ov2740.c       |  6 ++----
 drivers/media/i2c/ov5647.c       |  9 +++++----
 drivers/media/i2c/ov5648.c       |  6 ++----
 drivers/media/i2c/ov5670.c       |  6 ++----
 drivers/media/i2c/ov5675.c       |  3 +--
 drivers/media/i2c/ov5695.c       |  6 ++----
 drivers/media/i2c/ov7740.c       |  6 ++----
 drivers/media/i2c/ov8856.c       |  3 +--
 drivers/media/i2c/ov8865.c       |  6 ++----
 drivers/media/i2c/ov9734.c       |  3 +--
 drivers/media/i2c/tvp5150.c      | 16 +++-------------
 drivers/media/i2c/video-i2c.c    | 12 ++++--------
 30 files changed, 63 insertions(+), 142 deletions(-)