Skip to contentSkip to conversation

pwm: omap-dmtimer: Add missing put_device() call in pwm_omap_dmtimer_probe()

PATCH In review Markus Elfring 2 participants 23 messages Nov 9, 2019 – Nov 12, 2019

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

PATCH 1/1 pwm: omap-dmtimer: Add missing put_device() call in pwm_omap_dmtimer_probe()

From: Markus Elfring <[email protected]>
Date: Sat, 9 Nov 2019 13:09:42 +0100

A coccicheck run provided information like the following.

drivers/pwm/pwm-omap-dmtimer.c:304:2-8: ERROR: missing put_device; call of_find_device_by_node on line 255, but without a corresponding object release within this function.

Generated by: scripts/coccinelle/free/put_device.cocci

Thus add jump targets to fix the exception handling for this function implementation.

Fixes b7290cf6ff7869ec12070aa146c370728cab62c2 ("pwm: pwm-omap-dmtimer: Adapt driver to utilize dmtimer pdata ops")
Fixes 6604c6556db9e41c85f2839f66bd9d617bcf9f87 ("pwm: Add PWM driver for OMAP using dual-mode timers")
---
 drivers/pwm/pwm-omap-dmtimer.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/pwm/pwm-omap-dmtimer.c +11 -3
index 00772fc53490..958854213786 100644
@@ -301,12 +301,13 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
 put:
 	of_node_put(timer);
 	if (ret < 0)
-		return ret;
+		goto check_timer_pdev;
 
 	omap = devm_kzalloc(&pdev->dev, sizeof(*omap), GFP_KERNEL);
 	if (!omap) {
 		pdata->free(dm_timer);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto put_device;
 	}
 
 	omap->pdata = pdata;
@@ -340,12 +341,19 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to register PWM\n");
 		omap->pdata->free(omap->dm_timer);
-		return ret;
+		goto put_device;
 	}
 
 	platform_set_drvdata(pdev, omap);
 
 	return 0;
+
+check_timer_pdev:
+	if (timer_pdev)
+put_device:
+		put_device(&timer_pdev->dev);
+
+	return ret;
 }
 
 static int pwm_omap_dmtimer_remove(struct platform_device *pdev)

--
2.24.0

#1 lore raw

Hello Markus,

Quoted 47 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 9 Nov 2019 13:09:42 +0100

A coccicheck run provided information like the following.

drivers/pwm/pwm-omap-dmtimer.c:304:2-8: ERROR: missing put_device; call of_find_device_by_node on line 255, but without a corresponding object release within this function.

Generated by: scripts/coccinelle/free/put_device.cocci

Thus add jump targets to fix the exception handling for this function implementation.

Fixes b7290cf6ff7869ec12070aa146c370728cab62c2 ("pwm: pwm-omap-dmtimer: Adapt driver to utilize dmtimer pdata ops")
Fixes 6604c6556db9e41c85f2839f66bd9d617bcf9f87 ("pwm: Add PWM driver for OMAP using dual-mode timers")
---
 drivers/pwm/pwm-omap-dmtimer.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/pwm/pwm-omap-dmtimer.c +4 -3
index 00772fc53490..958854213786 100644
@@ -301,12 +301,13 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
 put:
 	of_node_put(timer);
 	if (ret < 0)
-		return ret;
+		goto check_timer_pdev;
 
 	omap = devm_kzalloc(&pdev->dev, sizeof(*omap), GFP_KERNEL);
 	if (!omap) {
 		pdata->free(dm_timer);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto put_device;
 	}
 
 	omap->pdata = pdata;
@@ -340,12 +341,19 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to register PWM\n");
 		omap->pdata->free(omap->dm_timer);
-		return ret;
+		goto put_device;

drivers/pwm/pwm-omap-dmtimer.c static int pwm_omap_dmtimer_probe(struct platform_device *pdev) · line 354

