Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

watchdog: loongson1_wdt: Add DT support

This patch adds the of_match_table to enable DT support
of Loongson-1 watchdog driver.
And modify the parameter of devm_clk_get_enabled() accordingly.

Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lkml.kernel.org/r/20230511121159.463645-3-keguang.zhang@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>

authored by

Keguang Zhang and committed by
Wim Van Sebroeck
20fbe629 547cc9be

+12 -1
+12 -1
drivers/watchdog/loongson1_wdt.c
··· 5 5 6 6 #include <linux/clk.h> 7 7 #include <linux/module.h> 8 + #include <linux/of.h> 8 9 #include <linux/platform_device.h> 9 10 #include <linux/watchdog.h> 10 11 ··· 113 112 if (IS_ERR(drvdata->base)) 114 113 return PTR_ERR(drvdata->base); 115 114 116 - drvdata->clk = devm_clk_get_enabled(dev, pdev->name); 115 + drvdata->clk = devm_clk_get_enabled(dev, NULL); 117 116 if (IS_ERR(drvdata->clk)) 118 117 return PTR_ERR(drvdata->clk); 119 118 ··· 145 144 return 0; 146 145 } 147 146 147 + #ifdef CONFIG_OF 148 + static const struct of_device_id ls1x_wdt_dt_ids[] = { 149 + { .compatible = "loongson,ls1b-wdt", }, 150 + { .compatible = "loongson,ls1c-wdt", }, 151 + { /* sentinel */ } 152 + }; 153 + MODULE_DEVICE_TABLE(of, ls1x_wdt_dt_ids); 154 + #endif 155 + 148 156 static struct platform_driver ls1x_wdt_driver = { 149 157 .probe = ls1x_wdt_probe, 150 158 .driver = { 151 159 .name = "ls1x-wdt", 160 + .of_match_table = of_match_ptr(ls1x_wdt_dt_ids), 152 161 }, 153 162 }; 154 163