From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Samuel Holland <samuel@sholland.org>,
Maxime Ripard <maxime@cerno.tech>,
Sasha Levin <sashal@kernel.org>,
mturquette@baylibre.com, sboyd@codeaurora.org,
maxime.ripard@free-electrons.com, wens@csie.org,
linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: [PATCH AUTOSEL 5.15 03/82] clk: sunxi-ng: Unregister clocks/resets when unbinding
Date: Tue, 9 Nov 2021 17:15:21 -0500 [thread overview]
Message-ID: <20211109221641.1233217-3-sashal@kernel.org> (raw)
In-Reply-To: <20211109221641.1233217-1-sashal@kernel.org>
From: Samuel Holland <samuel@sholland.org>
[ Upstream commit 9bec2b9c6134052994115d2d3374e96f2ccb9b9d ]
Currently, unbinding a CCU driver unmaps the device's MMIO region, while
leaving its clocks/resets and their providers registered. This can cause
a page fault later when some clock operation tries to perform MMIO. Fix
this by separating the CCU initialization from the memory allocation,
and then using a devres callback to unregister the clocks and resets.
This also fixes a memory leak of the `struct ccu_reset`, and uses the
correct owner (the specific platform driver) for the clocks and resets.
Early OF clock providers are never unregistered, and limited error
handling is possible, so they are mostly unchanged. The error reporting
is made more consistent by moving the message inside of_sunxi_ccu_probe.
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/20210901050526.45673-2-samuel@sholland.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/clk/sunxi-ng/ccu-sun4i-a10.c | 2 +-
drivers/clk/sunxi-ng/ccu-sun50i-a100-r.c | 2 +-
drivers/clk/sunxi-ng/ccu-sun50i-a100.c | 2 +-
drivers/clk/sunxi-ng/ccu-sun50i-a64.c | 2 +-
drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c | 2 +-
drivers/clk/sunxi-ng/ccu-sun50i-h6.c | 2 +-
drivers/clk/sunxi-ng/ccu-sun50i-h616.c | 4 +-
drivers/clk/sunxi-ng/ccu-sun5i.c | 2 +-
drivers/clk/sunxi-ng/ccu-sun6i-a31.c | 2 +-
drivers/clk/sunxi-ng/ccu-sun8i-a23.c | 2 +-
drivers/clk/sunxi-ng/ccu-sun8i-a33.c | 2 +-
drivers/clk/sunxi-ng/ccu-sun8i-a83t.c | 2 +-
drivers/clk/sunxi-ng/ccu-sun8i-de2.c | 2 +-
drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 2 +-
drivers/clk/sunxi-ng/ccu-sun8i-r.c | 2 +-
drivers/clk/sunxi-ng/ccu-sun8i-r40.c | 2 +-
drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 2 +-
drivers/clk/sunxi-ng/ccu-sun9i-a80-de.c | 3 +-
drivers/clk/sunxi-ng/ccu-sun9i-a80-usb.c | 3 +-
drivers/clk/sunxi-ng/ccu-sun9i-a80.c | 2 +-
drivers/clk/sunxi-ng/ccu-suniv-f1c100s.c | 2 +-
drivers/clk/sunxi-ng/ccu_common.c | 89 ++++++++++++++++++++----
drivers/clk/sunxi-ng/ccu_common.h | 6 +-
23 files changed, 100 insertions(+), 41 deletions(-)
diff --git a/drivers/clk/sunxi-ng/ccu-sun4i-a10.c b/drivers/clk/sunxi-ng/ccu-sun4i-a10.c
index f32366d9336e7..bd9a8782fec3d 100644
--- a/drivers/clk/sunxi-ng/ccu-sun4i-a10.c
+++ b/drivers/clk/sunxi-ng/ccu-sun4i-a10.c
@@ -1464,7 +1464,7 @@ static void __init sun4i_ccu_init(struct device_node *node,
val &= ~GENMASK(7, 6);
writel(val | (2 << 6), reg + SUN4I_AHB_REG);
- sunxi_ccu_probe(node, reg, desc);
+ of_sunxi_ccu_probe(node, reg, desc);
}
static void __init sun4i_a10_ccu_setup(struct device_node *node)
diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-a100-r.c b/drivers/clk/sunxi-ng/ccu-sun50i-a100-r.c
index a56142b909938..6f2a589705561 100644
--- a/drivers/clk/sunxi-ng/ccu-sun50i-a100-r.c
+++ b/drivers/clk/sunxi-ng/ccu-sun50i-a100-r.c
@@ -196,7 +196,7 @@ static int sun50i_a100_r_ccu_probe(struct platform_device *pdev)
if (IS_ERR(reg))
return PTR_ERR(reg);
- return sunxi_ccu_probe(pdev->dev.of_node, reg, &sun50i_a100_r_ccu_desc);
+ return devm_sunxi_ccu_probe(&pdev->dev, reg, &sun50i_a100_r_ccu_desc);
}
static const struct of_device_id sun50i_a100_r_ccu_ids[] = {
diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-a100.c b/drivers/clk/sunxi-ng/ccu-sun50i-a100.c
index 81b48c73d389f..913bb08e6dee8 100644
--- a/drivers/clk/sunxi-ng/ccu-sun50i-a100.c
+++ b/drivers/clk/sunxi-ng/ccu-sun50i-a100.c
@@ -1247,7 +1247,7 @@ static int sun50i_a100_ccu_probe(struct platform_device *pdev)
writel(val, reg + sun50i_a100_usb2_clk_regs[i]);
}
- ret = sunxi_ccu_probe(pdev->dev.of_node, reg, &sun50i_a100_ccu_desc);
+ ret = devm_sunxi_ccu_probe(&pdev->dev, reg, &sun50i_a100_ccu_desc);
if (ret)
return ret;
diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-a64.c b/drivers/clk/sunxi-ng/ccu-sun50i-a64.c
index 149cfde817cba..54f25c624f020 100644
--- a/drivers/clk/sunxi-ng/ccu-sun50i-a64.c
+++ b/drivers/clk/sunxi-ng/ccu-sun50i-a64.c
@@ -955,7 +955,7 @@ static int sun50i_a64_ccu_probe(struct platform_device *pdev)
writel(0x515, reg + SUN50I_A64_PLL_MIPI_REG);
- ret = sunxi_ccu_probe(pdev->dev.of_node, reg, &sun50i_a64_ccu_desc);
+ ret = devm_sunxi_ccu_probe(&pdev->dev, reg, &sun50i_a64_ccu_desc);
if (ret)
return ret;
diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c b/drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c
index f8909a7ed5539..f30d7eb5424d8 100644
--- a/drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c
+++ b/drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c
@@ -232,7 +232,7 @@ static void __init sunxi_r_ccu_init(struct device_node *node,
return;
}
- sunxi_ccu_probe(node, reg, desc);
+ of_sunxi_ccu_probe(node, reg, desc);
}
static void __init sun50i_h6_r_ccu_setup(struct device_node *node)
diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-h6.c b/drivers/clk/sunxi-ng/ccu-sun50i-h6.c
index bff446b782907..c0800da2fa3d7 100644
--- a/drivers/clk/sunxi-ng/ccu-sun50i-h6.c
+++ b/drivers/clk/sunxi-ng/ccu-sun50i-h6.c
@@ -1240,7 +1240,7 @@ static int sun50i_h6_ccu_probe(struct platform_device *pdev)
val |= BIT(24);
writel(val, reg + SUN50I_H6_HDMI_CEC_CLK_REG);
- return sunxi_ccu_probe(pdev->dev.of_node, reg, &sun50i_h6_ccu_desc);
+ return devm_sunxi_ccu_probe(&pdev->dev, reg, &sun50i_h6_ccu_desc);
}
static const struct of_device_id sun50i_h6_ccu_ids[] = {
diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-h616.c b/drivers/clk/sunxi-ng/ccu-sun50i-h616.c
index 225307305880e..22eb18079a154 100644
--- a/drivers/clk/sunxi-ng/ccu-sun50i-h616.c
+++ b/drivers/clk/sunxi-ng/ccu-sun50i-h616.c
@@ -1141,9 +1141,7 @@ static void __init sun50i_h616_ccu_setup(struct device_node *node)
val |= BIT(24);
writel(val, reg + SUN50I_H616_HDMI_CEC_CLK_REG);
- i = sunxi_ccu_probe(node, reg, &sun50i_h616_ccu_desc);
- if (i)
- pr_err("%pOF: probing clocks fails: %d\n", node, i);
+ of_sunxi_ccu_probe(node, reg, &sun50i_h616_ccu_desc);
}
CLK_OF_DECLARE(sun50i_h616_ccu, "allwinner,sun50i-h616-ccu",
diff --git a/drivers/clk/sunxi-ng/ccu-sun5i.c b/drivers/clk/sunxi-ng/ccu-sun5i.c
index b78e9b507c1c6..1f4bc0e773a7e 100644
--- a/drivers/clk/sunxi-ng/ccu-sun5i.c
+++ b/drivers/clk/sunxi-ng/ccu-sun5i.c
@@ -1012,7 +1012,7 @@ static void __init sun5i_ccu_init(struct device_node *node,
val &= ~GENMASK(7, 6);
writel(val | (2 << 6), reg + SUN5I_AHB_REG);
- sunxi_ccu_probe(node, reg, desc);
+ of_sunxi_ccu_probe(node, reg, desc);
}
static void __init sun5i_a10s_ccu_setup(struct device_node *node)
diff --git a/drivers/clk/sunxi-ng/ccu-sun6i-a31.c b/drivers/clk/sunxi-ng/ccu-sun6i-a31.c
index 9b40d53266a3f..3df5c0b415804 100644
--- a/drivers/clk/sunxi-ng/ccu-sun6i-a31.c
+++ b/drivers/clk/sunxi-ng/ccu-sun6i-a31.c
@@ -1257,7 +1257,7 @@ static void __init sun6i_a31_ccu_setup(struct device_node *node)
val |= 0x3 << 12;
writel(val, reg + SUN6I_A31_AHB1_REG);
- sunxi_ccu_probe(node, reg, &sun6i_a31_ccu_desc);
+ of_sunxi_ccu_probe(node, reg, &sun6i_a31_ccu_desc);
ccu_mux_notifier_register(pll_cpu_clk.common.hw.clk,
&sun6i_a31_cpu_nb);
diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-a23.c b/drivers/clk/sunxi-ng/ccu-sun8i-a23.c
index 103aa504f6c8a..577bb235d6584 100644
--- a/drivers/clk/sunxi-ng/ccu-sun8i-a23.c
+++ b/drivers/clk/sunxi-ng/ccu-sun8i-a23.c
@@ -745,7 +745,7 @@ static void __init sun8i_a23_ccu_setup(struct device_node *node)
val &= ~BIT(16);
writel(val, reg + SUN8I_A23_PLL_MIPI_REG);
- sunxi_ccu_probe(node, reg, &sun8i_a23_ccu_desc);
+ of_sunxi_ccu_probe(node, reg, &sun8i_a23_ccu_desc);
}
CLK_OF_DECLARE(sun8i_a23_ccu, "allwinner,sun8i-a23-ccu",
sun8i_a23_ccu_setup);
diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-a33.c b/drivers/clk/sunxi-ng/ccu-sun8i-a33.c
index 91838cd110377..8f65cd03f5acc 100644
--- a/drivers/clk/sunxi-ng/ccu-sun8i-a33.c
+++ b/drivers/clk/sunxi-ng/ccu-sun8i-a33.c
@@ -805,7 +805,7 @@ static void __init sun8i_a33_ccu_setup(struct device_node *node)
val &= ~BIT(16);
writel(val, reg + SUN8I_A33_PLL_MIPI_REG);
- sunxi_ccu_probe(node, reg, &sun8i_a33_ccu_desc);
+ of_sunxi_ccu_probe(node, reg, &sun8i_a33_ccu_desc);
/* Gate then ungate PLL CPU after any rate changes */
ccu_pll_notifier_register(&sun8i_a33_pll_cpu_nb);
diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-a83t.c b/drivers/clk/sunxi-ng/ccu-sun8i-a83t.c
index 2b434521c5ccf..c2ddcd2ddab4e 100644
--- a/drivers/clk/sunxi-ng/ccu-sun8i-a83t.c
+++ b/drivers/clk/sunxi-ng/ccu-sun8i-a83t.c
@@ -906,7 +906,7 @@ static int sun8i_a83t_ccu_probe(struct platform_device *pdev)
sun8i_a83t_cpu_pll_fixup(reg + SUN8I_A83T_PLL_C0CPUX_REG);
sun8i_a83t_cpu_pll_fixup(reg + SUN8I_A83T_PLL_C1CPUX_REG);
- return sunxi_ccu_probe(pdev->dev.of_node, reg, &sun8i_a83t_ccu_desc);
+ return devm_sunxi_ccu_probe(&pdev->dev, reg, &sun8i_a83t_ccu_desc);
}
static const struct of_device_id sun8i_a83t_ccu_ids[] = {
diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-de2.c b/drivers/clk/sunxi-ng/ccu-sun8i-de2.c
index 524f33275bc73..4b94b6041b271 100644
--- a/drivers/clk/sunxi-ng/ccu-sun8i-de2.c
+++ b/drivers/clk/sunxi-ng/ccu-sun8i-de2.c
@@ -342,7 +342,7 @@ static int sunxi_de2_clk_probe(struct platform_device *pdev)
goto err_disable_mod_clk;
}
- ret = sunxi_ccu_probe(pdev->dev.of_node, reg, ccu_desc);
+ ret = devm_sunxi_ccu_probe(&pdev->dev, reg, ccu_desc);
if (ret)
goto err_assert_reset;
diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
index 7e629a4493afd..d2fc2903787d8 100644
--- a/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
+++ b/drivers/clk/sunxi-ng/ccu-sun8i-h3.c
@@ -1154,7 +1154,7 @@ static void __init sunxi_h3_h5_ccu_init(struct device_node *node,
val &= ~GENMASK(19, 16);
writel(val | (0 << 16), reg + SUN8I_H3_PLL_AUDIO_REG);
- sunxi_ccu_probe(node, reg, desc);
+ of_sunxi_ccu_probe(node, reg, desc);
/* Gate then ungate PLL CPU after any rate changes */
ccu_pll_notifier_register(&sun8i_h3_pll_cpu_nb);
diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-r.c b/drivers/clk/sunxi-ng/ccu-sun8i-r.c
index 4c8c491b87c27..9e754d1f754a1 100644
--- a/drivers/clk/sunxi-ng/ccu-sun8i-r.c
+++ b/drivers/clk/sunxi-ng/ccu-sun8i-r.c
@@ -265,7 +265,7 @@ static void __init sunxi_r_ccu_init(struct device_node *node,
return;
}
- sunxi_ccu_probe(node, reg, desc);
+ of_sunxi_ccu_probe(node, reg, desc);
}
static void __init sun8i_a83t_r_ccu_setup(struct device_node *node)
diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-r40.c b/drivers/clk/sunxi-ng/ccu-sun8i-r40.c
index 84153418453f4..002e0c3a04dbe 100644
--- a/drivers/clk/sunxi-ng/ccu-sun8i-r40.c
+++ b/drivers/clk/sunxi-ng/ccu-sun8i-r40.c
@@ -1346,7 +1346,7 @@ static int sun8i_r40_ccu_probe(struct platform_device *pdev)
if (IS_ERR(regmap))
return PTR_ERR(regmap);
- ret = sunxi_ccu_probe(pdev->dev.of_node, reg, &sun8i_r40_ccu_desc);
+ ret = devm_sunxi_ccu_probe(&pdev->dev, reg, &sun8i_r40_ccu_desc);
if (ret)
return ret;
diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
index f49724a22540e..ce150f83ab54e 100644
--- a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
+++ b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
@@ -822,7 +822,7 @@ static void __init sun8i_v3_v3s_ccu_init(struct device_node *node,
val &= ~GENMASK(19, 16);
writel(val, reg + SUN8I_V3S_PLL_AUDIO_REG);
- sunxi_ccu_probe(node, reg, ccu_desc);
+ of_sunxi_ccu_probe(node, reg, ccu_desc);
}
static void __init sun8i_v3s_ccu_setup(struct device_node *node)
diff --git a/drivers/clk/sunxi-ng/ccu-sun9i-a80-de.c b/drivers/clk/sunxi-ng/ccu-sun9i-a80-de.c
index 6616e8114f623..261e64416f26a 100644
--- a/drivers/clk/sunxi-ng/ccu-sun9i-a80-de.c
+++ b/drivers/clk/sunxi-ng/ccu-sun9i-a80-de.c
@@ -246,8 +246,7 @@ static int sun9i_a80_de_clk_probe(struct platform_device *pdev)
goto err_disable_clk;
}
- ret = sunxi_ccu_probe(pdev->dev.of_node, reg,
- &sun9i_a80_de_clk_desc);
+ ret = devm_sunxi_ccu_probe(&pdev->dev, reg, &sun9i_a80_de_clk_desc);
if (ret)
goto err_assert_reset;
diff --git a/drivers/clk/sunxi-ng/ccu-sun9i-a80-usb.c b/drivers/clk/sunxi-ng/ccu-sun9i-a80-usb.c
index 4b4a507d04edf..596243b3e0fa3 100644
--- a/drivers/clk/sunxi-ng/ccu-sun9i-a80-usb.c
+++ b/drivers/clk/sunxi-ng/ccu-sun9i-a80-usb.c
@@ -117,8 +117,7 @@ static int sun9i_a80_usb_clk_probe(struct platform_device *pdev)
return ret;
}
- ret = sunxi_ccu_probe(pdev->dev.of_node, reg,
- &sun9i_a80_usb_clk_desc);
+ ret = devm_sunxi_ccu_probe(&pdev->dev, reg, &sun9i_a80_usb_clk_desc);
if (ret)
goto err_disable_clk;
diff --git a/drivers/clk/sunxi-ng/ccu-sun9i-a80.c b/drivers/clk/sunxi-ng/ccu-sun9i-a80.c
index ef29582676f6e..97aaed0e68500 100644
--- a/drivers/clk/sunxi-ng/ccu-sun9i-a80.c
+++ b/drivers/clk/sunxi-ng/ccu-sun9i-a80.c
@@ -1231,7 +1231,7 @@ static int sun9i_a80_ccu_probe(struct platform_device *pdev)
sun9i_a80_cpu_pll_fixup(reg + SUN9I_A80_PLL_C0CPUX_REG);
sun9i_a80_cpu_pll_fixup(reg + SUN9I_A80_PLL_C1CPUX_REG);
- return sunxi_ccu_probe(pdev->dev.of_node, reg, &sun9i_a80_ccu_desc);
+ return devm_sunxi_ccu_probe(&pdev->dev, reg, &sun9i_a80_ccu_desc);
}
static const struct of_device_id sun9i_a80_ccu_ids[] = {
diff --git a/drivers/clk/sunxi-ng/ccu-suniv-f1c100s.c b/drivers/clk/sunxi-ng/ccu-suniv-f1c100s.c
index 7ecc3a5a5b5e1..61ad7ee91c114 100644
--- a/drivers/clk/sunxi-ng/ccu-suniv-f1c100s.c
+++ b/drivers/clk/sunxi-ng/ccu-suniv-f1c100s.c
@@ -538,7 +538,7 @@ static void __init suniv_f1c100s_ccu_setup(struct device_node *node)
val &= ~GENMASK(19, 16);
writel(val | (3 << 16), reg + SUNIV_PLL_AUDIO_REG);
- sunxi_ccu_probe(node, reg, &suniv_ccu_desc);
+ of_sunxi_ccu_probe(node, reg, &suniv_ccu_desc);
/* Gate then ungate PLL CPU after any rate changes */
ccu_pll_notifier_register(&suniv_pll_cpu_nb);
diff --git a/drivers/clk/sunxi-ng/ccu_common.c b/drivers/clk/sunxi-ng/ccu_common.c
index 2e20e650b6c01..88cb569e58358 100644
--- a/drivers/clk/sunxi-ng/ccu_common.c
+++ b/drivers/clk/sunxi-ng/ccu_common.c
@@ -7,6 +7,7 @@
#include <linux/clk.h>
#include <linux/clk-provider.h>
+#include <linux/device.h>
#include <linux/iopoll.h>
#include <linux/slab.h>
@@ -14,6 +15,11 @@
#include "ccu_gate.h"
#include "ccu_reset.h"
+struct sunxi_ccu {
+ const struct sunxi_ccu_desc *desc;
+ struct ccu_reset reset;
+};
+
static DEFINE_SPINLOCK(ccu_lock);
void ccu_helper_wait_for_lock(struct ccu_common *common, u32 lock)
@@ -79,12 +85,15 @@ int ccu_pll_notifier_register(struct ccu_pll_nb *pll_nb)
&pll_nb->clk_nb);
}
-int sunxi_ccu_probe(struct device_node *node, void __iomem *reg,
- const struct sunxi_ccu_desc *desc)
+static int sunxi_ccu_probe(struct sunxi_ccu *ccu, struct device *dev,
+ struct device_node *node, void __iomem *reg,
+ const struct sunxi_ccu_desc *desc)
{
struct ccu_reset *reset;
int i, ret;
+ ccu->desc = desc;
+
for (i = 0; i < desc->num_ccu_clks; i++) {
struct ccu_common *cclk = desc->ccu_clks[i];
@@ -103,7 +112,10 @@ int sunxi_ccu_probe(struct device_node *node, void __iomem *reg,
continue;
name = hw->init->name;
- ret = of_clk_hw_register(node, hw);
+ if (dev)
+ ret = clk_hw_register(dev, hw);
+ else
+ ret = of_clk_hw_register(node, hw);
if (ret) {
pr_err("Couldn't register clock %d - %s\n", i, name);
goto err_clk_unreg;
@@ -115,15 +127,10 @@ int sunxi_ccu_probe(struct device_node *node, void __iomem *reg,
if (ret)
goto err_clk_unreg;
- reset = kzalloc(sizeof(*reset), GFP_KERNEL);
- if (!reset) {
- ret = -ENOMEM;
- goto err_alloc_reset;
- }
-
+ reset = &ccu->reset;
reset->rcdev.of_node = node;
reset->rcdev.ops = &ccu_reset_ops;
- reset->rcdev.owner = THIS_MODULE;
+ reset->rcdev.owner = dev ? dev->driver->owner : THIS_MODULE;
reset->rcdev.nr_resets = desc->num_resets;
reset->base = reg;
reset->lock = &ccu_lock;
@@ -131,13 +138,11 @@ int sunxi_ccu_probe(struct device_node *node, void __iomem *reg,
ret = reset_controller_register(&reset->rcdev);
if (ret)
- goto err_of_clk_unreg;
+ goto err_del_provider;
return 0;
-err_of_clk_unreg:
- kfree(reset);
-err_alloc_reset:
+err_del_provider:
of_clk_del_provider(node);
err_clk_unreg:
while (--i >= 0) {
@@ -149,3 +154,59 @@ err_clk_unreg:
}
return ret;
}
+
+static void devm_sunxi_ccu_release(struct device *dev, void *res)
+{
+ struct sunxi_ccu *ccu = res;
+ const struct sunxi_ccu_desc *desc = ccu->desc;
+ int i;
+
+ reset_controller_unregister(&ccu->reset.rcdev);
+ of_clk_del_provider(dev->of_node);
+
+ for (i = 0; i < desc->hw_clks->num; i++) {
+ struct clk_hw *hw = desc->hw_clks->hws[i];
+
+ if (!hw)
+ continue;
+ clk_hw_unregister(hw);
+ }
+}
+
+int devm_sunxi_ccu_probe(struct device *dev, void __iomem *reg,
+ const struct sunxi_ccu_desc *desc)
+{
+ struct sunxi_ccu *ccu;
+ int ret;
+
+ ccu = devres_alloc(devm_sunxi_ccu_release, sizeof(*ccu), GFP_KERNEL);
+ if (!ccu)
+ return -ENOMEM;
+
+ ret = sunxi_ccu_probe(ccu, dev, dev->of_node, reg, desc);
+ if (ret) {
+ devres_free(ccu);
+ return ret;
+ }
+
+ devres_add(dev, ccu);
+
+ return 0;
+}
+
+void of_sunxi_ccu_probe(struct device_node *node, void __iomem *reg,
+ const struct sunxi_ccu_desc *desc)
+{
+ struct sunxi_ccu *ccu;
+ int ret;
+
+ ccu = kzalloc(sizeof(*ccu), GFP_KERNEL);
+ if (!ccu)
+ return;
+
+ ret = sunxi_ccu_probe(ccu, NULL, node, reg, desc);
+ if (ret) {
+ pr_err("%pOF: probing clocks failed: %d\n", node, ret);
+ kfree(ccu);
+ }
+}
diff --git a/drivers/clk/sunxi-ng/ccu_common.h b/drivers/clk/sunxi-ng/ccu_common.h
index 04e7a12200a21..98a1834b58bb4 100644
--- a/drivers/clk/sunxi-ng/ccu_common.h
+++ b/drivers/clk/sunxi-ng/ccu_common.h
@@ -63,7 +63,9 @@ struct ccu_pll_nb {
int ccu_pll_notifier_register(struct ccu_pll_nb *pll_nb);
-int sunxi_ccu_probe(struct device_node *node, void __iomem *reg,
- const struct sunxi_ccu_desc *desc);
+int devm_sunxi_ccu_probe(struct device *dev, void __iomem *reg,
+ const struct sunxi_ccu_desc *desc);
+void of_sunxi_ccu_probe(struct device_node *node, void __iomem *reg,
+ const struct sunxi_ccu_desc *desc);
#endif /* _COMMON_H_ */
--
2.33.0
next prev parent reply other threads:[~2021-11-09 22:17 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-09 22:15 [PATCH AUTOSEL 5.15 01/82] arm64: zynqmp: Do not duplicate flash partition label property Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 02/82] arm64: zynqmp: Fix serial compatible string Sasha Levin
2021-11-09 22:15 ` Sasha Levin [this message]
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 04/82] ARM: dts: sunxi: Fix OPPs node name Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 05/82] arm64: dts: allwinner: h5: Fix GPU thermal zone " Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 06/82] arm64: dts: allwinner: a100: Fix " Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 07/82] staging: wfx: ensure IRQ is ready before enabling it Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 08/82] ARM: dts: BCM5301X: Fix nodes names Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 09/82] ARM: dts: BCM5301X: Fix MDIO mux binding Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 10/82] ARM: dts: NSP: Fix mpcore, mmc node names Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 11/82] arm64: dts: broadcom: bcm4908: Move reboot syscon out of bus Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 12/82] scsi: pm80xx: Fix memory leak during rmmod Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 13/82] scsi: lpfc: Fix list_add() corruption in lpfc_drain_txq() Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 14/82] ASoC: mediatek: mt8195: Add missing of_node_put() Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 15/82] arm64: dts: rockchip: Disable CDN DP on Pinebook Pro Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 16/82] arm64: dts: hisilicon: fix arm,sp805 compatible string Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 17/82] arm64: dts: rockchip: add Coresight debug range for RK3399 Sasha Levin
2021-11-09 23:25 ` Brian Norris
2021-11-10 0:44 ` Sasha Levin
2021-11-10 0:49 ` Brian Norris
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 18/82] RDMA/bnxt_re: Check if the vlan is valid before reporting Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 19/82] bus: ti-sysc: Add quirk handling for reinit on context lost Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 20/82] bus: ti-sysc: Use context lost quirk for otg Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 21/82] usb: musb: tusb6010: check return value after calling platform_get_resource() Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 22/82] usb: typec: tipd: Remove WARN_ON in tps6598x_block_read Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 23/82] ARM: dts: ux500: Skomer regulator fixes Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 24/82] staging: rtl8723bs: remove possible deadlock when disconnect (v2) Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 25/82] staging: rtl8723bs: remove a second possible deadlock Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 26/82] staging: rtl8723bs: remove a third " Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 27/82] ARM: BCM53016: Specify switch ports for Meraki MR32 Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 28/82] arm64: dts: qcom: msm8998: Fix CPU/L2 idle state latency and residency Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 29/82] arm64: dts: qcom: ipq6018: Fix qcom,controlled-remotely property Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 30/82] arm64: dts: qcom: ipq8074: " Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 31/82] arm64: dts: qcom: sdm845: " Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 32/82] arm64: dts: qcom: msm8916: Add unit name for /soc node Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 33/82] arm64: dts: freescale: fix arm,sp805 compatible string Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 34/82] arm64: dts: ls1012a: Add serial alias for ls1012a-rdb Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 35/82] RDMA/rxe: Separate HW and SW l/rkeys Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 36/82] ASoC: SOF: Intel: hda-dai: fix potential locking issue Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 37/82] scsi: core: Fix scsi_mode_sense() buffer length handling Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 38/82] ALSA: usb-audio: disable implicit feedback sync for Behringer UFX1204 and UFX1604 Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 39/82] clk: imx: imx6ul: Move csi_sel mux to correct base register Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 40/82] ASoC: es8316: Use IRQF_NO_AUTOEN when requesting the IRQ Sasha Levin
2021-11-09 22:15 ` [PATCH AUTOSEL 5.15 41/82] ASoC: rt5651: " Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 42/82] ASoC: nau8824: Add DMI quirk mechanism for active-high jack-detect Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 43/82] scsi: advansys: Fix kernel pointer leak Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 44/82] scsi: smartpqi: Add controller handshake during kdump Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 45/82] arm64: dts: imx8mm-kontron: Fix reset delays for ethernet PHY Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 46/82] ALSA: intel-dsp-config: add quirk for APL/GLK/TGL devices based on ES8336 codec Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 47/82] ASoC: Intel: soc-acpi: add missing quirk for TGL SDCA single amp Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 48/82] ASoC: Intel: sof_sdw: add missing quirk for Dell SKU 0A45 Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 49/82] firmware_loader: fix pre-allocated buf built-in firmware use Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 50/82] cpuidle: tegra: Check whether PMC is ready Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 51/82] HID: multitouch: disable sticky fingers for UPERFECT Y Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 52/82] ALSA: usb-audio: Add support for the Pioneer DJM 750MK2 Mixer/Soundcard Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 53/82] ARM: dts: omap: fix gpmc,mux-add-data type Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 54/82] usb: host: ohci-tmio: check return value after calling platform_get_resource() Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 55/82] ASoC: rt5682: fix a little pop while playback Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 56/82] ARM: dts: ls1021a: move thermal-zones node out of soc/ Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 57/82] ARM: dts: ls1021a-tsn: use generic "jedec,spi-nor" compatible for flash Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 58/82] ALSA: ISA: not for M68K Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 59/82] iommu/vt-d: Do not falsely log intel_iommu is unsupported kernel option Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 60/82] tty: tty_buffer: Fix the softlockup issue in flush_to_ldisc Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 61/82] MIPS: sni: Fix the build Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 62/82] scsi: scsi_debug: Fix out-of-bound read in resp_readcap16() Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 63/82] scsi: scsi_debug: Fix out-of-bound read in resp_report_tgtpgs() Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 64/82] scsi: target: Fix ordered tag handling Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 65/82] scsi: target: Fix alua_tg_pt_gps_count tracking Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 66/82] iio: imu: st_lsm6dsx: Avoid potential array overflow in st_lsm6dsx_set_odr() Sasha Levin
2021-11-12 17:33 ` Jonathan Cameron
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 67/82] RDMA/core: Use kvzalloc when allocating the struct ib_port Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 68/82] scsi: lpfc: Fix use-after-free in lpfc_unreg_rpi() routine Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 69/82] scsi: lpfc: Fix link down processing to address NULL pointer dereference Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 70/82] scsi: lpfc: Allow fabric node recovery if recovery is in progress before devloss Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 71/82] memory: tegra20-emc: Add runtime dependency on devfreq governor module Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 72/82] powerpc/5200: dts: fix memory node unit name Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 73/82] arm64: dts: qcom: msm8916: Add CPU ACC and SAW/SPM Sasha Levin
2021-11-10 8:40 ` Stephan Gerhold
2021-11-12 13:43 ` Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 74/82] ARM: dts: qcom: fix memory and mdio nodes naming for RB3011 Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 75/82] arm64: dts: qcom: Fix node name of rpm-msg-ram device nodes Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 76/82] ALSA: gus: fix null pointer dereference on pointer block Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 77/82] ALSA: usb-audio: fix null pointer dereference on pointer cs_desc Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 78/82] clk: at91: sama7g5: remove prescaler part of master clock Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 79/82] iommu/dart: Initialize DART_STREAMS_ENABLE Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 80/82] powerpc/dcr: Use cmplwi instead of 3-argument cmpli Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 81/82] powerpc/8xx: Fix Oops with STRICT_KERNEL_RWX without DEBUG_RODATA_TEST Sasha Levin
2021-11-09 22:16 ` [PATCH AUTOSEL 5.15 82/82] HID: playstation: require multicolor LED functionality Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211109221641.1233217-3-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime.ripard@free-electrons.com \
--cc=maxime@cerno.tech \
--cc=mturquette@baylibre.com \
--cc=samuel@sholland.org \
--cc=sboyd@codeaurora.org \
--cc=stable@vger.kernel.org \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox