[PATCH 6/8] led: pwm: fail if required max-brightness option is missing

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

 



If we leave max_value at the default value of zero led_pwm_set above
will divide by zero in do_div. The binding makes max-brightness
a mandatory property, so have the driver treat it as such as well.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 drivers/led/led-pwm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/led/led-pwm.c b/drivers/led/led-pwm.c
index 2b53614ed388..419d96eed392 100644
--- a/drivers/led/led-pwm.c
+++ b/drivers/led/led-pwm.c
@@ -61,7 +61,9 @@ static int led_pwm_of_probe(struct device_d *dev)
 		pwmled->led.name = xstrdup(child->name);
 		pwmled->pwm = pwm;
 
-		of_property_read_u32(child, "max-brightness", &pwmled->led.max_value);
+		ret = of_property_read_u32(child, "max-brightness", &pwmled->led.max_value);
+		if (ret)
+			return ret;
 
 		pwmled->period = pwm_get_period(pwmled->pwm);
 
-- 
2.25.0


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



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

  Powered by Linux