Re: [PATCH v2 2/3] iio: add MEMSensing MSA311 3-axis accelerometer driver

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

 



Le 25/05/2022 à 20:15, Dmitry Rokosov a écrit :
MSA311 is a tri-axial, low-g accelerometer with I2C digital output for
sensitivity consumer applications. It has dynamical user selectable full
scales range of +-2g/+-4g/+-8g/+-16g and allows acceleration measurements
with output data rates from 1Hz to 1000Hz.

Datasheet can be found at following URL:
https://cdn-shop.adafruit.com/product-files/5309/MSA311-V1.1-ENG.pdf

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

Signed-off-by: Dmitry Rokosov <ddrokosov-i4r8oA+eLlH99rHkP+FxIw@xxxxxxxxxxxxxxxx>
---
  MAINTAINERS                |    6 +
  drivers/iio/accel/Kconfig  |   13 +
  drivers/iio/accel/Makefile |    2 +
  drivers/iio/accel/msa311.c | 1525 ++++++++++++++++++++++++++++++++++++
  4 files changed, 1546 insertions(+)
  create mode 100644 drivers/iio/accel/msa311.c

[...]

+static int msa311_probe(struct i2c_client *i2c)
+{
+	struct msa311_priv *msa311;
+	struct iio_dev *indio_dev;
+	struct device *dev = &i2c->dev;
+	int err;
+
+	indio_dev = devm_iio_device_alloc(dev, sizeof(*msa311));
+	if (!indio_dev)
+		return dev_err_probe(dev, -ENOMEM,
+				     "iio device allocation failed\n");
+
+	msa311 = iio_priv(indio_dev);
+	msa311->i2c = i2c;
+	i2c_set_clientdata(i2c, indio_dev);
+
+	err = msa311_regmap_init(msa311);
+	if (err)
+		return err;
+
+	mutex_init(&msa311->lock);
+
+	err = devm_pm_runtime_enable(dev);
+	if (err)
+		return dev_err_probe(dev, err,
+				     "cannot enable runtime PM (%d)\n", err);
+

Nit: dev_err_probe() already print the 'err' (in a human readable maner), so unless the code itself is of any interest, it can be removed:

i.e.:
+		return dev_err_probe(dev, err,
+				     "cannot enable runtime PM");

This pattern is used in many places.

just my 2c.

CJ




[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