mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 19:13:47 +02:00
can: netlink: make can_tdc_fill_info() FD agnostic
can_tdc_fill_info() depends on some variables 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@kernel.org> Link: https://patch.msgid.link/20250923-canxl-netlink-prep-v4-17-e720d28f66fe@kernel.org Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
parent
d5ee934ee1
commit
e72f1ba700
|
|
@ -585,21 +585,34 @@ static int can_bitrate_const_fill_info(struct sk_buff *skb,
|
|||
sizeof(*bitrate_const) * cnt, bitrate_const);
|
||||
}
|
||||
|
||||
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,
|
||||
int ifla_can_tdc)
|
||||
{
|
||||
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 data_bittiming_params *dbt_params;
|
||||
const struct can_tdc_const *tdc_const;
|
||||
struct can_tdc *tdc;
|
||||
struct nlattr *nest;
|
||||
bool tdc_is_enabled, tdc_manual;
|
||||
|
||||
if (ifla_can_tdc == IFLA_CAN_TDC) {
|
||||
dbt_params = &priv->fd;
|
||||
tdc_is_enabled = can_fd_tdc_is_enabled(priv);
|
||||
tdc_manual = priv->ctrlmode & CAN_CTRLMODE_TDC_MANUAL;
|
||||
} else {
|
||||
return -EOPNOTSUPP; /* Place holder for CAN XL */
|
||||
}
|
||||
tdc_const = dbt_params->tdc_const;
|
||||
tdc = &dbt_params->tdc;
|
||||
|
||||
if (!tdc_const)
|
||||
return 0;
|
||||
|
||||
nest = nla_nest_start(skb, IFLA_CAN_TDC);
|
||||
nest = nla_nest_start(skb, ifla_can_tdc);
|
||||
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;
|
||||
|
|
@ -611,15 +624,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;
|
||||
|
|
@ -707,7 +720,7 @@ 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, IFLA_CAN_TDC) ||
|
||||
|
||||
can_ctrlmode_ext_fill_info(skb, priv)
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user