watchdog: sunxi_wdt: use of_device_get_match_data
authorCorentin Labbe <clabbe.montjoie@gmail.com>
Sat, 21 Oct 2017 17:45:13 +0000 (19:45 +0200)
committerWim Van Sebroeck <wim@iguana.be>
Thu, 28 Dec 2017 19:45:12 +0000 (20:45 +0100)
The usage of of_device_get_match_data reduce the code size a bit.
Furthermore, it prevents an improbable dereference when
of_match_device() return NULL.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
drivers/watchdog/sunxi_wdt.c

index 9728fa32c357b88f5cab03300c96aeaf9f6f1968..802e31b1416d5a11e84eefc2c614ecd58b27a295 100644 (file)
@@ -234,7 +234,6 @@ MODULE_DEVICE_TABLE(of, sunxi_wdt_dt_ids);
 static int sunxi_wdt_probe(struct platform_device *pdev)
 {
        struct sunxi_wdt_dev *sunxi_wdt;
-       const struct of_device_id *device;
        struct resource *res;
        int err;
 
@@ -242,12 +241,10 @@ static int sunxi_wdt_probe(struct platform_device *pdev)
        if (!sunxi_wdt)
                return -EINVAL;
 
-       device = of_match_device(sunxi_wdt_dt_ids, &pdev->dev);
-       if (!device)
+       sunxi_wdt->wdt_regs = of_device_get_match_data(&pdev->dev);
+       if (!sunxi_wdt->wdt_regs)
                return -ENODEV;
 
-       sunxi_wdt->wdt_regs = device->data;
-
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        sunxi_wdt->wdt_base = devm_ioremap_resource(&pdev->dev, res);
        if (IS_ERR(sunxi_wdt->wdt_base))