From e99eac5e4ea3bd8671bb1cedad10c3fec90ec0de Mon Sep 17 00:00:00 2001
From: Seth Forshee <seth.forshee@canonical.com>
Date: Fri, 17 Aug 2012 11:17:02 -0500
Subject: vga_switcheroo: Don't require handler init callback
Git-commit: e99eac5e4ea3bd8671bb1cedad10c3fec90ec0de
Patch-mainline: v3.6-rc3

This callback is a no-op in nouveau, and the upcoming apple-gmux
switcheroo support won't require it either. Rather than forcing drivers
to stub it out, just make it optional and remove the callback from
nouveau.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
Acked-by: Michal Srb <msrb@suse.com>
---
 drivers/gpu/drm/nouveau/nouveau_acpi.c |    6 ------
 drivers/gpu/vga/vga_switcheroo.c       |    3 ++-
 2 files changed, 2 insertions(+), 7 deletions(-)

Index: linux-3.0-SLE11-SP3/drivers/gpu/drm/nouveau/nouveau_acpi.c
===================================================================
--- linux-3.0-SLE11-SP3.orig/drivers/gpu/drm/nouveau/nouveau_acpi.c
+++ linux-3.0-SLE11-SP3/drivers/gpu/drm/nouveau/nouveau_acpi.c
@@ -211,11 +211,6 @@ static int nouveau_dsm_power_state(enum
 	return nouveau_dsm_set_discrete_state(nouveau_dsm_priv.dhandle, state);
 }
 
-static int nouveau_dsm_init(void)
-{
-	return 0;
-}
-
 static int nouveau_dsm_get_client_id(struct pci_dev *pdev)
 {
 	/* easy option one - intel vendor ID means Integrated */
@@ -232,7 +227,6 @@ static int nouveau_dsm_get_client_id(str
 static struct vga_switcheroo_handler nouveau_dsm_handler = {
 	.switchto = nouveau_dsm_switchto,
 	.power_state = nouveau_dsm_power_state,
-	.init = nouveau_dsm_init,
 	.get_client_id = nouveau_dsm_get_client_id,
 };
 
Index: linux-3.0-SLE11-SP3/drivers/gpu/vga/vga_switcheroo.c
===================================================================
--- linux-3.0-SLE11-SP3.orig/drivers/gpu/vga/vga_switcheroo.c
+++ linux-3.0-SLE11-SP3/drivers/gpu/vga/vga_switcheroo.c
@@ -87,7 +87,8 @@ static void vga_switcheroo_enable(void)
 	int i;
 	int ret;
 	/* call the handler to init */
-	vgasr_priv.handler->init();
+	if (vgasr_priv.handler->init)
+		vgasr_priv.handler->init();
 
 	for (i = 0; i < VGA_SWITCHEROO_MAX_CLIENTS; i++) {
 		ret = vgasr_priv.handler->get_client_id(vgasr_priv.clients[i].pdev);
