This is a preparation patch for the introduction of CAN XL. can_tdc_fill_info() depends on some varibles which are specific to CAN FD. Move these to the function parameters list so that, later on, this function can be reused for the CAN XL TDC. Signed-off-by: Vincent Mailhol <mailhol.vincent@xxxxxxxxxx> --- drivers/net/can/dev/netlink.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/net/can/dev/netlink.c b/drivers/net/can/dev/netlink.c index 1809f5e53a75..6c3fa5aa22cf 100644 --- a/drivers/net/can/dev/netlink.c +++ b/drivers/net/can/dev/netlink.c @@ -498,12 +498,13 @@ static size_t can_get_size(const struct net_device *dev) return size; } -static int can_tdc_fill_info(struct sk_buff *skb, const struct net_device *dev) +static int can_tdc_fill_info(struct sk_buff *skb, const struct net_device *dev, + struct data_bittiming_params *dbt_params, + bool tdc_is_enabled, bool tdc_manual) { struct nlattr *nest; - struct can_priv *priv = netdev_priv(dev); - struct can_tdc *tdc = &priv->fd.tdc; - const struct can_tdc_const *tdc_const = priv->fd.tdc_const; + struct can_tdc *tdc = &dbt_params->tdc; + const struct can_tdc_const *tdc_const = dbt_params->tdc_const; if (!tdc_const) return 0; @@ -512,7 +513,7 @@ static int can_tdc_fill_info(struct sk_buff *skb, const struct net_device *dev) if (!nest) return -EMSGSIZE; - if (priv->ctrlmode_supported & CAN_CTRLMODE_TDC_MANUAL && + if (tdc_manual && (nla_put_u32(skb, IFLA_CAN_TDC_TDCV_MIN, tdc_const->tdcv_min) || nla_put_u32(skb, IFLA_CAN_TDC_TDCV_MAX, tdc_const->tdcv_max))) goto err_cancel; @@ -524,15 +525,15 @@ static int can_tdc_fill_info(struct sk_buff *skb, const struct net_device *dev) nla_put_u32(skb, IFLA_CAN_TDC_TDCF_MAX, tdc_const->tdcf_max))) goto err_cancel; - if (can_fd_tdc_is_enabled(priv)) { + if (tdc_is_enabled) { u32 tdcv; int err = -EINVAL; - if (priv->ctrlmode & CAN_CTRLMODE_TDC_MANUAL) { + if (tdc_manual) { tdcv = tdc->tdcv; err = 0; - } else if (priv->fd.do_get_auto_tdcv) { - err = priv->fd.do_get_auto_tdcv(dev, &tdcv); + } else if (dbt_params->do_get_auto_tdcv) { + err = dbt_params->do_get_auto_tdcv(dev, &tdcv); } if (!err && nla_put_u32(skb, IFLA_CAN_TDC_TDCV, tdcv)) goto err_cancel; @@ -630,7 +631,8 @@ static int can_fill_info(struct sk_buff *skb, const struct net_device *dev) sizeof(priv->bitrate_max), &priv->bitrate_max)) || - can_tdc_fill_info(skb, dev) || + can_tdc_fill_info(skb, dev, &priv->fd, can_fd_tdc_is_enabled(priv), + priv->ctrlmode & CAN_CTRLMODE_TDC_MANUAL) || can_ctrlmode_ext_fill_info(skb, priv) ) -- 2.45.2