Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2726802imm; Tue, 4 Sep 2018 09:03:30 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZU5ASgS4W8j9ipK6aNKXMLGUNox+G2pGEycF2izX3qy+CP8LjrMakAu1H1vKVeRLk2Nw3L X-Received: by 2002:a63:b914:: with SMTP id z20-v6mr32031337pge.396.1536077010725; Tue, 04 Sep 2018 09:03:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536077010; cv=none; d=google.com; s=arc-20160816; b=VwnuZ9JFrQIglbkCU749rkrcwreobAdWL6LvT+ZMiRjEzkvzxVVOR0ezCrBBDl5zo6 9KKgqPZNEBI5Goz0gEinoCiDwAi4DW4cY7uCFlSmBM7/Dpg9yGrrIYPMfsbCrx6gdAE7 fWEterEJxq0Jlsbz5nPBEZo39eKukHHaxcoTD+T6LxOE8Y2MWEBInazvrBdlbgaGA2oP G8t4HeSCJBdCtjxGFXR9OuLxKqQDc/J6vb2mHHRg594uHVbAVyngL20jb2AN1DRhCDco m9euJkyAcnpeZQcsq1gtaQx+AOk0zFyIa8cBJXClmN5tfbyNfoizeBWXGGZMetHI0e87 OwOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=AMS/3x50ORCol7Ca4sLGpRWkJGgVeyTDsTYptvEZPdc=; b=qHWE4fKjurNlUPq621xXBCCU9Wh2+GBH4yPrTufUDjIsJr7mGMa/Xd270T21MEii+v V7mDh0NF4Q+LUVW2ZTz9QbYxH4jQkru59rv2tnCjCb2aJuyHOF8n71MS56xDXPgCfO4N TYQchsSFEmxI4w8kh6wS58TLyB4iLd8bYvs1n744A9TlxBL6sonUxu31/sln6/nY3ATz h1N/2kIe64Z1ILK+nV97CgqdYtRBDRl2rc7sB2lf3wC17y1DF/v+Gon1B4N7J6wXWVQz h2jRzVjHNj/uZpI4hUQCh0d6EUyhwgmzbWJM3uTexLB6T7SyBCBjGLGR2bTZT6dR5lSV QTvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b124-v6si1652046pgc.620.2018.09.04.09.03.05; Tue, 04 Sep 2018 09:03:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727758AbeIDUYs (ORCPT + 99 others); Tue, 4 Sep 2018 16:24:48 -0400 Received: from mx2.suse.de ([195.135.220.15]:50802 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726961AbeIDUYr (ORCPT ); Tue, 4 Sep 2018 16:24:47 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C0D3FB0A0; Tue, 4 Sep 2018 15:59:01 +0000 (UTC) From: Takashi Iwai To: Greg Kroah-Hartman Cc: Eric Anholt , Stefan Wahren , linux-rpi-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/29] staging: bcm2835-audio: Remove redundant substream mask checks Date: Tue, 4 Sep 2018 17:58:33 +0200 Message-Id: <20180904155858.8001-5-tiwai@suse.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180904155858.8001-1-tiwai@suse.de> References: <20180904155858.8001-1-tiwai@suse.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The avail_substreams bit mask is checked for the possible racy accesses, but this cannot happen in practice; i.e. the assignment and the check are superfluous. Let's rip them off. Signed-off-by: Takashi Iwai --- .../vc04_services/bcm2835-audio/bcm2835-ctl.c | 2 -- .../vc04_services/bcm2835-audio/bcm2835-pcm.c | 8 -------- .../vc04_services/bcm2835-audio/bcm2835-vchiq.c | 17 +++++++---------- .../vc04_services/bcm2835-audio/bcm2835.c | 5 +---- .../vc04_services/bcm2835-audio/bcm2835.h | 2 -- 5 files changed, 8 insertions(+), 26 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c index 1c5a87580978..d2f0f609f737 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c @@ -64,8 +64,6 @@ static int snd_bcm2835_ctl_get(struct snd_kcontrol *kcontrol, mutex_lock(&chip->audio_mutex); - BUG_ON(!chip && !(chip->avail_substreams & AVAIL_SUBSTREAMS_MASK)); - if (kcontrol->private_value == PCM_PLAYBACK_VOLUME) ucontrol->value.integer.value[0] = chip2alsa(chip->volume); else if (kcontrol->private_value == PCM_PLAYBACK_MUTE) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c index f2d8b17d0cfe..0be185350f33 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c @@ -118,14 +118,6 @@ static int snd_bcm2835_playback_open_generic( goto out; } - /* Check if we are ready */ - if (!(chip->avail_substreams & (1 << idx))) { - /* We are not ready yet */ - audio_error("substream(%d) device is not ready yet\n", idx); - err = -EAGAIN; - goto out; - } - alsa_stream = kzalloc(sizeof(*alsa_stream), GFP_KERNEL); if (!alsa_stream) { err = -ENOMEM; diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index bec361aff4fe..942a38942c29 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -523,16 +523,13 @@ int bcm2835_audio_set_ctls(struct bcm2835_chip *chip) /* change ctls for all substreams */ for (i = 0; i < MAX_SUBSTREAMS; i++) { - if (chip->avail_substreams & (1 << i)) { - if (!chip->alsa_stream[i]) { - LOG_DBG(" No ALSA stream available?! %i:%p (%x)\n", i, chip->alsa_stream[i], chip->avail_substreams); - ret = 0; - } else if (bcm2835_audio_set_ctls_chan(chip->alsa_stream[i], chip) != 0) { - LOG_ERR("Couldn't set the controls for stream %d\n", i); - ret = -1; - } else { - LOG_DBG(" Controls set for stream %d\n", i); - } + if (!chip->alsa_stream[i]) + continue; + if (bcm2835_audio_set_ctls_chan(chip->alsa_stream[i], chip) != 0) { + LOG_ERR("Couldn't set the controls for stream %d\n", i); + ret = -1; + } else { + LOG_DBG(" Controls set for stream %d\n", i); } } return ret; diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c index fa04f6bc9858..6876a5eadc07 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c @@ -280,7 +280,7 @@ static int snd_add_child_device(struct device *device, struct snd_card *card; struct device *child; struct bcm2835_chip *chip; - int err, i; + int err; child = snd_create_device(device, &audio_driver->driver, audio_driver->driver.name); @@ -325,9 +325,6 @@ static int snd_add_child_device(struct device *device, return err; } - for (i = 0; i < numchans; i++) - chip->avail_substreams |= (1 << i); - err = snd_card_register(card); if (err) { dev_err(child, "Failed to register card, error %d\n", err); diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h index 5dc427240a1d..c0e7df4914ed 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h @@ -98,8 +98,6 @@ struct bcm2835_chip { struct snd_card *card; struct snd_pcm *pcm; struct snd_pcm *pcm_spdif; - /* Bitmat for valid reg_base and irq numbers */ - unsigned int avail_substreams; struct device *dev; struct bcm2835_alsa_stream *alsa_stream[MAX_SUBSTREAMS]; -- 2.18.0