mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
RDMA/core: Add the function ib_mtu_int_to_enum
As the functionality to convert the MTU from a number to enum_ib_mtu is ubiquitous, define a dedicated function and remove the duplicated code. Signed-off-by: Ram Amrani <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
This commit is contained in:
parent
ff89b070b7
commit
d3f4aadd61
5 changed files with 18 additions and 41 deletions
|
|
@ -352,6 +352,20 @@ static inline int ib_mtu_enum_to_int(enum ib_mtu mtu)
|
|||
}
|
||||
}
|
||||
|
||||
static inline enum ib_mtu ib_mtu_int_to_enum(int mtu)
|
||||
{
|
||||
if (mtu >= 4096)
|
||||
return IB_MTU_4096;
|
||||
else if (mtu >= 2048)
|
||||
return IB_MTU_2048;
|
||||
else if (mtu >= 1024)
|
||||
return IB_MTU_1024;
|
||||
else if (mtu >= 512)
|
||||
return IB_MTU_512;
|
||||
else
|
||||
return IB_MTU_256;
|
||||
}
|
||||
|
||||
enum ib_port_state {
|
||||
IB_PORT_NOP = 0,
|
||||
IB_PORT_DOWN = 1,
|
||||
|
|
|
|||
Loading…
Reference in a new issue