All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: dri-devel@lists.freedesktop.org
Subject: [PATCH 07/15] vga_switcheroo: Use VGA_SWITCHEROO_UNKNOWN_ID instead of -1
Date: Fri, 28 Aug 2015 13:30:32 +0200	[thread overview]
Message-ID: <2e9c65e41511618ae183ecaa8b4eaa68c272a48d.1442497843.git.lukas@wunner.de> (raw)
In-Reply-To: <68e94f9e8066291430e6b5134284a965498bc8e9.1442497843.git.lukas@wunner.de>

Signed-off-by: Lukas Wunner <lukas@wunner.de>
---
 drivers/gpu/vga/vga_switcheroo.c | 17 +++++++++--------
 include/linux/vga_switcheroo.h   |  4 ++++
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
index 7b53246..bbd0a8e 100644
--- a/drivers/gpu/vga/vga_switcheroo.c
+++ b/drivers/gpu/vga/vga_switcheroo.c
@@ -86,9 +86,9 @@
  * @fb_info: framebuffer to which console is remapped on switching
  * @pwr_state: current power state
  * @ops: client callbacks
- * @id: client identifier, see enum vga_switcheroo_client_id.
- * 	Determining the id requires the handler, so GPUs are initially
- * 	assigned -1 and later given their true id in vga_switcheroo_enable()
+ * @id: client identifier. Determining the id requires the handler,
+ * 	so gpus are initially assigned VGA_SWITCHEROO_UNKNOWN_ID
+ * 	and later given their true id in vga_switcheroo_enable()
  * @active: whether the outputs are currently switched to this client
  * @driver_power_control: whether power state is controlled by the driver's
  * 	runtime pm. If true, writing ON and OFF to the vga_switcheroo debugfs
@@ -147,7 +147,8 @@ struct vgasr_priv {
 
 #define ID_BIT_AUDIO		0x100
 #define client_is_audio(c)	((c)->id & ID_BIT_AUDIO)
-#define client_is_vga(c)	((c)->id == -1 || !client_is_audio(c))
+#define client_is_vga(c)	((c)->id == VGA_SWITCHEROO_UNKNOWN_ID || \
+				 !client_is_audio(c))
 #define client_id(c)		((c)->id & ~ID_BIT_AUDIO)
 
 static int vga_switcheroo_debugfs_init(struct vgasr_priv *priv);
