Commit cfc5b2b5 authored by Bastian Stender's avatar Bastian Stender Committed by Bartlomiej Zolnierkiewicz

fbdev/ssd1307fb: fix optional VBAT support

SSD1306 needs VBAT when it is wired in charge pump configuration only.
Other controllers of the SSD1307 family do not need it at all. This was
introduced by commit ba14301e ("fbdev/ssd1307fb: add support to
enable VBAT").

Without VBAT configuration the driver now fails with:

	failed to get VBAT regulator: -19

This is caused by misinterpretation of devm_regulator_get_optional
which "returns a struct regulator corresponding to the regulator
producer or IS_ERR() condition".

Handle -ENODEV without bailing out and making VBAT support really
optional.
Signed-off-by: default avatarBastian Stender <bst@pengutronix.de>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Jyri Sarha <jsarha@ti.com>
Cc: Roger Quadros <rogerq@ti.com>
[b.zolnierkie: minor fixups]
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
parent c1ae3cfa
...@@ -578,11 +578,15 @@ static int ssd1307fb_probe(struct i2c_client *client, ...@@ -578,11 +578,15 @@ static int ssd1307fb_probe(struct i2c_client *client,
par->vbat_reg = devm_regulator_get_optional(&client->dev, "vbat"); par->vbat_reg = devm_regulator_get_optional(&client->dev, "vbat");
if (IS_ERR(par->vbat_reg)) { if (IS_ERR(par->vbat_reg)) {
dev_err(&client->dev, "failed to get VBAT regulator: %ld\n",
PTR_ERR(par->vbat_reg));
ret = PTR_ERR(par->vbat_reg); ret = PTR_ERR(par->vbat_reg);
if (ret == -ENODEV) {
par->vbat_reg = NULL;
} else {
dev_err(&client->dev, "failed to get VBAT regulator: %d\n",
ret);
goto fb_alloc_error; goto fb_alloc_error;
} }
}
if (of_property_read_u32(node, "solomon,width", &par->width)) if (of_property_read_u32(node, "solomon,width", &par->width))
par->width = 96; par->width = 96;
...@@ -668,11 +672,14 @@ static int ssd1307fb_probe(struct i2c_client *client, ...@@ -668,11 +672,14 @@ static int ssd1307fb_probe(struct i2c_client *client,
udelay(4); udelay(4);
} }
if (par->vbat_reg) {
ret = regulator_enable(par->vbat_reg); ret = regulator_enable(par->vbat_reg);
if (ret) { if (ret) {
dev_err(&client->dev, "failed to enable VBAT: %d\n", ret); dev_err(&client->dev, "failed to enable VBAT: %d\n",
ret);
goto reset_oled_error; goto reset_oled_error;
} }
}
ret = ssd1307fb_init(par); ret = ssd1307fb_init(par);
if (ret) if (ret)
...@@ -710,6 +717,7 @@ static int ssd1307fb_probe(struct i2c_client *client, ...@@ -710,6 +717,7 @@ static int ssd1307fb_probe(struct i2c_client *client,
pwm_put(par->pwm); pwm_put(par->pwm);
}; };
regulator_enable_error: regulator_enable_error:
if (par->vbat_reg)
regulator_disable(par->vbat_reg); regulator_disable(par->vbat_reg);
reset_oled_error: reset_oled_error:
fb_deferred_io_cleanup(info); fb_deferred_io_cleanup(info);
......
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