ACPI: Replace Ternary Operations with min()/max() Macros
cover ACPI: Replace Ternary Operations with min()/max() Macros
Hi all,
This patch series, generated using Coccinelle, aims to improve code readability and maintainability by replacing ternary operations with the min()
and max() macros where applicable in the ACPI subsystem.
The patches have been compiled and tested on an x86_64 system.
Prabhakar Pujeri (2):
ACPI: CPPC: Replace ternary operator with max() in cppc_find_dmi_mhz
ACPI: PM: Use max() for clearer D3 state selection in
acpi_dev_pm_get_state
drivers/acpi/cppc_acpi.c | 2 +- drivers/acpi/device_pm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.45.2
PATCH 1/2 ACPI: CPPC: Replace ternary operator with max() in cppc_find_dmi_mhz
--- drivers/acpi/cppc_acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/cppc_acpi.c +1 -1
@@ -1837,7 +1837,7 @@ static void cppc_find_dmi_mhz(const struct dmi_header *dm, void *private) dm->length >= DMI_ENTRY_PROCESSOR_MIN_LENGTH) {u16 val = (u16 )get_unaligned ((const u16 *) (dmi_data +DMI_PROCESSOR_MAX_SPEED )); - *mhz = val > *mhz ? val : *mhz; + *mhz =max (val, *mhz); } }
Signature · 1 line
2.45.2
Re: [PATCH 1/2] ACPI: CPPC: Replace ternary operator with max() in cppc_find_dmi_mhz
Quoted 11 lines · Prabhakar Pujeri
Signed-off-by Prabhakar Pujeri <[email protected]>--- drivers/acpi/cppc_acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/acpi/cppc_acpi.c +0
-0
drivers/acpi/cppc_acpi.c static void cppc_find_dmi_mhz(const struct dmi_header *dm, void *private)
Quoted 9 lines
drivers/acpi/cppc_acpi.c +1
-2@@ -1837,7 +1837,7 @@ static void cppc_find_dmi_mhz(const struct dmi_header *dm, void *private) dm->length >= DMI_ENTRY_PROCESSOR_MIN_LENGTH) {u16 val = (u16 )get_unaligned ((const u16 *) (dmi_data +DMI_PROCESSOR_MAX_SPEED )); - *mhz = val > *mhz ? val : *mhz; + *mhz =max (val, *mhz); } } --
Applied as 6.11 material with some edits in the subject and changelog, thanks!
PATCH 2/2 ACPI: PM: Use max() for clearer D3 state selection in acpi_dev_pm_get_state
In reply to Prabhakar Pujeri--- drivers/acpi/device_pm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/device_pm.c +1 -1
@@ -760,7 +760,7 @@ static int acpi_dev_pm_get_state(struct device *dev, struct acpi_device *adev,if (!adev->power.states[ret].flags.valid) ret =ACPI_STATE_D3_COLD ; - d_max = ret > d_min ? ret : d_min; + d_max =max (ret, d_min); }else {return -ENODATA ; }
Signature · 1 line
2.45.2