Quoted 10 lines
drivers/pwm/pwm-omap-dmtimer.c +5 -0
 	}
 
 	platform_set_drvdata(pdev, omap);
 
 	return 0;
+
+check_timer_pdev:
+	if (timer_pdev)
+put_device:
+		put_device(&timer_pdev->dev);

This is ugly but necessary with the driver as is because the error handling is interwinded within the normal path through this function.

I would prefer to clean this up first, then this fix gets a bit nicer. Will send a patch in reply to this mail.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
#2 lore raw

PATCH 1/4 pwm: omap-dmtimer: remove pwmchip in .remove before making it unfunctional

In the old code (e.g.) mutex_destroy() was called before pwmchip_remove(). Between these two calls it is possible that a pwm callback is used which tries to grab the mutex.

Fixes 6604c6556db9 ("pwm: Add PWM driver for OMAP using dual-mode timers")
---
 drivers/pwm/pwm-omap-dmtimer.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/pwm/pwm-omap-dmtimer.c +6 -1
index 00772fc53490..bdf94c78655f 100644
@@ -351,6 +351,11 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
 static int pwm_omap_dmtimer_remove(struct platform_device *pdev)
 {
 	struct pwm_omap_dmtimer_chip *omap = platform_get_drvdata(pdev);
+	int ret;
+
+	ret = pwmchip_remove(&omap->chip);
+	if (ret)
+		return ret;
 
 	if (pm_runtime_active(&omap->dm_timer_pdev->dev))
 		omap->pdata->stop(omap->dm_timer);
@@ -359,7 +364,7 @@ static int pwm_omap_dmtimer_remove(struct platform_device *pdev)
 
 	mutex_destroy(&omap->mutex);
 
-	return pwmchip_remove(&omap->chip);
+	return 0;
 }
 
 static const struct of_device_id pwm_omap_dmtimer_of_match[] = {
Signature · 1 line
2.23.0
#3 lore raw

Re: [PATCH 1/4] pwm: omap-dmtimer: remove pwmchip in .remove before making it unfunctional

Hello,

I created a cover letter but failed to send it together with the series :-|

It said:

| I promised a cleanup patch but as I found a few more issues I have four
| patches now. The third patch replaces Markus' patch with a more complete
| fix that also drops the reference in .remove not only the error path of
| .probe.
| 
| The last patch allows to compile the driver in more configurations, it
| compiled successfully on amd64 and arm.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
#4 lore raw

Re: [0/4] pwm: omap-dmtimer: Software improvements

Quoted 2 lines

I created a cover letter but failed to send it together with the series :-|

Did you omit the address “[email protected]” from the recipient list intentionally?

Regards,
Markus

#6 lore raw

Re: [0/4] pwm: omap-dmtimer: Software improvements

Quoted 5 lines · Markus Elfring
Quoted 2 lines

I created a cover letter but failed to send it together with the series :-|

Did you omit the address “[email protected]” from the recipient list intentionally?

Yes, even though it's documented to Cc: all patches there, there is IMHO little use. If there is a dedicated mailing list, not adding lkml is fine for all maintainers I interacted with in the last few years.

The volume on lkml is that high that sending all patches there only adds noise.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
#7 lore raw

Re: [PATCH 1/4] pwm: omap-dmtimer: remove pwmchip in .remove before making it unfunctional

In reply to Uwe Kleine-König
Quoted 3 lines

In the old code (e.g.) mutex_destroy() was called before pwmchip_remove(). Between these two calls it is possible that a pwm callback is used which tries to grab the mutex.

How do you think about to add a more “imperative mood” for your change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=31f4f5b495a62c9a8b15b1c3581acd5efeb9af8c#n151

drivers/pwm/pwm-omap-dmtimer.c static int pwm_omap_dmtimer_probe(struct platform_device *pdev) · line 361

Quoted 13 lines

+++ b/drivers/pwm/pwm-omap-dmtimer.c

drivers/pwm/pwm-omap-dmtimer.c +5 -0
@@ -351,6 +351,11 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
 static int pwm_omap_dmtimer_remove(struct platform_device *pdev)
 {
 	struct pwm_omap_dmtimer_chip *omap = platform_get_drvdata(pdev);
+	int ret;
+
+	ret = pwmchip_remove(&omap->chip);
+	if (ret)
+		return ret;
 
 	if (pm_runtime_active(&omap->dm_timer_pdev->dev))
 		omap->pdata->stop(omap->dm_timer);

How do you think about to use the following statement variant?

+ int ret = pwmchip_remove(&omap->chip);

Regards,
Markus

#8 lore raw

Re: [PATCH 1/4] pwm: omap-dmtimer: remove pwmchip in .remove before making it unfunctional

Hello Markus,

Quoted 7 lines · Markus Elfring
Quoted 3 lines

In the old code (e.g.) mutex_destroy() was called before pwmchip_remove(). Between these two calls it is possible that a pwm callback is used which tries to grab the mutex.

How do you think about to add a more “imperative mood” for your change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id1f4f5b495a62c9a8b15b1c3581acd5efeb9af8c#n151

I described the old behaviour and like my wording.

Quoted 16 lines

drivers/pwm/pwm-omap-dmtimer.c static int pwm_omap_dmtimer_probe(struct platform_device *pdev) · line 361

Quoted 13 lines

+++ b/drivers/pwm/pwm-omap-dmtimer.c

drivers/pwm/pwm-omap-dmtimer.c +5 -0
@@ -351,6 +351,11 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
 static int pwm_omap_dmtimer_remove(struct platform_device *pdev)
 {
 	struct pwm_omap_dmtimer_chip *omap = platform_get_drvdata(pdev);
+	int ret;
+
+	ret = pwmchip_remove(&omap->chip);
+	if (ret)
+		return ret;
 
 	if (pm_runtime_active(&omap->dm_timer_pdev->dev))
 		omap->pdata->stop(omap->dm_timer);

How do you think about to use the following statement variant?

Review

Quoted 1 line
(quoted diff) +1 -0
+	int ret = pwmchip_remove(&omap->chip);

I think that between the declarations and code should be an empty line and between the assignment to ret and the respective check there shouldn't be one.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
#9 lore raw

Re: [1/4] pwm: omap-dmtimer: remove pwmchip in .remove before making it unfunctional

Quoted 9 lines
Quoted 7 lines
Quoted 3 lines

In the old code (e.g.) mutex_destroy() was called before pwmchip_remove(). Between these two calls it is possible that a pwm callback is used which tries to grab the mutex.

How do you think about to add a more “imperative mood” for your change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=31f4f5b495a62c9a8b15b1c3581acd5efeb9af8c#n151

I described the old behaviour and like my wording.

I find that the first paragraph contains useful information. Would you like to specify any corresponding actions then at this place?

Regards,
Markus

#10 lore raw

PATCH 2/4 pwm: omap-dmtimer: simplify error handling

Instead of doing error handling in the middle of pwm_omap_dmtimer_probe() move error handling and freeing the reference to timer to the end.

This fixes a resource leak as dm_timer wasn't freed when allocating *omap failed.

Implementation note: The put: label was never reached without a goto and ret being unequal to 0, so the removed return statement is fine.

Fixes 6604c6556db9 ("pwm: Add PWM driver for OMAP using dual-mode timers")
---
 drivers/pwm/pwm-omap-dmtimer.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)
drivers/pwm/pwm-omap-dmtimer.c +19 -9
index bdf94c78655f..e36fcad668a6 100644
@@ -298,15 +298,10 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
 		goto put;
 	}
 
-put:
-	of_node_put(timer);
-	if (ret < 0)
-		return ret;
-
 	omap = devm_kzalloc(&pdev->dev, sizeof(*omap), GFP_KERNEL);
 	if (!omap) {
-		pdata->free(dm_timer);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto err_alloc_omap;
 	}
 
 	omap->pdata = pdata;
@@ -339,13 +334,28 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
 	ret = pwmchip_add(&omap->chip);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to register PWM\n");
-		omap->pdata->free(omap->dm_timer);
-		return ret;
+		goto err_pwmchip_add;
 	}
 
+	of_node_put(timer);
+
 	platform_set_drvdata(pdev, omap);
 
 	return 0;
+
+err_pwmchip_add:
+
+	/*
+	 * *omap is allocated using devm_kzalloc,
+	 * so no free necessary here
+	 */
+err_alloc_omap:
+
+	pdata->free(dm_timer);
+put:
+	of_node_put(timer);
+
+	return ret;
 }
 
 static int pwm_omap_dmtimer_remove(struct platform_device *pdev)
Signature · 1 line
2.23.0
#11 lore raw

Re: [PATCH 2/4] pwm: omap-dmtimer: simplify error handling

Quoted 2 lines

Implementation note: The put: label was never reached without a goto and ret being unequal to 0, so the removed return statement is fine.

This can look fine (in principle) because the label was repositioned here. Do you really want to call the function “of_node_put” at two places now?

Quoted 1 line

+++ b/drivers/pwm/pwm-omap-dmtimer.c

…

drivers/pwm/pwm-omap-dmtimer.c static int pwm_omap_dmtimer_probe(struct platform_device *pdev) · line 305

Quoted 7 lines
drivers/pwm/pwm-omap-dmtimer.c +2 -2
 	omap = devm_kzalloc(&pdev->dev, sizeof(*omap), GFP_KERNEL);
 	if (!omap) {
-		pdata->free(dm_timer);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto err_alloc_omap;
 	}

…

I suggest to reconsider your label name selection according to the Linux coding style.

Quoted 1 line
(quoted diff) +0 -0
@@ -339,13 +334,28 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)

…

drivers/pwm/pwm-omap-dmtimer.c static int pwm_omap_dmtimer_probe(struct platform_device *pdev) · line 354

Quoted 9 lines
drivers/pwm/pwm-omap-dmtimer.c +9 -0
+err_pwmchip_add:
+
+	/*
+	 * *omap is allocated using devm_kzalloc,
+	 * so no free necessary here
+	 */
+err_alloc_omap:
+
+	pdata->free(dm_timer);

Would the use of the label “free_dm_timer” be more appropriate?

drivers/pwm/pwm-omap-dmtimer.c static int pwm_omap_dmtimer_probe(struct platform_device *pdev) · line 356

Quoted 2 lines
drivers/pwm/pwm-omap-dmtimer.c +2 -0
+put:
+	of_node_put(timer);

…

Can the label “put_node” be nicer?

Regards,
Markus

#12 lore raw

Re: [PATCH 2/4] pwm: omap-dmtimer: simplify error handling

Quoted 5 lines · Markus Elfring
Quoted 2 lines

Implementation note: The put: label was never reached without a goto and ret being unequal to 0, so the removed return statement is fine.

This can look fine (in principle) because the label was repositioned here. Do you really want to call the function “of_node_put” at two places now?

Yes, this is in my eyes more sensible. Either you have the expected path and the error path interwinded, or you have to duplicate some cleanup. IMHO the latter variant is the one that is easier to understand and the one where it's less likely to oversee a needed cleanup.

Quoted 11 lines
Quoted 1 line

+++ b/drivers/pwm/pwm-omap-dmtimer.c

…

Quoted 7 lines
drivers/pwm/pwm-omap-dmtimer.c +2 -2
 	omap = devm_kzalloc(&pdev->dev, sizeof(*omap), GFP_KERNEL);
 	if (!omap) {
-		pdata->free(dm_timer);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto err_alloc_omap;
 	}

…

Quoted 2 lines

I suggest to reconsider your label name selection according to the Linux coding style.

Documentation/process/coding-style.rst states: "Choose label names which say what the goto does or why the goto exists." So I'd say my names are perfectly fine.

Quoted 13 lines
Quoted 1 line
(quoted diff) +0 -0
@@ -339,13 +334,28 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)

…

drivers/pwm/pwm-omap-dmtimer.c static int pwm_omap_dmtimer_probe(struct platform_device *pdev) · line 354

Quoted 9 lines
drivers/pwm/pwm-omap-dmtimer.c +9 -0
+err_pwmchip_add:
+
+	/*
+	 * *omap is allocated using devm_kzalloc,
+	 * so no free necessary here
+	 */
+err_alloc_omap:
+
+	pdata->free(dm_timer);

Would the use of the label “free_dm_timer” be more appropriate?

Either you name your labels after what the code at the label does (then "free_dm_timer" is good) or you name it after why you are here (and then err_alloc_omap is fine). I prefer the latter style and then the label name always has to correspond to the action just above it (if any). That's why I grouped the "err_alloc_omap" label to a comment saying that *omap doesn't need to be freed.

Quoted 5 lines

drivers/pwm/pwm-omap-dmtimer.c static int pwm_omap_dmtimer_probe(struct platform_device *pdev) · line 356

Quoted 2 lines
drivers/pwm/pwm-omap-dmtimer.c +2 -0
+put:
+	of_node_put(timer);

…

Can the label “put_node” be nicer?

I agree that the label name is bad. I kept the name here and after the 3rd patch the label names are consistent.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
#13 lore raw

Re: [PATCH 2/4] pwm: omap-dmtimer: simplify error handling

Quoted 3 lines
Quoted 1 line

Do you really want to call the function “of_node_put” at two places now?

Yes, this is in my eyes more sensible.

Thanks for this explanation.

Quoted 2 lines

Either you have the expected path and the error path interwinded, and the error path interwinded,

This is also reasonable then.
This design approach provides the possibility to release a few resources earlier before using additional functionality.

Quoted 1 line

or you have to duplicate some cleanup.

* This can be required.

* I imagine that specific software infrastructures can help to avoid such duplication, can't they?

Quoted 2 lines

IMHO the latter variant is the one that is easier to understand and the one where it's less likely to oversee a needed cleanup.

I am curious on how the clarification will be continued.

Quoted 11 lines
Quoted 11 lines
Quoted 1 line

+++ b/drivers/pwm/pwm-omap-dmtimer.c

…

Quoted 7 lines
drivers/pwm/pwm-omap-dmtimer.c +2 -2
 	omap = devm_kzalloc(&pdev->dev, sizeof(*omap), GFP_KERNEL);
 	if (!omap) {
-		pdata->free(dm_timer);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto err_alloc_omap;
 	}

…

Quoted 6 lines
Quoted 2 lines

I suggest to reconsider your label name selection according to the Linux coding style.

Documentation/process/coding-style.rst states: "Choose label names which say what the goto does or why the goto exists." So I'd say my names are perfectly fine.

The guidance from the example after this quotation might be still too terse so far, isn't it?

Quoted 14 lines
Quoted 13 lines
Quoted 1 line
(quoted diff) +0 -0
@@ -339,13 +334,28 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)

…

drivers/pwm/pwm-omap-dmtimer.c static int pwm_omap_dmtimer_probe(struct platform_device *pdev) · line 354

Quoted 9 lines
drivers/pwm/pwm-omap-dmtimer.c +9 -0
+err_pwmchip_add:
+
+	/*
+	 * *omap is allocated using devm_kzalloc,
+	 * so no free necessary here
+	 */
+err_alloc_omap:
+
+	pdata->free(dm_timer);

Would the use of the label “free_dm_timer” be more appropriate?

Quoted 2 lines

Either you name your labels after what the code at the label does (then "free_dm_timer" is good)

I got used to this approach.

