| @@ -647,6 +647,10 @@ static const struct nla_policy can_policy[IFLA_CAN_MAX + 1] = { · 646 unmodified lines |
| 647 | = { .len = sizeof(struct can_bittiming_const) }, | 647 | = { .len = sizeof(struct can_bittiming_const) }, |
| 648 | [IFLA_CAN_CLOCK] = { .len = sizeof(struct can_clock) }, | 648 | [IFLA_CAN_CLOCK] = { .len = sizeof(struct can_clock) }, |
| 649 | [IFLA_CAN_BERR_COUNTER] = { .len = sizeof(struct can_berr_counter) }, | 649 | [IFLA_CAN_BERR_COUNTER] = { .len = sizeof(struct can_berr_counter) }, |
| | 650 | [IFLA_CAN_DATA_BITTIMING] |
| | 651 | = { .len = sizeof(struct can_bittiming) }, |
| | 652 | [IFLA_CAN_DATA_BITTIMING_CONST] |
| | 653 | = { .len = sizeof(struct can_bittiming_const) }, |
| 650 | }; | 654 | }; |
| 651 | | 655 | |
| 652 | static int can_changelink(struct net_device *dev, | 656 | static int can_changelink(struct net_device *dev, |
| @@ -707,6 +711,27 @@ static int can_changelink(struct net_device *dev, · 54 unmodified lines |
| 707 | return err; | 711 | return err; |
| 708 | } | 712 | } |
| 709 | | 713 | |
| | 714 | if (data[IFLA_CAN_DATA_BITTIMING]) { |
| | 715 | struct can_bittiming dbt; |
| | 716 | |
| | 717 | /* Do not allow changing bittiming while running */ |
| | 718 | if (dev->flags & IFF_UP) |
| | 719 | return -EBUSY; |
| | 720 | memcpy(&dbt, nla_data(data[IFLA_CAN_DATA_BITTIMING]), |
| | 721 | sizeof(dbt)); |
| | 722 | err = can_get_bittiming(dev, &dbt, priv->data_bittiming_const); |
| | 723 | if (err) |
| | 724 | return err; |
| | 725 | memcpy(&priv->data_bittiming, &dbt, sizeof(dbt)); |
| | 726 | |
| | 727 | if (priv->do_set_data_bittiming) { |
| | 728 | /* Finally, set the bit-timing registers */ |
| | 729 | err = priv->do_set_data_bittiming(dev); |
| | 730 | if (err) |
| | 731 | return err; |
| | 732 | } |
| | 733 | } |
| | 734 | |
| 710 | return 0; | 735 | return 0; |
| 711 | } | 736 | } |
| 712 | | 737 | |
| @@ -725,6 +750,10 @@ static size_t can_get_size(const struct net_device *dev) · 12 unmodified lines |
| 725 | size += nla_total_size(sizeof(u32)); /* IFLA_CAN_RESTART_MS */ | 750 | size += nla_total_size(sizeof(u32)); /* IFLA_CAN_RESTART_MS */ |
| 726 | if (priv->do_get_berr_counter) /* IFLA_CAN_BERR_COUNTER */ | 751 | if (priv->do_get_berr_counter) /* IFLA_CAN_BERR_COUNTER */ |
| 727 | size += nla_total_size(sizeof(struct can_berr_counter)); | 752 | size += nla_total_size(sizeof(struct can_berr_counter)); |
| | 753 | if (priv->data_bittiming.bitrate) /* IFLA_CAN_DATA_BITTIMING */ |
| | 754 | size += nla_total_size(sizeof(struct can_bittiming)); |
| | 755 | if (priv->data_bittiming_const) /* IFLA_CAN_DATA_BITTIMING_CONST */ |
| | 756 | size += nla_total_size(sizeof(struct can_bittiming_const)); |
| 728 | | 757 | |
| 729 | return size; | 758 | return size; |
| 730 | } | 759 | } |
| @@ -738,20 +767,34 @@ static int can_fill_info(struct sk_buff *skb, const struct net_device *dev) · 7 unmodified lines |
| 738 | | 767 | |
| 739 | if (priv->do_get_state) | 768 | if (priv->do_get_state) |
| 740 | priv->do_get_state(dev, &state); | 769 | priv->do_get_state(dev, &state); |
| | 770 | |
| 741 | if ((priv->bittiming.bitrate && | 771 | if ((priv->bittiming.bitrate && |
| 742 | nla_put(skb, IFLA_CAN_BITTIMING, | 772 | nla_put(skb, IFLA_CAN_BITTIMING, |
| 743 | sizeof(priv->bittiming), &priv->bittiming)) || | 773 | sizeof(priv->bittiming), &priv->bittiming)) || |
| | 774 | |
| 744 | (priv->bittiming_const && | 775 | (priv->bittiming_const && |
| 745 | nla_put(skb, IFLA_CAN_BITTIMING_CONST, | 776 | nla_put(skb, IFLA_CAN_BITTIMING_CONST, |
| 746 | sizeof(*priv->bittiming_const), priv->bittiming_const)) || | 777 | sizeof(*priv->bittiming_const), priv->bittiming_const)) || |
| | 778 | |
| 747 | nla_put(skb, IFLA_CAN_CLOCK, sizeof(cm), &priv->clock) || | 779 | nla_put(skb, IFLA_CAN_CLOCK, sizeof(cm), &priv->clock) || |
| 748 | nla_put_u32(skb, IFLA_CAN_STATE, state) || | 780 | nla_put_u32(skb, IFLA_CAN_STATE, state) || |
| 749 | nla_put(skb, IFLA_CAN_CTRLMODE, sizeof(cm), &cm) || | 781 | nla_put(skb, IFLA_CAN_CTRLMODE, sizeof(cm), &cm) || |
| 750 | nla_put_u32(skb, IFLA_CAN_RESTART_MS, priv->restart_ms) || | 782 | nla_put_u32(skb, IFLA_CAN_RESTART_MS, priv->restart_ms) || |
| | 783 | |
| 751 | (priv->do_get_berr_counter && | 784 | (priv->do_get_berr_counter && |
| 752 | !priv->do_get_berr_counter(dev, &bec) && | 785 | !priv->do_get_berr_counter(dev, &bec) && |
| 753 | nla_put(skb, IFLA_CAN_BERR_COUNTER, sizeof(bec), &bec))) | 786 | nla_put(skb, IFLA_CAN_BERR_COUNTER, sizeof(bec), &bec)) || |
| | 787 | |
| | 788 | (priv->data_bittiming.bitrate && |
| | 789 | nla_put(skb, IFLA_CAN_DATA_BITTIMING, |
| | 790 | sizeof(priv->data_bittiming), &priv->data_bittiming)) || |
| | 791 | |
| | 792 | (priv->data_bittiming_const && |
| | 793 | nla_put(skb, IFLA_CAN_DATA_BITTIMING_CONST, |
| | 794 | sizeof(*priv->data_bittiming_const), |
| | 795 | priv->data_bittiming_const))) |
| 754 | return -EMSGSIZE; | 796 | return -EMSGSIZE; |
| | 797 | |
| 755 | return 0; | 798 | return 0; |
| 756 | } | 799 | } |
| 757 | | 800 | |