On 05/26/2015 02:46 PM, Pierre Moreau wrote:
I'm thinking of re-writing this patch to just OR the different returned retval and test for individual bits directly in the final conditionals.
So this would give something like:
int retval = 0;
while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
vga_count++;
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_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 && (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 (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",
acpi_method_name);
nouveau_dsm_priv.gmux_detected = true;
ret = true;
}
Any opinions on this?
If this improves readability of the code, go ahead.
Pierre
----- Mail original -----
Signed-off-by: Pierre Moreau <pierre.morrow@xxxxxxx>
---
drm/nouveau/nouveau_acpi.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drm/nouveau/nouveau_acpi.c b/drm/nouveau/nouveau_acpi.c
index 3d6a1ea..5d63621 100644
--- a/drm/nouveau/nouveau_acpi.c
+++ b/drm/nouveau/nouveau_acpi.c
@@ -297,8 +297,8 @@ 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_dsm = 0;
- int has_optimus = 0;
+ bool has_mux = false;
+ bool has_optimus = false;
bool has_gmux = false;
int vga_count = 0;
bool guid_valid;
@@ -317,9 +317,9 @@ static bool nouveau_dsm_detect(void)
retval = nouveau_dsm_pci_probe(pdev);
if (retval & NOUVEAU_DSM_HAS_MUX)
- has_dsm |= 1;
+ has_mux = true;
if (retval & NOUVEAU_DSM_HAS_OPT)
- has_optimus = 1;
+ has_optimus = true;
if (retval & NOUVEAU_DSM_HAS_GMUX)
has_gmux = true;
}
@@ -329,9 +329,9 @@ static bool nouveau_dsm_detect(void)
retval = nouveau_dsm_pci_probe(pdev);
if (retval & NOUVEAU_DSM_HAS_MUX)
- has_dsm |= 1;
+ has_mux = true;
if (retval & NOUVEAU_DSM_HAS_OPT)
- has_optimus = 1;
+ has_optimus = true;
if (retval & NOUVEAU_DSM_HAS_GMUX)
has_gmux = true;
}
@@ -344,7 +344,7 @@ static bool nouveau_dsm_detect(void)
acpi_method_name);
nouveau_dsm_priv.optimus_detected = true;
ret = true;
- } else if (vga_count == 2 && has_dsm && guid_valid) {
+ } else if (vga_count == 2 && 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",
--
2.4.1
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Nouveau mailing list
Nouveau@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel