From patchwork Thu Mar 28 12:04:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luis R. Rodriguez" X-Patchwork-Id: 2356281 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 85A4B3FD40 for ; Thu, 28 Mar 2013 12:06:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755479Ab3C1MGL (ORCPT ); Thu, 28 Mar 2013 08:06:11 -0400 Received: from mail-pd0-f177.google.com ([209.85.192.177]:53001 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755662Ab3C1MEu (ORCPT ); Thu, 28 Mar 2013 08:04:50 -0400 Received: by mail-pd0-f177.google.com with SMTP id y14so4025195pdi.22 for ; Thu, 28 Mar 2013 05:04:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=M67Js8oQHqa109PzVDVHsCq5rLpNdTjEj50iTemBB0I=; b=aqW/jzqj8CFevsZz0wU3LaTekwlUWvbyvAoK3rpoDTIGTZ+7Aw5NpUylYz6qafqboO jXaSLS5kWJ0TNkbaF24VEhM936XDPjB2fHer28KM4Ft4UbX508FHMaYfiJ9ztVlcPpeU lx2ZqrkAfyMFf5p4AVaTnZxtgILMp+HXg/9sFTUaFoYbNX2qiT+ee0sh1aL9nJcZc+xe NIVhVG/1Cm6s1/EHgbAX0tazTiDM8WqitCyBxIWnktn/44Errh+167Yu2mFEusbElh63 TQ43CkA0GogfuwBHFYUTxSR+YG6n///HWh0FfAk7SlP5dzN2MQ21MM6pkd+bfBVvGUhY eB2g== X-Received: by 10.68.225.40 with SMTP id rh8mr35447919pbc.137.1364472289815; Thu, 28 Mar 2013 05:04:49 -0700 (PDT) Received: from mcgrof@gmail.com (c-24-7-61-223.hsd1.ca.comcast.net. [24.7.61.223]) by mx.google.com with ESMTPS id eh5sm25313896pbc.44.2013.03.28.05.04.46 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 28 Mar 2013 05:04:48 -0700 (PDT) Received: by mcgrof@gmail.com (sSMTP sendmail emulation); Thu, 28 Mar 2013 05:04:43 -0700 From: "Luis R. Rodriguez" 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" Subject: [PATCH 2/4] compat: backport fb_info->skip_vt_switch using a static inline Date: Thu, 28 Mar 2013 05:04:28 -0700 Message-Id: <1364472270-9297-3-git-send-email-mcgrof@do-not-panic.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1364472270-9297-1-git-send-email-mcgrof@do-not-panic.com> References: <1364472270-9297-1-git-send-email-mcgrof@do-not-panic.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org From: "Luis R. Rodriguez" 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 Cc: Rodrigo Vivi Cc: Daniel Vetter Cc: Jesse Barnes Cc: Rafael J. Wysocki Signed-off-by: Luis R. Rodriguez --- 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 #include +#include #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 */