Quoted 1 line

you name it after why you are here (and then err_alloc_omap is fine).

This choice can trigger special software design consequences.

Quoted 4 lines

I prefer the latter style and then the label
name always has to correspond to the action just above it (if any). That's why I grouped the "err_alloc_omap" label to a comment saying that *omap doesn't need to be freed.

I am also curious if any other contributors would like to share more views around this choice.

Quoted 7 lines
Quoted 5 lines

drivers/pwm/pwm-omap-dmtimer.c static int pwm_omap_dmtimer_probe(struct platform_device *pdev) · line 356

Quoted 2 lines
drivers/pwm/pwm-omap-dmtimer.c +2 -0
+put:
+	of_node_put(timer);

…

Can the label “put_node” be nicer?

I agree that the label name is bad.

I find your agreement on this aspect interesting then.

Quoted 1 line

I kept the name here and after the 3rd patch the label names are consistent.

Can such an evolution be questionable?

Regards,
Markus

#14 lore raw

PATCH 3/4 pwm: omap-dmtimer: put_device() after of_find_device_by_node()

This was found by coccicheck:

drivers/pwm/pwm-omap-dmtimer.c:304:2-8: ERROR: missing put_device; call of_find_device_by_node on line 255, but without a corresponding object release within this function.

Fixes 6604c6556db9 ("pwm: Add PWM driver for OMAP using dual-mode timers")
---
 drivers/pwm/pwm-omap-dmtimer.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/pwm/pwm-omap-dmtimer.c +15 -6
index e36fcad668a6..88a3c5690fea 100644
@@ -256,7 +256,7 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
 	if (!timer_pdev) {
 		dev_err(&pdev->dev, "Unable to find Timer pdev\n");
 		ret = -ENODEV;
-		goto put;
+		goto err_find_timer_pdev;
 	}
 
 	timer_pdata = dev_get_platdata(&timer_pdev->dev);
@@ -264,7 +264,7 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
 		dev_dbg(&pdev->dev,
 			 "dmtimer pdata structure NULL, deferring probe\n");
 		ret = -EPROBE_DEFER;
-		goto put;
+		goto err_platdata;
 	}
 
 	pdata = timer_pdata->timer_ops;
@@ -283,19 +283,19 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
 	    !pdata->write_counter) {
 		dev_err(&pdev->dev, "Incomplete dmtimer pdata structure\n");
 		ret = -EINVAL;
-		goto put;
+		goto err_platdata;
 	}
 
 	if (!of_get_property(timer, "ti,timer-pwm", NULL)) {
 		dev_err(&pdev->dev, "Missing ti,timer-pwm capability\n");
 		ret = -ENODEV;
-		goto put;
+		goto err_timer_property;
 	}
 
 	dm_timer = pdata->request_by_node(timer);
 	if (!dm_timer) {
 		ret = -EPROBE_DEFER;
-		goto put;
+		goto err_request_timer;
 	}
 
 	omap = devm_kzalloc(&pdev->dev, sizeof(*omap), GFP_KERNEL);
@@ -352,7 +352,14 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
 err_alloc_omap:
 
 	pdata->free(dm_timer);
-put:
+err_request_timer:
+
+err_timer_property:
+err_platdata:
+
+	put_device(&timer_pdev->dev);
+err_find_timer_pdev:
+
 	of_node_put(timer);
 
 	return ret;
@@ -372,6 +379,8 @@ static int pwm_omap_dmtimer_remove(struct platform_device *pdev)
 
 	omap->pdata->free(omap->dm_timer);
 
+	put_device(&omap->dm_timer_pdev->dev);
+
 	mutex_destroy(&omap->mutex);
 
 	return 0;
Signature · 1 line
2.23.0
#15 lore raw

Re: [PATCH 3/4] pwm: omap-dmtimer: put_device() after of_find_device_by_node()

Quoted 5 lines

This was found by coccicheck:

