Skip to content

Commit 52d48a3

Browse files
Merge patch series "can: flexcan: only change CAN state when link up in system PM"
In this series Haibo Chen fixes several shortcomings of the suspend and resume functions of the flexcan driver. Link: https://patch.msgid.link/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]>
2 parents d5cd454 + 5a19143 commit 52d48a3

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

drivers/net/can/flexcan/flexcan-core.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2260,14 +2260,19 @@ static int __maybe_unused flexcan_suspend(struct device *device)
22602260

22612261
flexcan_chip_interrupts_disable(dev);
22622262

2263+
err = flexcan_transceiver_disable(priv);
2264+
if (err)
2265+
return err;
2266+
22632267
err = pinctrl_pm_select_sleep_state(device);
22642268
if (err)
22652269
return err;
22662270
}
22672271
netif_stop_queue(dev);
22682272
netif_device_detach(dev);
2273+
2274+
priv->can.state = CAN_STATE_SLEEPING;
22692275
}
2270-
priv->can.state = CAN_STATE_SLEEPING;
22712276

22722277
return 0;
22732278
}
@@ -2278,7 +2283,6 @@ static int __maybe_unused flexcan_resume(struct device *device)
22782283
struct flexcan_priv *priv = netdev_priv(dev);
22792284
int err;
22802285

2281-
priv->can.state = CAN_STATE_ERROR_ACTIVE;
22822286
if (netif_running(dev)) {
22832287
netif_device_attach(dev);
22842288
netif_start_queue(dev);
@@ -2292,12 +2296,20 @@ static int __maybe_unused flexcan_resume(struct device *device)
22922296
if (err)
22932297
return err;
22942298

2295-
err = flexcan_chip_start(dev);
2299+
err = flexcan_transceiver_enable(priv);
22962300
if (err)
22972301
return err;
22982302

2303+
err = flexcan_chip_start(dev);
2304+
if (err) {
2305+
flexcan_transceiver_disable(priv);
2306+
return err;
2307+
}
2308+
22992309
flexcan_chip_interrupts_enable(dev);
23002310
}
2311+
2312+
priv->can.state = CAN_STATE_ERROR_ACTIVE;
23012313
}
23022314

23032315
return 0;

0 commit comments

Comments
 (0)