Re: [PATCH v5 6/7] iio: add MEMSensing MSA311 3-axis accelerometer driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux