watchdog: orion: Use of_device_get_match_data()
PATCH 1/1 watchdog: orion: Use of_device_get_match_data()
Use of_device_get_match_data() to fetch watchdog match data directly instead of open-coding an of_match_device() lookup.
Keep the existing legacy fallback when no match data is available.
This also lets the driver drop the of_device.h include.
--- drivers/watchdog/orion_wdt.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/watchdog/orion_wdt.c +3 -6
@@ -21,7 +21,6 @@#include <linux/clk.h> #include <linux/err.h> #include <linux/of.h> -#include <linux/of_device.h> /* RSTOUT mask register physical address for Orion5x, Kirkwood and Dove */ #define ORION_RSTOUT_MASK_OFFSET 0x20108
@@ -554,7 +553,6 @@ static int orion_wdt_get_regs(struct platform_device *pdev,static int orion_wdt_probe (struct platform_device *pdev) {struct orion_watchdog *dev; -const struct of_device_id *match;unsigned int wdt_max_duration;/* (seconds) */ int ret, irq;
@@ -563,15 +561,14 @@ static int orion_wdt_probe(struct platform_device *pdev)if (!dev)return -ENOMEM ; - match =of_match_device (orion_wdt_of_match_table, &pdev->dev); -if (!match) + dev->data =of_device_get_match_data (&pdev->dev); +if (!dev->data)/* Default legacy match */ - match = &orion_wdt_of_match_table[0 ]; + dev->data = orion_wdt_of_match_table[0 ].data; dev->wdt.info = &orion_wdt_info; dev->wdt.ops = &orion_wdt_ops; dev->wdt.min_timeout =1 ; - dev->data = match->data; ret =orion_wdt_get_regs (pdev, dev);if (ret)
--
2.54.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The clock is explicitly disabled before the `devm`-managed interrupt is freed, leading to a…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The clock is explicitly disabled before the devm-managed interrupt is freed, leading to a potential bus fault or system hang. This problem wasn't introduced by this patch, but it is a pre-existing high-severity bug. --
commit d9eb7a064a32ff51e0077728d87320936861ffad
Author: Rosen Penev <[email protected]>
watchdog: orion: Use of_device_get_match_data()
Use of_device_get_match_data() to fetch watchdog match data directly instead of open-coding an of_match_device() lookup.
Quoted 4 lines
drivers/watchdog/orion_wdt.c +0
-0
[ ... ]
Quoted 9 lines
drivers/watchdog/orion_wdt.c +2
-2@@ -563,15 +561,14 @@ static int orion_wdt_probe(struct platform_device *pdev)if (!dev)return -ENOMEM ; - match =of_match_device (orion_wdt_of_match_table, &pdev->dev); -if (!match) + dev->data =of_device_get_match_data (&pdev->dev); +if (!dev->data)/* Default legacy match */
drivers/watchdog/orion_wdt.c static int orion_wdt_probe(struct platform_device *pdev) · line 574
Quoted 10 lines
drivers/watchdog/orion_wdt.c +1
-2- match = &orion_wdt_of_match_table[0 ]; + dev->data = orion_wdt_of_match_table[0 ].data; dev->wdt.info = &orion_wdt_info; dev->wdt.ops = &orion_wdt_ops; dev->wdt.min_timeout =1 ; - dev->data = match->data; ret =orion_wdt_get_regs (pdev, dev);if (ret)
While reviewing this patch, I noticed a pre-existing issue in the probe error path.
If watchdog_register_device() fails later in orion_wdt_probe(), the code jumps to the disable_clk label:
ret = watchdog_register_device(&dev->wdt);
if (ret)
goto disable_clk;[ ... ]
disable_clk:
clk_disable_unprepare(dev->clk);
clk_put(dev->clk);
return ret;Since devm_request_irq() is used to allocate the interrupts, the devres core will automatically free them only after the probe function returns.
Does this create a teardown window where the clock is explicitly disabled but the interrupts remain active?
If a watchdog pre-timeout interrupt fires during this window, could the handlers (orion_wdt_pre_irq or orion_wdt_irq) attempt to access memory-mapped hardware registers while the clock is turned off, resulting in a bus fault or system hang?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1