Linux-ACPI Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] trivial: acpi: replace some bitshifts with BIT macro
       [not found] <alpine.DEB.2.21.2007241814450.2834@hadrien>
@ 2020-07-24 16:20 ` Garrit Franke
  2020-07-24 16:29   ` Moore, Robert
  0 siblings, 1 reply; 8+ messages in thread
From: Garrit Franke @ 2020-07-24 16:20 UTC (permalink / raw)
  To: robert.moore, rafael.j.wysocki, lenb, trivial, linux-acpi, devel,
	kernel-janitors
  Cc: Garrit Franke

Signed-off-by: Garrit Franke <garritfranke@gmail.com>
---
 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(-)

diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c
index ade35ff1c7..92fc702456 100644
--- a/drivers/acpi/acpica/exfldio.c
+++ b/drivers/acpi/acpica/exfldio.c
@@ -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.
diff --git a/drivers/acpi/acpica/utownerid.c b/drivers/acpi/acpica/utownerid.c
index d3525ef8ed..c4e2db2f54 100644
--- a/drivers/acpi/acpica/utownerid.c
+++ b/drivers/acpi/acpica/utownerid.c
@@ -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 */
 
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 54002670cb..39ead80c45 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -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,
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index aff13bf4d9..38f5210313 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -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);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] trivial: acpi: replace some bitshifts with BIT macro
  2020-07-24 16:20 ` [PATCH] trivial: acpi: replace some bitshifts with BIT macro Garrit Franke
@ 2020-07-24 16:29   ` Moore, Robert
  2020-07-24 16:40     ` [Devel] " Colin Ian King
  2020-07-24 16:47     ` Garrit Franke
  0 siblings, 2 replies; 8+ messages in thread
From: Moore, Robert @ 2020-07-24 16:29 UTC (permalink / raw)
  To: Garrit Franke, Wysocki, Rafael J, lenb, trivial, linux-acpi,
	devel, kernel-janitors

Where is "BIT" defined?


-----Original Message-----
From: Garrit Franke <garritfranke@gmail.com> 
Sent: Friday, July 24, 2020 9:21 AM
To: Moore, Robert <robert.moore@intel.com>; Wysocki, Rafael J <rafael.j.wysocki@intel.com>; lenb@kernel.org; trivial@kernel.org; linux-acpi@vger.kernel.org; devel@acpica.org; kernel-janitors@vger.kernel.org
Cc: Garrit Franke <garritfranke@gmail.com>
Subject: [PATCH] trivial: acpi: replace some bitshifts with BIT macro

Signed-off-by: Garrit Franke <garritfranke@gmail.com>
---
 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(-)

diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c index ade35ff1c7..92fc702456 100644
--- a/drivers/acpi/acpica/exfldio.c
+++ b/drivers/acpi/acpica/exfldio.c
@@ -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.
diff --git a/drivers/acpi/acpica/utownerid.c b/drivers/acpi/acpica/utownerid.c index d3525ef8ed..c4e2db2f54 100644
--- a/drivers/acpi/acpica/utownerid.c
+++ b/drivers/acpi/acpica/utownerid.c
@@ -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 */
 
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 54002670cb..39ead80c45 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -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, diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index aff13bf4d9..38f5210313 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -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);
--
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Devel] Re: [PATCH] trivial: acpi: replace some bitshifts with BIT macro
  2020-07-24 16:29   ` Moore, Robert
@ 2020-07-24 16:40     ` Colin Ian King
  2020-07-24 16:47     ` Garrit Franke
  1 sibling, 0 replies; 8+ messages in thread
From: Colin Ian King @ 2020-07-24 16:40 UTC (permalink / raw)
  To: Moore, Robert, Garrit Franke, Wysocki, Rafael J, lenb, trivial,
	linux-acpi, devel, kernel-janitors

On 24/07/2020 17:29, Moore, Robert wrote:
> Where is "BIT" defined?

this is a linux macro, currently in include/vdso.bits.h, see also
linux/bits.h for the BIT_ULL() unsigned long long variant too.

> 
> 
> -----Original Message-----
> From: Garrit Franke <garritfranke@gmail.com> 
> Sent: Friday, July 24, 2020 9:21 AM
> To: Moore, Robert <robert.moore@intel.com>; Wysocki, Rafael J <rafael.j.wysocki@intel.com>; lenb@kernel.org; trivial@kernel.org; linux-acpi@vger.kernel.org; devel@acpica.org; kernel-janitors@vger.kernel.org
> Cc: Garrit Franke <garritfranke@gmail.com>
> Subject: [PATCH] trivial: acpi: replace some bitshifts with BIT macro
> 
> Signed-off-by: Garrit Franke <garritfranke@gmail.com>
> ---
>  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(-)
> 
> diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c index ade35ff1c7..92fc702456 100644
> --- a/drivers/acpi/acpica/exfldio.c
> +++ b/drivers/acpi/acpica/exfldio.c
> @@ -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.
> diff --git a/drivers/acpi/acpica/utownerid.c b/drivers/acpi/acpica/utownerid.c index d3525ef8ed..c4e2db2f54 100644
> --- a/drivers/acpi/acpica/utownerid.c
> +++ b/drivers/acpi/acpica/utownerid.c
> @@ -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 */
>  
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 54002670cb..39ead80c45 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -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, diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index aff13bf4d9..38f5210313 100644
> --- a/drivers/acpi/sleep.c
> +++ b/drivers/acpi/sleep.c
> @@ -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);
> --
> 2.25.1
> _______________________________________________
> Devel mailing list -- devel@acpica.org
> To unsubscribe send an email to devel-leave@acpica.org
> %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] trivial: acpi: replace some bitshifts with BIT macro
  2020-07-24 16:29   ` Moore, Robert
  2020-07-24 16:40     ` [Devel] " Colin Ian King
@ 2020-07-24 16:47     ` Garrit Franke
  2020-07-24 16:50       ` Moore, Robert
  2020-07-28 20:03       ` Moore, Robert
  1 sibling, 2 replies; 8+ messages in thread
