vga_switcheroo: make power switch handler optional
authorDave Airlie <airlied@redhat.com>
Mon, 6 Dec 2010 02:31:50 +0000 (12:31 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 5 Jan 2011 03:43:05 +0000 (13:43 +1000)
At least on the nvidia mux the power switch seems to be executed
by the ACPI PS0/PS3 methods so need to do it explicitly.

Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/vga/vga_switcheroo.c

index 0a8678fe4d64172cee6274a02b5c621bc6552316..c3c213b74478bc9281a0f1db0814c6afa2691b42 100644 (file)
@@ -191,9 +191,8 @@ static int vga_switcheroo_debugfs_open(struct inode *inode, struct file *file)
 
 static int vga_switchon(struct vga_switcheroo_client *client)
 {
-       int ret;
-
-       ret = vgasr_priv.handler->power_state(client->id, VGA_SWITCHEROO_ON);
+       if (vgasr_priv.handler->power_state)
+               vgasr_priv.handler->power_state(client->id, VGA_SWITCHEROO_ON);
        /* call the driver callback to turn on device */
        client->set_gpu_state(client->pdev, VGA_SWITCHEROO_ON);
        client->pwr_state = VGA_SWITCHEROO_ON;
@@ -204,7 +203,8 @@ static int vga_switchoff(struct vga_switcheroo_client *client)
 {
        /* call the driver callback to turn off device */
        client->set_gpu_state(client->pdev, VGA_SWITCHEROO_OFF);
-       vgasr_priv.handler->power_state(client->id, VGA_SWITCHEROO_OFF);
+       if (vgasr_priv.handler->power_state)
+               vgasr_priv.handler->power_state(client->id, VGA_SWITCHEROO_OFF);
        client->pwr_state = VGA_SWITCHEROO_OFF;
        return 0;
 }