From patchwork Thu Oct 27 09:57:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Povi=C5=A1er?= X-Patchwork-Id: 11707 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp136995wru; Thu, 27 Oct 2022 03:01:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ron0oOwBTMHwpvgCWiTEv5WCg8hTIYBEMEOD1piTZKzB02I/fb96qSRxrvaAjRdP/F5cx X-Received: by 2002:a05:6402:5107:b0:462:3014:3d73 with SMTP id m7-20020a056402510700b0046230143d73mr10541499edd.177.1666864898212; Thu, 27 Oct 2022 03:01:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666864898; cv=none; d=google.com; s=arc-20160816; b=WpJf3ywM99XKZTPDFSYrZIftBX2Xrtk2RRCKNbveL3LVUW8d6fOa8/QP9pMOTRYVX7 w528JCq/mhhn3PQKliIZtkbc47Dw+g8NPt2NwPX+SBuItz5bRvvP98/3RMMm5T0Xwq+g WYBOu4Yp5h73JWnGSyF1yIFN5p35fGIrnqpUhdja3HH3mWdr+lzuUuMOTLRF8R5vOuj2 u/U67AwmeuRCdpHnEeM6EWi/bh5kJ8oo4zq7uH8jJyiJUuhkRn6CEpSLBpFCgVa3Nn0S a7/JpGFt1KKZgX7A0E1iJMAY7iHN6RaRVcdZr64mzD7NyybGKRCJfz4/MpwdZHyxoZJ/ R43A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:dkim-signature:from; bh=v+OR8wmZOIyovuDfyWeiLKf+QGSEMk6EcfThh0NrItQ=; b=iYyB4IMCFWrBwcFcNfi8exHGv5/IIZXdydiBfJv38lp1Ngz4jPI/Wzj5rMu5YadR4g FwAWVZGhV0lf63AuEq7j5WEpzYjaP0BNm+OV6ZBZisCozbo0lRe1U6Vhv2FuRfJU03mv a+byRcG/RhYedxSjswK07W9fPeHHemlxozwP69Ae3tpKt5oVHSSqz4lASaYnPG9uwLv2 puuCUOqeCT04LKL3mFYljwN5YySUG8ZGtSS+xMvgXMQQxyTjdiOgpg6bI7sagl9FEYi+ YuTSYXH/3yFEFjD8b6WJ256IjeXCxxSsk0OHKaw3eyMmmSzafafeF9YqI9THh+8Azzeq sxsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cutebit.org header.s=mail header.b=PDjj5tIH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cutebit.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt16-20020a170907729000b0077d26491a9csi1049472ejc.141.2022.10.27.03.01.13; Thu, 27 Oct 2022 03:01:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cutebit.org header.s=mail header.b=PDjj5tIH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cutebit.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234375AbiJ0KAG (ORCPT + 99 others); Thu, 27 Oct 2022 06:00:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234838AbiJ0J7Z (ORCPT ); Thu, 27 Oct 2022 05:59:25 -0400 Received: from hutie.ust.cz (hutie.ust.cz [185.8.165.127]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 961B196203 for ; Thu, 27 Oct 2022 02:58:47 -0700 (PDT) From: =?utf-8?q?Martin_Povi=C5=A1er?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cutebit.org; s=mail; t=1666864724; bh=v+OR8wmZOIyovuDfyWeiLKf+QGSEMk6EcfThh0NrItQ=; h=From:To:Cc:Subject:Date; b=PDjj5tIHERq38p5UkEbRwLtCxradDm2f7h9sxBb6AvbPSwVitnC3JaaFdhg+3wiwO VEe+GFIhFHI1ltppU24s4MkjJhNb1lW56ZBGVInqqHXRjwfPcYZd9IdS7ZDW8loYqB 1V3cWumqiXT2Bs9EO7gbLbZ2JfzeOd+vMmbinbcs= To: Liam Girdwood , Mark Brown Cc: Stephen Kitt , Raphael-Xu <13691752556@139.com>, Frank Shi , shenghao-ding@ti.com, kevin-lu@ti.com, Jos Dehaes , alsa-devel@alsa-project.org, asahi@lists.linux.dev, linux-kernel@vger.kernel.org, =?utf-8?q?Martin_Povi?= =?utf-8?q?=C5=A1er?= Subject: [PATCH 1/3] ASoC: tas2770: Fix set_tdm_slot in case of single slot Date: Thu, 27 Oct 2022 11:57:58 +0200 Message-Id: <20221027095800.16094-1-povik+lin@cutebit.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747834527350084089?= X-GMAIL-MSGID: =?utf-8?q?1747834527350084089?= There's a special branch in the set_tdm_slot op for the case of nslots being 1, but: (1) That branch can never work (there's a check for tx_mask being non-zero, later there's another check for it *being* zero; one or the other always throws -EINVAL). (2) The intention of the branch seems to be what the general other branch reduces to in case of nslots being 1. For those reasons remove the 'nslots being 1' special case. Fixes: 1a476abc723e ("tas2770: add tas2770 smart PA kernel driver") Suggested-by: Jos Dehaes Signed-off-by: Martin Povišer --- sound/soc/codecs/tas2770.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/sound/soc/codecs/tas2770.c b/sound/soc/codecs/tas2770.c index b6765235a4b3..8557759acb1f 100644 --- a/sound/soc/codecs/tas2770.c +++ b/sound/soc/codecs/tas2770.c @@ -395,21 +395,13 @@ static int tas2770_set_dai_tdm_slot(struct snd_soc_dai *dai, if (tx_mask == 0 || rx_mask != 0) return -EINVAL; - if (slots == 1) { - if (tx_mask != 1) - return -EINVAL; - - left_slot = 0; - right_slot = 0; + left_slot = __ffs(tx_mask); + tx_mask &= ~(1 << left_slot); + if (tx_mask == 0) { + right_slot = left_slot; } else { - left_slot = __ffs(tx_mask); - tx_mask &= ~(1 << left_slot); - if (tx_mask == 0) { - right_slot = left_slot; - } else { - right_slot = __ffs(tx_mask); - tx_mask &= ~(1 << right_slot); - } + right_slot = __ffs(tx_mask); + tx_mask &= ~(1 << right_slot); } if (tx_mask != 0 || left_slot >= slots || right_slot >= slots) From patchwork Thu Oct 27 09:57:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Povi=C5=A1er?= X-Patchwork-Id: 11706 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp136969wru; Thu, 27 Oct 2022 03:01:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7MFnDG3iyLDxfHqgEvJHT7i7PXQP/PREcuy16T6IN+bcQ+g5ukq5ZNhtbo2UR5Eh3A2X13 X-Received: by 2002:a17:906:fe46:b0:73d:939a:ec99 with SMTP id wz6-20020a170906fe4600b0073d939aec99mr41902134ejb.169.1666864885567; Thu, 27 Oct 2022 03:01:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666864885; cv=none; d=google.com; s=arc-20160816; b=ylebEnApmfLEaQ5Tge8fMnOxNQL7GcYGNdWnCdbq7CcgTnsLWyXCxICaPqj1T623V/ yhAnFVB+jIpERRsNhttgY1UT0+mbbrvrPSlt5Kc2h6ziARjL4FKBVPUcVgVvO+ZcA2/S lW1wUp65YvPy3qhn1sgOEF6AhWFzfuyjBm+Gx/edSuJoiZ7iBr93Yubllt0+LgQl2nnn IT6DUCFV/BeK9hTHF4bbE7VQf5g7Tn6HA9GrMqZLrLZax1YulSLtCKDVZ2xveX1WA4Zv Nrkwt7lLP+o0CKOJ3LlqX0bkY0PCkKPBgUwVNwv9Whl0b38VsQ5kSHAmTFFeMYlK2bVy 7Z4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :from; bh=zafY4n3noNNCOhqBie7L/wTVrWC4g1SUal4WI4ax48o=; b=Emqz3eehJPx4s1XC4VtBk+OSQGw6mgxLA0AAVkIawiHfxvZPzDc/3WVZ8BXxoO1gJl k5Wxs8mY8qA2i70rCF86r8TOivur2HQ1C8rHQlBE6V8rtvuvS3mJJKPQyit0WdYA3INN cMN1L3gscAz5k/H6V9hz0vzT1skP8iinFAqAhiENKmbPYPNomeUTlWOWpIBlFeU9ZvIp LmBsMrEbd4lJUUG/xnlsQh8w+TNEOQef/K8XiSxYIH3eEuL5RrJK6C1PU0nC3y3ExId5 6/mD72HkVU2xpY+GLMfqYbIJVCUsjCP4QBPmBStkaLpCeL9+nFIbm8g9EsoQr3dzxMd0 xfDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cutebit.org header.s=mail header.b="kLA41O/W"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cutebit.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb37-20020a1709071ca500b0078217f3a033si363003ejc.652.2022.10.27.03.00.59; Thu, 27 Oct 2022 03:01:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cutebit.org header.s=mail header.b="kLA41O/W"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cutebit.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233166AbiJ0KAC (ORCPT + 99 others); Thu, 27 Oct 2022 06:00:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235001AbiJ0J7Z (ORCPT ); Thu, 27 Oct 2022 05:59:25 -0400 Received: from hutie.ust.cz (unknown [IPv6:2a03:3b40:fe:f0::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6D1CF6C1C for ; Thu, 27 Oct 2022 02:58:47 -0700 (PDT) From: =?utf-8?q?Martin_Povi=C5=A1er?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cutebit.org; s=mail; t=1666864724; bh=zafY4n3noNNCOhqBie7L/wTVrWC4g1SUal4WI4ax48o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kLA41O/WnlKOz+9do3+r5DrO19XcLsdxQ8iPXqdXw3FRvu9sSjESMw7zzz0golJvW f+6ejAdTY7J4q2hK5u77BJOe2IV0fli1G5A4ycL5ZA4w8G+oZtVf/Axxqs9W2yzdyk IghoOdn/L/mDoZgNxMBqmS0OYS1xnff9vWHuL7Ow= To: Liam Girdwood , Mark Brown Cc: Stephen Kitt , Raphael-Xu <13691752556@139.com>, Frank Shi , shenghao-ding@ti.com, kevin-lu@ti.com, Jos Dehaes , alsa-devel@alsa-project.org, asahi@lists.linux.dev, linux-kernel@vger.kernel.org, =?utf-8?q?Martin_Povi?= =?utf-8?q?=C5=A1er?= Subject: [PATCH 2/3] ASoC: tas2764: Fix set_tdm_slot in case of single slot Date: Thu, 27 Oct 2022 11:57:59 +0200 Message-Id: <20221027095800.16094-2-povik+lin@cutebit.org> In-Reply-To: <20221027095800.16094-1-povik+lin@cutebit.org> References: <20221027095800.16094-1-povik+lin@cutebit.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_FAIL,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747834513919026768?= X-GMAIL-MSGID: =?utf-8?q?1747834513919026768?= There's a special branch in the set_tdm_slot op for the case of nslots being 1, but: (1) That branch can never work (there's a check for tx_mask being non-zero, later there's another check for it *being* zero; one or the other always throws -EINVAL). (2) The intention of the branch seems to be what the general other branch reduces to in case of nslots being 1. For those reasons remove the 'nslots being 1' special case. Fixes: 827ed8a0fa50 ("ASoC: tas2764: Add the driver for the TAS2764") Suggested-by: Jos Dehaes Signed-off-by: Martin Povišer --- sound/soc/codecs/tas2764.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/sound/soc/codecs/tas2764.c b/sound/soc/codecs/tas2764.c index 51b87a936179..2e0ed3e68fa5 100644 --- a/sound/soc/codecs/tas2764.c +++ b/sound/soc/codecs/tas2764.c @@ -438,20 +438,13 @@ static int tas2764_set_dai_tdm_slot(struct snd_soc_dai *dai, if (tx_mask == 0 || rx_mask != 0) return -EINVAL; - if (slots == 1) { - if (tx_mask != 1) - return -EINVAL; - left_slot = 0; - right_slot = 0; + left_slot = __ffs(tx_mask); + tx_mask &= ~(1 << left_slot); + if (tx_mask == 0) { + right_slot = left_slot; } else { - left_slot = __ffs(tx_mask); - tx_mask &= ~(1 << left_slot); - if (tx_mask == 0) { - right_slot = left_slot; - } else { - right_slot = __ffs(tx_mask); - tx_mask &= ~(1 << right_slot); - } + right_slot = __ffs(tx_mask); + tx_mask &= ~(1 << right_slot); } if (tx_mask != 0 || left_slot >= slots || right_slot >= slots) From patchwork Thu Oct 27 09:58:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Povi=C5=A1er?= X-Patchwork-Id: 11708 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp137223wru; Thu, 27 Oct 2022 03:02:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4SeIMZuGXReaUXsL8EzgCupDb69+OdkuP1E0UPeox7/ibwvc9ahNh/kwobVy10EFHTQiQ1 X-Received: by 2002:a17:907:802:b0:781:8017:b2df with SMTP id wv2-20020a170907080200b007818017b2dfmr41282884ejb.606.1666864920813; Thu, 27 Oct 2022 03:02:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666864920; cv=none; d=google.com; s=arc-20160816; b=xcQ+NWKY+T2DOH5kGDTMbv+HerBckLhwQYjTt1oVvygyNB9wAOEjVtQZqZN/AEzWBF sG1Xrn23nJJUK7EAj+V7mD+6uXcK584tE20GRTn/n5gUrP08KZpzd7YwdVerSg09nnc5 lPwYXXfavFMuXIOuoswu57xNPHhJpq7vqKkJzS0GbfXTESrpkZqpofnXejdx2+9JSmOz kX/xar7hlFVDOf9qi1wgFinOkfPHEv8lyPxLvr/CegcMgt+1DaxhPDgymS8lpIoIvQqe yFMaUlMCfGDrJg2t3GpA6bNIUzjqB6Ueune0XQjYx9pjr87sxLCRj+7Oar5gbpRLGRGZ cWrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :from; bh=2Fc+yisSwfIomFrwc/B3SPRno9UwMqdBRdReCF0H+cU=; b=dspkAesd8DbFD6gTW1FYDMAy2r2SFp9ZKyyibYZH6jFQqIBz5VP8ZtY+Q01ID0afHH dD+TMDyhRZC2mvrrGLlwqWcfneoEZjqGHTO5Y45NPkHB1cSWHwwgI/Kk9EZFUn1NL9ez 2aCyQsvt85kSCBtKBtmx1Jv7mx7J4iUajgm5l8awOyGzEuOvvfl5WQR1dc4m7O86pfJD bgLhb1XOR6zBfMmGPzdbYzpL66zhVtFJ87pOXqZ1lnm8o3mgjK80S9rnsud8F4udktYh gB/hFUz3UxrH5olU+EqiMSjARhvBI2WSUZSSGkUj6x7j8mIvWJoFme9wOTL4oiQNZg95 nyRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cutebit.org header.s=mail header.b=Yy6o+PYY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cutebit.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w21-20020a170906385500b007ad7a46a4b7si908039ejc.454.2022.10.27.03.01.36; Thu, 27 Oct 2022 03:02:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cutebit.org header.s=mail header.b=Yy6o+PYY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cutebit.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235154AbiJ0KAP (ORCPT + 99 others); Thu, 27 Oct 2022 06:00:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234997AbiJ0J7Z (ORCPT ); Thu, 27 Oct 2022 05:59:25 -0400 Received: from hutie.ust.cz (hutie.ust.cz [185.8.165.127]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 966DCA6C03 for ; Thu, 27 Oct 2022 02:58:47 -0700 (PDT) From: =?utf-8?q?Martin_Povi=C5=A1er?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cutebit.org; s=mail; t=1666864725; bh=2Fc+yisSwfIomFrwc/B3SPRno9UwMqdBRdReCF0H+cU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Yy6o+PYYi8oZ3I31rDpzKVL1SdeZHBdl66Nya8PTgGaSZ2vLqtl7m/cMeLkAJax9D PbuJVZB1unK+byWC+IIfwqpKvHFngT9LrP3fUn1yg7iZI0Zp5SE1TLjvRg+KjjUQbp Ej4kzqEICrdFpaX+62ZM3M0BMCKzpdGTfZqKwS3I= To: Liam Girdwood , Mark Brown Cc: Stephen Kitt , Raphael-Xu <13691752556@139.com>, Frank Shi , shenghao-ding@ti.com, kevin-lu@ti.com, Jos Dehaes , alsa-devel@alsa-project.org, asahi@lists.linux.dev, linux-kernel@vger.kernel.org, =?utf-8?q?Martin_Povi?= =?utf-8?q?=C5=A1er?= Subject: [PATCH 3/3] ASoC: tas2780: Fix set_tdm_slot in case of single slot Date: Thu, 27 Oct 2022 11:58:00 +0200 Message-Id: <20221027095800.16094-3-povik+lin@cutebit.org> In-Reply-To: <20221027095800.16094-1-povik+lin@cutebit.org> References: <20221027095800.16094-1-povik+lin@cutebit.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747834551014170290?= X-GMAIL-MSGID: =?utf-8?q?1747834551014170290?= There's a special branch in the set_tdm_slot op for the case of nslots being 1, but: (1) That branch can never work (there's a check for tx_mask being non-zero, later there's another check for it *being* zero; one or the other always throws -EINVAL). (2) The intention of the branch seems to be what the general other branch reduces to in case of nslots being 1. For those reasons remove the 'nslots being 1' special case. Fixes: eae9f9ce181b ("ASoC: add tas2780 driver") Suggested-by: Jos Dehaes Signed-off-by: Martin Povišer --- sound/soc/codecs/tas2780.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/sound/soc/codecs/tas2780.c b/sound/soc/codecs/tas2780.c index a6db6f0e5431..afdf0c863aa1 100644 --- a/sound/soc/codecs/tas2780.c +++ b/sound/soc/codecs/tas2780.c @@ -380,20 +380,13 @@ static int tas2780_set_dai_tdm_slot(struct snd_soc_dai *dai, if (tx_mask == 0 || rx_mask != 0) return -EINVAL; - if (slots == 1) { - if (tx_mask != 1) - return -EINVAL; - left_slot = 0; - right_slot = 0; + left_slot = __ffs(tx_mask); + tx_mask &= ~(1 << left_slot); + if (tx_mask == 0) { + right_slot = left_slot; } else { - left_slot = __ffs(tx_mask); - tx_mask &= ~(1 << left_slot); - if (tx_mask == 0) { - right_slot = left_slot; - } else { - right_slot = __ffs(tx_mask); - tx_mask &= ~(1 << right_slot); - } + right_slot = __ffs(tx_mask); + tx_mask &= ~(1 << right_slot); } if (tx_mask != 0 || left_slot >= slots || right_slot >= slots)