unlocked_ioctl 与 compat_ioctl 的区别
.unlocked_ioctl = spidev_ioctl, | 32 位 程序 ->32位 kernel 64 位 程序 ->64位 kernel |
.compat_ioctl = spidev_compat_ioctl, | 32 位 程序 ->64位 kernel |
测试流程:
static const struct file_operations spidev_fops = {
.....
.unlocked_ioctl = spidev_ioctl,
.compat_ioctl = spidev_compat_ioctl,
.....
};
编译测试程序:
arm-linux-gnueabihf-gcc -static spi-ioctl.c -o spi-ioctl-32
aarch64-linux-gnu-gcc spi-ioctl.c -o spi-ioctl测试
niyu@raspberrypi:~$ file spi-ioctl spi-ioctl-32
spi-ioctl: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically ..
spi-ioctl-32: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), statically ....niyu@raspberrypi:~$
niyu@raspberrypi:~$ sudo dmesg -c > /dev/null
niyu@raspberrypi:~$ ./spi-ioctl
Current SPI mode: 0x0
niyu@raspberrypi:~$ sudo dmesg
[ 1124.885644] ########## spidev_open
[ 1124.885669] ########## spidev_ioctl
niyu@raspberrypi:~$
niyu@raspberrypi:~$
niyu@raspberrypi:~$ sudo dmesg -c > /dev/null
niyu@raspberrypi:~$ ./spi-ioctl-32
Current SPI mode: 0x0
niyu@raspberrypi:~$ sudo dmesg
[ 1140.444986] ########## spidev_open
[ 1140.445012] ########## spidev_compat_ioctl
[ 1140.445022] ########## spidev_ioctl
niyu@raspberrypi:~$