From: Bin Meng Date: Tue, 23 Jun 2020 05:29:42 +0000 (-0700) Subject: sysreset: syscon: Don't assume default value for offset and mask property X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=1ce8182b0f7254d0d01e309341c35bbc1b8c10e4;p=u-boot.git sysreset: syscon: Don't assume default value for offset and mask property Per the DT binding, is a required property. Let's abort the probe if it is missing. For the property, current codes assume a default value of zero, which is not correct either. Signed-off-by: Bin Meng Reviewed-by: Simon Glass Reviewed-by: Pragnesh Patel --- diff --git a/drivers/sysreset/sysreset_syscon.c b/drivers/sysreset/sysreset_syscon.c index f64701aab3..caf24823cc 100644 --- a/drivers/sysreset/sysreset_syscon.c +++ b/drivers/sysreset/sysreset_syscon.c @@ -41,6 +41,7 @@ static struct sysreset_ops syscon_reboot_ops = { int syscon_reboot_probe(struct udevice *dev) { struct syscon_reboot_priv *priv = dev_get_priv(dev); + int err; priv->regmap = syscon_regmap_lookup_by_phandle(dev, "regmap"); if (IS_ERR(priv->regmap)) { @@ -48,8 +49,17 @@ int syscon_reboot_probe(struct udevice *dev) return -ENODEV; } - priv->offset = dev_read_u32_default(dev, "offset", 0); - priv->mask = dev_read_u32_default(dev, "mask", 0); + err = dev_read_u32(dev, "offset", &priv->offset); + if (err) { + pr_err("unable to find offset\n"); + return -ENOENT; + } + + err = dev_read_u32(dev, "mask", &priv->mask); + if (err) { + pr_err("unable to find mask\n"); + return -ENOENT; + } return 0; }