Browse Source

[media] omap3isp: Fix division by 0

If the requested clock rate passed to the XCLK set_rate or round_rate
operation is 0, the driver will try to divide by 0. Fix this.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Laurent Pinchart 11 years ago
parent
commit
aadec012ea
1 changed files with 3 additions and 0 deletions
  1. 3 0
      drivers/media/platform/omap3isp/isp.c

+ 3 - 0
drivers/media/platform/omap3isp/isp.c

@@ -220,6 +220,9 @@ static u32 isp_xclk_calc_divider(unsigned long *rate, unsigned long parent_rate)
 		return ISPTCTRL_CTRL_DIV_BYPASS;
 		return ISPTCTRL_CTRL_DIV_BYPASS;
 	}
 	}
 
 
+	if (*rate == 0)
+		*rate = 1;
+
 	divider = DIV_ROUND_CLOSEST(parent_rate, *rate);
 	divider = DIV_ROUND_CLOSEST(parent_rate, *rate);
 	if (divider >= ISPTCTRL_CTRL_DIV_BYPASS)
 	if (divider >= ISPTCTRL_CTRL_DIV_BYPASS)
 		divider = ISPTCTRL_CTRL_DIV_BYPASS - 1;
 		divider = ISPTCTRL_CTRL_DIV_BYPASS - 1;