3 version of MKDEV: kernel, uapi, libc, why?
From: Zhang, Ning A
Date: Wed Apr 11 2018 - 04:51:14 EST
Hi, Greg, Thomas
I find 3 version of MKDEV (actually 2 + makedev)
in include/linux/kdev_t.h
#define MINORBITS 20
#define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi))
in inlcude/uapi/linux/kdev_t.h
#define MKDEV(ma,mi) ((ma)<<8 | (mi))
in Android bionic
#define makedev(__major, __minor) \
 ( \
ÂÂÂÂ(((__major) & 0xfffff000ULL) << 32) | (((__major) & 0xfffULL) <<
8) | \
ÂÂÂÂ(((__minor) & 0xffffff00ULL) << 12) | (((__minor) & 0xffULL)) \
 )
if I use mknod("renderD128", S_IFCHR|0666, MKDEV(226, 128));
I get wrong device:
crw-rw-rw- 1 root graphicsÂ0, 57984 2011-11-11 11:20 renderD128
if I use ("renderD128",S_IFCHR|0666, makedev(226, 128));
I get right device.
but, when I use: mknod("card0", S_IFCHR|0666, MKDEV(226, 0));
I can get right device.
BR.
Ning.