From: Garrit Franke @ 2020-07-24 16:47 UTC (permalink / raw)
  To: Moore, Robert
  Cc: Wysocki, Rafael J, lenb, trivial, linux-acpi, devel, kernel-janitors

On Fri, 24 Jul 2020 16:29:14 +0000
"Moore, Robert" <robert.moore@intel.com> wrote:

> Where is "BIT" defined?

It is defined in multiple places (see include/vdso/bits.h for example),
therefore I blatently assumed that it would be defined. I'm quite new
to kernel development, and I'm learning along the way. Thank you for
pointing this out.

Would it make sense to copy this file to this drivers root, or is it
not worth the effort?

Thanks for your time
Garrit

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] trivial: acpi: replace some bitshifts with BIT macro
  2020-07-24 16:47     ` Garrit Franke
@ 2020-07-24 16:50       ` Moore, Robert
  2020-07-28 20:03       ` Moore, Robert
  1 sibling, 0 replies; 8+ messages in thread
From: Moore, Robert @ 2020-07-24 16:50 UTC (permalink / raw)
  To: Garrit Franke
  Cc: Wysocki, Rafael J, lenb, trivial, linux-acpi, devel, kernel-janitors

Well, since BIT is a linux macro only, we can't use it in ACPICA, because the code is compiler/environment independent.
Bob


-----Original Message-----
From: Garrit Franke <garritfranke@gmail.com> 
Sent: Friday, July 24, 2020 9:48 AM
To: Moore, Robert <robert.moore@intel.com>
Cc: Wysocki, Rafael J <rafael.j.wysocki@intel.com>; lenb@kernel.org; trivial@kernel.org; linux-acpi@vger.kernel.org; devel@acpica.org; kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] trivial: acpi: replace some bitshifts with BIT macro

On Fri, 24 Jul 2020 16:29:14 +0000
"Moore, Robert" <robert.moore@intel.com> wrote:

> Where is "BIT" defined?

It is defined in multiple places (see include/vdso/bits.h for example), therefore I blatently assumed that it would be defined. I'm quite new to kernel development, and I'm learning along the way. Thank you for pointing this out.

Would it make sense to copy this file to this drivers root, or is it not worth the effort?

Thanks for your time
Garrit

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] trivial: acpi: replace some bitshifts with BIT macro
  2020-07-24 16:47     ` Garrit Franke
  2020-07-24 16:50       ` Moore, Robert
@ 2020-07-28 20:03       ` Moore, Robert
  1 sibling, 0 replies; 8+ messages in thread
From: Moore, Robert @ 2020-07-28 20:03 UTC (permalink / raw)
  To: Garrit Franke
  Cc: Wysocki, Rafael J, lenb, trivial, linux-acpi, devel, kernel-janitors



