Commit 7ad250e1 authored by Zhang Zekun's avatar Zhang Zekun Committed by Chen-Yu Tsai

bus: sunxi-rsb: Simplify code with dev_err_probe()

Use dev_err_probe() directly in the driver probe phase. This can
simplify the code a bit.
Signed-off-by: default avatarZhang Zekun <zhangzekun11@huawei.com>
Link: https://lore.kernel.org/r/20240905114134.80310-1-zhangzekun11@huawei.comSigned-off-by: default avatarChen-Yu Tsai <wens@csie.org>
parent 8400291e
...@@ -751,12 +751,10 @@ static int sunxi_rsb_probe(struct platform_device *pdev) ...@@ -751,12 +751,10 @@ static int sunxi_rsb_probe(struct platform_device *pdev)
int irq, ret; int irq, ret;
of_property_read_u32(np, "clock-frequency", &clk_freq); of_property_read_u32(np, "clock-frequency", &clk_freq);
if (clk_freq > RSB_MAX_FREQ) { if (clk_freq > RSB_MAX_FREQ)
dev_err(dev, return dev_err_probe(dev, -EINVAL,
"clock-frequency (%u Hz) is too high (max = 20MHz)\n", "clock-frequency (%u Hz) is too high (max = 20MHz)\n",
clk_freq); clk_freq);
return -EINVAL;
}
rsb = devm_kzalloc(dev, sizeof(*rsb), GFP_KERNEL); rsb = devm_kzalloc(dev, sizeof(*rsb), GFP_KERNEL);
if (!rsb) if (!rsb)
...@@ -774,28 +772,22 @@ static int sunxi_rsb_probe(struct platform_device *pdev) ...@@ -774,28 +772,22 @@ static int sunxi_rsb_probe(struct platform_device *pdev)
return irq; return irq;
rsb->clk = devm_clk_get(dev, NULL); rsb->clk = devm_clk_get(dev, NULL);
if (IS_ERR(rsb->clk)) { if (IS_ERR(rsb->clk))
ret = PTR_ERR(rsb->clk); return dev_err_probe(dev, PTR_ERR(rsb->clk),
dev_err(dev, "failed to retrieve clk: %d\n", ret); "failed to retrieve clk\n");
return ret;
}
rsb->rstc = devm_reset_control_get(dev, NULL); rsb->rstc = devm_reset_control_get(dev, NULL);
if (IS_ERR(rsb->rstc)) { if (IS_ERR(rsb->rstc))
ret = PTR_ERR(rsb->rstc); return dev_err_probe(dev, PTR_ERR(rsb->rstc),
dev_err(dev, "failed to retrieve reset controller: %d\n", ret); "failed to retrieve reset controller\n");
return ret;
}
init_completion(&rsb->complete); init_completion(&rsb->complete);
mutex_init(&rsb->lock); mutex_init(&rsb->lock);
ret = devm_request_irq(dev, irq, sunxi_rsb_irq, 0, RSB_CTRL_NAME, rsb); ret = devm_request_irq(dev, irq, sunxi_rsb_irq, 0, RSB_CTRL_NAME, rsb);
if (ret) { if (ret)
dev_err(dev, "can't register interrupt handler irq %d: %d\n", return dev_err_probe(dev, ret,
irq, ret); "can't register interrupt handler irq %d\n", irq);
return ret;
}
ret = sunxi_rsb_hw_init(rsb); ret = sunxi_rsb_hw_init(rsb);
if (ret) if (ret)
......
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