Skip to contentSkip to conversation

*** SUBJECT HERE ***

PATCH Superseded Cristian Sicilia 3 participants 32 messages Mar 23, 2019 – Mar 31, 2019

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

cover *** SUBJECT HERE ***

Some source refactoring, parameters aligment and camel case clearing.

Replacement of bool to bitfield in a struct, but not found the population to check if it is done correctly.

Cristian Sicilia (5):
staging: iio: adc: Tab alignment
staging: iio: adc: Converted bool to bitfield format
staging: iio: adc: Avoid precedence issues in macro
staging: iio: adc: Adding temp var to improve readability
staging: iio: adc: Remove CamelCase notation

 drivers/staging/iio/adc/ad7192.h  |  16 +++---
 drivers/staging/iio/adc/ad7280a.c | 109 ++++++++++++++++++--------------------
 2 files changed, 60 insertions(+), 65 deletions(-)
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/5 staging: iio: adc: Avoid precedence issues in macro

Enclosing parameter with parenthesis due to avoid
possible precedence issue.

---
 drivers/staging/iio/adc/ad7280a.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/iio/adc/ad7280a.c +4 -3
index 55b5879..d81a5bd 100644
@@ -97,9 +97,10 @@
 #define AD7280A_NUM_CH			(AD7280A_AUX_ADC_6 - \
 					AD7280A_CELL_VOLTAGE_1 + 1)
 
-#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) ((d * AD7280A_CELLS_PER_DEV) + c)
-#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)    ((d * AD7280A_CELLS_PER_DEV) + \
-					     c - AD7280A_CELLS_PER_DEV)
+#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) (((d) * AD7280A_CELLS_PER_DEV) + \
+					     (c))
+#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)    (((d) * AD7280A_CELLS_PER_DEV) + \
+					     (c) - AD7280A_CELLS_PER_DEV)
 
 #define AD7280A_DEVADDR_MASTER		0
 #define AD7280A_DEVADDR_ALL		0x1F
Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/5 staging: iio: adc: Adding temp var to improve readability

In reply to Cristian Sicilia

Creating a temporary variable to improve readability

---
 drivers/staging/iio/adc/ad7280a.c | 55 ++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 30 deletions(-)
drivers/staging/iio/adc/ad7280a.c +25 -30
index d81a5bd..5d848aa 100644
@@ -784,43 +784,38 @@ static irqreturn_t ad7280_event_handler(int irq, void *private)
 	for (i = 0; i < st->scan_cnt; i++) {
 		if (((channels[i] >> 23) & 0xF) <= AD7280A_CELL_VOLTAGE_6) {
 			if (((channels[i] >> 11) & 0xFFF) >=
-				st->cell_threshhigh)
-				iio_push_event(indio_dev,
-					       IIO_EVENT_CODE(IIO_VOLTAGE,
-							1,
-							0,
-							IIO_EV_DIR_RISING,
-							IIO_EV_TYPE_THRESH,
-							0, 0, 0),
+			    st->cell_threshhigh) {
+				u64 tmp = IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0,
+							 IIO_EV_DIR_RISING,
+							 IIO_EV_TYPE_THRESH,
+							 0, 0, 0);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
-			else if (((channels[i] >> 11) & 0xFFF) <=
-				st->cell_threshlow)
-				iio_push_event(indio_dev,
-					       IIO_EVENT_CODE(IIO_VOLTAGE,
-							1,
-							0,
-							IIO_EV_DIR_FALLING,
-							IIO_EV_TYPE_THRESH,
-							0, 0, 0),
+			} else if (((channels[i] >> 11) & 0xFFF) <=
+				   st->cell_threshlow) {
+				u64 tmp = IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0,
+							 IIO_EV_DIR_FALLING,
+							 IIO_EV_TYPE_THRESH,
+							 0, 0, 0);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
+			}
 		} else {
-			if (((channels[i] >> 11) & 0xFFF) >= st->aux_threshhigh)
-				iio_push_event(indio_dev,
-					       IIO_UNMOD_EVENT_CODE(
-							IIO_TEMP,
-							0,
+			if (((channels[i] >> 11) & 0xFFF) >=
+			    st->aux_threshhigh) {
+				u64 tmp = IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
 							IIO_EV_TYPE_THRESH,
-							IIO_EV_DIR_RISING),
+							IIO_EV_DIR_RISING);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
-			else if (((channels[i] >> 11) & 0xFFF) <=
-				st->aux_threshlow)
-				iio_push_event(indio_dev,
-					       IIO_UNMOD_EVENT_CODE(
-							IIO_TEMP,
-							0,
+			} else if (((channels[i] >> 11) & 0xFFF) <=
+				st->aux_threshlow) {
+				u64 tmp = IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
 							IIO_EV_TYPE_THRESH,
-							IIO_EV_DIR_FALLING),
+							IIO_EV_DIR_FALLING);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
+			}
 		}
 	}
 
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/5 staging: iio: adc: Converted bool to bitfield format

In reply to Cristian Sicilia

Changed bool format to bitfield format to save space.

---
The strange thing is that this struct seems not populated using a DTS binding function.

---
 drivers/staging/iio/adc/ad7192.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/staging/iio/adc/ad7192.h +8 -8
index 7433a43..87891ba 100644
@@ -35,13 +35,13 @@ struct ad7192_platform_data {
 	u16		vref_mv;
 	u8		clock_source_sel;
 	u32		ext_clk_hz;
-	bool		refin2_en;
-	bool		rej60_en;
-	bool		sinc3_en;
-	bool		chop_en;
-	bool		buf_en;
-	bool		unipolar_en;
-	bool		burnout_curr_en;
-};
+	u8		refin2_en:1;
+	u8		rej60_en:1;
+	u8		sinc3_en:1;
+	u8		chop_en:1;
+	u8		buf_en:1;
+	u8		unipolar_en:1;
+	u8		burnout_curr_en:1;
+} __attribute__((__packed__));
 
 #endif /* IIO_ADC_AD7192_H_ */
Signature · 1 line
2.7.4
#5 lore raw

PATCH 5/5 staging: iio: adc: Remove CamelCase notation

In reply to Cristian Sicilia
---
 drivers/staging/iio/adc/ad7280a.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/staging/iio/adc/ad7280a.c +5 -6
index 5d848aa..c02454c 100644
@@ -917,8 +917,8 @@ static int ad7280_probe(struct spi_device *spi)
 	const struct ad7280_platform_data *pdata = dev_get_platdata(&spi->dev);
 	struct ad7280_state *st;
 	int ret;
-	const unsigned short tACQ_ns[4] = {465, 1010, 1460, 1890};
-	const unsigned short nAVG[4] = {1, 2, 4, 8};
+	const unsigned short t_acq_ns[4] = {465, 1010, 1460, 1890};
+	const unsigned short n_avg[4] = {1, 2, 4, 8};
 	struct iio_dev *indio_dev;
 
 	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
@@ -966,10 +966,9 @@ static int ad7280_probe(struct spi_device *spi)
 	 */
 
 	st->readback_delay_us =
-		((tACQ_ns[pdata->acquisition_time & 0x3] + 695) *
-		(AD7280A_NUM_CH * nAVG[pdata->conversion_averaging & 0x3]))
-		- tACQ_ns[pdata->acquisition_time & 0x3] +
-		st->slave_num * 250;
+		((t_acq_ns[pdata->acquisition_time & 0x3] + 695) *
+		 (AD7280A_NUM_CH * n_avg[pdata->conversion_averaging & 0x3])) -
+		t_acq_ns[pdata->acquisition_time & 0x3] + st->slave_num * 250;
 
 	/* Convert to usecs */
 	st->readback_delay_us = DIV_ROUND_UP(st->readback_delay_us, 1000);
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/5 staging: iio: adc: Tab alignment

In reply to Cristian Sicilia

Aligned some parameters.

---
 drivers/staging/iio/adc/ad7280a.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/staging/iio/adc/ad7280a.c +18 -18
index d9df126..55b5879 100644
@@ -830,30 +830,30 @@ static irqreturn_t ad7280_event_handler(int irq, void *private)
 }
 
 static IIO_DEVICE_ATTR_NAMED(in_thresh_low_value,
-		in_voltage-voltage_thresh_low_value,
-		0644,
-		ad7280_read_channel_config,
-		ad7280_write_channel_config,
-		AD7280A_CELL_UNDERVOLTAGE);
+			     in_voltage - voltage_thresh_low_value,
+			     0644,
+			     ad7280_read_channel_config,
+			     ad7280_write_channel_config,
+			     AD7280A_CELL_UNDERVOLTAGE);
 
 static IIO_DEVICE_ATTR_NAMED(in_thresh_high_value,
-		in_voltage-voltage_thresh_high_value,
-		0644,
-		ad7280_read_channel_config,
-		ad7280_write_channel_config,
-		AD7280A_CELL_OVERVOLTAGE);
+			     in_voltage - voltage_thresh_high_value,
+			     0644,
+			     ad7280_read_channel_config,
+			     ad7280_write_channel_config,
+			     AD7280A_CELL_OVERVOLTAGE);
 
 static IIO_DEVICE_ATTR(in_temp_thresh_low_value,
-		0644,
-		ad7280_read_channel_config,
-		ad7280_write_channel_config,
-		AD7280A_AUX_ADC_UNDERVOLTAGE);
+		       0644,
+		       ad7280_read_channel_config,
+		       ad7280_write_channel_config,
+		       AD7280A_AUX_ADC_UNDERVOLTAGE);
 
 static IIO_DEVICE_ATTR(in_temp_thresh_high_value,
-		0644,
-		ad7280_read_channel_config,
-		ad7280_write_channel_config,
-		AD7280A_AUX_ADC_OVERVOLTAGE);
+		       0644,
+		       ad7280_read_channel_config,
+		       ad7280_write_channel_config,
+		       AD7280A_AUX_ADC_OVERVOLTAGE);
 
 static struct attribute *ad7280_event_attributes[] = {
 	&iio_dev_attr_in_thresh_low_value.dev_attr.attr,
Signature · 1 line
2.7.4
#6 lore raw

v2 cover staging: iio: adc: Code refactoring and bool to bitfield change

In reply to Cristian Sicilia

Some source refactoring, parameters alignment and camel case clearing.

Replacement of bool to bitfield in a struct, but not found the population to check if it is done correctly.

Cristian Sicilia (5):
staging: iio: adc: Tab alignment
staging: iio: adc: Converted bool to bitfield format
staging: iio: adc: Avoid precedence issues in macro
staging: iio: adc: Adding temp var to improve readability
staging: iio: adc: Remove CamelCase notation

 drivers/staging/iio/adc/ad7192.h  |  16 +++---
 drivers/staging/iio/adc/ad7280a.c | 109 ++++++++++++++++++--------------------
 2 files changed, 60 insertions(+), 65 deletions(-)
Signature · 1 line
2.7.4
#7 lore raw

PATCH v2 1/5 staging: iio: adc: Tab alignment

Aligned some parameters.

---
 drivers/staging/iio/adc/ad7280a.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/staging/iio/adc/ad7280a.c +18 -18
index d9df126..55b5879 100644
@@ -830,30 +830,30 @@ static irqreturn_t ad7280_event_handler(int irq, void *private)
 }
 
 static IIO_DEVICE_ATTR_NAMED(in_thresh_low_value,
-		in_voltage-voltage_thresh_low_value,
-		0644,
-		ad7280_read_channel_config,
-		ad7280_write_channel_config,
-		AD7280A_CELL_UNDERVOLTAGE);
+			     in_voltage - voltage_thresh_low_value,
+			     0644,
+			     ad7280_read_channel_config,
+			     ad7280_write_channel_config,
+			     AD7280A_CELL_UNDERVOLTAGE);
 
 static IIO_DEVICE_ATTR_NAMED(in_thresh_high_value,
-		in_voltage-voltage_thresh_high_value,
-		0644,
-		ad7280_read_channel_config,
-		ad7280_write_channel_config,
-		AD7280A_CELL_OVERVOLTAGE);
+			     in_voltage - voltage_thresh_high_value,
+			     0644,
+			     ad7280_read_channel_config,
+			     ad7280_write_channel_config,
+			     AD7280A_CELL_OVERVOLTAGE);
 
 static IIO_DEVICE_ATTR(in_temp_thresh_low_value,
-		0644,
-		ad7280_read_channel_config,
-		ad7280_write_channel_config,
-		AD7280A_AUX_ADC_UNDERVOLTAGE);
+		       0644,
+		       ad7280_read_channel_config,
+		       ad7280_write_channel_config,
+		       AD7280A_AUX_ADC_UNDERVOLTAGE);
 
 static IIO_DEVICE_ATTR(in_temp_thresh_high_value,
-		0644,
-		ad7280_read_channel_config,
-		ad7280_write_channel_config,
-		AD7280A_AUX_ADC_OVERVOLTAGE);
+		       0644,
+		       ad7280_read_channel_config,
+		       ad7280_write_channel_config,
+		       AD7280A_AUX_ADC_OVERVOLTAGE);
 
 static struct attribute *ad7280_event_attributes[] = {
 	&iio_dev_attr_in_thresh_low_value.dev_attr.attr,
Signature · 1 line
2.7.4
#10 lore raw

PATCH v2 2/5 staging: iio: adc: Converted bool to bitfield format

In reply to Cristian Sicilia

Changed bool format to bitfield format to save space.

---
The strange thing is that this struct seems not populated using a DTS binding function.

---
 drivers/staging/iio/adc/ad7192.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/staging/iio/adc/ad7192.h +8 -8
index 7433a43..87891ba 100644
@@ -35,13 +35,13 @@ struct ad7192_platform_data {
 	u16		vref_mv;
 	u8		clock_source_sel;
 	u32		ext_clk_hz;
-	bool		refin2_en;
-	bool		rej60_en;
-	bool		sinc3_en;
-	bool		chop_en;
-	bool		buf_en;
-	bool		unipolar_en;
-	bool		burnout_curr_en;
-};
+	u8		refin2_en:1;
+	u8		rej60_en:1;
+	u8		sinc3_en:1;
+	u8		chop_en:1;
+	u8		buf_en:1;
+	u8		unipolar_en:1;
+	u8		burnout_curr_en:1;
+} __attribute__((__packed__));
 
 #endif /* IIO_ADC_AD7192_H_ */
Signature · 1 line
2.7.4
#15 lore raw

PATCH v2 4/5 staging: iio: adc: Adding temp var to improve readability

In reply to Cristian Sicilia

Creating a temporary variable to improve readability

---
 drivers/staging/iio/adc/ad7280a.c | 55 ++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 30 deletions(-)
drivers/staging/iio/adc/ad7280a.c +25 -30
index d81a5bd..5d848aa 100644
@@ -784,43 +784,38 @@ static irqreturn_t ad7280_event_handler(int irq, void *private)
 	for (i = 0; i < st->scan_cnt; i++) {
 		if (((channels[i] >> 23) & 0xF) <= AD7280A_CELL_VOLTAGE_6) {
 			if (((channels[i] >> 11) & 0xFFF) >=
-				st->cell_threshhigh)
-				iio_push_event(indio_dev,
-					       IIO_EVENT_CODE(IIO_VOLTAGE,
-							1,
-							0,
-							IIO_EV_DIR_RISING,
-							IIO_EV_TYPE_THRESH,
-							0, 0, 0),
+			    st->cell_threshhigh) {
+				u64 tmp = IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0,
+							 IIO_EV_DIR_RISING,
+							 IIO_EV_TYPE_THRESH,
+							 0, 0, 0);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
-			else if (((channels[i] >> 11) & 0xFFF) <=
-				st->cell_threshlow)
-				iio_push_event(indio_dev,
-					       IIO_EVENT_CODE(IIO_VOLTAGE,
-							1,
-							0,
-							IIO_EV_DIR_FALLING,
-							IIO_EV_TYPE_THRESH,
-							0, 0, 0),
+			} else if (((channels[i] >> 11) & 0xFFF) <=
+				   st->cell_threshlow) {
+				u64 tmp = IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0,
+							 IIO_EV_DIR_FALLING,
+							 IIO_EV_TYPE_THRESH,
+							 0, 0, 0);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
+			}
 		} else {
-			if (((channels[i] >> 11) & 0xFFF) >= st->aux_threshhigh)
-				iio_push_event(indio_dev,
-					       IIO_UNMOD_EVENT_CODE(
-							IIO_TEMP,
-							0,
+			if (((channels[i] >> 11) & 0xFFF) >=
+			    st->aux_threshhigh) {
+				u64 tmp = IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
 							IIO_EV_TYPE_THRESH,
-							IIO_EV_DIR_RISING),
+							IIO_EV_DIR_RISING);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
-			else if (((channels[i] >> 11) & 0xFFF) <=
-				st->aux_threshlow)
-				iio_push_event(indio_dev,
-					       IIO_UNMOD_EVENT_CODE(
-							IIO_TEMP,
-							0,
+			} else if (((channels[i] >> 11) & 0xFFF) <=
+				st->aux_threshlow) {
+				u64 tmp = IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
 							IIO_EV_TYPE_THRESH,
-							IIO_EV_DIR_FALLING),
+							IIO_EV_DIR_FALLING);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
+			}
 		}
 	}
 
Signature · 1 line
2.7.4
#17 lore raw

PATCH v2 5/5 staging: iio: adc: Remove CamelCase notation

In reply to Cristian Sicilia

Fix CamelCase naming.

---
 drivers/staging/iio/adc/ad7280a.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/staging/iio/adc/ad7280a.c +5 -6
index 5d848aa..c02454c 100644
@@ -917,8 +917,8 @@ static int ad7280_probe(struct spi_device *spi)
 	const struct ad7280_platform_data *pdata = dev_get_platdata(&spi->dev);
 	struct ad7280_state *st;
 	int ret;
-	const unsigned short tACQ_ns[4] = {465, 1010, 1460, 1890};
-	const unsigned short nAVG[4] = {1, 2, 4, 8};
+	const unsigned short t_acq_ns[4] = {465, 1010, 1460, 1890};
+	const unsigned short n_avg[4] = {1, 2, 4, 8};
 	struct iio_dev *indio_dev;
 
 	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
@@ -966,10 +966,9 @@ static int ad7280_probe(struct spi_device *spi)
 	 */
 
 	st->readback_delay_us =
-		((tACQ_ns[pdata->acquisition_time & 0x3] + 695) *
-		(AD7280A_NUM_CH * nAVG[pdata->conversion_averaging & 0x3]))
-		- tACQ_ns[pdata->acquisition_time & 0x3] +
-		st->slave_num * 250;
+		((t_acq_ns[pdata->acquisition_time & 0x3] + 695) *
+		 (AD7280A_NUM_CH * n_avg[pdata->conversion_averaging & 0x3])) -
+		t_acq_ns[pdata->acquisition_time & 0x3] + st->slave_num * 250;
 
 	/* Convert to usecs */
 	st->readback_delay_us = DIV_ROUND_UP(st->readback_delay_us, 1000);
Signature · 1 line
2.7.4
#13 lore raw

PATCH v2 3/5 staging: iio: adc: Avoid precedence issues in macro

In reply to Cristian Sicilia

Enclosing parameter with parenthesis due to avoid
possible precedence issue.

---
 drivers/staging/iio/adc/ad7280a.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/iio/adc/ad7280a.c +4 -3
index 55b5879..d81a5bd 100644
@@ -97,9 +97,10 @@
 #define AD7280A_NUM_CH			(AD7280A_AUX_ADC_6 - \
 					AD7280A_CELL_VOLTAGE_1 + 1)
 
-#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) ((d * AD7280A_CELLS_PER_DEV) + c)
-#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)    ((d * AD7280A_CELLS_PER_DEV) + \
-					     c - AD7280A_CELLS_PER_DEV)
+#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) (((d) * AD7280A_CELLS_PER_DEV) + \
+					     (c))
+#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)    (((d) * AD7280A_CELLS_PER_DEV) + \
+					     (c) - AD7280A_CELLS_PER_DEV)
 
 #define AD7280A_DEVADDR_MASTER		0
 #define AD7280A_DEVADDR_ALL		0x1F
Signature · 1 line
2.7.4
#31 lore raw
In reply to Cristian Sicilia

You may want to change "*** SUBJECT HERE ***" in the future :)

- Matt

Quoted 20 lines · Cristian Sicilia

Some source refactoring, parameters aligment and camel case clearing.

Replacement of bool to bitfield in a struct, but not found the population to check if it is done correctly.

Cristian Sicilia (5):
staging: iio: adc: Tab alignment
staging: iio: adc: Converted bool to bitfield format
staging: iio: adc: Avoid precedence issues in macro
staging: iio: adc: Adding temp var to improve readability
staging: iio: adc: Remove CamelCase notation

 drivers/staging/iio/adc/ad7192.h  |  16 +++---
 drivers/staging/iio/adc/ad7280a.c | 109 ++++++++++++++++++--------------------
 2 files changed, 60 insertions(+), 65 deletions(-)

--
2.7.4

maintainer
#11 lore raw

Re: [PATCH v2 2/5] staging: iio: adc: Converted bool to bitfield format

In reply to Cristian Sicilia
Quoted 7 lines · On Sat, 23 Mar 2019 20:21:39 +0100 Cristian Sicilia…

Changed bool format to bitfield format to save space.

---
The strange thing is that this struct seems not populated using a DTS binding function.

Indeed and that should have definitely been a warning sign ;) We are looking at traditional platform data here (pre device tree) and generally we will want to drop it entirely for old drivers that we are looking to move out of staging.

I don't mind improving it prior to dropping (as it avoids setting bad precedence in the code base in the meantime) but one comment inline...

Quoted 18 lines
---
 drivers/staging/iio/adc/ad7192.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/staging/iio/adc/ad7192.h +0 -6
index 7433a43..87891ba 100644
@@ -35,13 +35,13 @@ struct ad7192_platform_data {
 	u16		vref_mv;
 	u8		clock_source_sel;
 	u32		ext_clk_hz;
-	bool		refin2_en;
-	bool		rej60_en;
-	bool		sinc3_en;
-	bool		chop_en;
-	bool		buf_en;
-	bool		unipolar_en;

drivers/staging/iio/adc/ad7192.h struct ad7192_platform_data { · line 45

Quoted 10 lines
drivers/staging/iio/adc/ad7192.h +8 -2
-	bool		burnout_curr_en;
-};
+	u8		refin2_en:1;
+	u8		rej60_en:1;
+	u8		sinc3_en:1;
+	u8		chop_en:1;
+	u8		buf_en:1;
+	u8		unipolar_en:1;
+	u8		burnout_curr_en:1;
+} __attribute__((__packed__));

Please don't use packed for anything without a very very good reason. it may result in data layouts that are much harder to read from. That obviously doesn't matter here as I doubt it's read in a fast path.

Quoted 2 lines
drivers/staging/iio/adc/ad7192.h +0 -0
 #endif /* IIO_ADC_AD7192_H_ */
maintainer
#8 lore raw

Re: [PATCH v2 1/5] staging: iio: adc: Tab alignment

In reply to Cristian Sicilia
Quoted 12 lines · On Sat, 23 Mar 2019 20:21:36 +0100 Cristian Sicilia…

Aligned some parameters.

---
 drivers/staging/iio/adc/ad7280a.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/staging/iio/adc/ad7280a.c +0 -0
index d9df126..55b5879 100644

drivers/staging/iio/adc/ad7280a.c static irqreturn_t ad7280_event_handler(int irq, void *private) · line 833

Quoted 9 lines
drivers/staging/iio/adc/ad7280a.c +1 -5
@@ -830,30 +830,30 @@ static irqreturn_t ad7280_event_handler(int irq, void *private)
 }
 
 static IIO_DEVICE_ATTR_NAMED(in_thresh_low_value,
-		in_voltage-voltage_thresh_low_value,
-		0644,
-		ad7280_read_channel_config,
-		ad7280_write_channel_config,
-		AD7280A_CELL_UNDERVOLTAGE);
+			     in_voltage - voltage_thresh_low_value,

Firstly, that isn't in your description and secondly you just broke the userspace ABI. Take a very good look at what is happening here.

Quoted 39 lines
drivers/staging/iio/adc/ad7280a.c +17 -13
+			     0644,
+			     ad7280_read_channel_config,
+			     ad7280_write_channel_config,
+			     AD7280A_CELL_UNDERVOLTAGE);
 
 static IIO_DEVICE_ATTR_NAMED(in_thresh_high_value,
-		in_voltage-voltage_thresh_high_value,
-		0644,
-		ad7280_read_channel_config,
-		ad7280_write_channel_config,
-		AD7280A_CELL_OVERVOLTAGE);
+			     in_voltage - voltage_thresh_high_value,
+			     0644,
+			     ad7280_read_channel_config,
+			     ad7280_write_channel_config,
+			     AD7280A_CELL_OVERVOLTAGE);
 
 static IIO_DEVICE_ATTR(in_temp_thresh_low_value,
-		0644,
-		ad7280_read_channel_config,
-		ad7280_write_channel_config,
-		AD7280A_AUX_ADC_UNDERVOLTAGE);
+		       0644,
+		       ad7280_read_channel_config,
+		       ad7280_write_channel_config,
+		       AD7280A_AUX_ADC_UNDERVOLTAGE);
 
 static IIO_DEVICE_ATTR(in_temp_thresh_high_value,
-		0644,
-		ad7280_read_channel_config,
-		ad7280_write_channel_config,
-		AD7280A_AUX_ADC_OVERVOLTAGE);
+		       0644,
+		       ad7280_read_channel_config,
+		       ad7280_write_channel_config,
+		       AD7280A_AUX_ADC_OVERVOLTAGE);
 
 static struct attribute *ad7280_event_attributes[] = {
 	&iio_dev_attr_in_thresh_low_value.dev_attr.attr,
maintainer Applied
#14 lore raw

Re: [PATCH v2 3/5] staging: iio: adc: Avoid precedence issues in macro

In reply to Cristian Sicilia
Quoted 4 lines · On Sat, 23 Mar 2019 20:21:42 +0100 Cristian Sicilia…

Enclosing parameter with parenthesis due to avoid
possible precedence issue.

Applied to the togreg branch of iio.git which will get first pushed out as testing for the autobuilders to play with it.

Thanks,

Jonathan

Quoted 22 lines
---
 drivers/staging/iio/adc/ad7280a.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/iio/adc/ad7280a.c +4 -3
index 55b5879..d81a5bd 100644
@@ -97,9 +97,10 @@
 #define AD7280A_NUM_CH			(AD7280A_AUX_ADC_6 - \
 					AD7280A_CELL_VOLTAGE_1 + 1)
 
-#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) ((d * AD7280A_CELLS_PER_DEV) + c)
-#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)    ((d * AD7280A_CELLS_PER_DEV) + \
-					     c - AD7280A_CELLS_PER_DEV)
+#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) (((d) * AD7280A_CELLS_PER_DEV) + \
+					     (c))
+#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)    (((d) * AD7280A_CELLS_PER_DEV) + \
+					     (c) - AD7280A_CELLS_PER_DEV)
 
 #define AD7280A_DEVADDR_MASTER		0
 #define AD7280A_DEVADDR_ALL		0x1F
maintainer Applied
#16 lore raw

Re: [PATCH v2 4/5] staging: iio: adc: Adding temp var to improve readability

In reply to Cristian Sicilia
Quoted 3 lines · On Sat, 23 Mar 2019 20:21:45 +0100 Cristian Sicilia…

Creating a temporary variable to improve readability

Indeed makes it a little more readable, so fair enough.

Applied

Thanks,

Jonathan

Quoted 77 lines
---
 drivers/staging/iio/adc/ad7280a.c | 55 ++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 30 deletions(-)
drivers/staging/iio/adc/ad7280a.c +25 -30
index d81a5bd..5d848aa 100644
@@ -784,43 +784,38 @@ static irqreturn_t ad7280_event_handler(int irq, void *private)
 	for (i = 0; i < st->scan_cnt; i++) {
 		if (((channels[i] >> 23) & 0xF) <= AD7280A_CELL_VOLTAGE_6) {
 			if (((channels[i] >> 11) & 0xFFF) >=
-				st->cell_threshhigh)
-				iio_push_event(indio_dev,
-					       IIO_EVENT_CODE(IIO_VOLTAGE,
-							1,
-							0,
-							IIO_EV_DIR_RISING,
-							IIO_EV_TYPE_THRESH,
-							0, 0, 0),
+			    st->cell_threshhigh) {
+				u64 tmp = IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0,
+							 IIO_EV_DIR_RISING,
+							 IIO_EV_TYPE_THRESH,
+							 0, 0, 0);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
-			else if (((channels[i] >> 11) & 0xFFF) <=
-				st->cell_threshlow)
-				iio_push_event(indio_dev,
-					       IIO_EVENT_CODE(IIO_VOLTAGE,
-							1,
-							0,
-							IIO_EV_DIR_FALLING,
-							IIO_EV_TYPE_THRESH,
-							0, 0, 0),
+			} else if (((channels[i] >> 11) & 0xFFF) <=
+				   st->cell_threshlow) {
+				u64 tmp = IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0,
+							 IIO_EV_DIR_FALLING,
+							 IIO_EV_TYPE_THRESH,
+							 0, 0, 0);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
+			}
 		} else {
-			if (((channels[i] >> 11) & 0xFFF) >= st->aux_threshhigh)
-				iio_push_event(indio_dev,
-					       IIO_UNMOD_EVENT_CODE(
-							IIO_TEMP,
-							0,
+			if (((channels[i] >> 11) & 0xFFF) >=
+			    st->aux_threshhigh) {
+				u64 tmp = IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
 							IIO_EV_TYPE_THRESH,
-							IIO_EV_DIR_RISING),
+							IIO_EV_DIR_RISING);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
-			else if (((channels[i] >> 11) & 0xFFF) <=
-				st->aux_threshlow)
-				iio_push_event(indio_dev,
-					       IIO_UNMOD_EVENT_CODE(
-							IIO_TEMP,
-							0,
+			} else if (((channels[i] >> 11) & 0xFFF) <=
+				st->aux_threshlow) {
+				u64 tmp = IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
 							IIO_EV_TYPE_THRESH,
-							IIO_EV_DIR_FALLING),
+							IIO_EV_DIR_FALLING);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
+			}
 		}
 	}
 
maintainer Applied
#18 lore raw

Re: [PATCH v2 5/5] staging: iio: adc: Remove CamelCase notation

In reply to Cristian Sicilia
Quoted 3 lines · On Sat, 23 Mar 2019 20:21:49 +0100 Cristian Sicilia…

Fix CamelCase naming.

Applied.

Note that I added the part number to the titles of all these patches so that people can readily see what they are actually changing. Directory isn't very helpful when there can potentially be many 10s of drivers in there (not true in this case, but still more than 1!)

Thanks,

Jonathan

Quoted 33 lines
---
 drivers/staging/iio/adc/ad7280a.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/staging/iio/adc/ad7280a.c +5 -6
index 5d848aa..c02454c 100644
@@ -917,8 +917,8 @@ static int ad7280_probe(struct spi_device *spi)
 	const struct ad7280_platform_data *pdata = dev_get_platdata(&spi->dev);
 	struct ad7280_state *st;
 	int ret;
-	const unsigned short tACQ_ns[4] = {465, 1010, 1460, 1890};
-	const unsigned short nAVG[4] = {1, 2, 4, 8};
+	const unsigned short t_acq_ns[4] = {465, 1010, 1460, 1890};
+	const unsigned short n_avg[4] = {1, 2, 4, 8};
 	struct iio_dev *indio_dev;
 
 	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
@@ -966,10 +966,9 @@ static int ad7280_probe(struct spi_device *spi)
 	 */
 
 	st->readback_delay_us =
-		((tACQ_ns[pdata->acquisition_time & 0x3] + 695) *
-		(AD7280A_NUM_CH * nAVG[pdata->conversion_averaging & 0x3]))
-		- tACQ_ns[pdata->acquisition_time & 0x3] +
-		st->slave_num * 250;
+		((t_acq_ns[pdata->acquisition_time & 0x3] + 695) *
+		 (AD7280A_NUM_CH * n_avg[pdata->conversion_averaging & 0x3])) -
+		t_acq_ns[pdata->acquisition_time & 0x3] + st->slave_num * 250;
 
 	/* Convert to usecs */
 	st->readback_delay_us = DIV_ROUND_UP(st->readback_delay_us, 1000);
#12 lore raw

Re: [PATCH v2 2/5] staging: iio: adc: Converted bool to bitfield format

In reply to Jonathan Cameron
Quoted 10 lines · Jonathan Cameron
Quoted 7 lines · On Sat, 23 Mar 2019 20:21:39 +0100 Cristian Sicilia…

Changed bool format to bitfield format to save space.

---
The strange thing is that this struct seems not populated using a DTS binding function.

Quoted 9 lines

Indeed and that should have definitely been a warning sign ;) We are looking at traditional platform data here (pre device tree) and generally we will want to drop it entirely for old drivers that we are looking to move out of staging.

I don't mind improving it prior to dropping (as it avoids setting bad precedence in the code base in the meantime) but one comment inline...

Thanks for comment

Quoted 23 lines
Quoted 23 lines
---
 drivers/staging/iio/adc/ad7192.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/staging/iio/adc/ad7192.h +3 -8
index 7433a43..87891ba 100644
@@ -35,13 +35,13 @@ struct ad7192_platform_data {
 	u16		vref_mv;
 	u8		clock_source_sel;
 	u32		ext_clk_hz;
-	bool		refin2_en;
-	bool		rej60_en;
-	bool		sinc3_en;
-	bool		chop_en;
-	bool		buf_en;
-	bool		unipolar_en;
-	bool		burnout_curr_en;
-};
+	u8		refin2_en:1;
+	u8		rej60_en:1;
+	u8		sinc3_en:1;
Quoted 8 lines

drivers/staging/iio/adc/ad7192.h struct ad7192_platform_data { · line 45

Quoted 5 lines
drivers/staging/iio/adc/ad7192.h +5 -0
+	u8		chop_en:1;
+	u8		buf_en:1;
+	u8		unipolar_en:1;
+	u8		burnout_curr_en:1;
+} __attribute__((__packed__));

Please don't use packed for anything without a very very good reason. it may result in data layouts that are much harder to read from. That obviously doesn't matter here as I doubt it's read in a fast path.

Ok, I remove it, thanks

Quoted 4 lines
Quoted 3 lines
drivers/staging/iio/adc/ad7192.h +0 -0
 #endif /* IIO_ADC_AD7192_H_ */
#9 lore raw

Re: [PATCH v2 1/5] staging: iio: adc: Tab alignment

In reply to Jonathan Cameron
Quoted 17 lines · Jonathan Cameron
Quoted 14 lines · On Sat, 23 Mar 2019 20:21:36 +0100 Cristian Sicilia…

Aligned some parameters.

---
 drivers/staging/iio/adc/ad7280a.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/staging/iio/adc/ad7280a.c +0 -0
index d9df126..55b5879 100644
@@ -830,30 +830,30 @@ static irqreturn_t ad7280_event_handler(int irq, void *private)
 }
 
Quoted 9 lines

drivers/staging/iio/adc/ad7280a.c static irqreturn_t ad7280_event_handler(int irq, void *private) · line 833

Quoted 7 lines
drivers/staging/iio/adc/ad7280a.c +1 -5
 static IIO_DEVICE_ATTR_NAMED(in_thresh_low_value,
-           in_voltage-voltage_thresh_low_value,
-           0644,
-           ad7280_read_channel_config,
-           ad7280_write_channel_config,
-           AD7280A_CELL_UNDERVOLTAGE);
+                        in_voltage - voltage_thresh_low_value,

Firstly, that isn't in your description and secondly you just broke the userspace ABI. Take a very good look at what is happening here.

Yes sorry, it will badly stringify, I fix it