drivers/pwm/pwm-omap-dmtimer.c:304:2-8: ERROR: missing put_device; call of_find_device_by_node on line 255, but without a corresponding object release within this function.

How do you think about to add a wording according to “imperative mood” for your change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=31f4f5b495a62c9a8b15b1c3581acd5efeb9af8c#n151

…

Quoted 1 line

+++ b/drivers/pwm/pwm-omap-dmtimer.c

…

Quoted 1 line
(quoted diff) +0 -0
@@ -352,7 +352,14 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)

…

drivers/pwm/pwm-omap-dmtimer.c static int pwm_omap_dmtimer_probe(struct platform_device *pdev) · line 360

Quoted 8 lines
drivers/pwm/pwm-omap-dmtimer.c +6 -1
 	pdata->free(dm_timer);
-put:
+err_request_timer:
+
+err_timer_property:
+err_platdata:
+
+	put_device(&timer_pdev->dev);

Would the use of the label “put_device” be more appropriate?

drivers/pwm/pwm-omap-dmtimer.c static int pwm_omap_dmtimer_probe(struct platform_device *pdev) · line 363

Quoted 3 lines
drivers/pwm/pwm-omap-dmtimer.c +2 -0
+err_find_timer_pdev:
+
 	of_node_put(timer);

…

Would the use of the label “put_node” be better here?

drivers/pwm/pwm-omap-dmtimer.c static int pwm_omap_dmtimer_remove(struct platform_device *pdev) · line 386

Quoted 9 lines
drivers/pwm/pwm-omap-dmtimer.c +2 -0
@@ -372,6 +379,8 @@ static int pwm_omap_dmtimer_remove(struct platform_device *pdev)
 
 	omap->pdata->free(omap->dm_timer);
 
+	put_device(&omap->dm_timer_pdev->dev);
+
 	mutex_destroy(&omap->mutex);
 
 	return 0;

I suggest to omit a few blank lines.

Regards,
Markus

#16 lore raw

Re: [PATCH 3/4] pwm: omap-dmtimer: put_device() after of_find_device_by_node()

Quoted 9 lines · Markus Elfring
Quoted 5 lines

This was found by coccicheck:

drivers/pwm/pwm-omap-dmtimer.c:304:2-8: ERROR: missing put_device; call of_find_device_by_node on line 255, but without a corresponding object release within this function.

How do you think about to add a wording according to “imperative mood” for your change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id1f4f5b495a62c9a8b15b1c3581acd5efeb9af8c#n151

Are you a bot?

Quoted 28 lines
Quoted 1 line

+++ b/drivers/pwm/pwm-omap-dmtimer.c

…

Quoted 1 line
(quoted diff) +0 -0
@@ -352,7 +352,14 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)

…

drivers/pwm/pwm-omap-dmtimer.c static int pwm_omap_dmtimer_probe(struct platform_device *pdev) · line 360

Quoted 8 lines
drivers/pwm/pwm-omap-dmtimer.c +6 -1
 	pdata->free(dm_timer);
-put:
+err_request_timer:
+
+err_timer_property:
+err_platdata:
+
+	put_device(&timer_pdev->dev);

Would the use of the label “put_device” be more appropriate?

drivers/pwm/pwm-omap-dmtimer.c static int pwm_omap_dmtimer_probe(struct platform_device *pdev) · line 363

Quoted 3 lines
drivers/pwm/pwm-omap-dmtimer.c +2 -0
+err_find_timer_pdev:
+
 	of_node_put(timer);

…

Would the use of the label “put_node” be better here?

Quoted 4 lines
drivers/pwm/pwm-omap-dmtimer.c +0 -0
@@ -372,6 +379,8 @@ static int pwm_omap_dmtimer_remove(struct platform_device *pdev)
 
 	omap->pdata->free(omap->dm_timer);
 
Quoted 7 lines

