Commit f003698e authored by Marc Kleine-Budde's avatar Marc Kleine-Budde

can: flexcan: factor out transceiver {en,dis}able into seperate functions

This patch moves the transceiver enable and disable into seperate functions,
where the NULL pointer check is hidden.

Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 9b00b300
...@@ -264,6 +264,22 @@ static inline void flexcan_write(u32 val, void __iomem *addr) ...@@ -264,6 +264,22 @@ static inline void flexcan_write(u32 val, void __iomem *addr)
} }
#endif #endif
static inline int flexcan_transceiver_enable(const struct flexcan_priv *priv)
{
if (!priv->reg_xceiver)
return 0;
return regulator_enable(priv->reg_xceiver);
}
static inline int flexcan_transceiver_disable(const struct flexcan_priv *priv)
{
if (!priv->reg_xceiver)
return 0;
return regulator_disable(priv->reg_xceiver);
}
static inline int flexcan_has_and_handle_berr(const struct flexcan_priv *priv, static inline int flexcan_has_and_handle_berr(const struct flexcan_priv *priv,
u32 reg_esr) u32 reg_esr)
{ {
...@@ -808,11 +824,9 @@ static int flexcan_chip_start(struct net_device *dev) ...@@ -808,11 +824,9 @@ static int flexcan_chip_start(struct net_device *dev)
if (priv->devtype_data->features & FLEXCAN_HAS_V10_FEATURES) if (priv->devtype_data->features & FLEXCAN_HAS_V10_FEATURES)
flexcan_write(0x0, &regs->rxfgmask); flexcan_write(0x0, &regs->rxfgmask);
if (priv->reg_xceiver) { err = flexcan_transceiver_enable(priv);
err = regulator_enable(priv->reg_xceiver);
if (err) if (err)
goto out; goto out;
}
/* synchronize with the can bus */ /* synchronize with the can bus */
reg_mcr = flexcan_read(&regs->mcr); reg_mcr = flexcan_read(&regs->mcr);
...@@ -857,8 +871,7 @@ static void flexcan_chip_stop(struct net_device *dev) ...@@ -857,8 +871,7 @@ static void flexcan_chip_stop(struct net_device *dev)
flexcan_write(priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL, flexcan_write(priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL,
&regs->ctrl); &regs->ctrl);
if (priv->reg_xceiver) flexcan_transceiver_disable(priv);
regulator_disable(priv->reg_xceiver);
priv->can.state = CAN_STATE_STOPPED; priv->can.state = CAN_STATE_STOPPED;
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment