summaryrefslogtreecommitdiffstats
path: root/drivers/led/led-pwm.c
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2020-02-06 12:23:32 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2020-02-10 09:16:15 +0100
commitf2fae1be3aa51e9665b4b947f7f0f4f723e264d6 (patch)
tree980e795965ce441cc0c3cd102d590a03562388b9 /drivers/led/led-pwm.c
parent213192253a4d8599f1d8127a7bdf87b80c767650 (diff)
downloadbarebox-f2fae1be3aa51e9665b4b947f7f0f4f723e264d6.tar.gz
barebox-f2fae1be3aa51e9665b4b947f7f0f4f723e264d6.tar.xz
led: pwm: fail if required max-brightness option is missing
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@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/led/led-pwm.c')
-rw-r--r--drivers/led/led-pwm.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/led/led-pwm.c b/drivers/led/led-pwm.c
index 2b53614ed3..419d96eed3 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);