diff options
| author | Jean-Sébastien Pédron <dumbbell@FreeBSD.org> | 2026-04-13 21:47:22 +0000 |
|---|---|---|
| committer | Jean-Sébastien Pédron <dumbbell@FreeBSD.org> | 2026-04-21 22:18:25 +0000 |
| commit | ae1f6954e2c82ad7f1d8b80155a921b908d51756 (patch) | |
| tree | e9d5f1305348cdb5a0a12335d126c69ec3899624 | |
| parent | 4dab15e96d40352e1a0b161a2a1cd763176108b6 (diff) | |
linuxkpi: Define `MINORBITS`
We can't really define a proper value for this constant because minor
and major are encoded in a complex way on FreeBSD which cannot be
represented with a simple shift.
The DRM generic code started to use it in Linux 6.12.
In this context, `MINORBITS` is used to define an upper limit passed to
`xa_alloc()`. Therefore it is not used to encode or decode minors. It is
used as an arbitrary value. Therefore, we define the constant to 20,
like on Linux.
Reviewed by: bz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D56447
| -rw-r--r-- | sys/compat/linuxkpi/common/include/linux/kdev_t.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/kdev_t.h b/sys/compat/linuxkpi/common/include/linux/kdev_t.h index 988dd771254a..964b7078e7f5 100644 --- a/sys/compat/linuxkpi/common/include/linux/kdev_t.h +++ b/sys/compat/linuxkpi/common/include/linux/kdev_t.h @@ -31,6 +31,21 @@ #include <sys/types.h> +/* + * The encoding of major/minor on FreeBSD is complex to take into account the + * compatibility with 16-bit dev_t (see <sys/types.h>). It is not possible to + * use a simple shift and thus, we can't have a proper definition of + * `MINORBITS`. + * + * At the time this is added to linuxkpi, this is used by the DRM generic code + * as the upper limit to allocate an ID using an xarray. It is not used to + * decode a minor, therefore any arbitrary value here is fine in this context. + * + * On Linux, the value is set to 20. Because of the above, we reuse this value, + * even so it does not correspond to the actual minor encoding on FreeBSD. + */ +#define MINORBITS 20 + #define MAJOR(dev) major(dev) #define MINOR(dev) minor(dev) #define MKDEV(ma, mi) makedev(ma, mi) |
