Re: [PATCH 05/11] watchdog: WatchDog Timer Driver Core - AddWDIOC_SETTIMEOUT and WDIOC_GETTIMEOUT ioctl

From: Wolfram Sang
Date: Mon Jul 11 2011 - 17:34:50 EST


> diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
> index 530003b..0d4b16d 100644
> --- a/drivers/watchdog/watchdog_dev.c
> +++ b/drivers/watchdog/watchdog_dev.c
> @@ -201,6 +201,26 @@ static long watchdog_ioctl(struct file *file, unsigned int cmd,
> return -EOPNOTSUPP;
> watchdog_ping(wdd);
> return 0;
> + case WDIOC_SETTIMEOUT:
> + if ((wdd->ops->set_timeout == NULL) ||
> + !(wdd->info->options & WDIOF_SETTIMEOUT))
> + return -EOPNOTSUPP;
> + if (get_user(val, p))
> + return -EFAULT;
> + err = wdd->ops->set_timeout(wdd, val);
> + if (err < 0)
> + return err;
> + wdd->timeout = val;
> + /* If the watchdog is active then we sent a keepalive ping

s/sent/send/

> + * to make sure that the watchdog keep's running (and if
> + * possible that it takes the new timeout) */
> + watchdog_ping(wdd);
> + /* Fall */
> + case WDIOC_GETTIMEOUT:
> + /* timeout == 0 means that we don't know the timeout */
> + if (wdd->timeout)
> + return put_user(wdd->timeout, p);
> + return -EOPNOTSUPP;

I'd suggest to swap the logic here (branch taken on error):

if (wdd->timeout == 0)
return -EOPNOTSUPP;
return put_user();

> default:
> return -ENOTTY;
> }

--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |

Attachment: signature.asc
Description: Digital signature