diff options
author | Vincent Mailhol <mailhol.vincent@wanadoo.fr> | 2021-09-18 18:56:34 +0900 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2021-10-24 16:24:29 +0200 |
commit | da45a1e4d7b9d6b5a8231acb812df719fe3228b4 (patch) | |
tree | a5c40e1ea130638957d6510fd4d2164de62e74b5 /drivers/net/can/dev/netlink.c | |
parent | 39f66c9e229797a58a12ea78388cbbad1f81aec9 (diff) |
can: bittiming: change can_calc_tdco()'s prototype to not directly modify priv
The function can_calc_tdco() directly retrieves can_priv from the
net_device and directly modifies it.
This is annoying for the upcoming patch. In
drivers/net/can/dev/netlink.c:can_changelink(), the data bittiming are
written to a temporary structure and memcpyed to can_priv only after
everything succeeded. In the next patch, where we will introduce the
netlink interface for TDC parameters, we will add a new TDC block
which can potentially fail. For this reason, the data bittiming
temporary structure has to be copied after that to-be-introduced TDC
block. However, TDC also needs to access data bittiming information.
We change the prototype so that the data bittiming structure is passed
to can_calc_tdco() as an argument instead of retrieving it from
priv. This way can_calc_tdco() can access the data bittiming before it
gets memcpyed to priv.
Link: https://lore.kernel.org/all/20210918095637.20108-4-mailhol.vincent@wanadoo.fr
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can/dev/netlink.c')
-rw-r--r-- | drivers/net/can/dev/netlink.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/net/can/dev/netlink.c b/drivers/net/can/dev/netlink.c index 80425636049d..e79c9a2ffbfc 100644 --- a/drivers/net/can/dev/netlink.c +++ b/drivers/net/can/dev/netlink.c @@ -189,7 +189,8 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[], memcpy(&priv->data_bittiming, &dbt, sizeof(dbt)); - can_calc_tdco(dev); + can_calc_tdco(&priv->tdc, priv->tdc_const, &priv->data_bittiming, + &priv->ctrlmode, priv->ctrlmode_supported); if (priv->do_set_data_bittiming) { /* Finally, set the bit-timing registers */ |