Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753202AbdLNPOa (ORCPT ); Thu, 14 Dec 2017 10:14:30 -0500 Received: from mx2.suse.de ([195.135.220.15]:52110 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752811AbdLNPO0 (ORCPT ); Thu, 14 Dec 2017 10:14:26 -0500 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" From: Michal Suchanek To: Jens Axboe , Kate Stewart , John Stultz , Philippe Ombredanne , Greg Kroah-Hartman , Thomas Gleixner , Russell King , Michal Suchanek , linux-kernel@vger.kernel.org Subject: [PATCH 1/6] delay: add poll_event_interruptible Date: Thu, 14 Dec 2017 16:13:50 +0100 Message-Id: <81f6b33f5fc43d174bfc5786818ad88dcd872e93.1513263482.git.msuchanek@suse.de> X-Mailer: git-send-email 2.13.6 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 745 Lines: 31 Add convenience macro for polling an event that does not have a waitqueue. Signed-off-by: Michal Suchanek --- include/linux/delay.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/delay.h b/include/linux/delay.h index b78bab4395d8..3ae9fa395628 100644 --- a/include/linux/delay.h +++ b/include/linux/delay.h @@ -64,4 +64,16 @@ static inline void ssleep(unsigned int seconds) msleep(seconds * 1000); } +#define poll_event_interruptible(event, interval) ({ \ + int ret = 0; \ + while (!(event)) { \ + if (signal_pending(current)) { \ + ret = -ERESTARTSYS; \ + break; \ + } \ + msleep_interruptible(interval); \ + } \ + ret; \ +}) + #endif /* defined(_LINUX_DELAY_H) */ -- 2.13.6