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
Re: [PATCH 1/2] staging: iio: cdc: ad7150: create of_device_id array
Quoted 4 lines · Bárbara Fernandes
Create structure of type
of_device_idin order to register all devices the driver is able to manage.
Hey,
CC-ing my work-email
There are some issues with it and mailing lists; I'll hopefully sort them out in the next weeks.
Quoted 15 lines
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]>--- 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 665
Quoted 10 lines
drivers/staging/iio/cdc/ad7150.c +8
-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);
nitpick: you don't need to add i2c in the name
so, this could be justMODULE_DEVICE_TABLE(of, ad7150_of_match);
but it's not a blocker for this;
So,
Quoted 13 lines
drivers/staging/iio/cdc/ad7150.c +2
-1+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
Re: [PATCH 1/2] staging: iio: cdc: ad7150: create of_device_id array
Quoted 47 lines · Alexandru Ardelean
[External]
Quoted 4 lines · Bárbara Fernandes
Create structure of type
of_device_idin order to register all devices the driver is able to manage.Hey,
CC-ing my work-email
There are some issues with it and mailing lists; I'll hopefully sort them out in the next weeks.Quoted 16 lines
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]>--- 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 665
Quoted 10 lines
drivers/staging/iio/cdc/ad7150.c +8
-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);nitpick: you don't need to add i2c in the name
so, this could be justMODULE_DEVICE_TABLE(of, ad7150_of_match);
Quoted 1 line
but it's not a blocker for this;
Actually, disregard the above comment.
I just thought of some cases where it makes sense to have the i2c in the name. So, ad7150_of_i2c_match is fine.
Quoted 18 lines
So,
Quoted 13 lines
drivers/staging/iio/cdc/ad7150.c +2
-1+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
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