From: Andreas Schwab <schwab@linux-m68k.org>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: linuxppc-dev@ozlabs.org
Subject: [PATCH] sound/aoa: remove i2c attach_adapter method
Date: Mon, 18 Jun 2012 09:30:09 +0200 [thread overview]
Message-ID: <m21uldvzzy.fsf_-_@igel.home> (raw)
In-Reply-To: <1339984980.2372.9.camel@pasglop> (Benjamin Herrenschmidt's message of "Mon, 18 Jun 2012 12:03:00 +1000")
Since i2c-powermac now creates all i2c devices on its own, remove the
attach_adapter methods from the TAS and Onyx drivers, and adjust the
module aliases to match the names used by i2c-powermac.
Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
---
sound/aoa/codecs/onyx.c | 75 ++--------------------------------------------
sound/aoa/codecs/tas.c | 80 ++-----------------------------------------------
2 files changed, 6 insertions(+), 149 deletions(-)
diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
index 270790d..4cedc69 100644
--- a/sound/aoa/codecs/onyx.c
+++ b/sound/aoa/codecs/onyx.c
@@ -997,45 +997,10 @@ static void onyx_exit_codec(struct aoa_codec *codec)
onyx->codec.soundbus_dev->detach_codec(onyx->codec.soundbus_dev, onyx);
}
-static int onyx_create(struct i2c_adapter *adapter,
- struct device_node *node,
- int addr)
-{
- struct i2c_board_info info;
- struct i2c_client *client;
-
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "aoa_codec_onyx", I2C_NAME_SIZE);
- info.addr = addr;
- info.platform_data = node;
- client = i2c_new_device(adapter, &info);
- if (!client)
- return -ENODEV;
-
- /*
- * We know the driver is already loaded, so the device should be
- * already bound. If not it means binding failed, which suggests
- * the device doesn't really exist and should be deleted.
- * Ideally this would be replaced by better checks _before_
- * instantiating the device.
- */
- if (!client->driver) {
- i2c_unregister_device(client);
- return -ENODEV;
- }
-
- /*
- * Let i2c-core delete that device on driver removal.
- * This is safe because i2c-core holds the core_lock mutex for us.
- */
- list_add_tail(&client->detected, &client->driver->clients);
- return 0;
-}
-
static int onyx_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
- struct device_node *node = client->dev.platform_data;
+ struct device_node *node = client->dev.of_node;
struct onyx *onyx;
u8 dummy;
@@ -1071,40 +1036,6 @@ static int onyx_i2c_probe(struct i2c_client *client,
return -ENODEV;
}
-static int onyx_i2c_attach(struct i2c_adapter *adapter)
-{
- struct device_node *busnode, *dev = NULL;
- struct pmac_i2c_bus *bus;
-
- bus = pmac_i2c_adapter_to_bus(adapter);
- if (bus == NULL)
- return -ENODEV;
- busnode = pmac_i2c_get_bus_node(bus);
-
- while ((dev = of_get_next_child(busnode, dev)) != NULL) {
- if (of_device_is_compatible(dev, "pcm3052")) {
- const u32 *addr;
- printk(KERN_DEBUG PFX "found pcm3052\n");
- addr = of_get_property(dev, "reg", NULL);
- if (!addr)
- return -ENODEV;
- return onyx_create(adapter, dev, (*addr)>>1);
- }
- }
-
- /* if that didn't work, try desperate mode for older
- * machines that have stuff missing from the device tree */
-
- if (!of_device_is_compatible(busnode, "k2-i2c"))
- return -ENODEV;
-
- printk(KERN_DEBUG PFX "found k2-i2c, checking if onyx chip is on it\n");
- /* probe both possible addresses for the onyx chip */
- if (onyx_create(adapter, NULL, 0x46) == 0)
- return 0;
- return onyx_create(adapter, NULL, 0x47);
-}
-
static int onyx_i2c_remove(struct i2c_client *client)
{
struct onyx *onyx = i2c_get_clientdata(client);
@@ -1117,16 +1048,16 @@ static int onyx_i2c_remove(struct i2c_client *client)
}
static const struct i2c_device_id onyx_i2c_id[] = {
- { "aoa_codec_onyx", 0 },
+ { "MAC,pcm3052", 0 },
{ }
};
+MODULE_DEVICE_TABLE(i2c,onyx_i2c_id);
static struct i2c_driver onyx_driver = {
.driver = {
.name = "aoa_codec_onyx",
.owner = THIS_MODULE,
},
- .attach_adapter = onyx_i2c_attach,
.probe = onyx_i2c_probe,
.remove = onyx_i2c_remove,
.id_table = onyx_i2c_id,
diff --git a/sound/aoa/codecs/tas.c b/sound/aoa/codecs/tas.c
index 8e63d1f..c491ae0 100644
--- a/sound/aoa/codecs/tas.c
+++ b/sound/aoa/codecs/tas.c
@@ -883,43 +883,10 @@ static void tas_exit_codec(struct aoa_codec *codec)
}
-static int tas_create(struct i2c_adapter *adapter,
- struct device_node *node,
- int addr)
-{
- struct i2c_board_info info;
- struct i2c_client *client;
-
- memset(&info, 0, sizeof(struct i2c_board_info));
- strlcpy(info.type, "aoa_codec_tas", I2C_NAME_SIZE);
- info.addr = addr;
- info.platform_data = node;
-
- client = i2c_new_device(adapter, &info);
- if (!client)
- return -ENODEV;
- /*
- * We know the driver is already loaded, so the device should be
- * already bound. If not it means binding failed, and then there
- * is no point in keeping the device instantiated.
- */
- if (!client->driver) {
- i2c_unregister_device(client);
- return -ENODEV;
- }
-
- /*
- * Let i2c-core delete that device on driver removal.
- * This is safe because i2c-core holds the core_lock mutex for us.
- */
- list_add_tail(&client->detected, &client->driver->clients);
- return 0;
-}
-
static int tas_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
- struct device_node *node = client->dev.platform_data;
+ struct device_node *node = client->dev.of_node;
struct tas *tas;
tas = kzalloc(sizeof(struct tas), GFP_KERNEL);
@@ -953,47 +920,6 @@ static int tas_i2c_probe(struct i2c_client *client,
return -EINVAL;
}
-static int tas_i2c_attach(struct i2c_adapter *adapter)
-{
- struct device_node *busnode, *dev = NULL;
- struct pmac_i2c_bus *bus;
-
- bus = pmac_i2c_adapter_to_bus(adapter);
- if (bus == NULL)
- return -ENODEV;
- busnode = pmac_i2c_get_bus_node(bus);
-
- while ((dev = of_get_next_child(busnode, dev)) != NULL) {
- if (of_device_is_compatible(dev, "tas3004")) {
- const u32 *addr;
- printk(KERN_DEBUG PFX "found tas3004\n");
- addr = of_get_property(dev, "reg", NULL);
- if (!addr)
- continue;
- return tas_create(adapter, dev, ((*addr) >> 1) & 0x7f);
- }
- /* older machines have no 'codec' node with a 'compatible'
- * property that says 'tas3004', they just have a 'deq'
- * node without any such property... */
- if (strcmp(dev->name, "deq") == 0) {
- const u32 *_addr;
- u32 addr;
- printk(KERN_DEBUG PFX "found 'deq' node\n");
- _addr = of_get_property(dev, "i2c-address", NULL);
- if (!_addr)
- continue;
- addr = ((*_addr) >> 1) & 0x7f;
- /* now, if the address doesn't match any of the two
- * that a tas3004 can have, we cannot handle this.
- * I doubt it ever happens but hey. */
- if (addr != 0x34 && addr != 0x35)
- continue;
- return tas_create(adapter, dev, addr);
- }
- }
- return -ENODEV;
-}
-
static int tas_i2c_remove(struct i2c_client *client)
{
struct tas *tas = i2c_get_clientdata(client);
@@ -1011,16 +937,16 @@ static int tas_i2c_remove(struct i2c_client *client)
}
static const struct i2c_device_id tas_i2c_id[] = {
- { "aoa_codec_tas", 0 },
+ { "MAC,tas3004", 0 },
{ }
};
+MODULE_DEVICE_TABLE(i2c,tas_i2c_id);
static struct i2c_driver tas_driver = {
.driver = {
.name = "aoa_codec_tas",
.owner = THIS_MODULE,
},
- .attach_adapter = tas_i2c_attach,
.probe = tas_i2c_probe,
.remove = tas_i2c_remove,
.id_table = tas_i2c_id,
--
1.7.11
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
next prev parent reply other threads:[~2012-06-18 7:30 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-19 8:16 [PATCH 00/15] PowerMac i2c API conversions & windfarm updates Benjamin Herrenschmidt
2012-04-19 8:16 ` [PATCH 01/15] i2c/powermac: Register i2c devices from device-tree Benjamin Herrenschmidt
2012-04-19 8:16 ` [PATCH 02/15] powerpc/pmac: Convert therm_adt746x to new i2c probing Benjamin Herrenschmidt
2012-04-19 8:16 ` [PATCH 03/15] powerpc/pmac: Convert windfarm_lm75 " Benjamin Herrenschmidt
2012-04-19 8:16 ` [PATCH 04/15] powerpc/pmac: Convert windfarm_max6690 " Benjamin Herrenschmidt
2012-04-19 8:16 ` [PATCH 05/15] powerpc/pmac: Convert windfarm_smu_sat " Benjamin Herrenschmidt
2012-04-19 8:16 ` [PATCH 06/15] powerpc/windfarm: const'ify and add "priv" field to controls & sensors Benjamin Herrenschmidt
2012-04-19 8:16 ` [PATCH 07/15] powerpc/pmac: Don't add_timer() twice Benjamin Herrenschmidt
2012-04-19 8:16 ` [PATCH 08/15] powerpc/windfarm: Remove spurrious sysfs_attr_init() Benjamin Herrenschmidt
2012-04-19 8:16 ` [PATCH 09/15] powerpc/windfarm: Improve display of fan speeds in sysfs Benjamin Herrenschmidt
2012-04-19 8:16 ` [PATCH 10/15] powerpc/windfarm: Add useful accessors Benjamin Herrenschmidt
2012-04-19 8:16 ` [PATCH 11/15] powerpc/windfarm: Add ad7417 sensor Benjamin Herrenschmidt
2012-04-19 8:16 ` [PATCH 12/15] powerpc/windfarm: Add lm87 sensor Benjamin Herrenschmidt
2012-04-19 8:16 ` [PATCH 13/15] powerpc/windfarm: Updates to lm75 and max6690 sensors Benjamin Herrenschmidt
2012-04-19 8:16 ` [PATCH 14/15] powerpc/windfarm: Add Fan Control Unit controls for G5s Benjamin Herrenschmidt
2012-04-19 8:16 ` [PATCH 15/15] powerpc/powermac: New windfarm driver for PowerMac G5 (AGP) and Xserve G5 Benjamin Herrenschmidt
[not found] ` <1334823416-9138-2-git-send-email-benh__33169.052625499$1334826821$gmane$org@kernel.crashing.org>
2012-04-19 9:34 ` [PATCH 01/15] i2c/powermac: Register i2c devices from device-tree Andreas Schwab
2012-06-09 13:58 ` Andreas Schwab
2012-06-09 22:11 ` Benjamin Herrenschmidt
2012-06-09 22:30 ` Andreas Schwab
2012-06-09 22:36 ` Benjamin Herrenschmidt
2012-06-09 22:59 ` Andreas Schwab
2012-06-09 23:10 ` Benjamin Herrenschmidt
2012-06-10 7:13 ` Andreas Schwab
2012-06-10 7:23 ` Benjamin Herrenschmidt
2012-06-10 11:35 ` Andreas Schwab
2012-06-18 1:27 ` Benjamin Herrenschmidt
2012-06-18 2:03 ` Benjamin Herrenschmidt
2012-06-18 7:30 ` Andreas Schwab [this message]
2012-04-19 9:37 ` [PATCH 00/15] PowerMac i2c API conversions & windfarm updates Jean Delvare
2012-04-19 9:36 ` Christian Kujau
2012-04-19 20:59 ` Benjamin Herrenschmidt
[not found] ` <20120419113723.03a24d46__2279.25503063506$1334829915$gmane$org@endymion.delvare>
2012-04-19 10:11 ` Andreas Schwab
2012-04-19 11:02 ` Jean Delvare
[not found] ` <m27gxc2fqq.fsf__16075.0973890119$1334830355$gmane$org@igel.home>
2012-04-19 10:14 ` Andreas Schwab
[not found] ` <m239802flw.fsf__48316.0902433612$1334830569$gmane$org@igel.home>
2012-04-19 10:19 ` Andreas Schwab
[not found] ` <1334823416-9138-3-git-send-email-benh__10691.3206204355$1334826366$gmane$org@kernel.crashing.org>
2012-04-19 13:10 ` [PATCH 02/15] powerpc/pmac: Convert therm_adt746x to new i2c probing Andreas Schwab
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=m21uldvzzy.fsf_-_@igel.home \
--to=schwab@linux-m68k.org \
--cc=benh@kernel.crashing.org \
--cc=linuxppc-dev@ozlabs.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).