diff mbox series

[v2,3/5] iio: adc: mcp320x: use conv_time instead of device_index switch

Message ID 20220831100506.3368103-4-vincent.whitchurch@axis.com (mailing list archive)
State Changes Requested
Headers show
Series iio: adc: mcp320x: Add triggered buffer support | expand

Commit Message

Vincent Whitchurch Aug. 31, 2022, 10:05 a.m. UTC
In mcp320x_adc_conversion(), the presence of the chip_info's conv_time
is used as a condition for using the conversion message.  Use that same
condition when initializing the conversion message and the other
handling for variants which need it, instead of the different condition
(checking of the device_index) which is used currently.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
 drivers/iio/adc/mcp320x.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Andy Shevchenko Aug. 31, 2022, 12:43 p.m. UTC | #1
On Wed, Aug 31, 2022 at 1:05 PM Vincent Whitchurch
<vincent.whitchurch@axis.com> wrote:
>
> In mcp320x_adc_conversion(), the presence of the chip_info's conv_time
> is used as a condition for using the conversion message.  Use that same
> condition when initializing the conversion message and the other
> handling for variants which need it, instead of the different condition
> (checking of the device_index) which is used currently.

...

> +       if (chip_info->conv_time) {

It would be nice to have conv_time_us renamed before this change.
diff mbox series

Patch

diff --git a/drivers/iio/adc/mcp320x.c b/drivers/iio/adc/mcp320x.c
index 77fb4522a378..8ed27df9a0bb 100644
--- a/drivers/iio/adc/mcp320x.c
+++ b/drivers/iio/adc/mcp320x.c
@@ -429,11 +429,7 @@  static int mcp320x_probe(struct spi_device *spi)
 		spi_message_init_with_transfers(&adc->msg, adc->transfer,
 						ARRAY_SIZE(adc->transfer));
 
-	switch (device_index) {
-	case mcp3550_50:
-	case mcp3550_60:
-	case mcp3551:
-	case mcp3553:
+	if (chip_info->conv_time) {
 		/* rx len increases from 24 to 25 bit in SPI mode 0,0 */
 		if (!(spi->mode & SPI_CPOL))
 			adc->transfer[1].len++;