ASoC: tas2781: Explicit association of Device, Device Name, and Device ID
Subsystems (3)
Shenghao Ding
maintainerPATCH 1/1 ASoC: tas2781: Explicit association of Device, Device Name, and Device ID
By correlating devices with their names and IDs, the driver becomes more discoverable.
---
v1:
- Added a new column to the tasdevice_acpi_match[] link each ACPI ID with its respective device name.
- Introduced a similar association in the tasdevice_of_match[] by including device names alongside their compatible strings.
- Refactor code to optimize device name retrieval logic.
- remove the assignment of .id_table in tasdevice_i2c_driver[].
--- sound/soc/codecs/tas2781-i2c.c | 104 ++++++++++++++++----------------- 1 file changed, 51 insertions(+), 53 deletions(-)
sound/soc/codecs/tas2781-i2c.c +51 -53
@@ -121,29 +121,28 @@ static const struct i2c_device_id tasdevice_id[] = { { "tas5830", TAS5830 }, {} }; -MODULE_DEVICE_TABLE (i2c, tasdevice_id);#ifdef CONFIG_OF static const struct of_device_id tasdevice_of_match[] = { - { .compatible ="ti,tas2020" }, - { .compatible ="ti,tas2118" }, - { .compatible ="ti,tas2120" }, - { .compatible ="ti,tas2320" }, - { .compatible ="ti,tas2563" }, - { .compatible ="ti,tas2568" }, - { .compatible ="ti,tas2570" }, - { .compatible ="ti,tas2572" }, - { .compatible ="ti,tas2574" }, - { .compatible ="ti,tas2781" }, - { .compatible ="ti,tas5802" }, - { .compatible ="ti,tas5806m" }, - { .compatible ="ti,tas5806md" }, - { .compatible ="ti,tas5815" }, - { .compatible ="ti,tas5822" }, - { .compatible ="ti,tas5825" }, - { .compatible ="ti,tas5827" }, - { .compatible ="ti,tas5828" }, - { .compatible ="ti,tas5830" }, + { .compatible ="ti,tas2020" , .data = &tasdevice_id[TAS2020 ] }, + { .compatible ="ti,tas2118" , .data = &tasdevice_id[TAS2118 ] }, + { .compatible ="ti,tas2120" , .data = &tasdevice_id[TAS2120 ] }, + { .compatible ="ti,tas2320" , .data = &tasdevice_id[TAS2320 ] }, + { .compatible ="ti,tas2563" , .data = &tasdevice_id[TAS2563 ] }, + { .compatible ="ti,tas2568" , .data = &tasdevice_id[TAS2568 ] }, + { .compatible ="ti,tas2570" , .data = &tasdevice_id[TAS2570 ] }, + { .compatible ="ti,tas2572" , .data = &tasdevice_id[TAS2572 ] }, + { .compatible ="ti,tas2574" , .data = &tasdevice_id[TAS2574 ] }, + { .compatible ="ti,tas2781" , .data = &tasdevice_id[TAS2781 ] }, + { .compatible ="ti,tas5802" , .data = &tasdevice_id[TAS5802 ] }, + { .compatible ="ti,tas5806m" , .data = &tasdevice_id[TAS5806M ] }, + { .compatible ="ti,tas5806md" , .data = &tasdevice_id[TAS5806MD ] }, + { .compatible ="ti,tas5815" , .data = &tasdevice_id[TAS5815 ] }, + { .compatible ="ti,tas5822" , .data = &tasdevice_id[TAS5822 ] }, + { .compatible ="ti,tas5825" , .data = &tasdevice_id[TAS5825 ] }, + { .compatible ="ti,tas5827" , .data = &tasdevice_id[TAS5827 ] }, + { .compatible ="ti,tas5828" , .data = &tasdevice_id[TAS5828 ] }, + { .compatible ="ti,tas5830" , .data = &tasdevice_id[TAS5830 ] }, {}, };MODULE_DEVICE_TABLE (of, tasdevice_of_match);
@@ -2023,15 +2022,12 @@ static void tasdevice_parse_dt(struct tasdevice_priv *tas_priv)if (IS_ERR (tas_priv->reset))dev_err (tas_priv->dev,"%s Can't get reset GPIO\n" , __func__); - -strscpy (tas_priv->dev_name, tasdevice_id[tas_priv->chip_id].name, -sizeof (tas_priv->dev_name)); }static int tasdevice_i2c_probe (struct i2c_client *i2c) { -const struct acpi_device_id *acpi_id;struct tasdevice_priv *tas_priv; +struct i2c_device_id *id_data;int ret; tas_priv =tasdevice_kzalloc (i2c);
@@ -2041,20 +2037,23 @@ static int tasdevice_i2c_probe(struct i2c_client *i2c)dev_set_drvdata (&i2c->dev, tas_priv);if (ACPI_HANDLE (&i2c->dev)) { - acpi_id =acpi_match_device (i2c->dev.driver->acpi_match_table, - &i2c->dev); -if (!acpi_id) { -dev_err (&i2c->dev,"No driver data\n" ); - ret = -EINVAL ; - goto err; - } - tas_priv->chip_id = acpi_id->driver_data; + id_data = (struct i2c_device_id *) +acpi_device_get_match_data (&i2c->dev); tas_priv->isacpi = true; }else { - tas_priv->chip_id = (uintptr_t )i2c_get_match_data (i2c); + id_data = (struct i2c_device_id *)i2c_get_match_data (i2c); tas_priv->isacpi = false; } +if (!id_data) { +dev_err (&i2c->dev,"No driver data\n" ); + ret = -EINVAL ; + goto err; + } + + tas_priv->chip_id = (uintptr_t )id_data->driver_data; +strscpy (tas_priv->dev_name, id_data->name,sizeof (tas_priv->dev_name)); +tasdevice_parse_dt (tas_priv); ret =tasdevice_init (tas_priv);
@@ -2086,25 +2085,25 @@ static void tasdevice_i2c_remove(struct i2c_client *client)#ifdef CONFIG_ACPI static const struct acpi_device_id tasdevice_acpi_match[] = { - {"TXNW2020" ,TAS2020 }, - {"TXNW2118" ,TAS2118 }, - {"TXNW2120" ,TAS2120 }, - {"TXNW2320" ,TAS2320 }, - {"TXNW2563" ,TAS2563 }, - {"TXNW2568" ,TAS2568 }, - {"TXNW2570" ,TAS2570 }, - {"TXNW2572" ,TAS2572 }, - {"TXNW2574" ,TAS2574 }, - {"TXNW2781" ,TAS2781 }, - {"TXNW5802" ,TAS5802 }, - {"TXNW806M" ,TAS5806M }, - {"TXNW806D" ,TAS5806MD }, - {"TXNW5815" ,TAS5815 }, - {"TXNW5822" ,TAS5822 }, - {"TXNW5825" ,TAS5825 }, - {"TXNW5827" ,TAS5827 }, - {"TXNW5828" ,TAS5828 }, - {"TXNW5830" ,TAS5830 }, + {"TXNW2020" , &tasdevice_id[TAS2020 ] }, + {"TXNW2118" , &tasdevice_id[TAS2118 ] }, + {"TXNW2120" , &tasdevice_id[TAS2120 ] }, + {"TXNW2320" , &tasdevice_id[TAS2320 ] }, + {"TXNW2563" , &tasdevice_id[TAS2563 ] }, + {"TXNW2568" , &tasdevice_id[TAS2568 ] }, + {"TXNW2570" , &tasdevice_id[TAS2570 ] }, + {"TXNW2572" , &tasdevice_id[TAS2572 ] }, + {"TXNW2574" , &tasdevice_id[TAS2574 ] }, + {"TXNW2781" , &tasdevice_id[TAS2781 ] }, + {"TXNW5802" , &tasdevice_id[TAS5802 ] }, + {"TXNW806M" , &tasdevice_id[TAS5806M ] }, + {"TXNW806D" , &tasdevice_id[TAS5806MD ] }, + {"TXNW5815" , &tasdevice_id[TAS5815 ] }, + {"TXNW5822" , &tasdevice_id[TAS5822 ] }, + {"TXNW5825" , &tasdevice_id[TAS5825 ] }, + {"TXNW5827" , &tasdevice_id[TAS5827 ] }, + {"TXNW5828" , &tasdevice_id[TAS5828 ] }, + {"TXNW5830" , &tasdevice_id[TAS5830 ] }, {}, };
@@ -2121,7 +2120,6 @@ static struct i2c_driver tasdevice_i2c_driver = { }, .probe = tasdevice_i2c_probe, .remove = tasdevice_i2c_remove, - .id_table = tasdevice_id, };module_i2c_driver (tasdevice_i2c_driver);
Signature · 1 line
2.43.0
Mark Brown
maintainerQuoted 2 lines · Shenghao Ding
By correlating devices with their names and IDs, the driver becomes more discoverable.
This breaks an x86_64 allmodconfig build:
/build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2088:23: error: initialization of ‘long unsigned int’ from ‘const struct i2c_device_id *’ makes integer from pointer without a cast [-Wint-conversion]
2088 | { "TXNW2020", &tasdevice_id[TAS2020] },
| ^
/build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2088:23: note: (near initialization for ‘tasdevice_acpi_match[0].driver_data’) /build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2089:23: error: initialization of ‘long unsigned int’ from ‘const struct i2c_device_id *’ makes integer from pointer without a cast [-Wint-conversion]
2089 | { "TXNW2118", &tasdevice_id[TAS2118] },
| ^
/build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2089:23: note: (near initialization for ‘tasdevice_acpi_match[1].driver_data’) /build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2090:23: error: initialization of ‘long unsigned int’ from ‘const struct i2c_device_id *’ makes integer from pointer without a cast [-Wint-conversion]
2090 | { "TXNW2120", &tasdevice_id[TAS2120] },
| ^
/build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2090:23: note: (near initialization for ‘tasdevice_acpi_match[2].driver_data’) /build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2091:23: error: initialization of ‘long unsigned int’ from ‘const struct i2c_device_id *’ makes integer from pointer without a cast [-Wint-conversion]
2091 | { "TXNW2320", &tasdevice_id[TAS2320] },
| ^
/build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2091:23: note: (near initialization for ‘tasdevice_acpi_match[3].driver_data’) /build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2092:23: error: initialization of ‘long unsigned int’ from ‘const struct i2c_device_id *’ makes integer from pointer without a cast [-Wint-conversion]
2092 | { "TXNW2563", &tasdevice_id[TAS2563] },
| ^
/build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2092:23: note: (near initialization for ‘tasdevice_acpi_match[4].driver_data’) /build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2093:23: error: initialization of ‘long unsigned int’ from ‘const struct i2c_device_id *’ makes integer from pointer without a cast [-Wint-conversion]
2093 | { "TXNW2568", &tasdevice_id[TAS2568] },
| ^
/build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2093:23: note: (near initialization for ‘tasdevice_acpi_match[5].driver_data’) /build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2094:23: error: initialization of ‘long unsigned int’ from ‘const struct i2c_device_id *’ makes integer from pointer without a cast [-Wint-conversion]
2094 | { "TXNW2570", &tasdevice_id[TAS2570] },
| ^
/build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2094:23: note: (near initialization for ‘tasdevice_acpi_match[6].driver_data’) /build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2095:23: error: initialization of ‘long unsigned int’ from ‘const struct i2c_device_id *’ makes integer from pointer without a cast [-Wint-conversion]
2095 | { "TXNW2572", &tasdevice_id[TAS2572] },
| ^
/build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2095:23: note: (near initialization for ‘tasdevice_acpi_match[7].driver_data’) /build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2096:23: error: initialization of ‘long unsigned int’ from ‘const struct i2c_device_id *’ makes integer from pointer without a cast [-Wint-conversion]
2096 | { "TXNW2574", &tasdevice_id[TAS2574] },
| ^
/build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2096:23: note: (near initialization for ‘tasdevice_acpi_match[8].driver_data’) /build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2097:23: error: initialization of ‘long unsigned int’ from ‘const struct i2c_device_id *’ makes integer from pointer without a cast [-Wint-conversion]
2097 | { "TXNW2781", &tasdevice_id[TAS2781] },
| ^
/build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2097:23: note: (near initialization for ‘tasdevice_acpi_match[9].driver_data’) /build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2098:23: error: initialization of ‘long unsigned int’ from ‘const struct i2c_device_id *’ makes integer from pointer without a cast [-Wint-conversion]
2098 | { "TXNW5802", &tasdevice_id[TAS5802] },
| ^
/build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2098:23: note: (near initialization for ‘tasdevice_acpi_match[10].driver_data’) /build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2099:23: error: initialization of ‘long unsigned int’ from ‘const struct i2c_device_id *’ makes integer from pointer without a cast [-Wint-conversion]
2099 | { "TXNW806M", &tasdevice_id[TAS5806M] },
| ^
/build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2099:23: note: (near initialization for ‘tasdevice_acpi_match[11].driver_data’) /build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2100:23: error: initialization of ‘long unsigned int’ from ‘const struct i2c_device_id *’ makes integer from pointer without a cast [-Wint-conversion]
2100 | { "TXNW806D", &tasdevice_id[TAS5806MD] },
| ^
/build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2100:23: note: (near initialization for ‘tasdevice_acpi_match[12].driver_data’) /build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2101:23: error: initialization of ‘long unsigned int’ from ‘const struct i2c_device_id *’ makes integer from pointer without a cast [-Wint-conversion]
2101 | { "TXNW5815", &tasdevice_id[TAS5815] },
| ^
/build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2101:23: note: (near initialization for ‘tasdevice_acpi_match[13].driver_data’) /build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2102:23: error: initialization of ‘long unsigned int’ from ‘const struct i2c_device_id *’ makes integer from pointer without a cast [-Wint-conversion]
2102 | { "TXNW5822", &tasdevice_id[TAS5822] },
| ^
/build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2102:23: note: (near initialization for ‘tasdevice_acpi_match[14].driver_data’) /build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2103:23: error: initialization of ‘long unsigned int’ from ‘const struct i2c_device_id *’ makes integer from pointer without a cast [-Wint-conversion]
2103 | { "TXNW5825", &tasdevice_id[TAS5825] },
| ^
/build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2103:23: note: (near initialization for ‘tasdevice_acpi_match[15].driver_data’) /build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2104:23: error: initialization of ‘long unsigned int’ from ‘const struct i2c_device_id *’ makes integer from pointer without a cast [-Wint-conversion]
2104 | { "TXNW5827", &tasdevice_id[TAS5827] },
| ^
/build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2104:23: note: (near initialization for ‘tasdevice_acpi_match[16].driver_data’) /build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2105:23: error: initialization of ‘long unsigned int’ from ‘const struct i2c_device_id *’ makes integer from pointer without a cast [-Wint-conversion]
2105 | { "TXNW5828", &tasdevice_id[TAS5828] },
| ^
/build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2105:23: note: (near initialization for ‘tasdevice_acpi_match[17].driver_data’) /build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2106:23: error: initialization of ‘long unsigned int’ from ‘const struct i2c_device_id *’ makes integer from pointer without a cast [-Wint-conversion]
2106 | { "TXNW5830", &tasdevice_id[TAS5830] },
| ^
/build/stage/linux/sound/soc/codecs/tas2781-i2c.c:2106:23: note: (near initialization for ‘tasdevice_acpi_match[18].driver_data’)
Mark Brown
maintainerQuoted 1 line · Shenghao Ding
ASoC: tas2781: Explicit association of Device, Device Name, and Device ID
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.1
Thanks!
[1/1] ASoC: tas2781: Explicit association of Device, Device Name, and Device ID
https://git.kernel.org/broonie/sound/c/78c59297280b
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark