public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail•com>
To: Jakub Kicinski <kuba@kernel•org>,
	"David S. Miller" <davem@davemloft•net>,
	netdev@vger•kernel.org
Cc: Wong Vee Khee <vee.khee.wong@linux•intel.com>,
	Ong Boon Leong <boon.leong.ong@intel•com>,
	Michael Sit Wei Hong <michael.wei.hong.sit@intel•com>,
	Giuseppe Cavallaro <peppe.cavallaro@st•com>,
	Alexandre Torgue <alexandre.torgue@foss•st.com>,
	Jose Abreu <joabreu@synopsys•com>,
	Maxime Coquelin <mcoquelin.stm32@gmail•com>,
	Heiner Kallweit <hkallweit1@gmail•com>,
	Russell King - ARM Linux admin <linux@armlinux•org.uk>,
	Florian Fainelli <f.fainelli@gmail•com>,
	Andrew Lunn <andrew@lunn•ch>,
	Vladimir Oltean <vladimir.oltean@nxp•com>
Subject: [RFC PATCH v2 net-next 4/9] net: pcs: xpcs: export xpcs_validate
Date: Tue,  1 Jun 2021 03:33:20 +0300	[thread overview]
Message-ID: <20210601003325.1631980-5-olteanv@gmail.com> (raw)
In-Reply-To: <20210601003325.1631980-1-olteanv@gmail.com>

From: Vladimir Oltean <vladimir.oltean@nxp•com>

Calling a function pointer with a single implementation through
struct mdio_xpcs_ops is clunky, and the stmmac_do_callback system forces
this to return int, even though it always returns zero.

Simply remove the "validate" function pointer from struct mdio_xpcs_ops
and replace it with an exported xpcs_validate symbol which is called
directly by stmmac.

priv->hw->xpcs is of the type "const struct mdio_xpcs_ops *" and is used
as a placeholder/synonym for priv->plat->mdio_bus_data->has_xpcs. It is
done that way because the mdio_bus_data pointer might or might not be
populated in all stmmac instantiations.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp•com>
---
 drivers/net/ethernet/stmicro/stmmac/hwif.h        |  2 --
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |  3 ++-
 drivers/net/pcs/pcs-xpcs.c                        | 11 ++++-------
 include/linux/pcs/pcs-xpcs.h                      |  5 ++---
 4 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
index 75a8b90c202a..a86b358feae9 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
@@ -613,8 +613,6 @@ struct stmmac_mmc_ops {
 	stmmac_do_void_callback(__priv, mmc, read, __args)
 
 /* XPCS callbacks */
-#define stmmac_xpcs_validate(__priv, __args...) \
-	stmmac_do_callback(__priv, xpcs, validate, __args)
 #define stmmac_xpcs_config(__priv, __args...) \
 	stmmac_do_callback(__priv, xpcs, config, __args)
 #define stmmac_xpcs_get_state(__priv, __args...) \
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 129b103cd2b5..9f72e4dd1457 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -996,7 +996,8 @@ static void stmmac_validate(struct phylink_config *config,
 	linkmode_andnot(state->advertising, state->advertising, mask);
 
 	/* If PCS is supported, check which modes it supports. */
-	stmmac_xpcs_validate(priv, &priv->hw->xpcs_args, supported, state);
+	if (priv->hw->xpcs)
+		xpcs_validate(&priv->hw->xpcs_args, supported, state);
 }
 
 static void stmmac_mac_pcs_get_state(struct phylink_config *config,
diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index 4bc63d7e3bda..a9bae263dcdb 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -720,9 +720,8 @@ static void xpcs_resolve_pma(struct mdio_xpcs_args *xpcs,
 	}
 }
 
-static int xpcs_validate(struct mdio_xpcs_args *xpcs,
-			 unsigned long *supported,
-			 struct phylink_link_state *state)
+void xpcs_validate(struct mdio_xpcs_args *xpcs, unsigned long *supported,
+		   struct phylink_link_state *state)
 {
 	__ETHTOOL_DECLARE_LINK_MODE_MASK(xpcs_supported);
 	const struct xpcs_compat *compat;
@@ -733,7 +732,7 @@ static int xpcs_validate(struct mdio_xpcs_args *xpcs,
 	 * advertising masks and exit.
 	 */
 	if (state->interface == PHY_INTERFACE_MODE_NA)
-		return 0;
+		return;
 
 	bitmap_zero(xpcs_supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
 
@@ -748,9 +747,8 @@ static int xpcs_validate(struct mdio_xpcs_args *xpcs,
 
 	linkmode_and(supported, supported, xpcs_supported);
 	linkmode_and(state->advertising, state->advertising, xpcs_supported);
-
-	return 0;
 }
+EXPORT_SYMBOL_GPL(xpcs_validate);
 
 static int xpcs_config_eee(struct mdio_xpcs_args *xpcs, int mult_fact_100ns,
 			   int enable)
@@ -1031,7 +1029,6 @@ static int xpcs_probe(struct mdio_xpcs_args *xpcs, phy_interface_t interface)
 }
 
 static struct mdio_xpcs_ops xpcs_ops = {
-	.validate = xpcs_validate,
 	.config = xpcs_config,
 	.get_state = xpcs_get_state,
 	.link_up = xpcs_link_up,
diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h
index c2ec440d2c5d..5ec9aaca01fe 100644
--- a/include/linux/pcs/pcs-xpcs.h
+++ b/include/linux/pcs/pcs-xpcs.h
@@ -23,9 +23,6 @@ struct mdio_xpcs_args {
 };
 
 struct mdio_xpcs_ops {
-	int (*validate)(struct mdio_xpcs_args *xpcs,
-			unsigned long *supported,
-			struct phylink_link_state *state);
 	int (*config)(struct mdio_xpcs_args *xpcs,
 		      const struct phylink_link_state *state);
 	int (*get_state)(struct mdio_xpcs_args *xpcs,
@@ -39,5 +36,7 @@ struct mdio_xpcs_ops {
 
 int xpcs_get_an_mode(struct mdio_xpcs_args *xpcs, phy_interface_t interface);
 struct mdio_xpcs_ops *mdio_xpcs_get_ops(void);
+void xpcs_validate(struct mdio_xpcs_args *xpcs, unsigned long *supported,
+		   struct phylink_link_state *state);
 
 #endif /* __LINUX_PCS_XPCS_H */
-- 
2.25.1


  parent reply	other threads:[~2021-06-01  0:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-01  0:33 [RFC PATCH v2 net-next 0/9] Convert xpcs to phylink_pcs_ops Vladimir Oltean
2021-06-01  0:33 ` [RFC PATCH v2 net-next 1/9] net: pcs: xpcs: delete shim definition for mdio_xpcs_get_ops() Vladimir Oltean
2021-06-01  0:33 ` [RFC PATCH v2 net-next 2/9] net: pcs: xpcs: there is only one PHY ID Vladimir Oltean
2021-06-01  0:33 ` [RFC PATCH v2 net-next 3/9] net: pcs: xpcs: make the checks related to the PHY interface mode stateless Vladimir Oltean
2021-06-01  0:33 ` Vladimir Oltean [this message]
2021-06-01  0:33 ` [RFC PATCH v2 net-next 5/9] net: pcs: xpcs: export xpcs_config_eee Vladimir Oltean
2021-06-01  0:33 ` [RFC PATCH v2 net-next 6/9] net: pcs: xpcs: export xpcs_probe Vladimir Oltean
2021-06-01  0:33 ` [RFC PATCH v2 net-next 7/9] net: pcs: xpcs: use mdiobus_c45_addr in xpcs_{read,write} Vladimir Oltean
2021-06-01  0:33 ` [RFC PATCH v2 net-next 8/9] net: pcs: xpcs: convert to mdio_device Vladimir Oltean
2021-06-01  0:33 ` [RFC PATCH v2 net-next 9/9] net: pcs: xpcs: convert to phylink_pcs_ops Vladimir Oltean
2021-06-01 12:10   ` Russell King (Oracle)
2021-06-02 13:43     ` Vladimir Oltean
2021-06-02 13:47       ` Russell King (Oracle)
2021-06-02 14:02         ` Vladimir Oltean
2021-06-02 14:43           ` Wong Vee Khee
2021-06-02 14:57             ` Vladimir Oltean
2021-06-02 15:10               ` Wong Vee Khee
2021-06-02 15:14                 ` Vladimir Oltean
2021-06-02 15:28                   ` Wong Vee Khee
2021-06-01  8:20 ` [RFC PATCH v2 net-next 0/9] Convert xpcs " Wong Vee Khee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210601003325.1631980-5-olteanv@gmail.com \
    --to=olteanv@gmail$(echo .)com \
    --cc=alexandre.torgue@foss$(echo .)st.com \
    --cc=andrew@lunn$(echo .)ch \
    --cc=boon.leong.ong@intel$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=f.fainelli@gmail$(echo .)com \
    --cc=hkallweit1@gmail$(echo .)com \
    --cc=joabreu@synopsys$(echo .)com \
    --cc=kuba@kernel$(echo .)org \
    --cc=linux@armlinux$(echo .)org.uk \
    --cc=mcoquelin.stm32@gmail$(echo .)com \
    --cc=michael.wei.hong.sit@intel$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=peppe.cavallaro@st$(echo .)com \
    --cc=vee.khee.wong@linux$(echo .)intel.com \
    --cc=vladimir.oltean@nxp$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox