From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Dmitry Rokosov <DDRokosov@sberdevices.ru>
Cc: "robh+dt@kernel.org" <robh+dt@kernel.org>,
"stano.jakubek@gmail.com" <stano.jakubek@gmail.com>,
"shawnguo@kernel.org" <shawnguo@kernel.org>,
"jic23@kernel.org" <jic23@kernel.org>,
"lars@metafoo.de" <lars@metafoo.de>,
"stephan@gerhold.net" <stephan@gerhold.net>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
kernel <kernel@sberdevices.ru>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 2/3] iio: add MEMSensing MSA311 3-axis accelerometer driver
Date: Thu, 4 Aug 2022 20:28:28 +0200 [thread overview]
Message-ID: <CAHp75VdCWKCVws_xp7igCAGYFC7bxkQgCyXFohQR5PHzTkoSpg@mail.gmail.com> (raw)
In-Reply-To: <20220803191621.tzrmndkygfe7nlpx@CAB-WSD-L081021.sigma.sbrf.ru>
On Wed, Aug 3, 2022 at 9:16 PM Dmitry Rokosov <DDRokosov@sberdevices.ru> wrote:
> On Wed, Aug 03, 2022 at 07:49:33PM +0200, Andy Shevchenko wrote:
> > On Wed, Aug 3, 2022 at 3:11 PM Dmitry Rokosov <DDRokosov@sberdevices.ru> wrote:
...
> > > +static const struct {
> > > + int val;
> > > + int val2;
> > > +} msa311_fs_table[] = {
> > > + {0, 9580}, {0, 19160}, {0, 38320}, {0, 76641}
> > > +};
> >
> > Besides that this struct is defined not only once in the file, this is
> > very well NIH struct s32_fract. Why not use the latter?
> Good point, but looks like this struct is not so popular in the other
> kernel drivers:
It's simply new, it is not about popularity. I would put it as it's
not _yet_ so popular.
...
> grep "s32_fract" -r -l . | wc -l
> 3
Hint: `git grep` much much faster on Git repositories (it goes via
index and not working copy) and see
`git grep -lw s32_fract`
...
> > > + .cache_type = REGCACHE_RBTREE,
> >
> > Tree hash is good for sparse data, do you really have it sparse (a lot
> > of big gaps in between)?
>
> I suppose so. MSA311 regmap has ~6 gaps.
Yes and how long is each gap in comparison to the overall space?
...
> > > + for (fs = 0; fs < ARRAY_SIZE(msa311_fs_table); ++fs)
> >
> > fs++ will work as well.
>
> I would prefer ++fs if you don't mind :)
Why? It's a non-standard pattern, and needs an explanation.
> > > + /* Do not check msa311_fs_table[fs].val, it's always 0 */
> > > + if (val2 == msa311_fs_table[fs].val2) {
> > > + mutex_lock(&msa311->lock);
> > > + err = regmap_field_write(msa311->fields[F_FS], fs);
> > > + mutex_unlock(&msa311->lock);
> >
> > > + if (err)
> > > + dev_err(dev, "cannot update scale (%d)\n", err);
> >
> > This can be done after putting the device back into (auto)sleep, right?
> >
>
> Are you talking about dev_err logging? Sure, it can be moved after
> pm_runtime* calls.
Yes.
> > > + break;
> > > + }
> > > +
> > > + pm_runtime_mark_last_busy(dev);
> > > + pm_runtime_put_autosuspend(dev);
...
> > > + for (odr = 0; odr < ARRAY_SIZE(msa311_odr_table); ++odr)
> >
> > odr++ works well also.
>
> I would prefer ++odr if you don't mind :)
See above.
...
> > > + dev_err(dev, "cannot update freq (%d)\n", err);
> >
> > frequency
>
> It will be more ugly due 80 symbols restriction.
Nope, it will be understandable by the user. You do code for the user
and then for the developer, right?
...
> > > + dev_dbg(dev, "found MSA311 compatible chip[%#x]\n", partid);
> >
> > Useless message.
>
> Why? It's under dynamic debug, so I will see it if I really want to.
So what the point of the _successful_ detection? You already know from
the code, that partid, you know by other means that probe was
successful, why this message is needed? Especially for debugging when
we have initcall_debug option.
...
> > > + return dev_err_probe(dev, err, "cannot disable set0 intrs\n");
> >
> > interrupts
>
> It will be more ugly due 80 symbols restriction.
As above to here and other cryptic messages. Please think about the users first.
...
> > > + indio_dev->modes = 0; /* setup buffered mode later */
> >
> > Why explicit assignment to 0? Doesn't kzalloc() do it for you?
>
> kzalloc() will do it for me, of course. Previously, I initialized modes to
> INDIO_DIRECT_MODE to just provide default value for that. Jonathan
> suggested to replace it with 0. I can remove this line at all, no problem.
> I just thought, it's more readable.
You may leave comment without assignment explaining that IIO core will
set the buffered mode.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2022-08-04 18:29 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-03 13:11 [PATCH v4 0/3] iio: accel: add MSA311 accelerometer driver Dmitry Rokosov
2022-08-03 13:11 ` [PATCH v4 1/3] dt-bindings: vendor-prefixes: add MEMSensing Microsystems Co., Ltd Dmitry Rokosov
2022-08-03 13:11 ` [PATCH v4 2/3] iio: add MEMSensing MSA311 3-axis accelerometer driver Dmitry Rokosov
2022-08-03 17:49 ` Andy Shevchenko
2022-08-03 19:16 ` Dmitry Rokosov
2022-08-04 18:17 ` Dmitry Rokosov
2022-08-04 18:30 ` Andy Shevchenko
2022-08-05 14:04 ` Dmitry Rokosov
2022-08-05 16:03 ` Andy Shevchenko
2022-08-05 16:20 ` Dmitry Rokosov
2022-08-05 17:59 ` Andy Shevchenko
2022-08-04 18:28 ` Andy Shevchenko [this message]
2022-08-05 14:19 ` Dmitry Rokosov
2022-08-06 14:55 ` Jonathan Cameron
2022-08-09 9:52 ` Dmitry Rokosov
2022-08-09 10:05 ` Andy Shevchenko
2022-08-09 10:35 ` Dmitry Rokosov
2022-08-13 15:27 ` Jonathan Cameron
2022-08-13 15:39 ` Jonathan Cameron
2022-08-03 18:11 ` Christophe JAILLET
2022-08-03 18:39 ` Dmitry Rokosov
2022-08-03 19:18 ` Christophe JAILLET
2022-08-03 19:26 ` Dmitry Rokosov
2022-08-06 15:32 ` Jonathan Cameron
2022-08-09 9:47 ` Dmitry Rokosov
2022-08-13 15:34 ` Jonathan Cameron
2022-08-03 13:11 ` [PATCH v4 3/3] dt-bindings: iio: accel: add dt-binding schema for msa311 accel driver Dmitry Rokosov
2022-08-03 23:41 ` Rob Herring
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=CAHp75VdCWKCVws_xp7igCAGYFC7bxkQgCyXFohQR5PHzTkoSpg@mail.gmail.com \
--to=andy.shevchenko@gmail.com \
--cc=DDRokosov@sberdevices.ru \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=kernel@sberdevices.ru \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=shawnguo@kernel.org \
--cc=stano.jakubek@gmail.com \
--cc=stephan@gerhold.net \
/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).