[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230612210826.gmgrwjyu2g7jrysh@intel.intel>
Date: Mon, 12 Jun 2023 23:08:26 +0200
From: Andi Shyti <andi.shyti@...nel.org>
To: Rob Herring <robh@...nel.org>
Cc: Chris Packham <chris.packham@...iedtelesis.co.nz>,
linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] i2c: mpc: Use of_property_read_reg() to parse "reg"
Hi Rob,
On Mon, Jun 12, 2023 at 01:27:03PM -0600, Rob Herring wrote:
> On Sat, Jun 10, 2023 at 3:36 AM Andi Shyti <andi.shyti@...nel.org> wrote:
> >
> > Hi Rob,
> >
> > On Fri, Jun 09, 2023 at 12:30:44PM -0600, Rob Herring wrote:
> > > Use the recently added of_property_read_reg() helper to get the
> > > untranslated "reg" address value.
> > >
> > > Signed-off-by: Rob Herring <robh@...nel.org>
> > > ---
> > > drivers/i2c/busses/i2c-mpc.c | 5 +++--
> > > 1 file changed, 3 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> > > index cfd074ee6d54..595dce9218ad 100644
> > > --- a/drivers/i2c/busses/i2c-mpc.c
> > > +++ b/drivers/i2c/busses/i2c-mpc.c
> > > @@ -316,9 +316,10 @@ static void mpc_i2c_setup_512x(struct device_node *node,
> > > if (node_ctrl) {
> > > ctrl = of_iomap(node_ctrl, 0);
> > > if (ctrl) {
> > > + u64 addr;
> > > /* Interrupt enable bits for i2c-0/1/2: bit 24/26/28 */
> > > - pval = of_get_property(node, "reg", NULL);
> > > - idx = (*pval & 0xff) / 0x20;
> > > + of_property_read_reg(node, 0, &addr, NULL);
> >
> > because of_property_read_reg() can return error, can we check
> > also the error value here?
>
> Why?
Because if a function can return an error, the error must be
checked. Even if the property is "reg" and the binding says that
it's required. Otherwise let's make those functions void.
> The old code wasn't worried about of_get_property() returning
> NULL on the same possible errors.
Sure! Checking the error comes for free. The patch is fine as it
is, mine was a little improvement I asked for. I can still ack
it and add the error handling later myself :)
> If anyone is still actually using
> mpc512x, I don't think their DTB will have an error at this point.
> IOW, is improving the error handling on this really worth it?
In my view, every error needs to be checked as every error is
unlikely to happen: it makes the code future proof and makes sure
other components failure don't impact the normal functioning of
this driver.
Anyway, the patch is doing what you described and for the sole
economy of this change:
Acked-by: Andi Shyti <andi.shyti@...nel.org>
Thank you,
Andi
Powered by blists - more mailing lists