Skip to content

Commit 1d44a30

Browse files
Stefan Bindingbroonie
authored andcommitted
ASoC: cs35l41: Fallback to using HID for system_name if no SUB is available
For systems which load firmware on the cs35l41 which use ACPI, the _SUB value is used to differentiate firmware and tuning files for the individual systems. In the case where a system does not have a _SUB defined in ACPI node for cs35l41, there needs to be a fallback to allow the files for that system to be differentiated. Since all ACPI nodes for cs35l41 should have a HID defined, the HID should be a safe option. Signed-off-by: Stefan Binding <[email protected]> Reviewed-by: André Almeida <[email protected]> Tested-by: André Almeida <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 6790749 commit 1d44a30

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

sound/soc/codecs/cs35l41.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,19 +1150,28 @@ static int cs35l41_dsp_init(struct cs35l41_private *cs35l41)
11501150

11511151
static int cs35l41_acpi_get_name(struct cs35l41_private *cs35l41)
11521152
{
1153-
acpi_handle handle = ACPI_HANDLE(cs35l41->dev);
1153+
struct acpi_device *adev = ACPI_COMPANION(cs35l41->dev);
1154+
acpi_handle handle = acpi_device_handle(adev);
1155+
const char *hid;
11541156
const char *sub;
11551157

1156-
/* If there is no ACPI_HANDLE, there is no ACPI for this system, return 0 */
1157-
if (!handle)
1158+
/* If there is no acpi_device, there is no ACPI for this system, return 0 */
1159+
if (!adev)
11581160
return 0;
11591161

11601162
sub = acpi_get_subsystem_id(handle);
11611163
if (IS_ERR(sub)) {
1162-
/* If bad ACPI, return 0 and fallback to legacy firmware path, otherwise fail */
1163-
if (PTR_ERR(sub) == -ENODATA)
1164-
return 0;
1165-
else
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
11661175
return PTR_ERR(sub);
11671176
}
11681177

0 commit comments

Comments
 (0)