drivers/pwm/pwm-omap-dmtimer.c static int pwm_omap_dmtimer_remove(struct platform_device *pdev) · line 386

Quoted 5 lines
drivers/pwm/pwm-omap-dmtimer.c +2 -0
+	put_device(&omap->dm_timer_pdev->dev);
+
 	mutex_destroy(&omap->mutex);
 
 	return 0;

I suggest to omit a few blank lines.

And I like it the way it is.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
#17 lore raw

Re: [3/4] pwm: omap-dmtimer: put_device() after of_find_device_by_node()

Quoted 3 lines
Quoted 1 line

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=31f4f5b495a62c9a8b15b1c3581acd5efeb9af8c#n151

Are you a bot?

I hope not.

But I got used to the need to point specific suggestions out several times. Would you like to mention any actions in the commit message explicitly?

Regards,
Markus

#18 lore raw

Re: [3/4] pwm: omap-dmtimer: put_device() after of_find_device_by_node()

Hello,

Quoted 7 lines · Markus Elfring
Quoted 3 lines
Quoted 1 line

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id1f4f5b495a62c9a8b15b1c3581acd5efeb9af8c#n151

Are you a bot?

I hope not.

But I got used to the need to point specific suggestions out several times.

And are you also used to people ignore at least n-1 of n of these repetitions? I don't feel that several near-identical mails that just include a link to some documentation is very constructive. Also I got some of your mails twice which doesn't improve the reception of your comments.

Quoted 1 line

Would you like to mention any actions in the commit message explicitly?

I don't understand your question, but I assume the answer is "No, I want to keep the commit log as is".

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
#19 lore raw

Re: [3/4] pwm: omap-dmtimer: put_device() after of_find_device_by_node()

Quoted 3 lines
Quoted 1 line

Would you like to mention any actions in the commit message explicitly?

I don't understand your question,

I hope that remaining communication difficulties will be resolved better.

Quoted 1 line

but I assume the answer is "No, I want to keep the commit log as is".

I suggest to take another look at the relevance of the corresponding Linux development documentation then.

Regards,
Markus

#20 lore raw

PATCH 4/4 pwm: omap-dmtimer: Allow compiling with COMPILE_TEST

The dependency on OMAP_DM_TIMER is only a runtime dependency. Also OMAP_DM_TIMER cannot be enabled without ARCH_OMAP being enabled.

---
 drivers/pwm/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pwm/Kconfig +2 -1
index e3a2518503ed..e49cbdb1ce29 100644
@@ -328,7 +328,8 @@ config PWM_MXS
 
 config PWM_OMAP_DMTIMER
 	tristate "OMAP Dual-Mode Timer PWM support"
-	depends on OF && ARCH_OMAP && OMAP_DM_TIMER
+	depends on OF
+	depends on OMAP_DM_TIMER || COMPILE_TEST
 	help
 	  Generic PWM framework driver for OMAP Dual-Mode Timer PWM output
 
Signature · 1 line
2.23.0
#21 lore raw

Re: [PATCH 4/4] pwm: omap-dmtimer: Allow compiling with COMPILE_TEST

Quoted 2 lines

The dependency on OMAP_DM_TIMER is only a runtime dependency. Also OMAP_DM_TIMER cannot be enabled without ARCH_OMAP being enabled.

Will a more “imperative mood” become relevant also for this change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=31f4f5b495a62c9a8b15b1c3581acd5efeb9af8c#n151

Regards,
Markus

#22 lore raw

Re: [PATCH 4/4] pwm: omap-dmtimer: Allow compiling with COMPILE_TEST

In reply to Uwe Kleine-König
Quoted 2 lines

The dependency on OMAP_DM_TIMER is only a runtime dependency. Also OMAP_DM_TIMER cannot be enabled without ARCH_OMAP being enabled.

Will a more “imperative mood” become relevant also for this change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=31f4f5b495a62c9a8b15b1c3581acd5efeb9af8c#n151

Regards,
Markus