[EXT] Re: [PATCH v4 3/4] clocksource/drivers/timer-mediatek: Convert timer-mediatek to a loadable module
Zhipeng Wang
zhipeng.wang_1 at nxp.com
Thu Mar 26 03:34:42 PDT 2026
> -----Original Message-----
> From: Daniel Lezcano <daniel.lezcano at oss.qualcomm.com>
> Sent: 2026年3月25日 22:43
> To: Zhipeng Wang <zhipeng.wang_1 at nxp.com>
> Cc: daniel.lezcano at linaro.org; tglx at kernel.org; shawnguo at kernel.org;
> s.hauer at pengutronix.de; kernel at pengutronix.de; festevam at gmail.com;
> matthias.bgg at gmail.com; angelogioacchino.delregno at collabora.com;
> linux-kernel at vger.kernel.org; imx at lists.linux.dev;
> linux-arm-kernel at lists.infradead.org; linux-mediatek at lists.infradead.org;
> chun-hung.wu at mediatek.com; walter.chang at mediatek.com;
> jstultz at google.com; amergnat at baylibre.com; Aisheng Dong
> <aisheng.dong at nxp.com>; Jindong Yue <jindong.yue at nxp.com>; Xuegang Liu
> <xuegang.liu at nxp.com>; Greg Kroah-Hartman <gregkh at google.com>
> Subject: Re: [EXT] Re: [PATCH v4 3/4] clocksource/drivers/timer-mediatek:
> Convert timer-mediatek to a loadable module
>
> Caution: This is an external email. Please take care when clicking links or
> opening attachments. When in doubt, report the message using the 'Report
> this email' button
>
>
> Hi Zhipeng,
>
> On 3/10/26 09:41, Zhipeng Wang wrote:
> >>
> >>
> >> Hi Zhipeng,
> >>
> >> On 3/9/26 06:31, Zhipeng Wang wrote:
> >>> Hello Daniel,
> >>>
> >>> I'd be very happy to collaborate on this!
> >>
> >> Great, let me see if I can cook a patch in the next days
> >>
> >>> My availability: I can dedicate time to work on this over the next few
> weeks.
> >> I'm happy to help with:
> >>> - Testing the new macros with IMX timer drivers
> >>> - Converting existing drivers as examples
> >>> - Reviewing and testing patches
> >>> - Documentation
> >>
> >> That's awesome, thanks
> >>
> >>> My understanding is that, based on your RFC, we should use two
> >>> macros —
> >> TIMER_OF_DECLARE_PDEV and TIMER_OF_DECLARE_PLATFORM_DRIVER.
> >>
> >> Yes, but also sort out the existing TIMER_OF_DECLARE macro vs MODULE
> >> in order to prevent #ifdef MODULE in the drivers
> >>
> > Hi Daniel,
> >
> > Yes, that's our goal.
> >
> > I'll test the new macros (TIMER_OF_DECLARE_PLATFORM_DRIVER and
> > TIMER_OF_DECLARE_EARLY_PLATFORM_DRIVER) with the IMX timer drivers
> > once the patches are available.
>
> I think I have an idea on how to achieve that. That will result in the removal of
> TIMER_OF_DECLARE() when all drivers will be changed to use the new macro.
>
> The #ifdef MODULE macro is set when the driver is compiled as a module.
>
> So we can do something like:
>
> #ifdef MODULE
>
I think there might be a typo here - should this be "#ifndef MODULE" instead?
> #define TIMER_OF_DECLARE_PDEV(name, compat, data, fn) \
> OF_DECLARE_1_RET(timer_pdev, name, compat, data, fn)
>
>
> #else
>
> #define TIMER_OF_DECLARE_PDEV(__name, compat, data, fn) \
> OF_DECLARE_1_RET(of_pdev_timer_match_table,
> __name, compat, data, fn)
>
> static struct platform_driver __##__name##_timer_driver = {
> .probe = __##__name##_timer_probe,
> .driver = {
> .name = name,
> .of_match_table = of_pdev_timer_match_table,
> },
> };
> module_platform_driver(__##__name##_timer_driver);
>
> #endif
>
> So we deal with two tables, one for platform device non module and one
> module for modules.
>
> The first one is called by the timer-of init routine. The other one is called by the
> probe function.
>
> The drawback will be the match table will be common to all timer drivers. So
> probe will be a bit slower. May be there is an area of optimization here.
This doesn't support EPROBE_DEFER for built-in drivers, correct?
BRs,
Zhipeng
More information about the Linux-mediatek
mailing list