[PATCH 3/3] lpd: Check for device tree property

Vasant Hegde <[email protected]> Mon, 21 Nov 2016 15:10:49 +0530
Newsgroups gmane.linux.tools.diag.devel
Message-ID <[email protected]>
Not all OPAL system supports OPAL leds. Check the existence of DT
property before using. Also if DT property doesn't exists, then
assume its in Light Path mode.

Signed-off-by: Vasant Hegde <[email protected]>
---
 lpd/indicator_opal.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lpd/indicator_opal.c b/lpd/indicator_opal.c
index f9780fc..5fb4d75 100644
--- a/lpd/indicator_opal.c
+++ b/lpd/indicator_opal.c
@@ -378,6 +378,13 @@ opal_get_indicator_mode(void)
 	int	rc = 0;
 	int	fd;
 	int	readsz;
+	struct stat sbuf;
+
+	rc = stat(OPAL_LED_MODE_PROPERTY, &sbuf);
+	if (rc) {
+		operating_mode = LED_MODE_LIGHT_PATH;
+		return 0;
+	}
 
 	fd = open(OPAL_LED_MODE_PROPERTY, O_RDONLY);
 	if (fd == -1) {


------------------------------------------------------------------------------