can: bittiming: can_validate_bitrate(): simplify bit rate checking
This patch simplifies the validation of the fixed bit rates. If a supported bit rate is found, directly return 0. If no valid bit rate is found return -EINVAL; Link: https://lore.kernel.org/all/20220124215642.3474154-6-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
parent
181d444790
commit
5b60d334e4
@ -248,18 +248,14 @@ can_validate_bitrate(struct net_device *dev, struct can_bittiming *bt,
|
|||||||
const u32 *bitrate_const,
|
const u32 *bitrate_const,
|
||||||
const unsigned int bitrate_const_cnt)
|
const unsigned int bitrate_const_cnt)
|
||||||
{
|
{
|
||||||
struct can_priv *priv = netdev_priv(dev);
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < bitrate_const_cnt; i++) {
|
for (i = 0; i < bitrate_const_cnt; i++) {
|
||||||
if (bt->bitrate == bitrate_const[i])
|
if (bt->bitrate == bitrate_const[i])
|
||||||
break;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= priv->bitrate_const_cnt)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int can_get_bittiming(struct net_device *dev, struct can_bittiming *bt,
|
int can_get_bittiming(struct net_device *dev, struct can_bittiming *bt,
|
||||||
|
Loading…
Reference in New Issue
Block a user