diff options
author | David S. Miller <davem@davemloft.net> | 2013-11-04 19:59:44 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-11-04 19:59:44 -0500 |
commit | 13521a57974635384db51d65135cc0267c6ae771 (patch) | |
tree | 7efbad661e4cdbb5e469dcb7c64e5b35ddc0266a /drivers/net/can | |
parent | 9f9843a751d0a2057f9f3d313886e7e5e6ebaac9 (diff) | |
parent | 26896fd98130cdda73b19c75849a0d25cb850cb8 (diff) |
Merge branch 'for-davem' of git://gitorious.org/linux-can/linux-can-next
Marc Kleine-Budde says:
====================
here's a pull request for net-next.
It includes a patch by Oliver Hartkopp et al. that adds documentation
for the broadcast manager to Documentation/networking/can.txt. Three
patches by me that clean up the netlink handling code in the CAN core.
And another patch that removes a not needed function from the ti_hecc
driver.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/can')
-rw-r--r-- | drivers/net/can/dev.c | 67 | ||||
-rw-r--r-- | drivers/net/can/ti_hecc.c | 10 |
2 files changed, 32 insertions, 45 deletions
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c index 1870c4731a57..bda1888cae9a 100644 --- a/drivers/net/can/dev.c +++ b/drivers/net/can/dev.c | |||
@@ -645,19 +645,6 @@ static int can_changelink(struct net_device *dev, | |||
645 | /* We need synchronization with dev->stop() */ | 645 | /* We need synchronization with dev->stop() */ |
646 | ASSERT_RTNL(); | 646 | ASSERT_RTNL(); |
647 | 647 | ||
648 | if (data[IFLA_CAN_CTRLMODE]) { | ||
649 | struct can_ctrlmode *cm; | ||
650 | |||
651 | /* Do not allow changing controller mode while running */ | ||
652 | if (dev->flags & IFF_UP) | ||
653 | return -EBUSY; | ||
654 | cm = nla_data(data[IFLA_CAN_CTRLMODE]); | ||
655 | if (cm->flags & ~priv->ctrlmode_supported) | ||
656 | return -EOPNOTSUPP; | ||
657 | priv->ctrlmode &= ~cm->mask; | ||
658 | priv->ctrlmode |= cm->flags; | ||
659 | } | ||
660 | |||
661 | if (data[IFLA_CAN_BITTIMING]) { | 648 | if (data[IFLA_CAN_BITTIMING]) { |
662 | struct can_bittiming bt; | 649 | struct can_bittiming bt; |
663 | 650 | ||
@@ -680,6 +667,19 @@ static int can_changelink(struct net_device *dev, | |||
680 | } | 667 | } |
681 | } | 668 | } |
682 | 669 | ||
670 | if (data[IFLA_CAN_CTRLMODE]) { | ||
671 | struct can_ctrlmode *cm; | ||
672 | |||
673 | /* Do not allow changing controller mode while running */ | ||
674 | if (dev->flags & IFF_UP) | ||
675 | return -EBUSY; | ||
676 | cm = nla_data(data[IFLA_CAN_CTRLMODE]); | ||
677 | if (cm->flags & ~priv->ctrlmode_supported) | ||
678 | return -EOPNOTSUPP; | ||
679 | priv->ctrlmode &= ~cm->mask; | ||
680 | priv->ctrlmode |= cm->flags; | ||
681 | } | ||
682 | |||
683 | if (data[IFLA_CAN_RESTART_MS]) { | 683 | if (data[IFLA_CAN_RESTART_MS]) { |
684 | /* Do not allow changing restart delay while running */ | 684 | /* Do not allow changing restart delay while running */ |
685 | if (dev->flags & IFF_UP) | 685 | if (dev->flags & IFF_UP) |
@@ -702,17 +702,17 @@ static int can_changelink(struct net_device *dev, | |||
702 | static size_t can_get_size(const struct net_device *dev) | 702 | static size_t can_get_size(const struct net_device *dev) |
703 | { | 703 | { |
704 | struct can_priv *priv = netdev_priv(dev); | 704 | struct can_priv *priv = netdev_priv(dev); |
705 | size_t size; | 705 | size_t size = 0; |
706 | 706 | ||
707 | size = nla_total_size(sizeof(u32)); /* IFLA_CAN_STATE */ | 707 | size += nla_total_size(sizeof(struct can_bittiming)); /* IFLA_CAN_BITTIMING */ |
708 | size += nla_total_size(sizeof(struct can_ctrlmode)); /* IFLA_CAN_CTRLMODE */ | 708 | if (priv->bittiming_const) /* IFLA_CAN_BITTIMING_CONST */ |
709 | size += nla_total_size(sizeof(u32)); /* IFLA_CAN_RESTART_MS */ | ||
710 | size += nla_total_size(sizeof(struct can_bittiming)); /* IFLA_CAN_BITTIMING */ | ||
711 | size += nla_total_size(sizeof(struct can_clock)); /* IFLA_CAN_CLOCK */ | ||
712 | if (priv->do_get_berr_counter) /* IFLA_CAN_BERR_COUNTER */ | ||
713 | size += nla_total_size(sizeof(struct can_berr_counter)); | ||
714 | if (priv->bittiming_const) /* IFLA_CAN_BITTIMING_CONST */ | ||
715 | size += nla_total_size(sizeof(struct can_bittiming_const)); | 709 | size += nla_total_size(sizeof(struct can_bittiming_const)); |
710 | size += nla_total_size(sizeof(struct can_clock)); /* IFLA_CAN_CLOCK */ | ||
711 | size += nla_total_size(sizeof(u32)); /* IFLA_CAN_STATE */ | ||
712 | size += nla_total_size(sizeof(struct can_ctrlmode)); /* IFLA_CAN_CTRLMODE */ | ||
713 | size += nla_total_size(sizeof(u32)); /* IFLA_CAN_RESTART_MS */ | ||
714 | if (priv->do_get_berr_counter) /* IFLA_CAN_BERR_COUNTER */ | ||
715 | size += nla_total_size(sizeof(struct can_berr_counter)); | ||
716 | 716 | ||
717 | return size; | 717 | return size; |
718 | } | 718 | } |
@@ -726,23 +726,20 @@ static int can_fill_info(struct sk_buff *skb, const struct net_device *dev) | |||
726 | 726 | ||
727 | if (priv->do_get_state) | 727 | if (priv->do_get_state) |
728 | priv->do_get_state(dev, &state); | 728 | priv->do_get_state(dev, &state); |
729 | if (nla_put_u32(skb, IFLA_CAN_STATE, state) || | 729 | if (nla_put(skb, IFLA_CAN_BITTIMING, |
730 | nla_put(skb, IFLA_CAN_CTRLMODE, sizeof(cm), &cm) || | ||
731 | nla_put_u32(skb, IFLA_CAN_RESTART_MS, priv->restart_ms) || | ||
732 | nla_put(skb, IFLA_CAN_BITTIMING, | ||
733 | sizeof(priv->bittiming), &priv->bittiming) || | 730 | sizeof(priv->bittiming), &priv->bittiming) || |
731 | (priv->bittiming_const && | ||
732 | nla_put(skb, IFLA_CAN_BITTIMING_CONST, | ||
733 | sizeof(*priv->bittiming_const), priv->bittiming_const)) || | ||
734 | nla_put(skb, IFLA_CAN_CLOCK, sizeof(cm), &priv->clock) || | 734 | nla_put(skb, IFLA_CAN_CLOCK, sizeof(cm), &priv->clock) || |
735 | nla_put_u32(skb, IFLA_CAN_STATE, state) || | ||
736 | nla_put(skb, IFLA_CAN_CTRLMODE, sizeof(cm), &cm) || | ||
737 | nla_put_u32(skb, IFLA_CAN_RESTART_MS, priv->restart_ms) || | ||
735 | (priv->do_get_berr_counter && | 738 | (priv->do_get_berr_counter && |
736 | !priv->do_get_berr_counter(dev, &bec) && | 739 | !priv->do_get_berr_counter(dev, &bec) && |
737 | nla_put(skb, IFLA_CAN_BERR_COUNTER, sizeof(bec), &bec)) || | 740 | nla_put(skb, IFLA_CAN_BERR_COUNTER, sizeof(bec), &bec))) |
738 | (priv->bittiming_const && | 741 | return -EMSGSIZE; |
739 | nla_put(skb, IFLA_CAN_BITTIMING_CONST, | ||
740 | sizeof(*priv->bittiming_const), priv->bittiming_const))) | ||
741 | goto nla_put_failure; | ||
742 | return 0; | 742 | return 0; |
743 | |||
744 | nla_put_failure: | ||
745 | return -EMSGSIZE; | ||
746 | } | 743 | } |
747 | 744 | ||
748 | static size_t can_get_xstats_size(const struct net_device *dev) | 745 | static size_t can_get_xstats_size(const struct net_device *dev) |
diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c index beb5ef834f0f..60d95b44d0f7 100644 --- a/drivers/net/can/ti_hecc.c +++ b/drivers/net/can/ti_hecc.c | |||
@@ -286,15 +286,6 @@ static inline u32 hecc_get_bit(struct ti_hecc_priv *priv, int reg, u32 bit_mask) | |||
286 | return (hecc_read(priv, reg) & bit_mask) ? 1 : 0; | 286 | return (hecc_read(priv, reg) & bit_mask) ? 1 : 0; |
287 | } | 287 | } |
288 | 288 | ||
289 | static int ti_hecc_get_state(const struct net_device *ndev, | ||
290 | enum can_state *state) | ||
291 | { | ||
292 | struct ti_hecc_priv *priv = netdev_priv(ndev); | ||
293 | |||
294 | *state = priv->can.state; | ||
295 | return 0; | ||
296 | } | ||
297 | |||
298 | static int ti_hecc_set_btc(struct ti_hecc_priv *priv) | 289 | static int ti_hecc_set_btc(struct ti_hecc_priv *priv) |
299 | { | 290 | { |
300 | struct can_bittiming *bit_timing = &priv->can.bittiming; | 291 | struct can_bittiming *bit_timing = &priv->can.bittiming; |
@@ -940,7 +931,6 @@ static int ti_hecc_probe(struct platform_device *pdev) | |||
940 | 931 | ||
941 | priv->can.bittiming_const = &ti_hecc_bittiming_const; | 932 | priv->can.bittiming_const = &ti_hecc_bittiming_const; |
942 | priv->can.do_set_mode = ti_hecc_do_set_mode; | 933 | priv->can.do_set_mode = ti_hecc_do_set_mode; |
943 | priv->can.do_get_state = ti_hecc_get_state; | ||
944 | priv->can.do_get_berr_counter = ti_hecc_get_berr_counter; | 934 | priv->can.do_get_berr_counter = ti_hecc_get_berr_counter; |
945 | priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES; | 935 | priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES; |
946 | 936 | ||