media: atomisp: gmin_platform: Make DMI quirks take precedence over the _DSM table
authorHans de Goede <hdegoede@redhat.com>
Fri, 10 Mar 2023 12:34:45 +0000 (12:34 +0000)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Sat, 15 Apr 2023 09:42:41 +0000 (10:42 +0100)
On some devices the _DSM sensor-info table contains wrong info,
move the DMI quirk handling up to above the _DSM table check
to allow DMI quirks to override wrong info in the _DSM table.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c

index fdd71b6..5dcfc12 100644 (file)
@@ -1353,37 +1353,22 @@ static int gmin_get_config_var(struct device *maindev,
                               const char *var,
                               char *out, size_t *out_len)
 {
+       struct acpi_device *adev = ACPI_COMPANION(maindev);
        efi_char16_t var16[CFG_VAR_NAME_MAX];
        const struct dmi_system_id *id;
-       struct device *dev = maindev;
        char var8[CFG_VAR_NAME_MAX];
        efi_status_t status;
        int i, ret;
 
-       /* For sensors, try first to use the _DSM table */
-       if (!is_gmin) {
-               ret = gmin_get_config_dsm_var(maindev, var, out, out_len);
-               if (!ret)
-                       return 0;
-       }
-
-       /* Fall-back to other approaches */
-
-       if (!is_gmin && ACPI_COMPANION(dev))
-               dev = &ACPI_COMPANION(dev)->dev;
-
-       if (!is_gmin)
-               ret = snprintf(var8, sizeof(var8), "%s_%s", dev_name(dev), var);
+       if (!is_gmin && adev)
+               ret = snprintf(var8, sizeof(var8), "%s_%s", acpi_dev_name(adev), var);
        else
                ret = snprintf(var8, sizeof(var8), "gmin_%s", var);
 
        if (ret < 0 || ret >= sizeof(var8) - 1)
                return -EINVAL;
 
-       /* First check a hard-coded list of board-specific variables.
-        * Some device firmwares lack the ability to set EFI variables at
-        * runtime.
-        */
+       /* DMI based quirks override both the _DSM table and EFI variables */
        id = dmi_first_match(gmin_vars);
        if (id) {
                ret = gmin_get_hardcoded_var(maindev, id->driver_data, var8,
@@ -1392,6 +1377,13 @@ static int gmin_get_config_var(struct device *maindev,
                        return 0;
        }
 
+       /* For sensors, try first to use the _DSM table */
+       if (!is_gmin) {
+               ret = gmin_get_config_dsm_var(maindev, var, out, out_len);
+               if (!ret)
+                       return 0;
+       }
+
        /* Our variable names are ASCII by construction, but EFI names
         * are wide chars.  Convert and zero-pad.
         */