Commit ce30eeb6 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Jonathan Cameron

iio: adc: stm32: Simplify with dev_err_probe()

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.
Signed-off-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20200829064726.26268-8-krzk@kernel.orgSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 6d2710ce
...@@ -582,11 +582,9 @@ static int stm32_adc_core_switches_probe(struct device *dev, ...@@ -582,11 +582,9 @@ static int stm32_adc_core_switches_probe(struct device *dev,
priv->syscfg = syscon_regmap_lookup_by_phandle(np, "st,syscfg"); priv->syscfg = syscon_regmap_lookup_by_phandle(np, "st,syscfg");
if (IS_ERR(priv->syscfg)) { if (IS_ERR(priv->syscfg)) {
ret = PTR_ERR(priv->syscfg); ret = PTR_ERR(priv->syscfg);
if (ret != -ENODEV) { if (ret != -ENODEV)
if (ret != -EPROBE_DEFER) return dev_err_probe(dev, ret, "Can't probe syscfg\n");
dev_err(dev, "Can't probe syscfg: %d\n", ret);
return ret;
}
priv->syscfg = NULL; priv->syscfg = NULL;
} }
...@@ -596,12 +594,9 @@ static int stm32_adc_core_switches_probe(struct device *dev, ...@@ -596,12 +594,9 @@ static int stm32_adc_core_switches_probe(struct device *dev,
priv->booster = devm_regulator_get_optional(dev, "booster"); priv->booster = devm_regulator_get_optional(dev, "booster");
if (IS_ERR(priv->booster)) { if (IS_ERR(priv->booster)) {
ret = PTR_ERR(priv->booster); ret = PTR_ERR(priv->booster);
if (ret != -ENODEV) { if (ret != -ENODEV)
if (ret != -EPROBE_DEFER) dev_err_probe(dev, ret, "can't get booster\n");
dev_err(dev, "can't get booster %d\n",
ret);
return ret;
}
priv->booster = NULL; priv->booster = NULL;
} }
} }
...@@ -612,11 +607,9 @@ static int stm32_adc_core_switches_probe(struct device *dev, ...@@ -612,11 +607,9 @@ static int stm32_adc_core_switches_probe(struct device *dev,
priv->vdd = devm_regulator_get_optional(dev, "vdd"); priv->vdd = devm_regulator_get_optional(dev, "vdd");
if (IS_ERR(priv->vdd)) { if (IS_ERR(priv->vdd)) {
ret = PTR_ERR(priv->vdd); ret = PTR_ERR(priv->vdd);
if (ret != -ENODEV) { if (ret != -ENODEV)
if (ret != -EPROBE_DEFER) return dev_err_probe(dev, ret, "can't get vdd\n");
dev_err(dev, "can't get vdd %d\n", ret);
return ret;
}
priv->vdd = NULL; priv->vdd = NULL;
} }
} }
...@@ -669,42 +662,24 @@ static int stm32_adc_probe(struct platform_device *pdev) ...@@ -669,42 +662,24 @@ static int stm32_adc_probe(struct platform_device *pdev)
priv->common.phys_base = res->start; priv->common.phys_base = res->start;
priv->vdda = devm_regulator_get(&pdev->dev, "vdda"); priv->vdda = devm_regulator_get(&pdev->dev, "vdda");
if (IS_ERR(priv->vdda)) { if (IS_ERR(priv->vdda))
ret = PTR_ERR(priv->vdda); return dev_err_probe(&pdev->dev, PTR_ERR(priv->vdda),
if (ret != -EPROBE_DEFER) "vdda get failed\n");
dev_err(&pdev->dev, "vdda get failed, %d\n", ret);
return ret;
}
priv->vref = devm_regulator_get(&pdev->dev, "vref"); priv->vref = devm_regulator_get(&pdev->dev, "vref");
if (IS_ERR(priv->vref)) { if (IS_ERR(priv->vref))
ret = PTR_ERR(priv->vref); return dev_err_probe(&pdev->dev, PTR_ERR(priv->vref),
if (ret != -EPROBE_DEFER) "vref get failed\n");
dev_err(&pdev->dev, "vref get failed, %d\n", ret);
return ret; priv->aclk = devm_clk_get_optional(&pdev->dev, "adc");
} if (IS_ERR(priv->aclk))
return dev_err_probe(&pdev->dev, PTR_ERR(priv->aclk),
priv->aclk = devm_clk_get(&pdev->dev, "adc"); "Can't get 'adc' clock\n");
if (IS_ERR(priv->aclk)) {
ret = PTR_ERR(priv->aclk); priv->bclk = devm_clk_get_optional(&pdev->dev, "bus");
if (ret != -ENOENT) { if (IS_ERR(priv->bclk))
if (ret != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(priv->bclk),
dev_err(&pdev->dev, "Can't get 'adc' clock\n"); "Can't get 'bus' clock\n");
return ret;
}
priv->aclk = NULL;
}
priv->bclk = devm_clk_get(&pdev->dev, "bus");
if (IS_ERR(priv->bclk)) {
ret = PTR_ERR(priv->bclk);
if (ret != -ENOENT) {
if (ret != -EPROBE_DEFER)
dev_err(&pdev->dev, "Can't get 'bus' clock\n");
return ret;
}
priv->bclk = NULL;
}
ret = stm32_adc_core_switches_probe(dev, priv); ret = stm32_adc_core_switches_probe(dev, priv);
if (ret) if (ret)
......
...@@ -1805,13 +1805,9 @@ static int stm32_adc_dma_request(struct device *dev, struct iio_dev *indio_dev) ...@@ -1805,13 +1805,9 @@ static int stm32_adc_dma_request(struct device *dev, struct iio_dev *indio_dev)
adc->dma_chan = dma_request_chan(dev, "rx"); adc->dma_chan = dma_request_chan(dev, "rx");
if (IS_ERR(adc->dma_chan)) { if (IS_ERR(adc->dma_chan)) {
ret = PTR_ERR(adc->dma_chan); ret = PTR_ERR(adc->dma_chan);
if (ret != -ENODEV) { if (ret != -ENODEV)
if (ret != -EPROBE_DEFER) return dev_err_probe(dev, ret,
dev_err(dev, "DMA channel request failed with\n");
"DMA channel request failed with %d\n",
ret);
return ret;
}
/* DMA is optional: fall back to IRQ mode */ /* DMA is optional: fall back to IRQ mode */
adc->dma_chan = NULL; adc->dma_chan = NULL;
......
...@@ -1473,13 +1473,9 @@ static int stm32_dfsdm_adc_init(struct device *dev, struct iio_dev *indio_dev) ...@@ -1473,13 +1473,9 @@ static int stm32_dfsdm_adc_init(struct device *dev, struct iio_dev *indio_dev)
/* Optionally request DMA */ /* Optionally request DMA */
ret = stm32_dfsdm_dma_request(dev, indio_dev); ret = stm32_dfsdm_dma_request(dev, indio_dev);
if (ret) { if (ret) {
if (ret != -ENODEV) { if (ret != -ENODEV)
if (ret != -EPROBE_DEFER) return dev_err_probe(dev, ret,
dev_err(dev, "DMA channel request failed with\n");
"DMA channel request failed with %d\n",
ret);
return ret;
}
dev_dbg(dev, "No DMA support\n"); dev_dbg(dev, "No DMA support\n");
return 0; return 0;
......
...@@ -243,12 +243,9 @@ static int stm32_dfsdm_parse_of(struct platform_device *pdev, ...@@ -243,12 +243,9 @@ static int stm32_dfsdm_parse_of(struct platform_device *pdev,
* on use case. * on use case.
*/ */
priv->clk = devm_clk_get(&pdev->dev, "dfsdm"); priv->clk = devm_clk_get(&pdev->dev, "dfsdm");
if (IS_ERR(priv->clk)) { if (IS_ERR(priv->clk))
ret = PTR_ERR(priv->clk); return dev_err_probe(&pdev->dev, PTR_ERR(priv->clk),
if (ret != -EPROBE_DEFER) "Failed to get clock\n");
dev_err(&pdev->dev, "Failed to get clock (%d)\n", ret);
return ret;
}
priv->aclk = devm_clk_get(&pdev->dev, "audio"); priv->aclk = devm_clk_get(&pdev->dev, "audio");
if (IS_ERR(priv->aclk)) if (IS_ERR(priv->aclk))
......
...@@ -150,10 +150,7 @@ static int stm32_dac_probe(struct platform_device *pdev) ...@@ -150,10 +150,7 @@ static int stm32_dac_probe(struct platform_device *pdev)
rst = devm_reset_control_get_optional_exclusive(dev, NULL); rst = devm_reset_control_get_optional_exclusive(dev, NULL);
if (rst) { if (rst) {
if (IS_ERR(rst)) { if (IS_ERR(rst)) {
ret = PTR_ERR(rst); ret = dev_err_probe(dev, PTR_ERR(rst), "reset get failed\n");
if (ret != -EPROBE_DEFER)
dev_err(dev, "reset get failed, %d\n", ret);
goto err_hw_stop; goto err_hw_stop;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment