]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/acpi/pmic/intel_pmic.c
ACPI / PMIC: Do not register handlers for unhandled OpRegions
[linux.git] / drivers / acpi / pmic / intel_pmic.c
index 452041398b347f67919f002b148730129919276e..a371f273f99dd59de3a4d13eaa3e9d888def59bc 100644 (file)
@@ -252,7 +252,7 @@ int intel_pmic_install_opregion_handler(struct device *dev, acpi_handle handle,
                                        struct regmap *regmap,
                                        struct intel_pmic_opregion_data *d)
 {
-       acpi_status status;
+       acpi_status status = AE_OK;
        struct intel_pmic_opregion *opregion;
        int ret;
 
@@ -270,7 +270,8 @@ int intel_pmic_install_opregion_handler(struct device *dev, acpi_handle handle,
        opregion->regmap = regmap;
        opregion->lpat_table = acpi_lpat_get_conversion_table(handle);
 
-       status = acpi_install_address_space_handler(handle,
+       if (d->power_table_count)
+               status = acpi_install_address_space_handler(handle,
                                                    PMIC_POWER_OPREGION_ID,
                                                    intel_pmic_power_handler,
                                                    NULL, opregion);
@@ -279,7 +280,8 @@ int intel_pmic_install_opregion_handler(struct device *dev, acpi_handle handle,
                goto out_error;
        }
 
-       status = acpi_install_address_space_handler(handle,
+       if (d->thermal_table_count)
+               status = acpi_install_address_space_handler(handle,
                                                    PMIC_THERMAL_OPREGION_ID,
                                                    intel_pmic_thermal_handler,
                                                    NULL, opregion);
@@ -301,12 +303,16 @@ int intel_pmic_install_opregion_handler(struct device *dev, acpi_handle handle,
        return 0;
 
 out_remove_thermal_handler:
-       acpi_remove_address_space_handler(handle, PMIC_THERMAL_OPREGION_ID,
-                                         intel_pmic_thermal_handler);
+       if (d->thermal_table_count)
+               acpi_remove_address_space_handler(handle,
+                                                 PMIC_THERMAL_OPREGION_ID,
+                                                 intel_pmic_thermal_handler);
 
 out_remove_power_handler:
-       acpi_remove_address_space_handler(handle, PMIC_POWER_OPREGION_ID,
-                                         intel_pmic_power_handler);
+       if (d->power_table_count)
+               acpi_remove_address_space_handler(handle,
+                                                 PMIC_POWER_OPREGION_ID,
+                                                 intel_pmic_power_handler);
 
 out_error:
        acpi_lpat_free_conversion_table(opregion->lpat_table);