Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: loongson: fix error codes in loongson_card_parse_acpi()

The acpi_node_get_property_reference() function returns kernel error
codes and not ACPI error codes. So, although it does not affect the
compiled code, using the ACPI_FAILURE() macro is wrong. Secondly,
if the is_acpi_device_node() function returns false, then we should
return -ENOENT instead of returning success.

Fixes: d24028606e76 ("ASoC: loongson: Add Loongson ASoC Sound Card Support")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/fb14815d-2f9a-4b42-b193-cec61e7417ca@moroto.mountain
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Dan Carpenter and committed by
Mark Brown
8fba13f0 2f76e1d6

+4 -4
+4 -4
sound/soc/loongson/loongson_card.c
··· 81 81 /* fixup platform name based on reference node */ 82 82 memset(&args, 0, sizeof(args)); 83 83 ret = acpi_node_get_property_reference(fwnode, "cpu", 0, &args); 84 - if (ACPI_FAILURE(ret) || !is_acpi_device_node(args.fwnode)) { 84 + if (ret || !is_acpi_device_node(args.fwnode)) { 85 85 dev_err(card->dev, "No matching phy in ACPI table\n"); 86 - return ret; 86 + return ret ?: -ENOENT; 87 87 } 88 88 adev = to_acpi_device_node(args.fwnode); 89 89 phy_dev = acpi_get_first_physical_node(adev); ··· 95 95 /* fixup codec name based on reference node */ 96 96 memset(&args, 0, sizeof(args)); 97 97 ret = acpi_node_get_property_reference(fwnode, "codec", 0, &args); 98 - if (ACPI_FAILURE(ret) || !is_acpi_device_node(args.fwnode)) { 98 + if (ret || !is_acpi_device_node(args.fwnode)) { 99 99 dev_err(card->dev, "No matching phy in ACPI table\n"); 100 - return ret; 100 + return ret ?: -ENOENT; 101 101 } 102 102 adev = to_acpi_device_node(args.fwnode); 103 103 snprintf(codec_name, sizeof(codec_name), "i2c-%s", acpi_dev_name(adev));