can: flexcan: using pm_runtime_resume_and_get instead of pm_runtime_get_sync
authorMinghao Chi <chi.minghao@zte.com.cn>
Tue, 19 Apr 2022 08:14:49 +0000 (08:14 +0000)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Tue, 19 Apr 2022 15:12:12 +0000 (17:12 +0200)
Using pm_runtime_resume_and_get is more appropriate
for simplifing code

Link: https://lore.kernel.org/all/20220419081449.2574026-1-chi.minghao@zte.com.cn
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/flexcan/flexcan-core.c

index 389bd9da7e9ad56854f1f63fce5e6e534b3f4b7a..fe9bda0f5ec46236be6bdfae70d506a791f9f388 100644 (file)
@@ -723,11 +723,9 @@ static int flexcan_get_berr_counter(const struct net_device *dev,
        const struct flexcan_priv *priv = netdev_priv(dev);
        int err;
 
-       err = pm_runtime_get_sync(priv->dev);
-       if (err < 0) {
-               pm_runtime_put_noidle(priv->dev);
+       err = pm_runtime_resume_and_get(priv->dev);
+       if (err < 0)
                return err;
-       }
 
        err = __flexcan_get_berr_counter(dev, bec);
 
@@ -1700,11 +1698,9 @@ static int flexcan_open(struct net_device *dev)
                return -EINVAL;
        }
 
-       err = pm_runtime_get_sync(priv->dev);
-       if (err < 0) {
-               pm_runtime_put_noidle(priv->dev);
+       err = pm_runtime_resume_and_get(priv->dev);
+       if (err < 0)
                return err;
-       }
 
        err = open_candev(dev);
        if (err)