netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Pellegrin <chripell-VaTbYqLCNhc@public.gmane.org>
To: socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org,
	pthomas8589-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Cc: Christian Pellegrin <chripell-VaTbYqLCNhc@public.gmane.org>
Subject: [PATCH net-next-2.6] can: fix setting mcp251x bit timing on open
Date: Tue, 17 Nov 2009 17:20:44 +0100	[thread overview]
Message-ID: <1258474844-10239-1-git-send-email-chripell@fsfe.org> (raw)


Signed-off-by: Christian Pellegrin <chripell-VaTbYqLCNhc@public.gmane.org>
---
 drivers/net/can/mcp251x.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index 8f48f4b..78b1b69 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -594,13 +594,7 @@ static int mcp251x_do_set_bittiming(struct net_device *net)
 static int mcp251x_setup(struct net_device *net, struct mcp251x_priv *priv,
 			 struct spi_device *spi)
 {
-	int ret;
-
-	ret = open_candev(net);
-	if (ret) {
-		dev_err(&spi->dev, "unable to set initial baudrate!\n");
-		return ret;
-	}
+	mcp251x_do_set_bittiming(net);
 
 	/* Enable RX0->RX1 buffer roll over and disable filters */
 	mcp251x_write_bits(spi, RXBCTRL(0),
@@ -671,6 +665,12 @@ static int mcp251x_open(struct net_device *net)
 	struct mcp251x_platform_data *pdata = spi->dev.platform_data;
 	int ret;
 
+	ret = open_candev(net);
+	if (ret) {
+		dev_err(&spi->dev, "unable to set initial baudrate!\n");
+		return ret;
+	}
+
 	if (pdata->transceiver_enable)
 		pdata->transceiver_enable(1);
 
@@ -684,6 +684,7 @@ static int mcp251x_open(struct net_device *net)
 		dev_err(&spi->dev, "failed to acquire irq %d\n", spi->irq);
 		if (pdata->transceiver_enable)
 			pdata->transceiver_enable(0);
+		close_candev(net);
 		return ret;
 	}
 
@@ -692,8 +693,10 @@ static int mcp251x_open(struct net_device *net)
 	ret = mcp251x_setup(net, priv, spi);
 	if (ret) {
 		free_irq(spi->irq, net);
+		mcp251x_hw_sleep(spi);
 		if (pdata->transceiver_enable)
 			pdata->transceiver_enable(0);
+		close_candev(net);
 		return ret;
 	}
 	mcp251x_set_normal_mode(spi);
@@ -956,7 +959,6 @@ static int __devinit mcp251x_can_probe(struct spi_device *spi)
 	priv->can.bittiming_const = &mcp251x_bittiming_const;
 	priv->can.do_set_mode = mcp251x_do_set_mode;
 	priv->can.clock.freq = pdata->oscillator_frequency / 2;
-	priv->can.do_set_bittiming = mcp251x_do_set_bittiming;
 	priv->net = net;
 	dev_set_drvdata(&spi->dev, priv);
 
-- 
1.5.6.5

             reply	other threads:[~2009-11-17 16:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-17 16:20 Christian Pellegrin [this message]
     [not found] ` <1258474844-10239-1-git-send-email-chripell-VaTbYqLCNhc@public.gmane.org>
2009-11-17 16:23   ` [PATCH net-next-2.6] can: fix setting mcp251x bit timing on open Wolfgang Grandegger
2009-11-18 13:06     ` David Miller

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=1258474844-10239-1-git-send-email-chripell@fsfe.org \
    --to=chripell-vatbyqlcnhc@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=pthomas8589-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org \
    --cc=wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).