From: Wolfram Sang <wsa@the-dreams.de>
To: linux-i2c@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Michael Ellerman <mpe@ellerman.id.au>,
linux-kernel@vger.kernel.org, Wolfram Sang <wsa@the-dreams.de>
Subject: [PATCH 1/2] macintosh: therm_windtunnel: drop using attach_adapter
Date: Tue, 21 Aug 2018 17:02:39 +0200 [thread overview]
Message-ID: <20180821150240.19964-2-wsa@the-dreams.de> (raw)
In-Reply-To: <20180821150240.19964-1-wsa@the-dreams.de>
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 <wsa@the-dreams.de>
---
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 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
next prev parent reply other threads:[~2018-08-21 15:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-21 15:02 [PATCH 0/2] i2c: remove deprecated attach_adapter callback Wolfram Sang
2018-08-21 15:02 ` Wolfram Sang [this message]
2018-08-23 3:31 ` [PATCH 1/2] macintosh: therm_windtunnel: drop using attach_adapter Michael Ellerman
2018-08-24 12:47 ` Wolfram Sang
2018-08-21 15:02 ` [PATCH 2/2] i2c: remove deprecated attach_adapter callback Wolfram Sang
2018-08-24 12:47 ` Wolfram Sang
2018-08-23 3:30 ` [PATCH 0/2] " Michael Ellerman
-- strict thread matches above, loose matches on Subject: below --
2015-04-16 13:23 [PATCH 0/2] i2c: rework last users of 2.4 style attach_adapter Wolfram Sang
2015-04-16 13:23 ` [PATCH 1/2] macintosh: therm_windtunnel: drop using attach adapter Wolfram Sang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180821150240.19964-2-wsa@the-dreams.de \
--to=wsa@the-dreams.de \
--cc=benh@kernel.crashing.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).