ALSA: hda: intel-nhlt: Print errors in intel_nhlt_ssp_device_type()
authorPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Thu, 8 May 2025 18:14:46 +0000 (21:14 +0300)
committerTakashi Iwai <tiwai@suse.de>
Sun, 11 May 2025 14:15:00 +0000 (16:15 +0200)
Do not fail silently when the intel_nhlt_ssp_device_type() fails as it can
be for two reasons:
The NHLT table is missing or the SSP instance is missing from the table.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://patch.msgid.link/20250508181446.25323-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/hda/intel-nhlt.c

index 088cff799e0bee5003f8d09ae0cb0087cc46ab33..6d72a871bda0b5ae53effebfe01063032f16cbaa 100644 (file)
@@ -350,8 +350,11 @@ int intel_nhlt_ssp_device_type(struct device *dev, struct nhlt_acpi_table *nhlt,
        struct nhlt_endpoint *epnt;
        int i;
 
-       if (!nhlt)
+       if (!nhlt) {
+               dev_err(dev, "%s: NHLT table is missing (query for SSP%d)\n",
+                       __func__, virtual_bus_id);
                return -EINVAL;
+       }
 
        epnt = (struct nhlt_endpoint *)nhlt->desc;
        for (i = 0; i < nhlt->endpoint_count; i++) {
@@ -366,6 +369,20 @@ int intel_nhlt_ssp_device_type(struct device *dev, struct nhlt_acpi_table *nhlt,
                epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length);
        }
 
+       dev_err(dev, "%s: No match for SSP%d in NHLT table\n", __func__,
+               virtual_bus_id);
+
+       dev_dbg(dev, "Available endpoints:\n");
+       epnt = (struct nhlt_endpoint *)nhlt->desc;
+       for (i = 0; i < nhlt->endpoint_count; i++) {
+               dev_dbg(dev,
+                       "%d: link_type: %d, vbus_id: %d, dir: %d, dev_type: %d\n",
+                       i, epnt->linktype, epnt->virtual_bus_id,
+                       epnt->direction, epnt->device_type);
+
+               epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length);
+       }
+
        return -EINVAL;
 }
 EXPORT_SYMBOL(intel_nhlt_ssp_device_type);