Skip to contentSkip to conversation

Qcom Geni exit path cleanups

PATCH Superseded Andi Shyti 4 participants 7 messages Dec 12, 2024 – Dec 13, 2024

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Andi Shyti

author maintainer
#0 lore raw

v2 cover Qcom Geni exit path cleanups

Hi,

I am submitting two trivial cleanups in this series. The first replaces all instances of dev_err with dev_err_probe throughout the probe function for consistency. The second improves the error exit path by introducing a single 'goto' label for better maintainability.

Thank you Mukesh for your reviews.

Thank you,
Andi

Changelog:
==========
v1 -> v2:
- Updated the final return statement to return 'ret' instead of '0' for consistency. Since 'ret' already holds the value '0', this change is purely aesthetic.
- Renamed the exit label from 'err_off' to 'err_resources' for improved clarity and alignment with its purpose.

Andi Shyti (2):
i2c: qcom-geni: Use dev_err_probe in the probe function
i2c: qcom-geni: Simplify error handling in probe function

 drivers/i2c/busses/i2c-qcom-geni.c | 55 ++++++++++++++----------------
 1 file changed, 26 insertions(+), 29 deletions(-)
Signature · 1 line
2.45.2
author maintainer
#1 lore raw

PATCH v2 1/2 i2c: qcom-geni: Use dev_err_probe in the probe function

Replace classical dev_err with dev_err_probe in the probe function for better error reporting. Also, use dev_err_probe in cases where the error number is clear (e.g., -EIO or -EINVAL) to maintain consistency.

Additionally, remove redundant logging to simplify the code.

---
 drivers/i2c/busses/i2c-qcom-geni.c | 33 +++++++++++++-----------------
 1 file changed, 14 insertions(+), 19 deletions(-)
drivers/i2c/busses/i2c-qcom-geni.c +14 -19
index 7a22e1f46e60..01db24188e29 100644
@@ -823,11 +823,9 @@ static int geni_i2c_probe(struct platform_device *pdev)
 		return gi2c->irq;
 
 	ret = geni_i2c_clk_map_idx(gi2c);
