[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZsxbDK25mJ0sjcQy@smile.fi.intel.com>
Date: Mon, 26 Aug 2024 13:38:04 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Ryan Chen <ryan_chen@...eedtech.com>
Cc: "brendan.higgins@...ux.dev" <brendan.higgins@...ux.dev>,
"benh@...nel.crashing.org" <benh@...nel.crashing.org>,
"joel@....id.au" <joel@....id.au>,
"andi.shyti@...nel.org" <andi.shyti@...nel.org>,
"robh@...nel.org" <robh@...nel.org>,
"krzk+dt@...nel.org" <krzk+dt@...nel.org>,
"conor+dt@...nel.org" <conor+dt@...nel.org>,
"andrew@...econstruct.com.au" <andrew@...econstruct.com.au>,
"p.zabel@...gutronix.de" <p.zabel@...gutronix.de>,
"linux-i2c@...r.kernel.org" <linux-i2c@...r.kernel.org>,
"openbmc@...ts.ozlabs.org" <openbmc@...ts.ozlabs.org>,
"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
"linux-arm-kernel@...ts.infradead.org" <linux-arm-kernel@...ts.infradead.org>,
"linux-aspeed@...ts.ozlabs.org" <linux-aspeed@...ts.ozlabs.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v13 2/3] i2c: aspeed: support AST2600 i2c new register
mode driver
On Mon, Aug 26, 2024 at 07:50:24AM +0000, Ryan Chen wrote:
> > On Fri, Aug 23, 2024 at 06:23:54AM +0000, Ryan Chen wrote:
> > > > On Thu, Aug 22, 2024 at 02:24:26AM +0000, Ryan Chen wrote:
> > > > > > On Wed, Aug 21, 2024 at 06:43:01AM +0000, Ryan Chen wrote:
> > > > > > > > On Mon, Aug 19, 2024 at 05:28:49PM +0800, Ryan Chen wrote:
...
> > > > > > > > > + if (i2c_bus->mode == BUFF_MODE) {
> > > > > > > > > + i2c_bus->buf_base =
> > > > > > > > devm_platform_get_and_ioremap_resource(pdev, 1, &res);
> > > > > > > > > + if (!IS_ERR_OR_NULL(i2c_bus->buf_base))
> > > > > > > > > + i2c_bus->buf_size = resource_size(res) / 2;
> > > > > > > > > + else
> > > > > > > > > + i2c_bus->mode = BYTE_MODE;
> > > > > > > >
> > > > > > > > What's wrong with positive conditional? And is it even
> > > > > > > > possible to have NULL here?
> > > > > > > >
> > > > > > > Yes, if dtsi fill not following yaml example have reg 1, that
> > > > > > > will failure at buffer
> > > > > > mode.
> > > > > > > And I can swith to byte mode.
> > > > > > >
> > > > > > > reg = <0x80 0x80>, <0xc00 0x20>;
> > > > > >
> > > > > > I was asking about if (!IS_ERR_OR_NULL(...)) line:
> > > > > > 1) Why 'if (!foo) {} else {}' instead of 'if (foo) {} else {}'?
> > > > > I will update to following.
> > > > > if (IS_ERR(i2c_bus->buf_base))
> > > > > i2c_bus->mode = BYTE_MODE;
> > > > > else
> > > > > i2c_bus->buf_size = resource_size(res) / 2;
> > > > >
> > > > > > 2) Why _NULL?
> > > > > If dtsi file is claim only 1 reg offset. reg = <0x80 0x80>; that
> > > > > will goto byte
> > > > mode.
> > > > > reg = <0x80 0x80>, <0xc00 0x20>; can support buffer mode.
> > > > > due to 2nd is buffer register offset.
> > > >
> > > > I have asked why IS_ERR_OR_NULL() and not IS_ERR().
> > > >
> > > OH, I will doing by this.
> > > if (IS_ERR_OR_NULL(i2c_bus->buf_base))
> >
> > The question about _NULL remains unanswered...
> Sorry, I may not catch your point.
> So, Do you mean I should passive coding by following?
No. I already mentioned that in one of the previous mails.
Why do you use IS_ERR_OR_NULL() and not IS_ERR()?
You should understand your code better than me :-)
> If (i2c_bus->buf_base > 0)
> i2c_bus->buf_size = resource_size(res) / 2;
> else
> i2c_bus->mode = BYTE_MODE;
>
> > > i2c_bus->mode = BYTE_MODE;
> > > else
> > > i2c_bus->buf_size = resource_size(res) / 2;
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists