Merge tag 'u-boot-rockchip-20200531' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / drivers / timer / timer-uclass.c
index 45397b230f03c25ac3a39ede454a4a361bbf42e4..14dde950a1834ccf9d22cf2a2ee1e5c0a4ca7c29 100644 (file)
@@ -1,17 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2015 Thomas Chou <thomas@wytron.com.tw>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <dm.h>
+#include <init.h>
 #include <dm/lists.h>
 #include <dm/device-internal.h>
 #include <dm/root.h>
 #include <clk.h>
 #include <errno.h>
 #include <timer.h>
+#include <linux/err.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -49,6 +50,10 @@ static int timer_pre_probe(struct udevice *dev)
        int err;
        ulong ret;
 
+       /* It is possible that a timer device has a null ofnode */
+       if (!dev_of_valid(dev))
+               return 0;
+
        err = clk_get_by_index(dev, 0, &timer_clk);
        if (!err) {
                ret = clk_get_rate(&timer_clk);
@@ -109,7 +114,7 @@ int notrace dm_timer_init(void)
                 * If the timer is not marked to be bound before
                 * relocation, bind it anyway.
                 */
-               if (!lists_bind_fdt(dm_root(), node, &dev)) {
+               if (!lists_bind_fdt(dm_root(), node, &dev, false)) {
                        ret = device_probe(dev);
                        if (ret)
                                return ret;