-	if (ret) {
-		dev_err(dev, "Invalid clk frequency %d Hz: %d\n",
-			gi2c->clk_freq_out, ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "Invalid clk frequency %d Hz\n",
+				     gi2c->clk_freq_out);
 
 	gi2c->adap.algo = &geni_i2c_algo;
 	init_completion(&gi2c->done);
@@ -837,11 +835,10 @@ static int geni_i2c_probe(struct platform_device *pdev)
 	/* Keep interrupts disabled initially to allow for low-power modes */
 	ret = devm_request_irq(dev, gi2c->irq, geni_i2c_irq, IRQF_NO_AUTOEN,
 			       dev_name(dev), gi2c);
-	if (ret) {
-		dev_err(dev, "Request_irq failed:%d: err:%d\n",
-			gi2c->irq, ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret,
+				     "Request_irq failed: %d\n", gi2c->irq);
+
 	i2c_set_adapdata(&gi2c->adap, gi2c);
 	gi2c->adap.dev.parent = dev;
 	gi2c->adap.dev.of_node = dev->of_node;
@@ -870,16 +867,14 @@ static int geni_i2c_probe(struct platform_device *pdev)
 
 	ret = geni_se_resources_on(&gi2c->se);
 	if (ret) {
-		dev_err(dev, "Error turning on resources %d\n", ret);
 		clk_disable_unprepare(gi2c->core_clk);
-		return ret;
+		return dev_err_probe(dev, ret, "Error turning on resources\n");
 	}
 	proto = geni_se_read_proto(&gi2c->se);
 	if (proto != GENI_SE_I2C) {
-		dev_err(dev, "Invalid proto %d\n", proto);
 		geni_se_resources_off(&gi2c->se);
 		clk_disable_unprepare(gi2c->core_clk);
-		return -ENXIO;
+		return dev_err_probe(dev, -ENXIO, "Invalid proto %d\n", proto);
 	}
 
 	if (desc && desc->no_dma_support)
@@ -894,7 +889,7 @@ static int geni_i2c_probe(struct platform_device *pdev)
 		if (ret) {
 			geni_se_resources_off(&gi2c->se);
 			clk_disable_unprepare(gi2c->core_clk);
-			return dev_err_probe(dev, ret, "Failed to setup GPI DMA mode\n");
+			return ret;
 		}
 
 		dev_dbg(dev, "Using GPI DMA mode for I2C\n");
@@ -907,10 +902,10 @@ static int geni_i2c_probe(struct platform_device *pdev)
 			tx_depth = desc->tx_fifo_depth;
 
 		if (!tx_depth) {
-			dev_err(dev, "Invalid TX FIFO depth\n");
 			geni_se_resources_off(&gi2c->se);
 			clk_disable_unprepare(gi2c->core_clk);
-			return -EINVAL;
+			return dev_err_probe(dev, -EINVAL,
+					     "Invalid TX FIFO depth\n");
 		}
 
 		gi2c->tx_wm = tx_depth - 1;
@@ -924,7 +919,7 @@ static int geni_i2c_probe(struct platform_device *pdev)
 	clk_disable_unprepare(gi2c->core_clk);
 	ret = geni_se_resources_off(&gi2c->se);
 	if (ret) {
-		dev_err(dev, "Error turning off resources %d\n", ret);
+		dev_err_probe(dev, ret, "Error turning off resources\n");
 		goto err_dma;
 	}
 
@@ -940,7 +935,7 @@ static int geni_i2c_probe(struct platform_device *pdev)
 
 	ret = i2c_add_adapter(&gi2c->adap);
 	if (ret) {
-		dev_err(dev, "Error adding i2c adapter %d\n", ret);
+		dev_err_probe(dev, ret, "Error adding i2c adapter\n");
 		pm_runtime_disable(gi2c->se.dev);
 		goto err_dma;
 	}
Signature · 1 line
2.45.2
Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] i2c: qcom-geni: Use dev_err_probe in the probe function

Quoted 67 lines · Andi Shyti

Replace classical dev_err with dev_err_probe in the probe function for better error reporting. Also, use dev_err_probe in cases where the error number is clear (e.g., -EIO or -EINVAL) to maintain consistency.

Additionally, remove redundant logging to simplify the code.

---
  drivers/i2c/busses/i2c-qcom-geni.c | 33 +++++++++++++-----------------
  1 file changed, 14 insertions(+), 19 deletions(-)
drivers/i2c/busses/i2c-qcom-geni.c +9 -14
index 7a22e1f46e60..01db24188e29 100644
@@ -823,11 +823,9 @@ static int geni_i2c_probe(struct platform_device *pdev)
  		return gi2c->irq;
 
  	ret = geni_i2c_clk_map_idx(gi2c);
-	if (ret) {
-		dev_err(dev, "Invalid clk frequency %d Hz: %d\n",
-			gi2c->clk_freq_out, ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "Invalid clk frequency %d Hz\n",
+				     gi2c->clk_freq_out);
 
  	gi2c->adap.algo = &geni_i2c_algo;
  	init_completion(&gi2c->done);
@@ -837,11 +835,10 @@ static int geni_i2c_probe(struct platform_device *pdev)
  	/* Keep interrupts disabled initially to allow for low-power modes */
  	ret = devm_request_irq(dev, gi2c->irq, geni_i2c_irq, IRQF_NO_AUTOEN,
  			       dev_name(dev), gi2c);
-	if (ret) {
-		dev_err(dev, "Request_irq failed:%d: err:%d\n",
-			gi2c->irq, ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret,
+				     "Request_irq failed: %d\n", gi2c->irq);
+
  	i2c_set_adapdata(&gi2c->adap, gi2c);
  	gi2c->adap.dev.parent = dev;
  	gi2c->adap.dev.of_node = dev->of_node;
@@ -870,16 +867,14 @@ static int geni_i2c_probe(struct platform_device *pdev)
 
  	ret = geni_se_resources_on(&gi2c->se);
  	if (ret) {
-		dev_err(dev, "Error turning on resources %d\n", ret);
  		clk_disable_unprepare(gi2c->core_clk);
-		return ret;
+		return dev_err_probe(dev, ret, "Error turning on resources\n");
  	}
  	proto = geni_se_read_proto(&gi2c->se);
  	if (proto != GENI_SE_I2C) {
-		dev_err(dev, "Invalid proto %d\n", proto);
  		geni_se_resources_off(&gi2c->se);
  		clk_disable_unprepare(gi2c->core_clk);
-		return -ENXIO;
+		return dev_err_probe(dev, -ENXIO, "Invalid proto %d\n", proto);
  	}
 
  	if (desc && desc->no_dma_support)

drivers/i2c/busses/i2c-qcom-geni.c static int geni_i2c_probe(struct platform_device *pdev) · line 892

Quoted 5 lines
drivers/i2c/busses/i2c-qcom-geni.c +1 -1
@@ -894,7 +889,7 @@ static int geni_i2c_probe(struct platform_device *pdev)
  		if (ret) {
  			geni_se_resources_off(&gi2c->se);
  			clk_disable_unprepare(gi2c->core_clk);
-			return dev_err_probe(dev, ret, "Failed to setup GPI DMA mode\n");
+			return ret;

I believe the removal is intentional, since setup_gpi_dma() reports better messages.

Quoted 26 lines
drivers/i2c/busses/i2c-qcom-geni.c +3 -3
  		}
 
  		dev_dbg(dev, "Using GPI DMA mode for I2C\n");
@@ -907,10 +902,10 @@ static int geni_i2c_probe(struct platform_device *pdev)
  			tx_depth = desc->tx_fifo_depth;
 
  		if (!tx_depth) {
-			dev_err(dev, "Invalid TX FIFO depth\n");
  			geni_se_resources_off(&gi2c->se);
  			clk_disable_unprepare(gi2c->core_clk);
-			return -EINVAL;
+			return dev_err_probe(dev, -EINVAL,
+					     "Invalid TX FIFO depth\n");
  		}
 
  		gi2c->tx_wm = tx_depth - 1;
@@ -924,7 +919,7 @@ static int geni_i2c_probe(struct platform_device *pdev)
  	clk_disable_unprepare(gi2c->core_clk);
  	ret = geni_se_resources_off(&gi2c->se);
  	if (ret) {
-		dev_err(dev, "Error turning off resources %d\n", ret);
+		dev_err_probe(dev, ret, "Error turning off resources\n");
  		goto err_dma;
  	}
 

drivers/i2c/busses/i2c-qcom-geni.c static int geni_i2c_probe(struct platform_device *pdev) · line 941

Quoted 8 lines
drivers/i2c/busses/i2c-qcom-geni.c +1 -1
@@ -940,7 +935,7 @@ static int geni_i2c_probe(struct platform_device *pdev)
 
  	ret = i2c_add_adapter(&gi2c->adap);
  	if (ret) {
-		dev_err(dev, "Error adding i2c adapter %d\n", ret);
+		dev_err_probe(dev, ret, "Error adding i2c adapter\n");
  		pm_runtime_disable(gi2c->se.dev);
  		goto err_dma;
  	}

--
Best wishes,
Vladimir

Acked-by on v2 1/2
#3 lore raw

Re: [PATCH v2 1/2] i2c: qcom-geni: Use dev_err_probe in the probe function

In reply to Andi Shyti
Quoted 98 lines · Andi Shyti

Replace classical dev_err with dev_err_probe in the probe function for better error reporting. Also, use dev_err_probe in cases where the error number is clear (e.g., -EIO or -EINVAL) to maintain consistency.

Additionally, remove redundant logging to simplify the code.

---
  drivers/i2c/busses/i2c-qcom-geni.c | 33 +++++++++++++-----------------
  1 file changed, 14 insertions(+), 19 deletions(-)
drivers/i2c/busses/i2c-qcom-geni.c +13 -18
index 7a22e1f46e60..01db24188e29 100644
@@ -823,11 +823,9 @@ static int geni_i2c_probe(struct platform_device *pdev)
  		return gi2c->irq;
 
  	ret = geni_i2c_clk_map_idx(gi2c);
-	if (ret) {
-		dev_err(dev, "Invalid clk frequency %d Hz: %d\n",
-			gi2c->clk_freq_out, ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "Invalid clk frequency %d Hz\n",
+				     gi2c->clk_freq_out);
 
  	gi2c->adap.algo = &geni_i2c_algo;
  	init_completion(&gi2c->done);
@@ -837,11 +835,10 @@ static int geni_i2c_probe(struct platform_device *pdev)
  	/* Keep interrupts disabled initially to allow for low-power modes */
  	ret = devm_request_irq(dev, gi2c->irq, geni_i2c_irq, IRQF_NO_AUTOEN,
  			       dev_name(dev), gi2c);
-	if (ret) {
-		dev_err(dev, "Request_irq failed:%d: err:%d\n",
-			gi2c->irq, ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret,
+				     "Request_irq failed: %d\n", gi2c->irq);
+
  	i2c_set_adapdata(&gi2c->adap, gi2c);
  	gi2c->adap.dev.parent = dev;
  	gi2c->adap.dev.of_node = dev->of_node;
@@ -870,16 +867,14 @@ static int geni_i2c_probe(struct platform_device *pdev)
 
  	ret = geni_se_resources_on(&gi2c->se);
  	if (ret) {
-		dev_err(dev, "Error turning on resources %d\n", ret);
  		clk_disable_unprepare(gi2c->core_clk);
-		return ret;
+		return dev_err_probe(dev, ret, "Error turning on resources\n");
  	}
  	proto = geni_se_read_proto(&gi2c->se);
  	if (proto != GENI_SE_I2C) {
-		dev_err(dev, "Invalid proto %d\n", proto);
  		geni_se_resources_off(&gi2c->se);
  		clk_disable_unprepare(gi2c->core_clk);
-		return -ENXIO;
+		return dev_err_probe(dev, -ENXIO, "Invalid proto %d\n", proto);
  	}
 
  	if (desc && desc->no_dma_support)
@@ -894,7 +889,7 @@ static int geni_i2c_probe(struct platform_device *pdev)
  		if (ret) {
  			geni_se_resources_off(&gi2c->se);
  			clk_disable_unprepare(gi2c->core_clk);
-			return dev_err_probe(dev, ret, "Failed to setup GPI DMA mode\n");
+			return ret;
  		}
 
  		dev_dbg(dev, "Using GPI DMA mode for I2C\n");
@@ -907,10 +902,10 @@ static int geni_i2c_probe(struct platform_device *pdev)
  			tx_depth = desc->tx_fifo_depth;
 
  		if (!tx_depth) {
-			dev_err(dev, "Invalid TX FIFO depth\n");
  			geni_se_resources_off(&gi2c->se);
  			clk_disable_unprepare(gi2c->core_clk);
-			return -EINVAL;
+			return dev_err_probe(dev, -EINVAL,
+					     "Invalid TX FIFO depth\n");
  		}
 
  		gi2c->tx_wm = tx_depth - 1;
@@ -924,7 +919,7 @@ static int geni_i2c_probe(struct platform_device *pdev)
  	clk_disable_unprepare(gi2c->core_clk);
  	ret = geni_se_resources_off(&gi2c->se);
  	if (ret) {
-		dev_err(dev, "Error turning off resources %d\n", ret);
+		dev_err_probe(dev, ret, "Error turning off resources\n");
  		goto err_dma;
  	}
 

drivers/i2c/busses/i2c-qcom-geni.c static int geni_i2c_probe(struct platform_device *pdev) · line 941

Quoted 8 lines
drivers/i2c/busses/i2c-qcom-geni.c +1 -1
@@ -940,7 +935,7 @@ static int geni_i2c_probe(struct platform_device *pdev)
 
  	ret = i2c_add_adapter(&gi2c->adap);
  	if (ret) {
-		dev_err(dev, "Error adding i2c adapter %d\n", ret);
+		dev_err_probe(dev, ret, "Error adding i2c adapter\n");
  		pm_runtime_disable(gi2c->se.dev);
  		goto err_dma;
  	}
author maintainer
#4 lore raw

PATCH v2 2/2 i2c: qcom-geni: Simplify error handling in probe function

In reply to Andi Shyti

Avoid repeating the error handling pattern:

        geni_se_resources_off(&gi2c->se);
        clk_disable_unprepare(gi2c->core_clk);
        return;

Introduce a single 'goto' exit label for cleanup in case of errors. While there are currently two distinct exit points, there is no overlap in their handling, allowing both branches to coexist cleanly.

---
 drivers/i2c/busses/i2c-qcom-geni.c | 32 ++++++++++++++++--------------
 1 file changed, 17 insertions(+), 15 deletions(-)
drivers/i2c/busses/i2c-qcom-geni.c +17 -15
index 01db24188e29..88709b97f86d 100644
@@ -867,14 +867,13 @@ static int geni_i2c_probe(struct platform_device *pdev)
 
 	ret = geni_se_resources_on(&gi2c->se);
 	if (ret) {
-		clk_disable_unprepare(gi2c->core_clk);
-		return dev_err_probe(dev, ret, "Error turning on resources\n");
+		dev_err_probe(dev, ret, "Error turning on resources\n");
+		goto err_clk;
 	}
 	proto = geni_se_read_proto(&gi2c->se);
 	if (proto != GENI_SE_I2C) {
-		geni_se_resources_off(&gi2c->se);
-		clk_disable_unprepare(gi2c->core_clk);
-		return dev_err_probe(dev, -ENXIO, "Invalid proto %d\n", proto);
+		dev_err_probe(dev, -ENXIO, "Invalid proto %d\n", proto);
+		goto err_resources;
 	}
 
 	if (desc && desc->no_dma_support)
@@ -886,11 +885,8 @@ static int geni_i2c_probe(struct platform_device *pdev)
 		/* FIFO is disabled, so we can only use GPI DMA */
 		gi2c->gpi_mode = true;
 		ret = setup_gpi_dma(gi2c);
-		if (ret) {
-			geni_se_resources_off(&gi2c->se);
-			clk_disable_unprepare(gi2c->core_clk);
-			return ret;
-		}
+		if (ret)
+			goto err_resources;
 
 		dev_dbg(dev, "Using GPI DMA mode for I2C\n");
 	} else {
@@ -902,10 +898,8 @@ static int geni_i2c_probe(struct platform_device *pdev)
 			tx_depth = desc->tx_fifo_depth;
 
 		if (!tx_depth) {
-			geni_se_resources_off(&gi2c->se);
-			clk_disable_unprepare(gi2c->core_clk);
-			return dev_err_probe(dev, -EINVAL,
-					     "Invalid TX FIFO depth\n");
+			dev_err_probe(dev, -EINVAL, "Invalid TX FIFO depth\n");
+			goto err_resources;
 		}
 
 		gi2c->tx_wm = tx_depth - 1;
@@ -942,10 +936,18 @@ static int geni_i2c_probe(struct platform_device *pdev)
 
 	dev_dbg(dev, "Geni-I2C adaptor successfully added\n");
 
-	return 0;
+	return ret;
+
+err_resources:
+	geni_se_resources_off(&gi2c->se);
+err_clk:
+	clk_disable_unprepare(gi2c->core_clk);
+
+	return ret;
 
 err_dma:
 	release_gpi_dma(gi2c);
+
 	return ret;
 }
 
Signature · 1 line
2.45.2
#5 lore raw

Re: [PATCH v2 2/2] i2c: qcom-geni: Simplify error handling in probe function

Quoted 26 lines · Andi Shyti

Avoid repeating the error handling pattern:

         geni_se_resources_off(&gi2c->se);
         clk_disable_unprepare(gi2c->core_clk);
         return;

Introduce a single 'goto' exit label for cleanup in case of errors. While there are currently two distinct exit points, there is no overlap in their handling, allowing both branches to coexist cleanly.

---
  drivers/i2c/busses/i2c-qcom-geni.c | 32 ++++++++++++++++--------------
  1 file changed, 17 insertions(+), 15 deletions(-)
drivers/i2c/busses/i2c-qcom-geni.c +0 -2
index 01db24188e29..88709b97f86d 100644
@@ -867,14 +867,13 @@ static int geni_i2c_probe(struct platform_device *pdev)
 
  	ret = geni_se_resources_on(&gi2c->se);
  	if (ret) {
-		clk_disable_unprepare(gi2c->core_clk);
-		return dev_err_probe(dev, ret, "Error turning on resources\n");

drivers/i2c/busses/i2c-qcom-geni.c static int geni_i2c_probe(struct platform_device *pdev) · line 876

Quoted 10 lines
drivers/i2c/busses/i2c-qcom-geni.c +4 -3
+		dev_err_probe(dev, ret, "Error turning on resources\n");
+		goto err_clk;
  	}
  	proto = geni_se_read_proto(&gi2c->se);
  	if (proto != GENI_SE_I2C) {
-		geni_se_resources_off(&gi2c->se);
-		clk_disable_unprepare(gi2c->core_clk);
-		return dev_err_probe(dev, -ENXIO, "Invalid proto %d\n", proto);
+		dev_err_probe(dev, -ENXIO, "Invalid proto %d\n", proto);
+		goto err_resources;

What's about setting ret = -ENXIO before bailing out?

Quoted 18 lines
drivers/i2c/busses/i2c-qcom-geni.c +2 -5
  	}
 
  	if (desc && desc->no_dma_support)
@@ -886,11 +885,8 @@ static int geni_i2c_probe(struct platform_device *pdev)
  		/* FIFO is disabled, so we can only use GPI DMA */
  		gi2c->gpi_mode = true;
  		ret = setup_gpi_dma(gi2c);
-		if (ret) {
-			geni_se_resources_off(&gi2c->se);
-			clk_disable_unprepare(gi2c->core_clk);
-			return ret;
-		}
+		if (ret)
+			goto err_resources;
 
  		dev_dbg(dev, "Using GPI DMA mode for I2C\n");
  	} else {

drivers/i2c/busses/i2c-qcom-geni.c static int geni_i2c_probe(struct platform_device *pdev) · line 902

Quoted 9 lines
drivers/i2c/busses/i2c-qcom-geni.c +2 -4
@@ -902,10 +898,8 @@ static int geni_i2c_probe(struct platform_device *pdev)
  			tx_depth = desc->tx_fifo_depth;
 
  		if (!tx_depth) {
-			geni_se_resources_off(&gi2c->se);
-			clk_disable_unprepare(gi2c->core_clk);
-			return dev_err_probe(dev, -EINVAL,
-					     "Invalid TX FIFO depth\n");
+			dev_err_probe(dev, -EINVAL, "Invalid TX FIFO depth\n");
+			goto err_resources;

Same comment as above.

Quoted 13 lines
drivers/i2c/busses/i2c-qcom-geni.c +5 -1
  		}
 
  		gi2c->tx_wm = tx_depth - 1;
@@ -942,10 +936,18 @@ static int geni_i2c_probe(struct platform_device *pdev)
 
  	dev_dbg(dev, "Geni-I2C adaptor successfully added\n");
 
-	return 0;
+	return ret;
+
+err_resources:
+	geni_se_resources_off(&gi2c->se);
+err_clk:

drivers/i2c/busses/i2c-qcom-geni.c static int geni_i2c_probe(struct platform_device *pdev) · line 953

Quoted 10 lines
drivers/i2c/busses/i2c-qcom-geni.c +4 -0
+	clk_disable_unprepare(gi2c->core_clk);
+
+	return ret;
 
  err_dma:
  	release_gpi_dma(gi2c);
+
  	return ret;
  }
 

--
Best wishes,
Vladimir

author maintainer
#6 lore raw

Re: [PATCH v2 2/2] i2c: qcom-geni: Simplify error handling in probe function

Quoted 9 lines

drivers/i2c/busses/i2c-qcom-geni.c static int geni_i2c_probe(struct platform_device *pdev) · line 876

Quoted 7 lines
  	proto = geni_se_read_proto(&gi2c->se);
  	if (proto != GENI_SE_I2C) {
drivers/i2c/busses/i2c-qcom-geni.c +2 -3
-		geni_se_resources_off(&gi2c->se);
-		clk_disable_unprepare(gi2c->core_clk);
-		return dev_err_probe(dev, -ENXIO, "Invalid proto %d\n", proto);
+		dev_err_probe(dev, -ENXIO, "Invalid proto %d\n", proto);
+		goto err_resources;

What's about setting ret = -ENXIO before bailing out?

Oh yes, sorry, my bad... I snap changed this patch without using my brain. It was better in v1 :-)

Thanks Vladimir,
Andi