diff mbox series

[4/8] net: dwc_eth_qos: Move interface() to eqos_ops struct

Message ID 20200430103656.29728-5-david.wu@rock-chips.com
State Superseded
Delegated to: Joe Hershberger
Headers show
Series Add dwc_eth_qos support for rockchip | expand

Commit Message

David Wu April 30, 2020, 10:36 a.m. UTC
After moving to eqos_ops, if eqos_config is defined
outside, can not export interface() definition.

Signed-off-by: David Wu <david.wu@rock-chips.com>
---

 drivers/net/dwc_eth_qos.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Stephen Warren April 30, 2020, 10:39 p.m. UTC | #1
On 4/30/20 4:36 AM, David Wu wrote:
> After moving to eqos_ops, if eqos_config is defined
> outside, can not export interface() definition.

Looking at the patch itself, I think this patch just moves a function
pointer from the config to the ops structure which makes sense. However,
I can't understand the patch description at all, so I worry there's
intended to be some other justification/implication for this patch, and
that may not be correct...

In particular, defined outside of what, and what does this have to do
with exporting things?
David Wu May 9, 2020, 3:22 a.m. UTC | #2
Hi Stephen,

在 2020/5/1 上午6:39, Stephen Warren 写道:
> On 4/30/20 4:36 AM, David Wu wrote:
>> After moving to eqos_ops, if eqos_config is defined
>> outside, can not export interface() definition.
> 
> Looking at the patch itself, I think this patch just moves a function
> pointer from the config to the ops structure which makes sense. However,
> I can't understand the patch description at all, so I worry there's
> intended to be some other justification/implication for this patch, and
> that may not be correct...
> 
> In particular, defined outside of what, and what does this have to do
> with exporting things
Yes, if define eqos_config structure in gmac_rockchip.c, need to export 
an eqos_get_interface function, or redefine a similar function in 
gmac_rockchip.c, but this function is the same implementation as 
eqos_get_interface_stm32(), so we can share this function. Move 
interface() to eqos_ops structure, no need to export interface() in the 
head file. I lost a patch to define eqos_ops structure at curent file, 
then only exprot eqos_rockchip_ops, so it would be simpler?

> 
> 
>
diff mbox series

Patch

diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
index 06a8d924a7..fbd6caf85b 100644
--- a/drivers/net/dwc_eth_qos.c
+++ b/drivers/net/dwc_eth_qos.c
@@ -267,7 +267,6 @@  struct eqos_config {
 	int swr_wait;
 	int config_mac;
 	int config_mac_mdio;
-	phy_interface_t (*interface)(struct udevice *dev);
 	struct eqos_ops *ops;
 };
 
@@ -286,6 +285,7 @@  struct eqos_ops {
 	int (*eqos_disable_calibration)(struct udevice *dev);
 	int (*eqos_set_tx_clk_speed)(struct udevice *dev);
 	ulong (*eqos_get_tick_clk_rate)(struct udevice *dev);
+	phy_interface_t (*eqos_get_interface)(struct udevice *dev);
 };
 
 struct eqos_priv {
@@ -1105,7 +1105,7 @@  static int eqos_start(struct udevice *dev)
 	 */
 	if (!eqos->phy) {
 		eqos->phy = phy_connect(eqos->mii, eqos->phyaddr, dev,
-					eqos->config->interface(dev));
+			  eqos->config->ops->eqos_get_interface(dev));
 		if (!eqos->phy) {
 			pr_err("phy_connect() failed");
 			goto err_stop_resets;
@@ -1675,7 +1675,7 @@  static int eqos_probe_resources_stm32(struct udevice *dev)
 
 	debug("%s(dev=%p):\n", __func__, dev);
 
-	interface = eqos->config->interface(dev);
+	interface = eqos->config->ops->eqos_get_interface(dev);
 
 	if (interface == PHY_INTERFACE_MODE_NONE) {
 		pr_err("Invalid PHY interface\n");
@@ -1918,7 +1918,8 @@  static struct eqos_ops eqos_tegra186_ops = {
 	.eqos_calibrate_pads = eqos_calibrate_pads_tegra186,
 	.eqos_disable_calibration = eqos_disable_calibration_tegra186,
 	.eqos_set_tx_clk_speed = eqos_set_tx_clk_speed_tegra186,
-	.eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_tegra186
+	.eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_tegra186,
+	.eqos_get_interface = eqos_get_interface_tegra186
 };
 
 static const struct eqos_config eqos_tegra186_config = {
@@ -1927,7 +1928,6 @@  static const struct eqos_config eqos_tegra186_config = {
 	.swr_wait = 10,
 	.config_mac = EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_DCB,
 	.config_mac_mdio = EQOS_MAC_MDIO_ADDRESS_CR_20_35,
-	.interface = eqos_get_interface_tegra186,
 	.ops = &eqos_tegra186_ops
 };
 
@@ -1945,7 +1945,8 @@  static struct eqos_ops eqos_stm32_ops = {
 	.eqos_calibrate_pads = eqos_calibrate_pads_stm32,
 	.eqos_disable_calibration = eqos_disable_calibration_stm32,
 	.eqos_set_tx_clk_speed = eqos_set_tx_clk_speed_stm32,
-	.eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_stm32
+	.eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_stm32,
+	.eqos_get_interface = eqos_get_interface_stm32
 };
 
 static const struct eqos_config eqos_stm32_config = {
@@ -1954,7 +1955,6 @@  static const struct eqos_config eqos_stm32_config = {
 	.swr_wait = 50,
 	.config_mac = EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_AV,
 	.config_mac_mdio = EQOS_MAC_MDIO_ADDRESS_CR_250_300,
-	.interface = eqos_get_interface_stm32,
 	.ops = &eqos_stm32_ops
 };