Skip to contentSkip to conversation

Fix style problems in ad7150 driver

PATCH Superseded Slawomir Stepien 2 participants 5 messages Oct 1, 2018 – Oct 4, 2018

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Fix style problems in ad7150 driver

This series will fix simple style problem inside the ad7150 driver.

Slawomir Stepien (2):
staging: iio: cdc: ad7150: use pointer to shorten the line length
staging: iio: cdc: ad7150: fix misaligned lines

 drivers/staging/iio/cdc/ad7150.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
Signature · 1 line
2.19.0
#1 lore raw

PATCH 1/2 staging: iio: cdc: ad7150: use pointer to shorten the line length

By using the pointer to channel attribute, we can now make the lines short enough to eliminate the checkpatch.pl problem:

CHECK: Alignment should match open parenthesis

---
 drivers/staging/iio/cdc/ad7150.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/staging/iio/cdc/ad7150.c +3 -2
index d16084d7068c..5b5b766a0405 100644
@@ -102,18 +102,19 @@ static int ad7150_read_raw(struct iio_dev *indio_dev,
 {
 	int ret;
 	struct ad7150_chip_info *chip = iio_priv(indio_dev);
+	const int *channel = &chan->channel;
 
 	switch (mask) {
 	case IIO_CHAN_INFO_RAW:
 		ret = i2c_smbus_read_word_data(chip->client,
-					ad7150_addresses[chan->channel][0]);
+					       ad7150_addresses[*channel][0]);
 		if (ret < 0)
 			return ret;
 		*val = swab16(ret);
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_AVERAGE_RAW:
 		ret = i2c_smbus_read_word_data(chip->client,
-					ad7150_addresses[chan->channel][1]);
+					       ad7150_addresses[*channel][1]);
 		if (ret < 0)
 			return ret;
 		*val = swab16(ret);
Signature · 1 line
2.19.0
#2 lore raw

Re: [PATCH 1/2] staging: iio: cdc: ad7150: use pointer to shorten the line length

Quoted 6 lines · Slawomir Stepien

By using the pointer to channel attribute, we can now make the lines short enough to eliminate the checkpatch.pl problem:

CHECK: Alignment should match open parenthesis

Hi,

Thanks for the patch. This looks good. But maybe a small suggestion further improvement.

drivers/staging/iio/cdc/ad7150.c static int ad7150_read_raw(struct iio_dev *indio_dev, · line 105

Quoted 13 lines
---
 drivers/staging/iio/cdc/ad7150.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/staging/iio/cdc/ad7150.c +1 -0
index d16084d7068c..5b5b766a0405 100644
@@ -102,18 +102,19 @@ static int ad7150_read_raw(struct iio_dev *indio_dev,
 {
 	int ret;
 	struct ad7150_chip_info *chip = iio_priv(indio_dev);
+	const int *channel = &chan->channel;

Instead of taking a pointer, just take the value of the channel index and use that. The generated code should be very similar but its a bit nicer to read.

#3 lore raw

Re: [PATCH 1/2] staging: iio: cdc: ad7150: use pointer to shorten the line length

Quoted 4 lines · Lars-Peter Clausen
Quoted 3 lines · Slawomir Stepien
 drivers/staging/iio/cdc/ad7150.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 12 lines

drivers/staging/iio/cdc/ad7150.c static int ad7150_read_raw(struct iio_dev *indio_dev, · line 105

Quoted 9 lines
drivers/staging/iio/cdc/ad7150.c +1 -0
index d16084d7068c..5b5b766a0405 100644
@@ -102,18 +102,19 @@ static int ad7150_read_raw(struct iio_dev *indio_dev,
 {
 	int ret;
 	struct ad7150_chip_info *chip = iio_priv(indio_dev);
+	const int *channel = &chan->channel;

Instead of taking a pointer, just take the value of the channel index and use that. The generated code should be very similar but its a bit nicer to read.

OK. I've been thinking about that for a moment, but in the end decided to go with the pointer. I don't mind the value. I'll prepare v2. Thank you.

Signature · 1 line
Slawomir Stepien
#4 lore raw

PATCH 2/2 staging: iio: cdc: ad7150: fix misaligned lines

In reply to Slawomir Stepien

These lines were misaligned, but the checkpatch.pl didn't indicate them as such.

---
 drivers/staging/iio/cdc/ad7150.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/cdc/ad7150.c +2 -2
index 5b5b766a0405..bbbf05ca2624 100644
@@ -183,8 +183,8 @@ static int ad7150_write_event_params(struct iio_dev *indio_dev,
 	case IIO_EV_TYPE_THRESH:
 		value = chip->threshold[rising][chan];
 		return i2c_smbus_write_word_data(chip->client,
-						ad7150_addresses[chan][3],
-						swab16(value));
+						 ad7150_addresses[chan][3],
+						 swab16(value));
 	case IIO_EV_TYPE_MAG_ADAPTIVE:
 		sens = chip->mag_sensitivity[rising][chan];
 		timeout = chip->mag_timeout[rising][chan];
Signature · 1 line
2.19.0