Skip to contentSkip to conversation

drivers/mmc/host/dw_mmc.c: fix error return code

PATCH Superseded Peter Senna Tschudin 6 participants 12 messages Sep 17, 2012 – Sep 19, 2012

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 drivers/mmc/host/dw_mmc.c: fix error return code

From: Peter Senna Tschudin <[email protected]>

Convert a nonnegative error return code to a negative one, as returned elsewhere in the function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1

    when != &ret

*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>

---
 drivers/mmc/host/dw_mmc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mmc/host/dw_mmc.c +3 -1
index 36f98c0..7ad5176 100644
@@ -2039,8 +2039,10 @@ int dw_mci_probe(struct dw_mci *host)
 	tasklet_init(&host->tasklet, dw_mci_tasklet_func, (unsigned long)host);
 	host->card_workqueue = alloc_workqueue("dw-mci-card",
 			WQ_MEM_RECLAIM | WQ_NON_REENTRANT, 1);
-	if (!host->card_workqueue)
+	if (!host->card_workqueue) {
+		err = -ENOMEM;
 		goto err_dmaunmap;
+	}
 	INIT_WORK(&host->card_work, dw_mci_work_routine_card);
 	ret = request_irq(host->irq, dw_mci_interrupt, host->irq_flags, "dw-mci", host);
 	if (ret)
Signature · 1 line
1.7.11.4
#1 lore raw

PATCH 2/4 drivers/mmc/host/omap.c: fix error return code

From: Peter Senna Tschudin <[email protected]>

Convert a nonnegative error return code to a negative one, as returned elsewhere in the function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1

    when != &ret

*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>

---
 drivers/mmc/host/omap.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/mmc/host/omap.c +6 -2
index 48ad361..d468f51 100644
@@ -1369,8 +1369,10 @@ static int __devinit mmc_omap_probe(struct platform_device *pdev)
 	host->irq = irq;
 	host->phys_base = host->mem_res->start;
 	host->virt_base = ioremap(res->start, resource_size(res));
-	if (!host->virt_base)
+	if (!host->virt_base) {
+		ret = -ENOMEM;
 		goto err_ioremap;
+	}
 
 	host->iclk = clk_get(&pdev->dev, "ick");
 	if (IS_ERR(host->iclk)) {
@@ -1438,8 +1440,10 @@ static int __devinit mmc_omap_probe(struct platform_device *pdev)
 	host->reg_shift = (cpu_is_omap7xx() ? 1 : 2);
 
 	host->mmc_omap_wq = alloc_workqueue("mmc_omap", 0, 0);
-	if (!host->mmc_omap_wq)
+	if (!host->mmc_omap_wq) {
+		err = -ENOMEM;
 		goto err_plat_cleanup;
+	}
 
 	for (i = 0; i < pdata->nr_slots; i++) {
 		ret = mmc_omap_new_slot(host, i);
Signature · 1 line
1.7.11.4
#2 lore raw

PATCH 3/4 drivers/mmc/host/omap_hsmmc.c: fix error return code

In reply to Peter Senna Tschudin

From: Peter Senna Tschudin <[email protected]>

Convert a nonnegative error return code to a negative one, as returned elsewhere in the function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1

    when != &ret

*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>

---
 drivers/mmc/host/omap_hsmmc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/host/omap_hsmmc.c +1 -0
index e59ac62..c8a2b36 100644
@@ -1893,6 +1893,7 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev)
 		if (pdata->init(&pdev->dev) != 0) {
 			dev_dbg(mmc_dev(host->mmc),
 				"Unable to configure MMC IRQs\n");
+			ret = -ENXIO;
 			goto err_irq_cd_init;
 		}
 	}
Signature · 1 line
1.7.11.4
#4 lore raw

PATCH 4/4 drivers/mmc/host/mxs-mmc.c: fix error return code

In reply to Peter Senna Tschudin

From: Peter Senna Tschudin <[email protected]>

Convert a nonnegative error return code to a negative one, as returned elsewhere in the function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1

    when != &ret

*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>

