All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Dooks <ben@simtec.co.uk>
To: alsa-devel@alsa-project.org
Subject: tlv320aic3x: Allow driver to use already registered i2c device
Date: Fri, 07 Aug 2009 00:02:05 +0100	[thread overview]
Message-ID: <20090806230204.992074844@fluff.org.uk> (raw)

[-- 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'

             reply	other threads:[~2009-08-06 23:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-06 23:02 Ben Dooks [this message]
2009-08-07  9:43 ` tlv320aic3x: Allow driver to use already registered i2c device Mark Brown
     [not found]   ` <4A84148E.7050307@simtec.co.uk>
2009-08-13 13:48     ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090806230204.992074844@fluff.org.uk \
    --to=ben@simtec.co.uk \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.