From 6712259efa4531d46aafb7ec42e1863c2c2eeb59 Mon Sep 17 00:00:00 2001
From: "Luis R. Rodriguez" <mcgrof@frijolero.org>
Date: Thu, 28 Jun 2012 12:30:54 -0700
Subject: [PATCH] compat: backport vga_switcheroo_client_ops addition

This backports this commit:

commit 26ec685ff9d9c16525d8ec4c97e52fcdb187b302
Author: Takashi Iwai <tiwai@suse.de>
Date:   Fri May 11 07:51:17 2012 +0200

    vga_switcheroo: Introduce struct vga_switcheroo_client_ops

    This changes the API as a clean-up.  Instead of passing multiple
    function pointers at each time, introduce a new struct holding the
    whole callback functions and pass it to the registration.

    The same struct will be used for the upcoming audio client
    registration, too.

    Signed-off-by: Takashi Iwai <tiwai@suse.de>

mcgrof@tux ~/linux-stable (git::master)$ git describe --contains 26ec685
v3.5-rc1~83^2~6

Signed-off-by: Luis R. Rodriguez <mcgrof@frijolero.org>
---
 compat/Makefile                |    1 +
 compat/compat-3.5.c            |   20 ++++++++++++++++++++
 include/linux/compat-3.5.h     |    3 +++
 include/linux/vga_switcheroo.h |    7 +++++++
 4 files changed, 31 insertions(+)
 create mode 100644 compat/compat-3.5.c

diff --git a/compat/Makefile b/compat/Makefile
index c661f5d..08b5fd7 100644
--- a/compat/Makefile
+++ b/compat/Makefile
@@ -43,6 +43,7 @@ compat-$(CONFIG_COMPAT_KERNEL_3_3) += \
 	compat-3.3.o \
 	flow_dissector.o
 compat-$(CONFIG_COMPAT_KERNEL_3_4) += compat-3.4.o
+compat-$(CONFIG_COMPAT_KERNEL_3_5) += compat-3.5.o
 
 compat-$(CONFIG_COMPAT_CORDIC) += cordic.o
 compat-$(CONFIG_COMPAT_CRC8) += crc8.o
diff --git a/compat/compat-3.5.c b/compat/compat-3.5.c
new file mode 100644
index 0000000..2daa222
--- /dev/null
+++ b/compat/compat-3.5.c
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2012  Luis R. Rodriguez <mcgrof@frijolero.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Compatibility file for Linux wireless for kernels 3.5.
+ */
+
+#include <linux/vga_switcheroo.h>
+
+int compat_vga_switcheroo_register_client(struct pci_dev *dev,
+					  const struct vga_switcheroo_client_ops *ops)
+{
+	return vga_switcheroo_register_client(dev,
+					      ops->set_gpu_state,
+					      ops->can_switch);
+}
+EXPORT_SYMBOL_GPL(compat_vga_switcheroo_register_client);
diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h
index 74c8176..857aff7 100644
--- a/include/linux/compat-3.5.h
+++ b/include/linux/compat-3.5.h
@@ -8,6 +8,9 @@
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
 
+#define vga_switcheroo_register_client(_dev, _ops) \
+	compat_vga_switcheroo_register_client(_dev, _ops)
+
 /*
  * This backports:
  *
diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
index 4bda17b..0e4775a 100644
--- a/include/linux/vga_switcheroo.h
+++ b/include/linux/vga_switcheroo.h
@@ -9,4 +9,11 @@
 #define LINUX_VGA_SWITCHEROO_H
 #endif /* case 1 LINUX_VGA_SWITCHEROO_H */
 #endif /* case 2 LINUX_VGA_SWITCHEROO_H */
+
+struct vga_switcheroo_client_ops {
+	void (*set_gpu_state)(struct pci_dev *dev, enum vga_switcheroo_state);
+	void (*reprobe)(struct pci_dev *dev);
+	bool (*can_switch)(struct pci_dev *dev);
+};
+
 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) */
-- 
1.7.10.rc1.22.gf5241

