From: Daniel Vetter <daniel@ffwll.ch>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Yisheng Xie <ysxie@foxmail.com>,
b.zolnierkie@samsung.com, keescook@chromium.org,
j.w.r.degoede@gmail.com, david@lechnology.com,
linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] fbcon: introduce for_each_registered_fb() helper
Date: Mon, 2 Jul 2018 09:30:28 +0200 [thread overview]
Message-ID: <20180702073028.GZ13978@phenom.ffwll.local> (raw)
In-Reply-To: <ffe03b382ee84dbef8567b7377b929e4a8d6c23c.camel@linux.intel.com>
On Fri, Jun 29, 2018 at 07:20:13PM +0300, Andy Shevchenko wrote:
> On Fri, 2018-06-29 at 00:20 +0800, Yisheng Xie wrote:
> > Following pattern is often used:
> >
> > for (i = 0; i < FB_MAX; i++) {
> > if (registered_fb[i]) {
> > ...
> > }
> > }
> >
> > Therefore, as Andy's suggestion, for_each_registered_fb() helper can
>
> Suggested-by then ?
>
> > be introduced to make the code easier to read and write by reducing
> > indentation level. It also saves few lines of code in each occurrence.
> >
> > This patch convert all part here at the same time.
>
> LGTM except macro implementation. That's why I have mentioned
> for_each_pci_bridge() to look at.
>
> > +#define for_each_registered_fb(i) \
> > + for (i = 0; i < FB_MAX; i++) \
> > + if (registered_fb[i])
> > +
>
> This needs to be protected against nested conditionals.
> Otherwise compiler issues a warning and even may generate wrong code.
See for_each_if() in include/drm/drmP.h ... we should probably lift that
into a general header. The for_each_if() is used all over drm in iterator
macros, exactly to avoid surprises.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
next prev parent reply other threads:[~2018-07-02 7:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-28 16:20 Yisheng Xie
2018-06-28 18:50 ` Hans de Goede
2018-06-29 16:20 ` Andy Shevchenko
2018-07-02 7:30 ` Daniel Vetter [this message]
2018-07-02 10:06 ` Andy Shevchenko
2018-07-02 7:36 ` Bernd Petrovitsch
2018-07-02 10:15 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180702073028.GZ13978@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=andriy.shevchenko@linux.intel.com \
--cc=b.zolnierkie@samsung.com \
--cc=david@lechnology.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=j.w.r.degoede@gmail.com \
--cc=keescook@chromium.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ysxie@foxmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome