I am creating a driver for a embeeded system. I am using IOCTL function. The device is register correctly and the open and write functions work as expected but IOCTL doesn't.
When I call IOCTL from user space with parameter 0 the my_ioctl function called with ioctl_num = 0 but when I use any other values the my_ioctl kernel function is not being called.
#define READ_IOCTL _IO(UAM_DEV_MAGIC, 0)
#define WRITE_IOCTL _IO(UAM_DEV_MAGIC, 1)
#define ASK_VALUE _IO(UAM_DEV_MAGIC, 2)
When I make a IOCTL call from user space using READ_IOCTL (0), everything work properly. However, when I try WRITE_IOCTL and ASK_VALUE (1 and 2).
If I use the following:
#define READ_IOCTL _IO(UAM_DEV_MAGIC, 1)
#define WRITE_IOCTL _IO(UAM_DEV_MAGIC, 0)
#define ASK_VALUE _IO(UAM_DEV_MAGIC, 2)
Only works WRITE_IOCTL calls from user space. I am using linux 3.16 and PowerPC. Any idea what is wrong?
Any idea why does it work with 0 and not with the 1,2,3,etc?- probably, your codes conincide with predefined ioctl codes. See man ioctl_list. - Tsyvarev