ACPI: New helper for warning messages and replacing ACPI_EXCEPTION()
Subsystems (4)
cover ACPI: New helper for warning messages and replacing ACPI_EXCEPTION()
Hi All,
The purpose of this series is to get rid of the remaining (questionable) usage of ACPI_EXCEPTION() outside ACPICA.
The first patch is a tiny cleanup of the ACPI processor driver, but it is depended on by the second one which in turn is depended on by the last two.
The second patch introduces a new helper function for logging messages regarding ACPI object evaluation failures and makes some code under drivers/acpi/ use it.
The other two patches use the new helper to get rid of ACPI_EXCEPTION() and the related definitions from the acpi-als and acpi_power_meter drivers.
Please see the patch changelogs for details.
Thanks!
PATCH 1/4 ACPI: processor: perflib: Eliminate redundant status check
From: Rafael J. Wysocki <[email protected]>
One of the "status != AE_NOT_FOUND" checks inacpi_processor_get_platform_limit() is redundant,
so rearrange the code to eliminate it.
No functional impact.
--- drivers/acpi/processor_perflib.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/acpi/processor_perflib.c +7 -6
@@ -63,14 +63,15 @@ static int acpi_processor_get_platform_l* (e.g. 0 = states 0..n; 1 = states 1..n; etc. */ status =acpi_evaluate_integer (pr->handle,"_PPC" ,NULL , &ppc); - -if (status !=AE_NOT_FOUND ) +if (status !=AE_NOT_FOUND ) { acpi_processor_ppc_in_use = true; -if (ACPI_FAILURE (status) && status !=AE_NOT_FOUND ) { -acpi_handle_warn (pr->handle,"_PPC evaluation failed: %s\n" , -acpi_format_exception (status)); -return -ENODEV ; +if (ACPI_FAILURE (status)) { +acpi_handle_warn (pr->handle, +"_PPC evaluation failed: %s\n" , +acpi_format_exception (status)); +return -ENODEV ; + } } pr_debug("CPU %d: _PPC is %d - frequency %s limited\n", pr->id,
PATCH 2/4 ACPI: utils: Introduce acpi_evaluation_failure_warn()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Quite a few users of ACPI objects want to log a warning message if the evaluation fails which is a repeating pattern, so introduce a helper function for that purpose and convert some code where it is open-coded to using it.
No intentional functional impact.
--- drivers/acpi/pci_link.c | 6 ++---- drivers/acpi/processor_perflib.c | 10 +++------- drivers/acpi/processor_throttling.c | 16 ++++------------ drivers/acpi/utils.c | 14 ++++++++++++++ include/linux/acpi.h | 5 +++++ 5 files changed, 28 insertions(+), 23 deletions(-)
drivers/acpi/utils.c +14 -0
@@ -512,6 +512,20 @@ EXPORT_SYMBOL(__acpi_handle_debug);#endif /** +* acpi_evaluation_failure_warn - Log evaluation failure warning. +* @handle: Parent object handle. +* @name: Name of the object whose evaluation has failed. +* @status: Status value returned by the failing object evaluation. +*/ +void acpi_evaluation_failure_warn (acpi_handle handle,const char *name, +acpi_status status) +{ +acpi_handle_warn (handle,"%s evaluation failed: %s\n" , name, +acpi_format_exception (status)); +} +EXPORT_SYMBOL_GPL (acpi_evaluation_failure_warn); + +/** * acpi_has_method: Check whether @handle has a method named @name * @handle: ACPI device handle * @name: name of object or method
include/linux/acpi.h +5 -0
@@ -1027,9 +1027,14 @@ static inline void acpi_ec_set_gpe_wake_ __printf(3, 4)void acpi_handle_printk (const char *level,acpi_handle handle,const char *fmt, ...); +void acpi_evaluation_failure_warn (acpi_handle handle,const char *name, +acpi_status status);#else /* !CONFIG_ACPI */ static inline __printf(3, 4) void acpi_handle_printk(const char *level, void *handle, const char *fmt, ...) {} +static inline void acpi_evaluation_failure_warn (acpi_handle handle, +const char *name, +acpi_status status) {}#endif /* !CONFIG_ACPI */ #if defined(CONFIG_ACPI ) && defined(CONFIG_DYNAMIC_DEBUG )
drivers/acpi/processor_throttling.c +4 -12
@@ -281,9 +281,7 @@ static int acpi_processor_get_platform_l status =acpi_evaluate_integer (pr->handle,"_TPC" ,NULL , &tpc);if (ACPI_FAILURE (status)) {if (status !=AE_NOT_FOUND ) -acpi_handle_warn (pr->handle, -"_TPC evaluation failed: %s\n" , -acpi_format_exception (status)); +acpi_evaluation_failure_warn (pr->handle,"_TPC" , status);return -ENODEV ; }
@@ -416,9 +414,7 @@ static int acpi_processor_get_throttling status =acpi_evaluate_object (pr->handle,"_PTC" ,NULL , &buffer);if (ACPI_FAILURE (status)) {if (status !=AE_NOT_FOUND ) -acpi_handle_warn (pr->handle, -"_PTC evaluation failed: %s\n" , -acpi_format_exception (status)); +acpi_evaluation_failure_warn (pr->handle,"_PTC" , status);return -ENODEV ; }
@@ -503,9 +499,7 @@ static int acpi_processor_get_throttling status =acpi_evaluate_object (pr->handle,"_TSS" ,NULL , &buffer);if (ACPI_FAILURE (status)) {if (status !=AE_NOT_FOUND ) -acpi_handle_warn (pr->handle, -"_TSS evaluation failed: %s\n" , -acpi_format_exception (status)); +acpi_evaluation_failure_warn (pr->handle,"_TSS" , status);return -ENODEV ; }
@@ -586,9 +580,7 @@ static int acpi_processor_get_tsd(struct status =acpi_evaluate_object (pr->handle,"_TSD" ,NULL , &buffer);if (ACPI_FAILURE (status)) {if (status !=AE_NOT_FOUND ) -acpi_handle_warn (pr->handle, -"_TSD evaluation failed: %s\n" , -acpi_format_exception (status)); +acpi_evaluation_failure_warn (pr->handle,"_TSD" , status);return -ENODEV ; }
drivers/acpi/pci_link.c +2 -4
@@ -256,8 +256,7 @@ static int acpi_pci_link_get_current(str status =acpi_walk_resources (handle,METHOD_NAME__CRS , acpi_pci_link_check_current, &irq);if (ACPI_FAILURE (status)) { -acpi_handle_warn (handle,"_CRS evaluation failed: %s\n" , -acpi_format_exception (status)); +acpi_evaluation_failure_warn (handle,"_CRS" , status); result = -ENODEV ; goto end; }
@@ -345,8 +344,7 @@ static int acpi_pci_link_set(struct acpi/* check for total failure */ if (ACPI_FAILURE (status)) { -acpi_handle_warn (handle,"_SRS evaluation failed: %s" , -acpi_format_exception (status)); +acpi_evaluation_failure_warn (handle,"_SRS" , status); result = -ENODEV ; goto end; }
drivers/acpi/processor_perflib.c +3 -7
@@ -67,9 +67,7 @@ static int acpi_processor_get_platform_l acpi_processor_ppc_in_use = true;if (ACPI_FAILURE (status)) { -acpi_handle_warn (pr->handle, -"_PPC evaluation failed: %s\n" , -acpi_format_exception (status)); +acpi_evaluation_failure_warn (pr->handle,"_PPC" , status);return -ENODEV ; } }
@@ -199,8 +197,7 @@ static int acpi_processor_get_performanc status =acpi_evaluate_object (pr->handle,"_PCT" ,NULL , &buffer);if (ACPI_FAILURE (status)) { -acpi_handle_warn (pr->handle,"_PCT evaluation failed: %s\n" , -acpi_format_exception (status)); +acpi_evaluation_failure_warn (pr->handle,"_PCT" , status);return -ENODEV ; }
@@ -300,8 +297,7 @@ static int acpi_processor_get_performanc status =acpi_evaluate_object (pr->handle,"_PSS" ,NULL , &buffer);if (ACPI_FAILURE (status)) { -acpi_handle_warn (pr->handle,"_PSS evaluation failed: %s\n" , -acpi_format_exception (status)); +acpi_evaluation_failure_warn (pr->handle,"_PSS" , status);return -ENODEV ; }
PATCH 3/4 IIO: acpi-als: Get rid of ACPICA message printing
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Use acpi_evaluation_failure_warn() introduced previously instead of the ACPICA-specific ACPI_EXCEPTION() macro to log warning messages regarding ACPI object evaluation failures and drop the ACPI_MODULE_NAME() definition only used by the ACPICA message printing macro.
--- drivers/iio/light/acpi-als.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/iio/light/acpi-als.c +1 -3
@@ -26,8 +26,6 @@#define ACPI_ALS_DEVICE_NAME "acpi-als"#define ACPI_ALS_NOTIFY_ILLUMINANCE 0x80 -ACPI_MODULE_NAME ("acpi-als" ); -/* * So far, there's only one channel in here, but the specification for * ACPI0008 says there can be more to what the block can report. Like
@@ -91,7 +89,7 @@ static int acpi_als_read_value(struct ac &temp_val);if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"Error reading ALS %s" , prop)); +acpi_evaluation_failure_warn (als->device->handle, prop, status);return -EIO ; }
Re: [PATCH v1 3/4] IIO: acpi-als: Get rid of ACPICA message printing
Quoted 9 lines · On Fri, 05 Mar 2021 19:42:29 +0100 "Rafael J. Wysocki" <[email protected]>…
From: Rafael J. Wysocki <[email protected]>
Use
acpi_evaluation_failure_warn()introduced previously instead of the ACPICA-specificACPI_EXCEPTION()macro to log warning messages regarding ACPI object evaluation failures and drop theACPI_MODULE_NAME()definition only used by the ACPICA message printing macro.Signed-off-by Rafael J. Wysocki <[email protected]>
Quoted 29 lines
--- drivers/iio/light/acpi-als.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)Index:
linux-pm/drivers/iio/light/acpi-als.c
===================================================================drivers/iio/light/acpi-als.c +1
-3@@ -26,8 +26,6 @@#define ACPI_ALS_DEVICE_NAME "acpi-als"#define ACPI_ALS_NOTIFY_ILLUMINANCE 0x80 -ACPI_MODULE_NAME ("acpi-als" ); -/* * So far, there's only one channel in here, but the specification for * ACPI0008 says there can be more to what the block can report. Like @@ -91,7 +89,7 @@ static int acpi_als_read_value(struct ac &temp_val);if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"Error reading ALS %s" , prop)); +acpi_evaluation_failure_warn (als->device->handle, prop, status);return -EIO ; }
PATCH 4/4 hwmon: acpi_power_meter: Get rid of ACPICA message printing
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Use acpi_evaluation_failure_warn() introduced previously instead of the ACPICA-specific ACPI_EXCEPTION() macro to log warning messages regarding ACPI object evaluation failures and use dev_err() instead of ACPI_EXCEPTION() to log _PMC package parsing failures, which is consistent with the other messages printed by the code in question.
Next, drop the ACPI_MODULE_NAME() definition only used by the ACPICA message printing macro.
--- drivers/hwmon/acpi_power_meter.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)
drivers/hwmon/acpi_power_meter.c +19 -10
@@ -20,7 +20,6 @@#include <linux/acpi.h> #define ACPI_POWER_METER_NAME "power_meter" -ACPI_MODULE_NAME (ACPI_POWER_METER_NAME );#define ACPI_POWER_METER_DEVICE_NAME "Power Meter"#define ACPI_POWER_METER_CLASS "pwr_meter_resource"
@@ -114,7 +113,8 @@ static int update_avg_interval(struct ac status =acpi_evaluate_integer (resource->acpi_dev->handle,"_GAI" ,NULL , &data);if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"Evaluating _GAI" )); +acpi_evaluation_failure_warn (resource->acpi_dev->handle,"_GAI" , + status);return -ENODEV ; }
@@ -166,7 +166,8 @@ static ssize_t set_avg_interval(struct dmutex_unlock (&resource->lock);if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"Evaluating _PAI" )); +acpi_evaluation_failure_warn (resource->acpi_dev->handle,"_PAI" , + status);return -EINVAL ; }
@@ -186,7 +187,8 @@ static int update_cap(struct acpi_power_ status =acpi_evaluate_integer (resource->acpi_dev->handle,"_GHL" ,NULL , &data);if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"Evaluating _GHL" )); +acpi_evaluation_failure_warn (resource->acpi_dev->handle,"_GHL" , + status);return -ENODEV ; }
@@ -237,7 +239,8 @@ static ssize_t set_cap(struct device *demutex_unlock (&resource->lock);if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"Evaluating _SHL" )); +acpi_evaluation_failure_warn (resource->acpi_dev->handle,"_SHL" , + status);return -EINVAL ; }
@@ -270,7 +273,8 @@ static int set_acpi_trip(struct acpi_pow status =acpi_evaluate_integer (resource->acpi_dev->handle,"_PTP" , &args, &data);if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"Evaluating _PTP" )); +acpi_evaluation_failure_warn (resource->acpi_dev->handle,"_PTP" , + status);return -EINVAL ; }
@@ -322,7 +326,8 @@ static int update_meter(struct acpi_powe status =acpi_evaluate_integer (resource->acpi_dev->handle,"_PMM" ,NULL , &data);if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"Evaluating _PMM" )); +acpi_evaluation_failure_warn (resource->acpi_dev->handle,"_PMM" , + status);return -ENODEV ; }
@@ -549,7 +554,8 @@ static int read_domain_devices(struct ac status =acpi_evaluate_object (resource->acpi_dev->handle,"_PMD" ,NULL , &buffer);if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"Evaluating _PMD" )); +acpi_evaluation_failure_warn (resource->acpi_dev->handle,"_PMD" , + status);return -ENODEV ; }
@@ -745,7 +751,8 @@ static int read_capabilities(struct acpi status =acpi_evaluate_object (resource->acpi_dev->handle,"_PMC" ,NULL , &buffer);if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"Evaluating _PMC" )); +acpi_evaluation_failure_warn (resource->acpi_dev->handle,"_PMC" , + status);return -ENODEV ; }
@@ -765,7 +772,9 @@ static int read_capabilities(struct acpi status =acpi_extract_package (pss, &format, &state);if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"Invalid data" )); +dev_err (&resource->acpi_dev->dev,ACPI_POWER_METER_NAME +"_PMC package parsing failed: %s\n" , +acpi_format_exception (status)); res = -EFAULT ; goto end; }
Re: [PATCH v1 4/4] hwmon: acpi_power_meter: Get rid of ACPICA message printing
Quoted 8 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Use
acpi_evaluation_failure_warn()introduced previously instead of the ACPICA-specificACPI_EXCEPTION()macro to log warning messages regarding ACPI object evaluation failures and usedev_err()instead ofACPI_EXCEPTION()to log_PMCpackage parsing failures, which is consistent with the other messages printed by the code in question.
Quoted 4 lines
Next, drop the
ACPI_MODULE_NAME()definition only used by the ACPICA message printing macro.Signed-off-by Rafael J. Wysocki <[email protected]>
Quoted 110 lines
--- drivers/hwmon/acpi_power_meter.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)Index:
linux-pm/drivers/hwmon/acpi_power_meter.c
===================================================================drivers/hwmon/acpi_power_meter.c +19
-10@@ -20,7 +20,6 @@#include <linux/acpi.h> #define ACPI_POWER_METER_NAME "power_meter" -ACPI_MODULE_NAME (ACPI_POWER_METER_NAME );#define ACPI_POWER_METER_DEVICE_NAME "Power Meter"#define ACPI_POWER_METER_CLASS "pwr_meter_resource"@@ -114,7 +113,8 @@ static int update_avg_interval(struct ac status =acpi_evaluate_integer (resource->acpi_dev->handle,"_GAI" ,NULL , &data);if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"Evaluating _GAI" )); +acpi_evaluation_failure_warn (resource->acpi_dev->handle,"_GAI" , + status);return -ENODEV ; }@@ -166,7 +166,8 @@ static ssize_t set_avg_interval(struct dmutex_unlock (&resource->lock);if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"Evaluating _PAI" )); +acpi_evaluation_failure_warn (resource->acpi_dev->handle,"_PAI" , + status);return -EINVAL ; }@@ -186,7 +187,8 @@ static int update_cap(struct acpi_power_ status =acpi_evaluate_integer (resource->acpi_dev->handle,"_GHL" ,NULL , &data);if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"Evaluating _GHL" )); +acpi_evaluation_failure_warn (resource->acpi_dev->handle,"_GHL" , + status);return -ENODEV ; }@@ -237,7 +239,8 @@ static ssize_t set_cap(struct device *demutex_unlock (&resource->lock);if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"Evaluating _SHL" )); +acpi_evaluation_failure_warn (resource->acpi_dev->handle,"_SHL" , + status);return -EINVAL ; }@@ -270,7 +273,8 @@ static int set_acpi_trip(struct acpi_pow status =acpi_evaluate_integer (resource->acpi_dev->handle,"_PTP" , &args, &data);if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"Evaluating _PTP" )); +acpi_evaluation_failure_warn (resource->acpi_dev->handle,"_PTP" , + status);return -EINVAL ; }@@ -322,7 +326,8 @@ static int update_meter(struct acpi_powe status =acpi_evaluate_integer (resource->acpi_dev->handle,"_PMM" ,NULL , &data);if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"Evaluating _PMM" )); +acpi_evaluation_failure_warn (resource->acpi_dev->handle,"_PMM" , + status);return -ENODEV ; }@@ -549,7 +554,8 @@ static int read_domain_devices(struct ac status =acpi_evaluate_object (resource->acpi_dev->handle,"_PMD" ,NULL , &buffer);if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"Evaluating _PMD" )); +acpi_evaluation_failure_warn (resource->acpi_dev->handle,"_PMD" , + status);return -ENODEV ; }@@ -745,7 +751,8 @@ static int read_capabilities(struct acpi status =acpi_evaluate_object (resource->acpi_dev->handle,"_PMC" ,NULL , &buffer);if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"Evaluating _PMC" )); +acpi_evaluation_failure_warn (resource->acpi_dev->handle,"_PMC" , + status);return -ENODEV ; }@@ -765,7 +772,9 @@ static int read_capabilities(struct acpi status =acpi_extract_package (pss, &format, &state);if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"Invalid data" )); +dev_err (&resource->acpi_dev->dev,ACPI_POWER_METER_NAME +"_PMC package parsing failed: %s\n" , +acpi_format_exception (status)); res = -EFAULT ; goto end; }