IIO: ADC: stm32-dfsdm: code optimization
Use of_device_get_match_data to optimize the source code. No check is needed on dev_data as match table is defined in driver. Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Родитель
d5ff18bcd4
Коммит
abaca806fd
|
@ -1087,18 +1087,11 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev)
|
||||||
struct device_node *np = dev->of_node;
|
struct device_node *np = dev->of_node;
|
||||||
const struct stm32_dfsdm_dev_data *dev_data;
|
const struct stm32_dfsdm_dev_data *dev_data;
|
||||||
struct iio_dev *iio;
|
struct iio_dev *iio;
|
||||||
const struct of_device_id *of_id;
|
|
||||||
char *name;
|
char *name;
|
||||||
int ret, irq, val;
|
int ret, irq, val;
|
||||||
|
|
||||||
of_id = of_match_node(stm32_dfsdm_adc_match, np);
|
|
||||||
if (!of_id->data) {
|
|
||||||
dev_err(&pdev->dev, "Data associated to device is missing\n");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev_data = (const struct stm32_dfsdm_dev_data *)of_id->data;
|
|
||||||
|
|
||||||
|
dev_data = of_device_get_match_data(dev);
|
||||||
iio = devm_iio_device_alloc(dev, sizeof(*adc));
|
iio = devm_iio_device_alloc(dev, sizeof(*adc));
|
||||||
if (!iio) {
|
if (!iio) {
|
||||||
dev_err(dev, "%s: Failed to allocate IIO\n", __func__);
|
dev_err(dev, "%s: Failed to allocate IIO\n", __func__);
|
||||||
|
|
|
@ -242,7 +242,6 @@ MODULE_DEVICE_TABLE(of, stm32_dfsdm_of_match);
|
||||||
static int stm32_dfsdm_probe(struct platform_device *pdev)
|
static int stm32_dfsdm_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct dfsdm_priv *priv;
|
struct dfsdm_priv *priv;
|
||||||
const struct of_device_id *of_id;
|
|
||||||
const struct stm32_dfsdm_dev_data *dev_data;
|
const struct stm32_dfsdm_dev_data *dev_data;
|
||||||
struct stm32_dfsdm *dfsdm;
|
struct stm32_dfsdm *dfsdm;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -253,13 +252,8 @@ static int stm32_dfsdm_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
priv->pdev = pdev;
|
priv->pdev = pdev;
|
||||||
|
|
||||||
of_id = of_match_node(stm32_dfsdm_of_match, pdev->dev.of_node);
|
dev_data = of_device_get_match_data(&pdev->dev);
|
||||||
if (!of_id->data) {
|
|
||||||
dev_err(&pdev->dev, "Data associated to device is missing\n");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev_data = (const struct stm32_dfsdm_dev_data *)of_id->data;
|
|
||||||
dfsdm = &priv->dfsdm;
|
dfsdm = &priv->dfsdm;
|
||||||
dfsdm->fl_list = devm_kcalloc(&pdev->dev, dev_data->num_filters,
|
dfsdm->fl_list = devm_kcalloc(&pdev->dev, dev_data->num_filters,
|
||||||
sizeof(*dfsdm->fl_list), GFP_KERNEL);
|
sizeof(*dfsdm->fl_list), GFP_KERNEL);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче