Skip to content

Commit 650fc12

Browse files
roliver-rpipelwell
authored andcommitted
media: i2c: imx500: pm_runtime error paths
This change amends various error-paths in imx500_start_streaming() to ensure that pm_runtime refcounts do not remain erroneously incremented on failure. Signed-off-by: Richard Oliver <richard.oliver@raspberrypi.com>
1 parent e6241fd commit 650fc12

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

drivers/media/i2c/imx500.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2572,7 +2572,7 @@ static int imx500_start_streaming(struct imx500 *imx500)
25722572
if (ret) {
25732573
dev_err(&client->dev, "%s failed to set image mode\n",
25742574
__func__);
2575-
return ret;
2575+
goto err_runtime_put;
25762576
}
25772577

25782578
/* Acquire loader and main firmware if needed */
@@ -2584,7 +2584,7 @@ static int imx500_start_streaming(struct imx500 *imx500)
25842584
if (ret) {
25852585
dev_err(&client->dev,
25862586
"Unable to acquire firmware loader\n");
2587-
return ret;
2587+
goto err_runtime_put;
25882588
}
25892589
}
25902590
if (!imx500->fw_main) {
@@ -2594,7 +2594,7 @@ static int imx500_start_streaming(struct imx500 *imx500)
25942594
if (ret) {
25952595
dev_err(&client->dev,
25962596
"Unable to acquire main firmware\n");
2597-
return ret;
2597+
goto err_runtime_put;
25982598
}
25992599
}
26002600
}
@@ -2606,7 +2606,7 @@ static int imx500_start_streaming(struct imx500 *imx500)
26062606
if (ret) {
26072607
dev_err(&client->dev,
26082608
"%s failed to set common settings\n", __func__);
2609-
return ret;
2609+
goto err_runtime_put;
26102610
}
26112611

26122612
imx500->common_regs_written = true;
@@ -2618,7 +2618,7 @@ static int imx500_start_streaming(struct imx500 *imx500)
26182618
dev_err(&client->dev,
26192619
"%s failed to transition from program empty state\n",
26202620
__func__);
2621-
return ret;
2621+
goto err_runtime_put;
26222622
}
26232623
imx500->loader_and_main_written = true;
26242624
}
@@ -2629,7 +2629,7 @@ static int imx500_start_streaming(struct imx500 *imx500)
26292629
dev_err(&client->dev,
26302630
"%s failed to transition to network loaded\n",
26312631
__func__);
2632-
return ret;
2632+
goto err_runtime_put;
26332633
}
26342634
imx500->network_written = true;
26352635
}
@@ -2640,7 +2640,7 @@ static int imx500_start_streaming(struct imx500 *imx500)
26402640
if (ret) {
26412641
dev_err(&client->dev, "%s failed to enable DNN\n",
26422642
__func__);
2643-
return ret;
2643+
goto err_runtime_put;
26442644
}
26452645

26462646
v4l2_ctrl_activate(imx500->device_id, true);
@@ -2652,7 +2652,7 @@ static int imx500_start_streaming(struct imx500 *imx500)
26522652
reg_list->num_of_regs, NULL);
26532653
if (ret) {
26542654
dev_err(&client->dev, "%s failed to set mode\n", __func__);
2655-
return ret;
2655+
goto err_runtime_put;
26562656
}
26572657

26582658
/* Apply customized values from user */
@@ -2668,6 +2668,14 @@ static int imx500_start_streaming(struct imx500 *imx500)
26682668
cci_write(imx500->regmap, IMX500_REG_MODE_SELECT, IMX500_MODE_STREAMING,
26692669
&ret);
26702670

2671+
if (ret)
2672+
goto err_runtime_put;
2673+
2674+
return 0;
2675+
2676+
err_runtime_put:
2677+
pm_runtime_mark_last_busy(&client->dev);
2678+
pm_runtime_put_autosuspend(&client->dev);
26712679
return ret;
26722680
}
26732681

0 commit comments

Comments
 (0)