-----Original Message-----
From: Garrit Franke <garritfranke@gmail.com> 
Sent: Friday, July 24, 2020 9:48 AM
To: Moore, Robert <robert.moore@intel.com>
Cc: Wysocki, Rafael J <rafael.j.wysocki@intel.com>; lenb@kernel.org; trivial@kernel.org; linux-acpi@vger.kernel.org; devel@acpica.org; kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] trivial: acpi: replace some bitshifts with BIT macro

On Fri, 24 Jul 2020 16:29:14 +0000
"Moore, Robert" <robert.moore@intel.com> wrote:

> Where is "BIT" defined?

It is defined in multiple places (see include/vdso/bits.h for example), therefore I blatently assumed that it would be defined. I'm quite new to kernel development, and I'm learning along the way. Thank you for pointing this out.

Would it make sense to copy this file to this drivers root, or is it not worth the effort?

I'm not sure that it is worth the effort. Linux is not the only OS supported (and GCC is not the only compiler supported) by ACPICA.


Thanks for your time
Garrit

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] trivial: acpi: replace some bitshifts with BIT macro
  2020-07-24 16:02 garritfra
@ 2020-07-27 12:48 ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2020-07-27 12:48 UTC (permalink / raw)
  To: garritfra
  Cc: robert.moore, rafael.j.wysocki, lenb, trivial, linux-acpi, devel,
	kernel-janitors

This patch introduces two bugs, so perhaps don't send risky changes to
the trivial tree.

On Fri, Jul 24, 2020 at 06:02:39PM +0200, garritfra wrote:
> Signed-off-by: garritfra <garritfranke@gmail.com>

You need a commit message, and your full legal name for both the
From and the Signing.


> ---
>  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(-)
> 
> diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c
> index ade35ff1c7..92fc702456 100644
> --- a/drivers/acpi/acpica/exfldio.c
> +++ b/drivers/acpi/acpica/exfldio.c
> @@ -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.

>  		/*
>  		 * The Value is larger than the maximum value that can fit into
>  		 * the register.
> diff --git a/drivers/acpi/acpica/utownerid.c b/drivers/acpi/acpica/utownerid.c
> index d3525ef8ed..c4e2db2f54 100644
> --- a/drivers/acpi/acpica/utownerid.c
> +++ b/drivers/acpi/acpica/utownerid.c
> @@ -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.

>  				/*
>  				 * 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));

Remove.

>  
>  	/* Free the owner ID only if it is valid */
>  
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index 54002670cb..39ead80c45 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] trivial: acpi: replace some bitshifts with BIT macro
@ 2020-07-24 16:02 garritfra
  2020-07-27 12:48 ` Dan Carpenter
  0 siblings, 1 reply; 8+ messages in thread
From: garritfra @ 2020-07-24 16:02 UTC (permalink / raw)
  To: robert.moore, rafael.j.wysocki, lenb, trivial, linux-acpi, devel,
	kernel-janitors
  Cc: garritfra

Signed-off-by: garritfra <garritfranke@gmail.com>
---
 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(-)

diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c
index ade35ff1c7..92fc702456 100644
--- a/drivers/acpi/acpica/exfldio.c
+++ b/drivers/acpi/acpica/exfldio.c
@@ -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.
diff --git a/drivers/acpi/acpica/utownerid.c b/drivers/acpi/acpica/utownerid.c
index d3525ef8ed..c4e2db2f54 100644
--- a/drivers/acpi/acpica/utownerid.c
+++ b/drivers/acpi/acpica/utownerid.c
@@ -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 */
 
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 54002670cb..39ead80c45 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -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,
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index aff13bf4d9..38f5210313 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -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);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, back to index

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <alpine.DEB.2.21.2007241814450.2834@hadrien>
2020-07-24 16:20 ` [PATCH] trivial: acpi: replace some bitshifts with BIT macro Garrit Franke
2020-07-24 16:29   ` Moore, Robert
2020-07-24 16:40     ` [Devel] " Colin Ian King
2020-07-24 16:47     ` Garrit Franke
2020-07-24 16:50       ` Moore, Robert
2020-07-28 20:03       ` Moore, Robert
2020-07-24 16:02 garritfra
2020-07-27 12:48 ` Dan Carpenter

Linux-ACPI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-acpi/0 linux-acpi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-acpi linux-acpi/ https://lore.kernel.org/linux-acpi \
		linux-acpi@vger.kernel.org
	public-inbox-index linux-acpi

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-acpi


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git