diff options
author | Christian Pellegrin <chripell@fsfe.org> | 2009-11-17 01:20:44 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-18 08:03:18 -0500 |
commit | 615534bc490606685621d63a40c0670d0f049d86 (patch) | |
tree | 8b58ce84e010715bf3b215cfb496582d252db98a | |
parent | 9a4e328eb2bfa23b160558cff96e17ffa65ea5cf (diff) |
can: fix setting mcp251x bit timing on open
Signed-off-by: Christian Pellegrin <chripell@fsfe.org>
Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | 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 8f48f4b50b7c..78b1b69b2921 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) | |||
594 | static int mcp251x_setup(struct net_device *net, struct mcp251x_priv *priv, | 594 | static int mcp251x_setup(struct net_device *net, struct mcp251x_priv *priv, |
595 | struct spi_device *spi) | 595 | struct spi_device *spi) |
596 | { | 596 | { |
597 | int ret; | 597 | mcp251x_do_set_bittiming(net); |
598 | |||
599 | ret = open_candev(net); | ||
600 | if (ret) { | ||
601 | dev_err(&spi->dev, "unable to set initial baudrate!\n"); | ||
602 | return ret; | ||
603 | } | ||
604 | 598 | ||
605 | /* Enable RX0->RX1 buffer roll over and disable filters */ | 599 | /* Enable RX0->RX1 buffer roll over and disable filters */ |
606 | mcp251x_write_bits(spi, RXBCTRL(0), | 600 | mcp251x_write_bits(spi, RXBCTRL(0), |
@@ -671,6 +665,12 @@ static int mcp251x_open(struct net_device *net) | |||
671 | struct mcp251x_platform_data *pdata = spi->dev.platform_data; | 665 | struct mcp251x_platform_data *pdata = spi->dev.platform_data; |
672 | int ret; | 666 | int ret; |
673 | 667 | ||
668 | ret = open_candev(net); | ||
669 | if (ret) { | ||
670 | dev_err(&spi->dev, "unable to set initial baudrate!\n"); | ||
671 | return ret; | ||
672 | } | ||
673 | |||
674 | if (pdata->transceiver_enable) | 674 | if (pdata->transceiver_enable) |
675 | pdata->transceiver_enable(1); | 675 | pdata->transceiver_enable(1); |
676 | 676 | ||
@@ -684,6 +684,7 @@ static int mcp251x_open(struct net_device *net) | |||
684 | dev_err(&spi->dev, "failed to acquire irq %d\n", spi->irq); | 684 | dev_err(&spi->dev, "failed to acquire irq %d\n", spi->irq); |
685 | if (pdata->transceiver_enable) | 685 | if (pdata->transceiver_enable) |
686 | pdata->transceiver_enable(0); | 686 | pdata->transceiver_enable(0); |
687 | close_candev(net); | ||
687 | return ret; | 688 | return ret; |
688 | } | 689 | } |
689 | 690 | ||
@@ -692,8 +693,10 @@ static int mcp251x_open(struct net_device *net) | |||
692 | ret = mcp251x_setup(net, priv, spi); | 693 | ret = mcp251x_setup(net, priv, spi); |
693 | if (ret) { | 694 | if (ret) { |
694 | free_irq(spi->irq, net); | 695 | free_irq(spi->irq, net); |
696 | mcp251x_hw_sleep(spi); | ||
695 | if (pdata->transceiver_enable) | 697 | if (pdata->transceiver_enable) |
696 | pdata->transceiver_enable(0); | 698 | pdata->transceiver_enable(0); |
699 | close_candev(net); | ||
697 | return ret; | 700 | return ret; |
698 | } | 701 | } |
699 | mcp251x_set_normal_mode(spi); | 702 | mcp251x_set_normal_mode(spi); |
@@ -956,7 +959,6 @@ static int __devinit mcp251x_can_probe(struct spi_device *spi) | |||
956 | priv->can.bittiming_const = &mcp251x_bittiming_const; | 959 | priv->can.bittiming_const = &mcp251x_bittiming_const; |
957 | priv->can.do_set_mode = mcp251x_do_set_mode; | 960 | priv->can.do_set_mode = mcp251x_do_set_mode; |
958 | priv->can.clock.freq = pdata->oscillator_frequency / 2; | 961 | priv->can.clock.freq = pdata->oscillator_frequency / 2; |
959 | priv->can.do_set_bittiming = mcp251x_do_set_bittiming; | ||
960 | priv->net = net; | 962 | priv->net = net; |
961 | dev_set_drvdata(&spi->dev, priv); | 963 | dev_set_drvdata(&spi->dev, priv); |
962 | 964 | ||