[PATCH] watchdog: mtk_wdt: Move mt6589-wdt fallback compatible to end of list

From: Chen-Yu Tsai
Date: Tue Jul 26 2022 - 02:25:51 EST


The watchdog facility in the MediaTek SoCs are all the same, but the
hardware block also contains a reset controller, which differs in the
number of resets used between different SoCs. This difference is
supported with of_device_get_match_data() supplying the number of reset
lines for the newer compatible strings. The original mt6589-wdt only
covers the watchdog facility.

of_device_is_compatible(), and by extension of_device_get_match_data(),
works by going through the given list of compatible strings sequentially,
and checks if any of the device node's compatible strings match.

To avoid early matching on the "mediatek,mt6589-wdt" fallback compatible,
which only provides watchdog functionality and no reset controller, move
the fallback entry to the end of the list, so that other, more specific
compatible strings have a chance at getting matched.

Fixes: c254e103082b ("watchdog: mtk_wdt: mt8183: Add reset controller")
Fixes: adc318a34066 ("watchdog: mt8192: add wdt support")
Fixes: 8c6b5ea6ac68 ("watchdog: mediatek: mt8195: add wdt support")
Fixes: 4dbabc4d9e8c ("watchdog: mediatek: mt8186: add wdt support")
Fixes: 711a5b25bac9 ("watchdog: mtk_wdt: mt7986: Add toprgu reset controller support")
Signed-off-by: Chen-Yu Tsai <wenst@xxxxxxxxxxxx>
---

This change complements the removal of the fallback compatible from the
bindings and DTSI files [1].

[1] https://lore.kernel.org/linux-mediatek/20220721014845.19044-1-allen-kh.cheng@xxxxxxxxxxxx/

drivers/watchdog/mtk_wdt.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c
index e97787536792..3d5a239b93ba 100644
--- a/drivers/watchdog/mtk_wdt.c
+++ b/drivers/watchdog/mtk_wdt.c
@@ -425,12 +425,13 @@ static int mtk_wdt_resume(struct device *dev)

static const struct of_device_id mtk_wdt_dt_ids[] = {
{ .compatible = "mediatek,mt2712-wdt", .data = &mt2712_data },
- { .compatible = "mediatek,mt6589-wdt" },
{ .compatible = "mediatek,mt7986-wdt", .data = &mt7986_data },
{ .compatible = "mediatek,mt8183-wdt", .data = &mt8183_data },
{ .compatible = "mediatek,mt8186-wdt", .data = &mt8186_data },
{ .compatible = "mediatek,mt8192-wdt", .data = &mt8192_data },
{ .compatible = "mediatek,mt8195-wdt", .data = &mt8195_data },
+ /* Fallback compatible string must be last entry */
+ { .compatible = "mediatek,mt6589-wdt" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, mtk_wdt_dt_ids);
--
2.37.1.359.gd136c6c3e2-goog