From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
To: FlorianSchandinat@gmx.de
Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
jbarnes@virtuousgeek.org, backports@vger.kernel.org,
cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org,
julia.lawall@lip6.fr, rodrigo.vivi@gmail.com,
daniel.vetter@ffwll.ch, rafael.j.wysocki@intel.com,
"Luis R. Rodriguez" <mcgrof@do-not-panic.com>
Subject: [PATCH 2/4] compat: backport fb_info->skip_vt_switch using a static inline
Date: Thu, 28 Mar 2013 12:04:28 +0000 [thread overview]
Message-ID: <1364472270-9297-3-git-send-email-mcgrof@do-not-panic.com> (raw)
In-Reply-To: <1364472270-9297-1-git-send-email-mcgrof@do-not-panic.com>
From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
Commit 3cf2667 as of next-20130301 extended the struct fb_info
with a skip_vt_switch to allow drivers to skip the VT switch
at suspend/resume time. For older kernels we can skip this
as all this switch does is call pm_vt_switch_required() with true
or false depending on this new flag and later
pm_vt_switch_unregister() would not have been made.
compat-drivers was backporting this using #ifdef's but by
integrating a static inline we'd reduce the number of lines
to backport to just 1 line replacement. This would be something
like:
- info->skip_vt_switch = true;
+ fb_enable_skip_vt_switch(info);
For kernels >= 3.10 we'd set the attribute as we do upstream,
for older kernels this would be a no-op.
If this static inline would have been added upstream it would
have meant this collateral evolution would require just adding
a no-op static inline to backport, and no changes as the above
example hunk for every driver that requires the change.
If this static inline ends up upstream *now* it means we do *not*
require the type of hunk above for every driver that requires
the change.
All the code would be left intact !
This is a linux-next 'data structure element collateral evolution'.
Cc: cocci@systeme.lip6.fr
Cc: backports@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: Julia Lawall <julia.lawall@lip6.fr>
Cc: Rodrigo Vivi <rodrigo.vivi@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
include/linux/compat-3.10.h | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/include/linux/compat-3.10.h b/include/linux/compat-3.10.h
index 69ddc11..9abfc4b 100644
--- a/include/linux/compat-3.10.h
+++ b/include/linux/compat-3.10.h
@@ -7,6 +7,7 @@
#include <linux/scatterlist.h>
#include <linux/mm.h>
+#include <linux/fb.h>
#define sg_page_iter_page LINUX_BACKPORT(sg_page_iter_page)
/**
@@ -29,6 +30,46 @@ static inline dma_addr_t sg_page_iter_dma_address(struct sg_page_iter *piter)
return sg_dma_address(piter->sg) + (piter->sg_pgoffset << PAGE_SHIFT);
}
+/*
+ * This is a linux-next data structure element collateral evolution,
+ * we use a wrapper to avoid #ifdef hell to backport it. This allows
+ * us to use a simple fb_info_skip_vt_switch() replacement for when
+ * the new data structure element is used. If coccinelle SmPL grammar
+ * could be used to express the transformation for us on compat-drivers
+ * it means we'd need to express it only once. If the structure element
+ * collateral evolution were to be used *at development* time and we'd
+ * have a way to express the inverse through SmPL we'd be able to
+ * backport this collateral evolution automatically for any new driver
+ * that used it. We'd use coccinelle to look for it and do the
+ * transformations for us based on the original commit (maybe SmPL
+ * would be listed on the commit log.
+ *
+ * We may need the LINUX_BACKPORT() call that adds the backport_
+ * prefix for older kernels than 3.10 if distros decide to
+ * add this same static inline themselves (although unlikely).
+ */
+#define fb_enable_skip_vt_switch LINUX_BACKPORT(fb_enable_skip_vt_switch)
+static inline void fb_enable_skip_vt_switch(struct fb_info *info)
+{
+}
+
+#else /* kernel is >= 3.10 */
+/*
+ * We'd delete this upstream ever got this, we use our
+ * backport_ prefix with LINUX_BACKPORT() so that if this
+ * does get upstream we would not have to add another ifdef
+ * here for the kernels in between v3.10.. up to the point
+ * the routine would have gotten added, we'd just delete this
+ * #else condition completely. If we didn't have this and
+ * say 3.12 added the static inline upstream, we'd have a
+ * clash on the backport for 3.12 as the routine would
+ * already be defined *but* we'd need it for 3.11.
+ */
+#define fb_enable_skip_vt_switch LINUX_BACKPORT(fb_enable_skip_vt_switch)
+static inline void fb_enable_skip_vt_switch(struct fb_info *info)
+{
+ info->skip_vt_switch = true;
+}
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) */
#endif /* LINUX_3_10_COMPAT_H */
--
1.7.10.4
next prev parent reply other threads:[~2013-03-28 12:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-28 12:04 [PATCH] compat/compat-drivers/linux-next: fb skip_vt_switch Luis R. Rodriguez
2013-03-28 12:04 ` [PATCH 1/4] compat-drivers: backport fb_info->skip_vt_switch using ifdefs Luis R. Rodriguez
2013-03-28 12:04 ` Luis R. Rodriguez [this message]
2013-03-28 12:04 ` [PATCH 3/4] compat-drivers: simplify backport fb_info->skip_vt_switch CE Luis R. Rodriguez
2013-03-28 12:04 ` [PATCH 4/4] fb: add helpers to enable and test for the skip_vt_switch Luis R. Rodriguez
2013-03-28 15:39 ` [PATCH] compat/compat-drivers/linux-next: fb skip_vt_switch Jesse Barnes
2013-03-28 16:19 ` Julia Lawall
2013-03-28 18:05 ` Luis R. Rodriguez
2013-03-28 18:10 ` Julia Lawall
2013-03-28 18:25 ` Luis R. Rodriguez
2013-03-28 22:29 ` Julia Lawall
2013-03-28 23:25 ` Luis R. Rodriguez
2013-03-29 6:21 ` Julia Lawall
2013-03-29 7:29 ` Luis R. Rodriguez
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=1364472270-9297-3-git-send-email-mcgrof@do-not-panic.com \
--to=mcgrof@do-not-panic.com \
--cc=FlorianSchandinat@gmx.de \
--cc=backports@vger.kernel.org \
--cc=cocci@systeme.lip6.fr \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=jbarnes@virtuousgeek.org \
--cc=julia.lawall@lip6.fr \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=rodrigo.vivi@gmail.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;
as well as URLs for NNTP newsgroup(s).