diff options
author | Takashi Iwai <tiwai@suse.de> | 2021-06-08 17:05:39 +0300 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2021-06-09 18:30:37 +0300 |
commit | dd1431e53515e5760c03975a0a35aef75924a66d (patch) | |
tree | 8e2c58daaab2133b5cfd5a53afd9edab75dee761 /sound/i2c | |
parent | e73ad38871cb20bbe1a74306f3798828b4c40175 (diff) | |
download | linux-dd1431e53515e5760c03975a0a35aef75924a66d.tar.xz |
ALSA: i2c: Fix assignment in if condition
ALSA I2C helper drivers contain a few assignments in if condition,
which is a bad coding style that may confuse readers and occasionally
lead to bugs.
This patch is merely for coding-style fixes, no functional changes.
Link: https://lore.kernel.org/r/20210608140540.17885-66-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/i2c')
-rw-r--r-- | sound/i2c/cs8427.c | 24 | ||||
-rw-r--r-- | sound/i2c/other/ak4114.c | 3 | ||||
-rw-r--r-- | sound/i2c/other/ak4117.c | 3 | ||||
-rw-r--r-- | sound/i2c/tea6330t.c | 24 |
4 files changed, 36 insertions, 18 deletions
diff --git a/sound/i2c/cs8427.c b/sound/i2c/cs8427.c index 8634d4f466b3..65012af6a36e 100644 --- a/sound/i2c/cs8427.c +++ b/sound/i2c/cs8427.c @@ -50,7 +50,8 @@ int snd_cs8427_reg_write(struct snd_i2c_device *device, unsigned char reg, buf[0] = reg & 0x7f; buf[1] = val; - if ((err = snd_i2c_sendbytes(device, buf, 2)) != 2) { + err = snd_i2c_sendbytes(device, buf, 2); + if (err != 2) { snd_printk(KERN_ERR "unable to send bytes 0x%02x:0x%02x " "to CS8427 (%i)\n", buf[0], buf[1], err); return err < 0 ? err : -EIO; @@ -65,12 +66,14 @@ static int snd_cs8427_reg_read(struct snd_i2c_device *device, unsigned char reg) int err; unsigned char buf; - if ((err = snd_i2c_sendbytes(device, ®, 1)) != 1) { + err = snd_i2c_sendbytes(device, ®, 1); + if (err != 1) { snd_printk(KERN_ERR "unable to send register 0x%x byte " "to CS8427\n", reg); return err < 0 ? err : -EIO; } - if ((err = snd_i2c_readbytes(device, &buf, 1)) != 1) { + err = snd_i2c_readbytes(device, &buf, 1); + if (err != 1) { snd_printk(KERN_ERR "unable to read register 0x%x byte " "from CS8427\n", reg); return err < 0 ? err : -EIO; @@ -108,7 +111,8 @@ static int snd_cs8427_send_corudata(struct snd_i2c_device *device, if (!memcmp(hw_data, ndata, count)) return 0; - if ((err = snd_cs8427_select_corudata(device, udata)) < 0) + err = snd_cs8427_select_corudata(device, udata); + if (err < 0) return err; memcpy(hw_data, ndata, count); if (udata) { @@ -209,7 +213,8 @@ int snd_cs8427_init(struct snd_i2c_bus *bus, goto __fail; /* send initial values */ memcpy(chip->regmap + (initvals1[0] & 0x7f), initvals1 + 1, 6); - if ((err = snd_i2c_sendbytes(device, initvals1, 7)) != 7) { + err = snd_i2c_sendbytes(device, initvals1, 7); + if (err != 7) { err = err < 0 ? err : -EIO; goto __fail; } @@ -217,11 +222,13 @@ int snd_cs8427_init(struct snd_i2c_bus *bus, memset(buf, 0, 7); /* from address 9 to 15 */ buf[0] = 9; /* register */ - if ((err = snd_i2c_sendbytes(device, buf, 7)) != 7) + err = snd_i2c_sendbytes(device, buf, 7); + if (err != 7) goto __fail; /* send transfer initialization sequence */ memcpy(chip->regmap + (initvals2[0] & 0x7f), initvals2 + 1, 3); - if ((err = snd_i2c_sendbytes(device, initvals2, 4)) != 4) { + err = snd_i2c_sendbytes(device, initvals2, 4); + if (err != 4) { err = err < 0 ? err : -EIO; goto __fail; } @@ -383,7 +390,8 @@ static int snd_cs8427_qsubcode_get(struct snd_kcontrol *kcontrol, int err; snd_i2c_lock(device->bus); - if ((err = snd_i2c_sendbytes(device, ®, 1)) != 1) { + err = snd_i2c_sendbytes(device, ®, 1); + if (err != 1) { snd_printk(KERN_ERR "unable to send register 0x%x byte " "to CS8427\n", reg); snd_i2c_unlock(device->bus); diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c index 2ce0a97957ab..c0cffe28989b 100644 --- a/sound/i2c/other/ak4114.c +++ b/sound/i2c/other/ak4114.c @@ -97,7 +97,8 @@ int snd_ak4114_create(struct snd_card *card, chip->rcs0 = reg_read(chip, AK4114_REG_RCS0) & ~(AK4114_QINT | AK4114_CINT); chip->rcs1 = reg_read(chip, AK4114_REG_RCS1); - if ((err = snd_device_new(card, SNDRV_DEV_CODEC, chip, &ops)) < 0) + err = snd_device_new(card, SNDRV_DEV_CODEC, chip, &ops); + if (err < 0) goto __fail; if (r_ak4114) diff --git a/sound/i2c/other/ak4117.c b/sound/i2c/other/ak4117.c index 905be2d0780b..1bc43e927d82 100644 --- a/sound/i2c/other/ak4117.c +++ b/sound/i2c/other/ak4117.c @@ -86,7 +86,8 @@ int snd_ak4117_create(struct snd_card *card, ak4117_read_t *read, ak4117_write_t chip->rcs1 = reg_read(chip, AK4117_REG_RCS1); chip->rcs2 = reg_read(chip, AK4117_REG_RCS2); - if ((err = snd_device_new(card, SNDRV_DEV_CODEC, chip, &ops)) < 0) + err = snd_device_new(card, SNDRV_DEV_CODEC, chip, &ops); + if (err < 0) goto __fail; if (r_ak4117) diff --git a/sound/i2c/tea6330t.c b/sound/i2c/tea6330t.c index 08eb6a873768..742d0f724375 100644 --- a/sound/i2c/tea6330t.c +++ b/sound/i2c/tea6330t.c @@ -115,7 +115,8 @@ static int snd_tea6330t_put_master_volume(struct snd_kcontrol *kcontrol, bytes[count++] = tea->regs[TEA6330T_SADDR_VOLUME_RIGHT] = tea->mright; } if (count > 0) { - if ((err = snd_i2c_sendbytes(tea->device, bytes, count)) < 0) + err = snd_i2c_sendbytes(tea->device, bytes, count); + if (err < 0) change = err; } snd_i2c_unlock(tea->bus); @@ -160,7 +161,8 @@ static int snd_tea6330t_put_master_switch(struct snd_kcontrol *kcontrol, bytes[0] = TEA6330T_SADDR_VOLUME_LEFT; bytes[1] = tea->regs[TEA6330T_SADDR_VOLUME_LEFT]; bytes[2] = tea->regs[TEA6330T_SADDR_VOLUME_RIGHT]; - if ((err = snd_i2c_sendbytes(tea->device, bytes, 3)) < 0) + err = snd_i2c_sendbytes(tea->device, bytes, 3); + if (err < 0) change = err; snd_i2c_unlock(tea->bus); return change; @@ -207,7 +209,8 @@ static int snd_tea6330t_put_bass(struct snd_kcontrol *kcontrol, change = tea->regs[TEA6330T_SADDR_BASS] != val1; bytes[0] = TEA6330T_SADDR_BASS; bytes[1] = tea->regs[TEA6330T_SADDR_BASS] = val1; - if ((err = snd_i2c_sendbytes(tea->device, bytes, 2)) < 0) + err = snd_i2c_sendbytes(tea->device, bytes, 2); + if (err < 0) change = err; snd_i2c_unlock(tea->bus); return change; @@ -254,7 +257,8 @@ static int snd_tea6330t_put_treble(struct snd_kcontrol *kcontrol, change = tea->regs[TEA6330T_SADDR_TREBLE] != val1; bytes[0] = TEA6330T_SADDR_TREBLE; bytes[1] = tea->regs[TEA6330T_SADDR_TREBLE] = val1; - if ((err = snd_i2c_sendbytes(tea->device, bytes, 2)) < 0) + err = snd_i2c_sendbytes(tea->device, bytes, 2); + if (err < 0) change = err; snd_i2c_unlock(tea->bus); return change; @@ -287,7 +291,8 @@ int snd_tea6330t_update_mixer(struct snd_card *card, tea = kzalloc(sizeof(*tea), GFP_KERNEL); if (tea == NULL) return -ENOMEM; - if ((err = snd_i2c_device_create(bus, "TEA6330T", TEA6330T_ADDR, &device)) < 0) { + err = snd_i2c_device_create(bus, "TEA6330T", TEA6330T_ADDR, &device); + if (err < 0) { kfree(tea); return err; } @@ -327,18 +332,21 @@ int snd_tea6330t_update_mixer(struct snd_card *card, bytes[0] = TEA6330T_SADDR_VOLUME_LEFT; for (idx = 0; idx < 6; idx++) bytes[idx+1] = tea->regs[idx]; - if ((err = snd_i2c_sendbytes(device, bytes, 7)) < 0) + err = snd_i2c_sendbytes(device, bytes, 7); + if (err < 0) goto __error; strcat(card->mixername, ",TEA6330T"); - if ((err = snd_component_add(card, "TEA6330T")) < 0) + err = snd_component_add(card, "TEA6330T"); + if (err < 0) goto __error; for (idx = 0; idx < ARRAY_SIZE(snd_tea6330t_controls); idx++) { knew = &snd_tea6330t_controls[idx]; if (tea->treble == 0 && !strcmp(knew->name, "Tone Control - Treble")) continue; - if ((err = snd_ctl_add(card, snd_ctl_new1(knew, tea))) < 0) + err = snd_ctl_add(card, snd_ctl_new1(knew, tea)); + if (err < 0) goto __error; } |