Skip to content

Commit

Permalink
can: netlink: can_changelink(): convert from netdev_err() to NL_SET_E…
Browse files Browse the repository at this point in the history
…RR_MSG_FMT()

Since commit 51c352b ("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>
  • Loading branch information
Marc Kleine-Budde committed Feb 6, 2023
1 parent 73335cf commit 1494d27
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/net/can/dev/netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,9 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[],
return err;

if (priv->bitrate_max && bt.bitrate > priv->bitrate_max) {
netdev_err(dev, "arbitration bitrate surpasses transceiver capabilities of %d bps\n",
priv->bitrate_max);
NL_SET_ERR_MSG_FMT(extack,
"arbitration bitrate %u bps surpasses transceiver capabilities of %u bps",
bt.bitrate, priv->bitrate_max);
return -EINVAL;
}

Expand Down Expand Up @@ -324,8 +325,9 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[],
return err;

if (priv->bitrate_max && dbt.bitrate > priv->bitrate_max) {
netdev_err(dev, "canfd data bitrate surpasses transceiver capabilities of %d bps\n",
priv->bitrate_max);
NL_SET_ERR_MSG_FMT(extack,
"CANFD data bitrate %u bps surpasses transceiver capabilities of %u bps",
dbt.bitrate, priv->bitrate_max);
return -EINVAL;
}

Expand Down

0 comments on commit 1494d27

Please sign in to comment.