Skip to content

Commit a0fcfed

Browse files
jwrdegoederafaeljw
authored andcommitted
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 <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 7d194c2 commit a0fcfed

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

drivers/acpi/pmic/intel_pmic.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ int intel_pmic_install_opregion_handler(struct device *dev, acpi_handle handle,
252252
struct regmap *regmap,
253253
struct intel_pmic_opregion_data *d)
254254
{
255-
acpi_status status;
255+
acpi_status status = AE_OK;
256256
struct intel_pmic_opregion *opregion;
257257
int ret;
258258

@@ -270,7 +270,8 @@ int intel_pmic_install_opregion_handler(struct device *dev, acpi_handle handle,
270270
opregion->regmap = regmap;
271271
opregion->lpat_table = acpi_lpat_get_conversion_table(handle);
272272

273-
status = acpi_install_address_space_handler(handle,
273+
if (d->power_table_count)
274+
status = acpi_install_address_space_handler(handle,
274275
PMIC_POWER_OPREGION_ID,
275276
intel_pmic_power_handler,
276277
NULL, opregion);
@@ -279,7 +280,8 @@ int intel_pmic_install_opregion_handler(struct device *dev, acpi_handle handle,
279280
goto out_error;
280281
}
281282

282-
status = acpi_install_address_space_handler(handle,
283+
if (d->thermal_table_count)
284+
status = acpi_install_address_space_handler(handle,
283285
PMIC_THERMAL_OPREGION_ID,
284286
intel_pmic_thermal_handler,
285287
NULL, opregion);
@@ -301,12 +303,16 @@ int intel_pmic_install_opregion_handler(struct device *dev, acpi_handle handle,
301303
return 0;
302304

303305
out_remove_thermal_handler:
304-
acpi_remove_address_space_handler(handle, PMIC_THERMAL_OPREGION_ID,
305-
intel_pmic_thermal_handler);
306+
if (d->thermal_table_count)
307+
acpi_remove_address_space_handler(handle,
308+
PMIC_THERMAL_OPREGION_ID,
309+
intel_pmic_thermal_handler);
306310

307311
out_remove_power_handler:
308-
acpi_remove_address_space_handler(handle, PMIC_POWER_OPREGION_ID,
309-
intel_pmic_power_handler);
312+
if (d->power_table_count)
313+
acpi_remove_address_space_handler(handle,
314+
PMIC_POWER_OPREGION_ID,
315+
intel_pmic_power_handler);
310316

311317
out_error:
312318
acpi_lpat_free_conversion_table(opregion->lpat_table);

0 commit comments

Comments
 (0)