Skip to contentSkip to conversation

staging: iio: accel: fix multiple checkpatch issues

PATCH New Ioana Ciornei 1 participant 9 messages Oct 28, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover staging: iio: accel: fix multiple checkpatch issues

This patchset fixes multiple checkpatch issues.

Ioana Ciornei (8):
staging: iio: accel: add spaces aroung binary operators
staging: iio: accel: properly align function arguments
staging: iio: accel: change uint8_t to u8
staging: iio: accel: add blank lines after function definitions
staging: iio: accel: fix block comments alignment
staging: iio: accel: remove unwanted blank lines
staging: iio: accel: place logical operators on the previous line
staging: iio: accel: add bracket on all branches of the if/else

 drivers/staging/iio/accel/lis3l02dq_core.c | 10 +++--
 drivers/staging/iio/accel/lis3l02dq_ring.c | 24 +++++------
 drivers/staging/iio/accel/sca3000_core.c   | 65 +++++++++++++++---------------
 drivers/staging/iio/accel/sca3000_ring.c   | 17 ++++----
 4 files changed, 60 insertions(+), 56 deletions(-)
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/8 staging: iio: accel: add spaces aroung binary operators

This patch adds spaces around binary operators such as '*', '/', '+' in order to improve readability.

---
 drivers/staging/iio/accel/lis3l02dq_core.c |  4 ++--
 drivers/staging/iio/accel/lis3l02dq_ring.c | 24 ++++++++++++------------
 drivers/staging/iio/accel/sca3000_core.c   | 28 ++++++++++++++--------------
 drivers/staging/iio/accel/sca3000_ring.c   |  4 ++--
 4 files changed, 30 insertions(+), 30 deletions(-)
