ssize_t opal_msglog_copy(char *to, loff_t pos, size_t count);
 
+static inline int opal_get_async_rc(struct opal_msg msg)
+{
+       if (msg.msg_type != OPAL_MSG_ASYNC_COMP)
+               return OPAL_PARAMETER;
+       else
+               return be64_to_cpu(msg.params[1]);
+}
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* _ASM_POWERPC_OPAL_H */
 
                        goto out_token;
                }
 
-               ret = opal_error_code(be64_to_cpu(msg.params[1]));
+               ret = opal_error_code(opal_get_async_rc(msg));
                *sensor_data = be32_to_cpu(data);
                break;
 
 
                goto out_token;
        }
 
-       ret = opal_error_code(be64_to_cpu(msg.params[1]));
+       ret = opal_error_code(opal_get_async_rc(msg));
 
 out_token:
        opal_async_release_token(token);
                goto out_token;
        }
 
-       ret = opal_error_code(be64_to_cpu(msg.params[1]));
+       ret = opal_error_code(opal_get_async_rc(msg));
 
 out_token:
        opal_async_release_token(token);
 
        if (rc)
                goto exit;
 
-       rc = be64_to_cpu(msg.params[1]);
+       rc = opal_get_async_rc(msg);
        if (rc != OPAL_SUCCESS) {
                rc = i2c_opal_translate_error(rc);
                goto exit;
 
                goto out_token;
        }
 
-       rc = be64_to_cpu(msg.params[1]);
+       rc = opal_get_async_rc(msg);
        if (rc != OPAL_SUCCESS)
                dev_err(dev, "%s : OAPL async call returned failed [rc=%d]\n",
                        __func__, rc);
 
                return -EIO;
        }
 
-       rc = be64_to_cpu(msg.params[1]);
+       rc = opal_get_async_rc(msg);
        if (rc == OPAL_SUCCESS) {
                rc = 0;
                if (retlen)
 
                goto exit;
        }
 
-       rc = be64_to_cpu(msg.params[1]);
+       rc = opal_get_async_rc(msg);
        if (rc != OPAL_SUCCESS) {
                rc = -EIO;
                goto exit;
                goto exit;
        }
 
-       rc = be64_to_cpu(msg.params[1]);
+       rc = opal_get_async_rc(msg);
        if (rc != OPAL_SUCCESS)
                rc = -EIO;