@@ -175,7 +176,7 @@ static void vga_switcheroo_enable(void)
 		vgasr_priv.handler->init();
 
 	list_for_each_entry(client, &vgasr_priv.clients, list) {
-		if (client->id != -1)
+		if (client->id != VGA_SWITCHEROO_UNKNOWN_ID)
 			continue;
 		ret = vgasr_priv.handler->get_client_id(client->pdev);
 		if (ret < 0)
@@ -279,7 +280,7 @@ int vga_switcheroo_register_client(struct pci_dev *pdev,
 				   const struct vga_switcheroo_client_ops *ops,
 				   bool driver_power_control)
 {
-	return register_client(pdev, ops, -1,
+	return register_client(pdev, ops, VGA_SWITCHEROO_UNKNOWN_ID,
 			       pdev == vga_default_device(),
 			       driver_power_control);
 }
@@ -583,7 +584,7 @@ vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf,
 	int ret;
 	bool delay = false, can_switch;
 	bool just_mux = false;
-	int client_id = -1;
+	int client_id = VGA_SWITCHEROO_UNKNOWN_ID;
 	struct vga_switcheroo_client *client = NULL;
 
 	if (cnt > 63)
@@ -652,7 +653,7 @@ vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf,
 		client_id = VGA_SWITCHEROO_DIS;
 	}
 
-	if (client_id == -1)
+	if (client_id == VGA_SWITCHEROO_UNKNOWN_ID)
 		goto out;
 	client = find_client_from_id(&vgasr_priv.clients, client_id);
 	if (!client)
diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
index 219876e..664dca5 100644
--- a/include/linux/vga_switcheroo.h
+++ b/include/linux/vga_switcheroo.h
@@ -54,6 +54,9 @@ enum vga_switcheroo_state {
 
 /**
  * enum vga_switcheroo_client_id - client identifier
+ * @VGA_SWITCHEROO_UNKNOWN_ID: initial identifier assigned to vga clients.
+ * 	Determining the id requires the handler, so GPUs are given their
+ * 	true id in a delayed fashion in vga_switcheroo_enable()
  * @VGA_SWITCHEROO_IGD: integrated graphics device
  * @VGA_SWITCHEROO_DIS: discrete graphics device
  * @VGA_SWITCHEROO_MAX_CLIENTS: currently no more than two GPUs are supported
@@ -61,6 +64,7 @@ enum vga_switcheroo_state {
  * Client identifier. Audio clients use the same identifier & 0x100.
  */
 enum vga_switcheroo_client_id {
+	VGA_SWITCHEROO_UNKNOWN_ID = -1,
 	VGA_SWITCHEROO_IGD,
 	VGA_SWITCHEROO_DIS,
 	VGA_SWITCHEROO_MAX_CLIENTS,
-- 
1.8.5.2 (Apple Git-48)

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2015-09-17 15:30 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-23 13:18 [PATCH 01/15] vga_switcheroo: Document _ALL_ the things! Lukas Wunner
2015-08-29 12:29 ` [PATCH 02/15] DocBook: Add vga_switcheroo Subsystem Guide Lukas Wunner
2015-08-27 14:43   ` [PATCH 03/15] vga_switcheroo: Set active attribute to false for audio clients Lukas Wunner
2015-08-23 21:23     ` [PATCH 04/15] vga_switcheroo: Add missing locking Lukas Wunner
2015-09-08 12:17       ` [PATCH 05/15] vga_switcheroo: Drop client power state VGA_SWITCHEROO_INIT Lukas Wunner
2015-08-28  9:56         ` [PATCH 06/15] vga_switcheroo: Use enum vga_switcheroo_state instead of int Lukas Wunner
2015-08-28 11:30           ` Lukas Wunner [this message]
2015-08-28 10:54             ` [PATCH 08/15] vga_switcheroo: Use enum vga_switcheroo_client_id " Lukas Wunner
2015-09-05 11:40               ` [PATCH 09/15] vga_switcheroo: Sort headers alphabetically Lukas Wunner
2015-09-04 18:49                 ` [PATCH 10/15] ALSA: hda - Spell vga_switcheroo consistently Lukas Wunner
2015-09-04 19:06                   ` [PATCH 11/15] drm/i915: " Lukas Wunner
2015-09-05  9:09                     ` [PATCH 12/15] drm/nouveau: " Lukas Wunner
2015-09-05  9:14                       ` [PATCH 13/15] drm/radeon: " Lukas Wunner
2015-09-05  9:17                         ` [PATCH 14/15] drm/amdgpu: " Lukas Wunner
2015-09-05  9:22                           ` [PATCH 15/15] drm: " Lukas Wunner
2015-09-22  9:20                             ` Daniel Vetter
2015-09-23 21:45                           ` [PATCH 14/15] drm/amdgpu: " Alex Deucher
2015-09-22  9:20                     ` [PATCH 11/15] drm/i915: " Daniel Vetter
2015-10-02  7:35           ` [PATCH 06/15] vga_switcheroo: Use enum vga_switcheroo_state instead of int Jani Nikula
2015-10-02  8:22         ` [PATCH 05/15] vga_switcheroo: Drop client power state VGA_SWITCHEROO_INIT Daniel Vetter
2015-10-25 18:19           ` Lukas Wunner
2015-10-26  7:24             ` Takashi Iwai
2015-08-27 14:43     ` [PATCH v1.1 03/15] vga_switcheroo: Set active attribute to false for audio clients Lukas Wunner
2015-09-23  7:13       ` Daniel Vetter
2015-09-24  9:40         ` Takashi Iwai
2015-09-24 15:13           ` Daniel Vetter
2015-10-01 16:19             ` Lukas Wunner
2015-09-24  9:37       ` Takashi Iwai
2015-09-17 17:15     ` [PATCH " Lukas Wunner
2015-09-22  9:17       ` Daniel Vetter
2015-09-19 16:44     ` Takashi Iwai
2015-09-19 17:50       ` Lukas Wunner
2015-09-24  9:39         ` Takashi Iwai
2015-09-22  8:38   ` [PATCH 02/15] DocBook: Add vga_switcheroo Subsystem Guide Daniel Vetter
2015-09-17 16:34 ` [PATCH 01/15] vga_switcheroo: Document _ALL_ the things! Danilo Cesar Lemes de Paula
2015-09-17 17:31   ` Lukas Wunner
2015-09-17 17:56     ` Danilo Cesar Lemes de Paula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2e9c65e41511618ae183ecaa8b4eaa68c272a48d.1442497843.git.lukas@wunner.de \
    --to=lukas@wunner.de \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.