*** SUBJECT HERE ***
Subsystems (4)
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
PATCH 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
@@ -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
PATCH 2/5 staging: iio: adc: Converted bool to bitfield format
In reply to Cristian SiciliaChanged 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
@@ -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
PATCH 3/5 staging: iio: adc: Avoid precedence issues in macro
In reply to Cristian SiciliaEnclosing 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
@@ -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
PATCH 4/5 staging: iio: adc: Adding temp var to improve readability
In reply to Cristian SiciliaCreating 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
@@ -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
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
@@ -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
v2 cover staging: iio: adc: Code refactoring and bool to bitfield change
In reply to Cristian SiciliaSome 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
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
@@ -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
Jonathan Cameron
maintainerRe: [PATCH v2 1/5] staging: iio: adc: Tab alignment
Quoted 12 lines · On Sat, 23 Mar 2019 20:21:36 +0100 Cristian Sicilia…
Aligned some parameters.
Signed-off-by Cristian Sicilia <[email protected]>--- drivers/staging/iio/adc/ad7280a.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)drivers/staging/iio/adc/ad7280a.c +0
-0
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,
Re: [PATCH v2 1/5] staging: iio: adc: Tab alignment
Quoted 17 lines · Jonathan Cameron
Quoted 14 lines · On Sat, 23 Mar 2019 20:21:36 +0100 Cristian Sicilia…
Aligned some parameters.
Signed-off-by Cristian Sicilia <[email protected]>--- drivers/staging/iio/adc/ad7280a.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)drivers/staging/iio/adc/ad7280a.c +0
-0@@ -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
-5static 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,
PATCH v2 2/5 staging: iio: adc: Converted bool to bitfield format
In reply to Cristian SiciliaChanged 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
@@ -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
Jonathan Cameron
maintainerRe: [PATCH v2 2/5] staging: iio: adc: Converted bool to bitfield format
Quoted 7 lines · On Sat, 23 Mar 2019 20:21:39 +0100 Cristian Sicilia…
Changed bool format to bitfield format to save space.
Signed-off-by Cristian Sicilia <[email protected]>---
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@@ -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_ */
Re: [PATCH v2 2/5] staging: iio: adc: Converted bool to bitfield format
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.
Signed-off-by Cristian Sicilia <[email protected]>---
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@@ -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_ */
PATCH v2 3/5 staging: iio: adc: Avoid precedence issues in macro
In reply to Cristian SiciliaEnclosing 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
@@ -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
Re: [PATCH v2 3/5] staging: iio: adc: Avoid precedence issues in macro
Quoted 4 lines · On Sat, 23 Mar 2019 20:21:42 +0100 Cristian Sicilia…
Enclosing parameter with parenthesis due to avoid
possible precedence issue.Signed-off-by Cristian Sicilia <[email protected]>
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@@ -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
PATCH v2 4/5 staging: iio: adc: Adding temp var to improve readability
In reply to Cristian SiciliaCreating 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
@@ -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
Re: [PATCH v2 4/5] staging: iio: adc: Adding temp var to improve readability
Quoted 3 lines · On Sat, 23 Mar 2019 20:21:45 +0100 Cristian Sicilia…
Creating a temporary variable to improve readability
Signed-off-by Cristian Sicilia <[email protected]>
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@@ -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)); + } } }
PATCH v2 5/5 staging: iio: adc: Remove CamelCase notation
In reply to Cristian SiciliaFix CamelCase naming.
--- drivers/staging/iio/adc/ad7280a.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/staging/iio/adc/ad7280a.c +5 -6
@@ -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
Re: [PATCH v2 5/5] staging: iio: adc: Remove CamelCase notation
Quoted 3 lines · On Sat, 23 Mar 2019 20:21:49 +0100 Cristian Sicilia…
Fix CamelCase naming.
Signed-off-by Cristian Sicilia <[email protected]>
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@@ -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 );
v2 cover staging: iio: adc: Code refactoring and bool to bitfield change
In reply to Cristian SiciliaSome 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
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
@@ -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
Jonathan Cameron
maintainerRe: [PATCH v3 1/5] staging: iio: adc: ad7280a: Tab alignment
Quoted 3 lines · On Sun, 24 Mar 2019 18:23:09 +0100 Cristian Sicilia…
Aligned some parameters.
Signed-off-by Cristian Sicilia <[email protected]>
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@@ -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,
PATCH v3 2/5 staging: iio: adc: ad7192: Converted bool to bitfield format
In reply to Cristian SiciliaChanged 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
@@ -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
Jonathan Cameron
maintainerRe: [PATCH v3 2/5] staging: iio: adc: ad7192: Converted bool to bitfield format
Quoted 3 lines · On Sun, 24 Mar 2019 18:23:11 +0100 Cristian Sicilia…
Changed bool format to bitfield format to save space.
Signed-off-by Cristian Sicilia <[email protected]>
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@@ -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_ */
PATCH v3 3/5 staging: iio: adc: ad7280a: Avoid precedence issues in macro
In reply to Cristian SiciliaEnclosing 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
@@ -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
Jonathan Cameron
maintainerRe: [PATCH v3 3/5] staging: iio: adc: ad7280a: Avoid precedence issues in macro
Quoted 4 lines · On Sun, 24 Mar 2019 18:23:12 +0100 Cristian Sicilia…
Enclosing parameter with parenthesis due to avoid
possible precedence issue.Signed-off-by Cristian Sicilia <[email protected]>
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@@ -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
PATCH v3 4/5 staging: iio: adc: ad7280a: Adding temp var to improve readability
In reply to Cristian SiciliaCreating 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
@@ -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
Jonathan Cameron
maintainerRe: [PATCH v3 4/5] staging: iio: adc: ad7280a: Adding temp var to improve readability
Quoted 3 lines · On Sun, 24 Mar 2019 18:23:14 +0100 Cristian Sicilia…
Creating a temporary variable to improve readability
Signed-off-by Cristian Sicilia <[email protected]>
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@@ -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)); + } } }
Jonathan Cameron
maintainerRe: [PATCH v3 4/5] staging: iio: adc: ad7280a: Adding temp var to improve readability
In reply to Cristian SiciliaQuoted 3 lines · On Sun, 24 Mar 2019 18:23:14 +0100 Cristian Sicilia…
Creating a temporary variable to improve readability
Signed-off-by Cristian Sicilia <[email protected]>
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@@ -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)); + } } }
PATCH v3 5/5 staging: iio: adc: ad7280a: Remove CamelCase notation
In reply to Cristian SiciliaFix CamelCase naming.
--- drivers/staging/iio/adc/ad7280a.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/staging/iio/adc/ad7280a.c +5 -6
@@ -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
Jonathan Cameron
maintainerRe: [PATCH v3 5/5] staging: iio: adc: ad7280a: Remove CamelCase notation
Quoted 3 lines · On Sun, 24 Mar 2019 18:23:16 +0100 Cristian Sicilia…
Fix CamelCase naming.
Signed-off-by Cristian Sicilia <[email protected]>
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@@ -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 );
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 notationdrivers/staging/iio/adc/ad7192.h | 16 +++--- drivers/staging/iio/adc/ad7280a.c | 109 ++++++++++++++++++-------------------- 2 files changed, 60 insertions(+), 65 deletions(-)--
2.7.4