Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id F2521C433F5 for ; Thu, 6 Jan 2022 12:43:28 +0000 (UTC) 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 1C86B1904; Thu, 6 Jan 2022 13:42:37 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1C86B1904 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1641473007; bh=wT/ZPqBkBaMheLCzIx+SiOVsTngrky5n/j5QT5DX82c=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=sjT3ML548dV03P9K16wDmQPiVCb6Eg1WLmWHYFwQpHpVWi/hS31WnHs0h0pQ6yIf1 RrrJC5onyTTKTaOzKRkhrIYuWmwEPJhF2C1YK/hvJCOrojh4idkCFYzXRC5Q4PvewL YPY23thmwIhYwsE/XPAv5wdipyaYpURhyNI4W2Z0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 612B6F80161; Thu, 6 Jan 2022 13:42:27 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 09848F80163; Thu, 6 Jan 2022 13:42:26 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 82F7FF80161 for ; Thu, 6 Jan 2022 13:42:20 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 82F7FF80161 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="caimkpIu" Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0B250B82104; Thu, 6 Jan 2022 12:42:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FBF0C36AE3; Thu, 6 Jan 2022 12:42:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1641472934; bh=wT/ZPqBkBaMheLCzIx+SiOVsTngrky5n/j5QT5DX82c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=caimkpIutlOCoOP0CBzGK2XgIeJfzboEd4LqeVnp7jNJcEXCDMB/KR/eALG7IT/Jr 7iQushwNOrobePTMmrh70Rr/UxU8+KYSOxZTAf7qJakQbJ6dd4eB0zwq38kJDk6aqs Txtu336IEPAFyGtQXppZQ0kfv3Izy7l/xFQ+Tl+JRr9z3GkTQGLMoAF/r01GOlnrpM MOyFxS4xGAZ7mcBtikjzPUOclZitvxPZ7RMmtmURpuUbsaLK85a/VuwKt4k2HirPwO hhLd63V4wBRr0At++gIkpmsVLvxGyQCmfiSLPt9gaB1N1tnezf6zi8Gt0JjdW+N0IG 1qfg6ziAN6oXg== Date: Thu, 6 Jan 2022 12:42:09 +0000 From: Mark Brown To: Robert Hancock Subject: Re: [PATCH 3/5] ASoC: xilinx: xlnx_i2s.c: Handle sysclk setting Message-ID: References: <20220105225146.3517039-1-robert.hancock@calian.com> <20220105225146.3517039-4-robert.hancock@calian.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="pehtLVQtJEeR8N3c" Content-Disposition: inline In-Reply-To: <20220105225146.3517039-4-robert.hancock@calian.com> X-Cookie: I think we're in trouble. Cc: alsa-devel@alsa-project.org, kuninori.morimoto.gx@renesas.com, michal.simek@xilinx.com, maruthi.srinivas.bayyavarapu@xilinx.com, tiwai@suse.com 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" --pehtLVQtJEeR8N3c Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jan 05, 2022 at 04:51:44PM -0600, Robert Hancock wrote: > + unsigned int last_sysclk; Same naming issue. > + if (drv_data->last_sysclk) { > + unsigned int bits_per_sample =3D drv_data->is_32bit_lrclk ? > + 32 : drv_data->data_width; Please write normal conditional statements, it improves legibility. > + unsigned int sclk =3D params_rate(params) * bits_per_sample * > + params_channels(params); snd_soc_params_to_bclk(). > + unsigned int sclk_div =3D DIV_ROUND_CLOSEST(drv_data->last_sysclk, scl= k) / 2; Same issue with _ROUND_CLOSEST() > + > + if (!sclk_div || (sclk_div & ~I2S_I2STIM_VALID_MASK)) { > + dev_warn(i2s_dai->dev, "invalid SCLK divisor for sysclk %u and sclk %= u\n", > + drv_data->last_sysclk, sclk); > + return -EINVAL; > + } This indicates that we should be setting some constraints on sample rate based on sysclk. > + writel(sclk_div, drv_data->base + I2S_I2STIM_OFFSET); > + } Does the device actually support operation without knowing the sysclk? > @@ -56,18 +90,18 @@ static int xlnx_i2s_hw_params(struct snd_pcm_substrea= m *substream, > static int xlnx_i2s_trigger(struct snd_pcm_substream *substream, int cmd, > struct snd_soc_dai *i2s_dai) > { > - void __iomem *base =3D snd_soc_dai_get_drvdata(i2s_dai); > + struct xlnx_i2s_drv_data *drv_data =3D snd_soc_dai_get_drvdata(i2s_dai); > =20 > switch (cmd) { > case SNDRV_PCM_TRIGGER_START: > case SNDRV_PCM_TRIGGER_RESUME: > case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: > - writel(1, base + I2S_CORE_CTRL_OFFSET); > + writel(I2S_CORE_CTRL_ENABLE, drv_data->base + I2S_CORE_CTRL_OFFSET); > break; > case SNDRV_PCM_TRIGGER_STOP: > case SNDRV_PCM_TRIGGER_SUSPEND: > case SNDRV_PCM_TRIGGER_PAUSE_PUSH: > - writel(0, base + I2S_CORE_CTRL_OFFSET); > + writel(0, drv_data->base + I2S_CORE_CTRL_OFFSET); > break; Please split the change to have a struct for driver data out into a separate change, it's a large reformatting and is big enough to justify it - more of the diff is that than the change described in the changelog which doesn't mention this at all. --pehtLVQtJEeR8N3c Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmHW46AACgkQJNaLcl1U h9AKyAf+LqvHZw9x6iS4JqwAQS2C1VkjpCr80QreCvyk1FPpJJbXxqZECJQGFCEE ewMJzdW3/wJrwqQBV1WUjf4cKfpJv4znf+etaDrUqD42vEgplv/AeLX8wn+dhC79 GmAJXjSqlPMhsz/I8oJLlC0VQ4PVUAh4je6IZPYFdaDjQeiBw7OSeFYFFEosgLND Ng8XhTmlBEvoIqCosp0ml4+LtQMbM1CYz5CkfKj/39Za7n3zTg3aOnQ2z1rXZc7g kBwbP5EVrYmqPC6wFAx5DQSoB2Zt057CkR5Jn9yJvEYlpaSSVR9vyG7x/BGCHltV ejwVbEixJoOfBsrc3TP6/+Y1YJxy8g== =7CG0 -----END PGP SIGNATURE----- --pehtLVQtJEeR8N3c--