Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2939628imw; Wed, 6 Jul 2022 14:30:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s2JyY827z23952UNjypEB+fIEQ+WKwg3/SQGdUkQ3umRzwUXqfkqP+Ax5IzthvTkZ61Nqt X-Received: by 2002:a17:907:6d8b:b0:72a:b3bc:2ab2 with SMTP id sb11-20020a1709076d8b00b0072ab3bc2ab2mr23797532ejc.67.1657143046025; Wed, 06 Jul 2022 14:30:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657143046; cv=none; d=google.com; s=arc-20160816; b=VpeB9JVwAbqeZbq18gHD/fslHTE9yMPmfzwYDnBEP0A07SyH80NZM5Qp+F9ktjHfRy YzXNbLPDpQSzoG2P0w9iLe3S2dI3c3LzG1XOnHJDjojGHzqblVf/GC+jAii8DSLkiA84 xQEdnbBokLQKlHPpL0dIeAKDkuQUZlsp+Q2Dl5c2WdaAbvGoppZcX+x7h38Wy4g+mbWW aNJrukGcfQBruHn4tBGA9oYLxVqEn+4S9mKeJajxUR8k/n6fs6Hc8YPk7SQdE/09P+9f wnzDpquJk7DD7v3bg3QVGc9qUmRtSMAIQz7V00YoMncjB7jmb3WshbpXGEHcEI42uNKh Vg+A== 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=lvGXj3ls7TV90GptpGG1jLpCJVEsDU4cCv/CoE+6bpM=; b=ts1tkN5IXdunDeJYH3Dq5dzO/4NDo8xoIovm8MYlpuWUn/VBlWCSMbSbjxN2r2+RJJ UhQXrRORA7ZkQsXLtcK4YuSnHfbR+ug1c4BtNt6e1+iHBc8kriXcFdpoHdI+9+Oyj2wn i5KQf7nKZLrYKe6M+N0/sTNwRbqPuxUZm+BdN2V18BIj/+KAmTKmmvYELaKyiXSqd8Tm T9ry+BFzhO3hAgFPG22P8oVVrPbVEtADd0F+5pHqhz6IcJXvBIk2UmUrLY2owRO9F7c/ VB+/ECNCg4LpgGEglehiQwWJMa8+h/g3fhyE7uDX1TzWxj8wpqegHc/m5HWLSxqtkeJV HLNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=krbHqmBR; 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 ot15-20020a170906cccf00b00725ea31cfbfsi16237404ejb.406.2022.07.06.14.30.20; Wed, 06 Jul 2022 14:30:46 -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=krbHqmBR; 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 S234605AbiGFVM5 (ORCPT + 99 others); Wed, 6 Jul 2022 17:12:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234558AbiGFVMt (ORCPT ); Wed, 6 Jul 2022 17:12:49 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFF08D129; Wed, 6 Jul 2022 14:12:48 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id n4so9886515ejz.10; Wed, 06 Jul 2022 14:12:48 -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=lvGXj3ls7TV90GptpGG1jLpCJVEsDU4cCv/CoE+6bpM=; b=krbHqmBRYekWzAlAtpO7sBN1ST+0G/8miKAo7OHmnIWBpNlinUrotSvvT1yBHIz7YZ OyA0CScteMVUjoIYc46Nonj3i80xglBJ6e+iyHV6uvOdKNYDlOhNUl+WnjJiwGbFFCxh z4t6U2R1AecTXan3+SfE7tpGRpqIJm6FfEWSnhdOnKS3f03WV5e5Jz3aEjJ2r0ovXzO2 HAT5CoieAPJbEzTrdWLBOAAre8VodDEtdXeYkqWMdq1SK01rx400RfpXfIGc1mZ4Vqua LRW3/AqfZgF0KSC7VpEQxfBIjTEQc3zjvjgWv7vkfjQt+UeSYixIPe26dxRUW2BKr60E VoAA== 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=lvGXj3ls7TV90GptpGG1jLpCJVEsDU4cCv/CoE+6bpM=; b=LNNuhQQ0BNRd1H+uEp3VetzH1Z9ecM4//8ae3V0nT4oCf3YEqveWJPsL1IA6zcti4/ NOq/rnfMVkZfAWXPlEdbxtOOgKJMEZ6MwgP/qpNSjQasaqkkhOXPcKSgW4ic3sAE3PVJ 2quxZH3X7bRXtJ1HlnGHS3lFOMW/KeHs8RU8x3+6/mIf2Nty6WIDa8/2a2iU010SuvOI sbWEta8EQ3ZmTTHlKAuA7CjP7jfVMH8whsRhstQ/cfZYbJmcHoGnA4lVktKO5zpn+6X7 4xriuXqbZhdJWKnRXPdkhH2ujQD8YCWnoZgtVoxwGyAddp2XeO5U94dIBVUuGHkGKxEy zq/g== X-Gm-Message-State: AJIora98E1swG5ttfDz1LG3uFlUh2QdM/6jFZj2f2FoXyFVY1vAYWu4y KmbiQ4uIEXreV+DjSbqFj8A= X-Received: by 2002:a17:906:149b:b0:726:2968:e32a with SMTP id x27-20020a170906149b00b007262968e32amr42064953ejc.71.1657141967428; Wed, 06 Jul 2022 14:12:47 -0700 (PDT) Received: from localhost (92.40.202.8.threembb.co.uk. [92.40.202.8]) by smtp.gmail.com with ESMTPSA id q17-20020a17090676d100b007121b22b376sm2164813ejn.105.2022.07.06.14.12.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 14:12:46 -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 06/11] ASoC: jz4740-i2s: Use FIELD_PREP() macros in hw_params callback Date: Wed, 6 Jul 2022 22:13:25 +0100 Message-Id: <20220706211330.120198-7-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20220706211330.120198-1-aidanmacdonald.0x0@gmail.com> References: <20220706211330.120198-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. 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 8bb9449d13d3..3c3cf78bf848 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 @@ -49,8 +50,8 @@ #define JZ4760_AIC_CONF_FIFO_RX_THRESHOLD_OFFSET 24 #define JZ4760_AIC_CONF_FIFO_TX_THRESHOLD_OFFSET 16 -#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) @@ -65,9 +66,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) @@ -245,8 +243,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 @@ -254,8 +253,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