i2c: mpc: Use devm_clk_get_optional_enabled() to simplify code
devm_clk_get_optional() and clk_prepare_enable() can be replaced by the helper function devm_clk_get_optional_enabled(). Let's simplify the code by using devm_clk_get_optional_enabled() and avoid calling clk_disable_unprepare(). Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
This commit is contained in:
parent
2259ce0daa
commit
016b221209
@ -88,7 +88,6 @@ struct mpc_i2c {
|
||||
int irq;
|
||||
u32 real_clk;
|
||||
u8 fdr, dfsrr;
|
||||
struct clk *clk_per;
|
||||
u32 cntl_bits;
|
||||
enum mpc_i2c_action action;
|
||||
struct i2c_msg *msgs;
|
||||
@ -779,7 +778,6 @@ static int fsl_i2c_probe(struct platform_device *op)
|
||||
struct clk *clk;
|
||||
int result;
|
||||
u32 clock;
|
||||
int err;
|
||||
|
||||
i2c = devm_kzalloc(&op->dev, sizeof(*i2c), GFP_KERNEL);
|
||||
if (!i2c)
|
||||
@ -809,18 +807,12 @@ static int fsl_i2c_probe(struct platform_device *op)
|
||||
* enable clock for the I2C peripheral (non fatal),
|
||||
* keep a reference upon successful allocation
|
||||
*/
|
||||
clk = devm_clk_get_optional(&op->dev, NULL);
|
||||
if (IS_ERR(clk))
|
||||
return PTR_ERR(clk);
|
||||
|
||||
err = clk_prepare_enable(clk);
|
||||
if (err) {
|
||||
clk = devm_clk_get_optional_enabled(&op->dev, NULL);
|
||||
if (IS_ERR(clk)) {
|
||||
dev_err(&op->dev, "failed to enable clock\n");
|
||||
return err;
|
||||
return PTR_ERR(clk);
|
||||
}
|
||||
|
||||
i2c->clk_per = clk;
|
||||
|
||||
if (of_property_read_bool(op->dev.of_node, "fsl,preserve-clocking")) {
|
||||
clock = MPC_I2C_CLOCK_PRESERVE;
|
||||
} else {
|
||||
@ -876,14 +868,9 @@ static int fsl_i2c_probe(struct platform_device *op)
|
||||
|
||||
result = i2c_add_numbered_adapter(&i2c->adap);
|
||||
if (result)
|
||||
goto fail_add;
|
||||
return result;
|
||||
|
||||
return 0;
|
||||
|
||||
fail_add:
|
||||
clk_disable_unprepare(i2c->clk_per);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
static void fsl_i2c_remove(struct platform_device *op)
|
||||
@ -891,8 +878,6 @@ static void fsl_i2c_remove(struct platform_device *op)
|
||||
struct mpc_i2c *i2c = platform_get_drvdata(op);
|
||||
|
||||
i2c_del_adapter(&i2c->adap);
|
||||
|
||||
clk_disable_unprepare(i2c->clk_per);
|
||||
};
|
||||
|
||||
static int __maybe_unused mpc_i2c_suspend(struct device *dev)
|
||||
|
Loading…
Reference in New Issue
Block a user