Commit e5310371 authored by Corentin Labbe's avatar Corentin Labbe Committed by Wim Van Sebroeck

watchdog: sunxi_wdt: use of_device_get_match_data

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: default avatarCorentin Labbe <clabbe.montjoie@gmail.com>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
parent b6c84c9f
...@@ -234,7 +234,6 @@ MODULE_DEVICE_TABLE(of, sunxi_wdt_dt_ids); ...@@ -234,7 +234,6 @@ MODULE_DEVICE_TABLE(of, sunxi_wdt_dt_ids);
static int sunxi_wdt_probe(struct platform_device *pdev) static int sunxi_wdt_probe(struct platform_device *pdev)
{ {
struct sunxi_wdt_dev *sunxi_wdt; struct sunxi_wdt_dev *sunxi_wdt;
const struct of_device_id *device;
struct resource *res; struct resource *res;
int err; int err;
...@@ -242,12 +241,10 @@ static int sunxi_wdt_probe(struct platform_device *pdev) ...@@ -242,12 +241,10 @@ static int sunxi_wdt_probe(struct platform_device *pdev)
if (!sunxi_wdt) if (!sunxi_wdt)
return -EINVAL; return -EINVAL;
device = of_match_device(sunxi_wdt_dt_ids, &pdev->dev); sunxi_wdt->wdt_regs = of_device_get_match_data(&pdev->dev);
if (!device) if (!sunxi_wdt->wdt_regs)
return -ENODEV; return -ENODEV;
sunxi_wdt->wdt_regs = device->data;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
sunxi_wdt->wdt_base = devm_ioremap_resource(&pdev->dev, res); sunxi_wdt->wdt_base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(sunxi_wdt->wdt_base)) if (IS_ERR(sunxi_wdt->wdt_base))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment