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