我移植了2.6.36的内核,使用MINI2440_LED驱动,发现led例子程序不能控制led;
在驱动中的ioctl函数里面加了打印语句后发现,ioctl得到的arg参数不是应用程序调用ioctl时传入的参数,一直是一个固定的数,但是不知道从何而来,不知道有哪位能指点一下。
函数代码如下:
驱动程序中:
static int sbc2440_led_ioctl(
struct inode *inode,
struct file *file,
unsigned int cmd,
unsigned long arg)
{
printk("control receive command %d, %8x\n", cmd, arg);
switch(cmd) {
case 0:
case 1:
if (arg > 4) {
return -EINVAL;
}
s3c2410_gpio_setpin(led_table[arg], !cmd);
return 0;
default:
return -EINVAL;
}
}
应用程序的调用如下:
printf("ioctrl led_state = %d, led_no = %d, led_state address %8x\n", led_state, led_no, (unsigned long)(&led_no));
if( led_no < 4)
ioctl(fd_led, led_no, led_state);
应用程序运行后打印出来的信息如下:
ioctrl led_state = 1, led_no = 0, led_state address be838d30
control receive command 1, c019c1a4