hc
2024-05-16 8d2a02b24d66aa359e83eebc1ed3c0f85367a1cb
kernel/drivers/gpu/vga/vga_switcheroo.c
....@@ -35,6 +35,7 @@
3535 #include <linux/debugfs.h>
3636 #include <linux/fb.h>
3737 #include <linux/fs.h>
38
+#include <linux/fbcon.h>
3839 #include <linux/module.h>
3940 #include <linux/pci.h>
4041 #include <linux/pm_domain.h>
....@@ -133,7 +134,6 @@
133134 * @delayed_switch_active: whether a delayed switch is pending
134135 * @delayed_client_id: client to which a delayed switch is pending
135136 * @debugfs_root: directory for vga_switcheroo debugfs interface
136
- * @switch_file: file for vga_switcheroo debugfs interface
137137 * @registered_clients: number of registered GPUs
138138 * (counting only vga clients, not audio clients)
139139 * @clients: list of registered clients
....@@ -152,7 +152,6 @@
152152 enum vga_switcheroo_client_id delayed_client_id;
153153
154154 struct dentry *debugfs_root;
155
- struct dentry *switch_file;
156155
157156 int registered_clients;
158157 struct list_head clients;
....@@ -168,7 +167,7 @@
168167 #define client_is_vga(c) (!client_is_audio(c))
169168 #define client_id(c) ((c)->id & ~ID_BIT_AUDIO)
170169
171
-static int vga_switcheroo_debugfs_init(struct vgasr_priv *priv);
170
+static void vga_switcheroo_debugfs_init(struct vgasr_priv *priv);
172171 static void vga_switcheroo_debugfs_fini(struct vgasr_priv *priv);
173172
174173 /* only one switcheroo per system */
....@@ -736,14 +735,8 @@
736735 if (!active->driver_power_control)
737736 set_audio_state(active->id, VGA_SWITCHEROO_OFF);
738737
739
- if (new_client->fb_info) {
740
- struct fb_event event;
741
-
742
- console_lock();
743
- event.info = new_client->fb_info;
744
- fb_notifier_call_chain(FB_EVENT_REMAP_ALL_CONSOLE, &event);
745
- console_unlock();
746
- }
738
+ if (new_client->fb_info)
739
+ fbcon_remap_all(new_client->fb_info);
747740
748741 mutex_lock(&vgasr_priv.mux_hw_lock);
749742 ret = vgasr_priv.handler->switchto(new_client->id);
....@@ -914,38 +907,20 @@
914907
915908 static void vga_switcheroo_debugfs_fini(struct vgasr_priv *priv)
916909 {
917
- debugfs_remove(priv->switch_file);
918
- priv->switch_file = NULL;
919
-
920
- debugfs_remove(priv->debugfs_root);
910
+ debugfs_remove_recursive(priv->debugfs_root);
921911 priv->debugfs_root = NULL;
922912 }
923913
924
-static int vga_switcheroo_debugfs_init(struct vgasr_priv *priv)
914
+static void vga_switcheroo_debugfs_init(struct vgasr_priv *priv)
925915 {
926
- static const char mp[] = "/sys/kernel/debug";
927
-
928916 /* already initialised */
929917 if (priv->debugfs_root)
930
- return 0;
918
+ return;
919
+
931920 priv->debugfs_root = debugfs_create_dir("vgaswitcheroo", NULL);
932921
933
- if (!priv->debugfs_root) {
934
- pr_err("Cannot create %s/vgaswitcheroo\n", mp);
935
- goto fail;
936
- }
937
-
938
- priv->switch_file = debugfs_create_file("switch", 0644,
939
- priv->debugfs_root, NULL,
940
- &vga_switcheroo_debugfs_fops);
941
- if (!priv->switch_file) {
942
- pr_err("cannot create %s/vgaswitcheroo/switch\n", mp);
943
- goto fail;
944
- }
945
- return 0;
946
-fail:
947
- vga_switcheroo_debugfs_fini(priv);
948
- return -1;
922
+ debugfs_create_file("switch", 0644, priv->debugfs_root, NULL,
923
+ &vga_switcheroo_debugfs_fops);
949924 }
950925
951926 /**