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.3 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,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 63818C433E0 for ; Tue, 4 Aug 2020 08:16:00 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (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 007D12076E for ; Tue, 4 Aug 2020 08:15:59 +0000 (UTC) Authentication-Results: mail.kernel.org; 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 007D12076E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4BLSHx4ksMzDqWZ for ; Tue, 4 Aug 2020 18:15:57 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::642; helo=mail-pl1-x642.google.com; envelope-from=nicoleotsuka@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=DYdif+vR; dkim-atps=neutral Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4BLSFY4VBtzDqB3 for ; Tue, 4 Aug 2020 18:13:50 +1000 (AEST) Received: by mail-pl1-x642.google.com with SMTP id r4so11790506pls.2 for ; Tue, 04 Aug 2020 01:13:50 -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=I3u/+QtLSpt30gunMIV+HBtBCAXhq9w7M1kBA8KC6OqFQSJUTOh5cavnDReyD7SZDK cdADHdnCXyP3tSk1GJ4+NEO0E7aZaKJKfHKO3Jj9HeU750nPAztSxUfN4EJKrbe2IF1Y pzupll4Quijsu6yy51Vj86H0klgKRgoVt7wuzfeHwAGNt0KjSaOdjQHooEWESJ4rzmCI ez0QBIib8EuCMKwCQBlnlcH3ItanEhAfg+cgU1E7ujWa9kyQyB+ZmBEpJj/IwEiVYL6T MGy6Iq0xUOrQIJKGeyRXkHfkVpR3uDQp2MXPe7R1Ouj6Mfo+bCfI5S8v6fsw66nI13QM QVtQ== X-Gm-Message-State: AOAM532zg5VYJ1pZOqa2uHC0zw/hY/UNSLacng0Xqvc5YqAcJkUv3Uvi D+twrF4y7wBrL7vowLFeGvU= 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) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linux-ALSA , Timur Tabi , Xiubo Li , Fabio Estevam , Shengjiu Wang , Takashi Iwai , Liam Girdwood , Mark Brown , linuxppc-dev@lists.ozlabs.org, linux-kernel Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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.