ALSA: Fix assignment in if condition
Subsystems (6)
cover ALSA: Fix assignment in if condition
Hi,
here is a largish patch set mostly for cleanup / a slight refactoring of the coding styles with assignment in if condition, typically such as:
if ((err = xxx()) < 0) return err;
This was a popular style in the old ages, but nowadays it's seen rather fairly harmful as it makes harder to read and easily hides bugs. Since we've hit quite a few issues (although most of them are trivial), I decided to fix those lines.
While conversions, I spotted a couple of real bugs. They are old driver codes and only in certain error paths, so most likely no one ever hits it.
Takashi
===
Takashi Iwai (66):
ALSA: sb: Fix assignment in if condition
ALSA: sb: Minor coding style fixes
ALSA: sb: Fix potential double-free of CSP mixer elements
ALSA: gus: Fix assignment in if condition
ALSA: ad1816a: Fix assignment in if condition
ALSA: wavefront: Fix assignment in if condition
ALSA: cs423x: Fix assignment in if condition
ALSA: opti9xx: Fix assignment in if condition
ALSA: opl3sa2: Fix assignment in if condition
ALSA: es18xx: Fix assignment in if condition
ALSA: cmi8330: Fix assignment in if condition
ALSA: als100: Fix assignment in if condition
ALSA: azt2320: Fix assignment in if condition
ALSA: isa: Fix assignment in if condition
ALSA: ad1889: Fix assignment in if condition
ALSA: ak4531: Fix assignment in if condition
ALSA: als300: Fix assignment in if condition
ALSA: als4000: Fix assignment in if condition
ALSA: atiixp: Fix assignment in if condition
ALSA: azt3328: Fix assignment in if condition
ALSA: bt87x: Fix assignment in if condition
ALSA: cmipci: Fix assignment in if condition
ALSA: cs4281: Fix assignment in if condition
ALSA: ens137x: Fix assignment in if condition
ALSA: es1938: Fix assignment in if condition
ALSA: es1968: Fix assignment in if condition
ALSA: fm801: Fix assignment in if condition
ALSA: intel8x0: Fix assignment in if condition
ALSA: maestro3: Fix assignment in if condition
ALSA: rme32: Fix assignment in if condition
ALSA: rme96: Fix assignment in if condition
ALSA: sonicvibes: Fix assignment in if condition
ALSA: via82xx: Fix assignment in if condition
ALSA: ac97: Fix assignment in if condition
ALSA: au88x0: Fix assignment in if condition
ALSA: ca0106: Fix assignment in if condition
ALSA: cs46xx: Fix assignment in if condition
ALSA: cs5535audio: Fix assignment in if condition
ALSA: echoaudio: Fix assignment in if condition
ALSA: emu10k1: Fix assignment in if condition
ALSA: emu10k1x: Fix assignment in if condition
ALSA: ice1712: Fix assignment in if condition
ALSA: korg1212: Fix assignment in if condition
ALSA: mixart: Fix assignment in if condition
ALSA: nm256: Fix assignment in if condition
ALSA: pcxhr: Fix assignment in if condition
ALSA: riptide: Fix assignment in if condition
ALSA: hdsp: Fix assignment in if condition
ALSA: rme9652: Fix assignment in if condition
ALSA: trident: Fix assignment in if condition
ALSA: vx222: Fix assignment in if condition
ALSA: ymfpci: Fix assignment in if condition
ALSA: core: Fix assignment in if condition
ALSA: pcm: Fix assignment in if condition
ALSA: oss: Fix assignment in if condition
ALSA: seq: Fix assignment in if condition
ALSA: pcmcia: Fix assignment in if condition
ALSA: sparc: Fix assignment in if condition
ALSA: mpu401: Fix assignment in if condition
ALSA: vx: Fix assignment in if condition
ALSA: opl3: Fix assignment in if condition
ALSA: serial: Fix assignment in if condition
ALSA: synth: Fix assignment in if condition
ALSA: poewrmac: Fix assignment in if condition
ALSA: i2c: Fix assignment in if condition
ALSA: parisc: Fix assignment in if condition
sound/core/hwdep.c | 6 +- sound/core/info_oss.c | 3 +- sound/core/init.c | 12 +- sound/core/oss/mixer_oss.c | 45 +++-- sound/core/oss/pcm_oss.c | 70 +++++--- sound/core/oss/pcm_plugin.c | 26 +-- sound/core/pcm_compat.c | 6 +- sound/core/pcm_misc.c | 12 +- sound/core/pcm_native.c | 6 +- sound/core/seq/oss/seq_oss.c | 26 +-- sound/core/seq/oss/seq_oss_init.c | 9 +- sound/core/seq/oss/seq_oss_midi.c | 33 ++-- sound/core/seq/oss/seq_oss_rw.c | 3 +- sound/core/seq/oss/seq_oss_synth.c | 9 +- sound/core/seq/oss/seq_oss_writeq.c | 3 +- sound/core/seq/seq_clientmgr.c | 51 ++++-- sound/core/seq/seq_dummy.c | 3 +- sound/core/seq/seq_fifo.c | 3 +- sound/core/seq/seq_memory.c | 6 +- sound/core/seq/seq_midi.c | 27 +-- sound/core/seq/seq_queue.c | 21 ++- sound/core/seq/seq_virmidi.c | 9 +- sound/core/sound.c | 3 +- sound/core/sound_oss.c | 3 +- sound/drivers/mpu401/mpu401.c | 9 +- sound/drivers/mpu401/mpu401_uart.c | 19 +- sound/drivers/mtpav.c | 15 +- sound/drivers/mts64.c | 15 +- sound/drivers/opl3/opl3_lib.c | 42 +++-- sound/drivers/opl3/opl3_oss.c | 6 +- sound/drivers/opl3/opl3_seq.c | 9 +- sound/drivers/portman2x4.c | 15 +- sound/drivers/serial-u16550.c | 27 +-- sound/drivers/vx/vx_core.c | 60 ++++--- sound/drivers/vx/vx_hwdep.c | 12 +- sound/drivers/vx/vx_mixer.c | 39 +++-- sound/drivers/vx/vx_pcm.c | 32 ++-- sound/i2c/cs8427.c | 24 ++- sound/i2c/other/ak4114.c | 3 +- sound/i2c/other/ak4117.c | 3 +- sound/i2c/tea6330t.c | 24 ++- sound/isa/ad1816a/ad1816a.c | 23 ++- sound/isa/ad1816a/ad1816a_lib.c | 27 ++- sound/isa/als100.c | 18 +- sound/isa/azt2320.c | 21 ++- sound/isa/cmi8330.c | 37 ++-- sound/isa/cs423x/cs4236.c | 21 ++- sound/isa/cs423x/cs4236_lib.c | 12 +- sound/isa/es1688/es1688_lib.c | 3 +- sound/isa/es18xx.c | 51 ++++-- sound/isa/gus/gus_main.c | 18 +- sound/isa/gus/gus_mem.c | 3 +- sound/isa/gus/gus_mixer.c | 6 +- sound/isa/gus/gus_pcm.c | 23 ++- sound/isa/gus/gus_uart.c | 3 +- sound/isa/gus/gusclassic.c | 6 +- sound/isa/gus/gusextreme.c | 6 +- sound/isa/gus/gusmax.c | 36 ++-- sound/isa/gus/interwave.c | 90 ++++++---- sound/isa/opl3sa2.c | 68 +++++--- sound/isa/opti9xx/miro.c | 27 ++- sound/isa/opti9xx/opti92x-ad1848.c | 27 ++- sound/isa/sb/emu8000.c | 21 ++- sound/isa/sb/emu8000_patch.c | 3 +- sound/isa/sb/emu8000_pcm.c | 6 +- sound/isa/sb/sb16.c | 65 ++++--- sound/isa/sb/sb16_csp.c | 29 ++-- sound/isa/sb/sb16_main.c | 6 +- sound/isa/sb/sb8.c | 38 ++-- sound/isa/sb/sb8_main.c | 3 +- sound/isa/sb/sb8_midi.c | 3 +- sound/isa/sb/sb_common.c | 9 +- sound/isa/sb/sb_mixer.c | 55 +++--- sound/isa/wavefront/wavefront.c | 6 +- sound/isa/wavefront/wavefront_midi.c | 20 ++- sound/isa/wavefront/wavefront_synth.c | 56 +++--- sound/isa/wss/wss_lib.c | 9 +- sound/parisc/harmony.c | 7 +- sound/pci/ac97/ac97_codec.c | 205 ++++++++++++++-------- sound/pci/ac97/ac97_patch.c | 137 ++++++++++----- sound/pci/ad1889.c | 15 +- sound/pci/ak4531_codec.c | 9 +- sound/pci/als300.c | 22 ++- sound/pci/als4000.c | 55 +++--- sound/pci/atiixp.c | 33 ++-- sound/pci/atiixp_modem.c | 40 +++-- sound/pci/au88x0/au88x0.c | 77 +++++---- sound/pci/au88x0/au88x0_a3d.c | 28 +-- sound/pci/au88x0/au88x0_core.c | 47 ++--- sound/pci/au88x0/au88x0_eq.c | 20 ++- sound/pci/au88x0/au88x0_mixer.c | 3 +- sound/pci/au88x0/au88x0_mpu401.c | 14 +- sound/pci/au88x0/au88x0_pcm.c | 15 +- sound/pci/azt3328.c | 3 +- sound/pci/bt87x.c | 3 +- sound/pci/ca0106/ca0106_main.c | 18 +- sound/pci/ca0106/ca_midi.c | 3 +- sound/pci/cmipci.c | 83 ++++++--- sound/pci/cs4281.c | 54 ++++-- sound/pci/cs46xx/cs46xx.c | 31 ++-- sound/pci/cs46xx/cs46xx_lib.c | 51 ++++-- sound/pci/cs46xx/dsp_spos.c | 3 +- sound/pci/cs5535audio/cs5535audio.c | 28 +-- sound/pci/cs5535audio/cs5535audio_pcm.c | 10 +- sound/pci/echoaudio/darla20_dsp.c | 6 +- sound/pci/echoaudio/darla24_dsp.c | 6 +- sound/pci/echoaudio/echo3g_dsp.c | 3 +- sound/pci/echoaudio/echoaudio.c | 220 ++++++++++++++---------- sound/pci/echoaudio/echoaudio_dsp.c | 12 +- sound/pci/echoaudio/echoaudio_gml.c | 3 +- sound/pci/echoaudio/gina20_dsp.c | 6 +- sound/pci/echoaudio/gina24_dsp.c | 6 +- sound/pci/echoaudio/indigo_dsp.c | 6 +- sound/pci/echoaudio/indigodj_dsp.c | 6 +- sound/pci/echoaudio/indigoio_dsp.c | 6 +- sound/pci/echoaudio/layla20_dsp.c | 6 +- sound/pci/echoaudio/layla24_dsp.c | 9 +- sound/pci/echoaudio/mia_dsp.c | 6 +- sound/pci/echoaudio/midi.c | 4 +- sound/pci/echoaudio/mona_dsp.c | 6 +- sound/pci/emu10k1/emu10k1.c | 42 +++-- sound/pci/emu10k1/emu10k1_callback.c | 3 +- sound/pci/emu10k1/emu10k1x.c | 85 +++++---- sound/pci/emu10k1/emufx.c | 13 +- sound/pci/emu10k1/emumixer.c | 78 ++++++--- sound/pci/emu10k1/emumpu401.c | 12 +- sound/pci/emu10k1/emupcm.c | 24 ++- sound/pci/emu10k1/memory.c | 21 ++- sound/pci/emu10k1/p16v.c | 13 +- sound/pci/emu10k1/timer.c | 3 +- sound/pci/ens1370.c | 45 +++-- sound/pci/es1938.c | 42 +++-- sound/pci/es1968.c | 75 ++++---- sound/pci/fm801.c | 63 ++++--- sound/pci/ice1712/delta.c | 6 +- sound/pci/ice1712/ews.c | 24 ++- sound/pci/intel8x0.c | 46 +++-- sound/pci/intel8x0m.c | 36 ++-- sound/pci/korg1212/korg1212.c | 24 ++- sound/pci/maestro3.c | 21 ++- sound/pci/mixart/mixart.c | 29 ++-- sound/pci/mixart/mixart_hwdep.c | 17 +- sound/pci/mixart/mixart_mixer.c | 33 ++-- sound/pci/nm256/nm256.c | 27 ++- sound/pci/pcxhr/pcxhr.c | 22 ++- sound/pci/pcxhr/pcxhr_hwdep.c | 9 +- sound/pci/riptide/riptide.c | 88 ++++++---- sound/pci/rme32.c | 76 +++++--- sound/pci/rme96.c | 148 +++++++++------- sound/pci/rme9652/hdsp.c | 121 ++++++++----- sound/pci/rme9652/rme9652.c | 98 ++++++----- sound/pci/sonicvibes.c | 67 +++++--- sound/pci/trident/trident.c | 41 +++-- sound/pci/trident/trident_main.c | 84 ++++++--- sound/pci/via82xx.c | 78 ++++++--- sound/pci/via82xx_modem.c | 52 ++++-- sound/pci/vx222/vx222.c | 18 +- sound/pci/vx222/vx222_ops.c | 12 +- sound/pci/ymfpci/ymfpci.c | 71 ++++---- sound/pci/ymfpci/ymfpci_main.c | 72 +++++--- sound/pcmcia/pdaudiocf/pdaudiocf.c | 3 +- sound/pcmcia/vx/vxp_mixer.c | 6 +- sound/pcmcia/vx/vxp_ops.c | 6 +- sound/pcmcia/vx/vxpocket.c | 3 +- sound/ppc/beep.c | 5 +- sound/ppc/daca.c | 24 ++- sound/ppc/keywest.c | 6 +- sound/ppc/pmac.c | 6 +- sound/ppc/powermac.c | 21 ++- sound/ppc/tumbler.c | 72 +++++--- sound/sparc/amd7930.c | 14 +- sound/sparc/cs4231.c | 10 +- sound/sparc/dbri.c | 11 +- sound/synth/emux/emux.c | 3 +- sound/synth/emux/emux_effect.c | 13 +- sound/synth/emux/emux_hwdep.c | 6 +- sound/synth/emux/soundfont.c | 40 +++-- 177 files changed, 3186 insertions(+), 1831 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/66 ALSA: sb: Fix assignment in if condition
A lot of code for SB drivers is in a legacy style with assignment in if condition. This also made harder to catch some bugs (e.g. the commit 1c98f574403d "ALSA: emu8000: Fix a use after free in snd_emu8000_create_mixer").
This patch fixes the coding style. All are rather simple conversions and there should be no functional changes.
(The changes in snd_emu8000_new() for hw->res_port1, 2 and 3 are
slightly different from the older ones, but this shouldn't matter much in practice.)
--- sound/isa/sb/emu8000.c | 17 ++++++---- sound/isa/sb/emu8000_patch.c | 3 +- sound/isa/sb/emu8000_pcm.c | 6 ++-- sound/isa/sb/sb16.c | 65 +++++++++++++++++++++--------------- sound/isa/sb/sb16_csp.c | 14 +++++--- sound/isa/sb/sb16_main.c | 6 ++-- sound/isa/sb/sb8.c | 38 +++++++++++---------- sound/isa/sb/sb8_main.c | 3 +- sound/isa/sb/sb8_midi.c | 3 +- sound/isa/sb/sb_common.c | 9 +++-- sound/isa/sb/sb_mixer.c | 55 ++++++++++++++++-------------- 11 files changed, 130 insertions(+), 89 deletions(-)
sound/isa/sb/emu8000.c +11 -6
@@ -1029,7 +1029,9 @@ snd_emu8000_create_mixer(struct snd_card *card, struct snd_emu8000 *emu)memset (emu->controls,0 ,sizeof (emu->controls));for (i =0 ; i <EMU8000_NUM_CONTROLS ; i++) { -if ((err =snd_ctl_add (card, emu->controls[i] =snd_ctl_new1 (mixer_defs[i], emu))) <0 ) { + emu->controls[i] =snd_ctl_new1 (mixer_defs[i], emu); + err =snd_ctl_add (card, emu->controls[i]); +if (err <0 ) { emu->controls[i] =NULL ; goto __error; }
@@ -1095,9 +1097,10 @@ snd_emu8000_new(struct snd_card *card, int index, long port, int seq_ports, hw->port1 = port; hw->port2 = port +0x400 ; hw->port3 = port +0x800 ; -if (!(hw->res_port1 =request_region (hw->port1,4 ,"Emu8000-1" )) || - !(hw->res_port2 =request_region (hw->port2,4 ,"Emu8000-2" )) || - !(hw->res_port3 =request_region (hw->port3,4 ,"Emu8000-3" ))) { + hw->res_port1 =request_region (hw->port1,4 ,"Emu8000-1" ); + hw->res_port2 =request_region (hw->port2,4 ,"Emu8000-2" ); + hw->res_port3 =request_region (hw->port3,4 ,"Emu8000-3" ); +if (!hw->res_port1 || !hw->res_port2 || !hw->res_port3) {snd_printk (KERN_ERR "sbawe: can't grab ports 0x%lx, 0x%lx, 0x%lx\n" , hw->port1, hw->port2, hw->port3);snd_emu8000_free (hw);return -EBUSY ;
@@ -1118,12 +1121,14 @@ snd_emu8000_new(struct snd_card *card, int index, long port, int seq_ports, }snd_emu8000_init_hw (hw); -if ((err =snd_emu8000_create_mixer (card, hw)) <0 ) { + err =snd_emu8000_create_mixer (card, hw); +if (err <0 ) {snd_emu8000_free (hw);return err; } -if ((err =snd_device_new (card,SNDRV_DEV_CODEC , hw, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_CODEC , hw, &ops); +if (err <0 ) {snd_emu8000_free (hw);return err; }
sound/isa/sb/emu8000_patch.c +2 -1
@@ -191,7 +191,8 @@ snd_emu8000_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, sp->v.truesize = truesize *2 ;/* in bytes */ snd_emux_terminate_all (emu->emu); -if ((rc =snd_emu8000_open_dma (emu,EMU8000_RAM_WRITE )) !=0 ) + rc =snd_emu8000_open_dma (emu,EMU8000_RAM_WRITE ); +if (rc)return rc;/* Set the address to start writing at */
sound/isa/sb/emu8000_pcm.c +4 -2
@@ -626,7 +626,8 @@ static int emu8k_pcm_prepare(struct snd_pcm_substream *subs)int err, i, ch;snd_emux_terminate_all (rec->emu->emu); -if ((err =emu8k_open_dram_for_pcm (rec->emu, rec->voices)) !=0 ) + err =emu8k_open_dram_for_pcm (rec->emu, rec->voices); +if (err)return err; rec->dram_opened =1 ;
@@ -682,7 +683,8 @@ int snd_emu8000_pcm_new(struct snd_card *card, struct snd_emu8000 *emu, int indestruct snd_pcm *pcm;int err; -if ((err =snd_pcm_new (card,"Emu8000 PCM" , index,1 ,0 , &pcm)) <0 ) + err =snd_pcm_new (card,"Emu8000 PCM" , index,1 ,0 , &pcm); +if (err <0 )return err; pcm->private_data = emu; pcm->private_free = snd_emu8000_pcm_free;
sound/isa/sb/sb16.c +39 -26
134 lines not on this page · raw message
sound/isa/sb/sb16_csp.c +10 -4
@@ -112,10 +112,12 @@ int snd_sb_csp_new(struct snd_sb *chip, int device, struct snd_hwdep ** rhwdep)if (csp_detect (chip, &version))return -ENODEV ; -if ((err =snd_hwdep_new (chip->card,"SB16-CSP" , device, &hw)) <0 ) + err =snd_hwdep_new (chip->card,"SB16-CSP" , device, &hw); +if (err <0 )return err; -if ((p =kzalloc (sizeof (*p),GFP_KERNEL )) ==NULL ) { + p =kzalloc (sizeof (*p),GFP_KERNEL ); +if (!p) {snd_device_free (chip->card, hw);return -ENOMEM ; }
@@ -1045,11 +1047,15 @@ static int snd_sb_qsound_build(struct snd_sb_csp * p)spin_lock_init (&p->q_lock); -if ((err =snd_ctl_add (card, p->qsound_switch =snd_ctl_new1 (&snd_sb_qsound_switch, p))) <0 ) { + p->qsound_switch =snd_ctl_new1 (&snd_sb_qsound_switch, p); + err =snd_ctl_add (card, p->qsound_switch); +if (err <0 ) { p->qsound_switch =NULL ; goto __error; } -if ((err =snd_ctl_add (card, p->qsound_space =snd_ctl_new1 (&snd_sb_qsound_space, p))) <0 ) { + p->qsound_space =snd_ctl_new1 (&snd_sb_qsound_space, p); + err =snd_ctl_add (card, p->qsound_space); +if (err <0 ) { p->qsound_space =NULL ; goto __error; }
sound/isa/sb/sb16_main.c +4 -2
@@ -703,7 +703,8 @@ static int snd_sb16_dma_control_put(struct snd_kcontrol *kcontrol, struct snd_ctunsigned char nval, oval;int change; -if ((nval = ucontrol->value.enumerated.item[0 ]) >2 ) + nval = ucontrol->value.enumerated.item[0 ]; +if (nval >2 )return -EINVAL ;spin_lock_irqsave (&chip->reg_lock, flags); oval =snd_sb16_get_dma_mode (chip);
@@ -836,7 +837,8 @@ int snd_sb16dsp_pcm(struct snd_sb *chip, int device)struct snd_pcm *pcm;int err; -if ((err =snd_pcm_new (card,"SB16 DSP" , device,1 ,1 , &pcm)) <0 ) + err =snd_pcm_new (card,"SB16 DSP" , device,1 ,1 , &pcm); +if (err <0 )return err;sprintf (pcm->name,"DSP v%i.%i" , chip->version >>8 , chip->version &0xff ); pcm->info_flags =SNDRV_PCM_INFO_JOINT_DUPLEX ;
sound/isa/sb/sb8.c +20 -18
@@ -101,12 +101,10 @@ static int snd_sb8_probe(struct device *pdev, unsigned int dev) }if (port[dev] !=SNDRV_AUTO_PORT ) { -if ((err =snd_sbdsp_create (card, port[dev], irq[dev], - snd_sb8_interrupt, - dma8[dev], --1 , -SB_HW_AUTO , - &chip)) <0 ) + err =snd_sbdsp_create (card, port[dev], irq[dev], + snd_sb8_interrupt, dma8[dev], +-1 ,SB_HW_AUTO , &chip); +if (err <0 ) goto _err; }else {/* auto-probe legacy ports */
@@ -145,32 +143,35 @@ static int snd_sb8_probe(struct device *pdev, unsigned int dev) goto _err; } -if ((err =snd_sb8dsp_pcm (chip,0 )) <0 ) + err =snd_sb8dsp_pcm (chip,0 ); +if (err <0 ) goto _err; -if ((err =snd_sbmixer_new (chip)) <0 ) + err =snd_sbmixer_new (chip); +if (err <0 ) goto _err;if (chip->hardware ==SB_HW_10 || chip->hardware ==SB_HW_20 ) { -if ((err =snd_opl3_create (card, chip->port +8 ,0 , -OPL3_HW_AUTO ,1 , - &opl3)) <0 ) { + err =snd_opl3_create (card, chip->port +8 ,0 , +OPL3_HW_AUTO ,1 , &opl3); +if (err <0 )snd_printk (KERN_WARNING "sb8: no OPL device at 0x%lx\n" , chip->port +8 ); - } }else { -if ((err =snd_opl3_create (card, chip->port, chip->port +2 , -OPL3_HW_AUTO ,1 , - &opl3)) <0 ) { + err =snd_opl3_create (card, chip->port, chip->port +2 , +OPL3_HW_AUTO ,1 , &opl3); +if (err <0 ) {snd_printk (KERN_WARNING "sb8: no OPL device at 0x%lx-0x%lx\n" , chip->port, chip->port +2 ); } }if (err >=0 ) { -if ((err =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL )) <0 ) + err =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL ); +if (err <0 ) goto _err; } -if ((err =snd_sb8dsp_midi (chip,0 )) <0 ) + err =snd_sb8dsp_midi (chip,0 ); +if (err <0 ) goto _err;strcpy (card->driver, chip->hardware ==SB_HW_PRO ?"SB Pro" :"SB8" );
@@ -180,7 +181,8 @@ static int snd_sb8_probe(struct device *pdev, unsigned int dev) chip->port, irq[dev], dma8[dev]); -if ((err =snd_card_register (card)) <0 ) + err =snd_card_register (card); +if (err <0 ) goto _err;dev_set_drvdata (pdev, card);
sound/isa/sb/sb8_main.c +2 -1
@@ -567,7 +567,8 @@ int snd_sb8dsp_pcm(struct snd_sb *chip, int device)int err;size_t max_prealloc =64 *1024 ; -if ((err =snd_pcm_new (card,"SB8 DSP" , device,1 ,1 , &pcm)) <0 ) + err =snd_pcm_new (card,"SB8 DSP" , device,1 ,1 , &pcm); +if (err <0 )return err;sprintf (pcm->name,"DSP v%i.%i" , chip->version >>8 , chip->version &0xff ); pcm->info_flags =SNDRV_PCM_INFO_HALF_DUPLEX ;
sound/isa/sb/sb8_midi.c +2 -1
@@ -251,7 +251,8 @@ int snd_sb8dsp_midi(struct snd_sb *chip, int device)struct snd_rawmidi *rmidi;int err; -if ((err =snd_rawmidi_new (chip->card,"SB8 MIDI" , device,1 ,1 , &rmidi)) <0 ) + err =snd_rawmidi_new (chip->card,"SB8 MIDI" , device,1 ,1 , &rmidi); +if (err <0 )return err;strcpy (rmidi->name,"SB8 MIDI" );snd_rawmidi_set_ops (rmidi,SNDRV_RAWMIDI_STREAM_OUTPUT , &snd_sb8dsp_midi_output);
sound/isa/sb/sb_common.c +6 -3
@@ -238,7 +238,8 @@ int snd_sbdsp_create(struct snd_card *card,if (hardware ==SB_HW_ALS4000 ) goto __skip_allocation; -if ((chip->res_port =request_region (port,16 ,"SoundBlaster" )) ==NULL ) { + chip->res_port =request_region (port,16 ,"SoundBlaster" ); +if (!chip->res_port) {snd_printk (KERN_ERR "sb: can't grab port 0x%lx\n" , port);snd_sbdsp_free (chip);return -EBUSY ;
@@ -267,11 +268,13 @@ int snd_sbdsp_create(struct snd_card *card, __skip_allocation: chip->card = card; chip->hardware = hardware; -if ((err =snd_sbdsp_probe (chip)) <0 ) { + err =snd_sbdsp_probe (chip); +if (err <0 ) {snd_sbdsp_free (chip);return err; } -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (err <0 ) {snd_sbdsp_free (chip);return err; }
sound/isa/sb/sb_mixer.c +30 -25
82 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 2/66 ALSA: sb: Minor coding style fixes
In reply to Takashi IwaiThe handling of snd_ctl_new1() and snd_ctl_add() can be sometimes tricky, as snd_ctl_add() automatically removes the passed object at its error path. The recent fix addressed an overlooked issue that is relevant with that in SB driver code, and it can be a bit more simplified by assigning to a temporary variable, i.e. storing to the struct field only after the creation succeeds.
--- sound/isa/sb/emu8000.c | 10 +++++----- sound/isa/sb/sb16_csp.c | 19 +++++++++---------- 2 files changed, 14 insertions(+), 15 deletions(-)
sound/isa/sb/emu8000.c +5 -5
@@ -1020,6 +1020,7 @@ static const struct snd_kcontrol_new *mixer_defs[EMU8000_NUM_CONTROLS] = {static int snd_emu8000_create_mixer (struct snd_card *card,struct snd_emu8000 *emu) { +struct snd_kcontrol *kctl;int i, err =0 ;if (snd_BUG_ON (!emu || !card))
@@ -1029,12 +1030,11 @@ snd_emu8000_create_mixer(struct snd_card *card, struct snd_emu8000 *emu)memset (emu->controls,0 ,sizeof (emu->controls));for (i =0 ; i <EMU8000_NUM_CONTROLS ; i++) { - emu->controls[i] =snd_ctl_new1 (mixer_defs[i], emu); - err =snd_ctl_add (card, emu->controls[i]); -if (err <0 ) { - emu->controls[i] =NULL ; + kctl =snd_ctl_new1 (mixer_defs[i], emu); + err =snd_ctl_add (card, kctl); +if (err <0 ) goto __error; - } + emu->controls[i] = kctl; }return 0 ;
sound/isa/sb/sb16_csp.c +9 -10
@@ -1036,6 +1036,7 @@ static const struct snd_kcontrol_new snd_sb_qsound_space = {static int snd_sb_qsound_build (struct snd_sb_csp * p) {struct snd_card *card; +struct snd_kcontrol *kctl;int err;if (snd_BUG_ON (!p))
@@ -1047,18 +1048,16 @@ static int snd_sb_qsound_build(struct snd_sb_csp * p)spin_lock_init (&p->q_lock); - p->qsound_switch =snd_ctl_new1 (&snd_sb_qsound_switch, p); - err =snd_ctl_add (card, p->qsound_switch); -if (err <0 ) { - p->qsound_switch =NULL ; + kctl =snd_ctl_new1 (&snd_sb_qsound_switch, p); + err =snd_ctl_add (card, kctl); +if (err <0 ) goto __error; - } - p->qsound_space =snd_ctl_new1 (&snd_sb_qsound_space, p); - err =snd_ctl_add (card, p->qsound_space); -if (err <0 ) { - p->qsound_space =NULL ; + p->qsound_switch = kctl; + kctl =snd_ctl_new1 (&snd_sb_qsound_space, p); + err =snd_ctl_add (card, kctl); +if (err <0 ) goto __error; - } + p->qsound_space = kctl;return 0 ;
Signature · 1 line
2.26.2
PATCH 3/66 ALSA: sb: Fix potential double-free of CSP mixer elements
In reply to Takashi Iwaisnd_sb_qsound_destroy() contains the calls of removing the previously created mixer controls, but it doesn't clear the pointers. As snd_sb_qsound_destroy() itself may be repeatedly called via ioctl, this could lead to double-free potentially.
Fix it by clearing the struct fields properly afterwards.
--- sound/isa/sb/sb16_csp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
sound/isa/sb/sb16_csp.c +6 -2
@@ -1077,10 +1077,14 @@ static void snd_sb_qsound_destroy(struct snd_sb_csp * p) card = p->chip->card;down_write (&card->controls_rwsem); -if (p->qsound_switch) +if (p->qsound_switch) {snd_ctl_remove (card, p->qsound_switch); -if (p->qsound_space) + p->qsound_switch =NULL ; + } +if (p->qsound_space) {snd_ctl_remove (card, p->qsound_space); + p->qsound_space =NULL ; + }up_write (&card->controls_rwsem);/* cancel pending transfer of QSound parameters */
Signature · 1 line
2.26.2
PATCH 4/66 ALSA: gus: Fix assignment in if condition
In reply to Takashi IwaiISA GUS driver 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.
--- sound/isa/gus/gus_main.c | 18 +++++--- sound/isa/gus/gus_mem.c | 3 +- sound/isa/gus/gus_mixer.c | 6 ++- sound/isa/gus/gus_pcm.c | 23 ++++++---- sound/isa/gus/gus_uart.c | 3 +- sound/isa/gus/gusclassic.c | 6 ++- sound/isa/gus/gusextreme.c | 6 ++- sound/isa/gus/gusmax.c | 36 ++++++++++----- sound/isa/gus/interwave.c | 90 ++++++++++++++++++++++++-------------- 9 files changed, 124 insertions(+), 67 deletions(-)
sound/isa/gus/gus_main.c +12 -6
@@ -165,12 +165,14 @@ int snd_gus_create(struct snd_card *card, gus->gf1.reg_timerctrl =GUSP (gus,TIMERCNTRL ); gus->gf1.reg_timerdata =GUSP (gus,TIMERDATA );/* allocate resources */ -if ((gus->gf1.res_port1 =request_region (port,16 ,"GUS GF1 (Adlib/SB)" )) ==NULL ) { + gus->gf1.res_port1 =request_region (port,16 ,"GUS GF1 (Adlib/SB)" ); +if (!gus->gf1.res_port1) {snd_printk (KERN_ERR "gus: can't grab SB port 0x%lx\n" , port);snd_gus_free (gus);return -EBUSY ; } -if ((gus->gf1.res_port2 =request_region (port +0x100 ,12 ,"GUS GF1 (Synth)" )) ==NULL ) { + gus->gf1.res_port2 =request_region (port +0x100 ,12 ,"GUS GF1 (Synth)" ); +if (!gus->gf1.res_port2) {snd_printk (KERN_ERR "gus: can't grab synth port 0x%lx\n" , port +0x100 );snd_gus_free (gus);return -EBUSY ;
@@ -215,7 +217,8 @@ int snd_gus_create(struct snd_card *card, gus->gf1.pcm_channels = pcm_channels; gus->gf1.volume_ramp =25 ; gus->gf1.smooth_pan =1 ; -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , gus, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , gus, &ops); +if (err <0 ) {snd_gus_free (gus);return err; }
@@ -404,14 +407,17 @@ int snd_gus_initialize(struct snd_gus_card *gus)int err;if (!gus->interwave) { -if ((err =snd_gus_check_version (gus)) <0 ) { + err =snd_gus_check_version (gus); +if (err <0 ) {snd_printk (KERN_ERR "version check failed\n" );return err; } -if ((err =snd_gus_detect_memory (gus)) <0 ) + err =snd_gus_detect_memory (gus); +if (err <0 )return err; } -if ((err =snd_gus_init_dma_irq (gus,1 )) <0 ) + err =snd_gus_init_dma_irq (gus,1 ); +if (err <0 )return err;snd_gf1_start (gus); gus->initialized =1 ;
sound/isa/gus/gus_mem.c +2 -1
@@ -210,7 +210,8 @@ int snd_gf1_mem_free(struct snd_gf1_mem * alloc, unsigned int address)struct snd_gf1_mem_block *block;snd_gf1_mem_lock (alloc,0 ); -if ((block =snd_gf1_mem_look (alloc, address)) !=NULL ) { + block =snd_gf1_mem_look (alloc, address); +if (block) { result =snd_gf1_mem_xfree (alloc, block);snd_gf1_mem_lock (alloc,1 );return result;
sound/isa/gus/gus_mixer.c +4 -2
@@ -162,12 +162,14 @@ int snd_gf1_new_mixer(struct snd_gus_card * gus)if (!gus->ics_flag) { max = gus->ess_flag ?1 :ARRAY_SIZE (snd_gf1_controls);for (idx =0 ; idx < max; idx++) { -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_gf1_controls[idx], gus))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_gf1_controls[idx], gus)); +if (err <0 )return err; } }else {for (idx =0 ; idx <ARRAY_SIZE (snd_ics_controls); idx++) { -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_ics_controls[idx], gus))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_ics_controls[idx], gus)); +if (err <0 )return err; } }
sound/isa/gus/gus_pcm.c +14 -9
@@ -430,17 +430,19 @@ static int snd_gf1_pcm_playback_hw_params(struct snd_pcm_substream *substream,snd_gf1_mem_free (&gus->gf1.mem_alloc, pcmp->memory); pcmp->memory =0 ; } -if ((block =snd_gf1_mem_alloc (&gus->gf1.mem_alloc, -SNDRV_GF1_MEM_OWNER_DRIVER , -"GF1 PCM" , - runtime->dma_bytes,1 ,32 , -NULL )) ==NULL ) + block =snd_gf1_mem_alloc (&gus->gf1.mem_alloc, +SNDRV_GF1_MEM_OWNER_DRIVER , +"GF1 PCM" , + runtime->dma_bytes,1 ,32 , +NULL ); +if (!block)return -ENOMEM ; pcmp->memory = block->ptr; } pcmp->voices =params_channels (hw_params);if (pcmp->pvoices[0 ] ==NULL ) { -if ((pcmp->pvoices[0 ] =snd_gf1_alloc_voice (pcmp->gus,SNDRV_GF1_VOICE_TYPE_PCM ,0 ,0 )) ==NULL ) + pcmp->pvoices[0 ] =snd_gf1_alloc_voice (pcmp->gus,SNDRV_GF1_VOICE_TYPE_PCM ,0 ,0 ); +if (!pcmp->pvoices[0 ])return -ENOMEM ; pcmp->pvoices[0 ]->handler_wave = snd_gf1_pcm_interrupt_wave; pcmp->pvoices[0 ]->handler_volume = snd_gf1_pcm_interrupt_volume;
@@ -448,7 +450,8 @@ static int snd_gf1_pcm_playback_hw_params(struct snd_pcm_substream *substream, pcmp->pvoices[0 ]->private_data = pcmp; }if (pcmp->voices >1 && pcmp->pvoices[1 ] ==NULL ) { -if ((pcmp->pvoices[1 ] =snd_gf1_alloc_voice (pcmp->gus,SNDRV_GF1_VOICE_TYPE_PCM ,0 ,0 )) ==NULL ) + pcmp->pvoices[1 ] =snd_gf1_alloc_voice (pcmp->gus,SNDRV_GF1_VOICE_TYPE_PCM ,0 ,0 ); +if (!pcmp->pvoices[1 ])return -ENOMEM ; pcmp->pvoices[1 ]->handler_wave = snd_gf1_pcm_interrupt_wave; pcmp->pvoices[1 ]->handler_volume = snd_gf1_pcm_interrupt_volume;
@@ -689,7 +692,8 @@ static int snd_gf1_pcm_playback_open(struct snd_pcm_substream *substream)printk (KERN_DEBUG "playback.buffer = 0x%lx, gf1.pcm_buffer = 0x%lx\n" , (long ) pcm->playback.buffer, (long ) gus->gf1.pcm_buffer);#endif -if ((err =snd_gf1_dma_init (gus)) <0 ) + err =snd_gf1_dma_init (gus); +if (err <0 )return err; pcmp->flags =SNDRV_GF1_PCM_PFLG_NONE ; pcmp->substream = substream;
@@ -888,7 +892,8 @@ int snd_gf1_pcm_new(struct snd_gus_card *gus, int pcm_dev, int control_index) kctl =snd_ctl_new1 (&snd_gf1_pcm_volume_control1, gus); else kctl =snd_ctl_new1 (&snd_gf1_pcm_volume_control, gus); -if ((err =snd_ctl_add (card, kctl)) <0 ) + err =snd_ctl_add (card, kctl); +if (err <0 )return err; kctl->id.index = control_index;
sound/isa/gus/gus_uart.c +2 -1
@@ -232,7 +232,8 @@ int snd_gf1_rawmidi_new(struct snd_gus_card *gus, int device)struct snd_rawmidi *rmidi;int err; -if ((err =snd_rawmidi_new (gus->card,"GF1" , device,1 ,1 , &rmidi)) <0 ) + err =snd_rawmidi_new (gus->card,"GF1" , device,1 ,1 , &rmidi); +if (err <0 )return err;strcpy (rmidi->name, gus->interwave ?"AMD InterWave" :"GF1" );snd_rawmidi_set_ops (rmidi,SNDRV_RAWMIDI_STREAM_OUTPUT , &snd_gf1_uart_output);
sound/isa/gus/gusclassic.c +4 -2
@@ -113,14 +113,16 @@ static int snd_gusclassic_detect(struct snd_gus_card *gus)unsigned char d;snd_gf1_i_write8 (gus,SNDRV_GF1_GB_RESET ,0 );/* reset GF1 */ -if (((d =snd_gf1_i_look8 (gus,SNDRV_GF1_GB_RESET )) &0x07 ) !=0 ) { + d =snd_gf1_i_look8 (gus,SNDRV_GF1_GB_RESET ); +if ((d &0x07 ) !=0 ) {snd_printdd ("[0x%lx] check 1 failed - 0x%x\n" , gus->gf1.port, d);return -ENODEV ; }udelay (160 );snd_gf1_i_write8 (gus,SNDRV_GF1_GB_RESET ,1 );/* release reset */ udelay (160 ); -if (((d =snd_gf1_i_look8 (gus,SNDRV_GF1_GB_RESET )) &0x07 ) !=1 ) { + d =snd_gf1_i_look8 (gus,SNDRV_GF1_GB_RESET ); +if ((d &0x07 ) !=1 ) {snd_printdd ("[0x%lx] check 2 failed - 0x%x\n" , gus->gf1.port, d);return -ENODEV ; }
sound/isa/gus/gusextreme.c +4 -2
@@ -177,14 +177,16 @@ static int snd_gusextreme_detect(struct snd_gus_card *gus,udelay (100 );snd_gf1_i_write8 (gus,SNDRV_GF1_GB_RESET ,0 );/* reset GF1 */ -if (((d =snd_gf1_i_look8 (gus,SNDRV_GF1_GB_RESET )) &0x07 ) !=0 ) { + d =snd_gf1_i_look8 (gus,SNDRV_GF1_GB_RESET ); +if ((d &0x07 ) !=0 ) {snd_printdd ("[0x%lx] check 1 failed - 0x%x\n" , gus->gf1.port, d);return -EIO ; }udelay (160 );snd_gf1_i_write8 (gus,SNDRV_GF1_GB_RESET ,1 );/* release reset */ udelay (160 ); -if (((d =snd_gf1_i_look8 (gus,SNDRV_GF1_GB_RESET )) &0x07 ) !=1 ) { + d =snd_gf1_i_look8 (gus,SNDRV_GF1_GB_RESET ); +if ((d &0x07 ) !=1 ) {snd_printdd ("[0x%lx] check 2 failed - 0x%x\n" , gus->gf1.port, d);return -EIO ; }
sound/isa/gus/gusmax.c +24 -12
@@ -71,14 +71,16 @@ static int snd_gusmax_detect(struct snd_gus_card *gus)unsigned char d;snd_gf1_i_write8 (gus,SNDRV_GF1_GB_RESET ,0 );/* reset GF1 */ -if (((d =snd_gf1_i_look8 (gus,SNDRV_GF1_GB_RESET )) &0x07 ) !=0 ) { + d =snd_gf1_i_look8 (gus,SNDRV_GF1_GB_RESET ); +if ((d &0x07 ) !=0 ) {snd_printdd ("[0x%lx] check 1 failed - 0x%x\n" , gus->gf1.port, d);return -ENODEV ; }udelay (160 );snd_gf1_i_write8 (gus,SNDRV_GF1_GB_RESET ,1 );/* release reset */ udelay (160 ); -if (((d =snd_gf1_i_look8 (gus,SNDRV_GF1_GB_RESET )) &0x07 ) !=1 ) { + d =snd_gf1_i_look8 (gus,SNDRV_GF1_GB_RESET ); +if ((d &0x07 ) !=1 ) {snd_printdd ("[0x%lx] check 2 failed - 0x%x\n" , gus->gf1.port, d);return -ENODEV ; }
@@ -136,20 +138,24 @@ static int snd_gusmax_mixer(struct snd_wss *chip)/* reassign AUXA to SYNTHESIZER */ strcpy (id1.name,"Aux Playback Switch" );strcpy (id2.name,"Synth Playback Switch" ); -if ((err =snd_ctl_rename_id (card, &id1, &id2)) <0 ) + err =snd_ctl_rename_id (card, &id1, &id2); +if (err <0 )return err;strcpy (id1.name,"Aux Playback Volume" );strcpy (id2.name,"Synth Playback Volume" ); -if ((err =snd_ctl_rename_id (card, &id1, &id2)) <0 ) + err =snd_ctl_rename_id (card, &id1, &id2); +if (err <0 )return err;/* reassign AUXB to CD */ strcpy (id1.name,"Aux Playback Switch" ); id1.index =1 ;strcpy (id2.name,"CD Playback Switch" ); -if ((err =snd_ctl_rename_id (card, &id1, &id2)) <0 ) + err =snd_ctl_rename_id (card, &id1, &id2); +if (err <0 )return err;strcpy (id1.name,"Aux Playback Volume" );strcpy (id2.name,"CD Playback Volume" ); -if ((err =snd_ctl_rename_id (card, &id1, &id2)) <0 ) + err =snd_ctl_rename_id (card, &id1, &id2); +if (err <0 )return err;#if 0 /* reassign Mono Input to MIC */
@@ -209,7 +215,8 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev) xirq = irq[dev];if (xirq ==SNDRV_AUTO_IRQ ) { -if ((xirq =snd_legacy_find_free_irq (possible_irqs)) <0 ) { + xirq =snd_legacy_find_free_irq (possible_irqs); +if (xirq <0 ) { snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); err = -EBUSY ; goto _err;
@@ -217,7 +224,8 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev) } xdma1 = dma1[dev];if (xdma1 ==SNDRV_AUTO_DMA ) { -if ((xdma1 =snd_legacy_find_free_dma (possible_dmas)) <0 ) { + xdma1 =snd_legacy_find_free_dma (possible_dmas); +if (xdma1 <0 ) { snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); err = -EBUSY ; goto _err;
@@ -225,7 +233,8 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev) } xdma2 = dma2[dev];if (xdma2 ==SNDRV_AUTO_DMA ) { -if ((xdma2 =snd_legacy_find_free_dma (possible_dmas)) <0 ) { + xdma2 =snd_legacy_find_free_dma (possible_dmas); +if (xdma2 <0 ) { snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); err = -EBUSY ; goto _err;
@@ -260,13 +269,15 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev)if (err <0 ) goto _err; -if ((err =snd_gusmax_detect (gus)) <0 ) + err =snd_gusmax_detect (gus); +if (err <0 ) goto _err; maxcard->gus_status_reg = gus->gf1.reg_irqstat; maxcard->pcm_status_reg = gus->gf1.port +0x10c +2 ;snd_gusmax_init (dev, card, gus); -if ((err =snd_gus_initialize (gus)) <0 ) + err =snd_gus_initialize (gus); +if (err <0 ) goto _err;if (!gus->max_flag) {
@@ -307,7 +318,8 @@ static int snd_gusmax_probe(struct device *pdev, unsigned int dev) goto _err;if (pcm_channels[dev] >0 ) { -if ((err =snd_gf1_pcm_new (gus,1 ,1 )) <0 ) + err =snd_gf1_pcm_new (gus,1 ,1 ); +if (err <0 ) goto _err; } err =snd_gusmax_mixer (wss);
sound/isa/gus/interwave.c +58 -32
207 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 5/66 ALSA: ad1816a: Fix assignment in if condition
In reply to Takashi IwaiISA AD1816A driver 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.
--- sound/isa/ad1816a/ad1816a.c | 23 ++++++++++++++--------- sound/isa/ad1816a/ad1816a_lib.c | 27 ++++++++++++++++++--------- 2 files changed, 32 insertions(+), 18 deletions(-)
sound/isa/ad1816a/ad1816a.c +14 -9
@@ -131,16 +131,18 @@ static int snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard,return error; chip = card->private_data; -if ((error =snd_card_ad1816a_pnp (dev, pcard, pid))) { + error =snd_card_ad1816a_pnp (dev, pcard, pid); +if (error) {snd_card_free (card);return error; } -if ((error =snd_ad1816a_create (card, port[dev], - irq[dev], - dma1[dev], - dma2[dev], - chip)) <0 ) { + error =snd_ad1816a_create (card, port[dev], + irq[dev], + dma1[dev], + dma2[dev], + chip); +if (error) {snd_card_free (card);return error; }
@@ -152,12 +154,14 @@ static int snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard,sprintf (card->longname,"%s, SS at 0x%lx, irq %d, dma %d&%d" , card->shortname, chip->port, irq[dev], dma1[dev], dma2[dev]); -if ((error =snd_ad1816a_pcm (chip,0 )) <0 ) { + error =snd_ad1816a_pcm (chip,0 ); +if (error <0 ) {snd_card_free (card);return error; } -if ((error =snd_ad1816a_mixer (chip)) <0 ) { + error =snd_ad1816a_mixer (chip); +if (error <0 ) {snd_card_free (card);return error; }
@@ -189,7 +193,8 @@ static int snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard, } } -if ((error =snd_card_register (card)) <0 ) { + error =snd_card_register (card); +if (error <0 ) {snd_card_free (card);return error; }
sound/isa/ad1816a/ad1816a_lib.c +18 -9
@@ -155,7 +155,8 @@ static void snd_ad1816a_close(struct snd_ad1816a *chip, unsigned int mode)snd_ad1816a_write_mask (chip,AD1816A_INTERRUPT_ENABLE ,AD1816A_TIMER_IRQ_ENABLE ,0x0000 ); } -if (!((chip->mode &= ~mode) &AD1816A_MODE_OPEN )) + chip->mode &= ~mode; +if (!(chip->mode &AD1816A_MODE_OPEN )) chip->mode =0 ;spin_unlock_irqrestore (&chip->lock, flags);
@@ -426,7 +427,8 @@ static int snd_ad1816a_playback_open(struct snd_pcm_substream *substream)struct snd_pcm_runtime *runtime = substream->runtime;int error; -if ((error =snd_ad1816a_open (chip,AD1816A_MODE_PLAYBACK )) <0 ) + error =snd_ad1816a_open (chip,AD1816A_MODE_PLAYBACK ); +if (error <0 )return error; runtime->hw = snd_ad1816a_playback;snd_pcm_limit_isa_dma_size (chip->dma1, &runtime->hw.buffer_bytes_max);
@@ -441,7 +443,8 @@ static int snd_ad1816a_capture_open(struct snd_pcm_substream *substream)struct snd_pcm_runtime *runtime = substream->runtime;int error; -if ((error =snd_ad1816a_open (chip,AD1816A_MODE_CAPTURE )) <0 ) + error =snd_ad1816a_open (chip,AD1816A_MODE_CAPTURE ); +if (error <0 )return error; runtime->hw = snd_ad1816a_capture;snd_pcm_limit_isa_dma_size (chip->dma2, &runtime->hw.buffer_bytes_max);
@@ -586,7 +589,8 @@ int snd_ad1816a_create(struct snd_card *card, chip->dma1 =-1 ; chip->dma2 =-1 ; -if ((chip->res_port =request_region (port,16 ,"AD1816A" )) ==NULL ) { + chip->res_port =request_region (port,16 ,"AD1816A" ); +if (!chip->res_port) {snd_printk (KERN_ERR "ad1816a: can't grab port 0x%lx\n" , port);snd_ad1816a_free (chip);return -EBUSY ;
@@ -615,7 +619,8 @@ int snd_ad1816a_create(struct snd_card *card, chip->port = port;spin_lock_init (&chip->lock); -if ((error =snd_ad1816a_probe (chip))) { + error =snd_ad1816a_probe (chip); +if (error) {snd_ad1816a_free (chip);return error; }
@@ -623,7 +628,8 @@ int snd_ad1816a_create(struct snd_card *card,snd_ad1816a_init (chip);/* Register device */ -if ((error =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops)) <0 ) { + error =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (error <0 ) {snd_ad1816a_free (chip);return error; }
@@ -652,7 +658,8 @@ int snd_ad1816a_pcm(struct snd_ad1816a *chip, int device)int error;struct snd_pcm *pcm; -if ((error =snd_pcm_new (chip->card,"AD1816A" , device,1 ,1 , &pcm))) + error =snd_pcm_new (chip->card,"AD1816A" , device,1 ,1 , &pcm); +if (error)return error;snd_pcm_set_ops (pcm,SNDRV_PCM_STREAM_PLAYBACK , &snd_ad1816a_playback_ops);
@@ -682,7 +689,8 @@ int snd_ad1816a_timer(struct snd_ad1816a *chip, int device) tid.card = chip->card->number; tid.device = device; tid.subdevice =0 ; -if ((error =snd_timer_new (chip->card,"AD1816A" , &tid, &timer)) <0 ) + error =snd_timer_new (chip->card,"AD1816A" , &tid, &timer); +if (error <0 )return error;strcpy (timer->name,snd_ad1816a_chip_id (chip)); timer->private_data = chip;
@@ -944,7 +952,8 @@ int snd_ad1816a_mixer(struct snd_ad1816a *chip)strcpy (card->mixername,snd_ad1816a_chip_id (chip));for (idx =0 ; idx <ARRAY_SIZE (snd_ad1816a_controls); idx++) { -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_ad1816a_controls[idx], chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_ad1816a_controls[idx], chip)); +if (err <0 )return err; }return 0 ;
Signature · 1 line
2.26.2
PATCH 6/66 ALSA: wavefront: Fix assignment in if condition
In reply to Takashi IwaiISA WaveFront driver 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.
--- sound/isa/wavefront/wavefront.c | 6 ++- sound/isa/wavefront/wavefront_midi.c | 20 ++++++---- sound/isa/wavefront/wavefront_synth.c | 56 ++++++++++++++++----------- 3 files changed, 50 insertions(+), 32 deletions(-)
sound/isa/wavefront/wavefront.c +4 -2
@@ -555,7 +555,8 @@ static int snd_wavefront_isa_probe(struct device *pdev, err =snd_wavefront_card_new (pdev, dev, &card);if (err <0 )return err; -if ((err =snd_wavefront_probe (card, dev)) <0 ) { + err =snd_wavefront_probe (card, dev); +if (err <0 ) {snd_card_free (card);return err; }
@@ -610,7 +611,8 @@ static int snd_wavefront_pnp_detect(struct pnp_card_link *pcard, } } -if ((res =snd_wavefront_probe (card, dev)) <0 ) + res =snd_wavefront_probe (card, dev); +if (res <0 )return res;pnp_set_card_drvdata (pcard, card);
sound/isa/wavefront/wavefront_midi.c +12 -8
@@ -239,7 +239,8 @@ static int snd_wavefront_midi_input_open(struct snd_rawmidi_substream *substream mpu = *((snd_wavefront_mpu_id *) substream->rmidi->private_data); -if ((midi =get_wavefront_midi (substream)) ==NULL ) + midi =get_wavefront_midi (substream); +if (!midi)return -EIO ;spin_lock_irqsave (&midi->open, flags);
@@ -263,7 +264,8 @@ static int snd_wavefront_midi_output_open(struct snd_rawmidi_substream *substrea mpu = *((snd_wavefront_mpu_id *) substream->rmidi->private_data); -if ((midi =get_wavefront_midi (substream)) ==NULL ) + midi =get_wavefront_midi (substream); +if (!midi)return -EIO ;spin_lock_irqsave (&midi->open, flags);
@@ -287,7 +289,8 @@ static int snd_wavefront_midi_input_close(struct snd_rawmidi_substream *substrea mpu = *((snd_wavefront_mpu_id *) substream->rmidi->private_data); -if ((midi =get_wavefront_midi (substream)) ==NULL ) + midi =get_wavefront_midi (substream); +if (!midi)return -EIO ;spin_lock_irqsave (&midi->open, flags);
@@ -310,7 +313,8 @@ static int snd_wavefront_midi_output_close(struct snd_rawmidi_substream *substre mpu = *((snd_wavefront_mpu_id *) substream->rmidi->private_data); -if ((midi =get_wavefront_midi (substream)) ==NULL ) + midi =get_wavefront_midi (substream); +if (!midi)return -EIO ;spin_lock_irqsave (&midi->open, flags);
@@ -333,9 +337,9 @@ static void snd_wavefront_midi_input_trigger(struct snd_rawmidi_substream *subst mpu = *((snd_wavefront_mpu_id *) substream->rmidi->private_data); -if ((midi =get_wavefront_midi (substream)) ==NULL ) { + midi =get_wavefront_midi (substream); +if (!midi)return ; - }spin_lock_irqsave (&midi->virtual, flags);if (up) {
@@ -372,9 +376,9 @@ static void snd_wavefront_midi_output_trigger(struct snd_rawmidi_substream *subs mpu = *((snd_wavefront_mpu_id *) substream->rmidi->private_data); -if ((midi =get_wavefront_midi (substream)) ==NULL ) { + midi =get_wavefront_midi (substream); +if (!midi)return ; - }spin_lock_irqsave (&midi->virtual, flags);if (up) {
sound/isa/wavefront/wavefront_synth.c +34 -22
156 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 7/66 ALSA: cs423x: Fix assignment in if condition
In reply to Takashi IwaiISA CS423x driver 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.
--- sound/isa/cs423x/cs4236.c | 21 ++++++++++++++------- sound/isa/cs423x/cs4236_lib.c | 12 ++++++++---- 2 files changed, 22 insertions(+), 11 deletions(-)
sound/isa/cs423x/cs4236.c +14 -7
@@ -339,11 +339,13 @@ static int snd_cs423x_probe(struct snd_card *card, int dev)int err; acard = card->private_data; -if (sb_port[dev] >0 && sb_port[dev] !=SNDRV_AUTO_PORT ) -if ((acard->res_sb_port =request_region (sb_port[dev],16 ,IDENT " SB" )) ==NULL ) { +if (sb_port[dev] >0 && sb_port[dev] !=SNDRV_AUTO_PORT ) { + acard->res_sb_port =request_region (sb_port[dev],16 ,IDENT " SB" ); +if (!acard->res_sb_port) { printk(KERN_ERR IDENT ": unable to register SB port at 0x%lx\n", sb_port[dev]);return -EBUSY ; } + } err = snd_cs4236_create(card, port[dev], cport[dev], irq[dev],
@@ -393,7 +395,8 @@ static int snd_cs423x_probe(struct snd_card *card, int dev) OPL3_HW_OPL3_CS, 0, &opl3) < 0) { printk(KERN_WARNING IDENT ": OPL3 not detected\n"); } else { -if ((err =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL )) <0 ) + err =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL ); +if (err <0 )return err; } }
@@ -444,7 +447,8 @@ static int snd_cs423x_isa_probe(struct device *pdev, err =snd_cs423x_card_new (pdev, dev, &card);if (err <0 )return err; -if ((err =snd_cs423x_probe (card, dev)) <0 ) { + err =snd_cs423x_probe (card, dev); +if (err <0 ) {snd_card_free (card);return err; }
@@ -538,7 +542,8 @@ static int snd_cs423x_pnpbios_detect(struct pnp_dev *pdev,snd_card_free (card);return err; } -if ((err =snd_cs423x_probe (card, dev)) <0 ) { + err =snd_cs423x_probe (card, dev); +if (err <0 ) {snd_card_free (card);return err; }
@@ -592,13 +597,15 @@ static int snd_cs423x_pnpc_detect(struct pnp_card_link *pcard, res =snd_cs423x_card_new (&pcard->card->dev, dev, &card);if (res <0 )return res; -if ((res =snd_card_cs423x_pnpc (dev, card->private_data, pcard, pid)) <0 ) { + res =snd_card_cs423x_pnpc (dev, card->private_data, pcard, pid); +if (res <0 ) {printk (KERN_ERR "isapnp detection failed and probing for " IDENT " is not supported\n" );snd_card_free (card);return res; } -if ((res =snd_cs423x_probe (card, dev)) <0 ) { + res =snd_cs423x_probe (card, dev); +if (res <0 ) {snd_card_free (card);return res; }
sound/isa/cs423x/cs4236_lib.c +8 -4
@@ -1030,12 +1030,14 @@ int snd_cs4236_mixer(struct snd_wss *chip)if (chip->hardware ==WSS_HW_CS4235 || chip->hardware ==WSS_HW_CS4239 ) {for (idx =0 ; idx <ARRAY_SIZE (snd_cs4235_controls); idx++) { -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_cs4235_controls[idx], chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_cs4235_controls[idx], chip)); +if (err <0 )return err; } }else {for (idx =0 ; idx <ARRAY_SIZE (snd_cs4236_controls); idx++) { -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_cs4236_controls[idx], chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_cs4236_controls[idx], chip)); +if (err <0 )return err; } }
@@ -1058,13 +1060,15 @@ int snd_cs4236_mixer(struct snd_wss *chip) kcontrol =NULL ; }for (idx =0 ; idx < count; idx++, kcontrol++) { -if ((err =snd_ctl_add (card,snd_ctl_new1 (kcontrol, chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (kcontrol, chip)); +if (err <0 )return err; }if (chip->hardware ==WSS_HW_CS4237B || chip->hardware ==WSS_HW_CS4238B ) {for (idx =0 ; idx <ARRAY_SIZE (snd_cs4236_iec958_controls); idx++) { -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_cs4236_iec958_controls[idx], chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_cs4236_iec958_controls[idx], chip)); +if (err <0 )return err; } }
Signature · 1 line
2.26.2
PATCH 8/66 ALSA: opti9xx: Fix assignment in if condition
In reply to Takashi IwaiISA Opti9xx driver 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.
--- sound/isa/opti9xx/miro.c | 27 ++++++++++++++++++--------- sound/isa/opti9xx/opti92x-ad1848.c | 27 ++++++++++++++++++--------- 2 files changed, 36 insertions(+), 18 deletions(-)
sound/isa/opti9xx/miro.c +18 -9
@@ -722,35 +722,43 @@ static int snd_miro_mixer(struct snd_card *card, }for (idx =0 ; idx <ARRAY_SIZE (snd_miro_controls); idx++) { -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_miro_controls[idx], miro))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_miro_controls[idx], miro)); +if (err <0 )return err; }if ((miro->aci->aci_product =='A' ) || (miro->aci->aci_product =='B' )) {/* PCM1/PCM12 with power-amp and Line 2 */ -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_miro_line_control[0 ], miro))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_miro_line_control[0 ], miro)); +if (err <0 )return err; -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_miro_amp_control[0 ], miro))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_miro_amp_control[0 ], miro)); +if (err <0 )return err; }if ((miro->aci->aci_product =='B' ) || (miro->aci->aci_product =='C' )) {/* PCM12/PCM20 with mic-preamp */ -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_miro_preamp_control[0 ], miro))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_miro_preamp_control[0 ], miro)); +if (err <0 )return err; -if (miro->aci->aci_version >=176 ) -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_miro_capture_control[0 ], miro))) <0 ) +if (miro->aci->aci_version >=176 ) { + err =snd_ctl_add (card,snd_ctl_new1 (&snd_miro_capture_control[0 ], miro)); +if (err <0 )return err; + } }if (miro->aci->aci_product =='C' ) {/* PCM20 with radio and 7 band equalizer */ -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_miro_radio_control[0 ], miro))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_miro_radio_control[0 ], miro)); +if (err <0 )return err;for (idx =0 ; idx <ARRAY_SIZE (snd_miro_eq_controls); idx++) { -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_miro_eq_controls[idx], miro))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_miro_eq_controls[idx], miro)); +if (err <0 )return err; } }
@@ -1178,7 +1186,8 @@ static int snd_card_miro_detect(struct snd_card *card,for (i = OPTi9XX_HW_82C929; i <= OPTi9XX_HW_82C924; i++) { -if ((err =snd_miro_init (chip, i)) <0 ) + err =snd_miro_init (chip, i); +if (err <0 )return err; err =snd_miro_opti_check (chip);
sound/isa/opti9xx/opti92x-ad1848.c +18 -9
@@ -970,32 +970,37 @@ static int snd_opti9xx_isa_probe(struct device *devptr,#endif /* CS4231 || OPTi93X */ if (mpu_port ==SNDRV_AUTO_PORT ) { -if ((mpu_port =snd_legacy_find_free_ioport (possible_mpu_ports,2 )) <0 ) { + mpu_port =snd_legacy_find_free_ioport (possible_mpu_ports,2 ); +if (mpu_port <0 ) {snd_printk (KERN_ERR "unable to find a free MPU401 port\n" );return -EBUSY ; } }if (irq ==SNDRV_AUTO_IRQ ) { -if ((irq =snd_legacy_find_free_irq (possible_irqs)) <0 ) { + irq =snd_legacy_find_free_irq (possible_irqs); +if (irq <0 ) {snd_printk (KERN_ERR "unable to find a free IRQ\n" );return -EBUSY ; } }if (mpu_irq ==SNDRV_AUTO_IRQ ) { -if ((mpu_irq =snd_legacy_find_free_irq (possible_mpu_irqs)) <0 ) { + mpu_irq =snd_legacy_find_free_irq (possible_mpu_irqs); +if (mpu_irq <0 ) {snd_printk (KERN_ERR "unable to find a free MPU401 IRQ\n" );return -EBUSY ; } }if (dma1 ==SNDRV_AUTO_DMA ) { -if ((dma1 =snd_legacy_find_free_dma (possible_dma1s)) <0 ) { + dma1 =snd_legacy_find_free_dma (possible_dma1s); +if (dma1 <0 ) {snd_printk (KERN_ERR "unable to find a free DMA1\n" );return -EBUSY ; } }#if defined(CS4231 ) || defined(OPTi93X)if (dma2 ==SNDRV_AUTO_DMA ) { -if ((dma2 =snd_legacy_find_free_dma (possible_dma2s[dma1 %4 ])) <0 ) { + dma2 =snd_legacy_find_free_dma (possible_dma2s[dma1 %4 ]); +if (dma2 <0 ) {snd_printk (KERN_ERR "unable to find a free DMA2\n" );return -EBUSY ; }
@@ -1006,11 +1011,13 @@ static int snd_opti9xx_isa_probe(struct device *devptr,if (error <0 )return error; -if ((error =snd_card_opti9xx_detect (card, card->private_data)) <0 ) { + error =snd_card_opti9xx_detect (card, card->private_data); +if (error <0 ) {snd_card_free (card);return error; } -if ((error =snd_opti9xx_probe (card)) <0 ) { + error =snd_opti9xx_probe (card); +if (error <0 ) {snd_card_free (card);return error; }
@@ -1111,7 +1118,8 @@ static int snd_opti9xx_pnp_probe(struct pnp_card_link *pcard,return -ENODEV ; } -if ((error =snd_opti9xx_init (chip, hw))) { + error =snd_opti9xx_init (chip, hw); +if (error) {snd_card_free (card);return error; }
@@ -1121,7 +1129,8 @@ static int snd_opti9xx_pnp_probe(struct pnp_card_link *pcard,snd_card_free (card);return error; } -if ((error =snd_opti9xx_probe (card)) <0 ) { + error =snd_opti9xx_probe (card); +if (error <0 ) {snd_card_free (card);return error; }
Signature · 1 line
2.26.2
PATCH 9/66 ALSA: opl3sa2: Fix assignment in if condition
In reply to Takashi IwaiISA OPL3SA2 driver 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.
--- sound/isa/opl3sa2.c | 68 +++++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 24 deletions(-)
sound/isa/opl3sa2.c +44 -24
@@ -208,7 +208,8 @@ static int snd_opl3sa2_detect(struct snd_card *card)char str[2 ]; port = chip->port; -if ((chip->res_port =request_region (port,2 ,"OPL3-SA control" )) ==NULL ) { + chip->res_port =request_region (port,2 ,"OPL3-SA control" ); +if (!chip->res_port) { snd_printk(KERN_ERR PFX "can't grab port 0x%lx\n", port);return -EBUSY ; }
@@ -239,14 +240,16 @@ static int snd_opl3sa2_detect(struct snd_card *card) str[1 ] =0 ;strcat (card->shortname, str);snd_opl3sa2_write (chip,OPL3SA2_MISC , tmp ^7 ); -if ((tmp1 =snd_opl3sa2_read (chip,OPL3SA2_MISC )) != tmp) { + tmp1 =snd_opl3sa2_read (chip,OPL3SA2_MISC ); +if (tmp1 != tmp) {snd_printd ("OPL3-SA [0x%lx] detect (1) = 0x%x (0x%x)\n" , port, tmp, tmp1);return -ENODEV ; }/* try if the MIC register is accessible */ tmp =snd_opl3sa2_read (chip,OPL3SA2_MIC );snd_opl3sa2_write (chip,OPL3SA2_MIC ,0x8a ); -if (((tmp1 =snd_opl3sa2_read (chip,OPL3SA2_MIC )) &0x9f ) !=0x8a ) { + tmp1 =snd_opl3sa2_read (chip,OPL3SA2_MIC ); +if ((tmp1 &0x9f ) !=0x8a ) {snd_printd ("OPL3-SA [0x%lx] detect (2) = 0x%x (0x%x)\n" , port, tmp, tmp1);return -ENODEV ; }
@@ -489,32 +492,38 @@ static int snd_opl3sa2_mixer(struct snd_card *card)/* reassign AUX0 to CD */ strcpy (id1.name,"Aux Playback Switch" );strcpy (id2.name,"CD Playback Switch" ); -if ((err =snd_ctl_rename_id (card, &id1, &id2)) <0 ) { + err =snd_ctl_rename_id (card, &id1, &id2); +if (err <0 ) {snd_printk (KERN_ERR "Cannot rename opl3sa2 control\n" );return err; }strcpy (id1.name,"Aux Playback Volume" );strcpy (id2.name,"CD Playback Volume" ); -if ((err =snd_ctl_rename_id (card, &id1, &id2)) <0 ) { + err =snd_ctl_rename_id (card, &id1, &id2); +if (err <0 ) {snd_printk (KERN_ERR "Cannot rename opl3sa2 control\n" );return err; }/* reassign AUX1 to FM */ strcpy (id1.name,"Aux Playback Switch" ); id1.index =1 ;strcpy (id2.name,"FM Playback Switch" ); -if ((err =snd_ctl_rename_id (card, &id1, &id2)) <0 ) { + err =snd_ctl_rename_id (card, &id1, &id2); +if (err <0 ) {snd_printk (KERN_ERR "Cannot rename opl3sa2 control\n" );return err; }strcpy (id1.name,"Aux Playback Volume" );strcpy (id2.name,"FM Playback Volume" ); -if ((err =snd_ctl_rename_id (card, &id1, &id2)) <0 ) { + err =snd_ctl_rename_id (card, &id1, &id2); +if (err <0 ) {snd_printk (KERN_ERR "Cannot rename opl3sa2 control\n" );return err; }/* add OPL3SA2 controls */ for (idx =0 ; idx <ARRAY_SIZE (snd_opl3sa2_controls); idx++) { -if ((err =snd_ctl_add (card, kctl =snd_ctl_new1 (&snd_opl3sa2_controls[idx], chip))) <0 ) + kctl =snd_ctl_new1 (&snd_opl3sa2_controls[idx], chip); + err =snd_ctl_add (card, kctl); +if (err <0 )return err;switch (idx) {case 0 : chip->master_switch = kctl; kctl->private_free = snd_opl3sa2_master_free;break ;
@@ -522,9 +531,11 @@ static int snd_opl3sa2_mixer(struct snd_card *card) } }if (chip->version >2 ) { -for (idx =0 ; idx <ARRAY_SIZE (snd_opl3sa2_tone_controls); idx++) -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_opl3sa2_tone_controls[idx], chip))) <0 ) +for (idx =0 ; idx <ARRAY_SIZE (snd_opl3sa2_tone_controls); idx++) { + err =snd_ctl_add (card,snd_ctl_new1 (&snd_opl3sa2_tone_controls[idx], chip)); +if (err <0 )return err; + } }return 0 ; }
@@ -677,20 +688,24 @@ static int snd_opl3sa2_probe(struct snd_card *card, int dev)if (err <0 )return err;if (fm_port[dev] >=0x340 && fm_port[dev] <0x400 ) { -if ((err =snd_opl3_create (card, fm_port[dev], - fm_port[dev] +2 , -OPL3_HW_OPL3 ,0 , &opl3)) <0 ) + err =snd_opl3_create (card, fm_port[dev], + fm_port[dev] +2 , +OPL3_HW_OPL3 ,0 , &opl3); +if (err <0 )return err; -if ((err =snd_opl3_timer_new (opl3,1 ,2 )) <0 ) + err =snd_opl3_timer_new (opl3,1 ,2 ); +if (err <0 )return err; -if ((err =snd_opl3_hwdep_new (opl3,0 ,1 , &chip->synth)) <0 ) + err =snd_opl3_hwdep_new (opl3,0 ,1 , &chip->synth); +if (err <0 )return err; }if (midi_port[dev] >=0x300 && midi_port[dev] <0x340 ) { -if ((err =snd_mpu401_uart_new (card,0 ,MPU401_HW_OPL3SA2 , - midi_port[dev], -MPU401_INFO_IRQ_HOOK ,-1 , - &chip->rmidi)) <0 ) + err =snd_mpu401_uart_new (card,0 ,MPU401_HW_OPL3SA2 , + midi_port[dev], +MPU401_INFO_IRQ_HOOK ,-1 , + &chip->rmidi); +if (err <0 )return err; } sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
@@ -721,11 +736,13 @@ static int snd_opl3sa2_pnp_detect(struct pnp_dev *pdev, err =snd_opl3sa2_card_new (&pdev->dev, dev, &card);if (err <0 )return err; -if ((err =snd_opl3sa2_pnp (dev, card->private_data, pdev)) <0 ) { + err =snd_opl3sa2_pnp (dev, card->private_data, pdev); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_opl3sa2_probe (card, dev)) <0 ) { + err =snd_opl3sa2_probe (card, dev); +if (err <0 ) {snd_card_free (card);return err; }
@@ -785,11 +802,13 @@ static int snd_opl3sa2_pnp_cdetect(struct pnp_card_link *pcard, err =snd_opl3sa2_card_new (&pdev->dev, dev, &card);if (err <0 )return err; -if ((err =snd_opl3sa2_pnp (dev, card->private_data, pdev)) <0 ) { + err =snd_opl3sa2_pnp (dev, card->private_data, pdev); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_opl3sa2_probe (card, dev)) <0 ) { + err =snd_opl3sa2_probe (card, dev); +if (err <0 ) {snd_card_free (card);return err; }
@@ -865,7 +884,8 @@ static int snd_opl3sa2_isa_probe(struct device *pdev, err =snd_opl3sa2_card_new (pdev, dev, &card);if (err <0 )return err; -if ((err =snd_opl3sa2_probe (card, dev)) <0 ) { + err =snd_opl3sa2_probe (card, dev); +if (err <0 ) {snd_card_free (card);return err; }
Signature · 1 line
2.26.2
PATCH 10/66 ALSA: es18xx: Fix assignment in if condition
In reply to Takashi IwaiISA ES18xx driver 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.
--- sound/isa/es18xx.c | 51 ++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 17 deletions(-)
sound/isa/es18xx.c +34 -17
@@ -1573,7 +1573,8 @@ static int snd_es18xx_identify(struct snd_es18xx *chip)udelay (10 ); chip->ctrl_port +=inb (chip->port +0x05 ); -if ((chip->res_ctrl_port =request_region (chip->ctrl_port,8 ,"ES18xx - CTRL" )) ==NULL ) { + chip->res_ctrl_port =request_region (chip->ctrl_port,8 ,"ES18xx - CTRL" ); +if (!chip->res_ctrl_port) { snd_printk(KERN_ERR PFX "unable go grab port 0x%lx\n", chip->ctrl_port);return -EBUSY ; }
@@ -1832,41 +1833,48 @@ static int snd_es18xx_mixer(struct snd_card *card)break ; } } -if ((err =snd_ctl_add (card, kctl)) <0 ) + err =snd_ctl_add (card, kctl); +if (err <0 )return err; }if (chip->caps &ES18XX_PCM2 ) {for (idx =0 ; idx <ARRAY_SIZE (snd_es18xx_pcm2_controls); idx++) { -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_es18xx_pcm2_controls[idx], chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_es18xx_pcm2_controls[idx], chip)); +if (err <0 )return err; } }else {for (idx =0 ; idx <ARRAY_SIZE (snd_es18xx_pcm1_controls); idx++) { -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_es18xx_pcm1_controls[idx], chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_es18xx_pcm1_controls[idx], chip)); +if (err <0 )return err; } }if (chip->caps &ES18XX_RECMIX ) {for (idx =0 ; idx <ARRAY_SIZE (snd_es18xx_recmix_controls); idx++) { -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_es18xx_recmix_controls[idx], chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_es18xx_recmix_controls[idx], chip)); +if (err <0 )return err; } }switch (chip->version) {default : -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_es18xx_micpre1_control, chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_es18xx_micpre1_control, chip)); +if (err <0 )return err;break ;case 0x1869 :case 0x1879 : -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_es18xx_micpre2_control, chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_es18xx_micpre2_control, chip)); +if (err <0 )return err;break ; }if (chip->caps &ES18XX_SPATIALIZER ) {for (idx =0 ; idx <ARRAY_SIZE (snd_es18xx_spatializer_controls); idx++) { -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_es18xx_spatializer_controls[idx], chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_es18xx_spatializer_controls[idx], chip)); +if (err <0 )return err; } }
@@ -1879,7 +1887,8 @@ static int snd_es18xx_mixer(struct snd_card *card)else chip->hw_switch = kctl; kctl->private_free = snd_es18xx_hwv_free; -if ((err =snd_ctl_add (card, kctl)) <0 ) + err =snd_ctl_add (card, kctl); +if (err <0 )return err; }
@@ -2154,7 +2163,8 @@ static int snd_es18xx_isa_probe1(int dev, struct device *devptr) err =snd_es18xx_card_new (devptr, dev, &card);if (err <0 )return err; -if ((err =snd_audiodrive_probe (card, dev)) <0 ) { + err =snd_audiodrive_probe (card, dev); +if (err <0 ) {snd_card_free (card);return err; }
@@ -2169,19 +2179,22 @@ static int snd_es18xx_isa_probe(struct device *pdev, unsigned int dev)static const int possible_dmas[] = {1 ,0 ,3 ,5 ,-1 };if (irq[dev] ==SNDRV_AUTO_IRQ ) { -if ((irq[dev] =snd_legacy_find_free_irq (possible_irqs)) <0 ) { + irq[dev] =snd_legacy_find_free_irq (possible_irqs); +if (irq[dev] <0 ) { snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");return -EBUSY ; } }if (dma1[dev] ==SNDRV_AUTO_DMA ) { -if ((dma1[dev] =snd_legacy_find_free_dma (possible_dmas)) <0 ) { + dma1[dev] =snd_legacy_find_free_dma (possible_dmas); +if (dma1[dev] <0 ) { snd_printk(KERN_ERR PFX "unable to find a free DMA1\n");return -EBUSY ; } }if (dma2[dev] ==SNDRV_AUTO_DMA ) { -if ((dma2[dev] =snd_legacy_find_free_dma (possible_dmas)) <0 ) { + dma2[dev] =snd_legacy_find_free_dma (possible_dmas); +if (dma2[dev] <0 ) { snd_printk(KERN_ERR PFX "unable to find a free DMA2\n");return -EBUSY ; }
@@ -2257,11 +2270,13 @@ static int snd_audiodrive_pnp_detect(struct pnp_dev *pdev, err =snd_es18xx_card_new (&pdev->dev, dev, &card);if (err <0 )return err; -if ((err =snd_audiodrive_pnp (dev, card->private_data, pdev)) <0 ) { + err =snd_audiodrive_pnp (dev, card->private_data, pdev); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_audiodrive_probe (card, dev)) <0 ) { + err =snd_audiodrive_probe (card, dev); +if (err <0 ) {snd_card_free (card);return err; }
@@ -2315,11 +2330,13 @@ static int snd_audiodrive_pnpc_detect(struct pnp_card_link *pcard,if (res <0 )return res; -if ((res =snd_audiodrive_pnpc (dev, card->private_data, pcard, pid)) <0 ) { + res =snd_audiodrive_pnpc (dev, card->private_data, pcard, pid); +if (res <0 ) {snd_card_free (card);return res; } -if ((res =snd_audiodrive_probe (card, dev)) <0 ) { + res =snd_audiodrive_probe (card, dev); +if (res <0 ) {snd_card_free (card);return res; }
Signature · 1 line
2.26.2
PATCH 11/66 ALSA: cmi8330: Fix assignment in if condition
In reply to Takashi IwaiISA CMI8330 driver 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.
--- sound/isa/cmi8330.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-)
sound/isa/cmi8330.c +23 -14
@@ -284,7 +284,8 @@ static int cmi8330_add_sb_mixers(struct snd_sb *chip) }for (idx =0 ; idx <ARRAY_SIZE (cmi8330_sb_mixers); idx++) { -if ((err =snd_sbmixer_add_ctl_elem (chip, &cmi8330_sb_mixers[idx])) <0 ) + err =snd_sbmixer_add_ctl_elem (chip, &cmi8330_sb_mixers[idx]); +if (err <0 )return err; }return 0 ;
@@ -307,7 +308,8 @@ static int snd_cmi8330_mixer(struct snd_card *card, struct snd_cmi8330 *acard) }#ifdef ENABLE_SB_MIXER -if ((err =cmi8330_add_sb_mixers (acard->sb)) <0 ) + err =cmi8330_add_sb_mixers (acard->sb); +if (err <0 )return err;#endif return 0 ;
@@ -432,7 +434,8 @@ static int snd_cmi8330_pcm(struct snd_card *card, struct snd_cmi8330 *chip) snd_cmi8330_capture_open }; -if ((err =snd_pcm_new (card, (chip->type ==CMI8329 ) ?"CMI8329" :"CMI8330" ,0 ,1 ,1 , &pcm)) <0 ) + err =snd_pcm_new (card, (chip->type ==CMI8329 ) ?"CMI8329" :"CMI8330" ,0 ,1 ,1 , &pcm); +if (err <0 )return err;strcpy (pcm->name, (chip->type ==CMI8329 ) ?"CMI8329" :"CMI8330" ); pcm->private_data = chip;
@@ -536,12 +539,13 @@ static int snd_cmi8330_probe(struct snd_card *card, int dev)return -ENODEV ; } -if ((err =snd_sbdsp_create (card, sbport[dev], - sbirq[dev], - snd_sb16dsp_interrupt, - sbdma8[dev], - sbdma16[dev], -SB_HW_AUTO , &acard->sb)) <0 ) { + err =snd_sbdsp_create (card, sbport[dev], + sbirq[dev], + snd_sb16dsp_interrupt, + sbdma8[dev], + sbdma16[dev], +SB_HW_AUTO , &acard->sb); +if (err <0 ) { snd_printk(KERN_ERR PFX "SB16 device busy??\n");return err; }
@@ -555,12 +559,14 @@ static int snd_cmi8330_probe(struct snd_card *card, int dev)snd_wss_out (acard->wss, i, snd_cmi8330_image[i -CMI8330_RMUX3D ]); -if ((err =snd_cmi8330_mixer (card, acard)) <0 ) { + err =snd_cmi8330_mixer (card, acard); +if (err <0 ) { snd_printk(KERN_ERR PFX "failed to create mixers\n");return err; } -if ((err =snd_cmi8330_pcm (card, acard)) <0 ) { + err =snd_cmi8330_pcm (card, acard); +if (err <0 ) { snd_printk(KERN_ERR PFX "failed to create pcms\n");return err; }
@@ -622,7 +628,8 @@ static int snd_cmi8330_isa_probe(struct device *pdev, err =snd_cmi8330_card_new (pdev, dev, &card);if (err <0 )return err; -if ((err =snd_cmi8330_probe (card, dev)) <0 ) { + err =snd_cmi8330_probe (card, dev); +if (err <0 ) {snd_card_free (card);return err; }
@@ -683,12 +690,14 @@ static int snd_cmi8330_pnp_detect(struct pnp_card_link *pcard, res =snd_cmi8330_card_new (&pcard->card->dev, dev, &card);if (res <0 )return res; -if ((res =snd_cmi8330_pnp (dev, card->private_data, pcard, pid)) <0 ) { + res =snd_cmi8330_pnp (dev, card->private_data, pcard, pid); +if (res <0 ) { snd_printk(KERN_ERR PFX "PnP detection failed\n");snd_card_free (card);return res; } -if ((res =snd_cmi8330_probe (card, dev)) <0 ) { + res =snd_cmi8330_probe (card, dev); +if (res <0 ) {snd_card_free (card);return res; }
Signature · 1 line
2.26.2
PATCH 12/66 ALSA: als100: Fix assignment in if condition
In reply to Takashi IwaiISA ALS100 driver 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.
--- sound/isa/als100.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
sound/isa/als100.c +12 -6
@@ -177,7 +177,8 @@ static int snd_card_als100_probe(int dev,return error; acard = card->private_data; -if ((error =snd_card_als100_pnp (dev, acard, pcard, pid))) { + error =snd_card_als100_pnp (dev, acard, pcard, pid); +if (error) {snd_card_free (card);return error; }
@@ -211,12 +212,14 @@ static int snd_card_als100_probe(int dev, dma16[dev]); } -if ((error =snd_sb16dsp_pcm (chip,0 )) <0 ) { + error =snd_sb16dsp_pcm (chip,0 ); +if (error <0 ) {snd_card_free (card);return error; } -if ((error =snd_sbmixer_new (chip)) <0 ) { + error =snd_sbmixer_new (chip); +if (error <0 ) {snd_card_free (card);return error; }
@@ -245,18 +248,21 @@ static int snd_card_als100_probe(int dev, snd_printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx\n", fm_port[dev], fm_port[dev] + 2); }else { -if ((error =snd_opl3_timer_new (opl3,0 ,1 )) <0 ) { + error =snd_opl3_timer_new (opl3,0 ,1 ); +if (error <0 ) {snd_card_free (card);return error; } -if ((error =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL )) <0 ) { + error =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL ); +if (error <0 ) {snd_card_free (card);return error; } } } -if ((error =snd_card_register (card)) <0 ) { + error =snd_card_register (card); +if (error <0 ) {snd_card_free (card);return error; }
Signature · 1 line
2.26.2
PATCH 13/66 ALSA: azt2320: Fix assignment in if condition
In reply to Takashi IwaiISA AZT2320 driver 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.
--- sound/isa/azt2320.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
sound/isa/azt2320.c +14 -7
@@ -148,9 +148,11 @@ static int snd_card_azt2320_enable_wss(unsigned long port) {int error; -if ((error =snd_card_azt2320_command (port,0x09 ))) + error =snd_card_azt2320_command (port,0x09 ); +if (error)return error; -if ((error =snd_card_azt2320_command (port,0x00 ))) + error =snd_card_azt2320_command (port,0x00 ); +if (error)return error;mdelay (5 );
@@ -174,12 +176,14 @@ static int snd_card_azt2320_probe(int dev,return error; acard = card->private_data; -if ((error =snd_card_azt2320_pnp (dev, acard, pcard, pid))) { + error =snd_card_azt2320_pnp (dev, acard, pcard, pid); +if (error) {snd_card_free (card);return error; } -if ((error =snd_card_azt2320_enable_wss (port[dev]))) { + error =snd_card_azt2320_enable_wss (port[dev]); +if (error) {snd_card_free (card);return error; }
@@ -228,18 +232,21 @@ static int snd_card_azt2320_probe(int dev, snd_printk(KERN_ERR PFX "no OPL device at 0x%lx-0x%lx\n", fm_port[dev], fm_port[dev] + 2); }else { -if ((error =snd_opl3_timer_new (opl3,1 ,2 )) <0 ) { + error =snd_opl3_timer_new (opl3,1 ,2 ); +if (error <0 ) {snd_card_free (card);return error; } -if ((error =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL )) <0 ) { + error =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL ); +if (error <0 ) {snd_card_free (card);return error; } } } -if ((error =snd_card_register (card)) <0 ) { + error =snd_card_register (card); +if (error <0 ) {snd_card_free (card);return error; }
Signature · 1 line
2.26.2
PATCH 14/66 ALSA: isa: Fix assignment in if condition
In reply to Takashi IwaiISA ES1688 and WSS 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.
--- sound/isa/es1688/es1688_lib.c | 3 ++- sound/isa/wss/wss_lib.c | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-)
sound/isa/es1688/es1688_lib.c +2 -1
@@ -971,7 +971,8 @@ int snd_es1688_mixer(struct snd_card *card, struct snd_es1688 *chip)strcpy (card->mixername,snd_es1688_chip_id (chip));for (idx =0 ; idx <ARRAY_SIZE (snd_es1688_controls); idx++) { -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_es1688_controls[idx], chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_es1688_controls[idx], chip)); +if (err <0 )return err; }for (idx =0 ; idx <ES1688_INIT_TABLE_SIZE ; idx++) {
sound/isa/wss/wss_lib.c +6 -3
@@ -1493,7 +1493,8 @@ static int snd_wss_playback_open(struct snd_pcm_substream *substream)snd_pcm_limit_isa_dma_size (chip->dma1, &runtime->hw.period_bytes_max);if (chip->claim_dma) { -if ((err = chip->claim_dma (chip, chip->dma_private_data, chip->dma1)) <0 ) + err = chip->claim_dma (chip, chip->dma_private_data, chip->dma1); +if (err <0 )return err; }
@@ -1533,7 +1534,8 @@ static int snd_wss_capture_open(struct snd_pcm_substream *substream)snd_pcm_limit_isa_dma_size (chip->dma2, &runtime->hw.period_bytes_max);if (chip->claim_dma) { -if ((err = chip->claim_dma (chip, chip->dma_private_data, chip->dma2)) <0 ) + err = chip->claim_dma (chip, chip->dma_private_data, chip->dma2); +if (err <0 )return err; }
@@ -1934,7 +1936,8 @@ int snd_wss_timer(struct snd_wss *chip, int device) tid.card = chip->card->number; tid.device = device; tid.subdevice =0 ; -if ((err =snd_timer_new (chip->card,"CS4231" , &tid, &timer)) <0 ) + err =snd_timer_new (chip->card,"CS4231" , &tid, &timer); +if (err <0 )return err;strcpy (timer->name,snd_wss_chip_id (chip)); timer->private_data = chip;
Signature · 1 line
2.26.2
PATCH 15/66 ALSA: ad1889: Fix assignment in if condition
In reply to Takashi IwaiPCI AD1889 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.
--- sound/pci/ad1889.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
sound/pci/ad1889.c +10 -5
@@ -852,7 +852,8 @@ snd_ad1889_create(struct snd_card *card, *rchip =NULL ; -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err;/* check PCI availability (32bit DMA) */
@@ -863,7 +864,8 @@ snd_ad1889_create(struct snd_card *card, }/* allocate chip specific data with zero-filled memory */ -if ((chip =kzalloc (sizeof (*chip),GFP_KERNEL )) ==NULL ) { + chip =kzalloc (sizeof (*chip),GFP_KERNEL ); +if (!chip) {pci_disable_device (pci);return -ENOMEM ; }
@@ -874,7 +876,8 @@ snd_ad1889_create(struct snd_card *card, chip->irq =-1 ;/* (1) PCI resource allocation */ -if ((err =pci_request_regions (pci, card->driver)) <0 ) + err =pci_request_regions (pci, card->driver); +if (err <0 ) goto free_and_ret; chip->bar =pci_resource_start (pci,0 );
@@ -900,12 +903,14 @@ snd_ad1889_create(struct snd_card *card, card->sync_irq = chip->irq;/* (2) initialization of the chip hardware */ -if ((err =snd_ad1889_init (chip)) <0 ) { + err =snd_ad1889_init (chip); +if (err <0 ) {snd_ad1889_free (chip);return err; } -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (err <0 ) {snd_ad1889_free (chip);return err; }
Signature · 1 line
2.26.2
PATCH 16/66 ALSA: ak4531: Fix assignment in if condition
In reply to Takashi IwaiAK4531 codec 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.
--- sound/pci/ak4531_codec.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
sound/pci/ak4531_codec.c +6 -3
@@ -384,7 +384,8 @@ int snd_ak4531_mixer(struct snd_card *card,return -ENOMEM ; *ak4531 = *_ak4531;mutex_init (&ak4531->reg_mutex); -if ((err =snd_component_add (card,"AK4531" )) <0 ) { + err =snd_component_add (card,"AK4531" ); +if (err <0 ) {snd_ak4531_free (ak4531);return err; }
@@ -398,13 +399,15 @@ int snd_ak4531_mixer(struct snd_card *card, ak4531->write (ak4531, idx, ak4531->regs[idx] = snd_ak4531_initial_map[idx]);/* recording source is mixer */ }for (idx =0 ; idx <ARRAY_SIZE (snd_ak4531_controls); idx++) { -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_ak4531_controls[idx], ak4531))) <0 ) { + err =snd_ctl_add (card,snd_ctl_new1 (&snd_ak4531_controls[idx], ak4531)); +if (err <0 ) {snd_ak4531_free (ak4531);return err; } }snd_ak4531_proc_init (card, ak4531); -if ((err =snd_device_new (card,SNDRV_DEV_CODEC , ak4531, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_CODEC , ak4531, &ops); +if (err <0 ) {snd_ak4531_free (ak4531);return err; }
Signature · 1 line
2.26.2
PATCH 17/66 ALSA: als300: Fix assignment in if condition
In reply to Takashi IwaiPCI ALS300 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.
--- sound/pci/als300.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
sound/pci/als300.c +14 -8
@@ -298,7 +298,8 @@ static int snd_als300_ac97(struct snd_als300 *chip) .read = snd_als300_ac97_read, }; -if ((err =snd_ac97_bus (chip->card,0 , &ops,NULL , &bus)) <0 ) + err =snd_ac97_bus (chip->card,0 , &ops,NULL , &bus); +if (err <0 )return err;memset (&ac97,0 ,sizeof (ac97));
@@ -621,7 +622,8 @@ static int snd_als300_create(struct snd_card *card, }; *rchip =NULL ; -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err;if (dma_set_mask_and_coherent (&pci->dev,DMA_BIT_MASK (28 ))) {
@@ -643,7 +645,8 @@ static int snd_als300_create(struct snd_card *card, chip->chip_type = chip_type;spin_lock_init (&chip->reg_lock); -if ((err =pci_request_regions (pci,"ALS300" )) <0 ) { + err =pci_request_regions (pci,"ALS300" ); +if (err <0 ) {kfree (chip);pci_disable_device (pci);return err;
@@ -673,14 +676,15 @@ static int snd_als300_create(struct snd_card *card,return err; } -if ((err =snd_als300_new_pcm (chip)) <0 ) { + err =snd_als300_new_pcm (chip); +if (err <0 ) {dev_err (card->dev,"Could not create PCM\n" );snd_als300_free (chip);return err; } -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , - chip, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (err <0 ) {snd_als300_free (chip);return err; }
@@ -741,7 +745,8 @@ static int snd_als300_probe(struct pci_dev *pci, chip_type = pci_id->driver_data; -if ((err =snd_als300_create (card, pci, chip_type, &chip)) <0 ) { + err =snd_als300_create (card, pci, chip_type, &chip); +if (err <0 ) {snd_card_free (card);return err; }
@@ -758,7 +763,8 @@ static int snd_als300_probe(struct pci_dev *pci,sprintf (card->longname,"%s at 0x%lx irq %i" , card->shortname, chip->port, chip->irq); -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_card_free (card);return err; }
Signature · 1 line
2.26.2
PATCH 18/66 ALSA: als4000: Fix assignment in if condition
In reply to Takashi IwaiPCI ALS4000 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.
--- sound/pci/als4000.c | 55 ++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 25 deletions(-)
sound/pci/als4000.c +30 -25
@@ -832,9 +832,10 @@ static int snd_card_als4000_probe(struct pci_dev *pci, }/* enable PCI device */ -if ((err =pci_enable_device (pci)) <0 ) { + err =pci_enable_device (pci); +if (err <0 )return err; - } +/* check, if we can restrict PCI DMA transfers to 24 bits */ if (dma_set_mask_and_coherent (&pci->dev,DMA_BIT_MASK (24 ))) {dev_err (&pci->dev,"architecture does not support 24bit PCI busmaster DMA\n" );
@@ -842,7 +843,8 @@ static int snd_card_als4000_probe(struct pci_dev *pci,return -ENXIO ; } -if ((err =pci_request_regions (pci,"ALS4000" )) <0 ) { + err =pci_request_regions (pci,"ALS4000" ); +if (err <0 ) {pci_disable_device (pci);return err; }
@@ -869,17 +871,17 @@ static int snd_card_als4000_probe(struct pci_dev *pci,/* disable all legacy ISA stuff */ snd_als4000_set_addr (acard->iobase,0 ,0 ,0 ,0 ); -if ((err =snd_sbdsp_create (card, - iobase +ALS4K_IOB_10_ADLIB_ADDR0 , - pci->irq, + err =snd_sbdsp_create (card, + iobase +ALS4K_IOB_10_ADLIB_ADDR0 , + pci->irq,/* internally registered as IRQF_SHARED in case of ALS4000 SB */ - snd_als4000_interrupt, --1 , --1 , -SB_HW_ALS4000 , - &chip)) <0 ) { + snd_als4000_interrupt, +-1 , +-1 , +SB_HW_ALS4000 , + &chip); +if (err <0 ) goto out_err; - } acard->chip = chip; chip->pci = pci;
@@ -892,11 +894,12 @@ static int snd_card_als4000_probe(struct pci_dev *pci,sprintf (card->longname,"%s at 0x%lx, irq %i" , card->shortname, chip->alt_port, chip->irq); -if ((err =snd_mpu401_uart_new ( card,0 ,MPU401_HW_ALS4000 , - iobase +ALS4K_IOB_30_MIDI_DATA , -MPU401_INFO_INTEGRATED | -MPU401_INFO_IRQ_HOOK , --1 , &chip->rmidi)) <0 ) { + err =snd_mpu401_uart_new (card,0 ,MPU401_HW_ALS4000 , + iobase +ALS4K_IOB_30_MIDI_DATA , +MPU401_INFO_INTEGRATED | +MPU401_INFO_IRQ_HOOK , +-1 , &chip->rmidi); +if (err <0 ) {dev_err (&pci->dev,"no MPU-401 device at 0x%lx?\n" , iobase +ALS4K_IOB_30_MIDI_DATA ); goto out_err;
@@ -907,12 +910,13 @@ static int snd_card_als4000_probe(struct pci_dev *pci,* however there doesn't seem to be an ALSA API for this... * SPECS_PAGE: 21 */ -if ((err =snd_als4000_pcm (chip,0 )) <0 ) { + err =snd_als4000_pcm (chip,0 ); +if (err <0 ) goto out_err; - } -if ((err =snd_sbmixer_new (chip)) <0 ) { + + err =snd_sbmixer_new (chip); +if (err <0 ) goto out_err; - } if (snd_opl3_create(card, iobase + ALS4K_IOB_10_ADLIB_ADDR0,
@@ -922,16 +926,17 @@ static int snd_card_als4000_probe(struct pci_dev *pci, iobase +ALS4K_IOB_10_ADLIB_ADDR0 , iobase + ALS4K_IOB_12_ADLIB_ADDR2); }else { -if ((err =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL )) <0 ) { + err =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL ); +if (err <0 ) goto out_err; - } }snd_als4000_create_gameport (acard, dev); -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) goto out_err; - } +pci_set_drvdata (pci, card); dev++; err =0 ;
Signature · 1 line
2.26.2
PATCH 19/66 ALSA: atiixp: Fix assignment in if condition
In reply to Takashi IwaiPCI ATIIXP 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.
--- sound/pci/atiixp.c | 33 ++++++++++++++++++++++----------- sound/pci/atiixp_modem.c | 40 +++++++++++++++++++++++++--------------- 2 files changed, 47 insertions(+), 26 deletions(-)
sound/pci/atiixp.c +22 -11
@@ -1039,7 +1039,8 @@ static int snd_atiixp_pcm_open(struct snd_pcm_substream *substream,/* direct SPDIF */ runtime->hw.formats =SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE ; } -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; runtime->private_data = dma;
@@ -1415,7 +1416,8 @@ static int snd_atiixp_mixer_new(struct atiixp *chip, int clock,if (snd_atiixp_codec_detect (chip) <0 )return -ENXIO ; -if ((err =snd_ac97_bus (chip->card,0 , &ops, chip, &pbus)) <0 ) + err =snd_ac97_bus (chip->card,0 , &ops, chip, &pbus); +if (err <0 )return err; pbus->clock = clock; chip->ac97_bus = pbus;
@@ -1431,7 +1433,8 @@ static int snd_atiixp_mixer_new(struct atiixp *chip, int clock, ac97.scaps =AC97_SCAP_SKIP_MODEM |AC97_SCAP_POWER_SAVE ;if (! chip->spdif_over_aclink) ac97.scaps |=AC97_SCAP_NO_SPDIF ; -if ((err =snd_ac97_mixer (pbus, &ac97, &chip->ac97[i])) <0 ) { + err =snd_ac97_mixer (pbus, &ac97, &chip->ac97[i]); +if (err <0 ) { chip->ac97[i] =NULL ;/* to be sure */ dev_dbg (chip->card->dev,"codec %d not available for audio\n" , i);
@@ -1562,7 +1565,8 @@ static int snd_atiixp_create(struct snd_card *card,struct atiixp *chip;int err; -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err; chip =kzalloc (sizeof (*chip),GFP_KERNEL );
@@ -1576,7 +1580,8 @@ static int snd_atiixp_create(struct snd_card *card, chip->card = card; chip->pci = pci; chip->irq =-1 ; -if ((err =pci_request_regions (pci,"ATI IXP AC97" )) <0 ) { + err =pci_request_regions (pci,"ATI IXP AC97" ); +if (err <0 ) {pci_disable_device (pci);kfree (chip);return err;
@@ -1599,7 +1604,8 @@ static int snd_atiixp_create(struct snd_card *card, card->sync_irq = chip->irq;pci_set_master (pci); -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (err <0 ) {snd_atiixp_free (chip);return err; }
@@ -1622,19 +1628,23 @@ static int snd_atiixp_probe(struct pci_dev *pci,strcpy (card->driver, spdif_aclink ?"ATIIXP" :"ATIIXP-SPDMA" );strcpy (card->shortname,"ATI IXP" ); -if ((err =snd_atiixp_create (card, pci, &chip)) <0 ) + err =snd_atiixp_create (card, pci, &chip); +if (err <0 ) goto __error; card->private_data = chip; -if ((err =snd_atiixp_aclink_reset (chip)) <0 ) + err =snd_atiixp_aclink_reset (chip); +if (err <0 ) goto __error; chip->spdif_over_aclink = spdif_aclink; -if ((err =snd_atiixp_mixer_new (chip, ac97_clock, ac97_quirk)) <0 ) + err =snd_atiixp_mixer_new (chip, ac97_clock, ac97_quirk); +if (err <0 ) goto __error; -if ((err =snd_atiixp_pcm_new (chip)) <0 ) + err =snd_atiixp_pcm_new (chip); +if (err <0 ) goto __error;snd_atiixp_proc_init (chip);
@@ -1647,7 +1657,8 @@ static int snd_atiixp_probe(struct pci_dev *pci, chip->ac97[0 ] ?snd_ac97_get_short_name (chip->ac97[0 ]) :"?" , chip->addr, chip->irq); -if ((err =snd_card_register (card)) <0 ) + err =snd_card_register (card); +if (err <0 ) goto __error;pci_set_drvdata (pci, card);
sound/pci/atiixp_modem.c +25 -15
@@ -856,12 +856,12 @@ static int snd_atiixp_pcm_open(struct snd_pcm_substream *substream, dma->substream = substream; runtime->hw = snd_atiixp_pcm_hw; dma->ac97_pcm_type = pcm_type; -if ((err =snd_pcm_hw_constraint_list (runtime,0 , -SNDRV_PCM_HW_PARAM_RATE , - &hw_constraints_rates)) <0 ) + err =snd_pcm_hw_constraint_list (runtime,0 ,SNDRV_PCM_HW_PARAM_RATE , + &hw_constraints_rates); +if (err <0 )return err; -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; runtime->private_data = dma;
@@ -1058,7 +1058,8 @@ static int snd_atiixp_mixer_new(struct atiixp_modem *chip, int clock)if (snd_atiixp_codec_detect (chip) <0 )return -ENXIO ; -if ((err =snd_ac97_bus (chip->card,0 , &ops, chip, &pbus)) <0 ) + err =snd_ac97_bus (chip->card,0 , &ops, chip, &pbus); +if (err <0 )return err; pbus->clock = clock; chip->ac97_bus = pbus;
@@ -1072,7 +1073,8 @@ static int snd_atiixp_mixer_new(struct atiixp_modem *chip, int clock) ac97.pci = chip->pci; ac97.num = i; ac97.scaps =AC97_SCAP_SKIP_AUDIO |AC97_SCAP_POWER_SAVE ; -if ((err =snd_ac97_mixer (pbus, &ac97, &chip->ac97[i])) <0 ) { + err =snd_ac97_mixer (pbus, &ac97, &chip->ac97[i]); +if (err <0 ) { chip->ac97[i] =NULL ;/* to be sure */ dev_dbg (chip->card->dev,"codec %d not available for modem\n" , i);
@@ -1192,7 +1194,8 @@ static int snd_atiixp_create(struct snd_card *card,struct atiixp_modem *chip;int err; -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err; chip =kzalloc (sizeof (*chip),GFP_KERNEL );
@@ -1206,7 +1209,8 @@ static int snd_atiixp_create(struct snd_card *card, chip->card = card; chip->pci = pci; chip->irq =-1 ; -if ((err =pci_request_regions (pci,"ATI IXP MC97" )) <0 ) { + err =pci_request_regions (pci,"ATI IXP MC97" ); +if (err <0 ) {kfree (chip);pci_disable_device (pci);return err;
@@ -1229,7 +1233,8 @@ static int snd_atiixp_create(struct snd_card *card, card->sync_irq = chip->irq;pci_set_master (pci); -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (err <0 ) {snd_atiixp_free (chip);return err; }
@@ -1252,17 +1257,21 @@ static int snd_atiixp_probe(struct pci_dev *pci,strcpy (card->driver,"ATIIXP-MODEM" );strcpy (card->shortname,"ATI IXP Modem" ); -if ((err =snd_atiixp_create (card, pci, &chip)) <0 ) + err =snd_atiixp_create (card, pci, &chip); +if (err <0 ) goto __error; card->private_data = chip; -if ((err =snd_atiixp_aclink_reset (chip)) <0 ) + err =snd_atiixp_aclink_reset (chip); +if (err <0 ) goto __error; -if ((err =snd_atiixp_mixer_new (chip, ac97_clock)) <0 ) + err =snd_atiixp_mixer_new (chip, ac97_clock); +if (err <0 ) goto __error; -if ((err =snd_atiixp_pcm_new (chip)) <0 ) + err =snd_atiixp_pcm_new (chip); +if (err <0 ) goto __error;snd_atiixp_proc_init (chip);
@@ -1272,7 +1281,8 @@ static int snd_atiixp_probe(struct pci_dev *pci,sprintf (card->longname,"%s rev %x at 0x%lx, irq %i" , card->shortname, pci->revision, chip->addr, chip->irq); -if ((err =snd_card_register (card)) <0 ) + err =snd_card_register (card); +if (err <0 ) goto __error;pci_set_drvdata (pci, card);
Signature · 1 line
2.26.2
PATCH 20/66 ALSA: azt3328: Fix assignment in if condition
In reply to Takashi IwaiPCI AZT3328 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.
--- sound/pci/azt3328.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/pci/azt3328.c +2 -1
@@ -1194,7 +1194,8 @@ snd_azf3328_mixer_new(struct snd_azf3328 *chip) sw = snd_azf3328_mixer_controls;for (idx =0 ; idx <ARRAY_SIZE (snd_azf3328_mixer_controls); ++idx, ++sw) { -if ((err =snd_ctl_add (chip->card,snd_ctl_new1 (sw, chip))) <0 ) + err =snd_ctl_add (chip->card,snd_ctl_new1 (sw, chip)); +if (err <0 )return err; }snd_component_add (card,"AZF3328 mixer" );
Signature · 1 line
2.26.2
PATCH 21/66 ALSA: bt87x: Fix assignment in if condition
In reply to Takashi IwaiPCI BT87x driver code contains an 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.
--- sound/pci/bt87x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/pci/bt87x.c +2 -1
@@ -719,7 +719,8 @@ static int snd_bt87x_create(struct snd_card *card, chip->irq =-1 ;spin_lock_init (&chip->reg_lock); -if ((err =pci_request_regions (pci,"Bt87x audio" )) <0 ) { + err =pci_request_regions (pci,"Bt87x audio" ); +if (err <0 ) {kfree (chip);pci_disable_device (pci);return err;
Signature · 1 line
2.26.2
PATCH 22/66 ALSA: cmipci: Fix assignment in if condition
In reply to Takashi IwaiPCI CMIPCI 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.
--- sound/pci/cmipci.c | 83 ++++++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 28 deletions(-)
sound/pci/cmipci.c +55 -28
@@ -1225,9 +1225,11 @@ static int setup_spdif_playback(struct cmipci *cm, struct snd_pcm_substream *sub rate = subs->runtime->rate; -if (up && do_ac3) -if ((err =save_mixer_state (cm)) <0 ) +if (up && do_ac3) { + err =save_mixer_state (cm); +if (err <0 )return err; + }spin_lock_irq (&cm->reg_lock); cm->spdif_playback_avail = up;
@@ -1276,7 +1278,8 @@ static int snd_cmipci_playback_prepare(struct snd_pcm_substream *substream) substream->runtime->channels == 2);if (do_spdif && cm->can_ac3_hw) do_ac3 = cm->dig_pcm_status &IEC958_AES0_NONAUDIO ; -if ((err =setup_spdif_playback (cm, substream, do_spdif, do_ac3)) <0 ) + err =setup_spdif_playback (cm, substream, do_spdif, do_ac3); +if (err <0 )return err;return snd_cmipci_pcm_prepare (cm, &cm->channel[CM_CH_PLAY ], substream); }
@@ -1291,7 +1294,8 @@ static int snd_cmipci_playback_spdif_prepare(struct snd_pcm_substream *substream do_ac3 = cm->dig_pcm_status &IEC958_AES0_NONAUDIO ; else do_ac3 =1 ;/* doesn't matter */ -if ((err =setup_spdif_playback (cm, substream,1 , do_ac3)) <0 ) + err =setup_spdif_playback (cm, substream,1 , do_ac3); +if (err <0 )return err;return snd_cmipci_pcm_prepare (cm, &cm->channel[CM_CH_PLAY ], substream); }
@@ -1639,7 +1643,8 @@ static int snd_cmipci_playback_open(struct snd_pcm_substream *substream)struct snd_pcm_runtime *runtime = substream->runtime;int err; -if ((err =open_device_check (cm,CM_OPEN_PLAYBACK , substream)) <0 ) + err =open_device_check (cm,CM_OPEN_PLAYBACK , substream); +if (err <0 )return err; runtime->hw = snd_cmipci_playback;if (cm->chip_version ==68 ) {
@@ -1665,7 +1670,8 @@ static int snd_cmipci_capture_open(struct snd_pcm_substream *substream)struct snd_pcm_runtime *runtime = substream->runtime;int err; -if ((err =open_device_check (cm,CM_OPEN_CAPTURE , substream)) <0 ) + err =open_device_check (cm,CM_OPEN_CAPTURE , substream); +if (err <0 )return err; runtime->hw = snd_cmipci_capture;if (cm->chip_version ==68 ) {// 8768 only supports 44k/48k recording
@@ -1689,7 +1695,9 @@ static int snd_cmipci_playback2_open(struct snd_pcm_substream *substream)struct snd_pcm_runtime *runtime = substream->runtime;int err; -if ((err =open_device_check (cm,CM_OPEN_PLAYBACK2 , substream)) <0 )/* use channel B */ +/* use channel B */ + err =open_device_check (cm,CM_OPEN_PLAYBACK2 , substream); +if (err <0 )return err; runtime->hw = snd_cmipci_playback2;mutex_lock (&cm->open_mutex);
@@ -1727,7 +1735,9 @@ static int snd_cmipci_playback_spdif_open(struct snd_pcm_substream *substream)struct snd_pcm_runtime *runtime = substream->runtime;int err; -if ((err =open_device_check (cm,CM_OPEN_SPDIF_PLAYBACK , substream)) <0 )/* use channel A */ +/* use channel A */ + err =open_device_check (cm,CM_OPEN_SPDIF_PLAYBACK , substream); +if (err <0 )return err;if (cm->can_ac3_hw) { runtime->hw = snd_cmipci_playback_spdif;
@@ -1754,7 +1764,9 @@ static int snd_cmipci_capture_spdif_open(struct snd_pcm_substream *substream)struct snd_pcm_runtime *runtime = substream->runtime;int err; -if ((err =open_device_check (cm,CM_OPEN_SPDIF_CAPTURE , substream)) <0 )/* use channel B */ +/* use channel B */ + err =open_device_check (cm,CM_OPEN_SPDIF_CAPTURE , substream); +if (err <0 )return err; runtime->hw = snd_cmipci_capture_spdif;if (cm->can_96k && !(cm->chip_version ==68 )) {
@@ -2650,7 +2662,8 @@ static int snd_cmipci_mixer_new(struct cmipci *cm, int pcm_spdif_device) "PCM Playback Volume"))continue ; } -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_cmipci_mixers[idx], cm))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_cmipci_mixers[idx], cm)); +if (err <0 )return err; }
@@ -2675,13 +2688,19 @@ static int snd_cmipci_mixer_new(struct cmipci *cm, int pcm_spdif_device)return err; }if (cm->can_ac3_hw) { -if ((err =snd_ctl_add (card, kctl =snd_ctl_new1 (&snd_cmipci_spdif_default, cm))) <0 ) + kctl =snd_ctl_new1 (&snd_cmipci_spdif_default, cm); + err =snd_ctl_add (card, kctl); +if (err <0 )return err; kctl->id.device = pcm_spdif_device; -if ((err =snd_ctl_add (card, kctl =snd_ctl_new1 (&snd_cmipci_spdif_mask, cm))) <0 ) + kctl =snd_ctl_new1 (&snd_cmipci_spdif_mask, cm); + err =snd_ctl_add (card, kctl); +if (err <0 )return err; kctl->id.device = pcm_spdif_device; -if ((err =snd_ctl_add (card, kctl =snd_ctl_new1 (&snd_cmipci_spdif_stream, cm))) <0 ) + kctl =snd_ctl_new1 (&snd_cmipci_spdif_stream, cm); + err =snd_ctl_add (card, kctl); +if (err <0 )return err; kctl->id.device = pcm_spdif_device; }
@@ -2955,7 +2974,8 @@ static int snd_cmipci_create_fm(struct cmipci *cm, long fm_port) goto disable_fm; } } -if ((err =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL )) <0 ) { + err =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL ); +if (err <0 ) {dev_err (cm->card->dev,"cannot create OPL3 hwdep\n" );return err; }
@@ -2987,7 +3007,8 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci, *rcmipci =NULL ; -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err; cm =kzalloc (sizeof (*cm),GFP_KERNEL );
@@ -3006,7 +3027,8 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci, cm->channel[1 ].ch =1 ; cm->channel[0 ].is_dac = cm->channel[1 ].is_dac =1 ;/* dual DAC mode */ -if ((err =pci_request_regions (pci, card->driver)) <0 ) { + err =pci_request_regions (pci, card->driver); +if (err <0 ) {kfree (cm);pci_disable_device (pci);return err;
@@ -3120,7 +3142,8 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci,sprintf (card->longname,"%s%s at %#lx, irq %i" , card->shortname, modelstr, cm->iobase, cm->irq); -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , cm, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , cm, &ops); +if (err <0 ) {snd_cmipci_free (cm);return err; }
@@ -3172,32 +3195,36 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci,/* create pcm devices */ pcm_index = pcm_spdif_index =0 ; -if ((err =snd_cmipci_pcm_new (cm, pcm_index)) <0 ) + err =snd_cmipci_pcm_new (cm, pcm_index); +if (err <0 )return err; pcm_index++; -if ((err =snd_cmipci_pcm2_new (cm, pcm_index)) <0 ) + err =snd_cmipci_pcm2_new (cm, pcm_index); +if (err <0 )return err; pcm_index++;if (cm->can_ac3_hw || cm->can_ac3_sw) { pcm_spdif_index = pcm_index; -if ((err =snd_cmipci_pcm_spdif_new (cm, pcm_index)) <0 ) + err =snd_cmipci_pcm_spdif_new (cm, pcm_index); +if (err <0 )return err; }/* create mixer interface & switches */ -if ((err =snd_cmipci_mixer_new (cm, pcm_spdif_index)) <0 ) + err =snd_cmipci_mixer_new (cm, pcm_spdif_index); +if (err <0 )return err;if (iomidi >0 ) { -if ((err =snd_mpu401_uart_new (card,0 ,MPU401_HW_CMIPCI , - iomidi, - (integrated_midi ? -MPU401_INFO_INTEGRATED :0 ) | -MPU401_INFO_IRQ_HOOK , --1 , &cm->rmidi)) <0 ) { + err =snd_mpu401_uart_new (card,0 ,MPU401_HW_CMIPCI , + iomidi, + (integrated_midi ? +MPU401_INFO_INTEGRATED :0 ) | +MPU401_INFO_IRQ_HOOK , +-1 , &cm->rmidi); +if (err <0 )dev_err (cm->card->dev,"no UART401 device at 0x%lx\n" , iomidi); - } }#ifdef USE_VAR48KRATE
Signature · 1 line
2.26.2
PATCH 23/66 ALSA: cs4281: Fix assignment in if condition
In reply to Takashi IwaiPCI CS4281 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.
--- sound/pci/cs4281.c | 54 ++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 18 deletions(-)
sound/pci/cs4281.c +36 -18
@@ -1068,23 +1068,28 @@ static int snd_cs4281_mixer(struct cs4281 *chip) .read = snd_cs4281_ac97_read, }; -if ((err =snd_ac97_bus (card,0 , &ops, chip, &chip->ac97_bus)) <0 ) + err =snd_ac97_bus (card,0 , &ops, chip, &chip->ac97_bus); +if (err <0 )return err; chip->ac97_bus->private_free = snd_cs4281_mixer_free_ac97_bus;memset (&ac97,0 ,sizeof (ac97)); ac97.private_data = chip; ac97.private_free = snd_cs4281_mixer_free_ac97; -if ((err =snd_ac97_mixer (chip->ac97_bus, &ac97, &chip->ac97)) <0 ) + err =snd_ac97_mixer (chip->ac97_bus, &ac97, &chip->ac97); +if (err <0 )return err;if (chip->dual_codec) { ac97.num =1 ; -if ((err =snd_ac97_mixer (chip->ac97_bus, &ac97, &chip->ac97_secondary)) <0 ) + err =snd_ac97_mixer (chip->ac97_bus, &ac97, &chip->ac97_secondary); +if (err <0 )return err; } -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_cs4281_fm_vol, chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_cs4281_fm_vol, chip)); +if (err <0 )return err; -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_cs4281_pcm_vol, chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&snd_cs4281_pcm_vol, chip)); +if (err <0 )return err;return 0 ; }
@@ -1308,7 +1313,8 @@ static int snd_cs4281_create(struct snd_card *card, }; *rchip =NULL ; -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err; chip =kzalloc (sizeof (*chip),GFP_KERNEL );if (chip ==NULL ) {
@@ -1326,7 +1332,8 @@ static int snd_cs4281_create(struct snd_card *card, } chip->dual_codec = dual_codec; -if ((err =pci_request_regions (pci,"CS4281" )) <0 ) { + err =pci_request_regions (pci,"CS4281" ); +if (err <0 ) {kfree (chip);pci_disable_device (pci);return err;
@@ -1356,7 +1363,8 @@ static int snd_cs4281_create(struct snd_card *card,return tmp; } -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (err <0 ) {snd_cs4281_free (chip);return err; }
@@ -1395,12 +1403,14 @@ static int snd_cs4281_chip_init(struct cs4281 *chip)* space between 0e4h and 0ffh to be written. */ snd_cs4281_pokeBA0 (chip,BA0_CWPR ,0x4281 ); -if ((tmp =snd_cs4281_peekBA0 (chip,BA0_SERC1 )) != (BA0_SERC1_SO1EN |BA0_SERC1_AC97 )) { + tmp =snd_cs4281_peekBA0 (chip,BA0_SERC1 ); +if (tmp != (BA0_SERC1_SO1EN |BA0_SERC1_AC97 )) {dev_err (chip->card->dev,"SERC1 AC'97 check failed (0x%x)\n" , tmp);return -EIO ; } -if ((tmp =snd_cs4281_peekBA0 (chip,BA0_SERC2 )) != (BA0_SERC2_SI1EN |BA0_SERC2_AC97 )) { + tmp =snd_cs4281_peekBA0 (chip,BA0_SERC2 ); +if (tmp != (BA0_SERC2_SI1EN |BA0_SERC2_AC97 )) {dev_err (chip->card->dev,"SERC2 AC'97 check failed (0x%x)\n" , tmp);return -EIO ;
@@ -1748,7 +1758,8 @@ static int snd_cs4281_midi(struct cs4281 *chip, int device)struct snd_rawmidi *rmidi;int err; -if ((err =snd_rawmidi_new (chip->card,"CS4281" , device,1 ,1 , &rmidi)) <0 ) + err =snd_rawmidi_new (chip->card,"CS4281" , device,1 ,1 , &rmidi); +if (err <0 )return err;strcpy (rmidi->name,"CS4281" );snd_rawmidi_set_ops (rmidi,SNDRV_RAWMIDI_STREAM_OUTPUT , &snd_cs4281_midi_output);
@@ -1881,32 +1892,38 @@ static int snd_cs4281_probe(struct pci_dev *pci,if (err <0 )return err; -if ((err =snd_cs4281_create (card, pci, &chip, dual_codec[dev])) <0 ) { + err =snd_cs4281_create (card, pci, &chip, dual_codec[dev]); +if (err <0 ) {snd_card_free (card);return err; } card->private_data = chip; -if ((err =snd_cs4281_mixer (chip)) <0 ) { + err =snd_cs4281_mixer (chip); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_cs4281_pcm (chip,0 )) <0 ) { + err =snd_cs4281_pcm (chip,0 ); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_cs4281_midi (chip,0 )) <0 ) { + err =snd_cs4281_midi (chip,0 ); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_opl3_new (card,OPL3_HW_OPL3_CS4281 , &opl3)) <0 ) { + err =snd_opl3_new (card,OPL3_HW_OPL3_CS4281 , &opl3); +if (err <0 ) {snd_card_free (card);return err; } opl3->private_data = chip; opl3->command = snd_cs4281_opl3_command;snd_opl3_init (opl3); -if ((err =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL )) <0 ) { + err =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL ); +if (err <0 ) {snd_card_free (card);return err; }
@@ -1918,7 +1935,8 @@ static int snd_cs4281_probe(struct pci_dev *pci, chip->ba0_addr, chip->irq); -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_card_free (card);return err; }
Signature · 1 line
2.26.2
PATCH 24/66 ALSA: ens137x: Fix assignment in if condition
In reply to Takashi IwaiPCI ENS137x 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.
--- sound/pci/ens1370.c | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-)
sound/pci/ens1370.c +30 -15
@@ -672,7 +672,8 @@ static unsigned short snd_es1371_codec_read(struct snd_ac97 *ac97, }/* now wait for the stinkin' data (RDY) */ for (t =0 ; t <POLL_COUNT ; t++) { - if ((x = inl(ES_REG(ensoniq, 1371_CODEC))) & ES_1371_CODEC_RDY) { + x = inl(ES_REG(ensoniq, 1371_CODEC)); +if (x &ES_1371_CODEC_RDY ) {if (is_ev1938 (ensoniq)) {for (t =0 ; t <100 ; t++)inl (ES_REG (ensoniq,CONTROL ));
@@ -1594,7 +1595,8 @@ static int snd_ensoniq_1371_mixer(struct ensoniq *ensoniq, .wait = snd_es1371_codec_wait, }; -if ((err =snd_ac97_bus (card,0 , &ops,NULL , &pbus)) <0 ) + err =snd_ac97_bus (card,0 , &ops,NULL , &pbus); +if (err <0 )return err;memset (&ac97,0 ,sizeof (ac97));
@@ -1602,7 +1604,8 @@ static int snd_ensoniq_1371_mixer(struct ensoniq *ensoniq, ac97.private_free = snd_ensoniq_mixer_free_ac97; ac97.pci = ensoniq->pci; ac97.scaps =AC97_SCAP_AUDIO ; -if ((err =snd_ac97_mixer (pbus, &ac97, &ensoniq->u.es1371.ac97)) <0 ) + err =snd_ac97_mixer (pbus, &ac97, &ensoniq->u.es1371.ac97); +if (err <0 )return err;if (has_spdif >0 || (!has_spdif &&es1371_quirk_lookup (ensoniq, es1371_spdif_present))) {
@@ -1722,7 +1725,8 @@ static int snd_ensoniq_1370_mixer(struct ensoniq *ensoniq) ak4531.write = snd_es1370_codec_write; ak4531.private_data = ensoniq; ak4531.private_free = snd_ensoniq_mixer_free_ak4531; -if ((err =snd_ak4531_mixer (card, &ak4531, &ensoniq->u.es1370.ak4531)) <0 ) + err =snd_ak4531_mixer (card, &ak4531, &ensoniq->u.es1370.ak4531); +if (err <0 )return err;for (idx =0 ; idx <ES1370_CONTROLS ; idx++) { err =snd_ctl_add (card,snd_ctl_new1 (&snd_es1370_controls[idx], ensoniq));
@@ -2038,7 +2042,8 @@ static int snd_ensoniq_create(struct snd_card *card, }; *rensoniq =NULL ; -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err; ensoniq =kzalloc (sizeof (*ensoniq),GFP_KERNEL );if (ensoniq ==NULL ) {
@@ -2050,7 +2055,8 @@ static int snd_ensoniq_create(struct snd_card *card, ensoniq->card = card; ensoniq->pci = pci; ensoniq->irq =-1 ; -if ((err =pci_request_regions (pci,"Ensoniq AudioPCI" )) <0 ) { + err =pci_request_regions (pci,"Ensoniq AudioPCI" ); +if (err <0 ) {kfree (ensoniq);pci_disable_device (pci);return err;
@@ -2095,7 +2101,8 @@ static int snd_ensoniq_create(struct snd_card *card,snd_ensoniq_chip_init (ensoniq); -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , ensoniq, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , ensoniq, &ops); +if (err <0 ) {snd_ensoniq_free (ensoniq);return err; }
@@ -2286,7 +2293,8 @@ static int snd_ensoniq_midi(struct ensoniq *ensoniq, int device)struct snd_rawmidi *rmidi;int err; -if ((err =snd_rawmidi_new (ensoniq->card,"ES1370/1" , device,1 ,1 , &rmidi)) <0 ) + err =snd_rawmidi_new (ensoniq->card,"ES1370/1" , device,1 ,1 , &rmidi); +if (err <0 )return err;strcpy (rmidi->name,CHIP_NAME );snd_rawmidi_set_ops (rmidi,SNDRV_RAWMIDI_STREAM_OUTPUT , &snd_ensoniq_midi_output);
@@ -2357,33 +2365,39 @@ static int snd_audiopci_probe(struct pci_dev *pci,if (err <0 )return err; -if ((err =snd_ensoniq_create (card, pci, &ensoniq)) <0 ) { + err =snd_ensoniq_create (card, pci, &ensoniq); +if (err <0 ) {snd_card_free (card);return err; } card->private_data = ensoniq;#ifdef CHIP1370 -if ((err =snd_ensoniq_1370_mixer (ensoniq)) <0 ) { + err =snd_ensoniq_1370_mixer (ensoniq); +if (err <0 ) {snd_card_free (card);return err; }#endif #ifdef CHIP1371 -if ((err =snd_ensoniq_1371_mixer (ensoniq, spdif[dev], lineio[dev])) <0 ) { + err =snd_ensoniq_1371_mixer (ensoniq, spdif[dev], lineio[dev]); +if (err <0 ) {snd_card_free (card);return err; }#endif -if ((err =snd_ensoniq_pcm (ensoniq,0 )) <0 ) { + err =snd_ensoniq_pcm (ensoniq,0 ); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_ensoniq_pcm2 (ensoniq,1 )) <0 ) { + err =snd_ensoniq_pcm2 (ensoniq,1 ); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_ensoniq_midi (ensoniq,0 )) <0 ) { + err =snd_ensoniq_midi (ensoniq,0 ); +if (err <0 ) {snd_card_free (card);return err; }
@@ -2399,7 +2413,8 @@ static int snd_audiopci_probe(struct pci_dev *pci, ensoniq->port, ensoniq->irq); -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_card_free (card);return err; }
Signature · 1 line
2.26.2
PATCH 25/66 ALSA: es1938: Fix assignment in if condition
In reply to Takashi IwaiPCI ES1938 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.
--- sound/pci/es1938.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-)
sound/pci/es1938.c +28 -14
@@ -293,7 +293,8 @@ static void snd_es1938_write_cmd(struct es1938 *chip, unsigned char cmd)int i;unsigned char v;for (i =0 ; i <WRITE_LOOP_TIMEOUT ; i++) { -if (!(v =inb (SLSB_REG (chip,READSTATUS )) &0x80 )) { + v =inb (SLSB_REG (chip,READSTATUS )); +if (!(v &0x80 )) {outb (cmd,SLSB_REG (chip,WRITEDATA ));return ; }
@@ -309,9 +310,11 @@ static int snd_es1938_get_byte(struct es1938 *chip) {int i;unsigned char v; -for (i =GET_LOOP_TIMEOUT ; i; i--) -if ((v =inb (SLSB_REG (chip,STATUS ))) &0x80 ) +for (i =GET_LOOP_TIMEOUT ; i; i--) { + v =inb (SLSB_REG (chip,STATUS )); +if (v &0x80 )return inb (SLSB_REG (chip,READDATA )); + }dev_err (chip->card->dev,"get_byte timeout: status 0x02%x\n" , v);return -ENODEV ; }
@@ -993,7 +996,8 @@ static int snd_es1938_new_pcm(struct es1938 *chip, int device)struct snd_pcm *pcm;int err; -if ((err =snd_pcm_new (chip->card,"es-1938-1946" , device,2 ,1 , &pcm)) <0 ) + err =snd_pcm_new (chip->card,"es-1938-1946" , device,2 ,1 , &pcm); +if (err <0 )return err;snd_pcm_set_ops (pcm,SNDRV_PCM_STREAM_PLAYBACK , &snd_es1938_playback_ops);snd_pcm_set_ops (pcm,SNDRV_PCM_STREAM_CAPTURE , &snd_es1938_capture_ops);
@@ -1553,7 +1557,8 @@ static int snd_es1938_create(struct snd_card *card, *rchip =NULL ;/* enable PCI device */ -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err;/* check, if we can restrict PCI DMA transfers to 24 bits */ if (dma_set_mask_and_coherent (&pci->dev,DMA_BIT_MASK (24 ))) {
@@ -1573,7 +1578,8 @@ static int snd_es1938_create(struct snd_card *card, chip->card = card; chip->pci = pci; chip->irq =-1 ; -if ((err =pci_request_regions (pci,"ESS Solo-1" )) <0 ) { + err =pci_request_regions (pci,"ESS Solo-1" ); +if (err <0 ) {kfree (chip);pci_disable_device (pci);return err;
@@ -1599,7 +1605,8 @@ static int snd_es1938_create(struct snd_card *card,snd_es1938_chip_init (chip); -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (err <0 ) {snd_es1938_free (chip);return err; }
@@ -1731,7 +1738,8 @@ static int snd_es1938_mixer(struct es1938 *chip) kctl->private_free = snd_es1938_hwv_free;break ; } -if ((err =snd_ctl_add (card, kctl)) <0 ) + err =snd_ctl_add (card, kctl); +if (err <0 )return err; }return 0 ;
@@ -1765,7 +1773,8 @@ static int snd_es1938_probe(struct pci_dev *pci,return -ENODEV ; } } -if ((err =snd_es1938_create (card, pci, &chip)) <0 ) { + err =snd_es1938_create (card, pci, &chip); +if (err <0 ) {snd_card_free (card);return err; }
@@ -1778,11 +1787,13 @@ static int snd_es1938_probe(struct pci_dev *pci, chip->revision, chip->irq); -if ((err =snd_es1938_new_pcm (chip,0 )) <0 ) { + err =snd_es1938_new_pcm (chip,0 ); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_es1938_mixer (chip)) <0 ) { + err =snd_es1938_mixer (chip); +if (err <0 ) {snd_card_free (card);return err; }
@@ -1793,11 +1804,13 @@ static int snd_es1938_probe(struct pci_dev *pci,dev_err (card->dev,"OPL3 not detected at 0x%lx\n" ,SLSB_REG (chip,FMLOWADDR )); }else { -if ((err =snd_opl3_timer_new (opl3,0 ,1 )) <0 ) { + err =snd_opl3_timer_new (opl3,0 ,1 ); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL )) <0 ) { + err =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL ); +if (err <0 ) {snd_card_free (card);return err; }
@@ -1815,7 +1828,8 @@ static int snd_es1938_probe(struct pci_dev *pci,snd_es1938_create_gameport (chip); -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_card_free (card);return err; }
Signature · 1 line
2.26.2
PATCH 26/66 ALSA: es1968: Fix assignment in if condition
In reply to Takashi IwaiPCI ES1968 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.
--- sound/pci/es1968.c | 75 +++++++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 30 deletions(-)
sound/pci/es1968.c +45 -30
@@ -1600,7 +1600,8 @@ static int snd_es1968_capture_open(struct snd_pcm_substream *substream) es->mode =ESM_MODE_CAPTURE ;/* get mixbuffer */ -if ((es->mixbuf =snd_es1968_new_memory (chip,ESM_MIXBUF_SIZE )) ==NULL ) { + es->mixbuf =snd_es1968_new_memory (chip,ESM_MIXBUF_SIZE ); +if (!es->mixbuf) {snd_es1968_free_apu_pair (chip, apu1);snd_es1968_free_apu_pair (chip, apu2);kfree (es);
@@ -1695,11 +1696,13 @@ static void es1968_measure_clock(struct es1968 *chip) chip->clock =48000 ;/* default clock value */ /* search 2 APUs (although one apu is enough) */ -if ((apu =snd_es1968_alloc_apu_pair (chip,ESM_APU_PCM_PLAY )) <0 ) { + apu =snd_es1968_alloc_apu_pair (chip,ESM_APU_PCM_PLAY ); +if (apu <0 ) {dev_err (chip->card->dev,"Hmm, cannot find empty APU pair!?\n" );return ; } -if ((memory =snd_es1968_new_memory (chip,CLOCK_MEASURE_BUFSIZE )) ==NULL ) { + memory =snd_es1968_new_memory (chip,CLOCK_MEASURE_BUFSIZE ); +if (!memory) {dev_warn (chip->card->dev,"cannot allocate dma buffer - using default clock %d\n" , chip->clock);
@@ -1791,7 +1794,8 @@ snd_es1968_pcm(struct es1968 *chip, int device)int err;/* get DMA buffer */ -if ((err =snd_es1968_init_dmabuf (chip)) <0 ) + err =snd_es1968_init_dmabuf (chip); +if (err <0 )return err;/* set PCMBAR */
@@ -1800,9 +1804,10 @@ snd_es1968_pcm(struct es1968 *chip, int device)wave_set_register (chip,0x01FE , chip->dma.addr >>12 );wave_set_register (chip,0x01FF , chip->dma.addr >>12 ); -if ((err =snd_pcm_new (chip->card,"ESS Maestro" , device, - chip->playback_streams, - chip->capture_streams, &pcm)) <0 ) + err =snd_pcm_new (chip->card,"ESS Maestro" , device, + chip->playback_streams, + chip->capture_streams, &pcm); +if (err <0 )return err; pcm->private_data = chip;
@@ -1953,7 +1958,8 @@ static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id)struct es1968 *chip = dev_id;u32 event; -if (!(event =inb (chip->io_port +0x1A ))) + event =inb (chip->io_port +0x1A ); +if (!event)return IRQ_NONE ;outw (inw (chip->io_port +4 ) &1 , chip->io_port +4 );
@@ -2008,13 +2014,15 @@ snd_es1968_mixer(struct es1968 *chip) .read = snd_es1968_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 ;/* ES1968 doesn't need VRA */ memset (&ac97,0 ,sizeof (ac97)); ac97.private_data = chip; -if ((err =snd_ac97_mixer (pbus, &ac97, &chip->ac97)) <0 ) + err =snd_ac97_mixer (pbus, &ac97, &chip->ac97); +if (err <0 )return err;#ifndef CONFIG_SND_ES1968_INPUT
@@ -2661,7 +2669,8 @@ static int snd_es1968_create(struct snd_card *card, *chip_ret =NULL ;/* enable PCI device */ -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err;/* check, if we can restrict PCI DMA transfers to 28 bits */ if (dma_set_mask_and_coherent (&pci->dev,DMA_BIT_MASK (28 ))) {
@@ -2692,7 +2701,8 @@ static int snd_es1968_create(struct snd_card *card, chip->playback_streams = play_streams; chip->capture_streams = capt_streams; -if ((err =pci_request_regions (pci,"ESS Maestro" )) <0 ) { + err =pci_request_regions (pci,"ESS Maestro" ); +if (err <0 ) {kfree (chip);pci_disable_device (pci);return err;
@@ -2739,7 +2749,8 @@ static int snd_es1968_create(struct snd_card *card,snd_es1968_chip_init (chip); -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (err <0 ) {snd_es1968_free (chip);return err; }
@@ -2804,14 +2815,15 @@ static int snd_es1968_probe(struct pci_dev *pci, total_bufsize[dev] =128 ;if (total_bufsize[dev] >4096 ) total_bufsize[dev] =4096 ; -if ((err =snd_es1968_create (card, pci, - total_bufsize[dev] *1024 ,/* in bytes */ - pcm_substreams_p[dev], - pcm_substreams_c[dev], - pci_id->driver_data, - use_pm[dev], - radio_nr[dev], - &chip)) <0 ) { + err =snd_es1968_create (card, pci, + total_bufsize[dev] *1024 ,/* in bytes */ + pcm_substreams_p[dev], + pcm_substreams_c[dev], + pci_id->driver_data, + use_pm[dev], + radio_nr[dev], + &chip); +if (err <0 ) {snd_card_free (card);return err; }
@@ -2832,12 +2844,14 @@ static int snd_es1968_probe(struct pci_dev *pci,break ; } -if ((err =snd_es1968_pcm (chip,0 )) <0 ) { + err =snd_es1968_pcm (chip,0 ); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_es1968_mixer (chip)) <0 ) { + err =snd_es1968_mixer (chip); +if (err <0 ) {snd_card_free (card);return err; }
@@ -2855,13 +2869,13 @@ static int snd_es1968_probe(struct pci_dev *pci, } }if (enable_mpu[dev]) { -if ((err =snd_mpu401_uart_new (card,0 ,MPU401_HW_MPU401 , - chip->io_port +ESM_MPU401_PORT , -MPU401_INFO_INTEGRATED | -MPU401_INFO_IRQ_HOOK , --1 , &chip->rmidi)) <0 ) { + err =snd_mpu401_uart_new (card,0 ,MPU401_HW_MPU401 , + chip->io_port +ESM_MPU401_PORT , +MPU401_INFO_INTEGRATED | +MPU401_INFO_IRQ_HOOK , +-1 , &chip->rmidi); +if (err <0 )dev_warn (card->dev,"skipping MPU-401 MIDI support..\n" ); - } }snd_es1968_create_gameport (chip, dev);
@@ -2882,7 +2896,8 @@ static int snd_es1968_probe(struct pci_dev *pci,sprintf (card->longname,"%s at 0x%lx, irq %i" , card->shortname, chip->io_port, chip->irq); -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_card_free (card);return err; }
Signature · 1 line
2.26.2
PATCH 27/66 ALSA: fm801: Fix assignment in if condition
In reply to Takashi IwaiPCI FM801 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.
--- sound/pci/fm801.c | 63 ++++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 23 deletions(-)
sound/pci/fm801.c +40 -23
@@ -659,7 +659,8 @@ static int snd_fm801_playback_open(struct snd_pcm_substream *substream)SNDRV_PCM_HW_PARAM_CHANNELS , &hw_constraints_channels); } -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;return 0 ; }
@@ -674,7 +675,8 @@ static int snd_fm801_capture_open(struct snd_pcm_substream *substream) runtime->hw = snd_fm801_capture;snd_pcm_hw_constraint_list (runtime,0 ,SNDRV_PCM_HW_PARAM_RATE , &hw_constraints_rates); -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;return 0 ; }
@@ -717,7 +719,8 @@ static int snd_fm801_pcm(struct fm801 *chip, int device)struct snd_pcm *pcm;int err; -if ((err =snd_pcm_new (chip->card,"FM801" , device,1 ,1 , &pcm)) <0 ) + err =snd_pcm_new (chip->card,"FM801" , device,1 ,1 , &pcm); +if (err <0 )return err;snd_pcm_set_ops (pcm,SNDRV_PCM_STREAM_PLAYBACK , &snd_fm801_playback_ops);
@@ -985,7 +988,8 @@ static int snd_fm801_put_mux(struct snd_kcontrol *kcontrol,struct fm801 *chip =snd_kcontrol_chip (kcontrol);unsigned short val; -if ((val = ucontrol->value.enumerated.item[0 ]) >4 ) + val = ucontrol->value.enumerated.item[0 ]; +if (val >4 )return -EINVAL ;return snd_fm801_update_bits (chip,FM801_REC_SRC ,7 , val); }
@@ -1050,19 +1054,22 @@ static int snd_fm801_mixer(struct fm801 *chip) .read = snd_fm801_codec_read, }; -if ((err =snd_ac97_bus (chip->card,0 , &ops, chip, &chip->ac97_bus)) <0 ) + err =snd_ac97_bus (chip->card,0 , &ops, chip, &chip->ac97_bus); +if (err <0 )return err; chip->ac97_bus->private_free = snd_fm801_mixer_free_ac97_bus;memset (&ac97,0 ,sizeof (ac97)); ac97.private_data = chip; ac97.private_free = snd_fm801_mixer_free_ac97; -if ((err =snd_ac97_mixer (chip->ac97_bus, &ac97, &chip->ac97)) <0 ) + err =snd_ac97_mixer (chip->ac97_bus, &ac97, &chip->ac97); +if (err <0 )return err;if (chip->secondary) { ac97.num =1 ; ac97.addr = chip->secondary_addr; -if ((err =snd_ac97_mixer (chip->ac97_bus, &ac97, &chip->ac97_sec)) <0 ) + err =snd_ac97_mixer (chip->ac97_bus, &ac97, &chip->ac97_sec); +if (err <0 )return err; }for (i =0 ; i <FM801_CONTROLS ; i++) {
@@ -1213,7 +1220,8 @@ static int snd_fm801_create(struct snd_card *card, }; *rchip =NULL ; -if ((err =pcim_enable_device (pci)) <0 ) + err =pcim_enable_device (pci); +if (err <0 )return err; chip =devm_kzalloc (&pci->dev,sizeof (*chip),GFP_KERNEL );if (chip ==NULL )
@@ -1223,7 +1231,8 @@ static int snd_fm801_create(struct snd_card *card, chip->dev = &pci->dev; chip->irq =-1 ; chip->tea575x_tuner = tea575x_tuner; -if ((err =pci_request_regions (pci,"FM801" )) <0 ) + err =pci_request_regions (pci,"FM801" ); +if (err <0 )return err; chip->port =pci_resource_start (pci,0 );
@@ -1254,7 +1263,8 @@ static int snd_fm801_create(struct snd_card *card,snd_fm801_chip_init (chip); -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (err <0 ) {snd_fm801_free (chip);return err; }
@@ -1327,7 +1337,8 @@ static int snd_card_fm801_probe(struct pci_dev *pci, 0, &card);if (err <0 )return err; -if ((err =snd_fm801_create (card, pci, tea575x_tuner[dev], radio_nr[dev], &chip)) <0 ) { + err =snd_fm801_create (card, pci, tea575x_tuner[dev], radio_nr[dev], &chip); +if (err <0 ) {snd_card_free (card);return err; }
@@ -1342,35 +1353,41 @@ static int snd_card_fm801_probe(struct pci_dev *pci,if (chip->tea575x_tuner &TUNER_ONLY ) goto __fm801_tuner_only; -if ((err =snd_fm801_pcm (chip,0 )) <0 ) { + err =snd_fm801_pcm (chip,0 ); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_fm801_mixer (chip)) <0 ) { + err =snd_fm801_mixer (chip); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_mpu401_uart_new (card,0 ,MPU401_HW_FM801 , - chip->port +FM801_MPU401_DATA , -MPU401_INFO_INTEGRATED | -MPU401_INFO_IRQ_HOOK , --1 , &chip->rmidi)) <0 ) { + err =snd_mpu401_uart_new (card,0 ,MPU401_HW_FM801 , + chip->port +FM801_MPU401_DATA , +MPU401_INFO_INTEGRATED | +MPU401_INFO_IRQ_HOOK , +-1 , &chip->rmidi); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_opl3_create (card, chip->port +FM801_OPL3_BANK0 , - chip->port +FM801_OPL3_BANK1 , -OPL3_HW_OPL3_FM801 ,1 , &opl3)) <0 ) { + err =snd_opl3_create (card, chip->port +FM801_OPL3_BANK0 , + chip->port +FM801_OPL3_BANK1 , +OPL3_HW_OPL3_FM801 ,1 , &opl3); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL )) <0 ) { + err =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL ); +if (err <0 ) {snd_card_free (card);return err; } __fm801_tuner_only: -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_card_free (card);return err; }
Signature · 1 line
2.26.2
PATCH 28/66 ALSA: intel8x0: Fix assignment in if condition
In reply to Takashi IwaiPCI intel8x0 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.
--- sound/pci/intel8x0.c | 46 ++++++++++++++++++++++++++++--------------- sound/pci/intel8x0m.c | 36 ++++++++++++++++++++++----------- 2 files changed, 54 insertions(+), 28 deletions(-)
sound/pci/intel8x0.c +30 -16
@@ -538,7 +538,8 @@ static unsigned short snd_intel8x0_codec_read(struct snd_ac97 *ac97, res =0xffff ; }else { res =iagetword (chip, reg + ac97->num *0x80 ); -if ((tmp =igetdword (chip,ICHREG (GLOB_STA ))) &ICH_RCS ) { + tmp =igetdword (chip,ICHREG (GLOB_STA )); +if (tmp &ICH_RCS ) {/* reset RCS and preserve other R/WC bits */ iputdword (chip,ICHREG (GLOB_STA ), tmp & ~(chip->codec_ready_bits |ICH_GSCI ));
@@ -559,7 +560,8 @@ static void snd_intel8x0_codec_read_test(struct intel8x0 *chip,if (snd_intel8x0_codec_semaphore (chip, codec) >=0 ) {iagetword (chip, codec *0x80 ); -if ((tmp =igetdword (chip,ICHREG (GLOB_STA ))) &ICH_RCS ) { + tmp =igetdword (chip,ICHREG (GLOB_STA )); +if (tmp &ICH_RCS ) {/* reset RCS and preserve other R/WC bits */ iputdword (chip,ICHREG (GLOB_STA ), tmp & ~(chip->codec_ready_bits |ICH_GSCI ));
@@ -1105,7 +1107,8 @@ static int snd_intel8x0_pcm_open(struct snd_pcm_substream *substream, struct ich runtime->hw.buffer_bytes_max =64 *1024 ; runtime->hw.period_bytes_max =64 *1024 ; } -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; runtime->private_data = ichdev;return 0 ;
@@ -2190,7 +2193,8 @@ static int snd_intel8x0_mixer(struct intel8x0 *chip, int ac97_clock,udelay (1 ); } } -if ((err =snd_ac97_bus (chip->card,0 , ops, chip, &pbus)) <0 ) + err =snd_ac97_bus (chip->card,0 , ops, chip, &pbus); +if (err <0 ) goto __err; pbus->private_free = snd_intel8x0_mixer_free_ac97_bus;if (ac97_clock >=8000 && ac97_clock <=48000 )
@@ -2206,7 +2210,8 @@ static int snd_intel8x0_mixer(struct intel8x0 *chip, int ac97_clock, ac97.pci = chip->pci;for (i =0 ; i < codecs; i++) { ac97.num = i; -if ((err =snd_ac97_mixer (pbus, &ac97, &chip->ac97[i])) <0 ) { + err =snd_ac97_mixer (pbus, &ac97, &chip->ac97[i]); +if (err <0 ) {if (err != -EACCES )dev_err (chip->card->dev,"Unable to initialize codec #%d\n" , i);
@@ -2491,11 +2496,13 @@ static int snd_intel8x0_chip_init(struct intel8x0 *chip, int probing)int err;if (chip->device_type !=DEVICE_ALI ) { -if ((err =snd_intel8x0_ich_chip_init (chip, probing)) <0 ) + err =snd_intel8x0_ich_chip_init (chip, probing); +if (err <0 )return err;iagetword (chip,0 );/* clear semaphore flag */ }else { -if ((err =snd_intel8x0_ali_chip_init (chip, probing)) <0 ) + err =snd_intel8x0_ali_chip_init (chip, probing); +if (err <0 )return err; }
@@ -2918,7 +2925,8 @@ static int snd_intel8x0_create(struct snd_card *card, *r_intel8x0 =NULL ; -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err; chip =kzalloc (sizeof (*chip),GFP_KERNEL );
@@ -2950,7 +2958,8 @@ static int snd_intel8x0_create(struct snd_card *card, pci->device == PCI_DEVICE_ID_INTEL_440MX) chip->fix_nocache = 1; /* enable workaround */ -if ((err =pci_request_regions (pci, card->shortname)) <0 ) { + err =pci_request_regions (pci, card->shortname); +if (err <0 ) {kfree (chip);pci_disable_device (pci);return err;
@@ -3064,7 +3073,8 @@ static int snd_intel8x0_create(struct snd_card *card,for (i =0 ; i < chip->max_codecs; i++) chip->codec_isr_bits |= chip->codec_bit[i]; -if ((err =snd_intel8x0_chip_init (chip,1 )) <0 ) { + err =snd_intel8x0_chip_init (chip,1 ); +if (err <0 ) {snd_intel8x0_free (chip);return err; }
@@ -3079,7 +3089,8 @@ static int snd_intel8x0_create(struct snd_card *card, chip->irq = pci->irq; card->sync_irq = chip->irq; -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (err <0 ) {snd_intel8x0_free (chip);return err; }
@@ -3186,18 +3197,20 @@ static int snd_intel8x0_probe(struct pci_dev *pci, buggy_irq =0 ; } -if ((err =snd_intel8x0_create (card, pci, pci_id->driver_data, - &chip)) <0 ) { + err =snd_intel8x0_create (card, pci, pci_id->driver_data, &chip); +if (err <0 ) {snd_card_free (card);return err; } card->private_data = chip; -if ((err =snd_intel8x0_mixer (chip, ac97_clock, ac97_quirk)) <0 ) { + err =snd_intel8x0_mixer (chip, ac97_clock, ac97_quirk); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_intel8x0_pcm (chip)) <0 ) { + err =snd_intel8x0_pcm (chip); +if (err <0 ) {snd_card_free (card);return err; }
@@ -3217,7 +3230,8 @@ static int snd_intel8x0_probe(struct pci_dev *pci, } } -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_card_free (card);return err; }
sound/pci/intel8x0m.c +24 -12
@@ -342,7 +342,8 @@ static unsigned short snd_intel8x0m_codec_read(struct snd_ac97 *ac97, res =0xffff ; }else { res =iagetword (chip, reg + ac97->num *0x80 ); -if ((tmp =igetdword (chip,ICHREG (GLOB_STA ))) &ICH_RCS ) { + tmp =igetdword (chip,ICHREG (GLOB_STA )); +if (tmp &ICH_RCS ) {/* reset RCS and preserve other R/WC bits */ iputdword (chip,ICHREG (GLOB_STA ), tmp & ~(ICH_SRI |ICH_PRI |ICH_TRI |ICH_GSCI ));
@@ -800,7 +801,8 @@ static int snd_intel8x0m_mixer(struct intel8x0m *chip, int ac97_clock) glob_sta =igetdword (chip,ICHREG (GLOB_STA )); -if ((err =snd_ac97_bus (chip->card,0 , &ops, chip, &pbus)) <0 ) + err =snd_ac97_bus (chip->card,0 , &ops, chip, &pbus); +if (err <0 ) goto __err; pbus->private_free = snd_intel8x0m_mixer_free_ac97_bus;if (ac97_clock >=8000 && ac97_clock <=48000 )
@@ -809,7 +811,8 @@ static int snd_intel8x0m_mixer(struct intel8x0m *chip, int ac97_clock) ac97.pci = chip->pci; ac97.num = glob_sta &ICH_SCR ?1 :0 ; -if ((err =snd_ac97_mixer (pbus, &ac97, &x97)) <0 ) { + err =snd_ac97_mixer (pbus, &ac97, &x97); +if (err <0 ) {dev_err (chip->card->dev,"Unable to initialize codec #%d\n" , ac97.num);if (ac97.num ==0 )
@@ -927,7 +930,8 @@ static int snd_intel8x0m_chip_init(struct intel8x0m *chip, int probing)unsigned int i;int err; -if ((err =snd_intel8x0m_ich_chip_init (chip, probing)) <0 ) + err =snd_intel8x0m_ich_chip_init (chip, probing); +if (err <0 )return err;iagetword (chip,0 );/* clear semaphore flag */
@@ -1075,7 +1079,8 @@ static int snd_intel8x0m_create(struct snd_card *card, *r_intel8x0m =NULL ; -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err; chip =kzalloc (sizeof (*chip),GFP_KERNEL );
@@ -1089,7 +1094,8 @@ static int snd_intel8x0m_create(struct snd_card *card, chip->pci = pci; chip->irq =-1 ; -if ((err =pci_request_regions (pci, card->shortname)) <0 ) { + err =pci_request_regions (pci, card->shortname); +if (err <0 ) {kfree (chip);pci_disable_device (pci);return err;
@@ -1167,7 +1173,8 @@ static int snd_intel8x0m_create(struct snd_card *card,pci_set_master (pci); -if ((err =snd_intel8x0m_chip_init (chip,1 )) <0 ) { + err =snd_intel8x0m_chip_init (chip,1 ); +if (err <0 ) {snd_intel8x0m_free (chip);return err; }
@@ -1181,7 +1188,8 @@ static int snd_intel8x0m_create(struct snd_card *card, chip->irq = pci->irq; card->sync_irq = chip->irq; -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (err <0 ) {snd_intel8x0m_free (chip);return err; }
@@ -1238,17 +1246,20 @@ static int snd_intel8x0m_probe(struct pci_dev *pci, }strcat (card->shortname," Modem" ); -if ((err =snd_intel8x0m_create (card, pci, pci_id->driver_data, &chip)) <0 ) { + err =snd_intel8x0m_create (card, pci, pci_id->driver_data, &chip); +if (err <0 ) {snd_card_free (card);return err; } card->private_data = chip; -if ((err =snd_intel8x0m_mixer (chip, ac97_clock)) <0 ) { + err =snd_intel8x0m_mixer (chip, ac97_clock); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_intel8x0m_pcm (chip)) <0 ) { + err =snd_intel8x0m_pcm (chip); +if (err <0 ) {snd_card_free (card);return err; }
@@ -1258,7 +1269,8 @@ static int snd_intel8x0m_probe(struct pci_dev *pci,sprintf (card->longname,"%s at irq %i" , card->shortname, chip->irq); -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_card_free (card);return err; }
Signature · 1 line
2.26.2
PATCH 29/66 ALSA: maestro3: Fix assignment in if condition
In reply to Takashi IwaiPCI maestro3 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.
--- sound/pci/maestro3.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
sound/pci/maestro3.c +14 -7
@@ -1765,7 +1765,8 @@ snd_m3_playback_open(struct snd_pcm_substream *subs)struct snd_pcm_runtime *runtime = subs->runtime;int err; -if ((err =snd_m3_substream_open (chip, subs)) <0 ) + err =snd_m3_substream_open (chip, subs); +if (err <0 )return err; runtime->hw = snd_m3_playback;
@@ -1789,7 +1790,8 @@ snd_m3_capture_open(struct snd_pcm_substream *subs)struct snd_pcm_runtime *runtime = subs->runtime;int err; -if ((err =snd_m3_substream_open (chip, subs)) <0 ) + err =snd_m3_substream_open (chip, subs); +if (err <0 )return err; runtime->hw = snd_m3_capture;
@@ -2036,12 +2038,14 @@ static int snd_m3_mixer(struct snd_m3 *chip) .read = snd_m3_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;memset (&ac97,0 ,sizeof (ac97)); ac97.private_data = chip; -if ((err =snd_ac97_mixer (pbus, &ac97, &chip->ac97)) <0 ) + err =snd_ac97_mixer (pbus, &ac97, &chip->ac97); +if (err <0 )return err;/* seems ac97 PCM needs initialization.. hack hack.. */
@@ -2642,16 +2646,19 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,if (err <0 ) goto free_chip; -if ((err =snd_m3_mixer (chip)) <0 ) + err =snd_m3_mixer (chip); +if (err <0 )return err;for (i =0 ; i < chip->num_substreams; i++) {struct m3_dma *s = &chip->substreams[i]; -if ((err =snd_m3_assp_client_init (chip, s, i)) <0 ) + err =snd_m3_assp_client_init (chip, s, i); +if (err <0 )return err; } -if ((err =snd_m3_pcm (chip,0 )) <0 ) + err =snd_m3_pcm (chip,0 ); +if (err <0 )return err;#ifdef CONFIG_SND_MAESTRO3_INPUT
Signature · 1 line
2.26.2
PATCH 30/66 ALSA: rme32: Fix assignment in if condition
In reply to Takashi IwaiPCI RME32 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 (except for a slight refactoring about AutoSync rate check, only systematic conversions), no functional changes.
--- sound/pci/rme32.c | 76 ++++++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 28 deletions(-)
sound/pci/rme32.c +48 -28
@@ -668,18 +668,24 @@ snd_rme32_playback_hw_params(struct snd_pcm_substream *substream, }spin_lock_irq (&rme32->lock); -if ((rme32->rcreg &RME32_RCR_KMODE ) && - (rate =snd_rme32_capture_getrate (rme32, &dummy)) >0 ) { + rate =0 ; +if (rme32->rcreg &RME32_RCR_KMODE ) + rate =snd_rme32_capture_getrate (rme32, &dummy); +if (rate >0 ) {/* AutoSync */ if ((int )params_rate (params) != rate) {spin_unlock_irq (&rme32->lock);return -EIO ; } - }else if ((err =snd_rme32_playback_setrate (rme32,params_rate (params))) <0 ) { -spin_unlock_irq (&rme32->lock); -return err; + }else { + err =snd_rme32_playback_setrate (rme32,params_rate (params)); +if (err <0 ) { +spin_unlock_irq (&rme32->lock); +return err; + } } -if ((err =snd_rme32_setformat (rme32,params_format (params))) <0 ) { + err =snd_rme32_setformat (rme32,params_format (params)); +if (err <0 ) {spin_unlock_irq (&rme32->lock);return err; }
@@ -723,15 +729,18 @@ snd_rme32_capture_hw_params(struct snd_pcm_substream *substream, rme32->wcreg |=RME32_WCR_AUTOSYNC ;writel (rme32->wcreg, rme32->iobase +RME32_IO_CONTROL_REGISTER ); -if ((err =snd_rme32_setformat (rme32,params_format (params))) <0 ) { + err =snd_rme32_setformat (rme32,params_format (params)); +if (err <0 ) {spin_unlock_irq (&rme32->lock);return err; } -if ((err =snd_rme32_playback_setrate (rme32,params_rate (params))) <0 ) { + err =snd_rme32_playback_setrate (rme32,params_rate (params)); +if (err <0 ) {spin_unlock_irq (&rme32->lock);return err; } -if ((rate =snd_rme32_capture_getrate (rme32, &isadat)) >0 ) { + rate =snd_rme32_capture_getrate (rme32, &isadat); +if (rate >0 ) {if ((int )params_rate (params) != rate) {spin_unlock_irq (&rme32->lock);return -EIO ;
@@ -854,8 +863,10 @@ static int snd_rme32_playback_spdif_open(struct snd_pcm_substream *substream) runtime->hw.rates |=SNDRV_PCM_RATE_64000 |SNDRV_PCM_RATE_88200 |SNDRV_PCM_RATE_96000 ; runtime->hw.rate_max =96000 ; } -if ((rme32->rcreg &RME32_RCR_KMODE ) && - (rate =snd_rme32_capture_getrate (rme32, &dummy)) >0 ) { + rate =0 ; +if (rme32->rcreg &RME32_RCR_KMODE ) + rate =snd_rme32_capture_getrate (rme32, &dummy); +if (rate >0 ) {/* AutoSync */ runtime->hw.rates =snd_pcm_rate_to_rate_bit (rate); runtime->hw.rate_min = rate;
@@ -895,7 +906,8 @@ static int snd_rme32_capture_spdif_open(struct snd_pcm_substream *substream) runtime->hw.rates |=SNDRV_PCM_RATE_88200 |SNDRV_PCM_RATE_96000 ; runtime->hw.rate_max =96000 ; } -if ((rate =snd_rme32_capture_getrate (rme32, &isadat)) >0 ) { + rate =snd_rme32_capture_getrate (rme32, &isadat); +if (rate >0 ) {if (isadat) {return -EIO ; }
@@ -932,8 +944,10 @@ snd_rme32_playback_adat_open(struct snd_pcm_substream *substream) runtime->hw = snd_rme32_adat_fd_info; else runtime->hw = snd_rme32_adat_info; -if ((rme32->rcreg &RME32_RCR_KMODE ) && - (rate =snd_rme32_capture_getrate (rme32, &dummy)) >0 ) { + rate =0 ; +if (rme32->rcreg &RME32_RCR_KMODE ) + rate =snd_rme32_capture_getrate (rme32, &dummy); +if (rate >0 ) {/* AutoSync */ runtime->hw.rates =snd_pcm_rate_to_rate_bit (rate); runtime->hw.rate_min = rate;
@@ -955,7 +969,8 @@ snd_rme32_capture_adat_open(struct snd_pcm_substream *substream) runtime->hw = snd_rme32_adat_fd_info; else runtime->hw = snd_rme32_adat_info; -if ((rate =snd_rme32_capture_getrate (rme32, &isadat)) >0 ) { + rate =snd_rme32_capture_getrate (rme32, &isadat); +if (rate >0 ) {if (!isadat) {return -EIO ; }
@@ -1307,10 +1322,12 @@ static int snd_rme32_create(struct rme32 *rme32) rme32->irq =-1 ;spin_lock_init (&rme32->lock); -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err; -if ((err =pci_request_regions (pci,"RME32" )) <0 ) + err =pci_request_regions (pci,"RME32" ); +if (err <0 )return err; rme32->port =pci_resource_start (rme32->pci,0 );
@@ -1334,9 +1351,9 @@ static int snd_rme32_create(struct rme32 *rme32)pci_read_config_byte (pci,8 , &rme32->rev);/* set up ALSA pcm device for S/PDIF */ -if ((err =snd_pcm_new (rme32->card,"Digi32 IEC958" ,0 ,1 ,1 , &rme32->spdif_pcm)) <0 ) { + err =snd_pcm_new (rme32->card,"Digi32 IEC958" ,0 ,1 ,1 , &rme32->spdif_pcm); +if (err <0 )return err; - } rme32->spdif_pcm->private_data = rme32; rme32->spdif_pcm->private_free = snd_rme32_free_spdif_pcm;strcpy (rme32->spdif_pcm->name,"Digi32 IEC958" );
@@ -1363,11 +1380,10 @@ static int snd_rme32_create(struct rme32 *rme32) rme32->adat_pcm =NULL ; }else { -if ((err =snd_pcm_new (rme32->card,"Digi32 ADAT" ,1 , -1 ,1 , &rme32->adat_pcm)) <0 ) - { + err =snd_pcm_new (rme32->card,"Digi32 ADAT" ,1 , +1 ,1 , &rme32->adat_pcm); +if (err <0 )return err; - } rme32->adat_pcm->private_data = rme32; rme32->adat_pcm->private_free = snd_rme32_free_adat_pcm;strcpy (rme32->adat_pcm->name,"Digi32 ADAT" );
@@ -1410,9 +1426,9 @@ static int snd_rme32_create(struct rme32 *rme32)/* init switch interface */ -if ((err =snd_rme32_create_switches (rme32->card, rme32)) <0 ) { + err =snd_rme32_create_switches (rme32->card, rme32); +if (err <0 )return err; - }/* init proc interface */ snd_rme32_proc_init (rme32);
@@ -1855,7 +1871,9 @@ static int snd_rme32_create_switches(struct snd_card *card, struct rme32 * rme32struct snd_kcontrol *kctl;for (idx =0 ; idx < (int )ARRAY_SIZE (snd_rme32_controls); idx++) { -if ((err =snd_ctl_add (card, kctl =snd_ctl_new1 (&snd_rme32_controls[idx], rme32))) <0 ) + kctl =snd_ctl_new1 (&snd_rme32_controls[idx], rme32); + err =snd_ctl_add (card, kctl); +if (err <0 )return err;if (idx ==1 )/* IEC958 (S/PDIF) Stream */ rme32->spdif_ctl = kctl;
@@ -1899,7 +1917,8 @@ snd_rme32_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) rme32->pci = pci;if (fullduplex[dev]) rme32->fullduplex_mode =1 ; -if ((err =snd_rme32_create (rme32)) <0 ) { + err =snd_rme32_create (rme32); +if (err <0 ) {snd_card_free (card);return err; }
@@ -1919,7 +1938,8 @@ snd_rme32_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)sprintf (card->longname,"%s (Rev. %d) at 0x%lx, irq %d" , card->shortname, rme32->rev, rme32->port, rme32->irq); -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_card_free (card);return err; }
Signature · 1 line
2.26.2
PATCH 31/66 ALSA: rme96: Fix assignment in if condition
In reply to Takashi IwaiPCI RME96 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 (only systematic conversions except for a few rate handling codes), no functional changes.
--- sound/pci/rme96.c | 148 +++++++++++++++++++++++++--------------------- 1 file changed, 82 insertions(+), 66 deletions(-)
sound/pci/rme96.c +82 -66
@@ -666,12 +666,14 @@ snd_rme96_playback_getrate(struct rme96 *rme96)int rate, dummy;if (!(rme96->wcreg &RME96_WCR_MASTER ) && -snd_rme96_getinputtype (rme96) !=RME96_INPUT_ANALOG && - (rate =snd_rme96_capture_getrate (rme96, &dummy)) >0 ) - { -/* slave clock */ -return rate; +snd_rme96_getinputtype (rme96) !=RME96_INPUT_ANALOG ) { + rate =snd_rme96_capture_getrate (rme96, &dummy); +if (rate >0 ) { +/* slave clock */ +return rate; + } } + rate = ((rme96->wcreg >>RME96_WCR_BITPOS_FREQ_0 ) &1 ) + (((rme96->wcreg >>RME96_WCR_BITPOS_FREQ_1 ) &1 ) <<1 );switch (rate) {
@@ -984,10 +986,11 @@ snd_rme96_playback_hw_params(struct snd_pcm_substream *substream, runtime->dma_bytes =RME96_BUFFER_SIZE ;spin_lock_irq (&rme96->lock); + rate =0 ;if (!(rme96->wcreg &RME96_WCR_MASTER ) && -snd_rme96_getinputtype (rme96) !=RME96_INPUT_ANALOG && - (rate =snd_rme96_capture_getrate (rme96, &dummy)) >0 ) - { +snd_rme96_getinputtype (rme96) !=RME96_INPUT_ANALOG ) + rate =snd_rme96_capture_getrate (rme96, &dummy); +if (rate >0 ) {/* slave clock */ if ((int )params_rate (params) != rate) { err = -EIO ;
@@ -1046,28 +1049,30 @@ snd_rme96_capture_hw_params(struct snd_pcm_substream *substream, runtime->dma_bytes =RME96_BUFFER_SIZE ;spin_lock_irq (&rme96->lock); -if ((err =snd_rme96_capture_setformat (rme96,params_format (params))) <0 ) { + err =snd_rme96_capture_setformat (rme96,params_format (params)); +if (err <0 ) {spin_unlock_irq (&rme96->lock);return err; }if (snd_rme96_getinputtype (rme96) ==RME96_INPUT_ANALOG ) { -if ((err =snd_rme96_capture_analog_setrate (rme96, -params_rate (params))) <0 ) - { + err =snd_rme96_capture_analog_setrate (rme96,params_rate (params)); +if (err <0 ) {spin_unlock_irq (&rme96->lock);return err; } - }else if ((rate =snd_rme96_capture_getrate (rme96, &isadat)) >0 ) { -if ((int )params_rate (params) != rate) { -spin_unlock_irq (&rme96->lock); -return -EIO ; - } -if ((isadat && runtime->hw.channels_min ==2 ) || - (!isadat && runtime->hw.channels_min ==8 )) - { -spin_unlock_irq (&rme96->lock); -return -EIO ; - } + }else { + rate =snd_rme96_capture_getrate (rme96, &isadat); +if (rate >0 ) { +if ((int )params_rate (params) != rate) { +spin_unlock_irq (&rme96->lock); +return -EIO ; + } +if ((isadat && runtime->hw.channels_min ==2 ) || + (!isadat && runtime->hw.channels_min ==8 )) { +spin_unlock_irq (&rme96->lock); +return -EIO ; + } + } }snd_rme96_setframelog (rme96,params_channels (params),0 );if (rme96->playback_periodsize !=0 ) {
@@ -1160,8 +1165,10 @@ rme96_set_buffer_size_constraint(struct rme96 *rme96,snd_pcm_hw_constraint_single (runtime,SNDRV_PCM_HW_PARAM_BUFFER_BYTES ,RME96_BUFFER_SIZE ); -if ((size = rme96->playback_periodsize) !=0 || - (size = rme96->capture_periodsize) !=0 ) + size = rme96->playback_periodsize; +if (!size) + size = rme96->capture_periodsize; +if (size)snd_pcm_hw_constraint_single (runtime,SNDRV_PCM_HW_PARAM_PERIOD_BYTES , size);
@@ -1191,13 +1198,14 @@ snd_rme96_playback_spdif_open(struct snd_pcm_substream *substream) runtime->hw = snd_rme96_playback_spdif_info;if (!(rme96->wcreg &RME96_WCR_MASTER ) && -snd_rme96_getinputtype (rme96) !=RME96_INPUT_ANALOG && - (rate =snd_rme96_capture_getrate (rme96, &dummy)) >0 ) - { -/* slave clock */ - runtime->hw.rates =snd_pcm_rate_to_rate_bit (rate); - runtime->hw.rate_min = rate; - runtime->hw.rate_max = rate; +snd_rme96_getinputtype (rme96) !=RME96_INPUT_ANALOG ) { + rate =snd_rme96_capture_getrate (rme96, &dummy); +if (rate >0 ) { +/* slave clock */ + runtime->hw.rates =snd_pcm_rate_to_rate_bit (rate); + runtime->hw.rate_min = rate; + runtime->hw.rate_max = rate; + } }rme96_set_buffer_size_constraint (rme96, runtime);
@@ -1217,16 +1225,16 @@ snd_rme96_capture_spdif_open(struct snd_pcm_substream *substream)snd_pcm_set_sync (substream); runtime->hw = snd_rme96_capture_spdif_info; -if (snd_rme96_getinputtype (rme96) !=RME96_INPUT_ANALOG && - (rate =snd_rme96_capture_getrate (rme96, &isadat)) >0 ) - { -if (isadat) { -return -EIO ; - } - runtime->hw.rates =snd_pcm_rate_to_rate_bit (rate); - runtime->hw.rate_min = rate; - runtime->hw.rate_max = rate; - } +if (snd_rme96_getinputtype (rme96) !=RME96_INPUT_ANALOG ) { + rate =snd_rme96_capture_getrate (rme96, &isadat); +if (rate >0 ) { +if (isadat) +return -EIO ; + runtime->hw.rates =snd_pcm_rate_to_rate_bit (rate); + runtime->hw.rate_min = rate; + runtime->hw.rate_max = rate; + } + }spin_lock_irq (&rme96->lock);if (rme96->capture_substream) {
@@ -1260,14 +1268,16 @@ snd_rme96_playback_adat_open(struct snd_pcm_substream *substream) runtime->hw = snd_rme96_playback_adat_info;if (!(rme96->wcreg &RME96_WCR_MASTER ) && -snd_rme96_getinputtype (rme96) !=RME96_INPUT_ANALOG && - (rate =snd_rme96_capture_getrate (rme96, &dummy)) >0 ) - { -/* slave clock */ - runtime->hw.rates =snd_pcm_rate_to_rate_bit (rate); - runtime->hw.rate_min = rate; - runtime->hw.rate_max = rate; - } +snd_rme96_getinputtype (rme96) !=RME96_INPUT_ANALOG ) { + rate =snd_rme96_capture_getrate (rme96, &dummy); +if (rate >0 ) { +/* slave clock */ + runtime->hw.rates =snd_pcm_rate_to_rate_bit (rate); + runtime->hw.rate_min = rate; + runtime->hw.rate_max = rate; + } + } +rme96_set_buffer_size_constraint (rme96, runtime);return 0 ; }
@@ -1286,7 +1296,8 @@ snd_rme96_capture_adat_open(struct snd_pcm_substream *substream)expension cards AEB4/8-I are RME96_INPUT_INTERNAL */ return -EIO ; } -if ((rate =snd_rme96_capture_getrate (rme96, &isadat)) >0 ) { + rate =snd_rme96_capture_getrate (rme96, &isadat); +if (rate >0 ) {if (!isadat) {return -EIO ; }
@@ -1603,10 +1614,12 @@ snd_rme96_create(struct rme96 *rme96) rme96->irq =-1 ;spin_lock_init (&rme96->lock); -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err; -if ((err =pci_request_regions (pci,"RME96" )) <0 ) + err =pci_request_regions (pci,"RME96" ); +if (err <0 )return err; rme96->port =pci_resource_start (rme96->pci,0 );
@@ -1630,11 +1643,11 @@ snd_rme96_create(struct rme96 *rme96)pci_read_config_byte (pci,8 , &rme96->rev);/* set up ALSA pcm device for S/PDIF */ -if ((err =snd_pcm_new (rme96->card,"Digi96 IEC958" ,0 , -1 ,1 , &rme96->spdif_pcm)) <0 ) - { + err =snd_pcm_new (rme96->card,"Digi96 IEC958" ,0 , +1 ,1 , &rme96->spdif_pcm); +if (err <0 )return err; - } + rme96->spdif_pcm->private_data = rme96; rme96->spdif_pcm->private_free = snd_rme96_free_spdif_pcm;strcpy (rme96->spdif_pcm->name,"Digi96 IEC958" );
@@ -1648,11 +1661,10 @@ snd_rme96_create(struct rme96 *rme96)/* ADAT is not available on the base model */ rme96->adat_pcm =NULL ; }else { -if ((err =snd_pcm_new (rme96->card,"Digi96 ADAT" ,1 , -1 ,1 , &rme96->adat_pcm)) <0 ) - { + err =snd_pcm_new (rme96->card,"Digi96 ADAT" ,1 , +1 ,1 , &rme96->adat_pcm); +if (err <0 )return err; - } rme96->adat_pcm->private_data = rme96; rme96->adat_pcm->private_free = snd_rme96_free_adat_pcm;strcpy (rme96->adat_pcm->name,"Digi96 ADAT" );
@@ -1701,9 +1713,9 @@ snd_rme96_create(struct rme96 *rme96) }/* init switch interface */ -if ((err =snd_rme96_create_switches (rme96->card, rme96)) <0 ) { + err =snd_rme96_create_switches (rme96->card, rme96); +if (err <0 )return err; - }/* init proc interface */ snd_rme96_proc_init (rme96);
@@ -2336,16 +2348,20 @@ snd_rme96_create_switches(struct snd_card *card,struct snd_kcontrol *kctl;for (idx =0 ; idx <7 ; idx++) { -if ((err =snd_ctl_add (card, kctl =snd_ctl_new1 (&snd_rme96_controls[idx], rme96))) <0 ) + kctl =snd_ctl_new1 (&snd_rme96_controls[idx], rme96); + err =snd_ctl_add (card, kctl); +if (err <0 )return err;if (idx ==1 )/* IEC958 (S/PDIF) Stream */ rme96->spdif_ctl = kctl; }if (RME96_HAS_ANALOG_OUT (rme96)) { -for (idx =7 ; idx <10 ; idx++) -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_rme96_controls[idx], rme96))) <0 ) +for (idx =7 ; idx <10 ; idx++) { + err =snd_ctl_add (card,snd_ctl_new1 (&snd_rme96_controls[idx], rme96)); +if (err <0 )return err; + } }return 0 ;
Signature · 1 line
2.26.2
PATCH 32/66 ALSA: sonicvibes: Fix assignment in if condition
In reply to Takashi IwaiPCI sonicvibes 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.
--- sound/pci/sonicvibes.c | 67 ++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 25 deletions(-)
sound/pci/sonicvibes.c +42 -25
@@ -852,7 +852,8 @@ static int snd_sonicvibes_pcm(struct sonicvibes *sonic, int device)struct snd_pcm *pcm;int err; -if ((err =snd_pcm_new (sonic->card,"s3_86c617" , device,1 ,1 , &pcm)) <0 ) + err =snd_pcm_new (sonic->card,"s3_86c617" , device,1 ,1 , &pcm); +if (err <0 )return err;if (snd_BUG_ON (!pcm))return -EINVAL ;
@@ -1093,7 +1094,9 @@ static int snd_sonicvibes_mixer(struct sonicvibes *sonic)strcpy (card->mixername,"S3 SonicVibes" );for (idx =0 ; idx <ARRAY_SIZE (snd_sonicvibes_controls); idx++) { -if ((err =snd_ctl_add (card, kctl =snd_ctl_new1 (&snd_sonicvibes_controls[idx], sonic))) <0 ) + kctl =snd_ctl_new1 (&snd_sonicvibes_controls[idx], sonic); + err =snd_ctl_add (card, kctl); +if (err <0 )return err;switch (idx) {case 0 :
@@ -1226,7 +1229,8 @@ static int snd_sonicvibes_create(struct snd_card *card, *rsonic =NULL ;/* enable PCI device */ -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err;/* check, if we can restrict PCI DMA transfers to 24 bits */ if (dma_set_mask_and_coherent (&pci->dev,DMA_BIT_MASK (24 ))) {
@@ -1246,7 +1250,8 @@ static int snd_sonicvibes_create(struct snd_card *card, sonic->pci = pci; sonic->irq =-1 ; -if ((err =pci_request_regions (pci,"S3 SonicVibes" )) <0 ) { + err =pci_request_regions (pci,"S3 SonicVibes" ); +if (err <0 ) {kfree (sonic);pci_disable_device (pci);return err;
@@ -1289,14 +1294,16 @@ static int snd_sonicvibes_create(struct snd_card *card,pci_write_config_dword (pci,0x40 , dmaa);pci_write_config_dword (pci,0x48 , dmac); -if ((sonic->res_dmaa =request_region (dmaa,0x10 ,"S3 SonicVibes DDMA-A" )) ==NULL ) { + sonic->res_dmaa =request_region (dmaa,0x10 ,"S3 SonicVibes DDMA-A" ); +if (!sonic->res_dmaa) {snd_sonicvibes_free (sonic);dev_err (card->dev,"unable to grab DDMA-A port at 0x%x-0x%x\n" , dmaa, dmaa +0x10 -1 );return -EBUSY ; } -if ((sonic->res_dmac =request_region (dmac,0x10 ,"S3 SonicVibes DDMA-C" )) ==NULL ) { + sonic->res_dmac =request_region (dmac,0x10 ,"S3 SonicVibes DDMA-C" ); +if (!sonic->res_dmac) {snd_sonicvibes_free (sonic); dev_err(card->dev, "unable to grab DDMA-C port at 0x%x-0x%x\n",
@@ -1358,7 +1365,8 @@ static int snd_sonicvibes_create(struct snd_card *card,#endif sonic->revision =snd_sonicvibes_in (sonic,SV_IREG_REVISION ); -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , sonic, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , sonic, &ops); +if (err <0 ) {snd_sonicvibes_free (sonic);return err; }
@@ -1405,9 +1413,11 @@ static int snd_sonicvibes_midi(struct sonicvibes *sonic, mpu->private_data = sonic; mpu->open_input = snd_sonicvibes_midi_input_open; mpu->close_input = snd_sonicvibes_midi_input_close; -for (idx =0 ; idx <ARRAY_SIZE (snd_sonicvibes_midi_controls); idx++) -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_sonicvibes_midi_controls[idx], sonic))) <0 ) +for (idx =0 ; idx <ARRAY_SIZE (snd_sonicvibes_midi_controls); idx++) { + err =snd_ctl_add (card,snd_ctl_new1 (&snd_sonicvibes_midi_controls[idx], sonic)); +if (err <0 )return err; + }return 0 ; }
@@ -1439,10 +1449,11 @@ static int snd_sonic_probe(struct pci_dev *pci,return -ENODEV ; } } -if ((err =snd_sonicvibes_create (card, pci, - reverb[dev] ?1 :0 , - mge[dev] ?1 :0 , - &sonic)) <0 ) { + err =snd_sonicvibes_create (card, pci, + reverb[dev] ?1 :0 , + mge[dev] ?1 :0 , + &sonic); +if (err <0 ) {snd_card_free (card);return err; }
@@ -1455,30 +1466,35 @@ static int snd_sonic_probe(struct pci_dev *pci, (unsigned long long )pci_resource_start (pci,1 ), sonic->irq); -if ((err =snd_sonicvibes_pcm (sonic,0 )) <0 ) { + err =snd_sonicvibes_pcm (sonic,0 ); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_sonicvibes_mixer (sonic)) <0 ) { + err =snd_sonicvibes_mixer (sonic); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_mpu401_uart_new (card,0 ,MPU401_HW_SONICVIBES , - sonic->midi_port, -MPU401_INFO_INTEGRATED | -MPU401_INFO_IRQ_HOOK , --1 , &midi_uart)) <0 ) { + err =snd_mpu401_uart_new (card,0 ,MPU401_HW_SONICVIBES , + sonic->midi_port, +MPU401_INFO_INTEGRATED | +MPU401_INFO_IRQ_HOOK , +-1 , &midi_uart); +if (err <0 ) {snd_card_free (card);return err; }snd_sonicvibes_midi (sonic, midi_uart); -if ((err =snd_opl3_create (card, sonic->synth_port, - sonic->synth_port +2 , -OPL3_HW_OPL3_SV ,1 , &opl3)) <0 ) { + err =snd_opl3_create (card, sonic->synth_port, + sonic->synth_port +2 , +OPL3_HW_OPL3_SV ,1 , &opl3); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL )) <0 ) { + err =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL ); +if (err <0 ) {snd_card_free (card);return err; }
@@ -1489,7 +1505,8 @@ static int snd_sonic_probe(struct pci_dev *pci,return err; } -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_card_free (card);return err; }
Signature · 1 line
2.26.2
PATCH 33/66 ALSA: via82xx: Fix assignment in if condition
In reply to Takashi IwaiPCI VIA82xx 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.
--- sound/pci/via82xx.c | 78 +++++++++++++++++++++++++-------------- sound/pci/via82xx_modem.c | 52 +++++++++++++++++--------- 2 files changed, 85 insertions(+), 45 deletions(-)
sound/pci/via82xx.c +51 -27
@@ -515,7 +515,8 @@ static int snd_via82xx_codec_ready(struct via82xx *chip, int secondary)while (timeout-- >0 ) {udelay (1 ); -if (!((val =snd_via82xx_codec_xread (chip)) &VIA_REG_AC97_BUSY )) + val =snd_via82xx_codec_xread (chip); +if (!(val &VIA_REG_AC97_BUSY ))return val &0xffff ; } dev_err(chip->card->dev, "codec_ready: codec %i is not ready [0x%x]\n",
@@ -1023,7 +1024,8 @@ static int snd_via8233_playback_prepare(struct snd_pcm_substream *substream)int rate_changed;u32 rbits; -if ((rate_changed =via_lock_rate (&chip->rates[0 ], ac97_rate)) <0 ) + rate_changed =via_lock_rate (&chip->rates[0 ], ac97_rate); +if (rate_changed <0 )return rate_changed;if (rate_changed) snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE,
@@ -1197,7 +1199,8 @@ static int snd_via82xx_pcm_open(struct via82xx *chip, struct viadev *viadev,/* we may remove following constaint when we modify table entries in interrupt */ -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 (use_src) {
@@ -1222,7 +1225,8 @@ static int snd_via686_playback_open(struct snd_pcm_substream *substream)struct viadev *viadev = &chip->devs[chip->playback_devno + substream->number];int err; -if ((err =snd_via82xx_pcm_open (chip, viadev, substream)) <0 ) + err =snd_via82xx_pcm_open (chip, viadev, substream); +if (err <0 )return err;return 0 ; }
@@ -1238,7 +1242,8 @@ static int snd_via8233_playback_open(struct snd_pcm_substream *substream)int err; viadev = &chip->devs[chip->playback_devno + substream->number]; -if ((err =snd_via82xx_pcm_open (chip, viadev, substream)) <0 ) + err =snd_via82xx_pcm_open (chip, viadev, substream); +if (err <0 )return err; stream = viadev->reg_offset /0x10 ;if (chip->dxs_controls[stream]) {
@@ -1275,7 +1280,8 @@ static int snd_via8233_multi_open(struct snd_pcm_substream *substream) .mask = 0, }; -if ((err =snd_via82xx_pcm_open (chip, viadev, substream)) <0 ) + err =snd_via82xx_pcm_open (chip, viadev, substream); +if (err <0 )return err; substream->runtime->hw.channels_max =6 ;if (chip->revision ==VIA_REV_8233A )
@@ -1875,7 +1881,8 @@ static int snd_via82xx_mixer_new(struct via82xx *chip, const char *quirk_overrid .wait = snd_via82xx_codec_wait, }; -if ((err =snd_ac97_bus (chip->card,0 , &ops, chip, &chip->ac97_bus)) <0 ) + err =snd_ac97_bus (chip->card,0 , &ops, chip, &chip->ac97_bus); +if (err <0 )return err; chip->ac97_bus->private_free = snd_via82xx_mixer_free_ac97_bus; chip->ac97_bus->clock = chip->ac97_clock;
@@ -1885,7 +1892,8 @@ static int snd_via82xx_mixer_new(struct via82xx *chip, const char *quirk_overrid ac97.private_free = snd_via82xx_mixer_free_ac97; ac97.pci = chip->pci; ac97.scaps =AC97_SCAP_SKIP_MODEM |AC97_SCAP_POWER_SAVE ; -if ((err =snd_ac97_mixer (chip->ac97_bus, &ac97, &chip->ac97)) <0 ) + err =snd_ac97_mixer (chip->ac97_bus, &ac97, &chip->ac97); +if (err <0 )return err;snd_ac97_tune_hardware (chip->ac97, ac97_quirks, quirk_override);
@@ -2054,9 +2062,9 @@ static int snd_via686_init_misc(struct via82xx *chip)break ; } } -if (mpu_port >=0x200 && - (chip->mpu_res =request_region (mpu_port,2 ,"VIA82xx MPU401" )) - !=NULL ) { +if (mpu_port >=0x200 ) + chip->mpu_res =request_region (mpu_port,2 ,"VIA82xx MPU401" ); +if (chip->mpu_res) {if (rev_h) legacy |=VIA_FUNC_MIDI_PNP ;/* enable PCI I/O 2 */ legacy |=VIA_FUNC_ENABLE_MIDI ;
@@ -2173,7 +2181,8 @@ static int snd_via82xx_chip_init(struct via82xx *chip)schedule_timeout_uninterruptible (1 ); }while (time_before (jiffies, end_time)); -if ((val =snd_via82xx_codec_xread (chip)) &VIA_REG_AC97_BUSY ) + val =snd_via82xx_codec_xread (chip); +if (val &VIA_REG_AC97_BUSY )dev_err (chip->card->dev,"AC'97 codec is not ready [0x%x]\n" , val);
@@ -2186,7 +2195,8 @@ static int snd_via82xx_chip_init(struct via82xx *chip)VIA_REG_AC97_SECONDARY_VALID | (VIA_REG_AC97_CODEC_ID_SECONDARY << VIA_REG_AC97_CODEC_ID_SHIFT)); do { - if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_SECONDARY_VALID) { + val = snd_via82xx_codec_xread(chip); + if (val & VIA_REG_AC97_SECONDARY_VALID) { chip->ac97_secondary = 1; goto __ac97_ok2; }
@@ -2337,10 +2347,12 @@ static int snd_via82xx_create(struct snd_card *card, .dev_free = snd_via82xx_dev_free, }; -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err; -if ((chip =kzalloc (sizeof (*chip),GFP_KERNEL )) ==NULL ) { + chip =kzalloc (sizeof (*chip),GFP_KERNEL ); +if (!chip) {pci_disable_device (pci);return -ENOMEM ; }
@@ -2360,7 +2372,8 @@ static int snd_via82xx_create(struct snd_card *card,pci_write_config_byte (chip->pci,VIA_FUNC_ENABLE , chip->old_legacy & ~(VIA_FUNC_ENABLE_SB |VIA_FUNC_ENABLE_FM )); -if ((err =pci_request_regions (pci, card->driver)) <0 ) { + err =pci_request_regions (pci, card->driver); +if (err <0 ) {kfree (chip);pci_disable_device (pci);return err;
@@ -2380,12 +2393,14 @@ static int snd_via82xx_create(struct snd_card *card,if (ac97_clock >=8000 && ac97_clock <=48000 ) chip->ac97_clock = ac97_clock; -if ((err =snd_via82xx_chip_init (chip)) <0 ) { + err =snd_via82xx_chip_init (chip); +if (err <0 ) {snd_via82xx_free (chip);return err; } -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (err <0 ) {snd_via82xx_free (chip);return err; }
@@ -2541,24 +2556,31 @@ static int snd_via82xx_probe(struct pci_dev *pci, goto __error; } -if ((err =snd_via82xx_create (card, pci, chip_type, pci->revision, - ac97_clock, &chip)) <0 ) + err =snd_via82xx_create (card, pci, chip_type, pci->revision, + ac97_clock, &chip); +if (err <0 ) goto __error; card->private_data = chip; -if ((err =snd_via82xx_mixer_new (chip, ac97_quirk)) <0 ) + err =snd_via82xx_mixer_new (chip, ac97_quirk); +if (err <0 ) goto __error;if (chip_type ==TYPE_VIA686 ) { -if ((err =snd_via686_pcm_new (chip)) <0 || - (err =snd_via686_init_misc (chip)) <0 ) + err =snd_via686_pcm_new (chip); +if (err <0 ) + goto __error; + err =snd_via686_init_misc (chip); +if (err <0 ) goto __error; }else {if (chip_type ==TYPE_VIA8233A ) { -if ((err =snd_via8233a_pcm_new (chip)) <0 ) + err =snd_via8233a_pcm_new (chip); +if (err <0 ) goto __error;// chip->dxs_fixed = 1; /* FIXME: use 48k for DXS #3? */ }else { -if ((err =snd_via8233_pcm_new (chip)) <0 ) + err =snd_via8233_pcm_new (chip); +if (err <0 ) goto __error;if (dxs_support ==VIA_DXS_48K ) chip->dxs_fixed =1 ;
@@ -2569,7 +2591,8 @@ static int snd_via82xx_probe(struct pci_dev *pci, chip->dxs_src =1 ; } } -if ((err =snd_via8233_init_misc (chip)) <0 ) + err =snd_via8233_init_misc (chip); +if (err <0 ) goto __error; }
@@ -2583,7 +2606,8 @@ static int snd_via82xx_probe(struct pci_dev *pci,snd_via82xx_proc_init (chip); -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_card_free (card);return err; }
sound/pci/via82xx_modem.c +34 -18
132 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 34/66 ALSA: ac97: Fix assignment in if condition
In reply to Takashi IwaiAC97 codec driver code contains a lot 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.
--- sound/pci/ac97/ac97_codec.c | 205 ++++++++++++++++++++++++------------ sound/pci/ac97/ac97_patch.c | 137 ++++++++++++++++-------- 2 files changed, 228 insertions(+), 114 deletions(-)
sound/pci/ac97/ac97_codec.c +136 -69
@@ -1286,15 +1286,17 @@ static int snd_ac97_cmix_new_stereo(struct snd_card *card, const char *pfx,if (snd_ac97_try_bit (ac97, reg,15 )) {sprintf (name,"%s Switch" , pfx); -if ((err =snd_ac97_cmute_new_stereo (card, name, reg, - check_stereo, check_amix, - ac97)) <0 ) + err =snd_ac97_cmute_new_stereo (card, name, reg, + check_stereo, check_amix, + ac97); +if (err <0 )return err; }check_volume_resolution (ac97, reg, &lo_max, &hi_max);if (lo_max) {sprintf (name,"%s Volume" , pfx); -if ((err =snd_ac97_cvol_new (card, name, reg, lo_max, hi_max, ac97)) <0 ) + err =snd_ac97_cvol_new (card, name, reg, lo_max, hi_max, ac97); +if (err <0 )return err; }return 0 ;
@@ -1333,9 +1335,11 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97)/* build center controls */ if ((snd_ac97_try_volume_mix (ac97,AC97_CENTER_LFE_MASTER )) && !(ac97->flags &AC97_AD_MULTI )) { -if ((err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_center[0 ], ac97))) <0 ) + err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_center[0 ], ac97)); +if (err <0 )return err; -if ((err =snd_ctl_add (card, kctl =snd_ac97_cnew (&snd_ac97_controls_center[1 ], ac97))) <0 ) + err =snd_ctl_add (card, kctl =snd_ac97_cnew (&snd_ac97_controls_center[1 ], ac97)); +if (err <0 )return err;snd_ac97_change_volume_params2 (ac97,AC97_CENTER_LFE_MASTER ,0 , &max); kctl->private_value &= ~(0xff <<16 );
@@ -1347,9 +1351,11 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97)/* build LFE controls */ if ((snd_ac97_try_volume_mix (ac97,AC97_CENTER_LFE_MASTER +1 )) && !(ac97->flags &AC97_AD_MULTI )) { -if ((err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_lfe[0 ], ac97))) <0 ) + err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_lfe[0 ], ac97)); +if (err <0 )return err; -if ((err =snd_ctl_add (card, kctl =snd_ac97_cnew (&snd_ac97_controls_lfe[1 ], ac97))) <0 ) + err =snd_ctl_add (card, kctl =snd_ac97_cnew (&snd_ac97_controls_lfe[1 ], ac97)); +if (err <0 )return err;snd_ac97_change_volume_params2 (ac97,AC97_CENTER_LFE_MASTER ,8 , &max); kctl->private_value &= ~(0xff <<16 );
@@ -1362,23 +1368,26 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97)if ((snd_ac97_try_volume_mix (ac97,AC97_SURROUND_MASTER )) && !(ac97->flags &AC97_AD_MULTI )) {/* Surround Master (0x38) is with stereo mutes */ -if ((err =snd_ac97_cmix_new_stereo (card,"Surround Playback" , -AC97_SURROUND_MASTER ,1 ,0 , - ac97)) <0 ) + err =snd_ac97_cmix_new_stereo (card,"Surround Playback" , +AC97_SURROUND_MASTER ,1 ,0 , + ac97); +if (err <0 )return err; }/* build headphone controls */ if (snd_ac97_try_volume_mix (ac97,AC97_HEADPHONE )) { -if ((err =snd_ac97_cmix_new (card,"Headphone Playback" , -AC97_HEADPHONE ,0 , ac97)) <0 ) + err =snd_ac97_cmix_new (card,"Headphone Playback" , +AC97_HEADPHONE ,0 , ac97); +if (err <0 )return err; }/* build master mono controls */ if (snd_ac97_try_volume_mix (ac97,AC97_MASTER_MONO )) { -if ((err =snd_ac97_cmix_new (card,"Master Mono Playback" , -AC97_MASTER_MONO ,0 , ac97)) <0 ) + err =snd_ac97_cmix_new (card,"Master Mono Playback" , +AC97_MASTER_MONO ,0 , ac97); +if (err <0 )return err; }
@@ -1386,7 +1395,9 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97)if (!(ac97->flags &AC97_HAS_NO_TONE )) {if (snd_ac97_try_volume_mix (ac97,AC97_MASTER_TONE )) {for (idx =0 ; idx <2 ; idx++) { -if ((err =snd_ctl_add (card, kctl =snd_ac97_cnew (&snd_ac97_controls_tone[idx], ac97))) <0 ) + kctl =snd_ac97_cnew (&snd_ac97_controls_tone[idx], ac97); + err =snd_ctl_add (card, kctl); +if (err <0 )return err;if (ac97->id ==AC97_ID_YMF743 || ac97->id ==AC97_ID_YMF753 ) {
@@ -1402,9 +1413,12 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97)if (!(ac97->flags &AC97_HAS_NO_PC_BEEP ) && ((ac97->flags &AC97_HAS_PC_BEEP ) ||snd_ac97_try_volume_mix (ac97,AC97_PC_BEEP ))) { -for (idx =0 ; idx <2 ; idx++) -if ((err =snd_ctl_add (card, kctl =snd_ac97_cnew (&snd_ac97_controls_pc_beep[idx], ac97))) <0 ) +for (idx =0 ; idx <2 ; idx++) { + kctl =snd_ac97_cnew (&snd_ac97_controls_pc_beep[idx], ac97); + err =snd_ctl_add (card, kctl); +if (err <0 )return err; + }set_tlv_db_scale (kctl, db_scale_4bit); snd_ac97_write_cache( ac97,
@@ -1417,8 +1431,9 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97)/* build Phone controls */ if (!(ac97->flags &AC97_HAS_NO_PHONE )) {if (snd_ac97_try_volume_mix (ac97,AC97_PHONE )) { -if ((err =snd_ac97_cmix_new (card,"Phone Playback" , -AC97_PHONE ,1 , ac97)) <0 ) + err =snd_ac97_cmix_new (card,"Phone Playback" , +AC97_PHONE ,1 , ac97); +if (err <0 )return err; } }
@@ -1426,26 +1441,30 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97)/* build MIC controls */ if (!(ac97->flags &AC97_HAS_NO_MIC )) {if (snd_ac97_try_volume_mix (ac97,AC97_MIC )) { -if ((err =snd_ac97_cmix_new (card,"Mic Playback" , -AC97_MIC ,1 , ac97)) <0 ) + err =snd_ac97_cmix_new (card,"Mic Playback" , +AC97_MIC ,1 , ac97); +if (err <0 )return err; -if ((err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_mic_boost, ac97))) <0 ) + err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_mic_boost, ac97)); +if (err <0 )return err; } }/* build Line controls */ if (snd_ac97_try_volume_mix (ac97,AC97_LINE )) { -if ((err =snd_ac97_cmix_new (card,"Line Playback" , -AC97_LINE ,1 , ac97)) <0 ) + err =snd_ac97_cmix_new (card,"Line Playback" , +AC97_LINE ,1 , ac97); +if (err <0 )return err; }/* build CD controls */ if (!(ac97->flags &AC97_HAS_NO_CD )) {if (snd_ac97_try_volume_mix (ac97,AC97_CD )) { -if ((err =snd_ac97_cmix_new (card,"CD Playback" , -AC97_CD ,1 , ac97)) <0 ) + err =snd_ac97_cmix_new (card,"CD Playback" , +AC97_CD ,1 , ac97); +if (err <0 )return err; } }
@@ -1453,8 +1472,9 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97)/* build Video controls */ if (!(ac97->flags &AC97_HAS_NO_VIDEO )) {if (snd_ac97_try_volume_mix (ac97,AC97_VIDEO )) { -if ((err =snd_ac97_cmix_new (card,"Video Playback" , -AC97_VIDEO ,1 , ac97)) <0 ) + err =snd_ac97_cmix_new (card,"Video Playback" , +AC97_VIDEO ,1 , ac97); +if (err <0 )return err; } }
@@ -1462,8 +1482,9 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97)/* build Aux controls */ if (!(ac97->flags &AC97_HAS_NO_AUX )) {if (snd_ac97_try_volume_mix (ac97,AC97_AUX )) { -if ((err =snd_ac97_cmix_new (card,"Aux Playback" , -AC97_AUX ,1 , ac97)) <0 ) + err =snd_ac97_cmix_new (card,"Aux Playback" , +AC97_AUX ,1 , ac97); +if (err <0 )return err; } }
@@ -1475,26 +1496,38 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97) init_val =0x9f9f ; else init_val =0x9f1f ; -for (idx =0 ; idx <2 ; idx++) -if ((err =snd_ctl_add (card, kctl =snd_ac97_cnew (&snd_ac97_controls_ad18xx_pcm[idx], ac97))) <0 ) +for (idx =0 ; idx <2 ; idx++) { + kctl =snd_ac97_cnew (&snd_ac97_controls_ad18xx_pcm[idx], ac97); + err =snd_ctl_add (card, kctl); +if (err <0 )return err; + }set_tlv_db_scale (kctl, db_scale_5bit); ac97->spec.ad18xx.pcmreg[0 ] = init_val;if (ac97->scaps &AC97_SCAP_SURROUND_DAC ) { -for (idx =0 ; idx <2 ; idx++) -if ((err =snd_ctl_add (card, kctl =snd_ac97_cnew (&snd_ac97_controls_ad18xx_surround[idx], ac97))) <0 ) +for (idx =0 ; idx <2 ; idx++) { + kctl =snd_ac97_cnew (&snd_ac97_controls_ad18xx_surround[idx], ac97); + err =snd_ctl_add (card, kctl); +if (err <0 )return err; + }set_tlv_db_scale (kctl, db_scale_5bit); ac97->spec.ad18xx.pcmreg[1 ] = init_val; }if (ac97->scaps &AC97_SCAP_CENTER_LFE_DAC ) { -for (idx =0 ; idx <2 ; idx++) -if ((err =snd_ctl_add (card, kctl =snd_ac97_cnew (&snd_ac97_controls_ad18xx_center[idx], ac97))) <0 ) +for (idx =0 ; idx <2 ; idx++) { + kctl =snd_ac97_cnew (&snd_ac97_controls_ad18xx_center[idx], ac97); + err =snd_ctl_add (card, kctl); +if (err <0 )return err; + }set_tlv_db_scale (kctl, db_scale_5bit); -for (idx =0 ; idx <2 ; idx++) -if ((err =snd_ctl_add (card, kctl =snd_ac97_cnew (&snd_ac97_controls_ad18xx_lfe[idx], ac97))) <0 ) +for (idx =0 ; idx <2 ; idx++) { + kctl =snd_ac97_cnew (&snd_ac97_controls_ad18xx_lfe[idx], ac97); + err =snd_ctl_add (card, kctl); +if (err <0 )return err; + }set_tlv_db_scale (kctl, db_scale_5bit); ac97->spec.ad18xx.pcmreg[2 ] = init_val; }
@@ -1515,7 +1548,8 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97)/* build Capture controls */ if (!(ac97->flags &AC97_HAS_NO_REC_GAIN )) { -if ((err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_control_capture_src, ac97))) <0 ) + err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_control_capture_src, ac97)); +if (err <0 )return err;if (snd_ac97_try_bit (ac97,AC97_REC_GAIN ,15 )) { err = snd_ac97_cmute_new(card, "Capture Switch",
@@ -1523,7 +1557,9 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97)if (err <0 )return err; } -if ((err =snd_ctl_add (card, kctl =snd_ac97_cnew (&snd_ac97_control_capture_vol, ac97))) <0 ) + kctl =snd_ac97_cnew (&snd_ac97_control_capture_vol, ac97); + err =snd_ctl_add (card, kctl); +if (err <0 )return err;set_tlv_db_scale (kctl, db_scale_rec_gain);snd_ac97_write_cache (ac97,AC97_REC_SEL ,0x0000 );
@@ -1531,52 +1567,62 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97) }/* build MIC Capture controls */ if (snd_ac97_try_volume_mix (ac97,AC97_REC_GAIN_MIC )) { -for (idx =0 ; idx <2 ; idx++) -if ((err =snd_ctl_add (card, kctl =snd_ac97_cnew (&snd_ac97_controls_mic_capture[idx], ac97))) <0 ) +for (idx =0 ; idx <2 ; idx++) { + kctl =snd_ac97_cnew (&snd_ac97_controls_mic_capture[idx], ac97); + err =snd_ctl_add (card, kctl); +if (err <0 )return err; + }set_tlv_db_scale (kctl, db_scale_rec_gain);snd_ac97_write_cache (ac97,AC97_REC_GAIN_MIC ,0x0000 ); }/* build PCM out path & mute control */ if (snd_ac97_try_bit (ac97,AC97_GENERAL_PURPOSE ,15 )) { -if ((err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_general[AC97_GENERAL_PCM_OUT ], ac97))) <0 ) + err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_general[AC97_GENERAL_PCM_OUT ], ac97)); +if (err <0 )return err; }/* build Simulated Stereo Enhancement control */ if (ac97->caps &AC97_BC_SIM_STEREO ) { -if ((err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_general[AC97_GENERAL_STEREO_ENHANCEMENT ], ac97))) <0 ) + err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_general[AC97_GENERAL_STEREO_ENHANCEMENT ], ac97)); +if (err <0 )return err; }/* build 3D Stereo Enhancement control */ if (snd_ac97_try_bit (ac97,AC97_GENERAL_PURPOSE ,13 )) { -if ((err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_general[AC97_GENERAL_3D ], ac97))) <0 ) + err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_general[AC97_GENERAL_3D ], ac97)); +if (err <0 )return err; }/* build Loudness control */ if (ac97->caps &AC97_BC_LOUDNESS ) { -if ((err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_general[AC97_GENERAL_LOUDNESS ], ac97))) <0 ) + err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_general[AC97_GENERAL_LOUDNESS ], ac97)); +if (err <0 )return err; }/* build Mono output select control */ if (snd_ac97_try_bit (ac97,AC97_GENERAL_PURPOSE ,9 )) { -if ((err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_general[AC97_GENERAL_MONO ], ac97))) <0 ) + err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_general[AC97_GENERAL_MONO ], ac97)); +if (err <0 )return err; }/* build Mic select control */ if (snd_ac97_try_bit (ac97,AC97_GENERAL_PURPOSE ,8 )) { -if ((err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_general[AC97_GENERAL_MIC ], ac97))) <0 ) + err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_general[AC97_GENERAL_MIC ], ac97)); +if (err <0 )return err; }/* build ADC/DAC loopback control */ if (enable_loopback &&snd_ac97_try_bit (ac97,AC97_GENERAL_PURPOSE ,7 )) { -if ((err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_general[AC97_GENERAL_LOOPBACK ], ac97))) <0 ) + err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_general[AC97_GENERAL_LOOPBACK ], ac97)); +if (err <0 )return err; }
@@ -1592,11 +1638,15 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97)snd_ac97_write (ac97,AC97_3D_CONTROL , val); val =snd_ac97_read (ac97,AC97_3D_CONTROL ); val = val ==0x0606 ; -if ((err =snd_ctl_add (card, kctl =snd_ac97_cnew (&snd_ac97_controls_3d[0 ], ac97))) <0 ) + kctl =snd_ac97_cnew (&snd_ac97_controls_3d[0 ], ac97); + err =snd_ctl_add (card, kctl); +if (err <0 )return err;if (val) kctl->private_value =AC97_3D_CONTROL | (9 <<8 ) | (7 <<16 ); -if ((err =snd_ctl_add (card, kctl =snd_ac97_cnew (&snd_ac97_controls_3d[1 ], ac97))) <0 ) + kctl =snd_ac97_cnew (&snd_ac97_controls_3d[1 ], ac97); + err =snd_ctl_add (card, kctl); +if (err <0 )return err;if (val) kctl->private_value =AC97_3D_CONTROL | (1 <<8 ) | (7 <<16 );
@@ -1613,14 +1663,18 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97)if ((ac97->ext_id &AC97_EI_SPDIF ) && !(ac97->scaps &AC97_SCAP_NO_SPDIF )) {if (ac97->build_ops->build_spdif) { -if ((err = ac97->build_ops->build_spdif (ac97)) <0 ) + err = ac97->build_ops->build_spdif (ac97); +if (err <0 )return err; }else { -for (idx =0 ; idx <5 ; idx++) -if ((err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_spdif[idx], ac97))) <0 ) +for (idx =0 ; idx <5 ; idx++) { + err =snd_ctl_add (card,snd_ac97_cnew (&snd_ac97_controls_spdif[idx], ac97)); +if (err <0 )return err; + }if (ac97->build_ops->build_post_spdif) { -if ((err = ac97->build_ops->build_post_spdif (ac97)) <0 ) + err = ac97->build_ops->build_post_spdif (ac97); +if (err <0 )return err; }/* set default PCM S/PDIF params */
@@ -1632,9 +1686,11 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97) }/* build chip specific controls */ -if (ac97->build_ops->build_specific) -if ((err = ac97->build_ops->build_specific (ac97)) <0 ) +if (ac97->build_ops->build_specific) { + err = ac97->build_ops->build_specific (ac97); +if (err <0 )return err; + }if (snd_ac97_try_bit (ac97,AC97_POWERDOWN ,15 )) { kctl =snd_ac97_cnew (&snd_ac97_control_eapd, ac97);
@@ -1642,7 +1698,8 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97)return -ENOMEM ;if (ac97->scaps &AC97_SCAP_INV_EAPD )set_inv_eapd (ac97, kctl); -if ((err =snd_ctl_add (card, kctl)) <0 ) + err =snd_ctl_add (card, kctl); +if (err <0 )return err; }
@@ -1664,14 +1721,18 @@ static int snd_ac97_modem_build(struct snd_card *card, struct snd_ac97 * ac97)snd_ac97_write (ac97,AC97_MISC_AFE ,0x0 );/* build modem switches */ -for (idx =0 ; idx <ARRAY_SIZE (snd_ac97_controls_modem_switches); idx++) -if ((err =snd_ctl_add (card,snd_ctl_new1 (&snd_ac97_controls_modem_switches[idx], ac97))) <0 ) +for (idx =0 ; idx <ARRAY_SIZE (snd_ac97_controls_modem_switches); idx++) { + err =snd_ctl_add (card,snd_ctl_new1 (&snd_ac97_controls_modem_switches[idx], ac97)); +if (err <0 )return err; + }/* build chip specific controls */ -if (ac97->build_ops->build_specific) -if ((err = ac97->build_ops->build_specific (ac97)) <0 ) +if (ac97->build_ops->build_specific) { + err = ac97->build_ops->build_specific (ac97); +if (err <0 )return err; + }return 0 ; }
@@ -1916,7 +1977,8 @@ int snd_ac97_bus(struct snd_card *card, int num, bus->clock =48000 ;spin_lock_init (&bus->bus_lock);snd_ac97_bus_proc_init (bus); -if ((err =snd_device_new (card,SNDRV_DEV_BUS , bus, &dev_ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_BUS , bus, &dev_ops); +if (err <0 ) {snd_ac97_bus_free (bus);return err; }
@@ -1944,7 +2006,8 @@ static int snd_ac97_dev_register(struct snd_device *device)dev_set_name (&ac97->dev,"%d-%d:%s" , ac97->bus->card->number, ac97->num,snd_ac97_get_short_name (ac97)); -if ((err =device_register (&ac97->dev)) <0 ) { + err =device_register (&ac97->dev); +if (err <0 ) {ac97_err (ac97,"Can't register ac97 bus\n" ); ac97->dev.bus =NULL ;return err;
@@ -2095,7 +2158,8 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,if (!(ac97->scaps &AC97_SCAP_SKIP_AUDIO ) && !(ac97->scaps &AC97_SCAP_AUDIO )) {/* test if we can write to the record gain volume register */ snd_ac97_write_cache (ac97,AC97_REC_GAIN ,0x8a06 ); -if (((err =snd_ac97_read (ac97,AC97_REC_GAIN )) &0x7fff ) ==0x0a06 ) + err =snd_ac97_read (ac97,AC97_REC_GAIN ); +if ((err &0x7fff ) ==0x0a06 ) ac97->scaps |=AC97_SCAP_AUDIO ; }if (ac97->scaps &AC97_SCAP_AUDIO ) {
@@ -2248,7 +2312,8 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template, } }sprintf (comp,"AC97a:%08x" , ac97->id); -if ((err =snd_component_add (card, comp)) <0 ) { + err =snd_component_add (card, comp); +if (err <0 ) {snd_ac97_free (ac97);return err; }
@@ -2268,7 +2333,8 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template, } }sprintf (comp,"AC97m:%08x" , ac97->id); -if ((err =snd_component_add (card, comp)) <0 ) { + err =snd_component_add (card, comp); +if (err <0 ) {snd_ac97_free (ac97);return err; }
@@ -2280,7 +2346,8 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,if (ac97_is_audio (ac97))update_power_regs (ac97);snd_ac97_proc_init (ac97); -if ((err =snd_device_new (card,SNDRV_DEV_CODEC , ac97, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_CODEC , ac97, &ops); +if (err <0 ) {snd_ac97_free (ac97);return err; }
sound/pci/ac97/ac97_patch.c +92 -45
312 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 35/66 ALSA: au88x0: Fix assignment in if condition
In reply to Takashi IwaiPCI AU88x0 driver code contains a lot 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. A potential real fix is about the PCI AGP bridge management refcount in addition while spotted out during conversions.
--- sound/pci/au88x0/au88x0.c | 77 +++++++++++++++++++------------- sound/pci/au88x0/au88x0_a3d.c | 28 +++++++----- sound/pci/au88x0/au88x0_core.c | 47 +++++++++---------- sound/pci/au88x0/au88x0_eq.c | 20 +++++---- sound/pci/au88x0/au88x0_mixer.c | 3 +- sound/pci/au88x0/au88x0_mpu401.c | 14 +++--- sound/pci/au88x0/au88x0_pcm.c | 15 ++++--- 7 files changed, 115 insertions(+), 89 deletions(-)
sound/pci/au88x0/au88x0.c +46 -31
@@ -46,8 +46,9 @@ MODULE_DEVICE_TABLE(pci, snd_vortex_ids);static void vortex_fix_latency (struct pci_dev *vortex) {int rc; -if (!(rc =pci_write_config_byte (vortex,0x40 ,0xff ))) { -dev_info (&vortex->dev,"vortex latency is 0xff\n" ); + rc =pci_write_config_byte (vortex,0x40 ,0xff ); +if (!rc) { +dev_info (&vortex->dev,"vortex latency is 0xff\n" ); }else {dev_warn (&vortex->dev,"could not set vortex latency: pci error 0x%x\n" , rc);
@@ -65,9 +66,12 @@ static void vortex_fix_agp_bridge(struct pci_dev *via)* read the config and it is not already set */ -if (!(rc =pci_read_config_byte (via,0x42 , &value)) - && ((value &0x10 ) - || !(rc =pci_write_config_byte (via,0x42 , value |0x10 )))) { + rc =pci_read_config_byte (via,0x42 , &value); +if (!rc) { +if (!(value &0x10 )) + rc =pci_write_config_byte (via,0x42 , value |0x10 ); + } +if (!rc) {dev_info (&via->dev,"bridge config is 0x%x\n" , value |0x10 ); }else { dev_warn(&via->dev,
@@ -102,14 +106,16 @@ static void snd_vortex_workaround(struct pci_dev *vortex, int fix) }else {if (fix &0x1 )vortex_fix_latency (vortex); -if ((fix &0x2 ) && (via =pci_get_device (PCI_VENDOR_ID_VIA , -PCI_DEVICE_ID_VIA_8365_1 ,NULL ))) -vortex_fix_agp_bridge (via); -if ((fix &0x4 ) && (via =pci_get_device (PCI_VENDOR_ID_VIA , -PCI_DEVICE_ID_VIA_82C598_1 ,NULL ))) -vortex_fix_agp_bridge (via); -if ((fix &0x8 ) && (via =pci_get_device (PCI_VENDOR_ID_AMD , -PCI_DEVICE_ID_AMD_FE_GATE_7007 ,NULL ))) +if (fix &0x2 ) + via =pci_get_device (PCI_VENDOR_ID_VIA , +PCI_DEVICE_ID_VIA_8365_1 ,NULL ); +else if (fix &0x4 ) + via =pci_get_device (PCI_VENDOR_ID_VIA , +PCI_DEVICE_ID_VIA_82C598_1 ,NULL ); +else if (fix &0x8 ) + via =pci_get_device (PCI_VENDOR_ID_AMD , +PCI_DEVICE_ID_AMD_FE_GATE_7007 ,NULL ); +if (via)vortex_fix_agp_bridge (via); }pci_dev_put (via);
@@ -147,7 +153,8 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip) *rchip =NULL ;// check PCI availability (DMA). -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err;if (dma_set_mask_and_coherent (&pci->dev,DMA_BIT_MASK (32 ))) {dev_err (card->dev,"error to set DMA mask\n" );
@@ -174,7 +181,8 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip)// (1) PCI resource allocation // Get MMIO area // -if ((err =pci_request_regions (pci,CARD_NAME_SHORT )) !=0 ) + err =pci_request_regions (pci,CARD_NAME_SHORT ); +if (err) goto regions_out; chip->mmio =pci_ioremap_bar (pci,0 );
@@ -187,14 +195,15 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip)/* Init audio core. * This must be done before we do request_irq otherwise we can get spurious * interrupts that we do not handle properly and make a mess of things */ -if ((err =vortex_core_init (chip)) !=0 ) { + err =vortex_core_init (chip); +if (err) {dev_err (card->dev,"hw core init failed\n" ); goto core_out; } -if ((err =request_irq (pci->irq, vortex_interrupt, -IRQF_SHARED ,KBUILD_MODNAME , - chip)) !=0 ) { + err =request_irq (pci->irq, vortex_interrupt, +IRQF_SHARED ,KBUILD_MODNAME , chip); +if (err) {dev_err (card->dev,"cannot grab irq\n" ); goto irq_out; }
@@ -205,9 +214,9 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip)// End of PCI setup. // Register alsa root device. -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (err <0 ) goto alloc_out; - } *rchip = chip;
@@ -252,7 +261,8 @@ snd_vortex_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)return err;// (3) -if ((err =snd_vortex_create (card, pci, &chip)) <0 ) { + err =snd_vortex_create (card, pci, &chip); +if (err <0 ) {snd_card_free (card);return err; }
@@ -278,12 +288,14 @@ snd_vortex_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) }#ifndef CHIP_AU8820 // ADB SPDIF -if ((err =snd_vortex_new_pcm (chip,VORTEX_PCM_SPDIF ,1 )) <0 ) { + err =snd_vortex_new_pcm (chip,VORTEX_PCM_SPDIF ,1 ); +if (err <0 ) {snd_card_free (card);return err; }// A3D -if ((err =snd_vortex_new_pcm (chip,VORTEX_PCM_A3D ,NR_A3D )) <0 ) { + err =snd_vortex_new_pcm (chip,VORTEX_PCM_A3D ,NR_A3D ); +if (err <0 ) {snd_card_free (card);return err; }
@@ -297,12 +309,14 @@ snd_vortex_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)*/ #ifndef CHIP_AU8810 // WT pcm. -if ((err =snd_vortex_new_pcm (chip,VORTEX_PCM_WT ,NR_WT )) <0 ) { + err =snd_vortex_new_pcm (chip,VORTEX_PCM_WT ,NR_WT ); +if (err <0 ) {snd_card_free (card);return err; }#endif -if ((err =snd_vortex_midi (chip)) <0 ) { + err =snd_vortex_midi (chip); +if (err <0 ) {snd_card_free (card);return err; }
@@ -327,13 +341,13 @@ snd_vortex_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)#endif // (5) -if ((err =pci_read_config_word (pci,PCI_DEVICE_ID , - &(chip->device))) <0 ) { + err =pci_read_config_word (pci,PCI_DEVICE_ID , &chip->device); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =pci_read_config_word (pci,PCI_VENDOR_ID , - &(chip->vendor))) <0 ) { + err =pci_read_config_word (pci,PCI_VENDOR_ID , &chip->vendor); +if (err <0 ) {snd_card_free (card);return err; }
@@ -352,7 +366,8 @@ snd_vortex_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)#endif // (6) -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_card_free (card);return err; }
sound/pci/au88x0/au88x0_a3d.c +16 -12
@@ -849,46 +849,50 @@ static int vortex_a3d_register_controls(vortex_t *vortex)int err, i;/* HRTF controls. */ for (i =0 ; i <NR_A3D ; i++) { -if ((kcontrol = -snd_ctl_new1 (&vortex_a3d_kcontrol, &vortex->a3d[i])) ==NULL ) + kcontrol =snd_ctl_new1 (&vortex_a3d_kcontrol, &vortex->a3d[i]); +if (!kcontrol)return -ENOMEM ; kcontrol->id.numid =CTRLID_HRTF ; kcontrol->info = snd_vortex_a3d_hrtf_info; kcontrol->put = snd_vortex_a3d_hrtf_put; -if ((err =snd_ctl_add (vortex->card, kcontrol)) <0 ) + err =snd_ctl_add (vortex->card, kcontrol); +if (err <0 )return err; }/* ITD controls. */ for (i =0 ; i <NR_A3D ; i++) { -if ((kcontrol = -snd_ctl_new1 (&vortex_a3d_kcontrol, &vortex->a3d[i])) ==NULL ) + kcontrol =snd_ctl_new1 (&vortex_a3d_kcontrol, &vortex->a3d[i]); +if (!kcontrol)return -ENOMEM ; kcontrol->id.numid =CTRLID_ITD ; kcontrol->info = snd_vortex_a3d_itd_info; kcontrol->put = snd_vortex_a3d_itd_put; -if ((err =snd_ctl_add (vortex->card, kcontrol)) <0 ) + err =snd_ctl_add (vortex->card, kcontrol); +if (err <0 )return err; }/* ILD (gains) controls. */ for (i =0 ; i <NR_A3D ; i++) { -if ((kcontrol = -snd_ctl_new1 (&vortex_a3d_kcontrol, &vortex->a3d[i])) ==NULL ) + kcontrol =snd_ctl_new1 (&vortex_a3d_kcontrol, &vortex->a3d[i]); +if (!kcontrol)return -ENOMEM ; kcontrol->id.numid =CTRLID_GAINS ; kcontrol->info = snd_vortex_a3d_ild_info; kcontrol->put = snd_vortex_a3d_ild_put; -if ((err =snd_ctl_add (vortex->card, kcontrol)) <0 ) + err =snd_ctl_add (vortex->card, kcontrol); +if (err <0 )return err; }/* Filter controls. */ for (i =0 ; i <NR_A3D ; i++) { -if ((kcontrol = -snd_ctl_new1 (&vortex_a3d_kcontrol, &vortex->a3d[i])) ==NULL ) + kcontrol =snd_ctl_new1 (&vortex_a3d_kcontrol, &vortex->a3d[i]); +if (!kcontrol)return -ENOMEM ; kcontrol->id.numid =CTRLID_FILTER ; kcontrol->info = snd_vortex_a3d_filter_info; kcontrol->put = snd_vortex_a3d_filter_put; -if ((err =snd_ctl_add (vortex->card, kcontrol)) <0 ) + err =snd_ctl_add (vortex->card, kcontrol); +if (err <0 )return err; }return 0 ;
sound/pci/au88x0/au88x0_core.c +24 -23
80 lines not on this page · raw message
sound/pci/au88x0/au88x0_eq.c +12 -8
@@ -873,29 +873,33 @@ static int vortex_eq_init(vortex_t *vortex)vortex_Eqlzr_init (vortex); -if ((kcontrol = -snd_ctl_new1 (&vortex_eqtoggle_kcontrol, vortex)) ==NULL ) + kcontrol =snd_ctl_new1 (&vortex_eqtoggle_kcontrol, vortex); +if (!kcontrol)return -ENOMEM ; kcontrol->private_value =0 ; -if ((err =snd_ctl_add (vortex->card, kcontrol)) <0 ) + err =snd_ctl_add (vortex->card, kcontrol); +if (err <0 )return err;/* EQ gain controls */ for (i =0 ; i <10 ; i++) { -if ((kcontrol = -snd_ctl_new1 (&vortex_eq_kcontrol, vortex)) ==NULL ) + kcontrol =snd_ctl_new1 (&vortex_eq_kcontrol, vortex); +if (!kcontrol)return -ENOMEM ;snprintf (kcontrol->id.name,sizeof (kcontrol->id.name),"%s Playback Volume" , EqBandLabels[i]); kcontrol->private_value = i; -if ((err =snd_ctl_add (vortex->card, kcontrol)) <0 ) + err =snd_ctl_add (vortex->card, kcontrol); +if (err <0 )return err;//vortex->eqctrl[i] = kcontrol; }/* EQ band levels */ -if ((kcontrol =snd_ctl_new1 (&vortex_levels_kcontrol, vortex)) ==NULL ) + kcontrol =snd_ctl_new1 (&vortex_levels_kcontrol, vortex); +if (!kcontrol)return -ENOMEM ; -if ((err =snd_ctl_add (vortex->card, kcontrol)) <0 ) + err =snd_ctl_add (vortex->card, kcontrol); +if (err <0 )return err;return 0 ;
sound/pci/au88x0/au88x0_mixer.c +2 -1
@@ -30,7 +30,8 @@ static int snd_vortex_mixer(vortex_t *vortex) .read = vortex_codec_read, }; -if ((err =snd_ac97_bus (vortex->card,0 , &ops,NULL , &pbus)) <0 ) + err =snd_ac97_bus (vortex->card,0 , &ops,NULL , &pbus); +if (err <0 )return err;memset (&ac97,0 ,sizeof (ac97));// Initialize AC97 codec stuff.
sound/pci/au88x0/au88x0_mpu401.c +7 -7
@@ -68,9 +68,9 @@ static int snd_vortex_midi(vortex_t *vortex)/* Create MPU401 instance. */ #ifdef VORTEX_MPU401_LEGACY -if ((temp = -snd_mpu401_uart_new (vortex->card,0 ,MPU401_HW_MPU401 ,0x330 , -MPU401_INFO_IRQ_HOOK ,-1 , &rmidi)) !=0 ) { + temp =snd_mpu401_uart_new (vortex->card,0 ,MPU401_HW_MPU401 ,0x330 , +MPU401_INFO_IRQ_HOOK ,-1 , &rmidi); +if (temp) {hwwrite (vortex->mmio,VORTEX_CTRL , (hwread (vortex->mmio,VORTEX_CTRL ) & ~CTRL_MIDI_PORT ) & ~CTRL_MIDI_EN );
@@ -78,10 +78,10 @@ static int snd_vortex_midi(vortex_t *vortex) }#else port = (unsigned long )(vortex->mmio +VORTEX_MIDI_DATA ); -if ((temp = -snd_mpu401_uart_new (vortex->card,0 ,MPU401_HW_AUREAL , port, -MPU401_INFO_INTEGRATED |MPU401_INFO_MMIO | -MPU401_INFO_IRQ_HOOK ,-1 , &rmidi)) !=0 ) { + temp =snd_mpu401_uart_new (vortex->card,0 ,MPU401_HW_AUREAL , port, +MPU401_INFO_INTEGRATED |MPU401_INFO_MMIO | +MPU401_INFO_IRQ_HOOK ,-1 , &rmidi); +if (temp) {hwwrite (vortex->mmio,VORTEX_CTRL , (hwread (vortex->mmio,VORTEX_CTRL ) & ~CTRL_MIDI_PORT ) & ~CTRL_MIDI_EN );
sound/pci/au88x0/au88x0_pcm.c +8 -7
@@ -130,14 +130,14 @@ static int snd_vortex_pcm_open(struct snd_pcm_substream *substream)int err;/* Force equal size periods */ -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;/* Avoid PAGE_SIZE boundary to fall inside of a period. */ -if ((err = -snd_pcm_hw_constraint_pow2 (runtime,0 , -SNDRV_PCM_HW_PARAM_PERIOD_BYTES )) <0 ) + err =snd_pcm_hw_constraint_pow2 (runtime,0 , +SNDRV_PCM_HW_PARAM_PERIOD_BYTES ); +if (err <0 )return err; snd_pcm_hw_constraint_step(runtime, 0,
@@ -658,7 +658,8 @@ static int snd_vortex_new_pcm(vortex_t *chip, int idx, int nr) kctl =snd_ctl_new1 (&snd_vortex_mixer_spdif[i], chip);if (!kctl)return -ENOMEM ; -if ((err =snd_ctl_add (chip->card, kctl)) <0 ) + err =snd_ctl_add (chip->card, kctl); +if (err <0 )return err; } }
Signature · 1 line
2.26.2
PATCH 36/66 ALSA: ca0106: Fix assignment in if condition
In reply to Takashi IwaiPCI 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.
--- sound/pci/ca0106/ca0106_main.c | 18 ++++++++++++------ sound/pci/ca0106/ca_midi.c | 3 ++- 2 files changed, 14 insertions(+), 7 deletions(-)
sound/pci/ca0106/ca0106_main.c +12 -6
@@ -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 ;
sound/pci/ca0106/ca_midi.c +2 -1
@@ -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;
Signature · 1 line
2.26.2
PATCH 37/66 ALSA: cs46xx: Fix assignment in if condition
In reply to Takashi IwaiPCI CS46xx 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.
--- sound/pci/cs46xx/cs46xx.c | 31 +++++++++++++-------- sound/pci/cs46xx/cs46xx_lib.c | 51 ++++++++++++++++++++++------------- sound/pci/cs46xx/dsp_spos.c | 3 ++- 3 files changed, 55 insertions(+), 30 deletions(-)
sound/pci/cs46xx/cs46xx.c +20 -11
@@ -70,45 +70,53 @@ static int snd_card_cs46xx_probe(struct pci_dev *pci, 0, &card);if (err <0 )return err; -if ((err =snd_cs46xx_create (card, pci, - external_amp[dev], thinkpad[dev], - &chip)) <0 ) { + err =snd_cs46xx_create (card, pci, + external_amp[dev], thinkpad[dev], + &chip); +if (err <0 ) {snd_card_free (card);return err; } card->private_data = chip; chip->accept_valid = mmap_valid[dev]; -if ((err =snd_cs46xx_pcm (chip,0 )) <0 ) { + err =snd_cs46xx_pcm (chip,0 ); +if (err <0 ) {snd_card_free (card);return err; }#ifdef CONFIG_SND_CS46XX_NEW_DSP -if ((err =snd_cs46xx_pcm_rear (chip,1 )) <0 ) { + err =snd_cs46xx_pcm_rear (chip,1 ); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_cs46xx_pcm_iec958 (chip,2 )) <0 ) { + err =snd_cs46xx_pcm_iec958 (chip,2 ); +if (err <0 ) {snd_card_free (card);return err; }#endif -if ((err =snd_cs46xx_mixer (chip,2 )) <0 ) { + err =snd_cs46xx_mixer (chip,2 ); +if (err <0 ) {snd_card_free (card);return err; }#ifdef CONFIG_SND_CS46XX_NEW_DSP if (chip->nr_ac97_codecs ==2 ) { -if ((err =snd_cs46xx_pcm_center_lfe (chip,3 )) <0 ) { + err =snd_cs46xx_pcm_center_lfe (chip,3 ); +if (err <0 ) {snd_card_free (card);return err; } }#endif -if ((err =snd_cs46xx_midi (chip,0 )) <0 ) { + err =snd_cs46xx_midi (chip,0 ); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_cs46xx_start_dsp (chip)) <0 ) { + err =snd_cs46xx_start_dsp (chip); +if (err <0 ) {snd_card_free (card);return err; }
@@ -124,7 +132,8 @@ static int snd_card_cs46xx_probe(struct pci_dev *pci, chip->ba1_addr, chip->irq); -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_card_free (card);return err; }
sound/pci/cs46xx/cs46xx_lib.c +33 -18
141 lines not on this page · raw message
sound/pci/cs46xx/dsp_spos.c +2 -1
@@ -617,7 +617,8 @@ static void cs46xx_dsp_proc_parameter_dump_read (struct snd_info_entry *entry, col =0 ; } -if ( (symbol =cs46xx_dsp_lookup_symbol_addr (chip,i /sizeof (u32),SYMBOL_PARAMETER )) !=NULL ) { + symbol =cs46xx_dsp_lookup_symbol_addr (chip, i /sizeof (u32),SYMBOL_PARAMETER ); +if (symbol) { col =0 ;snd_iprintf (buffer,"\n%s:\n" ,symbol->symbol_name); }
Signature · 1 line
2.26.2
PATCH 38/66 ALSA: cs5535audio: Fix assignment in if condition
In reply to Takashi IwaiPCI CS5535 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.
--- sound/pci/cs5535audio/cs5535audio.c | 28 ++++++++++++++++--------- sound/pci/cs5535audio/cs5535audio_pcm.c | 10 +++++---- 2 files changed, 24 insertions(+), 14 deletions(-)
sound/pci/cs5535audio/cs5535audio.c +18 -10
@@ -143,7 +143,8 @@ static int snd_cs5535audio_mixer(struct cs5535audio *cs5535au) .read = snd_cs5535audio_ac97_codec_read, }; -if ((err =snd_ac97_bus (card,0 , &ops,NULL , &pbus)) <0 ) + err =snd_ac97_bus (card,0 , &ops,NULL , &pbus); +if (err <0 )return err;memset (&ac97,0 ,sizeof (ac97));
@@ -155,7 +156,8 @@ static int snd_cs5535audio_mixer(struct cs5535audio *cs5535au)/* set any OLPC-specific scaps */ olpc_prequirks (card, &ac97); -if ((err =snd_ac97_mixer (pbus, &ac97, &cs5535au->ac97)) <0 ) { + err =snd_ac97_mixer (pbus, &ac97, &cs5535au->ac97); +if (err <0 ) {dev_err (card->dev,"mixer failed\n" );return err; }
@@ -266,7 +268,8 @@ static int snd_cs5535audio_create(struct snd_card *card, }; *rcs5535au =NULL ; -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err;if (dma_set_mask_and_coherent (&pci->dev,DMA_BIT_MASK (32 ))) {
@@ -286,7 +289,8 @@ static int snd_cs5535audio_create(struct snd_card *card, cs5535au->pci = pci; cs5535au->irq =-1 ; -if ((err =pci_request_regions (pci,"CS5535 Audio" )) <0 ) { + err =pci_request_regions (pci,"CS5535 Audio" ); +if (err <0 ) {kfree (cs5535au); goto pcifail; }
@@ -304,8 +308,8 @@ static int snd_cs5535audio_create(struct snd_card *card, card->sync_irq = cs5535au->irq;pci_set_master (pci); -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , - cs5535au, &ops)) <0 ) + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , cs5535au, &ops); +if (err <0 ) goto sndfail; *rcs5535au = cs5535au;
@@ -340,15 +344,18 @@ static int snd_cs5535audio_probe(struct pci_dev *pci,if (err <0 )return err; -if ((err =snd_cs5535audio_create (card, pci, &cs5535au)) <0 ) + err =snd_cs5535audio_create (card, pci, &cs5535au); +if (err <0 ) goto probefail_out; card->private_data = cs5535au; -if ((err =snd_cs5535audio_mixer (cs5535au)) <0 ) + err =snd_cs5535audio_mixer (cs5535au); +if (err <0 ) goto probefail_out; -if ((err =snd_cs5535audio_pcm (cs5535au)) <0 ) + err =snd_cs5535audio_pcm (cs5535au); +if (err <0 ) goto probefail_out;strcpy (card->driver,DRIVER_NAME );
@@ -358,7 +365,8 @@ static int snd_cs5535audio_probe(struct pci_dev *pci, card->shortname, card->driver, cs5535au->port, cs5535au->irq); -if ((err =snd_card_register (card)) <0 ) + err =snd_card_register (card); +if (err <0 ) goto probefail_out;pci_set_drvdata (pci, card);
sound/pci/cs5535audio/cs5535audio_pcm.c +6 -4
@@ -87,8 +87,9 @@ static int snd_cs5535audio_playback_open(struct snd_pcm_substream *substream)snd_pcm_limit_hw_rates (runtime); cs5535au->playback_substream = substream; runtime->private_data = &(cs5535au->dmas[CS5535AUDIO_DMA_PLAYBACK ]); -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;return 0 ;
@@ -342,8 +343,9 @@ static int snd_cs5535audio_capture_open(struct snd_pcm_substream *substream)snd_pcm_limit_hw_rates (runtime); cs5535au->capture_substream = substream; runtime->private_data = &(cs5535au->dmas[CS5535AUDIO_DMA_CAPTURE ]); -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;olpc_capture_open (cs5535au->ac97);return 0 ;
Signature · 1 line
2.26.2
PATCH 39/66 ALSA: echoaudio: Fix assignment in if condition
In reply to Takashi IwaiPCI echoaudio 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.
--- sound/pci/echoaudio/darla20_dsp.c | 6 +- sound/pci/echoaudio/darla24_dsp.c | 6 +- sound/pci/echoaudio/echo3g_dsp.c | 3 +- sound/pci/echoaudio/echoaudio.c | 220 ++++++++++++++++------------ sound/pci/echoaudio/echoaudio_dsp.c | 12 +- sound/pci/echoaudio/echoaudio_gml.c | 3 +- sound/pci/echoaudio/gina20_dsp.c | 6 +- sound/pci/echoaudio/gina24_dsp.c | 6 +- sound/pci/echoaudio/indigo_dsp.c | 6 +- sound/pci/echoaudio/indigodj_dsp.c | 6 +- sound/pci/echoaudio/indigoio_dsp.c | 6 +- sound/pci/echoaudio/layla20_dsp.c | 6 +- sound/pci/echoaudio/layla24_dsp.c | 9 +- sound/pci/echoaudio/mia_dsp.c | 6 +- sound/pci/echoaudio/midi.c | 4 +- sound/pci/echoaudio/mona_dsp.c | 6 +- 16 files changed, 190 insertions(+), 121 deletions(-)
sound/pci/echoaudio/darla20_dsp.c +4 -2
@@ -36,7 +36,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)if (snd_BUG_ON ((subdevice_id &0xfff0 ) !=DARLA20 ))return -ENODEV ; -if ((err =init_dsp_comm_page (chip))) { + err =init_dsp_comm_page (chip); +if (err) {dev_err (chip->card->dev,"init_hw: could not initialize DSP comm page\n" );return err;
@@ -53,7 +54,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) chip->asic_loaded = true; chip->input_clock_types =ECHO_CLOCK_BIT_INTERNAL ; -if ((err =load_firmware (chip)) <0 ) + err =load_firmware (chip); +if (err <0 )return err; chip->bad_board = false;
sound/pci/echoaudio/darla24_dsp.c +4 -2
@@ -36,7 +36,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)if (snd_BUG_ON ((subdevice_id &0xfff0 ) !=DARLA24 ))return -ENODEV ; -if ((err =init_dsp_comm_page (chip))) { + err =init_dsp_comm_page (chip); +if (err) {dev_err (chip->card->dev,"init_hw: could not initialize DSP comm page\n" );return err;
@@ -52,7 +53,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) chip->input_clock_types =ECHO_CLOCK_BIT_INTERNAL |ECHO_CLOCK_BIT_ESYNC ; -if ((err =load_firmware (chip)) <0 ) + err =load_firmware (chip); +if (err <0 )return err; chip->bad_board = false;
sound/pci/echoaudio/echo3g_dsp.c +2 -1
@@ -49,7 +49,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)if (snd_BUG_ON ((subdevice_id &0xfff0 ) !=ECHO3G ))return -ENODEV ; -if ((err =init_dsp_comm_page (chip))) { + err =init_dsp_comm_page (chip); +if (err) {dev_err (chip->card->dev,"init_hw - could not initialize DSP comm page\n" );return err;
sound/pci/echoaudio/echoaudio.c +130 -90
394 lines not on this page · raw message
sound/pci/echoaudio/echoaudio_dsp.c +8 -4
@@ -349,7 +349,8 @@ static int load_dsp(struct echoaudio *chip, u16 *code)/* If this board requires a resident loader, install it. */ #ifdef DSP_56361 -if ((i =install_resident_loader (chip)) <0 ) + i =install_resident_loader (chip); +if (i <0 )return i;#endif
@@ -495,7 +496,8 @@ static int load_firmware(struct echoaudio *chip)/* See if the ASIC is present and working - only if the DSP is already loaded */ if (chip->dsp_code) { -if ((box_type =check_asic_status (chip)) >=0 ) + box_type =check_asic_status (chip); +if (box_type >=0 )return box_type;/* ASIC check failed; force the DSP to reload */ chip->dsp_code =NULL ;
@@ -509,7 +511,8 @@ static int load_firmware(struct echoaudio *chip)if (err <0 )return err; -if ((box_type =load_asic (chip)) <0 ) + box_type =load_asic (chip); +if (box_type <0 )return box_type;/* error */ return box_type;
@@ -667,7 +670,8 @@ static int restore_dsp_rettings(struct echoaudio *chip) {int i, o, err; -if ((err =check_asic_status (chip)) <0 ) + err =check_asic_status (chip); +if (err <0 )return err;/* Gina20/Darla20 only. Should be harmless for other cards. */
sound/pci/echoaudio/echoaudio_gml.c +2 -1
@@ -194,7 +194,8 @@ static int set_professional_spdif(struct echoaudio *chip, char prof) } } -if ((err =write_control_reg (chip, control_reg, false))) + err =write_control_reg (chip, control_reg, false); +if (err)return err; chip->professional_spdif = prof; dev_dbg(chip->card->dev, "set_professional_spdif to %s\n",
sound/pci/echoaudio/gina20_dsp.c +4 -2
@@ -40,7 +40,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)if (snd_BUG_ON ((subdevice_id &0xfff0 ) !=GINA20 ))return -ENODEV ; -if ((err =init_dsp_comm_page (chip))) { + err =init_dsp_comm_page (chip); +if (err) {dev_err (chip->card->dev,"init_hw - could not initialize DSP comm page\n" );return err;
@@ -58,7 +59,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) chip->input_clock_types =ECHO_CLOCK_BIT_INTERNAL |ECHO_CLOCK_BIT_SPDIF ; -if ((err =load_firmware (chip)) <0 ) + err =load_firmware (chip); +if (err <0 )return err; chip->bad_board = false;
sound/pci/echoaudio/gina24_dsp.c +4 -2
@@ -44,7 +44,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)if (snd_BUG_ON ((subdevice_id &0xfff0 ) !=GINA24 ))return -ENODEV ; -if ((err =init_dsp_comm_page (chip))) { + err =init_dsp_comm_page (chip); +if (err) {dev_err (chip->card->dev,"init_hw - could not initialize DSP comm page\n" );return err;
@@ -74,7 +75,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_CDROM ; } -if ((err =load_firmware (chip)) <0 ) + err =load_firmware (chip); +if (err <0 )return err; chip->bad_board = false;
sound/pci/echoaudio/indigo_dsp.c +4 -2
@@ -41,7 +41,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)if (snd_BUG_ON ((subdevice_id &0xfff0 ) !=INDIGO ))return -ENODEV ; -if ((err =init_dsp_comm_page (chip))) { + err =init_dsp_comm_page (chip); +if (err) {dev_err (chip->card->dev,"init_hw - could not initialize DSP comm page\n" );return err;
@@ -56,7 +57,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) chip->asic_loaded = true; chip->input_clock_types =ECHO_CLOCK_BIT_INTERNAL ; -if ((err =load_firmware (chip)) <0 ) + err =load_firmware (chip); +if (err <0 )return err; chip->bad_board = false;
sound/pci/echoaudio/indigodj_dsp.c +4 -2
@@ -41,7 +41,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)if (snd_BUG_ON ((subdevice_id &0xfff0 ) !=INDIGO_DJ ))return -ENODEV ; -if ((err =init_dsp_comm_page (chip))) { + err =init_dsp_comm_page (chip); +if (err) {dev_err (chip->card->dev,"init_hw - could not initialize DSP comm page\n" );return err;
@@ -56,7 +57,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) chip->asic_loaded = true; chip->input_clock_types =ECHO_CLOCK_BIT_INTERNAL ; -if ((err =load_firmware (chip)) <0 ) + err =load_firmware (chip); +if (err <0 )return err; chip->bad_board = false;
sound/pci/echoaudio/indigoio_dsp.c +4 -2
@@ -41,7 +41,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)if (snd_BUG_ON ((subdevice_id &0xfff0 ) !=INDIGO_IO ))return -ENODEV ; -if ((err =init_dsp_comm_page (chip))) { + err =init_dsp_comm_page (chip); +if (err) {dev_err (chip->card->dev,"init_hw - could not initialize DSP comm page\n" );return err;
@@ -56,7 +57,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) chip->asic_loaded = true; chip->input_clock_types =ECHO_CLOCK_BIT_INTERNAL ; -if ((err =load_firmware (chip)) <0 ) + err =load_firmware (chip); +if (err <0 )return err; chip->bad_board = false;
sound/pci/echoaudio/layla20_dsp.c +4 -2
@@ -43,7 +43,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)if (snd_BUG_ON ((subdevice_id &0xfff0 ) !=LAYLA20 ))return -ENODEV ; -if ((err =init_dsp_comm_page (chip))) { + err =init_dsp_comm_page (chip); +if (err) {dev_err (chip->card->dev,"init_hw - could not initialize DSP comm page\n" );return err;
@@ -60,7 +61,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) chip->output_clock_types =ECHO_CLOCK_BIT_WORD |ECHO_CLOCK_BIT_SUPER ; -if ((err =load_firmware (chip)) <0 ) + err =load_firmware (chip); +if (err <0 )return err; chip->bad_board = false;
sound/pci/echoaudio/layla24_dsp.c +6 -3
@@ -43,7 +43,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)if (snd_BUG_ON ((subdevice_id &0xfff0 ) !=LAYLA24 ))return -ENODEV ; -if ((err =init_dsp_comm_page (chip))) { + err =init_dsp_comm_page (chip); +if (err) {dev_err (chip->card->dev,"init_hw - could not initialize DSP comm page\n" );return err;
@@ -62,11 +63,13 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL |ECHOCAPS_HAS_DIGITAL_MODE_ADAT ; -if ((err =load_firmware (chip)) <0 ) + err =load_firmware (chip); +if (err <0 )return err; chip->bad_board = false; -if ((err =init_line_levels (chip)) <0 ) + err =init_line_levels (chip); +if (err <0 )return err;return err;
sound/pci/echoaudio/mia_dsp.c +4 -2
@@ -44,7 +44,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)if (snd_BUG_ON ((subdevice_id &0xfff0 ) !=MIA ))return -ENODEV ; -if ((err =init_dsp_comm_page (chip))) { + err =init_dsp_comm_page (chip); +if (err) {dev_err (chip->card->dev,"init_hw - could not initialize DSP comm page\n" );return err;
@@ -62,7 +63,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) chip->input_clock_types =ECHO_CLOCK_BIT_INTERNAL |ECHO_CLOCK_BIT_SPDIF ; -if ((err =load_firmware (chip)) <0 ) + err =load_firmware (chip); +if (err <0 )return err; chip->bad_board = false;
sound/pci/echoaudio/midi.c +2 -2
@@ -308,8 +308,8 @@ static int snd_echo_midi_create(struct snd_card *card, {int err; -if ((err =snd_rawmidi_new (card, card->shortname,0 ,1 ,1 , - &chip->rmidi)) <0 ) + err =snd_rawmidi_new (card, card->shortname,0 ,1 ,1 , &chip->rmidi); +if (err <0 )return err;strcpy (chip->rmidi->name, card->shortname);
sound/pci/echoaudio/mona_dsp.c +4 -2
@@ -44,7 +44,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)if (snd_BUG_ON ((subdevice_id &0xfff0 ) !=MONA ))return -ENODEV ; -if ((err =init_dsp_comm_page (chip))) { + err =init_dsp_comm_page (chip); +if (err) {dev_err (chip->card->dev,"init_hw - could not initialize DSP comm page\n" );return err;
@@ -67,7 +68,8 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)else chip->dsp_code_to_load =FW_MONA_301_DSP ; -if ((err =load_firmware (chip)) <0 ) + err =load_firmware (chip); +if (err <0 )return err; chip->bad_board = false;
Signature · 1 line
2.26.2
PATCH 40/66 ALSA: emu10k1: Fix assignment in if condition
In reply to Takashi IwaiPCI EMU10k1 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.
--- sound/pci/emu10k1/emu10k1.c | 42 +++++++++------ sound/pci/emu10k1/emu10k1_callback.c | 3 +- sound/pci/emu10k1/emufx.c | 13 +++-- sound/pci/emu10k1/emumixer.c | 78 ++++++++++++++++++---------- sound/pci/emu10k1/emumpu401.c | 12 +++-- sound/pci/emu10k1/emupcm.c | 24 ++++++--- sound/pci/emu10k1/memory.c | 21 +++++--- sound/pci/emu10k1/p16v.c | 13 +++-- sound/pci/emu10k1/timer.c | 3 +- 9 files changed, 138 insertions(+), 71 deletions(-)
sound/pci/emu10k1/emu10k1.c +27 -15
@@ -107,18 +107,22 @@ static int snd_card_emu10k1_probe(struct pci_dev *pci, max_buffer_size[dev] =32 ; else if (max_buffer_size[dev] > 1024) max_buffer_size[dev] =1024 ; -if ((err =snd_emu10k1_create (card, pci, extin[dev], extout[dev], - (long )max_buffer_size[dev] *1024 *1024 , - enable_ir[dev], subsystem[dev], - &emu)) <0 ) + err =snd_emu10k1_create (card, pci, extin[dev], extout[dev], + (long )max_buffer_size[dev] *1024 *1024 , + enable_ir[dev], subsystem[dev], + &emu); +if (err <0 ) goto error; card->private_data = emu; emu->delay_pcm_irq = delay_pcm_irq[dev] &0x1f ; -if ((err =snd_emu10k1_pcm (emu,0 )) <0 ) + err =snd_emu10k1_pcm (emu,0 ); +if (err <0 ) goto error; -if ((err =snd_emu10k1_pcm_mic (emu,1 )) <0 ) + err =snd_emu10k1_pcm_mic (emu,1 ); +if (err <0 ) goto error; -if ((err =snd_emu10k1_pcm_efx (emu,2 )) <0 ) + err =snd_emu10k1_pcm_efx (emu,2 ); +if (err <0 ) goto error;/* This stores the periods table. */ if (emu->card_capabilities->ca0151_chip) {/* P16V */
@@ -128,26 +132,33 @@ static int snd_card_emu10k1_probe(struct pci_dev *pci, goto error; } -if ((err =snd_emu10k1_mixer (emu,0 ,3 )) <0 ) + err =snd_emu10k1_mixer (emu,0 ,3 ); +if (err <0 ) goto error; -if ((err =snd_emu10k1_timer (emu,0 )) <0 ) + err =snd_emu10k1_timer (emu,0 ); +if (err <0 ) goto error; -if ((err =snd_emu10k1_pcm_multi (emu,3 )) <0 ) + err =snd_emu10k1_pcm_multi (emu,3 ); +if (err <0 ) goto error;if (emu->card_capabilities->ca0151_chip) {/* P16V */ -if ((err =snd_p16v_pcm (emu,4 )) <0 ) + err =snd_p16v_pcm (emu,4 ); +if (err <0 ) goto error; }if (emu->audigy) { -if ((err =snd_emu10k1_audigy_midi (emu)) <0 ) + err =snd_emu10k1_audigy_midi (emu); +if (err <0 ) goto error; }else { -if ((err =snd_emu10k1_midi (emu)) <0 ) + err =snd_emu10k1_midi (emu); +if (err <0 ) goto error; } -if ((err =snd_emu10k1_fx8010_new (emu,0 )) <0 ) + err =snd_emu10k1_fx8010_new (emu,0 ); +if (err <0 ) goto error;#ifdef ENABLE_SYNTH if (snd_seq_device_new(card, 1, SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH,
@@ -174,7 +185,8 @@ static int snd_card_emu10k1_probe(struct pci_dev *pci,"%s (rev.%d, serial:0x%x) at 0x%lx, irq %i" , card->shortname, emu->revision, emu->serial, emu->port, emu->irq); -if ((err =snd_card_register (card)) <0 ) + err =snd_card_register (card); +if (err <0 ) goto error;if (emu->card_capabilities->emu_model)
sound/pci/emu10k1/emu10k1_callback.c +2 -1
@@ -90,7 +90,8 @@ snd_emu10k1_synth_get_voice(struct snd_emu10k1 *hw)if (best[i].voice >=0 ) {int ch; vp = &emu->voices[best[i].voice]; -if ((ch = vp->ch) <0 ) { + ch = vp->ch; +if (ch <0 ) {/* dev_warn(emu->card->dev, "synth_get_voice: ch < 0 (%d) ??", i);
sound/pci/emu10k1/emufx.c +9 -4
@@ -436,7 +436,8 @@ int snd_emu10k1_fx8010_unregister_irq_handler(struct snd_emu10k1 *emu,unsigned long flags;spin_lock_irqsave (&emu->fx8010.irq_lock, flags); -if ((tmp = emu->fx8010.irq_handlers) == irq) { + tmp = emu->fx8010.irq_handlers; +if (tmp == irq) { emu->fx8010.irq_handlers = tmp->next;if (emu->fx8010.irq_handlers ==NULL ) {snd_emu10k1_intr_disable (emu,INTE_FXDSPENABLE );
@@ -871,7 +872,9 @@ static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu, } knew.private_value = (unsigned long )ctl; *ctl = *nctl; -if ((err =snd_ctl_add (emu->card, kctl =snd_ctl_new1 (&knew, emu))) <0 ) { + kctl =snd_ctl_new1 (&knew, emu); + err =snd_ctl_add (emu->card, kctl); +if (err <0 ) {kfree (ctl);kfree (knew.tlv.p); goto __error;
@@ -2403,7 +2406,8 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)while (ptr <0x200 )OP (icode, &ptr, iACC3,C_00000000 ,C_00000000 ,C_00000000 ,C_00000000 ); -if ((err =snd_emu10k1_fx8010_tram_setup (emu, ipcm->buffer_size)) <0 ) + err =snd_emu10k1_fx8010_tram_setup (emu, ipcm->buffer_size); +if (err <0 ) goto __err; icode->gpr_add_control_count = i; icode->gpr_add_controls = controls;
@@ -2681,7 +2685,8 @@ int snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device)struct snd_hwdep *hw;int err; -if ((err =snd_hwdep_new (emu->card,"FX8010" , device, &hw)) <0 ) + err =snd_hwdep_new (emu->card,"FX8010" , device, &hw); +if (err <0 )return err;strcpy (hw->name,"EMU10K1 (FX8010)" ); hw->iface =SNDRV_HWDEP_IFACE_EMU10K1 ;
sound/pci/emu10k1/emumixer.c +52 -26
153 lines not on this page · raw message
sound/pci/emu10k1/emumpu401.c +8 -4
@@ -319,7 +319,8 @@ static int emu10k1_midi_init(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *mstruct snd_rawmidi *rmidi;int err; -if ((err =snd_rawmidi_new (emu->card, name, device,1 ,1 , &rmidi)) <0 ) + err =snd_rawmidi_new (emu->card, name, device,1 ,1 , &rmidi); +if (err <0 )return err; midi->emu = emu;spin_lock_init (&midi->open_lock);
@@ -342,7 +343,8 @@ int snd_emu10k1_midi(struct snd_emu10k1 *emu)struct snd_emu10k1_midi *midi = &emu->midi;int err; -if ((err =emu10k1_midi_init (emu, midi,0 ,"EMU10K1 MPU-401 (UART)" )) <0 ) + err =emu10k1_midi_init (emu, midi,0 ,"EMU10K1 MPU-401 (UART)" ); +if (err <0 )return err; midi->tx_enable =INTE_MIDITXENABLE ;
@@ -360,7 +362,8 @@ int snd_emu10k1_audigy_midi(struct snd_emu10k1 *emu)int err; midi = &emu->midi; -if ((err =emu10k1_midi_init (emu, midi,0 ,"Audigy MPU-401 (UART)" )) <0 ) + err =emu10k1_midi_init (emu, midi,0 ,"Audigy MPU-401 (UART)" ); +if (err <0 )return err; midi->tx_enable =INTE_MIDITXENABLE ;
@@ -371,7 +374,8 @@ int snd_emu10k1_audigy_midi(struct snd_emu10k1 *emu) midi->interrupt = snd_emu10k1_midi_interrupt; midi = &emu->midi2; -if ((err =emu10k1_midi_init (emu, midi,1 ,"Audigy MPU-401 #2" )) <0 ) + err =emu10k1_midi_init (emu, midi,1 ,"Audigy MPU-401 #2" ); +if (err <0 )return err; midi->tx_enable =INTE_A_MIDITXENABLE2 ;
sound/pci/emu10k1/emupcm.c +16 -8
@@ -25,7 +25,8 @@ static void snd_emu10k1_pcm_interrupt(struct snd_emu10k1 *emu, {struct snd_emu10k1_pcm *epcm; -if ((epcm = voice->epcm) ==NULL ) + epcm = voice->epcm; +if (!epcm)return ;if (epcm->substream ==NULL )return ;
@@ -399,7 +400,8 @@ static int snd_emu10k1_playback_hw_params(struct snd_pcm_substream *substream,size_t alloc_size;int err; -if ((err =snd_emu10k1_pcm_channel_alloc (epcm,params_channels (hw_params))) <0 ) + err =snd_emu10k1_pcm_channel_alloc (epcm,params_channels (hw_params)); +if (err <0 )return err; alloc_size =params_buffer_bytes (hw_params);
@@ -1124,11 +1126,13 @@ static int snd_emu10k1_playback_open(struct snd_pcm_substream *substream) runtime->private_data = epcm; runtime->private_free = snd_emu10k1_pcm_free_substream; runtime->hw = snd_emu10k1_playback; -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 ) {kfree (epcm);return err; } -if ((err =snd_pcm_hw_constraint_minmax (runtime,SNDRV_PCM_HW_PARAM_BUFFER_BYTES ,256 ,UINT_MAX )) <0 ) { + err =snd_pcm_hw_constraint_minmax (runtime,SNDRV_PCM_HW_PARAM_BUFFER_BYTES ,256 ,UINT_MAX ); +if (err <0 ) {kfree (epcm);return err; }
@@ -1380,7 +1384,8 @@ int snd_emu10k1_pcm(struct snd_emu10k1 *emu, int device)struct snd_pcm_substream *substream;int err; -if ((err =snd_pcm_new (emu->card,"emu10k1" , device,32 ,1 , &pcm)) <0 ) + err =snd_pcm_new (emu->card,"emu10k1" , device,32 ,1 , &pcm); +if (err <0 )return err; pcm->private_data = emu;
@@ -1412,7 +1417,8 @@ int snd_emu10k1_pcm_multi(struct snd_emu10k1 *emu, int device)struct snd_pcm_substream *substream;int err; -if ((err =snd_pcm_new (emu->card,"emu10k1" , device,1 ,0 , &pcm)) <0 ) + err =snd_pcm_new (emu->card,"emu10k1" , device,1 ,0 , &pcm); +if (err <0 )return err; pcm->private_data = emu;
@@ -1446,7 +1452,8 @@ int snd_emu10k1_pcm_mic(struct snd_emu10k1 *emu, int device)struct snd_pcm *pcm;int err; -if ((err =snd_pcm_new (emu->card,"emu10k1 mic" , device,0 ,1 , &pcm)) <0 ) + err =snd_pcm_new (emu->card,"emu10k1 mic" , device,0 ,1 , &pcm); +if (err <0 )return err; pcm->private_data = emu;
@@ -1774,7 +1781,8 @@ int snd_emu10k1_pcm_efx(struct snd_emu10k1 *emu, int device)struct snd_kcontrol *kctl;int err; -if ((err =snd_pcm_new (emu->card,"emu10k1 efx" , device,8 ,1 , &pcm)) <0 ) + err =snd_pcm_new (emu->card,"emu10k1 efx" , device,8 ,1 , &pcm); +if (err <0 )return err; pcm->private_data = emu;
sound/pci/emu10k1/memory.c +14 -7
@@ -169,16 +169,20 @@ static int unmap_memblk(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk)struct snd_emu10k1_memblk *q;/* calculate the expected size of empty region */ -if ((p = blk->mapped_link.prev) != &emu->mapped_link_head) { + p = blk->mapped_link.prev; +if (p != &emu->mapped_link_head) { q =get_emu10k1_memblk (p, mapped_link); start_page = q->mapped_page + q->pages; - }else + }else { start_page =1 ; -if ((p = blk->mapped_link.next) != &emu->mapped_link_head) { + } + p = blk->mapped_link.next; +if (p != &emu->mapped_link_head) { q =get_emu10k1_memblk (p, mapped_link); end_page = q->mapped_page; - }else + }else { end_page = (emu->address_mode ?MAX_ALIGN_PAGES1 :MAX_ALIGN_PAGES0 ); + }/* remove links */ list_del (&blk->mapped_link);
@@ -267,7 +271,8 @@ int snd_emu10k1_memblk_map(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *bspin_unlock_irqrestore (&emu->memblk_lock, flags);return 0 ; } -if ((err =map_memblk (emu, blk)) <0 ) { + err =map_memblk (emu, blk); +if (err <0 ) {/* no enough page - try to unmap some blocks */ /* starting from the oldest block */ p = emu->mapped_order_link_head.next;
@@ -454,13 +459,15 @@ static void get_single_page_range(struct snd_util_memhdr *hdr,struct snd_emu10k1_memblk *q;int first_page, last_page; first_page = blk->first_page; -if ((p = blk->mem.list.prev) != &hdr->block) { + p = blk->mem.list.prev; +if (p != &hdr->block) { q =get_emu10k1_memblk (p, mem.list);if (q->last_page == first_page) first_page++;/* first page was already allocated */ } last_page = blk->last_page; -if ((p = blk->mem.list.next) != &hdr->block) { + p = blk->mem.list.next; +if (p != &hdr->block) { q =get_emu10k1_memblk (p, mem.list);if (q->first_page == last_page) last_page--;/* last page was already allocated */
sound/pci/emu10k1/p16v.c +8 -5
@@ -194,7 +194,8 @@ static int snd_p16v_pcm_open_playback_channel(struct snd_pcm_substream *substrea#endif /* debug */ /* channel->interrupt = snd_p16v_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; runtime->sync.id32[0 ] = substream->pcm->card->number;
@@ -242,7 +243,8 @@ static int snd_p16v_pcm_open_capture_channel(struct snd_pcm_substream *substream#endif /* debug */ /* channel->interrupt = snd_p16v_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;return 0 ;
@@ -589,7 +591,8 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device)/* dev_dbg(emu->card->dev, "snd_p16v_pcm called. device=%d\n", device); */ emu->p16v_device_offset = device; -if ((err =snd_pcm_new (emu->card,"p16v" , device,1 , capture, &pcm)) <0 ) + err =snd_pcm_new (emu->card,"p16v" , device,1 , capture, &pcm); +if (err <0 )return err; pcm->private_data = emu;
@@ -808,8 +811,8 @@ int snd_p16v_mixer(struct snd_emu10k1 *emu)struct snd_card *card = emu->card;for (i =0 ; i <ARRAY_SIZE (p16v_mixer_controls); i++) { -if ((err =snd_ctl_add (card,snd_ctl_new1 (&p16v_mixer_controls[i], - emu))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&p16v_mixer_controls[i], emu)); +if (err <0 )return err; }return 0 ;
sound/pci/emu10k1/timer.c +2 -1
@@ -72,7 +72,8 @@ int snd_emu10k1_timer(struct snd_emu10k1 *emu, int device) tid.card = emu->card->number; tid.device = device; tid.subdevice =0 ; -if ((err =snd_timer_new (emu->card,"EMU10K1" , &tid, &timer)) >=0 ) { + err =snd_timer_new (emu->card,"EMU10K1" , &tid, &timer); +if (err >=0 ) {strcpy (timer->name,"EMU10K1 timer" ); timer->private_data = emu; timer->hw = snd_emu10k1_timer_hw;
Signature · 1 line
2.26.2
PATCH 41/66 ALSA: emu10k1x: Fix assignment in if condition
In reply to Takashi IwaiPCI EMU10k1X 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.
--- sound/pci/emu10k1/emu10k1x.c | 85 +++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 31 deletions(-)
sound/pci/emu10k1/emu10k1x.c +54 -31
@@ -349,7 +349,8 @@ static void snd_emu10k1x_pcm_interrupt(struct emu10k1x *emu, struct emu10k1x_voi {struct emu10k1x_pcm *epcm; -if ((epcm = voice->epcm) ==NULL ) + epcm = voice->epcm; +if (!epcm)return ;if (epcm->substream ==NULL )return ;
@@ -371,10 +372,11 @@ static int snd_emu10k1x_playback_open(struct snd_pcm_substream *substream)struct snd_pcm_runtime *runtime = substream->runtime;int err; -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; epcm =kzalloc (sizeof (*epcm),GFP_KERNEL );
@@ -550,10 +552,12 @@ static int snd_emu10k1x_pcm_open_capture(struct snd_pcm_substream *substream)struct snd_pcm_runtime *runtime = substream->runtime;int err; -if ((err =snd_pcm_hw_constraint_integer (runtime,SNDRV_PCM_HW_PARAM_PERIODS )) <0 ) -return err; -if ((err =snd_pcm_hw_constraint_step (runtime,0 ,SNDRV_PCM_HW_PARAM_PERIOD_BYTES ,64 )) <0 ) -return err; + err =snd_pcm_hw_constraint_integer (runtime,SNDRV_PCM_HW_PARAM_PERIODS ); +if (err <0 ) +return err; + err =snd_pcm_hw_constraint_step (runtime,0 ,SNDRV_PCM_HW_PARAM_PERIOD_BYTES ,64 ); +if (err <0 ) +return err; epcm =kzalloc (sizeof (*epcm),GFP_KERNEL );if (epcm ==NULL )
@@ -722,7 +726,8 @@ static int snd_emu10k1x_ac97(struct emu10k1x *chip) .read = snd_emu10k1x_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 */
@@ -838,7 +843,8 @@ static int snd_emu10k1x_pcm(struct emu10k1x *emu, int device)if (device ==0 ) capture =1 ; -if ((err =snd_pcm_new (emu->card,"emu10k1x" , device,1 , capture, &pcm)) <0 ) + err =snd_pcm_new (emu->card,"emu10k1x" , device,1 , capture, &pcm); +if (err <0 )return err; pcm->private_data = emu;
@@ -891,7 +897,8 @@ static int snd_emu10k1x_create(struct snd_card *card, *rchip =NULL ; -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err;if (dma_set_mask_and_coherent (&pci->dev,DMA_BIT_MASK (28 )) <0 ) {
@@ -914,8 +921,8 @@ static int snd_emu10k1x_create(struct snd_card *card,spin_lock_init (&chip->voice_lock); chip->port =pci_resource_start (pci,0 ); -if ((chip->res_port =request_region (chip->port,8 , -"EMU10K1X" )) ==NULL ) { + chip->res_port =request_region (chip->port,8 ,"EMU10K1X" ); +if (!chip->res_port) {dev_err (card->dev,"cannot allocate the port 0x%lx\n" , chip->port);snd_emu10k1x_free (chip);
@@ -991,8 +998,8 @@ static int snd_emu10k1x_create(struct snd_card *card,outl (HCFG_LOCKSOUNDCACHE |HCFG_AUDIOENABLE , chip->port+HCFG ); -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , - chip, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (err <0 ) {snd_emu10k1x_free (chip);return err; }
@@ -1171,17 +1178,23 @@ static int snd_emu10k1x_mixer(struct emu10k1x *emu)struct snd_kcontrol *kctl;struct snd_card *card = emu->card; -if ((kctl =snd_ctl_new1 (&snd_emu10k1x_spdif_mask_control, emu)) ==NULL ) + kctl =snd_ctl_new1 (&snd_emu10k1x_spdif_mask_control, emu); +if (!kctl)return -ENOMEM ; -if ((err =snd_ctl_add (card, kctl))) + err =snd_ctl_add (card, kctl); +if (err)return err; -if ((kctl =snd_ctl_new1 (&snd_emu10k1x_shared_spdif, emu)) ==NULL ) + kctl =snd_ctl_new1 (&snd_emu10k1x_shared_spdif, emu); +if (!kctl)return -ENOMEM ; -if ((err =snd_ctl_add (card, kctl))) + err =snd_ctl_add (card, kctl); +if (err)return err; -if ((kctl =snd_ctl_new1 (&snd_emu10k1x_spdif_control, emu)) ==NULL ) + kctl =snd_ctl_new1 (&snd_emu10k1x_spdif_control, emu); +if (!kctl)return -ENOMEM ; -if ((err =snd_ctl_add (card, kctl))) + err =snd_ctl_add (card, kctl); +if (err)return err;return 0 ;
@@ -1488,7 +1501,8 @@ static int emu10k1x_midi_init(struct emu10k1x *emu,struct snd_rawmidi *rmidi;int err; -if ((err =snd_rawmidi_new (emu->card, name, device,1 ,1 , &rmidi)) <0 ) + err =snd_rawmidi_new (emu->card, name, device,1 ,1 , &rmidi); +if (err <0 )return err; midi->emu = emu;spin_lock_init (&midi->open_lock);
@@ -1511,7 +1525,8 @@ static int snd_emu10k1x_midi(struct emu10k1x *emu)struct emu10k1x_midi *midi = &emu->midi;int err; -if ((err =emu10k1x_midi_init (emu, midi,0 ,"EMU10K1X MPU-401 (UART)" )) <0 ) + err =emu10k1x_midi_init (emu, midi,0 ,"EMU10K1X MPU-401 (UART)" ); +if (err <0 )return err; midi->tx_enable =INTE_MIDITXENABLE ;
@@ -1543,35 +1558,42 @@ static int snd_emu10k1x_probe(struct pci_dev *pci,if (err <0 )return err; -if ((err =snd_emu10k1x_create (card, pci, &chip)) <0 ) { + err =snd_emu10k1x_create (card, pci, &chip); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_emu10k1x_pcm (chip,0 )) <0 ) { + err =snd_emu10k1x_pcm (chip,0 ); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_emu10k1x_pcm (chip,1 )) <0 ) { + err =snd_emu10k1x_pcm (chip,1 ); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_emu10k1x_pcm (chip,2 )) <0 ) { + err =snd_emu10k1x_pcm (chip,2 ); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_emu10k1x_ac97 (chip)) <0 ) { + err =snd_emu10k1x_ac97 (chip); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_emu10k1x_mixer (chip)) <0 ) { + err =snd_emu10k1x_mixer (chip); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_emu10k1x_midi (chip)) <0 ) { + err =snd_emu10k1x_midi (chip); +if (err <0 ) {snd_card_free (card);return err; }
@@ -1583,7 +1605,8 @@ static int snd_emu10k1x_probe(struct pci_dev *pci,sprintf (card->longname,"%s at 0x%lx irq %i" , card->shortname, chip->port, chip->irq); -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_card_free (card);return err; }
Signature · 1 line
2.26.2
PATCH 42/66 ALSA: ice1712: Fix assignment in if condition
In reply to Takashi IwaiPCI ICE1712 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.
--- sound/pci/ice1712/delta.c | 6 ++++-- sound/pci/ice1712/ews.c | 24 ++++++++++++++++-------- 2 files changed, 20 insertions(+), 10 deletions(-)
sound/pci/ice1712/delta.c +4 -2
@@ -676,13 +676,15 @@ static int snd_ice1712_delta_init(struct snd_ice1712 *ice)case ICE1712_SUBDEVICE_DELTA1010LT :case ICE1712_SUBDEVICE_VX442 :case ICE1712_SUBDEVICE_DELTA66E : -if ((err =snd_i2c_bus_create (ice->card,"ICE1712 GPIO 1" ,NULL , &ice->i2c)) <0 ) { + err =snd_i2c_bus_create (ice->card,"ICE1712 GPIO 1" ,NULL , &ice->i2c); +if (err <0 ) {dev_err (ice->card->dev,"unable to create I2C bus\n" );return err; } ice->i2c->private_data = ice; ice->i2c->ops = &ap_cs8427_i2c_ops; -if ((err =snd_ice1712_init_cs8427 (ice,CS8427_BASE_ADDR )) <0 ) + err =snd_ice1712_init_cs8427 (ice,CS8427_BASE_ADDR ); +if (err <0 )return err;break ;case ICE1712_SUBDEVICE_DELTA1010 :
sound/pci/ice1712/ews.c +16 -8
@@ -442,7 +442,8 @@ static int snd_ice1712_ews_init(struct snd_ice1712 *ice) ice->spec = spec;/* create i2c */ -if ((err =snd_i2c_bus_create (ice->card,"ICE1712 GPIO 1" ,NULL , &ice->i2c)) <0 ) { + err =snd_i2c_bus_create (ice->card,"ICE1712 GPIO 1" ,NULL , &ice->i2c); +if (err <0 ) {dev_err (ice->card->dev,"unable to create I2C bus\n" );return err; }
@@ -483,7 +484,8 @@ static int snd_ice1712_ews_init(struct snd_ice1712 *ice)if (err <0 )return err;/* Check if the front module is connected */ -if ((err =snd_ice1712_ews88mt_chip_select (ice,0x0f )) <0 ) + err =snd_ice1712_ews88mt_chip_select (ice,0x0f ); +if (err <0 )return err;break ;case ICE1712_SUBDEVICE_EWS88D :
@@ -498,12 +500,14 @@ static int snd_ice1712_ews_init(struct snd_ice1712 *ice)/* set up SPDIF interface */ switch (ice->eeprom.subvendor) {case ICE1712_SUBDEVICE_EWX2496 : -if ((err =snd_ice1712_init_cs8427 (ice,CS8427_BASE_ADDR )) <0 ) + err =snd_ice1712_init_cs8427 (ice,CS8427_BASE_ADDR ); +if (err <0 )return err;snd_cs8427_reg_write (ice->cs8427,CS8427_REG_RECVERRMASK ,CS8427_UNLOCK |CS8427_CONF |CS8427_BIP |CS8427_PAR );break ;case ICE1712_SUBDEVICE_DMX6FIRE : -if ((err =snd_ice1712_init_cs8427 (ice,ICE1712_6FIRE_CS8427_ADDR )) <0 ) + err =snd_ice1712_init_cs8427 (ice,ICE1712_6FIRE_CS8427_ADDR ); +if (err <0 )return err;snd_cs8427_reg_write (ice->cs8427,CS8427_REG_RECVERRMASK ,CS8427_UNLOCK |CS8427_CONF |CS8427_BIP |CS8427_PAR );break ;
@@ -853,7 +857,8 @@ static int snd_ice1712_6fire_control_get(struct snd_kcontrol *kcontrol, struct sint invert = (kcontrol->private_value >>8 ) &1 ;int data; -if ((data =snd_ice1712_6fire_read_pca (ice,PCF9554_REG_OUTPUT )) <0 ) + data =snd_ice1712_6fire_read_pca (ice,PCF9554_REG_OUTPUT ); +if (data <0 )return data; data = (data >> shift) &1 ;if (invert)
@@ -869,7 +874,8 @@ static int snd_ice1712_6fire_control_put(struct snd_kcontrol *kcontrol, struct sint invert = (kcontrol->private_value >>8 ) &1 ;int data, ndata; -if ((data =snd_ice1712_6fire_read_pca (ice,PCF9554_REG_OUTPUT )) <0 ) + data =snd_ice1712_6fire_read_pca (ice,PCF9554_REG_OUTPUT ); +if (data <0 )return data; ndata = data & ~(1 << shift);if (ucontrol->value.integer.value[0 ])
@@ -896,7 +902,8 @@ static int snd_ice1712_6fire_select_input_get(struct snd_kcontrol *kcontrol, strstruct snd_ice1712 *ice =snd_kcontrol_chip (kcontrol);int data; -if ((data =snd_ice1712_6fire_read_pca (ice,PCF9554_REG_OUTPUT )) <0 ) + data =snd_ice1712_6fire_read_pca (ice,PCF9554_REG_OUTPUT ); +if (data <0 )return data; ucontrol->value.integer.value[0 ] = data &3 ;return 0 ;
@@ -907,7 +914,8 @@ static int snd_ice1712_6fire_select_input_put(struct snd_kcontrol *kcontrol, strstruct snd_ice1712 *ice =snd_kcontrol_chip (kcontrol);int data, ndata; -if ((data =snd_ice1712_6fire_read_pca (ice,PCF9554_REG_OUTPUT )) <0 ) + data =snd_ice1712_6fire_read_pca (ice,PCF9554_REG_OUTPUT ); +if (data <0 )return data; ndata = data & ~3 ; ndata |= (ucontrol->value.integer.value[0 ] &3 );
Signature · 1 line
2.26.2
PATCH 43/66 ALSA: korg1212: Fix assignment in if condition
In reply to Takashi IwaiPCI Korg1212 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.
--- sound/pci/korg1212/korg1212.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
sound/pci/korg1212/korg1212.c +16 -8
@@ -1527,7 +1527,8 @@ static int snd_korg1212_hw_params(struct snd_pcm_substream *substream,return 0 ; } -if ((err =snd_korg1212_SetRate (korg1212,params_rate (params))) <0 ) { + err =snd_korg1212_SetRate (korg1212,params_rate (params)); +if (err <0 ) {spin_unlock_irqrestore (&korg1212->lock, flags);return err; }
@@ -2159,7 +2160,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, }; * rchip =NULL ; -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err; korg1212 =kzalloc (sizeof (*korg1212),GFP_KERNEL );
@@ -2196,7 +2198,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,for (i=0 ; i<kAudioChannels; i++) korg1212->volumePhase[i] =0 ; -if ((err =pci_request_regions (pci,"korg1212" )) <0 ) { + err =pci_request_regions (pci,"korg1212" ); +if (err <0 ) {kfree (korg1212);pci_disable_device (pci);return err;
@@ -2220,7 +2223,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, korg1212->iomem2, iomem2_size, stateName[korg1212->cardState]); -if ((korg1212->iobase =ioremap (korg1212->iomem, iomem_size)) ==NULL ) { + korg1212->iobase =ioremap (korg1212->iomem, iomem_size); +if (!korg1212->iobase) {snd_printk (KERN_ERR "korg1212: unable to remap memory region 0x%lx-0x%lx\n" , korg1212->iomem, korg1212->iomem + iomem_size -1 );snd_korg1212_free (korg1212);
@@ -2360,7 +2364,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,if (rc)K1212_DEBUG_PRINTK ("K1212_DEBUG: Reboot Card - RC = %d [%s]\n" , rc, stateName[korg1212->cardState]); -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , korg1212, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , korg1212, &ops); +if (err <0 ) {snd_korg1212_free (korg1212);return err; }
@@ -2385,7 +2390,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, korg1212->RoutingTablePhy,LowerWordSwap (korg1212->RoutingTablePhy), korg1212->AdatTimeCodePhy, LowerWordSwap(korg1212->AdatTimeCodePhy)); -if ((err =snd_pcm_new (korg1212->card,"korg1212" ,0 ,1 ,1 , &korg1212->pcm)) <0 ) + err =snd_pcm_new (korg1212->card,"korg1212" ,0 ,1 ,1 , &korg1212->pcm); +if (err <0 )return err; korg1212->pcm->private_data = korg1212;
@@ -2436,7 +2442,8 @@ snd_korg1212_probe(struct pci_dev *pci,if (err <0 )return err; -if ((err =snd_korg1212_create (card, pci, &korg1212)) <0 ) { + err =snd_korg1212_create (card, pci, &korg1212); +if (err <0 ) {snd_card_free (card);return err; }
@@ -2448,7 +2455,8 @@ snd_korg1212_probe(struct pci_dev *pci,K1212_DEBUG_PRINTK ("K1212_DEBUG: %s\n" , card->longname); -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_card_free (card);return err; }
Signature · 1 line
2.26.2
PATCH 44/66 ALSA: mixart: Fix assignment in if condition
In reply to Takashi IwaiPCI miXart 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.
--- sound/pci/mixart/mixart.c | 29 ++++++++++++++++++----------- sound/pci/mixart/mixart_hwdep.c | 17 ++++++++++++----- sound/pci/mixart/mixart_mixer.c | 33 ++++++++++++++++++++++----------- 3 files changed, 52 insertions(+), 27 deletions(-)
sound/pci/mixart/mixart.c +18 -11
@@ -954,9 +954,10 @@ static int snd_mixart_pcm_analog(struct snd_mixart *chip)char name[32 ];sprintf (name,"miXart analog %d" , chip->chip_idx); -if ((err =snd_pcm_new (chip->card, name,MIXART_PCM_ANALOG , -MIXART_PLAYBACK_STREAMS , -MIXART_CAPTURE_STREAMS , &pcm)) <0 ) { + err =snd_pcm_new (chip->card, name,MIXART_PCM_ANALOG , +MIXART_PLAYBACK_STREAMS , +MIXART_CAPTURE_STREAMS , &pcm); +if (err <0 ) {dev_err (chip->card->dev,"cannot create the analog pcm %d\n" , chip->chip_idx);return err;
@@ -987,9 +988,10 @@ static int snd_mixart_pcm_digital(struct snd_mixart *chip)char name[32 ];sprintf (name,"miXart AES/EBU %d" , chip->chip_idx); -if ((err =snd_pcm_new (chip->card, name,MIXART_PCM_DIGITAL , -MIXART_PLAYBACK_STREAMS , -MIXART_CAPTURE_STREAMS , &pcm)) <0 ) { + err =snd_pcm_new (chip->card, name,MIXART_PCM_DIGITAL , +MIXART_PLAYBACK_STREAMS , +MIXART_CAPTURE_STREAMS , &pcm); +if (err <0 ) {dev_err (chip->card->dev,"cannot create the digital pcm %d\n" , chip->chip_idx);return err;
@@ -1042,7 +1044,8 @@ static int snd_mixart_create(struct mixart_mgr *mgr, struct snd_card *card, int chip->mgr = mgr; card->sync_irq = mgr->irq; -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (err <0 ) {snd_mixart_chip_free (chip);return err; }
@@ -1243,7 +1246,8 @@ static int snd_mixart_probe(struct pci_dev *pci, }/* enable PCI device */ -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err;pci_set_master (pci);
@@ -1267,7 +1271,8 @@ static int snd_mixart_probe(struct pci_dev *pci, mgr->irq =-1 ;/* resource assignment */ -if ((err =pci_request_regions (pci,CARD_NAME )) <0 ) { + err =pci_request_regions (pci,CARD_NAME ); +if (err <0 ) {kfree (mgr);pci_disable_device (pci);return err;
@@ -1332,7 +1337,8 @@ static int snd_mixart_probe(struct pci_dev *pci,"Digigram miXart at 0x%lx & 0x%lx, irq %i [PCM #%d]" , mgr->mem[0].phys, mgr->mem[1].phys, mgr->irq, i); -if ((err =snd_mixart_create (mgr, card, i)) <0 ) { + err =snd_mixart_create (mgr, card, i); +if (err <0 ) {snd_card_free (card);snd_mixart_free (mgr);return err;
@@ -1343,7 +1349,8 @@ static int snd_mixart_probe(struct pci_dev *pci,snd_mixart_proc_init (mgr->chip[i]); } -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_mixart_free (mgr);return err; }
sound/pci/mixart/mixart_hwdep.c +12 -5
@@ -306,9 +306,13 @@ static int mixart_first_init(struct mixart_mgr *mgr)int err;struct mixart_msg request; -if ((err =mixart_enum_connectors (mgr)) <0 )return err; + err =mixart_enum_connectors (mgr); +if (err <0 ) +return err; -if ((err =mixart_enum_physio (mgr)) <0 )return err; + err =mixart_enum_physio (mgr); +if (err <0 ) +return err;/* send a synchro command to card (necessary to do this before first MSG_STREAM_START_STREAM_GRP_PACKET) */ /* though why not here */
@@ -528,15 +532,18 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmwfor (card_index =0 ; card_index < mgr->num_cards; card_index++) {struct snd_mixart *chip = mgr->chip[card_index]; -if ((err =snd_mixart_create_pcm (chip)) <0 ) + err =snd_mixart_create_pcm (chip); +if (err <0 )return err;if (card_index ==0 ) { -if ((err =snd_mixart_create_mixer (chip->mgr)) <0 ) + err =snd_mixart_create_mixer (chip->mgr); +if (err <0 )return err; } -if ((err =snd_card_register (chip->card)) <0 ) + err =snd_card_register (chip->card); +if (err <0 )return err; }
sound/pci/mixart/mixart_mixer.c +22 -11
@@ -1114,10 +1114,12 @@ int snd_mixart_create_mixer(struct mixart_mgr *mgr) temp = mixart_control_analog_level; temp.name ="Master Playback Volume" ; temp.private_value =0 ;/* playback */ -if ((err =snd_ctl_add (chip->card,snd_ctl_new1 (&temp, chip))) <0 ) + err =snd_ctl_add (chip->card,snd_ctl_new1 (&temp, chip)); +if (err <0 )return err;/* output mute controls */ -if ((err =snd_ctl_add (chip->card,snd_ctl_new1 (&mixart_control_output_switch, chip))) <0 ) + err =snd_ctl_add (chip->card,snd_ctl_new1 (&mixart_control_output_switch, chip)); +if (err <0 )return err;/* analog input level control only on first two chips !*/
@@ -1125,7 +1127,8 @@ int snd_mixart_create_mixer(struct mixart_mgr *mgr) temp = mixart_control_analog_level; temp.name ="Master Capture Volume" ; temp.private_value =1 ;/* capture */ -if ((err =snd_ctl_add (chip->card,snd_ctl_new1 (&temp, chip))) <0 ) + err =snd_ctl_add (chip->card,snd_ctl_new1 (&temp, chip)); +if (err <0 )return err; }
@@ -1133,45 +1136,53 @@ int snd_mixart_create_mixer(struct mixart_mgr *mgr) temp.name ="PCM Playback Volume" ; temp.count =MIXART_PLAYBACK_STREAMS ; temp.private_value =0 ;/* playback analog */ -if ((err =snd_ctl_add (chip->card,snd_ctl_new1 (&temp, chip))) <0 ) + err =snd_ctl_add (chip->card,snd_ctl_new1 (&temp, chip)); +if (err <0 )return err; temp.name ="PCM Capture Volume" ; temp.count =1 ; temp.private_value =MIXART_VOL_REC_MASK ;/* capture analog */ -if ((err =snd_ctl_add (chip->card,snd_ctl_new1 (&temp, chip))) <0 ) + err =snd_ctl_add (chip->card,snd_ctl_new1 (&temp, chip)); +if (err <0 )return err;if (mgr->board_type ==MIXART_DAUGHTER_TYPE_AES ) { temp.name ="AES Playback Volume" ; temp.count =MIXART_PLAYBACK_STREAMS ; temp.private_value =MIXART_VOL_AES_MASK ;/* playback AES/EBU */ -if ((err =snd_ctl_add (chip->card,snd_ctl_new1 (&temp, chip))) <0 ) + err =snd_ctl_add (chip->card,snd_ctl_new1 (&temp, chip)); +if (err <0 )return err; temp.name ="AES Capture Volume" ; temp.count =0 ; temp.private_value =MIXART_VOL_REC_MASK |MIXART_VOL_AES_MASK ;/* capture AES/EBU */ -if ((err =snd_ctl_add (chip->card,snd_ctl_new1 (&temp, chip))) <0 ) + err =snd_ctl_add (chip->card,snd_ctl_new1 (&temp, chip)); +if (err <0 )return err; } temp = mixart_control_pcm_switch; temp.name ="PCM Playback Switch" ; temp.private_value =0 ;/* playback analog */ -if ((err =snd_ctl_add (chip->card,snd_ctl_new1 (&temp, chip))) <0 ) + err =snd_ctl_add (chip->card,snd_ctl_new1 (&temp, chip)); +if (err <0 )return err;if (mgr->board_type ==MIXART_DAUGHTER_TYPE_AES ) { temp.name ="AES Playback Switch" ; temp.private_value =MIXART_VOL_AES_MASK ;/* playback AES/EBU */ -if ((err =snd_ctl_add (chip->card,snd_ctl_new1 (&temp, chip))) <0 ) + err =snd_ctl_add (chip->card,snd_ctl_new1 (&temp, chip)); +if (err <0 )return err; }/* monitoring */ -if ((err =snd_ctl_add (chip->card,snd_ctl_new1 (&mixart_control_monitor_vol, chip))) <0 ) + err =snd_ctl_add (chip->card,snd_ctl_new1 (&mixart_control_monitor_vol, chip)); +if (err <0 )return err; -if ((err =snd_ctl_add (chip->card,snd_ctl_new1 (&mixart_control_monitor_sw, chip))) <0 ) + err =snd_ctl_add (chip->card,snd_ctl_new1 (&mixart_control_monitor_sw, chip)); +if (err <0 )return err;/* init all mixer data and program the master volumes/switches */
Signature · 1 line
2.26.2
PATCH 45/66 ALSA: nm256: Fix assignment in if condition
In reply to Takashi IwaiPCI NM256 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.
--- sound/pci/nm256/nm256.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
sound/pci/nm256/nm256.c +19 -8
@@ -1318,7 +1318,8 @@ snd_nm256_mixer(struct nm256 *chip)if (! chip->ac97_regs)return -ENOMEM ; -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;memset (&ac97,0 ,sizeof (ac97));
@@ -1476,7 +1477,8 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci, *chip_ret =NULL ; -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err; chip =kzalloc (sizeof (*chip),GFP_KERNEL );
@@ -1568,7 +1570,8 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci, chip->buffer_end = buffer_top; else {/* get buffer end pointer from signature */ -if ((err =snd_nm256_peek_for_sig (chip)) <0 ) + err =snd_nm256_peek_for_sig (chip); +if (err <0 ) goto __error; }
@@ -1618,7 +1621,8 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci,// pci_set_master(pci); /* needed? */ -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops)) <0 ) + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (err <0 ) goto __error; *chip_ret = chip;
@@ -1700,7 +1704,8 @@ static int snd_nm256_probe(struct pci_dev *pci, capture_bufsize =4 ;if (capture_bufsize >128 ) capture_bufsize =128 ; -if ((err =snd_nm256_create (card, pci, &chip)) <0 ) { + err =snd_nm256_create (card, pci, &chip); +if (err <0 ) {snd_card_free (card);return err; }
@@ -1716,8 +1721,13 @@ static int snd_nm256_probe(struct pci_dev *pci, chip->reset_workaround_2 =1 ; } -if ((err =snd_nm256_pcm (chip,0 )) <0 || - (err =snd_nm256_mixer (chip)) <0 ) { + err =snd_nm256_pcm (chip,0 ); +if (err <0 ) { +snd_card_free (card); +return err; + } + err =snd_nm256_mixer (chip); +if (err <0 ) {snd_card_free (card);return err; }
@@ -1727,7 +1737,8 @@ static int snd_nm256_probe(struct pci_dev *pci, card->shortname, chip->buffer_addr, chip->cport_addr, chip->irq); -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_card_free (card);return err; }
Signature · 1 line
2.26.2
PATCH 46/66 ALSA: pcxhr: Fix assignment in if condition
In reply to Takashi IwaiPCI PCXHR 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.
--- sound/pci/pcxhr/pcxhr.c | 22 ++++++++++++++-------- sound/pci/pcxhr/pcxhr_hwdep.c | 9 ++++++--- 2 files changed, 20 insertions(+), 11 deletions(-)
sound/pci/pcxhr/pcxhr.c +14 -8
@@ -1134,9 +1134,10 @@ int pcxhr_create_pcm(struct snd_pcxhr *chip)char name[32 ];snprintf (name,sizeof (name),"pcxhr %d" , chip->chip_idx); -if ((err =snd_pcm_new (chip->card, name,0 , - chip->nb_streams_play, - chip->nb_streams_capt, &pcm)) <0 ) { + err =snd_pcm_new (chip->card, name,0 , + chip->nb_streams_play, + chip->nb_streams_capt, &pcm); +if (err <0 ) {dev_err (chip->card->dev,"cannot create pcm %s\n" , name);return err; }
@@ -1202,7 +1203,8 @@ static int pcxhr_create(struct pcxhr_mgr *mgr, chip->nb_streams_capt =1 ;/* or 1 stereo stream */ } -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (err <0 ) {pcxhr_chip_free (chip);return err; }
@@ -1492,7 +1494,8 @@ static int pcxhr_probe(struct pci_dev *pci, }/* enable PCI device */ -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err;pci_set_master (pci);
@@ -1537,7 +1540,8 @@ static int pcxhr_probe(struct pci_dev *pci, mgr->granularity =PCXHR_GRANULARITY ;/* resource assignment */ -if ((err =pci_request_regions (pci, card_name)) <0 ) { + err =pci_request_regions (pci, card_name); +if (err <0 ) {kfree (mgr);pci_disable_device (pci);return err;
@@ -1608,7 +1612,8 @@ static int pcxhr_probe(struct pci_dev *pci,snprintf (card->longname,sizeof (card->longname),"%s [PCM #%d]" , mgr->name, i); -if ((err =pcxhr_create (mgr, card, i)) <0 ) { + err =pcxhr_create (mgr, card, i); +if (err <0 ) {snd_card_free (card);pcxhr_free (mgr);return err;
@@ -1618,7 +1623,8 @@ static int pcxhr_probe(struct pci_dev *pci,/* init proc interface only for chip0 */ pcxhr_proc_init (mgr->chip[i]); -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {pcxhr_free (mgr);return err; }
sound/pci/pcxhr/pcxhr_hwdep.c +6 -3
@@ -322,14 +322,17 @@ static int pcxhr_dsp_load(struct pcxhr_mgr *mgr, int index,for (card_index =0 ; card_index < mgr->num_cards; card_index++) {struct snd_pcxhr *chip = mgr->chip[card_index]; -if ((err =pcxhr_create_pcm (chip)) <0 ) + err =pcxhr_create_pcm (chip); +if (err <0 )return err;if (card_index ==0 ) { -if ((err =pcxhr_create_mixer (chip->mgr)) <0 ) + err =pcxhr_create_mixer (chip->mgr); +if (err <0 )return err; } -if ((err =snd_card_register (chip->card)) <0 ) + err =snd_card_register (chip->card); +if (err <0 )return err; } err =pcxhr_start_pipes (mgr);
Signature · 1 line
2.26.2
PATCH 47/66 ALSA: riptide: Fix assignment in if condition
In reply to Takashi IwaiPCI riptide 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.
--- sound/pci/riptide/riptide.c | 88 ++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 35 deletions(-)
sound/pci/riptide/riptide.c +53 -35
@@ -1087,9 +1087,15 @@ static irqreturn_t riptide_handleirq(int irq, void *dev_id) substream[i] = chip->playback_substream[i]; substream[i] = chip->capture_substream;for (i =0 ; i <PLAYBACK_SUBSTREAMS +1 ; i++) { -if (substream[i] && - (runtime = substream[i]->runtime) && - (data = runtime->private_data) && data->state !=ST_STOP ) { +if (!substream[i]) +continue ; + runtime = substream[i]->runtime; +if (!runtime) +continue ; + data = runtime->private_data; +if (!data) +continue ; +if (data->state !=ST_STOP ) { pos =0 ;for (j =0 ; j < data->pages; j++) { c = &data->sgdbuf[j];
@@ -1549,10 +1555,10 @@ snd_riptide_hw_params(struct snd_pcm_substream *substream, (int)sgdlist->bytes);if (sgdlist->area)snd_dma_free_pages (sgdlist); -if ((err =snd_dma_alloc_pages (SNDRV_DMA_TYPE_DEV , - &chip->pci->dev, -sizeof (struct sgd ) * (DESC_MAX_MASK +1 ), - sgdlist)) <0 ) { + err =snd_dma_alloc_pages (SNDRV_DMA_TYPE_DEV , &chip->pci->dev, +sizeof (struct sgd ) * (DESC_MAX_MASK +1 ), + sgdlist); +if (err <0 ) {snd_printk (KERN_ERR "Riptide: failed to alloc %d dma bytes\n" , (int )sizeof (struct sgd ) * (DESC_MAX_MASK +1 ));return err;
@@ -1677,9 +1683,9 @@ static int snd_riptide_pcm(struct snd_riptide *chip, int device)struct snd_pcm *pcm;int err; -if ((err = -snd_pcm_new (chip->card,"RIPTIDE" , device,PLAYBACK_SUBSTREAMS ,1 , - &pcm)) <0 ) + err =snd_pcm_new (chip->card,"RIPTIDE" , device,PLAYBACK_SUBSTREAMS ,1 , + &pcm); +if (err <0 )return err;snd_pcm_set_ops (pcm,SNDRV_PCM_STREAM_PLAYBACK , &snd_riptide_playback_ops);
@@ -1766,14 +1772,16 @@ static int snd_riptide_initialize(struct snd_riptide *chip) cif = chip->cif;if (!cif) { -if ((cif =kzalloc (sizeof (struct cmdif ),GFP_KERNEL )) ==NULL ) + cif =kzalloc (sizeof (struct cmdif ),GFP_KERNEL ); +if (!cif)return -ENOMEM ; cif->hwport = (struct riptideport *)chip->port;spin_lock_init (&cif->lock); chip->cif = cif; } cif->is_reset =0 ; -if ((err =riptide_reset (cif, chip)) !=0 ) + err =riptide_reset (cif, chip); +if (err)return err; device_id = chip->device_id;switch (device_id) {
@@ -1797,7 +1805,8 @@ static int snd_riptide_free(struct snd_riptide *chip)if (!chip)return 0 ; -if ((cif = chip->cif)) { + cif = chip->cif; +if (cif) {SET_GRESET (cif->hwport);udelay (100 );UNSET_GRESET (cif->hwport);
@@ -1830,9 +1839,11 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci, }; *rchip =NULL ; -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err; -if (!(chip =kzalloc (sizeof (struct snd_riptide ),GFP_KERNEL ))) + chip =kzalloc (sizeof (struct snd_riptide ),GFP_KERNEL ); +if (!chip)return -ENOMEM ;spin_lock_init (&chip->lock);
@@ -1845,8 +1856,8 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci, chip->handled_irqs =0 ; chip->cif =NULL ; -if ((chip->res_port = -request_region (chip->port,64 ,"RIPTIDE" )) ==NULL ) { + chip->res_port =request_region (chip->port,64 ,"RIPTIDE" ); +if (!chip->res_port) {snd_printk (KERN_ERR "Riptide: unable to grab region 0x%lx-0x%lx\n" , chip->port, chip->port +64 -1 );
@@ -1868,12 +1879,14 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci, card->sync_irq = chip->irq; chip->device_id = pci->device;pci_set_master (pci); -if ((err =snd_riptide_initialize (chip)) <0 ) { + err =snd_riptide_initialize (chip); +if (err <0 ) {snd_riptide_free (chip);return err; } -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (err <0 ) {snd_riptide_free (chip);return err; }
@@ -1903,7 +1916,8 @@ snd_riptide_proc_read(struct snd_info_entry *entry,for (i =0 ; i <64 ; i +=4 )snd_iprintf (buffer,"%c%02x: %08x" , (i %16 ) ?' ' :'\n' , i,inl (chip->port + i)); -if ((cif = chip->cif)) { + cif = chip->cif; +if (cif) { snd_iprintf(buffer, "\nVersion: ASIC: %d CODEC: %d AUXDSP: %d PROG: %d", chip->firmware.firmware.ASIC,
@@ -1922,10 +1936,11 @@ snd_riptide_proc_read(struct snd_info_entry *entry, }snd_iprintf (buffer,"\nOpen streams %d:\n" , chip->openstreams);for (i =0 ; i <PLAYBACK_SUBSTREAMS ; i++) { -if (chip->playback_substream[i] - && chip->playback_substream[i]->runtime - && (data = - chip->playback_substream[i]->runtime->private_data)) { +if (!chip->playback_substream[i] || + !chip->playback_substream[i]->runtime) +continue ; + data = chip->playback_substream[i]->runtime->private_data; +if (data) { snd_iprintf(buffer, "stream: %d mixer: %d source: %d (%d,%d)\n", data->id, data->mixer, data->source,
@@ -1934,15 +1949,16 @@ snd_riptide_proc_read(struct snd_info_entry *entry,snd_iprintf (buffer,"rate: %d\n" , rate); } } -if (chip->capture_substream - && chip->capture_substream->runtime - && (data = chip->capture_substream->runtime->private_data)) { -snd_iprintf (buffer, -"stream: %d mixer: %d source: %d (%d,%d)\n" , - data->id, data->mixer, - data->source, data->intdec[0 ], data->intdec[1 ]); -if (!(getsamplerate (cif, data->intdec, &rate))) -snd_iprintf (buffer,"rate: %d\n" , rate); +if (chip->capture_substream && chip->capture_substream->runtime) { + data = chip->capture_substream->runtime->private_data; +if (data) { +snd_iprintf (buffer, +"stream: %d mixer: %d source: %d (%d,%d)\n" , + data->id, data->mixer, + data->source, data->intdec[0 ], data->intdec[1 ]); +if (!(getsamplerate (cif, data->intdec, &rate))) +snd_iprintf (buffer,"rate: %d\n" , rate); + } }snd_iprintf (buffer,"Paths:\n" ); i =getpaths (cif, p);
@@ -1973,12 +1989,14 @@ static int snd_riptide_mixer(struct snd_riptide *chip) ac97.private_data = chip; ac97.scaps =AC97_SCAP_SKIP_MODEM ; -if ((err =snd_ac97_bus (chip->card,0 , &ops, chip, &pbus)) <0 ) + err =snd_ac97_bus (chip->card,0 , &ops, chip, &pbus); +if (err <0 )return err; chip->ac97_bus = pbus; ac97.pci = chip->pci; -if ((err =snd_ac97_mixer (pbus, &ac97, &chip->ac97)) <0 ) + err =snd_ac97_mixer (pbus, &ac97, &chip->ac97); +if (err <0 )return err;return err; }
Signature · 1 line
2.26.2
PATCH 48/66 ALSA: hdsp: Fix assignment in if condition
In reply to Takashi IwaiPCI HDSP driver 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.
--- sound/pci/rme9652/hdsp.c | 121 ++++++++++++++++++++++++++------------- 1 file changed, 82 insertions(+), 39 deletions(-)
sound/pci/rme9652/hdsp.c +82 -39
@@ -1318,11 +1318,13 @@ static int snd_hdsp_midi_output_write (struct hdsp_midi *hmidi)spin_lock_irqsave (&hmidi->lock, flags);if (hmidi->output) {if (!snd_rawmidi_transmit_empty (hmidi->output)) { -if ((n_pending =snd_hdsp_midi_output_possible (hmidi->hdsp, hmidi->id)) >0 ) { + n_pending =snd_hdsp_midi_output_possible (hmidi->hdsp, hmidi->id); +if (n_pending >0 ) {if (n_pending > (int )sizeof (buf)) n_pending =sizeof (buf); -if ((to_write =snd_rawmidi_transmit (hmidi->output, buf, n_pending)) >0 ) { + to_write =snd_rawmidi_transmit (hmidi->output, buf, n_pending); +if (to_write >0 ) {for (i =0 ; i < to_write; ++i)snd_hdsp_midi_write_byte (hmidi->hdsp, hmidi->id, buf[i]); }
@@ -1341,7 +1343,8 @@ static int snd_hdsp_midi_input_read (struct hdsp_midi *hmidi)int i;spin_lock_irqsave (&hmidi->lock, flags); -if ((n_pending =snd_hdsp_midi_input_available (hmidi->hdsp, hmidi->id)) >0 ) { + n_pending =snd_hdsp_midi_input_available (hmidi->hdsp, hmidi->id); +if (n_pending >0 ) {if (hmidi->input) {if (n_pending > (int )sizeof (buf)) n_pending =sizeof (buf);
@@ -3322,7 +3325,9 @@ static int snd_hdsp_create_controls(struct snd_card *card, struct hdsp *hdsp) }for (idx =0 ; idx <ARRAY_SIZE (snd_hdsp_controls); idx++) { -if ((err =snd_ctl_add (card, kctl =snd_ctl_new1 (&snd_hdsp_controls[idx], hdsp))) <0 ) + kctl =snd_ctl_new1 (&snd_hdsp_controls[idx], hdsp); + err =snd_ctl_add (card, kctl); +if (err <0 )return err;if (idx ==1 )/* IEC958 (S/PDIF) Stream */ hdsp->spdif_ctl = kctl;
@@ -3331,12 +3336,16 @@ static int snd_hdsp_create_controls(struct snd_card *card, struct hdsp *hdsp)/* ADAT SyncCheck status */ snd_hdsp_adat_sync_check.name ="ADAT Lock Status" ; snd_hdsp_adat_sync_check.index =1 ; -if ((err =snd_ctl_add (card, kctl =snd_ctl_new1 (&snd_hdsp_adat_sync_check, hdsp)))) + kctl =snd_ctl_new1 (&snd_hdsp_adat_sync_check, hdsp); + err =snd_ctl_add (card, kctl); +if (err <0 )return err;if (hdsp->io_type == Digiface || hdsp->io_type ==H9652 ) {for (idx =1 ; idx <3 ; ++idx) { snd_hdsp_adat_sync_check.index = idx+1 ; -if ((err =snd_ctl_add (card, kctl =snd_ctl_new1 (&snd_hdsp_adat_sync_check, hdsp)))) + kctl =snd_ctl_new1 (&snd_hdsp_adat_sync_check, hdsp); + err =snd_ctl_add (card, kctl); +if (err <0 )return err; } }
@@ -3344,7 +3353,9 @@ static int snd_hdsp_create_controls(struct snd_card *card, struct hdsp *hdsp)/* DA, AD and Phone gain and XLR breakout cable controls for H9632 cards */ if (hdsp->io_type ==H9632 ) {for (idx =0 ; idx <ARRAY_SIZE (snd_hdsp_9632_controls); idx++) { -if ((err =snd_ctl_add (card, kctl =snd_ctl_new1 (&snd_hdsp_9632_controls[idx], hdsp))) <0 ) + kctl =snd_ctl_new1 (&snd_hdsp_9632_controls[idx], hdsp); + err =snd_ctl_add (card, kctl); +if (err <0 )return err; } }
@@ -3362,8 +3373,10 @@ static int snd_hdsp_create_controls(struct snd_card *card, struct hdsp *hdsp)/* AEB control for H96xx card */ if (hdsp->io_type ==H9632 || hdsp->io_type ==H9652 ) { -if ((err =snd_ctl_add (card, kctl =snd_ctl_new1 (&snd_hdsp_96xx_aeb, hdsp))) <0 ) -return err; + kctl =snd_ctl_new1 (&snd_hdsp_96xx_aeb, hdsp); + err =snd_ctl_add (card, kctl); +if (err <0 ) +return err; }return 0 ;
@@ -3942,7 +3955,8 @@ static char *hdsp_channel_buffer_location(struct hdsp *hdsp,if (snd_BUG_ON (channel <0 || channel >= hdsp->max_channels))return NULL ; -if ((mapped_channel = hdsp->channel_map[channel]) <0 ) + mapped_channel = hdsp->channel_map[channel]; +if (mapped_channel <0 )return NULL ;if (stream ==SNDRV_PCM_STREAM_CAPTURE )
@@ -4114,7 +4128,8 @@ static int snd_hdsp_hw_params(struct snd_pcm_substream *substream,spin_lock_irq (&hdsp->lock);if (! hdsp->clock_source_locked) { -if ((err =hdsp_set_rate (hdsp,params_rate (params),0 )) <0 ) { + err =hdsp_set_rate (hdsp,params_rate (params),0 ); +if (err <0 ) {spin_unlock_irq (&hdsp->lock);_snd_pcm_hw_param_setempty (params,SNDRV_PCM_HW_PARAM_RATE );return err;
@@ -4122,7 +4137,8 @@ static int snd_hdsp_hw_params(struct snd_pcm_substream *substream, }spin_unlock_irq (&hdsp->lock); -if ((err =hdsp_set_interrupt_interval (hdsp,params_period_size (params))) <0 ) { + err =hdsp_set_interrupt_interval (hdsp,params_period_size (params)); +if (err <0 ) {_snd_pcm_hw_param_setempty (params,SNDRV_PCM_HW_PARAM_PERIOD_SIZE );return err; }
@@ -4854,13 +4870,15 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigneif (hdsp->io_type ==H9652 || hdsp->io_type ==H9632 )return -EINVAL ;if (hdsp->io_type == Undefined) { -if ((err =hdsp_get_iobox_version (hdsp)) <0 ) + err =hdsp_get_iobox_version (hdsp); +if (err <0 )return err; }memset (&hdsp_version,0 ,sizeof (hdsp_version)); hdsp_version.io_type = hdsp->io_type; hdsp_version.firmware_rev = hdsp->firmware_rev; -if ((err =copy_to_user (argp, &hdsp_version,sizeof (hdsp_version)))) + err =copy_to_user (argp, &hdsp_version,sizeof (hdsp_version)); +if (err <0 )return -EFAULT ;break ; }
@@ -4900,17 +4918,20 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne hdsp->state |= HDSP_FirmwareCached; -if ((err =snd_hdsp_load_firmware_from_cache (hdsp)) <0 ) + err =snd_hdsp_load_firmware_from_cache (hdsp); +if (err <0 )return err;if (!(hdsp->state & HDSP_InitializationComplete)) { -if ((err =snd_hdsp_enable_io (hdsp)) <0 ) + err =snd_hdsp_enable_io (hdsp); +if (err <0 )return err;snd_hdsp_initialize_channels (hdsp);snd_hdsp_initialize_midi_flush (hdsp); -if ((err =snd_hdsp_create_alsa_devices (hdsp->card, hdsp)) <0 ) { + err =snd_hdsp_create_alsa_devices (hdsp->card, hdsp); +if (err <0 ) {dev_err (hdsp->card->dev,"error creating alsa devices\n" );return err;
@@ -4960,7 +4981,8 @@ static int snd_hdsp_create_hwdep(struct snd_card *card, struct hdsp *hdsp)struct snd_hwdep *hw;int err; -if ((err =snd_hwdep_new (card,"HDSP hwdep" ,0 , &hw)) <0 ) + err =snd_hwdep_new (card,"HDSP hwdep" ,0 , &hw); +if (err <0 )return err; hdsp->hwdep = hw;
@@ -4978,7 +5000,8 @@ static int snd_hdsp_create_pcm(struct snd_card *card, struct hdsp *hdsp)struct snd_pcm *pcm;int err; -if ((err =snd_pcm_new (card, hdsp->card_name,0 ,1 ,1 , &pcm)) <0 ) + err =snd_pcm_new (card, hdsp->card_name,0 ,1 ,1 , &pcm); +if (err <0 )return err; hdsp->pcm = pcm;
@@ -5084,28 +5107,32 @@ static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp {int err; -if ((err =snd_hdsp_create_pcm (card, hdsp)) <0 ) { + err =snd_hdsp_create_pcm (card, hdsp); +if (err <0 ) {dev_err (card->dev,"Error creating pcm interface\n" );return err; } -if ((err =snd_hdsp_create_midi (card, hdsp,0 )) <0 ) { + err =snd_hdsp_create_midi (card, hdsp,0 ); +if (err <0 ) {dev_err (card->dev,"Error creating first midi interface\n" );return err; }if (hdsp->io_type == Digiface || hdsp->io_type ==H9652 ) { -if ((err =snd_hdsp_create_midi (card, hdsp,1 )) <0 ) { + err =snd_hdsp_create_midi (card, hdsp,1 ); +if (err <0 ) {dev_err (card->dev,"Error creating second midi interface\n" );return err; } } -if ((err =snd_hdsp_create_controls (card, hdsp)) <0 ) { + err =snd_hdsp_create_controls (card, hdsp); +if (err <0 ) {dev_err (card->dev,"Error creating ctl interface\n" );return err;
@@ -5119,7 +5146,8 @@ static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp hdsp->capture_substream =NULL ; hdsp->playback_substream =NULL ; -if ((err =snd_hdsp_set_defaults (hdsp)) <0 ) { + err =snd_hdsp_set_defaults (hdsp); +if (err <0 ) {dev_err (card->dev,"Error setting default values\n" );return err;
@@ -5130,7 +5158,8 @@ static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdspsprintf (card->longname,"%s at 0x%lx, irq %d" , hdsp->card_name, hdsp->port, hdsp->irq); -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {dev_err (card->dev,"error registering card\n" );return err;
@@ -5151,7 +5180,8 @@ static int hdsp_request_fw_loader(struct hdsp *hdsp)if (hdsp->io_type ==H9652 || hdsp->io_type ==H9632 )return 0 ;if (hdsp->io_type == Undefined) { -if ((err =hdsp_get_iobox_version (hdsp)) <0 ) + err =hdsp_get_iobox_version (hdsp); +if (err <0 )return err;if (hdsp->io_type ==H9652 || hdsp->io_type ==H9632 )return 0 ;
@@ -5197,21 +5227,25 @@ static int hdsp_request_fw_loader(struct hdsp *hdsp) hdsp->state |= HDSP_FirmwareCached; -if ((err =snd_hdsp_load_firmware_from_cache (hdsp)) <0 ) + err =snd_hdsp_load_firmware_from_cache (hdsp); +if (err <0 )return err;if (!(hdsp->state & HDSP_InitializationComplete)) { -if ((err =snd_hdsp_enable_io (hdsp)) <0 ) + err =snd_hdsp_enable_io (hdsp); +if (err <0 )return err; -if ((err =snd_hdsp_create_hwdep (hdsp->card, hdsp)) <0 ) { + err =snd_hdsp_create_hwdep (hdsp->card, hdsp); +if (err <0 ) {dev_err (hdsp->card->dev,"error creating hwdep device\n" );return err; }snd_hdsp_initialize_channels (hdsp);snd_hdsp_initialize_midi_flush (hdsp); -if ((err =snd_hdsp_create_alsa_devices (hdsp->card, hdsp)) <0 ) { + err =snd_hdsp_create_alsa_devices (hdsp->card, hdsp); +if (err <0 ) {dev_err (hdsp->card->dev,"error creating alsa devices\n" );return err;
@@ -5280,15 +5314,18 @@ static int snd_hdsp_create(struct snd_card *card, is_9632 =1 ; } -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err;pci_set_master (hdsp->pci); -if ((err =pci_request_regions (pci,"hdsp" )) <0 ) + err =pci_request_regions (pci,"hdsp" ); +if (err <0 )return err; hdsp->port =pci_resource_start (pci,0 ); -if ((hdsp->iobase =ioremap (hdsp->port,HDSP_IO_EXTENT )) ==NULL ) { + hdsp->iobase =ioremap (hdsp->port,HDSP_IO_EXTENT ); +if (!hdsp->iobase) {dev_err (hdsp->card->dev,"unable to remap region 0x%lx-0x%lx\n" , hdsp->port, hdsp->port +HDSP_IO_EXTENT -1 );return -EBUSY ;
@@ -5306,7 +5343,8 @@ static int snd_hdsp_create(struct snd_card *card, hdsp->use_midi_work =1 ; hdsp->dds_value =0 ; -if ((err =snd_hdsp_initialize_memory (hdsp)) <0 ) + err =snd_hdsp_initialize_memory (hdsp); +if (err <0 )return err;if (!is_9652 && !is_9632) {
@@ -5318,7 +5356,8 @@ static int snd_hdsp_create(struct snd_card *card,return err;if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) !=0 ) { -if ((err =hdsp_request_fw_loader (hdsp)) <0 ) + err =hdsp_request_fw_loader (hdsp); +if (err <0 )/* we don't fail as this can happen if userspace is not ready for firmware upload
@@ -5331,7 +5370,8 @@ static int snd_hdsp_create(struct snd_card *card,/* we defer initialization */ dev_info (hdsp->card->dev,"card initialization pending : waiting for firmware\n" ); -if ((err =snd_hdsp_create_hwdep (card, hdsp)) <0 ) + err =snd_hdsp_create_hwdep (card, hdsp); +if (err <0 )return err;return 0 ; }else {
@@ -5346,7 +5386,8 @@ static int snd_hdsp_create(struct snd_card *card, } } -if ((err =snd_hdsp_enable_io (hdsp)) !=0 ) + err =snd_hdsp_enable_io (hdsp); +if (err)return err;if (is_9652)
@@ -5355,7 +5396,8 @@ static int snd_hdsp_create(struct snd_card *card,if (is_9632) hdsp->io_type =H9632 ; -if ((err =snd_hdsp_create_hwdep (card, hdsp)) <0 ) + err =snd_hdsp_create_hwdep (card, hdsp); +if (err <0 )return err;snd_hdsp_initialize_channels (hdsp);
@@ -5363,7 +5405,8 @@ static int snd_hdsp_create(struct snd_card *card, hdsp->state |= HDSP_FirmwareLoaded; -if ((err =snd_hdsp_create_alsa_devices (card, hdsp)) <0 ) + err =snd_hdsp_create_alsa_devices (card, hdsp); +if (err <0 )return err;return 0 ;
Signature · 1 line
2.26.2
PATCH 49/66 ALSA: rme9652: Fix assignment in if condition
In reply to Takashi IwaiPCI RME9652 driver 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.
--- sound/pci/rme9652/rme9652.c | 98 +++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 47 deletions(-)
sound/pci/rme9652/rme9652.c +51 -47
@@ -433,9 +433,9 @@ static int rme9652_set_interrupt_interval(struct snd_rme9652 *s,spin_lock_irq (&s->lock); -if ((restart = s->running)) { + restart = s->running; +if (restart)rme9652_stop (s); - } frames >>=7 ; n =0 ;
@@ -518,16 +518,15 @@ static int rme9652_set_rate(struct snd_rme9652 *rme9652, int rate)return -EBUSY ; } -if ((restart = rme9652->running)) { + restart = rme9652->running; +if (restart)rme9652_stop (rme9652); - } rme9652->control_register &= ~(RME9652_freq |RME9652_DS ); rme9652->control_register |= rate;rme9652_write (rme9652, RME9652_control_register, rme9652->control_register); -if (restart) { +if (restart)rme9652_start (rme9652); - }if (rate &RME9652_DS ) {if (rme9652->ss_channels ==RME9652_NCHANNELS ) {
@@ -878,15 +877,14 @@ static int rme9652_set_adat1_input(struct snd_rme9652 *rme9652, int internal)/* XXX do we actually need to stop the card when we do this ? */ -if ((restart = rme9652->running)) { + restart = rme9652->running; +if (restart)rme9652_stop (rme9652); - }rme9652_write (rme9652, RME9652_control_register, rme9652->control_register); -if (restart) { +if (restart)rme9652_start (rme9652); - }return 0 ; }
@@ -943,15 +941,14 @@ static int rme9652_set_spdif_input(struct snd_rme9652 *rme9652, int in) rme9652->control_register &= ~RME9652_inp; rme9652->control_register |=rme9652_encode_spdif_in (in); -if ((restart = rme9652->running)) { + restart = rme9652->running; +if (restart)rme9652_stop (rme9652); - }rme9652_write (rme9652, RME9652_control_register, rme9652->control_register); -if (restart) { +if (restart)rme9652_start (rme9652); - }return 0 ; }
@@ -1010,15 +1007,14 @@ static int rme9652_set_spdif_output(struct snd_rme9652 *rme9652, int out) rme9652->control_register &= ~RME9652_opt_out; } -if ((restart = rme9652->running)) { + restart = rme9652->running; +if (restart)rme9652_stop (rme9652); - }rme9652_write (rme9652, RME9652_control_register, rme9652->control_register); -if (restart) { +if (restart)rme9652_start (rme9652); - }return 0 ; }
@@ -1086,15 +1082,14 @@ static int rme9652_set_sync_mode(struct snd_rme9652 *rme9652, int mode)break ; } -if ((restart = rme9652->running)) { + restart = rme9652->running; +if (restart)rme9652_stop (rme9652); - }rme9652_write (rme9652, RME9652_control_register, rme9652->control_register); -if (restart) { +if (restart)rme9652_start (rme9652); - }return 0 ; }
@@ -1173,15 +1168,14 @@ static int rme9652_set_sync_pref(struct snd_rme9652 *rme9652, int pref)break ; } -if ((restart = rme9652->running)) { + restart = rme9652->running; +if (restart)rme9652_stop (rme9652); - }rme9652_write (rme9652, RME9652_control_register, rme9652->control_register); -if (restart) { +if (restart)rme9652_start (rme9652); - }return 0 ; }
@@ -1513,19 +1507,27 @@ static int snd_rme9652_create_controls(struct snd_card *card, struct snd_rme9652struct snd_kcontrol *kctl;for (idx =0 ; idx <ARRAY_SIZE (snd_rme9652_controls); idx++) { -if ((err =snd_ctl_add (card, kctl =snd_ctl_new1 (&snd_rme9652_controls[idx], rme9652))) <0 ) + kctl =snd_ctl_new1 (&snd_rme9652_controls[idx], rme9652); + err =snd_ctl_add (card, kctl); +if (err <0 )return err;if (idx ==1 )/* IEC958 (S/PDIF) Stream */ rme9652->spdif_ctl = kctl; } -if (rme9652->ss_channels ==RME9652_NCHANNELS ) -if ((err =snd_ctl_add (card, kctl =snd_ctl_new1 (&snd_rme9652_adat3_check, rme9652))) <0 ) +if (rme9652->ss_channels ==RME9652_NCHANNELS ) { + kctl =snd_ctl_new1 (&snd_rme9652_adat3_check, rme9652); + err =snd_ctl_add (card, kctl); +if (err <0 )return err; + } -if (rme9652->hw_rev >=15 ) -if ((err =snd_ctl_add (card, kctl =snd_ctl_new1 (&snd_rme9652_adat1_input, rme9652))) <0 ) +if (rme9652->hw_rev >=15 ) { + kctl =snd_ctl_new1 (&snd_rme9652_adat1_input, rme9652); + err =snd_ctl_add (card, kctl); +if (err <0 )return err; + }return 0 ; }
@@ -1842,9 +1844,9 @@ static char *rme9652_channel_buffer_location(struct snd_rme9652 *rme9652,if (snd_BUG_ON (channel <0 || channel >=RME9652_NCHANNELS ))return NULL ; -if ((mapped_channel = rme9652->channel_map[channel]) <0 ) { + mapped_channel = rme9652->channel_map[channel]; +if (mapped_channel <0 )return NULL ; - }if (stream ==SNDRV_PCM_STREAM_CAPTURE ) { return rme9652->capture_buffer +
@@ -2021,12 +2023,14 @@ static int snd_rme9652_hw_params(struct snd_pcm_substream *substream,/* how to make sure that the rate matches an externally-set one ? */ -if ((err =rme9652_set_rate (rme9652,params_rate (params))) <0 ) { + err =rme9652_set_rate (rme9652,params_rate (params)); +if (err <0 ) {_snd_pcm_hw_param_setempty (params,SNDRV_PCM_HW_PARAM_RATE );return err; } -if ((err =rme9652_set_interrupt_interval (rme9652,params_period_size (params))) <0 ) { + err =rme9652_set_interrupt_interval (rme9652,params_period_size (params)); +if (err <0 ) {_snd_pcm_hw_param_setempty (params,SNDRV_PCM_HW_PARAM_PERIOD_SIZE );return err; }
@@ -2406,11 +2410,9 @@ static int snd_rme9652_create_pcm(struct snd_card *card,struct snd_pcm *pcm;int err; -if ((err =snd_pcm_new (card, - rme9652->card_name, -0 ,1 ,1 , &pcm)) <0 ) { + err =snd_pcm_new (card, rme9652->card_name,0 ,1 ,1 , &pcm); +if (err <0 )return err; - } rme9652->pcm = pcm; pcm->private_data = rme9652;
@@ -2450,12 +2452,14 @@ static int snd_rme9652_create(struct snd_card *card,return -ENODEV ; } -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err;spin_lock_init (&rme9652->lock); -if ((err =pci_request_regions (pci,"rme9652" )) <0 ) + err =pci_request_regions (pci,"rme9652" ); +if (err <0 )return err; rme9652->port =pci_resource_start (pci,0 ); rme9652->iobase =ioremap (rme9652->port,RME9652_IO_EXTENT );
@@ -2528,17 +2532,17 @@ static int snd_rme9652_create(struct snd_card *card,pci_set_master (rme9652->pci); -if ((err =snd_rme9652_initialize_memory (rme9652)) <0 ) { + err =snd_rme9652_initialize_memory (rme9652); +if (err <0 )return err; - } -if ((err =snd_rme9652_create_pcm (card, rme9652)) <0 ) { + err =snd_rme9652_create_pcm (card, rme9652); +if (err <0 )return err; - } -if ((err =snd_rme9652_create_controls (card, rme9652)) <0 ) { + err =snd_rme9652_create_controls (card, rme9652); +if (err <0 )return err; - }snd_rme9652_proc_init (rme9652);
Signature · 1 line
2.26.2
PATCH 50/66 ALSA: trident: Fix assignment in if condition
In reply to Takashi IwaiPCI Trident driver 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.
--- sound/pci/trident/trident.c | 41 +++++++++------- sound/pci/trident/trident_main.c | 84 ++++++++++++++++++++++---------- 2 files changed, 81 insertions(+), 44 deletions(-)
sound/pci/trident/trident.c +24 -17
@@ -67,11 +67,12 @@ static int snd_trident_probe(struct pci_dev *pci,if (err <0 )return err; -if ((err =snd_trident_create (card, pci, - pcm_channels[dev], - ((pci->vendor <<16 ) | pci->device) ==TRIDENT_DEVICE_ID_SI7018 ?1 :2 , - wavetable_size[dev], - &trident)) <0 ) { + err =snd_trident_create (card, pci, + pcm_channels[dev], + ((pci->vendor <<16 ) | pci->device) ==TRIDENT_DEVICE_ID_SI7018 ?1 :2 , + wavetable_size[dev], + &trident); +if (err <0 ) {snd_card_free (card);return err; }
@@ -100,38 +101,44 @@ static int snd_trident_probe(struct pci_dev *pci,sprintf (card->longname,"%s PCI Audio at 0x%lx, irq %d" , card->shortname, trident->port, trident->irq); -if ((err =snd_trident_pcm (trident, pcm_dev++)) <0 ) { + err =snd_trident_pcm (trident, pcm_dev++); +if (err <0 ) {snd_card_free (card);return err; }switch (trident->device) {case TRIDENT_DEVICE_ID_DX :case TRIDENT_DEVICE_ID_NX : -if ((err =snd_trident_foldback_pcm (trident, pcm_dev++)) <0 ) { + err =snd_trident_foldback_pcm (trident, pcm_dev++); +if (err <0 ) {snd_card_free (card);return err; }break ; }if (trident->device ==TRIDENT_DEVICE_ID_NX || trident->device ==TRIDENT_DEVICE_ID_SI7018 ) { -if ((err =snd_trident_spdif_pcm (trident, pcm_dev++)) <0 ) { + err =snd_trident_spdif_pcm (trident, pcm_dev++); +if (err <0 ) {snd_card_free (card);return err; } } -if (trident->device !=TRIDENT_DEVICE_ID_SI7018 && - (err =snd_mpu401_uart_new (card,0 ,MPU401_HW_TRID4DWAVE , - trident->midi_port, -MPU401_INFO_INTEGRATED | -MPU401_INFO_IRQ_HOOK , --1 , &trident->rmidi)) <0 ) { -snd_card_free (card); -return err; +if (trident->device !=TRIDENT_DEVICE_ID_SI7018 ) { + err =snd_mpu401_uart_new (card,0 ,MPU401_HW_TRID4DWAVE , + trident->midi_port, +MPU401_INFO_INTEGRATED | +MPU401_INFO_IRQ_HOOK , +-1 , &trident->rmidi); +if (err <0 ) { +snd_card_free (card); +return err; + } }snd_trident_create_gameport (trident); -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_card_free (card);return err; }
sound/pci/trident/trident_main.c +57 -27
200 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 51/66 ALSA: vx222: Fix assignment in if condition
In reply to Takashi IwaiPCI VX222 driver 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.
--- sound/pci/vx222/vx222.c | 18 ++++++++++++------ sound/pci/vx222/vx222_ops.c | 12 ++++++++---- 2 files changed, 20 insertions(+), 10 deletions(-)
sound/pci/vx222/vx222.c +12 -6
@@ -133,7 +133,8 @@ static int snd_vx222_create(struct snd_card *card, struct pci_dev *pci,const struct snd_vx_ops *vx_ops;/* enable PCI device */ -if ((err =pci_enable_device (pci)) <0 ) + err =pci_enable_device (pci); +if (err <0 )return err;pci_set_master (pci);
@@ -147,7 +148,8 @@ static int snd_vx222_create(struct snd_card *card, struct pci_dev *pci, vx =to_vx222 (chip); vx->pci = pci; -if ((err =pci_request_regions (pci,CARD_NAME )) <0 ) { + err =pci_request_regions (pci,CARD_NAME ); +if (err <0 ) {snd_vx222_free (chip);return err; }
@@ -164,7 +166,8 @@ static int snd_vx222_create(struct snd_card *card, struct pci_dev *pci, chip->irq = pci->irq; card->sync_irq = chip->irq; -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (err <0 ) {snd_vx222_free (chip);return err; }
@@ -207,7 +210,8 @@ static int snd_vx222_probe(struct pci_dev *pci, hw = &vx222_v2_hw;break ; } -if ((err =snd_vx222_create (card, pci, hw, &vx)) <0 ) { + err =snd_vx222_create (card, pci, hw, &vx); +if (err <0 ) {snd_card_free (card);return err; }
@@ -223,12 +227,14 @@ static int snd_vx222_probe(struct pci_dev *pci, vx->core.dev = &pci->dev;#endif -if ((err =snd_vx_setup_firmware (&vx->core)) <0 ) { + err =snd_vx_setup_firmware (&vx->core); +if (err <0 ) {snd_card_free (card);return err; } -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_card_free (card);return err; }
sound/pci/vx222/vx222_ops.c +8 -4
@@ -408,9 +408,11 @@ static int vx2_load_dsp(struct vx_core *vx, int index, const struct firmware *dsswitch (index) {case 1 :/* xilinx image */ -if ((err =vx2_load_xilinx_binary (vx, dsp)) <0 ) + err =vx2_load_xilinx_binary (vx, dsp); +if (err <0 )return err; -if ((err =vx2_test_xilinx (vx)) <0 ) + err =vx2_test_xilinx (vx); +if (err <0 )return err;return 0 ;case 2 :
@@ -972,9 +974,11 @@ static int vx2_add_mic_controls(struct vx_core *_chip)vx2_set_input_level (chip);/* controls */ -if ((err =snd_ctl_add (_chip->card,snd_ctl_new1 (&vx_control_input_level, chip))) <0 ) + err =snd_ctl_add (_chip->card,snd_ctl_new1 (&vx_control_input_level, chip)); +if (err <0 )return err; -if ((err =snd_ctl_add (_chip->card,snd_ctl_new1 (&vx_control_mic_level, chip))) <0 ) + err =snd_ctl_add (_chip->card,snd_ctl_new1 (&vx_control_mic_level, chip)); +if (err <0 )return err;return 0 ;
Signature · 1 line
2.26.2
PATCH 52/66 ALSA: ymfpci: Fix assignment in if condition
In reply to Takashi IwaiPCI YMFPCI driver 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.
--- sound/pci/ymfpci/ymfpci.c | 71 +++++++++++++++++++-------------- sound/pci/ymfpci/ymfpci_main.c | 72 +++++++++++++++++++++++----------- 2 files changed, 91 insertions(+), 52 deletions(-)
sound/pci/ymfpci/ymfpci.c +42 -29
@@ -72,7 +72,8 @@ static int snd_ymfpci_create_gameport(struct snd_ymfpci *chip, int dev,if (io_port ==1 ) {/* auto-detect */ -if (!(io_port =pci_resource_start (chip->pci,2 ))) + io_port =pci_resource_start (chip->pci,2 ); +if (!io_port)return -ENODEV ; } }else {
@@ -81,7 +82,8 @@ static int snd_ymfpci_create_gameport(struct snd_ymfpci *chip, int dev,for (io_port =0x201 ; io_port <=0x205 ; io_port++) {if (io_port ==0x203 )continue ; -if ((r =request_region (io_port,1 ,"YMFPCI gameport" )) !=NULL ) + r =request_region (io_port,1 ,"YMFPCI gameport" ); +if (r)break ; }if (!r) {
@@ -102,10 +104,13 @@ static int snd_ymfpci_create_gameport(struct snd_ymfpci *chip, int dev, } } -if (!r && !(r =request_region (io_port,1 ,"YMFPCI gameport" ))) { -dev_err (chip->card->dev, -"joystick port %#x is in use.\n" , io_port); -return -EBUSY ; +if (!r) { + r =request_region (io_port,1 ,"YMFPCI gameport" ); +if (!r) { +dev_err (chip->card->dev, +"joystick port %#x is in use.\n" , io_port); +return -EBUSY ; + } } chip->gameport = gp =gameport_allocate_port ();
@@ -193,8 +198,9 @@ static int snd_card_ymfpci_probe(struct pci_dev *pci,/* auto-detect */ fm_port[dev] =pci_resource_start (pci,1 ); } -if (fm_port[dev] >0 && - (fm_res =request_region (fm_port[dev],4 ,"YMFPCI OPL3" )) !=NULL ) { +if (fm_port[dev] >0 ) + fm_res =request_region (fm_port[dev],4 ,"YMFPCI OPL3" ); +if (fm_res) { legacy_ctrl |=YMFPCI_LEGACY_FMEN ;pci_write_config_word (pci,PCIR_DSXG_FMBASE , fm_port[dev]); }
@@ -202,8 +208,9 @@ static int snd_card_ymfpci_probe(struct pci_dev *pci,/* auto-detect */ mpu_port[dev] =pci_resource_start (pci,1 ) +0x20 ; } -if (mpu_port[dev] >0 && - (mpu_res =request_region (mpu_port[dev],2 ,"YMFPCI MPU401" )) !=NULL ) { +if (mpu_port[dev] >0 ) + mpu_res =request_region (mpu_port[dev],2 ,"YMFPCI MPU401" ); +if (mpu_res) { legacy_ctrl |=YMFPCI_LEGACY_MEN ;pci_write_config_word (pci,PCIR_DSXG_MPU401BASE , mpu_port[dev]); }
@@ -215,8 +222,9 @@ static int snd_card_ymfpci_probe(struct pci_dev *pci,case 0x3a8 : legacy_ctrl2 |=3 ;break ;default : fm_port[dev] =0 ;break ; } -if (fm_port[dev] >0 && - (fm_res =request_region (fm_port[dev],4 ,"YMFPCI OPL3" )) !=NULL ) { +if (fm_port[dev] >0 ) + fm_res =request_region (fm_port[dev],4 ,"YMFPCI OPL3" ); +if (fm_res) { legacy_ctrl |=YMFPCI_LEGACY_FMEN ; }else { legacy_ctrl2 &= ~YMFPCI_LEGACY2_FMIO ;
@@ -229,8 +237,9 @@ static int snd_card_ymfpci_probe(struct pci_dev *pci,case 0x334 : legacy_ctrl2 |=3 <<4 ;break ;default : mpu_port[dev] =0 ;break ; } -if (mpu_port[dev] >0 && - (mpu_res =request_region (mpu_port[dev],2 ,"YMFPCI MPU401" )) !=NULL ) { +if (mpu_port[dev] >0 ) + mpu_res =request_region (mpu_port[dev],2 ,"YMFPCI MPU401" ); +if (mpu_res) { legacy_ctrl |=YMFPCI_LEGACY_MEN ; }else { legacy_ctrl2 &= ~YMFPCI_LEGACY2_MPUIO ;
@@ -244,9 +253,8 @@ static int snd_card_ymfpci_probe(struct pci_dev *pci,pci_read_config_word (pci,PCIR_DSXG_LEGACY , &old_legacy_ctrl);pci_write_config_word (pci,PCIR_DSXG_LEGACY , legacy_ctrl);pci_write_config_word (pci,PCIR_DSXG_ELEGACY , legacy_ctrl2); -if ((err =snd_ymfpci_create (card, pci, - old_legacy_ctrl, - &chip)) <0 ) { + err =snd_ymfpci_create (card, pci, old_legacy_ctrl, &chip); +if (err <0 ) {release_and_free_resource (mpu_res);release_and_free_resource (fm_res); goto free_card;
@@ -287,11 +295,12 @@ static int snd_card_ymfpci_probe(struct pci_dev *pci, goto free_card;if (chip->mpu_res) { -if ((err =snd_mpu401_uart_new (card,0 ,MPU401_HW_YMFPCI , - mpu_port[dev], -MPU401_INFO_INTEGRATED | -MPU401_INFO_IRQ_HOOK , --1 , &chip->rawmidi)) <0 ) { + err =snd_mpu401_uart_new (card,0 ,MPU401_HW_YMFPCI , + mpu_port[dev], +MPU401_INFO_INTEGRATED | +MPU401_INFO_IRQ_HOOK , +-1 , &chip->rawmidi); +if (err <0 ) {dev_warn (card->dev,"cannot initialize MPU401 at 0x%lx, skipping...\n" , mpu_port[dev]);
@@ -300,18 +309,22 @@ static int snd_card_ymfpci_probe(struct pci_dev *pci, } }if (chip->fm_res) { -if ((err =snd_opl3_create (card, - fm_port[dev], - fm_port[dev] +2 , -OPL3_HW_OPL3 ,1 , &opl3)) <0 ) { + err =snd_opl3_create (card, + fm_port[dev], + fm_port[dev] +2 , +OPL3_HW_OPL3 ,1 , &opl3); +if (err <0 ) {dev_warn (card->dev,"cannot initialize FM OPL3 at 0x%lx, skipping...\n" , fm_port[dev]); legacy_ctrl &= ~YMFPCI_LEGACY_FMEN ;pci_write_config_word (pci,PCIR_DSXG_LEGACY , legacy_ctrl); - }else if ((err =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL )) <0 ) { -dev_err (card->dev,"cannot create opl3 hwdep\n" ); - goto free_card; + }else { + err =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL ); +if (err <0 ) { +dev_err (card->dev,"cannot create opl3 hwdep\n" ); + goto free_card; + } } }
sound/pci/ymfpci/ymfpci_main.c +49 -23
188 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 53/66 ALSA: core: Fix assignment in if condition
In reply to Takashi IwaiThere are a few places doing assignments in if condition in ALSA core code, 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.
--- sound/core/hwdep.c | 6 ++++-- sound/core/info_oss.c | 3 ++- sound/core/init.c | 12 ++++++++---- sound/core/sound.c | 3 ++- sound/core/sound_oss.c | 3 ++- 5 files changed, 18 insertions(+), 9 deletions(-)
sound/core/hwdep.c +4 -2
@@ -195,7 +195,8 @@ static int snd_hwdep_dsp_status(struct snd_hwdep *hw,return -ENXIO ;memset (&info,0 ,sizeof (info)); info.dsp_loaded = hw->dsp_loaded; -if ((err = hw->ops.dsp_status (hw, &info)) <0 ) + err = hw->ops.dsp_status (hw, &info); +if (err <0 )return err;if (copy_to_user (_info, &info,sizeof (info)))return -EFAULT ;
@@ -500,7 +501,8 @@ static void __init snd_hwdep_proc_init(void) {struct snd_info_entry *entry; -if ((entry =snd_info_create_module_entry (THIS_MODULE ,"hwdep" ,NULL )) !=NULL ) { + entry =snd_info_create_module_entry (THIS_MODULE ,"hwdep" ,NULL ); +if (entry) { entry->c.text.read = snd_hwdep_proc_read;if (snd_info_register (entry) <0 ) {snd_info_free_entry (entry);
sound/core/info_oss.c +2 -1
@@ -31,7 +31,8 @@ int snd_oss_info_register(int dev, int num, char *string)return -ENXIO ;mutex_lock (&strings);if (string ==NULL ) { -if ((x = snd_sndstat_strings[num][dev]) !=NULL ) { + x = snd_sndstat_strings[num][dev]; +if (x) {kfree (x); x =NULL ; }
sound/core/init.c +8 -4
@@ -770,7 +770,8 @@ int snd_card_register(struct snd_card *card) card->registered = true; } -if ((err =snd_device_register_all (card)) <0 ) + err =snd_device_register_all (card); +if (err <0 )return err;mutex_lock (&snd_card_mutex);if (snd_cards[card->number]) {
@@ -813,7 +814,8 @@ static void snd_card_info_read(struct snd_info_entry *entry,for (idx = count =0 ; idx <SNDRV_CARDS ; idx++) {mutex_lock (&snd_card_mutex); -if ((card = snd_cards[idx]) !=NULL ) { + card = snd_cards[idx]; +if (card) { count++; snd_iprintf(buffer, "%2i [%-15s]: %s - %s\n", idx,
@@ -837,7 +839,8 @@ void snd_card_info_read_oss(struct snd_info_buffer *buffer)for (idx = count =0 ; idx <SNDRV_CARDS ; idx++) {mutex_lock (&snd_card_mutex); -if ((card = snd_cards[idx]) !=NULL ) { + card = snd_cards[idx]; +if (card) { count++;snd_iprintf (buffer,"%s\n" , card->longname); }
@@ -859,7 +862,8 @@ static void snd_card_module_info_read(struct snd_info_entry *entry,for (idx =0 ; idx <SNDRV_CARDS ; idx++) {mutex_lock (&snd_card_mutex); -if ((card = snd_cards[idx]) !=NULL ) + card = snd_cards[idx]; +if (card)snd_iprintf (buffer,"%2i %s\n" , idx, card->module->name);mutex_unlock (&snd_card_mutex);
sound/core/sound.c +2 -1
@@ -357,7 +357,8 @@ static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_bumutex_lock (&sound_mutex);for (minor =0 ; minor <SNDRV_OS_MINORS ; ++minor) { -if (!(mptr = snd_minors[minor])) + mptr = snd_minors[minor]; +if (!mptr)continue ;if (mptr->card >=0 ) {if (mptr->device >=0 )
sound/core/sound_oss.c +2 -1
@@ -217,7 +217,8 @@ static void snd_minor_info_oss_read(struct snd_info_entry *entry,mutex_lock (&sound_oss_mutex);for (minor =0 ; minor <SNDRV_OSS_MINORS ; ++minor) { -if (!(mptr = snd_oss_minors[minor])) + mptr = snd_oss_minors[minor]; +if (!mptr)continue ;if (mptr->card >=0 ) snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", minor,
Signature · 1 line
2.26.2
PATCH 54/66 ALSA: pcm: Fix assignment in if condition
In reply to Takashi IwaiThere are a few places doing assignments in if condition in ALSA PCM core code, 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.
--- sound/core/pcm_compat.c | 6 ++++-- sound/core/pcm_misc.c | 12 ++++++++---- sound/core/pcm_native.c | 6 ++++-- 3 files changed, 16 insertions(+), 8 deletions(-)
sound/core/pcm_compat.c +4 -2
@@ -239,7 +239,8 @@ static int snd_pcm_ioctl_hw_params_compat(struct snd_pcm_substream *substream,struct snd_pcm_runtime *runtime;int err; -if (! (runtime = substream->runtime)) + runtime = substream->runtime; +if (!runtime)return -ENOTTY ; data =kmalloc (sizeof (*data),GFP_KERNEL );
@@ -343,7 +344,8 @@ static int snd_pcm_ioctl_xfern_compat(struct snd_pcm_substream *substream,if (substream->runtime->status->state ==SNDRV_PCM_STATE_OPEN )return -EBADFD ; -if ((ch = substream->runtime->channels) >128 ) + ch = substream->runtime->channels; +if (ch >128 )return -EINVAL ;if (get_user (buf, &data32->bufs) ||get_user (frames, &data32->frames))
sound/core/pcm_misc.c +8 -4
@@ -266,7 +266,8 @@ int snd_pcm_format_signed(snd_pcm_format_t format)int val;if (!valid_format (format))return -EINVAL ; -if ((val = pcm_formats[(INT )format].signd) <0 ) + val = pcm_formats[(INT )format].signd; +if (val <0 )return -EINVAL ;return val; }
@@ -314,7 +315,8 @@ int snd_pcm_format_little_endian(snd_pcm_format_t format)int val;if (!valid_format (format))return -EINVAL ; -if ((val = pcm_formats[(INT )format].le) <0 ) + val = pcm_formats[(INT )format].le; +if (val <0 )return -EINVAL ;return val; }
@@ -350,7 +352,8 @@ int snd_pcm_format_width(snd_pcm_format_t format)int val;if (!valid_format (format))return -EINVAL ; -if ((val = pcm_formats[(INT )format].width) ==0 ) + val = pcm_formats[(INT )format].width; +if (!val)return -EINVAL ;return val; }
@@ -368,7 +371,8 @@ int snd_pcm_format_physical_width(snd_pcm_format_t format)int val;if (!valid_format (format))return -EINVAL ; -if ((val = pcm_formats[(INT )format].phys) ==0 ) + val = pcm_formats[(INT )format].phys; +if (!val)return -EINVAL ;return val; }
sound/core/pcm_native.c +4 -2
@@ -768,7 +768,8 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream,if (cpu_latency_qos_request_active (&substream->latency_pm_qos_req))cpu_latency_qos_remove_request (&substream->latency_pm_qos_req); -if ((usecs =period_to_usecs (runtime)) >=0 ) + usecs =period_to_usecs (runtime); +if (usecs >=0 )cpu_latency_qos_add_request (&substream->latency_pm_qos_req, usecs);return 0 ;
@@ -2658,7 +2659,8 @@ int snd_pcm_open_substream(struct snd_pcm *pcm, int stream, goto error; } -if ((err = substream->ops->open (substream)) <0 ) + err = substream->ops->open (substream); +if (err <0 ) goto error; substream->hw_opened =1 ;
Signature · 1 line
2.26.2
PATCH 55/66 ALSA: oss: Fix assignment in if condition
In reply to Takashi IwaiThere are a few places doing assignments in if condition in ALSA PCM and OSS emulation layers, 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.
--- sound/core/oss/mixer_oss.c | 45 ++++++++++++++++-------- sound/core/oss/pcm_oss.c | 70 ++++++++++++++++++++++++------------- sound/core/oss/pcm_plugin.c | 26 ++++++++------ 3 files changed, 91 insertions(+), 50 deletions(-)
sound/core/oss/mixer_oss.c +30 -15
@@ -185,7 +185,8 @@ static int snd_mixer_oss_get_recsrc(struct snd_mixer_oss_file *fmixer)if (mixer->put_recsrc && mixer->get_recsrc) {/* exclusive */ int err;unsigned int index; -if ((err = mixer->get_recsrc (fmixer, &index)) <0 ) + err = mixer->get_recsrc (fmixer, &index); +if (err <0 )return err; result =1 << index; }else {
@@ -517,7 +518,8 @@ static void snd_mixer_oss_get_volume1_vol(struct snd_mixer_oss_file *fmixer,if (numid ==ID_UNKNOWN )return ;down_read (&card->controls_rwsem); -if ((kctl =snd_ctl_find_numid (card, numid)) ==NULL ) { + kctl =snd_ctl_find_numid (card, numid); +if (!kctl) {up_read (&card->controls_rwsem);return ; }
@@ -555,7 +557,8 @@ static void snd_mixer_oss_get_volume1_sw(struct snd_mixer_oss_file *fmixer,if (numid ==ID_UNKNOWN )return ;down_read (&card->controls_rwsem); -if ((kctl =snd_ctl_find_numid (card, numid)) ==NULL ) { + kctl =snd_ctl_find_numid (card, numid); +if (!kctl) {up_read (&card->controls_rwsem);return ; }
@@ -620,7 +623,8 @@ static void snd_mixer_oss_put_volume1_vol(struct snd_mixer_oss_file *fmixer,if (numid ==ID_UNKNOWN )return ;down_read (&card->controls_rwsem); -if ((kctl =snd_ctl_find_numid (card, numid)) ==NULL ) { + kctl =snd_ctl_find_numid (card, numid); +if (!kctl) {up_read (&card->controls_rwsem);return ; }
@@ -636,7 +640,8 @@ static void snd_mixer_oss_put_volume1_vol(struct snd_mixer_oss_file *fmixer, uctl->value.integer.value[0 ] =snd_mixer_oss_conv2 (left, uinfo->value.integer.min, uinfo->value.integer.max);if (uinfo->count >1 ) uctl->value.integer.value[1 ] =snd_mixer_oss_conv2 (right, uinfo->value.integer.min, uinfo->value.integer.max); -if ((res = kctl->put (kctl, uctl)) <0 ) + res = kctl->put (kctl, uctl); +if (res <0 ) goto __unalloc;if (res >0 )snd_ctl_notify (card,SNDRV_CTL_EVENT_MASK_VALUE , &kctl->id);
@@ -661,7 +666,8 @@ static void snd_mixer_oss_put_volume1_sw(struct snd_mixer_oss_file *fmixer,if (numid ==ID_UNKNOWN )return ;down_read (&card->controls_rwsem); -if ((kctl =snd_ctl_find_numid (card, numid)) ==NULL ) { + kctl =snd_ctl_find_numid (card, numid); +if (!kctl) {up_read (&card->controls_rwsem);return ; }
@@ -681,7 +687,8 @@ static void snd_mixer_oss_put_volume1_sw(struct snd_mixer_oss_file *fmixer, }else { uctl->value.integer.value[0 ] = (left >0 || right >0 ) ?1 :0 ; } -if ((res = kctl->put (kctl, uctl)) <0 ) + res = kctl->put (kctl, uctl); +if (res <0 ) goto __unalloc;if (res >0 )snd_ctl_notify (card,SNDRV_CTL_EVENT_MASK_VALUE , &kctl->id);
@@ -809,9 +816,11 @@ static int snd_mixer_oss_get_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned err = -ENOENT ; goto __unlock; } -if ((err = kctl->info (kctl, uinfo)) <0 ) + err = kctl->info (kctl, uinfo); +if (err <0 ) goto __unlock; -if ((err = kctl->get (kctl, uctl)) <0 ) + err = kctl->get (kctl, uctl); +if (err <0 ) goto __unlock;for (idx =0 ; idx <32 ; idx++) {if (!(mixer->mask_recsrc & (1 << idx)))
@@ -860,7 +869,8 @@ static int snd_mixer_oss_put_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned err = -ENOENT ; goto __unlock; } -if ((err = kctl->info (kctl, uinfo)) <0 ) + err = kctl->info (kctl, uinfo); +if (err <0 ) goto __unlock;for (idx =0 ; idx <32 ; idx++) {if (!(mixer->mask_recsrc & (1 << idx)))
@@ -915,7 +925,8 @@ static int snd_mixer_oss_build_test(struct snd_mixer_oss *mixer, struct slot *slup_read (&card->controls_rwsem);return -ENOMEM ; } -if ((err = kcontrol->info (kcontrol, info)) <0 ) { + err = kcontrol->info (kcontrol, info); +if (err <0 ) {up_read (&card->controls_rwsem);kfree (info);return err;
@@ -1036,7 +1047,10 @@ static int snd_mixer_oss_build_input(struct snd_mixer_oss *mixer,if (snd_mixer_oss_build_test_all (mixer, ptr, &slot))return 0 ;down_read (&mixer->card->controls_rwsem); -if (ptr->index ==0 && (kctl =snd_mixer_oss_test_id (mixer,"Capture Source" ,0 )) !=NULL ) { + kctl =NULL ; +if (!ptr->index) + kctl =snd_mixer_oss_test_id (mixer,"Capture Source" ,0 ); +if (kctl) {struct snd_ctl_elem_info *uinfo; uinfo =kzalloc (sizeof (*uinfo),GFP_KERNEL );
@@ -1343,9 +1357,10 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd)if (mixer ==NULL )return -ENOMEM ;mutex_init (&mixer->reg_mutex); -if ((err =snd_register_oss_device (SNDRV_OSS_DEVICE_TYPE_MIXER , - card,0 , - &snd_mixer_oss_f_ops, card)) <0 ) { + err =snd_register_oss_device (SNDRV_OSS_DEVICE_TYPE_MIXER , + card,0 , + &snd_mixer_oss_f_ops, card); +if (err <0 ) {dev_err (card->dev,"unable to register OSS mixer device %i:%i\n" , card->number,0 );
sound/core/oss/pcm_oss.c +45 -25
193 lines not on this page · raw message
sound/core/oss/pcm_plugin.c +16 -10
@@ -59,7 +59,8 @@ static int snd_pcm_plugin_alloc(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t }else { format = &plugin->dst_format; } -if ((width =snd_pcm_format_physical_width (format->format)) <0 ) + width =snd_pcm_format_physical_width (format->format); +if (width <0 )return width; size = frames * format->channels * width;if (snd_BUG_ON (size %8 ))
@@ -572,7 +573,8 @@ snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(struct snd_pcm_substream *plu } v = plugin->buf_channels; *channels = v; -if ((width =snd_pcm_format_physical_width (format->format)) <0 ) + width =snd_pcm_format_physical_width (format->format); +if (width <0 )return width; nchannels = format->channels; if (snd_BUG_ON(plugin->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED &&
@@ -600,16 +602,17 @@ snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct snd_pcm_substream *plug, stwhile (plugin) {if (frames <=0 )return frames; -if ((next = plugin->next) !=NULL ) { + next = plugin->next; +if (next) {snd_pcm_sframes_t frames1 = frames;if (plugin->dst_frames) { frames1 = plugin->dst_frames (plugin, frames);if (frames1 <=0 )return frames1; } -if ((err = next->client_channels (next, frames1, &dst_channels)) <0 ) { + err = next->client_channels (next, frames1, &dst_channels); +if (err <0 )return err; - }if (err != frames1) { frames = err;if (plugin->src_frames) {
@@ -621,7 +624,8 @@ snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct snd_pcm_substream *plug, st }else dst_channels =NULL ;pdprintf ("write plugin: %s, %li\n" , plugin->name, frames); -if ((frames = plugin->transfer (plugin, src_channels, dst_channels, frames)) <0 ) + frames = plugin->transfer (plugin, src_channels, dst_channels, frames); +if (frames <0 )return frames; src_channels = dst_channels; plugin = next;
@@ -643,16 +647,18 @@ snd_pcm_sframes_t snd_pcm_plug_read_transfer(struct snd_pcm_substream *plug, str src_channels =NULL ; plugin =snd_pcm_plug_first (plug);while (plugin && frames >0 ) { -if ((next = plugin->next) !=NULL ) { -if ((err = plugin->client_channels (plugin, frames, &dst_channels)) <0 ) { + next = plugin->next; +if (next) { + err = plugin->client_channels (plugin, frames, &dst_channels); +if (err <0 )return err; - } frames = err; }else { dst_channels = dst_channels_final; }pdprintf ("read plugin: %s, %li\n" , plugin->name, frames); -if ((frames = plugin->transfer (plugin, src_channels, dst_channels, frames)) <0 ) + frames = plugin->transfer (plugin, src_channels, dst_channels, frames); +if (frames <0 )return frames; plugin = next; src_channels = dst_channels;
Signature · 1 line
2.26.2
PATCH 56/66 ALSA: seq: Fix assignment in if condition
In reply to Takashi IwaiThere are lots of places doing assignments in if condition in ALSA sequencer core, 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.
--- sound/core/seq/oss/seq_oss.c | 26 +++++++++------ sound/core/seq/oss/seq_oss_init.c | 9 +++-- sound/core/seq/oss/seq_oss_midi.c | 33 ++++++++++++------- sound/core/seq/oss/seq_oss_rw.c | 3 +- sound/core/seq/oss/seq_oss_synth.c | 9 +++-- sound/core/seq/oss/seq_oss_writeq.c | 3 +- sound/core/seq/seq_clientmgr.c | 51 +++++++++++++++++++---------- sound/core/seq/seq_dummy.c | 3 +- sound/core/seq/seq_fifo.c | 3 +- sound/core/seq/seq_memory.c | 6 ++-- sound/core/seq/seq_midi.c | 27 ++++++++------- sound/core/seq/seq_queue.c | 21 ++++++++---- sound/core/seq/seq_virmidi.c | 9 ++--- 13 files changed, 131 insertions(+), 72 deletions(-)
sound/core/seq/oss/seq_oss.c +16 -10
@@ -67,13 +67,16 @@ static int __init alsa_seq_oss_init(void) {int rc; -if ((rc =register_device ()) <0 ) + rc =register_device (); +if (rc <0 ) goto error; -if ((rc =register_proc ()) <0 ) { + rc =register_proc (); +if (rc <0 ) {unregister_device (); goto error; } -if ((rc =snd_seq_oss_create_client ()) <0 ) { + rc =snd_seq_oss_create_client (); +if (rc <0 ) {unregister_proc ();unregister_device (); goto error;
@@ -133,7 +136,8 @@ odev_release(struct inode *inode, struct file *file) {struct seq_oss_devinfo *dp; -if ((dp = file->private_data) ==NULL ) + dp = file->private_data; +if (!dp)return 0 ;mutex_lock (®ister_mutex);
@@ -226,16 +230,18 @@ register_device(void)int rc;mutex_lock (®ister_mutex); -if ((rc =snd_register_oss_device (SNDRV_OSS_DEVICE_TYPE_SEQUENCER , -NULL ,0 , - &seq_oss_f_ops,NULL )) <0 ) { + rc =snd_register_oss_device (SNDRV_OSS_DEVICE_TYPE_SEQUENCER , +NULL ,0 , + &seq_oss_f_ops,NULL ); +if (rc <0 ) {pr_err ("ALSA: seq_oss: can't register device seq\n" );mutex_unlock (®ister_mutex);return rc; } -if ((rc =snd_register_oss_device (SNDRV_OSS_DEVICE_TYPE_MUSIC , -NULL ,0 , - &seq_oss_f_ops,NULL )) <0 ) { + rc =snd_register_oss_device (SNDRV_OSS_DEVICE_TYPE_MUSIC , +NULL ,0 , + &seq_oss_f_ops,NULL ); +if (rc <0 ) {pr_err ("ALSA: seq_oss: can't register device music\n" );snd_unregister_oss_device (SNDRV_OSS_DEVICE_TYPE_SEQUENCER ,NULL ,0 );mutex_unlock (®ister_mutex);
sound/core/seq/oss/seq_oss_init.c +6 -3
@@ -95,7 +95,8 @@ snd_seq_oss_create_client(void) port->kernel = &port_callback;call_ctl (SNDRV_SEQ_IOCTL_CREATE_PORT , port); -if ((system_port = port->addr.port) >=0 ) { + system_port = port->addr.port; +if (system_port >=0 ) {struct snd_seq_port_subscribe subs;memset (&subs,0 ,sizeof (subs));
@@ -354,7 +355,8 @@ alloc_seq_queue(struct seq_oss_devinfo *dp) qinfo.owner = system_client; qinfo.locked =1 ;strcpy (qinfo.name,"OSS Sequencer Emulation" ); -if ((rc =call_ctl (SNDRV_SEQ_IOCTL_CREATE_QUEUE , &qinfo)) <0 ) + rc =call_ctl (SNDRV_SEQ_IOCTL_CREATE_QUEUE , &qinfo); +if (rc <0 )return rc; dp->queue = qinfo.queue;return 0 ;
@@ -485,7 +487,8 @@ snd_seq_oss_system_info_read(struct snd_info_buffer *buf)snd_iprintf (buf,"\nNumber of applications: %d\n" , num_clients);for (i =0 ; i < num_clients; i++) {snd_iprintf (buf,"\nApplication %d: " , i); -if ((dp = client_table[i]) ==NULL ) { + dp = client_table[i]; +if (!dp) {snd_iprintf (buf,"*empty*\n" );continue ; }
sound/core/seq/oss/seq_oss_midi.c +22 -11
@@ -152,7 +152,8 @@ snd_seq_oss_midi_check_new_port(struct snd_seq_port_info *pinfo)/* * look for the identical slot */ -if ((mdev =find_slot (pinfo->addr.client, pinfo->addr.port)) !=NULL ) { + mdev =find_slot (pinfo->addr.client, pinfo->addr.port); +if (mdev) {/* already exists */ snd_use_lock_free (&mdev->use_lock);return 0 ;
@@ -218,7 +219,8 @@ snd_seq_oss_midi_check_exit_port(int client, int port)unsigned long flags;int index; -if ((mdev =find_slot (client, port)) !=NULL ) { + mdev =find_slot (client, port); +if (mdev) {spin_lock_irqsave (®ister_lock, flags); midi_devs[mdev->seq_device] =NULL ;spin_unlock_irqrestore (®ister_lock, flags);
@@ -250,7 +252,8 @@ snd_seq_oss_midi_clear_all(void)spin_lock_irqsave (®ister_lock, flags);for (i =0 ; i < max_midi_devs; i++) { -if ((mdev = midi_devs[i]) !=NULL ) { + mdev = midi_devs[i]; +if (mdev) {snd_midi_event_free (mdev->coder);kfree (mdev); midi_devs[i] =NULL ;
@@ -318,7 +321,8 @@ snd_seq_oss_midi_open(struct seq_oss_devinfo *dp, int dev, int fmode)struct seq_oss_midi *mdev;struct snd_seq_port_subscribe subs; -if ((mdev =get_mididev (dp, dev)) ==NULL ) + mdev =get_mididev (dp, dev); +if (!mdev)return -ENODEV ;/* already used? */
@@ -384,7 +388,8 @@ snd_seq_oss_midi_close(struct seq_oss_devinfo *dp, int dev)struct seq_oss_midi *mdev;struct snd_seq_port_subscribe subs; -if ((mdev =get_mididev (dp, dev)) ==NULL ) + mdev =get_mididev (dp, dev); +if (!mdev)return -ENODEV ;if (! mdev->opened || mdev->devinfo != dp) {snd_use_lock_free (&mdev->use_lock);
@@ -421,7 +426,8 @@ snd_seq_oss_midi_filemode(struct seq_oss_devinfo *dp, int dev)struct seq_oss_midi *mdev;int mode; -if ((mdev =get_mididev (dp, dev)) ==NULL ) + mdev =get_mididev (dp, dev); +if (!mdev)return 0 ; mode =0 ;
@@ -443,7 +449,8 @@ snd_seq_oss_midi_reset(struct seq_oss_devinfo *dp, int dev) {struct seq_oss_midi *mdev; -if ((mdev =get_mididev (dp, dev)) ==NULL ) + mdev =get_mididev (dp, dev); +if (!mdev)return ;if (! mdev->opened) {snd_use_lock_free (&mdev->use_lock);
@@ -491,7 +498,8 @@ snd_seq_oss_midi_get_addr(struct seq_oss_devinfo *dp, int dev, struct snd_seq_ad {struct seq_oss_midi *mdev; -if ((mdev =get_mididev (dp, dev)) ==NULL ) + mdev =get_mididev (dp, dev); +if (!mdev)return ; addr->client = mdev->client; addr->port = mdev->port;
@@ -511,7 +519,8 @@ snd_seq_oss_midi_input(struct snd_seq_event *ev, int direct, void *private_data)if (dp->readq ==NULL )return 0 ; -if ((mdev =find_slot (ev->source.client, ev->source.port)) ==NULL ) + mdev =find_slot (ev->source.client, ev->source.port); +if (!mdev)return 0 ;if (! (mdev->opened &PERM_READ )) {snd_use_lock_free (&mdev->use_lock);
@@ -623,7 +632,8 @@ snd_seq_oss_midi_putc(struct seq_oss_devinfo *dp, int dev, unsigned char c, stru {struct seq_oss_midi *mdev; -if ((mdev =get_mididev (dp, dev)) ==NULL ) + mdev =get_mididev (dp, dev); +if (!mdev)return -ENODEV ;if (snd_midi_event_encode_byte (mdev->coder, c, ev)) {snd_seq_oss_fill_addr (dp, ev, mdev->client, mdev->port);
@@ -642,7 +652,8 @@ snd_seq_oss_midi_make_info(struct seq_oss_devinfo *dp, int dev, struct midi_info {struct seq_oss_midi *mdev; -if ((mdev =get_mididev (dp, dev)) ==NULL ) + mdev =get_mididev (dp, dev); +if (!mdev)return -ENXIO ; inf->device = dev; inf->dev_type =0 ;/* FIXME: ?? */
sound/core/seq/oss/seq_oss_rw.c +2 -1
@@ -132,7 +132,8 @@ snd_seq_oss_write(struct seq_oss_devinfo *dp, const char __user *buf, int count, }/* insert queue */ -if ((err =insert_queue (dp, &rec, opt)) <0 ) + err =insert_queue (dp, &rec, opt); +if (err <0 )break ; result += ev_size;
sound/core/seq/oss/seq_oss_synth.c +6 -3
@@ -451,7 +451,8 @@ snd_seq_oss_synth_load_patch(struct seq_oss_devinfo *dp, int dev, int fmt,if (info->is_midi)return 0 ; -if ((rec =get_synthdev (dp, dev)) ==NULL ) + rec =get_synthdev (dp, dev); +if (!rec)return -ENXIO ;if (rec->oper.load_patch ==NULL )
@@ -569,7 +570,8 @@ snd_seq_oss_synth_ioctl(struct seq_oss_devinfo *dp, int dev, unsigned int cmd, u info =get_synthinfo_nospec (dp, dev);if (!info || info->is_midi)return -ENXIO ; -if ((rec =get_synthdev (dp, dev)) ==NULL ) + rec =get_synthdev (dp, dev); +if (!rec)return -ENXIO ;if (rec->oper.ioctl ==NULL ) rc = -ENXIO ;
@@ -619,7 +621,8 @@ snd_seq_oss_synth_make_info(struct seq_oss_devinfo *dp, int dev, struct synth_in inf->device = dev;strscpy (inf->name, minf.name,sizeof (inf->name)); }else { -if ((rec =get_synthdev (dp, dev)) ==NULL ) + rec =get_synthdev (dp, dev); +if (!rec)return -ENXIO ; inf->synth_type = rec->synth_type; inf->synth_subtype = rec->synth_subtype;
sound/core/seq/oss/seq_oss_writeq.c +2 -1
@@ -27,7 +27,8 @@ snd_seq_oss_writeq_new(struct seq_oss_devinfo *dp, int maxlen)struct seq_oss_writeq *q;struct snd_seq_client_pool pool; -if ((q =kzalloc (sizeof (*q),GFP_KERNEL )) ==NULL ) + q =kzalloc (sizeof (*q),GFP_KERNEL ); +if (!q)return NULL ; q->dp = dp; q->maxlen = maxlen;
sound/core/seq/seq_clientmgr.c +34 -17
108 lines not on this page · raw message
sound/core/seq/seq_dummy.c +2 -1
@@ -109,7 +109,8 @@ create_port(int idx, int type)struct snd_seq_port_callback pcb;struct snd_seq_dummy_port *rec; -if ((rec =kzalloc (sizeof (*rec),GFP_KERNEL )) ==NULL ) + rec =kzalloc (sizeof (*rec),GFP_KERNEL ); +if (!rec)return NULL ; rec->client = my_client;
sound/core/seq/seq_fifo.c +2 -1
@@ -143,7 +143,8 @@ static struct snd_seq_event_cell *fifo_cell_out(struct snd_seq_fifo *f) {struct snd_seq_event_cell *cell; -if ((cell = f->head) !=NULL ) { + cell = f->head; +if (cell) { f->head = cell->next;/* reset tail if this was the last element */
sound/core/seq/seq_memory.c +4 -2
@@ -69,7 +69,8 @@ int snd_seq_dump_var_event(const struct snd_seq_event *event,int len, err;struct snd_seq_event_cell *cell; -if ((len =get_var_len (event)) <=0 ) + len =get_var_len (event); +if (len <=0 )return len;if (event->data.ext.len &SNDRV_SEQ_EXT_USRPTR ) {
@@ -133,7 +134,8 @@ int snd_seq_expand_var_event(const struct snd_seq_event *event, int count, charint len, newlen;int err; -if ((len =get_var_len (event)) <0 ) + len =get_var_len (event); +if (len <0 )return len; newlen = len;if (size_aligned >0 )
sound/core/seq/seq_midi.c +16 -11
@@ -101,7 +101,8 @@ static int dump_midi(struct snd_rawmidi_substream *substream, const char *buf, iif (snd_BUG_ON (!substream || !buf))return -EINVAL ; runtime = substream->runtime; -if ((tmp = runtime->avail) < count) { + tmp = runtime->avail; +if (tmp < count) {if (printk_ratelimit ())pr_err ("ALSA: seq_midi: MIDI output buffer overrun\n" );return -ENOMEM ;
@@ -167,10 +168,11 @@ static int midisynth_subscribe(void *private_data, struct snd_seq_port_subscribestruct snd_rawmidi_params params;/* open midi port */ -if ((err =snd_rawmidi_kernel_open (msynth->card, msynth->device, - msynth->subdevice, -SNDRV_RAWMIDI_LFLG_INPUT , - &msynth->input_rfile)) <0 ) { + err =snd_rawmidi_kernel_open (msynth->card, msynth->device, + msynth->subdevice, +SNDRV_RAWMIDI_LFLG_INPUT , + &msynth->input_rfile); +if (err <0 ) {pr_debug ("ALSA: seq_midi: midi input open failed!!!\n" );return err; }
@@ -178,7 +180,8 @@ static int midisynth_subscribe(void *private_data, struct snd_seq_port_subscribememset (¶ms,0 ,sizeof (params)); params.avail_min =1 ; params.buffer_size = input_buffer_size; -if ((err =snd_rawmidi_input_params (msynth->input_rfile.input, ¶ms)) <0 ) { + err =snd_rawmidi_input_params (msynth->input_rfile.input, ¶ms); +if (err <0 ) {snd_rawmidi_kernel_release (&msynth->input_rfile);return err; }
@@ -209,10 +212,11 @@ static int midisynth_use(void *private_data, struct snd_seq_port_subscribe *infostruct snd_rawmidi_params params;/* open midi port */ -if ((err =snd_rawmidi_kernel_open (msynth->card, msynth->device, - msynth->subdevice, -SNDRV_RAWMIDI_LFLG_OUTPUT , - &msynth->output_rfile)) <0 ) { + err =snd_rawmidi_kernel_open (msynth->card, msynth->device, + msynth->subdevice, +SNDRV_RAWMIDI_LFLG_OUTPUT , + &msynth->output_rfile); +if (err <0 ) {pr_debug ("ALSA: seq_midi: midi output open failed!!!\n" );return err; }
@@ -220,7 +224,8 @@ static int midisynth_use(void *private_data, struct snd_seq_port_subscribe *info params.avail_min =1 ; params.buffer_size = output_buffer_size; params.no_active_sensing =1 ; -if ((err =snd_rawmidi_output_params (msynth->output_rfile.output, ¶ms)) <0 ) { + err =snd_rawmidi_output_params (msynth->output_rfile.output, ¶ms); +if (err <0 ) {snd_rawmidi_kernel_release (&msynth->output_rfile);return err; }
sound/core/seq/seq_queue.c +14 -7
@@ -222,7 +222,8 @@ struct snd_seq_queue *snd_seq_queue_find_name(char *name)struct snd_seq_queue *q;for (i =0 ; i <SNDRV_SEQ_MAX_QUEUES ; i++) { -if ((q =queueptr (i)) !=NULL ) { + q =queueptr (i); +if (q) {if (strncmp (q->name, name,sizeof (q->name)) ==0 )return q;queuefree (q);
@@ -432,7 +433,8 @@ int snd_seq_queue_timer_open(int queueid)if (queue ==NULL )return -EINVAL ; tmr = queue->timer; -if ((result =snd_seq_timer_open (queue)) <0 ) { + result =snd_seq_timer_open (queue); +if (result <0 ) {snd_seq_timer_defaults (tmr); result =snd_seq_timer_open (queue); }
@@ -548,7 +550,8 @@ void snd_seq_queue_client_leave(int client)/* delete own queues from queue list */ for (i =0 ; i <SNDRV_SEQ_MAX_QUEUES ; i++) { -if ((q =queue_list_remove (i, client)) !=NULL ) + q =queue_list_remove (i, client); +if (q)queue_delete (q); }
@@ -556,7 +559,8 @@ void snd_seq_queue_client_leave(int client)* they are not owned by this client */ for (i =0 ; i <SNDRV_SEQ_MAX_QUEUES ; i++) { -if ((q =queueptr (i)) ==NULL ) + q =queueptr (i); +if (!q)continue ;if (test_bit (client, q->clients_bitmap)) {snd_seq_prioq_leave (q->tickq, client,0 );
@@ -578,7 +582,8 @@ void snd_seq_queue_client_leave_cells(int client)struct snd_seq_queue *q;for (i =0 ; i <SNDRV_SEQ_MAX_QUEUES ; i++) { -if ((q =queueptr (i)) ==NULL ) + q =queueptr (i); +if (!q)continue ;snd_seq_prioq_leave (q->tickq, client,0 );snd_seq_prioq_leave (q->timeq, client,0 );
@@ -593,7 +598,8 @@ void snd_seq_queue_remove_cells(int client, struct snd_seq_remove_events *info)struct snd_seq_queue *q;for (i =0 ; i <SNDRV_SEQ_MAX_QUEUES ; i++) { -if ((q =queueptr (i)) ==NULL ) + q =queueptr (i); +if (!q)continue ; if (test_bit(client, q->clients_bitmap) && (! (info->remove_mode & SNDRV_SEQ_REMOVE_DEST) ||
@@ -724,7 +730,8 @@ void snd_seq_info_queues_read(struct snd_info_entry *entry,int owner;for (i =0 ; i <SNDRV_SEQ_MAX_QUEUES ; i++) { -if ((q =queueptr (i)) ==NULL ) + q =queueptr (i); +if (!q)continue ; tmr = q->timer;
sound/core/seq/seq_virmidi.c +5 -4
@@ -482,10 +482,11 @@ int snd_virmidi_new(struct snd_card *card, int device, struct snd_rawmidi **rrmiint err; *rrmidi =NULL ; -if ((err =snd_rawmidi_new (card,"VirMidi" , device, -16 ,/* may be configurable */ -16 ,/* may be configurable */ - &rmidi)) <0 ) + err =snd_rawmidi_new (card,"VirMidi" , device, +16 ,/* may be configurable */ +16 ,/* may be configurable */ + &rmidi); +if (err <0 )return err;strcpy (rmidi->name, rmidi->id); rdev =kzalloc (sizeof (*rdev),GFP_KERNEL );
Signature · 1 line
2.26.2
PATCH 57/66 ALSA: pcmcia: Fix assignment in if condition
In reply to Takashi IwaiPCMCIA VX222 and PDAudioCF 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.
--- sound/pcmcia/pdaudiocf/pdaudiocf.c | 3 ++- sound/pcmcia/vx/vxp_mixer.c | 6 ++++-- sound/pcmcia/vx/vxp_ops.c | 6 ++++-- sound/pcmcia/vx/vxpocket.c | 3 ++- 4 files changed, 12 insertions(+), 6 deletions(-)
sound/pcmcia/pdaudiocf/pdaudiocf.c +2 -1
@@ -170,7 +170,8 @@ static int snd_pdacf_assign_resources(struct snd_pdacf *pdacf, int port, int irqif (err <0 )return err; -if ((err =snd_card_register (card)) <0 ) + err =snd_card_register (card); +if (err <0 )return err;return 0 ;
sound/pcmcia/vx/vxp_mixer.c +4 -2
@@ -124,11 +124,13 @@ int vxp_add_mic_controls(struct vx_core *_chip)/* mic level */ switch (_chip->type) {case VX_TYPE_VXPOCKET : -if ((err =snd_ctl_add (_chip->card,snd_ctl_new1 (&vx_control_mic_level, chip))) <0 ) + err =snd_ctl_add (_chip->card,snd_ctl_new1 (&vx_control_mic_level, chip)); +if (err <0 )return err;break ;case VX_TYPE_VXP440 : -if ((err =snd_ctl_add (_chip->card,snd_ctl_new1 (&vx_control_mic_boost, chip))) <0 ) + err =snd_ctl_add (_chip->card,snd_ctl_new1 (&vx_control_mic_boost, chip)); +if (err <0 )return err;break ; }
sound/pcmcia/vx/vxp_ops.c +4 -2
@@ -237,9 +237,11 @@ static int vxp_load_dsp(struct vx_core *vx, int index, const struct firmware *fwswitch (index) {case 0 :/* xilinx boot */ -if ((err =vx_check_magic (vx)) <0 ) + err =vx_check_magic (vx); +if (err <0 )return err; -if ((err =snd_vx_load_boot_image (vx, fw)) <0 ) + err =snd_vx_load_boot_image (vx, fw); +if (err <0 )return err;return 0 ;case 1 :
sound/pcmcia/vx/vxpocket.c +2 -1
@@ -183,7 +183,8 @@ static int snd_vxpocket_assign_resources(struct vx_core *chip, int port, int irq chip->irq = irq; card->sync_irq = chip->irq; -if ((err =snd_vx_setup_firmware (chip)) <0 ) + err =snd_vx_setup_firmware (chip); +if (err <0 )return err;return 0 ;
Signature · 1 line
2.26.2
PATCH 58/66 ALSA: sparc: Fix assignment in if condition
In reply to Takashi IwaiSPARC 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.
--- sound/sparc/amd7930.c | 14 +++++++++----- sound/sparc/cs4231.c | 10 ++++++---- sound/sparc/dbri.c | 11 ++++++----- 3 files changed, 21 insertions(+), 14 deletions(-)
sound/sparc/amd7930.c +9 -5
@@ -975,8 +975,9 @@ static int snd_amd7930_create(struct snd_card *card,spin_unlock_irqrestore (&amd->lock, flags); -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , - amd, &snd_amd7930_dev_ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , + amd, &snd_amd7930_dev_ops); +if (err <0 ) {snd_amd7930_free (amd);return err; }
@@ -1019,13 +1020,16 @@ static int amd7930_sbus_probe(struct platform_device *op) irq, dev_num, &amd)) < 0) goto out_err; -if ((err =snd_amd7930_pcm (amd)) <0 ) + err =snd_amd7930_pcm (amd); +if (err <0 ) goto out_err; -if ((err =snd_amd7930_mixer (amd)) <0 ) + err =snd_amd7930_mixer (amd); +if (err <0 ) goto out_err; -if ((err =snd_card_register (card)) <0 ) + err =snd_card_register (card); +if (err <0 ) goto out_err; amd->next = amd7930_list;
sound/sparc/cs4231.c +6 -4
@@ -1828,8 +1828,9 @@ static int snd_cs4231_sbus_create(struct snd_card *card, }snd_cs4231_init (chip); -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , - chip, &snd_cs4231_sbus_dev_ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , + chip, &snd_cs4231_sbus_dev_ops); +if (err <0 ) {snd_cs4231_sbus_free (chip);return err; }
@@ -2020,8 +2021,9 @@ static int snd_cs4231_ebus_create(struct snd_card *card, }snd_cs4231_init (chip); -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , - chip, &snd_cs4231_ebus_dev_ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , + chip, &snd_cs4231_ebus_dev_ops); +if (err <0 ) {snd_cs4231_ebus_free (chip);return err; }
sound/sparc/dbri.c +6 -5
@@ -2226,11 +2226,12 @@ static int snd_dbri_pcm(struct snd_card *card)struct snd_pcm *pcm;int err; -if ((err =snd_pcm_new (card, -/* ID */ "sun_dbri" , -/* device */ 0 , -/* playback count */ 1 , -/* capture count */ 1 , &pcm)) <0 ) + err =snd_pcm_new (card, +/* ID */ "sun_dbri" , +/* device */ 0 , +/* playback count */ 1 , +/* capture count */ 1 , &pcm); +if (err <0 )return err;snd_pcm_set_ops (pcm,SNDRV_PCM_STREAM_PLAYBACK , &snd_dbri_ops);
Signature · 1 line
2.26.2
PATCH 59/66 ALSA: mpu401: Fix assignment in if condition
In reply to Takashi IwaiMPU401 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.
--- sound/drivers/mpu401/mpu401.c | 9 ++++++--- sound/drivers/mpu401/mpu401_uart.c | 19 +++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-)
sound/drivers/mpu401/mpu401.c +6 -3
@@ -104,7 +104,8 @@ static int snd_mpu401_probe(struct platform_device *devptr) err =snd_mpu401_create (&devptr->dev, dev, &card);if (err <0 )return err; -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_card_free (card);return err; }
@@ -182,7 +183,8 @@ static int snd_mpu401_pnp_probe(struct pnp_dev *pnp_dev, err =snd_mpu401_create (&pnp_dev->dev, dev, &card);if (err <0 )return err; -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_card_free (card);return err; }
@@ -227,7 +229,8 @@ static int __init alsa_card_mpu401_init(void) {int i, err; -if ((err =platform_driver_register (&snd_mpu401_driver)) <0 ) + err =platform_driver_register (&snd_mpu401_driver); +if (err <0 )return err;for (i =0 ; i <SNDRV_CARDS ; i++) {
sound/drivers/mpu401/mpu401_uart.c +13 -6
@@ -271,8 +271,11 @@ static int snd_mpu401_uart_input_open(struct snd_rawmidi_substream *substream)int err; mpu = substream->rmidi->private_data; -if (mpu->open_input && (err = mpu->open_input (mpu)) <0 ) -return err; +if (mpu->open_input) { + err = mpu->open_input (mpu); +if (err <0 ) +return err; + }if (!test_bit (MPU401_MODE_BIT_OUTPUT , &mpu->mode)) {if (snd_mpu401_do_reset (mpu) <0 ) goto error_out;
@@ -293,8 +296,11 @@ static int snd_mpu401_uart_output_open(struct snd_rawmidi_substream *substream)int err; mpu = substream->rmidi->private_data; -if (mpu->open_output && (err = mpu->open_output (mpu)) <0 ) -return err; +if (mpu->open_output) { + err = mpu->open_output (mpu); +if (err <0 ) +return err; + }if (!test_bit (MPU401_MODE_BIT_INPUT , &mpu->mode)) {if (snd_mpu401_do_reset (mpu) <0 ) goto error_out;
@@ -524,8 +530,9 @@ int snd_mpu401_uart_new(struct snd_card *card, int device, info_flags |=MPU401_INFO_INPUT |MPU401_INFO_OUTPUT ; in_enable = (info_flags &MPU401_INFO_INPUT ) ?1 :0 ; out_enable = (info_flags &MPU401_INFO_OUTPUT ) ?1 :0 ; -if ((err =snd_rawmidi_new (card,"MPU-401U" , device, - out_enable, in_enable, &rmidi)) <0 ) + err =snd_rawmidi_new (card,"MPU-401U" , device, + out_enable, in_enable, &rmidi); +if (err <0 )return err; mpu =kzalloc (sizeof (*mpu),GFP_KERNEL );if (!mpu) {
Signature · 1 line
2.26.2
PATCH 60/66 ALSA: vx: Fix assignment in if condition
In reply to Takashi IwaiVX 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.
--- sound/drivers/vx/vx_core.c | 60 ++++++++++++++++++++++++------------- sound/drivers/vx/vx_hwdep.c | 12 +++++--- sound/drivers/vx/vx_mixer.c | 39 ++++++++++++++++-------- sound/drivers/vx/vx_pcm.c | 32 +++++++++++++------- 4 files changed, 95 insertions(+), 48 deletions(-)
sound/drivers/vx/vx_core.c +40 -20
@@ -110,20 +110,25 @@ static int vx_transfer_end(struct vx_core *chip, int cmd) {int err; -if ((err =vx_reset_chk (chip)) <0 ) + err =vx_reset_chk (chip); +if (err <0 )return err;/* irq MESS_READ/WRITE_END */ -if ((err =vx_send_irq_dsp (chip, cmd)) <0 ) + err =vx_send_irq_dsp (chip, cmd); +if (err <0 )return err;/* Wait CHK = 1 */ -if ((err =vx_wait_isr_bit (chip,ISR_CHK )) <0 ) + err =vx_wait_isr_bit (chip,ISR_CHK ); +if (err <0 )return err;/* If error, Read RX */ -if ((err =vx_inb (chip,ISR )) &ISR_ERR ) { -if ((err =vx_wait_for_rx_full (chip)) <0 ) { + err =vx_inb (chip,ISR ); +if (err &ISR_ERR ) { + err =vx_wait_for_rx_full (chip); +if (err <0 ) {snd_printd (KERN_DEBUG "transfer_end: error in rx_full\n" );return err; }
@@ -232,7 +237,8 @@ int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh)if (chip->chip_status &VX_STAT_IS_STALE )return -EBUSY ; -if ((err =vx_reset_chk (chip)) <0 ) { + err =vx_reset_chk (chip); +if (err <0 ) {snd_printd (KERN_DEBUG "vx_send_msg: vx_reset_chk error\n" );return err; }
@@ -254,7 +260,8 @@ int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh) rmh->Cmd[0 ] &=MASK_1_WORD_COMMAND ;/* Wait for TX empty */ -if ((err =vx_wait_isr_bit (chip,ISR_TX_EMPTY )) <0 ) { + err =vx_wait_isr_bit (chip,ISR_TX_EMPTY ); +if (err <0 ) {snd_printd (KERN_DEBUG "vx_send_msg: wait tx empty error\n" );return err; }
@@ -265,18 +272,21 @@ int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh)vx_outb (chip,TXL , rmh->Cmd[0 ] &0xff );/* Trigger irq MESSAGE */ -if ((err =vx_send_irq_dsp (chip,IRQ_MESSAGE )) <0 ) { + err =vx_send_irq_dsp (chip,IRQ_MESSAGE ); +if (err <0 ) {snd_printd (KERN_DEBUG "vx_send_msg: send IRQ_MESSAGE error\n" );return err; }/* Wait for CHK = 1 */ -if ((err =vx_wait_isr_bit (chip,ISR_CHK )) <0 ) + err =vx_wait_isr_bit (chip,ISR_CHK ); +if (err <0 )return err;/* If error, get error value from RX */ if (vx_inb (chip,ISR ) &ISR_ERR ) { -if ((err =vx_wait_for_rx_full (chip)) <0 ) { + err =vx_wait_for_rx_full (chip); +if (err <0 ) {snd_printd (KERN_DEBUG "vx_send_msg: rx_full read error\n" );return err; }
@@ -292,7 +302,8 @@ int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh)if (rmh->LgCmd >1 ) {for (i =1 ; i < rmh->LgCmd; i++) {/* Wait for TX ready */ -if ((err =vx_wait_isr_bit (chip,ISR_TX_READY )) <0 ) { + err =vx_wait_isr_bit (chip,ISR_TX_READY ); +if (err <0 ) {snd_printd (KERN_DEBUG "vx_send_msg: tx_ready error\n" );return err; }
@@ -303,13 +314,15 @@ int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh)vx_outb (chip,TXL , rmh->Cmd[i] &0xff );/* Trigger irq MESS_READ_NEXT */ -if ((err =vx_send_irq_dsp (chip,IRQ_MESS_READ_NEXT )) <0 ) { + err =vx_send_irq_dsp (chip,IRQ_MESS_READ_NEXT ); +if (err <0 ) {snd_printd (KERN_DEBUG "vx_send_msg: IRQ_READ_NEXT error\n" );return err; } }/* Wait for TX empty */ -if ((err =vx_wait_isr_bit (chip,ISR_TX_READY )) <0 ) { + err =vx_wait_isr_bit (chip,ISR_TX_READY ); +if (err <0 ) {snd_printd (KERN_DEBUG "vx_send_msg: TX_READY error\n" );return err; }
@@ -362,17 +375,21 @@ int vx_send_rih_nolock(struct vx_core *chip, int cmd)#if 0 printk (KERN_DEBUG "send_rih: cmd = 0x%x\n" , cmd);#endif -if ((err =vx_reset_chk (chip)) <0 ) + err =vx_reset_chk (chip); +if (err <0 )return err;/* send the IRQ */ -if ((err =vx_send_irq_dsp (chip, cmd)) <0 ) + err =vx_send_irq_dsp (chip, cmd); +if (err <0 )return err;/* Wait CHK = 1 */ -if ((err =vx_wait_isr_bit (chip,ISR_CHK )) <0 ) + err =vx_wait_isr_bit (chip,ISR_CHK ); +if (err <0 )return err;/* If error, read RX */ if (vx_inb (chip,ISR ) &ISR_ERR ) { -if ((err =vx_wait_for_rx_full (chip)) <0 ) + err =vx_wait_for_rx_full (chip); +if (err <0 )return err; err =vx_inb (chip,RXH ) <<16 ; err |=vx_inb (chip,RXM ) <<8 ;
@@ -648,7 +665,8 @@ int snd_vx_dsp_boot(struct vx_core *chip, const struct firmware *boot)vx_reset_board (chip, cold_reset);vx_validate_irq (chip,0 ); -if ((err =snd_vx_load_boot_image (chip, boot)) <0 ) + err =snd_vx_load_boot_image (chip, boot); +if (err <0 )return err;msleep (10 );
@@ -678,7 +696,8 @@ int snd_vx_dsp_load(struct vx_core *chip, const struct firmware *dsp)for (i =0 ; i < dsp->size; i +=3 ) { image = dsp->data + i;/* Wait DSP ready for a new read */ -if ((err =vx_wait_isr_bit (chip,ISR_TX_EMPTY )) <0 ) { + err =vx_wait_isr_bit (chip,ISR_TX_EMPTY ); +if (err <0 ) {printk (KERN_ERR "dsp loading error at position %d\n" , i);return err;
@@ -698,7 +717,8 @@ int snd_vx_dsp_load(struct vx_core *chip, const struct firmware *dsp)msleep (200 ); -if ((err =vx_wait_isr_bit (chip,ISR_CHK )) <0 ) + err =vx_wait_isr_bit (chip,ISR_CHK ); +if (err <0 )return err;vx_toggle_dac_mute (chip,0 );
sound/drivers/vx/vx_hwdep.c +8 -4
@@ -78,15 +78,19 @@ int snd_vx_setup_firmware(struct vx_core *chip)/* ok, we reached to the last one */ /* create the devices if not built yet */ -if ((err =snd_vx_pcm_new (chip)) <0 ) + err =snd_vx_pcm_new (chip); +if (err <0 )return err; -if ((err =snd_vx_mixer_new (chip)) <0 ) + err =snd_vx_mixer_new (chip); +if (err <0 )return err; -if (chip->ops->add_controls) -if ((err = chip->ops->add_controls (chip)) <0 ) +if (chip->ops->add_controls) { + err = chip->ops->add_controls (chip); +if (err <0 )return err; + } chip->chip_status |=VX_STAT_DEVICE_INIT ; chip->chip_status |=VX_STAT_CHIP_INIT ;
sound/drivers/vx/vx_mixer.c +26 -13
@@ -910,7 +910,8 @@ int snd_vx_mixer_new(struct vx_core *chip) temp = vx_control_output_level; temp.index = i; temp.tlv.p = chip->hw->output_level_db_scale; -if ((err =snd_ctl_add (card,snd_ctl_new1 (&temp, chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&temp, chip)); +if (err <0 )return err; }
@@ -921,22 +922,26 @@ int snd_vx_mixer_new(struct vx_core *chip) temp.index = i; temp.name ="PCM Playback Volume" ; temp.private_value = val; -if ((err =snd_ctl_add (card,snd_ctl_new1 (&temp, chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&temp, chip)); +if (err <0 )return err; temp = vx_control_output_switch; temp.index = i; temp.private_value = val; -if ((err =snd_ctl_add (card,snd_ctl_new1 (&temp, chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&temp, chip)); +if (err <0 )return err; temp = vx_control_monitor_gain; temp.index = i; temp.private_value = val; -if ((err =snd_ctl_add (card,snd_ctl_new1 (&temp, chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&temp, chip)); +if (err <0 )return err; temp = vx_control_monitor_switch; temp.index = i; temp.private_value = val; -if ((err =snd_ctl_add (card,snd_ctl_new1 (&temp, chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&temp, chip)); +if (err <0 )return err; }for (i =0 ; i < chip->hw->num_outs; i++) {
@@ -944,20 +949,25 @@ int snd_vx_mixer_new(struct vx_core *chip) temp.index = i; temp.name ="PCM Capture Volume" ; temp.private_value = (i *2 ) | (1 <<8 ); -if ((err =snd_ctl_add (card,snd_ctl_new1 (&temp, chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&temp, chip)); +if (err <0 )return err; }/* Audio source */ -if ((err =snd_ctl_add (card,snd_ctl_new1 (&vx_control_audio_src, chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&vx_control_audio_src, chip)); +if (err <0 )return err;/* clock mode */ -if ((err =snd_ctl_add (card,snd_ctl_new1 (&vx_control_clock_mode, chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&vx_control_clock_mode, chip)); +if (err <0 )return err;/* IEC958 controls */ -if ((err =snd_ctl_add (card,snd_ctl_new1 (&vx_control_iec958_mask, chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&vx_control_iec958_mask, chip)); +if (err <0 )return err; -if ((err =snd_ctl_add (card,snd_ctl_new1 (&vx_control_iec958, chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&vx_control_iec958, chip)); +if (err <0 )return err;/* VU, peak, saturation meters */ for (c =0 ; c <2 ; c++) {
@@ -968,7 +978,8 @@ int snd_vx_mixer_new(struct vx_core *chip) temp = vx_control_saturation; temp.index = i; temp.private_value = val; -if ((err =snd_ctl_add (card,snd_ctl_new1 (&temp, chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&temp, chip)); +if (err <0 )return err; }sprintf (name,"%s VU Meter" , dir[c]);
@@ -976,14 +987,16 @@ int snd_vx_mixer_new(struct vx_core *chip) temp.index = i; temp.name = name; temp.private_value = val; -if ((err =snd_ctl_add (card,snd_ctl_new1 (&temp, chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&temp, chip)); +if (err <0 )return err;sprintf (name,"%s Peak Meter" , dir[c]); temp = vx_control_peak_meter; temp.index = i; temp.name = name; temp.private_value = val; -if ((err =snd_ctl_add (card,snd_ctl_new1 (&temp, chip))) <0 ) + err =snd_ctl_add (card,snd_ctl_new1 (&temp, chip)); +if (err <0 )return err; } }
sound/drivers/vx/vx_pcm.c +21 -11
@@ -341,10 +341,12 @@ static int vx_toggle_pipe(struct vx_core *chip, struct vx_pipe *pipe, int state) } } -if ((err =vx_conf_pipe (chip, pipe)) <0 ) + err =vx_conf_pipe (chip, pipe); +if (err <0 )return err; -if ((err =vx_send_irqa (chip)) <0 ) + err =vx_send_irqa (chip); +if (err <0 )return err;/* If it completes successfully, wait for the pipes
@@ -680,8 +682,9 @@ static void vx_pcm_playback_transfer(struct vx_core *chip,if (! pipe->prepared || (chip->chip_status &VX_STAT_IS_STALE ))return ;for (i =0 ; i < nchunks; i++) { -if ((err =vx_pcm_playback_transfer_chunk (chip, runtime, pipe, - chip->ibl.size)) <0 ) + err =vx_pcm_playback_transfer_chunk (chip, runtime, pipe, + chip->ibl.size); +if (err <0 )return ; } }
@@ -698,7 +701,8 @@ static void vx_pcm_playback_update(struct vx_core *chip,struct snd_pcm_runtime *runtime = subs->runtime;if (pipe->running && ! (chip->chip_status &VX_STAT_IS_STALE )) { -if ((err =vx_update_pipe_position (chip, runtime, pipe)) <0 ) + err =vx_update_pipe_position (chip, runtime, pipe); +if (err <0 )return ;if (pipe->transferred >= (int )runtime->period_size) { pipe->transferred %= runtime->period_size;
@@ -747,11 +751,13 @@ static int vx_pcm_trigger(struct snd_pcm_substream *subs, int cmd) pipe->running =0 ;break ;case SNDRV_PCM_TRIGGER_PAUSE_PUSH : -if ((err =vx_toggle_pipe (chip, pipe,0 )) <0 ) + err =vx_toggle_pipe (chip, pipe,0 ); +if (err <0 )return err;break ;case SNDRV_PCM_TRIGGER_PAUSE_RELEASE : -if ((err =vx_toggle_pipe (chip, pipe,1 )) <0 ) + err =vx_toggle_pipe (chip, pipe,1 ); +if (err <0 )return err;break ;default :
@@ -792,13 +798,15 @@ static int vx_pcm_prepare(struct snd_pcm_substream *subs)snd_printdd (KERN_DEBUG "reopen the pipe with data_mode = %d\n" , data_mode);vx_init_rmh (&rmh,CMD_FREE_PIPE );vx_set_pipe_cmd_params (&rmh,0 , pipe->number,0 ); -if ((err =vx_send_msg (chip, &rmh)) <0 ) + err =vx_send_msg (chip, &rmh); +if (err <0 )return err;vx_init_rmh (&rmh,CMD_RES_PIPE );vx_set_pipe_cmd_params (&rmh,0 , pipe->number, pipe->channels);if (data_mode) rmh.Cmd[0 ] |=BIT_DATA_MODE ; -if ((err =vx_send_msg (chip, &rmh)) <0 ) + err =vx_send_msg (chip, &rmh); +if (err <0 )return err; pipe->data_mode = data_mode; }
@@ -810,7 +818,8 @@ static int vx_pcm_prepare(struct snd_pcm_substream *subs) }vx_set_clock (chip, runtime->rate); -if ((err =vx_set_format (chip, pipe, runtime)) <0 ) + err =vx_set_format (chip, pipe, runtime); +if (err <0 )return err;if (vx_is_pcmcia (chip)) {
@@ -1187,7 +1196,8 @@ int snd_vx_pcm_new(struct vx_core *chip)unsigned int i;int err; -if ((err =vx_init_audio_io (chip)) <0 ) + err =vx_init_audio_io (chip); +if (err <0 )return err;for (i =0 ; i < chip->hw->num_codecs; i++) {
Signature · 1 line
2.26.2
PATCH 61/66 ALSA: opl3: Fix assignment in if condition
In reply to Takashi IwaiOPL3 helper 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.
--- sound/drivers/opl3/opl3_lib.c | 42 ++++++++++++++++++++++------------- sound/drivers/opl3/opl3_oss.c | 6 +++-- sound/drivers/opl3/opl3_seq.c | 9 +++++--- 3 files changed, 37 insertions(+), 20 deletions(-)
sound/drivers/opl3/opl3_lib.c +27 -15
@@ -243,7 +243,8 @@ static int snd_opl3_timer1_init(struct snd_opl3 * opl3, int timer_no) tid.card = opl3->card->number; tid.device = timer_no; tid.subdevice =0 ; -if ((err =snd_timer_new (opl3->card,"AdLib timer #1" , &tid, &timer)) >=0 ) { + err =snd_timer_new (opl3->card,"AdLib timer #1" , &tid, &timer); +if (err >=0 ) {strcpy (timer->name,"AdLib timer #1" ); timer->private_data = opl3; timer->hw = snd_opl3_timer1;
@@ -263,7 +264,8 @@ static int snd_opl3_timer2_init(struct snd_opl3 * opl3, int timer_no) tid.card = opl3->card->number; tid.device = timer_no; tid.subdevice =0 ; -if ((err =snd_timer_new (opl3->card,"AdLib timer #2" , &tid, &timer)) >=0 ) { + err =snd_timer_new (opl3->card,"AdLib timer #2" , &tid, &timer); +if (err >=0 ) {strcpy (timer->name,"AdLib timer #2" ); timer->private_data = opl3; timer->hw = snd_opl3_timer2;
@@ -348,7 +350,8 @@ int snd_opl3_new(struct snd_card *card,spin_lock_init (&opl3->reg_lock);spin_lock_init (&opl3->timer_lock); -if ((err =snd_device_new (card,SNDRV_DEV_CODEC , opl3, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_CODEC , opl3, &ops); +if (err <0 ) {snd_opl3_free (opl3);return err; }
@@ -396,19 +399,23 @@ int snd_opl3_create(struct snd_card *card,int err; *ropl3 =NULL ; -if ((err =snd_opl3_new (card, hardware, &opl3)) <0 ) + err =snd_opl3_new (card, hardware, &opl3); +if (err <0 )return err;if (! integrated) { -if ((opl3->res_l_port =request_region (l_port,2 ,"OPL2/3 (left)" )) ==NULL ) { + opl3->res_l_port =request_region (l_port,2 ,"OPL2/3 (left)" ); +if (!opl3->res_l_port) {snd_printk (KERN_ERR "opl3: can't grab left port 0x%lx\n" , l_port);snd_device_free (card, opl3);return -EBUSY ; } -if (r_port !=0 && - (opl3->res_r_port =request_region (r_port,2 ,"OPL2/3 (right)" )) ==NULL ) { -snd_printk (KERN_ERR "opl3: can't grab right port 0x%lx\n" , r_port); -snd_device_free (card, opl3); -return -EBUSY ; +if (r_port !=0 ) { + opl3->res_r_port =request_region (r_port,2 ,"OPL2/3 (right)" ); +if (!opl3->res_r_port) { +snd_printk (KERN_ERR "opl3: can't grab right port 0x%lx\n" , r_port); +snd_device_free (card, opl3); +return -EBUSY ; + } } } opl3->l_port = l_port;
@@ -423,7 +430,8 @@ int snd_opl3_create(struct snd_card *card,break ;default : opl3->command = &snd_opl2_command; -if ((err =snd_opl3_detect (opl3)) <0 ) { + err =snd_opl3_detect (opl3); +if (err <0 ) {snd_printd ("OPL2/3 chip not detected at 0x%lx/0x%lx\n" , opl3->l_port, opl3->r_port);snd_device_free (card, opl3);
@@ -449,11 +457,14 @@ int snd_opl3_timer_new(struct snd_opl3 * opl3, int timer1_dev, int timer2_dev) {int err; -if (timer1_dev >=0 ) -if ((err =snd_opl3_timer1_init (opl3, timer1_dev)) <0 ) +if (timer1_dev >=0 ) { + err =snd_opl3_timer1_init (opl3, timer1_dev); +if (err <0 )return err; + }if (timer2_dev >=0 ) { -if ((err =snd_opl3_timer2_init (opl3, timer2_dev)) <0 ) { + err =snd_opl3_timer2_init (opl3, timer2_dev); +if (err <0 ) {snd_device_free (opl3->card, opl3->timer1); opl3->timer1 =NULL ;return err;
@@ -477,7 +488,8 @@ int snd_opl3_hwdep_new(struct snd_opl3 * opl3,/* create hardware dependent device (direct FM) */ -if ((err =snd_hwdep_new (card,"OPL2/OPL3" , device, &hw)) <0 ) { + err =snd_hwdep_new (card,"OPL2/OPL3" , device, &hw); +if (err <0 ) {snd_device_free (card, opl3);return err; }
sound/drivers/opl3/opl3_oss.c +4 -2
@@ -136,7 +136,8 @@ static int snd_opl3_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure)if (snd_BUG_ON (!arg))return -ENXIO ; -if ((err =snd_opl3_synth_setup (opl3)) <0 ) + err =snd_opl3_synth_setup (opl3); +if (err <0 )return err;/* fill the argument data */
@@ -144,7 +145,8 @@ static int snd_opl3_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure) arg->addr.client = opl3->oss_chset->client; arg->addr.port = opl3->oss_chset->port; -if ((err =snd_opl3_synth_use_inc (opl3)) <0 ) + err =snd_opl3_synth_use_inc (opl3); +if (err <0 )return err; opl3->synth_mode =SNDRV_OPL3_MODE_SYNTH ;
sound/drivers/opl3/opl3_seq.c +6 -3
@@ -92,7 +92,8 @@ static int snd_opl3_synth_use(void *private_data, struct snd_seq_port_subscribestruct snd_opl3 *opl3 = private_data;int err; -if ((err =snd_opl3_synth_setup (opl3)) <0 ) + err =snd_opl3_synth_setup (opl3); +if (err <0 )return err;if (use_internal_drums) {
@@ -107,7 +108,8 @@ static int snd_opl3_synth_use(void *private_data, struct snd_seq_port_subscribe }if (info->sender.client !=SNDRV_SEQ_CLIENT_SYSTEM ) { -if ((err =snd_opl3_synth_use_inc (opl3)) <0 ) + err =snd_opl3_synth_use_inc (opl3); +if (err <0 )return err; } opl3->synth_mode =SNDRV_OPL3_MODE_SEQ ;
@@ -227,7 +229,8 @@ static int snd_opl3_seq_probe(struct device *_dev)if (client <0 )return client; -if ((err =snd_opl3_synth_create_port (opl3)) <0 ) { + err =snd_opl3_synth_create_port (opl3); +if (err <0 ) {snd_seq_delete_kernel_client (client); opl3->seq_client =-1 ;return err;
Signature · 1 line
2.26.2
PATCH 62/66 ALSA: serial: Fix assignment in if condition
In reply to Takashi IwaiA few ALSA serial drivers contain 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.
--- sound/drivers/mtpav.c | 15 +++++++++------ sound/drivers/mts64.c | 15 ++++++++++----- sound/drivers/portman2x4.c | 15 ++++++++++----- sound/drivers/serial-u16550.c | 27 ++++++++++++++------------- 4 files changed, 43 insertions(+), 29 deletions(-)
sound/drivers/mtpav.c +9 -6
@@ -566,7 +566,8 @@ static irqreturn_t snd_mtpav_irqh(int irq, void *dev_id)*/ static int snd_mtpav_get_ISA (struct mtpav *mcard) { -if ((mcard->res_port =request_region (port,3 ,"MotuMTPAV MIDI" )) ==NULL ) { + mcard->res_port =request_region (port,3 ,"MotuMTPAV MIDI" ); +if (!mcard->res_port) {snd_printk (KERN_ERR "MTVAP port 0x%lx is busy\n" , port);return -EBUSY ; }
@@ -628,10 +629,11 @@ static int snd_mtpav_get_RAWMIDI(struct mtpav *mcard) hwports =8 ; mcard->num_ports = hwports; -if ((rval =snd_rawmidi_new (mcard->card,"MotuMIDI" ,0 , - mcard->num_ports *2 +MTPAV_PIDX_BROADCAST +1 , - mcard->num_ports *2 +MTPAV_PIDX_BROADCAST +1 , - &mcard->rmidi)) <0 ) + rval =snd_rawmidi_new (mcard->card,"MotuMIDI" ,0 , + mcard->num_ports *2 +MTPAV_PIDX_BROADCAST +1 , + mcard->num_ports *2 +MTPAV_PIDX_BROADCAST +1 , + &mcard->rmidi); +if (rval <0 )return rval; rawmidi = mcard->rmidi; rawmidi->private_data = mcard;
@@ -744,7 +746,8 @@ static int __init alsa_card_mtpav_init(void) {int err; -if ((err =platform_driver_register (&snd_mtpav_driver)) <0 ) + err =platform_driver_register (&snd_mtpav_driver); +if (err <0 )return err; device =platform_device_register_simple (SND_MTPAV_DRIVER ,-1 ,NULL ,0 );
sound/drivers/mts64.c +10 -5
@@ -950,7 +950,8 @@ static int snd_mts64_probe(struct platform_device *pdev) goto free_pardev; } -if ((err =snd_mts64_create (card, pardev, &mts)) <0 ) { + err =snd_mts64_create (card, pardev, &mts); +if (err <0 ) {snd_printd ("Cannot create main component\n" ); goto release_pardev; }
@@ -963,19 +964,22 @@ static int snd_mts64_probe(struct platform_device *pdev) goto __err; } -if ((err =snd_mts64_rawmidi_create (card)) <0 ) { + err =snd_mts64_rawmidi_create (card); +if (err <0 ) {snd_printd ("Creating Rawmidi component failed\n" ); goto __err; }/* init device */ -if ((err =mts64_device_init (p)) <0 ) + err =mts64_device_init (p); +if (err <0 ) goto __err;platform_set_drvdata (pdev, card);/* At this point card will be usable */ -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_printd ("Cannot register card\n" ); goto __err; }
@@ -1031,7 +1035,8 @@ static int __init snd_mts64_module_init(void) {int err; -if ((err =platform_driver_register (&snd_mts64_driver)) <0 ) + err =platform_driver_register (&snd_mts64_driver); +if (err <0 )return err;if (parport_register_driver (&mts64_parport_driver) !=0 ) {
sound/drivers/portman2x4.c +10 -5
@@ -749,7 +749,8 @@ static int snd_portman_probe(struct platform_device *pdev) goto free_pardev; } -if ((err =portman_create (card, pardev, &pm)) <0 ) { + err =portman_create (card, pardev, &pm); +if (err <0 ) {snd_printd ("Cannot create main component\n" ); goto release_pardev; }
@@ -762,19 +763,22 @@ static int snd_portman_probe(struct platform_device *pdev) goto __err; } -if ((err =snd_portman_rawmidi_create (card)) <0 ) { + err =snd_portman_rawmidi_create (card); +if (err <0 ) {snd_printd ("Creating Rawmidi component failed\n" ); goto __err; }/* init device */ -if ((err =portman_device_init (pm)) <0 ) + err =portman_device_init (pm); +if (err <0 ) goto __err;platform_set_drvdata (pdev, card);/* At this point card will be usable */ -if ((err =snd_card_register (card)) <0 ) { + err =snd_card_register (card); +if (err <0 ) {snd_printd ("Cannot register card\n" ); goto __err; }
@@ -831,7 +835,8 @@ static int __init snd_portman_module_init(void) {int err; -if ((err =platform_driver_register (&snd_portman_driver)) <0 ) + err =platform_driver_register (&snd_portman_driver); +if (err <0 )return err;if (parport_register_driver (&portman_parport_driver) !=0 ) {
sound/drivers/serial-u16550.c +14 -13
@@ -783,7 +783,8 @@ static int snd_uart16550_create(struct snd_card *card,int err; -if ((uart =kzalloc (sizeof (*uart),GFP_KERNEL )) ==NULL ) + uart =kzalloc (sizeof (*uart),GFP_KERNEL ); +if (!uart)return -ENOMEM ; uart->adaptor = adaptor; uart->card = card;
@@ -792,7 +793,8 @@ static int snd_uart16550_create(struct snd_card *card, uart->base = iobase; uart->drop_on_full = droponfull; -if ((err =snd_uart16550_detect (uart)) <=0 ) { + err =snd_uart16550_detect (uart); +if (err <=0 ) {printk (KERN_ERR "no UART detected at 0x%lx\n" , iobase);snd_uart16550_free (uart);return -ENODEV ;
@@ -818,7 +820,8 @@ static int snd_uart16550_create(struct snd_card *card, uart->timer_running =0 ;/* Register device */ -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , uart, &ops)) <0 ) { + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , uart, &ops); +if (err <0 ) {snd_uart16550_free (uart);return err; }
@@ -932,14 +935,10 @@ static int snd_serial_probe(struct platform_device *devptr)strcpy (card->driver,"Serial" );strcpy (card->shortname,"Serial MIDI (UART16550A)" ); -if ((err =snd_uart16550_create (card, - port[dev], - irq[dev], - speed[dev], - base[dev], - adaptor[dev], - droponfull[dev], - &uart)) <0 ) + err =snd_uart16550_create (card, port[dev], irq[dev], speed[dev], + base[dev], adaptor[dev], droponfull[dev], + &uart); +if (err <0 ) goto _err; err =snd_uart16550_rmidi (uart,0 , outs[dev], ins[dev], &uart->rmidi);
@@ -952,7 +951,8 @@ static int snd_serial_probe(struct platform_device *devptr) uart->base, uart->irq); -if ((err =snd_card_register (card)) <0 ) + err =snd_card_register (card); +if (err <0 ) goto _err;platform_set_drvdata (devptr, card);
@@ -992,7 +992,8 @@ static int __init alsa_card_serial_init(void) {int i, cards, err; -if ((err =platform_driver_register (&snd_serial_driver)) <0 ) + err =platform_driver_register (&snd_serial_driver); +if (err <0 )return err; cards =0 ;
Signature · 1 line
2.26.2
PATCH 63/66 ALSA: synth: Fix assignment in if condition
In reply to Takashi IwaiEMUx synth driver 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.
--- sound/synth/emux/emux.c | 3 ++- sound/synth/emux/emux_effect.c | 13 ++++++++--- sound/synth/emux/emux_hwdep.c | 6 +++-- sound/synth/emux/soundfont.c | 40 ++++++++++++++++++++++------------ 4 files changed, 42 insertions(+), 20 deletions(-)
sound/synth/emux/emux.c +2 -1
@@ -104,7 +104,8 @@ int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, chif (emu->sflist ==NULL )return -ENOMEM ; -if ((err =snd_emux_init_hwdep (emu)) <0 ) + err =snd_emux_init_hwdep (emu); +if (err <0 )return err;snd_emux_init_voices (emu);
sound/synth/emux/emux_effect.c +10 -3
@@ -181,7 +181,10 @@ snd_emux_send_effect(struct snd_emux_port *port, struct snd_midi_channel *chan, fx->flag[type] = mode;/* do we need to modify the register in realtime ? */ -if (! parm_defs[type].update || (offset = parm_defs[type].offset) <0 ) +if (!parm_defs[type].update) +return ; + offset = parm_defs[type].offset; +if (offset <0 )return ;#ifdef SNDRV_LITTLE_ENDIAN
@@ -223,13 +226,17 @@ snd_emux_setup_effect(struct snd_emux_voice *vp)unsigned char *srcp;int i; -if (! (fx = chan->private)) + fx = chan->private; +if (!fx)return ;/* modify the register values via effect table */ for (i =0 ; i <EMUX_FX_END ; i++) {int offset; -if (! fx->flag[i] || (offset = parm_defs[i].offset) <0 ) +if (!fx->flag[i]) +continue ; + offset = parm_defs[i].offset; +if (offset <0 )continue ;#ifdef SNDRV_LITTLE_ENDIAN if (parm_defs[i].type &PARM_IS_ALIGN_HI )
sound/synth/emux/emux_hwdep.c +4 -2
@@ -116,7 +116,8 @@ snd_emux_init_hwdep(struct snd_emux *emu)struct snd_hwdep *hw;int err; -if ((err =snd_hwdep_new (emu->card,SNDRV_EMUX_HWDEP_NAME , emu->hwdep_idx, &hw)) <0 ) + err =snd_hwdep_new (emu->card,SNDRV_EMUX_HWDEP_NAME , emu->hwdep_idx, &hw); +if (err <0 )return err; emu->hwdep = hw;strcpy (hw->name,SNDRV_EMUX_HWDEP_NAME );
@@ -127,7 +128,8 @@ snd_emux_init_hwdep(struct snd_emux *emu) hw->ops.ioctl_compat = snd_emux_hwdep_ioctl; hw->exclusive =1 ; hw->private_data = emu; -if ((err =snd_card_register (emu->card)) <0 ) + err =snd_card_register (emu->card); +if (err <0 )return err;return 0 ;
sound/synth/emux/soundfont.c +26 -14
@@ -349,7 +349,8 @@ sf_zone_new(struct snd_sf_list *sflist, struct snd_soundfont *sf) {struct snd_sf_zone *zp; -if ((zp =kzalloc (sizeof (*zp),GFP_KERNEL )) ==NULL ) + zp =kzalloc (sizeof (*zp),GFP_KERNEL ); +if (!zp)return NULL ; zp->next = sf->zones; sf->zones = zp;
@@ -381,7 +382,8 @@ sf_sample_new(struct snd_sf_list *sflist, struct snd_soundfont *sf) {struct snd_sf_sample *sp; -if ((sp =kzalloc (sizeof (*sp),GFP_KERNEL )) ==NULL ) + sp =kzalloc (sizeof (*sp),GFP_KERNEL ); +if (!sp)return NULL ; sp->next = sf->samples;
@@ -451,7 +453,8 @@ load_map(struct snd_sf_list *sflist, const void __user *data, int count) }/* create a new zone */ -if ((zp =sf_zone_new (sflist, sf)) ==NULL ) + zp =sf_zone_new (sflist, sf); +if (!zp)return -ENOMEM ; zp->bank = map.map_bank;
@@ -514,7 +517,8 @@ load_info(struct snd_sf_list *sflist, const void __user *data, long count)int i;/* patch must be opened */ -if ((sf = sflist->currsf) ==NULL ) + sf = sflist->currsf; +if (!sf)return -EINVAL ;if (is_special_type (sf->type))
@@ -579,9 +583,9 @@ load_info(struct snd_sf_list *sflist, const void __user *data, long count)init_voice_parm (&tmpzone.v.parm);/* create a new zone */ -if ((zone =sf_zone_new (sflist, sf)) ==NULL ) { + zone =sf_zone_new (sflist, sf); +if (!zone)return -ENOMEM ; - }/* copy the temporary data */ zone->bank = tmpzone.bank;
@@ -700,7 +704,8 @@ load_data(struct snd_sf_list *sflist, const void __user *data, long count)long off;/* patch must be opened */ -if ((sf = sflist->currsf) ==NULL ) + sf = sflist->currsf; +if (!sf)return -EINVAL ;if (is_special_type (sf->type))
@@ -723,7 +728,8 @@ load_data(struct snd_sf_list *sflist, const void __user *data, long count) }/* Allocate a new sample structure */ -if ((sp =sf_sample_new (sflist, sf)) ==NULL ) + sp =sf_sample_new (sflist, sf); +if (!sp)return -ENOMEM ; sp->v = sample_info;
@@ -958,7 +964,8 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data, sf =newsf (sflist,SNDRV_SFNT_PAT_TYPE_GUS |SNDRV_SFNT_PAT_SHARED ,NULL );if (sf ==NULL )return -ENOMEM ; -if ((smp =sf_sample_new (sflist, sf)) ==NULL ) + smp =sf_sample_new (sflist, sf); +if (!smp)return -ENOMEM ; sample_id = sflist->sample_counter; smp->v.sample = sample_id;
@@ -996,7 +1003,8 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data, smp->v.sf_id = sf->id;/* set up voice info */ -if ((zone =sf_zone_new (sflist, sf)) ==NULL ) { + zone =sf_zone_new (sflist, sf); +if (!zone) {sf_sample_delete (sflist, sf, smp);return -ENOMEM ; }
@@ -1181,7 +1189,8 @@ add_preset(struct snd_sf_list *sflist, struct snd_sf_zone *cur) }/* prepend this zone */ -if ((index =get_index (cur->bank, cur->instr, cur->v.low)) <0 ) + index =get_index (cur->bank, cur->instr, cur->v.low); +if (index <0 )return ; cur->next_zone = zone;/* zone link */ cur->next_instr = sflist->presets[index];/* preset table link */
@@ -1197,7 +1206,8 @@ delete_preset(struct snd_sf_list *sflist, struct snd_sf_zone *zp)int index;struct snd_sf_zone *p; -if ((index =get_index (zp->bank, zp->instr, zp->v.low)) <0 ) + index =get_index (zp->bank, zp->instr, zp->v.low); +if (index <0 )return ;for (p = sflist->presets[index]; p; p = p->next_instr) {while (p->next_instr == zp) {
@@ -1257,7 +1267,8 @@ search_first_zone(struct snd_sf_list *sflist, int bank, int preset, int key)int index;struct snd_sf_zone *zp; -if ((index =get_index (bank, preset, key)) <0 ) + index =get_index (bank, preset, key); +if (index <0 )return NULL ;for (zp = sflist->presets[index]; zp; zp = zp->next_instr) {if (zp->instr == preset && zp->bank == bank)
@@ -1386,7 +1397,8 @@ snd_sf_new(struct snd_sf_callback *callback, struct snd_util_memhdr *hdr) {struct snd_sf_list *sflist; -if ((sflist =kzalloc (sizeof (*sflist),GFP_KERNEL )) ==NULL ) + sflist =kzalloc (sizeof (*sflist),GFP_KERNEL ); +if (!sflist)return NULL ;mutex_init (&sflist->presets_mutex);
Signature · 1 line
2.26.2
PATCH 64/66 ALSA: poewrmac: Fix assignment in if condition
In reply to Takashi IwaiPPC powermac 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.
--- sound/ppc/beep.c | 5 ++- sound/ppc/daca.c | 24 ++++++++++----- sound/ppc/keywest.c | 6 ++-- sound/ppc/pmac.c | 6 ++-- sound/ppc/powermac.c | 21 ++++++++----- sound/ppc/tumbler.c | 72 +++++++++++++++++++++++++++++--------------- 6 files changed, 89 insertions(+), 45 deletions(-)
sound/ppc/beep.c +4 -1
@@ -105,7 +105,10 @@ static int snd_pmac_beep_event(struct input_dev *dev, unsigned int type, } chip =input_get_drvdata (dev); -if (! chip || (beep = chip->beep) ==NULL ) +if (!chip) +return -1 ; + beep = chip->beep; +if (!beep)return -1 ;if (! hz) {
sound/ppc/daca.c +16 -8
@@ -84,7 +84,8 @@ static int daca_get_deemphasis(struct snd_kcontrol *kcontrol, {struct snd_pmac *chip =snd_kcontrol_chip (kcontrol);struct pmac_daca *mix; -if (! (mix = chip->mixer_data)) + mix = chip->mixer_data; +if (!mix)return -ENODEV ; ucontrol->value.integer.value[0 ] = mix->deemphasis ?1 :0 ;return 0 ;
@@ -97,7 +98,8 @@ static int daca_put_deemphasis(struct snd_kcontrol *kcontrol,struct pmac_daca *mix;int change; -if (! (mix = chip->mixer_data)) + mix = chip->mixer_data; +if (!mix)return -ENODEV ; change = mix->deemphasis != ucontrol->value.integer.value[0 ];if (change) {
@@ -123,7 +125,8 @@ static int daca_get_volume(struct snd_kcontrol *kcontrol, {struct snd_pmac *chip =snd_kcontrol_chip (kcontrol);struct pmac_daca *mix; -if (! (mix = chip->mixer_data)) + mix = chip->mixer_data; +if (!mix)return -ENODEV ; ucontrol->value.integer.value[0 ] = mix->left_vol; ucontrol->value.integer.value[1 ] = mix->right_vol;
@@ -138,7 +141,8 @@ static int daca_put_volume(struct snd_kcontrol *kcontrol,unsigned int vol[2 ];int change; -if (! (mix = chip->mixer_data)) + mix = chip->mixer_data; +if (!mix)return -ENODEV ; vol[0 ] = ucontrol->value.integer.value[0 ]; vol[1 ] = ucontrol->value.integer.value[1 ];
@@ -162,7 +166,8 @@ static int daca_get_amp(struct snd_kcontrol *kcontrol, {struct snd_pmac *chip =snd_kcontrol_chip (kcontrol);struct pmac_daca *mix; -if (! (mix = chip->mixer_data)) + mix = chip->mixer_data; +if (!mix)return -ENODEV ; ucontrol->value.integer.value[0 ] = mix->amp_on ?1 :0 ;return 0 ;
@@ -175,7 +180,8 @@ static int daca_put_amp(struct snd_kcontrol *kcontrol,struct pmac_daca *mix;int change; -if (! (mix = chip->mixer_data)) + mix = chip->mixer_data; +if (!mix)return -ENODEV ; change = mix->amp_on != ucontrol->value.integer.value[0 ];if (change) {
@@ -248,7 +254,8 @@ int snd_pmac_daca_init(struct snd_pmac *chip) mix->i2c.addr =DACA_I2C_ADDR ; mix->i2c.init_client = daca_init_client; mix->i2c.name ="DACA" ; -if ((err =snd_pmac_keywest_init (&mix->i2c)) <0 ) + err =snd_pmac_keywest_init (&mix->i2c); +if (err <0 )return err;/*
@@ -257,7 +264,8 @@ int snd_pmac_daca_init(struct snd_pmac *chip)strcpy (chip->card->mixername,"PowerMac DACA" );for (i =0 ; i <ARRAY_SIZE (daca_mixers); i++) { -if ((err =snd_ctl_add (chip->card,snd_ctl_new1 (&daca_mixers[i], chip))) <0 ) + err =snd_ctl_add (chip->card,snd_ctl_new1 (&daca_mixers[i], chip)); +if (err <0 )return err; }
sound/ppc/keywest.c +4 -2
@@ -114,7 +114,8 @@ int snd_pmac_tumbler_post_init(void)if (!keywest_ctx || !keywest_ctx->client)return -ENXIO ; -if ((err = keywest_ctx->init_client (keywest_ctx)) <0 ) { + err = keywest_ctx->init_client (keywest_ctx); +if (err <0 ) {snd_printk (KERN_ERR "tumbler: %i :cannot initialize the MCS\n" , err);return err; }
@@ -136,7 +137,8 @@ int snd_pmac_keywest_init(struct pmac_keywest *i2c) keywest_ctx = i2c; -if ((err =i2c_add_driver (&keywest_driver))) { + err =i2c_add_driver (&keywest_driver); +if (err) {snd_printk (KERN_ERR "cannot register keywest i2c driver\n" );i2c_put_adapter (adap);return err;
sound/ppc/pmac.c +4 -2
@@ -1160,7 +1160,8 @@ int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return) chip->playback.stream =SNDRV_PCM_STREAM_PLAYBACK ; chip->capture.stream =SNDRV_PCM_STREAM_CAPTURE ; -if ((err =snd_pmac_detect (chip)) <0 ) + err =snd_pmac_detect (chip); +if (err <0 ) goto __error; if (snd_pmac_dbdma_alloc(chip, &chip->playback.cmd, PMAC_MAX_FRAGS + 1) < 0 ||
@@ -1299,7 +1300,8 @@ int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)/* Reset dbdma channels */ snd_pmac_dbdma_reset (chip); -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops)) <0 ) + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops); +if (err <0 ) goto __error; *chip_return = chip;
sound/ppc/powermac.c +14 -7
@@ -48,7 +48,8 @@ static int snd_pmac_probe(struct platform_device *devptr)if (err <0 )return err; -if ((err =snd_pmac_new (card, &chip)) <0 ) + err =snd_pmac_new (card, &chip); +if (err <0 ) goto __error; card->private_data = chip;
@@ -58,7 +59,8 @@ static int snd_pmac_probe(struct platform_device *devptr)strcpy (card->shortname,"PowerMac Burgundy" );sprintf (card->longname,"%s (Dev %d) Sub-frame %d" , card->shortname, chip->device_id, chip->subframe); -if ((err =snd_pmac_burgundy_init (chip)) <0 ) + err =snd_pmac_burgundy_init (chip); +if (err <0 ) goto __error;break ;case PMAC_DACA :
@@ -66,7 +68,8 @@ static int snd_pmac_probe(struct platform_device *devptr)strcpy (card->shortname,"PowerMac DACA" );sprintf (card->longname,"%s (Dev %d) Sub-frame %d" , card->shortname, chip->device_id, chip->subframe); -if ((err =snd_pmac_daca_init (chip)) <0 ) + err =snd_pmac_daca_init (chip); +if (err <0 ) goto __error;break ;case PMAC_TUMBLER :
@@ -92,7 +95,8 @@ static int snd_pmac_probe(struct platform_device *devptr) name_ext ="" ;sprintf (card->longname,"%s%s Rev %d" , card->shortname, name_ext, chip->revision); -if ((err =snd_pmac_awacs_init (chip)) <0 ) + err =snd_pmac_awacs_init (chip); +if (err <0 ) goto __error;break ;default :
@@ -101,14 +105,16 @@ static int snd_pmac_probe(struct platform_device *devptr) goto __error; } -if ((err =snd_pmac_pcm_new (chip)) <0 ) + err =snd_pmac_pcm_new (chip); +if (err <0 ) goto __error; chip->initialized =1 ;if (enable_beep)snd_pmac_attach_beep (chip); -if ((err =snd_card_register (card)) <0 ) + err =snd_card_register (card); +if (err <0 ) goto __error;platform_set_drvdata (devptr, card);
@@ -162,7 +168,8 @@ static int __init alsa_card_pmac_init(void) {int err; -if ((err =platform_driver_register (&snd_pmac_driver)) <0 ) + err =platform_driver_register (&snd_pmac_driver); +if (err <0 )return err; device =platform_device_register_simple (SND_PMAC_DRIVER ,-1 ,NULL ,0 );return 0 ;
sound/ppc/tumbler.c +47 -25
184 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 65/66 ALSA: i2c: Fix assignment in if condition
In reply to Takashi IwaiALSA 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.
--- sound/i2c/cs8427.c | 24 ++++++++++++++++-------- sound/i2c/other/ak4114.c | 3 ++- sound/i2c/other/ak4117.c | 3 ++- sound/i2c/tea6330t.c | 24 ++++++++++++++++-------- 4 files changed, 36 insertions(+), 18 deletions(-)
sound/i2c/cs8427.c +16 -8
@@ -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);
sound/i2c/other/ak4114.c +2 -1
@@ -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)
sound/i2c/other/ak4117.c +2 -1
@@ -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)
sound/i2c/tea6330t.c +16 -8
@@ -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; }
Signature · 1 line
2.26.2
PATCH 66/66 ALSA: parisc: Fix assignment in if condition
In reply to Takashi IwaiPARISC harmony driver code contains an assignment 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.
--- sound/parisc/harmony.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
sound/parisc/harmony.c +3 -4
@@ -915,10 +915,9 @@ snd_harmony_create(struct snd_card *card,spin_lock_init (&h->mixer_lock);spin_lock_init (&h->lock); -if ((err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , - h, &ops)) <0 ) { - goto free_and_ret; - } + err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , h, &ops); +if (err <0 ) + goto free_and_ret; *rchip = h;
Signature · 1 line
2.26.2