Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp652983imw; Fri, 8 Jul 2022 09:16:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uVJCGR8hShKKsh/QNZ1zxRels3LIB6GZwnIaVahHaG7mGYFozlUQqXV83HxaxWqgUPsvOG X-Received: by 2002:a05:6402:26cb:b0:436:2173:3f7 with SMTP id x11-20020a05640226cb00b00436217303f7mr5976850edd.61.1657297014587; Fri, 08 Jul 2022 09:16:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657297014; cv=none; d=google.com; s=arc-20160816; b=SCl6l0j7pDDA216aWAjxmQLLzqY12Ebs57gitXKMUCMuiCOJ5cIsjW5J/X+t7wnr6/ zVr+8v1lUItrdvkezjiQsJ2XLO7rIS39p2yHZvllSVFEUUlGfcSvFGek7IWmhWDZ5BU4 ObOXWo/kC/8dgz6+eksEYXzkUdyQ1tOClWIiPCWhuf7xYaJRKS7fZUuoN5hVosNVryeX sUcPTG/Db76bB9NCIyYHFFDzY1dUQyYcuhM/Q66QVH5a9F6zSjCc1zuOsZqfwqKtmUv8 35HQjf2iySBzQvnIUn2NrR7HW3ActCvmjhMls6Se2FuSGGnErghExCAAb6IHyLi5K8kD b6YA== 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:from :dkim-signature; bh=15R8fRtnipOyDZjBwDRNBD+rUnFt8ovWDJg/qvPn+8w=; b=tFSCKV9ZDBv50ZDiD7eva2GsNsRTCKzINvLGQ3oqZAg9xRF1XGGiJKNN7tMTdgaj/c QT2hLAi+pm6+MKn8UTe/oHXrdigM4Q0xvzsSNngoEEzdENKvAoCk6F/hmsP2BHJ/IVz2 90ISxPMXrMse5GqiDybkpn3/tBkifmeDaHt/5d4A/IfburUnb3QflhQ/qSHDxU0IHJ96 J21LDLYfn8eEpauyspeYbaICtJw3B1qhT8rK9nSQNz29KHBOZsNrNRK1xcmgCmC0vKLR Qvu+pDJWbL8Npm3Y+bLBQL8ffw+rnDilN3AeZuOPKFfLd1e0ILCMJiXN3lpd++NQ1SHr VD1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AU6fDPxU; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ht21-20020a170907609500b0072a605a57e9si8339760ejc.329.2022.07.08.09.16.24; Fri, 08 Jul 2022 09:16:54 -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=@gmail.com header.s=20210112 header.b=AU6fDPxU; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238833AbiGHQCe (ORCPT + 99 others); Fri, 8 Jul 2022 12:02:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238972AbiGHQCR (ORCPT ); Fri, 8 Jul 2022 12:02:17 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC8847478B; Fri, 8 Jul 2022 09:02:15 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id g39-20020a05600c4ca700b003a03ac7d540so1407028wmp.3; Fri, 08 Jul 2022 09:02:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=15R8fRtnipOyDZjBwDRNBD+rUnFt8ovWDJg/qvPn+8w=; b=AU6fDPxUlSjzP6uJXV5tHBUw9pKc7/LhdFpHt+DMhFo9HD+Og4hsJb4xn8kJKpTAEb xaUVAFuWx0toFiGLCWyx9tkrItWlO7XNdVnO/nig9V+o5bTMk52mqX4RxFRJGbJJyk+Q OV8nlnIrxBuauL+cae4GpHBu/7RXjJiD9mIvsnZWNstqXIUrvFCfNJUYdOQZqmzz1cJr 8Pec/XaeH1y00WJw2A8DHuK46JRuIcprKcPXSLA2QXBPav5p6BwHZtQCe5jxYeTse37+ O4Y/8rg4Q6LRINqGPc93HX/6lLAyA4G4mcsskaUxj7yHkrdm0Q/OVwxqijL+4B8buD/l batw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=15R8fRtnipOyDZjBwDRNBD+rUnFt8ovWDJg/qvPn+8w=; b=2temSLKU7b1eh9ZaMljkqQNigTaPILeDQNptjZgslmc6ghdeGQUmAdHYeJbBvILAOC 8ZQxEJIcpANjG8xd1XYik2GkEToWXz3JtzxpyFb2wllicDegcNUVYMI3Po0GNBvtiVMt XhvYsBF715rveTX5L77F83b5+uKcoIJrNHP1R7d8d6T74bG0PF5OvY4ALAaw8VT1TjUy unXx6zMygkjtwBdMEmohU7YBc29TnQnP8Zj2sgoPotR4pud66Fu9q5924bdipKvflwjj qw6yDd7qN3+TLJA8G5pwvmPdLRvEV0nz1MSJALZDV5DR41LTAWcqJxJ0GwAkklLZIfzs nx1w== X-Gm-Message-State: AJIora/t1JTIygdIpcKH+2JTWc1A48IuRbqXjSWgLVGOigllJUYQveAk SvqSxtfcRpVVvAAAOA1t0gc= X-Received: by 2002:a05:600c:1d03:b0:3a1:7ab1:8dbe with SMTP id l3-20020a05600c1d0300b003a17ab18dbemr548294wms.202.1657296134342; Fri, 08 Jul 2022 09:02:14 -0700 (PDT) Received: from localhost (92.40.203.144.threembb.co.uk. [92.40.203.144]) by smtp.gmail.com with ESMTPSA id by13-20020a056000098d00b0021b89f8662esm17612309wrb.13.2022.07.08.09.02.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 09:02:13 -0700 (PDT) From: Aidan MacDonald To: paul@crapouillou.net, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com Cc: linux-mips@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 05/11] ASoC: jz4740-i2s: Use FIELD_PREP() macros in hw_params callback Date: Fri, 8 Jul 2022 17:02:38 +0100 Message-Id: <20220708160244.21933-6-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20220708160244.21933-1-aidanmacdonald.0x0@gmail.com> References: <20220708160244.21933-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Get rid of a couple of macros and improve readability by using FIELD_PREP() and GENMASK() for the sample size setting. Acked-by: Paul Cercueil Signed-off-by: Aidan MacDonald --- sound/soc/jz4740/jz4740-i2s.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/sound/soc/jz4740/jz4740-i2s.c 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 */ +#include #include #include #include @@ -42,8 +43,8 @@ #define JZ_AIC_CONF_SYNC_CLK_MASTER BIT(1) #define JZ_AIC_CONF_ENABLE BIT(0) -#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) -#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 snd_pcm_substream *substream, } if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - ctrl &= ~JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_MASK; - ctrl |= sample_size << JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_OFFSET; + ctrl &= ~JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE; + ctrl |= FIELD_PREP(JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE, sample_size); + if (params_channels(params) == 1) ctrl |= JZ_AIC_CTRL_MONO_TO_STEREO; else @@ -257,8 +256,8 @@ static int jz4740_i2s_hw_params(struct snd_pcm_substream *substream, div_field = i2s->field_i2sdiv_playback; } else { - ctrl &= ~JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_MASK; - ctrl |= sample_size << JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_OFFSET; + ctrl &= ~JZ_AIC_CTRL_INPUT_SAMPLE_SIZE; + ctrl |= FIELD_PREP(JZ_AIC_CTRL_INPUT_SAMPLE_SIZE, sample_size); div_field = i2s->field_i2sdiv_capture; } -- 2.35.1