@@ -2512,7 +2512,7 @@ static int imx500_start_streaming(struct imx500 *imx500)
25122512 if (ret ) {
25132513 dev_err (& client -> dev , "%s failed to set image mode\n" ,
25142514 __func__ );
2515- return ret ;
2515+ goto err_runtime_put ;
25162516 }
25172517
25182518 /* Acquire loader and main firmware if needed */
@@ -2524,7 +2524,7 @@ static int imx500_start_streaming(struct imx500 *imx500)
25242524 if (ret ) {
25252525 dev_err (& client -> dev ,
25262526 "Unable to acquire firmware loader\n" );
2527- return ret ;
2527+ goto err_runtime_put ;
25282528 }
25292529 }
25302530 if (!imx500 -> fw_main ) {
@@ -2534,7 +2534,7 @@ static int imx500_start_streaming(struct imx500 *imx500)
25342534 if (ret ) {
25352535 dev_err (& client -> dev ,
25362536 "Unable to acquire main firmware\n" );
2537- return ret ;
2537+ goto err_runtime_put ;
25382538 }
25392539 }
25402540 }
@@ -2546,7 +2546,7 @@ static int imx500_start_streaming(struct imx500 *imx500)
25462546 if (ret ) {
25472547 dev_err (& client -> dev ,
25482548 "%s failed to set common settings\n" , __func__ );
2549- return ret ;
2549+ goto err_runtime_put ;
25502550 }
25512551
25522552 imx500 -> common_regs_written = true;
@@ -2558,7 +2558,7 @@ static int imx500_start_streaming(struct imx500 *imx500)
25582558 dev_err (& client -> dev ,
25592559 "%s failed to transition from program empty state\n" ,
25602560 __func__ );
2561- return ret ;
2561+ goto err_runtime_put ;
25622562 }
25632563 imx500 -> loader_and_main_written = true;
25642564 }
@@ -2569,7 +2569,7 @@ static int imx500_start_streaming(struct imx500 *imx500)
25692569 dev_err (& client -> dev ,
25702570 "%s failed to transition to network loaded\n" ,
25712571 __func__ );
2572- return ret ;
2572+ goto err_runtime_put ;
25732573 }
25742574 imx500 -> network_written = true;
25752575 }
@@ -2580,7 +2580,7 @@ static int imx500_start_streaming(struct imx500 *imx500)
25802580 if (ret ) {
25812581 dev_err (& client -> dev , "%s failed to enable DNN\n" ,
25822582 __func__ );
2583- return ret ;
2583+ goto err_runtime_put ;
25842584 }
25852585 }
25862586
@@ -2590,7 +2590,7 @@ static int imx500_start_streaming(struct imx500 *imx500)
25902590 reg_list -> num_of_regs , NULL );
25912591 if (ret ) {
25922592 dev_err (& client -> dev , "%s failed to set mode\n" , __func__ );
2593- return ret ;
2593+ goto err_runtime_put ;
25942594 }
25952595
25962596 /* Apply customized values from user */
@@ -2603,6 +2603,14 @@ static int imx500_start_streaming(struct imx500 *imx500)
26032603 cci_write (imx500 -> regmap , IMX500_REG_MODE_SELECT , IMX500_MODE_STREAMING ,
26042604 & ret );
26052605
2606+ if (ret )
2607+ goto err_runtime_put ;
2608+
2609+ return 0 ;
2610+
2611+ err_runtime_put :
2612+ pm_runtime_mark_last_busy (& client -> dev );
2613+ pm_runtime_put_autosuspend (& client -> dev );
26062614 return ret ;
26072615}
26082616
0 commit comments