From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Ivan Mikhaylov <i.mikhaylov@yadro.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
linux-iio <linux-iio@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
devicetree <devicetree@vger.kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Rob Herring <robh+dt@kernel.org>
Subject: Re: [PATCH v5 2/2] iio: proximity: Add driver support for vcnl3020 proximity sensor
Date: Tue, 31 Mar 2020 14:00:55 +0300 [thread overview]
Message-ID: <CAHp75VexS-iVeDXsCFqgzCKokgzzeH=BFtUqOJdY+kS8O6B9bw@mail.gmail.com> (raw)
In-Reply-To: <5cb43513906e1175801ea4e753c855623fcd11d1.camel@yadro.com>
On Mon, Mar 30, 2020 at 11:41 PM Ivan Mikhaylov <i.mikhaylov@yadro.com> wrote:
> On Mon, 2020-03-30 at 22:07 +0300, Andy Shevchenko wrote:
> > On Mon, Mar 30, 2020 at 6:27 PM Ivan Mikhaylov <i.mikhaylov@yadro.com> wrote:
...
> > > +#define VCNL_DRV_NAME "vcnl3020"
> > > +#define VCNL_REGMAP_NAME "vcnl3020_regmap"
> >
> > I'm wondering why you need the second one.
>
> For regmap initialize as name in
> static const struct regmap_config vcnl3020_regmap_config = {
> .name = VCNL_REGMAP_NAME,
>
> I can get rid of it from struct with name definition.
I don't think we need a specific suffix. When somebody will look at it
they will already know that they are looking into regmap realm.
...
> > > + rc = device_property_read_u32(data->dev, "vishay,led-current-
> > > milliamp",
> > > + &led_current);
> > > + if (rc == 0) {
> > > + rc = regmap_write(data->regmap, VCNL_LED_CURRENT,
> > > led_current);
> > > + if (rc)
> > > + dev_err(data->dev,
> > > + "Error (%d) setting LED current", rc);
> > > + }
> > > +
> > > + return rc;
> >
> > Why not to use standard pattern, i.e.
> >
> > if (rc)
> > return rc;
> > ...
> > rc = regmap_write(...);
> >
> > ?
>
> Optional parameter. There exists a lot of ways to do it:
I'm simple reading the code. And I believe the above I suggested is
cleaner equivalent.
Is it?
> rc = device_property_read_u32(dev, "milliamp", &led_current);
> rc = regmap_write(regmap, VCNL_LED_CURRENT, (!rc) : led_current ? 0);
This seems not equal to above.
> Which one would be more preferable?
One which has better readability and smallest indentation level.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2020-03-31 11:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-30 15:27 [PATCH v5 0/2] iio: proximity: driver for vcnl3020 Ivan Mikhaylov
2020-03-30 15:27 ` [PATCH v5 1/2] iio: proximity: provide device tree binding document Ivan Mikhaylov
2020-03-30 15:27 ` [PATCH v5 2/2] iio: proximity: Add driver support for vcnl3020 proximity sensor Ivan Mikhaylov
2020-03-30 19:07 ` Andy Shevchenko
2020-03-30 20:41 ` Ivan Mikhaylov
2020-03-31 11:00 ` Andy Shevchenko [this message]
2020-03-31 16:56 ` Ivan Mikhaylov
2020-03-31 17:21 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAHp75VexS-iVeDXsCFqgzCKokgzzeH=BFtUqOJdY+kS8O6B9bw@mail.gmail.com' \
--to=andy.shevchenko@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=i.mikhaylov@yadro.com \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=pmeerw@pmeerw.net \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).