Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3618212pxb; Mon, 21 Feb 2022 01:59:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBG8ZFb8q748AjZNWirRfH1sIwCvs93/MRo9tfjYbF6oOk7OIiEc3ksqPf/HC4UjAvOTVM X-Received: by 2002:a17:902:ccc8:b0:14e:e89c:c688 with SMTP id z8-20020a170902ccc800b0014ee89cc688mr18350576ple.121.1645437544796; Mon, 21 Feb 2022 01:59:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645437544; cv=none; d=google.com; s=arc-20160816; b=VPbAwpu4QPaxqrMtnO+aGQvxoUrmvYk1FYN/eb3DhXwZDYVoWwC2imnWoFoorJc2cD /+uSX5ZzPTql7gAo/PNgsSEwVJIt13jUKmfsvB/5WHmNNm8jbraH1UxyGIWcVY6RMQKo 5zA2pnAJD4L3oSc2BTzbg/6uilDPZd9f2+7e9gOip+6ZuPCscSvI+svgdmlXg9QJAf6Q erz04k3UMUTcb9UEN0Fc12Wo3g7sBub10U3N0/cPPLCCkkz/W3115RffSa117XjyBPAJ DPOTXevx3ctSmxatu69TNIyi5wGnKe7pF+70cz/zB0F1x0gnNSqe1Q7HNlCe0idLOwGk ukmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=5v+5eGF0fWqQFfqO8WRWVTuzMoPWbF2CAaKbG/Q1V5s=; b=NRipCZqPQpCLZKXVdgh5S5QsPhN3zOdehxpq71c5mF9luMQJCF7RhJrNPldWIeGdsV 3j//rJNBh/wdnni3tUyeloS2njgMCmeMNsD0Xd5/BwbhP1h+f19yogq08yAC+4dXDkMi GS53XvK94Fb47mtdO3jCrvoOahiMpZvH03bfS+ORDM+iPabBh01KYeLVYIAhxJNfbbFM mrxXV90p0kvlIO24JAorF6C5FksfVDIR4hDeSDaUQPbMNvSqjWCoiKMwuD4xHki3drXc KDlZIpMzma3yV1GxX8CjMmiFGcZ+cwS1B9t5/GqiLr7l9qtSBWA2d6zbCoMkftoB0Q44 lXEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b="cv+A/fga"; 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=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f8si2618204plo.8.2022.02.21.01.58.51; Mon, 21 Feb 2022 01:59:04 -0800 (PST) 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=@quicinc.com header.s=qcdkim header.b="cv+A/fga"; 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=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242962AbiBSSpo (ORCPT + 99 others); Sat, 19 Feb 2022 13:45:44 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:55758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237985AbiBSSpn (ORCPT ); Sat, 19 Feb 2022 13:45:43 -0500 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5612D0B7F; Sat, 19 Feb 2022 10:45:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1645296323; x=1676832323; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=5v+5eGF0fWqQFfqO8WRWVTuzMoPWbF2CAaKbG/Q1V5s=; b=cv+A/fga6dk3Z/MjR/dfGD1quAdIMnw5kwVHl7+SeyLHtxeVdPwIuL/n 2IYcqUOIMuHxU/QtMZTvCR3h+IP49OCGIVT6LaWYR4jTH0ToTb1yAR9kc EUBgRXCpl+XN8U7LprUv3htX/CQTXQtH6lZ8MKDkozDTeZXgZr8N6fPVD Q=; Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by alexa-out-sd-02.qualcomm.com with ESMTP; 19 Feb 2022 10:45:23 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg05-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2022 10:45:23 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Sat, 19 Feb 2022 10:45:22 -0800 Received: from [10.216.20.52] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Sat, 19 Feb 2022 10:45:16 -0800 Message-ID: <356abae0-c19b-ccbb-fa5f-4e91619243bf@quicinc.com> Date: Sun, 20 Feb 2022 00:15:12 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [RESEND v13 04/10] ASoC: qcom: Add helper function to get dma control and lpaif handle Content-Language: en-US To: Stephen Boyd , , , , , , , , , , , , , , , , CC: Venkata Prasad Potturu 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: "Srinivasa Rao Mandadapu (Temp)" Organization: Qualcomm In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, 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 On 2/18/2022 1:11 AM, Stephen Boyd wrote: Thanks for Your time Stephen!!! > 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(). Okay. Agreed. But in initial review comments, asked to make common function for code readability, and to avoid duplicate code. Anyway will change accordingly and re post it.