From patchwork Fri Feb 26 10:38:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 82303 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1QAeQn4021437 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 26 Feb 2010 10:41:02 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NkxbB-0004da-GY; Fri, 26 Feb 2010 10:39:09 +0000 Received: from sfi-mx-4.v28.ch3.sourceforge.com ([172.29.28.124] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1Nkxb8-0004dO-Qa for dri-devel@lists.sourceforge.net; Fri, 26 Feb 2010 10:39:06 +0000 Received-SPF: pass (sfi-mx-4.v28.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.47 as permitted sender) client-ip=74.125.82.47; envelope-from=zajec5@gmail.com; helo=mail-ww0-f47.google.com; Received: from mail-ww0-f47.google.com ([74.125.82.47]) by sfi-mx-4.v28.ch3.sourceforge.com with esmtp (Exim 4.69) id 1Nkxb7-0003dz-T1 for dri-devel@lists.sourceforge.net; Fri, 26 Feb 2010 10:39:06 +0000 Received: by wwb22 with SMTP id 22so2258527wwb.34 for ; Fri, 26 Feb 2010 02:38:59 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.87.79 with SMTP id x57mr241942wee.83.1267180739696; Fri, 26 Feb 2010 02:38:59 -0800 (PST) In-Reply-To: <1266761422-2921-1-git-send-email-zajec5@gmail.com> References: <1266761422-2921-1-git-send-email-zajec5@gmail.com> Date: Fri, 26 Feb 2010 11:38:59 +0100 Message-ID: Subject: Re: [PATCH][RFC] time: add wait_interruptible_timeout macro to sleep (w. timeout) until wake_up From: =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= To: Andrew Morton , Thomas Gleixner , Ingo Molnar , Linus Torvalds X-Spam-Score: -1.6 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record -0.0 DKIM_VERIFIED Domain Keys Identified Mail: signature passes verification 0.0 DKIM_SIGNED Domain Keys Identified Mail: message has a signature -0.1 AWL AWL: From: address is in the auto white-list X-Headers-End: 1Nkxb7-0003dz-T1 Cc: DRI , Linux Kernel Mailing List X-BeenThere: dri-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 26 Feb 2010 10:41:03 +0000 (UTC) diff --git a/include/linux/wait.h b/include/linux/wait.h index a48e16b..998475b 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h @@ -332,6 +332,31 @@ do {                         \        __ret;                                                          \  }) +/** + * wait_interruptible_timeout - sleep until a waitqueue is woken up + * @wq: the waitqueue to wait on + * @timeout: timeout, in jiffies + * + * The process is put to sleep (TASK_INTERRUPTIBLE) until the waitqueue + * @wq is woken up. It can be done manually with wake_up or will happen + * if timeout elapses. + * + * The function returns 0 if the @timeout elapsed, remaining jiffies + * if workqueue was waken up earlier. + */ +#define wait_interruptible_timeout(wq, timeout)          \ +({                                                                     \ +       long __ret = timeout;                                           \ +                                                                       \ +       DEFINE_WAIT(__wait);                                            \ +       prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE);              \ +       if (!signal_pending(current))                                   \ +               __ret = schedule_timeout(__ret);                        \ +       finish_wait(&wq, &__wait);                                      \ +                                                                       \ +       __ret;                                                          \ +}) +  #define __wait_event_interruptible_exclusive(wq, condition, ret)       \