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]

 



Hello Christophe,

On Sun, Jun 12, 2022 at 11:46:19AM +0200, Christophe JAILLET wrote:
> Le 25/05/2022 à 20:15, Dmitry Rokosov a écrit :
> > +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.

Thank you for pointing this! It's a really helpful dev_err_probe() trait.
I'll use it in the v3 patchset.

-- 
Thank you,
Dmitry




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux