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>
This commit is contained in:
Родитель
ec82edb258
Коммит
9695a2a52c
|
@ -15,6 +15,7 @@
|
||||||
#include <linux/math64.h>
|
#include <linux/math64.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
|
#include <linux/of_device.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
@ -807,8 +808,6 @@ static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node)
|
||||||
struct adc5_channel_prop prop, *chan_props;
|
struct adc5_channel_prop prop, *chan_props;
|
||||||
struct device_node *child;
|
struct device_node *child;
|
||||||
unsigned int index = 0;
|
unsigned int index = 0;
|
||||||
const struct of_device_id *id;
|
|
||||||
const struct adc5_data *data;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
adc->nchannels = of_get_available_child_count(node);
|
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)
|
||||||
|
|
||||||
chan_props = adc->chan_props;
|
chan_props = adc->chan_props;
|
||||||
iio_chan = adc->iio_chans;
|
iio_chan = adc->iio_chans;
|
||||||
id = of_match_node(adc5_match_table, node);
|
adc->data = of_device_get_match_data(adc->dev);
|
||||||
if (id)
|
if (!adc->data)
|
||||||
data = id->data;
|
adc->data = &adc5_data_pmic;
|
||||||
else
|
|
||||||
data = &adc5_data_pmic;
|
|
||||||
adc->data = data;
|
|
||||||
|
|
||||||
for_each_available_child_of_node(node, child) {
|
for_each_available_child_of_node(node, child) {
|
||||||
ret = adc5_get_dt_channel_data(adc, &prop, child, data);
|
ret = adc5_get_dt_channel_data(adc, &prop, child, adc->data);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
of_node_put(child);
|
of_node_put(child);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
prop.scale_fn_type =
|
prop.scale_fn_type =
|
||||||
data->adc_chans[prop.channel].scale_fn_type;
|
adc->data->adc_chans[prop.channel].scale_fn_type;
|
||||||
*chan_props = prop;
|
*chan_props = prop;
|
||||||
adc_chan = &data->adc_chans[prop.channel];
|
adc_chan = &adc->data->adc_chans[prop.channel];
|
||||||
|
|
||||||
iio_chan->channel = prop.channel;
|
iio_chan->channel = prop.channel;
|
||||||
iio_chan->datasheet_name = prop.datasheet_name;
|
iio_chan->datasheet_name = prop.datasheet_name;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче