Commit 7075b0c9 authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Mark Brown

ASoC: SOF: Intel: hda-mlink: fix off-by-one error

The HCHAN parameter should be the highest channel number, not the
channel count.

While we're at it, handle LCHAN with the dual __ffs helper.

Fixes: ccc2f0c1 ("ASoC: SOF: Intel: hda-mlink: add helper to program SoundWire PCMSyCM registers")
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: default avatarRander Wang <rander.wang@intel.com>
Link: https://lore.kernel.org/r/20230807210959.506849-2-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 3f8c530f
...@@ -781,6 +781,8 @@ int hdac_bus_eml_sdw_map_stream_ch(struct hdac_bus *bus, int sublink, int y, ...@@ -781,6 +781,8 @@ int hdac_bus_eml_sdw_map_stream_ch(struct hdac_bus *bus, int sublink, int y,
{ {
struct hdac_ext2_link *h2link; struct hdac_ext2_link *h2link;
u16 __iomem *pcmsycm; u16 __iomem *pcmsycm;
int hchan;
int lchan;
u16 val; u16 val;
h2link = find_ext2_link(bus, true, AZX_REG_ML_LEPTR_ID_SDW); h2link = find_ext2_link(bus, true, AZX_REG_ML_LEPTR_ID_SDW);
...@@ -791,9 +793,17 @@ int hdac_bus_eml_sdw_map_stream_ch(struct hdac_bus *bus, int sublink, int y, ...@@ -791,9 +793,17 @@ int hdac_bus_eml_sdw_map_stream_ch(struct hdac_bus *bus, int sublink, int y,
h2link->instance_offset * sublink + h2link->instance_offset * sublink +
AZX_REG_SDW_SHIM_PCMSyCM(y); AZX_REG_SDW_SHIM_PCMSyCM(y);
if (channel_mask) {
hchan = __fls(channel_mask);
lchan = __ffs(channel_mask);
} else {
hchan = 0;
lchan = 0;
}
mutex_lock(&h2link->eml_lock); mutex_lock(&h2link->eml_lock);
hdaml_shim_map_stream_ch(pcmsycm, 0, hweight32(channel_mask), hdaml_shim_map_stream_ch(pcmsycm, lchan, hchan,
stream_id, dir); stream_id, dir);
mutex_unlock(&h2link->eml_lock); mutex_unlock(&h2link->eml_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment