Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Commit

Permalink
iio: adc: vf610: let channel order can be specified in device tree
Browse files Browse the repository at this point in the history
Add attribute 'use-channels' to specify which channel is used by ADC in device tree.
  • Loading branch information
richard-hu authored and ray-chang committed Dec 10, 2018
1 parent ca23882 commit 9bceeb3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion drivers/iio/adc/vf610_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,9 @@ static const struct iio_chan_spec_ext_info vf610_ext_info[] = {
}, \
}

static const struct iio_chan_spec vf610_adc_iio_channels[] = {
#define MAX_IIO_CHANNEL_NUM 16

static struct iio_chan_spec vf610_adc_iio_channels[] = {
VF610_ADC_CHAN(0, IIO_VOLTAGE),
VF610_ADC_CHAN(1, IIO_VOLTAGE),
VF610_ADC_CHAN(2, IIO_VOLTAGE),
Expand Down Expand Up @@ -819,6 +821,8 @@ static int vf610_adc_probe(struct platform_device *pdev)
struct resource *mem;
int irq;
int ret;
int i;
int use_channel[MAX_IIO_CHANNEL_NUM];
u32 channels;

indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct vf610_adc));
Expand Down Expand Up @@ -883,6 +887,13 @@ static int vf610_adc_probe(struct platform_device *pdev)
if (ret)
channels = ARRAY_SIZE(vf610_adc_iio_channels);

if (!of_property_read_u32_array(pdev->dev.of_node, "use-channels", use_channel, (int)channels)) {
if (((int)channels) <= MAX_IIO_CHANNEL_NUM) {
for (i = 0; i < (int)channels; i++)
vf610_adc_iio_channels[i].channel = use_channel[i];
}
}

indio_dev->name = dev_name(&pdev->dev);
indio_dev->dev.parent = &pdev->dev;
indio_dev->dev.of_node = pdev->dev.of_node;
Expand Down

0 comments on commit 9bceeb3

Please sign in to comment.