开发者

Performing an ioctl from the kernel-space

开发者 https://www.devze.com 2023-02-18 14:02 出处:网络
I\'m writing a kernel driver that needs to perform an ioctl on another device. I realize this is not the best way to handle the code, but this is just a temporary fix for now. I\'m getting back error

I'm writing a kernel driver that needs to perform an ioctl on another device. I realize this is not the best way to handle the code, but this is just a temporary fix for now. I'm getting back error code -22 (Invalid argument) from my ioctl call in the function, b开发者_开发技巧ut I don't see what could be wrong with the arguments. Here are the relevant sections of code.

#define GPIO74 "/dev/gpio/74"

struct file* gpio74FD;
  .
  .
  .
gpio74FD = filp_open(GPIO74,O_RDWR,0)
  .
  .
  .
int device_ioctl(struct inode* inode,struct file *file, unsigned int ioctl_num,unsigned long ioctl_param)
{
  .
  .
  .
ret_val = gpio74FD->f_op->ioctl(inode, gpio74FD, GPIO_CONFIG_AS_INP, 0); //returns error code -22 (Invlaid Argument)
  .
  .
  .
return ret_val;
}

I suspect it may have something to do with passing the incorrect inode here, but im not even sure how to get the correct inode if its not the one passed to ioctl from the user space.


Since you are now very deep in "don't do that" hacking territory, adding a few printk to the gpio driver could give you some valuable info.

Another options is to avoid this horrible hack, and switch to a less harmful one : add an exported function to the gpio driver, that you can call from your own module

0

精彩评论

暂无评论...
验证码 换一张
取 消