All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabio Estevam <festevam@gmail.com>
To: mkl@pengutronix.de
Cc: shawn.guo@linaro.org, linux-can@vger.kernel.org,
	Fabio Estevam <fabio.estevam@freescale.com>
Subject: [PATCH 2/2] flexcan: Enable/Disable the CAN regulator in probe/remove
Date: Wed,  5 Jun 2013 16:27:25 -0300	[thread overview]
Message-ID: <1370460445-15386-2-git-send-email-festevam@gmail.com> (raw)
In-Reply-To: <1370460445-15386-1-git-send-email-festevam@gmail.com>

From: Fabio Estevam <fabio.estevam@freescale.com>

mx28evk has two CAN ports and they are controlled by the same GPIO.

If can0 runs flexcan_chip_stop(), then the regulator will be disabled, which
means that can1 cannot run anymore.

To overcome such scenario, let's enable the CAN regulator in flexcan_probe()
and disabled it in flexcan_remove().

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/net/can/flexcan.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 3de02b1..456a549 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -792,12 +792,6 @@ static int flexcan_chip_start(struct net_device *dev)
 	if (priv->devtype_data->features & FLEXCAN_HAS_V10_FEATURES)
 		flexcan_write(0x0, &regs->rxfgmask);
 
-	if (priv->reg_xceiver)	{
-		err = regulator_enable(priv->reg_xceiver);
-		if (err)
-			goto out;
-	}
-
 	/* synchronize with the can bus */
 	reg_mcr = flexcan_read(&regs->mcr);
 	reg_mcr &= ~FLEXCAN_MCR_HALT;
@@ -839,8 +833,6 @@ static void flexcan_chip_stop(struct net_device *dev)
 	reg |= FLEXCAN_MCR_MDIS | FLEXCAN_MCR_HALT;
 	flexcan_write(reg, &regs->mcr);
 
-	if (priv->reg_xceiver)
-		regulator_disable(priv->reg_xceiver);
 	priv->can.state = CAN_STATE_STOPPED;
 
 	return;
@@ -1099,6 +1091,12 @@ static int flexcan_probe(struct platform_device *pdev)
 
 	devm_can_led_init(dev);
 
+	if (priv->reg_xceiver) {
+		err = regulator_enable(priv->reg_xceiver);
+		if (err)
+			goto failed_register;
+	}
+
 	dev_info(&pdev->dev, "device registered (reg_base=%p, irq=%d)\n",
 		 priv->base, dev->irq);
 
@@ -1122,6 +1120,9 @@ static int flexcan_remove(struct platform_device *pdev)
 	struct flexcan_priv *priv = netdev_priv(dev);
 	struct resource *mem;
 
+	if (priv->reg_xceiver)
+		regulator_disable(priv->reg_xceiver);
+
 	unregister_flexcandev(dev);
 	iounmap(priv->base);
 
-- 
1.8.1.2


  reply	other threads:[~2013-06-05 19:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-05 19:27 [PATCH 1/2] flexcan: Use a regulator to control the CAN transceiver Fabio Estevam
2013-06-05 19:27 ` Fabio Estevam [this message]
2013-06-10 17:02   ` [PATCH 2/2] flexcan: Enable/Disable the CAN regulator in probe/remove Marc Kleine-Budde
2013-06-10 19:05     ` Fabio Estevam
2013-06-10 20:39       ` Marc Kleine-Budde
2013-06-10 20:49         ` Fabio Estevam
2013-06-10 23:35           ` Marc Kleine-Budde
2013-06-06  5:21 ` [PATCH 1/2] flexcan: Use a regulator to control the CAN transceiver Marc Kleine-Budde
2013-06-10 16:59 ` Marc Kleine-Budde
2013-06-10 17:03   ` Fabio Estevam
2013-06-11  2:38   ` Fabio Estevam
2013-06-12  9:39     ` Marc Kleine-Budde
2013-06-12 11:42 ` Shawn Guo
2013-06-12 12:06   ` Marc Kleine-Budde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1370460445-15386-2-git-send-email-festevam@gmail.com \
    --to=festevam@gmail.com \
    --cc=fabio.estevam@freescale.com \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=shawn.guo@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.