History

ethtool: add speed/duplex validation functions

Add functions which check if the speed/duplex are defined.

Nikolay Aleksandrov committed 10 years ago

Commit 103a8ad1 parent 13340a01 file · +34 −0Browse files

Showing the changes to include/uapi (1 of 1 file). Show all

Unified · Split

include/uapi/linux/ethtool.h+34−0
@@ -1319,11 +1319,45 @@ enum ethtool_sfeatures_retval_bits { · 1318 unmodified lines
13191319
13201320 #define SPEED_UNKNOWN -1
13211321
1322+static inline int ethtool_validate_speed(__u32 speed)
1323+{
1324+ switch (speed) {
1325+ case SPEED_10:
1326+ case SPEED_100:
1327+ case SPEED_1000:
1328+ case SPEED_2500:
1329+ case SPEED_5000:
1330+ case SPEED_10000:
1331+ case SPEED_20000:
1332+ case SPEED_25000:
1333+ case SPEED_40000:
1334+ case SPEED_50000:
1335+ case SPEED_56000:
1336+ case SPEED_100000:
1337+ case SPEED_UNKNOWN:
1338+ return 1;
1339+ }
1340+
1341+ return 0;
1342+}
1343+
13221344 /* Duplex, half or full. */
13231345 #define DUPLEX_HALF 0x00
13241346 #define DUPLEX_FULL 0x01
13251347 #define DUPLEX_UNKNOWN 0xff
13261348
1349+static inline int ethtool_validate_duplex(__u8 duplex)
1350+{
1351+ switch (duplex) {
1352+ case DUPLEX_HALF:
1353+ case DUPLEX_FULL:
1354+ case DUPLEX_UNKNOWN:
1355+ return 1;
1356+ }
1357+
1358+ return 0;
1359+}
1360+
13271361 /* Which connector port. */
13281362 #define PORT_TP 0x00
13291363 #define PORT_AUI 0x01

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