9
0
Fork 0

led: test for led->set callback before calling it

Registering a LED can fail. If someone calls led_set for such
a LED no set function will be there. Fail gracefully in this
case.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2013-01-14 13:39:16 +01:00
parent 1431f4a7fc
commit 50da59975f
1 changed files with 3 additions and 0 deletions

View File

@ -106,6 +106,9 @@ int led_set(struct led *led, unsigned int value)
if (value > led->max_value)
value = led->max_value;
if (!led->set)
return -ENODEV;
led->set(led, value);
return 0;