]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: core: Change syscon to use helper function
authorSimon Glass <sjg@chromium.org>
Thu, 6 Feb 2020 16:54:51 +0000 (09:54 -0700)
committerBin Meng <bmeng.cn@gmail.com>
Fri, 7 Feb 2020 14:41:24 +0000 (22:41 +0800)
Now that we have uclass_first_device_drvdata(), use it from syscon to
reduce code duplication.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
drivers/core/syscon-uclass.c

index 5bb38e329cb847c3201e5a5c0f925f3a99856364..b9ae82174ee357f1229d3933ee268e432e5f8ad0 100644 (file)
@@ -128,22 +128,15 @@ struct regmap *syscon_regmap_lookup_by_phandle(struct udevice *dev,
 
 int syscon_get_by_driver_data(ulong driver_data, struct udevice **devp)
 {
-       struct udevice *dev;
-       struct uclass *uc;
        int ret;
 
        *devp = NULL;
-       ret = uclass_get(UCLASS_SYSCON, &uc);
+
+       ret = uclass_first_device_drvdata(UCLASS_SYSCON, driver_data, devp);
        if (ret)
-               return ret;
-       uclass_foreach_dev(dev, uc) {
-               if (dev->driver_data == driver_data) {
-                       *devp = dev;
-                       return device_probe(dev);
-               }
-       }
+               return log_msg_ret("find", ret);
 
-       return -ENODEV;
+       return 0;
 }
 
 struct regmap *syscon_get_regmap_by_driver_data(ulong driver_data)