From patchwork Thu Apr 16 13:23:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 6225801 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AA4C7BF4A6 for ; Thu, 16 Apr 2015 13:22:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DA96A202B8 for ; Thu, 16 Apr 2015 13:22:52 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 7518C2024D for ; Thu, 16 Apr 2015 13:22:51 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id F27D0261552; Thu, 16 Apr 2015 15:22:49 +0200 (CEST) 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, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 903432614D1; Thu, 16 Apr 2015 15:22:41 +0200 (CEST) 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 27DEB2614E2; Thu, 16 Apr 2015 15:22:40 +0200 (CEST) Received: from pokefinder.org (sauhun.de [89.238.76.85]) by alsa0.perex.cz (Postfix) with ESMTP id 0493B261497 for ; Thu, 16 Apr 2015 15:22:32 +0200 (CEST) Received: from p4fe25056.dip0.t-ipconnect.de ([79.226.80.86]:41119 helo=localhost) by pokefinder.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1YijkT-0001lr-T3; Thu, 16 Apr 2015 15:22:30 +0200 From: Wolfram Sang To: linuxppc-dev@lists.ozlabs.org Date: Thu, 16 Apr 2015 15:23:02 +0200 Message-Id: <1429190583-17517-2-git-send-email-wsa@the-dreams.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1429190583-17517-1-git-send-email-wsa@the-dreams.de> References: <1429190583-17517-1-git-send-email-wsa@the-dreams.de> Cc: alsa-devel@alsa-project.org, Wolfram Sang , Benjamin Herrenschmidt , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, Michael Ellerman Subject: [alsa-devel] [PATCH 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 835ca8be4c1632..57909a3ce67bf2 100644 --- a/drivers/macintosh/therm_windtunnel.c +++ b/drivers/macintosh/therm_windtunnel.c @@ -422,7 +422,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, @@ -435,7 +434,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) + return 0; + i2c_put_adapter(adap); + adap = i2c_get_adapter(++i); + } + + return -ENODEV; } static int