[2/9] vga_switcheroo: Use VGA_SWITCHEROO_UNKNOWN_ID instead of -1
diff mbox

Message ID 7acf5629ec156de3320dadb3f47415409466ee01.1444663039.git.lukas@wunner.de
State New
Headers show

Commit Message

Lukas Wunner Aug. 28, 2015, 11:30 a.m. UTC
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(-)

Comments

Alex Deucher Oct. 12, 2015, 4:09 p.m. UTC | #1
On Fri, Aug 28, 2015 at 7:30 AM, Lukas Wunner <lukas@wunner.de> wrote:
> Signed-off-by: Lukas Wunner <lukas@wunner.de>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  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 a7870d2..9896305 100644
> --- a/drivers/gpu/vga/vga_switcheroo.c
> +++ b/drivers/gpu/vga/vga_switcheroo.c
> @@ -84,9 +84,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
> @@ -145,7 +145,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);
> @@ -173,7 +174,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)
> @@ -277,7 +278,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 e636617..88909a8 100644
> --- a/include/linux/vga_switcheroo.h
> +++ b/include/linux/vga_switcheroo.h
> @@ -59,6 +59,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
> @@ -66,6 +69,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
Daniel Vetter Oct. 13, 2015, 7:28 a.m. UTC | #2
On Mon, Oct 12, 2015 at 12:09:53PM -0400, Alex Deucher wrote:
> On Fri, Aug 28, 2015 at 7:30 AM, Lukas Wunner <lukas@wunner.de> wrote:
> > Signed-off-by: Lukas Wunner <lukas@wunner.de>
> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

Merged the 3 cleanup patches to drm-misc.
-Daniel

> 
> > ---
> >  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 a7870d2..9896305 100644
> > --- a/drivers/gpu/vga/vga_switcheroo.c
> > +++ b/drivers/gpu/vga/vga_switcheroo.c
> > @@ -84,9 +84,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
> > @@ -145,7 +145,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);
> > @@ -173,7 +174,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)
> > @@ -277,7 +278,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 e636617..88909a8 100644
> > --- a/include/linux/vga_switcheroo.h
> > +++ b/include/linux/vga_switcheroo.h
> > @@ -59,6 +59,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
> > @@ -66,6 +69,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
Lukas Wunner Oct. 15, 2015, 6:14 p.m. UTC | #3
Hi Daniel,

On Tue, Oct 13, 2015 at 09:28:13AM +0200, Daniel Vetter wrote:
> On Mon, Oct 12, 2015 at 12:09:53PM -0400, Alex Deucher wrote:
> > On Fri, Aug 28, 2015 at 7:30 AM, Lukas Wunner <lukas@wunner.de> wrote:
> > > Signed-off-by: Lukas Wunner <lukas@wunner.de>
> > Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
> 
> Merged the 3 cleanup patches to drm-misc.
> -Daniel

Thanks a lot. Could you also merge the fourth patch:

Subject: [PATCH 4/9] ALSA: hda - Spell vga_switcheroo consistently
Message-Id: <9b0175319ce78d831acfcf11e4c6c760f826b0e3.1444663039.git.lukas@wunner.de>
Date: Fri, 4 Sep 2015 20:49:36 +0200


Takashi gave it a Reviewed-by tag (which I've included in the above resend)
and asked for it to be merged via drm-misc in this off-list e-mail:

Subject: Re: [PATCH 10/15] ALSA: hda - Spell vga_switcheroo consistently (fwd)
Message-ID: <s5hpp0zg2z3.wl-tiwai@suse.de>
Date: Wed, 30 Sep 2015 20:46:08 +0200


Thanks & best regards,

Lukas
Daniel Vetter Oct. 16, 2015, 2:25 p.m. UTC | #4
On Thu, Oct 15, 2015 at 08:14:20PM +0200, Lukas Wunner wrote:
> Hi Daniel,
> 
> On Tue, Oct 13, 2015 at 09:28:13AM +0200, Daniel Vetter wrote:
> > On Mon, Oct 12, 2015 at 12:09:53PM -0400, Alex Deucher wrote:
> > > On Fri, Aug 28, 2015 at 7:30 AM, Lukas Wunner <lukas@wunner.de> wrote:
> > > > Signed-off-by: Lukas Wunner <lukas@wunner.de>
> > > Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
> > 
> > Merged the 3 cleanup patches to drm-misc.
> > -Daniel
> 
> Thanks a lot. Could you also merge the fourth patch:
> 
> Subject: [PATCH 4/9] ALSA: hda - Spell vga_switcheroo consistently
> Message-Id: <9b0175319ce78d831acfcf11e4c6c760f826b0e3.1444663039.git.lukas@wunner.de>
> Date: Fri, 4 Sep 2015 20:49:36 +0200
> 
> 
> Takashi gave it a Reviewed-by tag (which I've included in the above resend)
> and asked for it to be merged via drm-misc in this off-list e-mail:
> 
> Subject: Re: [PATCH 10/15] ALSA: hda - Spell vga_switcheroo consistently (fwd)
> Message-ID: <s5hpp0zg2z3.wl-tiwai@suse.de>
> Date: Wed, 30 Sep 2015 20:46:08 +0200
> 
> 
> Thanks & best regards,

Right, dunno why I missed that. Merged to drm-misc now, thanks.
-Daniel

Patch
diff mbox

diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
index a7870d2..9896305 100644
--- a/drivers/gpu/vga/vga_switcheroo.c
+++ b/drivers/gpu/vga/vga_switcheroo.c
@@ -84,9 +84,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
@@ -145,7 +145,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);
@@ -173,7 +174,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)
@@ -277,7 +278,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 e636617..88909a8 100644
--- a/include/linux/vga_switcheroo.h
+++ b/include/linux/vga_switcheroo.h
@@ -59,6 +59,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
@@ -66,6 +69,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,