linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: wait_for_completion_interruptible does not wait !! [During PM suspend]
@ 2010-06-20  7:42 Suresh Rajashekara
  2010-06-20  7:51 ` Jiri Slaby
  0 siblings, 1 reply; 2+ messages in thread
From: Suresh Rajashekara @ 2010-06-20  7:42 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: linux-omap, linux-pm, LKML

On Sun, Jun 20, 2010 at 12:23 AM, Jiri Slaby <jirislaby@gmail.com> wrote:
> On 06/20/2010 08:52 AM, Suresh Rajashekara wrote:
>> The ioctl waits on a completion variable (using
>> wait_for_completion_interruptible).
> ...
>> I tried wait_for_completion instead, but now the kernel refuses to suspend.
>
> Do you check return value of wait_for_completion_interruptible and
> return its value if nonzero?
>
> We need the code to comment, otherwise it's hard to say.

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-06-20  7:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-20  7:42 wait_for_completion_interruptible does not wait !! [During PM suspend] Suresh Rajashekara
2010-06-20  7:51 ` Jiri Slaby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).