From patchwork Thu Dec 4 16:41:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 5439101 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CC8FDBEEA8 for ; Thu, 4 Dec 2014 16:43:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E1EA220266 for ; Thu, 4 Dec 2014 16:43:07 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id C0B5720225 for ; Thu, 4 Dec 2014 16:43:06 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id DECB5264F74; Thu, 4 Dec 2014 17:43:05 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 9F3B0264F2D; Thu, 4 Dec 2014 17:42:26 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 873DC264F1D; Thu, 4 Dec 2014 17:42:24 +0100 (CET) Received: from pokefinder.org (sauhun.de [89.238.76.85]) by alsa0.perex.cz (Postfix) with ESMTP id 7BC7E264EE5 for ; Thu, 4 Dec 2014 17:42:16 +0100 (CET) Received: from p4fe249ba.dip0.t-ipconnect.de ([79.226.73.186]:57929 helo=localhost) by pokefinder.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1XwZTo-00060c-Vq; Thu, 04 Dec 2014 17:42:13 +0100 From: Wolfram Sang To: linuxppc-dev@ozlabs.org Date: Thu, 4 Dec 2014 17:41:53 +0100 Message-Id: <1417711313-7257-3-git-send-email-wsa@the-dreams.de> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1417711313-7257-1-git-send-email-wsa@the-dreams.de> References: <1417711313-7257-1-git-send-email-wsa@the-dreams.de> Cc: Benjamin Herrenschmidt , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Wolfram Sang Subject: [alsa-devel] [RFC 2/2] sound: ppc: keywest: drop using attach adapter X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP As we now have deferred probing, we can use a custom mechanism and finally get rid of the legacy interface from the i2c core. Signed-off-by: Wolfram Sang --- sound/ppc/keywest.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/sound/ppc/keywest.c b/sound/ppc/keywest.c index 0d1c27e911b8..a957f32368fa 100644 --- a/sound/ppc/keywest.c +++ b/sound/ppc/keywest.c @@ -52,7 +52,7 @@ static int keywest_attach_adapter(struct i2c_adapter *adapter) return -EINVAL; if (strncmp(adapter->name, "mac-io", 6)) - return 0; /* ignored */ + return -EINVAL; /* ignored */ memset(&info, 0, sizeof(struct i2c_board_info)); strlcpy(info.type, "keywest", I2C_NAME_SIZE); @@ -100,7 +100,6 @@ static struct i2c_driver keywest_driver = { .driver = { .name = "PMac Keywest Audio", }, - .attach_adapter = keywest_attach_adapter, .probe = keywest_probe, .remove = keywest_remove, .id_table = keywest_i2c_id, @@ -132,16 +131,32 @@ int snd_pmac_tumbler_post_init(void) /* exported */ int snd_pmac_keywest_init(struct pmac_keywest *i2c) { - int err; + struct i2c_adapter *adap; + int err, i = 0; if (keywest_ctx) return -EBUSY; + adap = i2c_get_adapter(0); + if (!adap) + return -EPROBE_DEFER; + keywest_ctx = i2c; if ((err = i2c_add_driver(&keywest_driver))) { snd_printk(KERN_ERR "cannot register keywest i2c driver\n"); + i2c_put_adapter(adap); return err; } + + /* We assume Macs have consecutive I2C bus numbers starting at 0 */ + while (adap) { + err = keywest_attach_adapter(adap); + if (!err) + break; + i2c_put_adapter(adap); + adap = i2c_get_adapter(++i); + } + return 0; }