drivers/staging/iio/accel/lis3l02dq_core.c +2 -2
index ebcab56..db28b55 100644
@@ -565,7 +565,7 @@ static int lis3l02dq_read_event_config(struct iio_dev *indio_dev,
 {
 	u8 val;
 	int ret;
-	u8 mask = (1 << (chan->channel2*2 + (dir == IIO_EV_DIR_RISING)));
+	u8 mask = (1 << (chan->channel2 * 2 + (dir == IIO_EV_DIR_RISING)));
 
 	ret = lis3l02dq_spi_read_reg_8(indio_dev,
 				       LIS3L02DQ_REG_WAKE_UP_CFG_ADDR,
@@ -620,7 +620,7 @@ static int lis3l02dq_write_event_config(struct iio_dev *indio_dev,
 	u8 val, control;
 	u8 currentlyset;
 	bool changed = false;
-	u8 mask = (1 << (chan->channel2*2 + (dir == IIO_EV_DIR_RISING)));
+	u8 mask = (1 << (chan->channel2 * 2 + (dir == IIO_EV_DIR_RISING)));
 
 	mutex_lock(&indio_dev->mlock);
 	/* read current control */
drivers/staging/iio/accel/lis3l02dq_ring.c +12 -12
index 1a0651c..50c162e 100644
@@ -69,25 +69,25 @@ static int lis3l02dq_read_all(struct iio_dev *indio_dev, u8 *rx_array)
 
 	mutex_lock(&st->buf_lock);
 
-	for (i = 0; i < ARRAY_SIZE(read_all_tx_array)/4; i++)
+	for (i = 0; i < ARRAY_SIZE(read_all_tx_array) / 4; i++)
 		if (test_bit(i, indio_dev->active_scan_mask)) {
 			/* lower byte */
-			xfers[j].tx_buf = st->tx + 2*j;
-			st->tx[2*j] = read_all_tx_array[i*4];
-			st->tx[2*j + 1] = 0;
+			xfers[j].tx_buf = st->tx + (2 * j);
+			st->tx[2 * j] = read_all_tx_array[i * 4];
+			st->tx[2 * j + 1] = 0;
 			if (rx_array)
-				xfers[j].rx_buf = rx_array + j*2;
+				xfers[j].rx_buf = rx_array + (j * 2);
 			xfers[j].bits_per_word = 8;
 			xfers[j].len = 2;
 			xfers[j].cs_change = 1;
 			j++;
 
 			/* upper byte */
-			xfers[j].tx_buf = st->tx + 2*j;
-			st->tx[2*j] = read_all_tx_array[i*4 + 2];
-			st->tx[2*j + 1] = 0;
+			xfers[j].tx_buf = st->tx + (2 * j);
+			st->tx[2 * j] = read_all_tx_array[i * 4 + 2];
+			st->tx[2 * j + 1] = 0;
 			if (rx_array)
-				xfers[j].rx_buf = rx_array + j*2;
+				xfers[j].rx_buf = rx_array + (j * 2);
 			xfers[j].bits_per_word = 8;
 			xfers[j].len = 2;
 			xfers[j].cs_change = 1;
@@ -127,11 +127,11 @@ static int lis3l02dq_get_buffer_element(struct iio_dev *indio_dev,
 		return ret;
 	}
 	for (i = 0; i < scan_count; i++)
-		data[i] = combine_8_to_16(rx_array[i*4+1],
-					rx_array[i*4+3]);
+		data[i] = combine_8_to_16(rx_array[i * 4 + 1],
+					rx_array[i * 4 + 3]);
 	kfree(rx_array);
 
-	return i*sizeof(data[0]);
+	return i * sizeof(data[0]);
 }
 
 static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p)
drivers/staging/iio/accel/sca3000_core.c +14 -14
index b614f27..311c8a1 100644
@@ -471,8 +471,8 @@ static int sca3000_read_raw(struct iio_dev *indio_dev,
 				return ret;
 			}
 			*val = (be16_to_cpup((__be16 *)st->rx) >> 3) & 0x1FFF;
-			*val = ((*val) << (sizeof(*val)*8 - 13)) >>
-				(sizeof(*val)*8 - 13);
+			*val = ((*val) << (sizeof(*val) * 8 - 13)) >>
+				(sizeof(*val) * 8 - 13);
 		} else {
 			/* get the temperature when available */
 			ret = sca3000_read_data_short(st,
@@ -529,20 +529,20 @@ static ssize_t sca3000_read_av_freq(struct device *dev,
 	case SCA3000_MEAS_MODE_NORMAL:
 		len += sprintf(buf + len, "%d %d %d\n",
 			       st->info->measurement_mode_freq,
-			       st->info->measurement_mode_freq/2,
-			       st->info->measurement_mode_freq/4);
+			       st->info->measurement_mode_freq / 2,
+			       st->info->measurement_mode_freq / 4);
 		break;
 	case SCA3000_MEAS_MODE_OP_1:
 		len += sprintf(buf + len, "%d %d %d\n",
 			       st->info->option_mode_1_freq,
-			       st->info->option_mode_1_freq/2,
-			       st->info->option_mode_1_freq/4);
+			       st->info->option_mode_1_freq / 2,
+			       st->info->option_mode_1_freq / 4);
 		break;
 	case SCA3000_MEAS_MODE_OP_2:
 		len += sprintf(buf + len, "%d %d %d\n",
 			       st->info->option_mode_2_freq,
-			       st->info->option_mode_2_freq/2,
-			       st->info->option_mode_2_freq/4);
+			       st->info->option_mode_2_freq / 2,
+			       st->info->option_mode_2_freq / 4);
 		break;
 	}
 	return len;
@@ -605,10 +605,10 @@ static ssize_t sca3000_read_frequency(struct device *dev,
 			len = sprintf(buf, "%d\n", base_freq);
 			break;
 		case 0x01:
-			len = sprintf(buf, "%d\n", base_freq/2);
+			len = sprintf(buf, "%d\n", base_freq / 2);
 			break;
 		case 0x02:
-			len = sprintf(buf, "%d\n", base_freq/4);
+			len = sprintf(buf, "%d\n", base_freq / 4);
 			break;
 	}
 
@@ -650,9 +650,9 @@ static ssize_t sca3000_set_frequency(struct device *dev,
 	/* clear the bits */
 	ctrlval &= ~0x03;
 
-	if (val == base_freq/2) {
+	if (val == base_freq / 2) {
 		ctrlval |= SCA3000_OUT_CTRL_BUF_DIV_2;
-	} else if (val == base_freq/4) {
+	} else if (val == base_freq / 4) {
 		ctrlval |= SCA3000_OUT_CTRL_BUF_DIV_4;
 	} else if (val != base_freq) {
 		ret = -EINVAL;
@@ -997,14 +997,14 @@ exit_point:
 
 /* Free fall detector related event attribute */
 static IIO_DEVICE_ATTR_NAMED(accel_xayaz_mag_falling_en,
-			     in_accel_x&y&z_mag_falling_en,
+			     in_accel_x & y & z_mag_falling_en,
 			     S_IRUGO | S_IWUSR,
 			     sca3000_query_free_fall_mode,
 			     sca3000_set_free_fall_mode,
 			     0);
 
 static IIO_CONST_ATTR_NAMED(accel_xayaz_mag_falling_period,
-			    in_accel_x&y&z_mag_falling_period,
+			    in_accel_x & y & z_mag_falling_period,
 			    "0.226");
 
 static struct attribute *sca3000_event_attributes[] = {
drivers/staging/iio/accel/sca3000_ring.c +2 -2
index ac35d03..a029af0 100644
@@ -106,7 +106,7 @@ static int sca3000_read_first_n_hw_rb(struct iio_buffer *r,
 	 * i.e. number of time points * number of channels.
 	 */
 	if (count > num_available * bytes_per_sample)
-		num_read = num_available*bytes_per_sample;
+		num_read = num_available * bytes_per_sample;
 	else
 		num_read = count;
 
@@ -208,7 +208,7 @@ static ssize_t sca3000_show_buffer_scale(struct device *dev,
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct sca3000_state *st = iio_priv(indio_dev);
 
-	return sprintf(buf, "0.%06d\n", 4*st->info->scale);
+	return sprintf(buf, "0.%06d\n", 4 * st->info->scale);
 }
 
 static IIO_DEVICE_ATTR(in_accel_scale,
Signature · 1 line
2.1.4
#2 lore raw

PATCH 2/8 staging: iio: accel: properly align function arguments

In reply to Ioana Ciornei

This patch properly aligns the function arguments or its parameters in order to match the open bracket.

---
 drivers/staging/iio/accel/sca3000_core.c | 17 +++++++++--------
 drivers/staging/iio/accel/sca3000_ring.c |  6 +++---
 2 files changed, 12 insertions(+), 11 deletions(-)
drivers/staging/iio/accel/sca3000_core.c +9 -8
index 311c8a1..6aadaff 100644
@@ -476,7 +476,8 @@ static int sca3000_read_raw(struct iio_dev *indio_dev,
 		} else {
 			/* get the temperature when available */
 			ret = sca3000_read_data_short(st,
-				SCA3000_REG_ADDR_TEMP_MSB, 2);
+						      SCA3000_REG_ADDR_TEMP_MSB,
+						      2);
 			if (ret < 0) {
 				mutex_unlock(&st->lock);
 				return ret;
@@ -511,8 +512,8 @@ static int sca3000_read_raw(struct iio_dev *indio_dev,
  * at all.
  **/
 static ssize_t sca3000_read_av_freq(struct device *dev,
-			     struct device_attribute *attr,
-			     char *buf)
+				    struct device_attribute *attr,
+				    char *buf)
 {
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct sca3000_state *st = iio_priv(indio_dev);
@@ -582,8 +583,8 @@ error_ret:
  * sca3000_read_frequency() sysfs interface to get the current frequency
  **/
 static ssize_t sca3000_read_frequency(struct device *dev,
-			       struct device_attribute *attr,
-			       char *buf)
+				      struct device_attribute *attr,
+				      char *buf)
 {
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct sca3000_state *st = iio_priv(indio_dev);
@@ -623,9 +624,9 @@ error_ret:
  * sca3000_set_frequency() sysfs interface to set the current frequency
  **/
 static ssize_t sca3000_set_frequency(struct device *dev,
-			      struct device_attribute *attr,
-			      const char *buf,
-			      size_t len)
+				     struct device_attribute *attr,
+				     const char *buf,
+				     size_t len)
 {
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct sca3000_state *st = iio_priv(indio_dev);
drivers/staging/iio/accel/sca3000_ring.c +3 -3
index a029af0..f6a6083 100644
@@ -160,9 +160,9 @@ static ssize_t sca3000_query_ring_int(struct device *dev,
  * sca3000_set_ring_int() set state of ring status interrupt
  **/
 static ssize_t sca3000_set_ring_int(struct device *dev,
-				      struct device_attribute *attr,
-				      const char *buf,
-				      size_t len)
+				    struct device_attribute *attr,
+				    const char *buf,
+				    size_t len)
 {
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct sca3000_state *st = iio_priv(indio_dev);
Signature · 1 line
2.1.4
#4 lore raw

PATCH 4/8 staging: iio: accel: add blank lines after function definitions

In reply to Ioana Ciornei

This patch add blank lines after functions definitions in order to follow the linux coding style.

---
 drivers/staging/iio/accel/sca3000_core.c | 2 ++
 drivers/staging/iio/accel/sca3000_ring.c | 1 +
 2 files changed, 3 insertions(+)
drivers/staging/iio/accel/sca3000_core.c +2 -0
index 30fc1ad..961d310 100644
@@ -550,6 +550,7 @@ static ssize_t sca3000_read_av_freq(struct device *dev,
 error_ret:
 	return ret;
 }
+
 /**
  * __sca3000_get_base_freq() obtain mode specific base frequency
  *
@@ -864,6 +865,7 @@ error_ret:
 
 	return ret;
 }
+
 /**
  * sca3000_query_free_fall_mode() is free fall mode enabled
  **/
drivers/staging/iio/accel/sca3000_ring.c +1 -0
index e19e7a4..20b878d 100644
@@ -307,6 +307,7 @@ error_ret:
 
 	return ret;
 }
+
 /**
  * sca3000_hw_ring_preenable() hw ring buffer preenable function
  *
Signature · 1 line
2.1.4
#5 lore raw

PATCH 5/8 staging: iio: accel: fix block comments alignment

In reply to Ioana Ciornei

This patch properly aligns the block comment in order to follow the linux coding style convetions.

---
 drivers/staging/iio/accel/lis3l02dq_core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/iio/accel/lis3l02dq_core.c +4 -2
index db28b55..7a1939a 100644
@@ -406,8 +406,10 @@ static int lis3l02dq_initial_setup(struct iio_dev *indio_dev)
 		goto err_ret;
 	}
 
-	/* Read back to check this has worked acts as loose test of correct
-	 * chip */
+	/*
+	 * Read back to check this has worked acts as loose test of correct
+	 * chip
+	 */
 	ret = lis3l02dq_spi_read_reg_8(indio_dev,
 				       LIS3L02DQ_REG_CTRL_1_ADDR,
 				       &valtest);
Signature · 1 line
2.1.4
#6 lore raw

PATCH 6/8 staging: iio: accel: remove unwanted blank lines

In reply to Ioana Ciornei

This patch removes unwanted blank lines in order to follow the linux coding style.

---
 drivers/staging/iio/accel/sca3000_core.c | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/iio/accel/sca3000_core.c +0 -2
index 961d310..dbe0a64 100644
@@ -168,7 +168,6 @@ static int sca3000_write_ctrl_reg(struct sca3000_state *st,
 				  u8 sel,
 				  uint8_t val)
 {
-
 	int ret;
 
 	ret = sca3000_reg_lock_on(st);
@@ -374,7 +373,6 @@ error_ret:
 	return ret;
 }
 
-
 /*
  * Not even vaguely standard attributes so defined here rather than
  * in the relevant IIO core headers
Signature · 1 line
2.1.4
#7 lore raw

PATCH 7/8 staging: iio: accel: place logical operators on the previous line

In reply to Ioana Ciornei

This patch moves the logical operators on the previous line in order to follow the linux coding style.

---
 drivers/staging/iio/accel/sca3000_core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/iio/accel/sca3000_core.c +4 -4
index dbe0a64..455d896 100644
@@ -980,14 +980,14 @@ static int sca3000_write_event_config(struct iio_dev *indio_dev,
 	if (ret)
 		goto exit_point;
 	/* if off and should be on */
-	if ((st->mo_det_use_count)
-	    && ((st->rx[0] & protect_mask) != SCA3000_MEAS_MODE_MOT_DET))
+	if ((st->mo_det_use_count) &&
+	    ((st->rx[0] & protect_mask) != SCA3000_MEAS_MODE_MOT_DET))
 		ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE,
 					(st->rx[0] & ~protect_mask)
 					| SCA3000_MEAS_MODE_MOT_DET);
 	/* if on and should be off */
-	else if (!(st->mo_det_use_count)
-		 && ((st->rx[0] & protect_mask) == SCA3000_MEAS_MODE_MOT_DET))
+	else if (!(st->mo_det_use_count) &&
+		 ((st->rx[0] & protect_mask) == SCA3000_MEAS_MODE_MOT_DET))
 		ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE,
 					(st->rx[0] & ~protect_mask));
 exit_point:
Signature · 1 line
2.1.4
#8 lore raw

PATCH 8/8 staging: iio: accel: add bracket on all branches of the if/else

In reply to Ioana Ciornei

This patch adds brackets on all of the conditional branches in order to follow the linux coding style.

---
 drivers/staging/iio/accel/sca3000_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/accel/sca3000_core.c +2 -2
index 455d896..03cb225 100644
@@ -849,9 +849,9 @@ static int sca3000_read_event_config(struct iio_dev *indio_dev,
 	if (ret)
 		goto error_ret;
 
-	if ((st->rx[0] & protect_mask) != SCA3000_MEAS_MODE_MOT_DET)
+	if ((st->rx[0] & protect_mask) != SCA3000_MEAS_MODE_MOT_DET) {
 		ret = 0;
-	else {
+	} else {
 		ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_MD_CTRL);
 		if (ret < 0)
 			goto error_ret;
Signature · 1 line
2.1.4
#3 lore raw

PATCH 3/8 staging: iio: accel: change uint8_t to u8

In reply to Ioana Ciornei

This patch changes uint8_t type to preferred kernel type u8 in order to follow the linux coding style conventions.

---
 drivers/staging/iio/accel/sca3000_core.c | 4 ++--
 drivers/staging/iio/accel/sca3000_ring.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/staging/iio/accel/sca3000_core.c +2 -2
index 6aadaff..30fc1ad 100644
@@ -88,7 +88,7 @@ int sca3000_write_reg(struct sca3000_state *st, u8 address, u8 val)
 }
 
 int sca3000_read_data_short(struct sca3000_state *st,
-			    uint8_t reg_address_high,
+			    u8 reg_address_high,
 			    int len)
 {
 	struct spi_transfer xfer[2] = {
@@ -165,7 +165,7 @@ static int __sca3000_unlock_reg_lock(struct sca3000_state *st)
  * Lock must be held.
  **/
 static int sca3000_write_ctrl_reg(struct sca3000_state *st,
-				  uint8_t sel,
+				  u8 sel,
 				  uint8_t val)
 {
 
drivers/staging/iio/accel/sca3000_ring.c +3 -3
index f6a6083..e19e7a4 100644
@@ -34,9 +34,9 @@
  */
 
 static int sca3000_read_data(struct sca3000_state *st,
-			    uint8_t reg_address_high,
-			    u8 **rx_p,
-			    int len)
+			     u8 reg_address_high,
+			     u8 **rx_p,
+			     int len)
 {
 	int ret;
 	struct spi_transfer xfer[2] = {
Signature · 1 line
2.1.4