@@ -1646,8 +1646,8 @@ MODULE_DEVICE_TABLE(of, tegra_i2c_of_match);
static int tegra_i2c_probe(struct platform_device *pdev)
{
+ struct clk *div_clk, *fast_clk, *slow_clk;
struct device *dev = &pdev->dev;
- struct clk *div_clk, *fast_clk;
struct tegra_i2c_dev *i2c_dev;
phys_addr_t base_phys;
struct resource *res;
@@ -1668,13 +1668,9 @@ static int tegra_i2c_probe(struct platform_device *pdev)
irq = res->start;
div_clk = devm_clk_get(&pdev->dev, "div-clk");
- if (IS_ERR(div_clk)) {
- if (PTR_ERR(div_clk) != -EPROBE_DEFER)
- dev_err(&pdev->dev, "failed to get div-clk: %ld\n",
- PTR_ERR(div_clk));
-
- return PTR_ERR(div_clk);
- }
+ if (IS_ERR(div_clk))
+ return dev_err_probe(&pdev->dev, PTR_ERR(div_clk),
+ "failed to get div-clk\n");
i2c_dev = devm_kzalloc(&pdev->dev, sizeof(*i2c_dev), GFP_KERNEL);
if (!i2c_dev)
@@ -1713,24 +1709,20 @@ static int tegra_i2c_probe(struct platform_device *pdev)
if (!i2c_dev->hw->has_single_clk_source) {
fast_clk = devm_clk_get(&pdev->dev, "fast-clk");
- if (IS_ERR(fast_clk)) {
- dev_err(dev, "failed to get fast clock\n: %ld\n",
- PTR_ERR(fast_clk));
+ if (IS_ERR(fast_clk))
+ return dev_err_probe(&pdev->dev, PTR_ERR(fast_clk),
+ "failed to get fast clock\n");
- return PTR_ERR(fast_clk);
- }
i2c_dev->fast_clk = fast_clk;
}
if (i2c_dev->is_vi) {
- i2c_dev->slow_clk = devm_clk_get(dev, "slow");
- if (IS_ERR(i2c_dev->slow_clk)) {
- if (PTR_ERR(i2c_dev->slow_clk) != -EPROBE_DEFER)
- dev_err(dev, "failed to get slow clock: %ld\n",
- PTR_ERR(i2c_dev->slow_clk));
+ slow_clk = devm_clk_get(dev, "slow");
+ if (IS_ERR(slow_clk))
+ return dev_err_probe(&pdev->dev, PTR_ERR(slow_clk),
+ "failed to get slow clock\n");
- return PTR_ERR(i2c_dev->slow_clk);
- }
+ i2c_dev->slow_clk = slow_clk;
}
platform_set_drvdata(pdev, i2c_dev);
Use dev_err_probe() to replace the manual -EPROBE_DEFER handling, making code cleaner. Signed-off-by: Dmitry Osipenko <digetx@gmail.com> --- drivers/i2c/busses/i2c-tegra.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-)