]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
watchdog: gpio_wdt: Make use of device properties
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 25 Sep 2023 12:35:43 +0000 (15:35 +0300)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Sun, 29 Oct 2023 18:45:05 +0000 (19:45 +0100)
Convert the module to be property provider agnostic and allow
it to be used on non-OF platforms.

Include mod_devicetable.h explicitly to replace the dropped of.h
which included mod_devicetable.h indirectly.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20230925123543.2945710-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
drivers/watchdog/gpio_wdt.c

index 0923201ce8743af366bff7462c37bba9dff645da..a7b814ea740bb237020867673cbb5b904615f3cd 100644 (file)
@@ -5,12 +5,13 @@
  * Author: 2013, Alexander Shiyan <shc_work@mail.ru>
  */
 
-#include <linux/err.h>
 #include <linux/delay.h>
-#include <linux/module.h>
+#include <linux/err.h>
 #include <linux/gpio/consumer.h>
-#include <linux/of.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/watchdog.h>
 
 static bool nowayout = WATCHDOG_NOWAYOUT;
@@ -106,7 +107,6 @@ static const struct watchdog_ops gpio_wdt_ops = {
 static int gpio_wdt_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
-       struct device_node *np = dev->of_node;
        struct gpio_wdt_priv *priv;
        enum gpiod_flags gflags;
        unsigned int hw_margin;
@@ -119,7 +119,7 @@ static int gpio_wdt_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, priv);
 
-       ret = of_property_read_string(np, "hw_algo", &algo);
+       ret = device_property_read_string(dev, "hw_algo", &algo);
        if (ret)
                return ret;
        if (!strcmp(algo, "toggle")) {
@@ -136,16 +136,14 @@ static int gpio_wdt_probe(struct platform_device *pdev)
        if (IS_ERR(priv->gpiod))
                return PTR_ERR(priv->gpiod);
 
-       ret = of_property_read_u32(np,
-                                  "hw_margin_ms", &hw_margin);
+       ret = device_property_read_u32(dev, "hw_margin_ms", &hw_margin);
        if (ret)
                return ret;
        /* Disallow values lower than 2 and higher than 65535 ms */
        if (hw_margin < 2 || hw_margin > 65535)
                return -EINVAL;
 
-       priv->always_running = of_property_read_bool(np,
-                                                    "always-running");
+       priv->always_running = device_property_read_bool(dev, "always-running");
 
        watchdog_set_drvdata(&priv->wdd, priv);