public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yury Norov <ynorov@nvidia.com>
To: Paul Walmsley <pjw@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>,
	Yury Norov <yury.norov@gmail.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Arnd Bergmann <arnd@arndb.de>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	Stanislav Fomichev <sdf@fomichev.me>,
	Jinjie Ruan <ruanjinjie@huawei.com>,
	linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
	linux-arch@vger.kernel.org, netdev@vger.kernel.org,
	bpf@vger.kernel.org
Cc: Yury Norov <ynorov@nvidia.com>, Nathan Chancellor <nathan@kernel.org>
Subject: [PATCH 1/6] lib: include crc32.h conditionally on CONFIG_CRC32
Date: Thu, 30 Apr 2026 17:13:45 -0400	[thread overview]
Message-ID: <20260430211351.658193-2-ynorov@nvidia.com> (raw)
In-Reply-To: <20260430211351.658193-1-ynorov@nvidia.com>

Currently, bitreverse API is either declared based on
CONFIG_HAVE_ARCH_BITREVERSE, wired to arch implementation, or if the
arch has no bitreverse, based on generic implementation.

So, regardless of CONFIG_BITREVERSE=n, the corresponding API is always
declared. If that happens, the functions become declared but not
implemented, which is an error.

The following patches of the series make it possible to have bitreverse
API undeclared if CONFIG_BITREVERSE=n, thus spotting the problem when
building the tinyconfig:

   $ make -skj"$(nproc)" ARCH=s390 CROSS_COMPILE=s390-linux- mrproper tinyconfig fs/select.o
   In file included from include/linux/crc32.h:6,
                    from include/linux/etherdevice.h:23,
                    from include/linux/if_vlan.h:11,
                    from include/linux/filter.h:21,
                    from include/net/xdp.h:10,
                    from include/net/busy_poll.h:19,
                    from fs/select.c:33:
   include/linux/etherdevice.h: In function 'eth_hw_addr_crc':
   include/linux/bitrev.h:16:20: error: implicit declaration of function 'generic___bitrev32' [-Wimplicit-function-declaration]
      16 | #define __bitrev32 generic___bitrev32
         |                    ^~~~~~~~~~~~~~~~~~
   include/linux/bitrev.h:67:9: note: in expansion of macro '__bitrev32'
      67 |         __bitrev32(__x);                                \
         |         ^~~~~~~~~~
   include/linux/crc32.h:107:36: note: in expansion of macro 'bitrev32'
     107 | #define ether_crc(length, data)    bitrev32(crc32_le(~0, data, length))
         |                                    ^~~~~~~~
   include/linux/etherdevice.h:292:16: note: in expansion of macro 'ether_crc'
     292 |         return ether_crc(ETH_ALEN, ha->addr);
         |                ^~~~~~~~~
   make[5]: *** [scripts/Makefile.build:289: fs/select.o] Error 1
   ...

The current unconditionally enabled codebase doesn't use CRC32, neither
bitrev functionality, and if generic___bitrev32 prototype is provided,
the compilation and linkage phases are passed OK.

The only header requiring the crc32 and bitreverse prototypes is
include/linux/etherdevice.h. Thus, protect inclusion of corresponding
headers in the etherdevice with CONFIG_CRC32, together with the only
function depending on it.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
 include/linux/etherdevice.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index df8f88f63a70..d35be27a91a5 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -20,7 +20,9 @@
 #include <linux/if_ether.h>
 #include <linux/netdevice.h>
 #include <linux/random.h>
+#ifdef CONFIG_CRC32
 #include <linux/crc32.h>
+#endif
 #include <linux/unaligned.h>
 #include <asm/bitsperlong.h>
 
@@ -281,6 +283,7 @@ static inline void eth_hw_addr_random(struct net_device *dev)
 	dev->addr_assign_type = NET_ADDR_RANDOM;
 }
 
+#ifdef CONFIG_CRC32
 /**
  * eth_hw_addr_crc - Calculate CRC from netdev_hw_addr
  * @ha: pointer to hardware address
@@ -291,6 +294,7 @@ static inline u32 eth_hw_addr_crc(struct netdev_hw_addr *ha)
 {
 	return ether_crc(ETH_ALEN, ha->addr);
 }
+#endif
 
 /**
  * ether_addr_copy - Copy an Ethernet address
-- 
2.51.0


  reply	other threads:[~2026-04-30 21:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-30 21:13 [PATCH 0/6] lib: rework bitreverse Yury Norov
2026-04-30 21:13 ` Yury Norov [this message]
2026-05-04  8:03   ` [PATCH 1/6] lib: include crc32.h conditionally on CONFIG_CRC32 Arnd Bergmann
2026-05-04 12:43     ` David Laight
2026-05-04 16:46     ` Yury Norov
2026-05-04 17:18       ` Arnd Bergmann
2026-05-04 18:32         ` Yury Norov
2026-05-04 19:05           ` Arnd Bergmann
2026-04-30 21:13 ` [PATCH 2/6] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig Yury Norov
2026-04-30 21:13 ` [PATCH 3/6] bitops: Define generic __bitrev8/16/32 for reuse Yury Norov
2026-04-30 21:13 ` [PATCH 4/6] arch/riscv: Add bitrev.h file to support rev8 and brev8 Yury Norov
2026-04-30 21:13 ` [PATCH 5/6] lib: compile generic bitrev.c conditionally on GENERIC_BITREVERSE Yury Norov
2026-04-30 21:13 ` [PATCH 6/6] MAINTAINERS: BITOPS: include bitrev.[ch] Yury Norov
2026-05-02  1:40 ` [PATCH 0/6] lib: rework bitreverse Yury Norov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260430211351.658193-2-ynorov@nvidia.com \
    --to=ynorov@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex@ghiti.fr \
    --cc=andrew+netdev@lunn.ch \
    --cc=aou@eecs.berkeley.edu \
    --cc=arnd@arndb.de \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hawk@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=nathan@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=ruanjinjie@huawei.com \
    --cc=sdf@fomichev.me \
    --cc=yury.norov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox