Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soundwire: generic_bandwidth_allocation: change port_bo parameter to pointer

Currently, we do port_bo += bps * ch in both inside and outside
sdw_compute_master_ports(). We can pass port_bo as a pointer and only
calculate port_bo in sdw_compute_master_ports().
Besides, different port could use different lanes and we can't just
add port_bo based on total channels in a manager.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20240617121350.14074-1-yung-chuan.liao@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Bard Liao and committed by
Vinod Koul
8e8c0dfc b96f16bd

+6 -8
+6 -8
drivers/soundwire/generic_bandwidth_allocation.c
··· 83 83 84 84 static void sdw_compute_master_ports(struct sdw_master_runtime *m_rt, 85 85 struct sdw_group_params *params, 86 - int port_bo, int hstop) 86 + int *port_bo, int hstop) 87 87 { 88 88 struct sdw_transport_data t_data = {0}; 89 89 struct sdw_port_runtime *p_rt; ··· 108 108 109 109 sdw_fill_xport_params(&p_rt->transport_params, p_rt->num, 110 110 false, SDW_BLK_GRP_CNT_1, sample_int, 111 - port_bo, port_bo >> 8, hstart, hstop, 111 + *port_bo, (*port_bo) >> 8, hstart, hstop, 112 112 SDW_BLK_PKG_PER_PORT, 0x0); 113 113 114 114 sdw_fill_port_params(&p_rt->port_params, ··· 120 120 if (!(p_rt == list_first_entry(&m_rt->port_list, 121 121 struct sdw_port_runtime, 122 122 port_node))) { 123 - port_bo += bps * ch; 123 + (*port_bo) += bps * ch; 124 124 continue; 125 125 } 126 126 127 127 t_data.hstart = hstart; 128 128 t_data.hstop = hstop; 129 - t_data.block_offset = port_bo; 129 + t_data.block_offset = *port_bo; 130 130 t_data.sub_block_offset = 0; 131 - port_bo += bps * ch; 131 + (*port_bo) += bps * ch; 132 132 } 133 133 134 134 sdw_compute_slave_ports(m_rt, &t_data); ··· 146 146 port_bo = 1; 147 147 148 148 list_for_each_entry(m_rt, &bus->m_rt_list, bus_node) { 149 - sdw_compute_master_ports(m_rt, &params[i], port_bo, hstop); 150 - 151 - port_bo += m_rt->ch_count * m_rt->stream->params.bps; 149 + sdw_compute_master_ports(m_rt, &params[i], &port_bo, hstop); 152 150 } 153 151 154 152 hstop = hstop - params[i].hwidth;