linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] *** SUBJECT HERE ***
@ 2019-03-23 12:53 Cristian Sicilia
  2019-03-23 12:53 ` [PATCH 3/5] staging: iio: adc: Avoid precedence issues in macro Cristian Sicilia
                   ` (6 more replies)
  0 siblings, 7 replies; 33+ messages in thread
From: Cristian Sicilia @ 2019-03-23 12:53 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

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


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 3/5] staging: iio: adc: Avoid precedence issues in macro
  2019-03-23 12:53 [PATCH 0/5] *** SUBJECT HERE *** Cristian Sicilia
@ 2019-03-23 12:53 ` Cristian Sicilia
  2019-03-23 12:53 ` [PATCH 4/5] staging: iio: adc: Adding temp var to improve readability Cristian Sicilia
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 33+ messages in thread
From: Cristian Sicilia @ 2019-03-23 12:53 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

Enclosing parameter with parenthesis due to avoid
possible precedence issue.

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
---
 drivers/staging/iio/adc/ad7280a.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
index 55b5879..d81a5bd 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -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
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 4/5] staging: iio: adc: Adding temp var to improve readability
  2019-03-23 12:53 [PATCH 0/5] *** SUBJECT HERE *** Cristian Sicilia
  2019-03-23 12:53 ` [PATCH 3/5] staging: iio: adc: Avoid precedence issues in macro Cristian Sicilia
@ 2019-03-23 12:53 ` Cristian Sicilia
  2019-03-23 12:54 ` [PATCH 2/5] staging: iio: adc: Converted bool to bitfield format Cristian Sicilia
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 33+ messages in thread
From: Cristian Sicilia @ 2019-03-23 12:53 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

Creating a temporary variable to improve readability

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
---
 drivers/staging/iio/adc/ad7280a.c | 55 ++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
index d81a5bd..5d848aa 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -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));
+			}
 		}
 	}
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 2/5] staging: iio: adc: Converted bool to bitfield format
  2019-03-23 12:53 [PATCH 0/5] *** SUBJECT HERE *** Cristian Sicilia
  2019-03-23 12:53 ` [PATCH 3/5] staging: iio: adc: Avoid precedence issues in macro Cristian Sicilia
  2019-03-23 12:53 ` [PATCH 4/5] staging: iio: adc: Adding temp var to improve readability Cristian Sicilia
@ 2019-03-23 12:54 ` Cristian Sicilia
  2019-03-23 12:54 ` [PATCH 5/5] staging: iio: adc: Remove CamelCase notation Cristian Sicilia
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 33+ messages in thread
From: Cristian Sicilia @ 2019-03-23 12:54 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

Changed bool format to bitfield format to save space.

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>

---
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(-)

diff --git a/drivers/staging/iio/adc/ad7192.h b/drivers/staging/iio/adc/ad7192.h
index 7433a43..87891ba 100644
--- a/drivers/staging/iio/adc/ad7192.h
+++ b/drivers/staging/iio/adc/ad7192.h
@@ -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_ */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 5/5] staging: iio: adc: Remove CamelCase notation
  2019-03-23 12:53 [PATCH 0/5] *** SUBJECT HERE *** Cristian Sicilia
                   ` (2 preceding siblings ...)
  2019-03-23 12:54 ` [PATCH 2/5] staging: iio: adc: Converted bool to bitfield format Cristian Sicilia
@ 2019-03-23 12:54 ` Cristian Sicilia
  2019-03-23 12:58 ` [PATCH 1/5] staging: iio: adc: Tab alignment Cristian Sicilia
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 33+ messages in thread
From: Cristian Sicilia @ 2019-03-23 12:54 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
---
 drivers/staging/iio/adc/ad7280a.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
index 5d848aa..c02454c 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -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);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 1/5] staging: iio: adc: Tab alignment
  2019-03-23 12:53 [PATCH 0/5] *** SUBJECT HERE *** Cristian Sicilia
                   ` (3 preceding siblings ...)
  2019-03-23 12:54 ` [PATCH 5/5] staging: iio: adc: Remove CamelCase notation Cristian Sicilia
@ 2019-03-23 12:58 ` Cristian Sicilia
  2019-03-23 19:21 ` [PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
  2019-03-23 19:24 ` [PATCH 0/5] *** SUBJECT HERE *** Matt Ranostay
  6 siblings, 0 replies; 33+ messages in thread
From: Cristian Sicilia @ 2019-03-23 12:58 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

Aligned some parameters.

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
---
 drivers/staging/iio/adc/ad7280a.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
index d9df126..55b5879 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -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,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change
  2019-03-23 12:53 [PATCH 0/5] *** SUBJECT HERE *** Cristian Sicilia
                   ` (4 preceding siblings ...)
  2019-03-23 12:58 ` [PATCH 1/5] staging: iio: adc: Tab alignment Cristian Sicilia
@ 2019-03-23 19:21 ` Cristian Sicilia
  2019-03-23 19:21   ` [PATCH v2 1/5] staging: iio: adc: Tab alignment Cristian Sicilia
                     ` (5 more replies)
  2019-03-23 19:24 ` [PATCH 0/5] *** SUBJECT HERE *** Matt Ranostay
  6 siblings, 6 replies; 33+ messages in thread
From: Cristian Sicilia @ 2019-03-23 19:21 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

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(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v2 1/5] staging: iio: adc: Tab alignment
  2019-03-23 19:21 ` [PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
@ 2019-03-23 19:21   ` Cristian Sicilia
  2019-03-24 12:35     ` Jonathan Cameron
  2019-03-23 19:21   ` [PATCH v2 2/5] staging: iio: adc: Converted bool to bitfield format Cristian Sicilia
                     ` (4 subsequent siblings)
  5 siblings, 1 reply; 33+ messages in thread
From: Cristian Sicilia @ 2019-03-23 19:21 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

Aligned some parameters.

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
---
 drivers/staging/iio/adc/ad7280a.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
index d9df126..55b5879 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -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,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 2/5] staging: iio: adc: Converted bool to bitfield format
  2019-03-23 19:21 ` [PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
  2019-03-23 19:21   ` [PATCH v2 1/5] staging: iio: adc: Tab alignment Cristian Sicilia
@ 2019-03-23 19:21   ` Cristian Sicilia
  2019-03-24 12:34     ` Jonathan Cameron
  2019-03-23 19:21   ` [PATCH v2 3/5] staging: iio: adc: Avoid precedence issues in macro Cristian Sicilia
                     ` (3 subsequent siblings)
  5 siblings, 1 reply; 33+ messages in thread
From: Cristian Sicilia @ 2019-03-23 19:21 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

Changed bool format to bitfield format to save space.

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>

---
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(-)

diff --git a/drivers/staging/iio/adc/ad7192.h b/drivers/staging/iio/adc/ad7192.h
index 7433a43..87891ba 100644
--- a/drivers/staging/iio/adc/ad7192.h
+++ b/drivers/staging/iio/adc/ad7192.h
@@ -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_ */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 3/5] staging: iio: adc: Avoid precedence issues in macro
  2019-03-23 19:21 ` [PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
  2019-03-23 19:21   ` [PATCH v2 1/5] staging: iio: adc: Tab alignment Cristian Sicilia
  2019-03-23 19:21   ` [PATCH v2 2/5] staging: iio: adc: Converted bool to bitfield format Cristian Sicilia
@ 2019-03-23 19:21   ` Cristian Sicilia
  2019-03-24 12:37     ` Jonathan Cameron
  2019-03-23 19:21   ` [PATCH v2 4/5] staging: iio: adc: Adding temp var to improve readability Cristian Sicilia
                     ` (2 subsequent siblings)
  5 siblings, 1 reply; 33+ messages in thread
From: Cristian Sicilia @ 2019-03-23 19:21 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

Enclosing parameter with parenthesis due to avoid
possible precedence issue.

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
---
 drivers/staging/iio/adc/ad7280a.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
index 55b5879..d81a5bd 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -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
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 4/5] staging: iio: adc: Adding temp var to improve readability
  2019-03-23 19:21 ` [PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
                     ` (2 preceding siblings ...)
  2019-03-23 19:21   ` [PATCH v2 3/5] staging: iio: adc: Avoid precedence issues in macro Cristian Sicilia
@ 2019-03-23 19:21   ` Cristian Sicilia
  2019-03-24 12:41     ` Jonathan Cameron
  2019-03-23 19:21   ` [PATCH v2 5/5] staging: iio: adc: Remove CamelCase notation Cristian Sicilia
  2019-03-24 17:23   ` [PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
  5 siblings, 1 reply; 33+ messages in thread
From: Cristian Sicilia @ 2019-03-23 19:21 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

Creating a temporary variable to improve readability

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
---
 drivers/staging/iio/adc/ad7280a.c | 55 ++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
index d81a5bd..5d848aa 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -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));
+			}
 		}
 	}
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 5/5] staging: iio: adc: Remove CamelCase notation
  2019-03-23 19:21 ` [PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
                     ` (3 preceding siblings ...)
  2019-03-23 19:21   ` [PATCH v2 4/5] staging: iio: adc: Adding temp var to improve readability Cristian Sicilia
@ 2019-03-23 19:21   ` Cristian Sicilia
  2019-03-24 14:56     ` Jonathan Cameron
  2019-03-24 17:23   ` [PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
  5 siblings, 1 reply; 33+ messages in thread
From: Cristian Sicilia @ 2019-03-23 19:21 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

Fix CamelCase naming.

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
---
 drivers/staging/iio/adc/ad7280a.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
index 5d848aa..c02454c 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -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);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH 0/5] *** SUBJECT HERE ***
  2019-03-23 12:53 [PATCH 0/5] *** SUBJECT HERE *** Cristian Sicilia
                   ` (5 preceding siblings ...)
  2019-03-23 19:21 ` [PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
@ 2019-03-23 19:24 ` Matt Ranostay
  6 siblings, 0 replies; 33+ messages in thread
From: Matt Ranostay @ 2019-03-23 19:24 UTC (permalink / raw)
  To: Cristian Sicilia
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

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

- Matt

On Sat, Mar 23, 2019 at 5:53 AM Cristian Sicilia
<sicilia.cristian@gmail.com> wrote:
>
> 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
>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 2/5] staging: iio: adc: Converted bool to bitfield format
  2019-03-23 19:21   ` [PATCH v2 2/5] staging: iio: adc: Converted bool to bitfield format Cristian Sicilia
@ 2019-03-24 12:34     ` Jonathan Cameron
  2019-03-24 16:33       ` Sicilia Cristian
  0 siblings, 1 reply; 33+ messages in thread
From: Jonathan Cameron @ 2019-03-24 12:34 UTC (permalink / raw)
  To: Cristian Sicilia
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, Greg Kroah-Hartman, linux-iio, devel,
	linux-kernel

On Sat, 23 Mar 2019 20:21:39 +0100
Cristian Sicilia <sicilia.cristian@gmail.com> wrote:

> Changed bool format to bitfield format to save space.
> 
> Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
> 
> ---
> 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...

> ---
>  drivers/staging/iio/adc/ad7192.h | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7192.h b/drivers/staging/iio/adc/ad7192.h
> index 7433a43..87891ba 100644
> --- a/drivers/staging/iio/adc/ad7192.h
> +++ b/drivers/staging/iio/adc/ad7192.h
> @@ -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__));
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.

>  
>  #endif /* IIO_ADC_AD7192_H_ */


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 1/5] staging: iio: adc: Tab alignment
  2019-03-23 19:21   ` [PATCH v2 1/5] staging: iio: adc: Tab alignment Cristian Sicilia
@ 2019-03-24 12:35     ` Jonathan Cameron
  2019-03-24 16:34       ` Cristian Sicilia
  0 siblings, 1 reply; 33+ messages in thread
From: Jonathan Cameron @ 2019-03-24 12:35 UTC (permalink / raw)
  To: Cristian Sicilia
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, Greg Kroah-Hartman, linux-iio, devel,
	linux-kernel

On Sat, 23 Mar 2019 20:21:36 +0100
Cristian Sicilia <sicilia.cristian@gmail.com> wrote:

> Aligned some parameters.
> 
> Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
> ---
>  drivers/staging/iio/adc/ad7280a.c | 36 ++++++++++++++++++------------------
>  1 file changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
> index d9df126..55b5879 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -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.

> +			     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,


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 3/5] staging: iio: adc: Avoid precedence issues in macro
  2019-03-23 19:21   ` [PATCH v2 3/5] staging: iio: adc: Avoid precedence issues in macro Cristian Sicilia
@ 2019-03-24 12:37     ` Jonathan Cameron
  0 siblings, 0 replies; 33+ messages in thread
