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

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: tas2781: Explicit association of Device, Device Name, and Device ID

By correlating devices with their names and IDs, the driver becomes more
discoverable.

Signed-off-by: Shenghao Ding <shenghao-ding@ti.com>
Link: https://patch.msgid.link/20260406103131.1883-1-shenghao-ding@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Shenghao Ding and committed by
Mark Brown
9a52d1b7 3f4aa994

+51 -53
+51 -53
sound/soc/codecs/tas2781-i2c.c
··· 121 121 { "tas5830", TAS5830 }, 122 122 {} 123 123 }; 124 - MODULE_DEVICE_TABLE(i2c, tasdevice_id); 125 124 126 125 #ifdef CONFIG_OF 127 126 static const struct of_device_id tasdevice_of_match[] = { 128 - { .compatible = "ti,tas2020" }, 129 - { .compatible = "ti,tas2118" }, 130 - { .compatible = "ti,tas2120" }, 131 - { .compatible = "ti,tas2320" }, 132 - { .compatible = "ti,tas2563" }, 133 - { .compatible = "ti,tas2568" }, 134 - { .compatible = "ti,tas2570" }, 135 - { .compatible = "ti,tas2572" }, 136 - { .compatible = "ti,tas2574" }, 137 - { .compatible = "ti,tas2781" }, 138 - { .compatible = "ti,tas5802" }, 139 - { .compatible = "ti,tas5806m" }, 140 - { .compatible = "ti,tas5806md" }, 141 - { .compatible = "ti,tas5815" }, 142 - { .compatible = "ti,tas5822" }, 143 - { .compatible = "ti,tas5825" }, 144 - { .compatible = "ti,tas5827" }, 145 - { .compatible = "ti,tas5828" }, 146 - { .compatible = "ti,tas5830" }, 127 + { .compatible = "ti,tas2020", .data = &tasdevice_id[TAS2020] }, 128 + { .compatible = "ti,tas2118", .data = &tasdevice_id[TAS2118] }, 129 + { .compatible = "ti,tas2120", .data = &tasdevice_id[TAS2120] }, 130 + { .compatible = "ti,tas2320", .data = &tasdevice_id[TAS2320] }, 131 + { .compatible = "ti,tas2563", .data = &tasdevice_id[TAS2563] }, 132 + { .compatible = "ti,tas2568", .data = &tasdevice_id[TAS2568] }, 133 + { .compatible = "ti,tas2570", .data = &tasdevice_id[TAS2570] }, 134 + { .compatible = "ti,tas2572", .data = &tasdevice_id[TAS2572] }, 135 + { .compatible = "ti,tas2574", .data = &tasdevice_id[TAS2574] }, 136 + { .compatible = "ti,tas2781", .data = &tasdevice_id[TAS2781] }, 137 + { .compatible = "ti,tas5802", .data = &tasdevice_id[TAS5802] }, 138 + { .compatible = "ti,tas5806m", .data = &tasdevice_id[TAS5806M] }, 139 + { .compatible = "ti,tas5806md", .data = &tasdevice_id[TAS5806MD] }, 140 + { .compatible = "ti,tas5815", .data = &tasdevice_id[TAS5815] }, 141 + { .compatible = "ti,tas5822", .data = &tasdevice_id[TAS5822] }, 142 + { .compatible = "ti,tas5825", .data = &tasdevice_id[TAS5825] }, 143 + { .compatible = "ti,tas5827", .data = &tasdevice_id[TAS5827] }, 144 + { .compatible = "ti,tas5828", .data = &tasdevice_id[TAS5828] }, 145 + { .compatible = "ti,tas5830", .data = &tasdevice_id[TAS5830] }, 147 146 {}, 148 147 }; 149 148 MODULE_DEVICE_TABLE(of, tasdevice_of_match); ··· 2022 2023 if (IS_ERR(tas_priv->reset)) 2023 2024 dev_err(tas_priv->dev, "%s Can't get reset GPIO\n", 2024 2025 __func__); 2025 - 2026 - strscpy(tas_priv->dev_name, tasdevice_id[tas_priv->chip_id].name, 2027 - sizeof(tas_priv->dev_name)); 2028 2026 } 2029 2027 2030 2028 static int tasdevice_i2c_probe(struct i2c_client *i2c) 2031 2029 { 2032 - const struct acpi_device_id *acpi_id; 2033 2030 struct tasdevice_priv *tas_priv; 2031 + struct i2c_device_id *id_data; 2034 2032 int ret; 2035 2033 2036 2034 tas_priv = tasdevice_kzalloc(i2c); ··· 2037 2041 dev_set_drvdata(&i2c->dev, tas_priv); 2038 2042 2039 2043 if (ACPI_HANDLE(&i2c->dev)) { 2040 - acpi_id = acpi_match_device(i2c->dev.driver->acpi_match_table, 2041 - &i2c->dev); 2042 - if (!acpi_id) { 2043 - dev_err(&i2c->dev, "No driver data\n"); 2044 - ret = -EINVAL; 2045 - goto err; 2046 - } 2047 - tas_priv->chip_id = acpi_id->driver_data; 2044 + id_data = (struct i2c_device_id *) 2045 + acpi_device_get_match_data(&i2c->dev); 2048 2046 tas_priv->isacpi = true; 2049 2047 } else { 2050 - tas_priv->chip_id = (uintptr_t)i2c_get_match_data(i2c); 2048 + id_data = (struct i2c_device_id *)i2c_get_match_data(i2c); 2051 2049 tas_priv->isacpi = false; 2052 2050 } 2051 + 2052 + if (!id_data) { 2053 + dev_err(&i2c->dev, "No driver data\n"); 2054 + ret = -EINVAL; 2055 + goto err; 2056 + } 2057 + 2058 + tas_priv->chip_id = (uintptr_t)id_data->driver_data; 2059 + strscpy(tas_priv->dev_name, id_data->name, sizeof(tas_priv->dev_name)); 2053 2060 2054 2061 tasdevice_parse_dt(tas_priv); 2055 2062 ··· 2085 2086 2086 2087 #ifdef CONFIG_ACPI 2087 2088 static const struct acpi_device_id tasdevice_acpi_match[] = { 2088 - { "TXNW2020", TAS2020 }, 2089 - { "TXNW2118", TAS2118 }, 2090 - { "TXNW2120", TAS2120 }, 2091 - { "TXNW2320", TAS2320 }, 2092 - { "TXNW2563", TAS2563 }, 2093 - { "TXNW2568", TAS2568 }, 2094 - { "TXNW2570", TAS2570 }, 2095 - { "TXNW2572", TAS2572 }, 2096 - { "TXNW2574", TAS2574 }, 2097 - { "TXNW2781", TAS2781 }, 2098 - { "TXNW5802", TAS5802 }, 2099 - { "TXNW806M", TAS5806M }, 2100 - { "TXNW806D", TAS5806MD }, 2101 - { "TXNW5815", TAS5815 }, 2102 - { "TXNW5822", TAS5822 }, 2103 - { "TXNW5825", TAS5825 }, 2104 - { "TXNW5827", TAS5827 }, 2105 - { "TXNW5828", TAS5828 }, 2106 - { "TXNW5830", TAS5830 }, 2089 + { "TXNW2020", (kernel_ulong_t)&tasdevice_id[TAS2020] }, 2090 + { "TXNW2118", (kernel_ulong_t)&tasdevice_id[TAS2118] }, 2091 + { "TXNW2120", (kernel_ulong_t)&tasdevice_id[TAS2120] }, 2092 + { "TXNW2320", (kernel_ulong_t)&tasdevice_id[TAS2320] }, 2093 + { "TXNW2563", (kernel_ulong_t)&tasdevice_id[TAS2563] }, 2094 + { "TXNW2568", (kernel_ulong_t)&tasdevice_id[TAS2568] }, 2095 + { "TXNW2570", (kernel_ulong_t)&tasdevice_id[TAS2570] }, 2096 + { "TXNW2572", (kernel_ulong_t)&tasdevice_id[TAS2572] }, 2097 + { "TXNW2574", (kernel_ulong_t)&tasdevice_id[TAS2574] }, 2098 + { "TXNW2781", (kernel_ulong_t)&tasdevice_id[TAS2781] }, 2099 + { "TXNW5802", (kernel_ulong_t)&tasdevice_id[TAS5802] }, 2100 + { "TXNW806M", (kernel_ulong_t)&tasdevice_id[TAS5806M] }, 2101 + { "TXNW806D", (kernel_ulong_t)&tasdevice_id[TAS5806MD] }, 2102 + { "TXNW5815", (kernel_ulong_t)&tasdevice_id[TAS5815] }, 2103 + { "TXNW5822", (kernel_ulong_t)&tasdevice_id[TAS5822] }, 2104 + { "TXNW5825", (kernel_ulong_t)&tasdevice_id[TAS5825] }, 2105 + { "TXNW5827", (kernel_ulong_t)&tasdevice_id[TAS5827] }, 2106 + { "TXNW5828", (kernel_ulong_t)&tasdevice_id[TAS5828] }, 2107 + { "TXNW5830", (kernel_ulong_t)&tasdevice_id[TAS5830] }, 2107 2108 {}, 2108 2109 }; 2109 2110 ··· 2120 2121 }, 2121 2122 .probe = tasdevice_i2c_probe, 2122 2123 .remove = tasdevice_i2c_remove, 2123 - .id_table = tasdevice_id, 2124 2124 }; 2125 2125 2126 2126 module_i2c_driver(tasdevice_i2c_driver);