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

can: netlink: can_changelink(): convert from netdev_err() to NL_SET_ERR_MSG_FMT()

Since commit 51c352bdbcd2 ("netlink: add support for formatted extack
messages") formatted extack messages are supported to inform the user
space or warnings/errors during netlink calls.

Replace the netdev_err() by NL_SET_ERR_MSG_FMT() to better inform the
user about the problem. While there, use %u to print unsigned values
and improve error message a bit.

Link: https://lore.kernel.org/all/20230202110854.2318594-9-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

+6 -4
+6 -4
drivers/net/can/dev/netlink.c
··· 220 220 return err; 221 221 222 222 if (priv->bitrate_max && bt.bitrate > priv->bitrate_max) { 223 - netdev_err(dev, "arbitration bitrate surpasses transceiver capabilities of %d bps\n", 224 - priv->bitrate_max); 223 + NL_SET_ERR_MSG_FMT(extack, 224 + "arbitration bitrate %u bps surpasses transceiver capabilities of %u bps", 225 + bt.bitrate, priv->bitrate_max); 225 226 return -EINVAL; 226 227 } 227 228 ··· 325 324 return err; 326 325 327 326 if (priv->bitrate_max && dbt.bitrate > priv->bitrate_max) { 328 - netdev_err(dev, "canfd data bitrate surpasses transceiver capabilities of %d bps\n", 329 - priv->bitrate_max); 327 + NL_SET_ERR_MSG_FMT(extack, 328 + "CANFD data bitrate %u bps surpasses transceiver capabilities of %u bps", 329 + dbt.bitrate, priv->bitrate_max); 330 330 return -EINVAL; 331 331 } 332 332