From: Jonathan Cameron @ 2019-03-24 12:37 UTC (permalink / raw)
  To: Cristian Sicilia
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, Greg Kroah-Hartman, linux-iio, devel,
	linux-kernel

On Sat, 23 Mar 2019 20:21:42 +0100
Cristian Sicilia <sicilia.cristian@gmail.com> wrote:

> Enclosing parameter with parenthesis due to avoid
> possible precedence issue.
> 
> Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
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

> ---
>  drivers/staging/iio/adc/ad7280a.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
> index 55b5879..d81a5bd 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -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


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 4/5] staging: iio: adc: Adding temp var to improve readability
  2019-03-23 19:21   ` [PATCH v2 4/5] staging: iio: adc: Adding temp var to improve readability Cristian Sicilia
@ 2019-03-24 12:41     ` Jonathan Cameron
  0 siblings, 0 replies; 33+ messages in thread
From: Jonathan Cameron @ 2019-03-24 12:41 UTC (permalink / raw)
  To: Cristian Sicilia
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, Greg Kroah-Hartman, linux-iio, devel,
	linux-kernel

On Sat, 23 Mar 2019 20:21:45 +0100
Cristian Sicilia <sicilia.cristian@gmail.com> wrote:

> Creating a temporary variable to improve readability
> 
> Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>

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

