]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
serial: 8250_dw: fix runtime PM initialization sequence
authorArtem Shimko <a.shimko.dev@gmail.com>
Tue, 4 Nov 2025 14:54:26 +0000 (17:54 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Dec 2025 14:05:00 +0000 (15:05 +0100)
Move pm_runtime_set_active() call earlier in probe to simplify error
handling and add proper error checking to ensure the device is marked
as active before any runtime PM operations can occur.

Additionally, replace the const struct dev_pm_ops declaration with
_DEFINE_DEV_PM_OPS macro for better consistency with modern kernel PM
patterns.

Signed-off-by: Artem Shimko <a.shimko.dev@gmail.com>
Link: https://patch.msgid.link/20251104145433.2316165-3-a.shimko.dev@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/8250/8250_dw.c

index 0f8207652efe6fb2ccd4253a218ca0ee11803644..db73b2ae17fa3392e83d30d1d64a963410f4a339 100644 (file)
@@ -643,6 +643,10 @@ static int dw8250_probe(struct platform_device *pdev)
        if (err)
                return err;
 
+       err = pm_runtime_set_active(dev);
+       if (err)
+               return dev_err_probe(dev, err, "Failed to set the runtime suspend as active\n");
+
        data->uart_16550_compatible = device_property_read_bool(dev, "snps,uart-16550-compatible");
 
        data->pdata = device_get_match_data(p->dev);
@@ -685,7 +689,6 @@ static int dw8250_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, data);
 
-       pm_runtime_set_active(dev);
        pm_runtime_enable(dev);
 
        return 0;
@@ -757,10 +760,9 @@ static int dw8250_runtime_resume(struct device *dev)
        return 0;
 }
 
-static const struct dev_pm_ops dw8250_pm_ops = {
-       SYSTEM_SLEEP_PM_OPS(dw8250_suspend, dw8250_resume)
-       RUNTIME_PM_OPS(dw8250_runtime_suspend, dw8250_runtime_resume, NULL)
-};
+static _DEFINE_DEV_PM_OPS(dw8250_pm_ops, dw8250_suspend, dw8250_resume,
+                         dw8250_runtime_suspend, dw8250_runtime_resume,
+                         NULL);
 
 static const struct dw8250_platform_data dw8250_dw_apb = {
        .usr_reg = DW_UART_USR,