]> git.baikalelectronics.ru Git - kernel.git/commit
can: dev: add sanity check in can_set_static_ctrlmode()
authorVincent Mailhol <mailhol.vincent@wanadoo.fr>
Mon, 13 Dec 2021 16:02:24 +0000 (01:02 +0900)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Wed, 5 Jan 2022 11:09:05 +0000 (12:09 +0100)
commit6907f688412a3201453c2bc7b062803327e3c3da
treebf77ce3f94c4ef2687d4418e78bdf094ec573506
parent603a8b1d8c7dfeb20f43d9d79c14ed8adb8d3174
can: dev: add sanity check in can_set_static_ctrlmode()

Previous patch removed can_priv::ctrlmode_static to replace it with
can_get_static_ctrlmode().

A condition sine qua non for this to work is that the controller
static modes should never be set in can_priv::ctrlmode_supported
(c.f. the comment on can_priv::ctrlmode_supported which states that it
is for "options that can be *modified* by netlink"). Also, this
condition is already correctly fulfilled by all existing drivers
which rely on the ctrlmode_static feature.

Nonetheless, we added an extra safeguard in can_set_static_ctrlmode()
to return an error value and to warn the developer who would be
adventurous enough to set to static a given feature that is already
set to supported.

The drivers which rely on the static controller mode are then updated
to check the return value of can_set_static_ctrlmode().

Link: https://lore.kernel.org/all/20211213160226.56219-3-mailhol.vincent@wanadoo.fr
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/m_can/m_can.c
drivers/net/can/rcar/rcar_canfd.c
include/linux/can/dev.h