diff mbox series

[5/6] drm/panel: novatek-nt36672a: stop calling regulator_set_load manually

Message ID 20240404-drop-panel-unregister-v1-5-9f56953c5fb9@linaro.org (mailing list archive)
State New, archived
Headers show
Series drm/panel: small fixes for visionox and novatek panel drivers | expand

Commit Message

Dmitry Baryshkov April 4, 2024, 10:08 a.m. UTC
Use .init_load_uA part of the bulk regulator API instead of calling
register_set_load() manually.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 drivers/gpu/drm/panel/panel-novatek-nt36672a.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

Comments

Neil Armstrong April 24, 2024, 6:53 a.m. UTC | #1
On 04/04/2024 12:08, Dmitry Baryshkov wrote:
> Use .init_load_uA part of the bulk regulator API instead of calling
> register_set_load() manually.
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
>   drivers/gpu/drm/panel/panel-novatek-nt36672a.c | 11 +++--------
>   1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-novatek-nt36672a.c b/drivers/gpu/drm/panel/panel-novatek-nt36672a.c
> index 33fb3d715e54..3886372415c2 100644
> --- a/drivers/gpu/drm/panel/panel-novatek-nt36672a.c
> +++ b/drivers/gpu/drm/panel/panel-novatek-nt36672a.c
> @@ -605,21 +605,16 @@ static int nt36672a_panel_add(struct nt36672a_panel *pinfo)
>   	struct device *dev = &pinfo->link->dev;
>   	int i, ret;
>   
> -	for (i = 0; i < ARRAY_SIZE(pinfo->supplies); i++)
> +	for (i = 0; i < ARRAY_SIZE(pinfo->supplies); i++) {
>   		pinfo->supplies[i].supply = nt36672a_regulator_names[i];
> +		pinfo->supplies[i].init_load_uA = nt36672a_regulator_enable_loads[i];
> +	}
>   
>   	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(pinfo->supplies),
>   				      pinfo->supplies);
>   	if (ret < 0)
>   		return dev_err_probe(dev, ret, "failed to get regulators\n");
>   
> -	for (i = 0; i < ARRAY_SIZE(pinfo->supplies); i++) {
> -		ret = regulator_set_load(pinfo->supplies[i].consumer,
> -					 nt36672a_regulator_enable_loads[i]);
> -		if (ret)
> -			return dev_err_probe(dev, ret, "failed to set regulator enable loads\n");
> -	}
> -
>   	pinfo->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
>   	if (IS_ERR(pinfo->reset_gpio))
>   		return dev_err_probe(dev, PTR_ERR(pinfo->reset_gpio),
> 

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Doug Anderson May 3, 2024, 5:03 p.m. UTC | #2
Hi,

On Thu, Apr 4, 2024 at 3:08 AM Dmitry Baryshkov
<dmitry.baryshkov@linaro.org> wrote:
>
> Use .init_load_uA part of the bulk regulator API instead of calling
> register_set_load() manually.
>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
>  drivers/gpu/drm/panel/panel-novatek-nt36672a.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/panel/panel-novatek-nt36672a.c b/drivers/gpu/drm/panel/panel-novatek-nt36672a.c
> index 33fb3d715e54..3886372415c2 100644
> --- a/drivers/gpu/drm/panel/panel-novatek-nt36672a.c
> +++ b/drivers/gpu/drm/panel/panel-novatek-nt36672a.c
> @@ -605,21 +605,16 @@ static int nt36672a_panel_add(struct nt36672a_panel *pinfo)
>         struct device *dev = &pinfo->link->dev;
>         int i, ret;
>
> -       for (i = 0; i < ARRAY_SIZE(pinfo->supplies); i++)
> +       for (i = 0; i < ARRAY_SIZE(pinfo->supplies); i++) {
>                 pinfo->supplies[i].supply = nt36672a_regulator_names[i];
> +               pinfo->supplies[i].init_load_uA = nt36672a_regulator_enable_loads[i];
> +       }
>
>         ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(pinfo->supplies),
>                                       pinfo->supplies);
>         if (ret < 0)
>                 return dev_err_probe(dev, ret, "failed to get regulators\n");
>
> -       for (i = 0; i < ARRAY_SIZE(pinfo->supplies); i++) {
> -               ret = regulator_set_load(pinfo->supplies[i].consumer,
> -                                        nt36672a_regulator_enable_loads[i]);
> -               if (ret)
> -                       return dev_err_probe(dev, ret, "failed to set regulator enable loads\n");
> -       }

Thanks for the cleanup! I happened to notice this commit and I'm
curious why you didn't take the next step and move to
devm_regulator_bulk_get_const(). That would have allowed you to avoid
the "for" loop above that copies the data ;-)

-Doug
Dmitry Baryshkov May 3, 2024, 8:53 p.m. UTC | #3
On Fri, May 03, 2024 at 10:03:35AM -0700, Doug Anderson wrote:
> Hi,
> 
> On Thu, Apr 4, 2024 at 3:08 AM Dmitry Baryshkov
> <dmitry.baryshkov@linaro.org> wrote:
> >
> > Use .init_load_uA part of the bulk regulator API instead of calling
> > register_set_load() manually.
> >
> > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > ---
> >  drivers/gpu/drm/panel/panel-novatek-nt36672a.c | 11 +++--------
> >  1 file changed, 3 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/panel/panel-novatek-nt36672a.c b/drivers/gpu/drm/panel/panel-novatek-nt36672a.c
> > index 33fb3d715e54..3886372415c2 100644
> > --- a/drivers/gpu/drm/panel/panel-novatek-nt36672a.c
> > +++ b/drivers/gpu/drm/panel/panel-novatek-nt36672a.c
> > @@ -605,21 +605,16 @@ static int nt36672a_panel_add(struct nt36672a_panel *pinfo)
> >         struct device *dev = &pinfo->link->dev;
> >         int i, ret;
> >
> > -       for (i = 0; i < ARRAY_SIZE(pinfo->supplies); i++)
> > +       for (i = 0; i < ARRAY_SIZE(pinfo->supplies); i++) {
> >                 pinfo->supplies[i].supply = nt36672a_regulator_names[i];
> > +               pinfo->supplies[i].init_load_uA = nt36672a_regulator_enable_loads[i];
> > +       }
> >
> >         ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(pinfo->supplies),
> >                                       pinfo->supplies);
> >         if (ret < 0)
> >                 return dev_err_probe(dev, ret, "failed to get regulators\n");
> >
> > -       for (i = 0; i < ARRAY_SIZE(pinfo->supplies); i++) {
> > -               ret = regulator_set_load(pinfo->supplies[i].consumer,
> > -                                        nt36672a_regulator_enable_loads[i]);
> > -               if (ret)
> > -                       return dev_err_probe(dev, ret, "failed to set regulator enable loads\n");
> > -       }
> 
> Thanks for the cleanup! I happened to notice this commit and I'm
> curious why you didn't take the next step and move to
> devm_regulator_bulk_get_const(). That would have allowed you to avoid
> the "for" loop above that copies the data ;-)

I haven't noticed this function beforehand. Thanks for the pointer!

> 
> -Doug
diff mbox series

Patch

diff --git a/drivers/gpu/drm/panel/panel-novatek-nt36672a.c b/drivers/gpu/drm/panel/panel-novatek-nt36672a.c
index 33fb3d715e54..3886372415c2 100644
--- a/drivers/gpu/drm/panel/panel-novatek-nt36672a.c
+++ b/drivers/gpu/drm/panel/panel-novatek-nt36672a.c
@@ -605,21 +605,16 @@  static int nt36672a_panel_add(struct nt36672a_panel *pinfo)
 	struct device *dev = &pinfo->link->dev;
 	int i, ret;
 
-	for (i = 0; i < ARRAY_SIZE(pinfo->supplies); i++)
+	for (i = 0; i < ARRAY_SIZE(pinfo->supplies); i++) {
 		pinfo->supplies[i].supply = nt36672a_regulator_names[i];
+		pinfo->supplies[i].init_load_uA = nt36672a_regulator_enable_loads[i];
+	}
 
 	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(pinfo->supplies),
 				      pinfo->supplies);
 	if (ret < 0)
 		return dev_err_probe(dev, ret, "failed to get regulators\n");
 
-	for (i = 0; i < ARRAY_SIZE(pinfo->supplies); i++) {
-		ret = regulator_set_load(pinfo->supplies[i].consumer,
-					 nt36672a_regulator_enable_loads[i]);
-		if (ret)
-			return dev_err_probe(dev, ret, "failed to set regulator enable loads\n");
-	}
-
 	pinfo->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
 	if (IS_ERR(pinfo->reset_gpio))
 		return dev_err_probe(dev, PTR_ERR(pinfo->reset_gpio),