Skip to contentSkip to conversation

powerpc/powernv: Create opal sysfs directory

PATCH New Vasant Hegde 1 participant 1 message Aug 27, 2013 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/powernv: Create opal sysfs directory

Create /sys/firmware/opal directory. We wil use this interface to fetch opal error logs, firmware update, etc.

---
 arch/powerpc/include/asm/opal.h       |    3 +++
 arch/powerpc/platforms/powernv/opal.c |   21 ++++++++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/opal.h +3 -0
index ba6ffe6..4432b7a 100644
@@ -523,6 +523,9 @@ typedef struct oppanel_line {
 	uint64_t 	line_len;
 } oppanel_line_t;
 
+/* /sys/firmware/opal */
+extern struct kobject *opal_kobj;
+
 /* API functions */
 int64_t opal_console_write(int64_t term_number, int64_t *length,
 			   const uint8_t *buffer);
arch/powerpc/platforms/powernv/opal.c +20 -1
index 106301f..1c48a68 100644
@@ -17,11 +17,15 @@
 #include <linux/interrupt.h>
 #include <linux/notifier.h>
 #include <linux/slab.h>
+#include <linux/kobject.h>
 #include <asm/opal.h>
 #include <asm/firmware.h>
 
 #include "powernv.h"
 
+/* /sys/firmware/opal */
+struct kobject *opal_kobj;
+
 struct opal {
 	u64 base;
 	u64 entry;
@@ -369,6 +373,17 @@ static irqreturn_t opal_interrupt(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
+static int opal_sysfs_init(void)
+{
+	opal_kobj = kobject_create_and_add("opal", firmware_kobj);
+	if (!opal_kobj) {
+		pr_warn("kobject_create_and_add opal failed\n");
+		return -ENOMEM;
+	}
+
+	return 0;
+}
+
 static int __init opal_init(void)
 {
 	struct device_node *np, *consoles;
@@ -412,7 +427,11 @@ static int __init opal_init(void)
 				   " (0x%x)\n", rc, irq, hwirq);
 		opal_irqs[i] = irq;
 	}
-	return 0;
+
+	/* Create "opal" kobject under /sys/firmware */
+	rc = opal_sysfs_init();
+
+	return rc;
 }
 subsys_initcall(opal_init);