[Nouveau] [PATCH v2 9/9] acpi: Move detecting available _DSM outside of while loops

Pierre Moreau pierre.morrow at free.fr
Wed May 27 23:40:49 PDT 2015


Changes since v1:
* Re-write the whole patch to detect available _DSMs when we enable them rather
  than on each loop run

Signed-off-by: Pierre Moreau <pierre.morrow at free.fr>
---
 drm/nouveau/nouveau_acpi.c | 27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)

diff --git a/drm/nouveau/nouveau_acpi.c b/drm/nouveau/nouveau_acpi.c
index ee5fcfa..a970e41 100644
--- a/drm/nouveau/nouveau_acpi.c
+++ b/drm/nouveau/nouveau_acpi.c
@@ -301,12 +301,9 @@ static bool nouveau_dsm_detect(void)
 	char acpi_method_name[255] = { 0 };
 	struct acpi_buffer buffer = {sizeof(acpi_method_name), acpi_method_name};
 	struct pci_dev *pdev = NULL;
-	int has_mux = 0;
-	int has_optimus = 0;
-	bool has_gmux = false;
 	int vga_count = 0;
 	bool guid_valid;
-	int retval;
+	int retval = 0;
 	bool ret = false;
 
 	/* lookup the MXM GUID */
@@ -319,43 +316,31 @@ static bool nouveau_dsm_detect(void)
 	while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
 		vga_count++;
 
-		retval = nouveau_dsm_pci_probe(pdev);
-		if (retval & NOUVEAU_DSM_HAS_MUX)
-			has_mux |= 1;
-		if (retval & NOUVEAU_DSM_HAS_OPT)
-			has_optimus = 1;
-		if (retval & NOUVEAU_DSM_HAS_GMUX)
-			has_gmux = true;
+		retval |= nouveau_dsm_pci_probe(pdev);
 	}
 
 	while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_3D << 8, pdev)) != NULL) {
 		vga_count++;
 
-		retval = nouveau_dsm_pci_probe(pdev);
-		if (retval & NOUVEAU_DSM_HAS_MUX)
-			has_mux |= 1;
-		if (retval & NOUVEAU_DSM_HAS_OPT)
-			has_optimus = 1;
-		if (retval & NOUVEAU_DSM_HAS_GMUX)
-			has_gmux = true;
+		retval |= nouveau_dsm_pci_probe(pdev);
 	}
 
 	/* find the optimus DSM, the mux DSM or the gmux DSM */
-	if (has_optimus == 1) {
+	if (retval & NOUVEAU_DSM_HAS_OPT) {
 		acpi_get_name(nouveau_dsm_priv.dhandle, ACPI_FULL_PATHNAME,
 			&buffer);
 		printk(KERN_INFO "VGA switcheroo: detected Optimus DSM method %s handle\n",
 			acpi_method_name);
 		nouveau_dsm_priv.optimus_detected = true;
 		ret = true;
-	} else if (vga_count == 2 && has_mux && guid_valid) {
+	} else if (vga_count == 2 && (retval & NOUVEAU_DSM_HAS_MUX) && guid_valid) {
 		acpi_get_name(nouveau_dsm_priv.dhandle, ACPI_FULL_PATHNAME,
 			&buffer);
 		printk(KERN_INFO "VGA switcheroo: detected mux DSM switching method %s handle\n",
 			acpi_method_name);
 		nouveau_dsm_priv.mux_detected = true;
 		ret = true;
-	} else if (has_gmux) {
+	} else if (retval & NOUVEAU_DSM_HAS_GMUX) {
 		acpi_get_name(nouveau_dsm_priv.dhandle, ACPI_FULL_PATHNAME,
 			&buffer);
 		printk(KERN_INFO "VGA switcheroo: detected gmux DSM switching method %s handle\n",
-- 
2.4.2



More information about the Nouveau mailing list