From patchwork Wed Mar 8 10:58:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Flax X-Patchwork-Id: 9610817 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9E74C6016C for ; Wed, 8 Mar 2017 11:00:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A7A928567 for ; Wed, 8 Mar 2017 11:00:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8ECF928576; Wed, 8 Mar 2017 11:00:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B7352856F for ; Wed, 8 Mar 2017 11:00:02 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 2AF232669C4; Wed, 8 Mar 2017 11:59:56 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id CBE37266A3F; Wed, 8 Mar 2017 11:59:54 +0100 (CET) Received: from nsstlmta02p.bpe.bigpond.com (nsstlmta02p.bpe.bigpond.com [203.38.21.2]) by alsa0.perex.cz (Postfix) with ESMTP id 3A4D526697F for ; Wed, 8 Mar 2017 11:59:49 +0100 (CET) Received: from smtp.telstra.com ([10.10.24.4]) by nsstlfep02p-svc.bpe.nexus.telstra.com.au with ESMTP id <20170308105945.NNUW31190.nsstlfep02p-svc.bpe.nexus.telstra.com.au@smtp.telstra.com>; Wed, 8 Mar 2017 21:59:45 +1100 X-RG-Spam: Unknown X-Junkmail-Premium-Raw: score=28/50, refid=2.7.2:2017.3.8.95115:17:28.905, ip=124.190.105.82, rules=__HAS_FROM, __TO_MALFORMED_2, __TO_NO_NAME, __TO_NAME, __TO_NAME_DIFF_FROM_ACC, __MULTIPLE_RCPTS_TO_X5, __HAS_CC_HDR, __CC_NAME, __CC_NAME_DIFF_FROM_ACC, __SUBJ_ALPHA_END, __HAS_MSGID, __SANE_MSGID, __HAS_X_MAILER, __FROM_DOMAIN_IN_ANY_CC1, __ANY_URI, __URI_NO_WWW, __NO_HTML_TAG_RAW, BODY_SIZE_1500_1599, BODYTEXTP_SIZE_3000_LESS, __MIME_TEXT_P1, __MIME_TEXT_ONLY, RDNS_GENERIC_POOLED, __URI_NS, SXL_IP_DYNAMIC[82.105.190.124.fur], HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS, RDNS_SUSP_GENERIC, __FROM_DOMAIN_IN_RCPT, __TO_REAL_NAMES, __CC_REAL_NAMES, MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS, MULTIPLE_RCPTS, BODY_SIZE_2000_LESS, RDNS_SUSP, __MIME_TEXT_P, NO_URI_HTTPS, BODY_SIZE_7000_LESS X-RG-Spam: Unknown X-RG-Spam: Unknown X-RG-Spam: Unknown X-RG-Spam: Unknown X-RG-Spam: Unknown X-RG-Spam: Unknown X-RG-Spam: Unknown X-RG-Spam: Unknown X-RG-Spam: Unknown X-RG-Spam: Unknown X-RG-Spam: Unknown X-RG-Spam: Unknown X-RG-Spam: Unknown X-RG-Spam: Unknown X-RG-Spam: Unknown X-RG-Spam: Unknown Received: from meb (124.190.105.82) by smtp.telstra.com (9.0.019.11-1) id 58AB9A9305595FD5; Wed, 8 Mar 2017 21:59:45 +1100 Received: from monstilationax2 ([192.168.0.51] helo=monstilationax2.telstra.com.au) by meb with esmtp (Exim 4.84_2) (envelope-from ) id 1clZOy-0004j0-VI; Wed, 08 Mar 2017 22:05:05 +1100 From: Matt Flax To: alsa-devel@alsa-project.org, Stephen Warren , Lee Jones , Eric Anholt , linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Florian Meier , broonie@kernel.org, phil@raspberrypi.org, hias@horus.com, ckeepax@opensource.wolfsonmicro.com, florian.kauer@koalo.de, Liam Girdwood , Martin Sperl , Scott Branden , Ray Jui , Florian Fainelli Date: Wed, 8 Mar 2017 21:58:54 +1100 Message-Id: <1488970734-6596-1-git-send-email-flatmax@flatmax.org> X-Mailer: git-send-email 2.7.4 Cc: Matt Flax Subject: [alsa-devel] [PATCH] ASoC: bcm_2835: Simplify mono guard by returning error on mono X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP This patch simplifies the bcm2835_i2s.c code when the driver returns error on mono channel requests. It does this by testing for mono instead of using a switch statement to test for stereo. The bcm2835_i2s driver can only work in stereo mode. Whilst leaving the driver entirel compliant with the I2S protocol, it simplifies the code by removing a few redundant lines of code. Signed-off-by: Matt Flax --- sound/soc/bcm/bcm2835-i2s.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/sound/soc/bcm/bcm2835-i2s.c b/sound/soc/bcm/bcm2835-i2s.c index 6ba2049..1e6a1da 100644 --- a/sound/soc/bcm/bcm2835-i2s.c +++ b/sound/soc/bcm/bcm2835-i2s.c @@ -310,15 +310,16 @@ static int bcm2835_i2s_hw_params(struct snd_pcm_substream *substream, ch1pos = data_delay; ch2pos = bclk_ratio / 2 + data_delay; - switch (params_channels(params)) { - case 2: - format = BCM2835_I2S_CH1(format) | BCM2835_I2S_CH2(format); - format |= BCM2835_I2S_CH1(BCM2835_I2S_CHPOS(ch1pos)); - format |= BCM2835_I2S_CH2(BCM2835_I2S_CHPOS(ch2pos)); - break; - default: + /* C + * Check we aren't setting channel 2 on a mono stream. + * We currently only support stereo + */ + if (params_channels(params) == 1) return -EINVAL; - } + + format = BCM2835_I2S_CH1(format) | BCM2835_I2S_CH2(format); + format |= BCM2835_I2S_CH1(BCM2835_I2S_CHPOS(ch1pos)); + format |= BCM2835_I2S_CH2(BCM2835_I2S_CHPOS(ch2pos)); /* * Set format for both streams.