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
Enclosing parameter with parenthesis due to avoid
possible precedence issue.
Signed-off-by: Cristian Sicilia <[email protected]>
---
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
Creating a temporary variable to improve readability
Signed-off-by: Cristian Sicilia <[email protected]>
---
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
Signed-off-by: Cristian Sicilia <[email protected]>
---
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
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.
---
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
Aligned some parameters.
Signed-off-by: Cristian Sicilia <[email protected]>
---
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
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
Aligned some parameters.
Signed-off-by: Cristian Sicilia <[email protected]>
---
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
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.
---
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
Enclosing parameter with parenthesis due to avoid
possible precedence issue.
Signed-off-by: Cristian Sicilia <[email protected]>
---
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
Fix CamelCase naming.
Signed-off-by: Cristian Sicilia <[email protected]>
---
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
You may want to change "*** SUBJECT HERE ***" in the future :)
- Matt
On Sat, Mar 23, 2019 at 5:53 AM Cristian Sicilia
<[email protected]> 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
>
Creating a temporary variable to improve readability
Signed-off-by: Cristian Sicilia <[email protected]>
---
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
On Sat, 23 Mar 2019 20:21:39 +0100
Cristian Sicilia <[email protected]> wrote:
> 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...
> ---
> 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_ */
On Sat, 23 Mar 2019 20:21:36 +0100
Cristian Sicilia <[email protected]> wrote:
> Aligned some parameters.
>
> Signed-off-by: Cristian Sicilia <[email protected]>
> ---
> 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,
On Sat, 23 Mar 2019 20:21:42 +0100
Cristian Sicilia <[email protected]> wrote:
> 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
> ---
> 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
On Sat, 23 Mar 2019 20:21:45 +0100
Cristian Sicilia <[email protected]> wrote:
> 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
> ---
> 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));
> + }
> }
> }
>
On Sat, 23 Mar 2019 20:21:49 +0100
Cristian Sicilia <[email protected]> wrote:
> 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
> ---
> 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);
On Sun, Mar 24, 2019 at 12:34:52PM +0000, Jonathan Cameron wrote:
> On Sat, 23 Mar 2019 20:21:39 +0100
> Cristian Sicilia <[email protected]> wrote:
>
> > 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...
>
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_ */
>
On Sun, Mar 24, 2019 at 12:35:52PM +0000, Jonathan Cameron wrote:
> On Sat, 23 Mar 2019 20:21:36 +0100
> Cristian Sicilia <[email protected]> wrote:
>
> > Aligned some parameters.
> >
> > Signed-off-by: Cristian Sicilia <[email protected]>
> > ---
> > 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,
>
Changed bool format to bitfield format to save space.
Signed-off-by: Cristian Sicilia <[email protected]>
---
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
Aligned some parameters.
Signed-off-by: Cristian Sicilia <[email protected]>
---
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
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
Enclosing parameter with parenthesis due to avoid
possible precedence issue.
Signed-off-by: Cristian Sicilia <[email protected]>
---
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
Fix CamelCase naming.
Signed-off-by: Cristian Sicilia <[email protected]>
---
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
Creating a temporary variable to improve readability
Signed-off-by: Cristian Sicilia <[email protected]>
---
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
On Sun, 24 Mar 2019 18:23:09 +0100
Cristian Sicilia <[email protected]> wrote:
> 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
> ---
> 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,
On Sun, 24 Mar 2019 18:23:11 +0100
Cristian Sicilia <[email protected]> wrote:
> 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
> ---
> 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_ */
On Sun, 24 Mar 2019 18:23:12 +0100
Cristian Sicilia <[email protected]> wrote:
> 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
> ---
> 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
On Sun, 24 Mar 2019 18:23:14 +0100
Cristian Sicilia <[email protected]> wrote:
> Creating a temporary variable to improve readability
>
> Signed-off-by: Cristian Sicilia <[email protected]>
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));
> + }
> }
> }
>
On Sun, 24 Mar 2019 18:23:14 +0100
Cristian Sicilia <[email protected]> wrote:
> Creating a temporary variable to improve readability
>
> Signed-off-by: Cristian Sicilia <[email protected]>
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));
> + }
> }
> }
>
On Sun, 24 Mar 2019 18:23:16 +0100
Cristian Sicilia <[email protected]> wrote:
> Fix CamelCase naming.
>
> Signed-off-by: Cristian Sicilia <[email protected]>
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);