Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5400720imw; Wed, 20 Jul 2022 05:09:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ttxARcivbfMYULJS8mHnQ1qRfLqkMsiWMwFjqGumqi2Yp4JcCeFkkTng6G9MRlhesJ7rBM X-Received: by 2002:a05:6870:390c:b0:10d:4691:7ba2 with SMTP id b12-20020a056870390c00b0010d46917ba2mr2193183oap.160.1658318984971; Wed, 20 Jul 2022 05:09:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658318984; cv=none; d=google.com; s=arc-20160816; b=RF8cie6gJCADZ4l+eScmB+yD+w71nqw3rq8AJqpXgYZJVPLYDRfmZGheiINgxeZj3e vbIgqZYVyuiz7JzfqC8MiCf1PF0MLsFDSY3xoZbXU/uyiYbcadz2IUDCUGR+0+LEcvEB lvnLU5Di7H4AFoZK1EUu8ifkHkJPWnLM6o1dn+gQD+rvgaRkmkHuHvp7B6EBi3XCCXdS F7vXhHdeZtqTODSjVS7atunvhmdkLvuWxflH0sqBI5MQLxgpZvWyvD3t4KZGwdrit8eZ 5adbBzSLt1EHYMWv3dmzPyHYyCsoBlxA9qDI8INwqv+/Veq1YXtkNwdMvzFQf2XPeu1F Egrw== 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:cc:to:subject:from:date :dkim-signature; bh=RquTbtLtwFfQ9inCLk4Ulpomsb9JpjXW2cXEGm/uxE4=; b=LyaMfYlCcBDrZkHzhyH2PRz4+yOLwNqAQlXSJ9zeB6kjfzJe3weCshsZjwwy0qbBMJ Tz4R1Y4R+ZHGR/hssjsqH1fynO+FwVB2UZQbUJFilfMdskpMRcaNEgHXJLSLzg6NlQqm HJw5gpY5YechPjOS+fe3zqpDiNWonmnEecTrF7AEZGhWPPBJ6tMmACThnHWysgYbiNmq ZQiNGsDq4d9AFR5IRuRVNqF+fUTNZPEObjhb5cW86kueTaeqcSKT5xRno+WB1QVduxgo qyhA7Zislzl9kJR56keqjJG0zvPdMr6W4G0e3BVHAE5wVekFPa3K08L3YUuxAniuavRa b7vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=wsNEIB16; 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=crapouillou.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z128-20020aca3386000000b00337edf9a967si13318803oiz.113.2022.07.20.05.09.31; Wed, 20 Jul 2022 05:09:44 -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=@crapouillou.net header.s=mail header.b=wsNEIB16; 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=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237488AbiGTLwr (ORCPT + 99 others); Wed, 20 Jul 2022 07:52:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229490AbiGTLwq (ORCPT ); Wed, 20 Jul 2022 07:52:46 -0400 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DB5257E20; Wed, 20 Jul 2022 04:52:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1658317963; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RquTbtLtwFfQ9inCLk4Ulpomsb9JpjXW2cXEGm/uxE4=; b=wsNEIB169o1MRcAZxhjwv8ptH4fid4sU4el1kqmI0/g3slTw2idUGaNG7VYj6nhO+hqvvy Nd6FWw3fGS4z+2+MiZBhQ+A6I/etNY2Kkc614HPoIi/zxiurGsQmnVJrYvXpkrr/9oyUWy uPU7gx+RvNRaThAkPx9Pj3h4asQa+jE= Date: Wed, 20 Jul 2022 12:52:34 +0100 From: Paul Cercueil Subject: Re: [PATCH v4 05/11] ASoC: jz4740-i2s: Use FIELD_PREP() macros in hw_params callback To: Aidan MacDonald Cc: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, linux-mips@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Message-Id: In-Reply-To: <20220708160244.21933-6-aidanmacdonald.0x0@gmail.com> References: <20220708160244.21933-1-aidanmacdonald.0x0@gmail.com> <20220708160244.21933-6-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable 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_PASS,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 Hi Aidan, Le ven., juil. 8 2022 at 17:02:38 +0100, Aidan MacDonald=20 a =E9crit : > Get rid of a couple of macros and improve readability by using > FIELD_PREP() and GENMASK() for the sample size setting. >=20 > Acked-by: Paul Cercueil > Signed-off-by: Aidan MacDonald Reviewed-by: Paul Cercueil Cheers, -Paul > --- > sound/soc/jz4740/jz4740-i2s.c | 17 ++++++++--------- > 1 file changed, 8 insertions(+), 9 deletions(-) >=20 > diff --git a/sound/soc/jz4740/jz4740-i2s.c=20 > b/sound/soc/jz4740/jz4740-i2s.c > index 043f100a9cfa..d0791dfa9c7b 100644 > --- a/sound/soc/jz4740/jz4740-i2s.c > +++ b/sound/soc/jz4740/jz4740-i2s.c > @@ -3,6 +3,7 @@ > * Copyright (C) 2010, Lars-Peter Clausen > */ >=20 > +#include > #include > #include > #include > @@ -42,8 +43,8 @@ > #define JZ_AIC_CONF_SYNC_CLK_MASTER BIT(1) > #define JZ_AIC_CONF_ENABLE BIT(0) >=20 > -#define JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_MASK (0x7 << 19) > -#define JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_MASK (0x7 << 16) > +#define JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE GENMASK(21, 19) > +#define JZ_AIC_CTRL_INPUT_SAMPLE_SIZE GENMASK(18, 16) > #define JZ_AIC_CTRL_ENABLE_RX_DMA BIT(15) > #define JZ_AIC_CTRL_ENABLE_TX_DMA BIT(14) > #define JZ_AIC_CTRL_MONO_TO_STEREO BIT(11) > @@ -61,9 +62,6 @@ > #define JZ4760_AIC_CTRL_TFLUSH BIT(8) > #define JZ4760_AIC_CTRL_RFLUSH BIT(7) >=20 > -#define JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_OFFSET 19 > -#define JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_OFFSET 16 > - > #define JZ_AIC_I2S_FMT_DISABLE_BIT_CLK BIT(12) > #define JZ_AIC_I2S_FMT_DISABLE_BIT_ICLK BIT(13) > #define JZ_AIC_I2S_FMT_ENABLE_SYS_CLK BIT(4) > @@ -248,8 +246,9 @@ static int jz4740_i2s_hw_params(struct=20 > snd_pcm_substream *substream, > } >=20 > if (substream->stream =3D=3D SNDRV_PCM_STREAM_PLAYBACK) { > - ctrl &=3D ~JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_MASK; > - ctrl |=3D sample_size << JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_OFFSET; > + ctrl &=3D ~JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE; > + ctrl |=3D FIELD_PREP(JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE, sample_size); > + > if (params_channels(params) =3D=3D 1) > ctrl |=3D JZ_AIC_CTRL_MONO_TO_STEREO; > else > @@ -257,8 +256,8 @@ static int jz4740_i2s_hw_params(struct=20 > snd_pcm_substream *substream, >=20 > div_field =3D i2s->field_i2sdiv_playback; > } else { > - ctrl &=3D ~JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_MASK; > - ctrl |=3D sample_size << JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_OFFSET; > + ctrl &=3D ~JZ_AIC_CTRL_INPUT_SAMPLE_SIZE; > + ctrl |=3D FIELD_PREP(JZ_AIC_CTRL_INPUT_SAMPLE_SIZE, sample_size); >=20 > div_field =3D i2s->field_i2sdiv_capture; > } > -- > 2.35.1 >=20