Commit 06742086 authored by Marc Kleine-Budde's avatar Marc Kleine-Budde

can: bittiming: can_calc_bittiming(): convert from netdev_err() to NL_SET_ERR_MSG_FMT()

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.

In case of an error, return -EINVAL instead of -EDOM, this corresponds
better to the actual meaning of the error value.

Link: https://lore.kernel.org/all/20230202110854.2318594-17-mkl@pengutronix.deSigned-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent c7650728
...@@ -134,13 +134,14 @@ int can_calc_bittiming(const struct net_device *dev, struct can_bittiming *bt, ...@@ -134,13 +134,14 @@ int can_calc_bittiming(const struct net_device *dev, struct can_bittiming *bt,
do_div(v64, bt->bitrate); do_div(v64, bt->bitrate);
bitrate_error = (u32)v64; bitrate_error = (u32)v64;
if (bitrate_error > CAN_CALC_MAX_ERROR) { if (bitrate_error > CAN_CALC_MAX_ERROR) {
netdev_err(dev, NL_SET_ERR_MSG_FMT(extack,
"bitrate error %d.%d%% too high\n", "bitrate error: %u.%u%% too high",
bitrate_error / 10, bitrate_error % 10); bitrate_error / 10, bitrate_error % 10);
return -EDOM; return -EINVAL;
} }
netdev_warn(dev, "bitrate error %d.%d%%\n", NL_SET_ERR_MSG_FMT(extack,
bitrate_error / 10, bitrate_error % 10); "bitrate error: %u.%u%%",
bitrate_error / 10, bitrate_error % 10);
} }
/* real sample point */ /* real sample point */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment