public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Vasileios Amoiridis <vassilisamir@gmail.com>
Cc: lars@metafoo.de, andriy.shevchenko@linux.intel.com,
	ang.iglesiasg@gmail.com, mazziesaccount@gmail.com,
	ak@it-klinger.de, petre.rodan@subdimension.ro,
	phil@raspberrypi.com, 579lpy@gmail.com, linus.walleij@linaro.org,
	semen.protsenko@linaro.org, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 01/10] iio: pressure: bmp280: Improve indentation and line wrapping
Date: Sun, 5 May 2024 19:51:55 +0100	[thread overview]
Message-ID: <20240505195155.0c682ec2@jic23-huawei> (raw)
In-Reply-To: <20240429190046.24252-2-vassilisamir@gmail.com>

On Mon, 29 Apr 2024 21:00:37 +0200
Vasileios Amoiridis <vassilisamir@gmail.com> wrote:

> Fix indentations that are not following the standards, remove
> extra white lines and add missing white lines.
> 
> Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>

Possibly some reviewers will feel one or two of these are a little over zealous,
but this does both improve things and bring consistency to this code.

I'll pick up some of these cleanups now (maybe the whole set but who knows)
to reduce what is left if we end up with a v6.

Applied this one to the togreg branch of iio.git and pushed out as testing
for 0-day to see if we missed anything,

Thanks,

Jonathan

> ---
>  drivers/iio/pressure/bmp280-core.c | 108 ++++++++++++++++-------------
>  drivers/iio/pressure/bmp280-spi.c  |   4 +-
>  2 files changed, 61 insertions(+), 51 deletions(-)
> 
> diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
> index 09f53d987c7d..1a3241a41768 100644
> --- a/drivers/iio/pressure/bmp280-core.c
> +++ b/drivers/iio/pressure/bmp280-core.c
> @@ -52,7 +52,6 @@
>   */
>  enum { AC1, AC2, AC3, AC4, AC5, AC6, B1, B2, MB, MC, MD };
>  
> -
>  enum bmp380_odr {
>  	BMP380_ODR_200HZ,
>  	BMP380_ODR_100HZ,
> @@ -181,18 +180,19 @@ static int bmp280_read_calib(struct bmp280_data *data)
>  	struct bmp280_calib *calib = &data->calib.bmp280;
>  	int ret;
>  
> -
>  	/* Read temperature and pressure calibration values. */
>  	ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_TEMP_START,
> -			       data->bmp280_cal_buf, sizeof(data->bmp280_cal_buf));
> +			       data->bmp280_cal_buf,
> +			       sizeof(data->bmp280_cal_buf));
>  	if (ret < 0) {
>  		dev_err(data->dev,
> -			"failed to read temperature and pressure calibration parameters\n");
> +			"failed to read calibration parameters\n");
>  		return ret;
>  	}
>  
> -	/* Toss the temperature and pressure calibration data into the entropy pool */
> -	add_device_randomness(data->bmp280_cal_buf, sizeof(data->bmp280_cal_buf));
> +	/* Toss calibration data into the entropy pool */
> +	add_device_randomness(data->bmp280_cal_buf,
> +			      sizeof(data->bmp280_cal_buf));
>  
>  	/* Parse temperature calibration values. */
>  	calib->T1 = le16_to_cpu(data->bmp280_cal_buf[T1]);
> @@ -223,7 +223,7 @@ static int bme280_read_calib(struct bmp280_data *data)
>  	/* Load shared calibration params with bmp280 first */
>  	ret = bmp280_read_calib(data);
>  	if  (ret < 0) {
> -		dev_err(dev, "failed to read common bmp280 calibration parameters\n");
> +		dev_err(dev, "failed to read calibration parameters\n");
>  		return ret;
>  	}
>  
> @@ -283,6 +283,7 @@ static int bme280_read_calib(struct bmp280_data *data)
>  
>  	return 0;
>  }
> +
>  /*
>   * Returns humidity in percent, resolution is 0.01 percent. Output value of
>   * "47445" represents 47445/1024 = 46.333 %RH.
> @@ -305,7 +306,7 @@ static u32 bmp280_compensate_humidity(struct bmp280_data *data,
>  	var = clamp_val(var, 0, 419430400);
>  
>  	return var >> 12;
> -};
> +}
>  
>  /*
>   * Returns temperature in DegC, resolution is 0.01 DegC.  Output value of
> @@ -538,7 +539,7 @@ static int bmp280_read_raw(struct iio_dev *indio_dev,
>  }
>  
>  static int bmp280_write_oversampling_ratio_humid(struct bmp280_data *data,
> -					       int val)
> +						 int val)
>  {
>  	const int *avail = data->chip_info->oversampling_humid_avail;
>  	const int n = data->chip_info->num_oversampling_humid_avail;
> @@ -563,7 +564,7 @@ static int bmp280_write_oversampling_ratio_humid(struct bmp280_data *data,
>  }
>  
>  static int bmp280_write_oversampling_ratio_temp(struct bmp280_data *data,
> -					       int val)
> +						int val)
>  {
>  	const int *avail = data->chip_info->oversampling_temp_avail;
>  	const int n = data->chip_info->num_oversampling_temp_avail;
> @@ -588,7 +589,7 @@ static int bmp280_write_oversampling_ratio_temp(struct bmp280_data *data,
>  }
>  
>  static int bmp280_write_oversampling_ratio_press(struct bmp280_data *data,
> -					       int val)
> +						 int val)
>  {
>  	const int *avail = data->chip_info->oversampling_press_avail;
>  	const int n = data->chip_info->num_oversampling_press_avail;
> @@ -772,13 +773,12 @@ static int bmp280_chip_config(struct bmp280_data *data)
>  	int ret;
>  
>  	ret = regmap_write_bits(data->regmap, BMP280_REG_CTRL_MEAS,
> -				 BMP280_OSRS_TEMP_MASK |
> -				 BMP280_OSRS_PRESS_MASK |
> -				 BMP280_MODE_MASK,
> -				 osrs | BMP280_MODE_NORMAL);
> +				BMP280_OSRS_TEMP_MASK |
> +				BMP280_OSRS_PRESS_MASK |
> +				BMP280_MODE_MASK,
> +				osrs | BMP280_MODE_NORMAL);
>  	if (ret < 0) {
> -		dev_err(data->dev,
> -			"failed to write ctrl_meas register\n");
> +		dev_err(data->dev, "failed to write ctrl_meas register\n");
>  		return ret;
>  	}
>  
> @@ -786,8 +786,7 @@ static int bmp280_chip_config(struct bmp280_data *data)
>  				 BMP280_FILTER_MASK,
>  				 BMP280_FILTER_4X);
>  	if (ret < 0) {
> -		dev_err(data->dev,
> -			"failed to write config register\n");
> +		dev_err(data->dev, "failed to write config register\n");
>  		return ret;
>  	}
>  
> @@ -926,8 +925,8 @@ static int bmp380_cmd(struct bmp280_data *data, u8 cmd)
>  }
>  
>  /*
> - * Returns temperature in Celsius degrees, resolution is 0.01º C. Output value of
> - * "5123" equals 51.2º C. t_fine carries fine temperature as global value.
> + * Returns temperature in Celsius degrees, resolution is 0.01º C. Output value
> + * of "5123" equals 51.2º C. t_fine carries fine temperature as global value.
>   *
>   * Taken from datasheet, Section Appendix 9, "Compensation formula" and repo
>   * https://github.com/BoschSensortec/BMP3-Sensor-API.
> @@ -1069,7 +1068,8 @@ static int bmp380_read_calib(struct bmp280_data *data)
>  
>  	/* Read temperature and pressure calibration data */
>  	ret = regmap_bulk_read(data->regmap, BMP380_REG_CALIB_TEMP_START,
> -			       data->bmp380_cal_buf, sizeof(data->bmp380_cal_buf));
> +			       data->bmp380_cal_buf,
> +			       sizeof(data->bmp380_cal_buf));
>  	if (ret) {
>  		dev_err(data->dev,
>  			"failed to read temperature calibration parameters\n");
> @@ -1077,7 +1077,8 @@ static int bmp380_read_calib(struct bmp280_data *data)
>  	}
>  
>  	/* Toss the temperature calibration data into the entropy pool */
> -	add_device_randomness(data->bmp380_cal_buf, sizeof(data->bmp380_cal_buf));
> +	add_device_randomness(data->bmp380_cal_buf,
> +			      sizeof(data->bmp380_cal_buf));
>  
>  	/* Parse calibration values */
>  	calib->T1 = get_unaligned_le16(&data->bmp380_cal_buf[BMP380_T1]);
> @@ -1159,7 +1160,8 @@ static int bmp380_chip_config(struct bmp280_data *data)
>  
>  	/* Configure output data rate */
>  	ret = regmap_update_bits_check(data->regmap, BMP380_REG_ODR,
> -				       BMP380_ODRS_MASK, data->sampling_freq, &aux);
> +				       BMP380_ODRS_MASK, data->sampling_freq,
> +				       &aux);
>  	if (ret) {
>  		dev_err(data->dev, "failed to write ODR selection register\n");
>  		return ret;
> @@ -1178,12 +1180,13 @@ static int bmp380_chip_config(struct bmp280_data *data)
>  
>  	if (change) {
>  		/*
> -		 * The configurations errors are detected on the fly during a measurement
> -		 * cycle. If the sampling frequency is too low, it's faster to reset
> -		 * the measurement loop than wait until the next measurement is due.
> +		 * The configurations errors are detected on the fly during a
> +		 * measurement cycle. If the sampling frequency is too low, it's
> +		 * faster to reset the measurement loop than wait until the next
> +		 * measurement is due.
>  		 *
> -		 * Resets sensor measurement loop toggling between sleep and normal
> -		 * operating modes.
> +		 * Resets sensor measurement loop toggling between sleep and
> +		 * normal operating modes.
>  		 */
>  		ret = regmap_write_bits(data->regmap, BMP380_REG_POWER_CONTROL,
>  					BMP380_MODE_MASK,
> @@ -1201,22 +1204,21 @@ static int bmp380_chip_config(struct bmp280_data *data)
>  			return ret;
>  		}
>  		/*
> -		 * Waits for measurement before checking configuration error flag.
> -		 * Selected longest measure time indicated in section 3.9.1
> -		 * in the datasheet.
> +		 * Waits for measurement before checking configuration error
> +		 * flag. Selected longest measure time indicated in
> +		 * section 3.9.1 in the datasheet.
>  		 */
>  		msleep(80);
>  
>  		/* Check config error flag */
>  		ret = regmap_read(data->regmap, BMP380_REG_ERROR, &tmp);
>  		if (ret) {
> -			dev_err(data->dev,
> -				"failed to read error register\n");
> +			dev_err(data->dev, "failed to read error register\n");
>  			return ret;
>  		}
>  		if (tmp & BMP380_ERR_CONF_MASK) {
>  			dev_warn(data->dev,
> -				"sensor flagged configuration as incompatible\n");
> +				 "sensor flagged configuration as incompatible\n");
>  			return -EINVAL;
>  		}
>  	}
> @@ -1317,9 +1319,11 @@ static int bmp580_nvm_operation(struct bmp280_data *data, bool is_write)
>  	}
>  
>  	/* Start NVM operation sequence */
> -	ret = regmap_write(data->regmap, BMP580_REG_CMD, BMP580_CMD_NVM_OP_SEQ_0);
> +	ret = regmap_write(data->regmap, BMP580_REG_CMD,
> +			   BMP580_CMD_NVM_OP_SEQ_0);
>  	if (ret) {
> -		dev_err(data->dev, "failed to send nvm operation's first sequence\n");
> +		dev_err(data->dev,
> +			"failed to send nvm operation's first sequence\n");
>  		return ret;
>  	}
>  	if (is_write) {
> @@ -1327,7 +1331,8 @@ static int bmp580_nvm_operation(struct bmp280_data *data, bool is_write)
>  		ret = regmap_write(data->regmap, BMP580_REG_CMD,
>  				   BMP580_CMD_NVM_WRITE_SEQ_1);
>  		if (ret) {
> -			dev_err(data->dev, "failed to send nvm write sequence\n");
> +			dev_err(data->dev,
> +				"failed to send nvm write sequence\n");
>  			return ret;
>  		}
>  		/* Datasheet says on 4.8.1.2 it takes approximately 10ms */
> @@ -1338,7 +1343,8 @@ static int bmp580_nvm_operation(struct bmp280_data *data, bool is_write)
>  		ret = regmap_write(data->regmap, BMP580_REG_CMD,
>  				   BMP580_CMD_NVM_READ_SEQ_1);
>  		if (ret) {
> -			dev_err(data->dev, "failed to send nvm read sequence\n");
> +			dev_err(data->dev,
> +				"failed to send nvm read sequence\n");
>  			return ret;
>  		}
>  		/* Datasheet says on 4.8.1.1 it takes approximately 200us */
> @@ -1501,8 +1507,8 @@ static int bmp580_nvmem_read(void *priv, unsigned int offset, void *val,
>  		if (ret)
>  			goto exit;
>  
> -		ret = regmap_bulk_read(data->regmap, BMP580_REG_NVM_DATA_LSB, &data->le16,
> -				       sizeof(data->le16));
> +		ret = regmap_bulk_read(data->regmap, BMP580_REG_NVM_DATA_LSB,
> +				       &data->le16, sizeof(data->le16));
>  		if (ret) {
>  			dev_err(data->dev, "error reading nvm data regs\n");
>  			goto exit;
> @@ -1546,7 +1552,8 @@ static int bmp580_nvmem_write(void *priv, unsigned int offset, void *val,
>  	while (bytes >= sizeof(*buf)) {
>  		addr = bmp580_nvmem_addrs[offset / sizeof(*buf)];
>  
> -		ret = regmap_write(data->regmap, BMP580_REG_NVM_ADDR, BMP580_NVM_PROG_EN |
> +		ret = regmap_write(data->regmap, BMP580_REG_NVM_ADDR,
> +				   BMP580_NVM_PROG_EN |
>  				   FIELD_PREP(BMP580_NVM_ROW_ADDR_MASK, addr));
>  		if (ret) {
>  			dev_err(data->dev, "error writing nvm address\n");
> @@ -1554,8 +1561,8 @@ static int bmp580_nvmem_write(void *priv, unsigned int offset, void *val,
>  		}
>  		data->le16 = cpu_to_le16(*buf++);
>  
> -		ret = regmap_bulk_write(data->regmap, BMP580_REG_NVM_DATA_LSB, &data->le16,
> -					sizeof(data->le16));
> +		ret = regmap_bulk_write(data->regmap, BMP580_REG_NVM_DATA_LSB,
> +					&data->le16, sizeof(data->le16));
>  		if (ret) {
>  			dev_err(data->dev, "error writing LSB NVM data regs\n");
>  			goto exit;
> @@ -1662,7 +1669,8 @@ static int bmp580_chip_config(struct bmp280_data *data)
>  		  BMP580_OSR_PRESS_EN;
>  
>  	ret = regmap_update_bits_check(data->regmap, BMP580_REG_OSR_CONFIG,
> -				       BMP580_OSR_TEMP_MASK | BMP580_OSR_PRESS_MASK |
> +				       BMP580_OSR_TEMP_MASK |
> +				       BMP580_OSR_PRESS_MASK |
>  				       BMP580_OSR_PRESS_EN,
>  				       reg_val, &aux);
>  	if (ret) {
> @@ -1713,7 +1721,8 @@ static int bmp580_chip_config(struct bmp280_data *data)
>  		 */
>  		ret = regmap_read(data->regmap, BMP580_REG_EFF_OSR, &tmp);
>  		if (ret) {
> -			dev_err(data->dev, "error reading effective OSR register\n");
> +			dev_err(data->dev,
> +				"error reading effective OSR register\n");
>  			return ret;
>  		}
>  		if (!(tmp & BMP580_EFF_OSR_VALID_ODR)) {
> @@ -1848,7 +1857,8 @@ static int bmp180_read_calib(struct bmp280_data *data)
>  	}
>  
>  	/* Toss the calibration data into the entropy pool */
> -	add_device_randomness(data->bmp180_cal_buf, sizeof(data->bmp180_cal_buf));
> +	add_device_randomness(data->bmp180_cal_buf,
> +			      sizeof(data->bmp180_cal_buf));
>  
>  	calib->AC1 = be16_to_cpu(data->bmp180_cal_buf[AC1]);
>  	calib->AC2 = be16_to_cpu(data->bmp180_cal_buf[AC2]);
> @@ -1963,8 +1973,7 @@ static u32 bmp180_compensate_press(struct bmp280_data *data, s32 adc_press)
>  	return p + ((x1 + x2 + 3791) >> 4);
>  }
>  
> -static int bmp180_read_press(struct bmp280_data *data,
> -			     int *val, int *val2)
> +static int bmp180_read_press(struct bmp280_data *data, int *val, int *val2)
>  {
>  	u32 comp_press;
>  	s32 adc_press;
> @@ -2241,6 +2250,7 @@ static int bmp280_runtime_resume(struct device *dev)
>  	ret = regulator_bulk_enable(BMP280_NUM_SUPPLIES, data->supplies);
>  	if (ret)
>  		return ret;
> +
>  	usleep_range(data->start_up_time, data->start_up_time + 100);
>  	return data->chip_info->chip_config(data);
>  }
> diff --git a/drivers/iio/pressure/bmp280-spi.c b/drivers/iio/pressure/bmp280-spi.c
> index 4e19ea0b4d39..62b4e58104cf 100644
> --- a/drivers/iio/pressure/bmp280-spi.c
> +++ b/drivers/iio/pressure/bmp280-spi.c
> @@ -13,7 +13,7 @@
>  #include "bmp280.h"
>  
>  static int bmp280_regmap_spi_write(void *context, const void *data,
> -                                   size_t count)
> +				   size_t count)
>  {
>  	struct spi_device *spi = to_spi_device(context);
>  	u8 buf[2];
> @@ -29,7 +29,7 @@ static int bmp280_regmap_spi_write(void *context, const void *data,
>  }
>  
>  static int bmp280_regmap_spi_read(void *context, const void *reg,
> -                                  size_t reg_size, void *val, size_t val_size)
> +				  size_t reg_size, void *val, size_t val_size)
>  {
>  	struct spi_device *spi = to_spi_device(context);
>  
> 
> base-commit: b0a2c79c6f3590b74742cbbc76687014d47972d8


  reply	other threads:[~2024-05-05 18:52 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-29 19:00 [PATCH v5 00/10] iio: pressure: bmp280: Driver cleanup and add triggered buffer support Vasileios Amoiridis
2024-04-29 19:00 ` [PATCH v5 01/10] iio: pressure: bmp280: Improve indentation and line wrapping Vasileios Amoiridis
2024-05-05 18:51   ` Jonathan Cameron [this message]
2024-05-06  0:04     ` Vasileios Amoiridis
2024-05-06 12:38       ` Jonathan Cameron
2024-04-29 19:00 ` [PATCH v5 02/10] iio: pressure: bmp280: Use BME prefix for BME280 specifics Vasileios Amoiridis
2024-05-05 18:53   ` Jonathan Cameron
2024-04-29 19:00 ` [PATCH v5 03/10] iio: pressure: bmp280: Add identifier names in function definitions Vasileios Amoiridis
2024-05-05 18:54   ` Jonathan Cameron
2024-04-29 19:00 ` [PATCH v5 04/10] iio: pressure: bmp280: Add more intuitive name for bmp180_measure() Vasileios Amoiridis
2024-04-29 19:00 ` [PATCH v5 05/10] iio: pressure: bmp280: Make return values consistent Vasileios Amoiridis
2024-05-05 19:08   ` Jonathan Cameron
2024-05-05 23:08     ` Vasileios Amoiridis
2024-04-29 19:00 ` [PATCH v5 06/10] iio: pressure: bmp280: Refactorize reading functions Vasileios Amoiridis
2024-05-05 19:21   ` Jonathan Cameron
2024-05-05 23:47     ` Vasileios Amoiridis
2024-05-06 12:46       ` Jonathan Cameron
2024-04-29 19:00 ` [PATCH v5 07/10] iio: pressure: bmp280: Introduce new cleanup routines Vasileios Amoiridis
2024-05-05 19:22   ` Jonathan Cameron
2024-04-29 19:00 ` [PATCH v5 08/10] iio: pressure: bmp280: Generalize read_{temp,press,humid}() functions Vasileios Amoiridis
2024-04-29 19:00 ` [PATCH v5 09/10] iio: pressure: bmp280: Add SCALE, RAW values in channels and refactorize them Vasileios Amoiridis
2024-04-29 19:00 ` [PATCH v5 10/10] iio: pressure: bmp280: Add triggered buffer support Vasileios Amoiridis
2024-05-05 19:34   ` Jonathan Cameron
2024-05-05 23:57     ` Vasileios Amoiridis
2024-05-06 12:50       ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240505195155.0c682ec2@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=579lpy@gmail.com \
    --cc=ak@it-klinger.de \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=ang.iglesiasg@gmail.com \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mazziesaccount@gmail.com \
    --cc=petre.rodan@subdimension.ro \
    --cc=phil@raspberrypi.com \
    --cc=semen.protsenko@linaro.org \
    --cc=vassilisamir@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox