From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751825AbdKQJtD (ORCPT ); Fri, 17 Nov 2017 04:49:03 -0500 Received: from mout.web.de ([212.227.15.4]:51038 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751601AbdKQJs7 (ORCPT ); Fri, 17 Nov 2017 04:48:59 -0500 Subject: [PATCH 1/4] ALSA: riptide: Adjust 13 function calls together with a variable assignment From: SF Markus Elfring To: alsa-devel@alsa-project.org, Bhumika Goyal , David Howells , Jaroslav Kysela , Takashi Iwai Cc: LKML , kernel-janitors@vger.kernel.org References: <0eef2699-f28a-c1e0-9351-268b5eb7e0c1@users.sourceforge.net> Message-ID: <4dcb7c19-6683-7955-e9d7-e9989c9873e6@users.sourceforge.net> Date: Fri, 17 Nov 2017 10:47:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <0eef2699-f28a-c1e0-9351-268b5eb7e0c1@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:PB+jbcWc8rzwdftLnhvEEoD2mmf86Xb1Xq0hshrzXvaoDjsqsiS nTrsXryeS5EA3rr1zq942LRyOX84dFGUBspcaa5jFpMneXS67jPCH9B2zVPh8to+p4oJ1Qv nO+n0FSXntsrlI3jUko5Q9eNPaUie1YJBD7/LWQ3Nolxaq1BDiAu1O3g7fMoe+YOjqGF7R3 qNHHeFEJR9uNN2n9EzYiw== X-UI-Out-Filterresults: notjunk:1;V01:K0:WzWB7TMjLI4=:BZG7Fy8+p3ryOTDFcboBQj Az+Csr4YEMb0bGtu1ViaPwWD2MsOZ+hJpoM7JkohiFRI5AF90hbH13IfCiLg562zdPE3DmC2+ vU+y9aOnmcErkWnuaBBWXkq7nZIFi6utMeH83dJdV0KC6Ue4eIx1dwbmonHuIUlU6njKdzoOv JNZVcwEivUG+dp8W2GT5bP6VNQi632uNkJf/ULu/sLmA3rzz+JTRkA2TT4wbSaf7pSQz89iJw IUF/aagqtoMN4UEDRiU7poYsuzw04N1YlDgzJIIiLNDz5VtE/FZaxa6BmVn5PDujTO0veonBW pn40C7aFTzj8W9ddlSc1XwMiEehKooKb/R7QUHE9IYmhqFqhEXEzJj/nYk17sFl2HaaJyIYkB hGa5GTXzdJO86aoeF0mtHvSF6g+k5NuNQtANku5Ta8N9rT9adfsFKC8smFgm4yDwX/YkqezdG LSkU3X0UU2vQyEi59zH7nHivYpSyoruhBa1pMHDrrfL5DrIfCRaVH8S7XI4LVRyW36SxOmHqX yRtaGDv0PYKs1jmijwf6zNVMpj+CL+GQz+dxT67erRorEjPS9F/cqOLNF7Ymglk8GZh+iu8pR BFW1Yy3jc6sscW4rtPzgqTlFrkrrNc7n4SwKx54JN74PVMCPQvM5WuwY5QIJ7fWRTg8uelY21 mup9QfswHPRO9sqeIM4WenjlayHbjPqzlRqUojLpwNc6lfHPbCrjGYCWO4wav2glWkquM9JOB ZS9+ODptpEUDPhH8n221BuwiQJ3CSmre+Zf+1qCxPScFZnMyNV4dY4vLIoGDserBHl7ahRkoA JtG+rCP/iYmCM27Xpju4eKMMvRBqfKgordJIJWl/rrStvc7C0A= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Fri, 17 Nov 2017 09:43:55 +0100 * The script "checkpatch.pl" pointed information out like the following. ERROR: do not use assignment in if condition Thus fix affected source code places. * Replace the specification of two data structures by pointer dereferences as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- sound/pci/riptide/riptide.c | 53 ++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index 44f3b48d47b1..22d15ea7e210 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -1564,10 +1564,12 @@ 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, - snd_dma_pci_data(chip->pci), - sizeof(struct sgd) * (DESC_MAX_MASK + 1), - sgdlist)) < 0) { + + err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, + snd_dma_pci_data(chip->pci), + 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; @@ -1695,11 +1697,10 @@ static const struct snd_pcm_ops snd_riptide_capture_ops = { static int snd_riptide_pcm(struct snd_riptide *chip, int device) { struct snd_pcm *pcm; - int err; + int err = snd_pcm_new(chip->card, "RIPTIDE", device, + PLAYBACK_SUBSTREAMS, 1, &pcm); - if ((err = - snd_pcm_new(chip->card, "RIPTIDE", device, PLAYBACK_SUBSTREAMS, 1, - &pcm)) < 0) + if (err < 0) return err; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_riptide_playback_ops); @@ -1786,14 +1787,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(*cif), 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) { @@ -1817,7 +1820,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); @@ -1850,9 +1854,12 @@ 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(*chip), GFP_KERNEL); + if (!chip) return -ENOMEM; spin_lock_init(&chip->lock); @@ -1866,8 +1873,8 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci, chip->cif = NULL; tasklet_init(&chip->riptide_tq, riptide_handleirq, (unsigned long)chip); - 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); @@ -1887,12 +1894,14 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci, chip->irq = pci->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; } @@ -1922,7 +1931,9 @@ 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, @@ -1994,12 +2005,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; } -- 2.15.0