clocksource: timer-ti-dm: Hook device platform data if not already assigned
authorLadislav Michl <ladis@linux-mips.org>
Thu, 15 Feb 2018 06:01:49 +0000 (11:31 +0530)
committerTony Lindgren <tony@atomide.com>
Thu, 22 Feb 2018 18:54:14 +0000 (10:54 -0800)
In the case of device tree boot the device platform data is usually
NULL so hook the platform data obtained from the match.
As part of un-constify the platform_data pointer.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Keerthy <j-keerthy@ti.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Tony Lindgren <tony@atomide.com>
drivers/clocksource/timer-ti-dm.c

index 4496172b29278d089d329281b55f66f8739e1532..70782a41c493319a9c6c224312bc3458cd03e828 100644 (file)
@@ -806,14 +806,16 @@ static int omap_dm_timer_probe(struct platform_device *pdev)
        struct omap_dm_timer *timer;
        struct resource *mem, *irq;
        struct device *dev = &pdev->dev;
-       const struct of_device_id *match;
        const struct dmtimer_platform_data *pdata;
        int ret;
 
-       match = of_match_device(of_match_ptr(omap_timer_match), dev);
-       pdata = match ? match->data : dev->platform_data;
+       pdata = of_device_get_match_data(dev);
+       if (!pdata)
+               pdata = dev_get_platdata(dev);
+       else
+               dev->platform_data = (void *)pdata;
 
-       if (!pdata && !dev->of_node) {
+       if (!pdata) {
                dev_err(dev, "%s: no platform data.\n", __func__);
                return -ENODEV;
        }