[RESEND PATCH 0/2] Enhance dt support and channel creation
This series of patches set a struct of_device_id with all the devices this driver is able to manage and also add a macro to facilitate channel creation for its two capacitance channels. Bárbara Fernandes (2): staging: iio: cdc: ad7150: create of_device_id array staging: iio: cdc: ad7150: create macro for capacitance channels drivers/staging/iio/cdc/ad7150.c | 39 ++-- 1 file changed, 22 insertions(+), 17 deletions(-) -- 2.22.0.rc0.1.g337bb99195.dirty
[PATCH 1/2] staging: iio: cdc: ad7150: create of_device_id array
Create structure of type of_device_id in order to register all devices the driver is able to manage. Signed-off-by: Bárbara Fernandes Signed-off-by: Melissa Wen Co-developed-by: Melissa Wen Signed-off-by: Wilson Sales Co-developed-by: Wilson Sales --- drivers/staging/iio/cdc/ad7150.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index 4b1c90e1b0ea..072094227e1b 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -655,11 +655,21 @@ static const struct i2c_device_id ad7150_id[] = { {} }; +static const struct of_device_id ad7150_of_i2c_match[] = { + { .compatible = "adi,ad7150" }, + { .compatible = "adi,ad7151" }, + { .compatible = "adi,ad7156" }, + {} +}; + +MODULE_DEVICE_TABLE(of, ad7150_of_i2c_match); + MODULE_DEVICE_TABLE(i2c, ad7150_id); static struct i2c_driver ad7150_driver = { .driver = { .name = "ad7150", + .of_match_table = ad7150_of_i2c_match }, .probe = ad7150_probe, .id_table = ad7150_id, -- 2.22.0.rc0.1.g337bb99195.dirty
[PATCH 2/2] staging: iio: cdc: ad7150: create macro for capacitance channels
Create macro for capacitance channels in order to remove the repeated code and improve its readability. Signed-off-by: Bárbara Fernandes Signed-off-by: Wilson Sales Co-developed-by: Wilson Sales --- drivers/staging/iio/cdc/ad7150.c | 29 - 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index 072094227e1b..d8c43cabce25 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -468,24 +468,19 @@ static const struct iio_event_spec ad7150_events[] = { }, }; +#define AD7150_CAPACITANCE_CHAN(_chan) { \ + .type = IIO_CAPACITANCE,\ + .indexed = 1, \ + .channel = _chan, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_AVERAGE_RAW), \ + .event_spec = ad7150_events,\ + .num_event_specs = ARRAY_SIZE(ad7150_events), \ + } + static const struct iio_chan_spec ad7150_channels[] = { - { - .type = IIO_CAPACITANCE, - .indexed = 1, - .channel = 0, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | - BIT(IIO_CHAN_INFO_AVERAGE_RAW), - .event_spec = ad7150_events, - .num_event_specs = ARRAY_SIZE(ad7150_events), - }, { - .type = IIO_CAPACITANCE, - .indexed = 1, - .channel = 1, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | - BIT(IIO_CHAN_INFO_AVERAGE_RAW), - .event_spec = ad7150_events, - .num_event_specs = ARRAY_SIZE(ad7150_events), - }, + AD7150_CAPACITANCE_CHAN(0), + AD7150_CAPACITANCE_CHAN(1) }; /* -- 2.22.0.rc0.1.g337bb99195.dirty
[RESEND PATCH] staging: iio: adt7316: create of_device_id array
Create structure of type of_device_id in order to register all devices the driver is able to manage. Signed-off-by: Bárbara Fernandes Signed-off-by: Wilson Sales Co-developed-by: Wilson Sales --- drivers/staging/iio/addac/adt7316-spi.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index 8294b9c1e3c2..9968775f1d23 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -127,9 +127,22 @@ static const struct spi_device_id adt7316_spi_id[] = { MODULE_DEVICE_TABLE(spi, adt7316_spi_id); +static const struct of_device_id adt7316_of_spi_match[] = { + { .compatible = "adi,adt7316" }, + { .compatible = "adi,adt7317" }, + { .compatible = "adi,adt7318" }, + { .compatible = "adi,adt7516" }, + { .compatible = "adi,adt7517" }, + { .compatible = "adi,adt7519" }, + { } +}; + +MODULE_DEVICE_TABLE(of, adt7316_of_spi_match); + static struct spi_driver adt7316_driver = { .driver = { .name = "adt7316", + .of_match_table = adt7316_of_spi_match, .pm = ADT7316_PM_OPS, }, .probe = adt7316_spi_probe, -- 2.22.0.rc0.1.g337bb99195.dirty
[RESEND PATCH] staging: iio: ad7192: create of_device_id array
Create list of compatible device ids to be matched with those stated in the device tree. Signed-off-by: Bárbara Fernandes Signed-off-by: Wilson Sales Co-developed by: Wilson Sales --- drivers/staging/iio/adc/ad7192.c | 12 1 file changed, 12 insertions(+) diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index 3d74da9d37e7..cc886f944dbf 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -810,11 +810,23 @@ static const struct spi_device_id ad7192_id[] = { {"ad7195", ID_AD7195}, {} }; + +static const struct of_device_id ad7192_of_spi_match[] = { + { .compatible = "adi,ad7190" }, + { .compatible = "adi,ad7192" }, + { .compatible = "adi,ad7193" }, + { .compatible = "adi,ad7195" }, + {} +}; + +MODULE_DEVICE_TABLE(of, ad7192_of_spi_match); + MODULE_DEVICE_TABLE(spi, ad7192_id); static struct spi_driver ad7192_driver = { .driver = { .name = "ad7192", + .of_match_table = ad7192_of_spi_match, }, .probe = ad7192_probe, .remove = ad7192_remove, -- 2.22.0.rc0.1.g337bb99195.dirty
[PATCH v2] staging: iio: ad7192: create of_device_id array
Create list of compatible device ids to be matched with those stated in the device tree. Signed-off-by: Bárbara Fernandes Signed-off-by: Wilson Sales Co-developed by: Wilson Sales --- drivers/staging/iio/adc/ad7192.c | 12 1 file changed, 12 insertions(+) diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index 3d74da9d37e7..70118db98d94 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -810,11 +810,23 @@ static const struct spi_device_id ad7192_id[] = { {"ad7195", ID_AD7195}, {} }; + MODULE_DEVICE_TABLE(spi, ad7192_id); +static const struct of_device_id ad7192_of_match[] = { + { .compatible = "adi,ad7190" }, + { .compatible = "adi,ad7192" }, + { .compatible = "adi,ad7193" }, + { .compatible = "adi,ad7195" }, + {} +}; + +MODULE_DEVICE_TABLE(of, ad7192_of_match); + static struct spi_driver ad7192_driver = { .driver = { .name = "ad7192", + .of_match_table = ad7192_of_match, }, .probe = ad7192_probe, .remove = ad7192_remove, -- 2.17.1
[PATCH 0/4] Solve checkstyle problems
Solve checkpath.pl's CHECK messages: Bárbara Fernandes (4): iio:adc:ad7923: Align broken line to parenthesis iio:adc:ad7923: Use BIT macro instead of bitshift iio:adc:ad7923: Put macro argument between ()'s iio:adc:ad7923: Rewrite comparison to NULL drivers/iio/adc/ad7923.c | 24 1 file changed, 12 insertions(+), 12 deletions(-) -- 2.17.1
[PATCH 4/4] iio:adc:ad7923: Rewrite comparison to NULL
Solves checkpath.pl's message: CHECK: Comparison to NULL could be written "!indio_dev" Signed-off-by: Bárbara Fernandes --- drivers/iio/adc/ad7923.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c index dbece44e26e4..cb7b854df00c 100644 --- a/drivers/iio/adc/ad7923.c +++ b/drivers/iio/adc/ad7923.c @@ -272,7 +272,7 @@ static int ad7923_probe(struct spi_device *spi) int ret; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); - if (indio_dev == NULL) + if (!indio_dev) return -ENOMEM; st = iio_priv(indio_dev); -- 2.17.1
[PATCH 3/4] iio:adc:ad7923: Put macro argument between ()'s
Put macro argument between parenthesis in order to avoid precedence issues. Solves the following checkpath.pl's messages: CHECK: Macro argument 'mode' may be better as '(mode)' to avoid precedence issues CHECK: Macro argument 'channel' may be better as '(channel)' to avoid precedence issues CHECK: Macro argument reuse 'sequence' - possible side-effects? CHECK: Macro argument 'sequence' may be better as '(sequence)' to avoid precedence issues CHECK: Macro argument 'val' may be better as '(val)' to avoid precedence issues CHECK: Macro argument 'dec' may be better as '(dec)' to avoid precedence issues CHECK: Macro argument 'bits' may be better as '(bits)' to avoid precedence issues Signed-off-by: Bárbara Fernandes --- drivers/iio/adc/ad7923.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c index b39ea834cdd6..dbece44e26e4 100644 --- a/drivers/iio/adc/ad7923.c +++ b/drivers/iio/adc/ad7923.c @@ -40,16 +40,16 @@ #define AD7923_MAX_CHAN4 -#define AD7923_PM_MODE_WRITE(mode) (mode << 4) /* write mode */ -#define AD7923_CHANNEL_WRITE(channel) (channel << 6) /* write channel */ -#define AD7923_SEQUENCE_WRITE(sequence)(((sequence & 1) << 3) \ - + ((sequence & 2) << 9)) +#define AD7923_PM_MODE_WRITE(mode) ((mode) << 4)/* write mode */ +#define AD7923_CHANNEL_WRITE(channel) ((channel) << 6) /* write channel */ +#define AD7923_SEQUENCE_WRITE(sequence)sequence) & 1) << 3) \ + + (((sequence) & 2) << 9)) /* write sequence fonction */ /* left shift for CR : bit 11 transmit in first */ #define AD7923_SHIFT_REGISTER 4 /* val = value, dec = left shift, bits = number of bits of the mask */ -#define EXTRACT(val, dec, bits)((val >> dec) & ((1 << bits) - 1)) +#define EXTRACT(val, dec, bits)(((val) >> (dec)) & ((1 << (bits)) - 1)) struct ad7923_state { struct spi_device *spi; -- 2.17.1
[PATCH 1/4] iio:adc:ad7923: Align broken line to parenthesis
Get broken line aligned with parenthesis on upper line. Solves checkpatch.pl's message: CHECK: Alignment should match open parenthesis Signed-off-by: Bárbara Fernandes --- drivers/iio/adc/ad7923.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c index d62dbb62be45..ebae7522710a 100644 --- a/drivers/iio/adc/ad7923.c +++ b/drivers/iio/adc/ad7923.c @@ -130,7 +130,7 @@ static const struct ad7923_chip_info ad7923_chip_info[] = { * ad7923_update_scan_mode() setup the spi transfer buffer for the new scan mask **/ static int ad7923_update_scan_mode(struct iio_dev *indio_dev, - const unsigned long *active_scan_mask) + const unsigned long *active_scan_mask) { struct ad7923_state *st = iio_priv(indio_dev); int i, cmd, len; @@ -181,7 +181,7 @@ static irqreturn_t ad7923_trigger_handler(int irq, void *p) goto done; iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, - iio_get_time_ns(indio_dev)); + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); @@ -314,7 +314,7 @@ static int ad7923_probe(struct spi_device *spi) return ret; ret = iio_triggered_buffer_setup(indio_dev, NULL, - &ad7923_trigger_handler, NULL); +&ad7923_trigger_handler, NULL); if (ret) goto error_disable_reg; -- 2.17.1
[PATCH 2/4] iio:adc:ad7923: Use BIT macro instead of bitshift
Replace use of the operation '<<' by the BIT macro. Solves checkpath.pl's message: CHECK: Prefer using the BIT macro Signed-off-by: Bárbara Fernandes --- drivers/iio/adc/ad7923.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c index ebae7522710a..b39ea834cdd6 100644 --- a/drivers/iio/adc/ad7923.c +++ b/drivers/iio/adc/ad7923.c @@ -24,9 +24,9 @@ #include #include -#define AD7923_WRITE_CR(1 << 11) /* write control register */ -#define AD7923_RANGE (1 << 1)/* range to REFin */ -#define AD7923_CODING (1 << 0)/* coding is straight binary */ +#define AD7923_WRITE_CRBIT(11) /* write control register */ +#define AD7923_RANGE BIT(1) /* range to REFin */ +#define AD7923_CODING BIT(0) /* coding is straight binary */ #define AD7923_PM_MODE_AS (1) /* auto shutdown */ #define AD7923_PM_MODE_FS (2) /* full shutdown */ #define AD7923_PM_MODE_OPS (3) /* normal operation */ -- 2.17.1