
On Mon, Apr 26, 2021 at 6:47 PM Patrick Delaunay patrick.delaunay@foss.st.com wrote:
Add a common empty ops: eqos_null_ops() to remove the duplicated empty functions and reduce the driver size for stm32 and imx config.
This patch also aligns the prototype of ops 'eqos_stop_clks' with other eqos ops by adding return value.
Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com
Changes in v2:
- cleanup ops by adding a common null ops (NEW)
drivers/net/dwc_eth_qos.c | 97 +++++++++------------------------------ 1 file changed, 22 insertions(+), 75 deletions(-)
diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c index 3fb8bfaf3a..4d1e5d6f8f 100644 --- a/drivers/net/dwc_eth_qos.c +++ b/drivers/net/dwc_eth_qos.c @@ -285,7 +285,7 @@ struct eqos_ops { int (*eqos_remove_resources)(struct udevice *dev); int (*eqos_stop_resets)(struct udevice *dev); int (*eqos_start_resets)(struct udevice *dev);
void (*eqos_stop_clks)(struct udevice *dev);
int (*eqos_stop_clks)(struct udevice *dev); int (*eqos_start_clks)(struct udevice *dev); int (*eqos_calibrate_pads)(struct udevice *dev); int (*eqos_disable_calibration)(struct udevice *dev);
@@ -615,12 +615,7 @@ err: #endif }
-static int eqos_start_clks_imx(struct udevice *dev) -{
return 0;
-}
-static void eqos_stop_clks_tegra186(struct udevice *dev) +static int eqos_stop_clks_tegra186(struct udevice *dev) { #ifdef CONFIG_CLK struct eqos_priv *eqos = dev_get_priv(dev); @@ -635,9 +630,10 @@ static void eqos_stop_clks_tegra186(struct udevice *dev) #endif
debug("%s: OK\n", __func__);
return 0;
}
-static void eqos_stop_clks_stm32(struct udevice *dev) +static int eqos_stop_clks_stm32(struct udevice *dev) { #ifdef CONFIG_CLK struct eqos_priv *eqos = dev_get_priv(dev); @@ -652,11 +648,7 @@ static void eqos_stop_clks_stm32(struct udevice *dev) #endif
debug("%s: OK\n", __func__);
-}
-static void eqos_stop_clks_imx(struct udevice *dev) -{
/* empty */
return 0;
}
static int eqos_start_resets_tegra186(struct udevice *dev) @@ -698,16 +690,6 @@ static int eqos_start_resets_tegra186(struct udevice *dev) return 0; }
-static int eqos_start_resets_stm32(struct udevice *dev) -{
return 0;
-}
-static int eqos_start_resets_imx(struct udevice *dev) -{
return 0;
-}
static int eqos_stop_resets_tegra186(struct udevice *dev) { struct eqos_priv *eqos = dev_get_priv(dev); @@ -718,16 +700,6 @@ static int eqos_stop_resets_tegra186(struct udevice *dev) return 0; }
-static int eqos_stop_resets_stm32(struct udevice *dev) -{
return 0;
-}
-static int eqos_stop_resets_imx(struct udevice *dev) -{
return 0;
-}
static int eqos_calibrate_pads_tegra186(struct udevice *dev) { struct eqos_priv *eqos = dev_get_priv(dev); @@ -816,26 +788,6 @@ static ulong eqos_get_tick_clk_rate_imx(struct udevice *dev) return imx_get_eqos_csr_clk(); }
-static int eqos_calibrate_pads_stm32(struct udevice *dev) -{
return 0;
-}
-static int eqos_calibrate_pads_imx(struct udevice *dev) -{
return 0;
-}
-static int eqos_disable_calibration_stm32(struct udevice *dev) -{
return 0;
-}
-static int eqos_disable_calibration_imx(struct udevice *dev) -{
return 0;
-}
static int eqos_set_full_duplex(struct udevice *dev) { struct eqos_priv *eqos = dev_get_priv(dev); @@ -932,11 +884,6 @@ static int eqos_set_tx_clk_speed_tegra186(struct udevice *dev) return 0; }
-static int eqos_set_tx_clk_speed_stm32(struct udevice *dev) -{
return 0;
-}
static int eqos_set_tx_clk_speed_imx(struct udevice *dev) { struct eqos_priv *eqos = dev_get_priv(dev); @@ -1894,11 +1841,6 @@ static int eqos_remove_resources_stm32(struct udevice *dev) return 0; }
-static int eqos_remove_resources_imx(struct udevice *dev) -{
return 0;
-}
static int eqos_probe(struct udevice *dev) { struct eqos_priv *eqos = dev_get_priv(dev); @@ -1987,6 +1929,11 @@ static int eqos_remove(struct udevice *dev) return 0; }
+static int eqos_null_ops(struct udevice *dev) +{
return 0;
+}
static const struct eth_ops eqos_ops = { .start = eqos_start, .stop = eqos_stop, @@ -2032,13 +1979,13 @@ static struct eqos_ops eqos_stm32_ops = { .eqos_flush_buffer = eqos_flush_buffer_generic, .eqos_probe_resources = eqos_probe_resources_stm32, .eqos_remove_resources = eqos_remove_resources_stm32,
.eqos_stop_resets = eqos_stop_resets_stm32,
.eqos_start_resets = eqos_start_resets_stm32,
.eqos_stop_resets = eqos_null_ops,
.eqos_start_resets = eqos_null_ops, .eqos_stop_clks = eqos_stop_clks_stm32, .eqos_start_clks = eqos_start_clks_stm32,
.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_calibrate_pads = eqos_null_ops,
.eqos_disable_calibration = eqos_null_ops,
.eqos_set_tx_clk_speed = eqos_null_ops, .eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_stm32
};
@@ -2059,13 +2006,13 @@ static struct eqos_ops eqos_imx_ops = { .eqos_inval_buffer = eqos_inval_buffer_generic, .eqos_flush_buffer = eqos_flush_buffer_generic, .eqos_probe_resources = eqos_probe_resources_imx,
.eqos_remove_resources = eqos_remove_resources_imx,
.eqos_stop_resets = eqos_stop_resets_imx,
.eqos_start_resets = eqos_start_resets_imx,
.eqos_stop_clks = eqos_stop_clks_imx,
.eqos_start_clks = eqos_start_clks_imx,
.eqos_calibrate_pads = eqos_calibrate_pads_imx,
.eqos_disable_calibration = eqos_disable_calibration_imx,
.eqos_remove_resources = eqos_null_ops,
.eqos_stop_resets = eqos_null_ops,
.eqos_start_resets = eqos_null_ops,
.eqos_stop_clks = eqos_null_ops,
.eqos_start_clks = eqos_null_ops,
.eqos_calibrate_pads = eqos_null_ops,
.eqos_disable_calibration = eqos_null_ops, .eqos_set_tx_clk_speed = eqos_set_tx_clk_speed_imx, .eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_imx
};
2.17.1
Reviewed-by: Ramon Fried rfried.dev@gmail.com