From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6040C4321D for ; Thu, 23 Aug 2018 03:31:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A6473208E9 for ; Thu, 23 Aug 2018 03:31:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6473208E9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728220AbeHWG7O (ORCPT ); Thu, 23 Aug 2018 02:59:14 -0400 Received: from ozlabs.org ([203.11.71.1]:35641 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbeHWG7O (ORCPT ); Thu, 23 Aug 2018 02:59:14 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 41wqhW1yLSz9ryt; Thu, 23 Aug 2018 13:31:39 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au From: Michael Ellerman To: Wolfram Sang , linux-i2c@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, Benjamin Herrenschmidt , linux-kernel@vger.kernel.org, Wolfram Sang Subject: Re: [PATCH 1/2] macintosh: therm_windtunnel: drop using attach_adapter In-Reply-To: <20180821150240.19964-2-wsa@the-dreams.de> References: <20180821150240.19964-1-wsa@the-dreams.de> <20180821150240.19964-2-wsa@the-dreams.de> Date: Thu, 23 Aug 2018 13:31:39 +1000 Message-ID: <87ftz5lpwk.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Wolfram Sang writes: > 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(-) I don't have a G4 to test this on, so merge it and if it breaks we can fix it up later. Acked-by: Michael Ellerman cheers > diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c > index 68dcbcb4fc5b..8c744578122a 100644 > --- a/drivers/macintosh/therm_windtunnel.c > +++ b/drivers/macintosh/therm_windtunnel.c > @@ -432,7 +432,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, > @@ -445,7 +444,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 > -- > 2.11.0