From patchwork Mon Mar 15 16:56:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 400519 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3591546jai; Mon, 15 Mar 2021 09:57:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJT4TvTdztLCG7D2WfBanaoIcC/InUFqzr+z/vm0p6uBm8DxYuXZ7W/HWgRzUojx39jOlU X-Received: by 2002:a05:6402:34d5:: with SMTP id w21mr10149532edc.14.1615827460744; Mon, 15 Mar 2021 09:57:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615827460; cv=none; d=google.com; s=arc-20160816; b=JTansaHmspdtCmziTOZ8Hy81ZBUQWxOsmUsLVKj0ZkFQNT2YZf3xCvA2FepedTUaBX 3mb4n37n3vfG4xfqJKTUxR9boVJUBcGUI95EbUGacOA01C5t3//oiLUnjYSUWAd2umo7 vwFswsf97PX4ljsVZWI9CRYYndGhsOQ9Ayfonw5l/ASXwo0jTVGja43zsis6y0NugD9W j7s+vYvklei+n1EFQuZInaB6IiUfMakdCAOi7RJhlhK/vu63S3/Los9O2CP9UiLUNgh0 IBowzU1gF/ZX3Px1kQDToe9pclowYe51hNb61Mp8S+XBjRRVN+sQnboitqN97XXlb21D Id8g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZdZJGNP62lIlEnEmG/cCC95BLhByXorN62IvToLdpl4=; b=G74F978Z6sV6c22u3xXK0OthiMLc+uJOblLF0lyhUj2UhxZlHqnKus0GoogHoQA/30 paJBuQhoUYAg7WjN64FhqDVludYzo5rtiihYKWOVOVB0fffpx8y237MUAlMfEpDQqT0R VOf8t/haLnJlQtrJLvWeC9TTKg0znsAvoecHJ/fxXRRj+B6dtON2qMy3GarjvcoHj+fu UwAkY408JgtHflpo1Tld7dU84oVfO3nFFLbmtWNWCNz4w6wGPgLGN/ARc7f8fPLFMDHI LPKUE+8GcVAzx5CISPwOseLHv0PmzmwmTEaxR5kDXTWneeSOznzA8Q4Z5m7L3Fvy4/TE rd7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WAQzO0mH; 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 p8si11752848edm.44.2021.03.15.09.57.40; Mon, 15 Mar 2021 09:57:40 -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=WAQzO0mH; 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 S234279AbhCOQ5K (ORCPT + 6 others); Mon, 15 Mar 2021 12:57:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234338AbhCOQ45 (ORCPT ); Mon, 15 Mar 2021 12:56:57 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F238C061764 for ; Mon, 15 Mar 2021 09:56:57 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id j4-20020a05600c4104b029010c62bc1e20so19887427wmi.3 for ; Mon, 15 Mar 2021 09:56:57 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZdZJGNP62lIlEnEmG/cCC95BLhByXorN62IvToLdpl4=; b=WAQzO0mHPFAvj8xI6C+JLfJgBcnurW3P3e7LtcjfLvIf+WQJ9obNauAt0jq26jtK76 OyiyoEK6/MtbMXRt7XjRdOfJdHcAeqCq6igi58b20Juqge1uldi96B7qgd+Q+qFAzpDp cv5NKQbh9xv73qG55vroWhwyxUzHUj+xzuSXUNcJDqHlssvr60Je4bnPaVeRebskFXGT tU+CQee1BdIR8CdSHwrSxbFv98zZDq0mUWHSwA0QMsp5HXjxlzXpdqOIQ1q514Ee9jAq 2vbwOuX3taRNxDjolBiT71am2IVNcwP3DfTisGlPnMKTIoUrIk/KcyVIS2loXhcjnM2b Qb6Q== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZdZJGNP62lIlEnEmG/cCC95BLhByXorN62IvToLdpl4=; b=U2Hbf37Il8Pgia9HsY+WyhU9G+F82LhtFEw3JNGPuD6hNkyL9Kzsts1OTCebYUtY4i qDUApq9kGLlBdb1q1BbSURtdXCO29lJoBpqv7m5IHbc8WsWCYUDLnHdjGuq+ajOKlmJv /P6zR2H+sk+ExgczxQ4mmS2sExYTR9AESeJBAu3XGNDGb+iHi6m4eAbBacmDN8GZ5jtb mRb9J6ChSNiRkhLbCWR9nfJO1dhcYWKdVS/zWy0nnx+uX/XyBKrh+AS/IzdRJLp5RFk8 vtF6Q5kEmgsJozkH6cEFzNBtw23ehTxVuHFY+BvjongYwP8gIWyG2QXPTwxyBYk1B7Ua OtUQ== X-Gm-Message-State: AOAM531VhOiqqNHI/TiN/f+vkHndjVDc37Mp4QzemxV+EcMzSjRv2LZu 9yCEzIe798llcnkjgWTCeAp/YYl8kasE8g== X-Received: by 2002:a7b:c195:: with SMTP id y21mr601189wmi.178.1615827415959; Mon, 15 Mar 2021 09:56:55 -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 o2sm227656wmc.23.2021.03.15.09.56.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 09:56:55 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org, vkoul@kernel.org Cc: robh@kernel.org, devicetree@vger.kernel.org, yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Srinivas Kandagatla Subject: [PATCH v4 2/5] soundwire: qcom: update port map allocation bit mask Date: Mon, 15 Mar 2021 16:56:47 +0000 Message-Id: <20210315165650.13392-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210315165650.13392-1-srinivas.kandagatla@linaro.org> References: <20210315165650.13392-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org currently the internal bitmask used for allocating ports starts with offset 0. This is bit confusing as data port numbers on Qualcomm controller are valid from 1 to 14. So adjust this bit mask accordingly, this will also help while adding static port map support. Signed-off-by: Srinivas Kandagatla --- drivers/soundwire/qcom.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) -- 2.21.0 diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index 6d22df01f354..9e70c53e2c7b 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -519,7 +519,7 @@ static void qcom_swrm_stream_free_ports(struct qcom_swrm_ctrl *ctrl, port_mask = &ctrl->din_port_mask; list_for_each_entry(p_rt, &m_rt->port_list, port_node) - clear_bit(p_rt->num - 1, port_mask); + clear_bit(p_rt->num, port_mask); } mutex_unlock(&ctrl->port_lock); @@ -552,13 +552,13 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl, list_for_each_entry(p_rt, &s_rt->port_list, port_node) { /* Port numbers start from 1 - 14*/ pn = find_first_zero_bit(port_mask, maxport); - if (pn > (maxport - 1)) { + if (pn > maxport) { dev_err(ctrl->dev, "All ports busy\n"); ret = -EBUSY; goto err; } set_bit(pn, port_mask); - pconfig[nports].num = pn + 1; + pconfig[nports].num = pn; pconfig[nports].ch_mask = p_rt->ch_mask; nports++; } @@ -580,7 +580,7 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl, err: if (ret) { for (i = 0; i < nports; i++) - clear_bit(pconfig[i].num - 1, port_mask); + clear_bit(pconfig[i].num, port_mask); } mutex_unlock(&ctrl->port_lock); @@ -754,6 +754,9 @@ static int qcom_swrm_get_port_config(struct qcom_swrm_ctrl *ctrl) ctrl->num_dout_ports = val; nports = ctrl->num_dout_ports + ctrl->num_din_ports; + /* Valid port numbers are from 1-14, so mask out port 0 explicitly */ + set_bit(0, &ctrl->dout_port_mask); + set_bit(0, &ctrl->din_port_mask); ret = of_property_read_u8_array(np, "qcom,ports-offset1", off1, nports);