Re: [PATCH] s390/net: lcs: fix build errors when FDDI is a loadable module

From: Randy Dunlap
Date: Wed Jun 28 2023 - 03:56:54 EST


Hi Alexandra, Simon, others,

Here is v2 of this patch. I will send it formally after the merge window closes.

Thanks for all of your help.
---

From: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
Subject: [PATCH v2 net] s390/net: lcs: use IS_ENABLED() for kconfig detection

When CONFIG_ETHERNET is disabled and CONFIG_FDDI=m, lcs.s has build
errors or warnings:

../drivers/s390/net/lcs.c:40:2: error: #error Cannot compile lcs.c without some net devices switched on.
40 | #error Cannot compile lcs.c without some net devices switched on.
../drivers/s390/net/lcs.c: In function 'lcs_startlan_auto':
../drivers/s390/net/lcs.c:1601:13: warning: unused variable 'rc' [-Wunused-variable]
1601 | int rc;

Solve this by using IS_ENABLED(CONFIG_symbol) instead of ifdef
CONFIG_symbol. The latter only works for builtin (=y) values
while IS_ENABLED() works for builtin or modular values.

Modify the LCS Kconfig entry to allow combinations of builtin and
modular drivers to work as long as LCS <= FDDI (where n < m < y)
if FDDI is enabled. If FDDI is not enabled, ETHERNET must be =y,
so LCS can be builtin or modular since ETHERNET is a bool.

Remove the #error directive in the source file since the Kconfig
modification prevents that error combination.

Tested successfully with all possible combinations of ETHERNET, FDDI,
and LCS.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
Suggested-by: Alexandra Winter <wintera@xxxxxxxxxxxxx>
Cc: Wenjia Zhang <wenjia@xxxxxxxxxxxxx>
Cc: linux-s390@xxxxxxxxxxxxxxx
Cc: netdev@xxxxxxxxxxxxxxx
Cc: Heiko Carstens <hca@xxxxxxxxxxxxx>
Cc: Vasily Gorbik <gor@xxxxxxxxxxxxx>
Cc: Alexander Gordeev <agordeev@xxxxxxxxxxxxx>
Cc: Christian Borntraeger <borntraeger@xxxxxxxxxxxxx>
Cc: Sven Schnelle <svens@xxxxxxxxxxxxx>
Cc: Simon Horman <simon.horman@xxxxxxxxxxxx>
Cc: David S. Miller <davem@xxxxxxxxxxxxx>
Cc: Eric Dumazet <edumazet@xxxxxxxxxx>
Cc: Jakub Kicinski <kuba@xxxxxxxxxx>
Cc: Paolo Abeni <pabeni@xxxxxxxxxx>
---
drivers/s390/net/Kconfig | 1 +
drivers/s390/net/lcs.c | 13 ++++---------
2 files changed, 5 insertions(+), 9 deletions(-)

diff -- a/drivers/s390/net/Kconfig b/drivers/s390/net/Kconfig
--- a/drivers/s390/net/Kconfig
+++ b/drivers/s390/net/Kconfig
@@ -6,6 +6,7 @@ config LCS
def_tristate m
prompt "Lan Channel Station Interface"
depends on CCW && NETDEVICES && (ETHERNET || FDDI)
+ depends on FDDI || FDDI=n
help
Select this option if you want to use LCS networking on IBM System z.
This device driver supports FDDI (IEEE 802.7) and Ethernet.
diff -- a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -35,11 +35,6 @@

#include "lcs.h"

-
-#if !defined(CONFIG_ETHERNET) && !defined(CONFIG_FDDI)
-#error Cannot compile lcs.c without some net devices switched on.
-#endif
-
/*
* initialization string for output
*/
@@ -1601,14 +1596,14 @@ lcs_startlan_auto(struct lcs_card *card)
int rc;

LCS_DBF_TEXT(2, trace, "strtauto");
-#ifdef CONFIG_ETHERNET
+#if IS_ENABLED(CONFIG_ETHERNET)
card->lan_type = LCS_FRAME_TYPE_ENET;
rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
if (rc == 0)
return 0;

#endif
-#ifdef CONFIG_FDDI
+#if IS_ENABLED(CONFIG_FDDI)
card->lan_type = LCS_FRAME_TYPE_FDDI;
rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP);
if (rc == 0)
@@ -2140,13 +2135,13 @@ lcs_new_device(struct ccwgroup_device *c
goto netdev_out;
}
switch (card->lan_type) {
-#ifdef CONFIG_ETHERNET
+#if IS_ENABLED(CONFIG_ETHERNET)
case LCS_FRAME_TYPE_ENET:
card->lan_type_trans = eth_type_trans;
dev = alloc_etherdev(0);
break;
#endif
-#ifdef CONFIG_FDDI
+#if IS_ENABLED(CONFIG_FDDI)
case LCS_FRAME_TYPE_FDDI:
card->lan_type_trans = fddi_type_trans;
dev = alloc_fddidev(0);