diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2014-03-18 19:06:01 +0100 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2014-04-01 11:54:56 +0200 |
commit | 130a5171dad06c6d89fd5568260fbb0c4b34bd74 (patch) | |
tree | 8df907cd6f50521c9617a5b2e0270cf7212dee1c /drivers/net/can/c_can/c_can.c | |
parent | f29b423834be812b736bf5e804290c3e14b1dd67 (diff) | |
download | linux-130a5171dad06c6d89fd5568260fbb0c4b34bd74.tar.bz2 |
can: c_can: check return value to users of c_can_set_bittiming()
This patch adds return value checking to all direct and indirect users of
c_can_set_bittiming().
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can/c_can/c_can.c')
-rw-r--r-- | drivers/net/can/c_can/c_can.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c index 6c03731d7ee7..68839380086d 100644 --- a/drivers/net/can/c_can/c_can.c +++ b/drivers/net/can/c_can/c_can.c @@ -631,7 +631,7 @@ static void c_can_configure_msg_objects(struct net_device *dev) * - set operating mode * - configure message objects */ -static void c_can_chip_config(struct net_device *dev) +static int c_can_chip_config(struct net_device *dev) { struct c_can_priv *priv = netdev_priv(dev); @@ -668,15 +668,18 @@ static void c_can_chip_config(struct net_device *dev) priv->write_reg(priv, C_CAN_STS_REG, LEC_UNUSED); /* set bittiming params */ - c_can_set_bittiming(dev); + return c_can_set_bittiming(dev); } -static void c_can_start(struct net_device *dev) +static int c_can_start(struct net_device *dev) { struct c_can_priv *priv = netdev_priv(dev); + int err; /* basic c_can configuration */ - c_can_chip_config(dev); + err = c_can_chip_config(dev); + if (err) + return err; priv->can.state = CAN_STATE_ERROR_ACTIVE; @@ -685,6 +688,8 @@ static void c_can_start(struct net_device *dev) /* enable status change, error and module interrupts */ c_can_enable_all_interrupts(priv, ENABLE_ALL_INTERRUPTS); + + return 0; } static void c_can_stop(struct net_device *dev) @@ -700,9 +705,13 @@ static void c_can_stop(struct net_device *dev) static int c_can_set_mode(struct net_device *dev, enum can_mode mode) { + int err; + switch (mode) { case CAN_MODE_START: - c_can_start(dev); + err = c_can_start(dev); + if (err) + return err; netif_wake_queue(dev); break; default: @@ -1133,17 +1142,20 @@ static int c_can_open(struct net_device *dev) goto exit_irq_fail; } - napi_enable(&priv->napi); + /* start the c_can controller */ + err = c_can_start(dev); + if (err) + goto exit_start_fail; can_led_event(dev, CAN_LED_EVENT_OPEN); - /* start the c_can controller */ - c_can_start(dev); - + napi_enable(&priv->napi); netif_start_queue(dev); return 0; +exit_start_fail: + free_irq(dev->irq, dev); exit_irq_fail: close_candev(dev); exit_open_fail: @@ -1260,9 +1272,7 @@ int c_can_power_up(struct net_device *dev) if (time_after(jiffies, time_out)) return -ETIMEDOUT; - c_can_start(dev); - - return 0; + return c_can_start(dev); } EXPORT_SYMBOL_GPL(c_can_power_up); #endif |