Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i2c: sprd: Validate the return value of clock initialization

The 'enable' clock of I2C master is required, we should return an error
if failed to get the 'enable' clock, to make sure the I2C driver can be
defer probe if the clock resource is not ready.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

authored by

Baolin Wang and committed by
Wolfram Sang
bbeb6b6c 3c2588fa

+7 -4
+7 -4
drivers/i2c/busses/i2c-sprd.c
··· 466 466 467 467 i2c_dev->clk = devm_clk_get(i2c_dev->dev, "enable"); 468 468 if (IS_ERR(i2c_dev->clk)) { 469 - dev_warn(i2c_dev->dev, "i2c%d can't get the enable clock\n", 470 - i2c_dev->adap.nr); 471 - i2c_dev->clk = NULL; 469 + dev_err(i2c_dev->dev, "i2c%d can't get the enable clock\n", 470 + i2c_dev->adap.nr); 471 + return PTR_ERR(i2c_dev->clk); 472 472 } 473 473 474 474 return 0; ··· 519 519 if (i2c_dev->bus_freq != 100000 && i2c_dev->bus_freq != 400000) 520 520 return -EINVAL; 521 521 522 - sprd_i2c_clk_init(i2c_dev); 522 + ret = sprd_i2c_clk_init(i2c_dev); 523 + if (ret) 524 + return ret; 525 + 523 526 platform_set_drvdata(pdev, i2c_dev); 524 527 525 528 ret = clk_prepare_enable(i2c_dev->clk);