From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fabio Porcedda Subject: [PATCH v9 2/8] watchdog: core: fix watchdog_check_min_max_timeout() return value Date: Thu, 14 Feb 2013 09:14:24 +0100 Message-ID: <1360829670-10418-3-git-send-email-fabio.porcedda@gmail.com> References: <1360829670-10418-1-git-send-email-fabio.porcedda@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1360829670-10418-1-git-send-email-fabio.porcedda-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: devicetree-discuss-bounces+gldd-devicetree-discuss=m.gmane.org-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org Sender: "devicetree-discuss" To: Wim Van Sebroeck , linux-watchdog-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, Nicolas Ferre , Jean-Christophe PLAGNIOL-VILLARD , Andrew Victor , Jason Cooper , Andrew Lunn , Ben Dooks , Kukjin Kim Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org, Wenyou Yang List-Id: devicetree@vger.kernel.org The device tree support is not mandatory, so the function doesn't return error when is not used. Return -EINVAL when the module parameter or timeout-sec property is out of bounds. Signed-off-by: Fabio Porcedda Cc: Wim Van Sebroeck Cc: linux-watchdog-u79uwXL29TY76Z2rM5mHXA@public.gmane.org --- drivers/watchdog/watchdog_core.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c index 94590f6..05d18b4 100644 --- a/drivers/watchdog/watchdog_core.c +++ b/drivers/watchdog/watchdog_core.c @@ -73,22 +73,28 @@ int watchdog_init_timeout(struct watchdog_device *wdd, unsigned int timeout_parm, struct device *dev) { unsigned int t = 0; + int ret = 0; watchdog_check_min_max_timeout(wdd); /* try to get the tiemout module parameter first */ if (!watchdog_timeout_invalid(wdd, timeout_parm)) { wdd->timeout = timeout_parm; - return 0; + return ret; } + if (timeout_parm) + ret = -EINVAL; /* try to get the timeout_sec property */ if (dev == NULL || dev->of_node == NULL) - return -EINVAL; + return ret; of_property_read_u32(dev->of_node, "timeout-sec", &t); if (!watchdog_timeout_invalid(wdd, t)) wdd->timeout = t; - return 0; + else + ret = -EINVAL; + + return ret; } EXPORT_SYMBOL_GPL(watchdog_init_timeout); -- 1.8.1.1