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;
Unified · Split
| @@ -248,18 +248,14 @@ can_validate_bitrate(struct net_device *dev, struct can_bittiming *bt, · 247 unmodified lines | |||
| 248 | const u32 *bitrate_const, | 248 | const u32 *bitrate_const, |
| 249 | const unsigned int bitrate_const_cnt) | 249 | const unsigned int bitrate_const_cnt) |
| 250 | { | 250 | { |
| 251 | struct can_priv *priv = netdev_priv(dev); | ||
| 252 | unsigned int i; | 251 | unsigned int i; |
| 253 | 252 | ||
| 254 | for (i = 0; i < bitrate_const_cnt; i++) { | 253 | for (i = 0; i < bitrate_const_cnt; i++) { |
| 255 | if (bt->bitrate == bitrate_const[i]) | 254 | if (bt->bitrate == bitrate_const[i]) |
| 256 | break; | 255 | return 0; |
| 257 | } | 256 | } |
| 258 | 257 | ||
| 259 | if (i >= priv->bitrate_const_cnt) | 258 | return -EINVAL; |
| 260 | return -EINVAL; | ||
| 261 | |||
| 262 | return 0; | ||
| 263 | } | 259 | } |
| 264 | 260 | ||
| 265 | int can_get_bittiming(struct net_device *dev, struct can_bittiming *bt, | 261 | int can_get_bittiming(struct net_device *dev, struct can_bittiming *bt, |