From patchwork Mon Jul 9 08:36:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 10513875 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4A871600CA for ; Mon, 9 Jul 2018 08:37:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 353FB22362 for ; Mon, 9 Jul 2018 08:37:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E1B726CFC; Mon, 9 Jul 2018 08:37:04 +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=-5.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A7B3922362 for ; Mon, 9 Jul 2018 08:37:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 34C7F6E3D3; Mon, 9 Jul 2018 08:37:01 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by gabe.freedesktop.org (Postfix) with ESMTPS id 30ACB6E3CF for ; Mon, 9 Jul 2018 08:36:59 +0000 (UTC) Received: by mail-ed1-x544.google.com with SMTP id i20-v6so252431eds.12 for ; Mon, 09 Jul 2018 01:36:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Vu9RzlEPJntTQyrENRstLjpgmV5d//jzsaPCvZv1jcQ=; b=mDfIoUNLU8ZeOVACXhBTOYjpJ6OTnfngYcIaR1j8cEt2j1KIo8SSpoqCvz11D/vjPy BEslx+eQp0VbVgPJ2RslH6fXpqgJw4h2Bz+hdLjopjLQ8ZZdEEglZHDwiIiHtM+Yy/7P 9VcSdKGxVtaYEr1Rs3TTbBdgPmr+3uhOf+rfZwwM3KgzvTn/c0eU5IJyWwn4sIVJhgLm OuQ8kdeL1Tw1pK/LwEDapgFoeHmNqg5J1w57nbGwgQaoY/XnHgc+sWSRmGreW4ugKEMJ RRmlt5FDDM0ta3ySBZ6kb5ytAaK0DgU3PKrc3hR6X/X9Ts1Z58iCCQ0R/bFMhWqmODeF +TZg== X-Gm-Message-State: AOUpUlGa0VXOgcsKAdfLYdsSxlXmRFD9JtNHSckxWKD0m5vldNcaQTNz VO6AV7IaaLL26CU1o7dlJashcw== X-Google-Smtp-Source: AAOMgpf2l+vzXSm3p3DW3YtgR6sMwOacQB+bee96eD1s26xAU5o2rRZMcuK16Qk17hdGHvis++8BKQ== X-Received: by 2002:a50:d313:: with SMTP id g19-v6mr8089623edh.119.1531125417849; Mon, 09 Jul 2018 01:36:57 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:5628:0:496f:7dc5:66d7:a057]) by smtp.gmail.com with ESMTPSA id 8-v6sm340067edv.77.2018.07.09.01.36.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jul 2018 01:36:57 -0700 (PDT) From: Daniel Vetter To: LKML Date: Mon, 9 Jul 2018 10:36:39 +0200 Message-Id: <20180709083650.23549-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.18.0 Subject: [Intel-gfx] [PATCH 01/12] kernel.h: Add for_each_if() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kees Cook , Greg Kroah-Hartman , David Airlie , Intel Graphics Development , Randy Dunlap , NeilBrown , DRI Development , Yisheng Xie , Stefan Agner , Daniel Vetter , Wei Wang , Daniel Vetter , Andrew Morton , Andy Shevchenko , Ingo Molnar , Andrei Vagin MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP To avoid compilers complainig about ambigious else blocks when putting an if condition into a for_each macro one needs to invert the condition and add a dummy else. We have a nice little convenience macro for that in drm headers, let's move it out. Subsequent patches will roll it out to other places. Motivated by a discussion with Andy and Yisheng, who want to add another for_each_macro which would benefit from for_each_if() instead of hand-rolling it. Signed-off-by: Daniel Vetter Cc: Gustavo Padovan Cc: Maarten Lankhorst Cc: Sean Paul Cc: David Airlie Cc: Andrew Morton Cc: Kees Cook Cc: Ingo Molnar Cc: Greg Kroah-Hartman Cc: NeilBrown Cc: Wei Wang Cc: Stefan Agner Cc: Andrei Vagin Cc: Randy Dunlap Cc: Andy Shevchenko Cc: Yisheng Xie Reviewed-by: Andy Shevchenko --- include/drm/drmP.h | 3 --- include/linux/kernel.h | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/drm/drmP.h b/include/drm/drmP.h index f7a19c2a7a80..05350424a4d3 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -110,7 +110,4 @@ static inline bool drm_can_sleep(void) return true; } -/* helper for handling conditionals in various for_each macros */ -#define for_each_if(condition) if (!(condition)) {} else - #endif diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 941dc0a5a877..4cb95ab9a5bc 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -71,6 +71,9 @@ */ #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) +/* helper for handling conditionals in various for_each macros */ +#define for_each_if(condition) if (!(condition)) {} else + #define u64_to_user_ptr(x) ( \ { \ typecheck(u64, x); \