Commit 703b3228 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Wolfram Sang

i2c: stm32: Simplify with dev_err_probe()

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and the error value gets printed.
Signed-off-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: default avatarAlain Volmat <alain.volmat@st.com>
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
parent 27c90870
...@@ -26,8 +26,9 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev, ...@@ -26,8 +26,9 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev,
dma->chan_tx = dma_request_chan(dev, "tx"); dma->chan_tx = dma_request_chan(dev, "tx");
if (IS_ERR(dma->chan_tx)) { if (IS_ERR(dma->chan_tx)) {
ret = PTR_ERR(dma->chan_tx); ret = PTR_ERR(dma->chan_tx);
if ((ret != -ENODEV) && (ret != -EPROBE_DEFER)) if (ret != -ENODEV)
dev_err(dev, "can't request DMA tx channel\n"); ret = dev_err_probe(dev, ret,
"can't request DMA tx channel\n");
goto fail_al; goto fail_al;
} }
...@@ -46,8 +47,9 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev, ...@@ -46,8 +47,9 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev,
dma->chan_rx = dma_request_chan(dev, "rx"); dma->chan_rx = dma_request_chan(dev, "rx");
if (IS_ERR(dma->chan_rx)) { if (IS_ERR(dma->chan_rx)) {
ret = PTR_ERR(dma->chan_rx); ret = PTR_ERR(dma->chan_rx);
if ((ret != -ENODEV) && (ret != -EPROBE_DEFER)) if (ret != -ENODEV)
dev_err(dev, "can't request DMA rx channel\n"); ret = dev_err_probe(dev, ret,
"can't request DMA rx channel\n");
goto fail_tx; goto fail_tx;
} }
......
...@@ -797,10 +797,8 @@ static int stm32f4_i2c_probe(struct platform_device *pdev) ...@@ -797,10 +797,8 @@ static int stm32f4_i2c_probe(struct platform_device *pdev)
rst = devm_reset_control_get_exclusive(&pdev->dev, NULL); rst = devm_reset_control_get_exclusive(&pdev->dev, NULL);
if (IS_ERR(rst)) { if (IS_ERR(rst)) {
ret = PTR_ERR(rst); ret = dev_err_probe(&pdev->dev, PTR_ERR(rst),
if (ret != -EPROBE_DEFER) "Error: Missing reset ctrl\n");
dev_err(&pdev->dev, "Error: Missing reset ctrl\n");
goto clk_free; goto clk_free;
} }
reset_control_assert(rst); reset_control_assert(rst);
......
...@@ -2037,11 +2037,9 @@ static int stm32f7_i2c_probe(struct platform_device *pdev) ...@@ -2037,11 +2037,9 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
"wakeup-source"); "wakeup-source");
i2c_dev->clk = devm_clk_get(&pdev->dev, NULL); i2c_dev->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(i2c_dev->clk)) { if (IS_ERR(i2c_dev->clk))
if (PTR_ERR(i2c_dev->clk) != -EPROBE_DEFER) return dev_err_probe(&pdev->dev, PTR_ERR(i2c_dev->clk),
dev_err(&pdev->dev, "Failed to get controller clock\n"); "Failed to get controller clock\n");
return PTR_ERR(i2c_dev->clk);
}
ret = clk_prepare_enable(i2c_dev->clk); ret = clk_prepare_enable(i2c_dev->clk);
if (ret) { if (ret) {
...@@ -2051,10 +2049,8 @@ static int stm32f7_i2c_probe(struct platform_device *pdev) ...@@ -2051,10 +2049,8 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
rst = devm_reset_control_get(&pdev->dev, NULL); rst = devm_reset_control_get(&pdev->dev, NULL);
if (IS_ERR(rst)) { if (IS_ERR(rst)) {
ret = PTR_ERR(rst); ret = dev_err_probe(&pdev->dev, PTR_ERR(rst),
if (ret != -EPROBE_DEFER) "Error: Missing reset ctrl\n");
dev_err(&pdev->dev, "Error: Missing reset ctrl\n");
goto clk_free; goto clk_free;
} }
reset_control_assert(rst); reset_control_assert(rst);
......
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