Skip to content

Commit 3b7d8d1

Browse files
zandaeAndi Shyti
authored andcommitted
i2c: viai2c-wmt: Replace dev_err() with dev_err_probe() in probe function
This simplifies the code while improving log. Signed-off-by: Enrico Zanda <e.zanda1@gmail.com> Link: https://lore.kernel.org/r/20250513210246.528370-2-e.zanda1@gmail.com Signed-off-by: Andi Shyti <andi@smida.it>
1 parent bdf4442 commit 3b7d8d1

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

drivers/i2c/busses/i2c-viai2c-wmt.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,13 @@ static int wmt_i2c_reset_hardware(struct viai2c *i2c)
4444
int err;
4545

4646
err = clk_prepare_enable(i2c->clk);
47-
if (err) {
48-
dev_err(i2c->dev, "failed to enable clock\n");
49-
return err;
50-
}
47+
if (err)
48+
return dev_err_probe(i2c->dev, err, "failed to enable clock\n");
5149

5250
err = clk_set_rate(i2c->clk, 20000000);
5351
if (err) {
54-
dev_err(i2c->dev, "failed to set clock = 20Mhz\n");
5552
clk_disable_unprepare(i2c->clk);
56-
return err;
53+
return dev_err_probe(i2c->dev, err, "failed to set clock = 20Mhz\n");
5754
}
5855

5956
writew(0, i2c->base + VIAI2C_REG_CR);
@@ -121,10 +118,9 @@ static int wmt_i2c_probe(struct platform_device *pdev)
121118
"failed to request irq %i\n", i2c->irq);
122119

123120
i2c->clk = of_clk_get(np, 0);
124-
if (IS_ERR(i2c->clk)) {
125-
dev_err(&pdev->dev, "unable to request clock\n");
126-
return PTR_ERR(i2c->clk);
127-
}
121+
if (IS_ERR(i2c->clk))
122+
return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk),
123+
"unable to request clock\n");
128124

129125
err = of_property_read_u32(np, "clock-frequency", &clk_rate);
130126
if (!err && clk_rate == I2C_MAX_FAST_MODE_FREQ)
@@ -139,10 +135,8 @@ static int wmt_i2c_probe(struct platform_device *pdev)
139135
adap->dev.of_node = pdev->dev.of_node;
140136

141137
err = wmt_i2c_reset_hardware(i2c);
142-
if (err) {
143-
dev_err(&pdev->dev, "error initializing hardware\n");
138+
if (err)
144139
return err;
145-
}
146140

147141
err = i2c_add_adapter(adap);
148142
if (err)

0 commit comments

Comments
 (0)