diff options
| -rw-r--r-- | drivers/net/can/flexcan.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index 5af60ab23e6f..6b0fecd0a6ad 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c | |||
| @@ -264,6 +264,22 @@ static inline void flexcan_write(u32 val, void __iomem *addr) | |||
| 264 | } | 264 | } |
| 265 | #endif | 265 | #endif |
| 266 | 266 | ||
| 267 | static inline int flexcan_transceiver_enable(const struct flexcan_priv *priv) | ||
| 268 | { | ||
| 269 | if (!priv->reg_xceiver) | ||
| 270 | return 0; | ||
| 271 | |||
| 272 | return regulator_enable(priv->reg_xceiver); | ||
| 273 | } | ||
| 274 | |||
| 275 | static inline int flexcan_transceiver_disable(const struct flexcan_priv *priv) | ||
| 276 | { | ||
| 277 | if (!priv->reg_xceiver) | ||
| 278 | return 0; | ||
| 279 | |||
| 280 | return regulator_disable(priv->reg_xceiver); | ||
| 281 | } | ||
| 282 | |||
| 267 | static inline int flexcan_has_and_handle_berr(const struct flexcan_priv *priv, | 283 | static inline int flexcan_has_and_handle_berr(const struct flexcan_priv *priv, |
| 268 | u32 reg_esr) | 284 | u32 reg_esr) |
| 269 | { | 285 | { |
| @@ -808,11 +824,9 @@ static int flexcan_chip_start(struct net_device *dev) | |||
| 808 | if (priv->devtype_data->features & FLEXCAN_HAS_V10_FEATURES) | 824 | if (priv->devtype_data->features & FLEXCAN_HAS_V10_FEATURES) |
| 809 | flexcan_write(0x0, ®s->rxfgmask); | 825 | flexcan_write(0x0, ®s->rxfgmask); |
| 810 | 826 | ||
| 811 | if (priv->reg_xceiver) { | 827 | err = flexcan_transceiver_enable(priv); |
| 812 | err = regulator_enable(priv->reg_xceiver); | 828 | if (err) |
| 813 | if (err) | 829 | goto out; |
| 814 | goto out; | ||
| 815 | } | ||
| 816 | 830 | ||
| 817 | /* synchronize with the can bus */ | 831 | /* synchronize with the can bus */ |
| 818 | reg_mcr = flexcan_read(®s->mcr); | 832 | reg_mcr = flexcan_read(®s->mcr); |
| @@ -857,8 +871,7 @@ static void flexcan_chip_stop(struct net_device *dev) | |||
| 857 | flexcan_write(priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL, | 871 | flexcan_write(priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL, |
| 858 | ®s->ctrl); | 872 | ®s->ctrl); |
| 859 | 873 | ||
| 860 | if (priv->reg_xceiver) | 874 | flexcan_transceiver_disable(priv); |
| 861 | regulator_disable(priv->reg_xceiver); | ||
| 862 | priv->can.state = CAN_STATE_STOPPED; | 875 | priv->can.state = CAN_STATE_STOPPED; |
| 863 | 876 | ||
| 864 | return; | 877 | return; |
