media: i2c: use pm_runtime_resume_and_get() were possible
Subsystems (29)
v5 cover media: i2c: use pm_runtime_resume_and_get() were possible
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/[email protected]/
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(-)
Signature · 1 line
2.30.2
PATCH v5 1/30 media: i2c: ak7375: use pm_runtime_resume_and_get()
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.
--- drivers/media/i2c/ak7375.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/media/i2c/ak7375.c +1 -9
@@ -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)
Signature · 1 line
2.30.2
PATCH v5 2/30 media: i2c: dw9714: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/dw9714.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/media/i2c/dw9714.c +1 -9
@@ -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)
Signature · 1 line
2.30.2
PATCH v5 3/30 media: i2c: dw9768: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/dw9768.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/media/i2c/dw9768.c +1 -9
@@ -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)
Signature · 1 line
2.30.2
PATCH v5 4/30 media: i2c: dw9807-vcm: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/dw9807-vcm.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/media/i2c/dw9807-vcm.c +1 -9
@@ -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)
Signature · 1 line
2.30.2
PATCH v5 5/30 media: i2c: hi556: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/hi556.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/i2c/hi556.c +1 -2
@@ -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; }
Signature · 1 line
2.30.2
PATCH v5 6/30 media: i2c: imx214: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/imx214.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/i2c/imx214.c +2 -4
@@ -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 )
Signature · 1 line
2.30.2
PATCH v5 7/30 media: i2c: imx219: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/imx219.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/i2c/imx219.c +2 -4
@@ -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;
Signature · 1 line
2.30.2
PATCH v5 8/30 media: i2c: imx258: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/imx258.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/i2c/imx258.c +2 -4
@@ -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
Signature · 1 line
2.30.2
PATCH v5 9/30 media: i2c: imx274: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/imx274.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/i2c/imx274.c +1 -2
@@ -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; }
Signature · 1 line
2.30.2
PATCH v5 10/30 media: i2c: imx290: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/imx290.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/i2c/imx290.c +2 -4
@@ -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) {
Signature · 1 line
2.30.2
PATCH v5 11/30 media: i2c: imx319: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/imx319.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/i2c/imx319.c +2 -4
@@ -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
Signature · 1 line
2.30.2
PATCH v5 12/30 media: i2c: imx355: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/imx355.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/i2c/imx355.c +2 -4
@@ -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
Signature · 1 line
2.30.2
PATCH v5 13/30 media: i2c: mt9m001: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/mt9m001.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/media/i2c/mt9m001.c +7 -2
@@ -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);
Signature · 1 line
2.30.2
PATCH v5 14/30 media: i2c: ov02a10: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/ov02a10.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/i2c/ov02a10.c +2 -4
@@ -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) {
Signature · 1 line
2.30.2
PATCH v5 15/30 media: i2c: ov13858: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/ov13858.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/i2c/ov13858.c +2 -4
@@ -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
Signature · 1 line
2.30.2
PATCH v5 16/30 media: i2c: ov2659: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/ov2659.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/i2c/ov2659.c +2 -4
@@ -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)
Signature · 1 line
2.30.2
PATCH v5 17/30 media: i2c: ov2685: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/ov2685.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/media/i2c/ov2685.c +3 -4
@@ -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);
Signature · 1 line
2.30.2
PATCH v5 18/30 media: i2c: ov2740: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/ov2740.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/i2c/ov2740.c +2 -4
@@ -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; }
Signature · 1 line
2.30.2
PATCH v5 19/30 media: i2c: ov5647: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/ov5647.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/media/i2c/ov5647.c +5 -4
@@ -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;
Signature · 1 line
2.30.2
PATCH v5 20/30 media: i2c: ov5648: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/ov5648.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/i2c/ov5648.c +2 -4
@@ -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);
Signature · 1 line
2.30.2
PATCH v5 21/30 media: i2c: ov5670: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/ov5670.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/i2c/ov5670.c +2 -4
@@ -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)
Signature · 1 line
2.30.2
PATCH v5 22/30 media: i2c: ov5675: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/ov5675.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/i2c/ov5675.c +1 -2
@@ -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; }
Signature · 1 line
2.30.2
PATCH v5 23/30 media: i2c: ov5695: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/ov5695.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/i2c/ov5695.c +2 -4
@@ -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) {
Signature · 1 line
2.30.2
PATCH v5 24/30 media: i2c: ov7740: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/ov7740.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/i2c/ov7740.c +2 -4
@@ -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)
Signature · 1 line
2.30.2
PATCH v5 25/30 media: i2c: ov8856: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/ov8856.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/i2c/ov8856.c +1 -2
@@ -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; }
Signature · 1 line
2.30.2
PATCH v5 26/30 media: i2c: ov8865: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/ov8865.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/i2c/ov8865.c +2 -4
@@ -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);
Signature · 1 line
2.30.2
PATCH v5 27/30 media: i2c: ov9734: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/ov9734.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/i2c/ov9734.c +1 -2
@@ -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; }
Signature · 1 line
2.30.2
PATCH v5 28/30 media: i2c: tvp5150: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/tvp5150.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/media/i2c/tvp5150.c +3 -13
@@ -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)
Signature · 1 line
2.30.2
PATCH v5 29/30 media: i2c: video-i2c: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/video-i2c.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/media/i2c/video-i2c.c +4 -8
@@ -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)
Signature · 1 line
2.30.2
Re: [PATCH v5 29/30] media: i2c: video-i2c: use pm_runtime_resume_and_get()
Quoted 7 lines · Mauro Carvalho Chehab
Commit
dd8088d5a896("PM: runtime: Addpm_runtime_resume_and_getto deal with usage counter") addedpm_runtime_resume_and_get()in order to automatically handledev->power.usage_countdecrement on errors.Use the new API, in order to cleanup the error check logic.
Quoted 40 lines
Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/media/i2c/video-i2c.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)drivers/media/i2c/video-i2c.c +4
-9@@ -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
PATCH v5 30/30 media: i2c: ccs-core: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/i2c/ccs/ccs-core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/media/i2c/ccs/ccs-core.c +2 -5
@@ -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);
Signature · 1 line
2.30.2