[PATCH v3 3/3] lpd: marvell: do not exit early on empty /sys/class/leds dir (OPAL)

Mauricio Faria de Oliveira <[email protected]> Wed, 9 Nov 2016 10:44:11 -0200
Newsgroups gmane.linux.tools.diag.devel
Message-ID <[email protected]>
Some systems/conditions have no kernel LEDs present (thus nothing in
the /sys/class/leds directory), which would cause usysident to early
exit in the OPAL platform, and not give a chance for other LED types
(e.g., Marvell HDD LEDs) to be used.

This patch adds a check for that in the OPAL platform probe function,
and in case Marvell HDD devices are found, prevent usysident to exit
early, so they can be used.

Signed-off-by: Mauricio Faria de Oliveira <[email protected]>
---
Changelog:
  v2:
  - opal_indicator_probe() split into specific probe functions for
    LED class (a.k.a. platform LEDs) and Marvell LEDs

 lpd/indicator_opal.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 51 insertions(+), 3 deletions(-)

diff --git a/lpd/indicator_opal.c b/lpd/indicator_opal.c
index 123a1b2..c43ab7a 100644
--- a/lpd/indicator_opal.c
+++ b/lpd/indicator_opal.c
@@ -282,13 +282,14 @@ opal_set_indicator(struct loc_code *loc, int new_value)
 
 
 /*
- * opal_indicator_probe - Probe indicator support on OPAL based platform
+ * opal_indicator_probe_led_class - Probe LED class (/sys/class/leds)
+ *                                  indicator support on OPAL based platform
  *
  * Returns:
  *   0 if indicator is supported, else -1
  */
 static int
-opal_indicator_probe(void)
+opal_indicator_probe_led_class(void)
 {
 	int rc = -1;
 	DIR *led_dir;
@@ -314,12 +315,59 @@ opal_indicator_probe(void)
 		return 0;
 	}
 
-	fprintf(stderr, "Service indicators are not supported on this system."
+	fprintf(stderr, "Some service indicators are not supported on this system."
 		"\nMake sure 'leds_powernv' kernel module is loaded.\n");
 	close_sysfs_led_dir(led_dir);
 	return rc;
 }
 
+
+/*
+ * opal_indicator_probe_marvell - Probe Marvell indicator support on
+ *                                OPAL based platform
+ *
+ * Returns:
+ *   0 if indicator is supported, else -1
+ */
+static int
+opal_indicator_probe_marvell(void)
+{
+	struct loc_code *list = NULL;
+
+	get_mv_indices(LED_TYPE_IDENT, &list);
+	if (list) {
+		free_indicator_list(list);
+		return 0;
+	}
+
+	return -1;
+}
+/*
+ * opal_indicator_probe - Probe indicator support on OPAL based platform
+ *
+ * Returns:
+ *   0 if indicator is supported, else -1
+ */
+static int
+opal_indicator_probe(void)
+{
+	int rc = -1;
+
+	if (!opal_indicator_probe_led_class())
+		rc = 0;
+
+	/*
+	 * Marvell HDD LEDs are not presented/controlled via kernel LEDs
+	 * (i.e., /sys/class/leds), and some OPAL systems might not have
+	 * any kernel LEDs (e.g., modules not loaded) but still have the
+	 * Marvell SATA controller with LEDs available, and able to work.
+	 */
+	if (!opal_indicator_probe_marvell())
+		rc = 0;
+
+	return rc;
+}
+
 /**
  * opal_get_indicator_mode - Gets the service indicator operating mode
  *
-- 
1.8.3.1


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi