Re: [PATCH 09/46] watchdog: sa1100: use platform device registration

Guenter Roeck
2019-10-22T13:39:02Z

On 10/22/19 2:44 AM, Arnd Bergmann wrote:
> On Sat, Oct 19, 2019 at 4:07 PM Guenter Roeck <linux@roeck-us.net> wrote:
>
>>> @@ -319,10 +316,13 @@ static struct platform_device *sa11x0_devices[] __initdata = {
>>>
>>> static int __init sa1100_init(void)
>>> {
>>> + struct resource wdt_res = DEFINE_RES_MEM(0x90000000, 0x20);
>>> pm_power_off = sa1100_power_off;
>>>
>>> regulator_has_full_constraints();
>>>
>>> + platform_device_register_simple("sa1100_wdt", -1, &wdt_res, 1);
>>> +
>>> return platform_add_devices(sa11x0_devices, ARRAY_SIZE(sa11x0_devices));
>>
>> Wouldn't it be better to add the watchdog device to sa11x0_devices ?
>
> Generally speaking, platform_device_register_simple() is better than
> platform_add_devices(), it does the same thing with fewer source lines
> and smaller object code, and it doesn't have the problem of lifetime rules
> for statically allocated reference-counted devices.
>
> One day we may want to replace all static platform_device instances with
> platform_device_info instead, but right now there are too many of those.
>
> I can change this one to a platform_device for consistency though if you
> think it's worth it.
>

No, I was just wondering. Thanks for the explanation.

Guenter