From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 09DA0C433EF for ; Sat, 19 Feb 2022 18:46:26 +0000 (UTC) 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 F2D3C16B9; Sat, 19 Feb 2022 19:45:33 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F2D3C16B9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645296384; bh=CZZ4+U77AlL4oysAZTlA60Q73v4CU6EvIUT2oMgILrY=; h=Date:Subject:To:References:From:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=NGaF1z+7h1YK5hBMX8mMHip1n6aGWFGsDGILMgo2Pos7Bk6lFf/2ucOPIAx/CFZML sNdSYguSdQgJKItkCqM+opwH5I3WCLhC7OgUmByK8+p7YTiyYYKYao4I/LxPTAPW42 HeCeUyJoLgdmV1lrPXn3h5HwzjostXqugRYGnWlw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 834E0F8014B; Sat, 19 Feb 2022 19:45:33 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0083CF8016A; Sat, 19 Feb 2022 19:45:31 +0100 (CET) Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) (using TLSv1.2 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9997EF800AB for ; Sat, 19 Feb 2022 19:45:25 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9997EF800AB Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="AcIvg298" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1645296326; x=1676832326; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=5v+5eGF0fWqQFfqO8WRWVTuzMoPWbF2CAaKbG/Q1V5s=; b=AcIvg2989HP5p1SFVl7fqPpzzTu6HTgw4vFtdQoPvXdhj34c5t7vyT9j E22JmveyemAOKtJEYyb8ygEig3lrpI/6MCNwv5AT2HdZz6sUa25hxOAqy JpAdRsmtDSV765UFha+J7QdtWAwQB82Yi9NZDhj35Z7Q79uKj+mieTLGe 8=; 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 , , , , , , , , , , , , , , , , 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) Cc: Venkata Prasad Potturu 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" 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.