[EXT] Re: [PATCH v4 3/4] clocksource/drivers/timer-mediatek: Convert timer-mediatek to a loadable module

Daniel Lezcano daniel.lezcano at oss.qualcomm.com
Wed Mar 25 07:42:57 PDT 2026


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

#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.




More information about the Linux-mediatek mailing list