Re: [PATCH v4 2/7] iio: pressure: bmp280: Add support for bmp280 soft reset

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

 



On Wed, Aug 28, 2024 at 10:51:22PM +0200, Vasileios Amoiridis wrote:
> The BM(P/E)28x devices have an option for soft reset which is also
> recommended by the Bosch Sensortech BME2 Sensor API to be used before the
> initial configuration of the device.

...

> +static int bmp280_preinit(struct bmp280_data *data)
> +{

With

	struct device *dev = data->dev;

it will look better?

> +	unsigned int reg;
> +	int ret;

> +	ret = regmap_write(data->regmap, BMP280_REG_RESET, BMP280_RST_SOFT_CMD);
> +	if (ret)

> +		return dev_err_probe(data->dev, ret,
> +				     "Failed to reset device.\n");

		return dev_err_probe(dev, ret, "Failed to reset device.\n");

> +	/*
> +	 * According to the datasheet in Chapter 1: Specification, Table 2,
> +	 * after resetting, the device uses the complete power-on sequence so
> +	 * it needs to wait for the defined start-up time.
> +	 */
> +	fsleep(data->start_up_time);
> +
> +	ret = regmap_read(data->regmap, BMP280_REG_STATUS, &reg);
> +	if (ret)

> +		return dev_err_probe(data->dev, ret,
> +				     "Failed to read status register.\n");

		return dev_err_probe(dev, ret, "Failed to read status register.\n");

> +	if (reg & BMP280_REG_STATUS_IM_UPDATE)

> +		return dev_err_probe(data->dev, -EIO,
> +				     "Failed to copy NVM contents.\n");

		return dev_err_probe(dev, -EIO, "Failed to copy NVM contents.\n");

> +	return 0;
> +}

Yes, it's up to 84 characters long, but I think it improves readability.

-- 
With Best Regards,
Andy Shevchenko






[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