From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1izfG9-0005V1-Rn for barebox@lists.infradead.org; Thu, 06 Feb 2020 11:23:51 +0000 From: Ahmad Fatoum Date: Thu, 6 Feb 2020 12:23:32 +0100 Message-Id: <20200206112334.14314-7-a.fatoum@pengutronix.de> In-Reply-To: <20200206112334.14314-1-a.fatoum@pengutronix.de> References: <20200206112334.14314-1-a.fatoum@pengutronix.de> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 6/8] led: pwm: fail if required max-brightness option is missing To: barebox@lists.infradead.org Cc: Ahmad Fatoum 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 --- 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@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox