file_operations

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:~$

  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

乐分享-程序员

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值