linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net: lan743x: select CRC16
@ 2018-08-13 21:19 Arnd Bergmann
  2018-08-13 21:19 ` [PATCH 2/2] net: lan743x: fix building without CONFIG_PTP_1588_CLOCK Arnd Bergmann
  2018-08-14  3:44 ` [PATCH 1/2] net: lan743x: select CRC16 David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Arnd Bergmann @ 2018-08-13 21:19 UTC (permalink / raw)
  To: David S. Miller
  Cc: Arnd Bergmann, Bryan Whitehead, Andrew Lunn, netdev, linux-kernel

lan743x now fails to build when CONFIG_CRC16 is disabled:

drivers/net/ethernet/microchip/lan743x_main.o: In function crc16'

Force it on like all other users do.

Fixes: 4d94282afd95 ("lan743x: Add power management support")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/ethernet/microchip/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/microchip/Kconfig b/drivers/net/ethernet/microchip/Kconfig
index 71dca8bd51ac..16bd3f44dbe8 100644
--- a/drivers/net/ethernet/microchip/Kconfig
+++ b/drivers/net/ethernet/microchip/Kconfig
@@ -46,6 +46,7 @@ config LAN743X
 	tristate "LAN743x support"
 	depends on PCI
 	select PHYLIB
+	select CRC16
 	---help---
 	  Support for the Microchip LAN743x PCI Express Gigabit Ethernet chip
 
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] net: lan743x: fix building without CONFIG_PTP_1588_CLOCK
  2018-08-13 21:19 [PATCH 1/2] net: lan743x: select CRC16 Arnd Bergmann
@ 2018-08-13 21:19 ` Arnd Bergmann
  2018-08-14  3:44   ` David Miller
  2018-08-14  3:44 ` [PATCH 1/2] net: lan743x: select CRC16 David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2018-08-13 21:19 UTC (permalink / raw)
  To: David S. Miller
  Cc: Arnd Bergmann, Bryan Whitehead, Microchip Linux Driver Support,
	netdev, linux-kernel

Building without CONFIG_PTP_1588_CLOCK results in multiple failures,
this was obviously not well tested:

drivers/net/ethernet/microchip/lan743x_ptp.c: In function 'lan743x_ptp_isr':
drivers/net/ethernet/microchip/lan743x_ptp.c:781:28: error: 'struct lan743x_ptp' has no member named 'ptp_clock'; did you mean 'tx_ts_lock'?
   ptp_schedule_worker(ptp->ptp_clock, 0);
                            ^~~~~~~~~
                            tx_ts_lock
drivers/net/ethernet/microchip/lan743x_ptp.c: In function 'lan743x_ptp_open':
drivers/net/ethernet/microchip/lan743x_ptp.c:879:6: error: unused variable 'ret' [-Werror=unused-variable]
  int ret = -ENODEV;
      ^~~
At top level:
drivers/net/ethernet/microchip/lan743x_ptp.c:63:13: error: 'lan743x_ptp_tx_ts_enqueue_ts' defined but not used [-Werror=unused-function]
 static void lan743x_ptp_tx_ts_enqueue_ts(struct lan743x_adapter *adapter,
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
drivers/net/ethernet/microchip/lan743x_ethtool.c: In function 'lan743x_ethtool_get_ts_info':
drivers/net/ethernet/microchip/lan743x_ethtool.c:558:19: error: 'struct lan743x_ptp' has no member named 'ptp_clock'; did you mean 'tx_ts_lock'?

Those #ifdef checks are hard to get right, replace them all with
IS_ENABLED() checks that leave the same code visible to the compiler
but let it optimize out the unused bits based on the configuration.

Fixes: 07624df1c9ef ("lan743x: lan743x: Add PTP support")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/ethernet/microchip/lan743x_ptp.c | 15 ++++++---------
 drivers/net/ethernet/microchip/lan743x_ptp.h |  2 --
 2 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/microchip/lan743x_ptp.c b/drivers/net/ethernet/microchip/lan743x_ptp.c
index 42064fd2beb5..66e7568a0e7c 100644
--- a/drivers/net/ethernet/microchip/lan743x_ptp.c
+++ b/drivers/net/ethernet/microchip/lan743x_ptp.c
@@ -4,6 +4,7 @@
 #include <linux/netdevice.h>
 #include "lan743x_main.h"
 
+#include <linux/ptp_clock_kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/netdevice.h>
@@ -139,7 +140,6 @@ static void lan743x_ptp_tx_ts_complete(struct lan743x_adapter *adapter)
 	spin_unlock_bh(&ptp->tx_ts_lock);
 }
 
-#ifdef CONFIG_PTP_1588_CLOCK
 static int lan743x_ptp_reserve_event_ch(struct lan743x_adapter *adapter)
 {
 	struct lan743x_ptp *ptp = &adapter->ptp;
@@ -761,7 +761,6 @@ static void lan743x_ptp_clock_step(struct lan743x_adapter *adapter,
 		mutex_unlock(&ptp->command_lock);
 	}
 }
-#endif /* CONFIG_PTP_1588_CLOCK */
 
 void lan743x_ptp_isr(void *context)
 {
@@ -890,7 +889,9 @@ int lan743x_ptp_open(struct lan743x_adapter *adapter)
 			  PTP_INT_BIT_TX_SWTS_ERR_ | PTP_INT_BIT_TX_TS_);
 	ptp->flags |= PTP_FLAG_ISR_ENABLED;
 
-#ifdef CONFIG_PTP_1588_CLOCK
+	if (!IS_ENABLED(CONFIG_PTP_1588_CLOCK))
+		return 0;
+
 	snprintf(ptp->pin_config[0].name, 32, "lan743x_ptp_pin_0");
 	ptp->pin_config[0].index = 0;
 	ptp->pin_config[0].func = PTP_PF_PEROUT;
@@ -932,9 +933,6 @@ int lan743x_ptp_open(struct lan743x_adapter *adapter)
 done:
 	lan743x_ptp_close(adapter);
 	return ret;
-#else
-	return 0;
-#endif
 }
 
 void lan743x_ptp_close(struct lan743x_adapter *adapter)
@@ -942,15 +940,14 @@ void lan743x_ptp_close(struct lan743x_adapter *adapter)
 	struct lan743x_ptp *ptp = &adapter->ptp;
 	int index;
 
-#ifdef CONFIG_PTP_1588_CLOCK
-	if (ptp->flags & PTP_FLAG_PTP_CLOCK_REGISTERED) {
+	if (IS_ENABLED(CONFIG_PTP_1588_CLOCK) &&
+	    ptp->flags & PTP_FLAG_PTP_CLOCK_REGISTERED) {
 		ptp_clock_unregister(ptp->ptp_clock);
 		ptp->ptp_clock = NULL;
 		ptp->flags &= ~PTP_FLAG_PTP_CLOCK_REGISTERED;
 		netif_info(adapter, drv, adapter->netdev,
 			   "ptp clock unregister\n");
 	}
-#endif
 
 	if (ptp->flags & PTP_FLAG_ISR_ENABLED) {
 		lan743x_csr_write(adapter, PTP_INT_EN_CLR,
diff --git a/drivers/net/ethernet/microchip/lan743x_ptp.h b/drivers/net/ethernet/microchip/lan743x_ptp.h
index 20f2223024dc..5fc1b3cd5e33 100644
--- a/drivers/net/ethernet/microchip/lan743x_ptp.h
+++ b/drivers/net/ethernet/microchip/lan743x_ptp.h
@@ -49,11 +49,9 @@ struct lan743x_ptp {
 	/* command_lock: used to prevent concurrent ptp commands */
 	struct mutex	command_lock;
 
-#ifdef CONFIG_PTP_1588_CLOCK
 	struct ptp_clock *ptp_clock;
 	struct ptp_clock_info ptp_clock_info;
 	struct ptp_pin_desc pin_config[1];
-#endif /* CONFIG_PTP_1588_CLOCK */
 
 #define LAN743X_PTP_NUMBER_OF_EVENT_CHANNELS (2)
 	unsigned long used_event_ch;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] net: lan743x: select CRC16
  2018-08-13 21:19 [PATCH 1/2] net: lan743x: select CRC16 Arnd Bergmann
  2018-08-13 21:19 ` [PATCH 2/2] net: lan743x: fix building without CONFIG_PTP_1588_CLOCK Arnd Bergmann
