[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220815140201.5dpjpk35tdewcpvu@CAB-WSD-L081021.sigma.sbrf.ru>
Date: Mon, 15 Aug 2022 14:01:13 +0000
From: Dmitry Rokosov <DDRokosov@...rdevices.ru>
To: Andy Shevchenko <andy.shevchenko@...il.com>
CC: "akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
"jic23@...nel.org" <jic23@...nel.org>,
"robh+dt@...nel.org" <robh+dt@...nel.org>,
"andriy.shevchenko@...ux.intel.com"
<andriy.shevchenko@...ux.intel.com>,
"christophe.jaillet@...adoo.fr" <christophe.jaillet@...adoo.fr>,
"stano.jakubek@...il.com" <stano.jakubek@...il.com>,
"shawnguo@...nel.org" <shawnguo@...nel.org>,
"stephan@...hold.net" <stephan@...hold.net>,
"daniel.lezcano@...aro.org" <daniel.lezcano@...aro.org>,
"wsa@...nel.org" <wsa@...nel.org>,
"lars@...afoo.de" <lars@...afoo.de>,
"Michael.Hennerich@...log.com" <Michael.Hennerich@...log.com>,
"jbhayana@...gle.com" <jbhayana@...gle.com>,
"lucas.demarchi@...el.com" <lucas.demarchi@...el.com>,
"jani.nikula@...el.com" <jani.nikula@...el.com>,
"linus.walleij@...aro.org" <linus.walleij@...aro.org>,
"linux-iio@...r.kernel.org" <linux-iio@...r.kernel.org>,
kernel <kernel@...rdevices.ru>,
"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v5 6/7] iio: add MEMSensing MSA311 3-axis accelerometer
driver
On Sat, Aug 13, 2022 at 01:34:40AM +0300, Andy Shevchenko wrote:
[...]
> > Spec: https://cdn-shop.adafruit.com/product-files/5309/MSA311-V1.1-ENG.pdf
>
> Can you use Datasheet: tag below (just before your SoB tag)?
Sure, I can move it on the previous line beforce SoB tag.
But with Datasheet: tag this line will be over the commit msg line limit.
If you don't mind I will stay with Spec: tag instead of Datasheet:
[...]
> > +static const struct {
> > + int val;
> > + int val2;
> > +} msa311_fs_table[] = {
> > + {0, 9580}, {0, 19160}, {0, 38320}, {0, 76641}
> > +};
>
> At least you may deduplicate the type definition for these data structures, like
>
> struct iio_float {
> int integer;
> int fract;
> };
Agreed. I will make deduplication of this type inside msa311 driver
only.
[...]
> > + dev_err(dev,
> > + "cannot set odr %u.%luHz, not available in %s mode\n",
> > + msa311_odr_table[odr].val,
> > + msa311_odr_table[odr].val2 / MILLIHZ_PER_HZ,
>
> Logically it's MICROHZ_PER_MILLIHZ.
>
You are right. But I think it would be better to print the original val2
value with zero-padding.
[...]
> > + freq_uhz = msa311_odr_table[odr].val * MICROHZ_PER_HZ +
> > + msa311_odr_table[odr].val2;
> > + wait_ms = (MICROHZ_PER_HZ / freq_uhz) * MSEC_PER_SEC;
>
> On the contrary this seems correct.
Good
> > + err = iio_device_claim_direct_mode(indio_dev);
> > + if (err)
> > + return err;
> > +
> > + mutex_lock(&msa311->lock);
> > + err = msa311_get_axis(msa311, chan, &axis);
> > + mutex_unlock(&msa311->lock);
> > +
> > + iio_device_release_direct_mode(indio_dev);
> > +
> > + if (err) {
> > + dev_err(dev, "cannot get axis %s (%pe)\n",
> > + chan->datasheet_name, ERR_PTR(err));
> > + return err;
> > + }
> > +
> > + pm_runtime_mark_last_busy(dev);
> > + pm_runtime_put_autosuspend(dev);
>
> All error cases above miss the PM restoration. Is it on purpose?
> Otherwise fix it here and check everywhere else.
Nice catch! This is a bug. I'll fix it in v6
> > + used = scnprintf(msa311->chip_name, sizeof(msa311->chip_name),
> > + "msa311-%hhx", partid);
>
> > + msa311->chip_name[used] = '\0';
>
> What is this for exactly?
>
Ah, you are right, scnprintf() makes null terminating inside.
> > + /* Disable all interrupts by default */
> > + err = regmap_write(msa311->regs, MSA311_INT_SET_0_REG, 0);
> > + if (err)
> > + return dev_err_probe(dev, err,
> > + "cannot disable set0 interrupts\n");
> > +
> > + err = regmap_write(msa311->regs, MSA311_INT_SET_1_REG, 0);
> > + if (err)
> > + return dev_err_probe(dev, err,
> > + "cannot disable set1 interrupts\n");
>
> Wondering if the above can be combined to bulk write.
>
I will try and rework this place if it's workable.
> > + /* Unmap all INT1 interrupts by default */
> > + err = regmap_write(msa311->regs, MSA311_INT_MAP_0_REG, 0);
> > + if (err)
> > + return dev_err_probe(dev, err,
> > + "failed to unmap map0 interrupts\n");
> > +
> > + err = regmap_write(msa311->regs, MSA311_INT_MAP_1_REG, 0);
> > + if (err)
> > + return dev_err_probe(dev, err,
> > + "failed to unmap map1 interrupts\n");
>
> Ditto.
The same as above.
[...]
--
Thank you,
Dmitry
Powered by blists - more mailing lists