Quoted 41 lines
Quoted 40 lines
drivers/staging/iio/adc/ad7280a.c +17 -13
+                        0644,
+                        ad7280_read_channel_config,
+                        ad7280_write_channel_config,
+                        AD7280A_CELL_UNDERVOLTAGE);
 
 static IIO_DEVICE_ATTR_NAMED(in_thresh_high_value,
-           in_voltage-voltage_thresh_high_value,
-           0644,
-           ad7280_read_channel_config,
-           ad7280_write_channel_config,
-           AD7280A_CELL_OVERVOLTAGE);
+                        in_voltage - voltage_thresh_high_value,
+                        0644,
+                        ad7280_read_channel_config,
+                        ad7280_write_channel_config,
+                        AD7280A_CELL_OVERVOLTAGE);
 
 static IIO_DEVICE_ATTR(in_temp_thresh_low_value,
-           0644,
-           ad7280_read_channel_config,
-           ad7280_write_channel_config,
-           AD7280A_AUX_ADC_UNDERVOLTAGE);
+                  0644,
+                  ad7280_read_channel_config,
+                  ad7280_write_channel_config,
+                  AD7280A_AUX_ADC_UNDERVOLTAGE);
 
 static IIO_DEVICE_ATTR(in_temp_thresh_high_value,
-           0644,
-           ad7280_read_channel_config,
-           ad7280_write_channel_config,
-           AD7280A_AUX_ADC_OVERVOLTAGE);
+                  0644,
+                  ad7280_read_channel_config,
+                  ad7280_write_channel_config,
+                  AD7280A_AUX_ADC_OVERVOLTAGE);
 
 static struct attribute *ad7280_event_attributes[] = {
    &iio_dev_attr_in_thresh_low_value.dev_attr.attr,
#19 lore raw

v2 cover staging: iio: adc: Code refactoring and bool to bitfield change

In reply to Cristian Sicilia

Some source refactoring, parameters alignment and camel case clearing.

Replacement of bool to bitfield in a struct, but not found the population to check if it is done correctly.

Cristian Sicilia (5):
staging: iio: adc: ad7280a: Tab alignment
staging: iio: adc: ad7192: Converted bool to bitfield format
staging: iio: adc: ad7280a: Avoid precedence issues in macro
staging: iio: adc: ad7280a: Adding temp var to improve readability
staging: iio: adc: ad7280a: Remove CamelCase notation

 drivers/staging/iio/adc/ad7192.h  |  14 ++---
 drivers/staging/iio/adc/ad7280a.c | 109 ++++++++++++++++++--------------------
 2 files changed, 59 insertions(+), 64 deletions(-)
Signature · 1 line
2.7.4
#20 lore raw

PATCH v3 1/5 staging: iio: adc: ad7280a: Tab alignment

Aligned some parameters.

---
 drivers/staging/iio/adc/ad7280a.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/staging/iio/adc/ad7280a.c +18 -18
index d9df126..571535d 100644
@@ -830,30 +830,30 @@ static irqreturn_t ad7280_event_handler(int irq, void *private)
 }
 
 static IIO_DEVICE_ATTR_NAMED(in_thresh_low_value,
-		in_voltage-voltage_thresh_low_value,
-		0644,
-		ad7280_read_channel_config,
-		ad7280_write_channel_config,
-		AD7280A_CELL_UNDERVOLTAGE);
+			     in_voltage-voltage_thresh_low_value,
+			     0644,
+			     ad7280_read_channel_config,
+			     ad7280_write_channel_config,
+			     AD7280A_CELL_UNDERVOLTAGE);
 
 static IIO_DEVICE_ATTR_NAMED(in_thresh_high_value,
-		in_voltage-voltage_thresh_high_value,
-		0644,
-		ad7280_read_channel_config,
-		ad7280_write_channel_config,
-		AD7280A_CELL_OVERVOLTAGE);
+			     in_voltage-voltage_thresh_high_value,
+			     0644,
+			     ad7280_read_channel_config,
+			     ad7280_write_channel_config,
+			     AD7280A_CELL_OVERVOLTAGE);
 
 static IIO_DEVICE_ATTR(in_temp_thresh_low_value,
-		0644,
-		ad7280_read_channel_config,
-		ad7280_write_channel_config,
-		AD7280A_AUX_ADC_UNDERVOLTAGE);
+		       0644,
+		       ad7280_read_channel_config,
+		       ad7280_write_channel_config,
+		       AD7280A_AUX_ADC_UNDERVOLTAGE);
 
 static IIO_DEVICE_ATTR(in_temp_thresh_high_value,
-		0644,
-		ad7280_read_channel_config,
-		ad7280_write_channel_config,
-		AD7280A_AUX_ADC_OVERVOLTAGE);
+		       0644,
+		       ad7280_read_channel_config,
+		       ad7280_write_channel_config,
+		       AD7280A_AUX_ADC_OVERVOLTAGE);
 
 static struct attribute *ad7280_event_attributes[] = {
 	&iio_dev_attr_in_thresh_low_value.dev_attr.attr,
Signature · 1 line
2.7.4
#22 lore raw

PATCH v3 2/5 staging: iio: adc: ad7192: Converted bool to bitfield format

In reply to Cristian Sicilia

Changed bool format to bitfield format to save space.

---
 drivers/staging/iio/adc/ad7192.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/staging/iio/adc/ad7192.h +7 -7
index 7433a43..9c1d223 100644
@@ -35,13 +35,13 @@ struct ad7192_platform_data {
 	u16		vref_mv;
 	u8		clock_source_sel;
 	u32		ext_clk_hz;
-	bool		refin2_en;
-	bool		rej60_en;
-	bool		sinc3_en;
-	bool		chop_en;
-	bool		buf_en;
-	bool		unipolar_en;
-	bool		burnout_curr_en;
+	u8		refin2_en:1;
+	u8		rej60_en:1;
+	u8		sinc3_en:1;
+	u8		chop_en:1;
+	u8		buf_en:1;
+	u8		unipolar_en:1;
+	u8		burnout_curr_en:1;
 };
 
 #endif /* IIO_ADC_AD7192_H_ */
Signature · 1 line
2.7.4
#24 lore raw

PATCH v3 3/5 staging: iio: adc: ad7280a: Avoid precedence issues in macro

In reply to Cristian Sicilia

Enclosing parameter with parenthesis due to avoid
possible precedence issue.

---
 drivers/staging/iio/adc/ad7280a.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/iio/adc/ad7280a.c +4 -3
index 571535d..c2391f6 100644
@@ -97,9 +97,10 @@
 #define AD7280A_NUM_CH			(AD7280A_AUX_ADC_6 - \
 					AD7280A_CELL_VOLTAGE_1 + 1)
 
-#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) ((d * AD7280A_CELLS_PER_DEV) + c)
-#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)    ((d * AD7280A_CELLS_PER_DEV) + \
-					     c - AD7280A_CELLS_PER_DEV)
+#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) (((d) * AD7280A_CELLS_PER_DEV) + \
+					     (c))
+#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)    (((d) * AD7280A_CELLS_PER_DEV) + \
+					     (c) - AD7280A_CELLS_PER_DEV)
 
 #define AD7280A_DEVADDR_MASTER		0
 #define AD7280A_DEVADDR_ALL		0x1F
Signature · 1 line
2.7.4
#29 lore raw

PATCH v3 5/5 staging: iio: adc: ad7280a: Remove CamelCase notation

In reply to Cristian Sicilia

Fix CamelCase naming.

---
 drivers/staging/iio/adc/ad7280a.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/staging/iio/adc/ad7280a.c +5 -6
index 4ff28f1..229dcad 100644
@@ -917,8 +917,8 @@ static int ad7280_probe(struct spi_device *spi)
 	const struct ad7280_platform_data *pdata = dev_get_platdata(&spi->dev);
 	struct ad7280_state *st;
 	int ret;
-	const unsigned short tACQ_ns[4] = {465, 1010, 1460, 1890};
-	const unsigned short nAVG[4] = {1, 2, 4, 8};
+	const unsigned short t_acq_ns[4] = {465, 1010, 1460, 1890};
+	const unsigned short n_avg[4] = {1, 2, 4, 8};
 	struct iio_dev *indio_dev;
 
 	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
@@ -966,10 +966,9 @@ static int ad7280_probe(struct spi_device *spi)
 	 */
 
 	st->readback_delay_us =
-		((tACQ_ns[pdata->acquisition_time & 0x3] + 695) *
-		(AD7280A_NUM_CH * nAVG[pdata->conversion_averaging & 0x3]))
-		- tACQ_ns[pdata->acquisition_time & 0x3] +
-		st->slave_num * 250;
+		((t_acq_ns[pdata->acquisition_time & 0x3] + 695) *
+		 (AD7280A_NUM_CH * n_avg[pdata->conversion_averaging & 0x3])) -
+		t_acq_ns[pdata->acquisition_time & 0x3] + st->slave_num * 250;
 
 	/* Convert to usecs */
 	st->readback_delay_us = DIV_ROUND_UP(st->readback_delay_us, 1000);
Signature · 1 line
2.7.4
#26 lore raw

PATCH v3 4/5 staging: iio: adc: ad7280a: Adding temp var to improve readability

In reply to Cristian Sicilia

Creating a temporary variable to improve readability

---
 drivers/staging/iio/adc/ad7280a.c | 55 ++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 30 deletions(-)
