i2c: imx: Use dev_err_probe() to simplify error handling
PATCH 1/1 i2c: imx: Use dev_err_probe() to simplify error handling
dev_err_probe() can reduce code size, uniform error handling and record the defer probe reason etc., use it to simplify the code.
Signed-off-by Anson Huang <[email protected]>
--- drivers/i2c/busses/i2c-imx.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-imx.c +3 -5
@@ -1159,11 +1159,9 @@ static int i2c_imx_probe(struct platform_device *pdev)/* Get I2C clock */ i2c_imx->clk =devm_clk_get (&pdev->dev,NULL ); -if (IS_ERR (i2c_imx->clk)) { -if (PTR_ERR (i2c_imx->clk) != -EPROBE_DEFER ) -dev_err (&pdev->dev,"can't get I2C clock\n" ); -return PTR_ERR (i2c_imx->clk); - } +if (IS_ERR (i2c_imx->clk)) +return dev_err_probe (&pdev->dev,PTR_ERR (i2c_imx->clk), +"can't get I2C clock\n" ); ret =clk_prepare_enable (i2c_imx->clk);if (ret) {
Signature · 1 line
2.7.4
Quoted 18 lines · Anson Huang
dev_err_probe()can reduce code size, uniform error handling and record the defer probe reason etc., use it to simplify the code.Signed-off-by Anson Huang <[email protected]>--- drivers/i2c/busses/i2c-imx.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)drivers/i2c/busses/i2c-imx.c +0
-1@@ -1159,11 +1159,9 @@ static int i2c_imx_probe(struct platform_device *pdev)/* Get I2C clock */ i2c_imx->clk =devm_clk_get (&pdev->dev,NULL ); -if (IS_ERR (i2c_imx->clk)) {
drivers/i2c/busses/i2c-imx.c static int i2c_imx_probe(struct platform_device *pdev) · line 1167
Quoted 10 lines
drivers/i2c/busses/i2c-imx.c +3
-4-if (PTR_ERR (i2c_imx->clk) != -EPROBE_DEFER ) -dev_err (&pdev->dev,"can't get I2C clock\n" ); -return PTR_ERR (i2c_imx->clk); - } +if (IS_ERR (i2c_imx->clk)) +return dev_err_probe (&pdev->dev,PTR_ERR (i2c_imx->clk), +"can't get I2C clock\n" ); ret =clk_prepare_enable (i2c_imx->clk);if (ret) {
Acked-by Oleksij Rempel <[email protected]>
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Wolfram Sang
AppliedQuoted 4 lines · Anson Huang
dev_err_probe()can reduce code size, uniform error handling and record the defer probe reason etc., use it to simplify the code.Signed-off-by Anson Huang <[email protected]>
Applied to for-next, thanks!