Commit d0226d31 authored by Suraj Jitindar Singh's avatar Suraj Jitindar Singh Committed by Michael Ellerman

powerpc/opal: Add inline function to get rc from an ASYNC_COMP opal_msg

An opal_msg of type OPAL_MSG_ASYNC_COMP contains the return code in the
params[1] struct member. However this isn't intuitive or obvious when
reading the code and requires that a user look at the skiboot
documentation or opal-api.h to verify this.

Add an inline function to get the return code from an opal_msg and update
call sites accordingly.
Signed-off-by: default avatarSuraj Jitindar Singh <sjitindarsingh@gmail.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 1ae88fd5
...@@ -282,6 +282,14 @@ extern int opal_error_code(int rc); ...@@ -282,6 +282,14 @@ extern int opal_error_code(int rc);
ssize_t opal_msglog_copy(char *to, loff_t pos, size_t count); 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 /* __ASSEMBLY__ */
#endif /* _ASM_POWERPC_OPAL_H */ #endif /* _ASM_POWERPC_OPAL_H */
...@@ -55,7 +55,7 @@ int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data) ...@@ -55,7 +55,7 @@ int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data)
goto out_token; 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); *sensor_data = be32_to_cpu(data);
break; break;
......
...@@ -67,7 +67,7 @@ static ssize_t opal_get_sys_param(u32 param_id, u32 length, void *buffer) ...@@ -67,7 +67,7 @@ static ssize_t opal_get_sys_param(u32 param_id, u32 length, void *buffer)
goto out_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: out_token:
opal_async_release_token(token); opal_async_release_token(token);
...@@ -103,7 +103,7 @@ static int opal_set_sys_param(u32 param_id, u32 length, void *buffer) ...@@ -103,7 +103,7 @@ static int opal_set_sys_param(u32 param_id, u32 length, void *buffer)
goto out_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: out_token:
opal_async_release_token(token); opal_async_release_token(token);
......
...@@ -71,7 +71,7 @@ static int i2c_opal_send_request(u32 bus_id, struct opal_i2c_request *req) ...@@ -71,7 +71,7 @@ static int i2c_opal_send_request(u32 bus_id, struct opal_i2c_request *req)
if (rc) if (rc)
goto exit; goto exit;
rc = be64_to_cpu(msg.params[1]); rc = opal_get_async_rc(msg);
if (rc != OPAL_SUCCESS) { if (rc != OPAL_SUCCESS) {
rc = i2c_opal_translate_error(rc); rc = i2c_opal_translate_error(rc);
goto exit; goto exit;
......
...@@ -118,7 +118,7 @@ static int powernv_led_set(struct powernv_led_data *powernv_led, ...@@ -118,7 +118,7 @@ static int powernv_led_set(struct powernv_led_data *powernv_led,
goto out_token; goto out_token;
} }
rc = be64_to_cpu(msg.params[1]); rc = opal_get_async_rc(msg);
if (rc != OPAL_SUCCESS) if (rc != OPAL_SUCCESS)
dev_err(dev, "%s : OAPL async call returned failed [rc=%d]\n", dev_err(dev, "%s : OAPL async call returned failed [rc=%d]\n",
__func__, rc); __func__, rc);
......
...@@ -95,7 +95,7 @@ static int powernv_flash_async_op(struct mtd_info *mtd, enum flash_op op, ...@@ -95,7 +95,7 @@ static int powernv_flash_async_op(struct mtd_info *mtd, enum flash_op op,
return -EIO; return -EIO;
} }
rc = be64_to_cpu(msg.params[1]); rc = opal_get_async_rc(msg);
if (rc == OPAL_SUCCESS) { if (rc == OPAL_SUCCESS) {
rc = 0; rc = 0;
if (retlen) if (retlen)
......
...@@ -134,7 +134,7 @@ static int opal_get_tpo_time(struct device *dev, struct rtc_wkalrm *alarm) ...@@ -134,7 +134,7 @@ static int opal_get_tpo_time(struct device *dev, struct rtc_wkalrm *alarm)
goto exit; goto exit;
} }
rc = be64_to_cpu(msg.params[1]); rc = opal_get_async_rc(msg);
if (rc != OPAL_SUCCESS) { if (rc != OPAL_SUCCESS) {
rc = -EIO; rc = -EIO;
goto exit; goto exit;
...@@ -181,7 +181,7 @@ static int opal_set_tpo_time(struct device *dev, struct rtc_wkalrm *alarm) ...@@ -181,7 +181,7 @@ static int opal_set_tpo_time(struct device *dev, struct rtc_wkalrm *alarm)
goto exit; goto exit;
} }
rc = be64_to_cpu(msg.params[1]); rc = opal_get_async_rc(msg);
if (rc != OPAL_SUCCESS) if (rc != OPAL_SUCCESS)
rc = -EIO; rc = -EIO;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment