From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932190AbcFJJnl (ORCPT ); Fri, 10 Jun 2016 05:43:41 -0400 Received: from terminus.zytor.com ([198.137.202.10]:48804 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752885AbcFJJnh (ORCPT ); Fri, 10 Jun 2016 05:43:37 -0400 Date: Fri, 10 Jun 2016 02:43:22 -0700 From: tip-bot for Paul Bolle Message-ID: Cc: hpa@zytor.com, mingo@kernel.org, rusty@rustcorp.com.au, linux-kernel@vger.kernel.org, pebolle@tiscali.nl, tglx@linutronix.de Reply-To: tglx@linutronix.de, rusty@rustcorp.com.au, mingo@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org, pebolle@tiscali.nl In-Reply-To: <1457006501-5377-3-git-send-email-pebolle@tiscali.nl> References: <1457006501-5377-3-git-send-email-pebolle@tiscali.nl> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cleanups] lguest: Read offset of device_cap later Git-Commit-ID: cf2cf0f50c14e86e04cda2c684357eed77922666 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: cf2cf0f50c14e86e04cda2c684357eed77922666 Gitweb: http://git.kernel.org/tip/cf2cf0f50c14e86e04cda2c684357eed77922666 Author: Paul Bolle AuthorDate: Thu, 3 Mar 2016 13:01:41 +0100 Committer: Thomas Gleixner CommitDate: Fri, 10 Jun 2016 11:39:09 +0200 lguest: Read offset of device_cap later Read the offset of the capability with type VIRTIO_PCI_CAP_DEVICE_CFG only when we're sure we're going to need it. Which is when all checks have passed and we know we have a virtio console with an emerg_wr field. Signed-off-by: Paul Bolle Cc: Rusty Russell Cc: lguest@lists.ozlabs.org Link: http://lkml.kernel.org/r/1457006501-5377-3-git-send-email-pebolle@tiscali.nl Signed-off-by: Thomas Gleixner --- arch/x86/lguest/boot.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c index 146d11c..25da5bc8 100644 --- a/arch/x86/lguest/boot.c +++ b/arch/x86/lguest/boot.c @@ -1233,8 +1233,6 @@ static void write_bar_via_cfg(u32 cfg_offset, u32 off, u32 val) static void probe_pci_console(void) { u8 cap, common_cap = 0, device_cap = 0; - /* Offset within BAR0 */ - u32 device_offset; u32 device_len; /* Avoid recursive printk into here. */ @@ -1258,21 +1256,16 @@ static void probe_pci_console(void) u8 vndr = read_pci_config_byte(0, 1, 0, cap); if (vndr == PCI_CAP_ID_VNDR) { u8 type, bar; - u32 offset; type = read_pci_config_byte(0, 1, 0, cap + offsetof(struct virtio_pci_cap, cfg_type)); bar = read_pci_config_byte(0, 1, 0, cap + offsetof(struct virtio_pci_cap, bar)); - offset = read_pci_config(0, 1, 0, - cap + offsetof(struct virtio_pci_cap, offset)); switch (type) { case VIRTIO_PCI_CAP_DEVICE_CFG: - if (bar == 0) { + if (bar == 0) device_cap = cap; - device_offset = offset; - } break; case VIRTIO_PCI_CAP_PCI_CFG: console_access_cap = cap; @@ -1302,7 +1295,8 @@ static void probe_pci_console(void) return; } - console_cfg_offset = device_offset; + console_cfg_offset = read_pci_config(0, 1, 0, + device_cap + offsetof(struct virtio_pci_cap, offset)); printk(KERN_INFO "lguest: Console via virtio-pci emerg_wr\n"); }