Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: vx: Fix assignment in if condition

VX driver helper code contains lots of 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-61-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>

+95 -48
+40 -20
sound/drivers/vx/vx_core.c
··· 110 110 { 111 111 int err; 112 112 113 - if ((err = vx_reset_chk(chip)) < 0) 113 + err = vx_reset_chk(chip); 114 + if (err < 0) 114 115 return err; 115 116 116 117 /* irq MESS_READ/WRITE_END */ 117 - if ((err = vx_send_irq_dsp(chip, cmd)) < 0) 118 + err = vx_send_irq_dsp(chip, cmd); 119 + if (err < 0) 118 120 return err; 119 121 120 122 /* Wait CHK = 1 */ 121 - if ((err = vx_wait_isr_bit(chip, ISR_CHK)) < 0) 123 + err = vx_wait_isr_bit(chip, ISR_CHK); 124 + if (err < 0) 122 125 return err; 123 126 124 127 /* If error, Read RX */ 125 - if ((err = vx_inb(chip, ISR)) & ISR_ERR) { 126 - if ((err = vx_wait_for_rx_full(chip)) < 0) { 128 + err = vx_inb(chip, ISR); 129 + if (err & ISR_ERR) { 130 + err = vx_wait_for_rx_full(chip); 131 + if (err < 0) { 127 132 snd_printd(KERN_DEBUG "transfer_end: error in rx_full\n"); 128 133 return err; 129 134 } ··· 237 232 if (chip->chip_status & VX_STAT_IS_STALE) 238 233 return -EBUSY; 239 234 240 - if ((err = vx_reset_chk(chip)) < 0) { 235 + err = vx_reset_chk(chip); 236 + if (err < 0) { 241 237 snd_printd(KERN_DEBUG "vx_send_msg: vx_reset_chk error\n"); 242 238 return err; 243 239 } ··· 260 254 rmh->Cmd[0] &= MASK_1_WORD_COMMAND; 261 255 262 256 /* Wait for TX empty */ 263 - if ((err = vx_wait_isr_bit(chip, ISR_TX_EMPTY)) < 0) { 257 + err = vx_wait_isr_bit(chip, ISR_TX_EMPTY); 258 + if (err < 0) { 264 259 snd_printd(KERN_DEBUG "vx_send_msg: wait tx empty error\n"); 265 260 return err; 266 261 } ··· 272 265 vx_outb(chip, TXL, rmh->Cmd[0] & 0xff); 273 266 274 267 /* Trigger irq MESSAGE */ 275 - if ((err = vx_send_irq_dsp(chip, IRQ_MESSAGE)) < 0) { 268 + err = vx_send_irq_dsp(chip, IRQ_MESSAGE); 269 + if (err < 0) { 276 270 snd_printd(KERN_DEBUG "vx_send_msg: send IRQ_MESSAGE error\n"); 277 271 return err; 278 272 } 279 273 280 274 /* Wait for CHK = 1 */ 281 - if ((err = vx_wait_isr_bit(chip, ISR_CHK)) < 0) 275 + err = vx_wait_isr_bit(chip, ISR_CHK); 276 + if (err < 0) 282 277 return err; 283 278 284 279 /* If error, get error value from RX */ 285 280 if (vx_inb(chip, ISR) & ISR_ERR) { 286 - if ((err = vx_wait_for_rx_full(chip)) < 0) { 281 + err = vx_wait_for_rx_full(chip); 282 + if (err < 0) { 287 283 snd_printd(KERN_DEBUG "vx_send_msg: rx_full read error\n"); 288 284 return err; 289 285 } ··· 302 292 if (rmh->LgCmd > 1) { 303 293 for (i = 1; i < rmh->LgCmd; i++) { 304 294 /* Wait for TX ready */ 305 - if ((err = vx_wait_isr_bit(chip, ISR_TX_READY)) < 0) { 295 + err = vx_wait_isr_bit(chip, ISR_TX_READY); 296 + if (err < 0) { 306 297 snd_printd(KERN_DEBUG "vx_send_msg: tx_ready error\n"); 307 298 return err; 308 299 } ··· 314 303 vx_outb(chip, TXL, rmh->Cmd[i] & 0xff); 315 304 316 305 /* Trigger irq MESS_READ_NEXT */ 317 - if ((err = vx_send_irq_dsp(chip, IRQ_MESS_READ_NEXT)) < 0) { 306 + err = vx_send_irq_dsp(chip, IRQ_MESS_READ_NEXT); 307 + if (err < 0) { 318 308 snd_printd(KERN_DEBUG "vx_send_msg: IRQ_READ_NEXT error\n"); 319 309 return err; 320 310 } 321 311 } 322 312 /* Wait for TX empty */ 323 - if ((err = vx_wait_isr_bit(chip, ISR_TX_READY)) < 0) { 313 + err = vx_wait_isr_bit(chip, ISR_TX_READY); 314 + if (err < 0) { 324 315 snd_printd(KERN_DEBUG "vx_send_msg: TX_READY error\n"); 325 316 return err; 326 317 } ··· 375 362 #if 0 376 363 printk(KERN_DEBUG "send_rih: cmd = 0x%x\n", cmd); 377 364 #endif 378 - if ((err = vx_reset_chk(chip)) < 0) 365 + err = vx_reset_chk(chip); 366 + if (err < 0) 379 367 return err; 380 368 /* send the IRQ */ 381 - if ((err = vx_send_irq_dsp(chip, cmd)) < 0) 369 + err = vx_send_irq_dsp(chip, cmd); 370 + if (err < 0) 382 371 return err; 383 372 /* Wait CHK = 1 */ 384 - if ((err = vx_wait_isr_bit(chip, ISR_CHK)) < 0) 373 + err = vx_wait_isr_bit(chip, ISR_CHK); 374 + if (err < 0) 385 375 return err; 386 376 /* If error, read RX */ 387 377 if (vx_inb(chip, ISR) & ISR_ERR) { 388 - if ((err = vx_wait_for_rx_full(chip)) < 0) 378 + err = vx_wait_for_rx_full(chip); 379 + if (err < 0) 389 380 return err; 390 381 err = vx_inb(chip, RXH) << 16; 391 382 err |= vx_inb(chip, RXM) << 8; ··· 665 648 vx_reset_board(chip, cold_reset); 666 649 vx_validate_irq(chip, 0); 667 650 668 - if ((err = snd_vx_load_boot_image(chip, boot)) < 0) 651 + err = snd_vx_load_boot_image(chip, boot); 652 + if (err < 0) 669 653 return err; 670 654 msleep(10); 671 655 ··· 696 678 for (i = 0; i < dsp->size; i += 3) { 697 679 image = dsp->data + i; 698 680 /* Wait DSP ready for a new read */ 699 - if ((err = vx_wait_isr_bit(chip, ISR_TX_EMPTY)) < 0) { 681 + err = vx_wait_isr_bit(chip, ISR_TX_EMPTY); 682 + if (err < 0) { 700 683 printk(KERN_ERR 701 684 "dsp loading error at position %d\n", i); 702 685 return err; ··· 717 698 718 699 msleep(200); 719 700 720 - if ((err = vx_wait_isr_bit(chip, ISR_CHK)) < 0) 701 + err = vx_wait_isr_bit(chip, ISR_CHK); 702 + if (err < 0) 721 703 return err; 722 704 723 705 vx_toggle_dac_mute(chip, 0);
+8 -4
sound/drivers/vx/vx_hwdep.c
··· 78 78 79 79 /* ok, we reached to the last one */ 80 80 /* create the devices if not built yet */ 81 - if ((err = snd_vx_pcm_new(chip)) < 0) 81 + err = snd_vx_pcm_new(chip); 82 + if (err < 0) 82 83 return err; 83 84 84 - if ((err = snd_vx_mixer_new(chip)) < 0) 85 + err = snd_vx_mixer_new(chip); 86 + if (err < 0) 85 87 return err; 86 88 87 - if (chip->ops->add_controls) 88 - if ((err = chip->ops->add_controls(chip)) < 0) 89 + if (chip->ops->add_controls) { 90 + err = chip->ops->add_controls(chip); 91 + if (err < 0) 89 92 return err; 93 + } 90 94 91 95 chip->chip_status |= VX_STAT_DEVICE_INIT; 92 96 chip->chip_status |= VX_STAT_CHIP_INIT;
+26 -13
sound/drivers/vx/vx_mixer.c
··· 910 910 temp = vx_control_output_level; 911 911 temp.index = i; 912 912 temp.tlv.p = chip->hw->output_level_db_scale; 913 - if ((err = snd_ctl_add(card, snd_ctl_new1(&temp, chip))) < 0) 913 + err = snd_ctl_add(card, snd_ctl_new1(&temp, chip)); 914 + if (err < 0) 914 915 return err; 915 916 } 916 917 ··· 922 921 temp.index = i; 923 922 temp.name = "PCM Playback Volume"; 924 923 temp.private_value = val; 925 - if ((err = snd_ctl_add(card, snd_ctl_new1(&temp, chip))) < 0) 924 + err = snd_ctl_add(card, snd_ctl_new1(&temp, chip)); 925 + if (err < 0) 926 926 return err; 927 927 temp = vx_control_output_switch; 928 928 temp.index = i; 929 929 temp.private_value = val; 930 - if ((err = snd_ctl_add(card, snd_ctl_new1(&temp, chip))) < 0) 930 + err = snd_ctl_add(card, snd_ctl_new1(&temp, chip)); 931 + if (err < 0) 931 932 return err; 932 933 temp = vx_control_monitor_gain; 933 934 temp.index = i; 934 935 temp.private_value = val; 935 - if ((err = snd_ctl_add(card, snd_ctl_new1(&temp, chip))) < 0) 936 + err = snd_ctl_add(card, snd_ctl_new1(&temp, chip)); 937 + if (err < 0) 936 938 return err; 937 939 temp = vx_control_monitor_switch; 938 940 temp.index = i; 939 941 temp.private_value = val; 940 - if ((err = snd_ctl_add(card, snd_ctl_new1(&temp, chip))) < 0) 942 + err = snd_ctl_add(card, snd_ctl_new1(&temp, chip)); 943 + if (err < 0) 941 944 return err; 942 945 } 943 946 for (i = 0; i < chip->hw->num_outs; i++) { ··· 949 944 temp.index = i; 950 945 temp.name = "PCM Capture Volume"; 951 946 temp.private_value = (i * 2) | (1 << 8); 952 - if ((err = snd_ctl_add(card, snd_ctl_new1(&temp, chip))) < 0) 947 + err = snd_ctl_add(card, snd_ctl_new1(&temp, chip)); 948 + if (err < 0) 953 949 return err; 954 950 } 955 951 956 952 /* Audio source */ 957 - if ((err = snd_ctl_add(card, snd_ctl_new1(&vx_control_audio_src, chip))) < 0) 953 + err = snd_ctl_add(card, snd_ctl_new1(&vx_control_audio_src, chip)); 954 + if (err < 0) 958 955 return err; 959 956 /* clock mode */ 960 - if ((err = snd_ctl_add(card, snd_ctl_new1(&vx_control_clock_mode, chip))) < 0) 957 + err = snd_ctl_add(card, snd_ctl_new1(&vx_control_clock_mode, chip)); 958 + if (err < 0) 961 959 return err; 962 960 /* IEC958 controls */ 963 - if ((err = snd_ctl_add(card, snd_ctl_new1(&vx_control_iec958_mask, chip))) < 0) 961 + err = snd_ctl_add(card, snd_ctl_new1(&vx_control_iec958_mask, chip)); 962 + if (err < 0) 964 963 return err; 965 - if ((err = snd_ctl_add(card, snd_ctl_new1(&vx_control_iec958, chip))) < 0) 964 + err = snd_ctl_add(card, snd_ctl_new1(&vx_control_iec958, chip)); 965 + if (err < 0) 966 966 return err; 967 967 /* VU, peak, saturation meters */ 968 968 for (c = 0; c < 2; c++) { ··· 978 968 temp = vx_control_saturation; 979 969 temp.index = i; 980 970 temp.private_value = val; 981 - if ((err = snd_ctl_add(card, snd_ctl_new1(&temp, chip))) < 0) 971 + err = snd_ctl_add(card, snd_ctl_new1(&temp, chip)); 972 + if (err < 0) 982 973 return err; 983 974 } 984 975 sprintf(name, "%s VU Meter", dir[c]); ··· 987 976 temp.index = i; 988 977 temp.name = name; 989 978 temp.private_value = val; 990 - if ((err = snd_ctl_add(card, snd_ctl_new1(&temp, chip))) < 0) 979 + err = snd_ctl_add(card, snd_ctl_new1(&temp, chip)); 980 + if (err < 0) 991 981 return err; 992 982 sprintf(name, "%s Peak Meter", dir[c]); 993 983 temp = vx_control_peak_meter; 994 984 temp.index = i; 995 985 temp.name = name; 996 986 temp.private_value = val; 997 - if ((err = snd_ctl_add(card, snd_ctl_new1(&temp, chip))) < 0) 987 + err = snd_ctl_add(card, snd_ctl_new1(&temp, chip)); 988 + if (err < 0) 998 989 return err; 999 990 } 1000 991 }
+21 -11
sound/drivers/vx/vx_pcm.c
··· 341 341 } 342 342 } 343 343 344 - if ((err = vx_conf_pipe(chip, pipe)) < 0) 344 + err = vx_conf_pipe(chip, pipe); 345 + if (err < 0) 345 346 return err; 346 347 347 - if ((err = vx_send_irqa(chip)) < 0) 348 + err = vx_send_irqa(chip); 349 + if (err < 0) 348 350 return err; 349 351 350 352 /* If it completes successfully, wait for the pipes ··· 682 680 if (! pipe->prepared || (chip->chip_status & VX_STAT_IS_STALE)) 683 681 return; 684 682 for (i = 0; i < nchunks; i++) { 685 - if ((err = vx_pcm_playback_transfer_chunk(chip, runtime, pipe, 686 - chip->ibl.size)) < 0) 683 + err = vx_pcm_playback_transfer_chunk(chip, runtime, pipe, 684 + chip->ibl.size); 685 + if (err < 0) 687 686 return; 688 687 } 689 688 } ··· 701 698 struct snd_pcm_runtime *runtime = subs->runtime; 702 699 703 700 if (pipe->running && ! (chip->chip_status & VX_STAT_IS_STALE)) { 704 - if ((err = vx_update_pipe_position(chip, runtime, pipe)) < 0) 701 + err = vx_update_pipe_position(chip, runtime, pipe); 702 + if (err < 0) 705 703 return; 706 704 if (pipe->transferred >= (int)runtime->period_size) { 707 705 pipe->transferred %= runtime->period_size; ··· 751 747 pipe->running = 0; 752 748 break; 753 749 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 754 - if ((err = vx_toggle_pipe(chip, pipe, 0)) < 0) 750 + err = vx_toggle_pipe(chip, pipe, 0); 751 + if (err < 0) 755 752 return err; 756 753 break; 757 754 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 758 - if ((err = vx_toggle_pipe(chip, pipe, 1)) < 0) 755 + err = vx_toggle_pipe(chip, pipe, 1); 756 + if (err < 0) 759 757 return err; 760 758 break; 761 759 default: ··· 798 792 snd_printdd(KERN_DEBUG "reopen the pipe with data_mode = %d\n", data_mode); 799 793 vx_init_rmh(&rmh, CMD_FREE_PIPE); 800 794 vx_set_pipe_cmd_params(&rmh, 0, pipe->number, 0); 801 - if ((err = vx_send_msg(chip, &rmh)) < 0) 795 + err = vx_send_msg(chip, &rmh); 796 + if (err < 0) 802 797 return err; 803 798 vx_init_rmh(&rmh, CMD_RES_PIPE); 804 799 vx_set_pipe_cmd_params(&rmh, 0, pipe->number, pipe->channels); 805 800 if (data_mode) 806 801 rmh.Cmd[0] |= BIT_DATA_MODE; 807 - if ((err = vx_send_msg(chip, &rmh)) < 0) 802 + err = vx_send_msg(chip, &rmh); 803 + if (err < 0) 808 804 return err; 809 805 pipe->data_mode = data_mode; 810 806 } ··· 818 810 } 819 811 vx_set_clock(chip, runtime->rate); 820 812 821 - if ((err = vx_set_format(chip, pipe, runtime)) < 0) 813 + err = vx_set_format(chip, pipe, runtime); 814 + if (err < 0) 822 815 return err; 823 816 824 817 if (vx_is_pcmcia(chip)) { ··· 1196 1187 unsigned int i; 1197 1188 int err; 1198 1189 1199 - if ((err = vx_init_audio_io(chip)) < 0) 1190 + err = vx_init_audio_io(chip); 1191 + if (err < 0) 1200 1192 return err; 1201 1193 1202 1194 for (i = 0; i < chip->hw->num_codecs; i++) {