The IOCTL is used when writing kernel drivers. Define the cmd itself as the parameters of the IOCTL. As follows:
enum CMD { level_down, level_up, gpio_input, gpio_output, Gpio_get,};
IOCTL underlying calling code:
Static long led_ioctl (structintlong arg) { }
When the application layer invokes the IOCTL, an error occurs when the incoming cmd=2.
The IOCTL return value is-1. Error number errno:14, bad address.
Internet access only know the need to use macros such as _IOWR to generate CMD commands, but not to write their own.
Although it is possible to write on your own, it is likely to conflict with other CMD commands in the system. Just when the cmd=2 of the IOCTL made a mistake.
The new definition of CMD is as follows:
#define Type #define level_down _iowr (type, 0, int)#define level_up _iowr (type, 1, int)#define gpio_input _iowr (type, 2, int)#define gpio_output _iowr (type , 3, int)#define gpio_get _iowr (TYPE, 4, int)
IOCTL parameter cmd=2 error