]> git.ipfire.org Git - thirdparty/linux.git/commit
can: netlink: refactor can_validate_bittiming()
authorVincent Mailhol <mailhol@kernel.org>
Tue, 23 Sep 2025 06:58:29 +0000 (15:58 +0900)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Wed, 24 Sep 2025 15:09:44 +0000 (17:09 +0200)
commitf5ae5a75412db0b8ded2342d409c7ba504eb198f
tree157ad0b421e2c7e7a7845645c38c51e2a7f514ff
parent94040a8f484576cb1b7df3b2e93118c3b3e3aff4
can: netlink: refactor can_validate_bittiming()

Whenever can_validate_bittiming() is called, it is always preceded by
some boilerplate code which was copy pasted all over the place. Move
that repeated code directly inside can_validate_bittiming().

Finally, the mempcy() is not needed: the nla attributes are four bytes
aligned which is just enough for struct can_bittiming. Add a
static_assert() to document that the alignment is correct and just use
the pointer returned by nla_data() as-is.

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