Skip to content

Commit 4f0fa52

Browse files
Marek Vasutherbertx
authored andcommitted
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>
1 parent 1e16322 commit 4f0fa52

1 file changed

Lines changed: 13 additions & 18 deletions

File tree

‎drivers/crypto/caam/error.c‎

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -218,35 +218,30 @@ static void report_jump_status(struct device *jrdev, u32 status,
218218
static void report_deco_status(struct device *jrdev, u32 status,
219219
const char *error, char *__outstr)
220220
{
221-
char outstr[CAAM_ERROR_STR_MAX];
222-
223-
u8 desc_error = status & JRSTA_DECOERR_ERROR_MASK;
221+
u8 err_id = status & JRSTA_DECOERR_ERROR_MASK;
224222
u8 idx = (status & JRSTA_DECOERR_INDEX_MASK) >>
225223
JRSTA_DECOERR_INDEX_SHIFT;
226-
224+
char *idx_str;
225+
char *err_str = "unidentified error value 0x";
226+
char err_err_code[3] = { 0 };
227227
int i;
228-
sprintf(outstr, "%s: ", error);
229228

230229
if (status & JRSTA_DECOERR_JUMP)
231-
strcat(outstr, "jump tgt desc idx ");
230+
idx_str = "jump tgt desc idx";
232231
else
233-
strcat(outstr, "desc idx ");
234-
235-
SPRINTFCAT(outstr, "%d: ", idx, sizeof("255"));
232+
idx_str = "desc idx";
236233

237234
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)
239236
break;
240237

241-
if (i != ARRAY_SIZE(desc_error_list) && desc_error_list[i].error_text) {
242-
SPRINTFCAT(outstr, "%s", desc_error_list[i].error_text,
243-
strlen(desc_error_list[i].error_text));
244-
} else {
245-
SPRINTFCAT(outstr, "unidentified error value 0x%02x",
246-
desc_error, sizeof("ff"));
247-
}
238+
if (i != ARRAY_SIZE(desc_error_list) && desc_error_list[i].error_text)
239+
err_str = desc_error_list[i].error_text;
240+
else
241+
snprintf(err_err_code, sizeof(err_err_code), "%02x", err_id);
248242

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);
250245
}
251246

252247
static void report_jr_status(struct device *jrdev, u32 status,

0 commit comments

Comments
 (0)