linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible
@ 2021-05-06 15:22 Mauro Carvalho Chehab
  2021-05-06 15:22 ` [PATCH v5 01/30] media: i2c: ak7375: use pm_runtime_resume_and_get() Mauro Carvalho Chehab
                   ` (29 more replies)
  0 siblings, 30 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:22 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Lad, Prabhakar,
	Bingbu Cao, Chiranjeevi Rapolu, Dave Stevenson, Dongchun Zhu,
	Hyungwoo Yang, Jacopo Mondi, Leon Luo, Manivannan Sadhasivam,
	Matt Ranostay, Mauro Carvalho Chehab, Ricardo Ribalda,
	Sakari Ailus, Shawn Tu, Shunqian Zheng, Tianshu Qiu, Wenyou Yang,
	linux-kernel, linux-media

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(-)

-- 
2.30.2



^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH v5 01/30] media: i2c: ak7375: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
@ 2021-05-06 15:22 ` Mauro Carvalho Chehab
  2021-05-06 15:22 ` [PATCH v5 02/30] media: i2c: dw9714: " Mauro Carvalho Chehab
                   ` (28 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:22 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Mauro Carvalho Chehab, Tianshu Qiu, linux-kernel, linux-media,
	Jonathan Cameron

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/ak7375.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/media/i2c/ak7375.c b/drivers/media/i2c/ak7375.c
index e1f94ee0f48f..40b1a4aa846c 100644
--- a/drivers/media/i2c/ak7375.c
+++ b/drivers/media/i2c/ak7375.c
@@ -87,15 +87,7 @@ static const struct v4l2_ctrl_ops ak7375_vcm_ctrl_ops = {
 
 static int ak7375_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
 {
-	int ret;
-
-	ret = pm_runtime_get_sync(sd->dev);
-	if (ret < 0) {
-		pm_runtime_put_noidle(sd->dev);
-		return ret;
-	}
-
-	return 0;
+	return pm_runtime_resume_and_get(sd->dev);
 }
 
 static int ak7375_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 02/30] media: i2c: dw9714: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
  2021-05-06 15:22 ` [PATCH v5 01/30] media: i2c: ak7375: use pm_runtime_resume_and_get() Mauro Carvalho Chehab
@ 2021-05-06 15:22 ` Mauro Carvalho Chehab
  2021-05-06 15:22 ` [PATCH v5 03/30] media: i2c: dw9768: " Mauro Carvalho Chehab
                   ` (27 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:22 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Mauro Carvalho Chehab, Sakari Ailus, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/dw9714.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/media/i2c/dw9714.c b/drivers/media/i2c/dw9714.c
index 3f0b082f863f..c8b4292512dc 100644
--- a/drivers/media/i2c/dw9714.c
+++ b/drivers/media/i2c/dw9714.c
@@ -85,15 +85,7 @@ static const struct v4l2_ctrl_ops dw9714_vcm_ctrl_ops = {
 
 static int dw9714_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
 {
-	int rval;
-
-	rval = pm_runtime_get_sync(sd->dev);
-	if (rval < 0) {
-		pm_runtime_put_noidle(sd->dev);
-		return rval;
-	}
-
-	return 0;
+	return pm_runtime_resume_and_get(sd->dev);
 }
 
 static int dw9714_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 03/30] media: i2c: dw9768: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
  2021-05-06 15:22 ` [PATCH v5 01/30] media: i2c: ak7375: use pm_runtime_resume_and_get() Mauro Carvalho Chehab
  2021-05-06 15:22 ` [PATCH v5 02/30] media: i2c: dw9714: " Mauro Carvalho Chehab
@ 2021-05-06 15:22 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 04/30] media: i2c: dw9807-vcm: " Mauro Carvalho Chehab
                   ` (26 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:22 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Dongchun Zhu,
	Mauro Carvalho Chehab, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/dw9768.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/media/i2c/dw9768.c b/drivers/media/i2c/dw9768.c
index 8b8cb4b077b5..c086580efac7 100644
--- a/drivers/media/i2c/dw9768.c
+++ b/drivers/media/i2c/dw9768.c
@@ -374,15 +374,7 @@ static const struct v4l2_ctrl_ops dw9768_ctrl_ops = {
 
 static int dw9768_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
 {
-	int ret;
-
-	ret = pm_runtime_get_sync(sd->dev);
-	if (ret < 0) {
-		pm_runtime_put_noidle(sd->dev);
-		return ret;
-	}
-
-	return 0;
+	return pm_runtime_resume_and_get(sd->dev);
 }
 
 static int dw9768_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 04/30] media: i2c: dw9807-vcm: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (2 preceding siblings ...)
  2021-05-06 15:22 ` [PATCH v5 03/30] media: i2c: dw9768: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 05/30] media: i2c: hi556: " Mauro Carvalho Chehab
                   ` (25 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Mauro Carvalho Chehab, Sakari Ailus, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/dw9807-vcm.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/media/i2c/dw9807-vcm.c b/drivers/media/i2c/dw9807-vcm.c
index 438a44b76da8..95e06f13bc9e 100644
--- a/drivers/media/i2c/dw9807-vcm.c
+++ b/drivers/media/i2c/dw9807-vcm.c
@@ -130,15 +130,7 @@ static const struct v4l2_ctrl_ops dw9807_vcm_ctrl_ops = {
 
 static int dw9807_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
 {
-	int rval;
-
-	rval = pm_runtime_get_sync(sd->dev);
-	if (rval < 0) {
-		pm_runtime_put_noidle(sd->dev);
-		return rval;
-	}
-
-	return 0;
+	return pm_runtime_resume_and_get(sd->dev);
 }
 
 static int dw9807_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 05/30] media: i2c: hi556: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (3 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 04/30] media: i2c: dw9807-vcm: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 06/30] media: i2c: imx214: " Mauro Carvalho Chehab
                   ` (24 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Mauro Carvalho Chehab, Shawn Tu, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/hi556.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/i2c/hi556.c b/drivers/media/i2c/hi556.c
index 6f05c1138e3b..627ccfa34835 100644
--- a/drivers/media/i2c/hi556.c
+++ b/drivers/media/i2c/hi556.c
@@ -813,9 +813,8 @@ static int hi556_set_stream(struct v4l2_subdev *sd, int enable)
 
 	mutex_lock(&hi556->mutex);
 	if (enable) {
-		ret = pm_runtime_get_sync(&client->dev);
+		ret = pm_runtime_resume_and_get(&client->dev);
 		if (ret < 0) {
-			pm_runtime_put_noidle(&client->dev);
 			mutex_unlock(&hi556->mutex);
 			return ret;
 		}
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 06/30] media: i2c: imx214: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (4 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 05/30] media: i2c: hi556: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 07/30] media: i2c: imx219: " Mauro Carvalho Chehab
                   ` (23 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Mauro Carvalho Chehab, Ricardo Ribalda, linux-kernel,
	linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/imx214.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c
index e8b281e432e8..1a770a530cf5 100644
--- a/drivers/media/i2c/imx214.c
+++ b/drivers/media/i2c/imx214.c
@@ -776,11 +776,9 @@ static int imx214_s_stream(struct v4l2_subdev *subdev, int enable)
 		return 0;
 
 	if (enable) {
-		ret = pm_runtime_get_sync(imx214->dev);
-		if (ret < 0) {
-			pm_runtime_put_noidle(imx214->dev);
+		ret = pm_runtime_resume_and_get(imx214->dev);
+		if (ret < 0)
 			return ret;
-		}
 
 		ret = imx214_start_streaming(imx214);
 		if (ret < 0)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 07/30] media: i2c: imx219: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (5 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 06/30] media: i2c: imx214: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 08/30] media: i2c: imx258: " Mauro Carvalho Chehab
                   ` (22 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Dave Stevenson,
	Mauro Carvalho Chehab, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/imx219.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index 1054ffedaefd..74a0bf9b088b 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -1035,11 +1035,9 @@ static int imx219_start_streaming(struct imx219 *imx219)
 	const struct imx219_reg_list *reg_list;
 	int ret;
 
-	ret = pm_runtime_get_sync(&client->dev);
-	if (ret < 0) {
-		pm_runtime_put_noidle(&client->dev);
+	ret = pm_runtime_resume_and_get(&client->dev);
+	if (ret < 0)
 		return ret;
-	}
 
 	/* Apply default values of current mode */
 	reg_list = &imx219->mode->reg_list;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 08/30] media: i2c: imx258: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (6 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 07/30] media: i2c: imx219: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 09/30] media: i2c: imx274: " Mauro Carvalho Chehab
                   ` (21 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Mauro Carvalho Chehab, Sakari Ailus, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/imx258.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/imx258.c b/drivers/media/i2c/imx258.c
index a017ec4e0f50..90529424d5b6 100644
--- a/drivers/media/i2c/imx258.c
+++ b/drivers/media/i2c/imx258.c
@@ -1039,11 +1039,9 @@ static int imx258_set_stream(struct v4l2_subdev *sd, int enable)
 	}
 
 	if (enable) {
-		ret = pm_runtime_get_sync(&client->dev);
-		if (ret < 0) {
-			pm_runtime_put_noidle(&client->dev);
+		ret = pm_runtime_resume_and_get(&client->dev);
+		if (ret < 0)
 			goto err_unlock;
-		}
 
 		/*
 		 * Apply default & customized values
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 09/30] media: i2c: imx274: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (7 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 08/30] media: i2c: imx258: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 10/30] media: i2c: imx290: " Mauro Carvalho Chehab
                   ` (20 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Leon Luo,
	Mauro Carvalho Chehab, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/imx274.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/i2c/imx274.c b/drivers/media/i2c/imx274.c
index cdccaab3043a..ee2127436f0b 100644
--- a/drivers/media/i2c/imx274.c
+++ b/drivers/media/i2c/imx274.c
@@ -1441,9 +1441,8 @@ static int imx274_s_stream(struct v4l2_subdev *sd, int on)
 	mutex_lock(&imx274->lock);
 
 	if (on) {
-		ret = pm_runtime_get_sync(&imx274->client->dev);
+		ret = pm_runtime_resume_and_get(&imx274->client->dev);
 		if (ret < 0) {
-			pm_runtime_put_noidle(&imx274->client->dev);
 			mutex_unlock(&imx274->lock);
 			return ret;
 		}
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 10/30] media: i2c: imx290: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (8 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 09/30] media: i2c: imx274: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 11/30] media: i2c: imx319: " Mauro Carvalho Chehab
                   ` (19 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Manivannan Sadhasivam, Mauro Carvalho Chehab, linux-kernel,
	linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/imx290.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c
index 6319a42057d2..06020e648a97 100644
--- a/drivers/media/i2c/imx290.c
+++ b/drivers/media/i2c/imx290.c
@@ -764,11 +764,9 @@ static int imx290_set_stream(struct v4l2_subdev *sd, int enable)
 	int ret = 0;
 
 	if (enable) {
-		ret = pm_runtime_get_sync(imx290->dev);
-		if (ret < 0) {
-			pm_runtime_put_noidle(imx290->dev);
+		ret = pm_runtime_resume_and_get(imx290->dev);
+		if (ret < 0)
 			goto unlock_and_return;
-		}
 
 		ret = imx290_start_streaming(imx290);
 		if (ret) {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 11/30] media: i2c: imx319: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (9 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 10/30] media: i2c: imx290: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 12/30] media: i2c: imx355: " Mauro Carvalho Chehab
                   ` (18 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Bingbu Cao,
	Mauro Carvalho Chehab, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/imx319.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/imx319.c b/drivers/media/i2c/imx319.c
index 38540323a156..4e0a8c9d271f 100644
--- a/drivers/media/i2c/imx319.c
+++ b/drivers/media/i2c/imx319.c
@@ -2141,11 +2141,9 @@ static int imx319_set_stream(struct v4l2_subdev *sd, int enable)
 	}
 
 	if (enable) {
-		ret = pm_runtime_get_sync(&client->dev);
-		if (ret < 0) {
-			pm_runtime_put_noidle(&client->dev);
+		ret = pm_runtime_resume_and_get(&client->dev);
+		if (ret < 0)
 			goto err_unlock;
-		}
 
 		/*
 		 * Apply default & customized values
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 12/30] media: i2c: imx355: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (10 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 11/30] media: i2c: imx319: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 13/30] media: i2c: mt9m001: " Mauro Carvalho Chehab
                   ` (17 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Mauro Carvalho Chehab, Tianshu Qiu, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/imx355.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c
index ccedcd4c520a..93f13a04439a 100644
--- a/drivers/media/i2c/imx355.c
+++ b/drivers/media/i2c/imx355.c
@@ -1442,11 +1442,9 @@ static int imx355_set_stream(struct v4l2_subdev *sd, int enable)
 	}
 
 	if (enable) {
-		ret = pm_runtime_get_sync(&client->dev);
-		if (ret < 0) {
-			pm_runtime_put_noidle(&client->dev);
+		ret = pm_runtime_resume_and_get(&client->dev);
+		if (ret < 0)
 			goto err_unlock;
-		}
 
 		/*
 		 * Apply default & customized values
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 13/30] media: i2c: mt9m001: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (11 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 12/30] media: i2c: imx355: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 14/30] media: i2c: ov02a10: " Mauro Carvalho Chehab
                   ` (16 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Hans Verkuil,
	Jacopo Mondi, Mauro Carvalho Chehab, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/mt9m001.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/mt9m001.c b/drivers/media/i2c/mt9m001.c
index 3b0ba8ed5233..58c85a3bccf6 100644
--- a/drivers/media/i2c/mt9m001.c
+++ b/drivers/media/i2c/mt9m001.c
@@ -217,9 +217,9 @@ static int mt9m001_s_stream(struct v4l2_subdev *sd, int enable)
 		goto done;
 
 	if (enable) {
-		ret = pm_runtime_get_sync(&client->dev);
+		ret = pm_runtime_resume_and_get(&client->dev);
 		if (ret < 0)
-			goto put_unlock;
+			goto unlock;
 
 		ret = mt9m001_apply_selection(sd);
 		if (ret)
@@ -247,6 +247,7 @@ static int mt9m001_s_stream(struct v4l2_subdev *sd, int enable)
 
 put_unlock:
 	pm_runtime_put(&client->dev);
+unlock:
 	mutex_unlock(&mt9m001->mutex);
 
 	return ret;
@@ -834,6 +835,10 @@ static int mt9m001_remove(struct i2c_client *client)
 {
 	struct mt9m001 *mt9m001 = to_mt9m001(client);
 
+	/*
+	 * As it increments RPM usage_count even on errors, we don't need to
+	 * check the returned code here.
+	 */
 	pm_runtime_get_sync(&client->dev);
 
 	v4l2_async_unregister_subdev(&mt9m001->subdev);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 14/30] media: i2c: ov02a10: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (12 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 13/30] media: i2c: mt9m001: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 15/30] media: i2c: ov13858: " Mauro Carvalho Chehab
                   ` (15 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Dongchun Zhu,
	Mauro Carvalho Chehab, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/ov02a10.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/ov02a10.c b/drivers/media/i2c/ov02a10.c
index c47b1d45d8fd..a1d7314b20a9 100644
--- a/drivers/media/i2c/ov02a10.c
+++ b/drivers/media/i2c/ov02a10.c
@@ -540,11 +540,9 @@ static int ov02a10_s_stream(struct v4l2_subdev *sd, int on)
 	}
 
 	if (on) {
-		ret = pm_runtime_get_sync(&client->dev);
-		if (ret < 0) {
-			pm_runtime_put_noidle(&client->dev);
+		ret = pm_runtime_resume_and_get(&client->dev);
+		if (ret < 0)
 			goto unlock_and_return;
-		}
 
 		ret = __ov02a10_start_stream(ov02a10);
 		if (ret) {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 15/30] media: i2c: ov13858: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (13 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 14/30] media: i2c: ov02a10: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 16/30] media: i2c: ov2659: " Mauro Carvalho Chehab
                   ` (14 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Mauro Carvalho Chehab, Sakari Ailus, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/ov13858.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/ov13858.c b/drivers/media/i2c/ov13858.c
index 4a2885ff0cbe..9598c0b19603 100644
--- a/drivers/media/i2c/ov13858.c
+++ b/drivers/media/i2c/ov13858.c
@@ -1472,11 +1472,9 @@ static int ov13858_set_stream(struct v4l2_subdev *sd, int enable)
 	}
 
 	if (enable) {
-		ret = pm_runtime_get_sync(&client->dev);
-		if (ret < 0) {
-			pm_runtime_put_noidle(&client->dev);
+		ret = pm_runtime_resume_and_get(&client->dev);
+		if (ret < 0)
 			goto err_unlock;
-		}
 
 		/*
 		 * Apply default & customized values
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 16/30] media: i2c: ov2659: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (14 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 15/30] media: i2c: ov13858: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 17/30] media: i2c: ov2685: " Mauro Carvalho Chehab
                   ` (13 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Lad, Prabhakar,
	Mauro Carvalho Chehab, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Acked-by: Lad Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/ov2659.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 42f64175a6df..a3c8eae68486 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1186,11 +1186,9 @@ static int ov2659_s_stream(struct v4l2_subdev *sd, int on)
 		goto unlock;
 	}
 
-	ret = pm_runtime_get_sync(&client->dev);
-	if (ret < 0) {
-		pm_runtime_put_noidle(&client->dev);
+	ret = pm_runtime_resume_and_get(&client->dev);
+	if (ret < 0)
 		goto unlock;
-	}
 
 	ret = ov2659_init(sd, 0);
 	if (!ret)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 17/30] media: i2c: ov2685: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (15 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 16/30] media: i2c: ov2659: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 18/30] media: i2c: ov2740: " Mauro Carvalho Chehab
                   ` (12 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Mauro Carvalho Chehab, Shunqian Zheng, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/ov2685.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/ov2685.c b/drivers/media/i2c/ov2685.c
index 49a2dcedb347..2f3836dd8eed 100644
--- a/drivers/media/i2c/ov2685.c
+++ b/drivers/media/i2c/ov2685.c
@@ -456,11 +456,10 @@ static int ov2685_s_stream(struct v4l2_subdev *sd, int on)
 		goto unlock_and_return;
 
 	if (on) {
-		ret = pm_runtime_get_sync(&ov2685->client->dev);
-		if (ret < 0) {
-			pm_runtime_put_noidle(&client->dev);
+		ret = pm_runtime_resume_and_get(&ov2685->client->dev);
+		if (ret < 0)
 			goto unlock_and_return;
-		}
+
 		ret = __v4l2_ctrl_handler_setup(&ov2685->ctrl_handler);
 		if (ret) {
 			pm_runtime_put(&client->dev);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 18/30] media: i2c: ov2740: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (16 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 17/30] media: i2c: ov2685: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 19/30] media: i2c: ov5647: " Mauro Carvalho Chehab
                   ` (11 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Bingbu Cao,
	Mauro Carvalho Chehab, Shawn Tu, Tianshu Qiu, linux-kernel,
	linux-media, Jonathan Cameron

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/ov2740.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c
index 0f3f17f3c426..54779f720f9d 100644
--- a/drivers/media/i2c/ov2740.c
+++ b/drivers/media/i2c/ov2740.c
@@ -751,9 +751,8 @@ static int ov2740_set_stream(struct v4l2_subdev *sd, int enable)
 
 	mutex_lock(&ov2740->mutex);
 	if (enable) {
-		ret = pm_runtime_get_sync(&client->dev);
+		ret = pm_runtime_resume_and_get(&client->dev);
 		if (ret < 0) {
-			pm_runtime_put_noidle(&client->dev);
 			mutex_unlock(&ov2740->mutex);
 			return ret;
 		}
@@ -1049,9 +1048,8 @@ static int ov2740_nvmem_read(void *priv, unsigned int off, void *val,
 		goto exit;
 	}
 
-	ret = pm_runtime_get_sync(dev);
+	ret = pm_runtime_resume_and_get(dev);
 	if (ret < 0) {
-		pm_runtime_put_noidle(dev);
 		goto exit;
 	}
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 19/30] media: i2c: ov5647: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (17 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 18/30] media: i2c: ov2740: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 20/30] media: i2c: ov5648: " Mauro Carvalho Chehab
                   ` (10 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Dave Stevenson,
	Jacopo Mondi, Mauro Carvalho Chehab, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/ov5647.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index 1cefa15729ce..38faa74755e3 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -882,20 +882,20 @@ static int ov5647_s_stream(struct v4l2_subdev *sd, int enable)
 	}
 
 	if (enable) {
-		ret = pm_runtime_get_sync(&client->dev);
+		ret = pm_runtime_resume_and_get(&client->dev);
 		if (ret < 0)
 			goto error_unlock;
 
 		ret = ov5647_stream_on(sd);
 		if (ret < 0) {
 			dev_err(&client->dev, "stream start failed: %d\n", ret);
-			goto error_unlock;
+			goto error_pm;
 		}
 	} else {
 		ret = ov5647_stream_off(sd);
 		if (ret < 0) {
 			dev_err(&client->dev, "stream stop failed: %d\n", ret);
-			goto error_unlock;
+			goto error_pm;
 		}
 		pm_runtime_put(&client->dev);
 	}
@@ -905,8 +905,9 @@ static int ov5647_s_stream(struct v4l2_subdev *sd, int enable)
 
 	return 0;
 
+error_pm:
+	pm_runtime_put(&client->dev);
 error_unlock:
-	pm_runtime_put(&client->dev);
 	mutex_unlock(&sensor->lock);
 
 	return ret;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 20/30] media: i2c: ov5648: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (18 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 19/30] media: i2c: ov5647: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 21/30] media: i2c: ov5670: " Mauro Carvalho Chehab
                   ` (9 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Colin Ian King,
	Dan Carpenter, Ezequiel Garcia, Mauro Carvalho Chehab,
	Paul Kocialkowski, Sakari Ailus, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/ov5648.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/ov5648.c b/drivers/media/i2c/ov5648.c
index 3ecb4a3e8773..07e64ff0be3f 100644
--- a/drivers/media/i2c/ov5648.c
+++ b/drivers/media/i2c/ov5648.c
@@ -2132,11 +2132,9 @@ static int ov5648_s_stream(struct v4l2_subdev *subdev, int enable)
 	int ret;
 
 	if (enable) {
-		ret = pm_runtime_get_sync(sensor->dev);
-		if (ret < 0) {
-			pm_runtime_put_noidle(sensor->dev);
+		ret = pm_runtime_resume_and_get(sensor->dev);
+		if (ret < 0)
 			return ret;
-		}
 	}
 
 	mutex_lock(&sensor->mutex);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 21/30] media: i2c: ov5670: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (19 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 20/30] media: i2c: ov5648: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 22/30] media: i2c: ov5675: " Mauro Carvalho Chehab
                   ` (8 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Chiranjeevi Rapolu, Hyungwoo Yang, Mauro Carvalho Chehab,
	linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/ov5670.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c
index dee7df8dd100..182f271f118f 100644
--- a/drivers/media/i2c/ov5670.c
+++ b/drivers/media/i2c/ov5670.c
@@ -2347,11 +2347,9 @@ static int ov5670_set_stream(struct v4l2_subdev *sd, int enable)
 		goto unlock_and_return;
 
 	if (enable) {
-		ret = pm_runtime_get_sync(&client->dev);
-		if (ret < 0) {
-			pm_runtime_put_noidle(&client->dev);
+		ret = pm_runtime_resume_and_get(&client->dev);
+		if (ret < 0)
 			goto unlock_and_return;
-		}
 
 		ret = ov5670_start_streaming(ov5670);
 		if (ret)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 22/30] media: i2c: ov5675: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (20 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 21/30] media: i2c: ov5670: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 23/30] media: i2c: ov5695: " Mauro Carvalho Chehab
                   ` (7 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Mauro Carvalho Chehab, Shawn Tu, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/ov5675.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/i2c/ov5675.c b/drivers/media/i2c/ov5675.c
index dea32859459a..e7e297a23960 100644
--- a/drivers/media/i2c/ov5675.c
+++ b/drivers/media/i2c/ov5675.c
@@ -863,9 +863,8 @@ static int ov5675_set_stream(struct v4l2_subdev *sd, int enable)
 
 	mutex_lock(&ov5675->mutex);
 	if (enable) {
-		ret = pm_runtime_get_sync(&client->dev);
+		ret = pm_runtime_resume_and_get(&client->dev);
 		if (ret < 0) {
-			pm_runtime_put_noidle(&client->dev);
 			mutex_unlock(&ov5675->mutex);
 			return ret;
 		}
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 23/30] media: i2c: ov5695: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (21 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 22/30] media: i2c: ov5675: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 24/30] media: i2c: ov7740: " Mauro Carvalho Chehab
                   ` (6 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Mauro Carvalho Chehab, Shunqian Zheng, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/ov5695.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/ov5695.c b/drivers/media/i2c/ov5695.c
index 09bee57a241d..469d941813c6 100644
--- a/drivers/media/i2c/ov5695.c
+++ b/drivers/media/i2c/ov5695.c
@@ -946,11 +946,9 @@ static int ov5695_s_stream(struct v4l2_subdev *sd, int on)
 		goto unlock_and_return;
 
 	if (on) {
-		ret = pm_runtime_get_sync(&client->dev);
-		if (ret < 0) {
-			pm_runtime_put_noidle(&client->dev);
+		ret = pm_runtime_resume_and_get(&client->dev);
+		if (ret < 0)
 			goto unlock_and_return;
-		}
 
 		ret = __ov5695_start_stream(ov5695);
 		if (ret) {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 24/30] media: i2c: ov7740: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (22 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 23/30] media: i2c: ov5695: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 25/30] media: i2c: ov8856: " Mauro Carvalho Chehab
                   ` (5 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Mauro Carvalho Chehab, Wenyou Yang, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/ov7740.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/ov7740.c b/drivers/media/i2c/ov7740.c
index 47a9003d29d6..e0ff6506a543 100644
--- a/drivers/media/i2c/ov7740.c
+++ b/drivers/media/i2c/ov7740.c
@@ -624,11 +624,9 @@ static int ov7740_set_stream(struct v4l2_subdev *sd, int enable)
 	}
 
 	if (enable) {
-		ret = pm_runtime_get_sync(&client->dev);
-		if (ret < 0) {
-			pm_runtime_put_noidle(&client->dev);
+		ret = pm_runtime_resume_and_get(&client->dev);
+		if (ret < 0)
 			goto err_unlock;
-		}
 
 		ret = ov7740_start_streaming(ov7740);
 		if (ret)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 25/30] media: i2c: ov8856: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (23 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 24/30] media: i2c: ov7740: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 26/30] media: i2c: ov8865: " Mauro Carvalho Chehab
                   ` (4 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Dongchun Zhu,
	Mauro Carvalho Chehab, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/ov8856.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/i2c/ov8856.c b/drivers/media/i2c/ov8856.c
index e3af3ea277af..2875f8e4ddcb 100644
--- a/drivers/media/i2c/ov8856.c
+++ b/drivers/media/i2c/ov8856.c
@@ -1340,9 +1340,8 @@ static int ov8856_set_stream(struct v4l2_subdev *sd, int enable)
 
 	mutex_lock(&ov8856->mutex);
 	if (enable) {
-		ret = pm_runtime_get_sync(&client->dev);
+		ret = pm_runtime_resume_and_get(&client->dev);
 		if (ret < 0) {
-			pm_runtime_put_noidle(&client->dev);
 			mutex_unlock(&ov8856->mutex);
 			return ret;
 		}
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 26/30] media: i2c: ov8865: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (24 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 25/30] media: i2c: ov8856: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 27/30] media: i2c: ov9734: " Mauro Carvalho Chehab
                   ` (3 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Ezequiel Garcia,
	Hans Verkuil, Mauro Carvalho Chehab, Paul Kocialkowski,
	Sakari Ailus, Yang Li, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/ov8865.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c
index 9ecf180635ee..3bf6ee4898a9 100644
--- a/drivers/media/i2c/ov8865.c
+++ b/drivers/media/i2c/ov8865.c
@@ -2497,11 +2497,9 @@ static int ov8865_s_stream(struct v4l2_subdev *subdev, int enable)
 	int ret;
 
 	if (enable) {
-		ret = pm_runtime_get_sync(sensor->dev);
-		if (ret < 0) {
-			pm_runtime_put_noidle(sensor->dev);
+		ret = pm_runtime_resume_and_get(sensor->dev);
+		if (ret < 0)
 			return ret;
-		}
 	}
 
 	mutex_lock(&sensor->mutex);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 27/30] media: i2c: ov9734: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (25 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 26/30] media: i2c: ov8865: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 28/30] media: i2c: tvp5150: " Mauro Carvalho Chehab
                   ` (2 subsequent siblings)
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Bingbu Cao,
	Mauro Carvalho Chehab, Tianshu Qiu, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/ov9734.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/i2c/ov9734.c b/drivers/media/i2c/ov9734.c
index b7309a551cae..ba156683c533 100644
--- a/drivers/media/i2c/ov9734.c
+++ b/drivers/media/i2c/ov9734.c
@@ -644,9 +644,8 @@ static int ov9734_set_stream(struct v4l2_subdev *sd, int enable)
 	}
 
 	if (enable) {
-		ret = pm_runtime_get_sync(&client->dev);
+		ret = pm_runtime_resume_and_get(&client->dev);
 		if (ret < 0) {
-			pm_runtime_put_noidle(&client->dev);
 			mutex_unlock(&ov9734->mutex);
 			return ret;
 		}
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 28/30] media: i2c: tvp5150: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (26 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 27/30] media: i2c: ov9734: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 29/30] media: i2c: video-i2c: " Mauro Carvalho Chehab
  2021-05-06 15:23 ` [PATCH v5 30/30] media: i2c: ccs-core: " Mauro Carvalho Chehab
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Gustavo A. R. Silva, Chuhong Yuan, Hans Verkuil, Jacopo Mondi,
	Krzysztof Kozlowski, Marco Felsch, Mauro Carvalho Chehab,
	Sakari Ailus, Zhang Xiaoxu, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/tvp5150.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index e26e3f544054..374a9da75e4d 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -1448,11 +1448,9 @@ static int tvp5150_s_stream(struct v4l2_subdev *sd, int enable)
 	       TVP5150_MISC_CTL_CLOCK_OE;
 
 	if (enable) {
-		ret = pm_runtime_get_sync(sd->dev);
-		if (ret < 0) {
-			pm_runtime_put_noidle(sd->dev);
+		ret = pm_runtime_resume_and_get(sd->dev);
+		if (ret < 0)
 			return ret;
-		}
 
 		tvp5150_enable(sd);
 
@@ -1675,15 +1673,7 @@ static int tvp5150_registered(struct v4l2_subdev *sd)
 
 static int tvp5150_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
 {
-	int ret;
-
-	ret = pm_runtime_get_sync(sd->dev);
-	if (ret < 0) {
-		pm_runtime_put_noidle(sd->dev);
-		return ret;
-	}
-
-	return 0;
+	return pm_runtime_resume_and_get(sd->dev);
 }
 
 static int tvp5150_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 29/30] media: i2c: video-i2c: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (27 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 28/30] media: i2c: tvp5150: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  2021-05-07 21:26   ` Matt Ranostay
  2021-05-06 15:23 ` [PATCH v5 30/30] media: i2c: ccs-core: " Mauro Carvalho Chehab
  29 siblings, 1 reply; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Matt Ranostay,
	Mauro Carvalho Chehab, linux-kernel, linux-media

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/video-i2c.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c
index 0465832a4090..de12f38f347c 100644
--- a/drivers/media/i2c/video-i2c.c
+++ b/drivers/media/i2c/video-i2c.c
@@ -286,11 +286,9 @@ static int amg88xx_read(struct device *dev, enum hwmon_sensor_types type,
 	__le16 buf;
 	int tmp;
 
-	tmp = pm_runtime_get_sync(regmap_get_device(data->regmap));
-	if (tmp < 0) {
-		pm_runtime_put_noidle(regmap_get_device(data->regmap));
+	tmp = pm_runtime_resume_and_get(regmap_get_device(data->regmap));
+	if (tmp < 0)
 		return tmp;
-	}
 
 	tmp = regmap_bulk_read(data->regmap, AMG88XX_REG_TTHL, &buf, 2);
 	pm_runtime_mark_last_busy(regmap_get_device(data->regmap));
@@ -512,11 +510,9 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
 	if (data->kthread_vid_cap)
 		return 0;
 
-	ret = pm_runtime_get_sync(dev);
-	if (ret < 0) {
-		pm_runtime_put_noidle(dev);
+	ret = pm_runtime_resume_and_get(dev);
+	if (ret < 0)
 		goto error_del_list;
-	}
 
 	ret = data->chip->setup(data);
 	if (ret)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v5 30/30] media: i2c: ccs-core: use pm_runtime_resume_and_get()
  2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
                   ` (28 preceding siblings ...)
  2021-05-06 15:23 ` [PATCH v5 29/30] media: i2c: video-i2c: " Mauro Carvalho Chehab
@ 2021-05-06 15:23 ` Mauro Carvalho Chehab
  29 siblings, 0 replies; 32+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:23 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Mauro Carvalho Chehab, Sakari Ailus, linux-kernel, linux-media,
	Jonathan Cameron

Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.

Use the new API, in order to cleanup the error check logic.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/i2c/ccs/ccs-core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c
index 4a848ac2d2cd..a349189a38db 100644
--- a/drivers/media/i2c/ccs/ccs-core.c
+++ b/drivers/media/i2c/ccs/ccs-core.c
@@ -3101,12 +3101,9 @@ static int __maybe_unused ccs_suspend(struct device *dev)
 	bool streaming = sensor->streaming;
 	int rval;
 
-	rval = pm_runtime_get_sync(dev);
-	if (rval < 0) {
-		pm_runtime_put_noidle(dev);
-
+	rval = pm_runtime_resume_and_get(dev);
+	if (rval < 0)
 		return rval;
-	}
 
 	if (sensor->streaming)
 		ccs_stop_streaming(sensor);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH v5 29/30] media: i2c: video-i2c: use pm_runtime_resume_and_get()
  2021-05-06 15:23 ` [PATCH v5 29/30] media: i2c: video-i2c: " Mauro Carvalho Chehab
@ 2021-05-07 21:26   ` Matt Ranostay
  0 siblings, 0 replies; 32+ messages in thread
From: Matt Ranostay @ 2021-05-07 21:26 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, open list, linux-media

On Thu, May 6, 2021 at 8:23 AM Mauro Carvalho Chehab
<mchehab+huawei@kernel.org> wrote:
>
> Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
> added pm_runtime_resume_and_get() in order to automatically handle
> dev->power.usage_count decrement on errors.
>
> Use the new API, in order to cleanup the error check logic.
>

Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>

> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> ---
>  drivers/media/i2c/video-i2c.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c
> index 0465832a4090..de12f38f347c 100644
> --- a/drivers/media/i2c/video-i2c.c
> +++ b/drivers/media/i2c/video-i2c.c
> @@ -286,11 +286,9 @@ static int amg88xx_read(struct device *dev, enum hwmon_sensor_types type,
>         __le16 buf;
>         int tmp;
>
> -       tmp = pm_runtime_get_sync(regmap_get_device(data->regmap));
> -       if (tmp < 0) {
> -               pm_runtime_put_noidle(regmap_get_device(data->regmap));
> +       tmp = pm_runtime_resume_and_get(regmap_get_device(data->regmap));
> +       if (tmp < 0)
>                 return tmp;
> -       }
>
>         tmp = regmap_bulk_read(data->regmap, AMG88XX_REG_TTHL, &buf, 2);
>         pm_runtime_mark_last_busy(regmap_get_device(data->regmap));
> @@ -512,11 +510,9 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
>         if (data->kthread_vid_cap)
>                 return 0;
>
> -       ret = pm_runtime_get_sync(dev);
> -       if (ret < 0) {
> -               pm_runtime_put_noidle(dev);
> +       ret = pm_runtime_resume_and_get(dev);
> +       if (ret < 0)
>                 goto error_del_list;
> -       }
>
>         ret = data->chip->setup(data);
>         if (ret)
> --
> 2.30.2
>

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2021-05-07 21:26 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06 15:22 [PATCH v5 00/30] media: i2c: use pm_runtime_resume_and_get() were possible Mauro Carvalho Chehab
2021-05-06 15:22 ` [PATCH v5 01/30] media: i2c: ak7375: use pm_runtime_resume_and_get() Mauro Carvalho Chehab
2021-05-06 15:22 ` [PATCH v5 02/30] media: i2c: dw9714: " Mauro Carvalho Chehab
2021-05-06 15:22 ` [PATCH v5 03/30] media: i2c: dw9768: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 04/30] media: i2c: dw9807-vcm: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 05/30] media: i2c: hi556: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 06/30] media: i2c: imx214: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 07/30] media: i2c: imx219: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 08/30] media: i2c: imx258: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 09/30] media: i2c: imx274: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 10/30] media: i2c: imx290: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 11/30] media: i2c: imx319: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 12/30] media: i2c: imx355: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 13/30] media: i2c: mt9m001: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 14/30] media: i2c: ov02a10: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 15/30] media: i2c: ov13858: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 16/30] media: i2c: ov2659: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 17/30] media: i2c: ov2685: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 18/30] media: i2c: ov2740: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 19/30] media: i2c: ov5647: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 20/30] media: i2c: ov5648: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 21/30] media: i2c: ov5670: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 22/30] media: i2c: ov5675: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 23/30] media: i2c: ov5695: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 24/30] media: i2c: ov7740: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 25/30] media: i2c: ov8856: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 26/30] media: i2c: ov8865: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 27/30] media: i2c: ov9734: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 28/30] media: i2c: tvp5150: " Mauro Carvalho Chehab
2021-05-06 15:23 ` [PATCH v5 29/30] media: i2c: video-i2c: " Mauro Carvalho Chehab
2021-05-07 21:26   ` Matt Ranostay
2021-05-06 15:23 ` [PATCH v5 30/30] media: i2c: ccs-core: " Mauro Carvalho Chehab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).