diff mbox series

[v5,29/30] media: i2c: video-i2c: use pm_runtime_resume_and_get()

Message ID f6efc87d96826e3d2067b874e034b5edf73bb593.1620314098.git.mchehab+huawei@kernel.org
State Accepted
Commit a959a7bf3b939494adca95b1c53e98b74fd90702
Headers show
Series media: i2c: use pm_runtime_resume_and_get() were possible | expand

Commit Message

Mauro Carvalho Chehab May 6, 2021, 3:23 p.m. UTC
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(-)

Comments

Matt Ranostay May 7, 2021, 9:26 p.m. UTC | #1
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

>
diff mbox series

Patch

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)