aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2014-04-24 14:05:15 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2014-05-08 09:58:08 -0400
commit8a4758268292eb036a63f49746fbfe3fcdc0c51d (patch)
tree04d4fa29337c6e5eaffc65fec648e684234130c0
parent867e1ee395d845f49ae280c3d8f5271b214fa7e4 (diff)
crypto: caam - Pass error type into the functions
Pass the error type string into the functions, so they can handle the printing of the string. This is now still using the very unsafe sprintf(), but we will fix that. While at this, pass the device pointer too, so we can dev_err() functions readily when we start fixing this proper. 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>
-rw-r--r--drivers/crypto/caam/error.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/drivers/crypto/caam/error.c b/drivers/crypto/caam/error.c
index 961331d1b6ab..7ce1d0349d68 100644
--- a/drivers/crypto/caam/error.c
+++ b/drivers/crypto/caam/error.c
@@ -181,12 +181,15 @@ static void report_jump_idx(u32 status, char *outstr)
181 SPRINTFCAT(outstr, "%d: ", idx, sizeof("255")); 181 SPRINTFCAT(outstr, "%d: ", idx, sizeof("255"));
182} 182}
183 183
184static void report_ccb_status(u32 status, char *outstr) 184static void report_ccb_status(struct device *jrdev, u32 status,
185 const char *error, char *outstr)
185{ 186{
186 u8 cha_id = (status & JRSTA_CCBERR_CHAID_MASK) >> 187 u8 cha_id = (status & JRSTA_CCBERR_CHAID_MASK) >>
187 JRSTA_CCBERR_CHAID_SHIFT; 188 JRSTA_CCBERR_CHAID_SHIFT;
188 u8 err_id = status & JRSTA_CCBERR_ERRID_MASK; 189 u8 err_id = status & JRSTA_CCBERR_ERRID_MASK;
189 190
191 sprintf(outstr, "%s: ", error);
192
190 report_jump_idx(status, outstr); 193 report_jump_idx(status, outstr);
191 194
192 if (cha_id < ARRAY_SIZE(cha_id_list)) { 195 if (cha_id < ARRAY_SIZE(cha_id_list)) {
@@ -212,15 +215,19 @@ static void report_ccb_status(u32 status, char *outstr)
212 } 215 }
213} 216}
214 217
215static void report_jump_status(u32 status, char *outstr) 218static void report_jump_status(struct device *jrdev, u32 status,
219 const char *error, char *outstr)
216{ 220{
221 sprintf(outstr, "%s: ", error);
217 SPRINTFCAT(outstr, "%s() not implemented", __func__, sizeof(__func__)); 222 SPRINTFCAT(outstr, "%s() not implemented", __func__, sizeof(__func__));
218} 223}
219 224
220static void report_deco_status(u32 status, char *outstr) 225static void report_deco_status(struct device *jrdev, u32 status,
226 const char *error, char *outstr)
221{ 227{
222 u8 desc_error = status & JRSTA_DECOERR_ERROR_MASK; 228 u8 desc_error = status & JRSTA_DECOERR_ERROR_MASK;
223 int i; 229 int i;
230 sprintf(outstr, "%s: ", error);
224 231
225 report_jump_idx(status, outstr); 232 report_jump_idx(status, outstr);
226 233
@@ -237,13 +244,17 @@ static void report_deco_status(u32 status, char *outstr)
237 } 244 }
238} 245}
239 246
240static void report_jr_status(u32 status, char *outstr) 247static void report_jr_status(struct device *jrdev, u32 status,
248 const char *error, char *outstr)
241{ 249{
250 sprintf(outstr, "%s: ", error);
242 SPRINTFCAT(outstr, "%s() not implemented", __func__, sizeof(__func__)); 251 SPRINTFCAT(outstr, "%s() not implemented", __func__, sizeof(__func__));
243} 252}
244 253
245static void report_cond_code_status(u32 status, char *outstr) 254static void report_cond_code_status(struct device *jrdev, u32 status,
255 const char *error, char *outstr)
246{ 256{
257 sprintf(outstr, "%s: ", error);
247 SPRINTFCAT(outstr, "%s() not implemented", __func__, sizeof(__func__)); 258 SPRINTFCAT(outstr, "%s() not implemented", __func__, sizeof(__func__));
248} 259}
249 260
@@ -251,8 +262,9 @@ void caam_jr_strstatus(struct device *jrdev, u32 status)
251{ 262{
252 char outstr[CAAM_ERROR_STR_MAX]; 263 char outstr[CAAM_ERROR_STR_MAX];
253 static const struct stat_src { 264 static const struct stat_src {
254 void (*report_ssed)(u32 status, char *outstr); 265 void (*report_ssed)(struct device *jrdev, u32 status,
255 char *error; 266 const char *error, char *outstr);
267 const char *error;
256 } status_src[] = { 268 } status_src[] = {
257 { NULL, "No error" }, 269 { NULL, "No error" },
258 { NULL, NULL }, 270 { NULL, NULL },
@@ -274,9 +286,8 @@ void caam_jr_strstatus(struct device *jrdev, u32 status)
274 return; 286 return;
275 } 287 }
276 288
277 sprintf(outstr, "%s: ", status_src[ssrc].error); 289 status_src[ssrc].report_ssed(jrdev, status,
278 290 status_src[ssrc].error, outstr);
279 status_src[ssrc].report_ssed(status, outstr);
280 291
281 dev_err(jrdev, "%08x: %s\n", status, outstr); 292 dev_err(jrdev, "%08x: %s\n", status, outstr);
282} 293}