[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#741663: Follow up patch



Hi Bryan,

I hope you are still around and still interested in this bug. I am the
Linux I2C maintainer and I am currently trying to get rid of the
attach_adapter method which produces this ugly warning you already
mentioned. Your patch may work for you but I am afraid it is very likely
to cause regressions on other Macintosh computers with different device
trees. Can you try the following patch which is closer to the original
instantiation procedure? It should at least get rid of the warning. The
driver should still be loaded on boot. I am unsure if it fixes the
reload problem, you would need to try and report back. I'd be willing to
help further if the problem still remains.

Thanks,

   Wolfram

From: Wolfram Sang <wsa@the-dreams.de>
Subject: [PATCH] macintosh: therm_windtunnel: drop using attach adapter

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 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

Attachment: signature.asc
Description: Digital signature


Reply to: