Message ID | 1592890186-18082-1-git-send-email-bmeng.cn@gmail.com |
---|---|
State | New |
Headers | show |
Series | [1/5] sysreset: syscon: Don't assume default value for offset and mask property | expand |
On Mon, 22 Jun 2020 at 23:30, Bin Meng <bmeng.cn at gmail.com> wrote: > > From: Bin Meng <bin.meng at windriver.com> > > Per the DT binding, <offset> is a required property. Let's abort > the probe if it is missing. For the <mask> property, current codes > assume a default value of zero, which is not correct either. > > Signed-off-by: Bin Meng <bin.meng at windriver.com> > --- > > drivers/sysreset/sysreset_syscon.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > Reviewed-by: Simon Glass <sjg at chromium.org>
>-----Original Message----- >From: Bin Meng <bmeng.cn at gmail.com> >Sent: 23 June 2020 11:00 >To: Rick Chen <rick at andestech.com>; Simon Glass <sjg at chromium.org>; >Pragnesh Patel <pragnesh.patel at sifive.com>; Sagar Kadam ><sagar.kadam at sifive.com>; U-Boot Mailing List <u-boot at lists.denx.de> >Cc: Bin Meng <bin.meng at windriver.com> >Subject: [PATCH 1/5] sysreset: syscon: Don't assume default value for offset >and mask property > >[External Email] Do not click links or attachments unless you recognize the >sender and know the content is safe > >From: Bin Meng <bin.meng at windriver.com> > >Per the DT binding, <offset> is a required property. Let's abort the probe if it is >missing. For the <mask> property, current codes assume a default value of >zero, which is not correct either. > >Signed-off-by: Bin Meng <bin.meng at windriver.com> >--- > > drivers/sysreset/sysreset_syscon.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) Reviewed-by: Pragnesh Patel <pragnesh.patel at sifive.com>
diff --git a/drivers/sysreset/sysreset_syscon.c b/drivers/sysreset/sysreset_syscon.c index f64701a..caf2482 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; }