drivers/staging/iio/adc/ad7280a.c +25 -30
index c2391f6..4ff28f1 100644
@@ -784,43 +784,38 @@ static irqreturn_t ad7280_event_handler(int irq, void *private)
 	for (i = 0; i < st->scan_cnt; i++) {
 		if (((channels[i] >> 23) & 0xF) <= AD7280A_CELL_VOLTAGE_6) {
 			if (((channels[i] >> 11) & 0xFFF) >=
-				st->cell_threshhigh)
-				iio_push_event(indio_dev,
-					       IIO_EVENT_CODE(IIO_VOLTAGE,
-							1,
-							0,
-							IIO_EV_DIR_RISING,
-							IIO_EV_TYPE_THRESH,
-							0, 0, 0),
+			    st->cell_threshhigh) {
+				u64 tmp = IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0,
+							 IIO_EV_DIR_RISING,
+							 IIO_EV_TYPE_THRESH,
+							 0, 0, 0);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
-			else if (((channels[i] >> 11) & 0xFFF) <=
-				st->cell_threshlow)
-				iio_push_event(indio_dev,
-					       IIO_EVENT_CODE(IIO_VOLTAGE,
-							1,
-							0,
-							IIO_EV_DIR_FALLING,
-							IIO_EV_TYPE_THRESH,
-							0, 0, 0),
+			} else if (((channels[i] >> 11) & 0xFFF) <=
+				   st->cell_threshlow) {
+				u64 tmp = IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0,
+							 IIO_EV_DIR_FALLING,
+							 IIO_EV_TYPE_THRESH,
+							 0, 0, 0);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
+			}
 		} else {
-			if (((channels[i] >> 11) & 0xFFF) >= st->aux_threshhigh)
-				iio_push_event(indio_dev,
-					       IIO_UNMOD_EVENT_CODE(
-							IIO_TEMP,
-							0,
+			if (((channels[i] >> 11) & 0xFFF) >=
+			    st->aux_threshhigh) {
+				u64 tmp = IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
 							IIO_EV_TYPE_THRESH,
-							IIO_EV_DIR_RISING),
+							IIO_EV_DIR_RISING);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
-			else if (((channels[i] >> 11) & 0xFFF) <=
-				st->aux_threshlow)
-				iio_push_event(indio_dev,
-					       IIO_UNMOD_EVENT_CODE(
-							IIO_TEMP,
-							0,
+			} else if (((channels[i] >> 11) & 0xFFF) <=
+				st->aux_threshlow) {
+				u64 tmp = IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
 							IIO_EV_TYPE_THRESH,
-							IIO_EV_DIR_FALLING),
+							IIO_EV_DIR_FALLING);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
+			}
 		}
 	}
 
Signature · 1 line
2.7.4
maintainer
#21 lore raw

Re: [PATCH v3 1/5] staging: iio: adc: ad7280a: Tab alignment

In reply to Cristian Sicilia
Quoted 3 lines · On Sun, 24 Mar 2019 18:23:09 +0100 Cristian Sicilia…

Aligned some parameters.

Applied to the togreg branch of iio.git and pushed out as testing.

Thanks,

Jonathan

Quoted 57 lines
---
 drivers/staging/iio/adc/ad7280a.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/staging/iio/adc/ad7280a.c +18 -18
index d9df126..571535d 100644
@@ -830,30 +830,30 @@ static irqreturn_t ad7280_event_handler(int irq, void *private)
 }
 
 static IIO_DEVICE_ATTR_NAMED(in_thresh_low_value,
-		in_voltage-voltage_thresh_low_value,
-		0644,
-		ad7280_read_channel_config,
-		ad7280_write_channel_config,
-		AD7280A_CELL_UNDERVOLTAGE);
+			     in_voltage-voltage_thresh_low_value,
+			     0644,
+			     ad7280_read_channel_config,
+			     ad7280_write_channel_config,
+			     AD7280A_CELL_UNDERVOLTAGE);
 
 static IIO_DEVICE_ATTR_NAMED(in_thresh_high_value,
-		in_voltage-voltage_thresh_high_value,
-		0644,
-		ad7280_read_channel_config,
-		ad7280_write_channel_config,
-		AD7280A_CELL_OVERVOLTAGE);
+			     in_voltage-voltage_thresh_high_value,
+			     0644,
+			     ad7280_read_channel_config,
+			     ad7280_write_channel_config,
+			     AD7280A_CELL_OVERVOLTAGE);
 
 static IIO_DEVICE_ATTR(in_temp_thresh_low_value,
-		0644,
-		ad7280_read_channel_config,
-		ad7280_write_channel_config,
-		AD7280A_AUX_ADC_UNDERVOLTAGE);
+		       0644,
+		       ad7280_read_channel_config,
+		       ad7280_write_channel_config,
+		       AD7280A_AUX_ADC_UNDERVOLTAGE);
 
 static IIO_DEVICE_ATTR(in_temp_thresh_high_value,
-		0644,
-		ad7280_read_channel_config,
-		ad7280_write_channel_config,
-		AD7280A_AUX_ADC_OVERVOLTAGE);
+		       0644,
+		       ad7280_read_channel_config,
+		       ad7280_write_channel_config,
+		       AD7280A_AUX_ADC_OVERVOLTAGE);
 
 static struct attribute *ad7280_event_attributes[] = {
 	&iio_dev_attr_in_thresh_low_value.dev_attr.attr,
maintainer
#23 lore raw

Re: [PATCH v3 2/5] staging: iio: adc: ad7192: Converted bool to bitfield format

In reply to Cristian Sicilia
Quoted 3 lines · On Sun, 24 Mar 2019 18:23:11 +0100 Cristian Sicilia…

Changed bool format to bitfield format to save space.

This driver is undergoing active rework to move out of staging and in the meantime these fields have been dropped.

So not applied as no longer relevant.

Thanks,

Jonathan

Quoted 29 lines
---
 drivers/staging/iio/adc/ad7192.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/staging/iio/adc/ad7192.h +7 -7
index 7433a43..9c1d223 100644
@@ -35,13 +35,13 @@ struct ad7192_platform_data {
 	u16		vref_mv;
 	u8		clock_source_sel;
 	u32		ext_clk_hz;
-	bool		refin2_en;
-	bool		rej60_en;
-	bool		sinc3_en;
-	bool		chop_en;
-	bool		buf_en;
-	bool		unipolar_en;
-	bool		burnout_curr_en;
+	u8		refin2_en:1;
+	u8		rej60_en:1;
+	u8		sinc3_en:1;
+	u8		chop_en:1;
+	u8		buf_en:1;
+	u8		unipolar_en:1;
+	u8		burnout_curr_en:1;
 };
 
 #endif /* IIO_ADC_AD7192_H_ */
maintainer
#25 lore raw

Re: [PATCH v3 3/5] staging: iio: adc: ad7280a: Avoid precedence issues in macro

In reply to Cristian Sicilia
Quoted 4 lines · On Sun, 24 Mar 2019 18:23:12 +0100 Cristian Sicilia…

Enclosing parameter with parenthesis due to avoid
possible precedence issue.

I've already applied this one.

Thanks,

Jonathan

Quoted 22 lines
---
 drivers/staging/iio/adc/ad7280a.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/iio/adc/ad7280a.c +4 -3
index 571535d..c2391f6 100644
@@ -97,9 +97,10 @@
 #define AD7280A_NUM_CH			(AD7280A_AUX_ADC_6 - \
 					AD7280A_CELL_VOLTAGE_1 + 1)
 
-#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) ((d * AD7280A_CELLS_PER_DEV) + c)
-#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)    ((d * AD7280A_CELLS_PER_DEV) + \
-					     c - AD7280A_CELLS_PER_DEV)
+#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) (((d) * AD7280A_CELLS_PER_DEV) + \
+					     (c))
+#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)    (((d) * AD7280A_CELLS_PER_DEV) + \
+					     (c) - AD7280A_CELLS_PER_DEV)
 
 #define AD7280A_DEVADDR_MASTER		0
 #define AD7280A_DEVADDR_ALL		0x1F
maintainer
#27 lore raw

Re: [PATCH v3 4/5] staging: iio: adc: ad7280a: Adding temp var to improve readability

In reply to Cristian Sicilia
Quoted 3 lines · On Sun, 24 Mar 2019 18:23:14 +0100 Cristian Sicilia…

Creating a temporary variable to improve readability

I have already applied this one.

Thanks,

Jonathan

Quoted 77 lines
---
 drivers/staging/iio/adc/ad7280a.c | 55 ++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 30 deletions(-)
drivers/staging/iio/adc/ad7280a.c +25 -30
index c2391f6..4ff28f1 100644
@@ -784,43 +784,38 @@ static irqreturn_t ad7280_event_handler(int irq, void *private)
 	for (i = 0; i < st->scan_cnt; i++) {
 		if (((channels[i] >> 23) & 0xF) <= AD7280A_CELL_VOLTAGE_6) {
 			if (((channels[i] >> 11) & 0xFFF) >=
-				st->cell_threshhigh)
-				iio_push_event(indio_dev,
-					       IIO_EVENT_CODE(IIO_VOLTAGE,
-							1,
-							0,
-							IIO_EV_DIR_RISING,
-							IIO_EV_TYPE_THRESH,
-							0, 0, 0),
+			    st->cell_threshhigh) {
+				u64 tmp = IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0,
+							 IIO_EV_DIR_RISING,
+							 IIO_EV_TYPE_THRESH,
+							 0, 0, 0);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
-			else if (((channels[i] >> 11) & 0xFFF) <=
-				st->cell_threshlow)
-				iio_push_event(indio_dev,
-					       IIO_EVENT_CODE(IIO_VOLTAGE,
-							1,
-							0,
-							IIO_EV_DIR_FALLING,
-							IIO_EV_TYPE_THRESH,
-							0, 0, 0),
+			} else if (((channels[i] >> 11) & 0xFFF) <=
+				   st->cell_threshlow) {
+				u64 tmp = IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0,
+							 IIO_EV_DIR_FALLING,
+							 IIO_EV_TYPE_THRESH,
+							 0, 0, 0);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
+			}
 		} else {
-			if (((channels[i] >> 11) & 0xFFF) >= st->aux_threshhigh)
-				iio_push_event(indio_dev,
-					       IIO_UNMOD_EVENT_CODE(
-							IIO_TEMP,
-							0,
+			if (((channels[i] >> 11) & 0xFFF) >=
+			    st->aux_threshhigh) {
+				u64 tmp = IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
 							IIO_EV_TYPE_THRESH,
-							IIO_EV_DIR_RISING),
+							IIO_EV_DIR_RISING);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
-			else if (((channels[i] >> 11) & 0xFFF) <=
-				st->aux_threshlow)
-				iio_push_event(indio_dev,
-					       IIO_UNMOD_EVENT_CODE(
-							IIO_TEMP,
-							0,
+			} else if (((channels[i] >> 11) & 0xFFF) <=
+				st->aux_threshlow) {
+				u64 tmp = IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
 							IIO_EV_TYPE_THRESH,
-							IIO_EV_DIR_FALLING),
+							IIO_EV_DIR_FALLING);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
+			}
 		}
 	}
 
maintainer
#28 lore raw

Re: [PATCH v3 4/5] staging: iio: adc: ad7280a: Adding temp var to improve readability

In reply to Cristian Sicilia
Quoted 3 lines · On Sun, 24 Mar 2019 18:23:14 +0100 Cristian Sicilia…

Creating a temporary variable to improve readability

Already applied this one as well.

Thanks,

Jonathan

Quoted 77 lines
---
 drivers/staging/iio/adc/ad7280a.c | 55 ++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 30 deletions(-)
drivers/staging/iio/adc/ad7280a.c +25 -30
index c2391f6..4ff28f1 100644
@@ -784,43 +784,38 @@ static irqreturn_t ad7280_event_handler(int irq, void *private)
 	for (i = 0; i < st->scan_cnt; i++) {
 		if (((channels[i] >> 23) & 0xF) <= AD7280A_CELL_VOLTAGE_6) {
 			if (((channels[i] >> 11) & 0xFFF) >=
-				st->cell_threshhigh)
-				iio_push_event(indio_dev,
-					       IIO_EVENT_CODE(IIO_VOLTAGE,
-							1,
-							0,
-							IIO_EV_DIR_RISING,
-							IIO_EV_TYPE_THRESH,
-							0, 0, 0),
+			    st->cell_threshhigh) {
+				u64 tmp = IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0,
+							 IIO_EV_DIR_RISING,
+							 IIO_EV_TYPE_THRESH,
+							 0, 0, 0);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
-			else if (((channels[i] >> 11) & 0xFFF) <=
-				st->cell_threshlow)
-				iio_push_event(indio_dev,
-					       IIO_EVENT_CODE(IIO_VOLTAGE,
-							1,
-							0,
-							IIO_EV_DIR_FALLING,
-							IIO_EV_TYPE_THRESH,
-							0, 0, 0),
+			} else if (((channels[i] >> 11) & 0xFFF) <=
+				   st->cell_threshlow) {
+				u64 tmp = IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0,
+							 IIO_EV_DIR_FALLING,
+							 IIO_EV_TYPE_THRESH,
+							 0, 0, 0);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
+			}
 		} else {
-			if (((channels[i] >> 11) & 0xFFF) >= st->aux_threshhigh)
-				iio_push_event(indio_dev,
-					       IIO_UNMOD_EVENT_CODE(
-							IIO_TEMP,
-							0,
+			if (((channels[i] >> 11) & 0xFFF) >=
+			    st->aux_threshhigh) {
+				u64 tmp = IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
 							IIO_EV_TYPE_THRESH,
-							IIO_EV_DIR_RISING),
+							IIO_EV_DIR_RISING);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
-			else if (((channels[i] >> 11) & 0xFFF) <=
-				st->aux_threshlow)
-				iio_push_event(indio_dev,
-					       IIO_UNMOD_EVENT_CODE(
-							IIO_TEMP,
-							0,
+			} else if (((channels[i] >> 11) & 0xFFF) <=
+				st->aux_threshlow) {
+				u64 tmp = IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
 							IIO_EV_TYPE_THRESH,
-							IIO_EV_DIR_FALLING),
+							IIO_EV_DIR_FALLING);
+				iio_push_event(indio_dev, tmp,
 					       iio_get_time_ns(indio_dev));
+			}
 		}
 	}
 
maintainer
#30 lore raw

Re: [PATCH v3 5/5] staging: iio: adc: ad7280a: Remove CamelCase notation

In reply to Cristian Sicilia
Quoted 3 lines · On Sun, 24 Mar 2019 18:23:16 +0100 Cristian Sicilia…

Fix CamelCase naming.

Already applied this one as well.

So whole set has been applied.

Thanks,

Jonathan

Quoted 33 lines
---
 drivers/staging/iio/adc/ad7280a.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/staging/iio/adc/ad7280a.c +5 -6
index 4ff28f1..229dcad 100644
@@ -917,8 +917,8 @@ static int ad7280_probe(struct spi_device *spi)
 	const struct ad7280_platform_data *pdata = dev_get_platdata(&spi->dev);
 	struct ad7280_state *st;
 	int ret;
-	const unsigned short tACQ_ns[4] = {465, 1010, 1460, 1890};
-	const unsigned short nAVG[4] = {1, 2, 4, 8};
+	const unsigned short t_acq_ns[4] = {465, 1010, 1460, 1890};
+	const unsigned short n_avg[4] = {1, 2, 4, 8};
 	struct iio_dev *indio_dev;
 
 	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
@@ -966,10 +966,9 @@ static int ad7280_probe(struct spi_device *spi)
 	 */
 
 	st->readback_delay_us =
-		((tACQ_ns[pdata->acquisition_time & 0x3] + 695) *
-		(AD7280A_NUM_CH * nAVG[pdata->conversion_averaging & 0x3]))
-		- tACQ_ns[pdata->acquisition_time & 0x3] +
-		st->slave_num * 250;
+		((t_acq_ns[pdata->acquisition_time & 0x3] + 695) *
+		 (AD7280A_NUM_CH * n_avg[pdata->conversion_averaging & 0x3])) -
+		t_acq_ns[pdata->acquisition_time & 0x3] + st->slave_num * 250;
 
 	/* Convert to usecs */
 	st->readback_delay_us = DIV_ROUND_UP(st->readback_delay_us, 1000);