IOCTL parameter cmd=2 error

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.