[PATCH] clk: mediatek: Migrate to common probe/remove helpers and fix memory leaks - #73
Draft
akku1139 wants to merge 32 commits into
Draft
[PATCH] clk: mediatek: Migrate to common probe/remove helpers and fix memory leaks#73akku1139 wants to merge 32 commits into
akku1139 wants to merge 32 commits into
Conversation
akku1139
force-pushed
the
patch/mediatek-clk-simple-probe
branch
from
August 1, 2026 07:34
3d1c917 to
6c8a05c
Compare
Member
Author
|
akku1139
force-pushed
the
patch/mediatek-clk-simple-probe
branch
6 times, most recently
from
August 1, 2026 12:32
f92b254 to
e730177
Compare
Member
Author
|
akku1139
force-pushed
the
patch/mediatek-clk-simple-probe
branch
2 times, most recently
from
August 1, 2026 15:02
c3d6c46 to
78a130b
Compare
Member
Author
|
akku1139
force-pushed
the
patch/mediatek-clk-simple-probe
branch
3 times, most recently
from
August 2, 2026 08:21
49689e1 to
64ec78b
Compare
Member
Author
|
akku1139
force-pushed
the
patch/mediatek-clk-simple-probe
branch
10 times, most recently
from
August 2, 2026 10:58
822d3da to
b3c7497
Compare
clk_mt8192_apmixed_probe() in clk-mt8192-apmixedsys.c does not call platform_set_drvdata(), but clk_mt8192_apmixed_remove() callback calls platform_get_drvdata(). This results in platform_get_drvdata() returning NULL, which leads to calling kfree(NULL) in mtk_free_clk_data(NULL). This leaves clk_data unreleased, causing a memory leak. Fix this by calling platform_set_drvdata() during probe. Fixes: 124294f ("clk: mediatek: mt8192: Move apmixedsys clock driver to its own file") Cc: stable@vger.kernel.org Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com> Reviewed-by: Brian Masney <bmasney@redhat.com>
Add MODULE_DEVICE_TABLE() to the MT6735 clock drivers (imgsys, mfgcfg, vdecsys, vencsys) to export the Device Tree matching tables. This is required so that the clock drivers can be automatically loaded when built as modules. Fixes: 0bd9b12 ("clk: mediatek: Add drivers for MT6735 syscon clock and reset controllers") Cc: stable@vger.kernel.org Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Add MODULE_DEVICE_TABLE() to the MT7988 apmixedsys clock driver to export the Device Tree matching tables. This is required so that the clock drivers can be automatically loaded when built as modules. Fixes: 4b47194 ("clk: mediatek: add drivers for MT7988 SoC") Cc: stable@vger.kernel.org Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Extend __mtk_clk_simple_probe() and __mtk_clk_simple_remove() to support cpumux clocks. This reduces boilerplate code in drivers for SoCs that require cpumux registration, such as mt6795-infracfg. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com> Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Extend __mtk_clk_simple_probe() and __mtk_clk_simple_remove() to support PLLs. This reduces boilerplate code in apmixedsys drivers. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
…robe MediaTek audio clock drivers call devm_of_platform_populate() after mtk_clk_simple_probe(). Extend __mtk_clk_simple_probe() to run devm_of_platform_populate() when the new 'populate_children' flag is set, reducing boilerplate. Note that explicit of_platform_depopulate() calls in remove functions are unnecessary because devm_of_platform_populate() is managed by devres and cleans up automatically. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Extend __mtk_clk_simple_probe() and __mtk_clk_simple_remove() to support pll freqhoppings. This reduces boilerplate code in apmixedsys drivers with pllfh support. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
The MT2701 clock drivers can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. Drop the CLK_OF_DECLARE_DRIVER early init for infracfg; the kernel's deferred probe mechanism ensures dependent drivers like cpufreq are initialized correctly. Since all MT2701 clock drivers can now be built as modules, change Kconfig settings to "tristate". Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
The MT2712 apmixedsys driver can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
The MT6735 apmixedsys driver can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
The MT6779 main clock driver can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. Additionally, merge the separate infracfg and other drivers into a single platform driver, and add support for the apmixed and topckgen clock controllers using the consolidated of_match_table. Finally, replace the custom arch_initcall() initialization loop with the module_platform_driver() macro. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
The MT6795 infracfg and pericfg drivers can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. Note that the apmixedsys driver is excluded from this conversion because it requires ref2usb_tx clock handling, which is not currently supported by the common simple probe helper. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
The MT6797 clock drivers can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. Drop the CLK_OF_DECLARE_DRIVER early init for infracfg; the kernel's deferred probe mechanism ensures dependent drivers like cpufreq are initialized correctly. Since all MT6797 clock drivers can now be built as modules, change Kconfig setting to "tristate". Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
The MT7622 clock drivers can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
The MT7981 apmixed driver can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. This change also makes it possible to build the driver as a module. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
The MT7986 apmixed driver can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. Also, add a remove callback to properly support module unloading. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
The MT7988 apmixed driver can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
The MT8135 apmixedsys driver can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
The MT8167 apmixedsys driver can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. Also, add a remove callback to properly support module unloading. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
The MT8173 infracfg driver can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. Drop the CLK_OF_DECLARE_DRIVER early init for infracfg; the kernel's deferred probe mechanism ensures dependent drivers like cpufreq are initialized correctly. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
The MT8183 clock drivers can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. For the apmixedsys driver, add a remove callback to properly support module unloading. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
The MT8186 apmixedsys driver can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
The MT8188 apmixedsys driver can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
The MT8192 clock drivers can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
The MT8195 apusys_pll and apmixedsys drivers can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. Note that the topckgen driver is excluded from this conversion because it requires devm_mtk_clk_mux_notifier_register(), which is not currently supported by the common simple probe helper. Since all MT8195 clock drivers can now be built as modules, change Kconfig setting to "tristate". Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
The MT8196 apmixedsys, mcusys and mfg clock drivers can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. Note that the vlpckgen driver is excluded from this conversion because its probe callback needs to initialize the APLL tuner registers, which is not currently supported by the common simple probe helper. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
The MT8516 apmixedsys driver can use the MediaTek clock framework common initialization sequence. Reduce boilerplate code by creating struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers. Also, add a remove callback to properly support module unloading. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
akku1139
force-pushed
the
patch/mediatek-clk-simple-probe
branch
from
August 3, 2026 14:01
536b623 to
266c8aa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#57
git grep -LFE --name-only '.remove = (mtk_clk_simple_remove|mtk_clk_pdev_remove)' clk-mt*.cgit grep -EFL module_platform_drivergit grep -F builtin_platform_drivergit grep -F arch_initcallgit grep -EFL MODULE_DEVICE_TABLE