Skip to content
Snippets Groups Projects
Commit 650dfdb8 authored by Srinivas Kandagatla's avatar Srinivas Kandagatla Committed by Vinod Koul
Browse files

soundwire: qcom: update port map allocation bit mask


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: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20210315165650.13392-3-srinivas.kandagatla@linaro.org


Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent f4022062
No related branches found
No related tags found
No related merge requests found
...@@ -797,7 +797,7 @@ static void qcom_swrm_stream_free_ports(struct qcom_swrm_ctrl *ctrl, ...@@ -797,7 +797,7 @@ static void qcom_swrm_stream_free_ports(struct qcom_swrm_ctrl *ctrl,
port_mask = &ctrl->din_port_mask; port_mask = &ctrl->din_port_mask;
list_for_each_entry(p_rt, &m_rt->port_list, port_node) 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); mutex_unlock(&ctrl->port_lock);
...@@ -830,13 +830,13 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl, ...@@ -830,13 +830,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) { list_for_each_entry(p_rt, &s_rt->port_list, port_node) {
/* Port numbers start from 1 - 14*/ /* Port numbers start from 1 - 14*/
pn = find_first_zero_bit(port_mask, maxport); pn = find_first_zero_bit(port_mask, maxport);
if (pn > (maxport - 1)) { if (pn > maxport) {
dev_err(ctrl->dev, "All ports busy\n"); dev_err(ctrl->dev, "All ports busy\n");
ret = -EBUSY; ret = -EBUSY;
goto err; goto err;
} }
set_bit(pn, port_mask); set_bit(pn, port_mask);
pconfig[nports].num = pn + 1; pconfig[nports].num = pn;
pconfig[nports].ch_mask = p_rt->ch_mask; pconfig[nports].ch_mask = p_rt->ch_mask;
nports++; nports++;
} }
...@@ -858,7 +858,7 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl, ...@@ -858,7 +858,7 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl,
err: err:
if (ret) { if (ret) {
for (i = 0; i < nports; i++) 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); mutex_unlock(&ctrl->port_lock);
...@@ -1037,6 +1037,9 @@ static int qcom_swrm_get_port_config(struct qcom_swrm_ctrl *ctrl) ...@@ -1037,6 +1037,9 @@ static int qcom_swrm_get_port_config(struct qcom_swrm_ctrl *ctrl)
ctrl->num_dout_ports = val; ctrl->num_dout_ports = val;
nports = ctrl->num_dout_ports + ctrl->num_din_ports; 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", ret = of_property_read_u8_array(np, "qcom,ports-offset1",
off1, nports); off1, nports);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment