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),
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);
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;
}
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);
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);