>From 9b914fcf37d622f330a5997e0bc660c422bcc2f1 Mon Sep 17 00:00:00 2001 From: Lukas Wunner Date: Mon, 6 Apr 2020 04:54:14 +0200 Subject: [PATCH 2/2] net: ks8851: Unbreak the build of CONFIG_KS8851=y || CONFIG_KS8851_MLL=y If one of ks8851 or ks8851_mll is built-in: arm-linux-gnueabihf-ld: drivers/net/ethernet/micrel/ks8851_common.o:(__param+0x4): undefined reference to `__this_module' If both are built-in: arm-linux-gnueabihf-ld: drivers/net/ethernet/micrel/ks8851_par.o: in function `ks8851_lock': drivers/net/ethernet/micrel/ks8851_par.c:68: multiple definition of `ks8851_lock'; drivers/net/ethernet/micrel/ks8851_spi.o:drivers/net/ethernet/micrel/ks8851_spi.c:80: first defined here arm-linux-gnueabihf-ld: drivers/net/ethernet/micrel/ks8851_par.o: in function `ks8851_unlock': drivers/net/ethernet/micrel/ks8851_par.c:82: multiple definition of `ks8851_unlock'; drivers/net/ethernet/micrel/ks8851_spi.o:drivers/net/ethernet/micrel/ks8851_spi.c:94: first defined here arm-linux-gnueabihf-ld: drivers/net/ethernet/micrel/ks8851_par.o: in function `ks8851_wrreg16': drivers/net/ethernet/micrel/ks8851_par.c:141: multiple definition of `ks8851_wrreg16'; drivers/net/ethernet/micrel/ks8851_spi.o:drivers/net/ethernet/micrel/ks8851_spi.c:116: first defined here arm-linux-gnueabihf-ld: drivers/net/ethernet/micrel/ks8851_par.o: in function `ks8851_rdreg16': drivers/net/ethernet/micrel/ks8851_par.c:157: multiple definition of `ks8851_rdreg16'; drivers/net/ethernet/micrel/ks8851_spi.o:drivers/net/ethernet/micrel/ks8851_spi.c:195: first defined here arm-linux-gnueabihf-ld: drivers/net/ethernet/micrel/ks8851_par.o: in function `ks8851_rdfifo': drivers/net/ethernet/micrel/ks8851_par.c:175: multiple definition of `ks8851_rdfifo'; drivers/net/ethernet/micrel/ks8851_spi.o:drivers/net/ethernet/micrel/ks8851_spi.c:212: first defined here arm-linux-gnueabihf-ld: drivers/net/ethernet/micrel/ks8851_par.o: in function `ks8851_wrfifo': drivers/net/ethernet/micrel/ks8851_par.c:196: multiple definition of `ks8851_wrfifo'; drivers/net/ethernet/micrel/ks8851_spi.o:drivers/net/ethernet/micrel/ks8851_spi.c:263: first defined here arm-linux-gnueabihf-ld: drivers/net/ethernet/micrel/ks8851_par.o: in function `ks8851_rx_skb': drivers/net/ethernet/micrel/ks8851_par.c:221: multiple definition of `ks8851_rx_skb'; drivers/net/ethernet/micrel/ks8851_spi.o:drivers/net/ethernet/micrel/ks8851_spi.c:303: first defined here arm-linux-gnueabihf-ld: drivers/net/ethernet/micrel/ks8851_par.o: in function `ks8851_flush_tx_work': drivers/net/ethernet/micrel/ks8851_par.c:230: multiple definition of `ks8851_flush_tx_work'; drivers/net/ethernet/micrel/ks8851_spi.o:drivers/net/ethernet/micrel/ks8851_spi.c:350: first defined here arm-linux-gnueabihf-ld: drivers/net/ethernet/micrel/ks8851_par.o: in function `ks8851_start_xmit': drivers/net/ethernet/micrel/ks8851_par.c:247: multiple definition of `ks8851_start_xmit'; drivers/net/ethernet/micrel/ks8851_spi.o:drivers/net/ethernet/micrel/ks8851_spi.c:370: first defined here Signed-off-by: Lukas Wunner --- drivers/net/ethernet/micrel/Makefile | 2 - .../micrel/{ks8851_spi.c => ks8851.c} | 42 ++++++------------- drivers/net/ethernet/micrel/ks8851.h | 27 ++++-------- .../{ks8851_common.c => ks8851_common.h} | 19 ++------- .../micrel/{ks8851_par.c => ks8851_mll.c} | 41 ++++++------------ 5 files changed, 38 insertions(+), 93 deletions(-) rename drivers/net/ethernet/micrel/{ks8851_spi.c => ks8851.c} (91%) rename drivers/net/ethernet/micrel/{ks8851_common.c => ks8851_common.h} (98%) rename drivers/net/ethernet/micrel/{ks8851_par.c => ks8851_mll.c} (89%) diff --git a/drivers/net/ethernet/micrel/Makefile b/drivers/net/ethernet/micrel/Makefile index 5cc00d22c708..6d8ac5527aef 100644 --- a/drivers/net/ethernet/micrel/Makefile +++ b/drivers/net/ethernet/micrel/Makefile @@ -5,7 +5,5 @@ obj-$(CONFIG_KS8842) += ks8842.o obj-$(CONFIG_KS8851) += ks8851.o -ks8851-objs = ks8851_common.o ks8851_spi.o obj-$(CONFIG_KS8851_MLL) += ks8851_mll.o -ks8851_mll-objs = ks8851_common.o ks8851_par.o obj-$(CONFIG_KSZ884X_PCI) += ksz884x.o diff --git a/drivers/net/ethernet/micrel/ks8851_spi.c b/drivers/net/ethernet/micrel/ks8851.c similarity index 91% rename from drivers/net/ethernet/micrel/ks8851_spi.c rename to drivers/net/ethernet/micrel/ks8851.c index d08a51c55236..21c7e7d9872b 100644 --- a/drivers/net/ethernet/micrel/ks8851_spi.c +++ b/drivers/net/ethernet/micrel/ks8851.c @@ -6,28 +6,9 @@ * Ben Dooks */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#define DEBUG - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "ks8851.h" #include -#include -#include -#include - -#include "ks8851.h" /** * struct ks8851_net_spi - KS8851 SPI driver private data @@ -76,7 +57,7 @@ struct ks8851_net_spi { * * Claim chip register access lock */ -void ks8851_lock(struct ks8851_net *ks, unsigned long *flags) +static void ks8851_lock(struct ks8851_net *ks, unsigned long *flags) { struct ks8851_net_spi *kss = to_ks8851_spi(ks); @@ -90,7 +71,7 @@ void ks8851_lock(struct ks8851_net *ks, unsigned long *flags) * * Release chip register access lock */ -void ks8851_unlock(struct ks8851_net *ks, unsigned long *flags) +static void ks8851_unlock(struct ks8851_net *ks, unsigned long *flags) { struct ks8851_net_spi *kss = to_ks8851_spi(ks); @@ -112,7 +93,7 @@ void ks8851_unlock(struct ks8851_net *ks, unsigned long *flags) * * Issue a write to put the value @val into the register specified in @reg. */ -void ks8851_wrreg16(struct ks8851_net *ks, unsigned int reg, unsigned int val) +static void ks8851_wrreg16(struct ks8851_net *ks, unsigned int reg, unsigned int val) { struct ks8851_net_spi *kss = to_ks8851_spi(ks); struct spi_transfer *xfer = &kss->spi_xfer1; @@ -191,7 +172,7 @@ static void ks8851_rdreg(struct ks8851_net *ks, unsigned int op, * * Read a 16bit register from the chip, returning the result */ -unsigned int ks8851_rdreg16(struct ks8851_net *ks, unsigned int reg) +static unsigned int ks8851_rdreg16(struct ks8851_net *ks, unsigned int reg) { __le16 rx = 0; @@ -208,7 +189,7 @@ unsigned int ks8851_rdreg16(struct ks8851_net *ks, unsigned int reg) * Issue an RXQ FIFO read command and read the @len amount of data from * the FIFO into the buffer specified by @buff. */ -void ks8851_rdfifo(struct ks8851_net *ks, u8 *buff, unsigned int len) +static void ks8851_rdfifo(struct ks8851_net *ks, u8 *buff, unsigned int len) { struct ks8851_net_spi *kss = to_ks8851_spi(ks); struct spi_transfer *xfer = kss->spi_xfer2; @@ -259,7 +240,7 @@ static inline unsigned calc_txlen(unsigned len) * needs, such as IRQ on completion. Send the header and the packet data to * the device. */ -void ks8851_wrfifo(struct ks8851_net *ks, struct sk_buff *txp, bool irq) +static void ks8851_wrfifo(struct ks8851_net *ks, struct sk_buff *txp, bool irq) { struct ks8851_net_spi *kss = to_ks8851_spi(ks); struct spi_transfer *xfer = kss->spi_xfer2; @@ -299,7 +280,7 @@ void ks8851_wrfifo(struct ks8851_net *ks, struct sk_buff *txp, bool irq) * ks8851_rx_skb - receive skbuff * @skb: The skbuff */ -void ks8851_rx_skb(struct sk_buff *skb) +static void ks8851_rx_skb(struct sk_buff *skb) { netif_rx_ni(skb); } @@ -346,7 +327,7 @@ static void ks8851_tx_work(struct work_struct *work) * ks8851_flush_tx_work - flush outstanding TX work * @ks: The device state */ -void ks8851_flush_tx_work(struct ks8851_net *ks) +static void ks8851_flush_tx_work(struct ks8851_net *ks) { struct ks8851_net_spi *kss = to_ks8851_spi(ks); @@ -366,7 +347,7 @@ void ks8851_flush_tx_work(struct ks8851_net *ks) * and secondly so we can round up more than one packet to transmit which * means we can try and avoid generating too many transmit done interrupts. */ -netdev_tx_t ks8851_start_xmit(struct sk_buff *skb, struct net_device *dev) +static netdev_tx_t ks8851_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct ks8851_net *ks = netdev_priv(dev); struct ks8851_net_spi *kss = to_ks8851_spi(ks); @@ -392,6 +373,8 @@ netdev_tx_t ks8851_start_xmit(struct sk_buff *skb, struct net_device *dev) return ret; } +#include "ks8851_common.h" + static int ks8851_probe_spi(struct spi_device *spi) { struct device *dev = &spi->dev; @@ -459,3 +442,4 @@ module_spi_driver(ks8851_driver); MODULE_DESCRIPTION("KS8851 Network driver"); MODULE_AUTHOR("Ben Dooks "); MODULE_LICENSE("GPL"); +MODULE_ALIAS("spi:ks8851"); diff --git a/drivers/net/ethernet/micrel/ks8851.h b/drivers/net/ethernet/micrel/ks8851.h index 7932996c6ec4..a8fd2ece2345 100644 --- a/drivers/net/ethernet/micrel/ks8851.h +++ b/drivers/net/ethernet/micrel/ks8851.h @@ -304,6 +304,15 @@ #define TXFR_TXFID_MASK (0x3f << 0) #define TXFR_TXFID_SHIFT (0) +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#define DEBUG + +#include +#include +#include +#include + /** * struct ks8851_rxctrl - KS8851 driver rx control * @mchash: Multicast hash-table data. @@ -403,24 +412,6 @@ struct ks8851_net { struct sk_buff *txp, bool irq); }; -int ks8851_probe_common(struct net_device *netdev, struct device *dev); -int ks8851_remove_common(struct device *dev); -int ks8851_suspend(struct device *dev); -int ks8851_resume(struct device *dev); - -void ks8851_lock(struct ks8851_net *ks, unsigned long *flags); -void ks8851_unlock(struct ks8851_net *ks, unsigned long *flags); - -unsigned int ks8851_rdreg16(struct ks8851_net *ks, unsigned int reg); -void ks8851_wrreg16(struct ks8851_net *ks, unsigned int reg, unsigned int val); -void ks8851_rdfifo(struct ks8851_net *ks, u8 *buff, unsigned int len); -void ks8851_wrfifo(struct ks8851_net *ks, struct sk_buff *txp, bool irq); - -void ks8851_rx_skb(struct sk_buff *skb); -void ks8851_flush_tx_work(struct ks8851_net *ks); - -netdev_tx_t ks8851_start_xmit(struct sk_buff *skb, struct net_device *dev); - static SIMPLE_DEV_PM_OPS(ks8851_pm_ops, ks8851_suspend, ks8851_resume); /** diff --git a/drivers/net/ethernet/micrel/ks8851_common.c b/drivers/net/ethernet/micrel/ks8851_common.h similarity index 98% rename from drivers/net/ethernet/micrel/ks8851_common.c rename to drivers/net/ethernet/micrel/ks8851_common.h index 9878369efda2..5f96230e08cd 100644 --- a/drivers/net/ethernet/micrel/ks8851_common.c +++ b/drivers/net/ethernet/micrel/ks8851_common.h @@ -6,28 +6,18 @@ * Ben Dooks */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#define DEBUG - #include #include -#include -#include #include #include #include #include -#include -#include #include #include #include #include -#include "ks8851.h" - static int msg_enable; /** @@ -930,7 +920,7 @@ static int ks8851_read_selftest(struct ks8851_net *ks) #ifdef CONFIG_PM_SLEEP -int ks8851_suspend(struct device *dev) +static int ks8851_suspend(struct device *dev) { struct ks8851_net *ks = dev_get_drvdata(dev); struct net_device *netdev = ks->netdev; @@ -943,7 +933,7 @@ int ks8851_suspend(struct device *dev) return 0; } -int ks8851_resume(struct device *dev) +static int ks8851_resume(struct device *dev) { struct ks8851_net *ks = dev_get_drvdata(dev); struct net_device *netdev = ks->netdev; @@ -957,7 +947,7 @@ int ks8851_resume(struct device *dev) } #endif -int ks8851_probe_common(struct net_device *netdev, struct device *dev) +static int ks8851_probe_common(struct net_device *netdev, struct device *dev) { struct ks8851_net *ks = netdev_priv(netdev); unsigned cider; @@ -1086,7 +1076,7 @@ int ks8851_probe_common(struct net_device *netdev, struct device *dev) return ret; } -int ks8851_remove_common(struct device *dev) +static int ks8851_remove_common(struct device *dev) { struct ks8851_net *priv = dev_get_drvdata(dev); @@ -1104,4 +1094,3 @@ int ks8851_remove_common(struct device *dev) module_param_named(message, msg_enable, int, 0); MODULE_PARM_DESC(message, "Message verbosity level (0=none, 31=all)"); -MODULE_ALIAS("spi:ks8851"); diff --git a/drivers/net/ethernet/micrel/ks8851_par.c b/drivers/net/ethernet/micrel/ks8851_mll.c similarity index 89% rename from drivers/net/ethernet/micrel/ks8851_par.c rename to drivers/net/ethernet/micrel/ks8851_mll.c index 3f70f07bcb2f..82e76b80436e 100644 --- a/drivers/net/ethernet/micrel/ks8851_par.c +++ b/drivers/net/ethernet/micrel/ks8851_mll.c @@ -6,28 +6,9 @@ * Ben Dooks */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#define DEBUG - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "ks8851.h" #include -#include -#include -#include - -#include "ks8851.h" #define BE3 0x8000 /* Byte Enable 3 */ #define BE2 0x4000 /* Byte Enable 2 */ @@ -64,7 +45,7 @@ struct ks8851_net_par { * * Claim chip register access lock */ -void ks8851_lock(struct ks8851_net *ks, unsigned long *flags) +static void ks8851_lock(struct ks8851_net *ks, unsigned long *flags) { struct ks8851_net_par *ksp = to_ks8851_par(ks); @@ -78,7 +59,7 @@ void ks8851_lock(struct ks8851_net *ks, unsigned long *flags) * * Release chip register access lock */ -void ks8851_unlock(struct ks8851_net *ks, unsigned long *flags) +static void ks8851_unlock(struct ks8851_net *ks, unsigned long *flags) { struct ks8851_net_par *ksp = to_ks8851_par(ks); @@ -137,7 +118,7 @@ static int ks_check_endian(struct ks8851_net *ks) * * Issue a write to put the value @val into the register specified in @reg. */ -void ks8851_wrreg16(struct ks8851_net *ks, unsigned int reg, unsigned int val) +static void ks8851_wrreg16(struct ks8851_net *ks, unsigned int reg, unsigned int val) { struct ks8851_net_par *ksp = to_ks8851_par(ks); @@ -153,7 +134,7 @@ void ks8851_wrreg16(struct ks8851_net *ks, unsigned int reg, unsigned int val) * * Read a 16bit register from the chip, returning the result */ -unsigned int ks8851_rdreg16(struct ks8851_net *ks, unsigned int reg) +static unsigned int ks8851_rdreg16(struct ks8851_net *ks, unsigned int reg) { struct ks8851_net_par *ksp = to_ks8851_par(ks); @@ -171,7 +152,7 @@ unsigned int ks8851_rdreg16(struct ks8851_net *ks, unsigned int reg) * Issue an RXQ FIFO read command and read the @len amount of data from * the FIFO into the buffer specified by @buff. */ -void ks8851_rdfifo(struct ks8851_net *ks, u8 *buff, unsigned int len) +static void ks8851_rdfifo(struct ks8851_net *ks, u8 *buff, unsigned int len) { struct ks8851_net_par *ksp = to_ks8851_par(ks); @@ -192,7 +173,7 @@ void ks8851_rdfifo(struct ks8851_net *ks, u8 *buff, unsigned int len) * needs, such as IRQ on completion. Send the header and the packet data to * the device. */ -void ks8851_wrfifo(struct ks8851_net *ks, struct sk_buff *txp, bool irq) +static void ks8851_wrfifo(struct ks8851_net *ks, struct sk_buff *txp, bool irq) { struct ks8851_net_par *ksp = to_ks8851_par(ks); unsigned int len = ALIGN(txp->len, 4); @@ -217,7 +198,7 @@ void ks8851_wrfifo(struct ks8851_net *ks, struct sk_buff *txp, bool irq) * ks8851_rx_skb - receive skbuff * @skb: The skbuff */ -void ks8851_rx_skb(struct sk_buff *skb) +static void ks8851_rx_skb(struct sk_buff *skb) { netif_rx(skb); } @@ -226,7 +207,7 @@ void ks8851_rx_skb(struct sk_buff *skb) * ks8851_flush_tx_work - flush outstanding TX work * @ks: The device state */ -void ks8851_flush_tx_work(struct ks8851_net *ks) +static void ks8851_flush_tx_work(struct ks8851_net *ks) { } @@ -243,7 +224,7 @@ void ks8851_flush_tx_work(struct ks8851_net *ks) * and secondly so we can round up more than one packet to transmit which * means we can try and avoid generating too many transmit done interrupts. */ -netdev_tx_t ks8851_start_xmit(struct sk_buff *skb, struct net_device *dev) +static netdev_tx_t ks8851_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct ks8851_net *ks = netdev_priv(dev); netdev_tx_t ret = NETDEV_TX_OK; @@ -271,6 +252,8 @@ netdev_tx_t ks8851_start_xmit(struct sk_buff *skb, struct net_device *dev) return ret; } +#include "ks8851_common.h" + static int ks8851_probe_par(struct platform_device *pdev) { struct device *dev = &pdev->dev; -- 2.25.0