Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPI / PMIC: Do not register handlers for unhandled OpRegions

For some model PMIC's used on Intel boards we do not know how to
handle the power or thermal opregions because we have no documentation.

For example in the intel_pmic_chtwc.c driver thermal_table_count is 0,
which means that our PMIC_THERMAL_OPREGION_ID handler will always fail
with AE_BAD_PARAMETER, in this case it is better to simply not register
the handler at all.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Hans de Goede and committed by
Rafael J. Wysocki
a0fcfed1 7d194c21

+13 -7
+13 -7
drivers/acpi/pmic/intel_pmic.c
··· 252 252 struct regmap *regmap, 253 253 struct intel_pmic_opregion_data *d) 254 254 { 255 - acpi_status status; 255 + acpi_status status = AE_OK; 256 256 struct intel_pmic_opregion *opregion; 257 257 int ret; 258 258 ··· 270 270 opregion->regmap = regmap; 271 271 opregion->lpat_table = acpi_lpat_get_conversion_table(handle); 272 272 273 - status = acpi_install_address_space_handler(handle, 273 + if (d->power_table_count) 274 + status = acpi_install_address_space_handler(handle, 274 275 PMIC_POWER_OPREGION_ID, 275 276 intel_pmic_power_handler, 276 277 NULL, opregion); ··· 280 279 goto out_error; 281 280 } 282 281 283 - status = acpi_install_address_space_handler(handle, 282 + if (d->thermal_table_count) 283 + status = acpi_install_address_space_handler(handle, 284 284 PMIC_THERMAL_OPREGION_ID, 285 285 intel_pmic_thermal_handler, 286 286 NULL, opregion); ··· 303 301 return 0; 304 302 305 303 out_remove_thermal_handler: 306 - acpi_remove_address_space_handler(handle, PMIC_THERMAL_OPREGION_ID, 307 - intel_pmic_thermal_handler); 304 + if (d->thermal_table_count) 305 + acpi_remove_address_space_handler(handle, 306 + PMIC_THERMAL_OPREGION_ID, 307 + intel_pmic_thermal_handler); 308 308 309 309 out_remove_power_handler: 310 - acpi_remove_address_space_handler(handle, PMIC_POWER_OPREGION_ID, 311 - intel_pmic_power_handler); 310 + if (d->power_table_count) 311 + acpi_remove_address_space_handler(handle, 312 + PMIC_POWER_OPREGION_ID, 313 + intel_pmic_power_handler); 312 314 313 315 out_error: 314 316 acpi_lpat_free_conversion_table(opregion->lpat_table);