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

iio: adc: ab8500-gpadc: convert to device properties

Make the conversion to firmware agnostic device properties. As part of
the conversion the IIO inkern interface 'of_xlate()' is also converted to
'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
dependencies from IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220715122903.332535-9-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Nuno Sá and committed by
Jonathan Cameron
dec7e2c8 9ac07597

+12 -15
+12 -15
drivers/iio/adc/ab8500-gpadc.c
··· 925 925 return -EINVAL; 926 926 } 927 927 928 - static int ab8500_gpadc_of_xlate(struct iio_dev *indio_dev, 929 - const struct of_phandle_args *iiospec) 928 + static int ab8500_gpadc_fwnode_xlate(struct iio_dev *indio_dev, 929 + const struct fwnode_reference_args *iiospec) 930 930 { 931 931 int i; 932 932 ··· 938 938 } 939 939 940 940 static const struct iio_info ab8500_gpadc_info = { 941 - .of_xlate = ab8500_gpadc_of_xlate, 941 + .fwnode_xlate = ab8500_gpadc_fwnode_xlate, 942 942 .read_raw = ab8500_gpadc_read_raw, 943 943 }; 944 944 ··· 968 968 /** 969 969 * ab8500_gpadc_parse_channel() - process devicetree channel configuration 970 970 * @dev: pointer to containing device 971 - * @np: device tree node for the channel to configure 971 + * @fwnode: fw node for the channel to configure 972 972 * @ch: channel info to fill in 973 973 * @iio_chan: IIO channel specification to fill in 974 974 * ··· 976 976 * and define usage for things like AUX GPADC inputs more precisely. 977 977 */ 978 978 static int ab8500_gpadc_parse_channel(struct device *dev, 979 - struct device_node *np, 979 + struct fwnode_handle *fwnode, 980 980 struct ab8500_gpadc_chan_info *ch, 981 981 struct iio_chan_spec *iio_chan) 982 982 { 983 - const char *name = np->name; 983 + const char *name = fwnode_get_name(fwnode); 984 984 u32 chan; 985 985 int ret; 986 986 987 - ret = of_property_read_u32(np, "reg", &chan); 987 + ret = fwnode_property_read_u32(fwnode, "reg", &chan); 988 988 if (ret) { 989 989 dev_err(dev, "invalid channel number %s\n", name); 990 990 return ret; ··· 1021 1021 /** 1022 1022 * ab8500_gpadc_parse_channels() - Parse the GPADC channels from DT 1023 1023 * @gpadc: the GPADC to configure the channels for 1024 - * @np: device tree node containing the channel configurations 1025 1024 * @chans: the IIO channels we parsed 1026 1025 * @nchans: the number of IIO channels we parsed 1027 1026 */ 1028 1027 static int ab8500_gpadc_parse_channels(struct ab8500_gpadc *gpadc, 1029 - struct device_node *np, 1030 1028 struct iio_chan_spec **chans_parsed, 1031 1029 unsigned int *nchans_parsed) 1032 1030 { 1033 - struct device_node *child; 1031 + struct fwnode_handle *child; 1034 1032 struct ab8500_gpadc_chan_info *ch; 1035 1033 struct iio_chan_spec *iio_chans; 1036 1034 unsigned int nchans; 1037 1035 int i; 1038 1036 1039 - nchans = of_get_available_child_count(np); 1037 + nchans = device_get_child_node_count(gpadc->dev); 1040 1038 if (!nchans) { 1041 1039 dev_err(gpadc->dev, "no channel children\n"); 1042 1040 return -ENODEV; ··· 1052 1054 return -ENOMEM; 1053 1055 1054 1056 i = 0; 1055 - for_each_available_child_of_node(np, child) { 1057 + device_for_each_child_node(gpadc->dev, child) { 1056 1058 struct iio_chan_spec *iio_chan; 1057 1059 int ret; 1058 1060 ··· 1062 1064 ret = ab8500_gpadc_parse_channel(gpadc->dev, child, ch, 1063 1065 iio_chan); 1064 1066 if (ret) { 1065 - of_node_put(child); 1067 + fwnode_handle_put(child); 1066 1068 return ret; 1067 1069 } 1068 1070 i++; ··· 1079 1081 struct ab8500_gpadc *gpadc; 1080 1082 struct iio_dev *indio_dev; 1081 1083 struct device *dev = &pdev->dev; 1082 - struct device_node *np = pdev->dev.of_node; 1083 1084 struct iio_chan_spec *iio_chans; 1084 1085 unsigned int n_iio_chans; 1085 1086 int ret; ··· 1093 1096 gpadc->dev = dev; 1094 1097 gpadc->ab8500 = dev_get_drvdata(dev->parent); 1095 1098 1096 - ret = ab8500_gpadc_parse_channels(gpadc, np, &iio_chans, &n_iio_chans); 1099 + ret = ab8500_gpadc_parse_channels(gpadc, &iio_chans, &n_iio_chans); 1097 1100 if (ret) 1098 1101 return ret; 1099 1102