History

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;

Marc Kleine-Budde committed 6 years ago

Commit 5b60d331 parent 181d4441 file · +2 −6Browse files

Unified · Split

drivers/net/can/dev/bittiming.c+2−6
@@ -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
265int can_get_bittiming(struct net_device *dev, struct can_bittiming *bt,261int can_get_bittiming(struct net_device *dev, struct can_bittiming *bt,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t