Skip to content

Commit dd0c985

Browse files
Russell King (Oracle)kuba-moo
authored andcommitted
net: dsa: introduce dsa_phylink_to_port()
We convert from a phylink_config struct to a dsa_port struct in many places, let's provide a helper for this. Reviewed-by: Andrew Lunn <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: Russell King (Oracle) <[email protected]> Reviewed-by: Vladimir Oltean <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f7ac8fb commit dd0c985

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

include/net/dsa.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,12 @@ struct dsa_port {
327327
};
328328
};
329329

330+
static inline struct dsa_port *
331+
dsa_phylink_to_port(struct phylink_config *config)
332+
{
333+
return container_of(config, struct dsa_port, pl_config);
334+
}
335+
330336
/* TODO: ideally DSA ports would have a single dp->link_dp member,
331337
* and no dst->rtable nor this struct dsa_link would be needed,
332338
* but this would require some more complex tree walking,

net/dsa/port.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,7 @@ static struct phylink_pcs *
15581558
dsa_port_phylink_mac_select_pcs(struct phylink_config *config,
15591559
phy_interface_t interface)
15601560
{
1561-
struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
1561+
struct dsa_port *dp = dsa_phylink_to_port(config);
15621562
struct phylink_pcs *pcs = ERR_PTR(-EOPNOTSUPP);
15631563
struct dsa_switch *ds = dp->ds;
15641564

@@ -1572,7 +1572,7 @@ static int dsa_port_phylink_mac_prepare(struct phylink_config *config,
15721572
unsigned int mode,
15731573
phy_interface_t interface)
15741574
{
1575-
struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
1575+
struct dsa_port *dp = dsa_phylink_to_port(config);
15761576
struct dsa_switch *ds = dp->ds;
15771577
int err = 0;
15781578

@@ -1587,7 +1587,7 @@ static void dsa_port_phylink_mac_config(struct phylink_config *config,
15871587
unsigned int mode,
15881588
const struct phylink_link_state *state)
15891589
{
1590-
struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
1590+
struct dsa_port *dp = dsa_phylink_to_port(config);
15911591
struct dsa_switch *ds = dp->ds;
15921592

15931593
if (!ds->ops->phylink_mac_config)
@@ -1600,7 +1600,7 @@ static int dsa_port_phylink_mac_finish(struct phylink_config *config,
16001600
unsigned int mode,
16011601
phy_interface_t interface)
16021602
{
1603-
struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
1603+
struct dsa_port *dp = dsa_phylink_to_port(config);
16041604
struct dsa_switch *ds = dp->ds;
16051605
int err = 0;
16061606

@@ -1615,7 +1615,7 @@ static void dsa_port_phylink_mac_link_down(struct phylink_config *config,
16151615
unsigned int mode,
16161616
phy_interface_t interface)
16171617
{
1618-
struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
1618+
struct dsa_port *dp = dsa_phylink_to_port(config);
16191619
struct phy_device *phydev = NULL;
16201620
struct dsa_switch *ds = dp->ds;
16211621

@@ -1638,7 +1638,7 @@ static void dsa_port_phylink_mac_link_up(struct phylink_config *config,
16381638
int speed, int duplex,
16391639
bool tx_pause, bool rx_pause)
16401640
{
1641-
struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
1641+
struct dsa_port *dp = dsa_phylink_to_port(config);
16421642
struct dsa_switch *ds = dp->ds;
16431643

16441644
if (!ds->ops->phylink_mac_link_up) {

0 commit comments

Comments
 (0)