Skip to contentSkip to conversation

dma: imx-sdma: Add error check on sdma_get_firmware

PATCH In review Fabio Estevam 2 participants 3 messages Feb 20, 2012 – Feb 29, 2012

Subsystems (2)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH 1/1 dma: imx-sdma: Add error check on sdma_get_firmware

Add error check on sdma_get_firmware for the pdata case.

While at it, distinguish the error message between the pdata and dt cases.

---
 drivers/dma/imx-sdma.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/dma/imx-sdma.c +6 -2
index bf736ad..52a4e6a 100644
@@ -1388,7 +1388,11 @@ static int __init sdma_probe(struct platform_device *pdev)
 		sdma_add_scripts(sdma, pdata->script_addrs);
 
 	if (pdata) {
-		sdma_get_firmware(sdma, pdata->fw_name);
+		ret = sdma_get_firmware(sdma, pdata->fw_name);
+		if (ret) {
+			dev_err(&pdev->dev, "failed to get firmware from pdata\n");
+			goto err_init;
+		}
 	} else {
 		/*
 		 * Because that device tree does not encode ROM script address,
@@ -1404,7 +1408,7 @@ static int __init sdma_probe(struct platform_device *pdev)
 
 		ret = sdma_get_firmware(sdma, fw_name);
 		if (ret) {
-			dev_err(&pdev->dev, "failed to get firmware\n");
+			dev_err(&pdev->dev, "failed to get firmware from DT\n");
 			goto err_init;
 		}
 	}
Signature · 1 line
1.7.1
maintainer
#1 lore raw
Quoted 14 lines · Fabio Estevam

Add error check on sdma_get_firmware for the pdata case.

While at it, distinguish the error message between the pdata and dt cases.

---
 drivers/dma/imx-sdma.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/dma/imx-sdma.c +0 -0
index bf736ad..52a4e6a 100644

drivers/dma/imx-sdma.c static int __init sdma_probe(struct platform_device *pdev) · line 1395

Quoted 9 lines
drivers/dma/imx-sdma.c +5 -1
@@ -1388,7 +1388,11 @@ static int __init sdma_probe(struct platform_device *pdev)
 		sdma_add_scripts(sdma, pdata->script_addrs);
 
 	if (pdata) {
-		sdma_get_firmware(sdma, pdata->fw_name);
+		ret = sdma_get_firmware(sdma, pdata->fw_name);
+		if (ret) {
+			dev_err(&pdev->dev, "failed to get firmware from pdata\n");
+			goto err_init;
+		}

No, you shouldn't bail out here. A failure in sdma_get_firmware only means that we don't have the RAM scripts, but we can continue with the ROM scripts and still do useful things in the driver.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
author reviewer
#2 lore raw

On Wed, Feb 29, 2012 at 5:38 AM, Sascha Hauer <[email protected]> wrote:
...

Quoted 7 lines
Quoted 7 lines
drivers/dma/imx-sdma.c +0 -0
index bf736ad..52a4e6a 100644
@@ -1388,7 +1388,11 @@ static int __init sdma_probe(struct platform_device *pdev)
               sdma_add_scripts(sdma, pdata->script_addrs);
 
Quoted 11 lines

drivers/dma/imx-sdma.c static int __init sdma_probe(struct platform_device *pdev) · line 1395

Quoted 7 lines
drivers/dma/imx-sdma.c +5 -1
       if (pdata) {
-             sdma_get_firmware(sdma, pdata->fw_name);
+             ret = sdma_get_firmware(sdma, pdata->fw_name);
+             if (ret) {
+                     dev_err(&pdev->dev, "failed to get firmware from pdata\n");
+                     goto err_init;
+             }

No, you shouldn't bail out here. A failure in sdma_get_firmware only means that we don't have the RAM scripts, but we can continue with the ROM scripts and still do useful things in the driver.

Ok, the dt case also does a "goto err_init" and I just followed it on the pdata case.

So I plan to do the following:

1. Send a patch for removing the "goto err_init" from the sdma_get_firmware error check in the dt case
2. Send a patch that adds the error check for the pdata case.

Regards,

Fabio Estevam