powerpc/powernv: Fix endian issues with OPAL async code
[firefly-linux-kernel-4.4.55.git] / arch / powerpc / platforms / powernv / opal.c
index e92f2f67640f7db39e18d78ccbb08d6ad12eed7e..778a2793e75b019ef0dbc8e2732f5019dd7e0087 100644 (file)
@@ -180,6 +180,20 @@ int opal_notifier_register(struct notifier_block *nb)
        atomic_notifier_chain_register(&opal_notifier_head, nb);
        return 0;
 }
+EXPORT_SYMBOL_GPL(opal_notifier_register);
+
+int opal_notifier_unregister(struct notifier_block *nb)
+{
+       if (!nb) {
+               pr_warning("%s: Invalid argument (%p)\n",
+                          __func__, nb);
+               return -EINVAL;
+       }
+
+       atomic_notifier_chain_unregister(&opal_notifier_head, nb);
+       return 0;
+}
+EXPORT_SYMBOL_GPL(opal_notifier_unregister);
 
 static void opal_do_notifier(uint64_t events)
 {
@@ -267,6 +281,7 @@ static void opal_handle_message(void)
         * value in /proc/device-tree.
         */
        static struct opal_msg msg;
+       u32 type;
 
        ret = opal_get_msg(__pa(&msg), sizeof(msg));
        /* No opal message pending. */
@@ -280,13 +295,14 @@ static void opal_handle_message(void)
                return;
        }
 
+       type = be32_to_cpu(msg.msg_type);
+
        /* Sanity check */
-       if (msg.msg_type > OPAL_MSG_TYPE_MAX) {
-               pr_warning("%s: Unknown message type: %u\n",
-                               __func__, msg.msg_type);
+       if (type > OPAL_MSG_TYPE_MAX) {
+               pr_warning("%s: Unknown message type: %u\n", __func__, type);
                return;
        }
-       opal_message_do_notify(msg.msg_type, (void *)&msg);
+       opal_message_do_notify(type, (void *)&msg);
 }
 
 static int opal_message_notify(struct notifier_block *nb,