@ 2018-08-14  3:44 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2018-08-14  3:44 UTC (permalink / raw)
  To: arnd; +Cc: Bryan.Whitehead, andrew, netdev, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Mon, 13 Aug 2018 23:19:21 +0200

> lan743x now fails to build when CONFIG_CRC16 is disabled:
> 
> drivers/net/ethernet/microchip/lan743x_main.o: In function crc16'
> 
> Force it on like all other users do.
> 
> Fixes: 4d94282afd95 ("lan743x: Add power management support")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] net: lan743x: fix building without CONFIG_PTP_1588_CLOCK
  2018-08-13 21:19 ` [PATCH 2/2] net: lan743x: fix building without CONFIG_PTP_1588_CLOCK Arnd Bergmann
@ 2018-08-14  3:44   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2018-08-14  3:44 UTC (permalink / raw)
  To: arnd; +Cc: bryan.whitehead, UNGLinuxDriver, netdev, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Mon, 13 Aug 2018 23:19:22 +0200

> Building without CONFIG_PTP_1588_CLOCK results in multiple failures,
> this was obviously not well tested:
 ...
> Those #ifdef checks are hard to get right, replace them all with
> IS_ENABLED() checks that leave the same code visible to the compiler
> but let it optimize out the unused bits based on the configuration.
> 
> Fixes: 07624df1c9ef ("lan743x: lan743x: Add PTP support")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-08-14  3:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-13 21:19 [PATCH 1/2] net: lan743x: select CRC16 Arnd Bergmann
2018-08-13 21:19 ` [PATCH 2/2] net: lan743x: fix building without CONFIG_PTP_1588_CLOCK Arnd Bergmann
2018-08-14  3:44   ` David Miller
2018-08-14  3:44 ` [PATCH 1/2] net: lan743x: select CRC16 David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).