All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] backlight: pwm_bl: Don't assign levels table repeatedly
@ 2019-10-02 16:56 ` Matthias Kaehlcke
  0 siblings, 0 replies; 7+ messages in thread
From: Matthias Kaehlcke @ 2019-10-02 16:56 UTC (permalink / raw)
  To: Thierry Reding, Lee Jones, Daniel Thompson, Jingoo Han,
	Bartlomiej Zolnierkiewicz
  Cc: Matthias Kaehlcke, linux-pwm, linux-fbdev, dri-devel, linux-kernel

pwm_backlight_probe() re-assigns pb->levels for every brightness
level. This is not needed and was likely not intended, since
neither side of the assignment changes during the loop. Assign
the field only once.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---

Changes in v2:
- removed curly braces from for loop

 drivers/video/backlight/pwm_bl.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index 746eebc411df..05d3b3802658 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -564,18 +564,17 @@ static int pwm_backlight_probe(struct platform_device *pdev)
 	memset(&props, 0, sizeof(struct backlight_properties));
 
 	if (data->levels) {
+		pb->levels = data->levels;
+
 		/*
 		 * For the DT case, only when brightness levels is defined
 		 * data->levels is filled. For the non-DT case, data->levels
 		 * can come from platform data, however is not usual.
 		 */
-		for (i = 0; i <= data->max_brightness; i++) {
+		for (i = 0; i <= data->max_brightness; i++)
 			if (data->levels[i] > pb->scale)
 				pb->scale = data->levels[i];
 
-			pb->levels = data->levels;
-		}
-
 		if (pwm_backlight_is_linear(data))
 			props.scale = BACKLIGHT_SCALE_LINEAR;
 		else
-- 
2.23.0.444.g18eeb5a265-goog


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

* [PATCH v2] backlight: pwm_bl: Don't assign levels table repeatedly
@ 2019-10-02 16:56 ` Matthias Kaehlcke
  0 siblings, 0 replies; 7+ messages in thread
From: Matthias Kaehlcke @ 2019-10-02 16:56 UTC (permalink / raw)
  To: Thierry Reding, Lee Jones, Daniel Thompson, Jingoo Han,
	Bartlomiej Zolnierkiewicz
  Cc: Matthias Kaehlcke, linux-pwm, linux-fbdev, dri-devel, linux-kernel

pwm_backlight_probe() re-assigns pb->levels for every brightness
level. This is not needed and was likely not intended, since
neither side of the assignment changes during the loop. Assign
the field only once.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---

