Skip to content

Commit 2548c7a

Browse files
opanait-wrherbertx
authored andcommitted
crypto: sahara - use dev_err_probe()
Switch to use dev_err_probe() to simplify the error paths and unify message template. While at it, also remove explicit error messages from every potential -ENOMEM. Signed-off-by: Ovidiu Panait <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 2f8547a commit 2548c7a

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

drivers/crypto/sahara.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,10 +1346,9 @@ static int sahara_probe(struct platform_device *pdev)
13461346

13471347
err = devm_request_irq(&pdev->dev, irq, sahara_irq_handler,
13481348
0, dev_name(&pdev->dev), dev);
1349-
if (err) {
1350-
dev_err(&pdev->dev, "failed to request irq\n");
1351-
return err;
1352-
}
1349+
if (err)
1350+
return dev_err_probe(&pdev->dev, err,
1351+
"failed to request irq\n");
13531352

13541353
/* clocks */
13551354
dev->clk_ipg = devm_clk_get_enabled(&pdev->dev, "ipg");
@@ -1366,41 +1365,33 @@ static int sahara_probe(struct platform_device *pdev)
13661365
dev->hw_desc[0] = dmam_alloc_coherent(&pdev->dev,
13671366
SAHARA_MAX_HW_DESC * sizeof(struct sahara_hw_desc),
13681367
&dev->hw_phys_desc[0], GFP_KERNEL);
1369-
if (!dev->hw_desc[0]) {
1370-
dev_err(&pdev->dev, "Could not allocate hw descriptors\n");
1368+
if (!dev->hw_desc[0])
13711369
return -ENOMEM;
1372-
}
13731370
dev->hw_desc[1] = dev->hw_desc[0] + 1;
13741371
dev->hw_phys_desc[1] = dev->hw_phys_desc[0] +
13751372
sizeof(struct sahara_hw_desc);
13761373

13771374
/* Allocate space for iv and key */
13781375
dev->key_base = dmam_alloc_coherent(&pdev->dev, 2 * AES_KEYSIZE_128,
13791376
&dev->key_phys_base, GFP_KERNEL);
1380-
if (!dev->key_base) {
1381-
dev_err(&pdev->dev, "Could not allocate memory for key\n");
1377+
if (!dev->key_base)
13821378
return -ENOMEM;
1383-
}
13841379
dev->iv_base = dev->key_base + AES_KEYSIZE_128;
13851380
dev->iv_phys_base = dev->key_phys_base + AES_KEYSIZE_128;
13861381

13871382
/* Allocate space for context: largest digest + message length field */
13881383
dev->context_base = dmam_alloc_coherent(&pdev->dev,
13891384
SHA256_DIGEST_SIZE + 4,
13901385
&dev->context_phys_base, GFP_KERNEL);
1391-
if (!dev->context_base) {
1392-
dev_err(&pdev->dev, "Could not allocate memory for MDHA context\n");
1386+
if (!dev->context_base)
13931387
return -ENOMEM;
1394-
}
13951388

13961389
/* Allocate space for HW links */
13971390
dev->hw_link[0] = dmam_alloc_coherent(&pdev->dev,
13981391
SAHARA_MAX_HW_LINK * sizeof(struct sahara_hw_link),
13991392
&dev->hw_phys_link[0], GFP_KERNEL);
1400-
if (!dev->hw_link[0]) {
1401-
dev_err(&pdev->dev, "Could not allocate hw links\n");
1393+
if (!dev->hw_link[0])
14021394
return -ENOMEM;
1403-
}
14041395
for (i = 1; i < SAHARA_MAX_HW_LINK; i++) {
14051396
dev->hw_phys_link[i] = dev->hw_phys_link[i - 1] +
14061397
sizeof(struct sahara_hw_link);
@@ -1431,8 +1422,8 @@ static int sahara_probe(struct platform_device *pdev)
14311422
version = (version >> 8) & 0xff;
14321423
}
14331424
if (err == -ENODEV) {
1434-
dev_err(&pdev->dev, "SAHARA version %d not supported\n",
1435-
version);
1425+
dev_err_probe(&pdev->dev, err,
1426+
"SAHARA version %d not supported\n", version);
14361427
goto err_algs;
14371428
}
14381429

0 commit comments

Comments
 (0)