mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sound/i2c: Simplify the return expression of snd_i2c_bit_sendbyte()
@ 2021-03-23 12:14 caizhichao
  2021-03-23 13:27 ` Johan Hovold
  0 siblings, 1 reply; 2+ messages in thread
From: caizhichao @ 2021-03-23 12:14 UTC (permalink / raw)
  To: perex, tiwai; +Cc: linux-kernel, alsa-devel, Zhichao Cai

From: Zhichao Cai <caizhichao@yulong.com>

Simplify the return expression.

Signed-off-by: Zhichao Cai <caizhichao@yulong.com>
---
 sound/i2c/i2c.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sound/i2c/i2c.c b/sound/i2c/i2c.c
index 847e3b6..dfcc87e 100644
--- a/sound/i2c/i2c.c
+++ b/sound/i2c/i2c.c
@@ -235,9 +235,7 @@ static int snd_i2c_bit_sendbyte(struct snd_i2c_bus *bus, unsigned char data)
 	for (i = 7; i >= 0; i--)
 		snd_i2c_bit_send(bus, !!(data & (1 << i)));
 	err = snd_i2c_bit_ack(bus);
-	if (err < 0)
-		return err;
-	return 0;
+	return err < 0 ? err : 0;
 }
 
 static int snd_i2c_bit_readbyte(struct snd_i2c_bus *bus, int last)
-- 
1.9.1



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

* Re: [PATCH] sound/i2c: Simplify the return expression of snd_i2c_bit_sendbyte()
  2021-03-23 12:14 [PATCH] sound/i2c: Simplify the return expression of snd_i2c_bit_sendbyte() caizhichao
@ 2021-03-23 13:27 ` Johan Hovold
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2021-03-23 13:27 UTC (permalink / raw)
  To: caizhichao; +Cc: perex, tiwai, linux-kernel, alsa-devel, Zhichao Cai

On Tue, Mar 23, 2021 at 08:14:43PM +0800, caizhichao wrote:
> From: Zhichao Cai <caizhichao@yulong.com>
> 
> Simplify the return expression.
> 
> Signed-off-by: Zhichao Cai <caizhichao@yulong.com>
> ---
>  sound/i2c/i2c.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/sound/i2c/i2c.c b/sound/i2c/i2c.c
> index 847e3b6..dfcc87e 100644
> --- a/sound/i2c/i2c.c
> +++ b/sound/i2c/i2c.c
> @@ -235,9 +235,7 @@ static int snd_i2c_bit_sendbyte(struct snd_i2c_bus *bus, unsigned char data)
>  	for (i = 7; i >= 0; i--)
>  		snd_i2c_bit_send(bus, !!(data & (1 << i)));
>  	err = snd_i2c_bit_ack(bus);
> -	if (err < 0)
> -		return err;
> -	return 0;
> +	return err < 0 ? err : 0;

This isn't a simplification, you're just making the code harder to read
for no good reason.

>  }
>  
>  static int snd_i2c_bit_readbyte(struct snd_i2c_bus *bus, int last)

Johan

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

end of thread, other threads:[~2021-03-23 13:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-23 12:14 [PATCH] sound/i2c: Simplify the return expression of snd_i2c_bit_sendbyte() caizhichao
2021-03-23 13:27 ` Johan Hovold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®