Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 340e01248478ba8b78a6d4d1809b1eff > files > 564

kvm-83-270.el5_11.src.rpm

From 6e48603a3fc24e1d7e3e8b76f5e54d4d96349dbb Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost@redhat.com>
Date: Mon, 27 Sep 2010 17:47:57 -0300
Subject: [PATCH 2/2] kmod: use native pci_get_bus_and_slot() if available

RH-Author: Eduardo Habkost <ehabkost@redhat.com>
Message-id: <1285609677-21847-3-git-send-email-ehabkost@redhat.com>
Patchwork-id: 12311
O-Subject: [RHEL-5.6 KVM PATCH 2/2] kmod: use native pci_get_bus_and_slot() if
	available
Bugzilla: 539642
RH-Acked-by: Zachary Amsden <zamsden@redhat.com>
RH-Acked-by: Don Dutile <ddutile@redhat.com>

Add build-time test on configure and use the function if it is available.

Bugzilla: 539642

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 configure                            |    7 +++++++
 kernel/Makefile                      |    2 +-
 kernel/external-module-compat-comm.h |   12 +++++++++++-
 kernel/external-module-compat.c      |    9 ++++++++-
 4 files changed, 27 insertions(+), 3 deletions(-)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 configure                            |    7 +++++++
 kernel/Makefile                      |    2 +-
 kernel/external-module-compat-comm.h |   12 +++++++++++-
 kernel/external-module-compat.c      |    9 ++++++++-
 4 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 853cb18..65af4ca 100755
--- a/configure
+++ b/configure
@@ -145,6 +145,12 @@ else
 	has_cancel_work_sync=0
 fi
 
+if grep -q -w pci_get_bus_and_slot "$kerneldir/include/linux/pci.h";then
+	has_pci_get_bus_and_slot=1
+else
+	has_pci_get_bus_and_slot=0
+fi
+
 
 #configure user dir
 (cd user; ./configure --prefix="$prefix" --kerneldir="$libkvm_kerneldir" \
@@ -182,4 +188,5 @@ EOF
 cat <<EOF > kernel/config.kbuild
 EXT_CONFIG_KVM_TRACE=$kvm_trace
 HAS_CANCEL_WORK_SYNC=$has_cancel_work_sync
+HAS_PCI_GET_BUS_AND_SLOT=$has_pci_get_bus_and_slot
 EOF
diff --git a/kernel/Makefile b/kernel/Makefile
index d47dedb..5277db9 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -38,7 +38,7 @@ ifeq ($(EXT_CONFIG_KVM_TRACE),y)
 module_defines += -DEXT_CONFIG_KVM_TRACE=y
 endif
 
-module_defines += -DHAS_CANCEL_WORK_SYNC=$(HAS_CANCEL_WORK_SYNC)
+module_defines += -DHAS_CANCEL_WORK_SYNC=$(HAS_CANCEL_WORK_SYNC) -DHAS_PCI_GET_BUS_AND_SLOT=$(HAS_PCI_GET_BUS_AND_SLOT)
 
 
 all:: header-link prerequisite
diff --git a/kernel/external-module-compat-comm.h b/kernel/external-module-compat-comm.h
index 7e4ba74..ae646cd 100644
--- a/kernel/external-module-compat-comm.h
+++ b/kernel/external-module-compat-comm.h
@@ -583,7 +583,17 @@ static inline int kvm_cancel_work_sync(struct work_struct *work)
 
 #endif
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+/* Later RHEL5 kernel versions have pci_get_bus_and_slot() available */
+#if HAS_PCI_GET_BUS_AND_SLOT
+
+#include <linux/pci.h>
+/* static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus,
+ *						   unsigned int devfn)
+ */
+
+#define kvm_pci_get_bus_and_slot pci_get_bus_and_slot
+
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
 
 struct pci_dev;
 
diff --git a/kernel/external-module-compat.c b/kernel/external-module-compat.c
index b838d4e..1e7355c 100644
--- a/kernel/external-module-compat.c
+++ b/kernel/external-module-compat.c
@@ -309,7 +309,14 @@ struct timespec kvm_ns_to_timespec(const s64 nsec)
 
 #endif
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+/* Later RHEL5 kernel versions have pci_get_bus_and_slot() available */
+#if HAS_PCI_GET_BUS_AND_SLOT
+
+/* static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus,
+ *						   unsigned int devfn)
+ */
+
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
 
 #include <linux/pci.h>
 
-- 
1.6.5.5