From patchwork Thu Apr 1 09:24:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 413554 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp389252jai; Thu, 1 Apr 2021 02:25:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwiKv0BLqBkal7I1FmZowEuoAhUeWh66XRQX72W7ps+Md0/OQFmNVXv4qG3IY+kOhpwX94 X-Received: by 2002:a17:907:16a8:: with SMTP id hc40mr7973020ejc.40.1617269141013; Thu, 01 Apr 2021 02:25:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617269141; cv=none; d=google.com; s=arc-20160816; b=jl6v9b2WumlAWjMWDhU327ruZ/QgGbGeiIvG8t0FMDvztzJkj3S9LGqsEb4la3p5zi oGUFk7v+WkRNNk9g3EegpZkKVhnbBarOjuc/kySW7GhPac6aNec/SmyZne48lk0LqElr /Leche+x/U+wXwUx/Zy0NFALxW0qxF/3xHKVi7bgPWa98S1SZJkSC06ir0AsyfMY3+rk 0zm+YCXVWyJtQ5OnLqQoo/f0JbXt1/a/YS7y9DfwyKDfsP9VZc6ERK1OIs4K3Te1QVfj 49ZuOwmtIqlu7M+G1CHD9JsfGSGCji+QEILkDyIszboAxmybELruxMbo7rabx72t9vTh DOxw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=oOGfrAjnaHDyy1tyd/ITu7l8d1aLT0q9c434VgRCWEU=; b=AJJGPZwp8U3G/9ih6yrpaty+0wodHqAgTBZ2bwVyw2h3/Gs388zs/jl67EYFJZ/qeW XzYexDWk7u4TH43UML5J5KO7zWwQNFk0N54XsgxidXUdKbco3jZZ777WoGbwrwgAu8sw oMleyi1rxF5FZ2mb8R8S//JzMhFWLQRedxYfgS1A0JPvSTsAirADBsnstEjfcnq1a5PL GkpLyqNTbQvBlS2PBYSiFpZkiZppypOxN/Vp1spLCzoAdtFbFG7hwQyKxhjaP2fU904n N2Jo3k6DVoNxc/3w4lCD6sjJGA81GlUn5CxyDppPy9HmFvzEd9/5Ew7u1hrnsd9cBi1T niCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Hcyf8uZ1; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h26si3750285edw.139.2021.04.01.02.25.40; Thu, 01 Apr 2021 02:25:41 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Hcyf8uZ1; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233580AbhDAJZI (ORCPT + 6 others); Thu, 1 Apr 2021 05:25:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233748AbhDAJY7 (ORCPT ); Thu, 1 Apr 2021 05:24:59 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB7BFC0613E6 for ; Thu, 1 Apr 2021 02:24:58 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id ce10so1854713ejb.6 for ; Thu, 01 Apr 2021 02:24:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=oOGfrAjnaHDyy1tyd/ITu7l8d1aLT0q9c434VgRCWEU=; b=Hcyf8uZ1S+AbwrUswcBEuo0hbJdidSJ3m55scMsQLn6YgcfRifwgdwX9lFIdR0/EwD sGhFr60G2F8wy8HLT6Fq5DhdGsBHMiuPlmytuu7EgzkSuqlo95gnVhKjzr1ar1reXWRy zFyQ/s7NNZEF2DY6cBUFD4LsxM57FCe1SKmiy823/oelgR+egUmQIK7uO3UEGLNNyiHV y+t6qvzdHTboH9aDRDUNYi0DYZsK6YNoYc5CDjo7AeQwjabpspIEd+IprIQHYt+yPhvS WReETkGNvh5uLj8sisd8E9GbdkynxeV6Sz2jOsz2Nxo0HTjfX8ZYuwb52ygiKLE07zbC Bj/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=oOGfrAjnaHDyy1tyd/ITu7l8d1aLT0q9c434VgRCWEU=; b=Iqn3hRQKjxhErSOkSBTFN7fcbYZwGGrqvEJOhxftgya74cTiY/Woi/AVBKaP+vxxU8 yYHPEVVVgijd9cshO/couCcTnFZCfPBmR4E9c7tuuaoHxe8Jc0/hkt0oRfyktH/frdrF cTx1A2TKJmQlLNgKDd5vfe6tc7rvyKHDguCyQf3hMTK4qY+GoVIEcP9gYZoAP1DOX4TD ONXvpU2vBVX+SX2b7PDvR4zhhYhiLqpj7YuUyjmt3twxjzh3tNWofqx7p2U3B0Lvj8V4 BvMGj0jcntr1eOeQ/qmAnVuWqdQSSOTkSd0HFAs875QgBECOsVQpFmHbICTdItHfqY3t v/yA== X-Gm-Message-State: AOAM532iZBC8+4VgqnH+1zU6obognCtR8zn9gepSijbMSsdYNi3ijD1N d3Qtgdwyaf46s2PpP2IsLJaj1w== X-Received: by 2002:a17:907:94cc:: with SMTP id dn12mr8188592ejc.177.1617269097400; Thu, 01 Apr 2021 02:24:57 -0700 (PDT) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id cb17sm3221540edb.10.2021.04.01.02.24.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 02:24:56 -0700 (PDT) From: Srinivas Kandagatla To: vkoul@kernel.org Cc: yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, robh@kernel.org, devicetree@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH] soundwire: qcom: cleanup internal port config indexing Date: Thu, 1 Apr 2021 10:24:54 +0100 Message-Id: <20210401092454.21299-1-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Internally used portconfig array for storing port bandwidth params starts from offset zero. However port zero is not really used and we also copy the bus parameters to offset zero. So basically we endup with a code which has to subtract 1 from port number to get to port parameters. This is bit confusing to the reader so, make this bit more obvious by only copying the parameters to offset 1 instead of zero. This will avoid doing -1 every time when we try to get port params. Similar thing has been recently done with din/dout_port_mask. Signed-off-by: Srinivas Kandagatla --- drivers/soundwire/qcom.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) -- 2.21.0 diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index 94fd58f9dda3..348d9a46f850 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -724,7 +724,7 @@ static int qcom_swrm_transport_params(struct sdw_bus *bus, int reg = SWRM_DP_PORT_CTRL_BANK((params->port_num), bank); int ret; - pcfg = &ctrl->pconfig[params->port_num - 1]; + pcfg = &ctrl->pconfig[params->port_num]; value = pcfg->off1 << SWRM_DP_PORT_CTRL_OFFSET1_SHFT; value |= pcfg->off2 << SWRM_DP_PORT_CTRL_OFFSET2_SHFT; @@ -811,11 +811,11 @@ static int qcom_swrm_compute_params(struct sdw_bus *bus) struct qcom_swrm_port_config *pcfg; struct sdw_slave *slave; unsigned int m_port; - int i = 0; + int i = 1; list_for_each_entry(m_rt, &bus->m_rt_list, bus_node) { list_for_each_entry(p_rt, &m_rt->port_list, port_node) { - pcfg = &ctrl->pconfig[p_rt->num - 1]; + pcfg = &ctrl->pconfig[p_rt->num]; p_rt->transport_params.port_num = p_rt->num; if (pcfg->word_length != SWR_INVALID_PARAM) { sdw_fill_port_params(&p_rt->port_params, @@ -832,7 +832,7 @@ static int qcom_swrm_compute_params(struct sdw_bus *bus) m_port = slave->m_port_map[p_rt->num]; /* port config starts at offset 0 so -1 from actual port number */ if (m_port) - pcfg = &ctrl->pconfig[m_port - 1]; + pcfg = &ctrl->pconfig[m_port]; else pcfg = &ctrl->pconfig[i]; p_rt->transport_params.port_num = p_rt->num; @@ -1167,15 +1167,16 @@ static int qcom_swrm_get_port_config(struct qcom_swrm_ctrl *ctrl) of_property_read_u8_array(np, "qcom,ports-lane-control", lane_control, nports); for (i = 0; i < nports; i++) { - ctrl->pconfig[i].si = si[i]; - ctrl->pconfig[i].off1 = off1[i]; - ctrl->pconfig[i].off2 = off2[i]; - ctrl->pconfig[i].bp_mode = bp_mode[i]; - ctrl->pconfig[i].hstart = hstart[i]; - ctrl->pconfig[i].hstop = hstop[i]; - ctrl->pconfig[i].word_length = word_length[i]; - ctrl->pconfig[i].blk_group_count = blk_group_count[i]; - ctrl->pconfig[i].lane_control = lane_control[i]; + /* Valid port number range is from 1-14 */ + ctrl->pconfig[i + 1].si = si[i]; + ctrl->pconfig[i + 1].off1 = off1[i]; + ctrl->pconfig[i + 1].off2 = off2[i]; + ctrl->pconfig[i + 1].bp_mode = bp_mode[i]; + ctrl->pconfig[i + 1].hstart = hstart[i]; + ctrl->pconfig[i + 1].hstop = hstop[i]; + ctrl->pconfig[i + 1].word_length = word_length[i]; + ctrl->pconfig[i + 1].blk_group_count = blk_group_count[i]; + ctrl->pconfig[i + 1].lane_control = lane_control[i]; } return 0;