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
248248 const u32 *bitrate_const,
249249 const unsigned int bitrate_const_cnt)
250250 {
251− struct can_priv *priv = netdev_priv(dev);
252251 unsigned int i;
253252
254253 for (i = 0; i < bitrate_const_cnt; i++) {
255254 if (bt->bitrate == bitrate_const[i])
256− break;
255+ return 0;
257256 }
258257
259− if (i >= priv->bitrate_const_cnt)
260− return -EINVAL;
261−
262− return 0;
258+ return -EINVAL;
263259 }
264260
265261 int 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