tlv320aic3x: Allow driver to use already registered i2c device
Subsystems (3)
Add the ability for the driver to use an already registered i2c device instead of creating one of them itself. Add the field i2c_already field to the setup data and not set the i2c bus address the driver will then use the device already setup.
--- sound/soc/codecs/tlv320aic3x.c | 9 ++++++++- sound/soc/codecs/tlv320aic3x.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-)
sound/soc/codecs/tlv320aic3x.c +8 -1
@@ -1310,6 +1310,7 @@ static int aic3x_i2c_remove(struct i2c_cstatic const struct i2c_device_id aic3x_i2c_id[] = { {"tlv320aic3x" ,0 }, + {"tlv320aic33" ,0 }, { } };MODULE_DEVICE_TABLE (i2c, aic3x_i2c_id);
@@ -1405,6 +1406,10 @@ static int aic3x_probe(struct platform_d codec->hw_write = (hw_write_t ) i2c_master_send; codec->hw_read = (hw_read_t ) aic3x_i2c_read; ret = aic3x_add_i2c_device(pdev, setup); + }else if (setup->i2c_already) { + codec->hw_write = (hw_write_t ) i2c_master_send; + codec->hw_read = (hw_read_t ) aic3x_i2c_read; +i2c_add_driver (&aic3x_i2c_driver); }#else /* Add other interfaces here */
@@ -1421,6 +1426,7 @@ static int aic3x_remove(struct platform_ {struct snd_soc_device *socdev =platform_get_drvdata (pdev);struct snd_soc_codec *codec = socdev->card->codec; +struct aic3x_setup_data *setup = socdev->codec_data;/* power down chip */ if (codec->control_data)
@@ -1429,7 +1435,8 @@ static int aic3x_remove(struct platform_snd_soc_free_pcms (socdev);snd_soc_dapm_free (socdev);#if defined(CONFIG_I2C ) || defined(CONFIG_I2C_MODULE ) -i2c_unregister_device (codec->control_data); +if (setup && !setup->i2c_already) +i2c_unregister_device (codec->control_data);i2c_del_driver (&aic3x_i2c_driver);#endif kfree (codec->private_data);
sound/soc/codecs/tlv320aic3x.h +1 -0
@@ -283,6 +283,7 @@ int aic3x_button_pressed(struct snd_soc_struct aic3x_setup_data {int i2c_bus; +unsigned char i2c_already;/* i2c device already registered */ unsigned short i2c_address;unsigned int gpio_func[2 ]; };
Signature · 3 lines
Ben ([email protected], http://www.fluff.org/) 'a smiley only costs 4 bytes'
Quoted 4 lines · Ben Dooks
Add the ability for the driver to use an already registered i2c device instead of creating one of them itself. Add the field
i2c_alreadyfield to the setup data and not set the i2c bus address the driver will then use the device already setup.
Why would you want to do this? I suspect that perhaps you want to convert the driver to use the standard device model instead but without understanding your motivation for making this change it is very hard to comment in detail.
sound/soc/codecs/tlv320aic3x.c static int aic3x_i2c_remove(struct i2c_c · line 1315
Quoted 9 lines
sound/soc/codecs/tlv320aic3x.c +1
-0@@ -1310,6 +1310,7 @@ static int aic3x_i2c_remove(struct i2c_cstatic const struct i2c_device_id aic3x_i2c_id[] = { {"tlv320aic3x" ,0 }, + {"tlv320aic33" ,0 }, { } };
This is a reasonable but unrelated change.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · Ben Dooks
Quoted 4 lines · Mark Brown
Why would you want to do this? I suspect that perhaps you want to convert the driver to use the standard device model instead but without understanding your motivation for making this change it is very hard to comment in detail.
The device is registered by the code that sets the initial devices up that have been passed from the bootloader, thus the tlv320aic33 fails to initialise as there is already an i2c device on the i2c bus when it comes along.
OK, that's what I thought. You need to convert the driver to use the normal device model probe methods rather than using bodges like this. See drivers like wm8731 for an example of how the conversion looks.