All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] backlight: pwm_bl: Fix uninitialized variable
@ 2018-07-16 21:02 ` Daniel Thompson
  0 siblings, 0 replies; 58+ messages in thread
From: Daniel Thompson @ 2018-07-16 21:02 UTC (permalink / raw)
  To: Lee Jones, Daniel Thompson, Jingoo Han
  Cc: Thierry Reding, Bartlomiej Zolnierkiewicz, linux-pwm, dri-devel,
	linux-fbdev, linux-kernel, patches, Marcel Ziswiler

Currently, if the DT does not define num-interpolated-steps then
num_steps is undefined and the interpolation code will deploy randomly.
Fix this.

Fixes: 573fe6d1c25c ("backlight: pwm_bl: Linear interpolation between
brightness-levels")
Reported-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
---
 drivers/video/backlight/pwm_bl.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index 9ee4c1b735b2..e3c22b79fbcd 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -299,15 +299,14 @@ static int pwm_backlight_parse_dt(struct device *dev,
 		 * interpolation between each of the values of brightness levels
 		 * and creates a new pre-computed table.
 		 */
-		of_property_read_u32(node, "num-interpolated-steps",
-				     &num_steps);
-
-		/*
-		 * Make sure that there is at least two entries in the
-		 * brightness-levels table, otherwise we can't interpolate
-		 * between two points.
-		 */
-		if (num_steps) {
+		if ((of_property_read_u32(node, "num-interpolated-steps",
+					  &num_steps) = 0) && num_steps) {
+			/*
+			 * Make sure that there is at least two entries in the
+			 * brightness-levels table, otherwise we can't
+			 * interpolate
+			 * between two points.
+			 */
 			if (data->max_brightness < 2) {
 				dev_err(dev, "can't interpolate\n");
 				return -EINVAL;
--
2.17.1


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

end of thread, other threads:[~2018-07-25  8:03 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-16 21:02 [PATCH] backlight: pwm_bl: Fix uninitialized variable Daniel Thompson
2018-07-16 21:02 ` Daniel Thompson
2018-07-18  8:09 ` Lee Jones
2018-07-18  8:09   ` Lee Jones
2018-07-18  8:12   ` Lee Jones
2018-07-18  8:12     ` Lee Jones
2018-07-18  8:12     ` Lee Jones
2018-07-18  8:22   ` Marcel Ziswiler
2018-07-18  8:22     ` Marcel Ziswiler
2018-07-18  9:53     ` Lee Jones
2018-07-18  9:53       ` Lee Jones
2018-07-18  9:53       ` Lee Jones
2018-07-18 10:12       ` Daniel Thompson
2018-07-18 10:12         ` Daniel Thompson
2018-07-18 12:57         ` Marcel Ziswiler
2018-07-18 12:57           ` Marcel Ziswiler
2018-07-18 13:08           ` Lee Jones
2018-07-18 13:08             ` Lee Jones
2018-07-18 13:26             ` Marcel Ziswiler
2018-07-18 13:26               ` Marcel Ziswiler
2018-07-18 13:41             ` Daniel Thompson
2018-07-18 13:41               ` Daniel Thompson
2018-07-18 13:41               ` Daniel Thompson
2018-07-18 15:55               ` Lee Jones
2018-07-18 15:55                 ` Lee Jones
2018-07-18 15:55                 ` Lee Jones
2018-07-18 16:34                 ` Daniel Thompson
2018-07-18 16:34                   ` Daniel Thompson
2018-07-18 16:34                   ` Daniel Thompson
2018-07-23  7:25                   ` Lee Jones
2018-07-23  7:25                     ` Lee Jones
2018-07-23  7:25                     ` Lee Jones
2018-07-18  8:26   ` Daniel Thompson
2018-07-18  8:26     ` Daniel Thompson
2018-07-18  8:26     ` Daniel Thompson
2018-07-19 16:19 ` [PATCH v2] " Daniel Thompson
2018-07-19 16:19   ` Daniel Thompson
2018-07-19 16:19   ` Daniel Thompson
2018-07-23  7:23   ` Lee Jones
2018-07-23  7:23     ` Lee Jones
2018-07-24  6:48     ` Daniel Thompson
2018-07-24  6:48       ` Daniel Thompson
2018-07-24  7:01     ` Daniel Thompson
2018-07-24  7:01       ` Daniel Thompson
2018-07-24  7:01       ` Daniel Thompson
2018-07-24  7:12 ` [PATCH v3] " Daniel Thompson
2018-07-24  7:12   ` Daniel Thompson
2018-07-24  7:12   ` Daniel Thompson
2018-07-24 23:56   ` Doug Anderson
2018-07-24 23:56     ` Doug Anderson
2018-07-25  5:22   ` Lee Jones
2018-07-25  5:22     ` Lee Jones
2018-07-25  5:22     ` Lee Jones
2018-07-25  7:38 ` [PATCH v4] " Daniel Thompson
2018-07-25  7:38   ` Daniel Thompson
2018-07-25  7:38   ` Daniel Thompson
2018-07-25  8:03   ` Lee Jones
2018-07-25  8:03     ` 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.