diff mbox series

[v5,16/17] gpiolib: acpi: Use BIT() macro to increase readability

Message ID 20201109205332.19592-17-andriy.shevchenko@linux.intel.com
State Superseded
Headers show
Series gpiolib: acpi: pin configuration fixes | expand

Commit Message

Andy Shevchenko Nov. 9, 2020, 8:53 p.m. UTC
We may use BIT() macro to increase readability in
acpi_gpio_adr_space_handler().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpiolib-acpi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Mika Westerberg Nov. 11, 2020, 3:57 p.m. UTC | #1
On Mon, Nov 09, 2020 at 10:53:31PM +0200, Andy Shevchenko wrote:
> We may use BIT() macro to increase readability in

> acpi_gpio_adr_space_handler().

> 

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> ---

>  drivers/gpio/gpiolib-acpi.c | 3 +--

>  1 file changed, 1 insertion(+), 2 deletions(-)

> 

> diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c

> index 31008b0aef77..b9c3140cbd6d 100644

> --- a/drivers/gpio/gpiolib-acpi.c

> +++ b/drivers/gpio/gpiolib-acpi.c

> @@ -1097,8 +1097,7 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,

>  		mutex_unlock(&achip->conn_lock);

>  

>  		if (function == ACPI_WRITE)

> -			gpiod_set_raw_value_cansleep(desc,

> -						     !!((1 << i) & *value));

> +			gpiod_set_raw_value_cansleep(desc, !!(*value & BIT(i)));


Nit: Here I would use a helper variable to make it (much) more readable.

Anyway,

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Andy Shevchenko Nov. 11, 2020, 5:01 p.m. UTC | #2
On Wed, Nov 11, 2020 at 05:57:17PM +0200, Mika Westerberg wrote:
> On Mon, Nov 09, 2020 at 10:53:31PM +0200, Andy Shevchenko wrote:

> > We may use BIT() macro to increase readability in

> > acpi_gpio_adr_space_handler().

> > 

> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> > ---

> >  drivers/gpio/gpiolib-acpi.c | 3 +--

> >  1 file changed, 1 insertion(+), 2 deletions(-)

> > 

> > diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c

> > index 31008b0aef77..b9c3140cbd6d 100644

> > --- a/drivers/gpio/gpiolib-acpi.c

> > +++ b/drivers/gpio/gpiolib-acpi.c

> > @@ -1097,8 +1097,7 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,

> >  		mutex_unlock(&achip->conn_lock);

> >  

> >  		if (function == ACPI_WRITE)

> > -			gpiod_set_raw_value_cansleep(desc,

> > -						     !!((1 << i) & *value));

> > +			gpiod_set_raw_value_cansleep(desc, !!(*value & BIT(i)));

> 

> Nit: Here I would use a helper variable to make it (much) more readable.

> 

> Anyway,

> 

> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>


Thank you for review of almost all patches in the series!

I will try to address your comments against temporary variable in other
patches, but my motivation is quite similar to yours here.


-- 
With Best Regards,
Andy Shevchenko
diff mbox series

Patch

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 31008b0aef77..b9c3140cbd6d 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -1097,8 +1097,7 @@  acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
 		mutex_unlock(&achip->conn_lock);
 
 		if (function == ACPI_WRITE)
-			gpiod_set_raw_value_cansleep(desc,
-						     !!((1 << i) & *value));
+			gpiod_set_raw_value_cansleep(desc, !!(*value & BIT(i)));
 		else
 			*value |= (u64)gpiod_get_raw_value_cansleep(desc) << i;
 	}