From patchwork Tue Jun 8 14:04:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455881 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 554D5C47082 for ; Tue, 8 Jun 2021 14:07:40 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 79A6660FE9 for ; Tue, 8 Jun 2021 14:07:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 79A6660FE9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 1368116FD; Tue, 8 Jun 2021 16:06:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1368116FD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161258; bh=WRnu6g38dCY+7Ih3WEO5Xi6lECbUzr+L3YoJuTVhn8Y=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=rxqTv+Nj/SaNZG/QRE0uH4G8JqGSAOEpkh4+M+YsXm3HzSJWmrRUYF4H/WSLEGtVl L0xczIZujHbbn3Qj4EJ5OR+qP493qddvFpE4iN38qfx9XZDFJPXeI9KqrwTtGMcbwN WBqL5fgRSHasXTmB4f7/xsRgvTIEtpH5nvGnvSjk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 83A4DF8052E; Tue, 8 Jun 2021 16:05:57 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BC796F800FD; Tue, 8 Jun 2021 16:05:53 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 668B6F80218 for ; Tue, 8 Jun 2021 16:05:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 668B6F80218 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="zn6OXKZB"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="v9z0UnGH" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 8BB6F1FD46 for ; Tue, 8 Jun 2021 14:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161142; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Gxq0e3xUz5zY4k+XVIMj6L2KwO5Fi+p/Z4Efuyyx/RY=; b=zn6OXKZBrxojYTJedtNZF8aTlsCXBc+CI43uIdlkfEo3OJQkaxZbjqcmP0OAd/itBRlt7W aCyKmkz2scMJ0xyjb4QsJNB1vGclEPCEzDRVjiSbkoo3TiGJ2B1olcBPOqRJQvTj3Byc6S jZpRrx5mY//9bUsuSBHzXPpaQl0B/fI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161142; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Gxq0e3xUz5zY4k+XVIMj6L2KwO5Fi+p/Z4Efuyyx/RY=; b=v9z0UnGHG3FbvqCK9MVdoyQq/mFS27jS2T7mATYZVFmkikFbmgiDOhG5BBlMQWJSMJko3T WTIB/6CCy4yIz3AQ== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 78961A3B84; Tue, 8 Jun 2021 14:05:42 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 01/66] ALSA: sb: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:35 +0200 Message-Id: <20210608140540.17885-2-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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.) Signed-off-by: Takashi Iwai --- 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(-) diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c index 1c90421a88dc..896a862a9f9c 100644 --- a/sound/isa/sb/emu8000.c +++ b/sound/isa/sb/emu8000.c @@ -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; } diff --git a/sound/isa/sb/emu8000_patch.c b/sound/isa/sb/emu8000_patch.c index 0cb94cafb4c9..8c1e7f2bfc34 100644 --- a/sound/isa/sb/emu8000_patch.c +++ b/sound/isa/sb/emu8000_patch.c @@ -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 */ diff --git a/sound/isa/sb/emu8000_pcm.c b/sound/isa/sb/emu8000_pcm.c index 8e8257c574b0..f8d90a1e989b 100644 --- a/sound/isa/sb/emu8000_pcm.c +++ b/sound/isa/sb/emu8000_pcm.c @@ -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 inde struct 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; diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c index 63ef960abd25..d0f797c02841 100644 --- a/sound/isa/sb/sb16.c +++ b/sound/isa/sb/sb16.c @@ -332,14 +332,9 @@ static int snd_sb16_probe(struct snd_card *card, int dev) xdma8 = dma8[dev]; xdma16 = dma16[dev]; - if ((err = snd_sbdsp_create(card, - port[dev], - xirq, - snd_sb16dsp_interrupt, - xdma8, - xdma16, - SB_HW_AUTO, - &chip)) < 0) + err = snd_sbdsp_create(card, port[dev], xirq, snd_sb16dsp_interrupt, + xdma8, xdma16, SB_HW_AUTO, &chip); + if (err < 0) return err; acard->chip = chip; @@ -348,10 +343,14 @@ static int snd_sb16_probe(struct snd_card *card, int dev) return -ENODEV; } chip->mpu_port = mpu_port[dev]; - if (! is_isapnp_selected(dev) && (err = snd_sb16dsp_configure(chip)) < 0) - return err; + if (!is_isapnp_selected(dev)) { + err = snd_sb16dsp_configure(chip); + if (err < 0) + return err; + } - if ((err = snd_sb16dsp_pcm(chip, 0)) < 0) + err = snd_sb16dsp_pcm(chip, 0); + if (err < 0) return err; strcpy(card->driver, @@ -371,10 +370,11 @@ static int snd_sb16_probe(struct snd_card *card, int dev) xdma8 >= 0 ? "&" : "", xdma16); if (chip->mpu_port > 0 && chip->mpu_port != SNDRV_AUTO_PORT) { - if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_SB, - chip->mpu_port, - MPU401_INFO_IRQ_HOOK, -1, - &chip->rmidi)) < 0) + err = snd_mpu401_uart_new(card, 0, MPU401_HW_SB, + chip->mpu_port, + MPU401_INFO_IRQ_HOOK, -1, + &chip->rmidi); + if (err < 0) return err; chip->rmidi_callback = snd_mpu401_uart_interrupt; } @@ -397,12 +397,14 @@ static int snd_sb16_probe(struct snd_card *card, int dev) #else int seqdev = 1; #endif - if ((err = snd_opl3_hwdep_new(opl3, 0, seqdev, &synth)) < 0) + err = snd_opl3_hwdep_new(opl3, 0, seqdev, &synth); + if (err < 0) return err; } } - if ((err = snd_sbmixer_new(chip)) < 0) + err = snd_sbmixer_new(chip); + if (err < 0) return err; #ifdef CONFIG_SND_SB16_CSP @@ -419,8 +421,9 @@ static int snd_sb16_probe(struct snd_card *card, int dev) #endif #ifdef SNDRV_SBAWE_EMU8000 if (awe_port[dev] > 0) { - if ((err = snd_emu8000_new(card, 1, awe_port[dev], - seq_ports[dev], NULL)) < 0) { + err = snd_emu8000_new(card, 1, awe_port[dev], + seq_ports[dev], NULL); + if (err < 0) { snd_printk(KERN_ERR PFX "fatal error - EMU-8000 synthesizer not detected at 0x%lx\n", awe_port[dev]); return err; @@ -435,7 +438,8 @@ static int snd_sb16_probe(struct snd_card *card, int dev) (mic_agc[dev] ? 0x00 : 0x01)); spin_unlock_irqrestore(&chip->mixer_lock, flags); - if ((err = snd_card_register(card)) < 0) + err = snd_card_register(card); + if (err < 0) return err; return 0; @@ -484,7 +488,8 @@ static int snd_sb16_isa_probe1(int dev, struct device *pdev) awe_port[dev] = port[dev] + 0x400; #endif - if ((err = snd_sb16_probe(card, dev)) < 0) { + err = snd_sb16_probe(card, dev); + if (err < 0) { snd_card_free(card); return err; } @@ -506,19 +511,22 @@ static int snd_sb16_isa_probe(struct device *pdev, unsigned int dev) static const int possible_dmas16[] = {5, 6, 7, -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 (dma8[dev] == SNDRV_AUTO_DMA) { - if ((dma8[dev] = snd_legacy_find_free_dma(possible_dmas8)) < 0) { + dma8[dev] = snd_legacy_find_free_dma(possible_dmas8); + if (dma8[dev] < 0) { snd_printk(KERN_ERR PFX "unable to find a free 8-bit DMA\n"); return -EBUSY; } } if (dma16[dev] == SNDRV_AUTO_DMA) { - if ((dma16[dev] = snd_legacy_find_free_dma(possible_dmas16)) < 0) { + dma16[dev] = snd_legacy_find_free_dma(possible_dmas16); + if (dma16[dev] < 0) { snd_printk(KERN_ERR PFX "unable to find a free 16-bit DMA\n"); return -EBUSY; } @@ -591,8 +599,13 @@ static int snd_sb16_pnp_detect(struct pnp_card_link *pcard, res = snd_sb16_card_new(&pcard->card->dev, dev, &card); if (res < 0) return res; - if ((res = snd_card_sb16_pnp(dev, card->private_data, pcard, pid)) < 0 || - (res = snd_sb16_probe(card, dev)) < 0) { + res = snd_card_sb16_pnp(dev, card->private_data, pcard, pid); + if (res < 0) { + snd_card_free(card); + return res; + } + res = snd_sb16_probe(card, dev); + if (res < 0) { snd_card_free(card); return res; } diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c index 4789345a8fdd..d6ce6b16421c 100644 --- a/sound/isa/sb/sb16_csp.c +++ b/sound/isa/sb/sb16_csp.c @@ -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; } diff --git a/sound/isa/sb/sb16_main.c b/sound/isa/sb/sb16_main.c index 38dc1fde25f3..8945ee194ab6 100644 --- a/sound/isa/sb/sb16_main.c +++ b/sound/isa/sb/sb16_main.c @@ -703,7 +703,8 @@ static int snd_sb16_dma_control_put(struct snd_kcontrol *kcontrol, struct snd_ct unsigned 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; diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c index 6c9d534ce8b6..de68ac5df35b 100644 --- a/sound/isa/sb/sb8.c +++ b/sound/isa/sb/sb8.c @@ -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); diff --git a/sound/isa/sb/sb8_main.c b/sound/isa/sb/sb8_main.c index 8d01692c4f2a..2ed176a5a574 100644 --- a/sound/isa/sb/sb8_main.c +++ b/sound/isa/sb/sb8_main.c @@ -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; diff --git a/sound/isa/sb/sb8_midi.c b/sound/isa/sb/sb8_midi.c index 8c01460539ed..618366d5d984 100644 --- a/sound/isa/sb/sb8_midi.c +++ b/sound/isa/sb/sb8_midi.c @@ -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); diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c index 61ea4078aa95..57121218ed24 100644 --- a/sound/isa/sb/sb_common.c +++ b/sound/isa/sb/sb_common.c @@ -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; } diff --git a/sound/isa/sb/sb_mixer.c b/sound/isa/sb/sb_mixer.c index 5de5506e7e60..fffd681e5bf7 100644 --- a/sound/isa/sb/sb_mixer.c +++ b/sound/isa/sb/sb_mixer.c @@ -485,7 +485,8 @@ int snd_sbmixer_add_ctl(struct snd_sb *chip, const char *name, int index, int ty strscpy(ctl->id.name, name, sizeof(ctl->id.name)); ctl->id.index = index; ctl->private_value = value; - if ((err = snd_ctl_add(chip->card, ctl)) < 0) + err = snd_ctl_add(chip->card, ctl); + if (err < 0) return err; return 0; } @@ -736,33 +737,36 @@ int snd_sbmixer_new(struct snd_sb *chip) return 0; /* no mixer chip on SB1.x */ case SB_HW_20: case SB_HW_201: - if ((err = snd_sbmixer_init(chip, - snd_sb20_controls, - ARRAY_SIZE(snd_sb20_controls), - snd_sb20_init_values, - ARRAY_SIZE(snd_sb20_init_values), - "CTL1335")) < 0) + err = snd_sbmixer_init(chip, + snd_sb20_controls, + ARRAY_SIZE(snd_sb20_controls), + snd_sb20_init_values, + ARRAY_SIZE(snd_sb20_init_values), + "CTL1335"); + if (err < 0) return err; break; case SB_HW_PRO: case SB_HW_JAZZ16: - if ((err = snd_sbmixer_init(chip, - snd_sbpro_controls, - ARRAY_SIZE(snd_sbpro_controls), - snd_sbpro_init_values, - ARRAY_SIZE(snd_sbpro_init_values), - "CTL1345")) < 0) + err = snd_sbmixer_init(chip, + snd_sbpro_controls, + ARRAY_SIZE(snd_sbpro_controls), + snd_sbpro_init_values, + ARRAY_SIZE(snd_sbpro_init_values), + "CTL1345"); + if (err < 0) return err; break; case SB_HW_16: case SB_HW_ALS100: case SB_HW_CS5530: - if ((err = snd_sbmixer_init(chip, - snd_sb16_controls, - ARRAY_SIZE(snd_sb16_controls), - snd_sb16_init_values, - ARRAY_SIZE(snd_sb16_init_values), - "CTL1745")) < 0) + err = snd_sbmixer_init(chip, + snd_sb16_controls, + ARRAY_SIZE(snd_sb16_controls), + snd_sb16_init_values, + ARRAY_SIZE(snd_sb16_init_values), + "CTL1745"); + if (err < 0) return err; break; case SB_HW_ALS4000: @@ -775,12 +779,13 @@ int snd_sbmixer_new(struct snd_sb *chip) "ALS4000"); if (err < 0) return err; - if ((err = snd_sbmixer_init(chip, - snd_als4000_controls, - ARRAY_SIZE(snd_als4000_controls), - snd_als4000_init_values, - ARRAY_SIZE(snd_als4000_init_values), - "ALS4000")) < 0) + err = snd_sbmixer_init(chip, + snd_als4000_controls, + ARRAY_SIZE(snd_als4000_controls), + snd_als4000_init_values, + ARRAY_SIZE(snd_als4000_init_values), + "ALS4000"); + if (err < 0) return err; break; case SB_HW_DT019X: From patchwork Tue Jun 8 14:04:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455876 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54ED3C47082 for ; Tue, 8 Jun 2021 14:11:14 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CC2B060FE9 for ; Tue, 8 Jun 2021 14:11:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC2B060FE9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 76C42170E; Tue, 8 Jun 2021 16:10:22 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 76C42170E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161472; bh=14jP5jddyB48X39alTroo9ykaGEgrVE8RJlUwv5Z/zw=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ToposTrBavLfgx0NxuyA8s/MQ9JNswDmQ4V48eM7IsP14mw86DN11b1z7y76vKejR jo0TOLkV3EyLPtDVkJHRrYFhjdf6yNiTk/iSRj9JGvA/i+thCC6W4OsSHgUDmCnCEu Wt3WEHf0rQu3ZHAID1Ab2sOLVJNTA2NhorRJhtDg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 46DC0F80578; Tue, 8 Jun 2021 16:06:17 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CF056F804C2; Tue, 8 Jun 2021 16:06:09 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 08FBEF804C1 for ; Tue, 8 Jun 2021 16:05:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 08FBEF804C1 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="FySVDpYg"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="HnZq+Lsm" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 9987C1FD4B for ; Tue, 8 Jun 2021 14:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161142; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zqVC2xuRnBWCO44luoZ+mUvshtShSe+5Y9DTqvWzOYI=; b=FySVDpYgC0NEcTTof5UW9oQkOGV+0IIz9dOx9GKfd1FoqCaZbGuw0+6Jg3CyJ+XYx+afMk 2z9/4YB/KVx9T65Av2i91sZuO5XrCxP4JJUN04rvlwyQYxXTRVX6x9z1VpiRBtCYfay63R EsLotxxgqCGr+eFgUm4YEwP8J6XMpwc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161142; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zqVC2xuRnBWCO44luoZ+mUvshtShSe+5Y9DTqvWzOYI=; b=HnZq+LsmUO1KSRzmbZI+CAxJdT7itUIgTeeLgvi3/fOejWeEFMpyzMwRtrhurGESsO9fUb ALAOEqdF8NJqVvDQ== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 8A5A7A3B85; Tue, 8 Jun 2021 14:05:42 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 02/66] ALSA: sb: Minor coding style fixes Date: Tue, 8 Jun 2021 16:04:36 +0200 Message-Id: <20210608140540.17885-3-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" The 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. Signed-off-by: Takashi Iwai --- sound/isa/sb/emu8000.c | 10 +++++----- sound/isa/sb/sb16_csp.c | 19 +++++++++---------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c index 896a862a9f9c..5e4187940265 100644 --- a/sound/isa/sb/emu8000.c +++ b/sound/isa/sb/emu8000.c @@ -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; diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c index d6ce6b16421c..dec68ae6b599 100644 --- a/sound/isa/sb/sb16_csp.c +++ b/sound/isa/sb/sb16_csp.c @@ -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; From patchwork Tue Jun 8 14:04:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455878 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91190C47082 for ; Tue, 8 Jun 2021 14:09:57 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1DE8C60FE9 for ; Tue, 8 Jun 2021 14:09:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1DE8C60FE9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C0DF41717; Tue, 8 Jun 2021 16:09:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C0DF41717 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161395; bh=ctK53MDcd7HJ+YhqD/qQxvRVdabwy/t+BvA1U+GegK8=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Ye2Edz213P/OvY9LjK1nlS+6ph/c1TafVnYxGu837JkQMiDDFKDBc1KLOjoeyRms3 EhJcyMgInbUL27I7Kfm9m9czazL1RqIW1qvXfZfwcsyqWz86FFOjD1lzQssYUe8soV 8riyvh+ZT2jfFvAmB28ddZUs/msdryrGUQpXugKo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1BF92F8055A; Tue, 8 Jun 2021 16:06:11 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1BF7AF80557; Tue, 8 Jun 2021 16:06:07 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 091C0F804C2 for ; Tue, 8 Jun 2021 16:05:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 091C0F804C2 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="SqxNeqac"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="ZpHDB+99" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id A6CBF21956 for ; Tue, 8 Jun 2021 14:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161142; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ENsinWi7lONbu091FCneoMX/KYLLPwssYarjCCW12YU=; b=SqxNeqacc934d9u4E/1NDMQUE8u3X+ADGjGBdM+0N0v+JDCS+0K/+Wky96rIYty6YhkvCQ 1ecSDSSF3FQINYzQaoLorpFfCMEcv9j2ulkQ7S8JZ/vSGIsom+co6IUaq4uthNhr5QvC9S VwWi4AGXJRw9c5GS2KD2wwjuY3nf1Vs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161142; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ENsinWi7lONbu091FCneoMX/KYLLPwssYarjCCW12YU=; b=ZpHDB+99zwT93qVDw8fcl4VTXKz9TJ64u8ixcc9KlNMxYWXJip1ZuAlxORo5PcK0yCuu9C uRKlbozvjfM7vBAg== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 97E7EA3B84; Tue, 8 Jun 2021 14:05:42 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 03/66] ALSA: sb: Fix potential double-free of CSP mixer elements Date: Tue, 8 Jun 2021 16:04:37 +0200 Message-Id: <20210608140540.17885-4-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" snd_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. Signed-off-by: Takashi Iwai --- sound/isa/sb/sb16_csp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c index dec68ae6b599..5bbe6695689d 100644 --- a/sound/isa/sb/sb16_csp.c +++ b/sound/isa/sb/sb16_csp.c @@ -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 */ From patchwork Tue Jun 8 14:04:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455874 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4651C4743E for ; Tue, 8 Jun 2021 14:12:49 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E34676108E for ; Tue, 8 Jun 2021 14:12:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E34676108E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 81A4D16FD; Tue, 8 Jun 2021 16:11:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 81A4D16FD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161567; bh=laEbkPFPYqGO6VM7qX7LcMu22cBXGPKwYRDwK4rnYes=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=PArgQ2Es9348WIRVKVD7u5VWqBBc5xiVq70Zq6Nu4wiij6LAjFyq5mgoGoBxLoAAE osPx5ss7EVVAJhpi+gw8KEi/9Q1TuTEuF6Bn/Gc5g2UDJNeh1EXHNHlioTjII0qHrd xo7BrDB2Ee6g7meph7NRcyKNS2qfHqlaYxcoQook= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id F30B5F805AE; Tue, 8 Jun 2021 16:06:24 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 64420F8059F; Tue, 8 Jun 2021 16:06:19 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 10FC0F804BD for ; Tue, 8 Jun 2021 16:05:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 10FC0F804BD Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="m3BtcsEK"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Nq0mTtT5" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id B8E35219DB for ; Tue, 8 Jun 2021 14:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161142; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jDF2sBNWUYC12MOHbm7tU0/aT8lXOQZE6vT1pu0DXbU=; b=m3BtcsEKpYboTM8wxFhsM76UovWTjSC0yr4KrrHHwF78HcWtFFDj6Q9/QVM5YMd+0lOOGc fpr4YDP0LP8jjyr6GQxA+1kF5dYu9D/FEqLhb1y30nfU414ZO0wqUBGR5TI016eUDnxGlQ qORVJK0+2TWrfFJtiJolVElyRzFDu6w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161142; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jDF2sBNWUYC12MOHbm7tU0/aT8lXOQZE6vT1pu0DXbU=; b=Nq0mTtT5o6HoPoI/BEfuSez0FvgJ5HoXkJZZ/KNxe92Kb/MjhP98NDrGcqdvFfP6nRFCEE 8ItEJG2m4VAG2PDA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id A5881A3B85; Tue, 8 Jun 2021 14:05:42 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 04/66] ALSA: gus: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:38 +0200 Message-Id: <20210608140540.17885-5-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" ISA 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. Signed-off-by: Takashi Iwai --- 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(-) diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c index 46bfc5ae17c0..e7abbba9f377 100644 --- a/sound/isa/gus/gus_main.c +++ b/sound/isa/gus/gus_main.c @@ -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; diff --git a/sound/isa/gus/gus_mem.c b/sound/isa/gus/gus_mem.c index cb02d18dde60..ff9480f249fe 100644 --- a/sound/isa/gus/gus_mem.c +++ b/sound/isa/gus/gus_mem.c @@ -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; diff --git a/sound/isa/gus/gus_mixer.c b/sound/isa/gus/gus_mixer.c index 201d0c40d0d9..03f9cfcbf601 100644 --- a/sound/isa/gus/gus_mixer.c +++ b/sound/isa/gus/gus_mixer.c @@ -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; } } diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c index aca4ab90e5bc..230f65a0e4b0 100644 --- a/sound/isa/gus/gus_pcm.c +++ b/sound/isa/gus/gus_pcm.c @@ -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; diff --git a/sound/isa/gus/gus_uart.c b/sound/isa/gus/gus_uart.c index 4fb4ed79e262..3975848160e7 100644 --- a/sound/isa/gus/gus_uart.c +++ b/sound/isa/gus/gus_uart.c @@ -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); diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c index 0fba5d8fe84f..bca1caa4968c 100644 --- a/sound/isa/gus/gusclassic.c +++ b/sound/isa/gus/gusclassic.c @@ -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; } diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c index da2b2ca6b721..a409a4a29afc 100644 --- a/sound/isa/gus/gusextreme.c +++ b/sound/isa/gus/gusextreme.c @@ -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; } diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c index 24b945f1768d..ad118d462142 100644 --- a/sound/isa/gus/gusmax.c +++ b/sound/isa/gus/gusmax.c @@ -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); diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index 99581fba4ca8..755de47d0bb6 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -204,7 +204,8 @@ static int snd_interwave_detect_stb(struct snd_interwave *iwcard, port = 0x360; } while (port <= 0x380) { - if ((iwcard->i2c_res = request_region(port, 1, "InterWave (I2C bus)")) != NULL) + iwcard->i2c_res = request_region(port, 1, "InterWave (I2C bus)"); + if (iwcard->i2c_res) break; port += 0x10; } @@ -217,11 +218,13 @@ static int snd_interwave_detect_stb(struct snd_interwave *iwcard, } sprintf(name, "InterWave-%i", card->number); - if ((err = snd_i2c_bus_create(card, name, NULL, &bus)) < 0) + err = snd_i2c_bus_create(card, name, NULL, &bus); + if (err < 0) return err; bus->private_value = port; bus->hw_ops.bit = &snd_interwave_i2c_bit_ops; - if ((err = snd_tea6330t_detect(bus, 0)) < 0) + err = snd_tea6330t_detect(bus, 0); + if (err < 0) return err; *rbus = bus; return 0; @@ -241,14 +244,16 @@ static int snd_interwave_detect(struct snd_interwave *iwcard, int 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; } @@ -493,16 +498,20 @@ static int snd_interwave_mixer(struct snd_wss *chip) #if 0 /* remove mono microphone controls */ strcpy(id1.name, "Mic Playback Switch"); - if ((err = snd_ctl_remove_id(card, &id1)) < 0) + err = snd_ctl_remove_id(card, &id1); + if (err < 0) return err; strcpy(id1.name, "Mic Playback Volume"); - if ((err = snd_ctl_remove_id(card, &id1)) < 0) + err = snd_ctl_remove_id(card, &id1); + if (err < 0) return err; #endif /* add new master and mic controls */ - for (idx = 0; idx < ARRAY_SIZE(snd_interwave_controls); idx++) - if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_interwave_controls[idx], chip))) < 0) + for (idx = 0; idx < ARRAY_SIZE(snd_interwave_controls); idx++) { + err = snd_ctl_add(card, snd_ctl_new1(&snd_interwave_controls[idx], chip)); + if (err < 0) return err; + } snd_wss_out(chip, CS4231_LINE_LEFT_OUTPUT, 0x9f); snd_wss_out(chip, CS4231_LINE_RIGHT_OUTPUT, 0x9f); snd_wss_out(chip, CS4231_LEFT_MIC_INPUT, 0x9f); @@ -510,20 +519,24 @@ static int snd_interwave_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; return 0; } @@ -633,18 +646,20 @@ static int snd_interwave_probe(struct snd_card *card, int dev) xdma1 = dma1[dev]; xdma2 = dma2[dev]; - if ((err = snd_gus_create(card, - port[dev], - -xirq, xdma1, xdma2, - 0, 32, - pcm_channels[dev], effect[dev], &gus)) < 0) + err = snd_gus_create(card, + port[dev], + -xirq, xdma1, xdma2, + 0, 32, + pcm_channels[dev], effect[dev], &gus); + if (err < 0) return err; - if ((err = snd_interwave_detect(iwcard, gus, dev + err = snd_interwave_detect(iwcard, gus, dev #ifdef SNDRV_STB - , &i2c_bus + , &i2c_bus #endif - )) < 0) + ); + if (err < 0) return err; iwcard->gus_status_reg = gus->gf1.reg_irqstat; @@ -652,7 +667,8 @@ static int snd_interwave_probe(struct snd_card *card, int dev) snd_interwave_init(dev, gus); snd_interwave_detect_memory(gus); - if ((err = snd_gus_initialize(gus)) < 0) + err = snd_gus_initialize(gus); + if (err < 0) return err; if (request_irq(xirq, snd_interwave_interrupt, 0, @@ -708,19 +724,23 @@ static int snd_interwave_probe(struct snd_card *card, int dev) strcpy(id1.name, "Master Playback Switch"); strcpy(id2.name, id1.name); id2.index = 1; - 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, "Master Playback Volume"); strcpy(id2.name, id1.name); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + err = snd_ctl_rename_id(card, &id1, &id2); + if (err < 0) return err; - if ((err = snd_tea6330t_update_mixer(card, i2c_bus, 0, 1)) < 0) + err = snd_tea6330t_update_mixer(card, i2c_bus, 0, 1); + if (err < 0) return err; } #endif gus->uart_enable = midi[dev]; - if ((err = snd_gf1_rawmidi_new(gus, 0)) < 0) + err = snd_gf1_rawmidi_new(gus, 0); + if (err < 0) return err; #ifndef SNDRV_STB @@ -758,7 +778,8 @@ static int snd_interwave_isa_probe1(int dev, struct device *devptr) if (err < 0) return err; - if ((err = snd_interwave_probe(card, dev)) < 0) { + err = snd_interwave_probe(card, dev); + if (err < 0) { snd_card_free(card); return err; } @@ -786,19 +807,22 @@ static int snd_interwave_isa_probe(struct device *pdev, static const int possible_dmas[] = {0, 1, 3, 5, 6, 7, -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; } @@ -853,11 +877,13 @@ static int snd_interwave_pnp_detect(struct pnp_card_link *pcard, if (res < 0) return res; - if ((res = snd_interwave_pnp(dev, card->private_data, pcard, pid)) < 0) { + res = snd_interwave_pnp(dev, card->private_data, pcard, pid); + if (res < 0) { snd_card_free(card); return res; } - if ((res = snd_interwave_probe(card, dev)) < 0) { + res = snd_interwave_probe(card, dev); + if (res < 0) { snd_card_free(card); return res; } From patchwork Tue Jun 8 14:04:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456895 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B390C47082 for ; Tue, 8 Jun 2021 14:11:41 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8ED1661078 for ; Tue, 8 Jun 2021 14:11:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8ED1661078 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3291B16F0; Tue, 8 Jun 2021 16:10:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3291B16F0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161499; bh=bWvr5gG/RxkwPf3UAvGXIHTe/oddN4QAKyVxtapdZ8k=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=F2QgtiTSTMPQZ50B5h8stDf0rhpsX0lYPdI3GkuDYSxxWfHgcFx4kIPru+Z78zutK sSuiejPJoB00GYO4vl4RESChnzQEKd9pltPFk9oRWmUWdm7io+AyrX8v6WqbtmQ+Qq q2WQLHtnc50LU5Kus9mAZdhWEZyu4g1c2QHkmbeQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9E4E9F80587; Tue, 8 Jun 2021 16:06:18 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 87FEBF80566; Tue, 8 Jun 2021 16:06:12 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2A553F804C3 for ; Tue, 8 Jun 2021 16:05:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2A553F804C3 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="qd/iC8bh"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="lgR0LQCj" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id C7408219DC for ; Tue, 8 Jun 2021 14:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161142; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/Xszkd6G1zgaCiKxAkzQN2htm5JmsOJNmkoJY3/EnY8=; b=qd/iC8bh1dMyu4XNUJBCb9VLdqeGgAvXQxT4UTUlmMJ4pPaZz+JQ09g4e9Nd33g/OsgU1B Jib0U722dQKfvz8OMgxJgpSPzMRevN8DAVKWnJATpbdKULPYzlewndR9fkz+WEFXRvWHNy mxWmigCB0m08WzFqDDpYK7K4lMgvBY4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161142; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/Xszkd6G1zgaCiKxAkzQN2htm5JmsOJNmkoJY3/EnY8=; b=lgR0LQCjlRgmqOoBJGuG1dnqHBSVLSEWvmzRykQcP4cMwRXBcD4IFSIPs58A5fNynGRDyl NOLEQzOM4c+fVOBA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id B76B3A3B84; Tue, 8 Jun 2021 14:05:42 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 05/66] ALSA: ad1816a: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:39 +0200 Message-Id: <20210608140540.17885-6-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" ISA 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. Signed-off-by: Takashi Iwai --- sound/isa/ad1816a/ad1816a.c | 23 ++++++++++++++--------- sound/isa/ad1816a/ad1816a_lib.c | 27 ++++++++++++++++++--------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/sound/isa/ad1816a/ad1816a.c b/sound/isa/ad1816a/ad1816a.c index f11af983b3b6..fa5bed0d5a6f 100644 --- a/sound/isa/ad1816a/ad1816a.c +++ b/sound/isa/ad1816a/ad1816a.c @@ -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; } diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c index 01381fe7c0c9..6d4999b30461 100644 --- a/sound/isa/ad1816a/ad1816a_lib.c +++ b/sound/isa/ad1816a/ad1816a_lib.c @@ -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; From patchwork Tue Jun 8 14:04:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455875 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6C6BC4743E for ; Tue, 8 Jun 2021 14:12:08 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4F84E61359 for ; Tue, 8 Jun 2021 14:12:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4F84E61359 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id DA134171A; Tue, 8 Jun 2021 16:11:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DA134171A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161526; bh=56lKQAhZC10mtO1kGmqV91Sc0vrvUIV1VcXoukTei4c=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=QjZ6++ybsu/HpWsRbWT8WM2X35I9wOoLFQr2JL9IcOJUAJQ7SQZ/fl7doSjyu1KNk ls/F3M2CFe4VPk+sdrKGcxrj0oMxaJIe/XSw+tG43K42mj3SwEUU0mrnfAOjGHQMLe H09D9+AWbdF4c8VyypG3WTWs8WzrERkkEqZSUKn8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 76015F805A8; Tue, 8 Jun 2021 16:06:21 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DCCC2F80568; Tue, 8 Jun 2021 16:06:14 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3935DF804CC for ; Tue, 8 Jun 2021 16:05:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3935DF804CC Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="fzqNuTgF"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="8dfr2JgN" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id D6CCC219DD for ; Tue, 8 Jun 2021 14:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161142; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IFgdiVvOwqL9CQJiULO3bRQ7HnLstTqFwFD86fz2aTk=; b=fzqNuTgFcNc8HE5x4XBG3c6nplBE9SYcTzciC1UvCz6IxmiC+uXT2s/K3IoiD7Fh3Fr5Nj 3he/iHTMGC2iWYgSCSFoEvffS1cYFO9ANcJq1EMlgOIwEkw6xl3xVTa5w05XLVcs68/P4V 5DzrHbx+plpsgto9JyMsdfcFzp5Oy78= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161142; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IFgdiVvOwqL9CQJiULO3bRQ7HnLstTqFwFD86fz2aTk=; b=8dfr2JgN9kUU9aqoohcyAfOT2aQxWRAtcT4uPKboTVTg8s90XidqtS/g19fLVNZLoW29/1 s+E72+z2fl2FS3Cw== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id C6341A3B85; Tue, 8 Jun 2021 14:05:42 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 06/66] ALSA: wavefront: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:40 +0200 Message-Id: <20210608140540.17885-7-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" ISA 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. Signed-off-by: Takashi Iwai --- 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(-) diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c index a4437971df2f..dfdeaf7b6bf4 100644 --- a/sound/isa/wavefront/wavefront.c +++ b/sound/isa/wavefront/wavefront.c @@ -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); diff --git a/sound/isa/wavefront/wavefront_midi.c b/sound/isa/wavefront/wavefront_midi.c index a337a86f7a65..72e775ac7ad7 100644 --- a/sound/isa/wavefront/wavefront_midi.c +++ b/sound/isa/wavefront/wavefront_midi.c @@ -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) { diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c index d6420d224d09..69cbc79fbb71 100644 --- a/sound/isa/wavefront/wavefront_synth.c +++ b/sound/isa/wavefront/wavefront_synth.c @@ -339,7 +339,8 @@ snd_wavefront_cmd (snd_wavefront_t *dev, int c; struct wavefront_command *wfcmd; - if ((wfcmd = wavefront_get_command (cmd)) == NULL) { + wfcmd = wavefront_get_command(cmd); + if (!wfcmd) { snd_printk ("command 0x%x not supported.\n", cmd); return 1; @@ -391,7 +392,8 @@ snd_wavefront_cmd (snd_wavefront_t *dev, for (i = 0; i < wfcmd->read_cnt; i++) { - if ((c = wavefront_read (dev)) == -1) { + c = wavefront_read(dev); + if (c == -1) { DPRINT (WF_DEBUG_IO, "bad read for byte " "%d of 0x%x [%s].\n", i, cmd, wfcmd->action); @@ -401,7 +403,8 @@ snd_wavefront_cmd (snd_wavefront_t *dev, /* Now handle errors. Lots of special cases here */ if (c == 0xff) { - if ((c = wavefront_read (dev)) == -1) { + c = wavefront_read(dev); + if (c == -1) { DPRINT (WF_DEBUG_IO, "bad read for " "error byte at " "read byte %d " @@ -459,9 +462,9 @@ snd_wavefront_cmd (snd_wavefront_t *dev, of the standard value. */ - if ((ack = wavefront_read (dev)) == 0) { + ack = wavefront_read(dev); + if (ack == 0) ack = WF_ACK; - } if (ack != WF_ACK) { if (ack == -1) { @@ -475,7 +478,8 @@ snd_wavefront_cmd (snd_wavefront_t *dev, if (ack == 0xff) { /* explicit error */ - if ((err = wavefront_read (dev)) == -1) { + err = wavefront_read(dev); + if (err == -1) { DPRINT (WF_DEBUG_DATA, "cannot read err " "for 0x%x [%s].\n", @@ -603,9 +607,9 @@ wavefront_delete_sample (snd_wavefront_t *dev, int sample_num) wbuf[0] = sample_num & 0x7f; wbuf[1] = sample_num >> 7; - if ((x = snd_wavefront_cmd (dev, WFC_DELETE_SAMPLE, NULL, wbuf)) == 0) { + x = snd_wavefront_cmd(dev, WFC_DELETE_SAMPLE, NULL, wbuf); + if (!x) dev->sample_status[sample_num] = WF_ST_EMPTY; - } return x; } @@ -691,8 +695,9 @@ wavefront_get_patch_status (snd_wavefront_t *dev) patchnum[0] = i & 0x7f; patchnum[1] = i >> 7; - if ((x = snd_wavefront_cmd (dev, WFC_UPLOAD_PATCH, patchbuf, - patchnum)) == 0) { + x = snd_wavefront_cmd(dev, WFC_UPLOAD_PATCH, patchbuf, + patchnum); + if (x == 0) { dev->patch_status[i] |= WF_SLOT_FILLED; p = (wavefront_patch *) patchbuf; @@ -738,8 +743,9 @@ wavefront_get_program_status (snd_wavefront_t *dev) for (i = 0; i < WF_MAX_PROGRAM; i++) { prognum = i; - if ((x = snd_wavefront_cmd (dev, WFC_UPLOAD_PROGRAM, progbuf, - &prognum)) == 0) { + x = snd_wavefront_cmd(dev, WFC_UPLOAD_PROGRAM, progbuf, + &prognum); + if (x == 0) { dev->prog_status[i] |= WF_SLOT_USED; @@ -894,9 +900,9 @@ wavefront_send_sample (snd_wavefront_t *dev, if (header->number == WAVEFRONT_FIND_FREE_SAMPLE_SLOT) { int x; - if ((x = wavefront_find_free_sample (dev)) < 0) { + x = wavefront_find_free_sample(dev); + if (x < 0) return -ENOMEM; - } snd_printk ("unspecified sample => %d\n", x); header->number = x; } @@ -1137,7 +1143,8 @@ wavefront_send_sample (snd_wavefront_t *dev, nothing to do with DMA at all. */ - if ((dma_ack = wavefront_read (dev)) != WF_DMA_ACK) { + dma_ack = wavefront_read(dev); + if (dma_ack != WF_DMA_ACK) { if (dma_ack == -1) { snd_printk ("upload sample " "DMA ack timeout\n"); @@ -1282,14 +1289,16 @@ wavefront_fetch_multisample (snd_wavefront_t *dev, char d[2]; int val; - if ((val = wavefront_read (dev)) == -1) { + val = wavefront_read(dev); + if (val == -1) { snd_printk ("upload multisample failed " "during sample loop.\n"); return -EIO; } d[0] = val; - if ((val = wavefront_read (dev)) == -1) { + val = wavefront_read(dev); + if (val == -1) { snd_printk ("upload multisample failed " "during sample loop.\n"); return -EIO; @@ -1910,7 +1919,8 @@ wavefront_reset_to_cleanliness (snd_wavefront_t *dev) goto gone_bad; } - if ((hwv[0] = wavefront_read (dev)) == -1) { + hwv[0] = wavefront_read(dev); + if (hwv[0] == -1) { snd_printk ("board not responding correctly.\n"); goto gone_bad; } @@ -1921,7 +1931,8 @@ wavefront_reset_to_cleanliness (snd_wavefront_t *dev) and tell us about it either way. */ - if ((hwv[0] = wavefront_read (dev)) == -1) { + hwv[0] = wavefront_read(dev); + if (hwv[0] == -1) { snd_printk ("on-board RAM test failed " "(bad error code).\n"); } else { @@ -1934,7 +1945,8 @@ wavefront_reset_to_cleanliness (snd_wavefront_t *dev) /* We're OK, just get the next byte of the HW version response */ - if ((hwv[1] = wavefront_read (dev)) == -1) { + hwv[1] = wavefront_read(dev); + if (hwv[1] == -1) { snd_printk ("incorrect h/w response.\n"); goto gone_bad; } @@ -2079,9 +2091,9 @@ wavefront_do_reset (snd_wavefront_t *dev) about it. */ - if ((dev->freemem = wavefront_freemem (dev)) < 0) { + dev->freemem = wavefront_freemem(dev); + if (dev->freemem < 0) goto gone_bad; - } snd_printk ("available DRAM %dk\n", dev->freemem / 1024); From patchwork Tue Jun 8 14:04:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456900 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F320C47082 for ; Tue, 8 Jun 2021 14:07:56 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DFAF261360 for ; Tue, 8 Jun 2021 14:07:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DFAF261360 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 49F7D171A; Tue, 8 Jun 2021 16:07:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 49F7D171A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161274; bh=RWJFlBLHzCdFL0YlJCkn4WMXPWv/4rgsvP2Lz6A8Xw0=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=M6P40pkkrCPpaegMKA69v+7E7C6dwS8Yd7L/3X2mRXEtCNGZOzs1SHd8sHzf+zAuh p2jEJr6i9TSLr8Fxky5ww/H3K9Zq+BBc4zhn4gQjCRRP6KfYa/j1e0cNUqJ71CF8OA 3CKcjafGWOgaPFvyVylX24jwl5zcI+NC+hKw29tU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C34EDF804AB; Tue, 8 Jun 2021 16:06:01 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 97E6AF8053B; Tue, 8 Jun 2021 16:05:59 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5F57FF8019B for ; Tue, 8 Jun 2021 16:05:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5F57FF8019B Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="bRKfHFA/"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="HeyUg1/L" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id E5F931FD52 for ; Tue, 8 Jun 2021 14:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161142; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gGMzkt8vSK0YPPYgHa31aB9+Ht6tmNKGrb93PFlJg8U=; b=bRKfHFA/cgV8By9sIdkdN6+YPcappRt8R0Bu4knGnzk0moZ7K8fgmCs8ANPeJMz6+z+A+u UJaUnr2BqY0z8AScuGmfu+8LHQexKZ6vZYgeZdwa2W37xkVeUpXJzs/BrYhfXF1iQJs1vb CW+fFDkkKEVVlyXLt+Jlp5IqJuPW4rA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161142; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gGMzkt8vSK0YPPYgHa31aB9+Ht6tmNKGrb93PFlJg8U=; b=HeyUg1/L+ynyxiSlehVyZPRc5aHxmR8ZEDO/DoSePpHYrdFs/1sKO21mzoWnr0C4FxAQaS bgKX3XkaiiE7B+Bg== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id D5802A3B84; Tue, 8 Jun 2021 14:05:42 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 07/66] ALSA: cs423x: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:41 +0200 Message-Id: <20210608140540.17885-8-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" ISA 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. Signed-off-by: Takashi Iwai --- sound/isa/cs423x/cs4236.c | 21 ++++++++++++++------- sound/isa/cs423x/cs4236_lib.c | 12 ++++++++---- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c index 186d7d4db45e..0b7fd17f8ecc 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c @@ -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; } diff --git a/sound/isa/cs423x/cs4236_lib.c b/sound/isa/cs423x/cs4236_lib.c index 52f05adb1870..63957aea456b 100644 --- a/sound/isa/cs423x/cs4236_lib.c +++ b/sound/isa/cs423x/cs4236_lib.c @@ -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; } } From patchwork Tue Jun 8 14:04:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 491B2C47082 for ; Tue, 8 Jun 2021 14:13:10 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A897260FE9 for ; Tue, 8 Jun 2021 14:13:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A897260FE9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 456B71745; Tue, 8 Jun 2021 16:12:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 456B71745 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161588; bh=nhoCiR2R7d+Xtk/Nr/gkznCi1n0GGsrzUnJMhv2MM/s=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=QHhAkhMtBJToU/JlrESbZbh6g2l3NA1seehavAWRhogLS5qcXXJCHHmel194PDxyD 60Mxz2rNwUoNHymiiHog3i/Sk3kJ8stdclUT1Sz1ewX9Tf4boRbXblzSaC5B9V/ZX0 Ij1mpNcZb2ecHHgOas4Jvr4CWESaBR3jh2J4oiPU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B507BF805AF; Tue, 8 Jun 2021 16:06:26 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A030EF805A0; Tue, 8 Jun 2021 16:06:19 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 388AFF804CA for ; Tue, 8 Jun 2021 16:05:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 388AFF804CA Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="if1NXR1d"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="h6/RPCg3" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id F4076219DE for ; Tue, 8 Jun 2021 14:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ovcWUwDWW2APDyCVNThkQWH3oKuh52b02uGwP/BMkzc=; b=if1NXR1ducw3m67ph+vNue8B9b8cJBFRo0rsGttwZTb97wsRnofPes7AbMSbC9/SlgqAqT DgNldQdl539RdwgcB3J/KSpvA2f1C4jsbroKvWK12TIq7A4Wa0fg/GIraIykDf/+81mOza aJCnrkGvQa9YyhCk0bVtRHrrWCWqbrc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ovcWUwDWW2APDyCVNThkQWH3oKuh52b02uGwP/BMkzc=; b=h6/RPCg3K9X6WRV7bCg4SaZU7EhAfUZb7ax45/wuMh88ePDt5atUK/yd4lGehsSr7QcVhm ZuX5zmM3uF2HqWDg== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id E42E8A3B85; Tue, 8 Jun 2021 14:05:42 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 08/66] ALSA: opti9xx: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:42 +0200 Message-Id: <20210608140540.17885-9-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" ISA 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. Signed-off-by: Takashi Iwai --- sound/isa/opti9xx/miro.c | 27 ++++++++++++++++++--------- sound/isa/opti9xx/opti92x-ad1848.c | 27 ++++++++++++++++++--------- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c index a510b201143c..e1fb7567fdcc 100644 --- a/sound/isa/opti9xx/miro.c +++ b/sound/isa/opti9xx/miro.c @@ -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); diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index 08e61d90057b..4bd1dc6707fc 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -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; } From patchwork Tue Jun 8 14:04:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456901 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84967C47082 for ; Tue, 8 Jun 2021 14:06:49 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9A3E46127A for ; Tue, 8 Jun 2021 14:06:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A3E46127A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id D86A382E; Tue, 8 Jun 2021 16:05:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D86A382E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161206; bh=W+73SVXzuX5vOPgfmc3nBF86dEDoi6auFNmFju8yfP4=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=b08FPOBqsVEKI3mXljcn5eAHixCZwwnlfzdi3/kwPN9kv/1FVkKamZlLH0MM71iLu 1q5kCiy5Va+EdRhyPOorRW+DED6WfcFhm8fupsP/wkVyTLIQuFWRCneVyT+8E1SeJv S4iu+rCDfI4+kRrYh+PeDOcjarC4Qh6DfnWG1l9s= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DD47DF80510; Tue, 8 Jun 2021 16:05:55 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B6424F804FE; Tue, 8 Jun 2021 16:05:53 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 620DEF800FD for ; Tue, 8 Jun 2021 16:05:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 620DEF800FD Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="w/V1HYcz"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="RfrBW7lb" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 0EDA81FD53 for ; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m4fI4ry4NS51ViqA/znja68g32EK0QGyk/PhdRkxGG8=; b=w/V1HYczYte5rTU9ATiNJ3eXFkFD/0lQpoHX16PnjB3KOdjocF436No+H2z0oCaPs5gfG9 CuuP37MN6CEUhwsy7mXSgIo3x65eEAnqiHkIdtgMfOZc9ZWa9FoN05V/fL6RWmDftQDZWU EPqgmK0HFyy+C8ZJJuc9Q3KCf98TDTQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m4fI4ry4NS51ViqA/znja68g32EK0QGyk/PhdRkxGG8=; b=RfrBW7lb6RKMJ4+ZrO4fz2hv8FNDG6ab7S/25gR+dgufhSjruayjDQInUJi+q58JeJZoD2 iKUiGd/53dCYr4Cw== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id F2D50A3B84; Tue, 8 Jun 2021 14:05:42 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 09/66] ALSA: opl3sa2: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:43 +0200 Message-Id: <20210608140540.17885-10-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" ISA 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. Signed-off-by: Takashi Iwai --- sound/isa/opl3sa2.c | 68 +++++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index 9bde11d1cfe8..6f42f869928c 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c @@ -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; } From patchwork Tue Jun 8 14:04:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455879 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1741C47082 for ; Tue, 8 Jun 2021 14:09:03 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 288DA60FE9 for ; Tue, 8 Jun 2021 14:09:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 288DA60FE9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C83F016F2; Tue, 8 Jun 2021 16:08:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C83F016F2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161341; bh=ydVdRkQbxp13pssRyVForQORkaQmDqSJPkRo6l4SR9M=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=oLb/BMnFx9x10aa30D4YKBNyNlD9zDJZxcRIj96gDI8Xo3fp+/sZXRz6l0EEeoR+D qFVGLrVNLGiae4aa5/XAc/99K5MM6gML4w00mm3kwf5cuF7O4fx4RHRePFmJu68c2q zVTKKuQZGCCnAtsKU02Sfehjw2hOsASD1G7z/c5I= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D6C52F80542; Tue, 8 Jun 2021 16:06:05 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A4EF3F804AB; Tue, 8 Jun 2021 16:06:00 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id AE2B6F804AC for ; Tue, 8 Jun 2021 16:05:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz AE2B6F804AC Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="vj0ZXhyd"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="mr8idIHQ" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 1D09F1FD54 for ; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E+YbAFWSunVYHLJi0fLHR5pXtHXD9rNtYkcdg/TCpuY=; b=vj0ZXhyd6RI80IBAxn1aXpJmLusnLq1It2BfvyvGLS6NfeXiMCkb3jYJjJ1b8JZdvcljaH 1NFRCxM8V3A3fhdBDrzfHEoFP3mXuhxTn45hAW/XjVOrsVOTBTGOR0jvgdiaqDFjTOHvew bvEguV1N2UsugVjz1a5enjfqle0bZBI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E+YbAFWSunVYHLJi0fLHR5pXtHXD9rNtYkcdg/TCpuY=; b=mr8idIHQ05BEU6cj9edFacrB6OdKt7CkfsfzmnESbs57pw9XddxHNIengLR5qMOaJ3q7WU crFQU+O0zfbBm9CA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 0D7F2A3B85; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 10/66] ALSA: es18xx: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:44 +0200 Message-Id: <20210608140540.17885-11-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" ISA 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. Signed-off-by: Takashi Iwai --- sound/isa/es18xx.c | 51 ++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 375a4a6a4717..68b9c59e1127 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -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; } From patchwork Tue Jun 8 14:04:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456897 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D30CEC4743E for ; Tue, 8 Jun 2021 14:10:12 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3038D60FE9 for ; Tue, 8 Jun 2021 14:10:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3038D60FE9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C0DE516FE; Tue, 8 Jun 2021 16:09:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C0DE516FE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161410; bh=lvKCrZLd5gwmRxjjBenSSKAePxVY25oYXFN1jhpHDJ4=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=DvJDZst9d0xPMuvyRsny0qMspLrkcZ6qpN7/h8ypYdgXaeo8Qi7teT1CcENomjlwR 1vy7aB3JRevB8vVn9QrrSfvhCYO9CKRNS1ODifo0NPYWDGv2+tGBTNa6LpvaigFiQZ +Ws4o+HrzYvqeqG89rWRL776DoHvT/ztaYhG075Y= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 88A7DF80567; Tue, 8 Jun 2021 16:06:12 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A2A08F80256; Tue, 8 Jun 2021 16:06:08 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id AB978F80256 for ; Tue, 8 Jun 2021 16:05:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz AB978F80256 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="RPOiiNvh"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="+YxwL0EI" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 1F9A31FD55 for ; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r164ZoeX9+AfHhRZ8VIyrywW/15dU5dZNK+xcaYOV8U=; b=RPOiiNvhJt8uSgUcHhrh7WDtyuBe6QntiBFQxdW3HmGd0ZBbPayn7L+BmSfma5pq7DCEUx UJE7QOrPLkhyH1xdHHSUK1U4L0NZbYHz3Q7Up1/CHxe25wtI72qIjzwijOAg4gO5hvE8nS ON1jwCCA7RsfgJlHfV4boj+epoSzUa4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r164ZoeX9+AfHhRZ8VIyrywW/15dU5dZNK+xcaYOV8U=; b=+YxwL0EIj+6rewcbRRxqPgBFgEZENcogEC2jrOGFD2GkEd1XGIv2d1b/R73V1f1LSOlxcO VuCSw7Xmd7BGyeBA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 1BCEFA3B84; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 11/66] ALSA: cmi8330: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:45 +0200 Message-Id: <20210608140540.17885-12-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" ISA 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. Signed-off-by: Takashi Iwai --- sound/isa/cmi8330.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index bc112df10fc5..6c59a3eec59b 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c @@ -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; } From patchwork Tue Jun 8 14:04:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455880 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F391C47082 for ; Tue, 8 Jun 2021 14:08:24 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6755961078 for ; Tue, 8 Jun 2021 14:08:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6755961078 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id F1B2A16F4; Tue, 8 Jun 2021 16:07:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F1B2A16F4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161302; bh=kSiooSRmE/qjfJtGinQw4i1KzyelzraLV/ZyuookvoM=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=uJAcdB89hPYYoL3VLmNKRU0CakcHBCqDjwZyZKvPsokIrVFS0v47KrL7/psLZq46/ H3yuGdoFXMO559F03Xzd18NEVaQbZPiX+q2u89VWbeHaOaBGRKX3cq33HpqDxpZjQY 5LvRhjMFLfcVwDBaay3iWfeWxp+JJ22pIWyMRc8g= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 20174F80227; Tue, 8 Jun 2021 16:06:03 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CEB6DF8053A; Tue, 8 Jun 2021 16:05:59 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id AC74EF804AB for ; Tue, 8 Jun 2021 16:05:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz AC74EF804AB Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="0E+0dAZE"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="YcEVVtuT" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 2E1051FD56 for ; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3I72G48i2WW+u6ZQ5B0RTg3fWJO5iEq8hsqAx7cjlXE=; b=0E+0dAZEgaZDznIm9Kem8+0cVHg+ukouNKbIevEWDk8vjHlq3tNADsMg7NaBIA0417Aeu8 Koi2CPXcJBmkgYUPer4qb1S7J8dE5JOQLb7s0ep1TuzWxORiXTR+ZPk39sht4hsbZOSOeK qcXFO4sRdZSV1aHLubbahhjqjaAz9V4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3I72G48i2WW+u6ZQ5B0RTg3fWJO5iEq8hsqAx7cjlXE=; b=YcEVVtuTSGp/UkFv4oO4LNt/7qMQcQQlWPEifu0zUiucH/axA1jJF+74r9S3M2EEj16fIM XU4vof4M0sTWaLDg== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 1EFF0A3B87; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 12/66] ALSA: als100: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:46 +0200 Message-Id: <20210608140540.17885-13-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" ISA 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. Signed-off-by: Takashi Iwai --- sound/isa/als100.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sound/isa/als100.c b/sound/isa/als100.c index bacb7a1b930c..d4597fdfe091 100644 --- a/sound/isa/als100.c +++ b/sound/isa/als100.c @@ -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; } From patchwork Tue Jun 8 14:04:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456896 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87613C47082 for ; Tue, 8 Jun 2021 14:10:53 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 12F226127A for ; Tue, 8 Jun 2021 14:10:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 12F226127A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9761C16EC; Tue, 8 Jun 2021 16:10:01 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9761C16EC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161451; bh=Aipjm5O5mMllK4pe9ezKKbc/tDHyyVnDNXrLDmmP/Es=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=fZDVWAvrSo0vG4brLtLH2c5d4v7KcEO8FzsiLYganpHEUxFd/MxPzfPB0IONCcATP Dr5Gu0pct3EZ8F8k+DbwqGUEH0GtbINPmC26Q3PXPcHR0soXtl1t3bDCW3VuntAKsA LF45haEPDqCYMepMkstTgylG1XqHnpjbJFQyB9a4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 45B1EF80571; Tue, 8 Jun 2021 16:06:16 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 26E6FF804C2; Tue, 8 Jun 2021 16:06:09 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E7D3EF804B2 for ; Tue, 8 Jun 2021 16:05:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E7D3EF804B2 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="xMotSfy6"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="+XZuM8MG" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 3C1BD1FD57 for ; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TeejCGWgHbwBttd9JigXlJg1aOWIWlIRvUEwiWpt+eE=; b=xMotSfy6EhXvA1EB4eDmeIgDWt9ZtOboeERKXUgWXjxQ0rdersKwEj0VSbul3oz2/oiwyy 9blZGQz0rXRfo85IuFfEXoejD1kWCsQPbjqPJCC7cYFL8DVwzYJ+y9pT3vToH7u80jNLdK iVsTj04n7rpOf0DLzUOFjXlJsFLWjRM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TeejCGWgHbwBttd9JigXlJg1aOWIWlIRvUEwiWpt+eE=; b=+XZuM8MG7shwcwMfrNDOAVxOT8ovvFb9QbiqoeUJgUkGxWZDzRBWSYTlQkDAapXh1+PKAp EsvN/DlvQfM653BA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 2C8B2A3B84; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 13/66] ALSA: azt2320: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:47 +0200 Message-Id: <20210608140540.17885-14-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" ISA 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. Signed-off-by: Takashi Iwai --- sound/isa/azt2320.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/sound/isa/azt2320.c b/sound/isa/azt2320.c index 867e9ae8f65a..dd5c059b3744 100644 --- a/sound/isa/azt2320.c +++ b/sound/isa/azt2320.c @@ -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; } From patchwork Tue Jun 8 14:04:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455860 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BE1BC4743E for ; Tue, 8 Jun 2021 14:23:49 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 04A5D6135A for ; Tue, 8 Jun 2021 14:23:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 04A5D6135A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 83AB61820; Tue, 8 Jun 2021 16:22:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 83AB61820 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162227; bh=911+jmPkBius6j83n0O9C7FvusYJaz5xeY+iHY1XPkk=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=EHEk3Js5KA1YtWAwU2Y5uGjCOV07gzYhMsGZDboKeTnBQj/5qhNHGK9lZvvIkZCc0 QHei74SFJVtloeBve4Am5dn6hoTT8LDaXMFJkQx4avmroKJFMwZ+CoJW0NMUx0PEbp 0O/x//W3TIhJFxQw1A0n8TVfTtLK3MsA0NkykH2I= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 4EBE0F8065A; Tue, 8 Jun 2021 16:07:23 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 40322F8060C; Tue, 8 Jun 2021 16:07:00 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5AC97F804FE for ; Tue, 8 Jun 2021 16:05:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5AC97F804FE Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="wsb0+OKm"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="nvp9P5PO" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 4A87D219DF for ; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oD2IyxSC/XolnBEa4F4v/ISC8iZKSqSsYZ4AEMT4QXU=; b=wsb0+OKmIKgMTDFIMzqBbaG0JEjpyn2yPOdaHREzNkVxUEvwSTrqI/Ei0wKQW8NtJC7gnT d4dc8LJnjulhNqgO6b8Bg1Hlk8BIRvnoJv1ftPztuD49IfqjDk60j+6BbFQEXliIUZ4krt PU6JkmZvPUF+5qFpQwQEX3jc23WqSAM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oD2IyxSC/XolnBEa4F4v/ISC8iZKSqSsYZ4AEMT4QXU=; b=nvp9P5POeK5A0368jpcqo7sG6IP4SSQIPHJ3GRBIu5AqIhQPmQEiyeQ1ry6/ObDmvfvK8m fsxR6Kgc3GDrWuBw== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 3AD0DA3B85; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 14/66] ALSA: isa: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:48 +0200 Message-Id: <20210608140540.17885-15-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" ISA 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. Signed-off-by: Takashi Iwai --- sound/isa/es1688/es1688_lib.c | 3 ++- sound/isa/wss/wss_lib.c | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c index 1816e55c6edf..8554cb2263c1 100644 --- a/sound/isa/es1688/es1688_lib.c +++ b/sound/isa/es1688/es1688_lib.c @@ -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++) { diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c index ea5d3cdfe4e4..743e0f05e335 100644 --- a/sound/isa/wss/wss_lib.c +++ b/sound/isa/wss/wss_lib.c @@ -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; From patchwork Tue Jun 8 14:04:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455877 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB650C47082 for ; Tue, 8 Jun 2021 14:10:37 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3024361078 for ; Tue, 8 Jun 2021 14:10:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3024361078 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C313F171A; Tue, 8 Jun 2021 16:09:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C313F171A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161435; bh=jJBra0MhxW1522PRDcJFyqZRY73pOv32Kv5AhHgrprw=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=myEik8xnqIdThYAsaQ9GFIL2BacSyxb2lOGQCd8ovX+LoWX7dVW30rwmhorek2i1m g5sLd5W23Rqe2ZatucO2ZPNYeAbvOJ6yGdnVcq7djdnXN2q1JNGISQrr6wb+/K8qOw 81HBl/nMZuQ+mKoW1FuqwM7x2F3oxZqz5iTIJpbs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 19361F80566; Tue, 8 Jun 2021 16:06:15 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7ABECF80557; Tue, 8 Jun 2021 16:06:08 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D5983F804AD for ; Tue, 8 Jun 2021 16:05:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D5983F804AD Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="l7gkBm5T"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="kK+8hlLc" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 592A81FD58 for ; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KYYO28bjeU8Exu1/ElDX7Ep5x15PkwvUSZJv08j/XB8=; b=l7gkBm5Tcd4IK95KbNCPnYrYnzZH/SRxtlR+qedth1KyduVmDHkVa5EAAzIdl+mWn0Lw4Z xcSHG2J6Y0S9xh7WWhwMbHQXih/X0y6wpgoMQIS45povRPlMzffeYrdSZET6uKS1tPJB++ CISDNY0bJVjBxBGu/PRsSNcjAp2GwH4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KYYO28bjeU8Exu1/ElDX7Ep5x15PkwvUSZJv08j/XB8=; b=kK+8hlLcdWTq0lpiSIw4ivXhfdIxt7SkXKa/8s3sL/ozaBYQLFE26RNx71lBawIXXoflo1 BTeR1yTPMHA2vrDg== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 48AF7A3B84; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 15/66] ALSA: ad1889: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:49 +0200 Message-Id: <20210608140540.17885-16-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/ad1889.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index 4520022801d9..5c78951dd596 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -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; } From patchwork Tue Jun 8 14:04:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456877 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A72CDC47082 for ; Tue, 8 Jun 2021 14:25:44 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 29AF0611BD for ; Tue, 8 Jun 2021 14:25:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29AF0611BD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id AB79F1867; Tue, 8 Jun 2021 16:24:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AB79F1867 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162342; bh=QCWMO63zf5cwBCx7ES/qETUf4S/GTKgn1fwU9VW4408=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=q3JshdT7ZuWjpqEK+pWTFTRnWuXOYPIvsezdJ/vX+VORTPkLgJM4TCO3xSDvTDCGQ HF72SAoPGDQ25GKmPANEwJbCbhEJeF9/QV6C+It7ArOINRag0rQNWAsaoJ7sT6LG+B I7JD3jhdJcW9uW1Q5Fq2lspZdLVptnBNEg9kM8A0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id ADD1CF8067F; Tue, 8 Jun 2021 16:07:30 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 36A6AF80508; Tue, 8 Jun 2021 16:07:10 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5AB42F804F3 for ; Tue, 8 Jun 2021 16:05:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5AB42F804F3 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="elgWk7yE"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="0ED/deNU" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 5D844219E0 for ; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qGMLw27JChpT5CIlG46ADedxmhhe9FQt/gXNwwUhWlA=; b=elgWk7yETxDCbD3heE63yVTdkJWtTBFfcVl4NkJyfCfWBw/vLUH5IhHSzOP8mNSWXvPd6O nKJwBTtdJAcfsHp3JBM60jr276/Uo97g3YUWO68Z9Bsjvjq1ywm2gl/2J0X6QdaZ983mvg 6H31gwVfJZ60r+m1e9IR4wB88rlRjpc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qGMLw27JChpT5CIlG46ADedxmhhe9FQt/gXNwwUhWlA=; b=0ED/deNUgajQGeUlXKHfBqy8bb2hT2fvk629yB8APxCzjS1FvpHV92eql9PkiqbO//cwlX j7hRZgrC7Eo6x1AQ== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 579B2A3B88; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 16/66] ALSA: ak4531: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:50 +0200 Message-Id: <20210608140540.17885-17-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" AK4531 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. Signed-off-by: Takashi Iwai --- sound/pci/ak4531_codec.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sound/pci/ak4531_codec.c b/sound/pci/ak4531_codec.c index e0a81f99f79a..6af88e7b86f8 100644 --- a/sound/pci/ak4531_codec.c +++ b/sound/pci/ak4531_codec.c @@ -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; } From patchwork Tue Jun 8 14:04:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456899 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 629C9C47082 for ; Tue, 8 Jun 2021 14:08:36 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DDC2160FE9 for ; Tue, 8 Jun 2021 14:08:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DDC2160FE9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 753B31708; Tue, 8 Jun 2021 16:07:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 753B31708 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161314; bh=H4HHwa/GYSAL3mpDQFPXcCPlGNKkKKgyufphyCFFDmQ=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=G/rw9oHJxKkmwJnQ3laa8zvW0Qrqu302MIc8olaWcxs3XmklG85wqqjKQ16FKmu2h 9XfINWMOzucdnxwAtHblVVXOOopRsj7IV0XziqEwOUtZnkVyqK+4BloQr8r+nOR1eC ayk4fvZ9ljZfzU+MxMPKbDIOXe8VzQ23z4iAlG6I= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 23C1AF8053E; Tue, 8 Jun 2021 16:06:04 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 20679F8019B; Tue, 8 Jun 2021 16:05:59 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id CFD5DF80227 for ; Tue, 8 Jun 2021 16:05:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CFD5DF80227 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="os7HILAA"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="4SkmJ4LB" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 6ACE01FD59 for ; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HMcBGkcAi8GaQxmxe7DVDCbpP8M7oiW+SCPNRtPQXJ8=; b=os7HILAAZQ5jp6pKjkAZ9+gIXNY7KJYwVjfHqYy5jwXi+gp4dw+YzosZueBVpZW7ERvHAU lOqgiz337ErrEfUZgOCisnqSkcHgBhZd7/Y/sVlTyc9TDfcUG1vsi3yGzuiiI/drYaIe8u +secVkkOYxj35hrAGMxayKPjAAB6Rew= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HMcBGkcAi8GaQxmxe7DVDCbpP8M7oiW+SCPNRtPQXJ8=; b=4SkmJ4LBeHVlOiIS+GBwoCYbZ0puzcqTpDsam4iGq6Y/CGd/Ze903YestjTpIao68hYOvB eeRn0yt+vj2jzzAQ== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 5B847A3B89; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 17/66] ALSA: als300: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:51 +0200 Message-Id: <20210608140540.17885-18-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/als300.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/sound/pci/als300.c b/sound/pci/als300.c index bd4fd09e982b..668008fc21f7 100644 --- a/sound/pci/als300.c +++ b/sound/pci/als300.c @@ -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; } From patchwork Tue Jun 8 14:04:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456880 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86879C47082 for ; Tue, 8 Jun 2021 14:23:35 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 062FE60E08 for ; Tue, 8 Jun 2021 14:23:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 062FE60E08 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8A70A1811; Tue, 8 Jun 2021 16:22:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8A70A1811 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162213; bh=g/NWurs6n9A2LQLnfhwFZzXWKEcKNYe36kwZZoAh7og=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=t4chpsIeAa0wc/MM2RkkGkA688X0DxvrZuPcgrjT8GYMwyHxAm9hOHhr4WG5d5/vp 0fA6hapW/HROg2KswBKz8S4bgF7Zc/IE6czJ5JvlDtf2ofjaBOeclHD2kmMoZ98NmM RvO83Z/XKLrNazxKELrwF8VjYfYxUesXV7uPuLRg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 59608F80642; Tue, 8 Jun 2021 16:07:22 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 95B03F8060F; Tue, 8 Jun 2021 16:06:59 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5AD79F804FF for ; Tue, 8 Jun 2021 16:05:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5AD79F804FF Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="qFThDeO3"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="aCmI6rqx" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 79770219E1 for ; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lZ+UG1uKBKDfqyKhHwCLbnj2k0VpNP9yVUA48AI6+wk=; b=qFThDeO3JId+fIhaBxuQ297+rpR91zEAW/iK9kp+fKkaF00X6+xjtSC4leQ6NWc4xvuhvi ZKhvbmHk/avEUcAx3zHcjrcc+iPFp1dIvLVxYNIbnQxawDsR99sL/0M/iqCsYX98SLzAdK WsxOy8yfg6UkKaZxU2ye7qELHwf/oys= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lZ+UG1uKBKDfqyKhHwCLbnj2k0VpNP9yVUA48AI6+wk=; b=aCmI6rqx0u7KymjW2irNXFmk7iskMKmsTLrAJmZyNAqJSXxKFPXKlUitgeG47irAuTTaj7 yGi+rGFq6u8taXCg== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 69858A3B84; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 18/66] ALSA: als4000: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:52 +0200 Message-Id: <20210608140540.17885-19-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/als4000.c | 55 ++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c index 139ac2a3a0ef..509f317ee682 100644 --- a/sound/pci/als4000.c +++ b/sound/pci/als4000.c @@ -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; From patchwork Tue Jun 8 14:04:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 327FBC47082 for ; Tue, 8 Jun 2021 14:23:08 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A2AA960E08 for ; Tue, 8 Jun 2021 14:23:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2AA960E08 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4CCCE1772; Tue, 8 Jun 2021 16:22:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4CCCE1772 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162186; bh=nFe5PdAeC6h2uhaPqVOZV/muxqDzXwE83gYqvgz5MK4=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=SROB6R056KCPF2VG8w9uiRk2G6t0WtF3caICDn9Dvx79y4bdWamokfdz7aCe8qgVy Er7IegWkEEYo4z0j0tM3QhPZX8mkld4GPMbtGmIAMUXpIqKHSMN5qxgPJ1O7nIEaha vtUJHpz785VdXofWeMGMCma7fvVs0FkIxosFOkFo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id EE85AF80518; Tue, 8 Jun 2021 16:07:20 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 46AD6F8060D; Tue, 8 Jun 2021 16:06:59 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5ABF9F804FD for ; Tue, 8 Jun 2021 16:05:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5ABF9F804FD Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="jFd7QYBW"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="JDUaSOk/" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 883E2219E2 for ; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zJs7B1yHZzD6jxFsJBDqVRpDNxljHK04dXJGpCUnjfs=; b=jFd7QYBWr4QDvOMrCcpiMzRKuc6I9ITMIBQWnaS226GuSpaSZYX9hORVLIG1RkX+cw4zVV OnCr3PgndzR7FWjB9pvzxT+oZoh5aVGT41sFeK08AWT6EBuqeU4oCWBoxBJAj0139zqtQx U0s46OAJDM/w2pw0VWKEL6yc9OfbC84= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zJs7B1yHZzD6jxFsJBDqVRpDNxljHK04dXJGpCUnjfs=; b=JDUaSOk/vLxXlBhPNbV2IkMOEw59w7llmtAEaze7msuPgDmC5hwibaw1xgzXR3nmHlXr7C fPe3RJbvSyu0hdAQ== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 78B8EA3B88; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 19/66] ALSA: atiixp: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:53 +0200 Message-Id: <20210608140540.17885-20-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/atiixp.c | 33 ++++++++++++++++++++++----------- sound/pci/atiixp_modem.c | 40 +++++++++++++++++++++++++--------------- 2 files changed, 47 insertions(+), 26 deletions(-) diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 579425ccbb6a..5f8aa35c4bea 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -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); diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index 45e75afec7a0..9739c3a82777 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -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); From patchwork Tue Jun 8 14:04:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456894 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCB56C4743E for ; Tue, 8 Jun 2021 14:12:26 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5153F6108E for ; Tue, 8 Jun 2021 14:12:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5153F6108E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E1ADC1742; Tue, 8 Jun 2021 16:11:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E1ADC1742 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161545; bh=trkAL7eUsNE+SkyVCNtBVgRXp7QQn5rzxlfgIsvBFKU=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=XBCTJVXebtAlFTtWouzSvwXHmv6SBpeoGq+WauWHrY0P1A6z4w4+jHye+G7eh8bAv 227OoNBhRIrgFfQi6oi6+flowef8Zvjv9M4aX5lNyoq5vcwPzD9bc7fmj8/hO32s6M 7xDraMqVtCTAAFXiZiCjnIyuVlzk86xSmxgZQEC0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1981FF804D6; Tue, 8 Jun 2021 16:06:24 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8213BF80588; Tue, 8 Jun 2021 16:06:18 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 44C4AF804CB for ; Tue, 8 Jun 2021 16:05:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 44C4AF804CB Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="P9KSBt4e"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="31qTBajV" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 954FA1FD5A for ; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1PbQE6yZOFyrQdZlQGi34S+yclkwI3IT7sG59p/G+vA=; b=P9KSBt4eYfsJt9IyxfX6mtPvY+fUYVxIiHPuZprF+0eJp17jOQDyyibUSJFUMEx0y7+t1D XeWiurXm489Zxbz3fwJoyks7s/AHyS0MTtQM1CM8dqDXpxTtpkJR1v9N2J7VYibpUCCR0j X5ADVbLGk2u+izMsKc78U6ztwDcp+Fs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1PbQE6yZOFyrQdZlQGi34S+yclkwI3IT7sG59p/G+vA=; b=31qTBajVYcNiBMd5AQBdlXALm78n1GmjUUSmQW/bY/Ze/ggIS04F8ujl//D9fyYy0Vfuom pJxtlg3bj/ZVoSDA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 87193A3B84; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 20/66] ALSA: azt3328: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:54 +0200 Message-Id: <20210608140540.17885-21-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/azt3328.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index 51dcf1bc4c0c..4ee7ab409807 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -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"); From patchwork Tue Jun 8 14:04:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 658FFC47082 for ; Tue, 8 Jun 2021 14:13:27 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D733B61078 for ; Tue, 8 Jun 2021 14:13:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D733B61078 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 77218175D; Tue, 8 Jun 2021 16:12:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 77218175D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161605; bh=7FfnBSDPYtjIjnG46xjLHewrKm2bmai/Y7TjGPVJFEY=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=UKqYI7hC4b0MTXHg7j8CfVAoOxF1FZcIIdswCK9frZSNg6t6qASY/ikOnj4fT7F38 dGgaCRthrRk0SYneLDao8oCIOn9mh0xK+tAa50AmFWcsv/vlz31wS3+m+R3Sz3uLMB BvEfPd1XldwtJRXfqcynNma8hfMxbVIDAcu54ebM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3BDD5F805B2; Tue, 8 Jun 2021 16:06:29 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DF3A1F805A1; Tue, 8 Jun 2021 16:06:19 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5B639F804CF for ; Tue, 8 Jun 2021 16:05:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5B639F804CF Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="UB7xBYv0"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="2EIMtmzP" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id A253B1FD5B for ; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vpWoq2DTY1aFd4D1w+V7LqrOsRz2kV+MlzhmWa4phyk=; b=UB7xBYv0oruPNe64Iwe6fXDNmKLUJNM1L5yijm67iaDLQ6lYdkNNJg+g4XxHCjYwCdtNTO ikvTdpGo0ZynO4DiE0N77ULYCTi8upU6bQZ4Vwk7cwKCTpJt4jGEq6tMQCNtLY19Rp+COa kuqDH0z+5mZXm+KPs55KC5IWfagFLTs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vpWoq2DTY1aFd4D1w+V7LqrOsRz2kV+MlzhmWa4phyk=; b=2EIMtmzPqQqyjIc58kWc85/a0HRUcMON4cAuTYE1lNxpEnx4z3YfUXciMoU6IXLw9hflzR Gk/t2n+fQqJqMhDA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 93876A3B88; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 21/66] ALSA: bt87x: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:55 +0200 Message-Id: <20210608140540.17885-22-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/bt87x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index 91512b345d19..39bcfb81e81c 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -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; From patchwork Tue Jun 8 14:04:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455872 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58FBDC47082 for ; Tue, 8 Jun 2021 14:14:20 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D33B06108E for ; Tue, 8 Jun 2021 14:14:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D33B06108E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 730A41754; Tue, 8 Jun 2021 16:13:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 730A41754 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161658; bh=e/kjXKDAZf6C4zOp3AiWXMlBCHkSDqcFv2rFQ675ZSw=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=hscTMwKr6dbSX4vfrNfcggQG+DSlARSuCpmURE32219l1b21aAEp32QZIPNuIzdSu 2G9f+MF4T3YN/ESSb2XF4YliIxjWe5vtIK/ThEQ3LSFD0ur8qCCU3ZNFlyTuC4dxPV DhxVKGrEjp/h3Fbp4hzs9N/z6D86OcgOCu7StJ+0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2E402F805C5; Tue, 8 Jun 2021 16:06:33 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1CFF2F804D6; Tue, 8 Jun 2021 16:06:22 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 0375CF804D2 for ; Tue, 8 Jun 2021 16:05:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0375CF804D2 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="XgasgLrN"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="qgd5OAWy" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id B0C061FD5D for ; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0dyjkCvN+JsoW12iEOzkOaCETkRhgNPUGAI/Tlony50=; b=XgasgLrNahJ83L1HcpOuSq83vDFA264nsVHauFjMFKt9Ff2oh0Skznb2S9YwBYNcekBc43 Zg2PIImsd0xzIukwXH0umk58/YwiaSuVEL6aCQ6zgMsUVn4mrlQZfCF5wmW5y/GKEupx8z mCI0095dtWn15y5JEW93DL58jceyleo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0dyjkCvN+JsoW12iEOzkOaCETkRhgNPUGAI/Tlony50=; b=qgd5OAWynaIrjLZEgPTi6kyE6kOerkER/BFbhUpDwa8S1XZ7tBtY7fzqSQF+09RiGRUKxY XwZuQxwVjW90ZkDA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id A0CDEA3B84; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 22/66] ALSA: cmipci: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:56 +0200 Message-Id: <20210608140540.17885-23-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/cmipci.c | 83 ++++++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 28 deletions(-) diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index 598446348da6..f44f118aacad 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -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 From patchwork Tue Jun 8 14:04:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456890 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CACDCC47082 for ; Tue, 8 Jun 2021 14:15:35 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4DAAE61078 for ; Tue, 8 Jun 2021 14:15:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4DAAE61078 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id EBE59176A; Tue, 8 Jun 2021 16:14:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EBE59176A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161734; bh=qFLOavU54pz6bidWQlC5CS7tNMdI1uf/yHGjTXKEOyY=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Iz2rB+GM1IbH5orZ7Y5tfYZScYN6XSICB6B9zRh2S99wFTBi3aQ7wCCeU2dLOxQ2f s5ScyCdbXao04LpFkBBUUtoRdvvUcx25LyJJxiy6FjuBPxpTTdM9dRl4XEQ1KH0ICy WPS3Gl5ELSvzcC0cBaqniNtoH1JDj3PZCjH/bsa8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0CC16F805E0; Tue, 8 Jun 2021 16:06:38 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 102B5F805B2; Tue, 8 Jun 2021 16:06:26 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 015C5F804D1 for ; Tue, 8 Jun 2021 16:05:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 015C5F804D1 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="mHgVkZLg"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="17/XaTbq" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id BE3EC1FD5E for ; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/anyIUUM+4LjLDTbEqhbDnHp5tyg5myDxU7hYPe1kqM=; b=mHgVkZLgHZjbeYuC1LFcWzPnE6NO3kBGOCJOcBX+YHMaTfNz4zEu21JzjmbotESc+v+4bD c4D4zlIphr1wodKFvMMIAu+VRF5yk+b4WrITFjkDAXm41ExM9X9nj2KTUKwFOoitP5EoUm AVCVaBym6A1w/vJUPdQMIbfi1X/jr2U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/anyIUUM+4LjLDTbEqhbDnHp5tyg5myDxU7hYPe1kqM=; b=17/XaTbqSocQgurOGF2rRP1JeE6OtllG2dFde6OJsqyFYmP94wprUrfO0k1r4gLy5xq2ty 9jibYVib9bWeuwBg== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id AF691A3B88; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 23/66] ALSA: cs4281: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:57 +0200 Message-Id: <20210608140540.17885-24-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/cs4281.c | 54 ++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index bf3bb70ffaf9..e122a168c148 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -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; } From patchwork Tue Jun 8 14:04:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455858 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1DE8C47082 for ; Tue, 8 Jun 2021 14:25:23 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2581A61360 for ; Tue, 8 Jun 2021 14:25:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2581A61360 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 5A205185F; Tue, 8 Jun 2021 16:24:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5A205185F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162321; bh=LNtU1Vh0pSQMZhFauIWutxt/Dk7458NywzPRpUftMC8=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OOFk5I3BoUHoBRejPCIViJbVlsV22Yxl8h7C5CG4ggDTSqZY/OGAC+AvRLg5P8/si TOu2hJwXceT3TmMrDFNYUQ4am+xLtgRO8+h/6+53fBOtbfYpIzwFK9Kco3ZaZef1xh zMoG73FU8suUxCuljZ4tD2gN4NP08ewDFyEkkGn4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B83C3F8067D; Tue, 8 Jun 2021 16:07:29 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D96C5F800FD; Tue, 8 Jun 2021 16:07:09 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6466AF800FD for ; Tue, 8 Jun 2021 16:05:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6466AF800FD Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="VcvXzWKj"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="QiXe6DOk" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id CC571219E3 for ; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/dsp6UJORx2NRUtPhNePgc1n7hTkUyK0ugx+jinxDQw=; b=VcvXzWKjSkTxScbIWaSx6yIiZnyOabFRrVYBI4+u/g7RRkFzPuF1H+smAdMdGkNmUD5xfz HDoNCAaTPMCwLtlH/TTTJn58fC0SR0Jv3z4KifHqcbD5RhhkPai/dT6tjrXtcCFEbAcCL7 mYnmJRflgAFjnVXpBM5NoT5EK39HsM4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/dsp6UJORx2NRUtPhNePgc1n7hTkUyK0ugx+jinxDQw=; b=QiXe6DOkSiST4+iAUnJwfdy/h2diNsrSof9lDP9pGPcX69mbNGy+Foi2KGCd4spStNPgnM HEzgF0i/JVyq4EBg== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id BD00BA3B84; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 24/66] ALSA: ens137x: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:58 +0200 Message-Id: <20210608140540.17885-25-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/ens1370.c | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index 3ccccdbc0029..728b69dad21b 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -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; } From patchwork Tue Jun 8 14:04:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3135CC47082 for ; Tue, 8 Jun 2021 14:24:41 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AE927611BD for ; Tue, 8 Jun 2021 14:24:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE927611BD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 39EE01843; Tue, 8 Jun 2021 16:23:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 39EE01843 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162279; bh=jR/yXyXL8RkTk507GQl8Fyc4Iytko6yVQakxk+/tFuI=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OIr3ILzWFNiG6jBg5IawzmxdqFkzmjWVAasZTk1RfRGgUkadSwnC8BWfXDJkG99h9 v0C7SqBsXvEmm/qGkLqWzAL5am5+IeznPMXAVb0NkYibFVC4XG5KqaTjKDi0mrve5E 0jvCXV3iZBFrpqcZ+iZj8f0PCbFHH/Bjh83s9fcg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id F3F4CF80678; Tue, 8 Jun 2021 16:07:26 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5161BF8061C; Tue, 8 Jun 2021 16:07:05 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5AAD0F80218 for ; Tue, 8 Jun 2021 16:05:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5AAD0F80218 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="JhjO2f2D"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="aOOr90Q1" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id DB0CE219E4 for ; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g6xoBu+SlD976qWqssA9xQPt1AXjcZ48xWP2e8xlD7w=; b=JhjO2f2D1Xa517eIu6N8RkvW467yTxZ+1EWi8jRxO96ohF54vZZv7bVz8GK6Lpq5+JlzMA A5OJqYwChY4PtrHqiV9abWl3ccWHzkofXncCAjX3iPaPk9iajkhBK7c5Z4NizAasvM7bDW it85rxUg4aZcbXz5gPlXuJTrQZkXZe8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g6xoBu+SlD976qWqssA9xQPt1AXjcZ48xWP2e8xlD7w=; b=aOOr90Q1BlgDU3xZvBB1Sh9HFz9opAic3I9l7vvChsRDvtJH1wh2CKVNKdkblS6tO6lIXu NsZ33qZZeX1623DA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id CAE6AA3B88; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 25/66] ALSA: es1938: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:04:59 +0200 Message-Id: <20210608140540.17885-26-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/es1938.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index afc66347d162..33b1eb347a27 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -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; } From patchwork Tue Jun 8 14:05:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455871 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF3DFC47082 for ; Tue, 8 Jun 2021 14:15:10 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 553DD61359 for ; Tue, 8 Jun 2021 14:15:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 553DD61359 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E54BE1768; Tue, 8 Jun 2021 16:14:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E54BE1768 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161709; bh=IIW2J0kdOsSOcbwuJj1u/aju4t9jPYYj/iQcVJv2ePA=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=CSl3gshpsC15esqwuyTmM2WhLuvgs7WX8PjiQ9hj3QrawPKRbMocnSxSVe7p5/t5d 3K+/9YzwZL0WWy7uBOPYPajNbeLclTZ6/sSYCxJ2va1f7eOWEn4dW6YPYaUsDIt9Qu R3Q2jm40/aMkBY6rsi3ldcz8eoOBHnEeDSf1lekc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6627EF805DA; Tue, 8 Jun 2021 16:06:36 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0550CF805B0; Tue, 8 Jun 2021 16:06:25 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 1FEAFF804D8 for ; Tue, 8 Jun 2021 16:05:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1FEAFF804D8 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="BR5HQhdH"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Gi+Mb+xw" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id E9B611FDE0 for ; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W9T+JdEW44c8pK2gddTA0tnVWV89kpurUd5D+IyJdic=; b=BR5HQhdHfAFGQKcxcuPD43qkLcXc9vvYB3SRkf/7ZU5dSYWM12XUOAIvBW0nsRI6gn66Q8 N9itAd1AwHuaP7Sipoo28HO0EovRiNiwEnYEKA05Pe6DArp3jmdYae0n93IwSdPcieyxWa m7aMLmQ4u6SMBQIs8RFnrCmKHQViDbk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W9T+JdEW44c8pK2gddTA0tnVWV89kpurUd5D+IyJdic=; b=Gi+Mb+xwBroN0kMZdR5k04Tl7jI76J5n2Q98wdO+7XYn+1Q+auaNz/urJGTk/5bx+k/BLn Ql44Ph4xCdoOz8AA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id D9871A3B84; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 26/66] ALSA: es1968: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:00 +0200 Message-Id: <20210608140540.17885-27-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/es1968.c | 75 +++++++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 30 deletions(-) diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index 5fa1861236f5..c038c1035c39 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -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; } From patchwork Tue Jun 8 14:05:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456892 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D96E4C4743D for ; Tue, 8 Jun 2021 14:14:03 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 55B436108E for ; Tue, 8 Jun 2021 14:14:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 55B436108E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id EEBCE176A; Tue, 8 Jun 2021 16:13:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EEBCE176A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161642; bh=LOVArCiEL//CllApGDxsEiXVvvtV8WJ1Gjr0Ec65CPE=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=VdX9IKO0QLZZOx2VC5u8edwhL8tS44R1FSsuX+EbzDbp7mJKvtfqImoIYU2nVRnTw oy6j5/A80GQhHZfNAzEP3nyda+0lc0a6VJKXIHITGtBrDTcxyubReCLA4D2ffFpwbt D9LL2lVmf61mLpRDY9Rvq39i48KNECB/fjAV9sto= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 62088F805BA; Tue, 8 Jun 2021 16:06:32 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 05EC5F805AB; Tue, 8 Jun 2021 16:06:21 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 03FAFF804D6 for ; Tue, 8 Jun 2021 16:05:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 03FAFF804D6 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="OI0ALPwN"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="GakqhqpF" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 03C8D1FDE4 for ; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a5Y5YFHIFZcRTUpVpNHrCB5XrRFmFkWUZgucKl0dNJY=; b=OI0ALPwNTb6SMXpH/1xjsVV6ntEscP5BGPZsDLcM6VQdy5OhjF+VHFi4HRBKz1SypQqY2i rwEKFjn9AUOxFnE7jCQBiGYESrlc9vNPam9qzifsbdc066ilZur9N5Eag942FPLw2xgfxf exSUMEoG1kFQVAvtFUQoZJ+GJ/vNgVU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a5Y5YFHIFZcRTUpVpNHrCB5XrRFmFkWUZgucKl0dNJY=; b=GakqhqpFwXovnfZKq4JOEA+Nc7W8r7pyob0WZILxYxRWPD/iPkbUGgeYqhq+DegEbDicce l2h29hn+aCPwQ7Bg== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id E849CA3B88; Tue, 8 Jun 2021 14:05:43 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 27/66] ALSA: fm801: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:01 +0200 Message-Id: <20210608140540.17885-28-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/fm801.c | 63 ++++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index 6279eb156e36..ed9dae87145b 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -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; } From patchwork Tue Jun 8 14:05:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456888 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77F5CC47082 for ; Tue, 8 Jun 2021 14:17:07 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EDD7261359 for ; Tue, 8 Jun 2021 14:17:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EDD7261359 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 619BC176A; Tue, 8 Jun 2021 16:16:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 619BC176A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161825; bh=Z7U7H9KVK14owLdwNBKPTO4zuzhMbDEG7l3TsT7ltAw=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=RvB9xHqeMjXvEbHT+DmydG10E38IjFcnjTPoHl+Ilo83U52gWA/9AWPCnhHesD2aG tPGDldGPma23eqMXm+UBZVPlEguD5mlfsQLx8422TNuTyrg2qA5dR7AVgKNSx8KDyS V20l5bFGfEATBTyt7wzDAfz9j5cLAbnjEilrH6Xo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C10EDF805F2; Tue, 8 Jun 2021 16:06:44 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2E9D8F805C9; Tue, 8 Jun 2021 16:06:34 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4D080F804E0 for ; Tue, 8 Jun 2021 16:05:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4D080F804E0 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="NbtSztIv"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="/2LR15/h" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 136521FDE5 for ; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=16r9B/6Im4/3mQxUNyAsbqfcLxqSJ+j2o/5LIqvA/GY=; b=NbtSztIvVUrTr1niZNW4u/X44/a8Syk/bZHf70LbmEagjtDtVsKQypc/yU5bP7rbpXvaAR 8ygH06TPhu+hIoaOLmGzshdPDK421FXR9AL98TWnLFgvnP1xaQlmkmmKP+Wp20TKC4RkmB B6CfohqFxETK2PPMPnofTibLJK6JUE8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=16r9B/6Im4/3mQxUNyAsbqfcLxqSJ+j2o/5LIqvA/GY=; b=/2LR15/hS30YuTqcppObtmb3eUEljgMt4fpANOiQx/7sgwmPX5IZq/TGfDX2CPNBJw6E7b 5gvrGB9lJTWNPqCQ== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 03006A3B84; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 28/66] ALSA: intel8x0: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:02 +0200 Message-Id: <20210608140540.17885-29-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/intel8x0.c | 46 ++++++++++++++++++++++++++++--------------- sound/pci/intel8x0m.c | 36 ++++++++++++++++++++++----------- 2 files changed, 54 insertions(+), 28 deletions(-) diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index abc710ae3226..2d1bfbcba933 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -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; } diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 6793c1ffa71b..b96fce6cbd83 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -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; } From patchwork Tue Jun 8 14:05:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455850 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE929C47082 for ; Tue, 8 Jun 2021 14:31:36 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 30C6861183 for ; Tue, 8 Jun 2021 14:31:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 30C6861183 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id CDE4617EE; Tue, 8 Jun 2021 16:30:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CDE4617EE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162694; bh=82YEt0pvuV1FlxcXiBWNaZiZKRK/LBQm4hOI15Eh4IQ=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=KLpYrPBhp2RGe2IEwiy9CLx77AfBAizFV0OPph8dpLIVb7ZfWz2lb8/A+qyjdx9om wtLV6YVGIXrjU+BWyPybfE5uzidnD35HLngLnHAMG0Qs6c1P9GevoTYc9mbvL9U7Rz lde1qRaA46yZ79nu/0TjHSw9Ub/w/FN3zQW8vXzA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8A4DFF80760; Tue, 8 Jun 2021 16:07:47 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 91033F80527; Tue, 8 Jun 2021 16:07:32 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5F2D4F80527 for ; Tue, 8 Jun 2021 16:05:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5F2D4F80527 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="j+Q1/C/B"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="0CTUv/k/" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 2173A219E5 for ; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OkDVfz5cNXVWMIl5RMgrDNULy68gT5mvb6UX6fZL9Hc=; b=j+Q1/C/B4KVvJRhmSlUpwc0nUpdqhY1qjVYogBsHueSp9tvjfdbQtSyFBvLmaK4L/Ggb+T s1/3tKLIj8Wzw1pPrV+eF9rcIOuW5wayUstG2PUs29J50rKuMIP2mMQ+RSEe4pF8IZhi7B EDOEw2yURkxbHcFBVXFzXqVSKgvQzjc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OkDVfz5cNXVWMIl5RMgrDNULy68gT5mvb6UX6fZL9Hc=; b=0CTUv/k/UVSFEkDLWDnf0RS4UJDKn5undJiVQKjFmbt3WOXSoXhBwFNskNCaYA5hShfz3i TFxTv9kwWlRm/gDw== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 121E9A3B88; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 29/66] ALSA: maestro3: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:03 +0200 Message-Id: <20210608140540.17885-30-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/maestro3.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index cdc4b6106252..77a484bc8c0d 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -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 From patchwork Tue Jun 8 14:05:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456891 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6594BC47082 for ; Tue, 8 Jun 2021 14:14:55 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E213360FE9 for ; Tue, 8 Jun 2021 14:14:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E213360FE9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 7855D1776; Tue, 8 Jun 2021 16:14:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7855D1776 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161693; bh=lqVTr0kMYdoM9HWWlZguyB1AL6lT2cLE/ZntE4QJZeI=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=gHDsYR9ZebdXjWaYIMkXggDL6Gj2/9B7X7kw5Hgs83O85g4/ZnCj8EsYaBhU+48Se 30FzAU+HBN7NT0XzyaXOl8+y2oz2QnnG8ajJdzg8fTu0MaRg8ZNRCrFU/VEcsAKqRu 5my7Xzv/5mm+UYl6lHQORMwK7BKJe2oA/JYYZx4Y= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5EB17F805D6; Tue, 8 Jun 2021 16:06:35 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 09A9CF805B0; Tue, 8 Jun 2021 16:06:25 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3592CF804D0 for ; Tue, 8 Jun 2021 16:05:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3592CF804D0 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="0vlB7AJ8"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="OsN92iY0" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 2FCE51FDE6 for ; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HNiDMcHoMZXzTJB/qlYNdmgfB1huSxhHlYx/hJAGtDY=; b=0vlB7AJ8gbZQC/YjFt+mLt6qSWVRG27vjbz29/QGwFJ/fsIrbbiEWiQGXskg0qUD3SM0ZN FhNpnJEVS73r+lzOFoKVmdaIXVHjejJ+LJ7PgdFOmdxsu1SndQJSZHmt6cwvZDMqJLJIdm nKHGX1Li4hgEVaRrvhLad/onhSejwKc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HNiDMcHoMZXzTJB/qlYNdmgfB1huSxhHlYx/hJAGtDY=; b=OsN92iY099aqxoBAac5olEAJNxW54eL/WG3omeqXVMU61ZPXkEO05xCOTY1hkRrUyHWLff M/LD4bCADkpLl4Cg== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 2042FA3B84; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 30/66] ALSA: rme32: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:04 +0200 Message-Id: <20210608140540.17885-31-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/rme32.c | 76 ++++++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 28 deletions(-) diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c index 54f3e39f97f5..b5b357853c94 100644 --- a/sound/pci/rme32.c +++ b/sound/pci/rme32.c @@ -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 * rme32 struct 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; } From patchwork Tue Jun 8 14:05:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456869 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9479EC4743E for ; Tue, 8 Jun 2021 14:31:54 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1D34D61287 for ; Tue, 8 Jun 2021 14:31:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D34D61287 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B448B1845; Tue, 8 Jun 2021 16:31:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B448B1845 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162712; bh=MpHqU7KxekfEr1HHcoptAw+LGIQtke2wXYo2nQKdee0=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=CEMJmiPX4gT4COIaKhULtHnVzquyjbKbKiPSVk6GUV3v5TMU18ff6PPZeosM4YPM9 /lMge2Qx/eJ/WrFbyFYsGKW2KhVW79mxsqFu/XgCcK/UrNg0Nn+r30wZHzunrsDcAi D/M9PYr82dbbn9Mfir07zIXpygVzoHJ7hm8nvgW8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2169FF80766; Tue, 8 Jun 2021 16:07:48 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D7A07F80688; Tue, 8 Jun 2021 16:07:33 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5DB13F8051E for ; Tue, 8 Jun 2021 16:05:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5DB13F8051E Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Wy9162Or"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="9t88W6XP" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 3529F219E6 for ; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ygfpauNXyCcv3BSyNHTtrakzqgK/d6yg2s6K34gwJEY=; b=Wy9162Or++LmihXwgfXVpHKaY2VTQ7xodiZSYcqVbpM8+IyObpgZdTKCKqUOBx1oqMX4qb 0V8epvitCGPYH9NnONvraNOkRG74t2lBv5MUM8c2kJRmZ6gI37ljkA6EdD2bjnqE0a6Wdv qfswScgxrQxisfIo9pP87rs/LubUNmc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ygfpauNXyCcv3BSyNHTtrakzqgK/d6yg2s6K34gwJEY=; b=9t88W6XPWPLxvuTqxj8LjmwBoTETYevvmIjUivzdUzXop3AGDbOyIyRWFx74+6MSPX1psU H/r+bwo/9fhu2YBA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 2EC9FA3B88; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 31/66] ALSA: rme96: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:05 +0200 Message-Id: <20210608140540.17885-32-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/rme96.c | 148 +++++++++++++++++++++++++--------------------- 1 file changed, 82 insertions(+), 66 deletions(-) diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index 66082e9f526d..fc7ac077559c 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c @@ -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; From patchwork Tue Jun 8 14:05:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455869 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24673C47082 for ; Tue, 8 Jun 2021 14:16:42 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 98CB96108E for ; Tue, 8 Jun 2021 14:16:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 98CB96108E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 39CCC172B; Tue, 8 Jun 2021 16:15:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 39CCC172B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161800; bh=kohkaMvKxFCfPN6+6oaZUelEM6P0kOBsmnSrjgndRSM=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ljZhuubU3GizRqbw+cFHNnqd5EzkFAFcXo8QhkBhN3coC399AmoH5U2xZwglLuaSu 3a38BhhMDW9Mkm69ieOnImiP4acGNO8PS4h6PEJOHNbYdr6AbSNlb0I8ufOCX3YR9a SD9hyZG2Wv5dxoDKDJsE2Y1pj5Ek37D+AOX2zRD4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id CFFA1F804E5; Tue, 8 Jun 2021 16:06:42 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 75233F805C9; Tue, 8 Jun 2021 16:06:33 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 54353F804E1 for ; Tue, 8 Jun 2021 16:05:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 54353F804E1 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="VX86Ju5h"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="vQ8MvBpr" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 43CE71FDE7 for ; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b4m48LyFI1/8yO7SlVjCdEFdj5aKfo9N0XNR4L3Z8r0=; b=VX86Ju5hCPQ1HCfhWqgSCkzlWrJqzf1tM0qIWQsIQvfyT5RP13Ti3iO69IuKPg0BLt23ax 8waVG/twsdL39dy7KWyHFJs9CAqwoiUS/anVFirC4FQ1yI+KPNP935FNLaQcEG1Ml9YYtV TNF6Sud/hbuNLf2n1Znde+4UPzDuuJU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b4m48LyFI1/8yO7SlVjCdEFdj5aKfo9N0XNR4L3Z8r0=; b=vQ8MvBpr9jQlQ+itxAYcv2sPskdF6ualxp64nGkZrbUT+Zbhov/o26YQXbkK0oaGKaDdba usXSgz+f9sOKEXDw== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 339F2A3B89; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 32/66] ALSA: sonicvibes: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:06 +0200 Message-Id: <20210608140540.17885-33-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/sonicvibes.c | 67 ++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index 7de10997775f..03a48da897e3 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -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; } From patchwork Tue Jun 8 14:05:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456889 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B9B7C47082 for ; Tue, 8 Jun 2021 14:16:29 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6E62C6108E for ; Tue, 8 Jun 2021 14:16:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6E62C6108E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C96E216F8; Tue, 8 Jun 2021 16:15:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C96E216F8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161786; bh=UKyriRLQRoXzczcsoL8rAtltcz0aUq2nWrn2q49jL/Q=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=IU8XLuvjUKG0hKdYlzjENoTY5JGp43XGOGShnCUey7p1YAoIwDMTP5zvapDTKBZuo DStkfn87r5unm58gx6lZE9PBLa3d/2fCOjN5fJWkIgeoqm72kcqnaEPBmzuXjk8aXW dONngj4zBA4TRAmd7bYVtgrk0cHbOICmeA2sacMA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 584A8F805ED; Tue, 8 Jun 2021 16:06:41 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D8985F805B5; Tue, 8 Jun 2021 16:06:29 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 436DAF804D9 for ; Tue, 8 Jun 2021 16:05:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 436DAF804D9 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="GW0ifhGp"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="hp1G6miH" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 5412A1FDE8 for ; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RF3Iz2pRT4QTf36x7UpZxlv/CUB+SbuOxbVWYas+pgA=; b=GW0ifhGpzK8HES93mzPjKuqzJ8bvJ3K8N1Zp91VqQ+/ZqolDBZgp+bAee6SyU+vomaddDP MhYmiZULVWlCFlxyTdInBFG76A7F0cM29GSPq8BeETCmQsvTXhgrlI5zMXuW1pdGLabb0E wU5hMTohWtnXYt8N+K3oBFtiF30JCcc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RF3Iz2pRT4QTf36x7UpZxlv/CUB+SbuOxbVWYas+pgA=; b=hp1G6miHgnPeHaRrR76HvP/Ob9+SSxDgUhzTEBkl+YSfqHWESulw+AuysvVv26QylSX98N 57e+eFQbSa1nBUCw== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 42BB3A3B84; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 33/66] ALSA: via82xx: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:07 +0200 Message-Id: <20210608140540.17885-34-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/via82xx.c | 78 +++++++++++++++++++++++++-------------- sound/pci/via82xx_modem.c | 52 +++++++++++++++++--------- 2 files changed, 85 insertions(+), 45 deletions(-) diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index fd1f2f9cfbc3..943813a06abc 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -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; } diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index 30253306f67c..07278a3dc8c1 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c @@ -369,7 +369,8 @@ static int snd_via82xx_codec_ready(struct via82xx_modem *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", @@ -738,13 +739,15 @@ static int snd_via82xx_modem_pcm_open(struct via82xx_modem *chip, struct viadev runtime->hw = snd_via82xx_hw; - 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; /* 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; runtime->private_data = viadev; @@ -878,7 +881,8 @@ static int snd_via82xx_mixer_new(struct via82xx_modem *chip) .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; @@ -890,7 +894,8 @@ static int snd_via82xx_mixer_new(struct via82xx_modem *chip) ac97.scaps = AC97_SCAP_SKIP_AUDIO | AC97_SCAP_POWER_SAVE; ac97.num = chip->ac97_secondary; - 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; return 0; @@ -971,7 +976,8 @@ static int snd_via82xx_chip_init(struct via82xx_modem *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); @@ -983,7 +989,8 @@ static int snd_via82xx_chip_init(struct via82xx_modem *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; } @@ -1079,10 +1086,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; } @@ -1092,7 +1101,8 @@ static int snd_via82xx_create(struct snd_card *card, chip->pci = pci; chip->irq = -1; - 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; @@ -1109,12 +1119,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; } @@ -1154,14 +1166,17 @@ 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)) < 0) + err = snd_via82xx_mixer_new(chip); + if (err < 0) goto __error; - if ((err = snd_via686_pcm_new(chip)) < 0 ) + err = snd_via686_pcm_new(chip); + if (err < 0) goto __error; /* disable interrupts */ @@ -1173,7 +1188,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; } From patchwork Tue Jun 8 14:05:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455849 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54A3DC47082 for ; Tue, 8 Jun 2021 14:32:30 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7847760E08 for ; Tue, 8 Jun 2021 14:32:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7847760E08 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B35571792; Tue, 8 Jun 2021 16:31:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B35571792 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162747; bh=IpomKu4W2aQl43Xtgwq7xMBoDDiu1qVZdqvtsMB9fhA=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=votczfioZ1lrCqop2MrK8LJr+0uZegqPLWNMGCqdx0/C5L4aJtxiflC7uVZPjXHUz 1LbZwCmwGY5lgxS1mu9jNDwNahcS7Y4nU2Ei5DkVKFsIjhMWSrEXRBYulgpiypXKtW lZ6ptB6QWy5Utw9rX2tm4QEI923UBt0hdQBZQe14= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2A32CF80774; Tue, 8 Jun 2021 16:07:49 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CC099F806FA; Tue, 8 Jun 2021 16:07:38 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6C0D3F80528 for ; Tue, 8 Jun 2021 16:05:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6C0D3F80528 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="rvtrBU9u"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Gn7OiwHE" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 67FE3219E7 for ; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xVhZMvm8ltb6wtU/rOpFIt4dULJFI7aRB7O3osMb6eQ=; b=rvtrBU9uRvzIzSrDP4PvgUgR9sRAfmtGA8GMo6BOqCalYiU7FdFojpFagLyh7AKP0s2Zn+ v+ST2NeSjUlrGzsmlJseYdAtjT2pqPBBvbfKurBb/sHHlXwpWPOAWaaUebXJz0v+tE5CFD RE4R8Z9RRNZwixD49Yjj295O34GjTno= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xVhZMvm8ltb6wtU/rOpFIt4dULJFI7aRB7O3osMb6eQ=; b=Gn7OiwHEHufUsy4x0igkMdIIY7NwZTeH66s1smQ+nLE75K4HDNdt7/oP9fPUSCljMjS+mQ xjGi7PoSus5iW7Dg== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 542CCA3B88; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 34/66] ALSA: ac97: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:08 +0200 Message-Id: <20210608140540.17885-35-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" AC97 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. Signed-off-by: Takashi Iwai --- sound/pci/ac97/ac97_codec.c | 205 ++++++++++++++++++++++++------------ sound/pci/ac97/ac97_patch.c | 137 ++++++++++++++++-------- 2 files changed, 228 insertions(+), 114 deletions(-) diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index 012a7ee849e8..01f296d524ce 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -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; } diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index 1627a74baf3c..025c1666c1fc 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c @@ -29,9 +29,11 @@ static int patch_build_controls(struct snd_ac97 * ac97, const struct snd_kcontro { int idx, err; - for (idx = 0; idx < count; idx++) - if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&controls[idx], ac97))) < 0) + for (idx = 0; idx < count; idx++) { + err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&controls[idx], ac97)); + if (err < 0) return err; + } return 0; } @@ -416,7 +418,8 @@ static int patch_yamaha_ymf753_post_spdif(struct snd_ac97 * ac97) { int err; - if ((err = patch_build_controls(ac97, snd_ac97_ymf753_controls_spdif, ARRAY_SIZE(snd_ac97_ymf753_controls_spdif))) < 0) + err = patch_build_controls(ac97, snd_ac97_ymf753_controls_spdif, ARRAY_SIZE(snd_ac97_ymf753_controls_spdif)); + if (err < 0) return err; return 0; } @@ -461,7 +464,8 @@ static int patch_wolfson_wm9703_specific(struct snd_ac97 * ac97) int err, i; for (i = 0; i < ARRAY_SIZE(wm97xx_snd_ac97_controls); i++) { - if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm97xx_snd_ac97_controls[i], ac97))) < 0) + err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm97xx_snd_ac97_controls[i], ac97)); + if (err < 0) return err; } snd_ac97_write_cache(ac97, AC97_WM97XX_FMIXER_VOL, 0x0808); @@ -491,7 +495,8 @@ static int patch_wolfson_wm9704_specific(struct snd_ac97 * ac97) { int err, i; for (i = 0; i < ARRAY_SIZE(wm9704_snd_ac97_controls); i++) { - if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm9704_snd_ac97_controls[i], ac97))) < 0) + err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm9704_snd_ac97_controls[i], ac97)); + if (err < 0) return err; } /* patch for DVD noise */ @@ -631,7 +636,8 @@ static int patch_wolfson_wm9711_specific(struct snd_ac97 * ac97) int err, i; for (i = 0; i < ARRAY_SIZE(wm9711_snd_ac97_controls); i++) { - if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm9711_snd_ac97_controls[i], ac97))) < 0) + err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm9711_snd_ac97_controls[i], ac97)); + if (err < 0) return err; } snd_ac97_write_cache(ac97, AC97_CODEC_CLASS_REV, 0x0808); @@ -798,7 +804,8 @@ static int patch_wolfson_wm9713_3d (struct snd_ac97 * ac97) int err, i; for (i = 0; i < ARRAY_SIZE(wm13_snd_ac97_controls_3d); i++) { - if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm13_snd_ac97_controls_3d[i], ac97))) < 0) + err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm13_snd_ac97_controls_3d[i], ac97)); + if (err < 0) return err; } return 0; @@ -809,7 +816,8 @@ static int patch_wolfson_wm9713_specific(struct snd_ac97 * ac97) int err, i; for (i = 0; i < ARRAY_SIZE(wm13_snd_ac97_controls); i++) { - if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm13_snd_ac97_controls[i], ac97))) < 0) + err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm13_snd_ac97_controls[i], ac97)); + if (err < 0) return err; } snd_ac97_write_cache(ac97, AC97_PC_BEEP, 0x0808); @@ -883,7 +891,8 @@ static int patch_sigmatel_stac9700_3d(struct snd_ac97 * ac97) struct snd_kcontrol *kctl; int err; - if ((err = snd_ctl_add(ac97->bus->card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0) + err = snd_ctl_add(ac97->bus->card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97)); + if (err < 0) return err; strcpy(kctl->id.name, "3D Control Sigmatel - Depth"); kctl->private_value = AC97_SINGLE_VALUE(AC97_3D_CONTROL, 2, 3, 0); @@ -896,11 +905,15 @@ static int patch_sigmatel_stac9708_3d(struct snd_ac97 * ac97) struct snd_kcontrol *kctl; int err; - if ((err = snd_ctl_add(ac97->bus->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(ac97->bus->card, kctl); + if (err < 0) return err; strcpy(kctl->id.name, "3D Control Sigmatel - Depth"); kctl->private_value = AC97_SINGLE_VALUE(AC97_3D_CONTROL, 0, 3, 0); - if ((err = snd_ctl_add(ac97->bus->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(ac97->bus->card, kctl); + if (err < 0) return err; strcpy(kctl->id.name, "3D Control Sigmatel - Rear Depth"); kctl->private_value = AC97_SINGLE_VALUE(AC97_3D_CONTROL, 2, 3, 0); @@ -927,18 +940,26 @@ static int patch_sigmatel_stac97xx_specific(struct snd_ac97 * ac97) int err; snd_ac97_write_cache(ac97, AC97_SIGMATEL_ANALOG, snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG) & ~0x0003); - if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_ANALOG, 1)) - if ((err = patch_build_controls(ac97, &snd_ac97_sigmatel_controls[0], 1)) < 0) + if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_ANALOG, 1)) { + err = patch_build_controls(ac97, &snd_ac97_sigmatel_controls[0], 1); + if (err < 0) return err; - if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_ANALOG, 0)) - if ((err = patch_build_controls(ac97, &snd_ac97_sigmatel_controls[1], 1)) < 0) + } + if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_ANALOG, 0)) { + err = patch_build_controls(ac97, &snd_ac97_sigmatel_controls[1], 1); + if (err < 0) return err; - if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_DAC2INVERT, 2)) - if ((err = patch_build_controls(ac97, &snd_ac97_sigmatel_4speaker, 1)) < 0) + } + if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_DAC2INVERT, 2)) { + err = patch_build_controls(ac97, &snd_ac97_sigmatel_4speaker, 1); + if (err < 0) return err; - if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_DAC2INVERT, 3)) - if ((err = patch_build_controls(ac97, &snd_ac97_sigmatel_phaseinvert, 1)) < 0) + } + if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_DAC2INVERT, 3)) { + err = patch_build_controls(ac97, &snd_ac97_sigmatel_phaseinvert, 1); + if (err < 0) return err; + } return 0; } @@ -984,7 +1005,8 @@ static int patch_sigmatel_stac9708_specific(struct snd_ac97 *ac97) snd_ac97_remove_ctl(ac97, "PCM Out Path & Mute", NULL); snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Sigmatel Surround Playback"); - if ((err = patch_build_controls(ac97, &snd_ac97_stac9708_bias_control, 1)) < 0) + err = patch_build_controls(ac97, &snd_ac97_stac9708_bias_control, 1); + if (err < 0) return err; return patch_sigmatel_stac97xx_specific(ac97); } @@ -1262,14 +1284,17 @@ static int patch_cirrus_build_spdif(struct snd_ac97 * ac97) int err; /* con mask, pro mask, default */ - if ((err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3)) < 0) + err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3); + if (err < 0) return err; /* switch, spsa */ - if ((err = patch_build_controls(ac97, &snd_ac97_cirrus_controls_spdif[0], 1)) < 0) + err = patch_build_controls(ac97, &snd_ac97_cirrus_controls_spdif[0], 1); + if (err < 0) return err; switch (ac97->id & AC97_ID_CS_MASK) { case AC97_ID_CS4205: - if ((err = patch_build_controls(ac97, &snd_ac97_cirrus_controls_spdif[1], 1)) < 0) + err = patch_build_controls(ac97, &snd_ac97_cirrus_controls_spdif[1], 1); + if (err < 0) return err; break; } @@ -1324,10 +1349,12 @@ static int patch_conexant_build_spdif(struct snd_ac97 * ac97) int err; /* con mask, pro mask, default */ - if ((err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3)) < 0) + err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3); + if (err < 0) return err; /* switch */ - if ((err = patch_build_controls(ac97, &snd_ac97_conexant_controls_spdif[0], 1)) < 0) + err = patch_build_controls(ac97, &snd_ac97_conexant_controls_spdif[0], 1); + if (err < 0) return err; /* set default PCM S/PDIF params */ /* consumer,PCM audio,no copyright,no preemphasis,PCM coder,original,48000Hz */ @@ -1592,7 +1619,8 @@ static int patch_ad1885_specific(struct snd_ac97 * ac97) { int err; - if ((err = patch_build_controls(ac97, snd_ac97_controls_ad1885, ARRAY_SIZE(snd_ac97_controls_ad1885))) < 0) + err = patch_build_controls(ac97, snd_ac97_controls_ad1885, ARRAY_SIZE(snd_ac97_controls_ad1885)); + if (err < 0) return err; reset_tlv(ac97, "Headphone Playback Volume", db_scale_6bit_6db_max); @@ -1875,7 +1903,8 @@ static int patch_ad1981b_specific(struct snd_ac97 *ac97) { int err; - if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0) + err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1); + if (err < 0) return err; if (check_list(ac97, ad1981_jacks_denylist)) return 0; @@ -2060,7 +2089,8 @@ static int patch_ad1980_specific(struct snd_ac97 *ac97) { int err; - if ((err = patch_ad1888_specific(ac97)) < 0) + err = patch_ad1888_specific(ac97); + if (err < 0) return err; return patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1); } @@ -2168,7 +2198,8 @@ static int patch_ad1985_specific(struct snd_ac97 *ac97) "Master Surround Playback"); snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Master Playback"); - if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0) + err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1); + if (err < 0) return err; return patch_build_controls(ac97, snd_ac97_ad1985_controls, @@ -2460,7 +2491,8 @@ static int patch_ad1986_specific(struct snd_ac97 *ac97) { int err; - if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0) + err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1); + if (err < 0) return err; return patch_build_controls(ac97, snd_ac97_ad1986_controls, @@ -2582,10 +2614,12 @@ static int patch_alc650_specific(struct snd_ac97 * ac97) { int err; - if ((err = patch_build_controls(ac97, snd_ac97_controls_alc650, ARRAY_SIZE(snd_ac97_controls_alc650))) < 0) + err = patch_build_controls(ac97, snd_ac97_controls_alc650, ARRAY_SIZE(snd_ac97_controls_alc650)); + if (err < 0) return err; if (ac97->ext_id & AC97_EI_SPDIF) { - if ((err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc650, ARRAY_SIZE(snd_ac97_spdif_controls_alc650))) < 0) + err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc650, ARRAY_SIZE(snd_ac97_spdif_controls_alc650)); + if (err < 0) return err; } if (ac97->id != AC97_ID_ALC650F) @@ -2735,10 +2769,12 @@ static int patch_alc655_specific(struct snd_ac97 * ac97) { int err; - if ((err = patch_build_controls(ac97, snd_ac97_controls_alc655, ARRAY_SIZE(snd_ac97_controls_alc655))) < 0) + err = patch_build_controls(ac97, snd_ac97_controls_alc655, ARRAY_SIZE(snd_ac97_controls_alc655)); + if (err < 0) return err; if (ac97->ext_id & AC97_EI_SPDIF) { - if ((err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc655, ARRAY_SIZE(snd_ac97_spdif_controls_alc655))) < 0) + err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc655, ARRAY_SIZE(snd_ac97_spdif_controls_alc655)); + if (err < 0) return err; } return 0; @@ -2847,10 +2883,12 @@ static int patch_alc850_specific(struct snd_ac97 *ac97) { int err; - if ((err = patch_build_controls(ac97, snd_ac97_controls_alc850, ARRAY_SIZE(snd_ac97_controls_alc850))) < 0) + err = patch_build_controls(ac97, snd_ac97_controls_alc850, ARRAY_SIZE(snd_ac97_controls_alc850)); + if (err < 0) return err; if (ac97->ext_id & AC97_EI_SPDIF) { - if ((err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc655, ARRAY_SIZE(snd_ac97_spdif_controls_alc655))) < 0) + err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc655, ARRAY_SIZE(snd_ac97_spdif_controls_alc655)); + if (err < 0) return err; } return 0; @@ -3437,10 +3475,13 @@ static int patch_vt1616_specific(struct snd_ac97 * ac97) struct snd_kcontrol *kctl; int err; - if (snd_ac97_try_bit(ac97, 0x5a, 9)) - if ((err = patch_build_controls(ac97, &snd_ac97_controls_vt1616[0], 1)) < 0) + if (snd_ac97_try_bit(ac97, 0x5a, 9)) { + err = patch_build_controls(ac97, &snd_ac97_controls_vt1616[0], 1); + if (err < 0) return err; - if ((err = patch_build_controls(ac97, &snd_ac97_controls_vt1616[1], ARRAY_SIZE(snd_ac97_controls_vt1616) - 1)) < 0) + } + err = patch_build_controls(ac97, &snd_ac97_controls_vt1616[1], ARRAY_SIZE(snd_ac97_controls_vt1616) - 1); + if (err < 0) return err; /* There is already a misnamed master switch. Rename it. */ @@ -3810,9 +3851,11 @@ static const struct snd_kcontrol_new snd_ac97_spdif_controls_it2646[] = { static int patch_it2646_specific(struct snd_ac97 * ac97) { int err; - if ((err = patch_build_controls(ac97, snd_ac97_controls_it2646, ARRAY_SIZE(snd_ac97_controls_it2646))) < 0) + err = patch_build_controls(ac97, snd_ac97_controls_it2646, ARRAY_SIZE(snd_ac97_controls_it2646)); + if (err < 0) return err; - if ((err = patch_build_controls(ac97, snd_ac97_spdif_controls_it2646, ARRAY_SIZE(snd_ac97_spdif_controls_it2646))) < 0) + err = patch_build_controls(ac97, snd_ac97_spdif_controls_it2646, ARRAY_SIZE(snd_ac97_spdif_controls_it2646)); + if (err < 0) return err; return 0; } @@ -3845,9 +3888,11 @@ AC97_DOUBLE("Modem Speaker Volume", 0x5c, 14, 12, 3, 1) static int patch_si3036_specific(struct snd_ac97 * ac97) { int idx, err; - for (idx = 0; idx < ARRAY_SIZE(snd_ac97_controls_si3036); idx++) - if ((err = snd_ctl_add(ac97->bus->card, snd_ctl_new1(&snd_ac97_controls_si3036[idx], ac97))) < 0) + for (idx = 0; idx < ARRAY_SIZE(snd_ac97_controls_si3036); idx++) { + err = snd_ctl_add(ac97->bus->card, snd_ctl_new1(&snd_ac97_controls_si3036[idx], ac97)); + if (err < 0) return err; + } return 0; } @@ -3912,9 +3957,11 @@ AC97_SINGLE("Smart Low Power Mode", 0x6c, 4, 3, 0), static int patch_ucb1400_specific(struct snd_ac97 * ac97) { int idx, err; - for (idx = 0; idx < ARRAY_SIZE(snd_ac97_controls_ucb1400); idx++) - if ((err = snd_ctl_add(ac97->bus->card, snd_ctl_new1(&snd_ac97_controls_ucb1400[idx], ac97))) < 0) + for (idx = 0; idx < ARRAY_SIZE(snd_ac97_controls_ucb1400); idx++) { + err = snd_ctl_add(ac97->bus->card, snd_ctl_new1(&snd_ac97_controls_ucb1400[idx], ac97)); + if (err < 0) return err; + } return 0; } From patchwork Tue Jun 8 14:05:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456868 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73148C47082 for ; Tue, 8 Jun 2021 14:32:59 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F24BE60E08 for ; Tue, 8 Jun 2021 14:32:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F24BE60E08 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9F75F18DD; Tue, 8 Jun 2021 16:32:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9F75F18DD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162777; bh=bPYDRSFcLrpDMYZUaEaCQ31nK8wxfE3m1YWUW6kDEbc=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=GMfuAqF74+kz6ybFBvMWFyihlpemTV4IZYeJNoAB0/+zHfmhUTy1gOrqWD1HlndX/ 1950q9nELL5NtahoEWsrDD0JfAIot0bIlF6j0FTPexpUzryLiqZQAn3s5C5C3N3GJ3 pf26FSc1RQLO+ugFvHfnRhzqL7eoC6dM1KNzDUj4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 298C3F80798; Tue, 8 Jun 2021 16:07:50 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7F956F8052D; Tue, 8 Jun 2021 16:07:39 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 76EDBF8052D for ; Tue, 8 Jun 2021 16:05:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 76EDBF8052D Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="gEkIdjAv"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="0TKNk41+" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 79484219E8 for ; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/o06NoUcVG6+yqLEM0YsRzpJmDITHvDPocX6CnHcgVQ=; b=gEkIdjAvc4KQzlDJisCjotY5ecOGc7UULDeISGrJMGwwqyxd2XxWP4WUXwoYMP7TsXsf2Y QdvV4+/CXC1X2XljePxjd/KibZwqCQUZFZkAlwoRe7NuV83m8EGywlm6ZR8NK4LvYoAOqI W5rhM1nfd0GfTa89V/0COV6GeCOUjZQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/o06NoUcVG6+yqLEM0YsRzpJmDITHvDPocX6CnHcgVQ=; b=0TKNk41+y0LWMmT91j1YKD9/qdquhDmDftXbflIuSfu89SyXef5ckvHYZfZMMAOWl2w3iL IqFejcXhuQtbKlDA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 6719EA3B84; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 35/66] ALSA: au88x0: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:09 +0200 Message-Id: <20210608140540.17885-36-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- 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(-) diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c index 1b37b7225b1d..1f7fee470266 100644 --- a/sound/pci/au88x0/au88x0.c +++ b/sound/pci/au88x0/au88x0.c @@ -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; } diff --git a/sound/pci/au88x0/au88x0_a3d.c b/sound/pci/au88x0/au88x0_a3d.c index 2db183f8826a..eabaee0463fe 100644 --- a/sound/pci/au88x0/au88x0_a3d.c +++ b/sound/pci/au88x0/au88x0_a3d.c @@ -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; diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c index 5180f1bd1326..2ed5100b8cae 100644 --- a/sound/pci/au88x0/au88x0_core.c +++ b/sound/pci/au88x0/au88x0_core.c @@ -2120,9 +2120,9 @@ vortex_adb_allocroute(vortex_t *vortex, int dma, int nr_ch, int dir, VORTEX_RESOURCE_DMA); } else { en = 1; - if ((dma = - vortex_adb_checkinout(vortex, NULL, en, - VORTEX_RESOURCE_DMA)) < 0) + dma = vortex_adb_checkinout(vortex, NULL, en, + VORTEX_RESOURCE_DMA); + if (dma < 0) return -EBUSY; } @@ -2140,18 +2140,20 @@ vortex_adb_allocroute(vortex_t *vortex, int dma, int nr_ch, int dir, /* Get SRC and MIXER hardware resources. */ if (stream->type != VORTEX_PCM_SPDIF) { for (i = 0; i < nr_ch; i++) { - if ((src[i] = vortex_adb_checkinout(vortex, - stream->resources, en, - VORTEX_RESOURCE_SRC)) < 0) { + src[i] = vortex_adb_checkinout(vortex, + stream->resources, en, + VORTEX_RESOURCE_SRC); + if (src[i] < 0) { memset(stream->resources, 0, sizeof(stream->resources)); return -EBUSY; } if (stream->type != VORTEX_PCM_A3D) { - if ((mix[i] = vortex_adb_checkinout(vortex, - stream->resources, - en, - VORTEX_RESOURCE_MIXIN)) < 0) { + mix[i] = vortex_adb_checkinout(vortex, + stream->resources, + en, + VORTEX_RESOURCE_MIXIN); + if (mix[i] < 0) { memset(stream->resources, 0, sizeof(stream->resources)); @@ -2162,10 +2164,10 @@ vortex_adb_allocroute(vortex_t *vortex, int dma, int nr_ch, int dir, } #ifndef CHIP_AU8820 if (stream->type == VORTEX_PCM_A3D) { - if ((a3d = - vortex_adb_checkinout(vortex, - stream->resources, en, - VORTEX_RESOURCE_A3D)) < 0) { + a3d = vortex_adb_checkinout(vortex, + stream->resources, en, + VORTEX_RESOURCE_A3D); + if (a3d < 0) { memset(stream->resources, 0, sizeof(stream->resources)); dev_err(vortex->card->dev, @@ -2278,19 +2280,18 @@ vortex_adb_allocroute(vortex_t *vortex, int dma, int nr_ch, int dir, /* Get SRC and MIXER hardware resources. */ for (i = 0; i < nr_ch; i++) { - if ((mix[i] = - vortex_adb_checkinout(vortex, - stream->resources, en, - VORTEX_RESOURCE_MIXOUT)) - < 0) { + mix[i] = vortex_adb_checkinout(vortex, + stream->resources, en, + VORTEX_RESOURCE_MIXOUT); + if (mix[i] < 0) { memset(stream->resources, 0, sizeof(stream->resources)); return -EBUSY; } - if ((src[i] = - vortex_adb_checkinout(vortex, - stream->resources, en, - VORTEX_RESOURCE_SRC)) < 0) { + src[i] = vortex_adb_checkinout(vortex, + stream->resources, en, + VORTEX_RESOURCE_SRC); + if (src[i] < 0) { memset(stream->resources, 0, sizeof(stream->resources)); return -EBUSY; diff --git a/sound/pci/au88x0/au88x0_eq.c b/sound/pci/au88x0/au88x0_eq.c index 58e92f2a72c0..71c13100d7ef 100644 --- a/sound/pci/au88x0/au88x0_eq.c +++ b/sound/pci/au88x0/au88x0_eq.c @@ -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; diff --git a/sound/pci/au88x0/au88x0_mixer.c b/sound/pci/au88x0/au88x0_mixer.c index 5b647682b683..aeba684b8d18 100644 --- a/sound/pci/au88x0/au88x0_mixer.c +++ b/sound/pci/au88x0/au88x0_mixer.c @@ -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. diff --git a/sound/pci/au88x0/au88x0_mpu401.c b/sound/pci/au88x0/au88x0_mpu401.c index 603494e7d30e..164f6b7039ab 100644 --- a/sound/pci/au88x0/au88x0_mpu401.c +++ b/sound/pci/au88x0/au88x0_mpu401.c @@ -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); diff --git a/sound/pci/au88x0/au88x0_pcm.c b/sound/pci/au88x0/au88x0_pcm.c index d019aa566de3..546f71220604 100644 --- a/sound/pci/au88x0/au88x0_pcm.c +++ b/sound/pci/au88x0/au88x0_pcm.c @@ -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; } } From patchwork Tue Jun 8 14:05:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455870 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0F40C47082 for ; Tue, 8 Jun 2021 14:15:51 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5D26B6108E for ; Tue, 8 Jun 2021 14:15:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D26B6108E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 95E7D1754; Tue, 8 Jun 2021 16:14:59 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 95E7D1754 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161749; bh=KH7FoAZkiyGYDqMLQbsbv+bY88Ew2oppIOcWet01nGQ=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=BBaSv1VlspMd5sxDKAiqOs6fGIY+ULFOZrL/GW+DGtvwn9MmW0Tlw4+AdIZtv5Doj AZSPtxrFkfk44Dx63GaTf0CrTD6GwfjGeHoV4Qgfzyzn3EBVx03JdaJmkPOyfDsdgs Q0CdYRm+qhALccqAF1rMdMahrSq5Gt4sSsHLXB4M= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 81031F805E3; Tue, 8 Jun 2021 16:06:39 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0BA57F805B2; Tue, 8 Jun 2021 16:06:27 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4783CF804DA for ; Tue, 8 Jun 2021 16:05:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4783CF804DA Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Bm9AY63m"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="iEw6f+77" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 86B3D1FDE9 for ; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vJs1ezFt7SYyXEv2mdSxDNGmU67WBEB9eMUm3EuE8kE=; b=Bm9AY63mLc+nH8Ky73mdL58Vz1YtuF5Rh1zL2pkfgpRgDhbaEmzwYMsn+Gu8cGEjzA7pBv +z7O2HyHMcwy24DE1FLlhse4cbW06i4nXAeuZ1d39aSD0X6kyMTSruArEjfxAhchn/e8ga C5jfC5eSVvtLXv1ZRd8HkvV1+PgVfrI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vJs1ezFt7SYyXEv2mdSxDNGmU67WBEB9eMUm3EuE8kE=; b=iEw6f+77WZbY7b2q2kIWnkxGVlMMzdpn8LQ9wDu+YVfC7DZ/VMLQDtoJiUKdlM7Qxf7GHR 2cII5QF1OXBU2qCw== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 77CBAA3B88; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 36/66] ALSA: ca0106: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:10 +0200 Message-Id: <20210608140540.17885-37-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI CA0106 driver code contains a few assignments in if condition, which is a bad coding style that may confuse readers and occasionally lead to bugs. This patch is merely for coding-style fixes, no functional changes. Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106_main.c | 18 ++++++++++++------ sound/pci/ca0106/ca_midi.c | 3 ++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index bee4710916c4..99778711006a 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -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; diff --git a/sound/pci/ca0106/ca_midi.c b/sound/pci/ca0106/ca_midi.c index 18524e0a9102..957e60f64821 100644 --- a/sound/pci/ca0106/ca_midi.c +++ b/sound/pci/ca0106/ca_midi.c @@ -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; From patchwork Tue Jun 8 14:05:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455868 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2894C47082 for ; Tue, 8 Jun 2021 14:17:36 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4DE886135A for ; Tue, 8 Jun 2021 14:17:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4DE886135A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id D985C1797; Tue, 8 Jun 2021 16:16:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D985C1797 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161854; bh=ORjVJb5skpt9uImgGcnFTIYdZxzMSbHn9+X8D44WFho=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=PdrM+Rqd8KGBN229prUSeOFwBPMqEkBeaxCIfUw/vQ9nKGDsfm78WbJTbaATE01C+ 34Q34NYFqRw+14mycnqQI2b2DenSy30kD4DwAp+68GeVoyw7YQ4lFLU5jStqS3m4X4 7jB6MxSzKFPyEujppb11oK/nxzSSmKT7ZLwpXYpU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 84DBAF805FA; Tue, 8 Jun 2021 16:06:47 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D58F2F805DA; Tue, 8 Jun 2021 16:06:35 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5FFF4F804DF for ; Tue, 8 Jun 2021 16:05:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5FFF4F804DF Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="q3rfkVga"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="wdoMspDZ" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 8B4681FDEA for ; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pyB09o/IF8f200Wut2OgkP6yGdR5dmzOyxbwo5Zam6Y=; b=q3rfkVgabO9QB6h1GL2mC08tyXXTotrS50wZyd7xlNoCJxVGE6b/5bGM2qoGwdiqGFpNFP Nl/ZwCgy5Bf1KEgKP5gmEl4wxBs/QALH/4j2OkbaK5GgYSiGmccmirvM0PVJEhducB2a3J NZ3sCF4QXrLEfsoQvPxfXbWu5DOjako= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pyB09o/IF8f200Wut2OgkP6yGdR5dmzOyxbwo5Zam6Y=; b=wdoMspDZQVtyIIUwBuK0n24is9pTLUddVJgpkRWQvFCDT14YbNtn/6MXjZmmQvKlj3qSIh cLgi0RcWWDDkQGBg== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 858ECA3B84; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 37/66] ALSA: cs46xx: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:11 +0200 Message-Id: <20210608140540.17885-38-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- 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(-) diff --git a/sound/pci/cs46xx/cs46xx.c b/sound/pci/cs46xx/cs46xx.c index 1db7b4112840..358ca84cbdea 100644 --- a/sound/pci/cs46xx/cs46xx.c +++ b/sound/pci/cs46xx/cs46xx.c @@ -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; } diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 37f516e6a5c2..1e1eb17f8e07 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -1058,9 +1058,10 @@ static int _cs46xx_adjust_sample_rate (struct snd_cs46xx *chip, struct snd_cs46x int unlinked = cpcm->pcm_channel->unlinked; cs46xx_dsp_destroy_pcm_channel (chip,cpcm->pcm_channel); - if ( (cpcm->pcm_channel = cs46xx_dsp_create_pcm_channel (chip, sample_rate, cpcm, - cpcm->hw_buf.addr, - cpcm->pcm_channel_id)) == NULL) { + cpcm->pcm_channel = cs46xx_dsp_create_pcm_channel(chip, sample_rate, cpcm, + cpcm->hw_buf.addr, + cpcm->pcm_channel_id); + if (!cpcm->pcm_channel) { dev_err(chip->card->dev, "failed to re-create virtual PCM channel\n"); return -ENOMEM; @@ -1147,7 +1148,8 @@ static int snd_cs46xx_playback_hw_params(struct snd_pcm_substream *substream, runtime->dma_addr = 0; runtime->dma_bytes = 0; } - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) { + err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); + if (err < 0) { #ifdef CONFIG_SND_CS46XX_NEW_DSP mutex_unlock(&chip->spos_mutex); #endif @@ -1295,7 +1297,8 @@ static int snd_cs46xx_capture_hw_params(struct snd_pcm_substream *substream, runtime->dma_addr = 0; runtime->dma_bytes = 0; } - if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) + err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); + if (err < 0) return err; substream->ops = &snd_cs46xx_capture_indirect_ops; } @@ -1760,7 +1763,8 @@ int snd_cs46xx_pcm(struct snd_cs46xx *chip, int device) struct snd_pcm *pcm; int err; - if ((err = snd_pcm_new(chip->card, "CS46xx", device, MAX_PLAYBACK_CHANNELS, 1, &pcm)) < 0) + err = snd_pcm_new(chip->card, "CS46xx", device, MAX_PLAYBACK_CHANNELS, 1, &pcm); + if (err < 0) return err; pcm->private_data = chip; @@ -1787,7 +1791,8 @@ int snd_cs46xx_pcm_rear(struct snd_cs46xx *chip, int device) struct snd_pcm *pcm; int err; - if ((err = snd_pcm_new(chip->card, "CS46xx - Rear", device, MAX_PLAYBACK_CHANNELS, 0, &pcm)) < 0) + err = snd_pcm_new(chip->card, "CS46xx - Rear", device, MAX_PLAYBACK_CHANNELS, 0, &pcm); + if (err < 0) return err; pcm->private_data = chip; @@ -1811,7 +1816,8 @@ int snd_cs46xx_pcm_center_lfe(struct snd_cs46xx *chip, int device) struct snd_pcm *pcm; int err; - if ((err = snd_pcm_new(chip->card, "CS46xx - Center LFE", device, MAX_PLAYBACK_CHANNELS, 0, &pcm)) < 0) + err = snd_pcm_new(chip->card, "CS46xx - Center LFE", device, MAX_PLAYBACK_CHANNELS, 0, &pcm); + if (err < 0) return err; pcm->private_data = chip; @@ -1835,7 +1841,8 @@ int snd_cs46xx_pcm_iec958(struct snd_cs46xx *chip, int device) struct snd_pcm *pcm; int err; - if ((err = snd_pcm_new(chip->card, "CS46xx - IEC958", device, 1, 0, &pcm)) < 0) + err = snd_pcm_new(chip->card, "CS46xx - IEC958", device, 1, 0, &pcm); + if (err < 0) return err; pcm->private_data = chip; @@ -2414,7 +2421,8 @@ static void snd_cs46xx_codec_reset (struct snd_ac97 * ac97) /* test if we can write to the record gain volume register */ snd_ac97_write(ac97, AC97_REC_GAIN, 0x8a05); - if ((err = snd_ac97_read(ac97, AC97_REC_GAIN)) == 0x8a05) + err = snd_ac97_read(ac97, AC97_REC_GAIN); + if (err == 0x8a05) return; msleep(10); @@ -2476,7 +2484,8 @@ int snd_cs46xx_mixer(struct snd_cs46xx *chip, int spdif_device) /* detect primary codec */ chip->nr_ac97_codecs = 0; dev_dbg(chip->card->dev, "detecting primary codec\n"); - 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_cs46xx_mixer_free_ac97_bus; @@ -2497,7 +2506,8 @@ int snd_cs46xx_mixer(struct snd_cs46xx *chip, int spdif_device) kctl = snd_ctl_new1(&snd_cs46xx_controls[idx], chip); if (kctl && kctl->id.iface == SNDRV_CTL_ELEM_IFACE_PCM) kctl->id.device = spdif_device; - if ((err = snd_ctl_add(card, kctl)) < 0) + err = snd_ctl_add(card, kctl); + if (err < 0) return err; } @@ -2684,7 +2694,8 @@ int snd_cs46xx_midi(struct snd_cs46xx *chip, int device) struct snd_rawmidi *rmidi; int err; - if ((err = snd_rawmidi_new(chip->card, "CS46XX", device, 1, 1, &rmidi)) < 0) + err = snd_rawmidi_new(chip->card, "CS46XX", device, 1, 1, &rmidi); + if (err < 0) return err; strcpy(rmidi->name, "CS46XX"); snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_cs46xx_midi_output); @@ -3526,7 +3537,8 @@ static void hercules_mixer_init (struct snd_cs46xx *chip) struct snd_kcontrol *kctl; kctl = snd_ctl_new1(&snd_hercules_controls[idx], chip); - if ((err = snd_ctl_add(card, kctl)) < 0) { + err = snd_ctl_add(card, kctl); + if (err < 0) { dev_err(card->dev, "failed to initialize Hercules mixer (%d)\n", err); @@ -3871,7 +3883,8 @@ int snd_cs46xx_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; chip = kzalloc(sizeof(*chip), GFP_KERNEL); @@ -3965,8 +3978,9 @@ int snd_cs46xx_create(struct snd_card *card, for (idx = 0; idx < 5; idx++) { region = &chip->region.idx[idx]; - if ((region->resource = request_mem_region(region->base, region->size, - region->name)) == NULL) { + region->resource = request_mem_region(region->base, region->size, + region->name); + if (!region->resource) { dev_err(chip->card->dev, "unable to request memory region 0x%lx-0x%lx\n", region->base, region->base + region->size - 1); @@ -4005,7 +4019,8 @@ int snd_cs46xx_create(struct snd_card *card, 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_cs46xx_free(chip); return err; } diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c index 05f3f6dc918d..1db6bc58d6a6 100644 --- a/sound/pci/cs46xx/dsp_spos.c +++ b/sound/pci/cs46xx/dsp_spos.c @@ -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); } From patchwork Tue Jun 8 14:05:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455856 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2C32C47082 for ; Tue, 8 Jun 2021 14:27:01 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E5A69611BD for ; Tue, 8 Jun 2021 14:27:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5A69611BD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8365217A8; Tue, 8 Jun 2021 16:26:09 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8365217A8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162419; bh=4x7atCLBwhXnTKWp9LGln2F1jYwDDFjyqm6lNKmdI48=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=E88L/ZFrYvCgaSG8HN5GFMmc5NdowqANnxushqn0aCmxZTe4w8L5mAylQZ3DFPJxB ZCFoc6z5lT4lVgZxSwBoSd1RPe2q2ZACqFlNd8xzXCJdr/IeK6q5AMojAaEvnqHfgc qRxaFn9deYSCKhv+va8AwferfTe8+kVZ482qlE94= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 521E0F806E5; Tue, 8 Jun 2021 16:07:35 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id F10C0F80517; Tue, 8 Jun 2021 16:07:13 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id F198EF80517 for ; Tue, 8 Jun 2021 16:05:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz F198EF80517 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="kH9T1DPn"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="o5ij+r/e" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 9A554219E9 for ; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zrr4gQHCUKEw4VavQJPy1tbVXsA7gcjKqCUgUDfLD2g=; b=kH9T1DPnl2Im/UoJ4fy7Q6xHsHYmNRkjhp6JlFLmgVvh0MoeV8WFI32k55Mhhla/5rvlkk ZecDw2SzQvT5kbj3LBnnw2ce3nH6sEmN+YM24paxJLGSHOWawwORNEPt+Y1DhJsjEO+KQI M0OOQ3Cg2WRnyUzY6MPjQ1NjvoqFwnk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zrr4gQHCUKEw4VavQJPy1tbVXsA7gcjKqCUgUDfLD2g=; b=o5ij+r/ewLQ7xApvN8R6ZTZLL2DxaG+UL+QjFp/tI008LaIuJIGTSXYIIrTeYyKYCazkbo qdpQEFE09QUo8xBw== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 8A6AFA3B89; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 38/66] ALSA: cs5535audio: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:12 +0200 Message-Id: <20210608140540.17885-39-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/cs5535audio/cs5535audio.c | 28 ++++++++++++++++--------- sound/pci/cs5535audio/cs5535audio_pcm.c | 10 +++++---- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c index 9b716b56d739..e048b45d9e7e 100644 --- a/sound/pci/cs5535audio/cs5535audio.c +++ b/sound/pci/cs5535audio/cs5535audio.c @@ -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); diff --git a/sound/pci/cs5535audio/cs5535audio_pcm.c b/sound/pci/cs5535audio/cs5535audio_pcm.c index 4032b89b1fc1..5ff10fec7b90 100644 --- a/sound/pci/cs5535audio/cs5535audio_pcm.c +++ b/sound/pci/cs5535audio/cs5535audio_pcm.c @@ -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; From patchwork Tue Jun 8 14:05:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456887 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4B83C47082 for ; Tue, 8 Jun 2021 14:17:57 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4CE9F61359 for ; Tue, 8 Jun 2021 14:17:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4CE9F61359 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id DDB2316F2; Tue, 8 Jun 2021 16:17:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DDB2316F2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161876; bh=t525L66iFX5KrTozwEdzAMDpducLtI1AEoqPusfQljw=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=UgfUB4TP9q2Gce2WTxTT5IT5dJlVfpa38ngtm6zRJU5p+l1jWMPwuwBHn4rKKisV8 6BuwwOf+jJ4MyvSLdT/ZSh2OdGjfN5fwvQXmdMzq7rOnfPeyfODuJ5UpTzk7Y6aQ7W +wF2seENmQe3M3P0OcDfFCG7KjFHVktRzg06iTw8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C5203F805FB; Tue, 8 Jun 2021 16:06:48 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id F0434F805E3; Tue, 8 Jun 2021 16:06:37 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 71097F804E4 for ; Tue, 8 Jun 2021 16:05:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 71097F804E4 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="L6appTKM"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="9cvWwGSb" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id A26B01FDEB for ; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lo4EFOXWEMemGadDUi2/eZbJvCOOt+fp0emFD82IN1M=; b=L6appTKMg+8QO4gT24HPdt8QicCyF1W2e5LSo91RdLoyECBvGzLDFSTdz5B/Kgl8lXFPAD zSM+4tOcDIAxnASih0Bu3e6Bm5tRc0jqHY2GeRqrG9c/K431Q+dHvHICd53220a07b30jV ZM+CmZYAduChs6C6+oNZCQBzW1RPZwE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lo4EFOXWEMemGadDUi2/eZbJvCOOt+fp0emFD82IN1M=; b=9cvWwGSb/kRidmhXD2/v47pLgJW0un3goiHvJeBAGKrncM8EJW9fbO7Pi29HlIyOfzN7k1 +SDJjLPn89hm/qCg== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 99EF6A3B84; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 39/66] ALSA: echoaudio: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:13 +0200 Message-Id: <20210608140540.17885-40-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- 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(-) diff --git a/sound/pci/echoaudio/darla20_dsp.c b/sound/pci/echoaudio/darla20_dsp.c index 320837ba7bab..0356efad7528 100644 --- a/sound/pci/echoaudio/darla20_dsp.c +++ b/sound/pci/echoaudio/darla20_dsp.c @@ -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; diff --git a/sound/pci/echoaudio/darla24_dsp.c b/sound/pci/echoaudio/darla24_dsp.c index 8736b5e81ca3..b96300772aee 100644 --- a/sound/pci/echoaudio/darla24_dsp.c +++ b/sound/pci/echoaudio/darla24_dsp.c @@ -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; diff --git a/sound/pci/echoaudio/echo3g_dsp.c b/sound/pci/echoaudio/echo3g_dsp.c index 6deb80c42f11..9e1f2cad0909 100644 --- a/sound/pci/echoaudio/echo3g_dsp.c +++ b/sound/pci/echoaudio/echo3g_dsp.c @@ -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; diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index 9bd67ac33657..a62e5581ad14 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -301,38 +301,42 @@ static int pcm_open(struct snd_pcm_substream *substream, snd_pcm_set_sync(substream); /* Only mono and any even number of channels are allowed */ - if ((err = snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_CHANNELS, - &pipe->constr)) < 0) + err = snd_pcm_hw_constraint_list(runtime, 0, + SNDRV_PCM_HW_PARAM_CHANNELS, + &pipe->constr); + if (err < 0) return err; /* All periods should have the same size */ - 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; /* The hw accesses memory in chunks 32 frames long and they should be 32-bytes-aligned. It's not a requirement, but it seems that IRQs are generated with a resolution of 32 frames. Thus we need the following */ - if ((err = snd_pcm_hw_constraint_step(runtime, 0, - SNDRV_PCM_HW_PARAM_PERIOD_SIZE, - 32)) < 0) + err = snd_pcm_hw_constraint_step(runtime, 0, + SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 32); + if (err < 0) return err; - if ((err = snd_pcm_hw_constraint_step(runtime, 0, - SNDRV_PCM_HW_PARAM_BUFFER_SIZE, - 32)) < 0) + err = snd_pcm_hw_constraint_step(runtime, 0, + SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 32); + if (err < 0) return err; - if ((err = snd_pcm_hw_rule_add(substream->runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - hw_rule_sample_rate, chip, - SNDRV_PCM_HW_PARAM_RATE, -1)) < 0) + err = snd_pcm_hw_rule_add(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + hw_rule_sample_rate, chip, + SNDRV_PCM_HW_PARAM_RATE, -1); + if (err < 0) return err; /* Allocate a page for the scatter-gather list */ - if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, - &chip->pci->dev, - PAGE_SIZE, &pipe->sgpage)) < 0) { + err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, + &chip->pci->dev, + PAGE_SIZE, &pipe->sgpage); + if (err < 0) { dev_err(chip->card->dev, "s-g list allocation failed\n"); return err; } @@ -358,18 +362,21 @@ static int pcm_analog_in_open(struct snd_pcm_substream *substream) struct echoaudio *chip = snd_pcm_substream_chip(substream); int err; - if ((err = pcm_open(substream, num_analog_busses_in(chip) - - substream->number)) < 0) + err = pcm_open(substream, + num_analog_busses_in(chip) - substream->number); + if (err < 0) return err; - if ((err = snd_pcm_hw_rule_add(substream->runtime, 0, - SNDRV_PCM_HW_PARAM_CHANNELS, - hw_rule_capture_channels_by_format, NULL, - SNDRV_PCM_HW_PARAM_FORMAT, -1)) < 0) + err = snd_pcm_hw_rule_add(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_CHANNELS, + hw_rule_capture_channels_by_format, NULL, + SNDRV_PCM_HW_PARAM_FORMAT, -1); + if (err < 0) return err; - if ((err = snd_pcm_hw_rule_add(substream->runtime, 0, - SNDRV_PCM_HW_PARAM_FORMAT, - hw_rule_capture_format_by_channels, NULL, - SNDRV_PCM_HW_PARAM_CHANNELS, -1)) < 0) + err = snd_pcm_hw_rule_add(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_FORMAT, + hw_rule_capture_format_by_channels, NULL, + SNDRV_PCM_HW_PARAM_CHANNELS, -1); + if (err < 0) return err; return 0; @@ -387,19 +394,22 @@ static int pcm_analog_out_open(struct snd_pcm_substream *substream) #else max_channels = num_analog_busses_out(chip); #endif - if ((err = pcm_open(substream, max_channels - substream->number)) < 0) + err = pcm_open(substream, max_channels - substream->number); + if (err < 0) return err; - if ((err = snd_pcm_hw_rule_add(substream->runtime, 0, - SNDRV_PCM_HW_PARAM_CHANNELS, - hw_rule_playback_channels_by_format, - NULL, - SNDRV_PCM_HW_PARAM_FORMAT, -1)) < 0) + err = snd_pcm_hw_rule_add(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_CHANNELS, + hw_rule_playback_channels_by_format, + NULL, + SNDRV_PCM_HW_PARAM_FORMAT, -1); + if (err < 0) return err; - if ((err = snd_pcm_hw_rule_add(substream->runtime, 0, - SNDRV_PCM_HW_PARAM_FORMAT, - hw_rule_playback_format_by_channels, - NULL, - SNDRV_PCM_HW_PARAM_CHANNELS, -1)) < 0) + err = snd_pcm_hw_rule_add(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_FORMAT, + hw_rule_playback_format_by_channels, + NULL, + SNDRV_PCM_HW_PARAM_CHANNELS, -1); + if (err < 0) return err; return 0; @@ -426,15 +436,17 @@ static int pcm_digital_in_open(struct snd_pcm_substream *substream) if (err < 0) goto din_exit; - if ((err = snd_pcm_hw_rule_add(substream->runtime, 0, - SNDRV_PCM_HW_PARAM_CHANNELS, - hw_rule_capture_channels_by_format, NULL, - SNDRV_PCM_HW_PARAM_FORMAT, -1)) < 0) + err = snd_pcm_hw_rule_add(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_CHANNELS, + hw_rule_capture_channels_by_format, NULL, + SNDRV_PCM_HW_PARAM_FORMAT, -1); + if (err < 0) goto din_exit; - if ((err = snd_pcm_hw_rule_add(substream->runtime, 0, - SNDRV_PCM_HW_PARAM_FORMAT, - hw_rule_capture_format_by_channels, NULL, - SNDRV_PCM_HW_PARAM_CHANNELS, -1)) < 0) + err = snd_pcm_hw_rule_add(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_FORMAT, + hw_rule_capture_format_by_channels, NULL, + SNDRV_PCM_HW_PARAM_CHANNELS, -1); + if (err < 0) goto din_exit; din_exit: @@ -463,17 +475,19 @@ static int pcm_digital_out_open(struct snd_pcm_substream *substream) if (err < 0) goto dout_exit; - if ((err = snd_pcm_hw_rule_add(substream->runtime, 0, - SNDRV_PCM_HW_PARAM_CHANNELS, - hw_rule_playback_channels_by_format, - NULL, SNDRV_PCM_HW_PARAM_FORMAT, - -1)) < 0) + err = snd_pcm_hw_rule_add(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_CHANNELS, + hw_rule_playback_channels_by_format, + NULL, SNDRV_PCM_HW_PARAM_FORMAT, + -1); + if (err < 0) goto dout_exit; - if ((err = snd_pcm_hw_rule_add(substream->runtime, 0, - SNDRV_PCM_HW_PARAM_FORMAT, - hw_rule_playback_format_by_channels, - NULL, SNDRV_PCM_HW_PARAM_CHANNELS, - -1)) < 0) + err = snd_pcm_hw_rule_add(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_FORMAT, + hw_rule_playback_format_by_channels, + NULL, SNDRV_PCM_HW_PARAM_CHANNELS, + -1); + if (err < 0) goto dout_exit; dout_exit: @@ -907,8 +921,9 @@ static int snd_echo_new_pcm(struct echoaudio *chip) separated */ /* PCM#0 Virtual outputs and analog inputs */ - if ((err = snd_pcm_new(chip->card, "PCM", 0, num_pipes_out(chip), - num_analog_busses_in(chip), &pcm)) < 0) + err = snd_pcm_new(chip->card, "PCM", 0, num_pipes_out(chip), + num_analog_busses_in(chip), &pcm); + if (err < 0) return err; pcm->private_data = chip; chip->analog_pcm = pcm; @@ -919,8 +934,9 @@ static int snd_echo_new_pcm(struct echoaudio *chip) #ifdef ECHOCARD_HAS_DIGITAL_IO /* PCM#1 Digital inputs, no outputs */ - if ((err = snd_pcm_new(chip->card, "Digital PCM", 1, 0, - num_digital_busses_in(chip), &pcm)) < 0) + err = snd_pcm_new(chip->card, "Digital PCM", 1, 0, + num_digital_busses_in(chip), &pcm); + if (err < 0) return err; pcm->private_data = chip; chip->digital_pcm = pcm; @@ -937,9 +953,10 @@ static int snd_echo_new_pcm(struct echoaudio *chip) register two PCM devices: */ /* PCM#0 Analog i/o */ - if ((err = snd_pcm_new(chip->card, "Analog PCM", 0, - num_analog_busses_out(chip), - num_analog_busses_in(chip), &pcm)) < 0) + err = snd_pcm_new(chip->card, "Analog PCM", 0, + num_analog_busses_out(chip), + num_analog_busses_in(chip), &pcm); + if (err < 0) return err; pcm->private_data = chip; chip->analog_pcm = pcm; @@ -950,9 +967,10 @@ static int snd_echo_new_pcm(struct echoaudio *chip) #ifdef ECHOCARD_HAS_DIGITAL_IO /* PCM#1 Digital i/o */ - if ((err = snd_pcm_new(chip->card, "Digital PCM", 1, - num_digital_busses_out(chip), - num_digital_busses_in(chip), &pcm)) < 0) + err = snd_pcm_new(chip->card, "Digital PCM", 1, + num_digital_busses_out(chip), + num_digital_busses_in(chip), &pcm); + if (err < 0) return err; pcm->private_data = chip; chip->digital_pcm = pcm; @@ -1567,7 +1585,8 @@ static int snd_echo_clock_source_put(struct snd_kcontrol *kcontrol, if (chip->input_clock != dclock) { mutex_lock(&chip->mode_mutex); spin_lock_irq(&chip->lock); - if ((changed = set_input_clock(chip, dclock)) == 0) + changed = set_input_clock(chip, dclock); + if (!changed) changed = 1; /* no errors */ spin_unlock_irq(&chip->lock); mutex_unlock(&chip->mode_mutex); @@ -1911,7 +1930,8 @@ static int snd_echo_create(struct snd_card *card, pci_write_config_byte(pci, PCI_LATENCY_TIMER, 0xC0); - if ((err = pci_enable_device(pci)) < 0) + err = pci_enable_device(pci); + if (err < 0) return err; pci_set_master(pci); @@ -1943,8 +1963,9 @@ static int snd_echo_create(struct snd_card *card, if (sz > PAGE_SIZE) sz = PAGE_SIZE; /* We map only the required part */ - if ((chip->iores = request_mem_region(chip->dsp_registers_phys, sz, - ECHOCARD_NAME)) == NULL) { + chip->iores = request_mem_region(chip->dsp_registers_phys, sz, + ECHOCARD_NAME); + if (!chip->iores) { dev_err(chip->card->dev, "cannot get memory region\n"); snd_echo_free(chip); return -EBUSY; @@ -1988,7 +2009,8 @@ static int snd_echo_create(struct snd_card *card, 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_echo_free(chip); return err; } @@ -2024,7 +2046,8 @@ static int snd_echo_probe(struct pci_dev *pci, return err; chip = NULL; /* Tells snd_echo_create to allocate chip */ - if ((err = snd_echo_create(card, pci, &chip)) < 0) { + err = snd_echo_create(card, pci, &chip); + if (err < 0) { snd_card_free(card); return err; } @@ -2040,7 +2063,8 @@ static int snd_echo_probe(struct pci_dev *pci, card->shortname, pci_id->subdevice & 0x000f, dsp, chip->dsp_registers_phys, chip->irq); - if ((err = snd_echo_new_pcm(chip)) < 0) { + err = snd_echo_new_pcm(chip); + if (err < 0) { dev_err(chip->card->dev, "new pcm error %d\n", err); snd_card_free(card); return err; @@ -2048,7 +2072,8 @@ static int snd_echo_probe(struct pci_dev *pci, #ifdef ECHOCARD_HAS_MIDI if (chip->has_midi) { /* Some Mia's do not have midi */ - if ((err = snd_echo_midi_create(card, chip)) < 0) { + err = snd_echo_midi_create(card, chip); + if (err < 0) { dev_err(chip->card->dev, "new midi error %d\n", err); snd_card_free(card); return err; @@ -2058,7 +2083,8 @@ static int snd_echo_probe(struct pci_dev *pci, #ifdef ECHOCARD_HAS_VMIXER snd_echo_vmixer.count = num_pipes_out(chip) * num_busses_out(chip); - if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_vmixer, chip))) < 0) + err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_vmixer, chip)); + if (err < 0) goto ctl_error; #ifdef ECHOCARD_HAS_LINE_OUT_GAIN err = snd_ctl_add(chip->card, @@ -2074,39 +2100,48 @@ static int snd_echo_probe(struct pci_dev *pci, #endif /* ECHOCARD_HAS_VMIXER */ #ifdef ECHOCARD_HAS_INPUT_GAIN - if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_line_input_gain, chip))) < 0) + err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_line_input_gain, chip)); + if (err < 0) goto ctl_error; #endif #ifdef ECHOCARD_HAS_INPUT_NOMINAL_LEVEL - if (!chip->hasnt_input_nominal_level) - if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_intput_nominal_level, chip))) < 0) + if (!chip->hasnt_input_nominal_level) { + err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_intput_nominal_level, chip)); + if (err < 0) goto ctl_error; + } #endif #ifdef ECHOCARD_HAS_OUTPUT_NOMINAL_LEVEL - if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_output_nominal_level, chip))) < 0) + err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_output_nominal_level, chip)); + if (err < 0) goto ctl_error; #endif - if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_vumeters_switch, chip))) < 0) + err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_vumeters_switch, chip)); + if (err < 0) goto ctl_error; - if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_vumeters, chip))) < 0) + err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_vumeters, chip)); + if (err < 0) goto ctl_error; #ifdef ECHOCARD_HAS_MONITOR snd_echo_monitor_mixer.count = num_busses_in(chip) * num_busses_out(chip); - if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_monitor_mixer, chip))) < 0) + err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_monitor_mixer, chip)); + if (err < 0) goto ctl_error; #endif #ifdef ECHOCARD_HAS_DIGITAL_IN_AUTOMUTE - if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_automute_switch, chip))) < 0) + err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_automute_switch, chip)); + if (err < 0) goto ctl_error; #endif - if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_channels_info, chip))) < 0) + err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_channels_info, chip)); + if (err < 0) goto ctl_error; #ifdef ECHOCARD_HAS_DIGITAL_MODE_SWITCH @@ -2116,7 +2151,8 @@ static int snd_echo_probe(struct pci_dev *pci, if (chip->digital_modes & (1 << i)) chip->digital_mode_list[chip->num_digital_modes++] = i; - if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_digital_mode_switch, chip))) < 0) + err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_digital_mode_switch, chip)); + if (err < 0) goto ctl_error; #endif /* ECHOCARD_HAS_DIGITAL_MODE_SWITCH */ @@ -2129,20 +2165,24 @@ static int snd_echo_probe(struct pci_dev *pci, if (chip->num_clock_sources > 1) { chip->clock_src_ctl = snd_ctl_new1(&snd_echo_clock_source_switch, chip); - if ((err = snd_ctl_add(chip->card, chip->clock_src_ctl)) < 0) + err = snd_ctl_add(chip->card, chip->clock_src_ctl); + if (err < 0) goto ctl_error; } #endif /* ECHOCARD_HAS_EXTERNAL_CLOCK */ #ifdef ECHOCARD_HAS_DIGITAL_IO - if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_spdif_mode_switch, chip))) < 0) + err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_spdif_mode_switch, chip)); + if (err < 0) goto ctl_error; #endif #ifdef ECHOCARD_HAS_PHANTOM_POWER - if (chip->has_phantom_power) - if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_phantom_power_switch, chip))) < 0) + if (chip->has_phantom_power) { + err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_phantom_power_switch, chip)); + if (err < 0) goto ctl_error; + } #endif err = snd_card_register(card); diff --git a/sound/pci/echoaudio/echoaudio_dsp.c b/sound/pci/echoaudio/echoaudio_dsp.c index d10d0e460f0b..2a40091d472c 100644 --- a/sound/pci/echoaudio/echoaudio_dsp.c +++ b/sound/pci/echoaudio/echoaudio_dsp.c @@ -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. */ diff --git a/sound/pci/echoaudio/echoaudio_gml.c b/sound/pci/echoaudio/echoaudio_gml.c index eea6fe530ab4..248983fa2959 100644 --- a/sound/pci/echoaudio/echoaudio_gml.c +++ b/sound/pci/echoaudio/echoaudio_gml.c @@ -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", diff --git a/sound/pci/echoaudio/gina20_dsp.c b/sound/pci/echoaudio/gina20_dsp.c index b2377573de09..c93939850357 100644 --- a/sound/pci/echoaudio/gina20_dsp.c +++ b/sound/pci/echoaudio/gina20_dsp.c @@ -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; diff --git a/sound/pci/echoaudio/gina24_dsp.c b/sound/pci/echoaudio/gina24_dsp.c index 8eff2b4f5ceb..56e9d1b9b330 100644 --- a/sound/pci/echoaudio/gina24_dsp.c +++ b/sound/pci/echoaudio/gina24_dsp.c @@ -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; diff --git a/sound/pci/echoaudio/indigo_dsp.c b/sound/pci/echoaudio/indigo_dsp.c index c97dc83bbbdf..16eb082df56a 100644 --- a/sound/pci/echoaudio/indigo_dsp.c +++ b/sound/pci/echoaudio/indigo_dsp.c @@ -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; diff --git a/sound/pci/echoaudio/indigodj_dsp.c b/sound/pci/echoaudio/indigodj_dsp.c index 2428b35f45d6..17a1d888d0b9 100644 --- a/sound/pci/echoaudio/indigodj_dsp.c +++ b/sound/pci/echoaudio/indigodj_dsp.c @@ -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; diff --git a/sound/pci/echoaudio/indigoio_dsp.c b/sound/pci/echoaudio/indigoio_dsp.c index 79b68ba70936..791787aa0744 100644 --- a/sound/pci/echoaudio/indigoio_dsp.c +++ b/sound/pci/echoaudio/indigoio_dsp.c @@ -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; diff --git a/sound/pci/echoaudio/layla20_dsp.c b/sound/pci/echoaudio/layla20_dsp.c index 5e5b6e288a2d..5fb5c4a4598b 100644 --- a/sound/pci/echoaudio/layla20_dsp.c +++ b/sound/pci/echoaudio/layla20_dsp.c @@ -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; diff --git a/sound/pci/echoaudio/layla24_dsp.c b/sound/pci/echoaudio/layla24_dsp.c index c02bc1dcc170..ef27805d63f6 100644 --- a/sound/pci/echoaudio/layla24_dsp.c +++ b/sound/pci/echoaudio/layla24_dsp.c @@ -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; diff --git a/sound/pci/echoaudio/mia_dsp.c b/sound/pci/echoaudio/mia_dsp.c index 8f612a09c5d0..8a4dffc68889 100644 --- a/sound/pci/echoaudio/mia_dsp.c +++ b/sound/pci/echoaudio/mia_dsp.c @@ -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; diff --git a/sound/pci/echoaudio/midi.c b/sound/pci/echoaudio/midi.c index 6045a115cffe..cb72d27e809e 100644 --- a/sound/pci/echoaudio/midi.c +++ b/sound/pci/echoaudio/midi.c @@ -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); diff --git a/sound/pci/echoaudio/mona_dsp.c b/sound/pci/echoaudio/mona_dsp.c index f77db83dd73d..f8e7bb6ce040 100644 --- a/sound/pci/echoaudio/mona_dsp.c +++ b/sound/pci/echoaudio/mona_dsp.c @@ -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; From patchwork Tue Jun 8 14:05:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455867 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9534DC47082 for ; Tue, 8 Jun 2021 14:18:18 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1FAEF6135A for ; Tue, 8 Jun 2021 14:18:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1FAEF6135A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C1309172B; Tue, 8 Jun 2021 16:17:26 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C1309172B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161896; bh=reNNxptDXDlVW8mU4pNdY0zevzM8YS38sAP2rEQmLZ8=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=d6njmh1X4Kr8nbUcYh3EcLznwpA334qjSEQ2ZQ8GP8waJBtxsVriCwp6IjlV9bw7E p0KwvyWcAOKHthquaQ/wCMlp/tZrg+QECELjV5qkGv7OTEZs2TcwF73J0VbhrR0jQ1 mO3cemzLYM+f7gDZdqLBHu2SSu1BVlGSdtkkUxio= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5E4F8F80526; Tue, 8 Jun 2021 16:06:50 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BC857F805E4; Tue, 8 Jun 2021 16:06:38 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6F075F804E3 for ; Tue, 8 Jun 2021 16:05:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6F075F804E3 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="buXFu3H3"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="99ru0a/T" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id B33821FDEC for ; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DNDT0tcbUPSR1W36/Pg8mtVEfsPRem1XIqnhj/LvOIk=; b=buXFu3H3FuBWJzU2ndSKbdVAmDEBkWWMcjiinc4EKZUdkh6TrttSvBMbKkillqTuMb43nn BDslyaFB4tqnO8w0lrwn1MdeQaKeC3mx4SYPpl9kv0c1F9W6red7dDCWTIKT+VjlDq5Wrt /BkPNBEFeSBn/hql8GOrIZL6I8mGCSo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DNDT0tcbUPSR1W36/Pg8mtVEfsPRem1XIqnhj/LvOIk=; b=99ru0a/TcRp7f+YPF5rIlC4fFekf9hzaQBaZZiiv/TaRy9IMscJdN/Ipyy0cOooZ/RQ0Nl tWYNqrcBmmLjocCQ== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id A1A30A3B88; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 40/66] ALSA: emu10k1: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:14 +0200 Message-Id: <20210608140540.17885-41-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- 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(-) diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c index 45833bc2a7e7..887bfb3c1e17 100644 --- a/sound/pci/emu10k1/emu10k1.c +++ b/sound/pci/emu10k1/emu10k1.c @@ -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) diff --git a/sound/pci/emu10k1/emu10k1_callback.c b/sound/pci/emu10k1/emu10k1_callback.c index 07471c3dcbed..dba1e9fc2eec 100644 --- a/sound/pci/emu10k1/emu10k1_callback.c +++ b/sound/pci/emu10k1/emu10k1_callback.c @@ -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); diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index 80ef62a4a7c0..6cf7c8b1de47 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c @@ -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; diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c index 8a6cbe67e29d..e9c0fe3b8446 100644 --- a/sound/pci/emu10k1/emumixer.c +++ b/sound/pci/emu10k1/emumixer.c @@ -1119,7 +1119,8 @@ static int snd_audigy_spdif_output_rate_put(struct snd_kcontrol *kcontrol, reg = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0); tmp = reg & ~A_SPDIF_RATE_MASK; tmp |= val; - if ((change = (tmp != reg))) + change = (tmp != reg); + if (change) snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, 0, tmp); spin_unlock_irqrestore(&emu->reg_lock, flags); return change; @@ -1903,7 +1904,8 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu, .read = snd_emu10k1_ac97_read, }; - if ((err = snd_ac97_bus(emu->card, 0, &ops, NULL, &pbus)) < 0) + err = snd_ac97_bus(emu->card, 0, &ops, NULL, &pbus); + if (err < 0) return err; pbus->no_vra = 1; /* we don't need VRA */ @@ -1911,7 +1913,8 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu, ac97.private_data = emu; ac97.private_free = snd_emu10k1_mixer_free_ac97; ac97.scaps = AC97_SCAP_NO_SPDIF; - if ((err = snd_ac97_mixer(pbus, &ac97, &emu->ac97)) < 0) { + err = snd_ac97_mixer(pbus, &ac97, &emu->ac97); + if (err < 0) { if (emu->card_capabilities->ac97_chip == 1) return err; dev_info(emu->card->dev, @@ -1991,38 +1994,50 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu, rename_ctl(card, "Aux2 Capture Volume", "Line3 Capture Volume"); rename_ctl(card, "Mic Capture Volume", "Unknown1 Capture Volume"); } - if ((kctl = emu->ctl_send_routing = snd_ctl_new1(&snd_emu10k1_send_routing_control, emu)) == NULL) + kctl = emu->ctl_send_routing = snd_ctl_new1(&snd_emu10k1_send_routing_control, emu); + if (!kctl) return -ENOMEM; kctl->id.device = pcm_device; - if ((err = snd_ctl_add(card, kctl))) + err = snd_ctl_add(card, kctl); + if (err) return err; - if ((kctl = emu->ctl_send_volume = snd_ctl_new1(&snd_emu10k1_send_volume_control, emu)) == NULL) + kctl = emu->ctl_send_volume = snd_ctl_new1(&snd_emu10k1_send_volume_control, emu); + if (!kctl) return -ENOMEM; kctl->id.device = pcm_device; - if ((err = snd_ctl_add(card, kctl))) + err = snd_ctl_add(card, kctl); + if (err) return err; - if ((kctl = emu->ctl_attn = snd_ctl_new1(&snd_emu10k1_attn_control, emu)) == NULL) + kctl = emu->ctl_attn = snd_ctl_new1(&snd_emu10k1_attn_control, emu); + if (!kctl) return -ENOMEM; kctl->id.device = pcm_device; - if ((err = snd_ctl_add(card, kctl))) + err = snd_ctl_add(card, kctl); + if (err) return err; - if ((kctl = emu->ctl_efx_send_routing = snd_ctl_new1(&snd_emu10k1_efx_send_routing_control, emu)) == NULL) + kctl = emu->ctl_efx_send_routing = snd_ctl_new1(&snd_emu10k1_efx_send_routing_control, emu); + if (!kctl) return -ENOMEM; kctl->id.device = multi_device; - if ((err = snd_ctl_add(card, kctl))) + err = snd_ctl_add(card, kctl); + if (err) return err; - if ((kctl = emu->ctl_efx_send_volume = snd_ctl_new1(&snd_emu10k1_efx_send_volume_control, emu)) == NULL) + kctl = emu->ctl_efx_send_volume = snd_ctl_new1(&snd_emu10k1_efx_send_volume_control, emu); + if (!kctl) return -ENOMEM; kctl->id.device = multi_device; - if ((err = snd_ctl_add(card, kctl))) + err = snd_ctl_add(card, kctl); + if (err) return err; - if ((kctl = emu->ctl_efx_attn = snd_ctl_new1(&snd_emu10k1_efx_attn_control, emu)) == NULL) + kctl = emu->ctl_efx_attn = snd_ctl_new1(&snd_emu10k1_efx_attn_control, emu); + if (!kctl) return -ENOMEM; kctl->id.device = multi_device; - if ((err = snd_ctl_add(card, kctl))) + err = snd_ctl_add(card, kctl); + if (err) return err; /* initialize the routing and volume table for each pcm playback stream */ @@ -2069,42 +2084,53 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu, if (! emu->card_capabilities->ecard) { /* FIXME: APS has these controls? */ /* sb live! and audigy */ - if ((kctl = snd_ctl_new1(&snd_emu10k1_spdif_mask_control, emu)) == NULL) + kctl = snd_ctl_new1(&snd_emu10k1_spdif_mask_control, emu); + if (!kctl) return -ENOMEM; if (!emu->audigy) kctl->id.device = emu->pcm_efx->device; - if ((err = snd_ctl_add(card, kctl))) + err = snd_ctl_add(card, kctl); + if (err) return err; - if ((kctl = snd_ctl_new1(&snd_emu10k1_spdif_control, emu)) == NULL) + kctl = snd_ctl_new1(&snd_emu10k1_spdif_control, emu); + if (!kctl) return -ENOMEM; if (!emu->audigy) kctl->id.device = emu->pcm_efx->device; - if ((err = snd_ctl_add(card, kctl))) + err = snd_ctl_add(card, kctl); + if (err) return err; } if (emu->card_capabilities->emu_model) { ; /* Disable the snd_audigy_spdif_shared_spdif */ } else if (emu->audigy) { - if ((kctl = snd_ctl_new1(&snd_audigy_shared_spdif, emu)) == NULL) + kctl = snd_ctl_new1(&snd_audigy_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 0 - if ((kctl = snd_ctl_new1(&snd_audigy_spdif_output_rate, emu)) == NULL) + kctl = snd_ctl_new1(&snd_audigy_spdif_output_rate, emu); + if (!kctl) return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) + err = snd_ctl_add(card, kctl); + if (err) return err; #endif } else if (! emu->card_capabilities->ecard) { /* sb live! */ - if ((kctl = snd_ctl_new1(&snd_emu10k1_shared_spdif, emu)) == NULL) + kctl = snd_ctl_new1(&snd_emu10k1_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 (emu->card_capabilities->ca0151_chip) { /* P16V */ - if ((err = snd_p16v_mixer(emu))) + err = snd_p16v_mixer(emu); + if (err) return err; } diff --git a/sound/pci/emu10k1/emumpu401.c b/sound/pci/emu10k1/emumpu401.c index b62c95150702..3ce9b2129ce6 100644 --- a/sound/pci/emu10k1/emumpu401.c +++ b/sound/pci/emu10k1/emumpu401.c @@ -319,7 +319,8 @@ static int emu10k1_midi_init(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *m 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); @@ -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; diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c index b2ddabb99438..b2701a4452d8 100644 --- a/sound/pci/emu10k1/emupcm.c +++ b/sound/pci/emu10k1/emupcm.c @@ -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; diff --git a/sound/pci/emu10k1/memory.c b/sound/pci/emu10k1/memory.c index 288e0fd2e47d..9d26535f3fa3 100644 --- a/sound/pci/emu10k1/memory.c +++ b/sound/pci/emu10k1/memory.c @@ -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 *b spin_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 */ diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index 1099f102b365..ff2a3974c824 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c @@ -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; diff --git a/sound/pci/emu10k1/timer.c b/sound/pci/emu10k1/timer.c index c2803000aace..2435d3ba68f7 100644 --- a/sound/pci/emu10k1/timer.c +++ b/sound/pci/emu10k1/timer.c @@ -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; From patchwork Tue Jun 8 14:05:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4225C47082 for ; Tue, 8 Jun 2021 14:28:53 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DD62E610C7 for ; Tue, 8 Jun 2021 14:28:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD62E610C7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 7638B1711; Tue, 8 Jun 2021 16:28:01 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7638B1711 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162531; bh=pMBajeCDW1EO+ol4LLjZBrsmVlbsYPQWDe0gCksRTjo=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OO6RNQ4z33/x38JMAf6pWCExQm/4urgE1w84IiN7/I63KYRH1db6hq9h/QKVzVMnv 601NHq4qWRtsiNXEmoMCyxkLiqlhZmt+iN1Ov/1Ww5WH6aFfKl1X9jHQPTcY9DFV36 nc2FM3RDyO6pzjwyih/W1YzaZ+IGVuaPUHRqTfn4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 30DAEF80710; Tue, 8 Jun 2021 16:07:41 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 49BD3F8063D; Tue, 8 Jun 2021 16:07:20 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2E0E7F80518 for ; Tue, 8 Jun 2021 16:05:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2E0E7F80518 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="iGT6Fo8s"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="SrbXwE/1" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id C26BB219EA for ; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mz2hYP5Oh+PlY4BuVbSbX0fi3nx2qOY57RpUMX55pug=; b=iGT6Fo8slQi5c3Qrg49uA+KXkTHGRQwBKE/ye8ORhS7ewDzbHG52iBxbYp09YS748drJMz 27gif7COwt3Cb+GIuCvfVRpSUh2hUNEdouZdrxa8YEwikEmALaBqCEAk+I6T1+kb9Ux1d+ V8U6XrQGY7nQjcLBt7R8FGWcEIupoBI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mz2hYP5Oh+PlY4BuVbSbX0fi3nx2qOY57RpUMX55pug=; b=SrbXwE/134hovXCvPi2bcOtcIEy0HHIbFmzvVEaylopSfatzIP0fVh0PQUcB/K7RPUr3gK fvBiHe2HsWeadCDw== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id B2474A3B84; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 41/66] ALSA: emu10k1x: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:15 +0200 Message-Id: <20210608140540.17885-42-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/emu10k1/emu10k1x.c | 85 +++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 31 deletions(-) diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index d9a12cd01647..89b0f3884067 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -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; } From patchwork Tue Jun 8 14:05:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455854 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9D52C47082 for ; Tue, 8 Jun 2021 14:28:21 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2116D61003 for ; Tue, 8 Jun 2021 14:28:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2116D61003 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B7D80187A; Tue, 8 Jun 2021 16:27:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B7D80187A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162499; bh=VpaI09EeFYkszWjq7dpJWu8AACADuPf8I197Ayr0+vo=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=prb8KT3Qhgdf6kuj1yHP2jMDAKz6UlgHircOZVKx87iSYFun6GQt19KPfJ8JKXnKb HYv2e9/5F++Y1dpdNGX3A5HZsGTFdmP03FNxK/BYq8DQmJ4esPreWJT/xBrZ1Hlywe gwlHg7jUX/J2IqtnQ7oo2zXTbR2yMKYXbYeosOUE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D4AFEF8052D; Tue, 8 Jun 2021 16:07:39 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 73D95F80634; Tue, 8 Jun 2021 16:07:17 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 0937BF80519 for ; Tue, 8 Jun 2021 16:05:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0937BF80519 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="VUx5N/fM"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="ZgWbH6fE" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id D04CB219EB for ; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=si8FrI+trMYo24TA6jRWRcLvD22WVLvHwzu3gDyH8ww=; b=VUx5N/fMw1A1JR+D1YkNgZ2Xmf9dzeglm3yCtZSQNzpFJFc35EFJLhZfsaQfEeIDB/pMbq DH3tKjxnA5hWzfPVW6sEHtqntk9LSMosKe4gPN58B01d1u2DbnqBYMtl3V4E77zHprHJup yQy/nfepVOd5qNQNwYSpmrL4cfaPrgM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=si8FrI+trMYo24TA6jRWRcLvD22WVLvHwzu3gDyH8ww=; b=ZgWbH6fEw2v1yZxTpIImR5RZmGtKTC1I5M7zAC98BcoRKLtq7eU7BmI923X2TPqMDG5k0t GspBJSUd5epb5oAA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id C1047A3B88; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 42/66] ALSA: ice1712: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:16 +0200 Message-Id: <20210608140540.17885-43-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/ice1712/delta.c | 6 ++++-- sound/pci/ice1712/ews.c | 24 ++++++++++++++++-------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/sound/pci/ice1712/delta.c b/sound/pci/ice1712/delta.c index 1d2a0287284b..08adf4dd1303 100644 --- a/sound/pci/ice1712/delta.c +++ b/sound/pci/ice1712/delta.c @@ -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: diff --git a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c index 3794308313bf..8bb86b3c894e 100644 --- a/sound/pci/ice1712/ews.c +++ b/sound/pci/ice1712/ews.c @@ -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 s int 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 s int 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, str struct 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, str struct 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); From patchwork Tue Jun 8 14:05:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456875 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3557C47082 for ; Tue, 8 Jun 2021 14:27:19 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 48D65610C7 for ; Tue, 8 Jun 2021 14:27:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 48D65610C7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C23701711; Tue, 8 Jun 2021 16:26:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C23701711 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162437; bh=rs/dzwBvf3DAbIjciAyThWDDBPors+GZTpg4g/8QEmo=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=f5HpWq1tdALgGcAJ2d9YzgNzujS0V2hfrewivckw0m0Xp1stzMiQ2mckogp71s4kP DM0xAphAfrsJa0VddYyK55T+5liaNMDb0B1NouaF1xusUzyax/1Kh3ABi+SpjbHHhl ZyKJ+D/mUFU5FTOEyss7+EAbE2XfIsX2ZBJVYPcY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 92508F806F0; Tue, 8 Jun 2021 16:07:36 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 28CDFF80630; Tue, 8 Jun 2021 16:07:16 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E7DA0F80516 for ; Tue, 8 Jun 2021 16:05:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E7DA0F80516 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="k9ek5T4D"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="lZ+H4om7" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id E2253219EC for ; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=di0KYIbJL9zvYtvenAUIddvZR3J+8RIpg5XvF26IWpY=; b=k9ek5T4DO2sqHHPvh9TPEyX93zrXpQnWQiWH18N3VfdRLGAnq50f1mq3iST4SYNbRpDFsI xK2HK4aHig9W2e8LoGfTvFZ9qoOC7antJWeEuIEAe2rsr1fTTkBZ3Qir9b4mrCA4Oovgd/ ualkFTXc3yQO/ELklyi0vvBt2Z3kJic= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=di0KYIbJL9zvYtvenAUIddvZR3J+8RIpg5XvF26IWpY=; b=lZ+H4om76O2ihfGiz6RxAhOpQVKHNScWC1JSS5GfZIHvj+/Od2gn4VyTAld/+ipEaj6rpY 9Cmg1NuSJHvyL/Aw== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id CEDB3A3B84; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 43/66] ALSA: korg1212: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:17 +0200 Message-Id: <20210608140540.17885-44-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/korg1212/korg1212.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index 80ac3c6152ad..030e01b062e4 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -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; ivolumePhase[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; } From patchwork Tue Jun 8 14:05:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456874 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3627BC47082 for ; Tue, 8 Jun 2021 14:27:58 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B2C3E610C7 for ; Tue, 8 Jun 2021 14:27:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B2C3E610C7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 517421893; Tue, 8 Jun 2021 16:27:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 517421893 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162476; bh=hGDo0tUJ9sduzoXMHceClOGorI+S5xrVTOr/N1uAgsA=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=FyAgZHeR9tGCtO9DINaFg//QHN3MpanzczEvBXgGX9taJMkAlTvF+HG5IEB45fPEo q8e0rEI1r0sV4oXIC+Qtj+uPzNqLJWdYSRmGML+TSL39JjShQ4VIGKv4sSGwLs6eEI TIiWhLnARD9AzBQ2q+zV+nr2aUFvPkiK8+2ofP1s= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 050D8F806F9; Tue, 8 Jun 2021 16:07:39 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CD608F80630; Tue, 8 Jun 2021 16:07:16 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 02CD3F80515 for ; Tue, 8 Jun 2021 16:05:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 02CD3F80515 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="xRmLkGR8"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="xacYYwlz" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id EE647219EE for ; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=268R7RfcLPOHgTg88iRr0AiSpy1Cm6EldI+/sd5YZOY=; b=xRmLkGR8hbVH6XjSLuBgHp9qvx8cxoqe0aGacuXKFKwspcHjlJn4OwjMYTRgRbe17kW9hq WdYjh1iWtJTXp/7bbC3pyCWWyQyHWCWLXbwjiRkKhVQvr7jCjGI6ZpgdxMf2HgeIn7cDb8 kYju5GqKumOzlpH5oNXj+1BaOQndMY8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161144; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=268R7RfcLPOHgTg88iRr0AiSpy1Cm6EldI+/sd5YZOY=; b=xacYYwlzdPLeZ0P31yt+60DChJ6qm+maepam7C15qeV/0xbNEi027B2R9cO9oo666D7OaU ggflnOlkeXMmNyCw== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id DDBCEA3B88; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 44/66] ALSA: mixart: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:18 +0200 Message-Id: <20210608140540.17885-45-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- 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(-) diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index a0bbb386dc25..1b078b789604 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -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; } diff --git a/sound/pci/mixart/mixart_hwdep.c b/sound/pci/mixart/mixart_hwdep.c index f579f7698bba..689c0f995a9c 100644 --- a/sound/pci/mixart/mixart_hwdep.c +++ b/sound/pci/mixart/mixart_hwdep.c @@ -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 firmw for (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; } diff --git a/sound/pci/mixart/mixart_mixer.c b/sound/pci/mixart/mixart_mixer.c index d2e7c3381267..2727f3345795 100644 --- a/sound/pci/mixart/mixart_mixer.c +++ b/sound/pci/mixart/mixart_mixer.c @@ -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 */ From patchwork Tue Jun 8 14:05:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456886 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A648BC47082 for ; Tue, 8 Jun 2021 14:18:50 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 234E360FE9 for ; Tue, 8 Jun 2021 14:18:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 234E360FE9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C113117AB; Tue, 8 Jun 2021 16:17:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C113117AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161928; bh=F8PIYRGN+CCr6A3FE+vbm0FJCQIzD8s7RHploxxgk4g=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=TVOdICaKCVTlFWfDhKK8VzvA+a1RmxsH8g/Q1u16Bw8eHiinJNb6tEoh1ibyYTjw6 vI+nVVlwWMxqd7iTkctRh4RMzS5QmXmooZ4+/VMtxBJ+f+7iB+wuI+dNUN2MWEbdY/ N0AYE/Wh9gJUTbUi/yqQliNQBC7rB4a5hZjol1jU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7A5C1F80605; Tue, 8 Jun 2021 16:06:55 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C764CF805F3; Tue, 8 Jun 2021 16:06:42 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9AA1EF804E5 for ; Tue, 8 Jun 2021 16:05:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9AA1EF804E5 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="17jhbE+y"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Wtbr2TCY" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 087CF1FDED for ; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=88AndhKdAT76x6xvspiQKrkvmk8VN4fIvqcJYXn9TQc=; b=17jhbE+ys9nf0T03CzzAaDx2Wt6ytQcw7xq0WuUFJkUAzoPp5sqZd4cAdbe1rLeQEgjOhh AkGGdZb3TDGietAy2oX2mpdVCMcA1Ggzu+qD04iTKk2ANjQHyhOxAkdruyMdhhZs+qajZc 9mVSIxSTT2J5WndFYOOS7oyQaKYHC2k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=88AndhKdAT76x6xvspiQKrkvmk8VN4fIvqcJYXn9TQc=; b=Wtbr2TCYE9/xiBUoiSuf+LgDM+xwwN3xWgm2UR4zdx321d7ZZzUT3Dt4m7L+WOdHnbajnD nuMEancx0HeARiDA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id ED097A3B84; Tue, 8 Jun 2021 14:05:44 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 45/66] ALSA: nm256: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:19 +0200 Message-Id: <20210608140540.17885-46-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/nm256/nm256.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 6cb689aa28c2..12d02d7d3b51 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -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; } From patchwork Tue Jun 8 14:05:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455855 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E909CC47082 for ; Tue, 8 Jun 2021 14:27:39 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6B8AE61003 for ; Tue, 8 Jun 2021 14:27:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B8AE61003 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 04AF71878; Tue, 8 Jun 2021 16:26:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 04AF71878 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162458; bh=cyPMYi3kgA6+/R75kuLZeGfZBIeqA7H6hy/I1NyB+5g=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ZPaRrm/t2pwVe/sHxQ+e9YcCUDCsw0nTYY9MksX1pUQ+0ySPNALuvIj6QHSkyjFTN MqZPFiCjA9NiCY0k6lKNUDEnU+ZloUgGfKDwp0yRN4ky7vu/iNiVwYHPPtI+55s/Ix VBaVXT5rddfCuxa3BVbAnb91CKg1Alhsmy2epUAA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B7DA7F806F7; Tue, 8 Jun 2021 16:07:37 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D9D85F8062F; Tue, 8 Jun 2021 16:07:16 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D8B7CF80511 for ; Tue, 8 Jun 2021 16:05:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D8B7CF80511 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="biEeE+rN"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="/NoP4Aa9" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 0C231219EF for ; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xlwkpZP81U+zmwbLULv50cqDXSnlmjB0VciTF/cHS6M=; b=biEeE+rNf5ToIs+68Oqb2t70Op2uXKfiF4HR24Of+coSpBO4aBvjG6WTusM/WYitJv9cWl QG6M0aiRJK2qT83yp0A8U/1f0r25edXzeaFGEhIhYxoBUoOpsRc5bWIjJZiLa1ha1Ec8jR ZeRuYf1aJNpOHciHxGtu10g/TYqghWo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xlwkpZP81U+zmwbLULv50cqDXSnlmjB0VciTF/cHS6M=; b=/NoP4Aa9TrswM2RBwe0+x8mU9NKPuCiQ3GU+0HUEje7DkaaTu77i+neysKJWaBYJD+cIaB PDvRHOYH02yTE8CA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 076C3A3B88; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 46/66] ALSA: pcxhr: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:20 +0200 Message-Id: <20210608140540.17885-47-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/pcxhr/pcxhr.c | 22 ++++++++++++++-------- sound/pci/pcxhr/pcxhr_hwdep.c | 9 ++++++--- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index 751f9744b089..96b9371c201a 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c @@ -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; } diff --git a/sound/pci/pcxhr/pcxhr_hwdep.c b/sound/pci/pcxhr/pcxhr_hwdep.c index 2258bd698844..249805065f61 100644 --- a/sound/pci/pcxhr/pcxhr_hwdep.c +++ b/sound/pci/pcxhr/pcxhr_hwdep.c @@ -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); From patchwork Tue Jun 8 14:05:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456878 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C71EDC47082 for ; Tue, 8 Jun 2021 14:25:07 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F010A6135A for ; Tue, 8 Jun 2021 14:25:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F010A6135A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 7B62D1849; Tue, 8 Jun 2021 16:24:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7B62D1849 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162305; bh=uGdzMECVlQ4UJcv6HTFBWtP9rO7Qh19Bn2RLmMlJJPE=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ZtmHs5nZY6jSS4Jmy4P+lnWGR9+kfCCju8eSEyevcUuoTQZYWahEyaIx4r9AmWRWm RbFJDGx7f/hlRkYUCqWSMO68kwEy2YgCzNiWcZ1kvMARt8pDkKPjxgxALgWmhu6dyL ZgnwdG1TQ1JWitOq5sLgUR/gWUOkWXF6Hj+0QY3Y= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 06A4BF8067A; Tue, 8 Jun 2021 16:07:28 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CBE18F8061B; Tue, 8 Jun 2021 16:07:08 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id CB0B2F80508 for ; Tue, 8 Jun 2021 16:05:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CB0B2F80508 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="KjLLyrL1"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="EiSKJRRP" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 1A8EA219F1 for ; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=etsNqx9FEMj7bKbj4D8wStPv8YUo0zrtccZ0vVE/KEU=; b=KjLLyrL1RDGBDGQau3huuwgntvDxwMvvxyGwHU8veX2ly5z9benTTEvE/3587F+hEemL+O QNUGFjdpSck7pA6kECESN+sb7tcIVGm3piGlituXjAMQJllEdSRgiIpPd5/b4usCJTTZTf UDnq9+Y8ZmhUpyAIXPl8FuD+AMLYGGs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=etsNqx9FEMj7bKbj4D8wStPv8YUo0zrtccZ0vVE/KEU=; b=EiSKJRRP7Mr3YPXFBK1ojjtPlrdIsgQ6w8j4GGmXeDQ+zxLhsO9ZpvyBBkh1bUo7MK3Aig sqVZZBavosdvLoCw== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 0ABF4A3B89; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 47/66] ALSA: riptide: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:21 +0200 Message-Id: <20210608140540.17885-48-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/riptide/riptide.c | 88 ++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 35 deletions(-) diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index 56827db97239..709a1a2cde20 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -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; } From patchwork Tue Jun 8 14:05:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456885 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33568C4743E for ; Tue, 8 Jun 2021 14:19:29 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AFE026135A for ; Tue, 8 Jun 2021 14:19:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AFE026135A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 53EC717B7; Tue, 8 Jun 2021 16:18:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 53EC717B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161967; bh=XgW36zS+Ax3ucrJG4XksufFb6ieKppIP/lcHlDLjjdc=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=T7+ON3wXS156PvB7gjA27bGwwZqFubOacUlnbhIY4qmgeQYbE+rnHOsNj1OgxVVg2 2udN/pA0PZiKkcF43+l5k9cS0Ak4iuPUPVtRXQxyfivaBZGheVGk7l8nRGdOU8CwJ3 VkRHpuclTituHr30/ztIdWI7j7eWbUdPwN59ScJA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B01C4F8060B; Tue, 8 Jun 2021 16:06:58 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A2106F805F4; Tue, 8 Jun 2021 16:06:44 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 7CE64F804E2 for ; Tue, 8 Jun 2021 16:05:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7CE64F804E2 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="jOparCTQ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="AN2o5FS7" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 2B60D1FDEE for ; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QHl5uqFLjcmOTxz7KLDIAIDPk/Mw4vfRoaOcCaAPwVI=; b=jOparCTQoD53DPKR57QWX2zvX8J/Or7uUk3pUAtJk9E74p9evtD7EHnUUOx3Wg3EBuYujf ObErf1cVRFmaG8XgMRCe/Su3ldGx84gRyoMfGM2xQLgn/x9ieclcNlGk89NuaAE23/lkau oXIG9b10IA/TlaKxyPHjYXSUhYjYjiE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QHl5uqFLjcmOTxz7KLDIAIDPk/Mw4vfRoaOcCaAPwVI=; b=AN2o5FS7X/sIF8eLNnu0Dw78e/9+U3i2GRjya5J5Y1d1Lbz5ARam4ahKItf9UylQue2M2D FytjrcGiSBEbwkDA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 195BDA3B84; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 48/66] ALSA: hdsp: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:22 +0200 Message-Id: <20210608140540.17885-49-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/rme9652/hdsp.c | 121 ++++++++++++++++++++++++++------------- 1 file changed, 82 insertions(+), 39 deletions(-) diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index c79f13b1fc4e..e3e4fabf4abf 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -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, unsigne if (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 *hdsp sprintf(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; From patchwork Tue Jun 8 14:05:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455866 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A48BC47082 for ; Tue, 8 Jun 2021 14:19:08 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A855D6135A for ; Tue, 8 Jun 2021 14:19:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A855D6135A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4098116FB; Tue, 8 Jun 2021 16:18:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4098116FB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161946; bh=6+vMARa8I5ZmvSMFZNvDycbVxEZcBtBcK95df7VGdT8=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=PD1fxu5IC671aP9DMPIk9WKYdg0DZpQbHy3b0JzPtDPYK2pzo+qLcDIiFf5f0deCu L7TkfjXh8uPptimg9gfhF/ShKgGjG7+uUww8iNetJe09oD1trjiPMRCPUNh58divBc q2BtgxoF8p/j+9rlof9Si2BLESTUak15WF3NFuz0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id ADBBBF80609; Tue, 8 Jun 2021 16:06:56 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 441BCF805F5; Tue, 8 Jun 2021 16:06:44 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9324FF804E6 for ; Tue, 8 Jun 2021 16:05:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9324FF804E6 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Eb1xz2w4"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="oKbjG9oY" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 3A9DA1FDEF for ; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wCZhNctjXazKM/8z7D46HawzbJCfjTeLHoJQmJh0E6k=; b=Eb1xz2w4D9YjyG0qS8eLO1H0BZMtzHr+sZGJgKyOdOBXymp9/g8+rtes1cZ8lxiCs2NsIs k1HmGMoEVaWafZ/Tf6v5f/oEMunUITzVOsYp5EEozLM7K6rbqd8Ci2pV+7FE/BPuKXbsT9 7zLYY2yDXCOr3jWjH59mp+q4x8O0adw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wCZhNctjXazKM/8z7D46HawzbJCfjTeLHoJQmJh0E6k=; b=oKbjG9oYQGY4hlOUVXapBS5xVMzmhs8IL4LlACZR/RxTUoMISTh1HI+4F7/YMZsS+6OzWJ SknnfkxF/4rOa0CA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 29D34A3B88; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 49/66] ALSA: rme9652: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:23 +0200 Message-Id: <20210608140540.17885-50-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/rme9652/rme9652.c | 98 +++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 47 deletions(-) diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c index 7a4d395abcee..f1aad38760d6 100644 --- a/sound/pci/rme9652/rme9652.c +++ b/sound/pci/rme9652/rme9652.c @@ -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_rme9652 struct 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); From patchwork Tue Jun 8 14:05:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456884 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B001AC47082 for ; Tue, 8 Jun 2021 14:20:19 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3847261359 for ; Tue, 8 Jun 2021 14:20:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3847261359 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C672517A8; Tue, 8 Jun 2021 16:19:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C672517A8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162017; bh=xwamtDgWHLjuKg4uDh02KwOXnfzNc85P8p0/TBRDTjQ=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=CmDUHu5x33L2A2XXQgJJUJgEeHvvxgIaPKFgnDOo8lagT9A7CLXof5pDGcklhntQY qTk4LH5imoj9uSk1nuzM3b5ZRXaLNwvXwuMnUmxXUG5TjGPGorMRdn3BFw5s2yqMBz MPb8zwhv1swurSnpSSGbGSxpV7uiKj9uB8NzipEM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D98E3F80615; Tue, 8 Jun 2021 16:07:02 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4D81FF805FC; Tue, 8 Jun 2021 16:06:46 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 81597F804E7 for ; Tue, 8 Jun 2021 16:05:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 81597F804E7 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="S1d/GZQy"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="P/GOD8FF" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 4A0841FDF0 for ; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cZzBjsrMIs0UWLQXOkBF65WxJiDHr8snrQszh9BFULc=; b=S1d/GZQy1zJJmTrorJWyb/DioIlSMjDu5Jj72thOY5QWWjLiYvrJ7tnClmMamR1n3VwTP7 eY6Sv0O2zkeXCtifCpOZqYZs/jW9P9VBHwFmZMhxTIjFT383dATOQGwA1HUR005k55VJh1 9IuOts2lPQgHDUC+mNl2AYsqE8/OqTk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cZzBjsrMIs0UWLQXOkBF65WxJiDHr8snrQszh9BFULc=; b=P/GOD8FFf7L7EjZsksweVY3xBXTRTqypt5HZ0r3YKQQVVwlwc1Ll6uIxV++5utC7zBR6GB 8VqlB+c7D9VHlBDg== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 39BD7A3B84; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 50/66] ALSA: trident: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:24 +0200 Message-Id: <20210608140540.17885-51-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/trident/trident.c | 41 +++++++++------- sound/pci/trident/trident_main.c | 84 ++++++++++++++++++++++---------- 2 files changed, 81 insertions(+), 44 deletions(-) diff --git a/sound/pci/trident/trident.c b/sound/pci/trident/trident.c index a51041205f7c..60e4dca28c2b 100644 --- a/sound/pci/trident/trident.c +++ b/sound/pci/trident/trident.c @@ -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; } diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index 20145143f6a6..281ea7143b1c 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -2119,7 +2119,8 @@ int snd_trident_pcm(struct snd_trident *trident, int device) struct snd_pcm *pcm; int err; - if ((err = snd_pcm_new(trident->card, "trident_dx_nx", device, trident->ChanPCM, 1, &pcm)) < 0) + err = snd_pcm_new(trident->card, "trident_dx_nx", device, trident->ChanPCM, 1, &pcm); + if (err < 0) return err; pcm->private_data = trident; @@ -2178,7 +2179,8 @@ int snd_trident_foldback_pcm(struct snd_trident *trident, int device) if (trident->device == TRIDENT_DEVICE_ID_NX) num_chan = 4; - if ((err = snd_pcm_new(trident->card, "trident_dx_nx", device, 0, num_chan, &foldback)) < 0) + err = snd_pcm_new(trident->card, "trident_dx_nx", device, 0, num_chan, &foldback); + if (err < 0) return err; foldback->private_data = trident; @@ -2228,7 +2230,8 @@ int snd_trident_spdif_pcm(struct snd_trident *trident, int device) struct snd_pcm *spdif; int err; - if ((err = snd_pcm_new(trident->card, "trident_dx_nx IEC958", device, 1, 0, &spdif)) < 0) + err = snd_pcm_new(trident->card, "trident_dx_nx IEC958", device, 1, 0, &spdif); + if (err < 0) return err; spdif->private_data = trident; @@ -2921,7 +2924,8 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device) if (!uctl) return -ENOMEM; - if ((err = snd_ac97_bus(trident->card, 0, &ops, NULL, &trident->ac97_bus)) < 0) + err = snd_ac97_bus(trident->card, 0, &ops, NULL, &trident->ac97_bus); + if (err < 0) goto __out; memset(&_ac97, 0, sizeof(_ac97)); @@ -2929,9 +2933,11 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device) trident->ac97_detect = 1; __again: - if ((err = snd_ac97_mixer(trident->ac97_bus, &_ac97, &trident->ac97)) < 0) { + err = snd_ac97_mixer(trident->ac97_bus, &_ac97, &trident->ac97); + if (err < 0) { if (trident->device == TRIDENT_DEVICE_ID_SI7018) { - if ((err = snd_trident_sis_reset(trident)) < 0) + err = snd_trident_sis_reset(trident); + if (err < 0) goto __out; if (retries-- > 0) goto __again; @@ -2962,10 +2968,14 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device) trident->ac97_detect = 0; if (trident->device != TRIDENT_DEVICE_ID_SI7018) { - if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_trident_vol_wave_control, trident))) < 0) + kctl = snd_ctl_new1(&snd_trident_vol_wave_control, trident); + err = snd_ctl_add(card, kctl); + if (err < 0) goto __out; kctl->put(kctl, uctl); - if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_trident_vol_music_control, trident))) < 0) + kctl = snd_ctl_new1(&snd_trident_vol_music_control, trident); + err = snd_ctl_add(card, kctl); + if (err < 0) goto __out; kctl->put(kctl, uctl); outl(trident->musicvol_wavevol = 0x00000000, TRID_REG(trident, T4D_MUSICVOL_WAVEVOL)); @@ -2979,28 +2989,38 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device) tmix = &trident->pcm_mixer[idx]; tmix->voice = NULL; } - if ((trident->ctl_vol = snd_ctl_new1(&snd_trident_pcm_vol_control, trident)) == NULL) + trident->ctl_vol = snd_ctl_new1(&snd_trident_pcm_vol_control, trident); + if (!trident->ctl_vol) goto __nomem; - if ((err = snd_ctl_add(card, trident->ctl_vol))) + err = snd_ctl_add(card, trident->ctl_vol); + if (err) goto __out; - if ((trident->ctl_pan = snd_ctl_new1(&snd_trident_pcm_pan_control, trident)) == NULL) + trident->ctl_pan = snd_ctl_new1(&snd_trident_pcm_pan_control, trident); + if (!trident->ctl_pan) goto __nomem; - if ((err = snd_ctl_add(card, trident->ctl_pan))) + err = snd_ctl_add(card, trident->ctl_pan); + if (err) goto __out; - if ((trident->ctl_rvol = snd_ctl_new1(&snd_trident_pcm_rvol_control, trident)) == NULL) + trident->ctl_rvol = snd_ctl_new1(&snd_trident_pcm_rvol_control, trident); + if (!trident->ctl_rvol) goto __nomem; - if ((err = snd_ctl_add(card, trident->ctl_rvol))) + err = snd_ctl_add(card, trident->ctl_rvol); + if (err) goto __out; - if ((trident->ctl_cvol = snd_ctl_new1(&snd_trident_pcm_cvol_control, trident)) == NULL) + trident->ctl_cvol = snd_ctl_new1(&snd_trident_pcm_cvol_control, trident); + if (!trident->ctl_cvol) goto __nomem; - if ((err = snd_ctl_add(card, trident->ctl_cvol))) + err = snd_ctl_add(card, trident->ctl_cvol); + if (err) goto __out; if (trident->device == TRIDENT_DEVICE_ID_NX) { - if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_trident_ac97_rear_control, trident))) < 0) + kctl = snd_ctl_new1(&snd_trident_ac97_rear_control, trident); + err = snd_ctl_add(card, kctl); + if (err < 0) goto __out; kctl->put(kctl, uctl); } @@ -3016,7 +3036,8 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device) if (trident->ac97_sec && (trident->ac97_sec->ext_id & AC97_EI_SPDIF)) kctl->id.index++; idx = kctl->id.index; - if ((err = snd_ctl_add(card, kctl)) < 0) + err = snd_ctl_add(card, kctl); + if (err < 0) goto __out; kctl->put(kctl, uctl); @@ -3027,7 +3048,8 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device) } kctl->id.index = idx; kctl->id.device = pcm_spdif_device; - if ((err = snd_ctl_add(card, kctl)) < 0) + err = snd_ctl_add(card, kctl); + if (err < 0) goto __out; kctl = snd_ctl_new1(&snd_trident_spdif_mask, trident); @@ -3037,7 +3059,8 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device) } kctl->id.index = idx; kctl->id.device = pcm_spdif_device; - if ((err = snd_ctl_add(card, kctl)) < 0) + err = snd_ctl_add(card, kctl); + if (err < 0) goto __out; kctl = snd_ctl_new1(&snd_trident_spdif_stream, trident); @@ -3047,7 +3070,8 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device) } kctl->id.index = idx; kctl->id.device = pcm_spdif_device; - if ((err = snd_ctl_add(card, kctl)) < 0) + err = snd_ctl_add(card, kctl); + if (err < 0) goto __out; trident->spdif_pcm_ctl = kctl; } @@ -3449,7 +3473,8 @@ static int snd_trident_sis_init(struct snd_trident *trident) { int err; - if ((err = snd_trident_sis_reset(trident)) < 0) + err = snd_trident_sis_reset(trident); + if (err < 0) return err; snd_trident_stop_all_voices(trident); @@ -3494,7 +3519,8 @@ int snd_trident_create(struct snd_card *card, *rtrident = 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 30 bits */ if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(30))) { @@ -3528,7 +3554,8 @@ int snd_trident_create(struct snd_card *card, trident->midi_port = TRID_REG(trident, T4D_MPU401_BASE); pci_set_master(pci); - if ((err = pci_request_regions(pci, "Trident Audio")) < 0) { + err = pci_request_regions(pci, "Trident Audio"); + if (err < 0) { kfree(trident); pci_disable_device(pci); return err; @@ -3548,7 +3575,8 @@ int snd_trident_create(struct snd_card *card, trident->tlb.entries = NULL; trident->tlb.buffer.area = NULL; if (trident->device == TRIDENT_DEVICE_ID_NX) { - if ((err = snd_trident_tlb_alloc(trident)) < 0) { + err = snd_trident_tlb_alloc(trident); + if (err < 0) { snd_trident_free(trident); return err; } @@ -3576,12 +3604,14 @@ int snd_trident_create(struct snd_card *card, return err; } - if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, trident, &ops)) < 0) { + err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, trident, &ops); + if (err < 0) { snd_trident_free(trident); return err; } - if ((err = snd_trident_mixer(trident, pcm_spdif_device)) < 0) + err = snd_trident_mixer(trident, pcm_spdif_device); + if (err < 0) return err; /* initialise synth voices */ From patchwork Tue Jun 8 14:05:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455864 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D20DAC47082 for ; Tue, 8 Jun 2021 14:20:40 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5B20761359 for ; Tue, 8 Jun 2021 14:20:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B20761359 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0662A17B9; Tue, 8 Jun 2021 16:19:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0662A17B9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162039; bh=IlDcF1JFtA2EI5rj+5I+0ibl4kvo8BNc8D8F5ecpuhg=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Q/6a5ustg88Ow1bt3Cbkhtwszri3enGeJOCqy2izvlSITcmYZ9yRlY91gNgPeLMjy R3dYx/R/gLIBeGYRKlCHcQ5me7fL2CU6vy+TMYW9BuzSlu1urPJitY6QwapvMF0MR2 pe1dLDYO67Bw4NtG634uQQuP2AKADQqBIDKFzPiA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5C7C7F8019B; Tue, 8 Jun 2021 16:07:04 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D9CD9F80600; Tue, 8 Jun 2021 16:06:48 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 993ACF804ED for ; Tue, 8 Jun 2021 16:05:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 993ACF804ED Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="LK5u5R0H"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="/sJTZ5Xl" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 4C7CB1FDF1 for ; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jZH4J/GOkOavmZBc/g45R3fXl8GfJRPQb9vutixjtlk=; b=LK5u5R0Hkjbo52f5E96q37rhAJ3zpSKzb8kFOqQkmHj0iCyzAobELloOWOIVCJaizWB76z epBoVh66KaGQ9CZRdQHIk6NNXGjE6Jnp9Men+xcdhWDBaIYEtidpfRAqmM4oenN5xNJdNm 4xfcTX6qZpi9qWCyYQSn7HSr8TYKiuA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jZH4J/GOkOavmZBc/g45R3fXl8GfJRPQb9vutixjtlk=; b=/sJTZ5XlDkjrQiBS7V53LSSqZeqnbbdted82cd7876RUfeMSr3+LXX6bxDBJjg5IOXO54v W9MiinRW0oxLdNAA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 48B61A3B88; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 51/66] ALSA: vx222: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:25 +0200 Message-Id: <20210608140540.17885-52-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/vx222/vx222.c | 18 ++++++++++++------ sound/pci/vx222/vx222_ops.c | 12 ++++++++---- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c index 2a9e1a77a81a..04c7204cb7bc 100644 --- a/sound/pci/vx222/vx222.c +++ b/sound/pci/vx222/vx222.c @@ -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; } diff --git a/sound/pci/vx222/vx222_ops.c b/sound/pci/vx222/vx222_ops.c index a05537202738..3e7e928b24f8 100644 --- a/sound/pci/vx222/vx222_ops.c +++ b/sound/pci/vx222/vx222_ops.c @@ -408,9 +408,11 @@ static int vx2_load_dsp(struct vx_core *vx, int index, const struct firmware *ds switch (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; From patchwork Tue Jun 8 14:05:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455865 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC2F7C47082 for ; Tue, 8 Jun 2021 14:20:00 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 372396135A for ; Tue, 8 Jun 2021 14:20:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 372396135A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id CD12D17BE; Tue, 8 Jun 2021 16:19:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CD12D17BE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623161998; bh=9UzVO1vCL8ORb5CcpoclaNXga5bEiNLNJiMvQKtUftQ=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=k46S+VNaTfxHIZgVN5T6ZevcWSjdoLpbV13fdg/6d3ViagsvGle0AnJREHS4wmpOH AFdA12EjnYauqrpaX7jHmPcU0oHu72UgebEPLjstR2bb6zAo9aTXeUqUvx694dhPG5 2/N/zdUReykbO12p3wl8MuRxIn2IRQSUUzlQ3yMc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C1008F80612; Tue, 8 Jun 2021 16:07:01 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 672D3F805FB; Tue, 8 Jun 2021 16:06:46 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 95F42F804EC for ; Tue, 8 Jun 2021 16:05:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 95F42F804EC Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="G6zBC7WZ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="IiXUlO41" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 5D37C1FDF2 for ; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dVeAYC4msHXHu7jnZ5Xbz2SdoFI8P0bJA+h/WhOHUCM=; b=G6zBC7WZmmZewJKzeva11CKCGQTSxwYkrY2hQtoiRhSrrZzxY5ZmXpp80FHWD664exGq1B GnJt3BsmC4BCE0Ygsb6Y/1atpPMrcmTFdnnZD5LGoT8i9RhC7ZKJQ8CHV6yrpS4CAFYwcR lEkCEzrHoWuW8zcqFFZFoCv90Yo73vc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dVeAYC4msHXHu7jnZ5Xbz2SdoFI8P0bJA+h/WhOHUCM=; b=IiXUlO417PsD18u+lp1rHWw8XtR7xAk1Iu2Z0LGp2+ZOZ2Ri2m6d3IuEXJvFSHOBjbDM9/ 9VIgCwyDR6s6l9Aw== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 4C905A3B89; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 52/66] ALSA: ymfpci: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:26 +0200 Message-Id: <20210608140540.17885-53-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCI 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. Signed-off-by: Takashi Iwai --- sound/pci/ymfpci/ymfpci.c | 71 +++++++++++++++++++-------------- sound/pci/ymfpci/ymfpci_main.c | 72 +++++++++++++++++++++++----------- 2 files changed, 91 insertions(+), 52 deletions(-) diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c index 99be1490ef0e..7e32d57147ff 100644 --- a/sound/pci/ymfpci/ymfpci.c +++ b/sound/pci/ymfpci/ymfpci.c @@ -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; + } } } diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index cacc6a9d14c8..8fd060769882 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -292,7 +292,8 @@ static void snd_ymfpci_pcm_interrupt(struct snd_ymfpci *chip, struct snd_ymfpci_ struct snd_ymfpci_pcm *ypcm; u32 pos, delta; - if ((ypcm = voice->ypcm) == NULL) + ypcm = voice->ypcm; + if (!ypcm) return; if (ypcm->substream == NULL) return; @@ -628,7 +629,8 @@ static int snd_ymfpci_playback_hw_params(struct snd_pcm_substream *substream, struct snd_ymfpci_pcm *ypcm = runtime->private_data; int err; - if ((err = snd_ymfpci_pcm_voice_alloc(ypcm, params_channels(hw_params))) < 0) + err = snd_ymfpci_pcm_voice_alloc(ypcm, params_channels(hw_params)); + if (err < 0) return err; return 0; } @@ -932,7 +934,8 @@ static int snd_ymfpci_playback_open(struct snd_pcm_substream *substream) struct snd_ymfpci_pcm *ypcm; int err; - if ((err = snd_ymfpci_playback_open_1(substream)) < 0) + err = snd_ymfpci_playback_open_1(substream); + if (err < 0) return err; ypcm = runtime->private_data; ypcm->output_front = 1; @@ -954,7 +957,8 @@ static int snd_ymfpci_playback_spdif_open(struct snd_pcm_substream *substream) struct snd_ymfpci_pcm *ypcm; int err; - if ((err = snd_ymfpci_playback_open_1(substream)) < 0) + err = snd_ymfpci_playback_open_1(substream); + if (err < 0) return err; ypcm = runtime->private_data; ypcm->output_front = 0; @@ -982,7 +986,8 @@ static int snd_ymfpci_playback_4ch_open(struct snd_pcm_substream *substream) struct snd_ymfpci_pcm *ypcm; int err; - if ((err = snd_ymfpci_playback_open_1(substream)) < 0) + err = snd_ymfpci_playback_open_1(substream); + if (err < 0) return err; ypcm = runtime->private_data; ypcm->output_front = 0; @@ -1124,7 +1129,8 @@ int snd_ymfpci_pcm(struct snd_ymfpci *chip, int device) struct snd_pcm *pcm; int err; - if ((err = snd_pcm_new(chip->card, "YMFPCI", device, 32, 1, &pcm)) < 0) + err = snd_pcm_new(chip->card, "YMFPCI", device, 32, 1, &pcm); + if (err < 0) return err; pcm->private_data = chip; @@ -1157,7 +1163,8 @@ int snd_ymfpci_pcm2(struct snd_ymfpci *chip, int device) struct snd_pcm *pcm; int err; - if ((err = snd_pcm_new(chip->card, "YMFPCI - PCM2", device, 0, 1, &pcm)) < 0) + err = snd_pcm_new(chip->card, "YMFPCI - PCM2", device, 0, 1, &pcm); + if (err < 0) return err; pcm->private_data = chip; @@ -1190,7 +1197,8 @@ int snd_ymfpci_pcm_spdif(struct snd_ymfpci *chip, int device) struct snd_pcm *pcm; int err; - if ((err = snd_pcm_new(chip->card, "YMFPCI - IEC958", device, 1, 0, &pcm)) < 0) + err = snd_pcm_new(chip->card, "YMFPCI - IEC958", device, 1, 0, &pcm); + if (err < 0) return err; pcm->private_data = chip; @@ -1230,7 +1238,8 @@ int snd_ymfpci_pcm_4ch(struct snd_ymfpci *chip, int device) struct snd_pcm *pcm; int err; - if ((err = snd_pcm_new(chip->card, "YMFPCI - Rear", device, 1, 0, &pcm)) < 0) + err = snd_pcm_new(chip->card, "YMFPCI - Rear", device, 1, 0, &pcm); + if (err < 0) return err; pcm->private_data = chip; @@ -1785,7 +1794,8 @@ int snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch) .read = snd_ymfpci_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_ymfpci_mixer_free_ac97_bus; chip->ac97_bus->no_vra = 1; /* YMFPCI doesn't need VRA */ @@ -1793,7 +1803,8 @@ int snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch) memset(&ac97, 0, sizeof(ac97)); ac97.private_data = chip; ac97.private_free = snd_ymfpci_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; /* to be sure */ @@ -1801,7 +1812,8 @@ int snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch) AC97_EA_VRA|AC97_EA_VRM, 0); for (idx = 0; idx < ARRAY_SIZE(snd_ymfpci_controls); idx++) { - if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_ymfpci_controls[idx], chip))) < 0) + err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_ymfpci_controls[idx], chip)); + if (err < 0) return err; } if (chip->ac97->ext_id & AC97_EI_SDAC) { @@ -1814,27 +1826,37 @@ int snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch) /* add S/PDIF control */ if (snd_BUG_ON(!chip->pcm_spdif)) return -ENXIO; - if ((err = snd_ctl_add(chip->card, kctl = snd_ctl_new1(&snd_ymfpci_spdif_default, chip))) < 0) + kctl = snd_ctl_new1(&snd_ymfpci_spdif_default, chip); + err = snd_ctl_add(chip->card, kctl); + if (err < 0) return err; kctl->id.device = chip->pcm_spdif->device; - if ((err = snd_ctl_add(chip->card, kctl = snd_ctl_new1(&snd_ymfpci_spdif_mask, chip))) < 0) + kctl = snd_ctl_new1(&snd_ymfpci_spdif_mask, chip); + err = snd_ctl_add(chip->card, kctl); + if (err < 0) return err; kctl->id.device = chip->pcm_spdif->device; - if ((err = snd_ctl_add(chip->card, kctl = snd_ctl_new1(&snd_ymfpci_spdif_stream, chip))) < 0) + kctl = snd_ctl_new1(&snd_ymfpci_spdif_stream, chip); + err = snd_ctl_add(chip->card, kctl); + if (err < 0) return err; kctl->id.device = chip->pcm_spdif->device; chip->spdif_pcm_ctl = kctl; /* direct recording source */ - if (chip->device_id == PCI_DEVICE_ID_YAMAHA_754 && - (err = snd_ctl_add(chip->card, kctl = snd_ctl_new1(&snd_ymfpci_drec_source, chip))) < 0) - return err; + if (chip->device_id == PCI_DEVICE_ID_YAMAHA_754) { + kctl = snd_ctl_new1(&snd_ymfpci_drec_source, chip); + err = snd_ctl_add(chip->card, kctl); + if (err < 0) + return err; + } /* * shared rear/line-in */ if (rear_switch) { - if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_ymfpci_rear_shared, chip))) < 0) + err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_ymfpci_rear_shared, chip)); + if (err < 0) return err; } @@ -1847,7 +1869,8 @@ int snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch) kctl->id.device = chip->pcm->device; kctl->id.subdevice = idx; kctl->private_value = (unsigned long)substream; - if ((err = snd_ctl_add(chip->card, kctl)) < 0) + err = snd_ctl_add(chip->card, kctl); + if (err < 0) return err; chip->pcm_mixer[idx].left = 0x8000; chip->pcm_mixer[idx].right = 0x8000; @@ -1928,7 +1951,8 @@ int snd_ymfpci_timer(struct snd_ymfpci *chip, int device) tid.card = chip->card->number; tid.device = device; tid.subdevice = 0; - if ((err = snd_timer_new(chip->card, "YMFPCI", &tid, &timer)) >= 0) { + err = snd_timer_new(chip->card, "YMFPCI", &tid, &timer); + if (err >= 0) { strcpy(timer->name, "YMFPCI timer"); timer->private_data = chip; timer->hw = snd_ymfpci_timer_hw; @@ -2334,7 +2358,8 @@ int snd_ymfpci_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; chip = kzalloc(sizeof(*chip), GFP_KERNEL); @@ -2357,7 +2382,8 @@ int snd_ymfpci_create(struct snd_card *card, pci_set_master(pci); chip->src441_used = -1; - if ((chip->res_reg_area = request_mem_region(chip->reg_area_phys, 0x8000, "YMFPCI")) == NULL) { + chip->res_reg_area = request_mem_region(chip->reg_area_phys, 0x8000, "YMFPCI"); + if (!chip->res_reg_area) { dev_err(chip->card->dev, "unable to grab memory region 0x%lx-0x%lx\n", chip->reg_area_phys, chip->reg_area_phys + 0x8000 - 1); From patchwork Tue Jun 8 14:05:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DFEFC47082 for ; Tue, 8 Jun 2021 14:26:08 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AE5946135A for ; Tue, 8 Jun 2021 14:26:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE5946135A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4B25D1878; Tue, 8 Jun 2021 16:25:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4B25D1878 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162366; bh=TrymA9aTa5VtU2ZPa1othmTktLRP7nVSp2vdJXAPiVU=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=QRK8tQLldx3Mh2MZW4NclKFaBalH/DPmdVssLcuQYujXgwqldSgCKiG9UHiU2sKPU EaEy6wQjXqRZ8VSYw8dS2Ozu35G5qczDTva0qdHIskQeEhVF/QFuo2Sgc/eMstNz7F bblkZDeiN9Omo8q4Fh2Oxe8ZLn8wweHXofP2Rh2I= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 74933F80685; Tue, 8 Jun 2021 16:07:31 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 73B19F8061D; Tue, 8 Jun 2021 16:07:11 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id CCC25F8050F for ; Tue, 8 Jun 2021 16:05:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CCC25F8050F Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Hh0tAhfA"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="7Ly3tKeW" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 6CC05219F5 for ; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=40jNcmkFdBARhuXoBSJlvuDNhXJc00YvU0hr0bAMNCE=; b=Hh0tAhfA8jQaSbT/2NOaHCFD/JZ6Pc9VsZnGZ0jH7etIL1VWNoJVpIFr/rlDFs2u/nkVPJ 6MBPFqKuYt0+rUC4O4ebKhCcWgEBWjnN5dNQC9K38X19Jyp1+aDKh35eBrjKCRtZP/Amlg BYb8r0t8DUq8AknyJ0KwAObyGvrGf8M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=40jNcmkFdBARhuXoBSJlvuDNhXJc00YvU0hr0bAMNCE=; b=7Ly3tKeWKoUMiaLeM2njC0AXIaW1H24FyVEm3dbrihWTu2XEDk8UA8EAHZPM8m6XZPFVaI dlzxm03sQPKfXRBQ== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 5C47AA3B84; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 53/66] ALSA: core: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:27 +0200 Message-Id: <20210608140540.17885-54-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" There 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. Signed-off-by: Takashi Iwai --- 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(-) diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index 264b8ea64bc2..e95fa275c289 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -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); diff --git a/sound/core/info_oss.c b/sound/core/info_oss.c index 83900485dd8c..1ba887c7954e 100644 --- a/sound/core/info_oss.c +++ b/sound/core/info_oss.c @@ -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; } diff --git a/sound/core/init.c b/sound/core/init.c index 228faf9369dc..1490568efdb0 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -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); diff --git a/sound/core/sound.c b/sound/core/sound.c index af89e51dd44a..df5571d98629 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -357,7 +357,8 @@ static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_bu mutex_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) diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c index 610f317bea9d..7ed0a2a91035 100644 --- a/sound/core/sound_oss.c +++ b/sound/core/sound_oss.c @@ -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, From patchwork Tue Jun 8 14:05:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456876 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E5BCC47082 for ; Tue, 8 Jun 2021 14:26:37 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1DD5560FDB for ; Tue, 8 Jun 2021 14:26:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1DD5560FDB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id AD1041792; Tue, 8 Jun 2021 16:25:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AD1041792 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162395; bh=ojS34bKRzAWVyChP0ghZiGrVqY85MAfPLQF6hHu3mn4=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=e/zfUQ97UwXRRwc36ttTYg6pddMcOY5UfOuwO1Fm6MVA9Zpqee074LnAT7A7Rwh6H s/9ChwCBTfD2q1z3Cxd+zJNNAdN59GkLrH5aAzlMh9Da+sbvurMd8TWVeT13Pdf6wG FnqJDgTDc/GR/T1ifGPqCekhobNrPS+gsaG6gwXU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 73CCAF8068A; Tue, 8 Jun 2021 16:07:34 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 51A75F8061F; Tue, 8 Jun 2021 16:07:12 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D7A6EF80506 for ; Tue, 8 Jun 2021 16:05:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D7A6EF80506 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Og9iVR+j"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="v5NpJP63" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 720F0219F7 for ; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ngBZWaAxRQ6VxkkqhATNt41+hkFq28+9VORY7vSqh98=; b=Og9iVR+j9LMZUi20saPKniFTkkBS3MrN6asN3TyMdXjXIk5KIEEPHwyG60R14L9xdL5GuR rCZm7KsapxeK/lcSZfBBaay6Cxy6CmjiBj3GsB6sBeshGk/CKJjxwGKYBr6PKJD5aX8Wg1 TFKTBWpNySDbdejg7N8qf11xr1udmXw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ngBZWaAxRQ6VxkkqhATNt41+hkFq28+9VORY7vSqh98=; b=v5NpJP63gJVg+ORzN8Nq65OrV85dDvTTi1NAUmibNkZ8gnGgaEg0KL33987C6Yatlr7Te4 0/gyVgOmoU+88HBQ== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 6B1C7A3B88; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 54/66] ALSA: pcm: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:28 +0200 Message-Id: <20210608140540.17885-55-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" There 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. Signed-off-by: Takashi Iwai --- 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(-) diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c index 590a46a9e78d..a59de24695ec 100644 --- a/sound/core/pcm_compat.c +++ b/sound/core/pcm_compat.c @@ -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)) diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c index 257d412eac5d..4866aed97aac 100644 --- a/sound/core/pcm_misc.c +++ b/sound/core/pcm_misc.c @@ -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; } diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 11acea02bc74..eb468573f070 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -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; From patchwork Tue Jun 8 14:05:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455862 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1F3AC47082 for ; Tue, 8 Jun 2021 14:22:10 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 700A26135D for ; Tue, 8 Jun 2021 14:22:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 700A26135D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0FDD917D8; Tue, 8 Jun 2021 16:21:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0FDD917D8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162129; bh=Eu0i+Wj/Gv0fA6bdIEi4sZ7/XBKt9z/MBDgbHbpznwc=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=mNRGOkKjSE2mVya4mwIjyFYaEu1oeMRIzlpZ1u88ujpco49YRTjbaeUa1LmwI3EFH g8TQgnH6zj2XI/53vSQxVpPykpwmiaCs0A/sq9wuKeGr8oaIYd/FlJrFdTzqc7sNVQ 2aL2sc2Y6XLiCWr8j7/V3Lv+pIz7K/Jap1AoR4rw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D5461F8062D; Tue, 8 Jun 2021 16:07:15 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9FD19F80605; Tue, 8 Jun 2021 16:06:54 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A3D7FF804F1 for ; Tue, 8 Jun 2021 16:05:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A3D7FF804F1 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="w8cJQpZx"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="rjpa9xpn" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 80EB31FDF3 for ; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U9PPHyh9Pnmb9u/bloTfG6MdAafchoG+mTIVdFtEqhA=; b=w8cJQpZxkCLnyG3mvzqrtxYCxZ8eZuwj7X+cNlL5V+39frUAQ1IEo74Y++o4vJLvozSgVQ UpU0K2i07HeWTddrAOUYaMs6LqObxb6m09Dn3FwNW+jRstLm4OVpYbcg3QcUHnL1X0OM9o XgG7IvldDA5yvgQpwftpHQIMViflpwg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U9PPHyh9Pnmb9u/bloTfG6MdAafchoG+mTIVdFtEqhA=; b=rjpa9xpnFrLdbJU8X87mPChrLF8gKwtq4G8GJORltbw+2ZjKcP+1OJHHso2uOdYW9p5iVO Rwn8K3fN1UW+zADA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 6F71AA3B89; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 55/66] ALSA: oss: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:29 +0200 Message-Id: <20210608140540.17885-56-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" There 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. Signed-off-by: Takashi Iwai --- 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(-) diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index bec928327478..6a5abdd4271b 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c @@ -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 *sl up_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); diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index 86c39ee01aaa..82a818734a5f 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -955,9 +955,8 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream) if (!direct) { /* add necessary plugins */ snd_pcm_oss_plugin_clear(substream); - if ((err = snd_pcm_plug_format_plugins(substream, - params, - sparams)) < 0) { + err = snd_pcm_plug_format_plugins(substream, params, sparams); + if (err < 0) { pcm_dbg(substream->pcm, "snd_pcm_plug_format_plugins failed: %i\n", err); snd_pcm_oss_plugin_clear(substream); @@ -965,7 +964,8 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream) } if (runtime->oss.plugin_first) { struct snd_pcm_plugin *plugin; - if ((err = snd_pcm_plugin_build_io(substream, sparams, &plugin)) < 0) { + err = snd_pcm_plugin_build_io(substream, sparams, &plugin); + if (err < 0) { pcm_dbg(substream->pcm, "snd_pcm_plugin_build_io failed: %i\n", err); snd_pcm_oss_plugin_clear(substream); @@ -1011,7 +1011,8 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream) sw_params->silence_size = frames; } - if ((err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_SW_PARAMS, sw_params)) < 0) { + err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_SW_PARAMS, sw_params); + if (err < 0) { pcm_dbg(substream->pcm, "SW_PARAMS failed: %i\n", err); goto failure; } @@ -1573,7 +1574,8 @@ static int snd_pcm_oss_post(struct snd_pcm_oss_file *pcm_oss_file) substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; if (substream != NULL) { - if ((err = snd_pcm_oss_make_ready(substream)) < 0) + err = snd_pcm_oss_make_ready(substream); + if (err < 0) return err; snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_START, NULL); } @@ -1645,7 +1647,8 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file) runtime = substream->runtime; if (atomic_read(&substream->mmap_count)) goto __direct; - if ((err = snd_pcm_oss_make_ready(substream)) < 0) + err = snd_pcm_oss_make_ready(substream); + if (err < 0) return err; atomic_inc(&runtime->oss.rw_ref); if (mutex_lock_interruptible(&runtime->oss.params_lock)) { @@ -1711,7 +1714,8 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file) substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE]; if (substream != NULL) { - if ((err = snd_pcm_oss_make_ready(substream)) < 0) + err = snd_pcm_oss_make_ready(substream); + if (err < 0) return err; runtime = substream->runtime; err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); @@ -1758,7 +1762,8 @@ static int snd_pcm_oss_get_rate(struct snd_pcm_oss_file *pcm_oss_file) struct snd_pcm_substream *substream; int err; - if ((err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream)) < 0) + err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream); + if (err < 0) return err; return substream->runtime->oss.rate; } @@ -1795,7 +1800,8 @@ static int snd_pcm_oss_get_channels(struct snd_pcm_oss_file *pcm_oss_file) struct snd_pcm_substream *substream; int err; - if ((err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream)) < 0) + err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream); + if (err < 0) return err; return substream->runtime->oss.channels; } @@ -1805,7 +1811,8 @@ static int snd_pcm_oss_get_block_size(struct snd_pcm_oss_file *pcm_oss_file) struct snd_pcm_substream *substream; int err; - if ((err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream)) < 0) + err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream); + if (err < 0) return err; return substream->runtime->oss.period_bytes; } @@ -1820,7 +1827,8 @@ static int snd_pcm_oss_get_formats(struct snd_pcm_oss_file *pcm_oss_file) const struct snd_mask *format_mask; int fmt; - if ((err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream)) < 0) + err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream); + if (err < 0) return err; if (atomic_read(&substream->mmap_count)) direct = 1; @@ -1890,7 +1898,8 @@ static int snd_pcm_oss_get_format(struct snd_pcm_oss_file *pcm_oss_file) struct snd_pcm_substream *substream; int err; - if ((err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream)) < 0) + err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream); + if (err < 0) return err; return substream->runtime->oss.format; } @@ -2050,11 +2059,13 @@ static int snd_pcm_oss_set_trigger(struct snd_pcm_oss_file *pcm_oss_file, int tr csubstream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE]; if (psubstream) { - if ((err = snd_pcm_oss_make_ready(psubstream)) < 0) + err = snd_pcm_oss_make_ready(psubstream); + if (err < 0) return err; } if (csubstream) { - if ((err = snd_pcm_oss_make_ready(csubstream)) < 0) + err = snd_pcm_oss_make_ready(csubstream); + if (err < 0) return err; } if (psubstream) { @@ -2141,7 +2152,8 @@ static int snd_pcm_oss_get_odelay(struct snd_pcm_oss_file *pcm_oss_file) substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; if (substream == NULL) return -EINVAL; - if ((err = snd_pcm_oss_make_ready(substream)) < 0) + err = snd_pcm_oss_make_ready(substream); + if (err < 0) return err; runtime = substream->runtime; if (runtime->oss.params || runtime->oss.prepare) @@ -2168,7 +2180,8 @@ static int snd_pcm_oss_get_ptr(struct snd_pcm_oss_file *pcm_oss_file, int stream substream = pcm_oss_file->streams[stream]; if (substream == NULL) return -EINVAL; - if ((err = snd_pcm_oss_make_ready(substream)) < 0) + err = snd_pcm_oss_make_ready(substream); + if (err < 0) return err; runtime = substream->runtime; if (runtime->oss.params || runtime->oss.prepare) { @@ -2239,9 +2252,11 @@ static int snd_pcm_oss_get_space(struct snd_pcm_oss_file *pcm_oss_file, int stre return -EINVAL; runtime = substream->runtime; - if (runtime->oss.params && - (err = snd_pcm_oss_change_params(substream, false)) < 0) - return err; + if (runtime->oss.params) { + err = snd_pcm_oss_change_params(substream, false); + if (err < 0) + return err; + } info.fragsize = runtime->oss.period_bytes; info.fragstotal = runtime->periods; @@ -2601,7 +2616,8 @@ static long snd_pcm_oss_ioctl(struct file *file, unsigned int cmd, unsigned long case SNDCTL_DSP_SPEED: if (get_user(res, p)) return -EFAULT; - if ((res = snd_pcm_oss_set_rate(pcm_oss_file, res))<0) + res = snd_pcm_oss_set_rate(pcm_oss_file, res); + if (res < 0) return res; return put_user(res, p); case SOUND_PCM_READ_RATE: @@ -2613,7 +2629,8 @@ static long snd_pcm_oss_ioctl(struct file *file, unsigned int cmd, unsigned long if (get_user(res, p)) return -EFAULT; res = res > 0 ? 2 : 1; - if ((res = snd_pcm_oss_set_channels(pcm_oss_file, res)) < 0) + res = snd_pcm_oss_set_channels(pcm_oss_file, res); + if (res < 0) return res; return put_user(--res, p); case SNDCTL_DSP_GETBLKSIZE: @@ -2829,7 +2846,8 @@ static __poll_t snd_pcm_oss_poll(struct file *file, poll_table * wait) snd_pcm_state_t ostate; poll_wait(file, &runtime->sleep, wait); snd_pcm_stream_lock_irq(csubstream); - if ((ostate = runtime->status->state) != SNDRV_PCM_STATE_RUNNING || + ostate = runtime->status->state; + if (ostate != SNDRV_PCM_STATE_RUNNING || snd_pcm_oss_capture_ready(csubstream)) mask |= EPOLLIN | EPOLLRDNORM; snd_pcm_stream_unlock_irq(csubstream); @@ -3043,7 +3061,8 @@ static void snd_pcm_oss_proc_init(struct snd_pcm *pcm) struct snd_pcm_str *pstr = &pcm->streams[stream]; if (pstr->substream_count == 0) continue; - if ((entry = snd_info_create_card_entry(pcm->card, "oss", pstr->proc_root)) != NULL) { + entry = snd_info_create_card_entry(pcm->card, "oss", pstr->proc_root); + if (entry) { entry->content = SNDRV_INFO_CONTENT_TEXT; entry->mode = S_IFREG | 0644; entry->c.text.read = snd_pcm_oss_proc_read; @@ -3191,7 +3210,8 @@ static int __init alsa_pcm_oss_init(void) adsp_map[i] = 1; } } - if ((err = snd_pcm_notify(&snd_pcm_oss_notify, 0)) < 0) + err = snd_pcm_notify(&snd_pcm_oss_notify, 0); + if (err < 0) return err; return 0; } diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c index d5ca161d588c..061ba06bc926 100644 --- a/sound/core/oss/pcm_plugin.c +++ b/sound/core/oss/pcm_plugin.c @@ -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, st while (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; From patchwork Tue Jun 8 14:05:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456882 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAAEFC47082 for ; Tue, 8 Jun 2021 14:21:51 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5C08A610A1 for ; Tue, 8 Jun 2021 14:21:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C08A610A1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0707A17BF; Tue, 8 Jun 2021 16:21:00 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0707A17BF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162110; bh=r7pmUJ1Y0FnLmyTwMgS0bZMUxFWehPuJ68xBGwm8ZAw=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=DxLCwwOWPVQKdLDNpyjKwQ9Za2xXdwcJUOEFUo7CRJeGGBd65WIOc2EWaS7/yqQUD OgbC42UJoEEX3UzRi3HEZWUJWgkXOR1pwGnqsKd2tTWVyQuaGhG83EtWSh6+D5c+tr YsGlbVn8CqBfH/FQNWPL6vuBv7ma2R6SiAsNXT0Q= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id BF4DFF80621; Tue, 8 Jun 2021 16:07:14 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 17DA6F80604; Tue, 8 Jun 2021 16:06:54 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B3133F804EB for ; Tue, 8 Jun 2021 16:05:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B3133F804EB Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="pI6M5dTz"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="ngZ8KvxX" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 934501FDF4 for ; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a/xD5M9bVFxCi8b9w8koC91B3JsZYyeLE4W/1z6lYz4=; b=pI6M5dTzvKu+Fqn6jBpTzozcBm/FTsF8iQutUk/VrNl0Vk9epbo0dWfxSEF93zv9LRJc3U +sU3lWMdpHQxlsbhE+HobS6IO5JJ0g9lnxAO8wUyDKajt6SSu612zouCBBv1jE/X3gVyir XLt9UwHjyNpFzviJWLZauyVugh4ZPY8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a/xD5M9bVFxCi8b9w8koC91B3JsZYyeLE4W/1z6lYz4=; b=ngZ8KvxXLPjTTd+C6Tb0aVeP40EINYvbktYytLICLP2r5vBtjHKT86njkfoshpqvdBQmEb FEi3/gM80OldfbDA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 80501A3B84; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 56/66] ALSA: seq: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:30 +0200 Message-Id: <20210608140540.17885-57-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" There 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. Signed-off-by: Takashi Iwai --- 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(-) diff --git a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c index 250a92b18726..77c1214acd90 100644 --- a/sound/core/seq/oss/seq_oss.c +++ b/sound/core/seq/oss/seq_oss.c @@ -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); diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c index 4534a154b8c8..a53d81a86af2 100644 --- a/sound/core/seq/oss/seq_oss_init.c +++ b/sound/core/seq/oss/seq_oss_init.c @@ -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; } diff --git a/sound/core/seq/oss/seq_oss_midi.c b/sound/core/seq/oss/seq_oss_midi.c index 3f82c196de46..1e3bf086f867 100644 --- a/sound/core/seq/oss/seq_oss_midi.c +++ b/sound/core/seq/oss/seq_oss_midi.c @@ -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: ?? */ diff --git a/sound/core/seq/oss/seq_oss_rw.c b/sound/core/seq/oss/seq_oss_rw.c index 537d5f423e20..8a142fd54a19 100644 --- a/sound/core/seq/oss/seq_oss_rw.c +++ b/sound/core/seq/oss/seq_oss_rw.c @@ -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; diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c index 722f5059b300..e3394919daa0 100644 --- a/sound/core/seq/oss/seq_oss_synth.c +++ b/sound/core/seq/oss/seq_oss_synth.c @@ -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; diff --git a/sound/core/seq/oss/seq_oss_writeq.c b/sound/core/seq/oss/seq_oss_writeq.c index 0a02a59103b4..3e3209ce53b1 100644 --- a/sound/core/seq/oss/seq_oss_writeq.c +++ b/sound/core/seq/oss/seq_oss_writeq.c @@ -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; diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index b6a24fb5e76b..2e9d695d336c 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -416,7 +416,10 @@ static ssize_t snd_seq_read(struct file *file, char __user *buf, size_t count, if (snd_BUG_ON(!client)) return -ENXIO; - if (!client->accept_input || (fifo = client->data.user.fifo) == NULL) + if (!client->accept_input) + return -ENXIO; + fifo = client->data.user.fifo; + if (!fifo) return -ENXIO; if (atomic_read(&fifo->overflow) > 0) { @@ -435,9 +438,9 @@ static ssize_t snd_seq_read(struct file *file, char __user *buf, size_t count, int nonblock; nonblock = (file->f_flags & O_NONBLOCK) || result > 0; - if ((err = snd_seq_fifo_cell_out(fifo, &cell, nonblock)) < 0) { + err = snd_seq_fifo_cell_out(fifo, &cell, nonblock); + if (err < 0) break; - } if (snd_seq_ev_is_variable(&cell->event)) { struct snd_seq_event tmpev; tmpev = cell->event; @@ -970,7 +973,8 @@ static int snd_seq_client_enqueue_event(struct snd_seq_client *client, return err; /* we got a cell. enqueue it. */ - if ((err = snd_seq_enqueue_event(cell, atomic, hop)) < 0) { + err = snd_seq_enqueue_event(cell, atomic, hop); + if (err < 0) { snd_seq_cell_free(cell); return err; } @@ -1312,7 +1316,8 @@ static int snd_seq_ioctl_create_port(struct snd_seq_client *client, void *arg) return -EINVAL; } if (client->type == KERNEL_CLIENT) { - if ((callback = info->kernel) != NULL) { + callback = info->kernel; + if (callback) { if (callback->owner) port->owner = callback->owner; port->private_data = callback->private_data; @@ -1466,13 +1471,17 @@ static int snd_seq_ioctl_subscribe_port(struct snd_seq_client *client, struct snd_seq_client *receiver = NULL, *sender = NULL; struct snd_seq_client_port *sport = NULL, *dport = NULL; - if ((receiver = snd_seq_client_use_ptr(subs->dest.client)) == NULL) + receiver = snd_seq_client_use_ptr(subs->dest.client); + if (!receiver) goto __end; - if ((sender = snd_seq_client_use_ptr(subs->sender.client)) == NULL) + sender = snd_seq_client_use_ptr(subs->sender.client); + if (!sender) goto __end; - if ((sport = snd_seq_port_use_ptr(sender, subs->sender.port)) == NULL) + sport = snd_seq_port_use_ptr(sender, subs->sender.port); + if (!sport) goto __end; - if ((dport = snd_seq_port_use_ptr(receiver, subs->dest.port)) == NULL) + dport = snd_seq_port_use_ptr(receiver, subs->dest.port); + if (!dport) goto __end; result = check_subscription_permission(client, sport, dport, subs); @@ -1508,13 +1517,17 @@ static int snd_seq_ioctl_unsubscribe_port(struct snd_seq_client *client, struct snd_seq_client *receiver = NULL, *sender = NULL; struct snd_seq_client_port *sport = NULL, *dport = NULL; - if ((receiver = snd_seq_client_use_ptr(subs->dest.client)) == NULL) + receiver = snd_seq_client_use_ptr(subs->dest.client); + if (!receiver) goto __end; - if ((sender = snd_seq_client_use_ptr(subs->sender.client)) == NULL) + sender = snd_seq_client_use_ptr(subs->sender.client); + if (!sender) goto __end; - if ((sport = snd_seq_port_use_ptr(sender, subs->sender.port)) == NULL) + sport = snd_seq_port_use_ptr(sender, subs->sender.port); + if (!sport) goto __end; - if ((dport = snd_seq_port_use_ptr(receiver, subs->dest.port)) == NULL) + dport = snd_seq_port_use_ptr(receiver, subs->dest.port); + if (!dport) goto __end; result = check_subscription_permission(client, sport, dport, subs); @@ -1926,9 +1939,11 @@ static int snd_seq_ioctl_get_subscription(struct snd_seq_client *client, struct snd_seq_client_port *sport = NULL; result = -EINVAL; - if ((sender = snd_seq_client_use_ptr(subs->sender.client)) == NULL) + sender = snd_seq_client_use_ptr(subs->sender.client); + if (!sender) goto __end; - if ((sport = snd_seq_port_use_ptr(sender, subs->sender.port)) == NULL) + sport = snd_seq_port_use_ptr(sender, subs->sender.port); + if (!sport) goto __end; result = snd_seq_port_get_subscription(&sport->c_src, &subs->dest, subs); @@ -1955,9 +1970,11 @@ static int snd_seq_ioctl_query_subs(struct snd_seq_client *client, void *arg) struct list_head *p; int i; - if ((cptr = snd_seq_client_use_ptr(subs->root.client)) == NULL) + cptr = snd_seq_client_use_ptr(subs->root.client); + if (!cptr) goto __end; - if ((port = snd_seq_port_use_ptr(cptr, subs->root.port)) == NULL) + port = snd_seq_port_use_ptr(cptr, subs->root.port); + if (!port) goto __end; switch (subs->type) { diff --git a/sound/core/seq/seq_dummy.c b/sound/core/seq/seq_dummy.c index cd5a4cad8881..ac760b1e3d12 100644 --- a/sound/core/seq/seq_dummy.c +++ b/sound/core/seq/seq_dummy.c @@ -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; diff --git a/sound/core/seq/seq_fifo.c b/sound/core/seq/seq_fifo.c index eaaa8b5830bb..f8e02e98709a 100644 --- a/sound/core/seq/seq_fifo.c +++ b/sound/core/seq/seq_fifo.c @@ -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 */ diff --git a/sound/core/seq/seq_memory.c b/sound/core/seq/seq_memory.c index e245bb6ba533..b7aee23fc387 100644 --- a/sound/core/seq/seq_memory.c +++ b/sound/core/seq/seq_memory.c @@ -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, char int 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) diff --git a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c index 6825940ea2cf..4589aac09154 100644 --- a/sound/core/seq/seq_midi.c +++ b/sound/core/seq/seq_midi.c @@ -101,7 +101,8 @@ static int dump_midi(struct snd_rawmidi_substream *substream, const char *buf, i if (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_subscribe struct 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_subscribe memset(¶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 *info struct 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; } diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c index 13cfc2d47fa7..d6c02dea976c 100644 --- a/sound/core/seq/seq_queue.c +++ b/sound/core/seq/seq_queue.c @@ -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; diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c index 77d7037d1476..4abc38c70cae 100644 --- a/sound/core/seq/seq_virmidi.c +++ b/sound/core/seq/seq_virmidi.c @@ -482,10 +482,11 @@ int snd_virmidi_new(struct snd_card *card, int device, struct snd_rawmidi **rrmi int 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); From patchwork Tue Jun 8 14:05:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456883 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFBDBC47082 for ; Tue, 8 Jun 2021 14:21:11 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6FB8F60FE9 for ; Tue, 8 Jun 2021 14:21:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6FB8F60FE9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 1E2FB17D2; Tue, 8 Jun 2021 16:20:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1E2FB17D2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162070; bh=SwpHOi2hGhzhjpOS7lL+aqHeVzD/HgrjJUhDl5cuW8g=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=PSxMaMsUqt2SDA6TnKW5okqwg0fKHD0xlZ31pra1v7pR17YZIHsaU/tV/8wgCWg2F Dg87gpZT5ASD4SeT/HG+mw74Nd6rHVsnZ/N0cPywDk8h++8qJ1fBasQqZ9u76q9Khv Ptc39d1pS0mwfi/dALy4+jsW/ceDL98G926kzHyg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B4D13F8050F; Tue, 8 Jun 2021 16:07:11 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C0FC9F80603; Tue, 8 Jun 2021 16:06:52 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id BE110F804F2 for ; Tue, 8 Jun 2021 16:05:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BE110F804F2 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="W8Zg2v7l"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Q53fK63I" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id A16341FDF5 for ; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KEaRCQtvHtSFkd8UrC/B/t4vuzYsPNzCceBREMLVJE4=; b=W8Zg2v7l3tBGYCQp3ftUvYmtdgp9cpCeZxIU14Eiyg9rta3yWbyLkZHCgKJF+KX9LhV4bb Mss5JjMoYgHTFHOLYYk/rWG/r27TGVwiSPIcB5a4/7fSq5QaqF7Fq3aBi49jmNw1hfc3D9 f9SzEl8/dvoe9j0IhM83lH2saWlrmWc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KEaRCQtvHtSFkd8UrC/B/t4vuzYsPNzCceBREMLVJE4=; b=Q53fK63IjgVpq7Sf7WUSDNKE7sQf+l08VFlpav3m/LCNS0kVE1SAcfW5KeCra+4rsMj5CQ UnQTU0NuqvOIV/Dg== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 92101A3B88; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 57/66] ALSA: pcmcia: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:31 +0200 Message-Id: <20210608140540.17885-58-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PCMCIA 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. Signed-off-by: Takashi Iwai --- 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(-) diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c index 144582350a05..8363ec08df5d 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c @@ -170,7 +170,8 @@ static int snd_pdacf_assign_resources(struct snd_pdacf *pdacf, int port, int irq if (err < 0) return err; - if ((err = snd_card_register(card)) < 0) + err = snd_card_register(card); + if (err < 0) return err; return 0; diff --git a/sound/pcmcia/vx/vxp_mixer.c b/sound/pcmcia/vx/vxp_mixer.c index 0f59e4cca56d..bc2114475810 100644 --- a/sound/pcmcia/vx/vxp_mixer.c +++ b/sound/pcmcia/vx/vxp_mixer.c @@ -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; } diff --git a/sound/pcmcia/vx/vxp_ops.c b/sound/pcmcia/vx/vxp_ops.c index 45eeb0f57d59..4176abd73799 100644 --- a/sound/pcmcia/vx/vxp_ops.c +++ b/sound/pcmcia/vx/vxp_ops.c @@ -237,9 +237,11 @@ static int vxp_load_dsp(struct vx_core *vx, int index, const struct firmware *fw switch (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: diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c index 636320489805..0dfb6a943b60 100644 --- a/sound/pcmcia/vx/vxpocket.c +++ b/sound/pcmcia/vx/vxpocket.c @@ -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; From patchwork Tue Jun 8 14:05:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455853 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27433C47082 for ; Tue, 8 Jun 2021 14:29:12 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A181561287 for ; Tue, 8 Jun 2021 14:29:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A181561287 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3E19118A8; Tue, 8 Jun 2021 16:28:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3E19118A8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162550; bh=TH/aTQjhgusRwX8QvgQdLt1aUHu+7lZZuLJAYFBMWgA=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=fRhWIHC9eAW5xrXzwjBFAIadoYmZlj1+pFzvOrkr2eFAbxOrDHCx2qtO/rjsN8E3A qcSW+WJY7U9CITvsROPhW8xhSoYH4UU6C8ZkbiEFmBT4YGbviGBt8Q+JGP/gprRfo/ QVElZhs96j/vw9J6Ycscxk0NGauYiMIUAwKZoN2w= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E61B7F80718; Tue, 8 Jun 2021 16:07:41 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 68A0CF80679; Tue, 8 Jun 2021 16:07:25 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 31A3FF8051B for ; Tue, 8 Jun 2021 16:05:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 31A3FF8051B Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="1hRsvbd6"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="k8JtvboG" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id AF39D219F8 for ; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ffRc5xlMTTRcVA6ruNzgSyqkyLHJ78i9/2M/dZbU25I=; b=1hRsvbd6HlZWTKDQr8aipGwkrqxIqGLzPrYtN8Fg7PkRtwEQAxQ3cCJfY2Hekm3CDcIug8 6jrvk16bJXNitck9aa3ETv9QwOjkCjjoX0mB9D7ht0K1Ni7tqID1xamP75onZRgLWB5yeD cXWxDgpndbGBwJOeIRcKKjco1Eh4CFU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ffRc5xlMTTRcVA6ruNzgSyqkyLHJ78i9/2M/dZbU25I=; b=k8JtvboGkbufbrTe1+GalpJRv0gOhAkp2L9tvfvBatgu7waZVP+WhWup8jgfp0gZ3R645a SF72yMlOTCtpcDDg== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 9FF69A3B84; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 58/66] ALSA: sparc: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:32 +0200 Message-Id: <20210608140540.17885-59-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" SPARC 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. Signed-off-by: Takashi Iwai --- sound/sparc/amd7930.c | 14 +++++++++----- sound/sparc/cs4231.c | 10 ++++++---- sound/sparc/dbri.c | 11 ++++++----- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index d24ae00878f5..c434b69a83f1 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -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; diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index 35c17803a430..2942c8c7a236 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -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; } diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index b055f5839578..6b84f66e4af4 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -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); From patchwork Tue Jun 8 14:05:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456872 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90826C47082 for ; Tue, 8 Jun 2021 14:29:48 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1CA6861287 for ; Tue, 8 Jun 2021 14:29:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CA6861287 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 6F2A1189C; Tue, 8 Jun 2021 16:28:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6F2A1189C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162586; bh=gQc1AJriJ4g6lzt6P9heVQIlfoE7c9ANAwAK7F/1Sjo=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=eAX8vi0SXYXIeCZaJChMydkH6DkZUyRe6To82K6mKFGI5P9MQa4c/A/ZqEl0oRWAo UaHDS8WuRbvw5ipLz+HKvwGAlXUC8I9j9sLu6KJEWi/qtgRx4WkyvTUDl4GoYJzer3 K6S39IDhPgwBwiFWEfH43bgU1RA9FdD7mRmmBeno= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6C941F80730; Tue, 8 Jun 2021 16:07:43 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8210AF80678; Tue, 8 Jun 2021 16:07:25 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 31B37F8051C for ; Tue, 8 Jun 2021 16:05:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 31B37F8051C Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="OU8jziCZ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="ArkkkIH0" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id B2A38219F9 for ; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qh9LAZq//7GSYNBdWHtUNmduwIdvjHSGrxW3y85YVFU=; b=OU8jziCZl95wvwKV9VhfHJvK5jytGWTT0FOm0XqRoJ6i3Su1k56pFC7wDXtO5WJ5MCFC/V GgAHCc5fZ4cDqLCuxZLGLdeduOG/gzWx+PhcBnWRPVA50HgY9dmLmFGqwShGnbUxw1/Bqn vEQ4s7qcA7DVyPZyy/LneyjVBSM6yok= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qh9LAZq//7GSYNBdWHtUNmduwIdvjHSGrxW3y85YVFU=; b=ArkkkIH0n2xfiKae0LtMhdFB9stOOecFVn9vbH0adSAusEAFDF9W5qmtGHMPDr61ow5Eiv 2WEgkuW32PKTtJDw== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id AD658A3B88; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 59/66] ALSA: mpu401: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:33 +0200 Message-Id: <20210608140540.17885-60-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" MPU401 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. Signed-off-by: Takashi Iwai --- sound/drivers/mpu401/mpu401.c | 9 ++++++--- sound/drivers/mpu401/mpu401_uart.c | 19 +++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c index 8c552e25805a..d0b55dbb411a 100644 --- a/sound/drivers/mpu401/mpu401.c +++ b/sound/drivers/mpu401/mpu401.c @@ -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++) { diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c index 65982d6babfc..f435b9b4ae24 100644 --- a/sound/drivers/mpu401/mpu401_uart.c +++ b/sound/drivers/mpu401/mpu401_uart.c @@ -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) { From patchwork Tue Jun 8 14:05:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455851 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04E80C47082 for ; Tue, 8 Jun 2021 14:30:57 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7922861287 for ; Tue, 8 Jun 2021 14:30:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7922861287 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id AC4171792; Tue, 8 Jun 2021 16:30:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AC4171792 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162654; bh=63a5fEK7qn5VXjZYsCmlUXHq8uLUTju+tB285qTE9C4=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=c8o2hquxqyeif5yeZPv/J4+VJ0hZOgbEaGyPVGUx71q4+148kJVSTPsbf4ZhhDRkE YIm79H+IQSXzJvkRtGDOU+XOrbNhq6mXop7gUcRmt0cDi0/m4RnjcSZ9LOcEVrVCun E3dmFmbBPGtU43T2fN/AgUhRFfR5Vm72eb5f75ck= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3E663F80750; Tue, 8 Jun 2021 16:07:46 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 13309F80684; Tue, 8 Jun 2021 16:07:31 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 55CF9F80525 for ; Tue, 8 Jun 2021 16:05:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 55CF9F80525 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="hM1jrWEH"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="eI4Wr+2a" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id B85BB219FA for ; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z47lp9c+QxLL+q97FHhqJAGNuwxF6Mn2AGaa81WjnuU=; b=hM1jrWEHoous4VXM23zsibSBphjFqLPjQI7xCs4ZFJFTYmf+dvlsnsqreeNIPJBclktPEi xqlE4/Ec9X0qAj/SbLJl+9IChb8fH6ZHvtobcdVYI2dqhIEuxwVUN1iBWKx/jFeEGlLD0a 3hGSTHjBBMyWAP3iLo1en5XMQYqb0+k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z47lp9c+QxLL+q97FHhqJAGNuwxF6Mn2AGaa81WjnuU=; b=eI4Wr+2apddk2yfboXlTnE3ZVPpwIxQQswRctcPmHkEm6JPAnwcfDyzIIQpCmrFegcEze7 qOtw20/JHaiYIOCA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id B140BA3B89; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 60/66] ALSA: vx: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:34 +0200 Message-Id: <20210608140540.17885-61-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" VX driver helper code contains lots of assignments in if condition, which is a bad coding style that may confuse readers and occasionally lead to bugs. This patch is merely for coding-style fixes, no functional changes. Signed-off-by: Takashi Iwai --- 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(-) diff --git a/sound/drivers/vx/vx_core.c b/sound/drivers/vx/vx_core.c index a22e5b1a5458..a10449af5a76 100644 --- a/sound/drivers/vx/vx_core.c +++ b/sound/drivers/vx/vx_core.c @@ -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); diff --git a/sound/drivers/vx/vx_hwdep.c b/sound/drivers/vx/vx_hwdep.c index 01baa6d872e9..efbb644edba1 100644 --- a/sound/drivers/vx/vx_hwdep.c +++ b/sound/drivers/vx/vx_hwdep.c @@ -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; diff --git a/sound/drivers/vx/vx_mixer.c b/sound/drivers/vx/vx_mixer.c index 13099f8c84d6..53d78eb13c53 100644 --- a/sound/drivers/vx/vx_mixer.c +++ b/sound/drivers/vx/vx_mixer.c @@ -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; } } diff --git a/sound/drivers/vx/vx_pcm.c b/sound/drivers/vx/vx_pcm.c index daffda99b4f7..3924f5283745 100644 --- a/sound/drivers/vx/vx_pcm.c +++ b/sound/drivers/vx/vx_pcm.c @@ -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++) { From patchwork Tue Jun 8 14:05:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455863 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01835C47082 for ; Tue, 8 Jun 2021 14:21:30 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 82A9E60FE9 for ; Tue, 8 Jun 2021 14:21:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82A9E60FE9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2C1DD16F2; Tue, 8 Jun 2021 16:20:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2C1DD16F2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162088; bh=EWe65DrJ+mok7gl+MS1STeOR88hzkgdehmJQgEaPlho=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Y6xzQtToO3tiqTg72+pW74+yIi3qdcbyhuNbu2TunPOu8B5JsNulUyS8IdOLaI0g+ 3CVJg0ZxIbbwbVK6IRD8aYFZAduGZO934PbBbgF0QrDk1xootOAaUJbwprpOCXUSeD gcLF9NNkryTuXOXY7nSdtBozBr1IZQKauwbjzBRs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2F2BAF8061C; Tue, 8 Jun 2021 16:07:13 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1774DF80536; Tue, 8 Jun 2021 16:06:53 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id BEA26F804FA for ; Tue, 8 Jun 2021 16:05:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BEA26F804FA Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="F+1nRDn6"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="MCAz7O9C" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id C6FD21FDF6 for ; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UxL6ygppRuVuRIOnySsCavdhCCSMQyjQk/4Dot3lGZE=; b=F+1nRDn6PfJF54hvEuSc7rzmk5nMwSxpbaFA0P/o+RC7WgDbKStuCblGP/m1mK3gJWxvmp fVpRr1hpuvJJGQHHWhFff6D7nw24m0Jg0G1hrLLQ33+2+HaIylFXLmfrql+dPyzSREemz0 qPHsXz6g8ZS5Gv0mwMInSUWCn5zKdks= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UxL6ygppRuVuRIOnySsCavdhCCSMQyjQk/4Dot3lGZE=; b=MCAz7O9CV5v3mcv4SNKbVcWkmgDrGY04yHkRt0+prgT/ttMdFIg5z8ragirsYQNEdCitpd zh7OktYzUbmHdbDw== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id B77F8A3B84; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 61/66] ALSA: opl3: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:35 +0200 Message-Id: <20210608140540.17885-62-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" OPL3 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. Signed-off-by: Takashi Iwai --- 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(-) diff --git a/sound/drivers/opl3/opl3_lib.c b/sound/drivers/opl3/opl3_lib.c index 9259522483c8..6c1f1cc092d8 100644 --- a/sound/drivers/opl3/opl3_lib.c +++ b/sound/drivers/opl3/opl3_lib.c @@ -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; } diff --git a/sound/drivers/opl3/opl3_oss.c b/sound/drivers/opl3/opl3_oss.c index c82c7c1c0714..7645365eec89 100644 --- a/sound/drivers/opl3/opl3_oss.c +++ b/sound/drivers/opl3/opl3_oss.c @@ -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; diff --git a/sound/drivers/opl3/opl3_seq.c b/sound/drivers/opl3/opl3_seq.c index cd2a01b5e2e1..75de1299c3dc 100644 --- a/sound/drivers/opl3/opl3_seq.c +++ b/sound/drivers/opl3/opl3_seq.c @@ -92,7 +92,8 @@ static int snd_opl3_synth_use(void *private_data, struct snd_seq_port_subscribe struct 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; From patchwork Tue Jun 8 14:05:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 455852 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA60CC47082 for ; Tue, 8 Jun 2021 14:30:00 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 68D0161003 for ; Tue, 8 Jun 2021 14:30:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 68D0161003 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0C772188F; Tue, 8 Jun 2021 16:29:09 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0C772188F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162599; bh=S8PoKqc6i5doQwVBgKCh7FDkcnoZ/SytlO4ouJOOWCQ=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=tUqvrQvw0e8pO1+90uL7WEEMvDvrEL7AFZjzdO18ezuI/sjUhBc0GUgbwr8g9sbMk i6qxiHZDUvP69lZatXfW3Qz6QyGXLtzIC6fkaummf+QAcm/2Swg+52XtnUDxnxC3ba T7uGP6MtWDJxokMdBVjaoBN0QAYQK7/voBB/3gsI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 37DC3F80737; Tue, 8 Jun 2021 16:07:44 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9EF65F8067B; Tue, 8 Jun 2021 16:07:27 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4C9B4F80520 for ; Tue, 8 Jun 2021 16:05:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4C9B4F80520 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="S3dcDptV"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="lN/ztUmu" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id D6733219FB for ; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cXUZcujhpWJI3Z/TxgO3dxtyF6B9GN+18/4fZUZMWwY=; b=S3dcDptVbUdBzz3AfXx/tvsY9HFSstYvVG/4djXzAzR7ZqY549SY687WGZkOv+V8l7KIXC mcgmgmG7+1JamwIImFTcDfpI94CuOpLUuMr1j4DsR/LsIQIFly8lXdXz+kyw4AtSvJWS+4 vByWz0JokGCt4j1nDa2ghZQsKCsjNc8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cXUZcujhpWJI3Z/TxgO3dxtyF6B9GN+18/4fZUZMWwY=; b=lN/ztUmuFyBj21IRQrM+JGBG37AibBaXZirbnddEnMeJ6qLdApCJBgAwdf4F5xQlGuTIVz jNVQtjrc/smSKpDA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id C5DCDA3B88; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 62/66] ALSA: serial: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:36 +0200 Message-Id: <20210608140540.17885-63-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" A 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. Signed-off-by: Takashi Iwai --- 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(-) diff --git a/sound/drivers/mtpav.c b/sound/drivers/mtpav.c index df4b7f9cd50f..0e95b08d34d6 100644 --- a/sound/drivers/mtpav.c +++ b/sound/drivers/mtpav.c @@ -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); diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c index 322d530ab07b..d3bc9e8c407d 100644 --- a/sound/drivers/mts64.c +++ b/sound/drivers/mts64.c @@ -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) { diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c index 2f4514ed47c5..52a656735365 100644 --- a/sound/drivers/portman2x4.c +++ b/sound/drivers/portman2x4.c @@ -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) { diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c index 6d5d1ca59ecf..da9983cba01c 100644 --- a/sound/drivers/serial-u16550.c +++ b/sound/drivers/serial-u16550.c @@ -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; From patchwork Tue Jun 8 14:05:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456881 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 667A7C47082 for ; Tue, 8 Jun 2021 14:22:53 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 86750611BD for ; Tue, 8 Jun 2021 14:22:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 86750611BD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 281FD17F2; Tue, 8 Jun 2021 16:22:01 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 281FD17F2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162171; bh=plPW61EX4WQErZ4Uezc9zWjeTYN/ZPcJegeQ6nW4FlM=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Foh2t9M3VxE1oB8LRGGez/E0WaWmw3RV6RyBc9PoLYWBy7y6gSp8eAYuvFPwdex+I JmLGJqU1kbSETXJEsf9800rC8APVNdsZCVaofbKOofJg+ogabEKs7Z5p+c9pQpOho7 xfrRxtYdDZ8xmAEWoUhrvdS2OjyA9uYzWOa4kCiE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 01BD2F80639; Tue, 8 Jun 2021 16:07:18 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 44F40F8060B; Tue, 8 Jun 2021 16:06:57 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C3BB5F804FB for ; Tue, 8 Jun 2021 16:05:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C3BB5F804FB Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="QJZy0vSB"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="cRSfzGBt" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id DA2721FDF7 for ; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dV/5w4qelBBq9aFMldVVeaXHoSh4XlIMLv02AS+0+cg=; b=QJZy0vSBCVIAltAn8oK35f2hDhVS45Rbca+TZ3cGwJRn0Lnfij2NcNcMUla3mT5TkhC9mH 5tdikpj75SPcFp6q6YL6WMXXc29LZGSSJI/ZdNwQyK1IOm9iopAG/rVv91xzRWaOVF8/R2 5yfLqqD/kmWsHszBqqhXwaOtZIcpgug= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dV/5w4qelBBq9aFMldVVeaXHoSh4XlIMLv02AS+0+cg=; b=cRSfzGBt9lAxTCQUD/LPs86Or/PMnuf/uMoWEqJFr0UO3d0fP4JITULCQOtpLlyOtcnVlT rXZ/dZ5oCi4JTgDg== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id D4F33A3B84; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 63/66] ALSA: synth: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:37 +0200 Message-Id: <20210608140540.17885-64-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" EMUx 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. Signed-off-by: Takashi Iwai --- 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(-) diff --git a/sound/synth/emux/emux.c b/sound/synth/emux/emux.c index f65e6c7b139f..49d1976a132c 100644 --- a/sound/synth/emux/emux.c +++ b/sound/synth/emux/emux.c @@ -104,7 +104,8 @@ int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, ch if (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); diff --git a/sound/synth/emux/emux_effect.c b/sound/synth/emux/emux_effect.c index afd119b11f39..3c7314f5fb19 100644 --- a/sound/synth/emux/emux_effect.c +++ b/sound/synth/emux/emux_effect.c @@ -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) diff --git a/sound/synth/emux/emux_hwdep.c b/sound/synth/emux/emux_hwdep.c index 8a965e2f160a..81719bfb8ed7 100644 --- a/sound/synth/emux/emux_hwdep.c +++ b/sound/synth/emux/emux_hwdep.c @@ -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; diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c index 9ebc711afa6b..da3cf8912463 100644 --- a/sound/synth/emux/soundfont.c +++ b/sound/synth/emux/soundfont.c @@ -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); From patchwork Tue Jun 8 14:05:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456871 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8274C47082 for ; Tue, 8 Jun 2021 14:30:28 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2956B61003 for ; Tue, 8 Jun 2021 14:30:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2956B61003 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id BD78318B9; Tue, 8 Jun 2021 16:29:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BD78318B9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162626; bh=/1irUjfcDbTrN1/DJKGtuJ6wHV8P9TaBQDxURqaTzdM=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Q5Ph+cZILv9Ht2dqXc6JnHsoeeBmedzwOsNXXih1GD0pGfmBcdsVrm5Ng8nxamJmh SJvlfNUVKk6X0OODkzFf0a8nKY25mBCvxebxeQFnw9ZwK7xWdi0sK2u75g709fJ0V7 IbscLtsn3jXEjpCntVqd7tyIzMLnQIo49EK5/tX0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D1067F8074B; Tue, 8 Jun 2021 16:07:44 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id AF498F8067D; Tue, 8 Jun 2021 16:07:28 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4C913F8051F for ; Tue, 8 Jun 2021 16:05:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4C913F8051F Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="S3Ukpe4T"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="FDRgcNeN" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id EB8A3219FC for ; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LetJNNQsRS0zetcV8C/nuUiV97hdSqZB08I6LPHIvKQ=; b=S3Ukpe4TuokPNmA/WLzOfsNJyXn2xmMy61BSN26CEyWIZEuGE8GF+3sdfgl1CcFYRRTwNv Zj7UQ2Ab4lC/rxJCB8mRIDCV3OMSo4ZE31lIz3CNCOVuxLkr/sRaHIPOBXOxhI8upY7gh3 ySSOMTOVhY2EnQtGE/8V6Q/OukthW7I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LetJNNQsRS0zetcV8C/nuUiV97hdSqZB08I6LPHIvKQ=; b=FDRgcNeNp3U3IgbXuvpyOMY0n51lo9wr+jNnhSk6HCVH6/Km9hYZpgjoCea2DACJnjNcYF BkCDFoGoxIL3ehAw== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id D99D6A3B89; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 64/66] ALSA: poewrmac: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:38 +0200 Message-Id: <20210608140540.17885-65-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PPC 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. Signed-off-by: Takashi Iwai --- 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(-) diff --git a/sound/ppc/beep.c b/sound/ppc/beep.c index 6bc586a5db0f..0f4bce1c0d4f 100644 --- a/sound/ppc/beep.c +++ b/sound/ppc/beep.c @@ -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) { diff --git a/sound/ppc/daca.c b/sound/ppc/daca.c index 1eb698dafd93..4da9278dd58a 100644 --- a/sound/ppc/daca.c +++ b/sound/ppc/daca.c @@ -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; } diff --git a/sound/ppc/keywest.c b/sound/ppc/keywest.c index a8915100d6bb..6e5daae18f9d 100644 --- a/sound/ppc/keywest.c +++ b/sound/ppc/keywest.c @@ -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; diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index 2e750b317be1..84058bbf9d12 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -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; diff --git a/sound/ppc/powermac.c b/sound/ppc/powermac.c index 9fb51ebafde1..1d2865c43d4b 100644 --- a/sound/ppc/powermac.c +++ b/sound/ppc/powermac.c @@ -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; diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c index 6e5bdaa262b0..c65e74d7cd0a 100644 --- a/sound/ppc/tumbler.c +++ b/sound/ppc/tumbler.c @@ -402,7 +402,8 @@ static int tumbler_get_drc_value(struct snd_kcontrol *kcontrol, { struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); struct pmac_tumbler *mix; - if (! (mix = chip->mixer_data)) + mix = chip->mixer_data; + if (!mix) return -ENODEV; ucontrol->value.integer.value[0] = mix->drc_range; return 0; @@ -416,7 +417,8 @@ static int tumbler_put_drc_value(struct snd_kcontrol *kcontrol, unsigned int val; int change; - if (! (mix = chip->mixer_data)) + mix = chip->mixer_data; + if (!mix) return -ENODEV; val = ucontrol->value.integer.value[0]; if (chip->model == PMAC_TUMBLER) { @@ -442,7 +444,8 @@ static int tumbler_get_drc_switch(struct snd_kcontrol *kcontrol, { struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); struct pmac_tumbler *mix; - if (! (mix = chip->mixer_data)) + mix = chip->mixer_data; + if (!mix) return -ENODEV; ucontrol->value.integer.value[0] = mix->drc_enable; return 0; @@ -455,7 +458,8 @@ static int tumbler_put_drc_switch(struct snd_kcontrol *kcontrol, struct pmac_tumbler *mix; int change; - if (! (mix = chip->mixer_data)) + mix = chip->mixer_data; + if (!mix) return -ENODEV; change = mix->drc_enable != ucontrol->value.integer.value[0]; if (change) { @@ -524,7 +528,8 @@ static int tumbler_get_mono(struct snd_kcontrol *kcontrol, struct tumbler_mono_vol *info = (struct tumbler_mono_vol *)kcontrol->private_value; struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); struct pmac_tumbler *mix; - if (! (mix = chip->mixer_data)) + mix = chip->mixer_data; + if (!mix) return -ENODEV; ucontrol->value.integer.value[0] = mix->mono_vol[info->index]; return 0; @@ -539,7 +544,8 @@ static int tumbler_put_mono(struct snd_kcontrol *kcontrol, unsigned int vol; int change; - if (! (mix = chip->mixer_data)) + mix = chip->mixer_data; + if (!mix) return -ENODEV; vol = ucontrol->value.integer.value[0]; if (vol >= info->max) @@ -669,7 +675,8 @@ static int snapper_get_mix(struct snd_kcontrol *kcontrol, int idx = (int)kcontrol->private_value; struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); struct pmac_tumbler *mix; - if (! (mix = chip->mixer_data)) + mix = chip->mixer_data; + if (!mix) return -ENODEV; ucontrol->value.integer.value[0] = mix->mix_vol[idx][0]; ucontrol->value.integer.value[1] = mix->mix_vol[idx][1]; @@ -685,7 +692,8 @@ static int snapper_put_mix(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]; @@ -716,7 +724,8 @@ static int tumbler_get_mute_switch(struct snd_kcontrol *kcontrol, struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); struct pmac_tumbler *mix; struct pmac_gpio *gp; - if (! (mix = chip->mixer_data)) + mix = chip->mixer_data; + if (!mix) return -ENODEV; switch(kcontrol->private_value) { case TUMBLER_MUTE_HP: @@ -745,7 +754,8 @@ static int tumbler_put_mute_switch(struct snd_kcontrol *kcontrol, if (chip->update_automute && chip->auto_mute) return 0; /* don't touch in the auto-mute mode */ #endif - if (! (mix = chip->mixer_data)) + mix = chip->mixer_data; + if (!mix) return -ENODEV; switch(kcontrol->private_value) { case TUMBLER_MUTE_HP: @@ -1361,7 +1371,8 @@ int snd_pmac_tumbler_init(struct snd_pmac *chip) break; } } - if ((err = tumbler_init(chip)) < 0) + err = tumbler_init(chip); + if (err < 0) return err; /* set up TAS */ @@ -1392,7 +1403,8 @@ int snd_pmac_tumbler_init(struct snd_pmac *chip) chipname = "Snapper"; } - if ((err = snd_pmac_keywest_init(&mix->i2c)) < 0) + err = snd_pmac_keywest_init(&mix->i2c); + if (err < 0) return err; /* @@ -1402,28 +1414,34 @@ int snd_pmac_tumbler_init(struct snd_pmac *chip) if (chip->model == PMAC_TUMBLER) { for (i = 0; i < ARRAY_SIZE(tumbler_mixers); i++) { - if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&tumbler_mixers[i], chip))) < 0) + err = snd_ctl_add(chip->card, snd_ctl_new1(&tumbler_mixers[i], chip)); + if (err < 0) return err; } } else { for (i = 0; i < ARRAY_SIZE(snapper_mixers); i++) { - if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snapper_mixers[i], chip))) < 0) + err = snd_ctl_add(chip->card, snd_ctl_new1(&snapper_mixers[i], chip)); + if (err < 0) return err; } } chip->master_sw_ctl = snd_ctl_new1(&tumbler_hp_sw, chip); - if ((err = snd_ctl_add(chip->card, chip->master_sw_ctl)) < 0) + err = snd_ctl_add(chip->card, chip->master_sw_ctl); + if (err < 0) return err; chip->speaker_sw_ctl = snd_ctl_new1(&tumbler_speaker_sw, chip); - if ((err = snd_ctl_add(chip->card, chip->speaker_sw_ctl)) < 0) + err = snd_ctl_add(chip->card, chip->speaker_sw_ctl); + if (err < 0) return err; if (mix->line_mute.addr != 0) { chip->lineout_sw_ctl = snd_ctl_new1(&tumbler_lineout_sw, chip); - if ((err = snd_ctl_add(chip->card, chip->lineout_sw_ctl)) < 0) + err = snd_ctl_add(chip->card, chip->lineout_sw_ctl); + if (err < 0) return err; } chip->drc_sw_ctl = snd_ctl_new1(&tumbler_drc_sw, chip); - if ((err = snd_ctl_add(chip->card, chip->drc_sw_ctl)) < 0) + err = snd_ctl_add(chip->card, chip->drc_sw_ctl); + if (err < 0) return err; /* set initial DRC range to 60% */ @@ -1446,9 +1464,11 @@ int snd_pmac_tumbler_init(struct snd_pmac *chip) device_change_chip = chip; #ifdef PMAC_SUPPORT_AUTOMUTE - if ((mix->headphone_irq >=0 || mix->lineout_irq >= 0) - && (err = snd_pmac_add_automute(chip)) < 0) - return err; + if (mix->headphone_irq >= 0 || mix->lineout_irq >= 0) { + err = snd_pmac_add_automute(chip); + if (err < 0) + return err; + } chip->detect_headphone = tumbler_detect_headphone; chip->update_automute = tumbler_update_automute; tumbler_update_automute(chip, 0); /* update the status only */ @@ -1456,8 +1476,9 @@ int snd_pmac_tumbler_init(struct snd_pmac *chip) /* activate headphone status interrupts */ if (mix->headphone_irq >= 0) { unsigned char val; - if ((err = request_irq(mix->headphone_irq, headphone_intr, 0, - "Sound Headphone Detection", chip)) < 0) + err = request_irq(mix->headphone_irq, headphone_intr, 0, + "Sound Headphone Detection", chip); + if (err < 0) return 0; /* activate headphone status interrupts */ val = do_gpio_read(&mix->hp_detect); @@ -1465,8 +1486,9 @@ int snd_pmac_tumbler_init(struct snd_pmac *chip) } if (mix->lineout_irq >= 0) { unsigned char val; - if ((err = request_irq(mix->lineout_irq, headphone_intr, 0, - "Sound Lineout Detection", chip)) < 0) + err = request_irq(mix->lineout_irq, headphone_intr, 0, + "Sound Lineout Detection", chip); + if (err < 0) return 0; /* activate headphone status interrupts */ val = do_gpio_read(&mix->line_detect); From patchwork Tue Jun 8 14:05:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456879 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66118C47082 for ; Tue, 8 Jun 2021 14:24:27 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B1B3C611BD for ; Tue, 8 Jun 2021 14:24:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B1B3C611BD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 539B917F2; Tue, 8 Jun 2021 16:23:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 539B917F2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162265; bh=qb5KpQKULGkCQ0KTNVj8iSeRxKoGCeB3+hroGIsqmS4=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=SZE65ZnOEME8+EU8U8Ml27/HnnPQvn3kHK/Gofihuxe8D8hWTfiGjmxeMnDEcX7Cn 0fthcus+tYXVyLce47gVLYiRcGrPewMbDQ2d+ACapv06epdaU/Ma7Q8c8xxjPszGtm bbgZczrdT+/MK9bU6HgogP55/qMoyOIgjlvnn9NU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1B05AF80676; Tue, 8 Jun 2021 16:07:25 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DB0EBF80614; Tue, 8 Jun 2021 16:07:01 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D1A12F804FC for ; Tue, 8 Jun 2021 16:05:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D1A12F804FC Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="xajC1/GG"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="T2XuTzzH" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 0618C1FDF8 for ; Tue, 8 Jun 2021 14:05:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161146; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5nJFTD0gHOknziS1n7jxybqCEtKQfBolVx/wxrqk1is=; b=xajC1/GGP9fezIee/GU6b8zWhlrDhxon5CsSTY5cqAIXtzg3I8ilPHwLLxgvGpD3DdCBN5 iq/eMFBesUcNKlWFelMphAkiScBDTGQhPzrPSHVZafIxdClJ0QWrzWI3aiytWGMQjbiFbe 64dPc+nd9RBYUcR9t3q6k3FBHYvEc6s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161146; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5nJFTD0gHOknziS1n7jxybqCEtKQfBolVx/wxrqk1is=; b=T2XuTzzHVUKFL5rLMTFgOcf/vswjTekGEVt424SQOf7GYs97Z9ZireFDJ5Hk3/VDgXWcNF wUl5RL46RKFHJcAA== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id EA4C6A3B84; Tue, 8 Jun 2021 14:05:45 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 65/66] ALSA: i2c: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:39 +0200 Message-Id: <20210608140540.17885-66-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" ALSA I2C helper drivers contain a few assignments in if condition, which is a bad coding style that may confuse readers and occasionally lead to bugs. This patch is merely for coding-style fixes, no functional changes. Signed-off-by: Takashi Iwai --- 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(-) diff --git a/sound/i2c/cs8427.c b/sound/i2c/cs8427.c index 8634d4f466b3..65012af6a36e 100644 --- a/sound/i2c/cs8427.c +++ b/sound/i2c/cs8427.c @@ -50,7 +50,8 @@ int snd_cs8427_reg_write(struct snd_i2c_device *device, unsigned char reg, buf[0] = reg & 0x7f; buf[1] = val; - if ((err = snd_i2c_sendbytes(device, buf, 2)) != 2) { + err = snd_i2c_sendbytes(device, buf, 2); + if (err != 2) { snd_printk(KERN_ERR "unable to send bytes 0x%02x:0x%02x " "to CS8427 (%i)\n", buf[0], buf[1], err); return err < 0 ? err : -EIO; @@ -65,12 +66,14 @@ static int snd_cs8427_reg_read(struct snd_i2c_device *device, unsigned char reg) int err; unsigned char buf; - if ((err = snd_i2c_sendbytes(device, ®, 1)) != 1) { + err = snd_i2c_sendbytes(device, ®, 1); + if (err != 1) { snd_printk(KERN_ERR "unable to send register 0x%x byte " "to CS8427\n", reg); return err < 0 ? err : -EIO; } - if ((err = snd_i2c_readbytes(device, &buf, 1)) != 1) { + err = snd_i2c_readbytes(device, &buf, 1); + if (err != 1) { snd_printk(KERN_ERR "unable to read register 0x%x byte " "from CS8427\n", reg); return err < 0 ? err : -EIO; @@ -108,7 +111,8 @@ static int snd_cs8427_send_corudata(struct snd_i2c_device *device, if (!memcmp(hw_data, ndata, count)) return 0; - if ((err = snd_cs8427_select_corudata(device, udata)) < 0) + err = snd_cs8427_select_corudata(device, udata); + if (err < 0) return err; memcpy(hw_data, ndata, count); if (udata) { @@ -209,7 +213,8 @@ int snd_cs8427_init(struct snd_i2c_bus *bus, goto __fail; /* send initial values */ memcpy(chip->regmap + (initvals1[0] & 0x7f), initvals1 + 1, 6); - if ((err = snd_i2c_sendbytes(device, initvals1, 7)) != 7) { + err = snd_i2c_sendbytes(device, initvals1, 7); + if (err != 7) { err = err < 0 ? err : -EIO; goto __fail; } @@ -217,11 +222,13 @@ int snd_cs8427_init(struct snd_i2c_bus *bus, memset(buf, 0, 7); /* from address 9 to 15 */ buf[0] = 9; /* register */ - if ((err = snd_i2c_sendbytes(device, buf, 7)) != 7) + err = snd_i2c_sendbytes(device, buf, 7); + if (err != 7) goto __fail; /* send transfer initialization sequence */ memcpy(chip->regmap + (initvals2[0] & 0x7f), initvals2 + 1, 3); - if ((err = snd_i2c_sendbytes(device, initvals2, 4)) != 4) { + err = snd_i2c_sendbytes(device, initvals2, 4); + if (err != 4) { err = err < 0 ? err : -EIO; goto __fail; } @@ -383,7 +390,8 @@ static int snd_cs8427_qsubcode_get(struct snd_kcontrol *kcontrol, int err; snd_i2c_lock(device->bus); - if ((err = snd_i2c_sendbytes(device, ®, 1)) != 1) { + err = snd_i2c_sendbytes(device, ®, 1); + if (err != 1) { snd_printk(KERN_ERR "unable to send register 0x%x byte " "to CS8427\n", reg); snd_i2c_unlock(device->bus); diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c index 2ce0a97957ab..c0cffe28989b 100644 --- a/sound/i2c/other/ak4114.c +++ b/sound/i2c/other/ak4114.c @@ -97,7 +97,8 @@ int snd_ak4114_create(struct snd_card *card, chip->rcs0 = reg_read(chip, AK4114_REG_RCS0) & ~(AK4114_QINT | AK4114_CINT); chip->rcs1 = reg_read(chip, AK4114_REG_RCS1); - if ((err = snd_device_new(card, SNDRV_DEV_CODEC, chip, &ops)) < 0) + err = snd_device_new(card, SNDRV_DEV_CODEC, chip, &ops); + if (err < 0) goto __fail; if (r_ak4114) diff --git a/sound/i2c/other/ak4117.c b/sound/i2c/other/ak4117.c index 905be2d0780b..1bc43e927d82 100644 --- a/sound/i2c/other/ak4117.c +++ b/sound/i2c/other/ak4117.c @@ -86,7 +86,8 @@ int snd_ak4117_create(struct snd_card *card, ak4117_read_t *read, ak4117_write_t chip->rcs1 = reg_read(chip, AK4117_REG_RCS1); chip->rcs2 = reg_read(chip, AK4117_REG_RCS2); - if ((err = snd_device_new(card, SNDRV_DEV_CODEC, chip, &ops)) < 0) + err = snd_device_new(card, SNDRV_DEV_CODEC, chip, &ops); + if (err < 0) goto __fail; if (r_ak4117) diff --git a/sound/i2c/tea6330t.c b/sound/i2c/tea6330t.c index 08eb6a873768..742d0f724375 100644 --- a/sound/i2c/tea6330t.c +++ b/sound/i2c/tea6330t.c @@ -115,7 +115,8 @@ static int snd_tea6330t_put_master_volume(struct snd_kcontrol *kcontrol, bytes[count++] = tea->regs[TEA6330T_SADDR_VOLUME_RIGHT] = tea->mright; } if (count > 0) { - if ((err = snd_i2c_sendbytes(tea->device, bytes, count)) < 0) + err = snd_i2c_sendbytes(tea->device, bytes, count); + if (err < 0) change = err; } snd_i2c_unlock(tea->bus); @@ -160,7 +161,8 @@ static int snd_tea6330t_put_master_switch(struct snd_kcontrol *kcontrol, bytes[0] = TEA6330T_SADDR_VOLUME_LEFT; bytes[1] = tea->regs[TEA6330T_SADDR_VOLUME_LEFT]; bytes[2] = tea->regs[TEA6330T_SADDR_VOLUME_RIGHT]; - if ((err = snd_i2c_sendbytes(tea->device, bytes, 3)) < 0) + err = snd_i2c_sendbytes(tea->device, bytes, 3); + if (err < 0) change = err; snd_i2c_unlock(tea->bus); return change; @@ -207,7 +209,8 @@ static int snd_tea6330t_put_bass(struct snd_kcontrol *kcontrol, change = tea->regs[TEA6330T_SADDR_BASS] != val1; bytes[0] = TEA6330T_SADDR_BASS; bytes[1] = tea->regs[TEA6330T_SADDR_BASS] = val1; - if ((err = snd_i2c_sendbytes(tea->device, bytes, 2)) < 0) + err = snd_i2c_sendbytes(tea->device, bytes, 2); + if (err < 0) change = err; snd_i2c_unlock(tea->bus); return change; @@ -254,7 +257,8 @@ static int snd_tea6330t_put_treble(struct snd_kcontrol *kcontrol, change = tea->regs[TEA6330T_SADDR_TREBLE] != val1; bytes[0] = TEA6330T_SADDR_TREBLE; bytes[1] = tea->regs[TEA6330T_SADDR_TREBLE] = val1; - if ((err = snd_i2c_sendbytes(tea->device, bytes, 2)) < 0) + err = snd_i2c_sendbytes(tea->device, bytes, 2); + if (err < 0) change = err; snd_i2c_unlock(tea->bus); return change; @@ -287,7 +291,8 @@ int snd_tea6330t_update_mixer(struct snd_card *card, tea = kzalloc(sizeof(*tea), GFP_KERNEL); if (tea == NULL) return -ENOMEM; - if ((err = snd_i2c_device_create(bus, "TEA6330T", TEA6330T_ADDR, &device)) < 0) { + err = snd_i2c_device_create(bus, "TEA6330T", TEA6330T_ADDR, &device); + if (err < 0) { kfree(tea); return err; } @@ -327,18 +332,21 @@ int snd_tea6330t_update_mixer(struct snd_card *card, bytes[0] = TEA6330T_SADDR_VOLUME_LEFT; for (idx = 0; idx < 6; idx++) bytes[idx+1] = tea->regs[idx]; - if ((err = snd_i2c_sendbytes(device, bytes, 7)) < 0) + err = snd_i2c_sendbytes(device, bytes, 7); + if (err < 0) goto __error; strcat(card->mixername, ",TEA6330T"); - if ((err = snd_component_add(card, "TEA6330T")) < 0) + err = snd_component_add(card, "TEA6330T"); + if (err < 0) goto __error; for (idx = 0; idx < ARRAY_SIZE(snd_tea6330t_controls); idx++) { knew = &snd_tea6330t_controls[idx]; if (tea->treble == 0 && !strcmp(knew->name, "Tone Control - Treble")) continue; - if ((err = snd_ctl_add(card, snd_ctl_new1(knew, tea))) < 0) + err = snd_ctl_add(card, snd_ctl_new1(knew, tea)); + if (err < 0) goto __error; } From patchwork Tue Jun 8 14:05:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 456870 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6703C47082 for ; Tue, 8 Jun 2021 14:31:18 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 24956610C7 for ; Tue, 8 Jun 2021 14:31:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 24956610C7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B79B71772; Tue, 8 Jun 2021 16:30:26 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B79B71772 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1623162676; bh=sja7HEwjgMs558F1bxzooVXJUHNoGot0vtKzIrhs86s=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=cv+tYPnD/6T37eoH3AT2U/TnRq5gSwOOyPiATD41dnsfaxPwmDprBDvr6SJ6df8Ts zfmvlbDeFWKOA9+J86J3hx2jYpOTts16B9gNnG0f81BjKPLm2ihLLZNkkByI1ePL5E rbUBPiEuxKMoeAW1nHN60oWi8AfmwRomhw39xTyU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D87BEF80759; Tue, 8 Jun 2021 16:07:46 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C34B4F80687; Tue, 8 Jun 2021 16:07:31 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 55C53F80524 for ; Tue, 8 Jun 2021 16:05:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 55C53F80524 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="djDzrJvr"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="LnUjI4EY" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 126E5219FD for ; Tue, 8 Jun 2021 14:05:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623161146; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WI5ANRs2NFILkPRAaTEMuBWH+cReSJrAzsZ6HYYz1us=; b=djDzrJvrNbF+BBlcM0BD/z1IA9nYEwZGsdmkvcmXa5B0igRs+Ixpn/wd6H5JUvIkWDDRND BA2dtBw88nDuTgDVWNJqBem29QIM48jGZ5Kl3/LtIeoNf/h7/c8MeZHFJMvy1vPzI0QvAR UMO+/HZ/rQV7R4uSJ6/+dnyhdM5DhR8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623161146; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WI5ANRs2NFILkPRAaTEMuBWH+cReSJrAzsZ6HYYz1us=; b=LnUjI4EYS/Mxva6ZORtt8V8yxawmu9Yx6bXLNN/YcMDDnghUKtAFd+35vniFunzu/N0dHf R2pe5/Hn5EUcgAAQ== Received: from alsa1.nue.suse.com (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 04467A3B88; Tue, 8 Jun 2021 14:05:46 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH 66/66] ALSA: parisc: Fix assignment in if condition Date: Tue, 8 Jun 2021 16:05:40 +0200 Message-Id: <20210608140540.17885-67-tiwai@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210608140540.17885-1-tiwai@suse.de> References: <20210608140540.17885-1-tiwai@suse.de> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" PARISC 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. Signed-off-by: Takashi Iwai --- sound/parisc/harmony.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c index f2ca0a701987..1440db8b4177 100644 --- a/sound/parisc/harmony.c +++ b/sound/parisc/harmony.c @@ -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;