On Sun, Jun 20, 2010 at 12:23 AM, Jiri Slaby <jirislaby@gmail.com> wrote:
No. I am not checking the return value of the
wait_for_completion_interruptible. I can do it
The code is as follows. I have cut the relevant portion of the code
and pasted in to the email
My test application. The actual application is exactly similar (actual
application has different names)
<SNIP>
void *headset_detect_thread_start ( void *private_date )
{
int hs_fd = 0;
int iState = 0;
hs_fd = open("/dev/adc", O_RDWR);
if ( hs_fd == -1 ) {
printf("The headset device could not be opened\n");
goto hs_thread_exit;
}
for (;;) {
pthread_testcancel();
ioctl(hs_fd, IOCTL_CODEC_HEADSET_DETECT, &iState);
pthread_testcancel();
if ( iState )
printf("\n++++ Headset Insertion detected\n");
else
printf("\n---- Headset Removal detected\n");
SignalEvent(); // Dummy function, but the actual application
does inside the function
}
hs_thread_out:
close(hs_fd);
hs_thread_exit:
pthread_exit(NULL);
}
</SNIP>
Kernel Code:
/* Code from Ioctl of the codec driver*/
<SNIP>
case IOCTL_CODEC_HEADSET_DETECT:
headset_detect();
headset_detect_state = get_hsdetect_state();
copy_to_user( argp, &headset_detect_state, sizeof(int)) ;
break;
</SNIP>
implementation of headset_detect in the codec driver
<SNIP>
void headset_detect(void){
/* This variable is completed in interrupt handler */
wait_for_completion_interruptible(&drv_priv->headset_completion);
}
</SNIP>
Thanks,
Suresh
--