Skip to content

Commit eb7e511

Browse files
committed
crypto: atmel-tdes: Handle error messages
Downgrade all runtime error messages to dev_dbg so that we don't pollute the console. All probe error messages are kept with dev_err. Get rid of pr_err and use dev_dbg instead, so that we know from which device the error comes. dma_mapping_error() return code was overwritten, use the error code that the function returns. Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
1 parent 9a83055 commit eb7e511

1 file changed

Lines changed: 16 additions & 17 deletions

File tree

drivers/crypto/atmel-tdes.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ static int atmel_tdes_crypt_pdc_stop(struct atmel_tdes_dev *dd)
314314
dd->buf_out, dd->buflen, dd->dma_size, 1);
315315
if (count != dd->dma_size) {
316316
err = -EINVAL;
317-
pr_err("not all data converted: %zu\n", count);
317+
dev_dbg(dd->dev, "not all data converted: %zu\n", count);
318318
}
319319
}
320320

@@ -331,24 +331,24 @@ static int atmel_tdes_buff_init(struct atmel_tdes_dev *dd)
331331
dd->buflen &= ~(DES_BLOCK_SIZE - 1);
332332

333333
if (!dd->buf_in || !dd->buf_out) {
334-
dev_err(dd->dev, "unable to alloc pages.\n");
334+
dev_dbg(dd->dev, "unable to alloc pages.\n");
335335
goto err_alloc;
336336
}
337337

338338
/* MAP here */
339339
dd->dma_addr_in = dma_map_single(dd->dev, dd->buf_in,
340340
dd->buflen, DMA_TO_DEVICE);
341-
if (dma_mapping_error(dd->dev, dd->dma_addr_in)) {
342-
dev_err(dd->dev, "dma %zd bytes error\n", dd->buflen);
343-
err = -EINVAL;
341+
err = dma_mapping_error(dd->dev, dd->dma_addr_in);
342+
if (err) {
343+
dev_dbg(dd->dev, "dma %zd bytes error\n", dd->buflen);
344344
goto err_map_in;
345345
}
346346

347347
dd->dma_addr_out = dma_map_single(dd->dev, dd->buf_out,
348348
dd->buflen, DMA_FROM_DEVICE);
349-
if (dma_mapping_error(dd->dev, dd->dma_addr_out)) {
350-
dev_err(dd->dev, "dma %zd bytes error\n", dd->buflen);
351-
err = -EINVAL;
349+
err = dma_mapping_error(dd->dev, dd->dma_addr_out);
350+
if (err) {
351+
dev_dbg(dd->dev, "dma %zd bytes error\n", dd->buflen);
352352
goto err_map_out;
353353
}
354354

@@ -361,8 +361,6 @@ static int atmel_tdes_buff_init(struct atmel_tdes_dev *dd)
361361
err_alloc:
362362
free_page((unsigned long)dd->buf_out);
363363
free_page((unsigned long)dd->buf_in);
364-
if (err)
365-
pr_err("error: %d\n", err);
366364
return err;
367365
}
368366

@@ -514,14 +512,14 @@ static int atmel_tdes_crypt_start(struct atmel_tdes_dev *dd)
514512

515513
err = dma_map_sg(dd->dev, dd->in_sg, 1, DMA_TO_DEVICE);
516514
if (!err) {
517-
dev_err(dd->dev, "dma_map_sg() error\n");
515+
dev_dbg(dd->dev, "dma_map_sg() error\n");
518516
return -EINVAL;
519517
}
520518

521519
err = dma_map_sg(dd->dev, dd->out_sg, 1,
522520
DMA_FROM_DEVICE);
523521
if (!err) {
524-
dev_err(dd->dev, "dma_map_sg() error\n");
522+
dev_dbg(dd->dev, "dma_map_sg() error\n");
525523
dma_unmap_sg(dd->dev, dd->in_sg, 1,
526524
DMA_TO_DEVICE);
527525
return -EINVAL;
@@ -672,7 +670,7 @@ static int atmel_tdes_crypt_dma_stop(struct atmel_tdes_dev *dd)
672670
dd->buf_out, dd->buflen, dd->dma_size, 1);
673671
if (count != dd->dma_size) {
674672
err = -EINVAL;
675-
pr_err("not all data converted: %zu\n", count);
673+
dev_dbg(dd->dev, "not all data converted: %zu\n", count);
676674
}
677675
}
678676
}
@@ -684,35 +682,36 @@ static int atmel_tdes_crypt(struct skcipher_request *req, unsigned long mode)
684682
struct crypto_skcipher *skcipher = crypto_skcipher_reqtfm(req);
685683
struct atmel_tdes_ctx *ctx = crypto_skcipher_ctx(skcipher);
686684
struct atmel_tdes_reqctx *rctx = skcipher_request_ctx(req);
685+
struct device *dev = ctx->dd->dev;
687686

688687
switch (mode & TDES_FLAGS_OPMODE_MASK) {
689688
case TDES_FLAGS_CFB8:
690689
if (!IS_ALIGNED(req->cryptlen, CFB8_BLOCK_SIZE)) {
691-
pr_err("request size is not exact amount of CFB8 blocks\n");
690+
dev_dbg(dev, "request size is not exact amount of CFB8 blocks\n");
692691
return -EINVAL;
693692
}
694693
ctx->block_size = CFB8_BLOCK_SIZE;
695694
break;
696695

697696
case TDES_FLAGS_CFB16:
698697
if (!IS_ALIGNED(req->cryptlen, CFB16_BLOCK_SIZE)) {
699-
pr_err("request size is not exact amount of CFB16 blocks\n");
698+
dev_dbg(dev, "request size is not exact amount of CFB16 blocks\n");
700699
return -EINVAL;
701700
}
702701
ctx->block_size = CFB16_BLOCK_SIZE;
703702
break;
704703

705704
case TDES_FLAGS_CFB32:
706705
if (!IS_ALIGNED(req->cryptlen, CFB32_BLOCK_SIZE)) {
707-
pr_err("request size is not exact amount of CFB32 blocks\n");
706+
dev_dbg(dev, "request size is not exact amount of CFB32 blocks\n");
708707
return -EINVAL;
709708
}
710709
ctx->block_size = CFB32_BLOCK_SIZE;
711710
break;
712711

713712
default:
714713
if (!IS_ALIGNED(req->cryptlen, DES_BLOCK_SIZE)) {
715-
pr_err("request size is not exact amount of DES blocks\n");
714+
dev_dbg(dev, "request size is not exact amount of DES blocks\n");
716715
return -EINVAL;
717716
}
718717
ctx->block_size = DES_BLOCK_SIZE;

0 commit comments

Comments
 (0)