summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2026-03-14 12:53:01 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2026-04-07 21:06:59 +0200
commitd37ec2fbab55d732aae48ef2c877fb2d5ab08cd7 (patch)
tree35fff30ec10c8d0b704790e8482c281f1c868eff
parent112b2f978afee7df725cda74a94802f919c61564 (diff)
watchdog: ni903x_wdt: Convert to a platform driver
In all cases in which a struct acpi_driver is used for binding a driver to an ACPI device object, a corresponding platform device is created by the ACPI core and that device is regarded as a proper representation of underlying hardware. Accordingly, a struct platform_driver should be used by driver code to bind to that device. There are multiple reasons why drivers should not bind directly to ACPI device objects [1]. In particular, registering a watchdog device under a struct acpi_device is questionable because it causes the watchdog to be hidden in the ACPI bus sysfs hierarchy and it goes against the general rule that a struct acpi_device can only be a parent of another struct acpi_device. Overall, it is better to bind drivers to platform devices than to their ACPI companions, so convert the ni903x_wdt watchdog ACPI driver to a platform one. While this is not expected to alter functionality, it changes sysfs layout and so it will be visible to user space. Note that after this change it actually makes sense to look for the "timeout-sec" property via device_property_read_u32() under the device passed to watchdog_init_timeout() because it has an fwnode handle (unlike a struct acpi_device which is an fwnode itself). Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Link: https://patch.msgid.link/13996583.uLZWGnKmhe@rafael.j.wysocki
-rw-r--r--drivers/watchdog/ni903x_wdt.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/watchdog/ni903x_wdt.c b/drivers/watchdog/ni903x_wdt.c
index 045bb72d9a43..8b1b9baa914e 100644
--- a/drivers/watchdog/ni903x_wdt.c
+++ b/drivers/watchdog/ni903x_wdt.c
@@ -8,6 +8,7 @@
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/module.h>
+#include <linux/platform_device.h>
#include <linux/watchdog.h>
#define NIWD_CONTROL 0x01
@@ -177,9 +178,9 @@ static const struct watchdog_ops ni903x_wdd_ops = {
.get_timeleft = ni903x_wdd_get_timeleft,
};
-static int ni903x_acpi_add(struct acpi_device *device)
+static int ni903x_acpi_probe(struct platform_device *pdev)
{
- struct device *dev = &device->dev;
+ struct device *dev = &pdev->dev;
struct watchdog_device *wdd;
struct ni903x_wdt *wdt;
acpi_status status;
@@ -189,10 +190,10 @@ static int ni903x_acpi_add(struct acpi_device *device)
if (!wdt)
return -ENOMEM;
- device->driver_data = wdt;
+ platform_set_drvdata(pdev, wdt);
wdt->dev = dev;
- status = acpi_walk_resources(device->handle, METHOD_NAME__CRS,
+ status = acpi_walk_resources(ACPI_HANDLE(dev), METHOD_NAME__CRS,
ni903x_resources, wdt);
if (ACPI_FAILURE(status) || wdt->io_base == 0) {
dev_err(dev, "failed to get resources\n");
@@ -224,9 +225,9 @@ static int ni903x_acpi_add(struct acpi_device *device)
return 0;
}
-static void ni903x_acpi_remove(struct acpi_device *device)
+static void ni903x_acpi_remove(struct platform_device *pdev)
{
- struct ni903x_wdt *wdt = acpi_driver_data(device);
+ struct ni903x_wdt *wdt = platform_get_drvdata(pdev);
ni903x_wdd_stop(&wdt->wdd);
watchdog_unregister_device(&wdt->wdd);
@@ -238,16 +239,16 @@ static const struct acpi_device_id ni903x_device_ids[] = {
};
MODULE_DEVICE_TABLE(acpi, ni903x_device_ids);
-static struct acpi_driver ni903x_acpi_driver = {
- .name = NIWD_NAME,
- .ids = ni903x_device_ids,
- .ops = {
- .add = ni903x_acpi_add,
- .remove = ni903x_acpi_remove,
+static struct platform_driver ni903x_acpi_driver = {
+ .probe = ni903x_acpi_probe,
+ .remove = ni903x_acpi_remove,
+ .driver = {
+ .name = NIWD_NAME,
+ .acpi_match_table = ni903x_device_ids,
},
};
-module_acpi_driver(ni903x_acpi_driver);
+module_platform_driver(ni903x_acpi_driver);
MODULE_DESCRIPTION("NI 903x Watchdog");
MODULE_AUTHOR("Jeff Westfahl <jeff.westfahl@ni.com>");