[PATCH master] video: backlight: make brightness and slew time parameters unsigned

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Despite the backlight parameter being registered as uint32,
backlight_brightness_set took the brightness level as a signed value.

This can lead to wrap around for very large values of brightness
supplied as device parameter and if this results in a negative
brightness, the function appears to hang, because the slew rate loop
runs for a long time.

Fix this by making brightness level an unsigned entity.

Fixes: e3ea90860e99 ("video: Add backlight support")
Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 drivers/video/backlight.c | 6 +++---
 include/video/backlight.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/video/backlight.c b/drivers/video/backlight.c
index 6c00cc115e6d..d171b0d960d2 100644
--- a/drivers/video/backlight.c
+++ b/drivers/video/backlight.c
@@ -6,7 +6,7 @@
 
 static LIST_HEAD(backlights);
 
-int backlight_set_brightness(struct backlight_device *bl, int brightness)
+int backlight_set_brightness(struct backlight_device *bl, unsigned brightness)
 {
 	int ret, step, i, num_steps;
 
@@ -80,9 +80,9 @@ int backlight_register(struct backlight_device *bl)
 		return ret;
 
 	dev_add_param_uint32(&bl->dev, "brightness", backlight_brightness_set,
-			NULL, &bl->brightness, "%d", bl);
+			NULL, &bl->brightness, "%u", bl);
 	dev_add_param_uint32(&bl->dev, "slew_time_ms", NULL, NULL,
-			     &bl->slew_time_ms, "%d", NULL);
+			     &bl->slew_time_ms, "%u", NULL);
 
 	list_add_tail(&bl->list, &backlights);
 
diff --git a/include/video/backlight.h b/include/video/backlight.h
index b510de9d294f..2dd63202cd6e 100644
--- a/include/video/backlight.h
+++ b/include/video/backlight.h
@@ -16,7 +16,7 @@ struct backlight_device {
 	struct device_node *node;
 };
 
-int backlight_set_brightness(struct backlight_device *, int brightness);
+int backlight_set_brightness(struct backlight_device *, unsigned brightness);
 int backlight_set_brightness_default(struct backlight_device *);
 int backlight_register(struct backlight_device *);
 struct backlight_device *of_backlight_find(struct device_node *node);
@@ -24,7 +24,7 @@ struct backlight_device *of_backlight_find(struct device_node *node);
 struct backlight_device ;
 
 static inline int
-backlight_set_brightness(struct backlight_device *dev, int brightness)
+backlight_set_brightness(struct backlight_device *dev, unsigned brightness)
 {
 	return 0;
 }
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux