Commit 8ca3ee6f authored by Richard Fitzgerald's avatar Richard Fitzgerald Committed by Takashi Iwai

ALSA: hda/cs35l56: Reject I2C alias addresses

The ACPI nodes for CS35L56 can contain an extra I2CSerialBusV2 that
is not a real device, it is an alias address.

This alias address will not be in the cirrus,dev-index array, so reject
any instantions with a device address not found in the array.
Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230731165726.7940-10-rf@opensource.cirrus.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 3106797d
...@@ -852,8 +852,12 @@ static int cs35l56_hda_read_acpi(struct cs35l56_hda *cs35l56, int id) ...@@ -852,8 +852,12 @@ static int cs35l56_hda_read_acpi(struct cs35l56_hda *cs35l56, int id)
break; break;
} }
} }
/*
* It's not an error for the ID to be missing: for I2C there can be
* an alias address that is not a real device. So reject silently.
*/
if (cs35l56->index == -1) { if (cs35l56->index == -1) {
dev_err(cs35l56->base.dev, "No index found in %s\n", property); dev_dbg(cs35l56->base.dev, "No index found in %s\n", property);
ret = -ENODEV; ret = -ENODEV;
goto err; goto err;
} }
...@@ -891,7 +895,8 @@ static int cs35l56_hda_read_acpi(struct cs35l56_hda *cs35l56, int id) ...@@ -891,7 +895,8 @@ static int cs35l56_hda_read_acpi(struct cs35l56_hda *cs35l56, int id)
return 0; return 0;
err: err:
dev_err(cs35l56->base.dev, "Failed property %s: %d\n", property, ret); if (ret != -ENODEV)
dev_err(cs35l56->base.dev, "Failed property %s: %d\n", property, ret);
return ret; return ret;
} }
...@@ -904,10 +909,8 @@ int cs35l56_hda_common_probe(struct cs35l56_hda *cs35l56, int id) ...@@ -904,10 +909,8 @@ int cs35l56_hda_common_probe(struct cs35l56_hda *cs35l56, int id)
dev_set_drvdata(cs35l56->base.dev, cs35l56); dev_set_drvdata(cs35l56->base.dev, cs35l56);
ret = cs35l56_hda_read_acpi(cs35l56, id); ret = cs35l56_hda_read_acpi(cs35l56, id);
if (ret) { if (ret)
dev_err_probe(cs35l56->base.dev, ret, "Platform not supported\n");
goto err; goto err;
}
cs35l56->amp_name = devm_kasprintf(cs35l56->base.dev, GFP_KERNEL, "AMP%d", cs35l56->amp_name = devm_kasprintf(cs35l56->base.dev, GFP_KERNEL, "AMP%d",
cs35l56->index + 1); cs35l56->index + 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment