From patchwork Thu Sep 20 11:28:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Coelho X-Patchwork-Id: 10607517 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F9021508 for ; Thu, 20 Sep 2018 11:28:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F32D32D09B for ; Thu, 20 Sep 2018 11:28:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7BF32D0A8; Thu, 20 Sep 2018 11:28:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A07192D09B for ; Thu, 20 Sep 2018 11:28:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731100AbeITRLx (ORCPT ); Thu, 20 Sep 2018 13:11:53 -0400 Received: from paleale.coelho.fi ([176.9.41.70]:50954 "EHLO farmhouse.coelho.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727986AbeITRLw (ORCPT ); Thu, 20 Sep 2018 13:11:52 -0400 Received: from 91-156-4-241.elisa-laajakaista.fi ([91.156.4.241] helo=redipa.ger.corp.intel.com) by farmhouse.coelho.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.91) (envelope-from ) id 1g2x8b-0004SQ-AS; Thu, 20 Sep 2018 14:28:49 +0300 From: Luca Coelho To: backports@vger.kernel.org Cc: Shahar S Matityahu , Luca Coelho Date: Thu, 20 Sep 2018 14:28:30 +0300 Message-Id: <20180920112842.27198-3-luca@coelho.fi> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180920112842.27198-1-luca@coelho.fi> References: <20180920112842.27198-1-luca@coelho.fi> Subject: [PATCH 02/14] backports: add wait_event_killable_timeout backport support Sender: backports-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: backports@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Shahar S Matityahu Allow using wait_event_killable_timeout function in kernel older then 4.13 Signed-off-by: Shahar S Matityahu Signed-off-by: Luca Coelho --- backport/backport-include/linux/wait.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/backport/backport-include/linux/wait.h b/backport/backport-include/linux/wait.h index c4b1114e05ed..15a674cfe019 100644 --- a/backport/backport-include/linux/wait.h +++ b/backport/backport-include/linux/wait.h @@ -78,6 +78,21 @@ wait_on_bit_timeout(void *word, int bit, unsigned mode, unsigned long timeout) #if LINUX_VERSION_IS_LESS(4,13,0) #define wait_queue_entry_t wait_queue_t + +#define wait_event_killable_timeout(wq_head, condition, timeout) \ +({ \ + long __ret = timeout; \ + might_sleep(); \ + if (!___wait_cond_timeout(condition)) \ + __ret = __wait_event_killable_timeout(wq_head, \ + condition, timeout); \ + __ret; \ +}) + +#define __wait_event_killable_timeout(wq_head, condition, timeout) \ + ___wait_event(wq_head, ___wait_cond_timeout(condition), \ + TASK_KILLABLE, 0, timeout, \ + __ret = schedule_timeout(__ret)) #endif #endif /* __BACKPORT_LINUX_WAIT_H */