Changes in v2:
- removed curly braces from for loop

 drivers/video/backlight/pwm_bl.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index 746eebc411df..05d3b3802658 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -564,18 +564,17 @@ static int pwm_backlight_probe(struct platform_device *pdev)
 	memset(&props, 0, sizeof(struct backlight_properties));
 
 	if (data->levels) {
+		pb->levels = data->levels;
+
 		/*
 		 * For the DT case, only when brightness levels is defined
 		 * data->levels is filled. For the non-DT case, data->levels
 		 * can come from platform data, however is not usual.
 		 */
-		for (i = 0; i <= data->max_brightness; i++) {
+		for (i = 0; i <= data->max_brightness; i++)
 			if (data->levels[i] > pb->scale)
 				pb->scale = data->levels[i];
 
-			pb->levels = data->levels;
-		}
-
 		if (pwm_backlight_is_linear(data))
 			props.scale = BACKLIGHT_SCALE_LINEAR;
 		else
-- 
2.23.0.444.g18eeb5a265-goog

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

* Re: [PATCH v2] backlight: pwm_bl: Don't assign levels table repeatedly
  2019-10-02 16:56 ` Matthias Kaehlcke
  (?)
@ 2019-10-03 10:02   ` Daniel Thompson
  -1 siblings, 0 replies; 7+ messages in thread
From: Daniel Thompson @ 2019-10-03 10:02 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: Thierry Reding, Lee Jones, Jingoo Han, Bartlomiej Zolnierkiewicz,
	linux-pwm, linux-fbdev, linux-kernel, dri-devel

On Wed, Oct 02, 2019 at 09:56:01AM -0700, Matthias Kaehlcke wrote:
> pwm_backlight_probe() re-assigns pb->levels for every brightness
> level. This is not needed and was likely not intended, since
> neither side of the assignment changes during the loop. Assign
> the field only once.
> 
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>

> ---
> 
> Changes in v2:
> - removed curly braces from for loop
> 
>  drivers/video/backlight/pwm_bl.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
> index 746eebc411df..05d3b3802658 100644
> --- a/drivers/video/backlight/pwm_bl.c
> +++ b/drivers/video/backlight/pwm_bl.c
> @@ -564,18 +564,17 @@ static int pwm_backlight_probe(struct platform_device *pdev)
>  	memset(&props, 0, sizeof(struct backlight_properties));
>  
>  	if (data->levels) {
> +		pb->levels = data->levels;
> +
>  		/*
>  		 * For the DT case, only when brightness levels is defined
>  		 * data->levels is filled. For the non-DT case, data->levels
>  		 * can come from platform data, however is not usual.
>  		 */
> -		for (i = 0; i <= data->max_brightness; i++) {
> +		for (i = 0; i <= data->max_brightness; i++)
>  			if (data->levels[i] > pb->scale)
>  				pb->scale = data->levels[i];
>  
> -			pb->levels = data->levels;
> -		}
> -
>  		if (pwm_backlight_is_linear(data))
>  			props.scale = BACKLIGHT_SCALE_LINEAR;
>  		else
> -- 
> 2.23.0.444.g18eeb5a265-goog
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH v2] backlight: pwm_bl: Don't assign levels table repeatedly
@ 2019-10-03 10:02   ` Daniel Thompson
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Thompson @ 2019-10-03 10:02 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: linux-pwm, linux-fbdev, Bartlomiej Zolnierkiewicz, Jingoo Han,
	linux-kernel, dri-devel, Thierry Reding, Lee Jones

On Wed, Oct 02, 2019 at 09:56:01AM -0700, Matthias Kaehlcke wrote:
> pwm_backlight_probe() re-assigns pb->levels for every brightness
> level. This is not needed and was likely not intended, since
> neither side of the assignment changes during the loop. Assign
> the field only once.
> 
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>

> ---
> 
> Changes in v2:
> - removed curly braces from for loop
> 
>  drivers/video/backlight/pwm_bl.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
> index 746eebc411df..05d3b3802658 100644
> --- a/drivers/video/backlight/pwm_bl.c
> +++ b/drivers/video/backlight/pwm_bl.c
> @@ -564,18 +564,17 @@ static int pwm_backlight_probe(struct platform_device *pdev)
>  	memset(&props, 0, sizeof(struct backlight_properties));
>  
>  	if (data->levels) {
> +		pb->levels = data->levels;
> +
>  		/*
>  		 * For the DT case, only when brightness levels is defined
>  		 * data->levels is filled. For the non-DT case, data->levels
>  		 * can come from platform data, however is not usual.
>  		 */
> -		for (i = 0; i <= data->max_brightness; i++) {
> +		for (i = 0; i <= data->max_brightness; i++)
>  			if (data->levels[i] > pb->scale)
>  				pb->scale = data->levels[i];
>  
> -			pb->levels = data->levels;
> -		}
> -
>  		if (pwm_backlight_is_linear(data))
>  			props.scale = BACKLIGHT_SCALE_LINEAR;
>  		else
> -- 
> 2.23.0.444.g18eeb5a265-goog
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH v2] backlight: pwm_bl: Don't assign levels table repeatedly
@ 2019-10-03 10:02   ` Daniel Thompson
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Thompson @ 2019-10-03 10:02 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: linux-pwm, linux-fbdev, Bartlomiej Zolnierkiewicz, Jingoo Han,
	linux-kernel, dri-devel, Thierry Reding, Lee Jones

On Wed, Oct 02, 2019 at 09:56:01AM -0700, Matthias Kaehlcke wrote:
> pwm_backlight_probe() re-assigns pb->levels for every brightness
> level. This is not needed and was likely not intended, since
> neither side of the assignment changes during the loop. Assign
> the field only once.
> 
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>

> ---
> 
> Changes in v2:
> - removed curly braces from for loop
> 
>  drivers/video/backlight/pwm_bl.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
> index 746eebc411df..05d3b3802658 100644
> --- a/drivers/video/backlight/pwm_bl.c
> +++ b/drivers/video/backlight/pwm_bl.c
> @@ -564,18 +564,17 @@ static int pwm_backlight_probe(struct platform_device *pdev)
>  	memset(&props, 0, sizeof(struct backlight_properties));
>  
>  	if (data->levels) {
> +		pb->levels = data->levels;
> +
>  		/*
>  		 * For the DT case, only when brightness levels is defined
>  		 * data->levels is filled. For the non-DT case, data->levels
>  		 * can come from platform data, however is not usual.
>  		 */
> -		for (i = 0; i <= data->max_brightness; i++) {
> +		for (i = 0; i <= data->max_brightness; i++)
>  			if (data->levels[i] > pb->scale)
>  				pb->scale = data->levels[i];
>  
> -			pb->levels = data->levels;
> -		}
> -
>  		if (pwm_backlight_is_linear(data))
>  			props.scale = BACKLIGHT_SCALE_LINEAR;
>  		else
> -- 
> 2.23.0.444.g18eeb5a265-goog
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH v2] backlight: pwm_bl: Don't assign levels table repeatedly
  2019-10-02 16:56 ` Matthias Kaehlcke
@ 2019-10-16  7:52   ` Lee Jones
  -1 siblings, 0 replies; 7+ messages in thread
From: Lee Jones @ 2019-10-16  7:52 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: Thierry Reding, Daniel Thompson, Jingoo Han,
	Bartlomiej Zolnierkiewicz, linux-pwm, linux-fbdev, dri-devel,
	linux-kernel

On Wed, 02 Oct 2019, Matthias Kaehlcke wrote:

> pwm_backlight_probe() re-assigns pb->levels for every brightness
> level. This is not needed and was likely not intended, since
> neither side of the assignment changes during the loop. Assign
> the field only once.
> 
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
> 
> Changes in v2:
> - removed curly braces from for loop
> 
>  drivers/video/backlight/pwm_bl.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)

Applied, thanks.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH v2] backlight: pwm_bl: Don't assign levels table repeatedly
@ 2019-10-16  7:52   ` Lee Jones
  0 siblings, 0 replies; 7+ messages in thread
From: Lee Jones @ 2019-10-16  7:52 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: Thierry Reding, Daniel Thompson, Jingoo Han,
	Bartlomiej Zolnierkiewicz, linux-pwm, linux-fbdev, dri-devel,
	linux-kernel

On Wed, 02 Oct 2019, Matthias Kaehlcke wrote:

> pwm_backlight_probe() re-assigns pb->levels for every brightness
> level. This is not needed and was likely not intended, since
> neither side of the assignment changes during the loop. Assign
> the field only once.
> 
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
> 
> Changes in v2:
> - removed curly braces from for loop
> 
>  drivers/video/backlight/pwm_bl.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)

Applied, thanks.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

end of thread, other threads:[~2019-10-16  7:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-02 16:56 [PATCH v2] backlight: pwm_bl: Don't assign levels table repeatedly Matthias Kaehlcke
2019-10-02 16:56 ` Matthias Kaehlcke
2019-10-03 10:02 ` Daniel Thompson
2019-10-03 10:02   ` Daniel Thompson
2019-10-03 10:02   ` Daniel Thompson
2019-10-16  7:52 ` Lee Jones
2019-10-16  7:52   ` Lee Jones

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.