Commit 58b6be41 authored by Parav Pandit's avatar Parav Pandit Committed by David S. Miller

devlink: Use switch-case instead of if-else

Make core more readable with switch-case for various port flavours.
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c7282b50
...@@ -510,21 +510,22 @@ static int devlink_nl_port_attrs_put(struct sk_buff *msg, ...@@ -510,21 +510,22 @@ static int devlink_nl_port_attrs_put(struct sk_buff *msg,
return 0; return 0;
if (nla_put_u16(msg, DEVLINK_ATTR_PORT_FLAVOUR, attrs->flavour)) if (nla_put_u16(msg, DEVLINK_ATTR_PORT_FLAVOUR, attrs->flavour))
return -EMSGSIZE; return -EMSGSIZE;
if (devlink_port->attrs.flavour == DEVLINK_PORT_FLAVOUR_PCI_PF) { switch (devlink_port->attrs.flavour) {
case DEVLINK_PORT_FLAVOUR_PCI_PF:
if (nla_put_u16(msg, DEVLINK_ATTR_PORT_PCI_PF_NUMBER, if (nla_put_u16(msg, DEVLINK_ATTR_PORT_PCI_PF_NUMBER,
attrs->pci_pf.pf)) attrs->pci_pf.pf))
return -EMSGSIZE; return -EMSGSIZE;
} else if (devlink_port->attrs.flavour == DEVLINK_PORT_FLAVOUR_PCI_VF) { break;
case DEVLINK_PORT_FLAVOUR_PCI_VF:
if (nla_put_u16(msg, DEVLINK_ATTR_PORT_PCI_PF_NUMBER, if (nla_put_u16(msg, DEVLINK_ATTR_PORT_PCI_PF_NUMBER,
attrs->pci_vf.pf) || attrs->pci_vf.pf) ||
nla_put_u16(msg, DEVLINK_ATTR_PORT_PCI_VF_NUMBER, nla_put_u16(msg, DEVLINK_ATTR_PORT_PCI_VF_NUMBER,
attrs->pci_vf.vf)) attrs->pci_vf.vf))
return -EMSGSIZE; return -EMSGSIZE;
} break;
if (devlink_port->attrs.flavour != DEVLINK_PORT_FLAVOUR_PHYSICAL && case DEVLINK_PORT_FLAVOUR_PHYSICAL:
devlink_port->attrs.flavour != DEVLINK_PORT_FLAVOUR_CPU && case DEVLINK_PORT_FLAVOUR_CPU:
devlink_port->attrs.flavour != DEVLINK_PORT_FLAVOUR_DSA) case DEVLINK_PORT_FLAVOUR_DSA:
return 0;
if (nla_put_u32(msg, DEVLINK_ATTR_PORT_NUMBER, if (nla_put_u32(msg, DEVLINK_ATTR_PORT_NUMBER,
attrs->phys.port_number)) attrs->phys.port_number))
return -EMSGSIZE; return -EMSGSIZE;
...@@ -536,6 +537,10 @@ static int devlink_nl_port_attrs_put(struct sk_buff *msg, ...@@ -536,6 +537,10 @@ static int devlink_nl_port_attrs_put(struct sk_buff *msg,
if (nla_put_u32(msg, DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER, if (nla_put_u32(msg, DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER,
attrs->phys.split_subport_number)) attrs->phys.split_subport_number))
return -EMSGSIZE; return -EMSGSIZE;
break;
default:
break;
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment