watchdog: ath79_wdt: select OF and COMPILE_TEST
PATCH 1/1 watchdog: ath79_wdt: select OF and COMPILE_TEST
This has always been an OF driver. Select OF in Kconfig.
Add COMPILE_TEST for all platforms, not just ARM.
--- drivers/watchdog/Kconfig | 3 ++- drivers/watchdog/ath79_wdt.c | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/watchdog/Kconfig +2 -1
@@ -1785,7 +1785,8 @@ config M54xx_WATCHDOG config ATH79_WDT tristate "Atheros AR71XX/AR724X/AR913X hardware watchdog" - depends on ATH79 || (ARM && COMPILE_TEST) + depends on ATH79 || COMPILE_TEST + depends on OF help Hardware driver for the built-in watchdog timer on the Atheros AR71XX/AR724X/AR913X SoCs.
drivers/watchdog/ath79_wdt.c +1 -3
@@ -295,13 +295,11 @@ static void ath79_wdt_shutdown(struct platform_device *pdev)ath79_wdt_disable (); } -#ifdef CONFIG_OF static const struct of_device_id ath79_wdt_match[] = { { .compatible ="qca,ar7130-wdt" }, {}, };MODULE_DEVICE_TABLE (of, ath79_wdt_match); -#endif static struct platform_driver ath79_wdt_driver = { .probe = ath79_wdt_probe,
@@ -309,7 +307,7 @@ static struct platform_driver ath79_wdt_driver = { .shutdown = ath79_wdt_shutdown, .driver = { .name = DRIVER_NAME, - .of_match_table = of_match_ptr(ath79_wdt_match), + .of_match_table = ath79_wdt_match, }, };
Signature · 1 line
2.54.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Permanent failure of deferred probing and device re-binding due to uncleared global `wdt_base`…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Permanent failure of deferred probing and device re-binding due to uncleared global wdt_base pointer on error paths.
- [Medium] Mismatch between Kconfig changes and commit message regarding OF dependency.
--
commit 279311df3b831cb8a967974beeea1a51baecd0ac
Author: Rosen Penev <[email protected]>
watchdog: ath79_wdt: select OF and COMPILE_TEST
This has always been an OF driver. Select OF in Kconfig.
Add COMPILE_TEST for all platforms, not just ARM.
Quoted 3 lines
watchdog:
ath79_wdt: select OF andCOMPILE_TESTThis has always been an OF driver. Select OF in
Kconfig.
There is a discrepancy between the commit message and the implemented code. The commit message states it will "select OF", but the patch implements "depends on OF". Could the commit message be updated to match the implementation?
drivers/watchdog/Kconfig config M54xx_WATCHDOG · line 1815
Quoted 11 lines
drivers/watchdog/Kconfig +2
-1@@ -1811,7 +1811,8 @@ config M54xx_WATCHDOG config ATH79_WDT tristate "Atheros AR71XX/AR724X/AR913X hardware watchdog" - depends on ATH79 || (ARM && COMPILE_TEST) + depends on ATH79 || COMPILE_TEST + depends on OF
[ ... ]
While reviewing this patch, I noticed an existing issue in the probe function's error handling. The driver uses a global pointer to enforce a singleton instance:
drivers/watchdog/ath79_wdt.c:ath79_wdt_probe() {
...
if (wdt_base)
return -EBUSY;
wdt_base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(wdt_base))
return PTR_ERR(wdt_base);
wdt_clk = devm_clk_get_enabled(&pdev->dev, "wdt");
if (IS_ERR(wdt_clk))
return PTR_ERR(wdt_clk);
...
}If devm_platform_ioremap_resource() returns an error pointer, or if a later step like devm_clk_get_enabled() returns -EPROBE_DEFER, the global wdt_base pointer is never cleared.
Does this permanently break deferred probing and device re-binding? On a second probe attempt, the uncleared wdt_base pointer would still evaluate to true, causing the probe to immediately fail with -EBUSY.
Similarly, since ath79_wdt_remove() does not clear wdt_base, will unloading and reloading the driver also fail?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 15 lines · On Mon, May 18, 2026 at 2:19 PM <[email protected]> wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Permanent failure of deferred probing and device re-binding due to uncleared globalwdt_basepointer on error paths.
- [Medium] Mismatch betweenKconfigchanges and commit message regarding OF dependency.
--commit
279311df3b831cb8a967974beeea1a51baecd0ac
Author: Rosen Penev <[email protected]>watchdog:
ath79_wdt: select OF andCOMPILE_TESTThis has always been an OF driver. Select OF in
Kconfig.Add
COMPILE_TESTfor all platforms, not just ARM.
Quoted 8 lines
Quoted 3 lines
watchdog:
ath79_wdt: select OF andCOMPILE_TESTThis has always been an OF driver. Select OF in
Kconfig.There is a discrepancy between the commit message and the implemented code. The commit message states it will "select OF", but the patch implements "depends on OF". Could the commit message be updated to match the implementation?
Yeah probably.
Quoted 15 lines
Quoted 12 lines
drivers/watchdog/Kconfig +2
-1@@ -1811,7 +1811,8 @@ config M54xx_WATCHDOG config ATH79_WDT tristate "Atheros AR71XX/AR724X/AR913X hardware watchdog" - depends on ATH79 || (ARM && COMPILE_TEST) + depends on ATH79 || COMPILE_TEST + depends on OF[ ... ]
Quoted 3 lines
While reviewing this patch, I noticed an existing issue in the probe function's error handling. The driver uses a global pointer to enforce a singleton instance:
Yes, this is an ancient driver that needs to be migrated to watchdog_device. This is not relevant to COMPILE_TEST though.
Quoted 29 lines
drivers/watchdog/ath79_wdt.c:ath79_wdt_probe() { ... if (wdt_base) return -EBUSY; wdt_base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(wdt_base)) return PTR_ERR(wdt_base); wdt_clk = devm_clk_get_enabled(&pdev->dev, "wdt"); if (IS_ERR(wdt_clk)) return PTR_ERR(wdt_clk); ... }If
devm_platform_ioremap_resource()returns an error pointer, or if a later step likedevm_clk_get_enabled()returns -EPROBE_DEFER, the globalwdt_basepointer is never cleared.Does this permanently break deferred probing and device re-binding? On a second probe attempt, the uncleared
wdt_basepointer would still evaluate to true, causing the probe to immediately fail with-EBUSY.Similarly, since
ath79_wdt_remove()does not clearwdt_base, will unloading and reloading the driver also fail?--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Rosen,
kernel test robot noticed the following build warnings:
[auto build test WARNING on groeck-staging/hwmon]
[also build test WARNING on groeck-staging/hwmon-next groeck-staging/watchdog groeck-staging/watchdog-next linus/master v7.1-rc4 next-20260518] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Rosen-Penev/watchdog-ath79_wdt-select-OF-and-COMPILE_TEST/20260519-051137 base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon patch link: https://lore.kernel.org/r/20260518210957.10545-1-rosenp%40gmail.com patch subject: [PATCH] watchdog: ath79_wdt: select OF and COMPILE_TEST config: riscv-randconfig-r122-20260519 (https://download.01.org/0day-ci/archive/20260520/[email protected]/config) compiler: riscv64-linux-gcc (GCC) 8.5.0 sparse: v0.6.5-rc1 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260520/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
>> drivers/watchdog/ath79_wdt.c:161:37: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected char const [noderef] __user *__p @@ got char const * @@ drivers/watchdog/ath79_wdt.c:161:37: sparse: expected char const [noderef] __user *__p drivers/watchdog/ath79_wdt.c:161:37: sparse: got char const * >> drivers/watchdog/ath79_wdt.c:234:27: sparse: sparse: incorrect type in initializer (incompatible argument 2 (different address spaces)) @@ expected long ( *write )( ... ) @@ got long ( * )( ... ) @@
drivers/watchdog/ath79_wdt.c:234:27: sparse: expected long ( *write )( ... )
drivers/watchdog/ath79_wdt.c:234:27: sparse: got long ( * )( ... )
vim +161 drivers/watchdog/ath79_wdt.c
f8394f61c66f48 Gabor Juhos 2011-01-04 148
f8394f61c66f48 Gabor Juhos 2011-01-04 149 static ssize_t ath79_wdt_write(struct file *file, const char *data,
f8394f61c66f48 Gabor Juhos 2011-01-04 150 size_t len, loff_t *ppos)
f8394f61c66f48 Gabor Juhos 2011-01-04 151 {
f8394f61c66f48 Gabor Juhos 2011-01-04 152 if (len) {
f8394f61c66f48 Gabor Juhos 2011-01-04 153 if (!nowayout) {
f8394f61c66f48 Gabor Juhos 2011-01-04 154 size_t i;
f8394f61c66f48 Gabor Juhos 2011-01-04 155
f8394f61c66f48 Gabor Juhos 2011-01-04 156 clear_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags);
f8394f61c66f48 Gabor Juhos 2011-01-04 157
f8394f61c66f48 Gabor Juhos 2011-01-04 158 for (i = 0; i != len; i++) {
f8394f61c66f48 Gabor Juhos 2011-01-04 159 char c;
f8394f61c66f48 Gabor Juhos 2011-01-04 160
f8394f61c66f48 Gabor Juhos 2011-01-04 @161 if (get_user(c, data + i))
f8394f61c66f48 Gabor Juhos 2011-01-04 162 return -EFAULT;
f8394f61c66f48 Gabor Juhos 2011-01-04 163
f8394f61c66f48 Gabor Juhos 2011-01-04 164 if (c == 'V')
f8394f61c66f48 Gabor Juhos 2011-01-04 165 set_bit(WDT_FLAGS_EXPECT_CLOSE,
f8394f61c66f48 Gabor Juhos 2011-01-04 166 &wdt_flags);
f8394f61c66f48 Gabor Juhos 2011-01-04 167 }
f8394f61c66f48 Gabor Juhos 2011-01-04 168 }
f8394f61c66f48 Gabor Juhos 2011-01-04 169
f8394f61c66f48 Gabor Juhos 2011-01-04 170 ath79_wdt_keepalive();
f8394f61c66f48 Gabor Juhos 2011-01-04 171 }
f8394f61c66f48 Gabor Juhos 2011-01-04 172
f8394f61c66f48 Gabor Juhos 2011-01-04 173 return len;
f8394f61c66f48 Gabor Juhos 2011-01-04 174 }
f8394f61c66f48 Gabor Juhos 2011-01-04 175
f8394f61c66f48 Gabor Juhos 2011-01-04 176 static const struct watchdog_info ath79_wdt_info = {
f8394f61c66f48 Gabor Juhos 2011-01-04 177 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING |
f8394f61c66f48 Gabor Juhos 2011-01-04 178 WDIOF_MAGICCLOSE | WDIOF_CARDRESET,
f8394f61c66f48 Gabor Juhos 2011-01-04 179 .firmware_version = 0,
f8394f61c66f48 Gabor Juhos 2011-01-04 180 .identity = "ATH79 watchdog",
f8394f61c66f48 Gabor Juhos 2011-01-04 181 };
f8394f61c66f48 Gabor Juhos 2011-01-04 182
f8394f61c66f48 Gabor Juhos 2011-01-04 183 static long ath79_wdt_ioctl(struct file *file, unsigned int cmd,
f8394f61c66f48 Gabor Juhos 2011-01-04 184 unsigned long arg)
f8394f61c66f48 Gabor Juhos 2011-01-04 185 {
f8394f61c66f48 Gabor Juhos 2011-01-04 186 void __user *argp = (void __user *)arg;
f8394f61c66f48 Gabor Juhos 2011-01-04 187 int __user *p = argp;
f8394f61c66f48 Gabor Juhos 2011-01-04 188 int err;
f8394f61c66f48 Gabor Juhos 2011-01-04 189 int t;
f8394f61c66f48 Gabor Juhos 2011-01-04 190
f8394f61c66f48 Gabor Juhos 2011-01-04 191 switch (cmd) {
f8394f61c66f48 Gabor Juhos 2011-01-04 192 case WDIOC_GETSUPPORT:
f8394f61c66f48 Gabor Juhos 2011-01-04 193 err = copy_to_user(argp, &ath79_wdt_info,
f8394f61c66f48 Gabor Juhos 2011-01-04 194 sizeof(ath79_wdt_info)) ? -EFAULT : 0;
f8394f61c66f48 Gabor Juhos 2011-01-04 195 break;
f8394f61c66f48 Gabor Juhos 2011-01-04 196
f8394f61c66f48 Gabor Juhos 2011-01-04 197 case WDIOC_GETSTATUS:
f8394f61c66f48 Gabor Juhos 2011-01-04 198 err = put_user(0, p);
f8394f61c66f48 Gabor Juhos 2011-01-04 199 break;
f8394f61c66f48 Gabor Juhos 2011-01-04 200
f8394f61c66f48 Gabor Juhos 2011-01-04 201 case WDIOC_GETBOOTSTATUS:
f8394f61c66f48 Gabor Juhos 2011-01-04 202 err = put_user(boot_status, p);
f8394f61c66f48 Gabor Juhos 2011-01-04 203 break;
f8394f61c66f48 Gabor Juhos 2011-01-04 204
f8394f61c66f48 Gabor Juhos 2011-01-04 205 case WDIOC_KEEPALIVE:
f8394f61c66f48 Gabor Juhos 2011-01-04 206 ath79_wdt_keepalive();
f8394f61c66f48 Gabor Juhos 2011-01-04 207 err = 0;
f8394f61c66f48 Gabor Juhos 2011-01-04 208 break;
f8394f61c66f48 Gabor Juhos 2011-01-04 209
f8394f61c66f48 Gabor Juhos 2011-01-04 210 case WDIOC_SETTIMEOUT:
f8394f61c66f48 Gabor Juhos 2011-01-04 211 err = get_user(t, p);
f8394f61c66f48 Gabor Juhos 2011-01-04 212 if (err)
f8394f61c66f48 Gabor Juhos 2011-01-04 213 break;
f8394f61c66f48 Gabor Juhos 2011-01-04 214
f8394f61c66f48 Gabor Juhos 2011-01-04 215 err = ath79_wdt_set_timeout(t);
f8394f61c66f48 Gabor Juhos 2011-01-04 216 if (err)
f8394f61c66f48 Gabor Juhos 2011-01-04 217 break;
bd490f8222510d Gustavo A. R. Silva 2020-07-07 218 fallthrough;
f8394f61c66f48 Gabor Juhos 2011-01-04 219
f8394f61c66f48 Gabor Juhos 2011-01-04 220 case WDIOC_GETTIMEOUT:
f8394f61c66f48 Gabor Juhos 2011-01-04 221 err = put_user(timeout, p);
f8394f61c66f48 Gabor Juhos 2011-01-04 222 break;
f8394f61c66f48 Gabor Juhos 2011-01-04 223
f8394f61c66f48 Gabor Juhos 2011-01-04 224 default:
f8394f61c66f48 Gabor Juhos 2011-01-04 225 err = -ENOTTY;
f8394f61c66f48 Gabor Juhos 2011-01-04 226 break;
f8394f61c66f48 Gabor Juhos 2011-01-04 227 }
f8394f61c66f48 Gabor Juhos 2011-01-04 228
f8394f61c66f48 Gabor Juhos 2011-01-04 229 return err;
f8394f61c66f48 Gabor Juhos 2011-01-04 230 }
f8394f61c66f48 Gabor Juhos 2011-01-04 231
f8394f61c66f48 Gabor Juhos 2011-01-04 232 static const struct file_operations ath79_wdt_fops = {
f8394f61c66f48 Gabor Juhos 2011-01-04 233 .owner = THIS_MODULE,
f8394f61c66f48 Gabor Juhos 2011-01-04 @234 .write = ath79_wdt_write,
f8394f61c66f48 Gabor Juhos 2011-01-04 235 .unlocked_ioctl = ath79_wdt_ioctl,
b6dfb2477fb0bf Arnd Bergmann 2019-06-03 236 .compat_ioctl = compat_ptr_ioctl,
f8394f61c66f48 Gabor Juhos 2011-01-04 237 .open = ath79_wdt_open,
f8394f61c66f48 Gabor Juhos 2011-01-04 238 .release = ath79_wdt_release,
f8394f61c66f48 Gabor Juhos 2011-01-04 239 };
f8394f61c66f48 Gabor Juhos 2011-01-04 240 --
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki