Commit d607525b authored by Vivien Didelot's avatar Vivien Didelot Committed by David S. Miller

net: dsa: return directly from dsa_to_port

Return directly from within the loop as soon as the port is found,
otherwise we won't return NULL if the end of the list is reached.

Fixes: b96ddf25 ("net: dsa: use ports list in dsa_to_port")
Signed-off-by: default avatarVivien Didelot <vivien.didelot@gmail.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 92d72f1b
...@@ -283,13 +283,13 @@ struct dsa_switch { ...@@ -283,13 +283,13 @@ struct dsa_switch {
static inline struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p) static inline struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p)
{ {
struct dsa_switch_tree *dst = ds->dst; struct dsa_switch_tree *dst = ds->dst;
struct dsa_port *dp = NULL; struct dsa_port *dp;
list_for_each_entry(dp, &dst->ports, list) list_for_each_entry(dp, &dst->ports, list)
if (dp->ds == ds && dp->index == p) if (dp->ds == ds && dp->index == p)
break; return dp;
return dp; return NULL;
} }
static inline bool dsa_is_unused_port(struct dsa_switch *ds, int p) static inline bool dsa_is_unused_port(struct dsa_switch *ds, int p)
......
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