From: Justin Yeh <justin.yeh@mediatek.com>
To: Sean Wang <sean.wang@kernel.org>,
Linus Walleij <linusw@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>
Cc: <Project_Global_Chrome_Upstream_Group@mediatek.com>,
<linux-mediatek@lists.infradead.org>,
<linux-gpio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
Justin Yeh <justin.yeh@mediatek.com>
Subject: [PATCH v5 3/4] pinctrl: mediatek: mt7986: register both platform drivers from a single initcall
Date: Thu, 9 Jul 2026 14:33:48 +0800 [thread overview]
Message-ID: <20260709063450.1615041-4-justin.yeh@mediatek.com> (raw)
In-Reply-To: <20260709063450.1615041-1-justin.yeh@mediatek.com>
The MT7986 driver registers two separate platform drivers (mt7986a and
mt7986b) and used to call arch_initcall() twice, once for each.
This is fine while the driver is built-in, but a single translation unit
can only provide one module_init(). Since arch_initcall() expands to
module_init() when built as a module, having two of them would break the
module build with a redefinition of init_module()/__inittest().
Fold both platform drivers into a single driver array and register them
from one initcall using platform_register_drivers(), matching the shape of
the other MediaTek pinctrl SoC drivers. platform_register_drivers() also
rolls back the first registration if the second one fails.
No functional change for built-in builds; this is a preparatory cleanup
for enabling module builds.
Signed-off-by: Justin Yeh <justin.yeh@mediatek.com>
---
drivers/pinctrl/mediatek/pinctrl-mt7986.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7986.c b/drivers/pinctrl/mediatek/pinctrl-mt7986.c
index 5dda4b7467fd..8dae91530d9b 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt7986.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt7986.c
@@ -997,15 +997,14 @@ static struct platform_driver mt7986b_pinctrl_driver = {
.probe = mt7986b_pinctrl_probe,
};
-static int __init mt7986a_pinctrl_init(void)
-{
- return platform_driver_register(&mt7986a_pinctrl_driver);
-}
+static struct platform_driver * const mt7986_pinctrl_drivers[] = {
+ &mt7986a_pinctrl_driver,
+ &mt7986b_pinctrl_driver,
+};
-static int __init mt7986b_pinctrl_init(void)
+static int __init mt7986_pinctrl_init(void)
{
- return platform_driver_register(&mt7986b_pinctrl_driver);
+ return platform_register_drivers(mt7986_pinctrl_drivers,
+ ARRAY_SIZE(mt7986_pinctrl_drivers));
}
-
-arch_initcall(mt7986a_pinctrl_init);
-arch_initcall(mt7986b_pinctrl_init);
+arch_initcall(mt7986_pinctrl_init);
--
2.45.2
next prev parent reply other threads:[~2026-07-09 6:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 6:33 [PATCH v5 0/4] pinctrl: mediatek: Enable module build support Justin Yeh
2026-07-09 6:33 ` [PATCH v5 1/4] pinctrl: mediatek: use devm_gpiochip_add_data() for GPIO chip Justin Yeh
2026-07-09 8:26 ` Chen-Yu Tsai
2026-07-09 6:33 ` [PATCH v5 2/4] pinctrl: mediatek: allow common drivers to be built as modules Justin Yeh
2026-07-09 8:23 ` Chen-Yu Tsai
2026-07-09 6:33 ` Justin Yeh [this message]
2026-07-09 7:02 ` [PATCH v5 3/4] pinctrl: mediatek: mt7986: register both platform drivers from a single initcall Chen-Yu Tsai
2026-07-09 6:33 ` [PATCH v5 4/4] pinctrl: mediatek: enable module build support for all SoC drivers Justin Yeh
2026-07-10 20:29 ` [PATCH v5 0/4] pinctrl: mediatek: Enable module build support Linus Walleij
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=20260709063450.1615041-4-justin.yeh@mediatek.com \
--to=justin.yeh@mediatek.com \
--cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=sean.wang@kernel.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