Applied

Thanks,

Jonathan

> ---
>  drivers/staging/iio/adc/ad7280a.c | 55 ++++++++++++++++++---------------------
>  1 file changed, 25 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
> index d81a5bd..5d848aa 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -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));
> +			}
>  		}
>  	}
>  


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 5/5] staging: iio: adc: Remove CamelCase notation
  2019-03-23 19:21   ` [PATCH v2 5/5] staging: iio: adc: Remove CamelCase notation Cristian Sicilia
@ 2019-03-24 14:56     ` Jonathan Cameron
  0 siblings, 0 replies; 33+ messages in thread
From: Jonathan Cameron @ 2019-03-24 14:56 UTC (permalink / raw)
  To: Cristian Sicilia
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, Greg Kroah-Hartman, linux-iio, devel,
	linux-kernel

On Sat, 23 Mar 2019 20:21:49 +0100
Cristian Sicilia <sicilia.cristian@gmail.com> wrote:

> Fix CamelCase naming.
> 
> Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
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


> ---
>  drivers/staging/iio/adc/ad7280a.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
> index 5d848aa..c02454c 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -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);


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 2/5] staging: iio: adc: Converted bool to bitfield format
  2019-03-24 12:34     ` Jonathan Cameron
@ 2019-03-24 16:33       ` Sicilia Cristian
  0 siblings, 0 replies; 33+ messages in thread
From: Sicilia Cristian @ 2019-03-24 16:33 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, Greg Kroah-Hartman, linux-iio, devel,
	linux-kernel

On Sun, Mar 24, 2019 at 12:34:52PM +0000, Jonathan Cameron wrote:
> On Sat, 23 Mar 2019 20:21:39 +0100
> Cristian Sicilia <sicilia.cristian@gmail.com> wrote:
> 
 > > Changed bool format to bitfield format to save space.
> > 
> > Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
> > 
> > ---
> > 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...
> 

Thanks for comment

> > ---
> >  drivers/staging/iio/adc/ad7192.h | 16 ++++++++--------
> >  1 file changed, 8 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/staging/iio/adc/ad7192.h b/drivers/staging/iio/adc/ad7192.h
> > index 7433a43..87891ba 100644
> > --- a/drivers/staging/iio/adc/ad7192.h
> > +++ b/drivers/staging/iio/adc/ad7192.h
> > @@ -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__));
> 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

