Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp842949pxb; Thu, 17 Feb 2022 16:21:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJyE4OM8vpDV8KlemCaNGqpt50G9ZprVicRgLf5h0moDj98X2BSE3UgzBkbgm9BMLoy1ZOKI X-Received: by 2002:a17:90b:1104:b0:1b8:b90b:22c7 with SMTP id gi4-20020a17090b110400b001b8b90b22c7mr5661753pjb.45.1645143677178; Thu, 17 Feb 2022 16:21:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645143677; cv=none; d=google.com; s=arc-20160816; b=breREO1Lx8Ykz/yFAtMket37G4J9ueuDz0XavPzIq0aiDLngGS7wq6mJPom9jQ+QX7 smb+qy9TuSw1dSbGVE/CcL73Pz33VfnWLcYGlz4BPu7Anw1e7S9aOV02m5iyShAn0+3Z IhAbyHyO4ucVmj5ok+VTvBsOn99hp/wikSz51q4ApkP4cxzAiD6vnwpw1L240vqBzzhh A3x8EZa94FMxAQZ1uquz9QWcec0QKOz9KUQ4FlPxeOHTl4bI01M1J+QPlhfmfbemL/OX UmYrmXlvagluJQ0AffjbOaL/IsCj4zro1Fz0M/o0O/9Vj1p7ZP1OIBTvP0yDYSwJyIST jWiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:user-agent:from :references:in-reply-to:mime-version:dkim-signature; bh=3wvP+CouT5s7ckbu1I32aqEIyb+Q3SaOSxhlymVyShY=; b=O/rzG4ZLaHIvQWzqTbhc7VAVKoGuet5A4w9xrLdGu0amAzOp90UeCa3ksWQx6cy8ds /m2NJJJqQxAJ+B7OzNHcSLAJ+KMXUHMvVYwt5vwYyPrd2ZUnE6NcGKUKS11RR0RWITq5 j3hjhZfIXdxvAWWZBFPqO4K1LxHT0T+uzUe2IGAIyI/sSiwVJdA1gGoyriAHYedNXnPf Xz7rNRAMmU1mdy4ZFLcqqiJPn4zsfzQSAbNJshnBnJCBRAP3hrE2iSciCB+Fbp3e+UGq ZqdgGo57r61qGPzfKhms1f+OvNHriBjbCarjqfzSsauxP2yUcKCz4lMrA1ND2x03Jgx0 3YfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JYLlipsv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n7si24256084plc.206.2022.02.17.16.21.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 16:21:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JYLlipsv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C871436C57D; Thu, 17 Feb 2022 15:44:57 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243128AbiBQTl3 (ORCPT + 99 others); Thu, 17 Feb 2022 14:41:29 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:57606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239204AbiBQTl0 (ORCPT ); Thu, 17 Feb 2022 14:41:26 -0500 Received: from mail-oo1-xc2b.google.com (mail-oo1-xc2b.google.com [IPv6:2607:f8b0:4864:20::c2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAB0A11109A for ; Thu, 17 Feb 2022 11:41:10 -0800 (PST) Received: by mail-oo1-xc2b.google.com with SMTP id o128-20020a4a4486000000b003181707ed40so812228ooa.11 for ; Thu, 17 Feb 2022 11:41:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:user-agent:date:message-id :subject:to:cc; bh=3wvP+CouT5s7ckbu1I32aqEIyb+Q3SaOSxhlymVyShY=; b=JYLlipsvhfV7sqXYVa9saWxp8b9zR4ENVos6xsFloI664t0SttD4jiRU6dK7Qx9iEt S61i1/8tNV3jUM9VR3ZG7wp64r5V9E5vQnsZaBANQYM82bvxAaQ8ox9L1jtOsfI5rKNU GTeaDejUOd6Xe6Z2bxX5z5J05qs9XflVLniFE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:in-reply-to:references:from :user-agent:date:message-id:subject:to:cc; bh=3wvP+CouT5s7ckbu1I32aqEIyb+Q3SaOSxhlymVyShY=; b=fwr5lQ5odhQvcAuj/XtN5TwaXgIPxYw3fjPHyH6IPdcs2knlF3zo2Psj4Fh8CXZLUd hmE/1UwLv2B8ZWtHOM1G0LPs5jXw8W98iBswgzszWmiJI5hY5QhZW1X6/8OMwC2nz2SE vDuQuWGNxZn7pnnOl8MJQap2RO3iUtPFFkgL8qfqCgomaD+u1G5WsVAeG81pK4CYVWpN dLzJ52fQMkjH8tBns/8MsMjm0UkrXs/w7Qni9Vqh15FRE1H9T5QunZpr14HU/MAx/KOr UTTwq69s/fpVbiIV/DypLPaqZq6wQ1UECrPwexywjj8rgQyLE8+OshoLe/Ra9mw5SaGf MURg== X-Gm-Message-State: AOAM530wbRtZ7VJeAwfe1nrq8c7LW6IoNDHRav00P7OJaLFKWapZ9RST l8CCxrm7Ak07jkOZANTOlI/VQ4BZ5EehA3cOG/pKMA== X-Received: by 2002:a4a:d58b:0:b0:319:8746:ac3e with SMTP id z11-20020a4ad58b000000b003198746ac3emr1291325oos.1.1645126868547; Thu, 17 Feb 2022 11:41:08 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Thu, 17 Feb 2022 11:41:08 -0800 MIME-Version: 1.0 In-Reply-To: <13007276-c827-0cc4-5db1-396c5184bb35@quicinc.com> References: <1644850708-11099-1-git-send-email-quic_srivasam@quicinc.com> <1644850708-11099-5-git-send-email-quic_srivasam@quicinc.com> <13007276-c827-0cc4-5db1-396c5184bb35@quicinc.com> From: Stephen Boyd User-Agent: alot/0.10 Date: Thu, 17 Feb 2022 11:41:08 -0800 Message-ID: Subject: Re: [RESEND v13 04/10] ASoC: qcom: Add helper function to get dma control and lpaif handle To: Srinivasa Rao Mandadapu , agross@kernel.org, alsa-devel@alsa-project.org, bgoswami@codeaurora.org, bjorn.andersson@linaro.org, broonie@kernel.org, devicetree@vger.kernel.org, judyhsiao@chromium.org, lgirdwood@gmail.com, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, perex@perex.cz, quic_plai@quicinc.com, robh+dt@kernel.org, rohitkr@codeaurora.org, srinivas.kandagatla@linaro.org, tiwai@suse.com Cc: Venkata Prasad Potturu Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Quoting Srinivasa Rao Mandadapu (2022-02-15 21:11:29) > > On 2/15/2022 6:40 AM, Stephen Boyd wrote: > Thanks for your time Stephen!!! > > Quoting Srinivasa Rao Mandadapu (2022-02-14 06:58:22) > >> Add support function to get dma control and lpaif handle to avoid > >> repeated code in platform driver > >> > >> Signed-off-by: Srinivasa Rao Mandadapu > >> Co-developed-by: Venkata Prasad Potturu > >> Signed-off-by: Venkata Prasad Potturu > >> Reviewed-by: Srinivas Kandagatla > >> --- > >> sound/soc/qcom/lpass-platform.c | 113 +++++++++++++++++++++++----------------- > >> 1 file changed, 66 insertions(+), 47 deletions(-) > >> > >> diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c > >> index a44162c..5d77240 100644 > >> --- a/sound/soc/qcom/lpass-platform.c > >> +++ b/sound/soc/qcom/lpass-platform.c > >> @@ -177,6 +177,49 @@ static int lpass_platform_pcmops_close(struct snd_soc_component *component, > >> return 0; > >> } > >> > >> +static void __lpass_get_lpaif_handle(struct snd_pcm_substream *substream, > > const? > Okay. will add const to substream pointer. > > > >> + struct snd_soc_component *component, > > const? > Here const is giving compilation errors in below code. Ok > > > >> + l_id = pcm_data->dma_ch; > >> + l_dmactl = drvdata->rd_dmactl; > >> + } else { > >> + l_dmactl = drvdata->wr_dmactl; > >> + l_id = pcm_data->dma_ch - v->wrdma_channel_start; > >> + } > >> + l_map = drvdata->lpaif_map; > >> + break; > >> + case LPASS_DP_RX: > >> + l_id = pcm_data->dma_ch; > >> + l_dmactl = drvdata->hdmi_rd_dmactl; > >> + l_map = drvdata->hdmiif_map; > >> + break; > >> + default: > >> + break; > >> + } > >> + if (dmactl) > >> + *dmactl = l_dmactl; > >> + if (id) > >> + *id = l_id; > >> + if (map) > >> + *map = l_map; > > Why not 'return 0' here and return -EINVAL in the default case above? Then > > we can skip the checks for !map or !dmactl below and simply bail out if > > it failed with an error value. > > Here the check is for input params. some users call for only damctl or > only map. Yes the check is to make sure there's a pointer to store the value into. I get that. The users are all internal to this driver though because the function is static. If the function returned an error because it couldn't find something then we wouldn't have to test the resulting pointers for success, instead we could check for a return value. Similarly, it may be clearer to have a single get for each item and then return a pointer from the function vs. passing it in to extract something. It may duplicate some code but otherwise the code would be clearer because we're getting one thing and can pass an error value through the pointer with PTR_ERR().