Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp5551540rwi; Sun, 23 Oct 2022 07:58:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7KufN4Mt54eA3RyuEkaIcgVbH9tbEWCaNjTAV0B1YJvAxRRgoiG75sEZ6WIsCyTjdWU+o1 X-Received: by 2002:a17:906:65c6:b0:73c:8897:65b0 with SMTP id z6-20020a17090665c600b0073c889765b0mr24076105ejn.322.1666537108669; Sun, 23 Oct 2022 07:58:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666537108; cv=none; d=google.com; s=arc-20160816; b=wTwV6EzaWvTd0FNUZZJlyk/vBADrcBFhGGfZk0lgW6F8WHjfrwFsXJfdPNjFxe1GlA yO/RZeV22Sp8yYIbPXLTQLRaisbfAr8jNMoZ59EnQ9xijzi0srZbYlSVpB63K+TO3UcZ 91mMqQhRhTJyPPn5869dnyGQeR0Gqnq26F5t/nkjPWLwJHLFbXXS8YOhwLd1VyAoYbO0 jQYrd8OsIITDjsxZzKHi33n3mwh52+HhNitOxh2ti0MgmATq/uSHqFMb1YsnhoN1OiOH ATSTVOnSr+Im9rNtdCr/0Pv2EBIHalqn0l5+UX1BUn6oUERhv0+BkA6yoF+3Pmv6hjhr 8i0Q== 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=yagE6PfAWV1c7o+BEcxE7EzZidDlQUomGLf1in/WfkM=; b=1ElXbrg1aJDf/sL1QEwM0IhtVW5aNfg4n/j0eBPRDlHEhMW2lw8hKUDtm98oQ2s7O0 1S4bAjkMSEYFyysAVdPOn/I58s5tW+zZ/TZy77NCPgO1trRndDE42AbGZceuVnBWdnfv VIHgKgItraCDriitTKjTEtbweOSnxY0YeXIRQAx05Av9+NO6LbJPin2EEtfUvvah2fp3 gHAHajW/WwMpBRpfvy/i+QSWZsO5fVGidaETiifHxIorRnHFfCrluk0Wwo3gozay0Mcv KUnNzI1xXorw0t8gfvsxcQ7TYF61nocJ0PZDlC3saJzK/kiYpW+vX6Pk/KDGWW0Ct2MW qGsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Zy8H6eKZ; 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 dp14-20020a170906c14e00b00773e2e6f605si25360830ejc.930.2022.10.23.07.57.38; Sun, 23 Oct 2022 07:58:28 -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=Zy8H6eKZ; 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 S229707AbiJWOdo (ORCPT + 99 others); Sun, 23 Oct 2022 10:33:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230216AbiJWOdi (ORCPT ); Sun, 23 Oct 2022 10:33:38 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 143F061B39; Sun, 23 Oct 2022 07:33:37 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id bu30so11848062wrb.8; Sun, 23 Oct 2022 07:33:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yagE6PfAWV1c7o+BEcxE7EzZidDlQUomGLf1in/WfkM=; b=Zy8H6eKZB+FQ4I7VGkb+tY3m9TLER0iULJcO2taPxrxxwuUJaQLZ/wez+a11a5aZCZ sCV/ScsX03su9YQBJwbBw9XCFOnpkeHtDGPqSQ3GVWi02F4V7jFRDkkejzug5nlDOsFq Td1DG19OibxKTK52pcQyysCuqlFz05kzHv0iT7ufJERlUd36HZwQTGRPpgTxS1GrLl8U U+KXZQPew75mQKQ+R0yZ7hiv1/QuePiZI4ol59bRHJ+IXXf8fYMrk/tAQKXns0Zk3IWJ bvWL23Ife3D39mF/Nl+KVWbfUcLIm7GRSY+UcG+AcaTYgHrUYSGwzpFL9nECiQG6mum7 dZTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yagE6PfAWV1c7o+BEcxE7EzZidDlQUomGLf1in/WfkM=; b=gCz8SpKQgJ3NyXutPuCX6YzI+5Xc7Rvjjl5lXNtwRP9jDL+n3QuOuiW9GrakP/TSSv FgdNOhEm/qSZt0SqQfgCMYgI2xdyN0aFL1nk1fe2f2vkYhCaVmNILaG3Aqwa4oQ/Zymj KMb3vwfI34j8esSHDSRgH++G7gpNc0qVwPgySkrVnQvSvoInkMnBOMLjQqpIH2uN2Frj Iz7JF1qt6zAGSh4BCB8tZNG3vslGUY2y9m+/GUNBwiYbI6EjPPYoVudr8TcP4vLgV+v2 H0AuVIBn+f6+rZ0uqNVf3XSxqhEh5mld4dLuXPaPQ+06Tf4t9Ko5zRCmfguUOKGAA5KC 1/nA== X-Gm-Message-State: ACrzQf2JiBTuN1fCmX15W679V2vMBVv2jdP8fVOtbogKCeG1z7byk/3b W7PxOoU+HTVxjnXhJAnd+ew= X-Received: by 2002:a05:6000:50a:b0:225:210c:a7e4 with SMTP id a10-20020a056000050a00b00225210ca7e4mr18207884wrf.704.1666535616636; Sun, 23 Oct 2022 07:33:36 -0700 (PDT) Received: from localhost (94.197.10.75.threembb.co.uk. [94.197.10.75]) by smtp.gmail.com with ESMTPSA id c17-20020a5d4cd1000000b002362f6fcaf5sm2925381wrt.48.2022.10.23.07.33.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 07:33:36 -0700 (PDT) From: Aidan MacDonald To: paul@crapouillou.net, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com Cc: zhouyu@wanyeetech.com, linux-mips@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 4/9] ASoC: jz4740-i2s: Use FIELD_PREP() macros in hw_params callback Date: Sun, 23 Oct 2022 15:33:23 +0100 Message-Id: <20221023143328.160866-5-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20221023143328.160866-1-aidanmacdonald.0x0@gmail.com> References: <20221023143328.160866-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 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 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 Reviewed-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 b0bbcd025241..4767abea425f 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) @@ -59,9 +60,6 @@ #define JZ_AIC_CTRL_ENABLE_PLAYBACK BIT(1) #define JZ_AIC_CTRL_ENABLE_CAPTURE BIT(0) -#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) @@ -249,8 +247,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 @@ -258,8 +257,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.38.1