[PATCH] platform/x86: portwell-ec: Move watchdog device under correct platform hierarchy

Ivan Hu posted 1 patch 3 months, 4 weeks ago
There is a newer version of this series
drivers/platform/x86/portwell-ec.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] platform/x86: portwell-ec: Move watchdog device under correct platform hierarchy
Posted by Ivan Hu 3 months, 4 weeks ago
Without explicitly setting a parent for the watchdog device, the device is
registered with a NULL parent. This causes device_add() (called internally
by devm_watchdog_register_device()) to register the device under
/sys/devices/virtual, since no parent is provided. The result is:

DEVPATH=/devices/virtual/watchdog/watchdog0

To fix this, assign &pdev->dev as the parent of the watchdog device before
calling devm_watchdog_register_device(). This ensures the device is
associated with the Portwell EC platform device and placed correctly in
sysfs as:

DEVPATH=/devices/platform/portwell-ec/watchdog/watchdog0

This aligns the device hierarchy with expectations and avoids misplacement
under the virtual class.

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 drivers/platform/x86/portwell-ec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/platform/x86/portwell-ec.c b/drivers/platform/x86/portwell-ec.c
index 8b788822237b..3e019c51913e 100644
--- a/drivers/platform/x86/portwell-ec.c
+++ b/drivers/platform/x86/portwell-ec.c
@@ -236,6 +236,7 @@ static int pwec_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	ec_wdt_dev.parent = &pdev->dev;
 	ret = devm_watchdog_register_device(&pdev->dev, &ec_wdt_dev);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to register Portwell EC Watchdog\n");
-- 
2.34.1
Re: [PATCH] platform/x86: portwell-ec: Move watchdog device under correct platform hierarchy
Posted by Ilpo Järvinen 3 months, 4 weeks ago
On Fri, 13 Jun 2025, Ivan Hu wrote:

> Without explicitly setting a parent for the watchdog device, the device is
> registered with a NULL parent. This causes device_add() (called internally
> by devm_watchdog_register_device()) to register the device under
> /sys/devices/virtual, since no parent is provided. The result is:
> 
> DEVPATH=/devices/virtual/watchdog/watchdog0
> 
> To fix this, assign &pdev->dev as the parent of the watchdog device before
> calling devm_watchdog_register_device(). This ensures the device is
> associated with the Portwell EC platform device and placed correctly in
> sysfs as:
> 
> DEVPATH=/devices/platform/portwell-ec/watchdog/watchdog0
> 
> This aligns the device hierarchy with expectations and avoids misplacement
> under the virtual class.
> 

This is missing the Fixes tag.

> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  drivers/platform/x86/portwell-ec.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/platform/x86/portwell-ec.c b/drivers/platform/x86/portwell-ec.c
> index 8b788822237b..3e019c51913e 100644
> --- a/drivers/platform/x86/portwell-ec.c
> +++ b/drivers/platform/x86/portwell-ec.c
> @@ -236,6 +236,7 @@ static int pwec_probe(struct platform_device *pdev)
>  		return ret;
>  	}
>  
> +	ec_wdt_dev.parent = &pdev->dev;
>  	ret = devm_watchdog_register_device(&pdev->dev, &ec_wdt_dev);
>  	if (ret < 0) {
>  		dev_err(&pdev->dev, "failed to register Portwell EC Watchdog\n");
> 

-- 
 i.