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: 10513873 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 499A1600CA for ; Mon, 9 Jul 2018 08:37:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2907222362 for ; Mon, 9 Jul 2018 08:37:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BC3426256; Mon, 9 Jul 2018 08:37:02 +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=ham 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 5475622362 for ; Mon, 9 Jul 2018 08:37:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 33EF46E3CF; Mon, 9 Jul 2018 08:37:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@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 30B3F6E3D3 for ; Mon, 9 Jul 2018 08:36:59 +0000 (UTC) Received: by mail-ed1-x544.google.com with SMTP id v22-v6so13271669edq.4 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=Mt5z6WtNJ4XGNZP8F/Xc6briNC0s2NYk7mSY/ekwlxBvHcEA4h2rRxPxlh9fy51YX3 daXYu7QXlRh3femWXE80ExzOl1QtA+NLJudfTLk/f8qqFN69H6TgiICUS8Zg2XfdTjf0 j7aDwcXb5ePqDMsczG3e0zh7obrVw+3QFDtZVZ+NSGDanHhefHeTb2wKIAp5zs/xegbB EXLGrN7mnh9P2Ph7Jlhv37i0B2LxiZbBVfNuBbpQOngmjG0DAvwkBHQFTNzsa3ReKKhL Xyp71+gFu5uA9rQv+Vk/C5vZ99cVvu8IhTF/6frr7cX4DeveCx5iqVdyhNZsSvPNJ9Nt 45Gw== X-Gm-Message-State: AOUpUlHgLy2ArlRliSPDVw/i4beQL3oSw7bGr4bcGAgvFVRcIMAPqtxk ukNFlF0ad+M1/ob5j5x5nQZYbg== 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 Subject: [PATCH 01/12] kernel.h: Add for_each_if() 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - 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 , Daniel Vetter , Wei Wang , Daniel Vetter , Andrew Morton , Andy Shevchenko , Ingo Molnar , Andrei Vagin MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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); \