From mboxrd@z Thu Jan 1 00:00:00 1970 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=-5.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no 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 885C3C433E0 for ; Tue, 4 Aug 2020 08:17:05 +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 3853722B45 for ; Tue, 4 Aug 2020 08:17:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="YK/3va11"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DYdif+vR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3853722B45 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com 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 969B91668; Tue, 4 Aug 2020 10:16:13 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 969B91668 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1596529023; bh=C6Mmq1t0yH3MRwY/GwVOVy5HMKCguTxWUhvV4Sy4Ftc=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=YK/3va11NBQq8NVCbe5oZk9DkYtkmLvironjvQFlxiTl4DReJd6q+jjjhY3aI2+kk 5Z9lSpOFUQuj8Exnw/go16oIzeAFnazV8x6pwL1WN0VIpHEtx+hQOWb95S1t6wzygP 9zBWPl/8JEXuub/09in/ZWy4HJF+EaE8lFJRQWeo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 163ECF8015A; Tue, 4 Aug 2020 10:13:58 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 663FAF8015C; Tue, 4 Aug 2020 10:13:56 +0200 (CEST) Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) (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 A0EC7F80150 for ; Tue, 4 Aug 2020 10:13:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A0EC7F80150 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DYdif+vR" Received: by mail-pj1-x1043.google.com with SMTP id i92so1226333pje.0 for ; Tue, 04 Aug 2020 01:13:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=QTZfG/kR29WZl/QqtrKhHeYkzxPgGUcbCVsRoqYuMCg=; b=DYdif+vRQ34VCrII1rcRURMIr1UR4eoarWbg2ONWRx2uRCdkqrY/8JzU46Oa5nbfS1 uzfdNROpnO06HKpLdfpbuCQ6FGlq1Q5agZp+uGKZ5nqXoP26nuPN6pGHOUvRcoyQ5bfG Qx/B/rXOjGtqaGu/9kKoQQZm1SZEHot04BYIN3+aFdQAblXL7A87TG51b8LtSNB5EETn /UOZrqg0fsXd/BPGQy1t9OVN/S/GLvcqnKP5beN4UKBBmJY+KZhj5C/MnD9to9XjnKka UQ5K8pRSkK4hmoSUUGWd4okRUmae3379DE7RgP2SDmoISUxFqIE48oXwWhe4UDm+zj0M HtvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=QTZfG/kR29WZl/QqtrKhHeYkzxPgGUcbCVsRoqYuMCg=; b=ohLALKkK9ahsoSB9c8jLP90FPZRUUEcweA42IfYg1uCU4B/gqb5jS2F4EhJOQtWk6A E64kUNzBsWhfnd7qqscE8D7iJsDSUSt3+VtVulkUOS+Pk6kXQV5umcE/zYSy2/uLmjEN RQAHI/Wm+lat+xOW0qzFIiVTrDGMfCrGnWWugvcLCZtBGp6NvquKfMgDsd7J/NFxbEJd syuMSXJrQ9dv43lmfB41eCP7/DsNVW2gVDj6rPnVgoPxowhUSZCVKRTvubXqAIiOWjY5 uX5cSVn1oiDKaRzlam+Cpc+5F0c1tuRujqRckcfA3rv5OLorkf3wMojZWOFgruuqVkKs V/4w== X-Gm-Message-State: AOAM532BGp7TOf4VnJ0FJ8gdtKt2nQyurYmJIk2BZVuHeRlZjGmT1+Mk iqGLJTLHXKhtXMsMbzChabA= X-Google-Smtp-Source: ABdhPJz+uClNx0qLTPNR0v0kaWetuL5qHIA7MjIEAIYLOMnWp36caMp4FKmFAUV7cMJ+CR83l1o0Dg== X-Received: by 2002:a17:90b:c90:: with SMTP id o16mr3081175pjz.79.1596528827041; Tue, 04 Aug 2020 01:13:47 -0700 (PDT) Received: from Asurada-Nvidia (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id c10sm18237720pfc.62.2020.08.04.01.13.46 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Aug 2020 01:13:46 -0700 (PDT) Date: Tue, 4 Aug 2020 01:13:34 -0700 From: Nicolin Chen To: Shengjiu Wang Subject: Re: [PATCH] ASoC: fsl_sai: Clean code for synchronize mode Message-ID: <20200804081333.GA664@Asurada-Nvidia> References: <20200803215735.GA5461@Asurada-Nvidia> <20200804021114.GA15390@Asurada-Nvidia> <20200804030004.GA27028@Asurada-Nvidia> <20200804070345.GA27658@Asurada-Nvidia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Cc: Linux-ALSA , Timur Tabi , Xiubo Li , Fabio Estevam , Shengjiu Wang , Takashi Iwai , Liam Girdwood , Mark Brown , linuxppc-dev@lists.ozlabs.org, linux-kernel 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" On Tue, Aug 04, 2020 at 03:53:51PM +0800, Shengjiu Wang wrote: > > > /* Check if the opposite FRDE is also disabled */ > > > regmap_read(sai->regmap, FSL_SAI_xCSR(!tx, ofs), &xcsr); > > > + if (sai->synchronous[tx] && !sai->synchronous[!tx] && !(xcsr & FSL_SAI_CSR_FRDE)) > > > + fsl_sai_config_disable(sai, !tx); > > > > > + if (sai->synchronous[tx] || !sai->synchronous[!tx] || !(xcsr & FSL_SAI_CSR_FRDE)) > > > + fsl_sai_config_disable(sai, tx); > > > > The first "||" should probably be "&&". > > No. it is !(!sai->synchronous[tx] && sai->synchronous[!tx] && (xcsr & > FSL_SAI_CSR_FRDE)) > so then convert to > (sai->synchronous[tx] || !sai->synchronous[!tx] || !(xcsr & FSL_SAI_CSR_FRDE)) > > if change to &&, then it won't work for: > sai->synchronous[tx] = false, sai->synchronous[!tx]=false. Ahh..probably should be if (!(sync[dir] && !sync[adir]) || !frde) I have a (seemingly) correct version in my sample code. And...please untangle the logic using the given example -- adding helper function(s) and comments. And, though the driver does have places using array[tx] and array[!tx], better not to use any more boolean type variable as an array index, as it's hard to read. From mboxrd@z Thu Jan 1 00:00:00 1970 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=-5.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no 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 3816FC433E1 for ; Tue, 4 Aug 2020 08:13:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3FC032076E for ; Tue, 4 Aug 2020 08:13:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DYdif+vR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729606AbgHDINt (ORCPT ); Tue, 4 Aug 2020 04:13:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726201AbgHDINr (ORCPT ); Tue, 4 Aug 2020 04:13:47 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4811C06174A for ; Tue, 4 Aug 2020 01:13:47 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id d1so22411717plr.8 for ; Tue, 04 Aug 2020 01:13:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=QTZfG/kR29WZl/QqtrKhHeYkzxPgGUcbCVsRoqYuMCg=; b=DYdif+vRQ34VCrII1rcRURMIr1UR4eoarWbg2ONWRx2uRCdkqrY/8JzU46Oa5nbfS1 uzfdNROpnO06HKpLdfpbuCQ6FGlq1Q5agZp+uGKZ5nqXoP26nuPN6pGHOUvRcoyQ5bfG Qx/B/rXOjGtqaGu/9kKoQQZm1SZEHot04BYIN3+aFdQAblXL7A87TG51b8LtSNB5EETn /UOZrqg0fsXd/BPGQy1t9OVN/S/GLvcqnKP5beN4UKBBmJY+KZhj5C/MnD9to9XjnKka UQ5K8pRSkK4hmoSUUGWd4okRUmae3379DE7RgP2SDmoISUxFqIE48oXwWhe4UDm+zj0M HtvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=QTZfG/kR29WZl/QqtrKhHeYkzxPgGUcbCVsRoqYuMCg=; b=cy1SJiMs00eSn+uQSsHAEIleIcAeOViGcjyBsayIBjJvF5eRP6Pj5CfISx04O8dOoH kGh+GAFzpVFikUdJmSgHgjmQ3VAA1wO4xuTp+lqz7ntvVEg808HEmZ2xR+pp74kX/dpW Px9h8fkESWyZqCWgzjuC/Nu3AzxKY+BkDMEkAEpyAbMJ5hkegmCK/6JstQawpX1ELUCC hcAov7LqI7NOmKDhvFr1D0xMUgZoOGklNGFLHBtksx8JDORgICaDyRiR7ZCQrGvWqhlO BjSk0l2u4xdGCmyjQEKQMaw+KhyVM1ukbFFGB9RHdT12BNxZe8XSpPrOYya4NothHWMO MmXA== X-Gm-Message-State: AOAM533WbdPVSOponcfuTCnQ+jCwfU1Fr0Rk7a/QOYC6McYW5jTJUFzV nfQV641lTIh4CdzJ8+/qnzY= X-Google-Smtp-Source: ABdhPJz+uClNx0qLTPNR0v0kaWetuL5qHIA7MjIEAIYLOMnWp36caMp4FKmFAUV7cMJ+CR83l1o0Dg== X-Received: by 2002:a17:90b:c90:: with SMTP id o16mr3081175pjz.79.1596528827041; Tue, 04 Aug 2020 01:13:47 -0700 (PDT) Received: from Asurada-Nvidia (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id c10sm18237720pfc.62.2020.08.04.01.13.46 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Aug 2020 01:13:46 -0700 (PDT) Date: Tue, 4 Aug 2020 01:13:34 -0700 From: Nicolin Chen To: Shengjiu Wang Cc: Shengjiu Wang , Linux-ALSA , Timur Tabi , Xiubo Li , linuxppc-dev@lists.ozlabs.org, Takashi Iwai , Liam Girdwood , Mark Brown , Fabio Estevam , linux-kernel Subject: Re: [PATCH] ASoC: fsl_sai: Clean code for synchronize mode Message-ID: <20200804081333.GA664@Asurada-Nvidia> References: <20200803215735.GA5461@Asurada-Nvidia> <20200804021114.GA15390@Asurada-Nvidia> <20200804030004.GA27028@Asurada-Nvidia> <20200804070345.GA27658@Asurada-Nvidia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 04, 2020 at 03:53:51PM +0800, Shengjiu Wang wrote: > > > /* Check if the opposite FRDE is also disabled */ > > > regmap_read(sai->regmap, FSL_SAI_xCSR(!tx, ofs), &xcsr); > > > + if (sai->synchronous[tx] && !sai->synchronous[!tx] && !(xcsr & FSL_SAI_CSR_FRDE)) > > > + fsl_sai_config_disable(sai, !tx); > > > > > + if (sai->synchronous[tx] || !sai->synchronous[!tx] || !(xcsr & FSL_SAI_CSR_FRDE)) > > > + fsl_sai_config_disable(sai, tx); > > > > The first "||" should probably be "&&". > > No. it is !(!sai->synchronous[tx] && sai->synchronous[!tx] && (xcsr & > FSL_SAI_CSR_FRDE)) > so then convert to > (sai->synchronous[tx] || !sai->synchronous[!tx] || !(xcsr & FSL_SAI_CSR_FRDE)) > > if change to &&, then it won't work for: > sai->synchronous[tx] = false, sai->synchronous[!tx]=false. Ahh..probably should be if (!(sync[dir] && !sync[adir]) || !frde) I have a (seemingly) correct version in my sample code. And...please untangle the logic using the given example -- adding helper function(s) and comments. And, though the driver does have places using array[tx] and array[!tx], better not to use any more boolean type variable as an array index, as it's hard to read.