]> git.sur5r.net Git - u-boot/commitdiff
dm: core: Add device checking to syscon_get_regmap()
authorSimon Glass <sjg@chromium.org>
Mon, 6 Jul 2015 18:54:38 +0000 (12:54 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 21 Jul 2015 23:39:33 +0000 (17:39 -0600)
This function can only handle a syscon device. It is possible that someone
will make a mistake, so add a check for this.

Also we should return -ENODEV when a device cannot be found, so update the
syscon_get_regmap_by_driver_data() to follow this convention.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/core/syscon-uclass.c

index 4d66bb5d50631942a7c3a80e01c19f466a8397c9..686c32056ec6e38cb26b2a355471331b26d97382 100644 (file)
 
 struct regmap *syscon_get_regmap(struct udevice *dev)
 {
-       struct syscon_uc_info *priv = dev_get_uclass_priv(dev);
+       struct syscon_uc_info *priv;
 
+       if (device_get_uclass_id(dev) != UCLASS_SYSCON)
+               return ERR_PTR(-ENOEXEC);
+       priv = dev_get_uclass_priv(dev);
        return priv->regmap;
 }
 
@@ -52,7 +55,7 @@ struct regmap *syscon_get_regmap_by_driver_data(ulong driver_data)
                }
        }
 
-       return ERR_PTR(-ENOENT);
+       return ERR_PTR(-ENODEV);
 }
 
 void *syscon_get_first_range(ulong driver_data)