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: 417846 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D938A1400E2 for ; Fri, 5 Dec 2014 03:43:51 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id C374C1A0EB0 for ; Fri, 5 Dec 2014 03:43:51 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 268B41A0282 for ; Fri, 5 Dec 2014 03:42:20 +1100 (AEDT) Received: by ozlabs.org (Postfix) id B02231400F1; Fri, 5 Dec 2014 03:42:19 +1100 (AEDT) Delivered-To: linuxppc-dev@ozlabs.org Received: from pokefinder.org (sauhun.de [89.238.76.85]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4EDD51400E2 for ; Fri, 5 Dec 2014 03:42:18 +1100 (AEDT) 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 Subject: [RFC 1/2] macintosh: therm_windtunnel: drop using attach adapter 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: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Wolfram Sang X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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