Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: adc: vf610_adc: limit i.MX6SX's channel number to 4

i.MX6SX only has 4 ADC channels, so limit channel numbers to 4 for
compatible string 'fsl,imx6sx-adc'.

Reviewed-by: Haibo Chen <haibo.chen@nxp.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20241126195256.2441622-2-Frank.Li@nxp.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Frank Li and committed by
Jonathan Cameron
8278c08a 207149d9

+18 -2
+18 -2
drivers/iio/adc/vf610_adc.c
··· 177 177 } scan; 178 178 }; 179 179 180 + struct vf610_chip_info { 181 + u8 num_channels; 182 + }; 183 + 180 184 static const u32 vf610_hw_avgs[] = { 1, 4, 8, 16, 32 }; 181 185 static const u32 vf610_lst_adder[] = { 3, 5, 7, 9, 13, 17, 21, 25 }; 182 186 ··· 812 808 .attrs = &vf610_attribute_group, 813 809 }; 814 810 811 + static const struct vf610_chip_info vf610_chip_info = { 812 + .num_channels = ARRAY_SIZE(vf610_adc_iio_channels), 813 + }; 814 + 815 + static const struct vf610_chip_info imx6sx_chip_info = { 816 + .num_channels = 4, 817 + }; 818 + 815 819 static const struct of_device_id vf610_adc_match[] = { 816 - { .compatible = "fsl,vf610-adc", }, 820 + { .compatible = "fsl,imx6sx-adc", .data = &imx6sx_chip_info}, 821 + { .compatible = "fsl,vf610-adc", .data = &vf610_chip_info}, 817 822 { /* sentinel */ } 818 823 }; 819 824 MODULE_DEVICE_TABLE(of, vf610_adc_match); ··· 836 823 837 824 static int vf610_adc_probe(struct platform_device *pdev) 838 825 { 826 + const struct vf610_chip_info *chip_info; 839 827 struct device *dev = &pdev->dev; 840 828 struct vf610_adc *info; 841 829 struct iio_dev *indio_dev; ··· 853 839 info->regs = devm_platform_ioremap_resource(pdev, 0); 854 840 if (IS_ERR(info->regs)) 855 841 return PTR_ERR(info->regs); 842 + 843 + chip_info = device_get_match_data(dev); 856 844 857 845 irq = platform_get_irq(pdev, 0); 858 846 if (irq < 0) ··· 897 881 indio_dev->info = &vf610_adc_iio_info; 898 882 indio_dev->modes = INDIO_DIRECT_MODE; 899 883 indio_dev->channels = vf610_adc_iio_channels; 900 - indio_dev->num_channels = ARRAY_SIZE(vf610_adc_iio_channels); 884 + indio_dev->num_channels = chip_info->num_channels; 901 885 902 886 vf610_adc_cfg_init(info); 903 887 vf610_adc_hw_init(info);