| @@ -647,6 +647,10 @@ static const struct nla_policy can_policy[IFLA_CAN_MAX + 1] = { · 646 unmodified lines |
| 647 | 647 | = { .len = sizeof(struct can_bittiming_const) }, |
| 648 | 648 | [IFLA_CAN_CLOCK] = { .len = sizeof(struct can_clock) }, |
| 649 | 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 | 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 | 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 | 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 | 750 | size += nla_total_size(sizeof(u32)); /* IFLA_CAN_RESTART_MS */ |
| 726 | 751 | if (priv->do_get_berr_counter) /* IFLA_CAN_BERR_COUNTER */ |
| 727 | 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 | 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 | 768 | if (priv->do_get_state) |
| 740 | 769 | priv->do_get_state(dev, &state); |
| 770 | + |
| 741 | 771 | if ((priv->bittiming.bitrate && |
| 742 | 772 | nla_put(skb, IFLA_CAN_BITTIMING, |
| 743 | 773 | sizeof(priv->bittiming), &priv->bittiming)) || |
| 774 | + |
| 744 | 775 | (priv->bittiming_const && |
| 745 | 776 | nla_put(skb, IFLA_CAN_BITTIMING_CONST, |
| 746 | 777 | sizeof(*priv->bittiming_const), priv->bittiming_const)) || |
| 778 | + |
| 747 | 779 | nla_put(skb, IFLA_CAN_CLOCK, sizeof(cm), &priv->clock) || |
| 748 | 780 | nla_put_u32(skb, IFLA_CAN_STATE, state) || |
| 749 | 781 | nla_put(skb, IFLA_CAN_CTRLMODE, sizeof(cm), &cm) || |
| 750 | 782 | nla_put_u32(skb, IFLA_CAN_RESTART_MS, priv->restart_ms) || |
| 783 | + |
| 751 | 784 | (priv->do_get_berr_counter && |
| 752 | 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 | 796 | return -EMSGSIZE; |
| 797 | + |
| 755 | 798 | return 0; |
| 756 | 799 | } |
| 757 | 800 | |