From patchwork Thu Apr 1 04:16:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 413669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52F5DC433ED for ; Thu, 1 Apr 2021 04:20:09 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id BAA0F606A5 for ; Thu, 1 Apr 2021 04:20:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BAA0F606A5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 5901416CA; Thu, 1 Apr 2021 06:19:17 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5901416CA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1617250807; bh=j9l8VV+lzJVUJQAxCepIAHttpttTu0fKQtMNqHplA1I=; h=Date:From:Subject:To:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=oqMTnZlRRZSeB/OPnNMoQ8xRZuGe5teAGxj5NsOJrkVtcnWv/uKZ+xjygNKpnsuRZ Yj5uRdyUSHZb2fcnqZ1s8MtclSZOB/IWXgGghRcvqF+Pf8slUwDCbY8JY5qWInWEU4 m7GFfEUk5bF6LfoxJAYWEZ7ZLVHv5Kq6WOhNnp9w= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 564DEF804E3; Thu, 1 Apr 2021 06:16:33 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2DECEF804E4; Thu, 1 Apr 2021 06:16:32 +0200 (CEST) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id 4DA61F80424 for ; Thu, 1 Apr 2021 06:16:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4DA61F80424 Date: 01 Apr 2021 13:16:28 +0900 X-IronPort-AV: E=Sophos;i="5.81,295,1610377200"; d="scan'208";a="76950174" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 01 Apr 2021 13:16:28 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id DCFCE41860A4; Thu, 1 Apr 2021 13:16:28 +0900 (JST) Message-ID: <87im56od0j.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 10/14] ASoC: simple-card-utils: add simple_props_to_xxx() macro User-Agent: Wanderlust/2.15.9 Emacs/26.3 Mule/6.0 To: Mark Brown In-Reply-To: <87wntmod33.wl-kuninori.morimoto.gx@renesas.com> References: <87wntmod33.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Linux-ALSA 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" From: Kuninori Morimoto We shouldn't use dai_props->cpus/codecs/cpu_dai/codec_dai/codec_conf directly, because these are array to supporting multi CPU/Codec/Platform. This patch adds asoc_link_to_xxx() macro for it. Signed-off-by: Kuninori Morimoto --- include/sound/simple_card_utils.h | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index e366e432c475..78b6cf0194d2 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -74,32 +74,45 @@ struct asoc_simple_priv { #define simple_priv_to_dev(priv) (simple_priv_to_card(priv)->dev) #define simple_priv_to_link(priv, i) (simple_priv_to_card(priv)->dai_link + (i)) +#define simple_props_to_dlc_cpu(props, i) ((props)->cpus + i) +#define simple_props_to_dlc_codec(props, i) ((props)->codecs + i) +#define simple_props_to_dlc_platform(props, i) ((props)->platforms + i) + +#define simple_props_to_dai_cpu(props, i) ((props)->cpu_dai + i) +#define simple_props_to_dai_codec(props, i) ((props)->codec_dai + i) +#define simple_props_to_codec_conf(props, i) ((props)->codec_conf + i) + #define for_each_prop_dlc_cpus(props, i, cpu) \ for ((i) = 0; \ - ((i) < (props)->num.cpus) && ((cpu) = &(props)->cpus[i]); \ + ((i) < (props)->num.cpus) && \ + ((cpu) = simple_props_to_dlc_cpu(props, i)); \ (i)++) -#define for_each_prop_dlc_codecs(props, i, codec) \ +#define for_each_prop_dlc_codecs(props, i, codec) \ for ((i) = 0; \ - ((i) < (props)->num.codecs) && ((codec) = &(props)->codecs[i]); \ + ((i) < (props)->num.codecs) && \ + ((codec) = simple_props_to_dlc_codec(props, i)); \ (i)++) #define for_each_prop_dlc_platforms(props, i, platform) \ for ((i) = 0; \ - ((i) < (props)->num.platforms) && ((platform) = &(props)->platforms[i]); \ + ((i) < (props)->num.platforms) && \ + ((platform) = simple_props_to_dlc_platform(props, i)); \ (i)++) #define for_each_prop_codec_conf(props, i, conf) \ for ((i) = 0; \ ((i) < (props)->num.codecs) && \ (props)->codec_conf && \ - ((conf) = &(props)->codec_conf[i]); \ + ((conf) = simple_props_to_codec_conf(props, i)); \ (i)++) #define for_each_prop_dai_cpu(props, i, cpu) \ for ((i) = 0; \ - ((i) < (props)->num.cpus) && ((cpu) = &(props)->cpu_dai[i]); \ + ((i) < (props)->num.cpus) && \ + ((cpu) = simple_props_to_dai_cpu(props, i)); \ (i)++) #define for_each_prop_dai_codec(props, i, codec) \ for ((i) = 0; \ - ((i) < (props)->num.codecs) && ((codec) = &(props)->codec_dai[i]); \ + ((i) < (props)->num.codecs) && \ + ((codec) = simple_props_to_dai_codec(props, i)); \ (i)++) struct link_info {