[PATCH 2/3] ALSA: hda: hdmi_chmap: Update HDMI channel map codec read callers

From: Sreeraj S Kurup

Date: Thu Dec 03 2026 - 12:08:56 EST


Update callers of snd_hdac_codec_read() in hdmi_chmap.c to use
the new status and output parameter interface.

Check the return status before using the codec response, and
propagate read errors from the channel mapping helper functions.

Also avoid updating the converter channel count when reading the
current channel count fails.

Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@xxxxxxxxx>
---
sound/hda/core/hdmi_chmap.c | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/sound/hda/core/hdmi_chmap.c b/sound/hda/core/hdmi_chmap.c
index c897fc443467..e9e599154ef1 100644
--- a/sound/hda/core/hdmi_chmap.c
+++ b/sound/hda/core/hdmi_chmap.c
@@ -190,21 +190,41 @@ static int hdmi_pin_set_slot_channel(struct hdac_device *codec,
static int hdmi_pin_get_slot_channel(struct hdac_device *codec,
hda_nid_t pin_nid, int asp_slot)
{
- return (snd_hdac_codec_read(codec, pin_nid, 0,
+ unsigned int res;
+ int err;
+
+ err = snd_hdac_codec_read(codec, pin_nid, 0,
AC_VERB_GET_HDMI_CHAN_SLOT,
- asp_slot) & 0xf0) >> 4;
+ asp_slot, &res);
+ if (err < 0)
+ return err;
+
+ return (res & 0xf0) >> 4;
}

static int hdmi_get_channel_count(struct hdac_device *codec, hda_nid_t cvt_nid)
{
- return 1 + snd_hdac_codec_read(codec, cvt_nid, 0,
- AC_VERB_GET_CVT_CHAN_COUNT, 0);
+ unsigned int res;
+ int err;
+
+ err = snd_hdac_codec_read(codec, cvt_nid, 0,
+ AC_VERB_GET_CVT_CHAN_COUNT, 0, &res);
+ if (err < 0)
+ return err;
+
+ return 1 + res;
}

static void hdmi_set_channel_count(struct hdac_device *codec,
hda_nid_t cvt_nid, int chs)
{
- if (chs != hdmi_get_channel_count(codec, cvt_nid))
+ int current;
+
+ current = hdmi_get_channel_count(codec, cvt_nid);
+ if (current < 0)
+ return;
+
+ if (chs != current)
snd_hdac_codec_write(codec, cvt_nid, 0,
AC_VERB_SET_CVT_CHAN_COUNT, chs - 1);
}
--
2.55.0