aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2014-03-18 14:06:01 -0400
committerMarc Kleine-Budde <mkl@pengutronix.de>2014-04-01 05:54:56 -0400
commit130a5171dad06c6d89fd5568260fbb0c4b34bd74 (patch)
tree8df907cd6f50521c9617a5b2e0270cf7212dee1c
parentf29b423834be812b736bf5e804290c3e14b1dd67 (diff)
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>
-rw-r--r--drivers/net/can/c_can/c_can.c34
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)
631 * - set operating mode 631 * - set operating mode
632 * - configure message objects 632 * - configure message objects
633 */ 633 */
634static void c_can_chip_config(struct net_device *dev) 634static int c_can_chip_config(struct net_device *dev)
635{ 635{
636 struct c_can_priv *priv = netdev_priv(dev); 636 struct c_can_priv *priv = netdev_priv(dev);
637 637
@@ -668,15 +668,18 @@ static void c_can_chip_config(struct net_device *dev)
668 priv->write_reg(priv, C_CAN_STS_REG, LEC_UNUSED); 668 priv->write_reg(priv, C_CAN_STS_REG, LEC_UNUSED);
669 669
670 /* set bittiming params */ 670 /* set bittiming params */
671 c_can_set_bittiming(dev); 671 return c_can_set_bittiming(dev);
672} 672}
673 673
674static void c_can_start(struct net_device *dev) 674static int c_can_start(struct net_device *dev)
675{ 675{
676 struct c_can_priv *priv = netdev_priv(dev); 676 struct c_can_priv *priv = netdev_priv(dev);
677 int err;
677 678
678 /* basic c_can configuration */ 679 /* basic c_can configuration */
679 c_can_chip_config(dev); 680 err = c_can_chip_config(dev);
681 if (err)
682 return err;
680 683
681 priv->can.state = CAN_STATE_ERROR_ACTIVE; 684 priv->can.state = CAN_STATE_ERROR_ACTIVE;
682 685
@@ -685,6 +688,8 @@ static void c_can_start(struct net_device *dev)
685 688
686 /* enable status change, error and module interrupts */ 689 /* enable status change, error and module interrupts */
687 c_can_enable_all_interrupts(priv, ENABLE_ALL_INTERRUPTS); 690 c_can_enable_all_interrupts(priv, ENABLE_ALL_INTERRUPTS);
691
692 return 0;
688} 693}
689 694
690static void c_can_stop(struct net_device *dev) 695static void c_can_stop(struct net_device *dev)
@@ -700,9 +705,13 @@ static void c_can_stop(struct net_device *dev)
700 705
701static int c_can_set_mode(struct net_device *dev, enum can_mode mode) 706static int c_can_set_mode(struct net_device *dev, enum can_mode mode)
702{ 707{
708 int err;
709
703 switch (mode) { 710 switch (mode) {
704 case CAN_MODE_START: 711 case CAN_MODE_START:
705 c_can_start(dev); 712 err = c_can_start(dev);
713 if (err)
714 return err;
706 netif_wake_queue(dev); 715 netif_wake_queue(dev);
707 break; 716 break;
708 default: 717 default:
@@ -1133,17 +1142,20 @@ static int c_can_open(struct net_device *dev)
1133 goto exit_irq_fail; 1142 goto exit_irq_fail;
1134 } 1143 }
1135 1144
1136 napi_enable(&priv->napi); 1145 /* start the c_can controller */
1146 err = c_can_start(dev);
1147 if (err)
1148 goto exit_start_fail;
1137 1149
1138 can_led_event(dev, CAN_LED_EVENT_OPEN); 1150 can_led_event(dev, CAN_LED_EVENT_OPEN);
1139 1151
1140 /* start the c_can controller */ 1152 napi_enable(&priv->napi);
1141 c_can_start(dev);
1142
1143 netif_start_queue(dev); 1153 netif_start_queue(dev);
1144 1154
1145 return 0; 1155 return 0;
1146 1156
1157exit_start_fail:
1158 free_irq(dev->irq, dev);
1147exit_irq_fail: 1159exit_irq_fail:
1148 close_candev(dev); 1160 close_candev(dev);
1149exit_open_fail: 1161exit_open_fail:
@@ -1260,9 +1272,7 @@ int c_can_power_up(struct net_device *dev)
1260 if (time_after(jiffies, time_out)) 1272 if (time_after(jiffies, time_out))
1261 return -ETIMEDOUT; 1273 return -ETIMEDOUT;
1262 1274
1263 c_can_start(dev); 1275 return c_can_start(dev);
1264
1265 return 0;
1266} 1276}
1267EXPORT_SYMBOL_GPL(c_can_power_up); 1277EXPORT_SYMBOL_GPL(c_can_power_up);
1268#endif 1278#endif