summaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2015-07-30 11:32:23 +0200
committerWim Van Sebroeck <wim@iguana.be>2015-09-09 21:35:14 +0200
commit0a0a542f6bbb2ebe956f0117c842302442ef52da (patch)
treefcce706c2c692ae597097ea3d56cf13c6a48122c /drivers/watchdog
parentab54d7f017772e89964d4040937a83cd4468562a (diff)
downloadop-kernel-dev-0a0a542f6bbb2ebe956f0117c842302442ef52da.zip
op-kernel-dev-0a0a542f6bbb2ebe956f0117c842302442ef52da.tar.gz
watchdog: gpio-wdt: be more strict about hw_algo matching
strncmp(algo, "toggle", 6) doesn't compare the trailing '\0' byte, so using hw_algo = "toggleboggle" is recognized the same way as hw_algo = "toggle" . While this doesn't introduce any problems for a device tree that sticks to the documented settings it's still ugly. Fix this by using strcmp to only match on "toggle" and "level". Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/gpio_wdt.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/watchdog/gpio_wdt.c b/drivers/watchdog/gpio_wdt.c
index 1687cc2..57d30f1 100644
--- a/drivers/watchdog/gpio_wdt.c
+++ b/drivers/watchdog/gpio_wdt.c
@@ -182,10 +182,10 @@ static int gpio_wdt_probe(struct platform_device *pdev)
ret = of_property_read_string(pdev->dev.of_node, "hw_algo", &algo);
if (ret)
return ret;
- if (!strncmp(algo, "toggle", 6)) {
+ if (!strcmp(algo, "toggle")) {
priv->hw_algo = HW_ALGO_TOGGLE;
f = GPIOF_IN;
- } else if (!strncmp(algo, "level", 5)) {
+ } else if (!strcmp(algo, "level")) {
priv->hw_algo = HW_ALGO_LEVEL;
f = priv->active_low ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW;
} else {
OpenPOWER on IntegriCloud