diff mbox series

[RESEND,v2,8/8] Input: sx8654 - convert #defined flags to BIT(x)

Message ID 20181218084002.19454-1-richard.leitner@skidata.com (mailing list archive)
State Accepted
Commit aabcb424ff12accea6bfdf6a0e678a1b6f9094d1
Headers show
Series Input: sx8654 - reset-gpio, sx865[056] support, etc. | expand

Commit Message

Richard Leitner Dec. 18, 2018, 8:40 a.m. UTC
Some of the #defined register values are one-bit flags. Convert them to
use the BIT(x) macro instead of 1 byte hexadecimal values. This improves
readability and clarifies the intent.

Signed-off-by: Richard Leitner <richard.leitner@skidata.com>
---
 drivers/input/touchscreen/sx8654.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Dmitry Torokhov Jan. 29, 2019, 12:25 a.m. UTC | #1
On Tue, Dec 18, 2018 at 09:40:02AM +0100, Richard Leitner wrote:
> Some of the #defined register values are one-bit flags. Convert them to
> use the BIT(x) macro instead of 1 byte hexadecimal values. This improves
> readability and clarifies the intent.
> 
> Signed-off-by: Richard Leitner <richard.leitner@skidata.com>

Applied, thank you.

> ---
>  drivers/input/touchscreen/sx8654.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/sx8654.c b/drivers/input/touchscreen/sx8654.c
> index b7b263ed52af..3746ea855f94 100644
> --- a/drivers/input/touchscreen/sx8654.c
> +++ b/drivers/input/touchscreen/sx8654.c
> @@ -36,6 +36,7 @@
>  #include <linux/gpio/consumer.h>
>  #include <linux/delay.h>
>  #include <linux/input/touchscreen.h>
> +#include <linux/bitops.h>
>  
>  /* register addresses */
>  #define I2C_REG_TOUCH0			0x00
> @@ -46,7 +47,7 @@
>  #define I2C_REG_SOFTRESET		0x3f
>  
>  #define I2C_REG_SX8650_STAT		0x05
> -#define SX8650_STAT_CONVIRQ		0x80
> +#define SX8650_STAT_CONVIRQ		BIT(7)
>  
>  /* commands */
>  #define CMD_READ_REGISTER		0x40
> @@ -56,8 +57,8 @@
>  #define SOFTRESET_VALUE			0xde
>  
>  /* bits for I2C_REG_IRQSRC */
> -#define IRQ_PENTOUCH_TOUCHCONVDONE	0x08
> -#define IRQ_PENRELEASE			0x04
> +#define IRQ_PENTOUCH_TOUCHCONVDONE	BIT(7)
> +#define IRQ_PENRELEASE			BIT(6)
>  
>  /* bits for RegTouch1 */
>  #define CONDIRQ				0x20
> @@ -65,8 +66,8 @@
>  #define FILT_7SA			0x03
>  
>  /* bits for I2C_REG_CHANMASK */
> -#define CONV_X				0x80
> -#define CONV_Y				0x40
> +#define CONV_X				BIT(7)
> +#define CONV_Y				BIT(6)
>  
>  /* coordinates rate: higher nibble of CTRL0 register */
>  #define RATE_MANUAL			0x00
> -- 
> 2.11.0
>
Joe Perches Jan. 29, 2019, 5:40 a.m. UTC | #2
On Mon, 2019-01-28 at 16:25 -0800, Dmitry Torokhov wrote:
> On Tue, Dec 18, 2018 at 09:40:02AM +0100, Richard Leitner wrote:
> > Some of the #defined register values are one-bit flags. Convert them to
> > use the BIT(x) macro instead of 1 byte hexadecimal values. This improves
> > readability and clarifies the intent.
> > 
> > Signed-off-by: Richard Leitner <richard.leitner@skidata.com>
> 
> Applied, thank you.

Not so sure this should be applied.

> > diff --git a/drivers/input/touchscreen/sx8654.c b/drivers/input/touchscreen/sx8654.c
[]
> > @@ -46,7 +47,7 @@
[]
> >  /* bits for I2C_REG_IRQSRC */
> > -#define IRQ_PENTOUCH_TOUCHCONVDONE	0x08
> > -#define IRQ_PENRELEASE			0x04
> > +#define IRQ_PENTOUCH_TOUCHCONVDONE	BIT(7)
> > +#define IRQ_PENRELEASE			BIT(6)

Shouldn't this be BIT(3) and BIT(2)
or did you mean to change the values too?

If so, this change should be noted in the commit message.
Richard Leitner Jan. 29, 2019, 11:23 a.m. UTC | #3
Hi Joe,

On 29/01/2019 06:40, Joe Perches wrote:
> On Mon, 2019-01-28 at 16:25 -0800, Dmitry Torokhov wrote:
>> On Tue, Dec 18, 2018 at 09:40:02AM +0100, Richard Leitner wrote:
>>> Some of the #defined register values are one-bit flags. Convert them to
>>> use the BIT(x) macro instead of 1 byte hexadecimal values. This improves
>>> readability and clarifies the intent.
>>>
>>> Signed-off-by: Richard Leitner <richard.leitner@skidata.com>
>>
>> Applied, thank you.
> 
> Not so sure this should be applied.
> 
>>> diff --git a/drivers/input/touchscreen/sx8654.c b/drivers/input/touchscreen/sx8654.c
> []
>>> @@ -46,7 +47,7 @@
> []
>>>   /* bits for I2C_REG_IRQSRC */
>>> -#define IRQ_PENTOUCH_TOUCHCONVDONE	0x08
>>> -#define IRQ_PENRELEASE			0x04
>>> +#define IRQ_PENTOUCH_TOUCHCONVDONE	BIT(7)
>>> +#define IRQ_PENRELEASE			BIT(6)
> 
> Shouldn't this be BIT(3) and BIT(2)
> or did you mean to change the values too?
> 
> If so, this change should be noted in the commit message.
> 

That's true, those values should stay the same. Thanks for the catch!

@Dimitry: Should I send an updated version or do you fix it yourself?

regards;Richard.L
Dmitry Torokhov Feb. 5, 2019, 7:27 a.m. UTC | #4
On Tue, Jan 29, 2019 at 12:23:01PM +0100, Richard Leitner wrote:
> Hi Joe,
> 
> On 29/01/2019 06:40, Joe Perches wrote:
> > On Mon, 2019-01-28 at 16:25 -0800, Dmitry Torokhov wrote:
> > > On Tue, Dec 18, 2018 at 09:40:02AM +0100, Richard Leitner wrote:
> > > > Some of the #defined register values are one-bit flags. Convert them to
> > > > use the BIT(x) macro instead of 1 byte hexadecimal values. This improves
> > > > readability and clarifies the intent.
> > > > 
> > > > Signed-off-by: Richard Leitner <richard.leitner@skidata.com>
> > > 
> > > Applied, thank you.
> > 
> > Not so sure this should be applied.
> > 
> > > > diff --git a/drivers/input/touchscreen/sx8654.c b/drivers/input/touchscreen/sx8654.c
> > []
> > > > @@ -46,7 +47,7 @@
> > []
> > > >   /* bits for I2C_REG_IRQSRC */
> > > > -#define IRQ_PENTOUCH_TOUCHCONVDONE	0x08
> > > > -#define IRQ_PENRELEASE			0x04
> > > > +#define IRQ_PENTOUCH_TOUCHCONVDONE	BIT(7)
> > > > +#define IRQ_PENRELEASE			BIT(6)
> > 
> > Shouldn't this be BIT(3) and BIT(2)
> > or did you mean to change the values too?
> > 
> > If so, this change should be noted in the commit message.
> > 
> 
> That's true, those values should stay the same. Thanks for the catch!

Thanks Joe!

> 
> @Dimitry: Should I send an updated version or do you fix it yourself?
> 

I updated the values and pushed out the new version.

Thanks.
diff mbox series

Patch

diff --git a/drivers/input/touchscreen/sx8654.c b/drivers/input/touchscreen/sx8654.c
index b7b263ed52af..3746ea855f94 100644
--- a/drivers/input/touchscreen/sx8654.c
+++ b/drivers/input/touchscreen/sx8654.c
@@ -36,6 +36,7 @@ 
 #include <linux/gpio/consumer.h>
 #include <linux/delay.h>
 #include <linux/input/touchscreen.h>
+#include <linux/bitops.h>
 
 /* register addresses */
 #define I2C_REG_TOUCH0			0x00
@@ -46,7 +47,7 @@ 
 #define I2C_REG_SOFTRESET		0x3f
 
 #define I2C_REG_SX8650_STAT		0x05
-#define SX8650_STAT_CONVIRQ		0x80
+#define SX8650_STAT_CONVIRQ		BIT(7)
 
 /* commands */
 #define CMD_READ_REGISTER		0x40
@@ -56,8 +57,8 @@ 
 #define SOFTRESET_VALUE			0xde
 
 /* bits for I2C_REG_IRQSRC */
-#define IRQ_PENTOUCH_TOUCHCONVDONE	0x08
-#define IRQ_PENRELEASE			0x04
+#define IRQ_PENTOUCH_TOUCHCONVDONE	BIT(7)
+#define IRQ_PENRELEASE			BIT(6)
 
 /* bits for RegTouch1 */
 #define CONDIRQ				0x20
@@ -65,8 +66,8 @@ 
 #define FILT_7SA			0x03
 
 /* bits for I2C_REG_CHANMASK */
-#define CONV_X				0x80
-#define CONV_Y				0x40
+#define CONV_X				BIT(7)
+#define CONV_Y				BIT(6)
 
 /* coordinates rate: higher nibble of CTRL0 register */
 #define RATE_MANUAL			0x00