Skip to contentSkip to conversation

cadence: csi2rx: Fix csi2rx_start error handling

PATCH In review Sakari Ailus 2 participants 2 messages May 9, 2018 – May 11, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cadence: csi2rx: Fix csi2rx_start error handling

The clocks enabled by csi2rx_start function are intended to be disabled in an error path but there are two issues:

1) the loop condition is always true and

2) the first clock disabled is the the one enabling of which failed.

Fix these two bugs by changing the loop condition as well as only disabling the clocks that were actually enabled.

---
Hi Mauro, Maxime,

Let me know if you're happy with this. It's intended to fix the following warnings (C=1 W=1):

drivers/media/platform/cadence/cdns-csi2rx.c: In function ‘csi2rx_start’:
drivers/media/platform/cadence/cdns-csi2rx.c:177:11: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

 drivers/media/platform/cadence/cdns-csi2rx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/cadence/cdns-csi2rx.c +2 -2
index fe612ec1f99f..a0f02916006b 100644
@@ -174,8 +174,8 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
 	return 0;
 
 err_disable_pixclk:
-	for (; i >= 0; i--)
-		clk_disable_unprepare(csi2rx->pixel_clk[i]);
+	for (; i > 0; i--)
+		clk_disable_unprepare(csi2rx->pixel_clk[i - 1]);
 
 err_disable_pclk:
 	clk_disable_unprepare(csi2rx->p_clk);
Signature · 1 line
2.11.0
#1 lore raw
Quoted 15 lines · Sakari Ailus

The clocks enabled by csi2rx_start function are intended to be disabled in an error path but there are two issues:

1) the loop condition is always true and

2) the first clock disabled is the the one enabling of which failed.

Fix these two bugs by changing the loop condition as well as only disabling the clocks that were actually enabled.

---
Hi Mauro, Maxime,

Quoted 8 lines

Let me know if you're happy with this. It's intended to fix the following warnings (C=1 W=1):

drivers/media/platform/cadence/cdns-csi2rx.c: In function ‘csi2rx_start’:
drivers/media/platform/cadence/cdns-csi2rx.c:177:11: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

 drivers/media/platform/cadence/cdns-csi2rx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

That works for me :)

Feel free to add my Acked-by: Maxime Ripard <[email protected]>

Thanks!
Maxime

Signature · 3 lines
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com