[PATCH 3/3] ASoC: codecs: hdac_hdmi: Update codec read API callers

From: Sreeraj S Kurup

Date: Thu Dec 03 2026 - 12:09:23 EST


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

Check the return status before using codec responses and handle
command failures appropriately in port selection, power
management and vendor-specific verb operations.

This ensures that codec read errors are handled separately
from response values.

Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@xxxxxxxxx>
---
sound/soc/codecs/hdac_hdmi.c | 72 +++++++++++++++++++++++-------------
1 file changed, 47 insertions(+), 25 deletions(-)

diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index f7922ffaad97..8dad9f1644f8 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -241,8 +241,15 @@ static int hdac_hdmi_get_port_len(struct hdac_device *hdev, hda_nid_t nid)
static int hdac_hdmi_port_select_get(struct hdac_device *hdev,
struct hdac_hdmi_port *port)
{
- return snd_hdac_codec_read(hdev, port->pin->nid,
- 0, AC_VERB_GET_DEVICE_SEL, 0);
+ unsigned int res;
+ int err;
+
+ err = snd_hdac_codec_read(hdev, port->pin->nid,
+ 0, AC_VERB_GET_DEVICE_SEL, 0, &res);
+ if (err < 0)
+ return err;
+
+ return res;
}

/*
@@ -253,6 +260,7 @@ static int hdac_hdmi_port_select_set(struct hdac_device *hdev,
struct hdac_hdmi_port *port)
{
int num_ports;
+ int selected;

if (!port->pin->mst_capable)
return 0;
@@ -271,7 +279,11 @@ static int hdac_hdmi_port_select_set(struct hdac_device *hdev,
snd_hdac_codec_write(hdev, port->pin->nid, 0,
AC_VERB_SET_DEVICE_SEL, port->id);

- if (port->id != hdac_hdmi_port_select_get(hdev, port))
+ selected = hdac_hdmi_port_select_get(hdev, port);
+ if (selected < 0)
+ return selected;
+
+ if (port->id != selected)
return -EIO;

dev_dbg(&hdev->dev, "Selected the port=%d\n", port->id);
@@ -740,15 +752,18 @@ static struct hdac_hdmi_pcm *hdac_hdmi_get_pcm(struct hdac_device *hdev,
static void hdac_hdmi_set_power_state(struct hdac_device *hdev,
hda_nid_t nid, unsigned int pwr_state)
{
- int count;
- unsigned int state;
+ int count, err;
+ unsigned int state, res;

if (snd_hdac_get_wcaps(hdev, nid) & AC_WCAP_POWER) {
if (!snd_hdac_check_power_state(hdev, nid, pwr_state)) {
for (count = 0; count < 10; count++) {
- snd_hdac_codec_read(hdev, nid, 0,
+ err = snd_hdac_codec_read(hdev, nid, 0,
AC_VERB_SET_POWER_STATE,
- pwr_state);
+ pwr_state, &res);
+ if (err < 0)
+ break;
+
state = snd_hdac_sync_power_state(hdev,
nid, pwr_state);
if (!(state & AC_PWRST_ERROR))
@@ -1401,38 +1416,40 @@ static int hdac_hdmi_add_pin(struct hdac_device *hdev, hda_nid_t nid)

static void hdac_hdmi_skl_enable_all_pins(struct hdac_device *hdev)
{
- unsigned int vendor_param;
+ unsigned int vendor_param, res;
struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev);
unsigned int vendor_nid = hdmi->drv_data->vendor_nid;
+ int err;

- vendor_param = snd_hdac_codec_read(hdev, vendor_nid, 0,
- INTEL_GET_VENDOR_VERB, 0);
- if (vendor_param == -1 || vendor_param & INTEL_EN_ALL_PIN_CVTS)
+ err = snd_hdac_codec_read(hdev, vendor_nid, 0,
+ INTEL_GET_VENDOR_VERB, 0, &vendor_param);
+ if (err < 0 || (vendor_param & INTEL_EN_ALL_PIN_CVTS))
return;

vendor_param |= INTEL_EN_ALL_PIN_CVTS;
- vendor_param = snd_hdac_codec_read(hdev, vendor_nid, 0,
- INTEL_SET_VENDOR_VERB, vendor_param);
- if (vendor_param == -1)
+ err = snd_hdac_codec_read(hdev, vendor_nid, 0,
+ INTEL_SET_VENDOR_VERB, vendor_param, &res);
+ if (err < 0)
return;
}

static void hdac_hdmi_skl_enable_dp12(struct hdac_device *hdev)
{
- unsigned int vendor_param;
+ unsigned int vendor_param, res;
struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev);
unsigned int vendor_nid = hdmi->drv_data->vendor_nid;
+ int err;

- vendor_param = snd_hdac_codec_read(hdev, vendor_nid, 0,
- INTEL_GET_VENDOR_VERB, 0);
- if (vendor_param == -1 || vendor_param & INTEL_EN_DP12)
+ err = snd_hdac_codec_read(hdev, vendor_nid, 0,
+ INTEL_GET_VENDOR_VERB, 0, &vendor_param);
+ if (err < 0 || (vendor_param & INTEL_EN_DP12))
return;

/* enable DP1.2 mode */
vendor_param |= INTEL_EN_DP12;
- vendor_param = snd_hdac_codec_read(hdev, vendor_nid, 0,
- INTEL_SET_VENDOR_VERB, vendor_param);
- if (vendor_param == -1)
+ err = snd_hdac_codec_read(hdev, vendor_nid, 0,
+ INTEL_SET_VENDOR_VERB, vendor_param, &res);
+ if (err < 0)
return;

}
@@ -1942,6 +1959,8 @@ static int hdac_hdmi_runtime_suspend(struct device *dev)
struct hdac_device *hdev = dev_to_hdac_dev(dev);
struct hdac_bus *bus = hdev->bus;
struct hdac_ext_link *hlink;
+ int ret;
+ unsigned int res;

dev_dbg(dev, "Enter: %s\n", __func__);

@@ -1956,8 +1975,10 @@ static int hdac_hdmi_runtime_suspend(struct device *dev)
* is received. So setting power state is ensured without using loop
* to read the state.
*/
- snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE,
- AC_PWRST_D3);
+ ret = snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE,
+ AC_PWRST_D3, &res);
+ if (ret < 0)
+ return ret;

hlink = snd_hdac_ext_bus_get_hlink_by_name(bus, dev_name(dev));
if (!hlink) {
@@ -1978,6 +1999,7 @@ static int hdac_hdmi_runtime_resume(struct device *dev)
struct hdac_device *hdev = dev_to_hdac_dev(dev);
struct hdac_bus *bus = hdev->bus;
struct hdac_ext_link *hlink;
+ unsigned int res;

dev_dbg(dev, "Enter: %s\n", __func__);

@@ -2000,8 +2022,8 @@ static int hdac_hdmi_runtime_resume(struct device *dev)
hdac_hdmi_skl_enable_dp12(hdev);

/* Power up afg */
- snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE,
- AC_PWRST_D0);
+ snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE,
+ AC_PWRST_D0, &res);

return 0;
}
--
2.55.0