From patchwork Fri Mar 12 12:22:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 398604 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1149335jai; Fri, 12 Mar 2021 04:24:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzcrGPDOwwA2ebmC8YB1fRdQ4RyUTZBcBWmia+0lZMNt4Pm/rCp/vp/sNKzT0NzmZOoQwRF X-Received: by 2002:a17:906:2818:: with SMTP id r24mr8302456ejc.472.1615551842316; Fri, 12 Mar 2021 04:24:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615551842; cv=none; d=google.com; s=arc-20160816; b=mAtN0+9iDNY9cFsZ8z7PQw1v2z/keOoR8udta1HcwyYswhILayy+yNZitFQfDG0RSx ukJy/pu8QJYwYlIoyDIQK8OEe5hHc0tURfoUGf+52FxPTupqg2oGNtlf7LD5bWl9BVfv kkgwKH0wfBuCXCQ6wRWLECaBlhcCUTqctC69G+xrcW3Os0MykNnr8vPTMatF2zeFvfGz 6LQEB/QTWQKy3pl3cW+wcR+Z9jK7ZJB1Ks4fNyoUKrMZV2YME+R7LhDl4KkSYkTEaCcn NBY0WT8MuCIiH+JNMwHwuGHX4si//SVkJbndiwIi1AZ0mfRkwN5Djo/Ey95n6vvOu58m 2IOg== 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=VVrrT49hCh8QSMeYRaF6jC+6kuSNOd+smZiBEFnxgnez8SdHS8doX3c7Cda3/vdbBB zkTZpTi2Xr0y8IiUBmh5yaHslkJNUwDaZYyCc8fCUNGwO6iQPFD5ncVuf+mmorFUKRUj NpJ0zW1H8zXsk+RPVDSlAwwAGEIYcKlnZU/MCCR/cfVUQSkZOw1ga8Zfv4tX60Tg1pX4 1YtgLoO4cjZKAi0oTW9WBozcakM/fDCJL/4gwvGmxSlRQnFB58Yyqp9Z2MJj09MSy/zC +1Al0l5v76J+L40UZX4o757BzsoWOx3lZRV0YSVad5VvBjAw5jAPC95GguDLs9RpMMl3 ZsGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ylWoX9xU; 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 qu25si4092931ejb.665.2021.03.12.04.24.02; Fri, 12 Mar 2021 04:24:02 -0800 (PST) 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=ylWoX9xU; 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 S229501AbhCLMX0 (ORCPT + 6 others); Fri, 12 Mar 2021 07:23:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231252AbhCLMXB (ORCPT ); Fri, 12 Mar 2021 07:23:01 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60587C061761 for ; Fri, 12 Mar 2021 04:23:01 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id 7so4709474wrz.0 for ; Fri, 12 Mar 2021 04:23:01 -0800 (PST) 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=ylWoX9xUNZ8xM+1HGI2ImLh8mOmk1MiOPYZg1P7v+ETDVLVHX9F80XJcdSoCzTBImJ tCl38ELjaOK5iwx6nSQQPT7VslSzPgOOrQFPioqLi3t0PxDz7up1bLTv8Q7cVjv8rx+d JQ9DXuka8FoHix/r977MhlIq90uFd70y1D5s3DPL2mw3VpHaN5NuI62SauLnwGXb9u8h h/JyFg6TGGNyNLMXhkBHKISbJ2s6Hgy9YXEpeqXjFqZep2C8mb4H+IiC+GjWptsjhf0i qEHU6URAL24+N9BqJbAOt+9m7QBP7hgOZUvQKGJ1+cTHPsYZkT2Wo+nLouh0OufzcAKw CvEA== 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=AzM7rJRoW+G2xuMW/HJeaXhk3UgpVcyKQDW2Fd6kD99LORf4V//usclevhhgXQp84d ZPtq/ZO0nEzPAxrcNbaK+mWuOprxilvnb/3TN6oEXv3ogim7HFWe3QWaoonRP6sdiJzE 4FQopG6GpNh1R82rxD5Se2NO8+fkTA8FH/2dCeeTbDjQsxMU2ic14+/gr6j95LGga2vp SQoVIgVvTWffiElzPT6UmOxpue6OX9e6Y2XFUuQtNNdNZRHReRDGrZxlrYauWzU7QhLT 5qdLw9TI6li+U79rd5c4nXI6iRPsLXelzjgTWGUZT2qVyQuXOAFCVkB/x4H81gRBIdsH rELA== X-Gm-Message-State: AOAM530cvEiGq3Dcl6Q6oGC9WbpjNw1PvJXVpm5q9Fz/TarTdsF1NL0M xOVqVBXMeEnjs1E1nhBG/lYbAw== X-Received: by 2002:adf:e603:: with SMTP id p3mr13900719wrm.360.1615551780146; Fri, 12 Mar 2021 04:23:00 -0800 (PST) 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 3sm8804329wry.72.2021.03.12.04.22.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 04:22:59 -0800 (PST) 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: [RESEND PATCH v3 2/5] soundwire: qcom: update port map allocation bit mask Date: Fri, 12 Mar 2021 12:22:52 +0000 Message-Id: <20210312122255.3143-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210312122255.3143-1-srinivas.kandagatla@linaro.org> References: <20210312122255.3143-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);