From patchwork Sun Feb 21 14:10:22 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 81015 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 o1LEC5gg030506 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 21 Feb 2010 14:12:41 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NjCWB-00085O-Nl; Sun, 21 Feb 2010 14:10:43 +0000 Received: from sfi-mx-1.v28.ch3.sourceforge.com ([172.29.28.121] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NjCWA-00085I-FC for dri-devel@lists.sourceforge.net; Sun, 21 Feb 2010 14:10:42 +0000 Received-SPF: pass (sfi-mx-1.v28.ch3.sourceforge.com: domain of gmail.com designates 209.85.220.222 as permitted sender) client-ip=209.85.220.222; envelope-from=zajec5@gmail.com; helo=mail-fx0-f222.google.com; Received: from mail-fx0-f222.google.com ([209.85.220.222]) by sfi-mx-1.v28.ch3.sourceforge.com with esmtp (Exim 4.69) id 1NjCW8-0005X3-59 for dri-devel@lists.sourceforge.net; Sun, 21 Feb 2010 14:10:42 +0000 Received: by fxm22 with SMTP id 22so1809926fxm.6 for ; Sun, 21 Feb 2010 06:10:34 -0800 (PST) Received: by 10.87.48.11 with SMTP id a11mr5773354fgk.36.1266761434126; Sun, 21 Feb 2010 06:10:34 -0800 (PST) Received: from localhost.localdomain (77-253-200-80.ip.netia.com.pl [77.253.200.80]) by mx.google.com with ESMTPS id 14sm976807fxm.5.2010.02.21.06.10.32 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 21 Feb 2010 06:10:33 -0800 (PST) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: Linux Kernel Mailing List , dri-devel@lists.sourceforge.net Subject: [PATCH][RFC] time: add wait_interruptible_timeout macro to sleep (w. timeout) until wake_up Date: Sun, 21 Feb 2010 15:10:22 +0100 Message-Id: <1266761422-2921-1-git-send-email-zajec5@gmail.com> X-Mailer: git-send-email 1.6.4.2 MIME-Version: 1.0 X-Spam-Score: -1.5 (-) 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 X-Headers-End: 1NjCW8-0005X3-59 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]); Sun, 21 Feb 2010 14:12:41 +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) \ do { \ DEFINE_WAIT(__wait); \