Skip to contentSkip to conversation

compat: Define include guard for vga_switcheroo.h

PATCH Superseded Ozan Çağlayan 2 participants 4 messages Jun 21, 2012 – Jun 22, 2012

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 compat: Define include guard for vga_switcheroo.h

The check is missing in upstream. Patch sent but until this gets merged, define it in compat tree for fixing compat-drm builds.

Also add a temporary header with the same name which will be used to check whether the header should be included or not.

---
 include/linux/compat-3.5.h     |    6 ++++++
 include/linux/vga_switcheroo.h |    6 ++++++
 2 files changed, 12 insertions(+)
 create mode 100644 include/linux/vga_switcheroo.h
include/linux/compat-3.5.h +6 -0
index 74c8176..e999aee 100644
@@ -78,6 +78,12 @@ static inline int fault_in_multipages_readable(const char __user *uaddr,
 /* switcheroo is available on >= 2.6.34 */
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
 #include <linux/vga_switcheroo.h>
+
+/* FIXME: The include guard is sent upstream, drop this
+ * once the guard is merged. */
+#ifndef LINUX_VGA_SWITCHEROO_H
+#define LINUX_VGA_SWITCHEROO_H
+#endif
 /*
  * This backports:
  *
include/linux/vga_switcheroo.h new file +6 -0
new file mode 100644
index 0000000..26ac71d
@@ -0,0 +1,6 @@
+/* Hack for fixing the missing include guard in upstream
+ * header. We will drop this when the patch is merged upstream. */
+
+#ifndef LINUX_VGA_SWITCHEROO_H
+#include_next <linux/vga_switcheroo.h>
+#endif
Signature · 1 line
1.7.10.2
#1 lore raw
Quoted 18 lines · Ozan Çağlayan

The check is missing in upstream. Patch sent but until this gets merged, define it in compat tree for fixing compat-drm builds.

Also add a temporary header with the same name which will be used to check whether the header should be included or not.

---
 include/linux/compat-3.5.h     |    6 ++++++
 include/linux/vga_switcheroo.h |    6 ++++++

 2 files changed, 12 insertions(+)

 create mode 100644 include/linux/vga_switcheroo.h

include/linux/compat-3.5.h +0 -0
index 74c8176..e999aee 100644

include/linux/compat-3.5.h static inline int fault_in_multipages_readable(const char __user *uaddr, · line 86

Quoted 9 lines
include/linux/compat-3.5.h +6 -0
@@ -78,6 +78,12 @@ static inline int fault_in_multipages_readable(const char __user *uaddr,
  /* switcheroo is available on >= 2.6.34 */
  #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
  #include <linux/vga_switcheroo.h>
+
+/* FIXME: The include guard is sent upstream, drop this
+ * once the guard is merged. */
+#ifndef LINUX_VGA_SWITCHEROO_H
+#define LINUX_VGA_SWITCHEROO_H
+#endif

Don't you want this under the ifdef above?

include/linux/vga_switcheroo.h line 3

Quoted 12 lines
include/linux/compat-3.5.h +0 -0
  /*
  * This backports:
  *
include/linux/vga_switcheroo.h new file +3 -0
new file mode 100644
index 0000000..26ac71d
@@ -0,0 +1,6 @@
+/* Hack for fixing the missing include guard in upstream
+ * header. We will drop this when the patch is merged upstream. */
+

How about just adding this file but with something like this:

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
/*
* XXX: The include guard was sent upstream, drop this
* once the guard is merged.
*/
#ifndef LINUX_VGA_SWITCHEROO_H /* in case this gets upstream */ #include_next <linux/vga_switcheroo.h>
#ifndef LINUX_VGA_SWITCHEROO_H /* do not redefine once this gets upstream */ #define LINUX_VGA_SWITCHEROO_H
#endif /* case 1 LINUX_VGA_SWITCHEROO_H
#endif /* case 2 LINUX_VGA_SWITCHEROO_H
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) */

Luis

#2 lore raw
Quoted 14 lines

How about just adding this file but with something like this:

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
/*
 * XXX: The include guard was sent upstream, drop this
 * once the guard is merged.
 */
#ifndef LINUX_VGA_SWITCHEROO_H /* in case this gets upstream */ #include_next <linux/vga_switcheroo.h>
#ifndef LINUX_VGA_SWITCHEROO_H /* do not redefine once this gets upstream */ #define LINUX_VGA_SWITCHEROO_H
#endif /* case 1 LINUX_VGA_SWITCHEROO_H
#endif /* case 2 LINUX_VGA_SWITCHEROO_H
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) */

Ah, that is much clever, thanks.

I've tested in and it works correctly, will send a v3. But just to make clear: I'm just adding a vga_switcheroo.h with the above content and I don't touch compat-3.5.h right?

Signature · 1 line
Ozan Çağlayan
#3 lore raw
Quoted 15 lines · Ozan Çağlayan
Quoted 14 lines

How about just adding this file but with something like this:

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
/*
 * XXX: The include guard was sent upstream, drop this
 * once the guard is merged.
 */
#ifndef LINUX_VGA_SWITCHEROO_H /* in case this gets upstream */ #include_next <linux/vga_switcheroo.h>
#ifndef LINUX_VGA_SWITCHEROO_H /* do not redefine once this gets upstream */ #define LINUX_VGA_SWITCHEROO_H
#endif /* case 1 LINUX_VGA_SWITCHEROO_H
#endif /* case 2 LINUX_VGA_SWITCHEROO_H
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) */

Quoted 1 line

Ah, that is much clever, thanks.

No problem!

Quoted 3 lines

I've tested in and it works correctly, will send a v3. But just to make clear: I'm just adding a vga_switcheroo.h with the above content and I don't touch compat-3.5.h right?

Yeap.

Luis