> 
> >  
> >  #endif /* IIO_ADC_AD7192_H_ */
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 1/5] staging: iio: adc: Tab alignment
  2019-03-24 12:35     ` Jonathan Cameron
@ 2019-03-24 16:34       ` Cristian Sicilia
  0 siblings, 0 replies; 33+ messages in thread
From: Cristian Sicilia @ 2019-03-24 16:34 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, Greg Kroah-Hartman, linux-iio, devel,
	linux-kernel

On Sun, Mar 24, 2019 at 12:35:52PM +0000, Jonathan Cameron wrote:
> On Sat, 23 Mar 2019 20:21:36 +0100
> Cristian Sicilia <sicilia.cristian@gmail.com> wrote:
>
> > Aligned some parameters.
> >
> > Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
> > ---
> >  drivers/staging/iio/adc/ad7280a.c | 36 ++++++++++++++++++------------------
> >  1 file changed, 18 insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
> > index d9df126..55b5879 100644
> > --- a/drivers/staging/iio/adc/ad7280a.c
> > +++ b/drivers/staging/iio/adc/ad7280a.c
> > @@ -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.

Yes sorry, it will badly stringify, I fix it


>
> > +                        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,
>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change
  2019-03-23 19:21 ` [PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
                     ` (4 preceding siblings ...)
  2019-03-23 19:21   ` [PATCH v2 5/5] staging: iio: adc: Remove CamelCase notation Cristian Sicilia
@ 2019-03-24 17:23   ` Cristian Sicilia
  2019-03-24 17:23     ` [PATCH v3 1/5] staging: iio: adc: ad7280a: Tab alignment Cristian Sicilia
                       ` (5 more replies)
  5 siblings, 6 replies; 33+ messages in thread
