ALSA: ca0106: Fix assignment in if condition
authorTakashi Iwai <tiwai@suse.de>
Tue, 8 Jun 2021 14:05:10 +0000 (16:05 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 9 Jun 2021 15:30:05 +0000 (17:30 +0200)
PCI CA0106 driver code contains 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-37-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/ca0106/ca0106_main.c
sound/pci/ca0106/ca_midi.c

index bee4710..9977871 100644 (file)
@@ -575,9 +575,11 @@ static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substr
        */
         //channel->interrupt = snd_ca0106_pcm_channel_interrupt;
        channel->epcm = epcm;
-       if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0)
+       err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
+       if (err < 0)
                 return err;
-       if ((err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64)) < 0)
+       err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64);
+       if (err < 0)
                 return err;
        snd_pcm_set_sync(substream);
 
@@ -668,10 +670,12 @@ static int snd_ca0106_pcm_open_capture_channel(struct snd_pcm_substream *substre
        */
         //channel->interrupt = snd_ca0106_pcm_channel_interrupt;
         channel->epcm = epcm;
-       if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0)
+       err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
+       if (err < 0)
                 return err;
        //snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, &hw_constraints_capture_period_sizes);
-       if ((err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64)) < 0)
+       err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64);
+       if (err < 0)
                 return err;
        return 0;
 }
@@ -1166,7 +1170,8 @@ static int snd_ca0106_ac97(struct snd_ca0106 *chip)
                .read = snd_ca0106_ac97_read,
        };
   
-       if ((err = snd_ac97_bus(chip->card, 0, &ops, NULL, &pbus)) < 0)
+       err = snd_ac97_bus(chip->card, 0, &ops, NULL, &pbus);
+       if (err < 0)
                return err;
        pbus->no_vra = 1; /* we don't need VRA */
 
@@ -1759,7 +1764,8 @@ static int snd_ca0106_midi(struct snd_ca0106 *chip, unsigned int channel)
 
        midi->dev_id = chip;
        
-       if ((err = ca_midi_init(chip, midi, 0, name)) < 0)
+       err = ca_midi_init(chip, midi, 0, name);
+       if (err < 0)
                return err;
 
        return 0;
index 18524e0..957e60f 100644 (file)
@@ -276,7 +276,8 @@ int ca_midi_init(void *dev_id, struct snd_ca_midi *midi, int device, char *name)
        struct snd_rawmidi *rmidi;
        int err;
 
-       if ((err = snd_rawmidi_new(midi->get_dev_id_card(midi->dev_id), name, device, 1, 1, &rmidi)) < 0)
+       err = snd_rawmidi_new(midi->get_dev_id_card(midi->dev_id), name, device, 1, 1, &rmidi);
+       if (err < 0)
                return err;
 
        midi->dev_id = dev_id;