Mulyadi Santosa wrote:
Hi...
Before going further, I believe this is on ARM architecture, right? OK,
not much I can suggest...however...
Ok so what functions should i use to synchronise my application with
the kernel module?
And when i call copy_to_user() and the user space pointer is invalid,
it should return a
negative value right (-EFAULT) and shouldnt give an unhandled page
fault.
Perhaps what Arjan suggest is, try to check whether it is awaken because
other code path wakes it or it is awaken by pending signal. In that
case, try non-interruptible variant.
regards,
Mulyadi
Thanks, yes its ARM architecture.
I changed the code to use wait_event_interruptible:
When there is an interrupt , i fill a Data array with data and do:
DataArrived = 1;
wake_up_interruptible(&WaitQueue);
My read function is:
static __u16 Data[650];
ssize_t EribRead (struct file *filp, char *buf, size_t count, loff_t *offp)
{
wait_event_interruptible(WaitQueue, DataArrived != 0);
if (signal_pending (current))
{
return -ERESTARTSYS;
}
DataArrived = 0;
if (copy_to_user(buf, (char*)&Data, sizeof(Data)))
{
return -EFAULT;
}
return 0;
}
should this work?
Chris.
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/