Xilinx / open-nic-driver

AMD OpenNIC driver includes the Linux kernel driver
GNU General Public License v2.0
58 stars 40 forks source link

Fix to compile on linux kernel 6.4: Rename FIELD_GET to BITFIELD_GET #52

Closed cyberang3l closed 9 months ago

cyberang3l commented 10 months ago

The macro FIELD_GET is already defined in linux/bitfield.h, that is somehow included when compiling the onic driver on linux 6.4. This causes the following error:

open-nic-driver/onic_common.h:64: error: "FIELD_GET" redefined [-Werror]
   64 | #define FIELD_GET(mask, reg)    ((reg & mask) >> FIELD_SHIFT(mask))

Unfortunately, the FIELD_GET macro that is already defined in linux/bitfield.h is using the typeof operator, and the typeof operator cannot be applied to bit-field members:

The onic driver is making heavy use of bit-fields, thus, we cannot use the already defined FIELD_GET macro without a heavy code refactoring.

This commit simply renames the FIELD_GET macro defined in the onic driver to BITFIELD_GET to avoid the macro redefinition error.