diff options
author | Takashi Iwai <tiwai@suse.de> | 2012-05-11 07:51:17 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2012-05-13 11:24:09 +0200 |
commit | 26ec685ff9d9c16525d8ec4c97e52fcdb187b302 (patch) | |
tree | 2536e4fd8fc9b41736c481822fb032a4e4efc81a /drivers/gpu/vga | |
parent | 79721e0a91b5e8f662f12eeb50ea205c761e6bf8 (diff) | |
download | linux-stable-26ec685ff9d9c16525d8ec4c97e52fcdb187b302.tar.gz linux-stable-26ec685ff9d9c16525d8ec4c97e52fcdb187b302.tar.bz2 linux-stable-26ec685ff9d9c16525d8ec4c97e52fcdb187b302.zip |
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>
Diffstat (limited to 'drivers/gpu/vga')
-rw-r--r-- | drivers/gpu/vga/vga_switcheroo.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c index da29da6aadac..a049b743cad0 100644 --- a/drivers/gpu/vga/vga_switcheroo.c +++ b/drivers/gpu/vga/vga_switcheroo.c @@ -34,9 +34,7 @@ struct vga_switcheroo_client { struct pci_dev *pdev; struct fb_info *fb_info; int pwr_state; - void (*set_gpu_state)(struct pci_dev *pdev, enum vga_switcheroo_state); - void (*reprobe)(struct pci_dev *pdev); - bool (*can_switch)(struct pci_dev *pdev); + const struct vga_switcheroo_client_ops *ops; int id; bool active; struct list_head list; @@ -109,9 +107,7 @@ static void vga_switcheroo_enable(void) } int vga_switcheroo_register_client(struct pci_dev *pdev, - void (*set_gpu_state)(struct pci_dev *pdev, enum vga_switcheroo_state), - void (*reprobe)(struct pci_dev *pdev), - bool (*can_switch)(struct pci_dev *pdev)) + const struct vga_switcheroo_client_ops *ops) { struct vga_switcheroo_client *client; @@ -121,9 +117,7 @@ int vga_switcheroo_register_client(struct pci_dev *pdev, client->pwr_state = VGA_SWITCHEROO_ON; client->pdev = pdev; - client->set_gpu_state = set_gpu_state; - client->reprobe = reprobe; - client->can_switch = can_switch; + client->ops = ops; client->id = -1; if (pdev == vga_default_device()) client->active = true; @@ -230,7 +224,7 @@ static int vga_switchon(struct vga_switcheroo_client *client) 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->ops->set_gpu_state(client->pdev, VGA_SWITCHEROO_ON); client->pwr_state = VGA_SWITCHEROO_ON; return 0; } @@ -238,7 +232,7 @@ static int vga_switchon(struct vga_switcheroo_client *client) 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); + client->ops->set_gpu_state(client->pdev, 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; @@ -284,8 +278,8 @@ static int vga_switchto_stage2(struct vga_switcheroo_client *new_client) if (ret) return ret; - if (new_client->reprobe) - new_client->reprobe(new_client->pdev); + if (new_client->ops->reprobe) + new_client->ops->reprobe(new_client->pdev); if (active->pwr_state == VGA_SWITCHEROO_ON) vga_switchoff(active); @@ -299,7 +293,7 @@ static bool check_can_switch(void) struct vga_switcheroo_client *client; list_for_each_entry(client, &vgasr_priv.clients, list) { - if (!client->can_switch(client->pdev)) { + if (!client->ops->can_switch(client->pdev)) { printk(KERN_ERR "vga_switcheroo: client %x refused switch\n", client->id); return false; } |