Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Suraj Jitindar Singh and committed by
Michael Ellerman
d0226d31 1ae88fd5

+16 -8
+8
arch/powerpc/include/asm/opal.h
··· 282 282 283 283 ssize_t opal_msglog_copy(char *to, loff_t pos, size_t count); 284 284 285 + static inline int opal_get_async_rc(struct opal_msg msg) 286 + { 287 + if (msg.msg_type != OPAL_MSG_ASYNC_COMP) 288 + return OPAL_PARAMETER; 289 + else 290 + return be64_to_cpu(msg.params[1]); 291 + } 292 + 285 293 #endif /* __ASSEMBLY__ */ 286 294 287 295 #endif /* _ASM_POWERPC_OPAL_H */
+1 -1
arch/powerpc/platforms/powernv/opal-sensor.c
··· 55 55 goto out_token; 56 56 } 57 57 58 - ret = opal_error_code(be64_to_cpu(msg.params[1])); 58 + ret = opal_error_code(opal_get_async_rc(msg)); 59 59 *sensor_data = be32_to_cpu(data); 60 60 break; 61 61
+2 -2
arch/powerpc/platforms/powernv/opal-sysparam.c
··· 67 67 goto out_token; 68 68 } 69 69 70 - ret = opal_error_code(be64_to_cpu(msg.params[1])); 70 + ret = opal_error_code(opal_get_async_rc(msg)); 71 71 72 72 out_token: 73 73 opal_async_release_token(token); ··· 103 103 goto out_token; 104 104 } 105 105 106 - ret = opal_error_code(be64_to_cpu(msg.params[1])); 106 + ret = opal_error_code(opal_get_async_rc(msg)); 107 107 108 108 out_token: 109 109 opal_async_release_token(token);
+1 -1
drivers/i2c/busses/i2c-opal.c
··· 71 71 if (rc) 72 72 goto exit; 73 73 74 - rc = be64_to_cpu(msg.params[1]); 74 + rc = opal_get_async_rc(msg); 75 75 if (rc != OPAL_SUCCESS) { 76 76 rc = i2c_opal_translate_error(rc); 77 77 goto exit;
+1 -1
drivers/leds/leds-powernv.c
··· 118 118 goto out_token; 119 119 } 120 120 121 - rc = be64_to_cpu(msg.params[1]); 121 + rc = opal_get_async_rc(msg); 122 122 if (rc != OPAL_SUCCESS) 123 123 dev_err(dev, "%s : OAPL async call returned failed [rc=%d]\n", 124 124 __func__, rc);
+1 -1
drivers/mtd/devices/powernv_flash.c
··· 95 95 return -EIO; 96 96 } 97 97 98 - rc = be64_to_cpu(msg.params[1]); 98 + rc = opal_get_async_rc(msg); 99 99 if (rc == OPAL_SUCCESS) { 100 100 rc = 0; 101 101 if (retlen)
+2 -2
drivers/rtc/rtc-opal.c
··· 134 134 goto exit; 135 135 } 136 136 137 - rc = be64_to_cpu(msg.params[1]); 137 + rc = opal_get_async_rc(msg); 138 138 if (rc != OPAL_SUCCESS) { 139 139 rc = -EIO; 140 140 goto exit; ··· 181 181 goto exit; 182 182 } 183 183 184 - rc = be64_to_cpu(msg.params[1]); 184 + rc = opal_get_async_rc(msg); 185 185 if (rc != OPAL_SUCCESS) 186 186 rc = -EIO; 187 187