aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2014-02-28 11:18:27 -0500
committerMarc Kleine-Budde <mkl@pengutronix.de>2014-03-03 06:41:39 -0500
commitf003698e23f6f56a791774f14d0ac35d04872490 (patch)
treefd6af2b168c5275e05977bbfd4aae5ce051809c5 /drivers/net/can
parent9b00b300e7bce032c467c36ca47fe2a776887fc2 (diff)
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: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can')
-rw-r--r--drivers/net/can/flexcan.c27
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
267static 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
275static 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
267static inline int flexcan_has_and_handle_berr(const struct flexcan_priv *priv, 283static 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, &regs->rxfgmask); 825 flexcan_write(0x0, &regs->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(&regs->mcr); 832 reg_mcr = flexcan_read(&regs->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 &regs->ctrl); 872 &regs->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;