Skip to content

Commit 46c8b4d

Browse files
Stefan Bindingbroonie
authored andcommitted
ASoC: cs35l41: Fallback to reading Subsystem ID property if not ACPI
If ACPI is not used, then there is currently no way of reading a Subsystem ID property used for a system name to uniquely identify the system in order to load the correct firmware and tuning. Add a new property which can be read from device tree to be able to set the system name. Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com> Link: https://patch.msgid.link/20250917153722.94978-3-sbinding@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent f8673e4 commit 46c8b4d

1 file changed

Lines changed: 44 additions & 33 deletions

File tree

sound/soc/codecs/cs35l41.c

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// Author: David Rhodes <david.rhodes@cirrus.com>
88

99
#include <linux/acpi.h>
10+
#include <acpi/acpi_bus.h>
1011
#include <linux/delay.h>
1112
#include <linux/err.h>
1213
#include <linux/init.h>
@@ -1147,45 +1148,55 @@ static int cs35l41_dsp_init(struct cs35l41_private *cs35l41)
11471148
return ret;
11481149
}
11491150

1150-
#ifdef CONFIG_ACPI
1151-
static int cs35l41_acpi_get_name(struct cs35l41_private *cs35l41)
1151+
static int cs35l41_get_system_name(struct cs35l41_private *cs35l41)
11521152
{
11531153
struct acpi_device *adev = ACPI_COMPANION(cs35l41->dev);
1154-
acpi_handle handle = acpi_device_handle(adev);
1155-
const char *hid;
1156-
const char *sub;
1157-
1158-
/* If there is no acpi_device, there is no ACPI for this system, return 0 */
1159-
if (!adev)
1160-
return 0;
1154+
const char *sub = NULL;
1155+
const char *tmp;
1156+
int ret = 0;
11611157

1162-
sub = acpi_get_subsystem_id(handle);
1163-
if (IS_ERR(sub)) {
1164-
/* If no _SUB, fallback to _HID, otherwise fail */
1165-
if (PTR_ERR(sub) == -ENODATA) {
1166-
hid = acpi_device_hid(adev);
1167-
/* If dummy hid, return 0 and fallback to legacy firmware path */
1168-
if (!strcmp(hid, "device"))
1169-
return 0;
1170-
sub = kstrdup(hid, GFP_KERNEL);
1171-
if (!sub)
1172-
sub = ERR_PTR(-ENOMEM);
1173-
1174-
} else
1175-
return PTR_ERR(sub);
1158+
/* If there is no acpi_device, there is no ACPI for this system, skip checking ACPI */
1159+
if (adev) {
1160+
acpi_handle handle = acpi_device_handle(adev);
1161+
1162+
sub = acpi_get_subsystem_id(handle);
1163+
ret = PTR_ERR_OR_ZERO(sub);
1164+
if (ret) {
1165+
sub = NULL;
1166+
/* If no _SUB, fallback to _HID, otherwise fail */
1167+
if (ret == -ENODATA) {
1168+
tmp = acpi_device_hid(adev);
1169+
/* If dummy hid, return 0 and fallback to legacy firmware path */
1170+
if (!strcmp(tmp, "device")) {
1171+
ret = 0;
1172+
goto err;
1173+
}
1174+
sub = kstrdup(tmp, GFP_KERNEL);
1175+
if (!sub) {
1176+
ret = -ENOMEM;
1177+
goto err;
1178+
}
1179+
}
1180+
}
1181+
} else {
1182+
if (!device_property_read_string(cs35l41->dev, "cirrus,subsystem-id", &tmp)) {
1183+
sub = kstrdup(tmp, GFP_KERNEL);
1184+
if (!sub) {
1185+
ret = -ENOMEM;
1186+
goto err;
1187+
}
1188+
}
11761189
}
11771190

1178-
cs35l41->dsp.system_name = sub;
1179-
dev_dbg(cs35l41->dev, "Subsystem ID: %s\n", cs35l41->dsp.system_name);
1191+
err:
1192+
if (sub) {
1193+
cs35l41->dsp.system_name = sub;
1194+
dev_info(cs35l41->dev, "Subsystem ID: %s\n", cs35l41->dsp.system_name);
1195+
} else
1196+
dev_warn(cs35l41->dev, "Subsystem ID not found\n");
11801197

1181-
return 0;
1182-
}
1183-
#else
1184-
static int cs35l41_acpi_get_name(struct cs35l41_private *cs35l41)
1185-
{
1186-
return 0;
1198+
return ret;
11871199
}
1188-
#endif /* CONFIG_ACPI */
11891200

11901201
int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg *hw_cfg)
11911202
{
@@ -1317,7 +1328,7 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg *
13171328
goto err;
13181329
}
13191330

1320-
ret = cs35l41_acpi_get_name(cs35l41);
1331+
ret = cs35l41_get_system_name(cs35l41);
13211332
if (ret < 0)
13221333
goto err;
13231334

0 commit comments

Comments
 (0)