diff options
author | Marek Vasut <marex@denx.de> | 2014-04-24 14:05:18 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2014-05-08 09:58:09 -0400 |
commit | 1e16322da45b747c753162e421b7a1b25259377a (patch) | |
tree | 15fad0338e05cdbc50d92c4f2d9f2a798f355da4 /drivers/crypto | |
parent | 526243cc872398ed8139a52ee0bf7715a3abcf31 (diff) |
crypto: caam - Clean up report_ccb_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, possible stack overwriting, 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 | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/drivers/crypto/caam/error.c b/drivers/crypto/caam/error.c index aa7d5cf2a294..91cc5fc7670f 100644 --- a/drivers/crypto/caam/error.c +++ b/drivers/crypto/caam/error.c | |||
@@ -171,46 +171,41 @@ static const char * const rng_err_id_list[] = { | |||
171 | static void report_ccb_status(struct device *jrdev, u32 status, | 171 | static void report_ccb_status(struct device *jrdev, u32 status, |
172 | const char *error, char *__outstr) | 172 | const char *error, char *__outstr) |
173 | { | 173 | { |
174 | char outstr[CAAM_ERROR_STR_MAX]; | ||
175 | |||
176 | u8 cha_id = (status & JRSTA_CCBERR_CHAID_MASK) >> | 174 | u8 cha_id = (status & JRSTA_CCBERR_CHAID_MASK) >> |
177 | JRSTA_CCBERR_CHAID_SHIFT; | 175 | JRSTA_CCBERR_CHAID_SHIFT; |
178 | u8 err_id = status & JRSTA_CCBERR_ERRID_MASK; | 176 | u8 err_id = status & JRSTA_CCBERR_ERRID_MASK; |
179 | u8 idx = (status & JRSTA_DECOERR_INDEX_MASK) >> | 177 | u8 idx = (status & JRSTA_DECOERR_INDEX_MASK) >> |
180 | JRSTA_DECOERR_INDEX_SHIFT; | 178 | JRSTA_DECOERR_INDEX_SHIFT; |
181 | 179 | char *idx_str; | |
182 | sprintf(outstr, "%s: ", error); | 180 | const char *cha_str = "unidentified cha_id value 0x"; |
181 | char cha_err_code[3] = { 0 }; | ||
182 | const char *err_str = "unidentified err_id value 0x"; | ||
183 | char err_err_code[3] = { 0 }; | ||
183 | 184 | ||
184 | if (status & JRSTA_DECOERR_JUMP) | 185 | if (status & JRSTA_DECOERR_JUMP) |
185 | strcat(outstr, "jump tgt desc idx "); | 186 | idx_str = "jump tgt desc idx"; |
186 | else | 187 | else |
187 | strcat(outstr, "desc idx "); | 188 | idx_str = "desc idx"; |
188 | |||
189 | SPRINTFCAT(outstr, "%d: ", idx, sizeof("255")); | ||
190 | 189 | ||
191 | if (cha_id < ARRAY_SIZE(cha_id_list)) { | 190 | if (cha_id < ARRAY_SIZE(cha_id_list)) |
192 | SPRINTFCAT(outstr, "%s: ", cha_id_list[cha_id], | 191 | cha_str = cha_id_list[cha_id]; |
193 | strlen(cha_id_list[cha_id])); | 192 | else |
194 | } else { | 193 | snprintf(cha_err_code, sizeof(cha_err_code), "%02x", cha_id); |
195 | SPRINTFCAT(outstr, "unidentified cha_id value 0x%02x: ", | ||
196 | cha_id, sizeof("ff")); | ||
197 | } | ||
198 | 194 | ||
199 | if ((cha_id << JRSTA_CCBERR_CHAID_SHIFT) == JRSTA_CCBERR_CHAID_RNG && | 195 | if ((cha_id << JRSTA_CCBERR_CHAID_SHIFT) == JRSTA_CCBERR_CHAID_RNG && |
200 | err_id < ARRAY_SIZE(rng_err_id_list) && | 196 | err_id < ARRAY_SIZE(rng_err_id_list) && |
201 | strlen(rng_err_id_list[err_id])) { | 197 | strlen(rng_err_id_list[err_id])) { |
202 | /* RNG-only error */ | 198 | /* RNG-only error */ |
203 | SPRINTFCAT(outstr, "%s", rng_err_id_list[err_id], | 199 | err_str = rng_err_id_list[err_id]; |
204 | strlen(rng_err_id_list[err_id])); | 200 | } else if (err_id < ARRAY_SIZE(err_id_list)) |
205 | } else if (err_id < ARRAY_SIZE(err_id_list)) { | 201 | err_str = err_id_list[err_id]; |
206 | SPRINTFCAT(outstr, "%s", err_id_list[err_id], | 202 | else |
207 | strlen(err_id_list[err_id])); | 203 | snprintf(err_err_code, sizeof(err_err_code), "%02x", err_id); |
208 | } else { | ||
209 | SPRINTFCAT(outstr, "unidentified err_id value 0x%02x", | ||
210 | err_id, sizeof("ff")); | ||
211 | } | ||
212 | 204 | ||
213 | dev_err(jrdev, "%08x: %s\n", status, outstr); | 205 | dev_err(jrdev, "%08x: %s: %s %d: %s%s: %s%s\n", |
206 | status, error, idx_str, idx, | ||
207 | cha_str, cha_err_code, | ||
208 | err_str, err_err_code); | ||
214 | } | 209 | } |
215 | 210 | ||
216 | static void report_jump_status(struct device *jrdev, u32 status, | 211 | static void report_jump_status(struct device *jrdev, u32 status, |