* tlv320aic3x: Allow driver to use already registered i2c device
@ 2009-08-06 23:02 Ben Dooks
2009-08-07 9:43 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Ben Dooks @ 2009-08-06 23:02 UTC (permalink / raw)
To: alsa-devel
[-- Attachment #1: dbg-tlv320aic33.patch --]
[-- Type: text/plain, Size: 2567 bytes --]
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.
Signed-off-by: Ben Dooks <ben@simtec.co.uk>
---
sound/soc/codecs/tlv320aic3x.c | 9 ++++++++-
sound/soc/codecs/tlv320aic3x.h | 1 +
2 files changed, 9 insertions(+), 1 deletion(-)
Index: b/sound/soc/codecs/tlv320aic3x.c
===================================================================
--- a/sound/soc/codecs/tlv320aic3x.c 2009-08-06 11:53:30.000000000 +0100
+++ b/sound/soc/codecs/tlv320aic3x.c 2009-08-06 15:29:45.000000000 +0100
@@ -1310,6 +1310,7 @@ static int aic3x_i2c_remove(struct i2c_c
static 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);
Index: b/sound/soc/codecs/tlv320aic3x.h
===================================================================
--- a/sound/soc/codecs/tlv320aic3x.h 2009-08-06 11:53:30.000000000 +0100
+++ b/sound/soc/codecs/tlv320aic3x.h 2009-08-06 12:11:03.000000000 +0100
@@ -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];
};
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: tlv320aic3x: Allow driver to use already registered i2c device
2009-08-06 23:02 tlv320aic3x: Allow driver to use already registered i2c device Ben Dooks
@ 2009-08-07 9:43 ` Mark Brown
[not found] ` <4A84148E.7050307@simtec.co.uk>
0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2009-08-07 9:43 UTC (permalink / raw)
To: Ben Dooks; +Cc: alsa-devel
On Fri, Aug 07, 2009 at 12:02:05AM +0100, Ben Dooks wrote:
> 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.
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.
> --- a/sound/soc/codecs/tlv320aic3x.c 2009-08-06 11:53:30.000000000 +0100
> +++ b/sound/soc/codecs/tlv320aic3x.c 2009-08-06 15:29:45.000000000 +0100
> @@ -1310,6 +1310,7 @@ static int aic3x_i2c_remove(struct i2c_c
>
> static const struct i2c_device_id aic3x_i2c_id[] = {
> { "tlv320aic3x", 0 },
> + { "tlv320aic33", 0 },
> { }
> };
This is a reasonable but unrelated change.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: tlv320aic3x: Allow driver to use already registered i2c device
[not found] ` <4A84148E.7050307@simtec.co.uk>
@ 2009-08-13 13:48 ` Mark Brown
0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2009-08-13 13:48 UTC (permalink / raw)
To: Ben Dooks; +Cc: alsa-devel
On Thu, Aug 13, 2009 at 02:26:38PM +0100, Ben Dooks wrote:
> Mark Brown wrote:
> >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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-08-13 13:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-06 23:02 tlv320aic3x: Allow driver to use already registered i2c device Ben Dooks
2009-08-07 9:43 ` Mark Brown
[not found] ` <4A84148E.7050307@simtec.co.uk>
2009-08-13 13:48 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox