trivial: acpi: replace some bitshifts with BIT macro
Subsystems (3)
PATCH 1/1 trivial: acpi: replace some bitshifts with BIT macro
--- drivers/acpi/acpica/exfldio.c | 2 +- drivers/acpi/acpica/utownerid.c | 6 +++--- drivers/acpi/bus.c | 2 +- drivers/acpi/sleep.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
drivers/acpi/acpica/exfldio.c +1 -1
@@ -298,7 +298,7 @@ acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value)return (FALSE); } -if (value >= ((u64 )1 << obj_desc->common_field.bit_length)) { +if (value >= ((u64 )BIT (obj_desc->common_field.bit_length))) {/* * The Value is larger than the maximum value that can fit into * the register.
drivers/acpi/acpica/utownerid.c +3 -3
@@ -74,13 +74,13 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id *owner_id)* int. Some compilers or runtime error detection may flag this as * an error. */ -if (!(acpi_gbl_owner_id_mask[j] & ((u32 )1 << k))) { +if (!(acpi_gbl_owner_id_mask[j] & (u32 )BIT (k))) {/* * Found a free ID. The actual ID is the bit index plus one, * making zero an invalid Owner ID. Save this as the last ID * allocated and update the global ID mask. */ - acpi_gbl_owner_id_mask[j] |= ((u32 )1 << k); + acpi_gbl_owner_id_mask[j] |= (u32 )BIT (k); acpi_gbl_last_owner_id_index = (u8 )j; acpi_gbl_next_owner_id_offset = (u8)(k +1 );
@@ -171,7 +171,7 @@ void acpi_ut_release_owner_id(acpi_owner_id *owner_id_ptr)/* Decode ID to index/offset pair */ index =ACPI_DIV_32 (owner_id); - bit = (u32 )1 <<ACPI_MOD_32 (owner_id); + bit = (u32 )BIT (ACPI_MOD_32 (owner_id));/* Free the owner ID only if it is valid */
drivers/acpi/bus.c +1 -1
@@ -233,7 +233,7 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context) goto out_kfree; }/* Need to ignore the bit0 in result code */ - errors = *((u32 *)out_obj->buffer.pointer) & ~(1 <<0 ); + errors = *((u32 *)out_obj->buffer.pointer) &BIT (0 );if (errors) {if (errors &OSC_REQUEST_ERROR ) acpi_print_osc_error(handle, context,
drivers/acpi/sleep.c +1 -1
@@ -880,7 +880,7 @@ static void acpi_sleep_run_lps0_dsm(unsigned int func) {union acpi_object *out_obj; -if (!(lps0_dsm_func_mask & (1 << func))) +if (!(lps0_dsm_func_mask &BIT (func)))return ; out_obj =acpi_evaluate_dsm (lps0_device_handle, &lps0_dsm_guid,1 , func,NULL );
Signature · 1 line
2.25.1
This patch introduces two bugs, so perhaps don't send risky changes to the trivial tree.
Quoted 1 line · garritfra
Signed-off-by garritfra <[email protected]>
You need a commit message, and your full legal name for both the From and the Signing.
Quoted 12 lines
--- drivers/acpi/acpica/exfldio.c | 2 +- drivers/acpi/acpica/utownerid.c | 6 +++--- drivers/acpi/bus.c | 2 +- drivers/acpi/sleep.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)drivers/acpi/acpica/exfldio.c +0
-0
drivers/acpi/acpica/exfldio.c acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value) · line 301
Quoted 5 lines
drivers/acpi/acpica/exfldio.c +1
-1@@ -298,7 +298,7 @@ acpi_ex_register_overflow(union acpi_operand_object *obj_desc, u64 value)return (FALSE); } -if (value >= ((u64 )1 << obj_desc->common_field.bit_length)) { +if (value >= ((u64 )BIT (obj_desc->common_field.bit_length))) {
This breaks the code... The original code casts 1 to 1ULL so we can shift by 63 but the BIT() macro can only shift by 31. It should use the BIT_ULL() macro here.
drivers/acpi/acpica/utownerid.c acpi_status acpi_ut_allocate_owner_id(acpi_owner_id *owner_id) · line 77
Quoted 13 lines
drivers/acpi/acpica/exfldio.c +0
-0/* * The Value is larger than the maximum value that can fit into * the register. drivers/acpi/acpica/utownerid.c +1
-1@@ -74,13 +74,13 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id *owner_id)* int. Some compilers or runtime error detection may flag this as * an error. */ -if (!(acpi_gbl_owner_id_mask[j] & ((u32 )1 << k))) { +if (!(acpi_gbl_owner_id_mask[j] & (u32 )BIT (k))) {
This cast can be removed.
Quoted 11 lines
drivers/acpi/acpica/utownerid.c +1
-1/* * Found a free ID. The actual ID is the bit index plus one, * making zero an invalid Owner ID. Save this as the last ID * allocated and update the global ID mask. */ - acpi_gbl_owner_id_mask[j] |= ((u32 )1 << k); + acpi_gbl_owner_id_mask[j] |= (u32 )BIT (k); acpi_gbl_last_owner_id_index = (u8 )j; acpi_gbl_next_owner_id_offset = (u8)(k +1 );
drivers/acpi/acpica/utownerid.c void acpi_ut_release_owner_id(acpi_owner_id *owner_id_ptr) · line 174
Quoted 5 lines
drivers/acpi/acpica/utownerid.c +1
-1@@ -171,7 +171,7 @@ void acpi_ut_release_owner_id(acpi_owner_id *owner_id_ptr)/* Decode ID to index/offset pair */ index =ACPI_DIV_32 (owner_id); - bit = (u32 )1 <<ACPI_MOD_32 (owner_id); + bit = (u32 )BIT (ACPI_MOD_32 (owner_id));
Remove.
drivers/acpi/bus.c acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context) · line 236
Quoted 13 lines
drivers/acpi/acpica/utownerid.c +0
-0/* Free the owner ID only if it is valid */ drivers/acpi/bus.c +1
-1@@ -233,7 +233,7 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context) goto out_kfree; }/* Need to ignore the bit0 in result code */ - errors = *((u32 *)out_obj->buffer.pointer) & ~(1 <<0 ); + errors = *((u32 *)out_obj->buffer.pointer) &BIT (0 );
This removes the ~ so it totally breaks the code.
regards,
dan carpenter