can: calc_bittiming: make can_calc_tdco() FD agnostic
can_calc_tdco() uses the CAN_CTRLMODE_FD_TDC_MASK and CAN_CTRLMODE_TDC_AUTO macros making it specific to CAN FD. Add the tdc mask to the function parameter list. The value of the tdc auto flag can then be derived from that mask and stored in a local variable. This way, the function becomes CAN FD agnostic and can be reused later on for the CAN XL TDC. Signed-off-by: Vincent Mailhol <mailhol@kernel.org> Link: https://patch.msgid.link/20250923-canxl-netlink-prep-v4-18-e720d28f66fe@kernel.org Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
committed by
Marc Kleine-Budde
parent
e72f1ba700
commit
6ffc1230d3
@@ -173,13 +173,15 @@ int can_calc_bittiming(const struct net_device *dev, struct can_bittiming *bt,
|
||||
|
||||
void can_calc_tdco(struct can_tdc *tdc, const struct can_tdc_const *tdc_const,
|
||||
const struct can_bittiming *dbt,
|
||||
u32 *ctrlmode, u32 ctrlmode_supported)
|
||||
u32 tdc_mask, u32 *ctrlmode, u32 ctrlmode_supported)
|
||||
|
||||
{
|
||||
if (!tdc_const || !(ctrlmode_supported & CAN_CTRLMODE_TDC_AUTO))
|
||||
u32 tdc_auto = tdc_mask & CAN_CTRLMODE_TDC_AUTO_MASK;
|
||||
|
||||
if (!tdc_const || !(ctrlmode_supported & tdc_auto))
|
||||
return;
|
||||
|
||||
*ctrlmode &= ~CAN_CTRLMODE_FD_TDC_MASK;
|
||||
*ctrlmode &= ~tdc_mask;
|
||||
|
||||
/* As specified in ISO 11898-1 section 11.3.3 "Transmitter
|
||||
* delay compensation" (TDC) is only applicable if data BRP is
|
||||
@@ -193,6 +195,6 @@ void can_calc_tdco(struct can_tdc *tdc, const struct can_tdc_const *tdc_const,
|
||||
if (sample_point_in_tc < tdc_const->tdco_min)
|
||||
return;
|
||||
tdc->tdco = min(sample_point_in_tc, tdc_const->tdco_max);
|
||||
*ctrlmode |= CAN_CTRLMODE_TDC_AUTO;
|
||||
*ctrlmode |= tdc_auto;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ static int can_dbt_changelink(struct net_device *dev, struct nlattr *data[],
|
||||
* do calculation
|
||||
*/
|
||||
can_calc_tdco(&dbt_params->tdc, dbt_params->tdc_const, &dbt,
|
||||
&priv->ctrlmode, priv->ctrlmode_supported);
|
||||
tdc_mask, &priv->ctrlmode, priv->ctrlmode_supported);
|
||||
} /* else: both CAN_CTRLMODE_TDC_{AUTO,MANUAL} are explicitly
|
||||
* turned off. TDC is disabled: do nothing
|
||||
*/
|
||||
|
||||
@@ -135,7 +135,7 @@ int can_calc_bittiming(const struct net_device *dev, struct can_bittiming *bt,
|
||||
|
||||
void can_calc_tdco(struct can_tdc *tdc, const struct can_tdc_const *tdc_const,
|
||||
const struct can_bittiming *dbt,
|
||||
u32 *ctrlmode, u32 ctrlmode_supported);
|
||||
u32 tdc_mask, u32 *ctrlmode, u32 ctrlmode_supported);
|
||||
#else /* !CONFIG_CAN_CALC_BITTIMING */
|
||||
static inline int
|
||||
can_calc_bittiming(const struct net_device *dev, struct can_bittiming *bt,
|
||||
@@ -148,7 +148,7 @@ can_calc_bittiming(const struct net_device *dev, struct can_bittiming *bt,
|
||||
static inline void
|
||||
can_calc_tdco(struct can_tdc *tdc, const struct can_tdc_const *tdc_const,
|
||||
const struct can_bittiming *dbt,
|
||||
u32 *ctrlmode, u32 ctrlmode_supported)
|
||||
u32 tdc_mask, u32 *ctrlmode, u32 ctrlmode_supported)
|
||||
{
|
||||
}
|
||||
#endif /* CONFIG_CAN_CALC_BITTIMING */
|
||||
|
||||
Reference in New Issue
Block a user