LinuxKPI: make bcd.h use libkern

Rather than having code to re-define bcd2bin() for the LinuxKPI
make sure libkern.h is always included before the LinuxKPI version.
Then only re-define our local LinuxKPI implementation.  [1]

From the argument truncating wrapper call the libkern version.
If we change our libkern implementation in the future we can save
us the remainder of the hassle. [2]  Given I need this to MFC,
which I am not sure we can with libkern, commit this intermediate
step.

Suggested by:	Johannes Berg (johannes sipsolutions.net) [1]
Suggested by:	ian [2]
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
X-MFC with:	548ada00e5
Differential Revision: https://reviews.freebsd.org/D32695
This commit is contained in:
Bjoern A. Zeeb 2021-10-27 17:07:38 +00:00
parent f4bf849bb8
commit ae2268efd5

View File

@ -31,23 +31,15 @@
#define _LINUXKPI_LINUX_BCD_H
#include <sys/types.h>
#include <sys/libkern.h>
/*
* We could use libkern, but we need the argument truncating.
*
* This leaves us with a duplicate symbol with conflicting types
* so we cannot simply re-define as libkern.h gets included in
* too many places directly or indirectly. This means for now
* drivers will have to be adjusted to call linuxkpi_bcd2bin().
*/
/* Compared to the libkern version this one truncates the argument. */
static inline uint8_t linuxkpi_bcd2bin(uint8_t x)
{
return (x & 0x0f) + (x >> 4) * 10;
return (bcd2bin(x));
}
#if 0
#define bcd2bin(_x) linuxkpi_bcd2bin(_x)
#endif
#endif /* _LINUXKPI_LINUX_BCD_H */