All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fbdev/ssd1307fb: fix optional VBAT support
@ 2017-04-03 13:53 Bastian Stender
  2017-04-07 15:21 ` Bartlomiej Zolnierkiewicz
  2017-04-07 15:29 ` Bastian Stender
  0 siblings, 2 replies; 3+ messages in thread
From: Bastian Stender @ 2017-04-03 13:53 UTC (permalink / raw)
  To: linux-fbdev

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 ba14301e0356c99803e07db60e129a2ca9e50ff0.

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: Bastian Stender <bst@pengutronix.de>
---
 drivers/video/fbdev/ssd1307fb.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c
index bd017b57c47f..1c9e2c51e692 100644
--- a/drivers/video/fbdev/ssd1307fb.c
+++ b/drivers/video/fbdev/ssd1307fb.c
@@ -578,10 +578,14 @@ static int ssd1307fb_probe(struct i2c_client *client,
 
 	par->vbat_reg = devm_regulator_get_optional(&client->dev, "vbat");
 	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);
-		goto fb_alloc_error;
+		if (ret = -ENODEV) {
+			par->vbat_reg = NULL;
+		} else {
+			dev_err(&client->dev, "failed to get VBAT regulator: %ld\n",
+				ret);
+			goto fb_alloc_error;
+		}
 	}
 
 	if (of_property_read_u32(node, "solomon,width", &par->width))
@@ -668,10 +672,13 @@ static int ssd1307fb_probe(struct i2c_client *client,
 		udelay(4);
 	}
 
-	ret = regulator_enable(par->vbat_reg);
-	if (ret) {
-		dev_err(&client->dev, "failed to enable VBAT: %d\n", ret);
-		goto reset_oled_error;
+	if (par->vbat_reg) {
+		ret = regulator_enable(par->vbat_reg);
+		if (ret) {
+			dev_err(&client->dev, "failed to enable VBAT: %d\n",
+				ret);
+			goto reset_oled_error;
+		}
 	}
 
 	ret = ssd1307fb_init(par);
@@ -710,7 +717,8 @@ static int ssd1307fb_probe(struct i2c_client *client,
 		pwm_put(par->pwm);
 	};
 regulator_enable_error:
-	regulator_disable(par->vbat_reg);
+	if (par->vbat_reg)
+		regulator_disable(par->vbat_reg);
 reset_oled_error:
 	fb_deferred_io_cleanup(info);
 fb_alloc_error:
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] fbdev/ssd1307fb: fix optional VBAT support
  2017-04-03 13:53 [PATCH] fbdev/ssd1307fb: fix optional VBAT support Bastian Stender
@ 2017-04-07 15:21 ` Bartlomiej Zolnierkiewicz
  2017-04-07 15:29 ` Bastian Stender
  1 sibling, 0 replies; 3+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2017-04-07 15:21 UTC (permalink / raw)
  To: linux-fbdev


Hi,

On Monday, April 03, 2017 03:53:44 PM Bastian Stender wrote:
> 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 ba14301e0356c99803e07db60e129a2ca9e50ff0.

checkpatch.pl complained about this:

ERROR: Please use git commit description style 'commit <12+ chars of sha1> ("<title line>")' - ie: 'commit ba14301e0356 ("fbdev/ssd1307fb: add support to enable VBAT")'
#6: 
introduced by commit ba14301e0356c99803e07db60e129a2ca9e50ff0.

I fixed this while applying the patch.

> 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: Bastian Stender <bst@pengutronix.de>

[...]

> @@ -578,10 +578,14 @@ static int ssd1307fb_probe(struct i2c_client *client,
>  
>  	par->vbat_reg = devm_regulator_get_optional(&client->dev, "vbat");
>  	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);
> -		goto fb_alloc_error;
> +		if (ret = -ENODEV) {
> +			par->vbat_reg = NULL;
> +		} else {
> +			dev_err(&client->dev, "failed to get VBAT regulator: %ld\n",
> +				ret);

gcc complained after this change:

drivers/video/fbdev/ssd1307fb.c: In function ‘ssd1307fb_probe’:
drivers/video/fbdev/ssd1307fb.c:586:5: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat]

I fixed this while applying the patch.

[...]

Patch queued for 4.11, thanks!

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fbdev/ssd1307fb: fix optional VBAT support
  2017-04-03 13:53 [PATCH] fbdev/ssd1307fb: fix optional VBAT support Bastian Stender
  2017-04-07 15:21 ` Bartlomiej Zolnierkiewicz
@ 2017-04-07 15:29 ` Bastian Stender
  1 sibling, 0 replies; 3+ messages in thread
From: Bastian Stender @ 2017-04-07 15:29 UTC (permalink / raw)
  To: linux-fbdev

Hey,

On 04/07/2017 05:21 PM, Bartlomiej Zolnierkiewicz wrote:
> On Monday, April 03, 2017 03:53:44 PM Bastian Stender wrote:
>> 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 ba14301e0356c99803e07db60e129a2ca9e50ff0.
>
> checkpatch.pl complained about this:
>
> ERROR: Please use git commit description style 'commit <12+ chars of sha1> ("<title line>")' - ie: 'commit ba14301e0356 ("fbdev/ssd1307fb: add support to enable VBAT")'
> #6:
> introduced by commit ba14301e0356c99803e07db60e129a2ca9e50ff0.
>
> I fixed this while applying the patch.

Yes, saw that after the patch was already sent. Thanks.

>> 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: Bastian Stender <bst@pengutronix.de>
>
> [...]
>
>> @@ -578,10 +578,14 @@ static int ssd1307fb_probe(struct i2c_client *client,
>>
>>  	par->vbat_reg = devm_regulator_get_optional(&client->dev, "vbat");
>>  	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);
>> -		goto fb_alloc_error;
>> +		if (ret = -ENODEV) {
>> +			par->vbat_reg = NULL;
>> +		} else {
>> +			dev_err(&client->dev, "failed to get VBAT regulator: %ld\n",
>> +				ret);
>
> gcc complained after this change:
>
> drivers/video/fbdev/ssd1307fb.c: In function ‘ssd1307fb_probe’:
> drivers/video/fbdev/ssd1307fb.c:586:5: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat]
>
> I fixed this while applying the patch.

Woops, thanks so much.

>
> [...]
>
> Patch queued for 4.11, thanks!

Cool :)

Regards,
Bastian

-- 
Pengutronix e.K.
Industrial Linux Solutions
http://www.pengutronix.de/
Peiner Str. 6-8, 31137 Hildesheim, Germany
Amtsgericht Hildesheim, HRA 2686

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-07 15:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-03 13:53 [PATCH] fbdev/ssd1307fb: fix optional VBAT support Bastian Stender
2017-04-07 15:21 ` Bartlomiej Zolnierkiewicz
2017-04-07 15:29 ` Bastian Stender

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.