diff options
author | Marek Vasut <marex@denx.de> | 2014-04-24 14:05:19 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2014-05-08 09:58:10 -0400 |
commit | 4f0fa52a5d89d763423cb9b428e988ea824fd95a (patch) | |
tree | 7b595616896004ba66357697ab555d731be16478 /drivers/crypto | |
parent | 1e16322da45b747c753162e421b7a1b25259377a (diff) |
crypto: caam - Clean up report_deco_status()
Clean this function up and rework it into sensible shape. This function
now contains one single dev_err() instead of the previous insanity full
of memory allocation, chaotic string handling and use of SPRINTFCAT().
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Horia Geanta <horia.geanta@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r-- | drivers/crypto/caam/error.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/drivers/crypto/caam/error.c b/drivers/crypto/caam/error.c index 91cc5fc7670f..66a7461cf9ae 100644 --- a/drivers/crypto/caam/error.c +++ b/drivers/crypto/caam/error.c | |||
@@ -218,35 +218,30 @@ static void report_jump_status(struct device *jrdev, u32 status, | |||
218 | static void report_deco_status(struct device *jrdev, u32 status, | 218 | static void report_deco_status(struct device *jrdev, u32 status, |
219 | const char *error, char *__outstr) | 219 | const char *error, char *__outstr) |
220 | { | 220 | { |
221 | char outstr[CAAM_ERROR_STR_MAX]; | 221 | u8 err_id = status & JRSTA_DECOERR_ERROR_MASK; |
222 | |||
223 | u8 desc_error = status & JRSTA_DECOERR_ERROR_MASK; | ||
224 | u8 idx = (status & JRSTA_DECOERR_INDEX_MASK) >> | 222 | u8 idx = (status & JRSTA_DECOERR_INDEX_MASK) >> |
225 | JRSTA_DECOERR_INDEX_SHIFT; | 223 | JRSTA_DECOERR_INDEX_SHIFT; |
226 | 224 | char *idx_str; | |
225 | char *err_str = "unidentified error value 0x"; | ||
226 | char err_err_code[3] = { 0 }; | ||
227 | int i; | 227 | int i; |
228 | sprintf(outstr, "%s: ", error); | ||
229 | 228 | ||
230 | if (status & JRSTA_DECOERR_JUMP) | 229 | if (status & JRSTA_DECOERR_JUMP) |
231 | strcat(outstr, "jump tgt desc idx "); | 230 | idx_str = "jump tgt desc idx"; |
232 | else | 231 | else |
233 | strcat(outstr, "desc idx "); | 232 | idx_str = "desc idx"; |
234 | |||
235 | SPRINTFCAT(outstr, "%d: ", idx, sizeof("255")); | ||
236 | 233 | ||
237 | for (i = 0; i < ARRAY_SIZE(desc_error_list); i++) | 234 | for (i = 0; i < ARRAY_SIZE(desc_error_list); i++) |
238 | if (desc_error_list[i].value == desc_error) | 235 | if (desc_error_list[i].value == err_id) |
239 | break; | 236 | break; |
240 | 237 | ||
241 | if (i != ARRAY_SIZE(desc_error_list) && desc_error_list[i].error_text) { | 238 | if (i != ARRAY_SIZE(desc_error_list) && desc_error_list[i].error_text) |
242 | SPRINTFCAT(outstr, "%s", desc_error_list[i].error_text, | 239 | err_str = desc_error_list[i].error_text; |
243 | strlen(desc_error_list[i].error_text)); | 240 | else |
244 | } else { | 241 | snprintf(err_err_code, sizeof(err_err_code), "%02x", err_id); |
245 | SPRINTFCAT(outstr, "unidentified error value 0x%02x", | ||
246 | desc_error, sizeof("ff")); | ||
247 | } | ||
248 | 242 | ||
249 | dev_err(jrdev, "%08x: %s\n", status, outstr); | 243 | dev_err(jrdev, "%08x: %s: %s %d: %s%s\n", |
244 | status, error, idx_str, idx, err_str, err_err_code); | ||
250 | } | 245 | } |
251 | 246 | ||
252 | static void report_jr_status(struct device *jrdev, u32 status, | 247 | static void report_jr_status(struct device *jrdev, u32 status, |