Enhance dt support and channel creation
Subsystems (4)
cover 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(-)
Signature · 1 line
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.
--- drivers/staging/iio/cdc/ad7150.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/staging/iio/cdc/ad7150.c +10 -0
@@ -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,
Signature · 1 line
2.22.0.rc0.1.g337bb99195.dirty
Jonathan Cameron
maintainerRe: [PATCH 1/2] staging: iio: cdc: ad7150: create of_device_id array
Quoted 8 lines · On Sat, 18 May 2019 19:41:35 -0300 Bárbara Fernandes…
Create structure of type
of_device_idin order to register all devices the driver is able to manage.Signed-off-by Bárbara Fernandes <[email protected]>Signed-off-by Melissa Wen <[email protected]>Co-developed-by Melissa Wen <[email protected]>Signed-off-by Wilson Sales <[email protected]>Co-developed-by Wilson Sales <[email protected]>
Hi,
One really minor point inline, otherwise looks good to me.
Thanks,
Jonathan
Quoted 11 lines
--- drivers/staging/iio/cdc/ad7150.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/staging/iio/cdc/ad7150.c +0
-0@@ -655,11 +655,21 @@ static const struct i2c_device_id ad7150_id[] = { {} };
drivers/staging/iio/cdc/ad7150.c static const struct i2c_device_id ad7150_id[] = { · line 666
Quoted 10 lines
drivers/staging/iio/cdc/ad7150.c +9
-0+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); +
I would suggest keeping the below MODULE_DEVICE_TABLE entry next to the definition of ad7150_id rather than putting this new block in between them.
In short, just move your additions below the next line.
Thanks,
Jonathan
Quoted 9 lines
drivers/staging/iio/cdc/ad7150.c +1
-0MODULE_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,
PATCH 2/2 staging: iio: cdc: ad7150: create macro for capacitance channels
In reply to Bárbara FernandesCreate macro for capacitance channels in order to remove the repeated code and improve its readability.
--- drivers/staging/iio/cdc/ad7150.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-)
drivers/staging/iio/cdc/ad7150.c +12 -17
@@ -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 ) };/*
Signature · 1 line
2.22.0.rc0.1.g337bb99195.dirty
Jonathan Cameron
maintainerRe: [PATCH 2/2] staging: iio: cdc: ad7150: create macro for capacitance channels
Quoted 6 lines · On Sat, 18 May 2019 19:41:36 -0300 Bárbara Fernandes…
Create macro for capacitance channels in order to remove the repeated code and improve its readability.
Signed-off-by Bárbara Fernandes <[email protected]>Signed-off-by Wilson Sales <[email protected]>Co-developed-by Wilson Sales <[email protected]>
Not a totally clear cut case given there are only two instances, but I think, on balance that it is an improvement.
As this isn't really connected to patch 1 in the series (or the fix going via the other tree) I'll apply this one now. Please only send a new version of patch 1.
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders (0-day etc) to see if they can find anything we have missed.
Some time after those test results have come in, I'll push the tree out as togreg, and in a few weeks send a pull request to Greg to hopefully have it pulled into his tree which is part of Linux next and from which he will then send a pull request to Linus in the next merge window.
Thanks,
Jonathan
Quoted 45 lines
--- drivers/staging/iio/cdc/ad7150.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-)drivers/staging/iio/cdc/ad7150.c +12
-17@@ -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 ) };/*