staging: sm750fb: Convert sw_i2c_read_sda to return bool
PATCH v3 1/1 staging: sm750fb: Convert sw_i2c_read_sda to return bool
The sw_i2c_read_sda() function currently returns unsigned char (1 or 0). Standardize it to return bool (true or false) to match kernel standards.
---
v3:
- Add version history (Reported by kernel test robot).
v2:
- Fix invalid "Unix Antigravity" Signed-off-by.
- Submit as standalone patch (detached from unrelated series).
drivers/staging/sm750fb/ddk750_swi2c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/sm750fb/ddk750_swi2c.c +3 -3
@@ -180,7 +180,7 @@ static void sw_i2c_sda(unsigned char value)* Return Value: * The SDA data bit sent by the Slave */ -static unsigned char sw_i2c_read_sda (void ) +static bool sw_i2c_read_sda (void ) {unsigned long gpio_dir;unsigned long gpio_data;
@@ -196,9 +196,9 @@ static unsigned char sw_i2c_read_sda(void)/* Now read the SDA line */ gpio_data =peek32 (sw_i2c_data_gpio_data_reg);if (gpio_data & (1 << sw_i2c_data_gpio)) -return 1 ; +return true;else -return 0 ; +return false; }/*
Signature · 1 line
2.43.0
Greg KH
maintainerQuoted 19 lines · Karthikey Kadati
The
sw_i2c_read_sda()function currently returns unsigned char (1 or 0). Standardize it to return bool (true or false) to match kernel standards.Signed-off-by Karthikey Kadati <[email protected]>---
v3:
- Add version history (Reported by kernel test robot).
v2:
- Fix invalid "Unix Antigravity" Signed-off-by.
- Submit as standalone patch (detached from unrelated series).drivers/staging/sm750fb/ddk750_swi2c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/staging/sm750fb/ddk750_swi2c.c +0
-0
drivers/staging/sm750fb/ddk750_swi2c.c static void sw_i2c_sda(unsigned char value) · line 183
Quoted 5 lines
drivers/staging/sm750fb/ddk750_swi2c.c +1
-1@@ -180,7 +180,7 @@ static void sw_i2c_sda(unsigned char value)* Return Value: * The SDA data bit sent by the Slave */ -static unsigned char sw_i2c_read_sda (void ) +static bool sw_i2c_read_sda (void )
So how does this call:
data |= (sw_i2c_read_sda() << i);
work with a boolean?
confused,
greg k-h
You are right. I overlooked that the return value is used in bitwise shift operations used to construct the data byte.
Since sw_i2c_read_sda() returns a raw data bit (0 or 1) intended for shifting, bool is semantically incorrect here.
I will drop this patch.
Thanks,
Karthikey
Quoted 34 lines · Greg KH
Quoted 19 lines · Karthikey Kadati
The
sw_i2c_read_sda()function currently returns unsigned char (1 or 0). Standardize it to return bool (true or false) to match kernel standards.Signed-off-by Karthikey Kadati <[email protected]>---
v3:
- Add version history (Reported by kernel test robot).
v2:
- Fix invalid "Unix Antigravity" Signed-off-by.
- Submit as standalone patch (detached from unrelated series).drivers/staging/sm750fb/ddk750_swi2c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/staging/sm750fb/ddk750_swi2c.c +0
-0drivers/staging/sm750fb/ddk750_swi2c.c static void sw_i2c_sda(unsigned char value) · line 183
Quoted 5 lines
drivers/staging/sm750fb/ddk750_swi2c.c +1
-1@@ -180,7 +180,7 @@ static void sw_i2c_sda(unsigned char value)* Return Value: * The SDA data bit sent by the Slave */ -static unsigned char sw_i2c_read_sda (void ) +static bool sw_i2c_read_sda (void )So how does this call:
data |= (sw_i2c_read_sda() << i);work with a boolean?
confused,
greg k-h