[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Ve8VtwGX6YeuGvhUat5UfoLXB4RdkW4vc1kQUk71+_aCA@mail.gmail.com>
Date: Sat, 13 Aug 2022 01:34:40 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Dmitry Rokosov <DDRokosov@...rdevices.ru>
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 Fri, Aug 12, 2022 at 7:52 PM Dmitry Rokosov <DDRokosov@...rdevices.ru> wrote:
>
> MSA311 is a tri-axial, low-g accelerometer with I2C digital output for
> sensitivity consumer applications. It has dynamic user-selectable full
> scales range of +-2g/+-4g/+-8g/+-16g and allows acceleration measurements
> with output data rates from 1Hz to 1000Hz.
> 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)?
> This driver supports following MSA311 features:
> - IIO interface
> - Different power modes: NORMAL and SUSPEND (using pm_runtime)
> - ODR (Output Data Rate) selection
> - Scale and samp_freq selection
> - IIO triggered buffer, IIO reg access
> - NEW_DATA interrupt + trigger
>
> Below features to be done:
> - Motion Events: ACTIVE, TAP, ORIENT, FREEFALL
> - Low Power mode
...
> +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;
};
...
> + 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.
> + msa311_pwr_modes[pwr_mode]);
...
> + 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.
...
> + 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.
...
> + used = scnprintf(msa311->chip_name, sizeof(msa311->chip_name),
> + "msa311-%hhx", partid);
> + msa311->chip_name[used] = '\0';
What is this for exactly?
...
> + /* 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.
...
> + /* 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.
...
> + /* Keep going without interrupts if no initialized I2C irq */
IRQ
...
> + "cannot allocate newdata trigger\n");
In case you wish to make them shorter, you can use "can't".
...
> + "can't register newdata trigger\n");
...esp. if you already do this in the other message, but not in all.
So, some consistency would be good to have.
...
I avoided commenting on the points that were not addressed and you
explained why.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists