diff options
author | Madalin Bucur <madalin.bucur@freescale.com> | 2014-07-25 07:12:09 (GMT) |
---|---|---|
committer | Madalin Bucur <madalin.bucur@freescale.com> | 2015-02-25 16:26:53 (GMT) |
commit | cd9b7b9718e6044358f030694cb5dba61ba31784 (patch) | |
tree | 983ad54ef7f3c598157286e65386299d240fe6c4 /drivers | |
parent | 7eb361ffc4e115a17b182ec08c35bd86a64cc17f (diff) | |
download | linux-fsl-qoriq-cd9b7b9718e6044358f030694cb5dba61ba31784.tar.xz |
dpaa_eth: use common initialization function
Use a common initialization function for MACless, shared and proxy
Ethernet drivers.
Signed-off-by: Madalin Bucur <madalin.bucur@freescale.com>
Change-Id: I7a0ec70b33ad7ad92cb559dbd828572f83b5c98e
Reviewed-on: http://git.am.freescale.net:8181/15296
Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com>
Reviewed-by: Cristian Bercaru <cristian.bercaru@freescale.com>
Conflicts:
drivers/net/ethernet/freescale/dpa/dpaa_eth_base.c
Diffstat (limited to 'drivers')
5 files changed, 71 insertions, 41 deletions
diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth_base.c b/drivers/net/ethernet/freescale/dpa/dpaa_eth_base.c index 2a744e5..bcae5b2 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth_base.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth_base.c @@ -29,6 +29,15 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifdef CONFIG_FSL_DPAA_ETH_DEBUG +#define pr_fmt(fmt) \ + KBUILD_MODNAME ": %s:%hu:%s() " fmt, \ + KBUILD_BASENAME".c", __LINE__, __func__ +#else +#define pr_fmt(fmt) \ + KBUILD_MODNAME ": " fmt +#endif + #include <linux/init.h> #include <linux/module.h> #include <linux/of_platform.h> @@ -43,6 +52,12 @@ #include "dpaa_eth_common.h" #include "dpaa_eth_base.h" +#define DPA_DESCRIPTION "FSL DPAA Advanced drivers:" + +uint8_t advanced_debug = -1; +module_param(advanced_debug, byte, S_IRUGO); +MODULE_PARM_DESC(advanced_debug, "Module/Driver verbosity level"); + static int dpa_bp_cmp(const void *dpa_bp0, const void *dpa_bp1) { return ((struct dpa_bp *)dpa_bp0)->size - @@ -219,3 +234,31 @@ int dpa_bp_create(struct net_device *net_dev, struct dpa_bp *dpa_bp, return 0; } +static int __init __cold dpa_advanced_load(void) +{ + int _errno; + + pr_info(DPA_DESCRIPTION " (" VERSION ")\n"); + + _errno = dpa_proxy_load(); + + if (_errno == 0) + _errno = dpa_shared_load(); + + if (_errno == 0) + _errno = dpa_macless_load(); /* must be after proxy */ + + return _errno; +} +module_init(dpa_advanced_load); + +static void __exit __cold dpa_advanced_unload(void) +{ + pr_debug(KBUILD_MODNAME ": -> %s:%s()\n", + KBUILD_BASENAME".c", __func__); + + dpa_macless_unload(); + dpa_shared_unload(); + dpa_proxy_unload(); +} +module_exit(dpa_advanced_unload); diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth_base.h b/drivers/net/ethernet/freescale/dpa/dpaa_eth_base.h index 5b5ef1e..3554e2e 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth_base.h +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth_base.h @@ -37,10 +37,18 @@ #include <linux/of_platform.h> /* struct platform_device */ #include <linux/net_tstamp.h> /* struct hwtstamp_config */ +extern uint8_t advanced_debug; + struct dpa_bp * __cold __must_check /* __attribute__((nonnull)) */ dpa_bp_probe(struct platform_device *_of_dev, size_t *count); int dpa_bp_create(struct net_device *net_dev, struct dpa_bp *dpa_bp, size_t count); int dpa_bp_shared_port_seed(struct dpa_bp *bp); +int __init __cold dpa_proxy_load(void); +int __init __cold dpa_shared_load(void); +int __init __cold dpa_macless_load(void); +void __exit __cold dpa_proxy_unload(void); +void __exit __cold dpa_shared_unload(void); +void __exit __cold dpa_macless_unload(void); #endif /* __DPAA_ETH_BASE_H */ diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth_macless.c b/drivers/net/ethernet/freescale/dpa/dpaa_eth_macless.c index 0258c90..c829ed4 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth_macless.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth_macless.c @@ -65,14 +65,10 @@ MODULE_LICENSE("Dual BSD/GPL"); MODULE_DESCRIPTION(DPA_DESCRIPTION); -static uint8_t debug = -1; -module_param(debug, byte, S_IRUGO); -MODULE_PARM_DESC(debug, "Module/Driver verbosity level"); - /* This has to work in tandem with the DPA_CS_THRESHOLD_xxx values. */ -static uint16_t tx_timeout = 1000; -module_param(tx_timeout, ushort, S_IRUGO); -MODULE_PARM_DESC(tx_timeout, "The Tx timeout in ms"); +static uint16_t macless_tx_timeout = 1000; +module_param(macless_tx_timeout, ushort, S_IRUGO); +MODULE_PARM_DESC(macless_tx_timeout, "The MACless Tx timeout in ms"); /* reused from the shared driver */ extern const struct dpa_fq_cbs_t shared_fq_cbs; @@ -119,7 +115,7 @@ MODULE_DEVICE_TABLE(of, dpa_macless_match); static struct platform_driver dpa_macless_driver = { .driver = { - .name = KBUILD_MODNAME, + .name = KBUILD_MODNAME "-macless", .of_match_table = dpa_macless_match, .owner = THIS_MODULE, }, @@ -228,7 +224,7 @@ static int dpa_macless_netdev_init(struct device_node *dpa_node, net_dev->mem_end = mac_dev->res->end; return dpa_netdev_init(dpa_node, net_dev, mac_dev->addr, - tx_timeout); + macless_tx_timeout); } else { /* Get the MAC address from device tree */ mac_addr = of_get_mac_address(dpa_node); @@ -240,7 +236,7 @@ static int dpa_macless_netdev_init(struct device_node *dpa_node, } return dpa_netdev_init(dpa_node, net_dev, mac_addr, - tx_timeout); + macless_tx_timeout); } } @@ -358,7 +354,7 @@ static int dpaa_eth_macless_probe(struct platform_device *_of_dev) priv->net_dev = net_dev; sprintf(priv->if_type, "macless%d", macless_idx++); - priv->msg_enable = netif_msg_init(debug, -1); + priv->msg_enable = netif_msg_init(advanced_debug, -1); priv->peer = NULL; priv->mac_dev = NULL; @@ -475,7 +471,7 @@ fq_probe_failed: return err; } -static int __init __cold dpa_macless_load(void) +int __init __cold dpa_macless_load(void) { int _errno; @@ -497,16 +493,11 @@ static int __init __cold dpa_macless_load(void) return _errno; } -/* waits for proxy to initialize first, in case MAC device reference - * is needed - */ -late_initcall(dpa_macless_load); -static void __exit __cold dpa_macless_unload(void) +void __exit __cold dpa_macless_unload(void) { platform_driver_unregister(&dpa_macless_driver); pr_debug(KBUILD_MODNAME ": %s:%s() ->\n", KBUILD_BASENAME".c", __func__); } -module_exit(dpa_macless_unload); diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth_proxy.c b/drivers/net/ethernet/freescale/dpa/dpaa_eth_proxy.c index 57aacb9..a668c6d 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth_proxy.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth_proxy.c @@ -53,10 +53,6 @@ MODULE_LICENSE("Dual BSD/GPL"); MODULE_DESCRIPTION(DPA_DESCRIPTION); -static uint8_t debug = -1; -module_param(debug, byte, S_IRUGO); -MODULE_PARM_DESC(debug, "Module/Driver verbosity level"); - static int __cold dpa_eth_proxy_remove(struct platform_device *of_dev); #ifdef CONFIG_PM @@ -329,7 +325,7 @@ MODULE_DEVICE_TABLE(of, dpa_proxy_match); static struct platform_driver dpa_proxy_driver = { .driver = { - .name = KBUILD_MODNAME"-proxy", + .name = KBUILD_MODNAME "-proxy", .of_match_table = dpa_proxy_match, .owner = THIS_MODULE, .pm = PROXY_PM_OPS, @@ -338,7 +334,7 @@ static struct platform_driver dpa_proxy_driver = { .remove = dpa_eth_proxy_remove }; -static int __init __cold dpa_proxy_load(void) +int __init __cold dpa_proxy_load(void) { int _errno; @@ -360,13 +356,11 @@ static int __init __cold dpa_proxy_load(void) return _errno; } -module_init(dpa_proxy_load); -static void __exit __cold dpa_proxy_unload(void) +void __exit __cold dpa_proxy_unload(void) { platform_driver_unregister(&dpa_proxy_driver); pr_debug(KBUILD_MODNAME ": %s:%s() ->\n", KBUILD_BASENAME".c", __func__); } -module_exit(dpa_proxy_unload); diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth_shared.c b/drivers/net/ethernet/freescale/dpa/dpaa_eth_shared.c index 797dac9..fc849b8d 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth_shared.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth_shared.c @@ -75,14 +75,10 @@ MODULE_LICENSE("Dual BSD/GPL"); MODULE_DESCRIPTION(DPA_DESCRIPTION); -static uint8_t debug = -1; -module_param(debug, byte, S_IRUGO); -MODULE_PARM_DESC(debug, "Module/Driver verbosity level"); - /* This has to work in tandem with the DPA_CS_THRESHOLD_xxx values. */ -static uint16_t tx_timeout = 1000; -module_param(tx_timeout, ushort, S_IRUGO); -MODULE_PARM_DESC(tx_timeout, "The Tx timeout in ms"); +static uint16_t shared_tx_timeout = 1000; +module_param(shared_tx_timeout, ushort, S_IRUGO); +MODULE_PARM_DESC(shared_tx_timeout, "The Tx timeout in ms"); static const struct of_device_id dpa_shared_match[]; @@ -600,7 +596,7 @@ static int dpa_shared_netdev_init(struct device_node *dpa_node, net_dev->hw_features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_LLTX); - return dpa_netdev_init(dpa_node, net_dev, mac_addr, tx_timeout); + return dpa_netdev_init(dpa_node, net_dev, mac_addr, shared_tx_timeout); } #ifdef CONFIG_PM @@ -717,7 +713,7 @@ dpaa_eth_shared_probe(struct platform_device *_of_dev) priv->net_dev = net_dev; strcpy(priv->if_type, "shared"); - priv->msg_enable = netif_msg_init(debug, -1); + priv->msg_enable = netif_msg_init(advanced_debug, -1); mac_dev = dpa_mac_probe(_of_dev); if (IS_ERR(mac_dev) || !mac_dev) { @@ -866,7 +862,7 @@ MODULE_DEVICE_TABLE(of, dpa_shared_match); static struct platform_driver dpa_shared_driver = { .driver = { - .name = KBUILD_MODNAME, + .name = KBUILD_MODNAME "-shared", .of_match_table = dpa_shared_match, .owner = THIS_MODULE, .pm = SHARED_PM_OPS, @@ -875,7 +871,7 @@ static struct platform_driver dpa_shared_driver = { .remove = dpa_remove }; -static int __init __cold dpa_shared_load(void) +int __init __cold dpa_shared_load(void) { int _errno; @@ -897,13 +893,11 @@ static int __init __cold dpa_shared_load(void) return _errno; } -module_init(dpa_shared_load); -static void __exit __cold dpa_shared_unload(void) +void __exit __cold dpa_shared_unload(void) { pr_debug(KBUILD_MODNAME ": -> %s:%s()\n", KBUILD_BASENAME".c", __func__); platform_driver_unregister(&dpa_shared_driver); } -module_exit(dpa_shared_unload); |