Skip to content

Commit 9695a2a

Browse files
lumagjic23
authored andcommitted
iio: adc: qcom-spmi-adc5: use of_device_get_match_data
Use of_device_get_match_data() instead of hand-coding it manually. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Acked-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Link: https://lore.kernel.org/r/20201204025509.1075506-7-dmitry.baryshkov@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent ec82edb commit 9695a2a

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

drivers/iio/adc/qcom-spmi-adc5.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/math64.h>
1616
#include <linux/module.h>
1717
#include <linux/of.h>
18+
#include <linux/of_device.h>
1819
#include <linux/platform_device.h>
1920
#include <linux/regmap.h>
2021
#include <linux/slab.h>
@@ -807,8 +808,6 @@ static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node)
807808
struct adc5_channel_prop prop, *chan_props;
808809
struct device_node *child;
809810
unsigned int index = 0;
810-
const struct of_device_id *id;
811-
const struct adc5_data *data;
812811
int ret;
813812

814813
adc->nchannels = of_get_available_child_count(node);
@@ -827,24 +826,21 @@ static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node)
827826

828827
chan_props = adc->chan_props;
829828
iio_chan = adc->iio_chans;
830-
id = of_match_node(adc5_match_table, node);
831-
if (id)
832-
data = id->data;
833-
else
834-
data = &adc5_data_pmic;
835-
adc->data = data;
829+
adc->data = of_device_get_match_data(adc->dev);
830+
if (!adc->data)
831+
adc->data = &adc5_data_pmic;
836832

837833
for_each_available_child_of_node(node, child) {
838-
ret = adc5_get_dt_channel_data(adc, &prop, child, data);
834+
ret = adc5_get_dt_channel_data(adc, &prop, child, adc->data);
839835
if (ret) {
840836
of_node_put(child);
841837
return ret;
842838
}
843839

844840
prop.scale_fn_type =
845-
data->adc_chans[prop.channel].scale_fn_type;
841+
adc->data->adc_chans[prop.channel].scale_fn_type;
846842
*chan_props = prop;
847-
adc_chan = &data->adc_chans[prop.channel];
843+
adc_chan = &adc->data->adc_chans[prop.channel];
848844

849845
iio_chan->channel = prop.channel;
850846
iio_chan->datasheet_name = prop.datasheet_name;

0 commit comments

Comments
 (0)