Gpio driver, ioctl cannot be accessed, always return error-1 -- Linux general technology-Linux technology and application information, the following is read details. Today, I wrote an application to test linux and found that ioctl went wrong.-1 was returned. why?
What's more strange is that when the kernel-side gpio_ioctl is added to the printk mode, there is no output, which means that when the user program ioctl, gpio_ioctl will not be executed at all !!!
Ask for help. give me some advice on linux Cainiao! And the called write and read are all good.
Kernel Driver
Define GPIO_MAGIC 'M'
# Define GPIO_CMD1 _ IOR (GPIO_MAGIC, 0x1a, unsigned long)
# Define GPIO_CMD2 _ IOR (GPIO_MAGIC, 0x1b, unsigned long)
Static long gpio_ioctl (struct file * file, unsigned int cmd, unsigned long arg)
{
Int ret = 3;
Int val;
Printk (KERN_WARNING "wuwuwuwuwuw \ n ");
Printk (KERN_WARNING "cmd = % d \ n", cmd); ------- This place has not been printed
Switch (cmd ){
Case GPIO_CMD1:
Case GPIO_CMD2:
If (arg> 7 ){
Return 10;
}
_ Raw_writel (1 <val =__ raw_readl (gpdat );
Printk (KERN_WARNING "the value of % x \ n", val );
Printk (KERN_WARNING "the value is 1 \ n ");
Break;
Default:
Return 0;
}
Return ret;
}
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.