All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Michael Grzeschik <m.grzeschik@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2] video: simple-panel: add regulator support
Date: Tue, 28 Jan 2025 11:14:48 +0100	[thread overview]
Message-ID: <Z5iuGPFKtRCYSw3D@pengutronix.de> (raw)
In-Reply-To: <20250126214614.258154-1-m.grzeschik@pengutronix.de>

On Sun, Jan 26, 2025 at 10:46:14PM +0100, Michael Grzeschik wrote:
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> ---
> v1 -> v2: added the missging signed-off-by
> 
>  drivers/video/simple-panel.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/video/simple-panel.c b/drivers/video/simple-panel.c
> index 7048e2f51b..d4c6874987 100644
> --- a/drivers/video/simple-panel.c
> +++ b/drivers/video/simple-panel.c
> @@ -10,6 +10,7 @@
>  #include <linux/err.h>
>  #include <of.h>
>  #include <fb.h>
> +#include <regulator.h>
>  #include <gpio.h>
>  #include <of_gpio.h>
>  #include <video/backlight.h>
> @@ -25,6 +26,7 @@ struct simple_panel {
>  	struct device_node *backlight_node;
>  	struct backlight_device *backlight;
>  	struct device_node *ddc_node;
> +	struct regulator *power;
>  	int enable_delay;
>  };
>  
> @@ -49,6 +51,8 @@ static int simple_panel_enable(struct simple_panel *panel)
>  	if (panel->enable_delay)
>  		mdelay(panel->enable_delay);
>  
> +	regulator_enable(panel->power);
> +
>  	if (panel->backlight) {
>  		ret = backlight_set_brightness_default(panel->backlight);
>  		if (ret)
> @@ -65,6 +69,8 @@ static int simple_panel_disable(struct simple_panel *panel)
>  	if (panel->backlight)
>  		backlight_set_brightness(panel->backlight, 0);
>  
> +	regulator_disable(panel->power);
> +
>  	if (gpio_is_valid(panel->enable_gpio))
>  		gpio_direction_output(panel->enable_gpio,
>  			!panel->enable_active_high);
> @@ -154,6 +160,10 @@ static int simple_panel_probe(struct device *dev)
>  
>  	panel->backlight_node = of_parse_phandle(node, "backlight", 0);
>  
> +	panel->power = regulator_get(dev, "power");
> +	if (IS_ERR(panel->power))
> +		dev_warn(dev, "Cannot find regulator\n");

When there's an error you should return it.
regulator_enable()/regulator_disable() do not handle error pointers
gracefully.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      reply	other threads:[~2025-01-28 10:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-26 21:46 [PATCH v2] video: simple-panel: add regulator support Michael Grzeschik
2025-01-28 10:14 ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z5iuGPFKtRCYSw3D@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=m.grzeschik@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.