From: Cristian Sicilia @ 2019-03-24 17:23 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

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(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v3 1/5] staging: iio: adc: ad7280a: Tab alignment
  2019-03-24 17:23   ` [PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
@ 2019-03-24 17:23     ` Cristian Sicilia
  2019-03-31  9:29       ` Jonathan Cameron
  2019-03-24 17:23     ` [PATCH v3 2/5] staging: iio: adc: ad7192: Converted bool to bitfield format Cristian Sicilia
                       ` (4 subsequent siblings)
  5 siblings, 1 reply; 33+ messages in thread
From: Cristian Sicilia @ 2019-03-24 17:23 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

Aligned some parameters.

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
---
 drivers/staging/iio/adc/ad7280a.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
index d9df126..571535d 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -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,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 2/5] staging: iio: adc: ad7192: Converted bool to bitfield format
  2019-03-24 17:23   ` [PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
  2019-03-24 17:23     ` [PATCH v3 1/5] staging: iio: adc: ad7280a: Tab alignment Cristian Sicilia
@ 2019-03-24 17:23     ` Cristian Sicilia
  2019-03-31  9:32       ` Jonathan Cameron
  2019-03-24 17:23     ` [PATCH v3 3/5] staging: iio: adc: ad7280a: Avoid precedence issues in macro Cristian Sicilia
                       ` (3 subsequent siblings)
  5 siblings, 1 reply; 33+ messages in thread
From: Cristian Sicilia @ 2019-03-24 17:23 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

Changed bool format to bitfield format to save space.

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
---
 drivers/staging/iio/adc/ad7192.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7192.h b/drivers/staging/iio/adc/ad7192.h
index 7433a43..9c1d223 100644
--- a/drivers/staging/iio/adc/ad7192.h
+++ b/drivers/staging/iio/adc/ad7192.h
@@ -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_ */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 3/5] staging: iio: adc: ad7280a: Avoid precedence issues in macro
  2019-03-24 17:23   ` [PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
  2019-03-24 17:23     ` [PATCH v3 1/5] staging: iio: adc: ad7280a: Tab alignment Cristian Sicilia
  2019-03-24 17:23     ` [PATCH v3 2/5] staging: iio: adc: ad7192: Converted bool to bitfield format Cristian Sicilia
@ 2019-03-24 17:23     ` Cristian Sicilia
  2019-03-31  9:34       ` Jonathan Cameron
  2019-03-24 17:23     ` [PATCH v3 4/5] staging: iio: adc: ad7280a: Adding temp var to improve readability Cristian Sicilia
                       ` (2 subsequent siblings)
  5 siblings, 1 reply; 33+ messages in thread
From: Cristian Sicilia @ 2019-03-24 17:23 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

Enclosing parameter with parenthesis due to avoid
possible precedence issue.

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
---
 drivers/staging/iio/adc/ad7280a.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
index 571535d..c2391f6 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -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
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 4/5] staging: iio: adc: ad7280a: Adding temp var to improve readability
  2019-03-24 17:23   ` [PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
                       ` (2 preceding siblings ...)
  2019-03-24 17:23     ` [PATCH v3 3/5] staging: iio: adc: ad7280a: Avoid precedence issues in macro Cristian Sicilia
@ 2019-03-24 17:23     ` Cristian Sicilia
  2019-03-31  9:35       ` Jonathan Cameron
  2019-03-31  9:35       ` Jonathan Cameron
  2019-03-24 17:23     ` [PATCH v3 5/5] staging: iio: adc: ad7280a: Remove CamelCase notation Cristian Sicilia
  2019-03-24 17:27     ` [PATCH v3 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
  5 siblings, 2 replies; 33+ messages in thread
From: Cristian Sicilia @ 2019-03-24 17:23 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

Creating a temporary variable to improve readability

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
---
 drivers/staging/iio/adc/ad7280a.c | 55 ++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
index c2391f6..4ff28f1 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -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));
+			}
 		}
 	}
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 5/5] staging: iio: adc: ad7280a: Remove CamelCase notation
  2019-03-24 17:23   ` [PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
                       ` (3 preceding siblings ...)
  2019-03-24 17:23     ` [PATCH v3 4/5] staging: iio: adc: ad7280a: Adding temp var to improve readability Cristian Sicilia
@ 2019-03-24 17:23     ` Cristian Sicilia
  2019-03-31  9:37       ` Jonathan Cameron
  2019-03-24 17:27     ` [PATCH v3 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
  5 siblings, 1 reply; 33+ messages in thread
From: Cristian Sicilia @ 2019-03-24 17:23 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

Fix CamelCase naming.

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
---
 drivers/staging/iio/adc/ad7280a.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
index 4ff28f1..229dcad 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -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);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v3 0/5] staging: iio: adc: Code refactoring and bool to bitfield change
  2019-03-24 17:23   ` [PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
                       ` (4 preceding siblings ...)
  2019-03-24 17:23     ` [PATCH v3 5/5] staging: iio: adc: ad7280a: Remove CamelCase notation Cristian Sicilia
@ 2019-03-24 17:27     ` Cristian Sicilia
  5 siblings, 0 replies; 33+ messages in thread
From: Cristian Sicilia @ 2019-03-24 17:27 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, Greg Kroah-Hartman,
	linux-iio, devel, linux-kernel

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(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 1/5] staging: iio: adc: ad7280a: Tab alignment
  2019-03-24 17:23     ` [PATCH v3 1/5] staging: iio: adc: ad7280a: Tab alignment Cristian Sicilia
@ 2019-03-31  9:29       ` Jonathan Cameron
  0 siblings, 0 replies; 33+ messages in thread
From: Jonathan Cameron @ 2019-03-31  9:29 UTC (permalink / raw)
  To: Cristian Sicilia
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, Greg Kroah-Hartman, linux-iio, devel,
	linux-kernel

On Sun, 24 Mar 2019 18:23:09 +0100
Cristian Sicilia <sicilia.cristian@gmail.com> wrote:

> Aligned some parameters.
> 
> Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
Applied to the togreg branch of iio.git and pushed out as testing.

Thanks,

Jonathan

> ---
>  drivers/staging/iio/adc/ad7280a.c | 36 ++++++++++++++++++------------------
>  1 file changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
> index d9df126..571535d 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -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,


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 2/5] staging: iio: adc: ad7192: Converted bool to bitfield format
  2019-03-24 17:23     ` [PATCH v3 2/5] staging: iio: adc: ad7192: Converted bool to bitfield format Cristian Sicilia
@ 2019-03-31  9:32       ` Jonathan Cameron
  0 siblings, 0 replies; 33+ messages in thread
From: Jonathan Cameron @ 2019-03-31  9:32 UTC (permalink / raw)
  To: Cristian Sicilia
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, Greg Kroah-Hartman, linux-iio, devel,
	linux-kernel

On Sun, 24 Mar 2019 18:23:11 +0100
Cristian Sicilia <sicilia.cristian@gmail.com> wrote:

> Changed bool format to bitfield format to save space.
> 
> Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
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

> ---
>  drivers/staging/iio/adc/ad7192.h | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7192.h b/drivers/staging/iio/adc/ad7192.h
> index 7433a43..9c1d223 100644
> --- a/drivers/staging/iio/adc/ad7192.h
> +++ b/drivers/staging/iio/adc/ad7192.h
> @@ -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_ */


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 3/5] staging: iio: adc: ad7280a: Avoid precedence issues in macro
  2019-03-24 17:23     ` [PATCH v3 3/5] staging: iio: adc: ad7280a: Avoid precedence issues in macro Cristian Sicilia
@ 2019-03-31  9:34       ` Jonathan Cameron
  0 siblings, 0 replies; 33+ messages in thread
From: Jonathan Cameron @ 2019-03-31  9:34 UTC (permalink / raw)
  To: Cristian Sicilia
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, Greg Kroah-Hartman, linux-iio, devel,
	linux-kernel

On Sun, 24 Mar 2019 18:23:12 +0100
Cristian Sicilia <sicilia.cristian@gmail.com> wrote:

> Enclosing parameter with parenthesis due to avoid
> possible precedence issue.
> 
> Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
I've already applied this one.

Thanks,

Jonathan

> ---
>  drivers/staging/iio/adc/ad7280a.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
> index 571535d..c2391f6 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -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


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 4/5] staging: iio: adc: ad7280a: Adding temp var to improve readability
  2019-03-24 17:23     ` [PATCH v3 4/5] staging: iio: adc: ad7280a: Adding temp var to improve readability Cristian Sicilia
@ 2019-03-31  9:35       ` Jonathan Cameron
  2019-03-31  9:35       ` Jonathan Cameron
  1 sibling, 0 replies; 33+ messages in thread
From: Jonathan Cameron @ 2019-03-31  9:35 UTC (permalink / raw)
  To: Cristian Sicilia
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, Greg Kroah-Hartman, linux-iio, devel,
	linux-kernel

On Sun, 24 Mar 2019 18:23:14 +0100
Cristian Sicilia <sicilia.cristian@gmail.com> wrote:

> Creating a temporary variable to improve readability
> 
> Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
I have already applied this one.

Thanks,

Jonathan

> ---
>  drivers/staging/iio/adc/ad7280a.c | 55 ++++++++++++++++++---------------------
>  1 file changed, 25 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
> index c2391f6..4ff28f1 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -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));
> +			}
>  		}
>  	}
>  


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 4/5] staging: iio: adc: ad7280a: Adding temp var to improve readability
  2019-03-24 17:23     ` [PATCH v3 4/5] staging: iio: adc: ad7280a: Adding temp var to improve readability Cristian Sicilia
  2019-03-31  9:35       ` Jonathan Cameron
@ 2019-03-31  9:35       ` Jonathan Cameron
  1 sibling, 0 replies; 33+ messages in thread
From: Jonathan Cameron @ 2019-03-31  9:35 UTC (permalink / raw)
  To: Cristian Sicilia
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, Greg Kroah-Hartman, linux-iio, devel,
	linux-kernel

On Sun, 24 Mar 2019 18:23:14 +0100
Cristian Sicilia <sicilia.cristian@gmail.com> wrote:

> Creating a temporary variable to improve readability
> 
> Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
Already applied this one as well.

Thanks,

Jonathan

> ---
>  drivers/staging/iio/adc/ad7280a.c | 55 ++++++++++++++++++---------------------
>  1 file changed, 25 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
> index c2391f6..4ff28f1 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -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));
> +			}
>  		}
>  	}
>  


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v3 5/5] staging: iio: adc: ad7280a: Remove CamelCase notation
  2019-03-24 17:23     ` [PATCH v3 5/5] staging: iio: adc: ad7280a: Remove CamelCase notation Cristian Sicilia
@ 2019-03-31  9:37       ` Jonathan Cameron
  0 siblings, 0 replies; 33+ messages in thread
From: Jonathan Cameron @ 2019-03-31  9:37 UTC (permalink / raw)
  To: Cristian Sicilia
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, Greg Kroah-Hartman, linux-iio, devel,
	linux-kernel

On Sun, 24 Mar 2019 18:23:16 +0100
Cristian Sicilia <sicilia.cristian@gmail.com> wrote:

> Fix CamelCase naming.
> 
> Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
Already applied this one as well.

So whole set has been applied.

Thanks,

Jonathan

> ---
>  drivers/staging/iio/adc/ad7280a.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
> index 4ff28f1..229dcad 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -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);


^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2019-03-31  9:37 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-23 12:53 [PATCH 0/5] *** SUBJECT HERE *** Cristian Sicilia
2019-03-23 12:53 ` [PATCH 3/5] staging: iio: adc: Avoid precedence issues in macro Cristian Sicilia
2019-03-23 12:53 ` [PATCH 4/5] staging: iio: adc: Adding temp var to improve readability Cristian Sicilia
2019-03-23 12:54 ` [PATCH 2/5] staging: iio: adc: Converted bool to bitfield format Cristian Sicilia
2019-03-23 12:54 ` [PATCH 5/5] staging: iio: adc: Remove CamelCase notation Cristian Sicilia
2019-03-23 12:58 ` [PATCH 1/5] staging: iio: adc: Tab alignment Cristian Sicilia
2019-03-23 19:21 ` [PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
2019-03-23 19:21   ` [PATCH v2 1/5] staging: iio: adc: Tab alignment Cristian Sicilia
2019-03-24 12:35     ` Jonathan Cameron
2019-03-24 16:34       ` Cristian Sicilia
2019-03-23 19:21   ` [PATCH v2 2/5] staging: iio: adc: Converted bool to bitfield format Cristian Sicilia
2019-03-24 12:34     ` Jonathan Cameron
2019-03-24 16:33       ` Sicilia Cristian
2019-03-23 19:21   ` [PATCH v2 3/5] staging: iio: adc: Avoid precedence issues in macro Cristian Sicilia
2019-03-24 12:37     ` Jonathan Cameron
2019-03-23 19:21   ` [PATCH v2 4/5] staging: iio: adc: Adding temp var to improve readability Cristian Sicilia
2019-03-24 12:41     ` Jonathan Cameron
2019-03-23 19:21   ` [PATCH v2 5/5] staging: iio: adc: Remove CamelCase notation Cristian Sicilia
2019-03-24 14:56     ` Jonathan Cameron
2019-03-24 17:23   ` [PATCH v2 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
2019-03-24 17:23     ` [PATCH v3 1/5] staging: iio: adc: ad7280a: Tab alignment Cristian Sicilia
2019-03-31  9:29       ` Jonathan Cameron
2019-03-24 17:23     ` [PATCH v3 2/5] staging: iio: adc: ad7192: Converted bool to bitfield format Cristian Sicilia
2019-03-31  9:32       ` Jonathan Cameron
2019-03-24 17:23     ` [PATCH v3 3/5] staging: iio: adc: ad7280a: Avoid precedence issues in macro Cristian Sicilia
2019-03-31  9:34       ` Jonathan Cameron
2019-03-24 17:23     ` [PATCH v3 4/5] staging: iio: adc: ad7280a: Adding temp var to improve readability Cristian Sicilia
2019-03-31  9:35       ` Jonathan Cameron
2019-03-31  9:35       ` Jonathan Cameron
2019-03-24 17:23     ` [PATCH v3 5/5] staging: iio: adc: ad7280a: Remove CamelCase notation Cristian Sicilia
2019-03-31  9:37       ` Jonathan Cameron
2019-03-24 17:27     ` [PATCH v3 0/5] staging: iio: adc: Code refactoring and bool to bitfield change Cristian Sicilia
2019-03-23 19:24 ` [PATCH 0/5] *** SUBJECT HERE *** Matt Ranostay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).