[PATCH] mfd: menf21bmc: inline i2c_check_functionality check

Thorsten Blum posted 1 patch 1 month, 2 weeks ago
drivers/mfd/menf21bmc.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
[PATCH] mfd: menf21bmc: inline i2c_check_functionality check
Posted by Thorsten Blum 1 month, 2 weeks ago
Inline the i2c_check_functionality() check, since the function returns a
boolean status rather than an error code.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/mfd/menf21bmc.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/mfd/menf21bmc.c b/drivers/mfd/menf21bmc.c
index 1d36095155e0..0f24de516d72 100644
--- a/drivers/mfd/menf21bmc.c
+++ b/drivers/mfd/menf21bmc.c
@@ -54,11 +54,9 @@ menf21bmc_probe(struct i2c_client *client)
 	int rev_major, rev_minor, rev_main;
 	int ret;
 
-	ret = i2c_check_functionality(client->adapter,
-				      I2C_FUNC_SMBUS_BYTE_DATA |
-				      I2C_FUNC_SMBUS_WORD_DATA |
-				      I2C_FUNC_SMBUS_BYTE);
-	if (!ret)
+	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA |
+						      I2C_FUNC_SMBUS_WORD_DATA |
+						      I2C_FUNC_SMBUS_BYTE))
 		return -ENODEV;
 
 	rev_major = i2c_smbus_read_word_data(client, BMC_CMD_REV_MAJOR);
Re: (subset) [PATCH] mfd: menf21bmc: inline i2c_check_functionality check
Posted by Lee Jones 1 month ago
On Tue, 28 Apr 2026 18:58:01 +0200, Thorsten Blum wrote:
> Inline the i2c_check_functionality() check, since the function returns a
> boolean status rather than an error code.

Applied, thanks!

[1/1] mfd: menf21bmc: inline i2c_check_functionality check
      commit: 20a343984ff8daca514325fc208f9f56a4b2d1c0

--
Lee Jones [李琼斯]

Re: [PATCH] mfd: menf21bmc: inline i2c_check_functionality check
Posted by Lee Jones 1 month, 1 week ago
On Tue, 28 Apr 2026, Thorsten Blum wrote:

> Inline the i2c_check_functionality() check, since the function returns a
> boolean status rather than an error code.

This my well be a personal thing, but I don't generally like functions
being stuffed into if () statements.  So this one is a no I'm afraid.
Please leave it as it is.

> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  drivers/mfd/menf21bmc.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/mfd/menf21bmc.c b/drivers/mfd/menf21bmc.c
> index 1d36095155e0..0f24de516d72 100644
> --- a/drivers/mfd/menf21bmc.c
> +++ b/drivers/mfd/menf21bmc.c
> @@ -54,11 +54,9 @@ menf21bmc_probe(struct i2c_client *client)
>  	int rev_major, rev_minor, rev_main;
>  	int ret;
>  
> -	ret = i2c_check_functionality(client->adapter,
> -				      I2C_FUNC_SMBUS_BYTE_DATA |
> -				      I2C_FUNC_SMBUS_WORD_DATA |
> -				      I2C_FUNC_SMBUS_BYTE);
> -	if (!ret)
> +	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA |
> +						      I2C_FUNC_SMBUS_WORD_DATA |
> +						      I2C_FUNC_SMBUS_BYTE))
>  		return -ENODEV;
>  
>  	rev_major = i2c_smbus_read_word_data(client, BMC_CMD_REV_MAJOR);

-- 
Lee Jones
Re: [PATCH] mfd: menf21bmc: inline i2c_check_functionality check
Posted by Thorsten Blum 1 month, 1 week ago
Hi Lee,

On Thu, May 07, 2026 at 02:47:08PM +0100, Lee Jones wrote:
> On Tue, 28 Apr 2026, Thorsten Blum wrote:
> 
> > Inline the i2c_check_functionality() check, since the function returns a
> > boolean status rather than an error code.
> 
> This my well be a personal thing, but I don't generally like functions
> being stuffed into if () statements.  So this one is a no I'm afraid.
> Please leave it as it is.

Wolfram (cc'ed) asked me to change the call sites before applying this
patch:

https://lore.kernel.org/lkml/20260421161607.61314-3-thorsten.blum@linux.dev/

Also, nearly all i2c_check_functionality() call sites already use it as
a boolean value. There are only 2-3 call sites left where it's still
used as an int.

Should I send a v2 with a local bool variable, or would you reconsider
inlining it?

Thanks,
Thorsten