---
 drivers/mmc/host/mxs-mmc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/host/mxs-mmc.c +1 -0
index 80d1e6d..afd8fdd 100644
@@ -674,6 +674,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 	if (!ssp->dmach) {
 		dev_err(mmc_dev(host->mmc),
 			"%s: failed to request dma\n", __func__);
+		ret = -ENODEV;
 		goto out_clk_put;
 	}
 
Signature · 1 line
1.7.11.4
Acked-by on v1 1/4
#7 lore raw
In reply to Peter Senna Tschudin
Quoted 25 lines · Peter Senna Tschudin

From: Peter Senna Tschudin <[email protected]>

Convert a nonnegative error return code to a negative one, as returned elsewhere in the function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1

    when != &ret

*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>

Quoted 1 line
#8 lore raw
In reply to Peter Senna Tschudin
Quoted 35 lines · Peter Senna Tschudin

From: Peter Senna Tschudin <[email protected]>

Convert a nonnegative error return code to a negative one, as returned elsewhere in the function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1

    when != &ret

*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>

---
 drivers/mmc/host/dw_mmc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mmc/host/dw_mmc.c +0 -0
index 36f98c0..7ad5176 100644

drivers/mmc/host/dw_mmc.c int dw_mci_probe(struct dw_mci *host) · line 2043

Quoted 6 lines
drivers/mmc/host/dw_mmc.c +2 -1
@@ -2039,8 +2039,10 @@ int dw_mci_probe(struct dw_mci *host)
 	tasklet_init(&host->tasklet, dw_mci_tasklet_func, (unsigned long)host);
 	host->card_workqueue = alloc_workqueue("dw-mci-card",
 			WQ_MEM_RECLAIM | WQ_NON_REENTRANT, 1);
-	if (!host->card_workqueue)
+	if (!host->card_workqueue) {
+		err = -ENOMEM;

ret is expected instead of err.
err isn't defined.

Thanks,
Seungwon Jeon

Quoted 7 lines
drivers/mmc/host/dw_mmc.c +1 -1
 		goto err_dmaunmap;
+	}
 	INIT_WORK(&host->card_work, dw_mci_work_routine_card);
 	ret = request_irq(host->irq, dw_mci_interrupt, host->irq_flags, "dw-mci", host);
 	if (ret)
--

1.7.11.4

Acked-by on v1 4/4
#5 lore raw

Re: [PATCH 4/4] drivers/mmc/host/mxs-mmc.c: fix error return code

In reply to Peter Senna Tschudin

Dear Peter Senna Tschudin,

Quoted 1 line

From: Peter Senna Tschudin <[email protected]>

The patch description is a bit crap, but otherwise

Quoted 33 lines

Convert a nonnegative error return code to a negative one, as returned elsewhere in the function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }

ret@p1 = 0
)
... when != ret = e1

    when != &ret

*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>

---
 drivers/mmc/host/mxs-mmc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/host/mxs-mmc.c +0 -0
index 80d1e6d..afd8fdd 100644

drivers/mmc/host/mxs-mmc.c static int mxs_mmc_probe(struct platform_device *pdev) · line 679

Quoted 6 lines
drivers/mmc/host/mxs-mmc.c +1 -0
@@ -674,6 +674,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 	if (!ssp->dmach) {
 		dev_err(mmc_dev(host->mmc),
 			"%s: failed to request dma\n", __func__);
+		ret = -ENODEV;
 		goto out_clk_put;
 	}

Best regards,
Marek Vasut

#9 lore raw
In reply to Seungwon Jeon
Quoted 31 lines · Seungwon Jeon
Quoted 30 lines · Peter Senna Tschudin

From: Peter Senna Tschudin <[email protected]>

Convert a nonnegative error return code to a negative one, as returned elsewhere in the function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1

    when != &ret

*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>

---
 drivers/mmc/host/dw_mmc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 13 lines

drivers/mmc/host/dw_mmc.c int dw_mci_probe(struct dw_mci *host) · line 2043

Quoted 11 lines
drivers/mmc/host/dw_mmc.c +2 -1
index 36f98c0..7ad5176 100644
@@ -2039,8 +2039,10 @@ int dw_mci_probe(struct dw_mci *host)
      tasklet_init(&host->tasklet, dw_mci_tasklet_func, (unsigned long)host);
      host->card_workqueue = alloc_workqueue("dw-mci-card",
                      WQ_MEM_RECLAIM | WQ_NON_REENTRANT, 1);
-     if (!host->card_workqueue)
+     if (!host->card_workqueue) {
+             err = -ENOMEM;

ret is expected instead of err.
err isn't defined.

I'm sorry. Somehow I did not compile for testing this one before sending. I'll fix, test and resend.

Quoted 16 lines

Thanks,
Seungwon Jeon

Quoted 7 lines
drivers/mmc/host/dw_mmc.c +1 -1
              goto err_dmaunmap;
+     }
      INIT_WORK(&host->card_work, dw_mci_work_routine_card);
      ret = request_irq(host->irq, dw_mci_interrupt, host->irq_flags, "dw-mci", host);
      if (ret)
--

1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 1 line
Peter
#10 lore raw

PATCH v2 1/4 drivers/mmc/host/dw_mmc.c: fix error return code

In reply to Peter Senna Tschudin

From: Peter Senna Tschudin <[email protected]>

Convert a nonnegative error return code to a negative one, as returned elsewhere in the function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1

    when != &ret

*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>

---
 drivers/mmc/host/dw_mmc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mmc/host/dw_mmc.c +3 -1
index 36f98c0..43a2663 100644
@@ -2039,8 +2039,10 @@ int dw_mci_probe(struct dw_mci *host)
 	tasklet_init(&host->tasklet, dw_mci_tasklet_func, (unsigned long)host);
 	host->card_workqueue = alloc_workqueue("dw-mci-card",
 			WQ_MEM_RECLAIM | WQ_NON_REENTRANT, 1);
-	if (!host->card_workqueue)
+	if (!host->card_workqueue) {
+		ret = -ENOMEM;
 		goto err_dmaunmap;
+	}
 	INIT_WORK(&host->card_work, dw_mci_work_routine_card);
 	ret = request_irq(host->irq, dw_mci_interrupt, host->irq_flags, "dw-mci", host);
 	if (ret)
Signature · 1 line
1.7.11.4
Acked-by on v1 3/4
#3 lore raw

Re: [PATCH 3/4] drivers/mmc/host/omap_hsmmc.c: fix error return code

In reply to Peter Senna Tschudin
Quoted 25 lines · Peter Senna Tschudin

From: Peter Senna Tschudin <[email protected]>

Convert a nonnegative error return code to a negative one, as returned elsewhere in the function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1

    when != &ret

*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>

Quoted 1 line

Looks good.

Acked-by on v2 1/4
#11 lore raw
In reply to Peter Senna Tschudin
Quoted 25 lines · Peter Senna Tschudin

From: Peter Senna Tschudin <[email protected]>

Convert a nonnegative error return code to a negative one, as returned elsewhere in the function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1

    when != &ret

*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>

Quoted 1 line

Looks good.

Quoted 2 lines

--
1.7.11.4

Acked-by on v1 4/4
#6 lore raw

Re: [PATCH 4/4] drivers/mmc/host/mxs-mmc.c: fix error return code

In reply to Peter Senna Tschudin
Quoted 25 lines · Peter Senna Tschudin

From: Peter Senna Tschudin <[email protected]>

Convert a nonnegative error return code to a negative one, as returned elsewhere in the function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1

    when != &ret

*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>

Quoted 1 line
Quoted 19 lines
---
 drivers/mmc/host/mxs-mmc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/host/mxs-mmc.c +1 -0
index 80d1e6d..afd8fdd 100644
@@ -674,6 +674,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 	if (!ssp->dmach) {
 		dev_err(mmc_dev(host->mmc),
 			"%s: failed to request dma\n", __func__);
+		ret = -ENODEV;
 		goto out_clk_put;
 	}
 
Signature · 1 line
1.7.11.4