[PATCH] watchdog: imx: error out on negative timeouts

Sascha Hauer s.hauer at pengutronix.de
Mon Feb 2 03:04:32 PST 2015


On Mon, Feb 02, 2015 at 11:49:57AM +0100, Uwe Kleine-König wrote:
> Hello,
> 
> On Tue, Jan 27, 2015 at 02:41:01PM +0100, Uwe Kleine-König wrote:
> > I'm not sure where a negative timeout could come from but making the
> > code more robust for no additional runtime cost is good nevertheless.
> > 
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
> > ---
> >  drivers/watchdog/imxwd.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/watchdog/imxwd.c b/drivers/watchdog/imxwd.c
> > index 31c3d0d85353..66e9f6848f74 100644
> > --- a/drivers/watchdog/imxwd.c
> > +++ b/drivers/watchdog/imxwd.c
> > @@ -87,7 +87,7 @@ static int imx21_watchdog_set_timeout(struct imx_wd *priv, int timeout)
> >  
> >  	dev_dbg(priv->dev, "%s: %d\n", __func__, timeout);
> >  
> > -	if (!timeout || timeout > 128)
> > +	if (timeout <= 0 || timeout > 128)
> >  		return -EINVAL;
> This patch is broken because reset_cpu (in the same source file) calls
> set_timeout with timeout=-1 to reset the cpu immediatly. The wd command
> only parses non-negative values, so from there nothing strange should be
> expected.
> 
> Returning -EINVAL on timeout=0 (which means "disable watchdog") is OK
> because the imx21 watchdog cannot be stopped.
> 
> So in short: please drop this patch from next.

Did that.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list