Re: [PATCH v5 1/2] i2c: imx-lpi2c: properly unwind resources on probe failure

Carlos Song <[email protected]>
Newsgroups org.kernel.vger.linux-i2c,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-kernel
Message-ID <5fp45u3yuwz73nk6eeofx5fp5drvaqxp435mithslttb73zylb@t2s3se5a4qux>
On Tue, Jul 14, 2026 at 04:10:20PM +0200, Markus Elfring wrote:
> …
> > Introduce a new error label 'clk_disable' …
> 
> Can another bit of duplicate source code be avoided in any if branches?
>
> Regards,
> Markus
>

Thank you! I plan to change the code like this:
'''
        ret = devm_clk_rate_exclusive_get(&pdev->dev, lpi2c_imx->clks[0].clk);
        if (ret) {
                ret = dev_err_probe(&pdev->dev, ret,
                                    "can't lock I2C peripheral clock rate\n");
                goto clk_disable;
        }

        lpi2c_imx->rate_per = clk_get_rate(lpi2c_imx->clks[0].clk);
        if (!lpi2c_imx->rate_per) {
                ret = dev_err_probe(&pdev->dev, -EINVAL,
                                    "can't get I2C peripheral clock rate\n");
                goto clk_disable;
        }
'''
Does it look better?

Carlos Song
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.