Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

can: netlink: refactor CAN_CTRLMODE_TDC_{AUTO,MANUAL} flag reset logic

CAN_CTRLMODE_TDC_AUTO and CAN_CTRLMODE_TDC_MANUAL are mutually
exclusive. This means that whenever the user switches from auto to
manual mode (or vice versa), the other flag which was set previously
needs to be cleared.

Currently, this is handled with a masking operation. It can be done in
a simpler manner by clearing any of the previous TDC flags before
copying netlink attributes. The code becomes easier to understand and
will make it easier to add the new upcoming CAN XL flags which will
have a similar reset logic as the current TDC flags.

Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
Link: https://patch.msgid.link/20250923-canxl-netlink-prep-v4-7-e720d28f66fe@kernel.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Vincent Mailhol and committed by
Marc Kleine-Budde
45be26b7 3820a415

+4 -5
+4 -5
drivers/net/can/dev/netlink.c
··· 255 255 if ((maskedflags & ctrlstatic) != ctrlstatic) 256 256 return -EOPNOTSUPP; 257 257 258 + /* If a top dependency flag is provided, reset all its dependencies */ 259 + if (cm->mask & CAN_CTRLMODE_FD) 260 + priv->ctrlmode &= ~CAN_CTRLMODE_FD_TDC_MASK; 261 + 258 262 /* clear bits to be modified and copy the flag values */ 259 263 priv->ctrlmode &= ~cm->mask; 260 264 priv->ctrlmode |= maskedflags; ··· 274 270 can_set_default_mtu(dev); 275 271 276 272 fd_tdc_flag_provided = cm->mask & CAN_CTRLMODE_FD_TDC_MASK; 277 - /* CAN_CTRLMODE_TDC_{AUTO,MANUAL} are mutually 278 - * exclusive: make sure to turn the other one off 279 - */ 280 - if (fd_tdc_flag_provided) 281 - priv->ctrlmode &= cm->flags | ~CAN_CTRLMODE_FD_TDC_MASK; 282 273 } 283 274 284 275 if (data[IFLA_CAN_BITTIMING]) {