watchdog: Convert drivers to DEFINE_SIMPLE_DEV_PM_OPS()
Subsystems (6)
cover watchdog: Convert drivers to DEFINE_SIMPLE_DEV_PM_OPS()
This series converts the watchdog drivers to use DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr().
This is a straightforward cleanup with no functional change intended.
Triet Hoang (8):
watchdog: cadence_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
watchdog: da9062: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
watchdog: keembay_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
watchdog: msc313e_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
watchdog: of_xilinx_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
watchdog: pm8916_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
watchdog: sp805_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
watchdog: stmp3xxx_rtc_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
drivers/watchdog/cadence_wdt.c | 8 ++++---- drivers/watchdog/da9062_wdt.c | 8 ++++---- drivers/watchdog/keembay_wdt.c | 8 ++++---- drivers/watchdog/msc313e_wdt.c | 8 ++++---- drivers/watchdog/of_xilinx_wdt.c | 8 ++++---- drivers/watchdog/pm8916_wdt.c | 8 ++++---- drivers/watchdog/sp805_wdt.c | 8 ++++---- drivers/watchdog/stmp3xxx_rtc_wdt.c | 8 ++++---- 8 files changed, 32 insertions(+), 32 deletions(-)
Signature · 1 line
2.53.0
PATCH 1/8 watchdog: cadence_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
Convert deprecated SIMPLE_DEV_PM_OPS() to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr().
This lets us drop the __maybe_unused annotations from the resume callback.
--- drivers/watchdog/cadence_wdt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/cadence_wdt.c +4 -4
@@ -359,7 +359,7 @@ static int cdns_wdt_probe(struct platform_device *pdev)* @dev: handle to the device structure. * Return: 0 always. */ -static int __maybe_unused cdns_wdt_suspend (struct device *dev) +static int cdns_wdt_suspend (struct device *dev) {struct cdns_wdt *wdt =dev_get_drvdata (dev);
@@ -377,7 +377,7 @@ static int __maybe_unused cdns_wdt_suspend(struct device *dev)* @dev: handle to the device structure. * Return: 0 on success, errno otherwise. */ -static int __maybe_unused cdns_wdt_resume (struct device *dev) +static int cdns_wdt_resume (struct device *dev) {int ret;struct cdns_wdt *wdt =dev_get_drvdata (dev);
@@ -394,7 +394,7 @@ static int __maybe_unused cdns_wdt_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(cdns_wdt_pm_ops, cdns_wdt_suspend, cdns_wdt_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(cdns_wdt_pm_ops, cdns_wdt_suspend, cdns_wdt_resume);static const struct of_device_id cdns_wdt_of_match[] = { { .compatible ="cdns,wdt-r1p2" , },
@@ -408,7 +408,7 @@ static struct platform_driver cdns_wdt_driver = { .driver = { .name = "cdns-wdt", .of_match_table = cdns_wdt_of_match, - .pm = &cdns_wdt_pm_ops, + .pm = pm_sleep_ptr(&cdns_wdt_pm_ops), }, };
Signature · 1 line
2.53.0
PATCH 2/8 watchdog: da9062: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
In reply to Triet HoangConvert deprecated SIMPLE_DEV_PM_OPS() to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr().
This lets us drop the __maybe_unused annotations from the resume callback.
--- drivers/watchdog/da9062_wdt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/da9062_wdt.c +4 -4
@@ -248,7 +248,7 @@ static int da9062_wdt_probe(struct platform_device *pdev)return devm_watchdog_register_device (dev, &wdt->wdtdev); } -static int __maybe_unused da9062_wdt_suspend (struct device *dev) +static int da9062_wdt_suspend (struct device *dev) {struct watchdog_device *wdd =dev_get_drvdata (dev);struct da9062_watchdog *wdt =watchdog_get_drvdata (wdd);
@@ -262,7 +262,7 @@ static int __maybe_unused da9062_wdt_suspend(struct device *dev)return 0 ; } -static int __maybe_unused da9062_wdt_resume (struct device *dev) +static int da9062_wdt_resume (struct device *dev) {struct watchdog_device *wdd =dev_get_drvdata (dev);struct da9062_watchdog *wdt =watchdog_get_drvdata (wdd);
@@ -276,14 +276,14 @@ static int __maybe_unused da9062_wdt_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(da9062_wdt_pm_ops, +static DEFINE_SIMPLE_DEV_PM_OPS(da9062_wdt_pm_ops, da9062_wdt_suspend, da9062_wdt_resume);static struct platform_driver da9062_wdt_driver = { .probe = da9062_wdt_probe, .driver = { .name ="da9062-watchdog" , - .pm = &da9062_wdt_pm_ops, + .pm =pm_sleep_ptr (&da9062_wdt_pm_ops), .of_match_table = da9062_compatible_id_table, }, };
Signature · 1 line
2.53.0
PATCH 3/8 watchdog: keembay_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
In reply to Triet HoangConvert deprecated SIMPLE_DEV_PM_OPS() to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr().
This lets us drop the __maybe_unused annotations from the resume callback.
--- drivers/watchdog/keembay_wdt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/keembay_wdt.c +4 -4
@@ -250,7 +250,7 @@ static int keembay_wdt_probe(struct platform_device *pdev)return 0 ; } -static int __maybe_unused keembay_wdt_suspend (struct device *dev) +static int keembay_wdt_suspend (struct device *dev) {struct keembay_wdt *wdt =dev_get_drvdata (dev);
@@ -260,7 +260,7 @@ static int __maybe_unused keembay_wdt_suspend(struct device *dev)return 0 ; } -static int __maybe_unused keembay_wdt_resume (struct device *dev) +static int keembay_wdt_resume (struct device *dev) {struct keembay_wdt *wdt =dev_get_drvdata (dev);
@@ -270,7 +270,7 @@ static int __maybe_unused keembay_wdt_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(keembay_wdt_pm_ops, keembay_wdt_suspend, +static DEFINE_SIMPLE_DEV_PM_OPS(keembay_wdt_pm_ops, keembay_wdt_suspend, keembay_wdt_resume);static const struct of_device_id keembay_wdt_match[] = {
@@ -284,7 +284,7 @@ static struct platform_driver keembay_wdt_driver = { .driver = { .name = "keembay_wdt", .of_match_table = keembay_wdt_match, - .pm = &keembay_wdt_pm_ops, + .pm = pm_sleep_ptr(&keembay_wdt_pm_ops), }, };
Signature · 1 line
2.53.0
PATCH 4/8 watchdog: msc313e_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
In reply to Triet HoangConvert deprecated SIMPLE_DEV_PM_OPS() to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr().
This lets us drop the __maybe_unused annotations from the resume callback.
--- drivers/watchdog/msc313e_wdt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/msc313e_wdt.c +4 -4
@@ -132,7 +132,7 @@ static int msc313e_wdt_probe(struct platform_device *pdev)return devm_watchdog_register_device (dev, &priv->wdev); } -static int __maybe_unused msc313e_wdt_suspend (struct device *dev) +static int msc313e_wdt_suspend (struct device *dev) {struct msc313e_wdt_priv *priv =dev_get_drvdata (dev);
@@ -142,7 +142,7 @@ static int __maybe_unused msc313e_wdt_suspend(struct device *dev)return 0 ; } -static int __maybe_unused msc313e_wdt_resume (struct device *dev) +static int msc313e_wdt_resume (struct device *dev) {struct msc313e_wdt_priv *priv =dev_get_drvdata (dev);
@@ -152,13 +152,13 @@ static int __maybe_unused msc313e_wdt_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(msc313e_wdt_pm_ops, msc313e_wdt_suspend, msc313e_wdt_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(msc313e_wdt_pm_ops, msc313e_wdt_suspend, msc313e_wdt_resume);static struct platform_driver msc313e_wdt_driver = { .driver = { .name ="msc313e-wdt" , .of_match_table = msc313e_wdt_of_match, - .pm = &msc313e_wdt_pm_ops, + .pm =pm_sleep_ptr (&msc313e_wdt_pm_ops), }, .probe = msc313e_wdt_probe, };
Signature · 1 line
2.53.0
PATCH 5/8 watchdog: of_xilinx_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
In reply to Triet HoangConvert deprecated SIMPLE_DEV_PM_OPS() to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr().
This lets us drop the __maybe_unused annotations from the resume callback.
--- drivers/watchdog/of_xilinx_wdt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/of_xilinx_wdt.c +4 -4
@@ -251,7 +251,7 @@ static int xwdt_probe(struct platform_device *pdev)* @dev: handle to the device structure. * Return: 0 always. */ -static int __maybe_unused xwdt_suspend (struct device *dev) +static int xwdt_suspend (struct device *dev) {struct xwdt_device *xdev =dev_get_drvdata (dev);
@@ -267,7 +267,7 @@ static int __maybe_unused xwdt_suspend(struct device *dev)* @dev: handle to the device structure. * Return: 0 on success, errno otherwise. */ -static int __maybe_unused xwdt_resume (struct device *dev) +static int xwdt_resume (struct device *dev) {struct xwdt_device *xdev =dev_get_drvdata (dev);int ret =0 ;
@@ -278,7 +278,7 @@ static int __maybe_unused xwdt_resume(struct device *dev)return ret; } -static SIMPLE_DEV_PM_OPS(xwdt_pm_ops, xwdt_suspend, xwdt_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(xwdt_pm_ops, xwdt_suspend, xwdt_resume);/* Match table for of_platform binding */ static const struct of_device_id xwdt_of_match[] = {
@@ -293,7 +293,7 @@ static struct platform_driver xwdt_driver = { .driver = { .name = WATCHDOG_NAME, .of_match_table = xwdt_of_match, - .pm = &xwdt_pm_ops, + .pm = pm_sleep_ptr(&xwdt_pm_ops), }, };
Signature · 1 line
2.53.0
PATCH 6/8 watchdog: pm8916_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
In reply to Triet HoangConvert deprecated SIMPLE_DEV_PM_OPS() to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr().
This lets us drop the __maybe_unused annotations from the resume callback.
--- drivers/watchdog/pm8916_wdt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/pm8916_wdt.c +4 -4
@@ -233,7 +233,7 @@ static int pm8916_wdt_probe(struct platform_device *pdev)return devm_watchdog_register_device (dev, &wdt->wdev); } -static int __maybe_unused pm8916_wdt_suspend (struct device *dev) +static int pm8916_wdt_suspend (struct device *dev) {struct pm8916_wdt *wdt =dev_get_drvdata (dev);
@@ -243,7 +243,7 @@ static int __maybe_unused pm8916_wdt_suspend(struct device *dev)return 0 ; } -static int __maybe_unused pm8916_wdt_resume (struct device *dev) +static int pm8916_wdt_resume (struct device *dev) {struct pm8916_wdt *wdt =dev_get_drvdata (dev);
@@ -253,7 +253,7 @@ static int __maybe_unused pm8916_wdt_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(pm8916_wdt_pm_ops, pm8916_wdt_suspend, +static DEFINE_SIMPLE_DEV_PM_OPS(pm8916_wdt_pm_ops, pm8916_wdt_suspend, pm8916_wdt_resume);static const struct of_device_id pm8916_wdt_id_table[] = {
@@ -267,7 +267,7 @@ static struct platform_driver pm8916_wdt_driver = { .driver = { .name = "pm8916-wdt", .of_match_table = pm8916_wdt_id_table, - .pm = &pm8916_wdt_pm_ops, + .pm = pm_sleep_ptr(&pm8916_wdt_pm_ops), }, };module_platform_driver (pm8916_wdt_driver);
Signature · 1 line
2.53.0
PATCH 7/8 watchdog: sp805_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
In reply to Triet HoangConvert deprecated SIMPLE_DEV_PM_OPS() to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr().
This lets us drop the __maybe_unused annotations from the resume callback.
--- drivers/watchdog/sp805_wdt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/sp805_wdt.c +4 -4
@@ -321,7 +321,7 @@ static void sp805_wdt_remove(struct amba_device *adev)watchdog_set_drvdata (&wdt->wdd,NULL ); } -static int __maybe_unused sp805_wdt_suspend (struct device *dev) +static int sp805_wdt_suspend (struct device *dev) {struct sp805_wdt *wdt =dev_get_drvdata (dev);
@@ -331,7 +331,7 @@ static int __maybe_unused sp805_wdt_suspend(struct device *dev)return 0 ; } -static int __maybe_unused sp805_wdt_resume (struct device *dev) +static int sp805_wdt_resume (struct device *dev) {struct sp805_wdt *wdt =dev_get_drvdata (dev);
@@ -341,7 +341,7 @@ static int __maybe_unused sp805_wdt_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(sp805_wdt_dev_pm_ops, sp805_wdt_suspend, +static DEFINE_SIMPLE_DEV_PM_OPS(sp805_wdt_dev_pm_ops, sp805_wdt_suspend, sp805_wdt_resume);static const struct amba_id sp805_wdt_ids[] = {
@@ -361,7 +361,7 @@ MODULE_DEVICE_TABLE(amba, sp805_wdt_ids);static struct amba_driver sp805_wdt_driver = { .drv = { .name =MODULE_NAME , - .pm = &sp805_wdt_dev_pm_ops, + .pm =pm_sleep_ptr (&sp805_wdt_dev_pm_ops), }, .id_table = sp805_wdt_ids, .probe = sp805_wdt_probe,
Signature · 1 line
2.53.0
PATCH 8/8 watchdog: stmp3xxx_rtc_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
In reply to Triet HoangConvert deprecated SIMPLE_DEV_PM_OPS() to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr().
This lets us drop the __maybe_unused annotations from the resume callback.
--- drivers/watchdog/stmp3xxx_rtc_wdt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/watchdog/stmp3xxx_rtc_wdt.c +4 -4
@@ -114,7 +114,7 @@ static void stmp3xxx_wdt_remove(struct platform_device *pdev)unregister_reboot_notifier (&wdt_notifier); } -static int __maybe_unused stmp3xxx_wdt_suspend (struct device *dev) +static int stmp3xxx_wdt_suspend (struct device *dev) {struct watchdog_device *wdd = &stmp3xxx_wdd;
@@ -124,7 +124,7 @@ static int __maybe_unused stmp3xxx_wdt_suspend(struct device *dev)return 0 ; } -static int __maybe_unused stmp3xxx_wdt_resume (struct device *dev) +static int stmp3xxx_wdt_resume (struct device *dev) {struct watchdog_device *wdd = &stmp3xxx_wdd;
@@ -134,13 +134,13 @@ static int __maybe_unused stmp3xxx_wdt_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(stmp3xxx_wdt_pm_ops, +static DEFINE_SIMPLE_DEV_PM_OPS(stmp3xxx_wdt_pm_ops, stmp3xxx_wdt_suspend, stmp3xxx_wdt_resume);static struct platform_driver stmp3xxx_wdt_driver = { .driver = { .name ="stmp3xxx_rtc_wdt" , - .pm = &stmp3xxx_wdt_pm_ops, + .pm =pm_sleep_ptr (&stmp3xxx_wdt_pm_ops), }, .probe = stmp3xxx_wdt_probe, .remove = stmp3xxx_wdt_remove,
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH 3/8] watchdog: keembay_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
In reply to Triet HoangThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The driver uses `pm_sleep_ptr()` for the `dev_pm_ops` structure pointer in the platform driver…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The driver uses pm_sleep_ptr() for the dev_pm_ops structure pointer in the platform driver definition, which violates the strict subsystem guidelines mandating pm_ptr(). --
commit a755ace210f3814431fd01a8ffbd96e121f18dda
Author: Triet Hoang <[email protected]>
watchdog: keembay_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
This commit converts the deprecated SIMPLE_DEV_PM_OPS() to DEFINE_SIMPLE_DEV_PM_OPS() and wraps the PM operations pointer with pm_sleep_ptr(). This enables dropping the __maybe_unused annotations from the suspend and resume callbacks.
Quoted 4 lines
drivers/watchdog/keembay_wdt.c +0
-0
[ ... ]
drivers/watchdog/keembay_wdt.c static struct platform_driver keembay_wdt_driver = { · line 288
Quoted 6 lines
drivers/watchdog/keembay_wdt.c +1
-1@@ -285,7 +285,7 @@ static struct platform_driver keembay_wdt_driver = { .driver = { .name = "keembay_wdt", .of_match_table = keembay_wdt_match, - .pm = &keembay_wdt_pm_ops, + .pm = pm_sleep_ptr(&keembay_wdt_pm_ops),
[Severity: Low]
Is it correct to use pm_sleep_ptr() here for the dev_pm_ops structure pointer? The PM subsystem guidelines require using pm_ptr() for dev_pm_ops structure pointers, reserving pm_sleep_ptr() for the sleep callbacks themselves.
Quoted 2 lines
drivers/watchdog/keembay_wdt.c +0
-0}, };
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
[email protected]
AI reviewRe: [PATCH 7/8] watchdog: sp805_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
In reply to Triet HoangThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Incorrect PM macro used for dev_pm_ops structure pointer --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Incorrect PM macro used for dev_pm_ops structure pointer
--
commit 9fbd3f6262590348a0368f82478f6de749787ec2
Author: Triet Hoang <[email protected]>
watchdog: sp805_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
This commit converts the deprecated SIMPLE_DEV_PM_OPS() to DEFINE_SIMPLE_DEV_PM_OPS() and wraps the struct pointer. This allows the removal of __maybe_unused annotations from the callbacks.
Quoted 4 lines
drivers/watchdog/sp805_wdt.c +0
-0
[ ... ]
drivers/watchdog/sp805_wdt.c MODULE_DEVICE_TABLE(amba, sp805_wdt_ids); · line 364
Quoted 6 lines
drivers/watchdog/sp805_wdt.c +1
-1@@ -361,7 +361,7 @@ MODULE_DEVICE_TABLE(amba, sp805_wdt_ids);static struct amba_driver sp805_wdt_driver = { .drv = { .name =MODULE_NAME , - .pm = &sp805_wdt_dev_pm_ops, + .pm =pm_sleep_ptr (&sp805_wdt_dev_pm_ops),
[Severity: Low]
Should this use pm_ptr() instead of pm_sleep_ptr() for the structure pointer?
According to the power management guidelines, dev_pm_ops structure pointers should be wrapped with pm_ptr() rather than pm_sleep_ptr(). Using pm_sleep_ptr() here drops the entire dev_pm_ops structure when CONFIG_PM_SLEEP is disabled. If runtime PM callbacks are added to this structure in the future, they will be incorrectly discarded even when CONFIG_PM is enabled.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
[email protected]
AI reviewRe: [PATCH 8/8] watchdog: stmp3xxx_rtc_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
In reply to Triet HoangThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Incorrect wrapper macro used for the dev_pm_ops structure pointer. --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Incorrect wrapper macro used for the dev_pm_ops structure pointer. --
commit 1f11ea674c46c75875588fac7d892578dd01a7b5
Author: Triet Hoang <[email protected]>
watchdog: stmp3xxx_rtc_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
This commit converts the deprecated SIMPLE_DEV_PM_OPS macro to DEFINE_SIMPLE_DEV_PM_OPS and wraps the pm_ops pointer, which allows dropping the maybe_unused annotations from the suspend and resume callbacks.
Quoted 3 lines
drivers/watchdog/stmp3xxx_rtc_wdt.c +0
-0
[ ... ]
drivers/watchdog/stmp3xxx_rtc_wdt.c static int __maybe_unused stmp3xxx_wdt_resume(struct device *dev) · line 143
Quoted 9 lines
drivers/watchdog/stmp3xxx_rtc_wdt.c +2
-2-static SIMPLE_DEV_PM_OPS(stmp3xxx_wdt_pm_ops, +static DEFINE_SIMPLE_DEV_PM_OPS(stmp3xxx_wdt_pm_ops, stmp3xxx_wdt_suspend, stmp3xxx_wdt_resume);static struct platform_driver stmp3xxx_wdt_driver = { .driver = { .name ="stmp3xxx_rtc_wdt" , - .pm = &stmp3xxx_wdt_pm_ops, + .pm =pm_sleep_ptr (&stmp3xxx_wdt_pm_ops),
[Severity: Low]
Is it correct to use pm_sleep_ptr() here instead of pm_ptr() for the dev_pm_ops structure pointer?
According to the power management callback conditional compilation guidelines, pm_ptr() should be used for dev_pm_ops structure pointers, while pm_sleep_ptr() is intended for the specific sleep callbacks (like suspend, resume, freeze, thaw, etc.).
By using pm_sleep_ptr() on the structure pointer itself, it will evaluate to NULL when CONFIG_PM_SLEEP is disabled. If any runtime PM callbacks were later added to this dev_pm_ops structure, they would be silently compiled out even if CONFIG_PM is enabled.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
[email protected]
AI reviewRe: [PATCH 4/8] watchdog: msc313e_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
In reply to Triet HoangThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing platform_set_drvdata() or dev_set_drvdata() in the probe function leads to a guaranteed NULL pointer dereference during suspend/resume operations.
- [High] The driver accesses hardware registers without ensuring the required clock is enabled, which can lead to a synchronous bus fault. --
commit 906c6a1c7ebc485b90aee7c86e2994040111e762
Author: Triet Hoang <[email protected]>
watchdog: msc313e_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
Convert deprecated SIMPLE_DEV_PM_OPS() to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr(). This lets us drop the __maybe_unused annotations from the resume callback.
drivers/watchdog/msc313e_wdt.c static int msc313e_wdt_probe(struct platform_device *pdev) · line 138
Quoted 12 lines
drivers/watchdog/msc313e_wdt.c +1
-1@@ -133,7 +133,7 @@ static int msc313e_wdt_probe(struct platform_device *pdev)return devm_watchdog_register_device (dev, &priv->wdev); } -static int __maybe_unused msc313e_wdt_suspend (struct device *dev) +static int msc313e_wdt_suspend (struct device *dev) {struct msc313e_wdt_priv *priv =dev_get_drvdata (dev);
[Severity: High]
This isn't a bug introduced by this patch, but does this result in a NULL pointer dereference when the system suspends?
The PM core invokes msc313e_wdt_suspend() and passes the platform device as the dev parameter. However, msc313e_wdt_probe() never calls platform_set_drvdata() or dev_set_drvdata() for the platform device:
drivers/watchdog/msc313e_wdt.c:msc313e_wdt_probe() {
...
watchdog_set_drvdata(&priv->wdev, priv);
watchdog_init_timeout(&priv->wdev, timeout, dev);
watchdog_stop_on_reboot(&priv->wdev);
watchdog_stop_on_unregister(&priv->wdev);
return devm_watchdog_register_device(dev, &priv->wdev);
}Because the driver data is uninitialized, dev_get_drvdata(dev) evaluates to NULL. The callback then computes an offset into this NULL pointer via &priv->wdev and passes it to watchdog_active(), which unconditionally dereferences it via test_bit(WDOG_ACTIVE, &wdd->status), causing a fatal page fault.
The identical NULL pointer dereference logic also executes on the resume path in msc313e_wdt_resume().
[Severity: High]
This is also a pre-existing issue, but does this driver access hardware registers without ensuring the required clock is enabled?
The probe function reads from hardware registers without first calling clk_prepare_enable(), which can crash if the clock is disabled by the bootloader:
drivers/watchdog/msc313e_wdt.c:msc313e_wdt_probe() {
...
/* If the period is non-zero the WDT is running */
if (readw(priv->base + REG_WDT_MAX_PRD_L) | (readw(priv->base + REG_WDT_MAX_PRD_H) << 16))
set_bit(WDOG_HW_RUNNING, &priv->wdev.status);
...
}Additionally, because the clock is never enabled in the probe function, when the Common Clock Framework's late_initcall executes, it physically disables the unreferenced clock. If the watchdog is already running at boot time, the watchdog core will periodically call the background ping callback:
drivers/watchdog/msc313e_wdt.c:msc313e_wdt_ping() {
...
writew(1, priv->base + REG_WDT_CLR);
...
}Writing to these unclocked watchdog registers will trigger a synchronous bus fault.
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Guenter Roeck
maintainerRe: [PATCH 3/8] watchdog: keembay_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
In reply to [email protected]Quoted 19 lines · On 8/25/26 23:17, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The driver usespm_sleep_ptr()for thedev_pm_opsstructure pointer in the platform driver definition, which violates the strict subsystem guidelines mandatingpm_ptr(). --commit
a755ace210f3814431fd01a8ffbd96e121f18dda
Author: Triet Hoang <[email protected]>watchdog:
keembay_wdt: Convert toDEFINE_SIMPLE_DEV_PM_OPS()This commit converts the deprecated
SIMPLE_DEV_PM_OPS()toDEFINE_SIMPLE_DEV_PM_OPS()and wraps the PM operations pointer withpm_sleep_ptr(). This enables dropping the__maybe_unusedannotations from the suspend and resume callbacks.Quoted 4 lines
drivers/watchdog/keembay_wdt.c +0
-0[ ... ]
Quoted 12 lines
drivers/watchdog/keembay_wdt.c static struct platform_driver keembay_wdt_driver = { · line 288
Quoted 6 lines
drivers/watchdog/keembay_wdt.c +1
-1@@ -285,7 +285,7 @@ static struct platform_driver keembay_wdt_driver = { .driver = { .name = "keembay_wdt", .of_match_table = keembay_wdt_match, - .pm = &keembay_wdt_pm_ops, + .pm = pm_sleep_ptr(&keembay_wdt_pm_ops),[Severity: Low]
Is it correct to usepm_sleep_ptr()here for thedev_pm_opsstructure pointer? The PM subsystem guidelines require usingpm_ptr()fordev_pm_opsstructure pointers, reservingpm_sleep_ptr()for the sleep callbacks themselves.
The use of pm_sleep_ptr() for .pm is widely used in the kernel, but at least Sashiko's guidance suggests that pm_ptr() should be used instead. Please do that for .pm pointers.
Thanks,
Guenter
Re: [PATCH 4/8] watchdog: msc313e_wdt: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
In reply to [email protected]Quoted 3 lines · On Wed, Aug 26, 2026 at 06:20:35AM +0000, [email protected] wrote:
Pre-existing issues:
- [High] Missingplatform_set_drvdata()ordev_set_drvdata()in the probe function leads to a guaranteed NULL pointer dereference during suspend/resume operations.
- [High] The driver accesses hardware registers without ensuring the required clock is enabled, which can lead to a synchronous bus fault.
They are real issues. Sent [1] for fixing if they are still relevant.
[1] https://lore.kernel.org/linux-watchdog/[email protected]
Quoted 24 lines
drivers/watchdog/msc313e_wdt.c static int msc313e_wdt_probe(struct platform_device *pdev) · line 137
Quoted 4 lines
drivers/watchdog/msc313e_wdt.c +1
-1-static int __maybe_unused msc313e_wdt_suspend (struct device *dev) +static int msc313e_wdt_suspend (struct device *dev) {struct msc313e_wdt_priv *priv =dev_get_drvdata (dev);[Severity: High]
This isn't a bug introduced by this patch, but does this result in a NULL pointer dereference when the system suspends?The PM core invokes
msc313e_wdt_suspend()and passes the platform device as the dev parameter. However,msc313e_wdt_probe()never callsplatform_set_drvdata()ordev_set_drvdata()for the platform device:drivers/watchdog/msc313e_wdt.c:msc313e_wdt_probe() { ... watchdog_set_drvdata(&priv->wdev, priv); watchdog_init_timeout(&priv->wdev, timeout, dev); watchdog_stop_on_reboot(&priv->wdev); watchdog_stop_on_unregister(&priv->wdev); return devm_watchdog_register_device(dev, &priv->wdev); }
Quoted 8 lines
Because the driver data is uninitialized,
dev_get_drvdata(dev)evaluates to NULL. The callback then computes an offset into this NULL pointer via&priv->wdevand passes it towatchdog_active(), which unconditionally dereferences it viatest_bit(WDOG_ACTIVE, &wdd->status), causing a fatal page fault.The identical NULL pointer dereference logic also executes on the resume path in
msc313e_wdt_resume().
https://lore.kernel.org/linux-watchdog/[email protected]
Quoted 21 lines
[Severity: High]
This is also a pre-existing issue, but does this driver access hardware registers without ensuring the required clock is enabled?The probe function reads from hardware registers without first calling
clk_prepare_enable(), which can crash if the clock is disabled by the bootloader:drivers/watchdog/msc313e_wdt.c:msc313e_wdt_probe() { ... /* If the period is non-zero the WDT is running */ if (readw(priv->base + REG_WDT_MAX_PRD_L) | (readw(priv->base + REG_WDT_MAX_PRD_H) << 16)) set_bit(WDOG_HW_RUNNING, &priv->wdev.status); ... }Additionally, because the clock is never enabled in the probe function, when the Common Clock Framework's
late_initcallexecutes, it physically disables the unreferenced clock. If the watchdog is already running at boot time, the watchdog core will periodically call the background ping callback:
Quoted 8 lines
drivers/watchdog/msc313e_wdt.c:msc313e_wdt_ping() { ... writew(1, priv->base + REG_WDT_CLR); ... }Writing to these unclocked watchdog registers will trigger a synchronous bus fault.
Re: [PATCH 2/8] watchdog: da9062: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
In reply to Triet HoangQuoted 1 line · Triet Hoang
drivers/watchdog/da9062_wdt.c +0
-0
...
drivers/watchdog/da9062_wdt.c static int __maybe_unused da9062_wdt_resume(struct device *dev) · line 280
Quoted 3 lines
drivers/watchdog/da9062_wdt.c +1
-1-static SIMPLE_DEV_PM_OPS(da9062_wdt_pm_ops, +static DEFINE_SIMPLE_DEV_PM_OPS(da9062_wdt_pm_ops, da9062_wdt_suspend, da9062_wdt_resume);
To be neat, it'd probably like to align the parameters to '(' or simply combine them into a single line if it fits within the 100-col limit.
The suggestion applies to all other patches in the series as well.
Guenter Roeck
maintainerRe: [PATCH 2/8] watchdog: da9062: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
Quoted 11 lines · Tzung-Bi Shih
Quoted 1 line · Triet Hoang
drivers/watchdog/da9062_wdt.c +0
-0...
drivers/watchdog/da9062_wdt.c static int __maybe_unused da9062_wdt_resume(struct device *dev) · line 280
Quoted 3 lines
drivers/watchdog/da9062_wdt.c +1
-1-static SIMPLE_DEV_PM_OPS(da9062_wdt_pm_ops, +static DEFINE_SIMPLE_DEV_PM_OPS(da9062_wdt_pm_ops, da9062_wdt_suspend, da9062_wdt_resume);To be neat, it'd probably like to align the parameters to '(' or simply combine them into a single line if it fits within the 100-col limit.
The suggestion applies to all other patches in the series as well.
I agree.
Thanks,
Guenter