linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Dmitry Rokosov <DDRokosov@sberdevices.ru>
Cc: "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"jic23@kernel.org" <jic23@kernel.org>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"andriy.shevchenko@linux.intel.com" 
	<andriy.shevchenko@linux.intel.com>,
	"christophe.jaillet@wanadoo.fr" <christophe.jaillet@wanadoo.fr>,
	"stano.jakubek@gmail.com" <stano.jakubek@gmail.com>,
	"shawnguo@kernel.org" <shawnguo@kernel.org>,
	"stephan@gerhold.net" <stephan@gerhold.net>,
	"daniel.lezcano@linaro.org" <daniel.lezcano@linaro.org>,
	"wsa@kernel.org" <wsa@kernel.org>,
	"lars@metafoo.de" <lars@metafoo.de>,
	"Michael.Hennerich@analog.com" <Michael.Hennerich@analog.com>,
	"jbhayana@google.com" <jbhayana@google.com>,
	"lucas.demarchi@intel.com" <lucas.demarchi@intel.com>,
	"jani.nikula@intel.com" <jani.nikula@intel.com>,
	"linus.walleij@linaro.org" <linus.walleij@linaro.org>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	kernel <kernel@sberdevices.ru>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5 6/7] iio: add MEMSensing MSA311 3-axis accelerometer driver
Date: Sat, 13 Aug 2022 01:34:40 +0300	[thread overview]
Message-ID: <CAHp75Ve8VtwGX6YeuGvhUat5UfoLXB4RdkW4vc1kQUk71+_aCA@mail.gmail.com> (raw)
In-Reply-To: <20220812165243.22177-7-ddrokosov@sberdevices.ru>

On Fri, Aug 12, 2022 at 7:52 PM Dmitry Rokosov <DDRokosov@sberdevices.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

  parent reply	other threads:[~2022-08-12 22:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-12 16:52 [PATCH v5 0/7] iio: accel: add MSA311 accelerometer driver Dmitry Rokosov
2022-08-12 16:52 ` [PATCH v5 1/7] lib/string_helpers: Add str_read_write() helper Dmitry Rokosov
2022-08-12 17:15   ` Dmitry Rokosov
2022-08-12 16:52 ` [PATCH v5 2/7] units: complement the set of Hz units Dmitry Rokosov
2022-08-28 15:55   ` Jonathan Cameron
2022-08-29 21:06     ` Andrew Morton
2022-08-29 21:07     ` Andrew Morton
2022-08-12 16:52 ` [PATCH v5 4/7] iio: common: scmi_sensors: use HZ macro from units.h Dmitry Rokosov
2022-08-12 16:52 ` [PATCH v5 3/7] iio: accel: adxl345: " Dmitry Rokosov
2022-08-12 16:52 ` [PATCH v5 5/7] dt-bindings: vendor-prefixes: add MEMSensing Microsystems Co., Ltd Dmitry Rokosov
2022-08-12 16:52 ` [PATCH v5 6/7] iio: add MEMSensing MSA311 3-axis accelerometer driver Dmitry Rokosov
2022-08-12 17:10   ` Dmitry Rokosov
2022-08-12 22:34   ` Andy Shevchenko [this message]
2022-08-14 16:26     ` Jonathan Cameron
2022-08-15 14:01     ` Dmitry Rokosov
2022-08-14 16:41   ` Jonathan Cameron
2022-08-12 16:52 ` [PATCH v5 7/7] dt-bindings: iio: accel: add dt-binding schema for msa311 accel driver Dmitry Rokosov

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=CAHp75Ve8VtwGX6YeuGvhUat5UfoLXB4RdkW4vc1kQUk71+_aCA@mail.gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=DDRokosov@sberdevices.ru \
    --cc=Michael.Hennerich@analog.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=daniel.lezcano@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jani.nikula@intel.com \
    --cc=jbhayana@google.com \
    --cc=jic23@kernel.org \
    --cc=kernel@sberdevices.ru \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucas.demarchi@intel.com \
    --cc=robh+dt@kernel.org \
    --cc=shawnguo@kernel.org \
    --cc=stano.jakubek@gmail.com \
    --cc=stephan@gerhold.net \
    --cc=wsa@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).