From patchwork Thu Dec 4 16:41:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 5439081 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 13BCF9F456 for ; Thu, 4 Dec 2014 16:42:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 57D892022A for ; Thu, 4 Dec 2014 16:42:36 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 3ACB920225 for ; Thu, 4 Dec 2014 16:42:35 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 73E3D264F3A; Thu, 4 Dec 2014 17:42:33 +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 0E15F264EE5; Thu, 4 Dec 2014 17:42:25 +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 71879264F22; 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 75CE7264ED4 for ; Thu, 4 Dec 2014 17:42:16 +0100 (CET) Received: from p4fe249ba.dip0.t-ipconnect.de ([79.226.73.186]:57928 helo=localhost) by pokefinder.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1XwZTm-00060X-5Y; Thu, 04 Dec 2014 17:42:10 +0100 From: Wolfram Sang To: linuxppc-dev@ozlabs.org Date: Thu, 4 Dec 2014 17:41:52 +0100 Message-Id: <1417711313-7257-2-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 1/2] macintosh: therm_windtunnel: 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 --- drivers/macintosh/therm_windtunnel.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c index 3b4a157714b1..9de83cdd0bca 100644 --- a/drivers/macintosh/therm_windtunnel.c +++ b/drivers/macintosh/therm_windtunnel.c @@ -431,7 +431,6 @@ static struct i2c_driver g4fan_driver = { .driver = { .name = "therm_windtunnel", }, - .attach_adapter = do_attach, .probe = do_probe, .remove = do_remove, .id_table = therm_windtunnel_id, @@ -444,7 +443,29 @@ static struct i2c_driver g4fan_driver = { static int therm_of_probe(struct platform_device *dev) { - return i2c_add_driver( &g4fan_driver ); + struct i2c_adapter *adap; + int ret, i = 0; + + adap = i2c_get_adapter(0); + if (!adap) + return -EPROBE_DEFER; + + ret = i2c_add_driver(&g4fan_driver); + if (ret) { + i2c_put_adapter(adap); + return ret; + } + + /* We assume Macs have consecutive I2C bus numbers starting at 0 */ + while (adap) { + do_attach(adap); + if (x.running) + break; + i2c_put_adapter(adap); + adap = i2c_get_adapter(++i); + } + + return 0; } static int