Re: [PATCH] watchdog: take all OF aliases into account when assigning id

From: Guenter Roeck

Date: Wed Jul 08 2026 - 11:08:33 EST


On Mon, Jun 15, 2026 at 04:57:59PM +0200, Rasmus Villemoes wrote:
> If some, but not all, watchdog devices have device tree aliases, those
> without aliases might (depending on probe order) be assigned an id
> which would otherwise be assigned to one of those with an alias.
>
> This is problematic when for example watchdog0 is an alias for an
> always-running gpio watchdog that userspace must handle, but the SOC's
> watchdog device(s) get probed first and thus one of those become
> /dev/watchdog0.
>
> Ensure that ids for devices without a device tree alias are allocated
> from above the highest numbered alias, if any.
>
> Signed-off-by: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>
> ---
>
> This is similar to how the mmc, i2c, i3c and spi subsystems handle
> device tree aliases and avoid using an id that might be assigned to a
> device/bus that is probed later.

The patch makes sense. Unfortunately, there are systems with aliased
watchdogs which do not enable "watchdog0" (e.g., several Nuvoton based
boards). On such systems, if they do have an unaliased / auto-generated
watchdog, /dev/watchdog0 and with it /dev/watchdog would no longer be
created. This would result in a ABI break.

On top of that, the patch only affects systems with both aliased and
un-aliased watchdogs, which makes me even more concerned.

To apply this or a similar patch, we would have to ensure that there
is no enabled watchdog with ID == 0.

Thanks,
Guenter