I want to implement an 8ms delay in my driver code. I used the
Код: Выделить всё
msleep
Код: Выделить всё
dmesg
a part of
Код: Выделить всё
dmesg
Код: Выделить всё
[ 386.199343] this is ioctl [ 386.199359] ioctl value = 0 [ 386.210085] ioctl value = 1
Код: Выделить всё
ioctl
Код: Выделить всё
static long spiio_drv_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { int i = 0; int value = 0; int *param = (int *)arg; printk("this is ioctl\n"); switch (cmd) { case 0: /*no sleep*/ *param = 0; case 1: /*SPIIO_IOCTL_CMD*/ do { value = gpio_get_value(spiio_gpio); printk("ioctl value = %d\n", value); if (value == 1) { return 1; } else { if (*param) { msleep(1); } i ++; } } while(i < *param); break; default: printk("spiio ioctrl cmd %d is error", cmd); return -1; } return 0; }
Источник: https://stackoverflow.com/questions/781 ... t-accurate