Skip to contentSkip to conversation

clk: mvebu: armada-37xx-tbg: Balance devm_clk_get in probe

PATCH In review Gregory CLEMENT 2 participants 3 messages Sep 14, 2018 – Oct 10, 2018

Subsystems (2)
lore
Share & tools
lore

Gregory CLEMENT

author maintainer
#0 lore raw

PATCH 1/1 clk: mvebu: armada-37xx-tbg: Balance devm_clk_get in probe

The parent clock is get only to have its name, and then the clock is no more used, so we can safely free it using devm_clk_put.

---
 drivers/clk/mvebu/armada-37xx-tbg.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/mvebu/armada-37xx-tbg.c +1 -0
index 71f30149e80e..caaa91a41683 100644
@@ -102,6 +102,7 @@ static int armada_3700_tbg_clock_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 	parent_name = __clk_get_name(parent);
+	devm_clk_put(dev, parent);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	reg = devm_ioremap_resource(dev, res);
Signature · 1 line
2.18.0
maintainer
#1 lore raw

Quoting Gregory CLEMENT (2018-09-14 08:34:21)

Quoted 13 lines

The parent clock is get only to have its name, and then the clock is no more used, so we can safely free it using devm_clk_put.

---
 drivers/clk/mvebu/armada-37xx-tbg.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/mvebu/armada-37xx-tbg.c +0 -0
index 71f30149e80e..caaa91a41683 100644

drivers/clk/mvebu/armada-37xx-tbg.c static int armada_3700_tbg_clock_probe(struct platform_device *pdev) · line 105

Quoted 4 lines
drivers/clk/mvebu/armada-37xx-tbg.c +1 -0
@@ -102,6 +102,7 @@ static int armada_3700_tbg_clock_probe(struct platform_device *pdev)
                return -EINVAL;
        }
        parent_name = __clk_get_name(parent);
+       devm_clk_put(dev, parent);

So then why use devm_clk_get()? Please replace both so tha devm_clk_put() doesn't need to be used..

Quoted 3 lines
drivers/clk/mvebu/armada-37xx-tbg.c +0 -0
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        reg = devm_ioremap_resource(dev, res);
author maintainer
#2 lore raw

Hi Stephen,

Quoted 9 lines · Stephen Boyd

Quoting Gregory CLEMENT (2018-09-14 08:34:21)

Quoted 8 lines

The parent clock is get only to have its name, and then the clock is no more used, so we can safely free it using devm_clk_put.

---
 drivers/clk/mvebu/armada-37xx-tbg.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 12 lines

drivers/clk/mvebu/armada-37xx-tbg.c static int armada_3700_tbg_clock_probe(struct platform_device *pdev) · line 105

Quoted 9 lines
drivers/clk/mvebu/armada-37xx-tbg.c +1 -0
index 71f30149e80e..caaa91a41683 100644
@@ -102,6 +102,7 @@ static int armada_3700_tbg_clock_probe(struct platform_device *pdev)
                return -EINVAL;
        }
        parent_name = __clk_get_name(parent);
+       devm_clk_put(dev, parent);

So then why use devm_clk_get()? Please replace both so tha devm_clk_put() doesn't need to be used..

Indeed between the successful devm_clk_get and the devm_clk_put we don't exit the function in error so I can use clk_get and clk_put.

Gregory

Quoted 4 lines
Quoted 4 lines
drivers/clk/mvebu/armada-37xx-tbg.c +0 -0
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        reg = devm_ioremap_resource(dev, res);
Signature · 3 lines
Gregory Clement, Bootlin
Embedded Linux and Kernel engineering
http://bootlin.com